@jiggai/kitchen 0.3.14 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +2 -2
  3. package/.next/server/app/_global-error.html +2 -2
  4. package/.next/server/app/_global-error.rsc +1 -1
  5. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  6. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  10. package/.next/server/app/_not-found.html +1 -1
  11. package/.next/server/app/_not-found.rsc +2 -2
  12. package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  13. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  14. package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  15. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  16. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  17. package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  18. package/.next/server/app/channels.html +2 -2
  19. package/.next/server/app/channels.rsc +2 -2
  20. package/.next/server/app/channels.segments/_full.segment.rsc +2 -2
  21. package/.next/server/app/channels.segments/_head.segment.rsc +1 -1
  22. package/.next/server/app/channels.segments/_index.segment.rsc +1 -1
  23. package/.next/server/app/channels.segments/_tree.segment.rsc +1 -1
  24. package/.next/server/app/channels.segments/channels/__PAGE__.segment.rsc +1 -1
  25. package/.next/server/app/channels.segments/channels.segment.rsc +1 -1
  26. package/.next/server/app/goals/new.html +2 -2
  27. package/.next/server/app/goals/new.rsc +2 -2
  28. package/.next/server/app/goals/new.segments/_full.segment.rsc +2 -2
  29. package/.next/server/app/goals/new.segments/_head.segment.rsc +1 -1
  30. package/.next/server/app/goals/new.segments/_index.segment.rsc +1 -1
  31. package/.next/server/app/goals/new.segments/_tree.segment.rsc +1 -1
  32. package/.next/server/app/goals/new.segments/goals/new/__PAGE__.segment.rsc +1 -1
  33. package/.next/server/app/goals/new.segments/goals/new.segment.rsc +1 -1
  34. package/.next/server/app/goals/new.segments/goals.segment.rsc +1 -1
  35. package/.next/server/app/goals.html +1 -1
  36. package/.next/server/app/goals.rsc +2 -2
  37. package/.next/server/app/goals.segments/_full.segment.rsc +2 -2
  38. package/.next/server/app/goals.segments/_head.segment.rsc +1 -1
  39. package/.next/server/app/goals.segments/_index.segment.rsc +1 -1
  40. package/.next/server/app/goals.segments/_tree.segment.rsc +1 -1
  41. package/.next/server/app/goals.segments/goals/__PAGE__.segment.rsc +1 -1
  42. package/.next/server/app/goals.segments/goals.segment.rsc +1 -1
  43. package/.next/server/app/settings.html +1 -1
  44. package/.next/server/app/settings.rsc +2 -2
  45. package/.next/server/app/settings.segments/_full.segment.rsc +2 -2
  46. package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  47. package/.next/server/app/settings.segments/_index.segment.rsc +1 -1
  48. package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
  49. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
  50. package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  51. package/.next/server/app/teams/[teamId]/page_client-reference-manifest.js +1 -1
  52. package/.next/server/app/teams/[teamId]/tickets/[ticket]/page_client-reference-manifest.js +1 -1
  53. package/.next/server/app/teams/[teamId]/tickets/page_client-reference-manifest.js +1 -1
  54. package/.next/server/app/tickets/[ticket]/page_client-reference-manifest.js +1 -1
  55. package/.next/server/app/tickets/page_client-reference-manifest.js +1 -1
  56. package/.next/server/chunks/[root-of-the-server]__05f5e243._.js +1 -1
  57. package/.next/server/chunks/[root-of-the-server]__05f5e243._.js.map +1 -1
  58. package/.next/server/chunks/[root-of-the-server]__47eb3111._.js +1 -1
  59. package/.next/server/chunks/[root-of-the-server]__47eb3111._.js.map +1 -1
  60. package/.next/server/chunks/[root-of-the-server]__502825d0._.js +9 -3
  61. package/.next/server/chunks/[root-of-the-server]__502825d0._.js.map +1 -1
  62. package/.next/server/chunks/[root-of-the-server]__542a081b._.js +1 -1
  63. package/.next/server/chunks/[root-of-the-server]__542a081b._.js.map +1 -1
  64. package/.next/server/chunks/[root-of-the-server]__5ceff0f3._.js +3 -3
  65. package/.next/server/chunks/[root-of-the-server]__5ceff0f3._.js.map +1 -1
  66. package/.next/server/chunks/[root-of-the-server]__5ea38a67._.js +1 -1
  67. package/.next/server/chunks/[root-of-the-server]__5ea38a67._.js.map +1 -1
  68. package/.next/server/chunks/[root-of-the-server]__b002764e._.js +1 -1
  69. package/.next/server/chunks/[root-of-the-server]__b002764e._.js.map +1 -1
  70. package/.next/server/chunks/[root-of-the-server]__d924e5ac._.js +1 -1
  71. package/.next/server/chunks/[root-of-the-server]__d924e5ac._.js.map +1 -1
  72. package/.next/server/chunks/[root-of-the-server]__e063a986._.js +1 -1
  73. package/.next/server/chunks/[root-of-the-server]__e063a986._.js.map +1 -1
  74. package/.next/server/chunks/[root-of-the-server]__ff69832c._.js +2 -2
  75. package/.next/server/chunks/[root-of-the-server]__ff69832c._.js.map +1 -1
  76. package/.next/server/chunks/ssr/[root-of-the-server]__17b046ea._.js +1 -1
  77. package/.next/server/chunks/ssr/[root-of-the-server]__17b046ea._.js.map +1 -1
  78. package/.next/server/chunks/ssr/[root-of-the-server]__3b880807._.js +1 -1
  79. package/.next/server/chunks/ssr/[root-of-the-server]__3b880807._.js.map +1 -1
  80. package/.next/server/chunks/ssr/[root-of-the-server]__49281b4c._.js +1 -1
  81. package/.next/server/chunks/ssr/[root-of-the-server]__49281b4c._.js.map +1 -1
  82. package/.next/server/chunks/ssr/[root-of-the-server]__9a7d79aa._.js +1 -1
  83. package/.next/server/chunks/ssr/[root-of-the-server]__9a7d79aa._.js.map +1 -1
  84. package/.next/server/chunks/ssr/[root-of-the-server]__c777e326._.js +1 -1
  85. package/.next/server/chunks/ssr/[root-of-the-server]__c777e326._.js.map +1 -1
  86. package/.next/server/chunks/ssr/src_59477309._.js +1 -1
  87. package/.next/server/chunks/ssr/src_59477309._.js.map +1 -1
  88. package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_index_tsx_e68e9cbc._.js +1 -1
  89. package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_index_tsx_e68e9cbc._.js.map +1 -1
  90. package/.next/server/chunks/ssr/src_app_tickets_TicketsBoardClient_tsx_5e156ef3._.js +1 -1
  91. package/.next/server/chunks/ssr/src_app_tickets_TicketsBoardClient_tsx_5e156ef3._.js.map +1 -1
  92. package/.next/server/pages/404.html +1 -1
  93. package/.next/server/pages/500.html +2 -2
  94. package/.next/static/chunks/4a6dcf80b293d7a4.js +1 -0
  95. package/.next/static/chunks/{5f77499ca309ab9d.js → a719c5f36ffeec2a.js} +1 -1
  96. package/.next/static/chunks/{febbbb81927c8042.js → e083bcf4a197beae.js} +1 -1
  97. package/openclaw.plugin.json +1 -1
  98. package/package.json +1 -1
  99. package/.next/static/chunks/be12a66bd736fad8.js +0 -1
  100. /package/.next/static/{cp-U4VbwzSh2raGh9eqcl → iyJZclE058TbSPEFRavWV}/_buildManifest.js +0 -0
  101. /package/.next/static/{cp-U4VbwzSh2raGh9eqcl → iyJZclE058TbSPEFRavWV}/_clientMiddlewareManifest.json +0 -0
  102. /package/.next/static/{cp-U4VbwzSh2raGh9eqcl → iyJZclE058TbSPEFRavWV}/_ssgManifest.js +0 -0
@@ -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.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`---
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)(`~/swarm-worktrees/${e}`),[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:"~/my-project",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`---