@jiggai/kitchen 0.3.8 → 0.3.10
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +3 -3
- package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/agents/[agentId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/channels/page_client-reference-manifest.js +1 -1
- package/.next/server/app/channels.html +2 -2
- package/.next/server/app/channels.rsc +4 -4
- package/.next/server/app/channels.segments/_full.segment.rsc +4 -4
- package/.next/server/app/channels.segments/_head.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_index.segment.rsc +3 -3
- package/.next/server/app/channels.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/channels.segments/channels/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/channels.segments/channels.segment.rsc +1 -1
- package/.next/server/app/cron-jobs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/goals/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/goals/new/page_client-reference-manifest.js +1 -1
- package/.next/server/app/goals/new.html +2 -2
- package/.next/server/app/goals/new.rsc +4 -4
- package/.next/server/app/goals/new.segments/_full.segment.rsc +4 -4
- package/.next/server/app/goals/new.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_index.segment.rsc +3 -3
- package/.next/server/app/goals/new.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/goals/new.segments/goals/new/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/goals/new.segments/goals/new.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals.segment.rsc +1 -1
- package/.next/server/app/goals/page_client-reference-manifest.js +1 -1
- package/.next/server/app/goals.html +1 -1
- package/.next/server/app/goals.rsc +4 -4
- package/.next/server/app/goals.segments/_full.segment.rsc +4 -4
- package/.next/server/app/goals.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_index.segment.rsc +3 -3
- package/.next/server/app/goals.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/goals.segments/goals/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/goals.segments/goals.segment.rsc +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/recipes/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/recipes/page_client-reference-manifest.js +1 -1
- package/.next/server/app/runs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +4 -4
- package/.next/server/app/settings.segments/_full.segment.rsc +4 -4
- package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_index.segment.rsc +3 -3
- package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/server/app/teams/[teamId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/teams/[teamId]/runs/[workflowId]/[runId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/teams/[teamId]/runs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/teams/[teamId]/tickets/[ticket]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/teams/[teamId]/tickets/page_client-reference-manifest.js +1 -1
- package/.next/server/app/teams/[teamId]/workflows/[workflowId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/teams/[teamId]/workflows/page_client-reference-manifest.js +1 -1
- package/.next/server/app/tickets/[ticket]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/tickets/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_1fe98a49.js +1 -1
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_1fe98a49.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__450d6006._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__450d6006._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__471bc2e7._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__471bc2e7._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__49281b4c._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__49281b4c._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__9a7d79aa._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__9a7d79aa._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__b577b475._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__b577b475._.js.map +1 -1
- package/.next/server/chunks/ssr/b1a17_app_teams_[teamId]_workflows_[workflowId]_workflows-editor-client_tsx_5e714aa2._.js +1 -1
- package/.next/server/chunks/ssr/b1a17_app_teams_[teamId]_workflows_[workflowId]_workflows-editor-client_tsx_5e714aa2._.js.map +1 -1
- package/.next/server/chunks/ssr/src_59477309._.js +1 -1
- package/.next/server/chunks/ssr/src_59477309._.js.map +1 -1
- package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_index_tsx_e68e9cbc._.js +1 -1
- package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_index_tsx_e68e9cbc._.js.map +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/static/chunks/{8683ed0404be8cb7.js → 42b3230688d0834c.js} +1 -1
- package/.next/static/chunks/5f77499ca309ab9d.js +10 -0
- package/.next/static/chunks/7495459fdf300bf9.js +1 -0
- package/.next/static/chunks/{b28737d6a10af30d.js → ecdc9465f0e4d954.js} +1 -1
- package/.next/static/chunks/{cfe32a0bce2eab2b.css → f5d0d403c0fecb7f.css} +1 -1
- package/README.md +10 -5
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/.next/static/chunks/635adeaf329f2446.js +0 -1
- package/.next/static/chunks/6427cd3eaffdd572.js +0 -10
- /package/.next/static/{rZ9CCEgFiMjcIjsKtAtE0 → 0PWp2TzSmiSf_Pf9YHES-}/_buildManifest.js +0 -0
- /package/.next/static/{rZ9CCEgFiMjcIjsKtAtE0 → 0PWp2TzSmiSf_Pf9YHES-}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{rZ9CCEgFiMjcIjsKtAtE0 → 0PWp2TzSmiSf_Pf9YHES-}/_ssgManifest.js +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[74621,a=>{"use strict";function b(a){return a instanceof Error?a.message:String(a)}a.s(["errorMessage",()=>b])},16627,a=>{"use strict";var b=a.i(87924),c=a.i(38246),d=a.i(50944),e=a.i(72131),f=a.i(61889),g=a.i(74621),h=a.i(51200);function i({teamId:a,ticket:c,currentOwner:f}){let g=(0,d.useRouter)(),[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)(f??""),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(null);(0,e.useEffect)(()=>{let b=!1;return(async()=>{try{let c=a?`/api/teams/${encodeURIComponent(a)}/tickets/assignees`:"/api/tickets/assignees",d=await fetch(c,{cache:"no-store"}),e=await d.json();if(b)return;i(Array.isArray(e.assignees)?e.assignees:[])}catch{if(b)return;i([])}})(),()=>{b=!0}},[]);let p=(0,e.useMemo)(()=>{let a=new Set(h);return f&&a.add(f),Array.from(a).sort()},[h,f]);async function q(){m(!0),o(null);try{let b=a?`/api/teams/${encodeURIComponent(a)}/tickets/assign`:"/api/tickets/assign",d=await fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:c,assignee:j})}),e=await d.json();if(!d.ok)return void o(e.error||"Assign failed");g.refresh()}catch{o("Assign failed")}finally{m(!1)}}return(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Assignee"}),(0,b.jsxs)("select",{className:"rounded-md border border-white/10 bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",value:j,onChange:a=>k(a.target.value),children:[(0,b.jsx)("option",{value:"",disabled:!0,children:"Select…"}),p.map(a=>(0,b.jsx)("option",{value:a,children:a},a))]}),(0,b.jsx)("button",{type:"button",onClick:q,disabled:l||!j||j===(f??""),className:"rounded-md bg-emerald-600 px-3 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-50",children:l?"Assigning…":"Assign"}),f?(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Currently: ",f]}):null]}),n?(0,b.jsx)("div",{className:"mt-2 text-xs text-red-300",children:n}):null]})}function j(a){let j=(0,d.useRouter)(),k=(0,f.useToast)(),[l,m]=(0,e.useTransition)(),[n,o]=(0,e.useState)(null),[p,q]=(0,e.useState)(null),r=(0,e.useMemo)(()=>(function(a){let b=function(a){let b=/^## Comments\s*$/gim.exec(a);if(!b)return null;let c=b.index+b[0].length,d=a.slice(c).search(/^##\s+/m),e=-1===d?a.length:c+d;return{start:c,end:e}}(a);if(!b)return[];let c=a.slice(b.start,b.end).replace(/^\s+/,"").split("\n"),d=[],e=null,f=/^- \*\*(.+?)\*\*\s+—\s+(.*)$/;for(let a of c){let b=a.replace(/\r$/,""),c=b.match(f);if(c){e&&d.push({...e,body:e.body.trimEnd()});let a=c[1].trim(),b=c[2].trim(),f=b.indexOf(":"),g=(f>=0?b.slice(0,f):b).trim()||"unknown",h=f>=0?b.slice(f+1).trimStart():"";e={timestamp:a,author:g,body:h?h+"\n":""};continue}e&&(e.body+=b.replace(/^\s{0,2}/,"")+"\n")}return e&&d.push({...e,body:e.body.trimEnd()}),d})(a.markdown),[a.markdown]),[s,t]=(0,e.useState)(""),[u,v]=(0,e.useState)("");async function w(){o(null),await (0,h.fetchJson)(`/api/teams/${encodeURIComponent(a.teamId)}/tickets/move-to-goals`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:a.ticketId})})}async function x(){o(null),await (0,h.fetchJson)(`/api/teams/${encodeURIComponent(a.teamId)}/tickets/delete`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:a.ticketId})})}async function y(){o(null);let b=u.trim();if(!b)throw Error("Comment cannot be empty.");await (0,h.fetchJson)(`/api/teams/${encodeURIComponent(a.teamId)}/tickets/comment`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:a.ticketId,author:s.trim()||void 0,comment:b})}),v(""),k.push({kind:"success",message:"Comment added."}),j.refresh()}return(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)(c.default,{href:a.backHref??"/tickets",className:"text-sm font-medium hover:underline",children:"← Back"}),(0,b.jsx)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:a.file})]}),n?(0,b.jsx)("div",{className:"ck-glass border border-[color:var(--ck-border-strong)] p-3 text-sm text-[color:var(--ck-text-primary)]",children:n}):null,void 0!==a.currentOwner?(0,b.jsx)(i,{teamId:a.teamId,ticket:a.ticketId,currentOwner:a.currentOwner??null}):null,(0,b.jsx)("div",{className:"ck-glass p-4",children:(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(0,b.jsx)("button",{className:"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:border-[color:var(--ck-border-strong)]",onClick:()=>q({kind:"goals"}),disabled:l,children:"Move to Goals"}),(0,b.jsx)("button",{className:"rounded border border-[color:var(--ck-accent-red)] bg-[color:var(--ck-accent-red-soft)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-accent-red)] hover:bg-[color:var(--ck-accent-red-soft-strong)]",onClick:()=>q({kind:"delete"}),disabled:l,children:"Delete Ticket"})]})}),(0,b.jsxs)("div",{className:"ck-glass p-6",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Comments"}),(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:r.length})]}),r.length?(0,b.jsx)("div",{className:"mt-3 space-y-3",children:r.map((a,c)=>(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-[color:var(--ck-border-subtle)] bg-black/10 p-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-primary)]",children:a.author}),(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:a.timestamp})]}),(0,b.jsx)("div",{className:"mt-2 whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-secondary)]",children:a.body})]},`${a.timestamp}-${c}`))}):(0,b.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"No comments yet."}),(0,b.jsxs)("div",{className:"mt-4 border-t border-[color:var(--ck-border-subtle)] pt-4",children:[(0,b.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Add comment"}),(0,b.jsxs)("div",{className:"mt-3 grid gap-3",children:[(0,b.jsxs)("div",{className:"grid gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",htmlFor:"ck-comment-author",children:"Author (optional)"}),(0,b.jsx)("input",{id:"ck-comment-author",value:s,onChange:a=>t(a.target.value),placeholder:"unknown",className:"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]",disabled:l})]}),(0,b.jsxs)("div",{className:"grid gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",htmlFor:"ck-comment-body",children:"Comment"}),(0,b.jsx)("textarea",{id:"ck-comment-body",value:u,onChange:a=>v(a.target.value),rows:4,className:"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]",disabled:l})]}),(0,b.jsx)("div",{className:"flex items-center justify-end",children:(0,b.jsx)("button",{className:"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-semibold text-black disabled:opacity-50",onClick:()=>{m(()=>{y().catch(a=>o((0,g.errorMessage)(a)))})},disabled:l||!u.trim(),children:"Post comment"})})]})]})]}),(0,b.jsx)("div",{className:"ck-glass p-6",children:(0,b.jsx)("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-primary)]",children:a.markdown})}),p?(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:(0,b.jsxs)("div",{className:"ck-glass w-full max-w-lg rounded-[var(--ck-radius-md)] border border-[color:var(--ck-border-strong)] p-4",children:[(0,b.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"goals"===p.kind?"Move to Goals":"Delete ticket"}),(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"goals"===p.kind?(0,b.jsxs)(b.Fragment,{children:["This will move the ticket out of the work lanes into ",(0,b.jsx)("code",{children:"work/goals/"})," so it won’t be picked up by automation."]}):(0,b.jsx)(b.Fragment,{children:"This will permanently remove the ticket markdown file. Assignment stubs (if any) will be archived."})}),(0,b.jsxs)("div",{className:"mt-4 flex items-center justify-end gap-2",children:[(0,b.jsx)("button",{className:"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs text-[color:var(--ck-text-secondary)]",onClick:()=>q(null),disabled:l,children:"Cancel"}),(0,b.jsx)("button",{className:"delete"===p.kind?"rounded bg-[color:var(--ck-accent-red)] px-3 py-1.5 text-xs font-medium text-white":"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-medium text-black",onClick:()=>{let b=p.kind;q(null),m(()=>{("goals"===b?w():x()).then(()=>{k.push({kind:"success",message:"delete"===b?"Ticket deleted.":"Moved to Goals."}),"delete"===b?j.push(a.backHref??"/tickets"):j.refresh()}).catch(a=>o((0,g.errorMessage)(a)))})},disabled:l,children:"Confirm"})]})]})}):null]})}a.s(["TicketDetailClient",()=>j],16627)}];
|
|
1
|
+
module.exports=[74621,a=>{"use strict";function b(a){return a instanceof Error?a.message:String(a)}a.s(["errorMessage",()=>b])},16627,a=>{"use strict";var b=a.i(87924),c=a.i(38246),d=a.i(50944),e=a.i(72131),f=a.i(61889),g=a.i(74621),h=a.i(51200);function i({teamId:a,ticket:c,currentOwner:f}){let g=(0,d.useRouter)(),[h,i]=(0,e.useState)([]),[j,k]=(0,e.useState)(f??""),[l,m]=(0,e.useState)(!1),[n,o]=(0,e.useState)(null);(0,e.useEffect)(()=>{let b=!1;return(async()=>{try{let c=a?`/api/teams/${encodeURIComponent(a)}/tickets/assignees`:"/api/tickets/assignees",d=await fetch(c,{cache:"no-store"}),e=await d.json();if(b)return;i(Array.isArray(e.assignees)?e.assignees:[])}catch{if(b)return;i([])}})(),()=>{b=!0}},[]);let p=(0,e.useMemo)(()=>{let a=new Set(h);return f&&a.add(f),Array.from(a).sort()},[h,f]);async function q(){m(!0),o(null);try{let b=a?`/api/teams/${encodeURIComponent(a)}/tickets/assign`:"/api/tickets/assign",d=await fetch(b,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:c,assignee:j})}),e=await d.json();if(!d.ok)return void o(e.error||"Assign failed");g.refresh()}catch{o("Assign failed")}finally{m(!1)}}return(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Assignee"}),(0,b.jsxs)("select",{className:"rounded-md border border-white/10 bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",value:j,onChange:a=>k(a.target.value),children:[(0,b.jsx)("option",{value:"",disabled:!0,children:"Select…"}),p.map(a=>(0,b.jsx)("option",{value:a,children:a},a))]}),(0,b.jsx)("button",{type:"button",onClick:q,disabled:l||!j||j===(f??""),className:"rounded-md bg-emerald-600 px-3 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-50",children:l?"Assigning…":"Assign"}),f?(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Currently: ",f]}):null]}),n?(0,b.jsx)("div",{className:"mt-2 text-xs text-red-300",children:n}):null]})}function j(a,b){return b||0==a.trim().length}function k(a){let k=(0,d.useRouter)(),l=(0,f.useToast)(),[m,n]=(0,e.useTransition)(),[o,p]=(0,e.useState)(null),[q,r]=(0,e.useState)(null),s=(0,e.useMemo)(()=>(function(a){let b=function(a){let b=/^## Comments\s*$/gim.exec(a);if(!b)return null;let c=b.index+b[0].length,d=a.slice(c).search(/^##\s+/m),e=-1===d?a.length:c+d;return{start:c,end:e}}(a);if(!b)return[];let c=a.slice(b.start,b.end).replace(/^\s+/,"").split("\n"),d=[],e=null,f=/^- \*\*(.+?)\*\*\s+—\s+(.*)$/;for(let a of c){let b=a.replace(/\r$/,""),c=b.match(f);if(c){e&&d.push({...e,body:e.body.trimEnd()});let a=c[1].trim(),b=c[2].trim(),f=b.indexOf(":"),g=(f>=0?b.slice(0,f):b).trim()||"unknown",h=f>=0?b.slice(f+1).trimStart():"";e={timestamp:a,author:g,body:h?h+"\n":""};continue}e&&(e.body+=b.replace(/^\s{0,2}/,"")+"\n")}return e&&d.push({...e,body:e.body.trimEnd()}),d})(a.markdown),[a.markdown]),[t,u]=(0,e.useState)(""),[v,w]=(0,e.useState)("");async function x(){p(null),await (0,h.fetchJson)(`/api/teams/${encodeURIComponent(a.teamId)}/tickets/move-to-goals`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:a.ticketId})})}async function y(){p(null),await (0,h.fetchJson)(`/api/teams/${encodeURIComponent(a.teamId)}/tickets/delete`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:a.ticketId})})}async function z(){p(null);let b=v.trim();if(!b)throw Error("Comment cannot be empty.");await (0,h.fetchJson)(`/api/teams/${encodeURIComponent(a.teamId)}/tickets/comment`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:a.ticketId,author:t.trim()||void 0,comment:b})}),w(""),l.push({kind:"success",message:"Comment added."}),k.refresh()}return(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)(c.default,{href:a.backHref??"/tickets",className:"text-sm font-medium hover:underline",children:"← Back"}),(0,b.jsx)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:a.file})]}),o?(0,b.jsx)("div",{className:"ck-glass border border-[color:var(--ck-border-strong)] p-3 text-sm text-[color:var(--ck-text-primary)]",children:o}):null,void 0!==a.currentOwner?(0,b.jsx)(i,{teamId:a.teamId,ticket:a.ticketId,currentOwner:a.currentOwner??null}):null,(0,b.jsx)("div",{className:"ck-glass p-4",children:(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(0,b.jsx)("button",{className:"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:border-[color:var(--ck-border-strong)]",onClick:()=>r({kind:"goals"}),disabled:m,children:"Move to Goals"}),(0,b.jsx)("button",{className:"rounded border border-[color:var(--ck-accent-red)] bg-[color:var(--ck-accent-red-soft)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-accent-red)] hover:bg-[color:var(--ck-accent-red-soft-strong)]",onClick:()=>r({kind:"delete"}),disabled:m,children:"Delete Ticket"})]})}),(0,b.jsxs)("div",{className:"ck-glass p-6",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Comments"}),(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:s.length})]}),s.length?(0,b.jsx)("div",{className:"mt-3 space-y-3",children:s.map((a,c)=>(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-[color:var(--ck-border-subtle)] bg-black/10 p-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-primary)]",children:a.author}),(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:a.timestamp})]}),(0,b.jsx)("div",{className:"mt-2 whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-secondary)]",children:a.body})]},`${a.timestamp}-${c}`))}):(0,b.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"No comments yet."}),(0,b.jsxs)("div",{className:"mt-4 border-t border-[color:var(--ck-border-subtle)] pt-4",children:[(0,b.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Add comment"}),(0,b.jsxs)("div",{className:"mt-3 grid gap-3",children:[(0,b.jsxs)("div",{className:"grid gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",htmlFor:"ck-comment-author",children:"Author (optional)"}),(0,b.jsx)("input",{id:"ck-comment-author",value:t,onChange:a=>u(a.target.value),placeholder:"unknown",className:"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]",disabled:m})]}),(0,b.jsxs)("div",{className:"grid gap-1",children:[(0,b.jsx)("label",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",htmlFor:"ck-comment-body",children:"Comment"}),(0,b.jsx)("textarea",{id:"ck-comment-body",value:v,onChange:a=>w(a.target.value),rows:4,className:"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]",disabled:m})]}),(0,b.jsx)("div",{className:"flex items-center justify-end",children:(0,b.jsx)("button",{type:"button","aria-busy":m,className:"rounded-[var(--ck-radius-sm)] bg-[color:var(--ck-accent)] px-3 py-2 text-xs font-semibold text-black transition hover:brightness-110 active:brightness-95 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ck-border-strong)] focus-visible:ring-offset-2 focus-visible:ring-offset-black/30 disabled:cursor-not-allowed disabled:border disabled:border-[color:var(--ck-border-subtle)] disabled:bg-[color:var(--ck-bg-glass)] disabled:text-[color:var(--ck-text-tertiary)]",onClick:()=>{n(()=>{z().catch(a=>p((0,g.errorMessage)(a)))})},disabled:j(v,m),children:m?"Posting…":"Post comment"})})]})]})]}),(0,b.jsx)("div",{className:"ck-glass p-6",children:(0,b.jsx)("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-primary)]",children:a.markdown})}),q?(0,b.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:(0,b.jsxs)("div",{className:"ck-glass w-full max-w-lg rounded-[var(--ck-radius-md)] border border-[color:var(--ck-border-strong)] p-4",children:[(0,b.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"goals"===q.kind?"Move to Goals":"Delete ticket"}),(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"goals"===q.kind?(0,b.jsxs)(b.Fragment,{children:["This will move the ticket out of the work lanes into ",(0,b.jsx)("code",{children:"work/goals/"})," so it won’t be picked up by automation."]}):(0,b.jsx)(b.Fragment,{children:"This will permanently remove the ticket markdown file. Assignment stubs (if any) will be archived."})}),(0,b.jsxs)("div",{className:"mt-4 flex items-center justify-end gap-2",children:[(0,b.jsx)("button",{className:"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs text-[color:var(--ck-text-secondary)]",onClick:()=>r(null),disabled:m,children:"Cancel"}),(0,b.jsx)("button",{className:"delete"===q.kind?"rounded bg-[color:var(--ck-accent-red)] px-3 py-1.5 text-xs font-medium text-white":"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-medium text-black",onClick:()=>{let b=q.kind;r(null),n(()=>{("goals"===b?x():y()).then(()=>{l.push({kind:"success",message:"delete"===b?"Ticket deleted.":"Moved to Goals."}),"delete"===b?k.push(a.backHref??"/tickets"):k.refresh()}).catch(a=>p((0,g.errorMessage)(a)))})},disabled:m,children:"Confirm"})]})]})}):null]})}a.s(["TicketDetailClient",()=>k,"isPostCommentDisabled",()=>j],16627)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=src_59477309._.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/errors.ts","../../../../src/app/tickets/TicketDetailClient.tsx","../../../../src/lib/ticket-comments.ts","../../../../src/app/tickets/%5Bticket%5D/TicketAssignControl.tsx"],"sourcesContent":["/**\n * Extracts a string message from an unknown error value.\n * Used consistently across API routes and client components.\n */\nexport function errorMessage(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n","\"use client\";\n\nimport Link from \"next/link\";\nimport { useRouter } from \"next/navigation\";\nimport { useMemo, useState, useTransition } from \"react\";\n\nimport { useToast } from \"@/components/ToastProvider\";\nimport { errorMessage } from \"@/lib/errors\";\nimport { fetchJson } from \"@/lib/fetch-json\";\nimport { parseTicketComments } from \"@/lib/ticket-comments\";\nimport { TicketAssignControl } from \"@/app/tickets/[ticket]/TicketAssignControl\";\n\nexport function TicketDetailClient(props: {\n teamId: string;\n ticketId: string;\n file: string;\n markdown: string;\n backHref?: string;\n currentOwner?: string | null;\n}) {\n const router = useRouter();\n const toast = useToast();\n const [isPending, startTransition] = useTransition();\n const [error, setError] = useState<string | null>(null);\n const [confirm, setConfirm] = useState<null | { kind: \"goals\" | \"delete\" }>(null);\n\n const comments = useMemo(() => parseTicketComments(props.markdown), [props.markdown]);\n\n const [commentAuthor, setCommentAuthor] = useState<string>(\"\");\n const [commentBody, setCommentBody] = useState<string>(\"\");\n\n async function moveToGoals() {\n setError(null);\n await fetchJson(`/api/teams/${encodeURIComponent(props.teamId)}/tickets/move-to-goals`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ ticket: props.ticketId }),\n });\n }\n\n async function deleteTicket() {\n setError(null);\n await fetchJson(`/api/teams/${encodeURIComponent(props.teamId)}/tickets/delete`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ ticket: props.ticketId }),\n });\n }\n\n async function submitComment() {\n setError(null);\n const body = commentBody.trim();\n if (!body) throw new Error(\"Comment cannot be empty.\");\n\n await fetchJson(`/api/teams/${encodeURIComponent(props.teamId)}/tickets/comment`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n ticket: props.ticketId,\n author: commentAuthor.trim() || undefined,\n comment: body,\n }),\n });\n\n setCommentBody(\"\");\n toast.push({ kind: \"success\", message: \"Comment added.\" });\n router.refresh();\n }\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between gap-3\">\n <Link href={props.backHref ?? \"/tickets\"} className=\"text-sm font-medium hover:underline\">\n ← Back\n </Link>\n <span className=\"text-xs text-[color:var(--ck-text-tertiary)]\">{props.file}</span>\n </div>\n\n {error ? (\n <div className=\"ck-glass border border-[color:var(--ck-border-strong)] p-3 text-sm text-[color:var(--ck-text-primary)]\">\n {error}\n </div>\n ) : null}\n\n {props.currentOwner !== undefined ? (\n <TicketAssignControl teamId={props.teamId} ticket={props.ticketId} currentOwner={props.currentOwner ?? null} />\n ) : null}\n\n <div className=\"ck-glass p-4\">\n <div className=\"flex flex-wrap items-center justify-end gap-2\">\n <button\n className=\"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:border-[color:var(--ck-border-strong)]\"\n onClick={() => setConfirm({ kind: \"goals\" })}\n disabled={isPending}\n >\n Move to Goals\n </button>\n <button\n className=\"rounded border border-[color:var(--ck-accent-red)] bg-[color:var(--ck-accent-red-soft)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-accent-red)] hover:bg-[color:var(--ck-accent-red-soft-strong)]\"\n onClick={() => setConfirm({ kind: \"delete\" })}\n disabled={isPending}\n >\n Delete Ticket\n </button>\n </div>\n </div>\n\n <div className=\"ck-glass p-6\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"text-sm font-semibold text-[color:var(--ck-text-primary)]\">Comments</div>\n <div className=\"text-xs text-[color:var(--ck-text-tertiary)]\">{comments.length}</div>\n </div>\n\n {comments.length ? (\n <div className=\"mt-3 space-y-3\">\n {comments.map((c, idx) => (\n <div\n key={`${c.timestamp}-${idx}`}\n className=\"rounded-[var(--ck-radius-sm)] border border-[color:var(--ck-border-subtle)] bg-black/10 p-3\"\n >\n <div className=\"flex flex-wrap items-baseline justify-between gap-2\">\n <div className=\"text-xs font-medium text-[color:var(--ck-text-primary)]\">{c.author}</div>\n <div className=\"text-xs text-[color:var(--ck-text-tertiary)]\">{c.timestamp}</div>\n </div>\n <div className=\"mt-2 whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-secondary)]\">\n {c.body}\n </div>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"mt-3 text-sm text-[color:var(--ck-text-secondary)]\">No comments yet.</div>\n )}\n\n <div className=\"mt-4 border-t border-[color:var(--ck-border-subtle)] pt-4\">\n <div className=\"text-sm font-semibold text-[color:var(--ck-text-primary)]\">Add comment</div>\n\n <div className=\"mt-3 grid gap-3\">\n <div className=\"grid gap-1\">\n <label className=\"text-xs font-medium text-[color:var(--ck-text-secondary)]\" htmlFor=\"ck-comment-author\">\n Author (optional)\n </label>\n <input\n id=\"ck-comment-author\"\n value={commentAuthor}\n onChange={(e) => setCommentAuthor(e.target.value)}\n placeholder=\"unknown\"\n className=\"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]\"\n disabled={isPending}\n />\n </div>\n\n <div className=\"grid gap-1\">\n <label className=\"text-xs font-medium text-[color:var(--ck-text-secondary)]\" htmlFor=\"ck-comment-body\">\n Comment\n </label>\n <textarea\n id=\"ck-comment-body\"\n value={commentBody}\n onChange={(e) => setCommentBody(e.target.value)}\n rows={4}\n className=\"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]\"\n disabled={isPending}\n />\n </div>\n\n <div className=\"flex items-center justify-end\">\n <button\n className=\"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-semibold text-black disabled:opacity-50\"\n onClick={() => {\n startTransition(() => {\n submitComment().catch((e: unknown) => setError(errorMessage(e)));\n });\n }}\n disabled={isPending || !commentBody.trim()}\n >\n Post comment\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"ck-glass p-6\">\n <pre className=\"whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-primary)]\">\n {props.markdown}\n </pre>\n </div>\n\n {confirm ? (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4\">\n <div className=\"ck-glass w-full max-w-lg rounded-[var(--ck-radius-md)] border border-[color:var(--ck-border-strong)] p-4\">\n <div className=\"text-sm font-semibold text-[color:var(--ck-text-primary)]\">\n {confirm.kind === \"goals\" ? \"Move to Goals\" : \"Delete ticket\"}\n </div>\n\n <div className=\"mt-2 text-sm text-[color:var(--ck-text-secondary)]\">\n {confirm.kind === \"goals\" ? (\n <>\n This will move the ticket out of the work lanes into <code>work/goals/</code> so it won’t be picked up by\n automation.\n </>\n ) : (\n <>This will permanently remove the ticket markdown file. Assignment stubs (if any) will be archived.</>\n )}\n </div>\n\n <div className=\"mt-4 flex items-center justify-end gap-2\">\n <button\n className=\"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs text-[color:var(--ck-text-secondary)]\"\n onClick={() => setConfirm(null)}\n disabled={isPending}\n >\n Cancel\n </button>\n <button\n className={\n confirm.kind === \"delete\"\n ? \"rounded bg-[color:var(--ck-accent-red)] px-3 py-1.5 text-xs font-medium text-white\"\n : \"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-medium text-black\"\n }\n onClick={() => {\n const kind = confirm.kind;\n setConfirm(null);\n startTransition(() => {\n const op = kind === \"goals\" ? moveToGoals() : deleteTicket();\n op\n .then(() => {\n toast.push({\n kind: \"success\",\n message: kind === \"delete\" ? \"Ticket deleted.\" : \"Moved to Goals.\",\n });\n if (kind === \"delete\") {\n router.push(props.backHref ?? \"/tickets\");\n } else {\n router.refresh();\n }\n })\n .catch((e: unknown) => setError(errorMessage(e)));\n });\n }}\n disabled={isPending}\n >\n Confirm\n </button>\n </div>\n </div>\n </div>\n ) : null}\n </div>\n );\n}\n","export type TicketComment = {\n timestamp: string;\n author: string;\n body: string;\n};\n\nfunction findCommentsSection(md: string): { start: number; end: number } | null {\n const headerRe = /^## Comments\\s*$/gim;\n const m = headerRe.exec(md);\n if (!m) return null;\n\n const start = m.index + m[0].length;\n\n // Find next heading of same or higher level.\n const rest = md.slice(start);\n const nextHeading = rest.search(/^##\\s+/m);\n const end = nextHeading === -1 ? md.length : start + nextHeading;\n return { start, end };\n}\n\nexport function parseTicketComments(md: string): TicketComment[] {\n const section = findCommentsSection(md);\n if (!section) return [];\n\n const body = md.slice(section.start, section.end).replace(/^\\s+/, \"\");\n const lines = body.split(\"\\n\");\n\n const out: TicketComment[] = [];\n let current: TicketComment | null = null;\n\n const header = /^- \\*\\*(.+?)\\*\\*\\s+—\\s+(.*)$/;\n\n for (const rawLine of lines) {\n const line = rawLine.replace(/\\r$/, \"\");\n const m = line.match(header);\n if (m) {\n if (current) out.push({ ...current, body: current.body.trimEnd() });\n const timestamp = m[1].trim();\n const rest = m[2].trim();\n // Support either \"author: first line\" or just \"author\".\n const colonIdx = rest.indexOf(\":\");\n const author = (colonIdx >= 0 ? rest.slice(0, colonIdx) : rest).trim() || \"unknown\";\n const firstBody = colonIdx >= 0 ? rest.slice(colonIdx + 1).trimStart() : \"\";\n current = { timestamp, author, body: firstBody ? firstBody + \"\\n\" : \"\" };\n continue;\n }\n\n if (!current) continue;\n\n // Allow list paragraph indentation, but keep it simple.\n current.body += line.replace(/^\\s{0,2}/, \"\") + \"\\n\";\n }\n\n if (current) out.push({ ...current, body: current.body.trimEnd() });\n return out;\n}\n\nexport function formatTicketCommentMarkdown(args: {\n timestamp: string;\n author: string;\n body: string;\n}): string {\n const body = args.body.trim().replace(/\\r\\n/g, \"\\n\");\n const indented = body\n .split(\"\\n\")\n .map((l) => ` ${l}`)\n .join(\"\\n\");\n\n const author = args.author?.trim() || \"unknown\";\n return `\\n- **${args.timestamp}** — ${author}:\\n${indented}\\n`;\n}\n","\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useRouter } from \"next/navigation\";\n\nexport function TicketAssignControl({\n teamId,\n ticket,\n currentOwner,\n}: {\n teamId?: string | null;\n ticket: string;\n currentOwner: string | null;\n}) {\n const router = useRouter();\n const [assignees, setAssignees] = useState<string[]>([]);\n const [selected, setSelected] = useState<string>(currentOwner ?? \"\");\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n (async () => {\n try {\n const url = teamId\n ? `/api/teams/${encodeURIComponent(teamId)}/tickets/assignees`\n : \"/api/tickets/assignees\";\n const res = await fetch(url, { cache: \"no-store\" });\n const json = (await res.json()) as { assignees?: string[] };\n if (cancelled) return;\n setAssignees(Array.isArray(json.assignees) ? json.assignees : []);\n } catch {\n if (cancelled) return;\n setAssignees([]);\n }\n })();\n return () => {\n cancelled = true;\n };\n }, []);\n\n const options = useMemo(() => {\n const base = new Set(assignees);\n if (currentOwner) base.add(currentOwner);\n return Array.from(base).sort();\n }, [assignees, currentOwner]);\n\n async function onAssign() {\n setLoading(true);\n setError(null);\n try {\n const url = teamId\n ? `/api/teams/${encodeURIComponent(teamId)}/tickets/assign`\n : \"/api/tickets/assign\";\n\n const res = await fetch(url, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ ticket, assignee: selected }),\n });\n\n const json = (await res.json()) as { error?: string };\n if (!res.ok) {\n setError(json.error || \"Assign failed\");\n return;\n }\n\n router.refresh();\n } catch {\n setError(\"Assign failed\");\n } finally {\n setLoading(false);\n }\n }\n\n return (\n <div className=\"ck-glass p-4\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <div className=\"text-xs font-medium text-[color:var(--ck-text-tertiary)]\">Assignee</div>\n <select\n className=\"rounded-md border border-white/10 bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]\"\n value={selected}\n onChange={(e) => setSelected(e.target.value)}\n >\n <option value=\"\" disabled>\n Select…\n </option>\n {options.map((a) => (\n <option key={a} value={a}>\n {a}\n </option>\n ))}\n </select>\n\n <button\n type=\"button\"\n onClick={onAssign}\n disabled={loading || !selected || selected === (currentOwner ?? \"\")}\n className=\"rounded-md bg-emerald-600 px-3 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {loading ? \"Assigning…\" : \"Assign\"}\n </button>\n\n {currentOwner ? (\n <div className=\"text-xs text-[color:var(--ck-text-tertiary)]\">Currently: {currentOwner}</div>\n ) : null}\n </div>\n\n {error ? <div className=\"mt-2 text-xs text-red-300\">{error}</div> : null}\n </div>\n );\n}\n"],"names":[],"mappings":"uCAIO,SAAS,EAAa,CAAU,EACrC,OAAO,aAAa,MAAQ,EAAE,OAAO,CAAG,OAAO,EACjD,sECJA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAEA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OEHO,SAAS,EAAoB,QAClC,CAAM,QACN,CAAM,CACN,cAAY,CAKb,EACC,IAAM,EAAS,CAAA,EAAA,EAAA,SAAA,AAAS,IAClB,CAAC,EAAW,EAAa,CAAG,CAAA,EAAA,EAAA,QAAA,AAAQ,EAAW,EAAE,EACjD,CAAC,EAAU,EAAY,CAAG,CAAA,EAAA,EAAA,QAAA,AAAQ,EAAS,GAAgB,IAC3D,CAAC,EAAS,EAAW,CAAG,CAAA,EAAA,EAAA,QAAQ,AAAR,GAAS,GACjC,CAAC,EAAO,EAAS,CAAG,CAAA,EAAA,EAAA,QAAA,AAAQ,EAAgB,MAElD,CAAA,EAAA,EAAA,SAAA,AAAS,EAAC,KACR,IAAI,GAAY,EAehB,MAdA,CAAC,UACC,GAAI,CACF,IAAM,EAAM,EACR,CAAC,WAAW,EAAE,mBAAmB,GAAQ,kBAAkB,CAAC,CAC5D,yBACE,EAAM,MAAM,MAAM,EAAK,CAAE,MAAO,UAAW,GAC3C,EAAQ,MAAM,EAAI,IAAI,GAC5B,G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,UAAU,qHACb,CAAA,EAAA,EAAA,GAAA,EAAC,MAAA,CAAI,UAAU,qEACK,UAAjB,EAAQ,IAAI,CAAe,gBAAkB,kBAGhD,CAAA,EAAA,EAAA,GAAA,EAAC,MAAA,CAAI,UAAU,8DACK,UAAjB,EAAQ,IAAI,CACX,CAAA,EAAA,EAAA,IAAA,EAAA,EAAA,QAAA,CAAA,WAAE,wDACqD,CAAA,EAAA,EAAA,GAAA,EAAC,OAAA,UAAK,gBAAkB,8CAI/E,CAAA,EAAA,EAAA,GAAA,EAAA,EAAA,QAAA,CAAA,UAAE,yGAIN,CAAA,EAAA,EAAA,IAAA,EAAC,MAAA,CAAI,UAAU,qDACb,CAAA,EAAA,EAAA,GAAA,EAAC,SAAA,CACC,UAAU,kHACV,QAAS,IAAM,EAAW,MAC1B,SAAU,WACX,WAGD,CAAA,EAAA,EAAA,GAAA,EAAC,SAAA,CACC,UACE,AAAiB,aAAT,IAAI,CACR,qFACA,iFAEN,QAAS,KACP,IAAM,EAAO,EAAQ,IAAI,CACzB,EAAW,MACX,EAAgB,KAEd,CADoB,UAAT,EAAmB,IAAgB,GAAA,EAE3C,IAAI,CAAC,KACJ,EAAM,IAAI,CAAC,CACT,KAAM,UACN,QAAkB,WAAT,EAAoB,kBAAoB,iBACnD,GACa,UAAU,CAAnB,EACF,EAAO,IAAI,CAAC,EAAM,QAAQ,EAAI,YAE9B,EAAO,OAAO,EAElB,GACC,KAAK,CAAC,AAAC,GAAe,EAAS,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,IACjD,EACF,EACA,SAAU,WACX,oBAML,OAGV"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/lib/errors.ts","../../../../src/app/tickets/TicketDetailClient.tsx","../../../../src/lib/ticket-comments.ts","../../../../src/app/tickets/%5Bticket%5D/TicketAssignControl.tsx"],"sourcesContent":["/**\n * Extracts a string message from an unknown error value.\n * Used consistently across API routes and client components.\n */\nexport function errorMessage(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n","\"use client\";\n\nimport Link from \"next/link\";\nimport { useRouter } from \"next/navigation\";\nimport { useMemo, useState, useTransition } from \"react\";\n\nimport { useToast } from \"@/components/ToastProvider\";\nimport { errorMessage } from \"@/lib/errors\";\nimport { fetchJson } from \"@/lib/fetch-json\";\nimport { parseTicketComments } from \"@/lib/ticket-comments\";\nimport { TicketAssignControl } from \"@/app/tickets/[ticket]/TicketAssignControl\";\n\nexport function isPostCommentDisabled(commentBody: string, isPending: boolean) {\n return isPending || commentBody.trim().length == 0;\n}\n\nexport function TicketDetailClient(props: {\n teamId: string;\n ticketId: string;\n file: string;\n markdown: string;\n backHref?: string;\n currentOwner?: string | null;\n}) {\n const router = useRouter();\n const toast = useToast();\n const [isPending, startTransition] = useTransition();\n const [error, setError] = useState<string | null>(null);\n const [confirm, setConfirm] = useState<null | { kind: \"goals\" | \"delete\" }>(null);\n\n const comments = useMemo(() => parseTicketComments(props.markdown), [props.markdown]);\n\n const [commentAuthor, setCommentAuthor] = useState<string>(\"\");\n const [commentBody, setCommentBody] = useState<string>(\"\");\n\n async function moveToGoals() {\n setError(null);\n await fetchJson(`/api/teams/${encodeURIComponent(props.teamId)}/tickets/move-to-goals`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ ticket: props.ticketId }),\n });\n }\n\n async function deleteTicket() {\n setError(null);\n await fetchJson(`/api/teams/${encodeURIComponent(props.teamId)}/tickets/delete`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ ticket: props.ticketId }),\n });\n }\n\n async function submitComment() {\n setError(null);\n const body = commentBody.trim();\n if (!body) throw new Error(\"Comment cannot be empty.\");\n\n await fetchJson(`/api/teams/${encodeURIComponent(props.teamId)}/tickets/comment`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n ticket: props.ticketId,\n author: commentAuthor.trim() || undefined,\n comment: body,\n }),\n });\n\n setCommentBody(\"\");\n toast.push({ kind: \"success\", message: \"Comment added.\" });\n router.refresh();\n }\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between gap-3\">\n <Link href={props.backHref ?? \"/tickets\"} className=\"text-sm font-medium hover:underline\">\n ← Back\n </Link>\n <span className=\"text-xs text-[color:var(--ck-text-tertiary)]\">{props.file}</span>\n </div>\n\n {error ? (\n <div className=\"ck-glass border border-[color:var(--ck-border-strong)] p-3 text-sm text-[color:var(--ck-text-primary)]\">\n {error}\n </div>\n ) : null}\n\n {props.currentOwner !== undefined ? (\n <TicketAssignControl teamId={props.teamId} ticket={props.ticketId} currentOwner={props.currentOwner ?? null} />\n ) : null}\n\n <div className=\"ck-glass p-4\">\n <div className=\"flex flex-wrap items-center justify-end gap-2\">\n <button\n className=\"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:border-[color:var(--ck-border-strong)]\"\n onClick={() => setConfirm({ kind: \"goals\" })}\n disabled={isPending}\n >\n Move to Goals\n </button>\n <button\n className=\"rounded border border-[color:var(--ck-accent-red)] bg-[color:var(--ck-accent-red-soft)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-accent-red)] hover:bg-[color:var(--ck-accent-red-soft-strong)]\"\n onClick={() => setConfirm({ kind: \"delete\" })}\n disabled={isPending}\n >\n Delete Ticket\n </button>\n </div>\n </div>\n\n <div className=\"ck-glass p-6\">\n <div className=\"flex items-center justify-between gap-3\">\n <div className=\"text-sm font-semibold text-[color:var(--ck-text-primary)]\">Comments</div>\n <div className=\"text-xs text-[color:var(--ck-text-tertiary)]\">{comments.length}</div>\n </div>\n\n {comments.length ? (\n <div className=\"mt-3 space-y-3\">\n {comments.map((c, idx) => (\n <div\n key={`${c.timestamp}-${idx}`}\n className=\"rounded-[var(--ck-radius-sm)] border border-[color:var(--ck-border-subtle)] bg-black/10 p-3\"\n >\n <div className=\"flex flex-wrap items-baseline justify-between gap-2\">\n <div className=\"text-xs font-medium text-[color:var(--ck-text-primary)]\">{c.author}</div>\n <div className=\"text-xs text-[color:var(--ck-text-tertiary)]\">{c.timestamp}</div>\n </div>\n <div className=\"mt-2 whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-secondary)]\">\n {c.body}\n </div>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"mt-3 text-sm text-[color:var(--ck-text-secondary)]\">No comments yet.</div>\n )}\n\n <div className=\"mt-4 border-t border-[color:var(--ck-border-subtle)] pt-4\">\n <div className=\"text-sm font-semibold text-[color:var(--ck-text-primary)]\">Add comment</div>\n\n <div className=\"mt-3 grid gap-3\">\n <div className=\"grid gap-1\">\n <label className=\"text-xs font-medium text-[color:var(--ck-text-secondary)]\" htmlFor=\"ck-comment-author\">\n Author (optional)\n </label>\n <input\n id=\"ck-comment-author\"\n value={commentAuthor}\n onChange={(e) => setCommentAuthor(e.target.value)}\n placeholder=\"unknown\"\n className=\"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]\"\n disabled={isPending}\n />\n </div>\n\n <div className=\"grid gap-1\">\n <label className=\"text-xs font-medium text-[color:var(--ck-text-secondary)]\" htmlFor=\"ck-comment-body\">\n Comment\n </label>\n <textarea\n id=\"ck-comment-body\"\n value={commentBody}\n onChange={(e) => setCommentBody(e.target.value)}\n rows={4}\n className=\"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]\"\n disabled={isPending}\n />\n </div>\n\n <div className=\"flex items-center justify-end\">\n <button\n type=\"button\"\n aria-busy={isPending}\n className={\n \"rounded-[var(--ck-radius-sm)] bg-[color:var(--ck-accent)] px-3 py-2 text-xs font-semibold text-black transition \" +\n \"hover:brightness-110 active:brightness-95 \" +\n \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--ck-border-strong)] focus-visible:ring-offset-2 focus-visible:ring-offset-black/30 \" +\n \"disabled:cursor-not-allowed disabled:border disabled:border-[color:var(--ck-border-subtle)] disabled:bg-[color:var(--ck-bg-glass)] disabled:text-[color:var(--ck-text-tertiary)]\"\n }\n onClick={() => {\n startTransition(() => {\n submitComment().catch((e: unknown) => setError(errorMessage(e)));\n });\n }}\n disabled={isPostCommentDisabled(commentBody, isPending)}\n >\n {isPending ? \"Posting…\" : \"Post comment\"}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"ck-glass p-6\">\n <pre className=\"whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-primary)]\">\n {props.markdown}\n </pre>\n </div>\n\n {confirm ? (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4\">\n <div className=\"ck-glass w-full max-w-lg rounded-[var(--ck-radius-md)] border border-[color:var(--ck-border-strong)] p-4\">\n <div className=\"text-sm font-semibold text-[color:var(--ck-text-primary)]\">\n {confirm.kind === \"goals\" ? \"Move to Goals\" : \"Delete ticket\"}\n </div>\n\n <div className=\"mt-2 text-sm text-[color:var(--ck-text-secondary)]\">\n {confirm.kind === \"goals\" ? (\n <>\n This will move the ticket out of the work lanes into <code>work/goals/</code> so it won’t be picked up by\n automation.\n </>\n ) : (\n <>This will permanently remove the ticket markdown file. Assignment stubs (if any) will be archived.</>\n )}\n </div>\n\n <div className=\"mt-4 flex items-center justify-end gap-2\">\n <button\n className=\"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs text-[color:var(--ck-text-secondary)]\"\n onClick={() => setConfirm(null)}\n disabled={isPending}\n >\n Cancel\n </button>\n <button\n className={\n confirm.kind === \"delete\"\n ? \"rounded bg-[color:var(--ck-accent-red)] px-3 py-1.5 text-xs font-medium text-white\"\n : \"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-medium text-black\"\n }\n onClick={() => {\n const kind = confirm.kind;\n setConfirm(null);\n startTransition(() => {\n const op = kind === \"goals\" ? moveToGoals() : deleteTicket();\n op\n .then(() => {\n toast.push({\n kind: \"success\",\n message: kind === \"delete\" ? \"Ticket deleted.\" : \"Moved to Goals.\",\n });\n if (kind === \"delete\") {\n router.push(props.backHref ?? \"/tickets\");\n } else {\n router.refresh();\n }\n })\n .catch((e: unknown) => setError(errorMessage(e)));\n });\n }}\n disabled={isPending}\n >\n Confirm\n </button>\n </div>\n </div>\n </div>\n ) : null}\n </div>\n );\n}\n","export type TicketComment = {\n timestamp: string;\n author: string;\n body: string;\n};\n\nfunction findCommentsSection(md: string): { start: number; end: number } | null {\n const headerRe = /^## Comments\\s*$/gim;\n const m = headerRe.exec(md);\n if (!m) return null;\n\n const start = m.index + m[0].length;\n\n // Find next heading of same or higher level.\n const rest = md.slice(start);\n const nextHeading = rest.search(/^##\\s+/m);\n const end = nextHeading === -1 ? md.length : start + nextHeading;\n return { start, end };\n}\n\nexport function parseTicketComments(md: string): TicketComment[] {\n const section = findCommentsSection(md);\n if (!section) return [];\n\n const body = md.slice(section.start, section.end).replace(/^\\s+/, \"\");\n const lines = body.split(\"\\n\");\n\n const out: TicketComment[] = [];\n let current: TicketComment | null = null;\n\n const header = /^- \\*\\*(.+?)\\*\\*\\s+—\\s+(.*)$/;\n\n for (const rawLine of lines) {\n const line = rawLine.replace(/\\r$/, \"\");\n const m = line.match(header);\n if (m) {\n if (current) out.push({ ...current, body: current.body.trimEnd() });\n const timestamp = m[1].trim();\n const rest = m[2].trim();\n // Support either \"author: first line\" or just \"author\".\n const colonIdx = rest.indexOf(\":\");\n const author = (colonIdx >= 0 ? rest.slice(0, colonIdx) : rest).trim() || \"unknown\";\n const firstBody = colonIdx >= 0 ? rest.slice(colonIdx + 1).trimStart() : \"\";\n current = { timestamp, author, body: firstBody ? firstBody + \"\\n\" : \"\" };\n continue;\n }\n\n if (!current) continue;\n\n // Allow list paragraph indentation, but keep it simple.\n current.body += line.replace(/^\\s{0,2}/, \"\") + \"\\n\";\n }\n\n if (current) out.push({ ...current, body: current.body.trimEnd() });\n return out;\n}\n\nexport function formatTicketCommentMarkdown(args: {\n timestamp: string;\n author: string;\n body: string;\n}): string {\n const body = args.body.trim().replace(/\\r\\n/g, \"\\n\");\n const indented = body\n .split(\"\\n\")\n .map((l) => ` ${l}`)\n .join(\"\\n\");\n\n const author = args.author?.trim() || \"unknown\";\n return `\\n- **${args.timestamp}** — ${author}:\\n${indented}\\n`;\n}\n","\"use client\";\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useRouter } from \"next/navigation\";\n\nexport function TicketAssignControl({\n teamId,\n ticket,\n currentOwner,\n}: {\n teamId?: string | null;\n ticket: string;\n currentOwner: string | null;\n}) {\n const router = useRouter();\n const [assignees, setAssignees] = useState<string[]>([]);\n const [selected, setSelected] = useState<string>(currentOwner ?? \"\");\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n let cancelled = false;\n (async () => {\n try {\n const url = teamId\n ? `/api/teams/${encodeURIComponent(teamId)}/tickets/assignees`\n : \"/api/tickets/assignees\";\n const res = await fetch(url, { cache: \"no-store\" });\n const json = (await res.json()) as { assignees?: string[] };\n if (cancelled) return;\n setAssignees(Array.isArray(json.assignees) ? json.assignees : []);\n } catch {\n if (cancelled) return;\n setAssignees([]);\n }\n })();\n return () => {\n cancelled = true;\n };\n }, []);\n\n const options = useMemo(() => {\n const base = new Set(assignees);\n if (currentOwner) base.add(currentOwner);\n return Array.from(base).sort();\n }, [assignees, currentOwner]);\n\n async function onAssign() {\n setLoading(true);\n setError(null);\n try {\n const url = teamId\n ? `/api/teams/${encodeURIComponent(teamId)}/tickets/assign`\n : \"/api/tickets/assign\";\n\n const res = await fetch(url, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ ticket, assignee: selected }),\n });\n\n const json = (await res.json()) as { error?: string };\n if (!res.ok) {\n setError(json.error || \"Assign failed\");\n return;\n }\n\n router.refresh();\n } catch {\n setError(\"Assign failed\");\n } finally {\n setLoading(false);\n }\n }\n\n return (\n <div className=\"ck-glass p-4\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <div className=\"text-xs font-medium text-[color:var(--ck-text-tertiary)]\">Assignee</div>\n <select\n className=\"rounded-md border border-white/10 bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]\"\n value={selected}\n onChange={(e) => setSelected(e.target.value)}\n >\n <option value=\"\" disabled>\n Select…\n </option>\n {options.map((a) => (\n <option key={a} value={a}>\n {a}\n </option>\n ))}\n </select>\n\n <button\n type=\"button\"\n onClick={onAssign}\n disabled={loading || !selected || selected === (currentOwner ?? \"\")}\n className=\"rounded-md bg-emerald-600 px-3 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {loading ? \"Assigning…\" : \"Assign\"}\n </button>\n\n {currentOwner ? (\n <div className=\"text-xs text-[color:var(--ck-text-tertiary)]\">Currently: {currentOwner}</div>\n ) : null}\n </div>\n\n {error ? <div className=\"mt-2 text-xs text-red-300\">{error}</div> : null}\n </div>\n );\n}\n"],"names":[],"mappings":"uCAIO,SAAS,EAAa,CAAU,EACrC,OAAO,aAAa,MAAQ,EAAE,OAAO,CAAG,OAAO,EACjD,sECJA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAEA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OEHO,SAAS,EAAoB,QAClC,CAAM,QACN,CAAM,CACN,cAAY,CAKb,EACC,IAAM,EAAS,CAAA,EAAA,EAAA,SAAA,AAAS,IAClB,CAAC,EAAW,EAAa,CAAG,CAAA,EAAA,EAAA,QAAA,AAAQ,EAAW,EAAE,EACjD,CAAC,EAAU,EAAY,CAAG,CAAA,EAAA,EAAA,QAAA,AAAQ,EAAS,GAAgB,IAC3D,CAAC,EAAS,EAAW,CAAG,CAAA,EAA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,CAAC,CACT,KAAM,UACN,QAAkB,WAAT,EAAoB,kBAAoB,iBACnD,GACI,AAAS,UAAU,GACrB,EAAO,IAAI,CAAC,EAAM,QAAQ,EAAI,YAE9B,EAAO,OAAO,EAElB,GACC,KAAK,CAAC,AAAC,GAAe,EAAS,CAAA,EAAA,EAAA,YAAA,AAAY,EAAC,IACjD,EACF,EACA,SAAU,WACX,oBAML,OAGV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports=[67004,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(1760),e=a.i(50944),f=a.i(88764),g=a.i(66063);function h({open:a,teamId:c,recipeId:d,onClose:e,onConfirm:f,busy:h}){return(0,b.jsxs)(g.ConfirmationModal,{open:a,onClose:e,title:"Publish changes",confirmLabel:"Publish changes",confirmBusyLabel:"Publishing…",busy:h,onConfirm:f,confirmButtonClassName:"rounded-[var(--ck-radius-sm)] bg-emerald-600 px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-emerald-500 disabled:opacity-50",children:[(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["This will re-scaffold team ",(0,b.jsx)("code",{className:"font-mono",children:c})," from recipe ",(0,b.jsx)("code",{className:"font-mono",children:d}),"."]}),(0,b.jsxs)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-3 text-sm text-amber-100",children:[(0,b.jsx)("div",{className:"font-medium",children:"Complete overwrite"}),(0,b.jsxs)("div",{className:"mt-1",children:["All existing team workspace files managed by the recipe will be overwritten (for example: ",(0,b.jsx)("code",{className:"font-mono",children:"AGENTS.md"}),","," ",(0,b.jsx)("code",{className:"font-mono",children:"SOUL.md"}),", role templates, and other scaffolded files). Any manual edits in those files will be lost."]})]})]})}var i=a.i(61889),j=a.i(74621),k=a.i(51200);function l(a,b){try{return JSON.parse(a)}catch{return b}}async function m(a){let[b,c]=await Promise.all([(0,k.fetchJson)("/api/recipes",{cache:"no-store"}),fetch(`/api/teams/meta?teamId=${encodeURIComponent(a)}`,{cache:"no-store"})]);return{recipesData:b,metaRes:c}}async function n(a){let b=await (0,k.fetchAll)([`/api/teams/files?teamId=${encodeURIComponent(a)}`,`/api/cron/jobs?teamId=${encodeURIComponent(a)}`,"/api/agents",`/api/teams/skills?teamId=${encodeURIComponent(a)}`,"/api/skills/available"]),c=await Promise.all(b.map(a=>a.text()));return{responses:b,texts:c}}async function o(a,b){b.setTeamFilesLoading(!0),b.setCronLoading(!0),b.setTeamAgentsLoading(!0),b.setSkillsLoading(!0);try{let{responses:c,texts:d}=await n(a),[e,f,g,h,i]=c,[j,k,m,o,p]=d,q=l(j,{});e.ok&&q.ok&&Array.isArray(q.files)&&b.setTeamFiles(q.files.map(a=>({name:String(a.name??""),missing:!!a.missing,required:!!a.required,rationale:"string"==typeof a.rationale?a.rationale:void 0})));let r=l(k,{});f.ok&&r.ok&&Array.isArray(r.jobs)&&b.setCronJobs(r.jobs);let s=l(m,{});if(g.ok&&Array.isArray(s.agents)){let c=s.agents.filter(b=>String(b.id??"").startsWith(`${a}-`));b.setTeamAgents(c.map(a=>({id:String(a.id??""),identityName:"string"==typeof a.identityName?a.identityName:void 0})))}let t=l(o,{});h.ok&&t.ok&&Array.isArray(t.skills)&&b.setSkillsList(t.skills);let u=l(p,{});if(i.ok&&u.ok&&Array.isArray(u.skills)){let a=u.skills;b.setAvailableSkills(a),b.setSelectedSkill(b=>{let c=String(b??"").trim();return c&&a.includes(c)?c:a[0]??""})}}finally{b.setTeamFilesLoading(!1),b.setCronLoading(!1),b.setTeamAgentsLoading(!1),b.setSkillsLoading(!1)}}async function p(a,b){let c=await m(a);b.setRecipes(c.recipesData.recipes??[]);let d=null;try{let a=await c.metaRes.json(),e=a.meta;c.metaRes.ok&&a.ok&&e?.recipeId?(d={recipeId:String(e.recipeId),recipeName:"string"==typeof e.recipeName?e.recipeName:void 0},b.setTeamMetaRecipeHash("string"==typeof e.recipeHash?e.recipeHash:null)):b.setTeamMetaRecipeHash(null)}catch{b.setTeamMetaRecipeHash(null)}if(d)b.setLockedFromId(d.recipeId),b.setLockedFromName(d.recipeName??null),b.setProvenanceMissing(!1),b.setFromId(d.recipeId);else{b.setLockedFromId(null),b.setLockedFromName(null),b.setProvenanceMissing(!0);let d=c.recipesData.recipes??[],e=d.find(b=>"team"===b.kind&&b.id===a),f=d.find(a=>"team"===a.kind),g=e??f;g&&b.setFromId(g.id)}await o(a,{setTeamFiles:b.setTeamFiles,setCronJobs:b.setCronJobs,setTeamAgents:b.setTeamAgents,setSkillsList:b.setSkillsList,setAvailableSkills:b.setAvailableSkills,setSelectedSkill:b.setSelectedSkill,setTeamFilesLoading:b.setTeamFilesLoading,setCronLoading:b.setCronLoading,setTeamAgentsLoading:b.setTeamAgentsLoading,setSkillsLoading:b.setSkillsLoading})}async function q(a){try{let b=await (0,k.fetchJson)("/api/agents",{cache:"no-store"}),c=(Array.isArray(b.agents)?b.agents:[]).filter(b=>String(b.id??"").startsWith(`${a}-`)).map(a=>({id:String(a.id??""),identityName:"string"==typeof a.identityName?a.identityName:void 0}));return{ok:!0,agents:c}}catch{return{ok:!1,agents:[]}}}async function r(a,b,c){try{await (0,k.fetchJson)("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:b.trim(),teamId:a,applyConfig:!0,overwrite:!1,allowExisting:!0,cronInstallChoice:"no"})})}catch(a){c((0,j.errorMessage)(a),"error")}}async function s(a,b,c,d){let e=Date.now();for(;Date.now()-e<d;){try{let d=await q(a);if(d.ok){c(d.agents);let a=!!b&&d.agents.some(a=>a.id===b);if(!b||a)return!0}}catch{}await new Promise(a=>setTimeout(a,500))}return!1}async function t(a){let{teamId:b,toId:c,newRole:d,derivedRole:e,newRoleName:f,content:g,setContent:h,setTeamAgents:i,flashMessage:l,ensureCustomRecipeExists:m}=a;try{await m({overwrite:!1})}catch(b){let a=(0,j.errorMessage)(b);if(!/Recipe id already exists:/i.test(a))throw b}let n=await (0,k.fetchJson)("/api/recipes/team-agents",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("__custom__"===d?{recipeId:c.trim(),op:"add",role:e,name:f}:{recipeId:c.trim(),op:"addLike",baseRole:e,teamId:b,name:f})});if(!n.ok)throw Error("Failed updating agents list");h(String(n.content??g)),await r(b,c,l);let o="string"==typeof n.addedAgentId?n.addedAgentId:"";if(!await s(b,o,i,5e3)&&o){try{fetch("/api/gateway/restart",{method:"POST"})}catch{}await s(b,o,i,1e4)}l(`Updated agents list in ${c}`,"success")}function u(a){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Custom recipe target"}),a.loading?(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"Loading team…"}):null]}),(0,b.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team id"}),(0,b.jsx)("input",{value:a.toId,onChange:b=>a.setToId(b.target.value),disabled:!a.canEditTargetId,className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70"}),(0,b.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:"This is the custom recipe id that will be created when you save."}),(0,b.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team name"}),(0,b.jsx)("input",{value:a.toName,onChange:b=>a.setToName(b.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2",children:[(0,b.jsx)("button",{type:"button",disabled:a.saving||!a.teamIdValid||!a.targetIdValid||a.targetIsBuiltin,onClick:()=>a.onSaveCustom(!0),className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:a.saving?"Saving":"Save"}),(0,b.jsx)("button",{type:"button",disabled:a.saving||!a.teamIdValid||!a.targetIdValid||a.targetIsBuiltin||!a.loadedRecipeHash||!a.teamMetaRecipeHash||a.loadedRecipeHash===a.teamMetaRecipeHash,onClick:a.onPublishOpen,className:"rounded-[var(--ck-radius-sm)] bg-emerald-600 px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:a.publishing?"Publishing":"Publish changes"}),(0,b.jsx)("button",{type:"button",disabled:a.saving,onClick:a.onDeleteOpen,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] disabled:opacity-50",children:"Delete Team"})]})]}),(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Notes"}),(0,b.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Parent recipe (locked)"}),(0,b.jsx)("select",{disabled:!0,className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70",value:a.fromId,onChange:b=>a.setFromId(b.target.value),children:a.teamRecipes.map(a=>(0,b.jsxs)("option",{value:a.id,children:[a.id," (",a.source,")"]},`${a.source}:${a.id}`))}),a.lockedFromId&&(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("code",{children:a.lockedFromId}),a.lockedFromName?` (${a.lockedFromName})`:""]}),!a.lockedFromId&&a.provenanceMissing&&(0,b.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Provenance not found for this team."})]}),(0,b.jsxs)("ul",{className:"mt-4 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("li",{children:"Save writes the custom recipe file identified by Team id."}),(0,b.jsx)("li",{children:"Publish changes re-scaffolds this team from your custom recipe."}),(0,b.jsx)("li",{children:"Delete Team runs openclaw recipes remove-team."})]})]})]}),(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recipe markdown"}),a.recipeLoadError?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:a.recipeLoadError}):null,(0,b.jsx)("textarea",{value:a.content,onChange:b=>{a.setContent(b.target.value),a.setLoadedRecipeHash(null)},className:"mt-2 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1})]})]})}function v(a){let{teamId:c,toId:d,recipeAgents:e,newRole:f,setNewRole:g,customRole:h,setCustomRole:i,newRoleName:j,setNewRoleName:k,derivedRole:l,saving:m,teamAgents:n,teamAgentsLoading:o,onAddAgent:p}=a;return(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Agents in this team"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Add/remove agents by updating the ",(0,b.jsx)("code",{children:"agents:"})," list in your custom team recipe (",(0,b.jsx)("code",{children:d}),")."]}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Role"}),(0,b.jsxs)("select",{value:f,onChange:a=>{let b=a.target.value;if(g(b),"__custom__"===b){i(""),k("");return}i("");let c=e.find(a=>a.role===b);k(c?.name||"")},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",children:[(0,b.jsx)("option",{value:"",children:"Select…"}),e.map(a=>(0,b.jsx)("option",{value:a.role,children:a.name||a.role},a.role)),(0,b.jsx)("option",{value:"__custom__",children:"Other…"})]}),"__custom__"===f?(0,b.jsx)("input",{value:h,onChange:a=>i(a.target.value),placeholder:"role (e.g. researcher)",className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}):null,(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["This writes to the recipe's ",(0,b.jsx)("code",{children:"agents:"})," list."]})]}),(0,b.jsx)("div",{className:"sm:col-span-2",children:(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Name (optional)"}),(0,b.jsx)("input",{value:j,onChange:a=>k(a.target.value),placeholder:"Onchain Researcher",className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"})]})})]}),(0,b.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:(0,b.jsx)("button",{disabled:m||!l,onClick:p,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:"Add agent"})}),(0,b.jsxs)("div",{className:"mt-6",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Detected installed team agents (read-only)"}),(0,b.jsxs)("ul",{className:"mt-2 space-y-2",children:[n.length?n.map(a=>(0,b.jsxs)("li",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:a.identityName||a.id}),(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:a.id})]}),(0,b.jsx)("a",{className:"text-sm font-medium text-[var(--ck-accent-red)] hover:text-[color:var(--ck-accent-red-hover)]",href:"/agents/"+encodeURIComponent(a.id)+"?returnTo="+encodeURIComponent("/teams/"+c+"?tab=agents"),children:"Edit"})]},a.id)):null,0===n.length&&!o&&(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No team agents detected."}),0===n.length&&o&&(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"})]})]})]})}function w(a){return(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Skills"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"Skills installed in this team workspace. For agent-specific skills, open the agent from the Agents tab."}),(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Installed"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:a.skillsList.length?a.skillsList.map(a=>(0,b.jsx)("li",{children:a},a)):(0,b.jsx)("li",{children:"None installed."})})]}),(0,b.jsxs)("div",{className:"mt-5 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15 p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Add a skill"}),(0,b.jsxs)("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,b.jsx)("select",{value:a.selectedSkill,onChange:b=>a.setSelectedSkill(b.target.value),disabled:a.installingSkill||a.skillsLoading||!a.availableSkills.length,className:"w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",children:a.availableSkills.length?a.availableSkills.map(a=>(0,b.jsx)("option",{value:a,children:a},a)):(0,b.jsx)("option",{value:"",children:"No skills found"})}),(0,b.jsx)("button",{type:"button",disabled:a.installingSkill||a.skillsLoading||!a.selectedSkill,onClick:a.onInstallSkill,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:a.installingSkill?"Adding":"Add"})]}),a.teamSkillError&&(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:a.teamSkillError}),a.teamSkillMsg&&(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 p-3 text-sm text-emerald-100",children:a.teamSkillMsg}),(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Uses openclaw recipes install-skill with team-id ",a.teamId,"."]})]})]})}function x(a){let{cronJobs:c,cronLoading:d,saving:e,onCronAction:f}=a;return(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Cron jobs (filtered by team name)"}),(0,b.jsxs)("ul",{className:"mt-3 space-y-3",children:[c.length?c.map(a=>{let c=String(a.id??a.jobId??"").trim(),d=c||String(a.name??"job"),g=String(a.name??a.id??a.jobId??"(unnamed)"),h=a.enabled??a.state?.enabled;return(0,b.jsxs)("li",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:g}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Enabled: ",String(h??"?")]}),(0,b.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,b.jsx)("button",{disabled:e||!c,onClick:()=>f(c,g,"run"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Run"}),(0,b.jsx)("button",{disabled:e||!c,onClick:()=>f(c,g,"enable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Enable"}),(0,b.jsx)("button",{disabled:e||!c,onClick:()=>f(c,g,"disable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Disable"}),c?null:(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"(missing id)"})]})]},d)}):null,0===c.length&&d&&(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading"}),0===c.length&&!d&&(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No cron jobs detected for this team."})]})]})}var y=a.i(60791);function z(a){let{teamFiles:c,teamFilesLoading:d,showOptionalFiles:e,setShowOptionalFiles:f,fileName:g,fileContent:h,setFileContent:i,teamFileError:j,saving:k,onLoadTeamFile:l,onSaveTeamFile:m}=a;return(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3",children:[(0,b.jsx)(y.FileListWithOptionalToggle,{title:"Team files",files:c,loading:d,showOptionalFiles:e,onShowOptionalChange:f,selectedFileName:g,onSelectFile:l}),(0,b.jsxs)("div",{className:"ck-glass-strong p-4 lg:col-span-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:["Edit: ",g]}),(0,b.jsx)("button",{disabled:k,onClick:m,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:k?"Saving…":"Save file"})]}),j?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:j}):null,(0,b.jsx)("textarea",{value:h,onChange:a=>i(a.target.value),className:"mt-3 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1})]})]})}function A(a){return`${a._file??""}:${a._line??0}`}function B({teamId:a}){let[d,e]=(0,c.useState)(!1),[f,g]=(0,c.useState)(""),[h,i]=(0,c.useState)([]),[k,l]=(0,c.useState)([]),[m,n]=(0,c.useState)([]),[o,p]=(0,c.useState)("learning"),[q,r]=(0,c.useState)(""),[s,t]=(0,c.useState)(""),[u,v]=(0,c.useState)(!1),[w,x]=(0,c.useState)(null);async function y(){e(!0),g("");try{let b=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to load memory");i(Array.isArray(c.files)?c.files:[]),l(Array.isArray(c.pinnedItems)?c.pinnedItems:[]),n(Array.isArray(c.items)?c.items:[])}catch(a){g((0,j.errorMessage)(a)),i([]),l([]),n([])}finally{e(!1)}}(0,c.useEffect)(()=>{y()},[a]);let z=(0,c.useMemo)(()=>[{label:"decision",value:"decision"},{label:"learning",value:"learning"},{label:"bug",value:"bug"},{label:"customer",value:"customer"},{label:"release",value:"release"}],[]),B=(0,c.useMemo)(()=>new Set(k.map(a=>a._key)),[k]);async function C(b){let c=A(b);if(b._file&&b._line){x(c),g("");try{let c={op:"pin",ts:new Date().toISOString(),actor:`${a}-lead`,key:{file:"team.jsonl",line:b._line},item:{ts:b.ts,author:b.author,type:b.type,content:b.content,source:b.source}},d=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(c)}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to pin");await y()}catch(a){g((0,j.errorMessage)(a))}finally{x(null)}}}async function D(b){let c=A(b);if(b._file&&b._line){x(c),g("");try{let c={op:"unpin",ts:new Date().toISOString(),actor:`${a}-lead`,key:{file:"team.jsonl",line:b._line}},d=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(c)}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to unpin");await y()}catch(a){g((0,j.errorMessage)(a))}finally{x(null)}}}return(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Team memory (file-first)"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["Stored in ",(0,b.jsx)("span",{className:"font-mono",children:"shared-context/memory/*.jsonl"}),". Items must be attributable."]})]}),(0,b.jsx)("button",{type:"button",onClick:y,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Refresh"})]}),f?(0,b.jsx)("div",{className:"mt-3 rounded border border-red-400/30 bg-red-500/10 p-2 text-sm text-red-100",children:f}):null,(0,b.jsxs)("div",{className:"mt-3 text-xs text-[color:var(--ck-text-secondary)]",children:["Files: ",h.length?h.join(", "):"(none)"]})]}),(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Add memory item"}),(0,b.jsxs)("div",{className:"mt-3 grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,b.jsx)("select",{value:o,onChange:a=>p(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-2 text-sm text-[color:var(--ck-text-primary)]",children:z.map(a=>(0,b.jsx)("option",{value:a.value,children:a.label},a.value))})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"source (ticket/pr/path)"}),(0,b.jsx)("input",{value:s,onChange:a=>t(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-2 text-sm text-[color:var(--ck-text-primary)]",placeholder:"e.g. ticket 0088, PR https://..., shared-context/DECISIONS.md"})]}),(0,b.jsxs)("label",{className:"block md:col-span-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"content"}),(0,b.jsx)("textarea",{value:q,onChange:a=>r(a.target.value),className:"mt-1 h-[110px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-sm text-[color:var(--ck-text-primary)]",placeholder:"Write a small, specific memory item…"})]}),(0,b.jsx)("div",{className:"md:col-span-2",children:(0,b.jsx)("button",{type:"button",disabled:u||!q.trim(),onClick:async()=>{v(!0),g("");try{let b={op:"append",ts:new Date().toISOString(),author:`${a}-lead`,type:o,content:q.trim(),source:s.trim()?{text:s.trim()}:void 0,file:"team.jsonl"},c=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to append memory");r(""),t(""),await y()}catch(a){g((0,j.errorMessage)(a))}finally{v(!1)}},className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:u?"Saving…":"Append to team.jsonl"})})]})]}),(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Pinned memory"}),(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[k.length," pinned"]})]}),d?(0,b.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,(0,b.jsx)("div",{className:"mt-3 space-y-3",children:k.length?k.map(a=>(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.ts}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsx)("span",{className:"rounded bg-white/5 px-2 py-0.5 font-mono",children:a.type}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsx)("span",{className:"font-mono",children:a.author}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsxs)("span",{className:"font-mono",children:["pinned ",a.pinnedAt]})]}),(0,b.jsx)("button",{type:"button",onClick:()=>void D(a),disabled:w===a._key,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:w===a._key?"Unpinning…":"Unpin"})]}),(0,b.jsx)("div",{className:"mt-2 whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:a.content}),a.source?(0,b.jsx)("pre",{className:"mt-2 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(a.source,null,2)}):null]},a._key)):(0,b.jsx)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No pinned items yet."})})]}),(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recent memory"}),(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Showing ",m.length," (max 200)"]})]}),d?(0,b.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,(0,b.jsx)("div",{className:"mt-3 space-y-3",children:m.length?m.map(a=>{let c=A(a),d=B.has(c);return(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.ts}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsx)("span",{className:"rounded bg-white/5 px-2 py-0.5 font-mono",children:a.type}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsx)("span",{className:"font-mono",children:a.author})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[a._file?(0,b.jsxs)("span",{className:"text-[10px] text-[color:var(--ck-text-tertiary)] font-mono",children:[a._file,":",a._line]}):null,(0,b.jsx)("button",{type:"button",onClick:()=>void C(a),disabled:d||w===c||!a._file||!a._line,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:d?"Pinned":w===c?"Pinning…":"Pin"})]})]}),(0,b.jsx)("div",{className:"mt-2 whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:a.content}),a.source?(0,b.jsx)("pre",{className:"mt-2 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(a.source,null,2)}):null]},`${a._file??"?"}:${a._line??0}`)}):(0,b.jsx)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No memory items yet."})})]})]})}var C=a.i(35112);function D({open:a,onClose:d,teamId:e,onInstalled:f}){let g=(0,c.useMemo)(()=>`${e}-swarm-orchestrator`,[e]),[h,i]=(0,c.useState)(g),[j,l]=(0,c.useState)(""),[m,n]=(0,c.useState)("/home/control/swarm-worktrees"),[o,p]=(0,c.useState)("origin/main"),[q,r]=(0,c.useState)(!0),[s,t]=(0,c.useState)(!0),[u,v]=(0,c.useState)(!1),[w,x]=(0,c.useState)(null),[y,z]=(0,c.useState)(null),A=(0,c.useMemo)(()=>({effectiveAgentId:String(h??"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/--+/g,"-")}),[h]);return a?(0,C.createPortal)((0,b.jsxs)("div",{className:"fixed inset-0 z-[210]",children:[(0,b.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:()=>{u||d()}}),(0,b.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,b.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,b.jsxs)("div",{className:"w-full max-w-xl rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,b.jsx)("div",{className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:"Add Orchestrator"}),(0,b.jsxs)("p",{className:"mt-1 text-sm text-[color:var(--ck-text-secondary)]",children:["This will scaffold a new ",(0,b.jsx)("span",{className:"font-mono text-xs",children:"swarm-orchestrator"})," agent workspace for this team and prefill its config."]}),(0,b.jsx)("label",{className:"mt-4 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Orchestrator agent id"}),(0,b.jsx)("input",{value:h,onChange:a=>i(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["Default: ",(0,b.jsx)("span",{className:"font-mono",children:g})," (normalized: ",(0,b.jsx)("span",{className:"font-mono",children:A.effectiveAgentId}),")"]}),(0,b.jsx)("label",{className:"mt-4 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Repo directory (SWARM_REPO_DIR)"}),(0,b.jsx)("input",{value:j,onChange:a=>l(a.target.value),placeholder:"/home/control/clawkitchen",className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Worktree root (SWARM_WORKTREE_ROOT)"}),(0,b.jsx)("input",{value:m,onChange:a=>n(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:"Recommend a dedicated folder outside the repo."})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Base ref (SWARM_BASE_REF)"}),(0,b.jsx)("input",{value:o,onChange:a=>p(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"})]})]}),(0,b.jsxs)("label",{className:"mt-5 flex items-start gap-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("input",{type:"checkbox",checked:q,onChange:a=>r(a.target.checked),className:"mt-1"}),(0,b.jsxs)("span",{children:["Add this agent to OpenClaw config (recommended).",(0,b.jsx)("br",{}),(0,b.jsxs)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["This will modify ",(0,b.jsx)("span",{className:"font-mono",children:"~/.openclaw/openclaw.json"})," to add ",(0,b.jsx)("span",{className:"font-mono",children:A.effectiveAgentId}),"."]})]})]}),(0,b.jsxs)("label",{className:"mt-3 flex items-start gap-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("input",{type:"checkbox",checked:s,onChange:a=>t(a.target.checked),className:"mt-1"}),(0,b.jsxs)("span",{children:["Make scripts executable (developer convenience).",(0,b.jsx)("br",{}),(0,b.jsxs)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Runs ",(0,b.jsx)("span",{className:"font-mono",children:"chmod +x .clawdbot/*.sh"})," in the orchestrator workspace."]})]})]}),w?(0,b.jsx)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:w}):null,y?(0,b.jsxs)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 p-3 text-sm text-emerald-100",children:["Installed ",(0,b.jsx)("span",{className:"font-mono",children:y.orchestratorAgentId})," → ",(0,b.jsx)("span",{className:"font-mono",children:y.workspace})]}):null,(0,b.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:d,disabled:u,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Cancel"}),(0,b.jsx)("button",{type:"button",disabled:u||!A.effectiveAgentId||!j.trim(),onClick:async()=>{v(!0),x(null),z(null);try{let a=await (0,k.fetchJson)("/api/teams/orchestrator/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,orchestratorAgentId:A.effectiveAgentId,repoDir:j.trim(),worktreeRoot:m.trim(),baseRef:o.trim(),applyConfig:q,makeExecutable:s})});if(!a.ok)throw Error(a.error);z({orchestratorAgentId:a.orchestratorAgentId,workspace:a.workspace}),f()}catch(a){x(a instanceof Error?a.message:String(a))}finally{v(!1)}},className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-[var(--ck-accent-red-hover)] disabled:opacity-50",children:u?"Installing…":"Install"})]})]})})})]}),document.body):null}function E({teamId:a}){let[d,e]=(0,c.useState)(!0),[f,g]=(0,c.useState)(null),[h,i]=(0,c.useState)(null),[j,l]=(0,c.useState)(!1),m=(0,c.useCallback)(async()=>{e(!0);try{let b=await (0,k.fetchJson)(`/api/teams/orchestrator?teamId=${encodeURIComponent(a)}`,{cache:"no-store"});g(b),i(new Date().toISOString())}catch(a){g({ok:!1,error:a instanceof Error?a.message:String(a)}),i(new Date().toISOString())}finally{e(!1)}},[a]);return((0,c.useEffect)(()=>{m()},[m]),d)?(0,b.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"Loading orchestrator state…"}):f?f.ok?f.present?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Agent: ",(0,b.jsx)("span",{className:"font-mono",children:f.agent.id}),f.agent.identityName?` (${f.agent.identityName})`:""]}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Workspace: ",(0,b.jsx)("span",{className:"font-mono",children:f.agent.workspace})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:h?(0,b.jsxs)("span",{children:["Last updated: ",(0,b.jsx)("span",{className:"font-mono",children:h})]}):null}),(0,b.jsx)("button",{type:"button",onClick:()=>void m(),disabled:d,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] transition-colors hover:bg-white/10 active:bg-white/15 disabled:opacity-50",children:d?"Refreshing…":"Refresh"})]})]}),(0,b.jsxs)("div",{className:"mt-5 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,b.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"tmux sessions"}),f.tmuxSessions.length?(0,b.jsx)("ul",{className:"mt-2 space-y-2",children:f.tmuxSessions.map(a=>(0,b.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.name}),(0,b.jsxs)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["attached=",String(a.attached),"number"==typeof a.windows?` windows=${a.windows}`:""]})]},a.name))}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No sessions detected (or tmux not running)."})]}),(0,b.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"git worktrees"}),f.worktrees.length?(0,b.jsx)("ul",{className:"mt-2 space-y-2",children:f.worktrees.map(a=>(0,b.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"font-mono text-xs",children:a.path}),(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[a.branch?a.branch:"(no branch)",a.sha?` @ ${a.sha.slice(0,7)}`:""]})]},a.path))}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No worktrees detected."})]})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Active tasks"}),f.activeTasksSummary?(0,b.jsxs)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"font-mono text-xs",children:f.activeTasksSummary.path}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["number"==typeof f.activeTasksSummary.taskCount?`tasks=${f.activeTasksSummary.taskCount}`:"tasks=?",f.activeTasksSummary.rawType?` type=${f.activeTasksSummary.rawType}`:""]})]}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No active-tasks.json found."})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"CLI quick actions"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"The orchestrator is designed to be driven from the CLI (and usually tmux). Common commands:"}),(0,b.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-mono text-xs",children:"tmux ls"}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(list sessions)"})]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-mono text-xs",children:"tmux attach -t <session>"}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(jump into a running swarm)"})]}),(0,b.jsxs)("li",{children:[(0,b.jsxs)("span",{className:"font-mono text-xs",children:["git -C ",f.agent.workspace," worktree list"]}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(inspect worktrees)"})]})]}),(0,b.jsx)("p",{className:"mt-3 text-xs text-[color:var(--ck-text-tertiary)]",children:"Note: ClawKitchen is read-only here; it surfaces status and pointers, but does not run or attach to tmux."})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Human approval gate (recommended)"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["For workflows that publish, deploy, or send outbound messages, keep a ",(0,b.jsx)("strong",{children:"human approval step"}),"."]}),(0,b.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("li",{children:"Generate a proposed change/post as a draft."}),(0,b.jsx)("li",{children:"Send the draft to a bound messaging channel (e.g. Telegram) for approval."}),(0,b.jsx)("li",{children:"Only execute the final action after explicit approve/deny."})]})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Where to change settings"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"These are the common knobs for a swarm/orchestrator scaffold (read-only references):"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:f.settingsPaths.map(a=>(0,b.jsx)("li",{className:"font-mono text-xs",children:a},a))})]})]}):(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No swarm/orchestrator detected for this team."})]}),(0,b.jsx)("button",{type:"button",onClick:()=>l(!0),className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-[var(--ck-accent-red-hover)]",children:"Add Orchestrator"})]}),(0,b.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Detection"}),(0,b.jsx)("div",{className:"mt-1 font-mono text-xs",children:f.reason||"(no reason provided)"})]}),(0,b.jsxs)("p",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:["Default convention is ",(0,b.jsx)("code",{children:"<teamId>-swarm-orchestrator"}),". Once installed, this tab will show: tmux sessions, git worktrees/branches, and active task state."]}),(0,b.jsx)(D,{open:j,onClose:()=>l(!1),teamId:a,onInstalled:()=>{l(!1),m()}})]}):(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:f.error})]}):(0,b.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"No orchestrator state available."})}var F=a.i(83856);let G=[{id:"recipe",label:"Recipe"},{id:"agents",label:"Agents"},{id:"skills",label:"Skills"},{id:"cron",label:"Cron"},{id:"files",label:"Files"},{id:"orchestrator",label:"Orchestrator"}],H=[{id:"memory",label:"Memory"},{id:"workflows",label:"Workflows"}];function I({teamId:a,initialTab:g}){let l=(0,e.useRouter)(),[m,n]=(0,c.useState)([]),[o,q]=(0,c.useState)(""),[r,s]=(0,c.useState)(null),[y,A]=(0,c.useState)(null),[C,D]=(0,c.useState)(!1),[I,J]=(0,c.useState)(a),[K,L]=(0,c.useState)(a),[M,N]=(0,c.useState)(""),[O,P]=(0,c.useState)(null),[Q,R]=(0,c.useState)(()=>["recipe","agents","skills","cron","files","memory","orchestrator","workflows"].includes(g)?g:"recipe"),S=(0,c.useMemo)(()=>[...G,...H],[]),[T,U]=(0,c.useState)(!0),[V,W]=(0,c.useState)(!1),[X,Y]=(0,c.useState)(!1),[Z,$]=(0,c.useState)(!1),[_,aa]=(0,c.useState)(!1),[ab,ac]=(0,c.useState)(""),ad=(0,i.useToast)(),[ae,af]=(0,c.useState)(!1),[ag,ah]=(0,c.useState)(!1),[ai,aj]=(0,c.useState)(null);function ak(a,b="info"){let c=String(a??"").trim();c&&ad.push({kind:b,message:c})}let[al,am]=(0,c.useState)([]),[an,ao]=(0,c.useState)(!1),[ap,aq]=(0,c.useState)(""),[ar,as]=(0,c.useState)(!1),[at,au]=(0,c.useState)("SOUL.md"),[av,aw]=(0,c.useState)(""),[ax,ay]=(0,c.useState)([]),[az,aA]=(0,c.useState)(!1),[aB,aC]=(0,c.useState)([]),[aD,aE]=(0,c.useState)(!1),aF=(0,c.useMemo)(()=>{let a=String(M??"");if(!a.startsWith("---\n"))return[];let b=a.indexOf("\n---\n",4);if(-1===b)return[];let c=a.slice(4,b+1);try{let a=(0,d.parse)(c)??{};return(Array.isArray(a.agents)?a.agents:[]).map(a=>a).map(a=>({role:String(a.role??"").trim(),name:"string"==typeof a.name?a.name:void 0})).filter(a=>!!a.role)}catch{return[]}},[M]),[aG,aH]=(0,c.useState)(""),[aI,aJ]=(0,c.useState)(""),[aK,aL]=(0,c.useState)(""),aM=(0,c.useMemo)(()=>("__custom__"===aG?aI:aG).trim()||"",[aG,aI]),[aN,aO]=(0,c.useState)([]),[aP,aQ]=(0,c.useState)([]),[aR,aS]=(0,c.useState)(!1),[aT,aU]=(0,c.useState)(""),[aV,aW]=(0,c.useState)(!1),[aX,aY]=(0,c.useState)(""),[aZ,a$]=(0,c.useState)(""),a_=(0,c.useMemo)(()=>m.filter(a=>"team"===a.kind),[m]),a0=(0,c.useMemo)(()=>m.find(a=>a.id===I&&"workspace"===a.source)??m.find(a=>a.id===I)??null,[m,I]),a1=!!a.trim(),a2=!!I.trim(),a3=m.some(a=>a.id===I&&"workspace"===a.source),a4=!!(a0?.source==="builtin"&&!a3);async function a5(){let a=I.trim();if(a){aa(!0),ac("");try{let b=await (0,k.fetchJson)(`/api/recipes/${encodeURIComponent(a)}`,{cache:"no-store"}),c=b.recipe;N(c.content),P("string"==typeof b.recipeHash?b.recipeHash:null)}catch(a){ac((0,j.errorMessage)(a))}finally{aa(!1)}}}async function a6(a){let b=o.trim(),c=String(a.toId??I).trim(),d=String(a.toName??K).trim(),e=!!a.overwrite,f=!!a.scaffold;if(!b)throw Error("Source recipe id is required");if(!c)throw Error("Custom recipe id is required");return await (0,k.fetchJson)("/api/recipes/clone",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:b,toId:c,toName:d||void 0,overwrite:e,scaffold:f})})}async function a7(a,b){W(!0),ak("");try{let c=await a6({overwrite:a,...b});if(c.scaffold&&!c.scaffold.ok&&ak(`Scaffold failed (recipe was still cloned): ${c.scaffold.error||"Unknown error"}`,"error"),M.trim()&&M.trim()!==c.content.trim()){let a=function(a,b){if(!a.startsWith("---\n"))return a;let c=a.indexOf("\n---\n",4);if(-1===c)return a;let d=a.slice(4,c),e=a.slice(c+5),{next:f,sawTeamBlock:g,patched:h}=function(a,b){let c=[],d=!1,e=!1,f=!1;for(let g of a){if(/^team\s*:\s*$/i.test(g)){d=!0,e=!0,c.push(g);continue}if(d&&/^\S/.test(g)&&(d=!1),d&&/^\s+teamId\s*:/i.test(g)){c.push(` teamId: ${b}`),f=!0;continue}c.push(g)}return{next:c,sawTeamBlock:e,patched:f}}(d.split("\n"),b);if(g&&!h){let a=[];for(let c of f)a.push(c),/^team\s*:\s*$/i.test(c)&&a.push(` teamId: ${b}`);return`---
|
|
1
|
+
module.exports=[67004,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(1760),e=a.i(50944),f=a.i(88764),g=a.i(66063);function h({open:a,teamId:c,recipeId:d,onClose:e,onConfirm:f,busy:h}){return(0,b.jsxs)(g.ConfirmationModal,{open:a,onClose:e,title:"Publish changes",confirmLabel:"Publish changes",confirmBusyLabel:"Publishing…",busy:h,onConfirm:f,confirmButtonClassName:"rounded-[var(--ck-radius-sm)] bg-emerald-600 px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-emerald-500 disabled:opacity-50",children:[(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["This will re-scaffold team ",(0,b.jsx)("code",{className:"font-mono",children:c})," from recipe ",(0,b.jsx)("code",{className:"font-mono",children:d}),"."]}),(0,b.jsxs)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-3 text-sm text-amber-100",children:[(0,b.jsx)("div",{className:"font-medium",children:"Complete overwrite"}),(0,b.jsxs)("div",{className:"mt-1",children:["All existing team workspace files managed by the recipe will be overwritten (for example: ",(0,b.jsx)("code",{className:"font-mono",children:"AGENTS.md"}),","," ",(0,b.jsx)("code",{className:"font-mono",children:"SOUL.md"}),", role templates, and other scaffolded files). Any manual edits in those files will be lost."]})]})]})}var i=a.i(61889),j=a.i(74621),k=a.i(51200);function l(a,b){try{return JSON.parse(a)}catch{return b}}async function m(a){let[b,c]=await Promise.all([(0,k.fetchJson)("/api/recipes",{cache:"no-store"}),fetch(`/api/teams/meta?teamId=${encodeURIComponent(a)}`,{cache:"no-store"})]);return{recipesData:b,metaRes:c}}async function n(a){let b=await (0,k.fetchAll)([`/api/teams/files?teamId=${encodeURIComponent(a)}`,`/api/cron/jobs?teamId=${encodeURIComponent(a)}`,"/api/agents",`/api/teams/skills?teamId=${encodeURIComponent(a)}`,"/api/skills/available"]),c=await Promise.all(b.map(a=>a.text()));return{responses:b,texts:c}}async function o(a,b){b.setTeamFilesLoading(!0),b.setCronLoading(!0),b.setTeamAgentsLoading(!0),b.setSkillsLoading(!0);try{let{responses:c,texts:d}=await n(a),[e,f,g,h,i]=c,[j,k,m,o,p]=d,q=l(j,{});e.ok&&q.ok&&Array.isArray(q.files)&&b.setTeamFiles(q.files.map(a=>({name:String(a.name??""),missing:!!a.missing,required:!!a.required,rationale:"string"==typeof a.rationale?a.rationale:void 0})));let r=l(k,{});f.ok&&r.ok&&Array.isArray(r.jobs)&&b.setCronJobs(r.jobs);let s=l(m,{});if(g.ok&&Array.isArray(s.agents)){let c=s.agents.filter(b=>String(b.id??"").startsWith(`${a}-`));b.setTeamAgents(c.map(a=>({id:String(a.id??""),identityName:"string"==typeof a.identityName?a.identityName:void 0})))}let t=l(o,{});h.ok&&t.ok&&Array.isArray(t.skills)&&b.setSkillsList(t.skills);let u=l(p,{});if(i.ok&&u.ok&&Array.isArray(u.skills)){let a=u.skills;b.setAvailableSkills(a),b.setSelectedSkill(b=>{let c=String(b??"").trim();return c&&a.includes(c)?c:a[0]??""})}}finally{b.setTeamFilesLoading(!1),b.setCronLoading(!1),b.setTeamAgentsLoading(!1),b.setSkillsLoading(!1)}}async function p(a,b){let c=await m(a);b.setRecipes(c.recipesData.recipes??[]);let d=null;try{let a=await c.metaRes.json(),e=a.meta;c.metaRes.ok&&a.ok&&e?.recipeId?(d={recipeId:String(e.recipeId),recipeName:"string"==typeof e.recipeName?e.recipeName:void 0},b.setTeamMetaRecipeHash("string"==typeof e.recipeHash?e.recipeHash:null)):b.setTeamMetaRecipeHash(null)}catch{b.setTeamMetaRecipeHash(null)}if(d)b.setLockedFromId(d.recipeId),b.setLockedFromName(d.recipeName??null),b.setProvenanceMissing(!1),b.setFromId(d.recipeId);else{b.setLockedFromId(null),b.setLockedFromName(null),b.setProvenanceMissing(!0);let d=c.recipesData.recipes??[],e=d.find(b=>"team"===b.kind&&b.id===a),f=d.find(a=>"team"===a.kind),g=e??f;g&&b.setFromId(g.id)}await o(a,{setTeamFiles:b.setTeamFiles,setCronJobs:b.setCronJobs,setTeamAgents:b.setTeamAgents,setSkillsList:b.setSkillsList,setAvailableSkills:b.setAvailableSkills,setSelectedSkill:b.setSelectedSkill,setTeamFilesLoading:b.setTeamFilesLoading,setCronLoading:b.setCronLoading,setTeamAgentsLoading:b.setTeamAgentsLoading,setSkillsLoading:b.setSkillsLoading})}async function q(a){try{let b=await (0,k.fetchJson)("/api/agents",{cache:"no-store"}),c=(Array.isArray(b.agents)?b.agents:[]).filter(b=>String(b.id??"").startsWith(`${a}-`)).map(a=>({id:String(a.id??""),identityName:"string"==typeof a.identityName?a.identityName:void 0}));return{ok:!0,agents:c}}catch{return{ok:!1,agents:[]}}}async function r(a,b,c){try{await (0,k.fetchJson)("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:b.trim(),teamId:a,applyConfig:!0,overwrite:!1,allowExisting:!0,cronInstallChoice:"no"})})}catch(a){c((0,j.errorMessage)(a),"error")}}async function s(a,b,c,d){let e=Date.now();for(;Date.now()-e<d;){try{let d=await q(a);if(d.ok){c(d.agents);let a=!!b&&d.agents.some(a=>a.id===b);if(!b||a)return!0}}catch{}await new Promise(a=>setTimeout(a,500))}return!1}async function t(a){let{teamId:b,toId:c,newRole:d,derivedRole:e,newRoleName:f,content:g,setContent:h,setTeamAgents:i,flashMessage:l,ensureCustomRecipeExists:m}=a;try{await m({overwrite:!1})}catch(b){let a=(0,j.errorMessage)(b);if(!/Recipe id already exists:/i.test(a))throw b}let n=await (0,k.fetchJson)("/api/recipes/team-agents",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("__custom__"===d?{recipeId:c.trim(),op:"add",role:e,name:f}:{recipeId:c.trim(),op:"addLike",baseRole:e,teamId:b,name:f})});if(!n.ok)throw Error("Failed updating agents list");h(String(n.content??g)),await r(b,c,l);let o="string"==typeof n.addedAgentId?n.addedAgentId:"";if(!await s(b,o,i,5e3)&&o){try{fetch("/api/gateway/restart",{method:"POST"})}catch{}await s(b,o,i,1e4)}l(`Updated agents list in ${c}`,"success")}function u(a){return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Custom recipe target"}),a.loading?(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"Loading team…"}):null]}),(0,b.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team id"}),(0,b.jsx)("input",{value:a.toId,onChange:b=>a.setToId(b.target.value),disabled:!a.canEditTargetId,className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70"}),(0,b.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:"This is the custom recipe id that will be created when you save."}),(0,b.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team name"}),(0,b.jsx)("input",{value:a.toName,onChange:b=>a.setToName(b.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2",children:[(0,b.jsx)("button",{type:"button",disabled:a.saving||!a.teamIdValid||!a.targetIdValid||a.targetIsBuiltin,onClick:()=>a.onSaveCustom(!0),className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:a.saving?"Saving":"Save"}),(0,b.jsx)("button",{type:"button",disabled:a.saving||!a.teamIdValid||!a.targetIdValid||a.targetIsBuiltin||!a.loadedRecipeHash||!a.teamMetaRecipeHash||a.loadedRecipeHash===a.teamMetaRecipeHash,onClick:a.onPublishOpen,className:"rounded-[var(--ck-radius-sm)] bg-emerald-600 px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:a.publishing?"Publishing":"Publish changes"}),(0,b.jsx)("button",{type:"button",disabled:a.saving,onClick:a.onDeleteOpen,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] disabled:opacity-50",children:"Delete Team"})]})]}),(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Notes"}),(0,b.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Parent recipe (locked)"}),(0,b.jsx)("select",{disabled:!0,className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70",value:a.fromId,onChange:b=>a.setFromId(b.target.value),children:a.teamRecipes.map(a=>(0,b.jsxs)("option",{value:a.id,children:[a.id," (",a.source,")"]},`${a.source}:${a.id}`))}),a.lockedFromId&&(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("code",{children:a.lockedFromId}),a.lockedFromName?` (${a.lockedFromName})`:""]}),!a.lockedFromId&&a.provenanceMissing&&(0,b.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Provenance not found for this team."})]}),(0,b.jsxs)("ul",{className:"mt-4 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("li",{children:"Save writes the custom recipe file identified by Team id."}),(0,b.jsx)("li",{children:"Publish changes re-scaffolds this team from your custom recipe."}),(0,b.jsx)("li",{children:"Delete Team runs openclaw recipes remove-team."})]})]})]}),(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recipe markdown"}),a.recipeLoadError?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:a.recipeLoadError}):null,(0,b.jsx)("textarea",{value:a.content,onChange:b=>{a.setContent(b.target.value),a.setLoadedRecipeHash(null)},className:"mt-2 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1})]})]})}function v(a){let{teamId:c,toId:d,recipeAgents:e,newRole:f,setNewRole:g,customRole:h,setCustomRole:i,newRoleName:j,setNewRoleName:k,derivedRole:l,saving:m,teamAgents:n,teamAgentsLoading:o,onAddAgent:p}=a;return(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Agents in this team"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Add/remove agents by updating the ",(0,b.jsx)("code",{children:"agents:"})," list in your custom team recipe (",(0,b.jsx)("code",{children:d}),")."]}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Role"}),(0,b.jsxs)("select",{value:f,onChange:a=>{let b=a.target.value;if(g(b),"__custom__"===b){i(""),k("");return}i("");let c=e.find(a=>a.role===b);k(c?.name||"")},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",children:[(0,b.jsx)("option",{value:"",children:"Select…"}),e.map(a=>(0,b.jsx)("option",{value:a.role,children:a.name||a.role},a.role)),(0,b.jsx)("option",{value:"__custom__",children:"Other…"})]}),"__custom__"===f?(0,b.jsx)("input",{value:h,onChange:a=>i(a.target.value),placeholder:"role (e.g. researcher)",className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}):null,(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["This writes to the recipe's ",(0,b.jsx)("code",{children:"agents:"})," list."]})]}),(0,b.jsx)("div",{className:"sm:col-span-2",children:(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Name (optional)"}),(0,b.jsx)("input",{value:j,onChange:a=>k(a.target.value),placeholder:"Onchain Researcher",className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"})]})})]}),(0,b.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:(0,b.jsx)("button",{disabled:m||!l,onClick:p,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:"Add agent"})}),(0,b.jsxs)("div",{className:"mt-6",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Detected installed team agents (read-only)"}),(0,b.jsxs)("ul",{className:"mt-2 space-y-2",children:[n.length?n.map(a=>(0,b.jsxs)("li",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:a.identityName||a.id}),(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:a.id})]}),(0,b.jsx)("a",{className:"text-sm font-medium text-[var(--ck-accent-red)] hover:text-[color:var(--ck-accent-red-hover)]",href:"/agents/"+encodeURIComponent(a.id)+"?returnTo="+encodeURIComponent("/teams/"+c+"?tab=agents"),children:"Edit"})]},a.id)):null,0===n.length&&!o&&(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No team agents detected."}),0===n.length&&o&&(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"})]})]})]})}function w(a){return(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Skills"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"Skills installed in this team workspace. For agent-specific skills, open the agent from the Agents tab."}),(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Installed"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:a.skillsList.length?a.skillsList.map(a=>(0,b.jsx)("li",{children:a},a)):(0,b.jsx)("li",{children:"None installed."})})]}),(0,b.jsxs)("div",{className:"mt-5 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15 p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Add a skill"}),(0,b.jsxs)("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,b.jsx)("select",{value:a.selectedSkill,onChange:b=>a.setSelectedSkill(b.target.value),disabled:a.installingSkill||a.skillsLoading||!a.availableSkills.length,className:"w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",children:a.availableSkills.length?a.availableSkills.map(a=>(0,b.jsx)("option",{value:a,children:a},a)):(0,b.jsx)("option",{value:"",children:"No skills found"})}),(0,b.jsx)("button",{type:"button",disabled:a.installingSkill||a.skillsLoading||!a.selectedSkill,onClick:a.onInstallSkill,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:a.installingSkill?"Adding":"Add"})]}),a.teamSkillError&&(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:a.teamSkillError}),a.teamSkillMsg&&(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 p-3 text-sm text-emerald-100",children:a.teamSkillMsg}),(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Uses openclaw recipes install-skill with team-id ",a.teamId,"."]})]})]})}function x(a){let{cronJobs:c,cronLoading:d,saving:e,onCronAction:f}=a;return(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Cron jobs (filtered by team name)"}),(0,b.jsxs)("ul",{className:"mt-3 space-y-3",children:[c.length?c.map(a=>{let c=String(a.id??a.jobId??"").trim(),d=c||String(a.name??"job"),g=String(a.name??a.id??a.jobId??"(unnamed)"),h=a.enabled??a.state?.enabled;return(0,b.jsxs)("li",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:g}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Enabled: ",String(h??"?")]}),(0,b.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,b.jsx)("button",{disabled:e||!c,onClick:()=>f(c,g,"run"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Run"}),(0,b.jsx)("button",{disabled:e||!c,onClick:()=>f(c,g,"enable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Enable"}),(0,b.jsx)("button",{disabled:e||!c,onClick:()=>f(c,g,"disable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Disable"}),c?null:(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"(missing id)"})]})]},d)}):null,0===c.length&&d&&(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading"}),0===c.length&&!d&&(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No cron jobs detected for this team."})]})]})}var y=a.i(60791);function z(a){let{teamFiles:c,teamFilesLoading:d,showOptionalFiles:e,setShowOptionalFiles:f,fileName:g,fileContent:h,setFileContent:i,teamFileError:j,saving:k,onLoadTeamFile:l,onSaveTeamFile:m}=a;return(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3",children:[(0,b.jsx)(y.FileListWithOptionalToggle,{title:"Team files",files:c,loading:d,showOptionalFiles:e,onShowOptionalChange:f,selectedFileName:g,onSelectFile:l}),(0,b.jsxs)("div",{className:"ck-glass-strong p-4 lg:col-span-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:["Edit: ",g]}),(0,b.jsx)("button",{disabled:k,onClick:m,className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:k?"Saving…":"Save file"})]}),j?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:j}):null,(0,b.jsx)("textarea",{value:h,onChange:a=>i(a.target.value),className:"mt-3 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1})]})]})}function A(a){return`${a._file??""}:${a._line??0}`}function B({teamId:a}){let[d,e]=(0,c.useState)(!1),[f,g]=(0,c.useState)(""),[h,i]=(0,c.useState)([]),[k,l]=(0,c.useState)([]),[m,n]=(0,c.useState)([]),[o,p]=(0,c.useState)("learning"),[q,r]=(0,c.useState)(""),[s,t]=(0,c.useState)(""),[u,v]=(0,c.useState)(!1),[w,x]=(0,c.useState)(null);async function y(){e(!0),g("");try{let b=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to load memory");i(Array.isArray(c.files)?c.files:[]),l(Array.isArray(c.pinnedItems)?c.pinnedItems:[]),n(Array.isArray(c.items)?c.items:[])}catch(a){g((0,j.errorMessage)(a)),i([]),l([]),n([])}finally{e(!1)}}(0,c.useEffect)(()=>{y()},[a]);let z=(0,c.useMemo)(()=>[{label:"decision",value:"decision"},{label:"learning",value:"learning"},{label:"bug",value:"bug"},{label:"customer",value:"customer"},{label:"release",value:"release"}],[]),B=(0,c.useMemo)(()=>new Set(k.map(a=>a._key)),[k]);async function C(b){let c=A(b);if(b._file&&b._line){x(c),g("");try{let c={op:"pin",ts:new Date().toISOString(),actor:`${a}-lead`,key:{file:"team.jsonl",line:b._line},item:{ts:b.ts,author:b.author,type:b.type,content:b.content,source:b.source}},d=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(c)}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to pin");await y()}catch(a){g((0,j.errorMessage)(a))}finally{x(null)}}}async function D(b){let c=A(b);if(b._file&&b._line){x(c),g("");try{let c={op:"unpin",ts:new Date().toISOString(),actor:`${a}-lead`,key:{file:"team.jsonl",line:b._line}},d=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(c)}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to unpin");await y()}catch(a){g((0,j.errorMessage)(a))}finally{x(null)}}}return(0,b.jsxs)("div",{className:"space-y-4",children:[(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Team memory (file-first)"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["Stored in ",(0,b.jsx)("span",{className:"font-mono",children:"shared-context/memory/*.jsonl"}),". Items must be attributable."]}),(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Canonical memory model doc:"," ",(0,b.jsx)("a",{className:"underline decoration-white/20 underline-offset-4 hover:decoration-white/40",href:"https://github.com/JIGGAI/ClawRecipes/blob/main/docs/MEMORY_MODEL.md",target:"_blank",rel:"noreferrer",children:"ClawRecipes/docs/MEMORY_MODEL.md"})]})]}),(0,b.jsx)("button",{type:"button",onClick:y,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Refresh"})]}),f?(0,b.jsx)("div",{className:"mt-3 rounded border border-red-400/30 bg-red-500/10 p-2 text-sm text-red-100",children:f}):null,(0,b.jsxs)("div",{className:"mt-3 text-xs text-[color:var(--ck-text-secondary)]",children:["Files: ",h.length?h.join(", "):"(none)"]})]}),(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Add memory item"}),(0,b.jsxs)("div",{className:"mt-3 grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,b.jsx)("select",{value:o,onChange:a=>p(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-2 text-sm text-[color:var(--ck-text-primary)]",children:z.map(a=>(0,b.jsx)("option",{value:a.value,children:a.label},a.value))})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"source (ticket/pr/path)"}),(0,b.jsx)("input",{value:s,onChange:a=>t(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-2 text-sm text-[color:var(--ck-text-primary)]",placeholder:"e.g. ticket 0088, PR https://..., shared-context/DECISIONS.md"})]}),(0,b.jsxs)("label",{className:"block md:col-span-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"content"}),(0,b.jsx)("textarea",{value:q,onChange:a=>r(a.target.value),className:"mt-1 h-[110px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-sm text-[color:var(--ck-text-primary)]",placeholder:"Write a small, specific memory item…"})]}),(0,b.jsx)("div",{className:"md:col-span-2",children:(0,b.jsx)("button",{type:"button",disabled:u||!q.trim(),onClick:async()=>{v(!0),g("");try{let b={op:"append",ts:new Date().toISOString(),author:`${a}-lead`,type:o,content:q.trim(),source:s.trim()?{text:s.trim()}:void 0,file:"team.jsonl"},c=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(a)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(b)}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to append memory");r(""),t(""),await y()}catch(a){g((0,j.errorMessage)(a))}finally{v(!1)}},className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] disabled:opacity-50",children:u?"Saving…":"Append to team.jsonl"})})]})]}),(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Pinned memory"}),(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[k.length," pinned"]})]}),d?(0,b.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,(0,b.jsx)("div",{className:"mt-3 space-y-3",children:k.length?k.map(a=>(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.ts}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsx)("span",{className:"rounded bg-white/5 px-2 py-0.5 font-mono",children:a.type}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsx)("span",{className:"font-mono",children:a.author}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsxs)("span",{className:"font-mono",children:["pinned ",a.pinnedAt]})]}),(0,b.jsx)("button",{type:"button",onClick:()=>void D(a),disabled:w===a._key,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:w===a._key?"Unpinning…":"Unpin"})]}),(0,b.jsx)("div",{className:"mt-2 whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:a.content}),a.source?(0,b.jsx)("pre",{className:"mt-2 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(a.source,null,2)}):null]},a._key)):(0,b.jsx)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No pinned items yet."})})]}),(0,b.jsxs)("div",{className:"ck-glass p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recent memory"}),(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Showing ",m.length," (max 200)"]})]}),d?(0,b.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,(0,b.jsx)("div",{className:"mt-3 space-y-3",children:m.length?m.map(a=>{let c=A(a),d=B.has(c);return(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.ts}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsx)("span",{className:"rounded bg-white/5 px-2 py-0.5 font-mono",children:a.type}),(0,b.jsx)("span",{className:"mx-2",children:"•"}),(0,b.jsx)("span",{className:"font-mono",children:a.author})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[a._file?(0,b.jsxs)("span",{className:"text-[10px] text-[color:var(--ck-text-tertiary)] font-mono",children:[a._file,":",a._line]}):null,(0,b.jsx)("button",{type:"button",onClick:()=>void C(a),disabled:d||w===c||!a._file||!a._line,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:d?"Pinned":w===c?"Pinning…":"Pin"})]})]}),(0,b.jsx)("div",{className:"mt-2 whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:a.content}),a.source?(0,b.jsx)("pre",{className:"mt-2 overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(a.source,null,2)}):null]},`${a._file??"?"}:${a._line??0}`)}):(0,b.jsx)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No memory items yet."})})]})]})}var C=a.i(35112);function D({open:a,onClose:d,teamId:e,onInstalled:f}){let g=(0,c.useMemo)(()=>`${e}-swarm-orchestrator`,[e]),[h,i]=(0,c.useState)(g),[j,l]=(0,c.useState)(""),[m,n]=(0,c.useState)("/home/control/swarm-worktrees"),[o,p]=(0,c.useState)("origin/main"),[q,r]=(0,c.useState)(!0),[s,t]=(0,c.useState)(!0),[u,v]=(0,c.useState)(!1),[w,x]=(0,c.useState)(null),[y,z]=(0,c.useState)(null),A=(0,c.useMemo)(()=>({effectiveAgentId:String(h??"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/--+/g,"-")}),[h]);return a?(0,C.createPortal)((0,b.jsxs)("div",{className:"fixed inset-0 z-[210]",children:[(0,b.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:()=>{u||d()}}),(0,b.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,b.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,b.jsxs)("div",{className:"w-full max-w-xl rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,b.jsx)("div",{className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:"Add Orchestrator"}),(0,b.jsxs)("p",{className:"mt-1 text-sm text-[color:var(--ck-text-secondary)]",children:["This will scaffold a new ",(0,b.jsx)("span",{className:"font-mono text-xs",children:"swarm-orchestrator"})," agent workspace for this team and prefill its config."]}),(0,b.jsx)("label",{className:"mt-4 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Orchestrator agent id"}),(0,b.jsx)("input",{value:h,onChange:a=>i(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["Default: ",(0,b.jsx)("span",{className:"font-mono",children:g})," (normalized: ",(0,b.jsx)("span",{className:"font-mono",children:A.effectiveAgentId}),")"]}),(0,b.jsx)("label",{className:"mt-4 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Repo directory (SWARM_REPO_DIR)"}),(0,b.jsx)("input",{value:j,onChange:a=>l(a.target.value),placeholder:"/home/control/clawkitchen",className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Worktree root (SWARM_WORKTREE_ROOT)"}),(0,b.jsx)("input",{value:m,onChange:a=>n(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:"Recommend a dedicated folder outside the repo."})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Base ref (SWARM_BASE_REF)"}),(0,b.jsx)("input",{value:o,onChange:a=>p(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"})]})]}),(0,b.jsxs)("label",{className:"mt-5 flex items-start gap-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("input",{type:"checkbox",checked:q,onChange:a=>r(a.target.checked),className:"mt-1"}),(0,b.jsxs)("span",{children:["Add this agent to OpenClaw config (recommended).",(0,b.jsx)("br",{}),(0,b.jsxs)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["This will modify ",(0,b.jsx)("span",{className:"font-mono",children:"~/.openclaw/openclaw.json"})," to add ",(0,b.jsx)("span",{className:"font-mono",children:A.effectiveAgentId}),"."]})]})]}),(0,b.jsxs)("label",{className:"mt-3 flex items-start gap-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("input",{type:"checkbox",checked:s,onChange:a=>t(a.target.checked),className:"mt-1"}),(0,b.jsxs)("span",{children:["Make scripts executable (developer convenience).",(0,b.jsx)("br",{}),(0,b.jsxs)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Runs ",(0,b.jsx)("span",{className:"font-mono",children:"chmod +x .clawdbot/*.sh"})," in the orchestrator workspace."]})]})]}),w?(0,b.jsx)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:w}):null,y?(0,b.jsxs)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 p-3 text-sm text-emerald-100",children:["Installed ",(0,b.jsx)("span",{className:"font-mono",children:y.orchestratorAgentId})," → ",(0,b.jsx)("span",{className:"font-mono",children:y.workspace})]}):null,(0,b.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:d,disabled:u,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Cancel"}),(0,b.jsx)("button",{type:"button",disabled:u||!A.effectiveAgentId||!j.trim(),onClick:async()=>{v(!0),x(null),z(null);try{let a=await (0,k.fetchJson)("/api/teams/orchestrator/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,orchestratorAgentId:A.effectiveAgentId,repoDir:j.trim(),worktreeRoot:m.trim(),baseRef:o.trim(),applyConfig:q,makeExecutable:s})});if(!a.ok)throw Error(a.error);z({orchestratorAgentId:a.orchestratorAgentId,workspace:a.workspace}),f()}catch(a){x(a instanceof Error?a.message:String(a))}finally{v(!1)}},className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-[var(--ck-accent-red-hover)] disabled:opacity-50",children:u?"Installing…":"Install"})]})]})})})]}),document.body):null}function E({teamId:a}){let[d,e]=(0,c.useState)(!0),[f,g]=(0,c.useState)(null),[h,i]=(0,c.useState)(null),[j,l]=(0,c.useState)(!1),m=(0,c.useCallback)(async()=>{e(!0);try{let b=await (0,k.fetchJson)(`/api/teams/orchestrator?teamId=${encodeURIComponent(a)}`,{cache:"no-store"});g(b),i(new Date().toISOString())}catch(a){g({ok:!1,error:a instanceof Error?a.message:String(a)}),i(new Date().toISOString())}finally{e(!1)}},[a]);return((0,c.useEffect)(()=>{m()},[m]),d)?(0,b.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"Loading orchestrator state…"}):f?f.ok?f.present?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Agent: ",(0,b.jsx)("span",{className:"font-mono",children:f.agent.id}),f.agent.identityName?` (${f.agent.identityName})`:""]}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Workspace: ",(0,b.jsx)("span",{className:"font-mono",children:f.agent.workspace})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:h?(0,b.jsxs)("span",{children:["Last updated: ",(0,b.jsx)("span",{className:"font-mono",children:h})]}):null}),(0,b.jsx)("button",{type:"button",onClick:()=>void m(),disabled:d,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] transition-colors hover:bg-white/10 active:bg-white/15 disabled:opacity-50",children:d?"Refreshing…":"Refresh"})]})]}),(0,b.jsxs)("div",{className:"mt-5 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,b.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"tmux sessions"}),f.tmuxSessions.length?(0,b.jsx)("ul",{className:"mt-2 space-y-2",children:f.tmuxSessions.map(a=>(0,b.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.name}),(0,b.jsxs)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["attached=",String(a.attached),"number"==typeof a.windows?` windows=${a.windows}`:""]})]},a.name))}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No sessions detected (or tmux not running)."})]}),(0,b.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"git worktrees"}),f.worktrees.length?(0,b.jsx)("ul",{className:"mt-2 space-y-2",children:f.worktrees.map(a=>(0,b.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"font-mono text-xs",children:a.path}),(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[a.branch?a.branch:"(no branch)",a.sha?` @ ${a.sha.slice(0,7)}`:""]})]},a.path))}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No worktrees detected."})]})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Active tasks"}),f.activeTasksSummary?(0,b.jsxs)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"font-mono text-xs",children:f.activeTasksSummary.path}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["number"==typeof f.activeTasksSummary.taskCount?`tasks=${f.activeTasksSummary.taskCount}`:"tasks=?",f.activeTasksSummary.rawType?` type=${f.activeTasksSummary.rawType}`:""]})]}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No active-tasks.json found."})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"CLI quick actions"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"The orchestrator is designed to be driven from the CLI (and usually tmux). Common commands:"}),(0,b.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-mono text-xs",children:"tmux ls"}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(list sessions)"})]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-mono text-xs",children:"tmux attach -t <session>"}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(jump into a running swarm)"})]}),(0,b.jsxs)("li",{children:[(0,b.jsxs)("span",{className:"font-mono text-xs",children:["git -C ",f.agent.workspace," worktree list"]}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(inspect worktrees)"})]})]}),(0,b.jsx)("p",{className:"mt-3 text-xs text-[color:var(--ck-text-tertiary)]",children:"Note: ClawKitchen is read-only here; it surfaces status and pointers, but does not run or attach to tmux."})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Human approval gate (recommended)"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["For workflows that publish, deploy, or send outbound messages, keep a ",(0,b.jsx)("strong",{children:"human approval step"}),"."]}),(0,b.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("li",{children:"Generate a proposed change/post as a draft."}),(0,b.jsx)("li",{children:"Send the draft to a bound messaging channel (e.g. Telegram) for approval."}),(0,b.jsx)("li",{children:"Only execute the final action after explicit approve/deny."})]})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Where to change settings"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"These are the common knobs for a swarm/orchestrator scaffold (read-only references):"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:f.settingsPaths.map(a=>(0,b.jsx)("li",{className:"font-mono text-xs",children:a},a))})]})]}):(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No swarm/orchestrator detected for this team."})]}),(0,b.jsx)("button",{type:"button",onClick:()=>l(!0),className:"rounded-[var(--ck-radius-sm)] bg-[var(--ck-accent-red)] px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] hover:bg-[var(--ck-accent-red-hover)]",children:"Add Orchestrator"})]}),(0,b.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Detection"}),(0,b.jsx)("div",{className:"mt-1 font-mono text-xs",children:f.reason||"(no reason provided)"})]}),(0,b.jsxs)("p",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:["Default convention is ",(0,b.jsx)("code",{children:"<teamId>-swarm-orchestrator"}),". Once installed, this tab will show: tmux sessions, git worktrees/branches, and active task state."]}),(0,b.jsx)(D,{open:j,onClose:()=>l(!1),teamId:a,onInstalled:()=>{l(!1),m()}})]}):(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:f.error})]}):(0,b.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"No orchestrator state available."})}var F=a.i(83856);let G=[{id:"recipe",label:"Recipe"},{id:"agents",label:"Agents"},{id:"skills",label:"Skills"},{id:"cron",label:"Cron"},{id:"files",label:"Files"},{id:"orchestrator",label:"Orchestrator"}],H=[{id:"memory",label:"Memory"},{id:"workflows",label:"Workflows"}];function I({teamId:a,initialTab:g}){let l=(0,e.useRouter)(),[m,n]=(0,c.useState)([]),[o,q]=(0,c.useState)(""),[r,s]=(0,c.useState)(null),[y,A]=(0,c.useState)(null),[C,D]=(0,c.useState)(!1),[I,J]=(0,c.useState)(a),[K,L]=(0,c.useState)(a),[M,N]=(0,c.useState)(""),[O,P]=(0,c.useState)(null),[Q,R]=(0,c.useState)(()=>["recipe","agents","skills","cron","files","memory","orchestrator","workflows"].includes(g)?g:"recipe"),S=(0,c.useMemo)(()=>[...G,...H],[]),[T,U]=(0,c.useState)(!0),[V,W]=(0,c.useState)(!1),[X,Y]=(0,c.useState)(!1),[Z,$]=(0,c.useState)(!1),[_,aa]=(0,c.useState)(!1),[ab,ac]=(0,c.useState)(""),ad=(0,i.useToast)(),[ae,af]=(0,c.useState)(!1),[ag,ah]=(0,c.useState)(!1),[ai,aj]=(0,c.useState)(null);function ak(a,b="info"){let c=String(a??"").trim();c&&ad.push({kind:b,message:c})}let[al,am]=(0,c.useState)([]),[an,ao]=(0,c.useState)(!1),[ap,aq]=(0,c.useState)(""),[ar,as]=(0,c.useState)(!1),[at,au]=(0,c.useState)("SOUL.md"),[av,aw]=(0,c.useState)(""),[ax,ay]=(0,c.useState)([]),[az,aA]=(0,c.useState)(!1),[aB,aC]=(0,c.useState)([]),[aD,aE]=(0,c.useState)(!1),aF=(0,c.useMemo)(()=>{let a=String(M??"");if(!a.startsWith("---\n"))return[];let b=a.indexOf("\n---\n",4);if(-1===b)return[];let c=a.slice(4,b+1);try{let a=(0,d.parse)(c)??{};return(Array.isArray(a.agents)?a.agents:[]).map(a=>a).map(a=>({role:String(a.role??"").trim(),name:"string"==typeof a.name?a.name:void 0})).filter(a=>!!a.role)}catch{return[]}},[M]),[aG,aH]=(0,c.useState)(""),[aI,aJ]=(0,c.useState)(""),[aK,aL]=(0,c.useState)(""),aM=(0,c.useMemo)(()=>("__custom__"===aG?aI:aG).trim()||"",[aG,aI]),[aN,aO]=(0,c.useState)([]),[aP,aQ]=(0,c.useState)([]),[aR,aS]=(0,c.useState)(!1),[aT,aU]=(0,c.useState)(""),[aV,aW]=(0,c.useState)(!1),[aX,aY]=(0,c.useState)(""),[aZ,a$]=(0,c.useState)(""),a_=(0,c.useMemo)(()=>m.filter(a=>"team"===a.kind),[m]),a0=(0,c.useMemo)(()=>m.find(a=>a.id===I&&"workspace"===a.source)??m.find(a=>a.id===I)??null,[m,I]),a1=!!a.trim(),a2=!!I.trim(),a3=m.some(a=>a.id===I&&"workspace"===a.source),a4=!!(a0?.source==="builtin"&&!a3);async function a5(){let a=I.trim();if(a){aa(!0),ac("");try{let b=await (0,k.fetchJson)(`/api/recipes/${encodeURIComponent(a)}`,{cache:"no-store"}),c=b.recipe;N(c.content),P("string"==typeof b.recipeHash?b.recipeHash:null)}catch(a){ac((0,j.errorMessage)(a))}finally{aa(!1)}}}async function a6(a){let b=o.trim(),c=String(a.toId??I).trim(),d=String(a.toName??K).trim(),e=!!a.overwrite,f=!!a.scaffold;if(!b)throw Error("Source recipe id is required");if(!c)throw Error("Custom recipe id is required");return await (0,k.fetchJson)("/api/recipes/clone",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:b,toId:c,toName:d||void 0,overwrite:e,scaffold:f})})}async function a7(a,b){W(!0),ak("");try{let c=await a6({overwrite:a,...b});if(c.scaffold&&!c.scaffold.ok&&ak(`Scaffold failed (recipe was still cloned): ${c.scaffold.error||"Unknown error"}`,"error"),M.trim()&&M.trim()!==c.content.trim()){let a=function(a,b){if(!a.startsWith("---\n"))return a;let c=a.indexOf("\n---\n",4);if(-1===c)return a;let d=a.slice(4,c),e=a.slice(c+5),{next:f,sawTeamBlock:g,patched:h}=function(a,b){let c=[],d=!1,e=!1,f=!1;for(let g of a){if(/^team\s*:\s*$/i.test(g)){d=!0,e=!0,c.push(g);continue}if(d&&/^\S/.test(g)&&(d=!1),d&&/^\s+teamId\s*:/i.test(g)){c.push(` teamId: ${b}`),f=!0;continue}c.push(g)}return{next:c,sawTeamBlock:e,patched:f}}(d.split("\n"),b);if(g&&!h){let a=[];for(let c of f)a.push(c),/^team\s*:\s*$/i.test(c)&&a.push(` teamId: ${b}`);return`---
|
|
2
2
|
${a.join("\n")}
|
|
3
3
|
---
|
|
4
4
|
${e}`}return`---
|