@jiggai/kitchen 0.3.9 → 0.3.11

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 (200) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +2 -2
  3. package/.next/prerender-manifest.json +3 -3
  4. package/.next/server/app/_global-error.html +2 -2
  5. package/.next/server/app/_global-error.rsc +1 -1
  6. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/server/app/_not-found.html +1 -1
  13. package/.next/server/app/_not-found.rsc +3 -3
  14. package/.next/server/app/_not-found.segments/_full.segment.rsc +3 -3
  15. package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
  17. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/.next/server/app/agents/[agentId]/page_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/goals/[id]/promote/route.js.nft.json +1 -1
  22. package/.next/server/app/api/goals/[id]/route.js.nft.json +1 -1
  23. package/.next/server/app/api/goals/route.js.nft.json +1 -1
  24. package/.next/server/app/api/recipes/[id]/route.js.nft.json +1 -1
  25. package/.next/server/app/api/recipes/clone/route.js.nft.json +1 -1
  26. package/.next/server/app/api/recipes/custom-team/route.js.nft.json +1 -1
  27. package/.next/server/app/api/recipes/delete/route.js.nft.json +1 -1
  28. package/.next/server/app/api/recipes/team-agents/route.js.nft.json +1 -1
  29. package/.next/server/app/api/scaffold/route.js.nft.json +1 -1
  30. package/.next/server/app/api/teams/[teamId]/tickets/assign/route.js.nft.json +1 -1
  31. package/.next/server/app/api/teams/[teamId]/tickets/comment/route.js.nft.json +1 -1
  32. package/.next/server/app/api/teams/[teamId]/tickets/delete/route.js.nft.json +1 -1
  33. package/.next/server/app/api/teams/[teamId]/tickets/move/route.js.nft.json +1 -1
  34. package/.next/server/app/api/teams/[teamId]/tickets/move-to-goals/route.js.nft.json +1 -1
  35. package/.next/server/app/api/teams/orchestrator/route.js.nft.json +1 -1
  36. package/.next/server/app/api/teams/remove-team/route.js.nft.json +1 -1
  37. package/.next/server/app/api/tickets/assign/route.js.nft.json +1 -1
  38. package/.next/server/app/api/tickets/assignees/route.js.nft.json +1 -1
  39. package/.next/server/app/api/tickets/move/route.js.nft.json +1 -1
  40. package/.next/server/app/channels/page_client-reference-manifest.js +1 -1
  41. package/.next/server/app/channels.html +2 -2
  42. package/.next/server/app/channels.rsc +4 -4
  43. package/.next/server/app/channels.segments/_full.segment.rsc +4 -4
  44. package/.next/server/app/channels.segments/_head.segment.rsc +1 -1
  45. package/.next/server/app/channels.segments/_index.segment.rsc +3 -3
  46. package/.next/server/app/channels.segments/_tree.segment.rsc +2 -2
  47. package/.next/server/app/channels.segments/channels/__PAGE__.segment.rsc +2 -2
  48. package/.next/server/app/channels.segments/channels.segment.rsc +1 -1
  49. package/.next/server/app/cron-jobs/page_client-reference-manifest.js +1 -1
  50. package/.next/server/app/goals/[id]/page_client-reference-manifest.js +1 -1
  51. package/.next/server/app/goals/new/page_client-reference-manifest.js +1 -1
  52. package/.next/server/app/goals/new.html +2 -2
  53. package/.next/server/app/goals/new.rsc +4 -4
  54. package/.next/server/app/goals/new.segments/_full.segment.rsc +4 -4
  55. package/.next/server/app/goals/new.segments/_head.segment.rsc +1 -1
  56. package/.next/server/app/goals/new.segments/_index.segment.rsc +3 -3
  57. package/.next/server/app/goals/new.segments/_tree.segment.rsc +2 -2
  58. package/.next/server/app/goals/new.segments/goals/new/__PAGE__.segment.rsc +2 -2
  59. package/.next/server/app/goals/new.segments/goals/new.segment.rsc +1 -1
  60. package/.next/server/app/goals/new.segments/goals.segment.rsc +1 -1
  61. package/.next/server/app/goals/page_client-reference-manifest.js +1 -1
  62. package/.next/server/app/goals.html +1 -1
  63. package/.next/server/app/goals.rsc +4 -4
  64. package/.next/server/app/goals.segments/_full.segment.rsc +4 -4
  65. package/.next/server/app/goals.segments/_head.segment.rsc +1 -1
  66. package/.next/server/app/goals.segments/_index.segment.rsc +3 -3
  67. package/.next/server/app/goals.segments/_tree.segment.rsc +2 -2
  68. package/.next/server/app/goals.segments/goals/__PAGE__.segment.rsc +2 -2
  69. package/.next/server/app/goals.segments/goals.segment.rsc +1 -1
  70. package/.next/server/app/page.js +2 -2
  71. package/.next/server/app/page.js.nft.json +1 -1
  72. package/.next/server/app/page_client-reference-manifest.js +1 -1
  73. package/.next/server/app/recipes/[id]/page.js +3 -3
  74. package/.next/server/app/recipes/[id]/page.js.nft.json +1 -1
  75. package/.next/server/app/recipes/[id]/page_client-reference-manifest.js +1 -1
  76. package/.next/server/app/recipes/page.js +2 -2
  77. package/.next/server/app/recipes/page.js.nft.json +1 -1
  78. package/.next/server/app/recipes/page_client-reference-manifest.js +1 -1
  79. package/.next/server/app/runs/page.js +3 -3
  80. package/.next/server/app/runs/page.js.nft.json +1 -1
  81. package/.next/server/app/runs/page_client-reference-manifest.js +1 -1
  82. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  83. package/.next/server/app/settings.html +1 -1
  84. package/.next/server/app/settings.rsc +4 -4
  85. package/.next/server/app/settings.segments/_full.segment.rsc +4 -4
  86. package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  87. package/.next/server/app/settings.segments/_index.segment.rsc +3 -3
  88. package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  89. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  90. package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  91. package/.next/server/app/teams/[teamId]/page.js +3 -3
  92. package/.next/server/app/teams/[teamId]/page.js.nft.json +1 -1
  93. package/.next/server/app/teams/[teamId]/page_client-reference-manifest.js +1 -1
  94. package/.next/server/app/teams/[teamId]/runs/[workflowId]/[runId]/page.js +2 -2
  95. package/.next/server/app/teams/[teamId]/runs/[workflowId]/[runId]/page.js.nft.json +1 -1
  96. package/.next/server/app/teams/[teamId]/runs/[workflowId]/[runId]/page_client-reference-manifest.js +1 -1
  97. package/.next/server/app/teams/[teamId]/runs/page_client-reference-manifest.js +1 -1
  98. package/.next/server/app/teams/[teamId]/tickets/[ticket]/page.js.nft.json +1 -1
  99. package/.next/server/app/teams/[teamId]/tickets/[ticket]/page_client-reference-manifest.js +1 -1
  100. package/.next/server/app/teams/[teamId]/tickets/page.js.nft.json +1 -1
  101. package/.next/server/app/teams/[teamId]/tickets/page_client-reference-manifest.js +1 -1
  102. package/.next/server/app/teams/[teamId]/workflows/[workflowId]/page.js +3 -3
  103. package/.next/server/app/teams/[teamId]/workflows/[workflowId]/page.js.nft.json +1 -1
  104. package/.next/server/app/teams/[teamId]/workflows/[workflowId]/page_client-reference-manifest.js +1 -1
  105. package/.next/server/app/teams/[teamId]/workflows/page.js +3 -3
  106. package/.next/server/app/teams/[teamId]/workflows/page.js.nft.json +1 -1
  107. package/.next/server/app/teams/[teamId]/workflows/page_client-reference-manifest.js +1 -1
  108. package/.next/server/app/tickets/[ticket]/page.js.nft.json +1 -1
  109. package/.next/server/app/tickets/[ticket]/page_client-reference-manifest.js +1 -1
  110. package/.next/server/app/tickets/page.js.nft.json +1 -1
  111. package/.next/server/app/tickets/page_client-reference-manifest.js +1 -1
  112. package/.next/server/chunks/[root-of-the-server]__ff69832c._.js.map +1 -1
  113. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_1fe98a49.js +1 -1
  114. package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_1fe98a49.js.map +1 -1
  115. package/.next/server/chunks/ssr/[root-of-the-server]__24c20736._.js +3 -0
  116. package/.next/server/chunks/ssr/[root-of-the-server]__24c20736._.js.map +1 -0
  117. package/.next/server/chunks/ssr/[root-of-the-server]__30619465._.js +3 -0
  118. package/.next/server/chunks/ssr/[root-of-the-server]__30619465._.js.map +1 -0
  119. package/.next/server/chunks/ssr/[root-of-the-server]__471bc2e7._.js +1 -1
  120. package/.next/server/chunks/ssr/[root-of-the-server]__471bc2e7._.js.map +1 -1
  121. package/.next/server/chunks/ssr/[root-of-the-server]__49281b4c._.js +1 -1
  122. package/.next/server/chunks/ssr/[root-of-the-server]__49281b4c._.js.map +1 -1
  123. package/.next/server/chunks/ssr/[root-of-the-server]__4981f370._.js +3 -0
  124. package/.next/server/chunks/ssr/[root-of-the-server]__4981f370._.js.map +1 -0
  125. package/.next/server/chunks/ssr/[root-of-the-server]__4c66998a._.js +3 -0
  126. package/.next/server/chunks/ssr/[root-of-the-server]__4c66998a._.js.map +1 -0
  127. package/.next/server/chunks/ssr/[root-of-the-server]__7fcc6175._.js +3 -0
  128. package/.next/server/chunks/ssr/[root-of-the-server]__7fcc6175._.js.map +1 -0
  129. package/.next/server/chunks/ssr/[root-of-the-server]__8e001110._.js +3 -0
  130. package/.next/server/chunks/ssr/[root-of-the-server]__8e001110._.js.map +1 -0
  131. package/.next/server/chunks/ssr/[root-of-the-server]__9a7d79aa._.js +1 -1
  132. package/.next/server/chunks/ssr/[root-of-the-server]__9a7d79aa._.js.map +1 -1
  133. package/.next/server/chunks/ssr/[root-of-the-server]__ad4e8478._.js +3 -0
  134. package/.next/server/chunks/ssr/[root-of-the-server]__ad4e8478._.js.map +1 -0
  135. package/.next/server/chunks/ssr/[root-of-the-server]__bd20cf10._.js +3 -0
  136. package/.next/server/chunks/ssr/[root-of-the-server]__bd20cf10._.js.map +1 -0
  137. package/.next/server/chunks/ssr/[root-of-the-server]__cefae8c8._.js +3 -0
  138. package/.next/server/chunks/ssr/[root-of-the-server]__cefae8c8._.js.map +1 -0
  139. package/.next/server/chunks/ssr/{node_modules_next_10fb6ad9._.js → _7f9e89d2._.js} +2 -2
  140. package/.next/server/chunks/ssr/_7f9e89d2._.js.map +1 -0
  141. package/.next/server/chunks/ssr/b1a17_app_teams_[teamId]_workflows_[workflowId]_workflows-editor-client_tsx_5e714aa2._.js +1 -1
  142. package/.next/server/chunks/ssr/b1a17_app_teams_[teamId]_workflows_[workflowId]_workflows-editor-client_tsx_5e714aa2._.js.map +1 -1
  143. package/.next/server/chunks/ssr/src_59477309._.js +1 -1
  144. package/.next/server/chunks/ssr/src_59477309._.js.map +1 -1
  145. package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_index_tsx_e68e9cbc._.js +1 -1
  146. package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_index_tsx_e68e9cbc._.js.map +1 -1
  147. package/.next/server/chunks/ssr/src_app_teams_[teamId]_workflows_workflows-client_tsx_12742cc9._.js +3 -0
  148. package/.next/server/chunks/ssr/src_app_teams_[teamId]_workflows_workflows-client_tsx_12742cc9._.js.map +1 -0
  149. package/.next/server/chunks/ssr/src_lib_errors_ts_f440efeb._.js +3 -0
  150. package/.next/server/chunks/ssr/src_lib_errors_ts_f440efeb._.js.map +1 -0
  151. package/.next/server/pages/404.html +1 -1
  152. package/.next/server/pages/500.html +2 -2
  153. package/.next/server/server-reference-manifest.js +1 -1
  154. package/.next/server/server-reference-manifest.json +1 -1
  155. package/.next/static/chunks/3e0d3a43014c0ad2.css +3 -0
  156. package/.next/static/chunks/43d0024279c6160e.js +1 -0
  157. package/.next/static/chunks/4f5e02a609758a0b.js +1 -0
  158. package/.next/static/chunks/5e3b1d0f61a651bf.js +1 -0
  159. package/.next/static/chunks/5f77499ca309ab9d.js +10 -0
  160. package/.next/static/chunks/be12a66bd736fad8.js +1 -0
  161. package/.next/static/chunks/{b28737d6a10af30d.js → ecdc9465f0e4d954.js} +1 -1
  162. package/README.md +6 -5
  163. package/openclaw.plugin.json +1 -1
  164. package/package.json +1 -1
  165. package/public/images/clawkitchen/home.png +0 -0
  166. package/public/images/clawkitchen/recipes.png +0 -0
  167. package/public/images/clawkitchen/runs.png +0 -0
  168. package/public/images/clawkitchen/team.png +0 -0
  169. package/public/images/clawkitchen/tickets.png +0 -0
  170. package/public/images/clawkitchen/workflows.png +0 -0
  171. package/.next/server/chunks/ssr/[root-of-the-server]__1d65fddf._.js +0 -3
  172. package/.next/server/chunks/ssr/[root-of-the-server]__1d65fddf._.js.map +0 -1
  173. package/.next/server/chunks/ssr/[root-of-the-server]__450d6006._.js +0 -3
  174. package/.next/server/chunks/ssr/[root-of-the-server]__450d6006._.js.map +0 -1
  175. package/.next/server/chunks/ssr/[root-of-the-server]__76f9757d._.js +0 -3
  176. package/.next/server/chunks/ssr/[root-of-the-server]__76f9757d._.js.map +0 -1
  177. package/.next/server/chunks/ssr/[root-of-the-server]__9ffebe91._.js +0 -3
  178. package/.next/server/chunks/ssr/[root-of-the-server]__9ffebe91._.js.map +0 -1
  179. package/.next/server/chunks/ssr/[root-of-the-server]__a26db919._.js +0 -3
  180. package/.next/server/chunks/ssr/[root-of-the-server]__a26db919._.js.map +0 -1
  181. package/.next/server/chunks/ssr/[root-of-the-server]__afaa71fe._.js +0 -3
  182. package/.next/server/chunks/ssr/[root-of-the-server]__afaa71fe._.js.map +0 -1
  183. package/.next/server/chunks/ssr/[root-of-the-server]__b577b475._.js +0 -3
  184. package/.next/server/chunks/ssr/[root-of-the-server]__b577b475._.js.map +0 -1
  185. package/.next/server/chunks/ssr/[root-of-the-server]__e94ab521._.js +0 -3
  186. package/.next/server/chunks/ssr/[root-of-the-server]__e94ab521._.js.map +0 -1
  187. package/.next/server/chunks/ssr/[root-of-the-server]__fb6781d4._.js +0 -3
  188. package/.next/server/chunks/ssr/[root-of-the-server]__fb6781d4._.js.map +0 -1
  189. package/.next/server/chunks/ssr/node_modules_next_10fb6ad9._.js.map +0 -1
  190. package/.next/server/chunks/ssr/src_e54f24fb._.js +0 -3
  191. package/.next/server/chunks/ssr/src_e54f24fb._.js.map +0 -1
  192. package/.next/static/chunks/42b3230688d0834c.js +0 -1
  193. package/.next/static/chunks/635adeaf329f2446.js +0 -1
  194. package/.next/static/chunks/6427cd3eaffdd572.js +0 -10
  195. package/.next/static/chunks/be874907adf946fd.js +0 -1
  196. package/.next/static/chunks/cfe32a0bce2eab2b.css +0 -3
  197. package/.next/static/chunks/e397a21bf5f13650.js +0 -1
  198. /package/.next/static/{AKnetF2w3rOYqZBVpzsLP → pW5SAQ1dzPcsq_66yy5po}/_buildManifest.js +0 -0
  199. /package/.next/static/{AKnetF2w3rOYqZBVpzsLP → pW5SAQ1dzPcsq_66yy5po}/_clientMiddlewareManifest.json +0 -0
  200. /package/.next/static/{AKnetF2w3rOYqZBVpzsLP → pW5SAQ1dzPcsq_66yy5po}/_ssgManifest.js +0 -0
@@ -1,3 +0,0 @@
1
- module.exports=[74621,a=>{"use strict";function b(a){return a instanceof Error?a.message:String(a)}a.s(["errorMessage",()=>b])},83856,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(50944),f=a.i(51200),g=a.i(74621);function h(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}function i({teamId:a}){let i=(0,e.useRouter)(),[j,k]=(0,c.useState)([]),[l,m]=(0,c.useState)(!0),[n,o]=(0,c.useState)(!1),[p,q]=(0,c.useState)(""),[r,s]=(0,c.useState)(""),[t,u]=(0,c.useState)({}),[v,w]=(0,c.useState)({}),[x,y]=(0,c.useState)(""),[z,A]=(0,c.useState)(""),[B,C]=(0,c.useState)(null),[D,E]=(0,c.useState)(""),[F,G]=(0,c.useState)(""),[H,I]=(0,c.useState)(!1),J=(0,c.useCallback)(async b=>{let c=!!b?.quiet;q(""),c||m(!0);try{let b=await (0,f.fetchJson)(`/api/teams/workflows?teamId=${encodeURIComponent(a)}`,{cache:"no-store"});if(!b.ok)throw Error("Failed to load workflows");let c=(Array.isArray(b.files)?b.files:[]).map(a=>a.endsWith(".workflow.json")?a.slice(0,-14):null).filter(a=>!!a);k(c.map(a=>({id:a,name:a})))}catch(a){q((0,g.errorMessage)(a))}finally{c||m(!1)}},[a]);async function K(){o(!0);try{await J({quiet:!0})}finally{o(!1)}}async function L(b){if(confirm(`Delete workflow “${b}”? This removes the .workflow.json file from the team workspace.`)){q("");try{let c=await (0,f.fetchJson)(`/api/teams/workflows?teamId=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"});if(!c.ok)throw Error(c.error||"Failed to delete workflow");await J({quiet:!0}),r===b&&(s(""),y(""),C(null))}catch(a){q((0,g.errorMessage)(a))}}}async function M(b){w(a=>({...a,[b]:!0})),E("");try{let c=await (0,f.fetchJson)(`/api/teams/workflow-runs?teamId=${encodeURIComponent(a)}&workflowId=${encodeURIComponent(b)}`,{cache:"no-store"});if(!c.ok)throw Error(c.error||"Failed to load runs");let d=Array.isArray(c.runIds)?c.runIds.map(a=>String(a||"").trim()).filter(Boolean):Array.isArray(c.files)?c.files.map(a=>"string"==typeof a&&a.endsWith(".run.json")?a.slice(0,-9):null).filter(a=>!!a):[];u(a=>({...a,[b]:d}))}catch(a){E((0,g.errorMessage)(a)),u(a=>({...a,[b]:[]}))}finally{w(a=>({...a,[b]:!1}))}}async function N(b,c){A(b),y(c),C(null),E(""),G("");try{let d=await (0,f.fetchJson)(`/api/teams/workflow-runs?teamId=${encodeURIComponent(a)}&workflowId=${encodeURIComponent(b)}&runId=${encodeURIComponent(c)}`,{cache:"no-store"});if(!d.ok)throw Error(d.error||"Failed to load run");let e=h(d.run)?d.run:null;if(!e)throw Error("Invalid run format");C({id:String(e.id??c),status:"string"==typeof e.status?e.status:void 0,startedAt:"string"==typeof e.startedAt?e.startedAt:void 0,finishedAt:"string"==typeof e.finishedAt?String(e.finishedAt):void 0,meta:e.meta,memoryUsed:e.memoryUsed,approval:e.approval,raw:e})}catch(a){E((0,g.errorMessage)(a)),C(null)}}async function O(b){if(confirm(`Add workflow from template “${b}”?`)){q("");try{let c=await (0,f.fetchJson)("/api/teams/workflow-templates",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,templateId:b})});if(!c.ok)throw Error(c.error||"Failed to apply template");let d=String(c.workflowId??"").trim();if(!d)throw Error("Template applied but workflowId missing");await J({quiet:!0}),i.push(`/teams/${encodeURIComponent(a)}/workflows/${encodeURIComponent(d)}`)}catch(a){q((0,g.errorMessage)(a))}}}(0,c.useEffect)(()=>{J()},[J]);let P=(0,c.useMemo)(()=>{if(!B)return[];let a=B.memoryUsed??(h(B.meta)?B.meta.memoryUsed:void 0);return Array.isArray(a)?a.map(a=>h(a)?a:null).filter(Boolean).map(a=>({ts:String(a.ts??"").trim(),author:String(a.author??"").trim(),type:String(a.type??"").trim(),content:String(a.content??"").trim(),source:a.source})).filter(a=>a.ts&&a.author&&a.type&&a.content):[]},[B]);return l?(0,b.jsx)("div",{className:"ck-glass p-4",children:"Loading workflows…"}):(0,b.jsxs)("div",{className:"ck-glass p-6",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("h2",{className:"text-lg font-semibold",children:"Workflows (file-first)"}),(0,b.jsxs)("p",{className:"mt-1 text-sm text-[color:var(--ck-text-secondary)]",children:["Stored in ",(0,b.jsx)("code",{children:"shared-context/workflows/<id>.workflow.json"})," inside the team workspace."]}),(0,b.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-start gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:()=>{let b=`new-${Date.now()}`;i.push(`/teams/${encodeURIComponent(a)}/workflows/${encodeURIComponent(b)}?draft=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)]",children:"Add workflow"}),(0,b.jsx)("button",{type:"button",onClick:()=>void O("marketing-cadence-v1"),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:"Add example template"}),(0,b.jsx)("button",{type:"button",onClick:K,disabled:n,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-60",children:n?"Refreshing…":"Refresh"})]})]}),p?(0,b.jsx)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-4 text-sm text-red-100",children:p}):null,0===j.length?(0,b.jsx)("p",{className:"mt-4 text-sm text-[color:var(--ck-text-secondary)]",children:"No workflows yet."}):(0,b.jsx)("ul",{className:"mt-4 divide-y divide-white/10 overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10",children:j.map(c=>{let e=r===c.id,f=t[c.id]??[],i=!!v[c.id];return(0,b.jsxs)("li",{className:"bg-white/5",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[(0,b.jsxs)("button",{type:"button",onClick:async()=>{let a=e?"":c.id;s(a),y(""),C(null),E(""),a&&await M(a)},className:"min-w-0 flex-1 text-left",children:[(0,b.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:c.name||c.id}),(0,b.jsx)("div",{className:"truncate text-xs text-[color:var(--ck-text-tertiary)]",children:c.id}),(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["Click to ",e?"collapse":"expand"," run details"]})]}),(0,b.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,b.jsx)(d.default,{href:`/teams/${encodeURIComponent(a)}/workflows/${encodeURIComponent(c.id)}`,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-1.5 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Edit"}),(0,b.jsx)("button",{type:"button",onClick:()=>void L(c.id),className:"rounded-[var(--ck-radius-sm)] border border-[color:rgba(255,59,48,0.45)] bg-[color:rgba(255,59,48,0.08)] px-3 py-1.5 text-sm font-medium text-[color:var(--ck-accent-red)] transition-colors hover:bg-[color:rgba(255,59,48,0.12)]",children:"Delete"})]})]}),e?(0,b.jsxs)("div",{className:"border-t border-white/10 bg-black/20 px-4 py-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Runs"}),(0,b.jsx)("button",{type:"button",disabled:i,onClick:()=>void M(c.id),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60",children:i?"Loading…":"Refresh runs"})]}),D?(0,b.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:D}):null,(0,b.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-3 lg:grid-cols-2",children:[(0,b.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:f.length?(0,b.jsx)("div",{className:"space-y-1",children:f.slice(0,8).map(a=>{let d=x===a;return(0,b.jsx)("button",{type:"button",onClick:()=>void N(c.id,a),className:d?"w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-primary)]":"w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:(0,b.jsx)("span",{className:"font-mono",children:a})},a)})}):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"No runs yet."})}),(0,b.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:B?(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Run detail"}),(0,b.jsxs)("div",{className:"mt-1 text-[11px] text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:B.id}),B.status?(0,b.jsxs)("span",{children:[" • ",B.status]}):null]})]}),(0,b.jsxs)("div",{className:"border-t border-white/10 pt-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Approval"}),(()=>{let c=B.approval;if(!h(c))return(0,b.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(No approval info recorded.)"});let d=String(c.state??"").trim(),e="string"==typeof c.requestedAt?c.requestedAt:"",f="string"==typeof c.decidedAt?c.decidedAt:"",i="string"==typeof c.decidedBy?c.decidedBy:"",j="string"==typeof c.note?c.note:"",k=h(c.outbound)?c.outbound:null,l="pending"===d||"waiting_for_approval"===B.status;return(0,b.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-[11px] text-[color:var(--ck-text-secondary)]",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"font-mono",children:"state"}),": ",(0,b.jsx)("span",{className:"font-mono text-[color:var(--ck-text-primary)]",children:d||"(unknown)"})]}),e?(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"font-mono",children:"requestedAt"}),": ",(0,b.jsx)("span",{className:"font-mono",children:e})]}):null,f?(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"font-mono",children:"decidedAt"}),": ",(0,b.jsx)("span",{className:"font-mono",children:f})]}):null,i?(0,b.jsxs)("div",{children:[(0,b.jsx)("span",{className:"font-mono",children:"decidedBy"}),": ",(0,b.jsx)("span",{className:"font-mono",children:i})]}):null,j?(0,b.jsx)("div",{className:"mt-1 whitespace-pre-wrap text-xs text-[color:var(--ck-text-primary)]",children:j}):null,k?(0,b.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px]",children:[(0,b.jsx)("div",{className:"text-[color:var(--ck-text-tertiary)]",children:"Outbound"}),(0,b.jsx)("pre",{className:"mt-1 overflow-auto whitespace-pre-wrap",children:JSON.stringify(k,null,2)})]}):null]}),l?(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"approval note (optional)"}),(0,b.jsx)("textarea",{value:F,onChange:a=>G(a.target.value),rows:3,className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"e.g. Ship it / please tweak hook"}),(0,b.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:[{action:"approve",label:"Approve"},{action:"request_changes",label:"Request changes"},{action:"cancel",label:"Cancel"}].map(c=>(0,b.jsx)("button",{type:"button",disabled:H,onClick:async()=>{if(z&&x&&confirm(`${c.label} run ${x}?`)){I(!0),E("");try{let b=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:z,runId:x,action:c.action,note:F||void 0,decidedBy:"ClawKitchen UI"})}),d=await b.json();if(!b.ok||!d.ok)throw Error(d.error||"Failed to apply approval action");await N(z,x)}catch(a){E((0,g.errorMessage)(a))}finally{I(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60",children:c.label},c.action))})]}):null]})})()]}),(0,b.jsxs)("div",{className:"border-t border-white/10 pt-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Memory used in this run"}),P.length?(0,b.jsx)("div",{className:"mt-2 space-y-2",children:P.slice(0,20).map((a,c)=>(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:[(0,b.jsxs)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.ts})," • ",(0,b.jsx)("span",{className:"font-mono",children:a.type})," • ",(0,b.jsx)("span",{className:"font-mono",children:a.author})]}),(0,b.jsx)("div",{className:"mt-1 whitespace-pre-wrap text-xs text-[color:var(--ck-text-primary)]",children:a.content}),void 0!==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.ts}-${c}`))}):(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["(None recorded yet.)",(0,b.jsxs)("div",{className:"mt-1",children:["Next step: have the workflow runner write an explicit ",(0,b.jsx)("span",{className:"font-mono",children:"memoryUsed[]"})," list into the run file."]})]})]})]}):x?(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Loading run…"}):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"Select a run to see details."})})]})]}):null]},c.id)})})]})}a.s(["default",()=>i])}];
2
-
3
- //# sourceMappingURL=src_e54f24fb._.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/errors.ts","../../../../src/app/teams/%5BteamId%5D/workflows/workflows-client.tsx"],"sourcesContent":["/**\n * Extracts a string message from an unknown error value.\n * Used consistently across API routes and client components.\n */\nexport function errorMessage(e: unknown): string {\n return e instanceof Error ? e.message : String(e);\n}\n","\"use client\";\n\nimport { useCallback, useEffect, useMemo, useState } from \"react\";\nimport Link from \"next/link\";\nimport { useRouter } from \"next/navigation\";\nimport { fetchJson } from \"@/lib/fetch-json\";\nimport { errorMessage } from \"@/lib/errors\";\n\ntype RunDetail = {\n id: string;\n status?: string;\n startedAt?: string;\n finishedAt?: string;\n meta?: unknown;\n memoryUsed?: unknown;\n approval?: unknown;\n raw?: Record<string, unknown>;\n};\n\nfunction isRecord(v: unknown): v is Record<string, unknown> {\n return Boolean(v) && typeof v === \"object\" && !Array.isArray(v);\n}\n\nexport default function WorkflowsClient({ teamId }: { teamId: string }) {\n const router = useRouter();\n const [workflows, setWorkflows] = useState<Array<{ id: string; name?: string }>>([]);\n const [loading, setLoading] = useState(true);\n const [refreshing, setRefreshing] = useState(false);\n const [error, setError] = useState<string>(\"\");\n\n const [expandedWorkflowId, setExpandedWorkflowId] = useState<string>(\"\");\n const [runsByWorkflow, setRunsByWorkflow] = useState<Record<string, string[]>>({});\n const [runsLoading, setRunsLoading] = useState<Record<string, boolean>>({});\n const [selectedRunId, setSelectedRunId] = useState<string>(\"\");\n const [selectedWorkflowId, setSelectedWorkflowId] = useState<string>(\"\");\n const [selectedRun, setSelectedRun] = useState<RunDetail | null>(null);\n const [runError, setRunError] = useState<string>(\"\");\n const [approvalNote, setApprovalNote] = useState<string>(\"\");\n const [approvalBusy, setApprovalBusy] = useState<boolean>(false);\n\n const load = useCallback(\n async (opts?: { quiet?: boolean }) => {\n const quiet = Boolean(opts?.quiet);\n setError(\"\");\n if (!quiet) setLoading(true);\n try {\n const json = await fetchJson<{ ok?: boolean; files?: string[] }>(\n `/api/teams/workflows?teamId=${encodeURIComponent(teamId)}`,\n { cache: \"no-store\" }\n );\n if (!json.ok) throw new Error(\"Failed to load workflows\");\n const files = Array.isArray(json.files) ? json.files : [];\n const ids = files\n .map((f) => (f.endsWith(\".workflow.json\") ? f.slice(0, -\".workflow.json\".length) : null))\n .filter((id): id is string => Boolean(id));\n setWorkflows(ids.map((id) => ({ id, name: id })));\n } catch (e: unknown) {\n setError(errorMessage(e));\n } finally {\n if (!quiet) setLoading(false);\n }\n },\n [teamId]\n );\n\n useEffect(() => {\n void load();\n }, [load]);\n\n async function onRefresh() {\n setRefreshing(true);\n try {\n await load({ quiet: true });\n } finally {\n setRefreshing(false);\n }\n }\n\n async function onDelete(id: string) {\n if (!confirm(`Delete workflow “${id}”? This removes the .workflow.json file from the team workspace.`)) return;\n setError(\"\");\n try {\n const json = await fetchJson<{ ok?: boolean; error?: string }>(\n `/api/teams/workflows?teamId=${encodeURIComponent(teamId)}&id=${encodeURIComponent(id)}`,\n { method: \"DELETE\" }\n );\n if (!json.ok) throw new Error(json.error || \"Failed to delete workflow\");\n await load({ quiet: true });\n if (expandedWorkflowId === id) {\n setExpandedWorkflowId(\"\");\n setSelectedRunId(\"\");\n setSelectedRun(null);\n }\n } catch (e: unknown) {\n setError(errorMessage(e));\n }\n }\n\n async function loadRunsForWorkflow(workflowId: string) {\n setRunsLoading((s) => ({ ...s, [workflowId]: true }));\n setRunError(\"\");\n try {\n const json = await fetchJson<{ ok?: boolean; runIds?: string[]; files?: string[]; error?: string }>(\n `/api/teams/workflow-runs?teamId=${encodeURIComponent(teamId)}&workflowId=${encodeURIComponent(workflowId)}`,\n { cache: \"no-store\" }\n );\n if (!json.ok) throw new Error(json.error || \"Failed to load runs\");\n\n // New API: runIds (directory-per-run layout). Back-compat: files[] of *.run.json.\n const runIds = Array.isArray(json.runIds)\n ? json.runIds.map((x) => String(x || \"\").trim()).filter(Boolean)\n : Array.isArray(json.files)\n ? json.files\n .map((f) => (typeof f === \"string\" && f.endsWith(\".run.json\") ? f.slice(0, -\".run.json\".length) : null))\n .filter((x): x is string => Boolean(x))\n : [];\n\n setRunsByWorkflow((s) => ({ ...s, [workflowId]: runIds }));\n } catch (e: unknown) {\n setRunError(errorMessage(e));\n setRunsByWorkflow((s) => ({ ...s, [workflowId]: [] }));\n } finally {\n setRunsLoading((s) => ({ ...s, [workflowId]: false }));\n }\n }\n\n async function loadRunDetail(workflowId: string, runId: string) {\n setSelectedWorkflowId(workflowId);\n setSelectedRunId(runId);\n setSelectedRun(null);\n setRunError(\"\");\n setApprovalNote(\"\");\n try {\n const json = await fetchJson<{ ok?: boolean; run?: unknown; error?: string }>(\n `/api/teams/workflow-runs?teamId=${encodeURIComponent(teamId)}&workflowId=${encodeURIComponent(workflowId)}&runId=${encodeURIComponent(runId)}`,\n { cache: \"no-store\" }\n );\n if (!json.ok) throw new Error(json.error || \"Failed to load run\");\n const run = isRecord(json.run) ? json.run : null;\n if (!run) throw new Error(\"Invalid run format\");\n setSelectedRun({\n id: String(run.id ?? runId),\n status: typeof run.status === \"string\" ? run.status : undefined,\n startedAt: typeof run.startedAt === \"string\" ? run.startedAt : undefined,\n finishedAt: typeof (run as Record<string, unknown>).finishedAt === \"string\" ? String((run as Record<string, unknown>).finishedAt) : undefined,\n meta: (run as Record<string, unknown>).meta,\n memoryUsed: (run as Record<string, unknown>).memoryUsed,\n approval: (run as Record<string, unknown>).approval,\n raw: run,\n });\n } catch (e: unknown) {\n setRunError(errorMessage(e));\n setSelectedRun(null);\n }\n }\n\n async function onAddTemplate(templateId: string) {\n if (!confirm(`Add workflow from template “${templateId}”?`)) return;\n setError(\"\");\n try {\n const json = await fetchJson<{ ok?: boolean; workflowId?: string; error?: string }>(\"/api/teams/workflow-templates\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ teamId, templateId }),\n });\n if (!json.ok) throw new Error(json.error || \"Failed to apply template\");\n const workflowId = String(json.workflowId ?? \"\").trim();\n if (!workflowId) throw new Error(\"Template applied but workflowId missing\");\n await load({ quiet: true });\n router.push(`/teams/${encodeURIComponent(teamId)}/workflows/${encodeURIComponent(workflowId)}`);\n } catch (e: unknown) {\n setError(errorMessage(e));\n }\n }\n const memoryUsedItems = useMemo(() => {\n const run = selectedRun;\n if (!run) return [] as Array<{ ts: string; author: string; type: string; content: string; source?: unknown }>;\n\n const raw = run.memoryUsed ?? (isRecord(run.meta) ? (run.meta as Record<string, unknown>).memoryUsed : undefined);\n if (!Array.isArray(raw)) return [];\n\n return raw\n .map((x) => (isRecord(x) ? x : null))\n .filter(Boolean)\n .map((o) => ({\n ts: String((o as Record<string, unknown>).ts ?? \"\").trim(),\n author: String((o as Record<string, unknown>).author ?? \"\").trim(),\n type: String((o as Record<string, unknown>).type ?? \"\").trim(),\n content: String((o as Record<string, unknown>).content ?? \"\").trim(),\n source: (o as Record<string, unknown>).source,\n }))\n .filter((it) => it.ts && it.author && it.type && it.content);\n }, [selectedRun]);\n\n if (loading) {\n return <div className=\"ck-glass p-4\">Loading workflows…</div>;\n }\n\n return (\n <div className=\"ck-glass p-6\">\n <div>\n <h2 className=\"text-lg font-semibold\">Workflows (file-first)</h2>\n <p className=\"mt-1 text-sm text-[color:var(--ck-text-secondary)]\">\n Stored in <code>shared-context/workflows/&lt;id&gt;.workflow.json</code> inside the team workspace.\n </p>\n\n <div className=\"mt-3 flex flex-wrap items-center justify-start gap-2\">\n <button\n type=\"button\"\n onClick={() => {\n const id = `new-${Date.now()}`;\n router.push(`/teams/${encodeURIComponent(teamId)}/workflows/${encodeURIComponent(id)}?draft=1`);\n }}\n 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)]\"\n >\n Add workflow\n </button>\n\n\n <button\n type=\"button\"\n onClick={() => void onAddTemplate(\"marketing-cadence-v1\")}\n 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\"\n >\n Add example template\n </button>\n\n <button\n type=\"button\"\n onClick={onRefresh}\n disabled={refreshing}\n 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-60\"\n >\n {refreshing ? \"Refreshing…\" : \"Refresh\"}\n </button>\n </div>\n </div>\n\n {error ? (\n <div className=\"mt-4 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-4 text-sm text-red-100\">\n {error}\n </div>\n ) : null}\n\n {workflows.length === 0 ? (\n <p className=\"mt-4 text-sm text-[color:var(--ck-text-secondary)]\">No workflows yet.</p>\n ) : (\n <ul className=\"mt-4 divide-y divide-white/10 overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10\">\n {workflows.map((w) => {\n const expanded = expandedWorkflowId === w.id;\n const runs = runsByWorkflow[w.id] ?? [];\n const isLoadingRuns = Boolean(runsLoading[w.id]);\n\n return (\n <li key={w.id} className=\"bg-white/5\">\n <div className=\"flex items-center justify-between gap-3 px-4 py-3\">\n <button\n type=\"button\"\n onClick={async () => {\n const next = expanded ? \"\" : w.id;\n setExpandedWorkflowId(next);\n setSelectedRunId(\"\");\n setSelectedRun(null);\n setRunError(\"\");\n if (next) await loadRunsForWorkflow(next);\n }}\n className=\"min-w-0 flex-1 text-left\"\n >\n <div className=\"truncate text-sm font-medium text-[color:var(--ck-text-primary)]\">{w.name || w.id}</div>\n <div className=\"truncate text-xs text-[color:var(--ck-text-tertiary)]\">{w.id}</div>\n <div className=\"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]\">\n Click to {expanded ? \"collapse\" : \"expand\"} run details\n </div>\n </button>\n\n <div className=\"flex shrink-0 items-center gap-2\">\n <Link\n href={`/teams/${encodeURIComponent(teamId)}/workflows/${encodeURIComponent(w.id)}`}\n className=\"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-1.5 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10\"\n >\n Edit\n </Link>\n <button\n type=\"button\"\n onClick={() => void onDelete(w.id)}\n className=\"rounded-[var(--ck-radius-sm)] border border-[color:rgba(255,59,48,0.45)] bg-[color:rgba(255,59,48,0.08)] px-3 py-1.5 text-sm font-medium text-[color:var(--ck-accent-red)] transition-colors hover:bg-[color:rgba(255,59,48,0.12)]\"\n >\n Delete\n </button>\n </div>\n </div>\n\n {expanded ? (\n <div className=\"border-t border-white/10 bg-black/20 px-4 py-3\">\n <div className=\"flex flex-wrap items-center justify-between gap-2\">\n <div className=\"text-xs font-medium text-[color:var(--ck-text-secondary)]\">Runs</div>\n <button\n type=\"button\"\n disabled={isLoadingRuns}\n onClick={() => void loadRunsForWorkflow(w.id)}\n className=\"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60\"\n >\n {isLoadingRuns ? \"Loading…\" : \"Refresh runs\"}\n </button>\n </div>\n\n {runError ? (\n <div className=\"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100\">{runError}</div>\n ) : null}\n\n <div className=\"mt-2 grid grid-cols-1 gap-3 lg:grid-cols-2\">\n <div className=\"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2\">\n {runs.length ? (\n <div className=\"space-y-1\">\n {runs.slice(0, 8).map((runId) => {\n const selected = selectedRunId === runId;\n return (\n <button\n key={runId}\n type=\"button\"\n onClick={() => void loadRunDetail(w.id, runId)}\n className={\n selected\n ? \"w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-primary)]\"\n : \"w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-secondary)] hover:bg-white/5\"\n }\n >\n <span className=\"font-mono\">{runId}</span>\n </button>\n );\n })}\n </div>\n ) : (\n <div className=\"text-xs text-[color:var(--ck-text-tertiary)]\">No runs yet.</div>\n )}\n </div>\n\n <div className=\"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3\">\n {selectedRun ? (\n <div className=\"space-y-3\">\n <div>\n <div className=\"text-xs font-medium text-[color:var(--ck-text-secondary)]\">Run detail</div>\n <div className=\"mt-1 text-[11px] text-[color:var(--ck-text-tertiary)]\">\n <span className=\"font-mono\">{selectedRun.id}</span>\n {selectedRun.status ? <span> • {selectedRun.status}</span> : null}\n </div>\n </div>\n\n <div className=\"border-t border-white/10 pt-3\">\n <div className=\"text-xs font-medium text-[color:var(--ck-text-secondary)]\">Approval</div>\n {(() => {\n const approval = selectedRun.approval;\n if (!isRecord(approval)) {\n return <div className=\"mt-2 text-xs text-[color:var(--ck-text-tertiary)]\">(No approval info recorded.)</div>;\n }\n\n const state = String(approval.state ?? \"\").trim();\n const requestedAt = typeof approval.requestedAt === \"string\" ? approval.requestedAt : \"\";\n const decidedAt = typeof approval.decidedAt === \"string\" ? approval.decidedAt : \"\";\n const decidedBy = typeof approval.decidedBy === \"string\" ? approval.decidedBy : \"\";\n const note = typeof approval.note === \"string\" ? approval.note : \"\";\n const outbound = isRecord(approval.outbound) ? approval.outbound : null;\n\n const canAct = state === \"pending\" || selectedRun.status === \"waiting_for_approval\";\n\n return (\n <div className=\"mt-2 space-y-2\">\n <div className=\"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-[11px] text-[color:var(--ck-text-secondary)]\">\n <div>\n <span className=\"font-mono\">state</span>: <span className=\"font-mono text-[color:var(--ck-text-primary)]\">{state || \"(unknown)\"}</span>\n </div>\n {requestedAt ? (\n <div>\n <span className=\"font-mono\">requestedAt</span>: <span className=\"font-mono\">{requestedAt}</span>\n </div>\n ) : null}\n {decidedAt ? (\n <div>\n <span className=\"font-mono\">decidedAt</span>: <span className=\"font-mono\">{decidedAt}</span>\n </div>\n ) : null}\n {decidedBy ? (\n <div>\n <span className=\"font-mono\">decidedBy</span>: <span className=\"font-mono\">{decidedBy}</span>\n </div>\n ) : null}\n {note ? (\n <div className=\"mt-1 whitespace-pre-wrap text-xs text-[color:var(--ck-text-primary)]\">{note}</div>\n ) : null}\n {outbound ? (\n <div className=\"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px]\">\n <div className=\"text-[color:var(--ck-text-tertiary)]\">Outbound</div>\n <pre className=\"mt-1 overflow-auto whitespace-pre-wrap\">{JSON.stringify(outbound, null, 2)}</pre>\n </div>\n ) : null}\n </div>\n\n {canAct ? (\n <div className=\"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2\">\n <div className=\"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]\">approval note (optional)</div>\n <textarea\n value={approvalNote}\n onChange={(e) => setApprovalNote(e.target.value)}\n rows={3}\n className=\"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]\"\n placeholder=\"e.g. Ship it / please tweak hook\"\n />\n <div className=\"mt-2 flex flex-wrap gap-2\">\n {([\n { action: \"approve\", label: \"Approve\" },\n { action: \"request_changes\", label: \"Request changes\" },\n { action: \"cancel\", label: \"Cancel\" },\n ] as const).map((btn) => (\n <button\n key={btn.action}\n type=\"button\"\n disabled={approvalBusy}\n onClick={async () => {\n if (!selectedWorkflowId || !selectedRunId) return;\n if (!confirm(`${btn.label} run ${selectedRunId}?`)) return;\n setApprovalBusy(true);\n setRunError(\"\");\n try {\n const res = await fetch(\"/api/teams/workflow-runs\", {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n teamId,\n workflowId: selectedWorkflowId,\n runId: selectedRunId,\n action: btn.action,\n note: approvalNote || undefined,\n decidedBy: \"ClawKitchen UI\",\n }),\n });\n const json = await res.json();\n if (!res.ok || !json.ok) throw new Error(json.error || \"Failed to apply approval action\");\n await loadRunDetail(selectedWorkflowId, selectedRunId);\n } catch (e: unknown) {\n setRunError(errorMessage(e));\n } finally {\n setApprovalBusy(false);\n }\n }}\n className=\"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60\"\n >\n {btn.label}\n </button>\n ))}\n </div>\n </div>\n ) : null}\n </div>\n );\n })()}\n </div>\n\n <div className=\"border-t border-white/10 pt-3\">\n <div className=\"text-xs font-medium text-[color:var(--ck-text-secondary)]\">Memory used in this run</div>\n {memoryUsedItems.length ? (\n <div className=\"mt-2 space-y-2\">\n {memoryUsedItems.slice(0, 20).map((m, idx) => (\n <div key={`${m.ts}-${idx}`} className=\"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2\">\n <div className=\"text-[10px] text-[color:var(--ck-text-tertiary)]\">\n <span className=\"font-mono\">{m.ts}</span> • <span className=\"font-mono\">{m.type}</span> • <span className=\"font-mono\">{m.author}</span>\n </div>\n <div className=\"mt-1 whitespace-pre-wrap text-xs text-[color:var(--ck-text-primary)]\">{m.content}</div>\n {m.source !== undefined ? (\n <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)]\">\n {JSON.stringify(m.source, null, 2)}\n </pre>\n ) : null}\n </div>\n ))}\n </div>\n ) : (\n <div className=\"mt-2 text-xs text-[color:var(--ck-text-tertiary)]\">\n (None recorded yet.)\n <div className=\"mt-1\">Next step: have the workflow runner write an explicit <span className=\"font-mono\">memoryUsed[]</span> list into the run file.</div>\n </div>\n )}\n </div>\n </div>\n ) : selectedRunId ? (\n <div className=\"text-xs text-[color:var(--ck-text-secondary)]\">Loading run…</div>\n ) : (\n <div className=\"text-xs text-[color:var(--ck-text-tertiary)]\">Select a run to see details.</div>\n )}\n </div>\n </div>\n </div>\n ) : null}\n </li>\n );\n })}\n </ul>\n )}\n </div>\n );\n}\n"],"names":[],"mappings":"uCAIO,SAAS,EAAa,CAAU,EACrC,OAAO,aAAa,MAAQ,EAAE,OAAO,CAAG,OAAO,EACjD,sECJA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OACA,EAAA,EAAA,CAAA,CAAA,OAaA,SAAS,EAAS,CAAU,EAC1B,OAAO,CAAQ,GAAmB,UAAb,OAAO,GAAkB,CAAC,MAAM,OAAO,CAAC,EAC/D,CAEe,SAAS,EAAgB,QAAE,CAAM,CAAsB,EACpE,IAAM,EAAS,CAAA,EAAA,EAAA,SAAA,AAAS,IAClB,CAAC,EAAW,EAAa,CAAG,CAAA,EAAA,EAAA,QAAA,AAAQ,EAAuC,EAAE,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0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,87090,e=>{"use strict";var t=e.i(43476),r=e.i(71645),a=e.i(22016),s=e.i(44355);function o(e){let t=new Set;for(let r of e)t.add(r);return t.size}function i(e,t){return`ck-wf-draft:${e}:${t}`}function n({teamId:e,workflowId:n,draft:l}){let d,c,x,m,p,u,h,g,v,[b,k]=(0,r.useState)("canvas"),[y,f]=(0,r.useState)(!1),[w,j]=(0,r.useState)({kind:"loading"}),[N,S]=(0,r.useState)(""),C=(0,r.useRef)(null),[T,I]=(0,r.useState)(!1),[A,$]=(0,r.useState)(1),M=(0,r.useRef)(null),[O,L]=(0,r.useState)(""),[E,R]=(0,r.useState)(null),[B,z]=(0,r.useState)({kind:"select"}),[U,_]=(0,r.useState)(""),[W,P]=(0,r.useState)([]),[D,J]=(0,r.useState)(""),[F,q]=(0,r.useState)([]),[K,Z]=(0,r.useState)(""),Y=(0,r.useMemo)(()=>/Tool not available:\s*gateway/i.test(String(K||"")),[K]),[V,H]=(0,r.useState)([]),[X,Q]=(0,r.useState)(!1),[G,ee]=(0,r.useState)(""),[et,er]=(0,r.useState)(""),[ea,es]=(0,r.useState)(!1),[eo,ei]=(0,r.useState)(""),[en,el]=(0,r.useState)({}),[ed,ec]=(0,r.useState)(!1),[ex,em]=(0,r.useState)(!1),[ep,eu]=(0,r.useState)(""),[eh,eg]=(0,r.useState)(""),[ev,eb]=(0,r.useState)(""),[ek,ey]=(0,r.useState)("llm"),[ef,ew]=(0,r.useState)(""),[ej,eN]=(0,r.useState)(""),[eS,eC]=(0,r.useState)("");function eT(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function eI(e){if(!eT(e))return null;let t=eT(e.match)?e.match:null;if(!t)return null;let r=String(t.channel??"").trim();if(!r)return null;let a=String(t.accountId??"").trim();if(a)return{id:`${r}:account:${a}`,label:`${r} \xb7 account:${a}`,channel:r,target:a};let s=eT(t.peer)?t.peer:null,o=s?String(s.kind??"").trim():"",i=s?String(s.id??"").trim():"";return o&&i?{id:`${r}:${o}:${i}`,label:`${r} \xb7 ${o}:${i}`,channel:r,target:i}:null}(0,r.useEffect)(()=>{(async()=>{try{if(l){let t=sessionStorage.getItem(i(e,n));if(t)return void j({kind:"ready",jsonText:t});let r=JSON.stringify({schema:"clawkitchen.workflow.v1",id:n,name:"New workflow",timezone:"UTC",nodes:[{id:"start",type:"start",name:"start",x:80,y:80,config:{}},{id:"end",type:"end",name:"end",x:520,y:80,config:{}}],edges:[{id:"e1",from:"start",to:"end"}]},null,2)+"\n";j({kind:"ready",jsonText:r});try{sessionStorage.setItem(i(e,n),r)}catch{}return}let t=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(e)}&id=${encodeURIComponent(n)}`,{cache:"no-store"}),r=await t.json();if(!t.ok||!r.ok)throw Error(r.error||"Failed to load workflow");j({kind:"ready",jsonText:JSON.stringify(r.workflow,null,2)+"\n"})}catch(e){j({kind:"error",error:e instanceof Error?e.message:String(e)})}})()},[e,n,l]),(0,r.useEffect)(()=>{(async()=>{J("");try{let t=await fetch("/api/agents",{cache:"no-store"}),r=await t.json();if(!t.ok)throw Error(r.error||r.message||"Failed to load agents");let a=(Array.isArray(r.agents)?r.agents:[]).map(e=>({id:String(e.id??"").trim(),identityName:"string"==typeof e.identityName?e.identityName:void 0})).filter(t=>t.id&&t.id.startsWith(`${e}-`));P(a)}catch(e){J(e instanceof Error?e.message:String(e)),P([])}})()},[e]),(0,r.useEffect)(()=>{(async()=>{Z("");try{let e=await fetch("/api/channels/bindings",{cache:"no-store"}),t=await e.json();if(!e.ok||!1===t.ok)throw Error(t.error||"Failed to load bindings");let r=(Array.isArray(t.bindings)?t.bindings:[]).map(eI).filter(Boolean);q(r)}catch(e){Z(e instanceof Error?e.message:String(e)),q([])}})()},[]);let eA=(0,r.useCallback)(async()=>{ei(""),es(!0);try{let e=await fetch("/api/cron/jobs",{cache:"no-store"}),t=await e.json();if(!e.ok||!1===t.ok)throw Error(t.error||"Failed to load cron jobs");let r=Array.isArray(t.jobs)?t.jobs:[],a={};for(let e of r){if(!e||!e.enabled)continue;let t=String(e.agentId??"").trim();if(t){a[t]=!0;continue}if(e.scope&&"agent"===String(e.scope.kind)){let t=String(e.scope.id??"").trim();t&&(a[t]=!0)}}return el(a),a}catch(e){return ei(e instanceof Error?e.message:String(e)),el({}),{}}finally{es(!1)}},[]);(0,r.useEffect)(()=>{eA()},[eA]);let e$=(0,r.useMemo)(()=>{if("ready"!==w.kind)return{wf:null,err:""};try{return{wf:JSON.parse(w.jsonText),err:""}}catch(e){return{wf:null,err:e instanceof Error?e.message:String(e)}}},[w]),eM=(0,r.useMemo)(()=>e$.wf?function(e){let t=[],r=[];"clawkitchen.workflow.v1"!==e.schema&&t.push(`schema must be clawkitchen.workflow.v1 (got ${String(e.schema)})`),String(e.id||"").trim()||t.push("id is required"),String(e.name||"").trim()||t.push("name is required");let a=Array.isArray(e.nodes)?e.nodes:[],s=Array.isArray(e.edges)?e.edges:[],i=Array.isArray(e.triggers)?e.triggers:[],n=a.map(e=>String(e?.id??"").trim()).filter(Boolean);n.length!==a.length&&t.push("all nodes must have a non-empty id"),o(n)!==n.length&&t.push("node ids must be unique");let l=s.map(e=>String(e?.id??"").trim()).filter(Boolean);l.length!==s.length&&t.push("all edges must have a non-empty id"),o(l)!==l.length&&t.push("edge ids must be unique");let d=new Set(n);for(let e of s){let r=String(e?.from??"").trim(),a=String(e?.to??"").trim();if(!r||!a){t.push(`edge ${String(e?.id??"(missing id)")} must have from/to`);continue}d.has(r)||t.push(`edge ${String(e.id)} references missing from node: ${r}`),d.has(a)||t.push(`edge ${String(e.id)} references missing to node: ${a}`)}let c=a.filter(e=>"start"===e.type),x=a.filter(e=>"end"===e.type);for(let e of(c.length||r.push("no start node found"),c.length>1&&r.push("multiple start nodes found (MVP supports this, but execution semantics may be ambiguous)"),x.length||r.push("no end node found"),i))if("cron"===e.kind){(String(e.id||"").trim()||t.push("cron trigger missing id"),String(e.expr||"").trim())?5!==String(e.expr||"").trim().split(/\s+/).filter(Boolean).length&&r.push(`cron trigger ${String(e.id)} expr is not 5-field: ${String(e.expr)}`):t.push(`cron trigger ${String(e.id||"(missing id)")} missing expr`);let a=e.tz?String(e.tz).trim():"";a&&"UTC"!==a&&!a.includes("/")&&r.push(`cron trigger ${String(e.id)} tz doesn't look like an IANA timezone: ${String(e.tz)}`)}let m=e.meta&&"object"==typeof e.meta&&!Array.isArray(e.meta)?e.meta:{},p=String(m.approvalTarget??"").trim();for(let e of a){if("human_approval"!==e.type)continue;let t=e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{},a=String(t.target??t.chatId??"").trim(),s=String(t.provider??t.channel??"").trim();a||p||r.push(`human_approval node ${String(e.id)} has no target (set node.config.target or workflow.meta.approvalTarget)`),!a||s||String(m.approvalProvider??"").trim()||r.push(`human_approval node ${String(e.id)} has a target but no provider (set node.config.provider or workflow.meta.approvalProvider)`)}return{errors:t,warnings:r}}(e$.wf):{errors:[],warnings:[]},[e$.wf]),eO=(0,r.useMemo)(()=>{let e=e$.wf;if(!e)return{missingAgentOnNodeIds:[],requiredAgentIds:[],agentIdsMissingCron:[],ok:!0};let t=(e.nodes??[]).filter(e=>"start"!==e.type&&"end"!==e.type&&"human_approval"!==e.type),r=t.filter(e=>!String((e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{}).agentId??"").trim()).map(e=>e.id),a=Array.from(new Set(t.map(e=>String((e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{}).agentId??"").trim()).filter(Boolean))),s=a.filter(e=>!en[e]),o=0===r.length&&0===s.length;return{missingAgentOnNodeIds:r,requiredAgentIds:a,agentIdsMissingCron:s,ok:o}},[e$.wf,en]);function eL(t){let r=JSON.stringify(t,null,2)+"\n";if(j({kind:"ready",jsonText:r}),l)try{sessionStorage.setItem(i(e,n),r)}catch{}}async function eE(){if("ready"===w.kind&&e$.wf&&!e$.err&&!eM.errors.length){f(!0),S("");try{let t=await fetch("/api/teams/workflows",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,workflow:e$.wf})}),r=await t.json();if(!t.ok||!r.ok)throw Error(r.error||"Failed to save workflow");try{sessionStorage.removeItem(i(e,n))}catch{}}catch(e){S(e instanceof Error?e.message:String(e))}finally{f(!1)}}}return"loading"===w.kind?(0,t.jsx)("div",{className:"ck-glass w-full p-6",children:"Loading…"}):"error"===w.kind?(0,t.jsx)("div",{className:"ck-glass w-full p-6",children:w.error}):(0,t.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-3 py-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,t.jsx)("a",{href:`/teams/${encodeURIComponent(e)}?tab=workflows`,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:"Back"}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"truncate text-base font-medium text-[color:var(--ck-text-primary)]",children:[n,".workflow.json"]}),(0,t.jsxs)("div",{className:"mt-0.5 text-sm text-[color:var(--ck-text-tertiary)]",children:["Team: ",e]})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("div",{className:"flex overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10",children:[(0,t.jsx)("button",{type:"button",onClick:()=>k("canvas"),className:"canvas"===b?"bg-white/10 px-3 py-2 text-xs font-medium text-[color:var(--ck-text-primary)]":"bg-transparent px-3 py-2 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:"Canvas"}),(0,t.jsx)("button",{type:"button",onClick:()=>k("json"),className:"json"===b?"bg-white/10 px-3 py-2 text-xs font-medium text-[color:var(--ck-text-primary)]":"bg-transparent px-3 py-2 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:"JSON"})]}),(0,t.jsx)("input",{ref:C,type:"file",accept:"application/json,.json",className:"hidden",onChange:async t=>{let r=t.target.files?.[0];if(t.target.value="",r){S("");try{let t=await r.text(),a=JSON.parse(t);if(j({kind:"ready",jsonText:JSON.stringify(a,null,2)+"\n"}),l)try{sessionStorage.setItem(i(e,n),JSON.stringify(a,null,2)+"\n")}catch{}}catch(e){S(e instanceof Error?e.message:String(e))}}}}),(0,t.jsx)("button",{type:"button",disabled:y,onClick:()=>C.current?.click(),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)] hover:bg-white/10 disabled:opacity-50",children:"Import"}),(0,t.jsx)("button",{type:"button",disabled:!e$.wf||!!e$.err||eM.errors.length>0,onClick:function(){if(!e$.wf||e$.err||eM.errors.length)return;let e=`${e$.wf.id||n}.workflow.json`,t=new Blob([JSON.stringify(e$.wf,null,2)+"\n"],{type:"application/json"}),r=URL.createObjectURL(t),a=document.createElement("a");a.href=r,a.download=e,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)},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)] hover:bg-white/10 disabled:opacity-50",children:"Export"}),(0,t.jsx)("button",{type:"button",disabled:y||!e$.wf||!!e$.err||eM.errors.length>0,onClick:eE,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:y?"Saving…":"Save"})]})]}),e$.err?(0,t.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-yellow-400/30 bg-yellow-500/10 p-3 text-sm text-yellow-100",children:["JSON parse error: ",e$.err]}):null,!e$.err&&eM.errors.length?(0,t.jsxs)("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:[(0,t.jsx)("div",{className:"font-medium",children:"Workflow validation errors"}),(0,t.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:eM.errors.map(e=>(0,t.jsx)("li",{children:e},e))})]}):null,e$.err||eM.errors.length||!eM.warnings.length?null:(0,t.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-yellow-400/30 bg-yellow-500/10 p-3 text-sm text-yellow-100",children:[(0,t.jsx)("div",{className:"font-medium",children:"Workflow validation warnings"}),(0,t.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:eM.warnings.map(e=>(0,t.jsx)("li",{children:e},e))})]}),N?(0,t.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:N}):null,(0,t.jsxs)("div",{className:"flex min-h-0 flex-1 gap-0",children:["json"===b?(0,t.jsx)("textarea",{value:w.jsonText,onChange:t=>{let r=t.target.value;if(j({kind:"ready",jsonText:r}),l)try{sessionStorage.setItem(i(e,n),r)}catch{}},className:"h-full min-h-0 w-full flex-1 resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]"}):(0,t.jsx)("div",{ref:M,className:"relative h-full min-h-0 w-full flex-1 overflow-auto bg-black/20",onWheel:e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();let t=e.deltaY>0?-1:1;$(e=>Math.max(.5,Math.min(2.5,Math.round((e+.1*t)*10)/10)))},onClick:e=>{if("add-node"!==B.kind)return;let t=e$.wf;if(!t)return;let r=M.current;if(!r)return;let a=e.target;if(a&&a.closest("[data-wf-node='1']"))return;let s=r.getBoundingClientRect(),o=(e.clientX-s.left+r.scrollLeft)/A,i=(e.clientY-s.top+r.scrollTop)/A,n=B.nodeType.replace(/[^a-z0-9_\-]/gi,"_"),l=new Set(t.nodes.map(e=>e.id)),d=1,c=`${n}_${d}`;for(;l.has(c);)d++,c=`${n}_${d}`;let x=Math.max(0,o-90),m=Math.max(0,i-24),p={id:c,type:B.nodeType,name:c,x,y:m,config:{}};eL({...t,nodes:[...t.nodes,p]}),L(c),z({kind:"select"})},children:(0,t.jsxs)("div",{className:"relative",style:{width:2200*A,height:1200*A},children:[(0,t.jsxs)("div",{className:T?"absolute left-3 top-3 z-20 w-[44px] overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/40 p-2 backdrop-blur":"absolute left-3 top-3 z-20 w-[260px] rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/40 p-2 backdrop-blur",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:T?"hidden":"text-[10px] font-medium uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Tools"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:T?"hidden":"flex items-center gap-1",children:[(0,t.jsx)("button",{type:"button",onClick:()=>$(e=>Math.max(.5,Math.round((e-.1)*10)/10)),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Zoom out (Ctrl/Cmd+wheel)",children:"-"}),(0,t.jsxs)("div",{className:"min-w-[42px] text-center text-[10px] text-[color:var(--ck-text-tertiary)]",children:[Math.round(100*A),"%"]}),(0,t.jsx)("button",{type:"button",onClick:()=>$(e=>Math.min(2.5,Math.round((e+.1)*10)/10)),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Zoom in (Ctrl/Cmd+wheel)",children:"+"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>I(e=>!e),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:T?"Expand":"Collapse",children:T?">":"<"})]})]}),T?(0,t.jsx)("div",{className:"mt-2 flex flex-col items-center gap-2",children:[{key:"select",label:"Select",active:"select"===B.kind,onClick:()=>{z({kind:"select"}),_("")},icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M5 4l7 16 2-7 7-2L5 4Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})},{key:"connect",label:"Connect",active:"connect"===B.kind,onClick:()=>{z(e=>"connect"===e.kind?{kind:"select"}:{kind:"connect"}),_("")},icon:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M10 13a5 5 0 0 1 0-7l1.2-1.2a5 5 0 0 1 7 7L17 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M14 11a5 5 0 0 1 0 7L12.8 19.2a5 5 0 1 1-7-7L7 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})},{key:"llm",label:"LLM",active:"add-node"===B.kind&&"llm"===B.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"llm"}),_("")},icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M12 2l1.5 6.5L20 10l-6.5 1.5L12 18l-1.5-6.5L4 10l6.5-1.5L12 2Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})},{key:"tool",label:"Tool",active:"add-node"===B.kind&&"tool"===B.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"tool"}),_("")},icon:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M14.5 7.5l2 2-8.5 8.5H6v-2l8.5-8.5Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M12 6a4 4 0 0 0-5 5l3-3 2 2 3-3A4 4 0 0 0 12 6Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})]})},{key:"condition",label:"If",active:"add-node"===B.kind&&"condition"===B.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"condition"}),_("")},icon:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M7 4v7a3 3 0 0 0 3 3h7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M17 10l3 3-3 3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})},{key:"delay",label:"Delay",active:"add-node"===B.kind&&"delay"===B.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"delay"}),_("")},icon:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M12 7v5l3 2",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),(0,t.jsx)("path",{d:"M21 12a9 9 0 1 1-9-9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})},{key:"approval",label:"Approval",active:"add-node"===B.kind&&"human_approval"===B.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"human_approval"}),_("")},icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M20 6 9 17l-5-5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})},{key:"end",label:"End",active:"add-node"===B.kind&&"end"===B.nodeType,onClick:()=>{z({kind:"add-node",nodeType:"end"}),_("")},icon:(0,t.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M7 7h10v10H7V7Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})}].map(e=>(0,t.jsx)("button",{type:"button",onClick:e.onClick,className:e.active?"flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] bg-white/10 text-[color:var(--ck-text-primary)]":"flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:e.label,"aria-label":e.label,children:e.icon},e.key))}):(0,t.jsxs)("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{z({kind:"select"}),_("")},className:"select"===B.kind?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",children:"Select"}),(0,t.jsx)("button",{type:"button",onClick:()=>{z({kind:"connect"}),_("")},className:"connect"===B.kind?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Click a node, then click another node to create an edge",children:"Connect"}),[{t:"llm",label:"LLM"},{t:"tool",label:"Tool"},{t:"condition",label:"If"},{t:"delay",label:"Delay"},{t:"human_approval",label:"Approve"},{t:"end",label:"End"}].map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{z({kind:"add-node",nodeType:e.t}),_("")},className:"add-node"===B.kind&&B.nodeType===e.t?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Select tool, then click on the canvas to place",children:["+ ",e.label]},e.t))]}),!T&&"connect"===B.kind&&U?(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Connecting from: ",(0,t.jsx)("span",{className:"font-mono",children:U})]}):null,T||"add-node"!==B.kind?null:(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Click on the canvas to place a ",(0,t.jsx)("span",{className:"font-mono",children:B.nodeType})," node."]}),(0,t.jsxs)("div",{className:"mt-3 border-t border-white/10 pt-3",children:[(0,t.jsxs)("div",{className:T?"hidden":"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-[10px] font-medium uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Agents"}),(0,t.jsx)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:"drag → node"})]}),T?(0,t.jsx)("button",{type:"button",onClick:()=>I(!1),className:"mt-2 flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Expand to see agents","aria-label":"Expand to see agents",children:(0,t.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,t.jsx)("path",{d:"M16 11a4 4 0 1 0-8 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,t.jsx)("path",{d:"M4 20a8 8 0 0 1 16 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}):(0,t.jsxs)(t.Fragment,{children:[D?(0,t.jsx)("div",{className:"mt-1 text-[11px] text-red-200",children:D}):null,(0,t.jsx)("div",{className:"mt-2 max-h-[140px] space-y-1 overflow-auto",children:W.length?W.map(r=>(0,t.jsx)("div",{draggable:!0,onDragStart:e=>{e.dataTransfer.setData("text/plain",r.id),e.dataTransfer.effectAllowed="copy"},className:"cursor-grab rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:r.id,children:r.identityName?r.identityName:r.id.replace(`${e}-`,"")},r.id)):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"No team agents found."})})]})]})]}),(0,t.jsxs)("div",{className:"relative h-[1200px] w-[2200px]",style:{transform:`scale(${A})`,transformOrigin:"0 0"},children:[(0,t.jsx)("svg",{className:"pointer-events-none absolute inset-0 -z-10",width:2200,height:1200,style:{overflow:"visible"},children:(e$.wf?.edges??[]).map(e=>{let r=e$.wf;if(!r)return null;let a=r.nodes.find(t=>t.id===e.from),s=r.nodes.find(t=>t.id===e.to);if(!a||!s)return null;let o=("number"==typeof a.x?a.x:80)+90,i=("number"==typeof a.y?a.y:80)+24,n=("number"==typeof s.x?s.x:80)+90,l=("number"==typeof s.y?s.y:80)+24;return(0,t.jsx)("line",{x1:o,y1:i,x2:n,y2:l,stroke:"rgba(255,255,255,0.35)",strokeWidth:3},e.id)})}),(e$.wf?.nodes??[]).map((r,a)=>{let s="number"==typeof r.x?r.x:80+220*a,o="number"==typeof r.y?r.y:80,i=O===r.id;return(0,t.jsxs)("div",{role:"button",tabIndex:0,"data-wf-node":"1",draggable:"select"===B.kind||"connect"===B.kind,onDragStart:e=>{"select"===B.kind&&e.dataTransfer.setData("text/plain","")},onDragOver:e=>{e.dataTransfer.types.includes("text/plain")&&e.preventDefault()},onDrop:e=>{let t=e$.wf;if(!t)return;e.preventDefault(),e.stopPropagation();let a=String(e.dataTransfer.getData("text/plain")||"").trim();if(!a)return;let s=t.nodes.map(e=>{if(e.id!==r.id)return e;let t=e.config&&"object"==typeof e.config&&!Array.isArray(e.config)?e.config:{};return{...e,config:{...t,agentId:a}}});eL({...t,nodes:s}),L(r.id)},onClick:e=>{e.stopPropagation();let t=e$.wf;if("connect"===B.kind){if(!t)return;if(!U){_(r.id),L(r.id);return}let e=r.id;if(_(""),!U||!e||U===e||(t.edges??[]).some(t=>t.from===U&&t.to===e))return;let a=`e${Date.now()}`;eL({...t,edges:[...t.edges??[],{id:a,from:U,to:e}]}),z({kind:"select"});return}L(r.id)},onPointerDown:e=>{if("add-node"===B.kind||0!==e.button)return;let t=M.current;if(!t)return;let a=t.getBoundingClientRect();L(r.id);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}e.preventDefault();let i=(e.clientX-a.left+t.scrollLeft)/A,n=(e.clientY-a.top+t.scrollTop)/A;R({nodeId:r.id,dx:i-s,dy:n-o})},onPointerUp:e=>{try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}R(null)},onPointerMove:e=>{if(!E||E.nodeId!==r.id)return;let t=e$.wf;if(!t)return;let a=M.current;if(!a)return;let s=a.getBoundingClientRect(),o=(e.clientX-s.left+a.scrollLeft)/A,i=(e.clientY-s.top+a.scrollTop)/A,n=o-E.dx,l=i-E.dy,d=t.nodes.map(e=>e.id===r.id?{...e,x:n,y:l}:e);j({kind:"ready",jsonText:JSON.stringify({...t,nodes:d},null,2)+"\n"})},className:i?"absolute z-10 cursor-grab rounded-[var(--ck-radius-sm)] border border-white/25 bg-white/10 px-3 py-2 text-xs text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)]":"absolute z-10 cursor-grab rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",style:{left:s,top:o,width:180},children:[(0,t.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:r.name||r.id}),(0,t.jsx)("div",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:r.type}),(()=>{let a=r.config&&"object"==typeof r.config&&!Array.isArray(r.config)?r.config:null,s=a?String(a.agentId??"").trim():"";if(!s)return null;let o=s.replace(`${e}-`,"");return(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-secondary)]",children:["Agent: ",o]})})()]},r.id)}),(()=>{let e=e$.wf;if(!e||!O)return null;let r=e.nodes.find(e=>e.id===O);if(!r)return null;let a="number"==typeof r.x?r.x:80,s="number"==typeof r.y?r.y:80,o=r.config&&"object"==typeof r.config&&!Array.isArray(r.config)?r.config:{},i=String(o.agentId??"").trim();return(0,t.jsxs)("div",{className:"absolute z-10 w-[320px] rounded-[var(--ck-radius-sm)] border border-white/15 bg-black/60 p-3 shadow-[var(--ck-shadow-1)] backdrop-blur",style:{left:a+200,top:s},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-primary)]",children:r.name||r.id}),(0,t.jsx)("button",{type:"button",onClick:()=>L(""),className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Close"})]}),(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name"}),(0,t.jsx)("input",{value:String(r.name??""),onChange:t=>{let a=t.target.value;eL({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,name:a}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Optional"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,t.jsxs)("select",{value:r.type,onChange:t=>{let a=t.target.value;eL({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,type:a}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"start",children:"start"}),(0,t.jsx)("option",{value:"end",children:"end"}),(0,t.jsx)("option",{value:"llm",children:"llm"}),(0,t.jsx)("option",{value:"tool",children:"tool"}),(0,t.jsx)("option",{value:"condition",children:"condition"}),(0,t.jsx)("option",{value:"delay",children:"delay"}),(0,t.jsx)("option",{value:"human_approval",children:"human_approval"})]})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"agentId"}),(0,t.jsx)("input",{value:i,onChange:t=>{let a=String(t.target.value||"").trim(),s={...o,...a?{agentId:a}:{}};a||delete s.agentId,eL({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:s}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"(drag an agent onto the node or type)"})]}),"human_approval"===r.type?(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"approval config"}),(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"provider"}),(0,t.jsx)("input",{value:String(o.provider??""),onChange:t=>{let a=String(t.target.value||"").trim(),s={...o,...a?{provider:a}:{}};a||delete s.provider,eL({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:s}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"telegram"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"target"}),(0,t.jsx)("input",{value:String(o.target??""),onChange:t=>{let a=String(t.target.value||"").trim(),s={...o,...a?{target:a}:{}};a||delete s.target,eL({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:s}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"(e.g. Telegram chat id)"}),(0,t.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Overrides workflow-level default when set."})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"messageTemplate (optional)"}),(0,t.jsx)("textarea",{value:String(o.messageTemplate??""),onChange:t=>{let a=String(t.target.value||""),s={...o,...a.trim()?{messageTemplate:a}:{}};a.trim()||delete s.messageTemplate,eL({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:s}:e)})},className:"mt-1 h-[70px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 font-mono text-[10px] text-[color:var(--ck-text-primary)]",placeholder:"Approval needed for {{workflowName}} (run {{runId}})",spellCheck:!1}),(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["Vars: ","{{workflowName}}",", ","{{workflowId}}",", ","{{runId}}",", ","{{nodeId}}"]})]})]})]}):null,(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"config (json)"}),(0,t.jsx)("textarea",{value:JSON.stringify(o,null,2),onChange:t=>{try{let a=JSON.parse(t.target.value);if(!a||"object"!=typeof a||Array.isArray(a))return;eL({...e,nodes:e.nodes.map(e=>e.id===r.id?{...e,config:a}:e)})}catch{}},className:"mt-1 h-[140px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 font-mono text-[10px] text-[color:var(--ck-text-primary)]",spellCheck:!1}),(0,t.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"(Edits apply when JSON is valid.)"})]})]})]})})()]})]})}),(0,t.jsx)("div",{className:"w-[380px] shrink-0 overflow-auto p-3 text-sm",children:(0,t.jsx)("div",{className:"space-y-3",children:e$.wf?(c=String((d=e$.wf).timezone??"").trim()||"UTC",x=d.triggers??[],p=String((m=d.meta&&"object"==typeof d.meta&&!Array.isArray(d.meta)?d.meta:{}).approvalBindingId??"").trim(),u=String(m.approvalProvider??"telegram").trim()||"telegram",h=String(m.approvalTarget??"").trim(),g=[{label:"(no preset)",expr:""},{label:"Weekdays 09:00 local",expr:"0 9 * * 1-5"},{label:"Mon/Wed/Fri 09:00 local",expr:"0 9 * * 1,3,5"},{label:"Daily 08:00 local",expr:"0 8 * * *"},{label:"Daily 12:00 local",expr:"0 12 * * *"},{label:"Mon 09:30 local",expr:"30 9 * * 1"}],(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Workflow"}),(0,t.jsx)("div",{className:"px-3 pb-3",children:(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[11px] font-medium text-[color:var(--ck-text-tertiary)]",children:"Timezone"}),(0,t.jsx)("input",{value:c,onChange:e=>{let t=String(e.target.value||"").trim()||"UTC";eL({...d,timezone:t})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-sm text-[color:var(--ck-text-primary)]",placeholder:"America/New_York"})]})})]}),(0,t.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Approval Channel"}),(0,t.jsxs)("div",{className:"px-3 pb-3 space-y-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"binding (recommended)"}),(0,t.jsxs)("select",{value:p,onChange:e=>{let t=String(e.target.value||"").trim(),r=F.find(e=>e.id===t);r?eL({...d,meta:{...m,approvalBindingId:r.id,approvalProvider:r.channel,approvalTarget:r.target}}):eL({...d,meta:{...m,approvalBindingId:""}})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"",children:"(manual)"}),F.map(e=>(0,t.jsx)("option",{value:e.id,children:e.label},e.id))]}),Y?(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-yellow-200",children:["Kitchen looks out of date. Run ",(0,t.jsx)("code",{className:"font-mono",children:"openclaw plugins update"})," then",(0,t.jsx)("code",{className:"ml-1 font-mono",children:"openclaw gateway restart"}),"."]}):null,K?(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-red-200",children:["Failed to load bindings: ",K]}):null,(0,t.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Uses your existing OpenClaw bindings (recommended). Manual provider/target is an advanced override."})]}),(0,t.jsxs)("details",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-secondary)]",children:"Advanced: manual override"}),(0,t.jsxs)("div",{className:"px-2 pb-2 pt-1 space-y-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"provider"}),(0,t.jsx)("input",{value:u,onChange:e=>{let t=String(e.target.value||"").trim()||"telegram";eL({...d,meta:{...m,approvalBindingId:"",approvalProvider:t}})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"telegram"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"target"}),(0,t.jsx)("input",{value:h,onChange:e=>{let t=String(e.target.value||"").trim();eL({...d,meta:{...m,approvalBindingId:"",approvalTarget:t}})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"(e.g. Telegram chat id)"})]})]})]})]})]}),(0,t.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Triggers"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"triggers"}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=`t${Date.now()}`;eL({...d,triggers:[...x,{kind:"cron",id:e,name:"New trigger",enabled:!0,expr:"0 9 * * 1-5",tz:c}]})},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"+ Add"})]}),(0,t.jsx)("div",{className:"mt-2 space-y-2",children:x.length?x.map((e,r)=>{let a=e.kind,s=String(e.id??""),o=String(e.name??""),i=!!e.enabled,n=String(e.expr??""),l=String(e.tz??c),m=n.trim().split(/\s+/).filter(Boolean),p=!n.trim()||5===m.length;return(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-primary)]",children:o||s||`trigger-${r+1}`}),(0,t.jsx)("button",{type:"button",onClick:()=>eL({...d,triggers:x.filter((e,t)=>t!==r)}),className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Remove"})]}),"cron"===a?null:(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Unsupported trigger kind: ",String(a)]}),(0,t.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-xs text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("input",{type:"checkbox",checked:i,onChange:e=>{let t=e.target.checked;eL({...d,triggers:x.map((e,a)=>a===r&&"cron"===e.kind?{...e,enabled:t}:e)})}}),"Enabled"]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name"}),(0,t.jsx)("input",{value:o,onChange:e=>{let t=e.target.value;eL({...d,triggers:x.map((e,a)=>a===r&&"cron"===e.kind?{...e,name:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Content cadence"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"schedule (cron)"}),(0,t.jsx)("input",{value:n,onChange:e=>{let t=e.target.value;eL({...d,triggers:x.map((e,a)=>a===r&&"cron"===e.kind?{...e,expr:t}:e)})},className:p?"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 font-mono text-[11px] text-[color:var(--ck-text-primary)]":"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-red-400/50 bg-black/25 px-2 py-1 font-mono text-[11px] text-[color:var(--ck-text-primary)]",placeholder:"0 9 * * 1,3,5"}),p?null:(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-red-200",children:["Cron should be 5 fields (min hour dom month dow). You entered ",m.length,"."]}),(0,t.jsxs)("div",{className:"mt-1 grid grid-cols-1 gap-1",children:[(0,t.jsx)("select",{value:g.some(e=>e.expr===n)?n:"",onChange:e=>{let t=e.target.value;eL({...d,triggers:x.map((e,a)=>a===r&&"cron"===e.kind?{...e,expr:t}:e)})},className:"w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-[11px] text-[color:var(--ck-text-secondary)]",children:g.map(e=>(0,t.jsx)("option",{value:e.expr,children:e.label},e.label))}),(0,t.jsx)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Presets set the cron; edit freely for advanced schedules."})]})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"timezone override"}),(0,t.jsx)("input",{value:l,onChange:e=>{let t=String(e.target.value||"").trim()||c;eL({...d,triggers:x.map((e,a)=>a===r&&"cron"===e.kind?{...e,tz:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:c})]})]})]},`${s}-${r}`)}):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No triggers yet."})})]})]}),(0,t.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Runs"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Runs (history)"}),(0,t.jsx)(a.default,{href:`/teams/${encodeURIComponent(e)}/runs`,className:"text-[10px] font-medium text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-secondary)] hover:underline",children:"View all →"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",disabled:y,onClick:async()=>{let t=String(d.id??"").trim();if(t){ee(""),Q(!0);try{let r=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,workflowId:t,mode:"enqueue"})}),a=await r.json();if(!r.ok||!a.ok)throw Error(a.error||"Failed to enqueue run");let s=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(e)}&workflowId=${encodeURIComponent(t)}`,{cache:"no-store"}),o=await s.json();if(!s.ok||!o.ok)throw Error(o.error||"Failed to refresh runs");let i=(Array.isArray(o.files)?o.files:[]).map(e=>String(e??"").trim()).filter(e=>!!e);H(i)}catch(e){ee(e instanceof Error?e.message:String(e))}finally{Q(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"+ Queue run"}),(0,t.jsx)("button",{type:"button",disabled:y||ea||!eO.ok,onClick:async()=>{let t=String(d.id??"").trim();if(t){if(eO.missingAgentOnNodeIds.length)return void ee("All nodes must be assigned to an agent.");if(eO.agentIdsMissingCron.length){em(!0),eu("");try{let t=await fetch("/api/cron/worker",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"reconcile",teamId:e})}),r=await t.json();if(!t.ok||!1===r.ok)throw Error(r.error||"Failed to reconcile worker crons");let a=await eA(),s=eO.requiredAgentIds.filter(e=>!a[e]);if(s.length)return void ee(`Cron not set up for: ${s.join(", ")}`)}catch(e){ee(e instanceof Error?e.message:String(e));return}finally{em(!1)}}ee(""),Q(!0);try{let r=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,workflowId:t,mode:"run_now"})}),a=await r.json();if(!r.ok||!a.ok)throw Error(a.error||"Failed to create run");let s=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(e)}&workflowId=${encodeURIComponent(t)}`,{cache:"no-store"}),o=await s.json();if(!s.ok||!o.ok)throw Error(o.error||"Failed to refresh runs");let i=(Array.isArray(o.files)?o.files:[]).map(e=>String(e??"").trim()).filter(e=>!!e);H(i)}catch(e){ee(e instanceof Error?e.message:String(e))}finally{Q(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 px-2 py-1 text-[10px] font-medium text-emerald-50 hover:bg-emerald-500/15 disabled:opacity-50",title:"Enqueue a run for the workflow runner (Kitchen does not execute nodes)",children:"+ Run now"}),eo?(0,t.jsx)("div",{className:"ml-2 text-[10px] text-amber-100/90",title:eo,children:"Cron check unavailable"}):null]})]}),eO.missingAgentOnNodeIds.length?(0,t.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:["All nodes must be assigned to an agent. Missing agentId on: ",eO.missingAgentOnNodeIds.join(", ")]}):eO.agentIdsMissingCron.length?(0,t.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-2 text-xs text-amber-50",children:[(0,t.jsxs)("div",{children:["Cron not set up for: ",eO.agentIdsMissingCron.join(", ")]}),(0,t.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{eu(""),ec(!0)},className:"rounded-[var(--ck-radius-sm)] border border-amber-300/30 bg-amber-500/10 px-2 py-1 text-[10px] font-medium text-amber-50 hover:bg-amber-500/15",children:"Install worker cron(s)"}),(0,t.jsx)("button",{type:"button",onClick:()=>void eA(),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Re-check"})]})]}):null,(0,t.jsx)(s.ConfirmationModal,{open:ed,title:"Install worker cron jobs?",busy:ex,error:ep||void 0,confirmLabel:"Install",onClose:()=>{ex||ec(!1)},onConfirm:async()=>{em(!0),eu("");try{let t=await fetch("/api/cron/worker",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"reconcile",teamId:e})}),r=await t.json();if(!t.ok||!1===r.ok)throw Error(r.error||"Failed to install worker crons");await eA(),ec(!1)}catch(e){eu(e instanceof Error?e.message:String(e))}finally{em(!1)}},children:(0,t.jsxs)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:["Kitchen will install (or enable) worker cron jobs for the following agents so this workflow can drain:",(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 font-mono text-[11px] text-[color:var(--ck-text-primary)]",children:eO.agentIdsMissingCron.join(", ")}),(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Cron cadence: 1 minute. The worker runs: ",(0,t.jsx)("span",{className:"font-mono",children:"openclaw recipes workflows worker-tick"}),"."]})]})}),G?(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:G}):null,(0,t.jsx)("div",{className:"mt-2 space-y-1",children:X?(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Loading runs…"}):V.length?V.slice(0,8).map(r=>{let s=String(d.id??"").trim(),o=String(r).replace(/\.run\.json$/i,""),i=et===o,n=s?`/teams/${encodeURIComponent(e)}/runs/${encodeURIComponent(s)}/${encodeURIComponent(o)}`:"#";return(0,t.jsx)(a.default,{href:n,onClick:()=>er(o),className:i?"block w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] font-mono text-[color:var(--ck-text-primary)]":"block w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] font-mono text-[color:var(--ck-text-secondary)] hover:bg-white/5",title:"Open run detail",children:o},r)}):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No runs yet."})}),(0,t.jsxs)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Nodes"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"id"}),(0,t.jsx)("input",{value:eh,onChange:e=>eg(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"e.g. draft_assets"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name (optional)"}),(0,t.jsx)("input",{value:ev,onChange:e=>eb(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Human-friendly label"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,t.jsxs)("select",{value:ek,onChange:e=>ey(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"start",children:"start"}),(0,t.jsx)("option",{value:"end",children:"end"}),(0,t.jsx)("option",{value:"llm",children:"llm"}),(0,t.jsx)("option",{value:"tool",children:"tool"}),(0,t.jsx)("option",{value:"condition",children:"condition"}),(0,t.jsx)("option",{value:"delay",children:"delay"}),(0,t.jsx)("option",{value:"human_approval",children:"human_approval"})]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=String(eh||"").trim().replace(/[^a-z0-9_\-]/gi,"_");if(!e||d.nodes.some(t=>t.id===e))return;let t=d.nodes.reduce((e,t)=>"number"==typeof t.x?Math.max(e,t.x):e,80),r={id:e,type:ek,name:String(ev||"").trim()||e,x:t+220,y:80};eL({...d,nodes:[...d.nodes,r]}),L(e),eg(""),eb("")},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"+ Add node"})]})}),(0,t.jsx)("div",{className:"mt-2 space-y-1",children:d.nodes.map(e=>{let r=O===e.id;return(0,t.jsxs)("button",{type:"button",onClick:()=>L(e.id),className:r?"w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-primary)]":"w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:[(0,t.jsx)("span",{className:"font-mono",children:e.id}),(0,t.jsx)("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:e.type})]},e.id)})})]})]}),(0,t.jsxs)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Edges"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"from"}),(0,t.jsxs)("select",{value:ef,onChange:e=>ew(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"",children:"(select)"}),d.nodes.map(e=>(0,t.jsx)("option",{value:e.id,children:e.id},e.id))]})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"to"}),(0,t.jsxs)("select",{value:ej,onChange:e=>eN(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"",children:"(select)"}),d.nodes.map(e=>(0,t.jsx)("option",{value:e.id,children:e.id},e.id))]})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"label (optional)"}),(0,t.jsx)("input",{value:eS,onChange:e=>eC(e.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"e.g. approve"})]}),(0,t.jsx)("button",{type:"button",onClick:()=>{let e=String(ef||"").trim(),t=String(ej||"").trim();if(!e||!t||e===t)return;let r={id:`e${Date.now()}`,from:e,to:t,...String(eS||"").trim()?{label:String(eS).trim()}:{}};eL({...d,edges:[...d.edges??[],r]}),eC("")},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"+ Add edge"})]})}),(0,t.jsx)("div",{className:"mt-2 space-y-2",children:(d.edges??[]).length?(d.edges??[]).map(e=>(0,t.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"text-[11px] text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.from})," → ",(0,t.jsx)("span",{className:"font-mono",children:e.to}),e.label?(0,t.jsxs)("span",{className:"ml-2 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["(",e.label,")"]}):null]}),(0,t.jsx)("button",{type:"button",onClick:()=>eL({...d,edges:(d.edges??[]).filter(t=>t.id!==e.id)}),className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Remove"})]})},e.id)):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No edges yet."})})]})]}),(0,t.jsxs)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,t.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Node inspector"}),(0,t.jsxs)("div",{className:"px-3 pb-3",children:[(0,t.jsx)("div",{className:"flex items-center justify-between gap-2",children:O?(0,t.jsx)("button",{type:"button",onClick:()=>{let e=d.nodes.filter(e=>e.id!==O),t=(d.edges??[]).filter(e=>e.from!==O&&e.to!==O);eL({...d,nodes:e,edges:t}),L("")},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-red-100 hover:bg-white/10",children:"Delete node"}):null}),O?(v=d.nodes.find(e=>e.id===O))?(0,t.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"id"}),(0,t.jsx)("div",{className:"mt-1 rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:v.id})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name"}),(0,t.jsx)("input",{value:String(v.name??""),onChange:e=>{let t=e.target.value;eL({...d,nodes:d.nodes.map(e=>e.id===v.id?{...e,name:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Optional"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,t.jsxs)("select",{value:v.type,onChange:e=>{let t=e.target.value;eL({...d,nodes:d.nodes.map(e=>e.id===v.id?{...e,type:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,t.jsx)("option",{value:"start",children:"start"}),(0,t.jsx)("option",{value:"end",children:"end"}),(0,t.jsx)("option",{value:"llm",children:"llm"}),(0,t.jsx)("option",{value:"tool",children:"tool"}),(0,t.jsx)("option",{value:"condition",children:"condition"}),(0,t.jsx)("option",{value:"delay",children:"delay"}),(0,t.jsx)("option",{value:"human_approval",children:"human_approval"})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"x"}),(0,t.jsx)("input",{type:"number",value:"number"==typeof v.x?v.x:0,onChange:e=>{let t=Number(e.target.value);eL({...d,nodes:d.nodes.map(e=>e.id===v.id?{...e,x:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]"})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"y"}),(0,t.jsx)("input",{type:"number",value:"number"==typeof v.y?v.y:0,onChange:e=>{let t=Number(e.target.value);eL({...d,nodes:d.nodes.map(e=>e.id===v.id?{...e,y:t}:e)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"config"}),(0,t.jsx)("pre",{className:"mt-1 max-h-[200px] overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-[10px] text-[color:var(--ck-text-secondary)]",children:JSON.stringify(v.config??{},null,2)})]})]}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No node selected."}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"Select a node."})]})]})]})]})]})):null})})]})]})}e.s(["default",()=>n],87090)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,82310,e=>{"use strict";function t(e){return e instanceof Error?e.message:String(e)}e.s(["errorMessage",()=>t])},36288,e=>{"use strict";var t=e.i(43476),s=e.i(22016),r=e.i(18566),a=e.i(71645),c=e.i(76972),o=e.i(82310),n=e.i(42771);function l({teamId:e,ticket:s,currentOwner:c}){let o=(0,r.useRouter)(),[n,l]=(0,a.useState)([]),[i,d]=(0,a.useState)(c??""),[m,x]=(0,a.useState)(!1),[u,b]=(0,a.useState)(null);(0,a.useEffect)(()=>{let t=!1;return(async()=>{try{let s=e?`/api/teams/${encodeURIComponent(e)}/tickets/assignees`:"/api/tickets/assignees",r=await fetch(s,{cache:"no-store"}),a=await r.json();if(t)return;l(Array.isArray(a.assignees)?a.assignees:[])}catch{if(t)return;l([])}})(),()=>{t=!0}},[]);let h=(0,a.useMemo)(()=>{let e=new Set(n);return c&&e.add(c),Array.from(e).sort()},[n,c]);async function p(){x(!0),b(null);try{let t=e?`/api/teams/${encodeURIComponent(e)}/tickets/assign`:"/api/tickets/assign",r=await fetch(t,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:s,assignee:i})}),a=await r.json();if(!r.ok)return void b(a.error||"Assign failed");o.refresh()}catch{b("Assign failed")}finally{x(!1)}}return(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Assignee"}),(0,t.jsxs)("select",{className:"rounded-md border border-white/10 bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",value:i,onChange:e=>d(e.target.value),children:[(0,t.jsx)("option",{value:"",disabled:!0,children:"Select…"}),h.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]}),(0,t.jsx)("button",{type:"button",onClick:p,disabled:m||!i||i===(c??""),className:"rounded-md bg-emerald-600 px-3 py-2 text-sm font-semibold text-white hover:bg-emerald-500 disabled:cursor-not-allowed disabled:opacity-50",children:m?"Assigning…":"Assign"}),c?(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Currently: ",c]}):null]}),u?(0,t.jsx)("div",{className:"mt-2 text-xs text-red-300",children:u}):null]})}function i(e){let i=(0,r.useRouter)(),d=(0,c.useToast)(),[m,x]=(0,a.useTransition)(),[u,b]=(0,a.useState)(null),[h,p]=(0,a.useState)(null),k=(0,a.useMemo)(()=>(function(e){let t=function(e){let t=/^## Comments\s*$/gim.exec(e);if(!t)return null;let s=t.index+t[0].length,r=e.slice(s).search(/^##\s+/m),a=-1===r?e.length:s+r;return{start:s,end:a}}(e);if(!t)return[];let s=e.slice(t.start,t.end).replace(/^\s+/,"").split("\n"),r=[],a=null,c=/^- \*\*(.+?)\*\*\s+—\s+(.*)$/;for(let e of s){let t=e.replace(/\r$/,""),s=t.match(c);if(s){a&&r.push({...a,body:a.body.trimEnd()});let e=s[1].trim(),t=s[2].trim(),c=t.indexOf(":"),o=(c>=0?t.slice(0,c):t).trim()||"unknown",n=c>=0?t.slice(c+1).trimStart():"";a={timestamp:e,author:o,body:n?n+"\n":""};continue}a&&(a.body+=t.replace(/^\s{0,2}/,"")+"\n")}return a&&r.push({...a,body:a.body.trimEnd()}),r})(e.markdown),[e.markdown]),[v,f]=(0,a.useState)(""),[g,y]=(0,a.useState)("");async function j(){b(null),await (0,n.fetchJson)(`/api/teams/${encodeURIComponent(e.teamId)}/tickets/move-to-goals`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:e.ticketId})})}async function N(){b(null),await (0,n.fetchJson)(`/api/teams/${encodeURIComponent(e.teamId)}/tickets/delete`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:e.ticketId})})}async function w(){b(null);let t=g.trim();if(!t)throw Error("Comment cannot be empty.");await (0,n.fetchJson)(`/api/teams/${encodeURIComponent(e.teamId)}/tickets/comment`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ticket:e.ticketId,author:v.trim()||void 0,comment:t})}),y(""),d.push({kind:"success",message:"Comment added."}),i.refresh()}return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)(s.default,{href:e.backHref??"/tickets",className:"text-sm font-medium hover:underline",children:"← Back"}),(0,t.jsx)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:e.file})]}),u?(0,t.jsx)("div",{className:"ck-glass border border-[color:var(--ck-border-strong)] p-3 text-sm text-[color:var(--ck-text-primary)]",children:u}):null,void 0!==e.currentOwner?(0,t.jsx)(l,{teamId:e.teamId,ticket:e.ticketId,currentOwner:e.currentOwner??null}):null,(0,t.jsx)("div",{className:"ck-glass p-4",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(0,t.jsx)("button",{className:"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-text-secondary)] hover:border-[color:var(--ck-border-strong)]",onClick:()=>p({kind:"goals"}),disabled:m,children:"Move to Goals"}),(0,t.jsx)("button",{className:"rounded border border-[color:var(--ck-accent-red)] bg-[color:var(--ck-accent-red-soft)] px-3 py-1.5 text-xs font-medium text-[color:var(--ck-accent-red)] hover:bg-[color:var(--ck-accent-red-soft-strong)]",onClick:()=>p({kind:"delete"}),disabled:m,children:"Delete Ticket"})]})}),(0,t.jsxs)("div",{className:"ck-glass p-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Comments"}),(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:k.length})]}),k.length?(0,t.jsx)("div",{className:"mt-3 space-y-3",children:k.map((e,s)=>(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-[color:var(--ck-border-subtle)] bg-black/10 p-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-primary)]",children:e.author}),(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:e.timestamp})]}),(0,t.jsx)("div",{className:"mt-2 whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-secondary)]",children:e.body})]},`${e.timestamp}-${s}`))}):(0,t.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"No comments yet."}),(0,t.jsxs)("div",{className:"mt-4 border-t border-[color:var(--ck-border-subtle)] pt-4",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"Add comment"}),(0,t.jsxs)("div",{className:"mt-3 grid gap-3",children:[(0,t.jsxs)("div",{className:"grid gap-1",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",htmlFor:"ck-comment-author",children:"Author (optional)"}),(0,t.jsx)("input",{id:"ck-comment-author",value:v,onChange:e=>f(e.target.value),placeholder:"unknown",className:"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]",disabled:m})]}),(0,t.jsxs)("div",{className:"grid gap-1",children:[(0,t.jsx)("label",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",htmlFor:"ck-comment-body",children:"Comment"}),(0,t.jsx)("textarea",{id:"ck-comment-body",value:g,onChange:e=>y(e.target.value),rows:4,className:"w-full rounded border border-[color:var(--ck-border-subtle)] bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] outline-none focus:border-[color:var(--ck-border-strong)]",disabled:m})]}),(0,t.jsx)("div",{className:"flex items-center justify-end",children:(0,t.jsx)("button",{className:"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-semibold text-black disabled:opacity-50",onClick:()=>{x(()=>{w().catch(e=>b((0,o.errorMessage)(e)))})},disabled:m||!g.trim(),children:"Post comment"})})]})]})]}),(0,t.jsx)("div",{className:"ck-glass p-6",children:(0,t.jsx)("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-[color:var(--ck-text-primary)]",children:e.markdown})}),h?(0,t.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",children:(0,t.jsxs)("div",{className:"ck-glass w-full max-w-lg rounded-[var(--ck-radius-md)] border border-[color:var(--ck-border-strong)] p-4",children:[(0,t.jsx)("div",{className:"text-sm font-semibold text-[color:var(--ck-text-primary)]",children:"goals"===h.kind?"Move to Goals":"Delete ticket"}),(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"goals"===h.kind?(0,t.jsxs)(t.Fragment,{children:["This will move the ticket out of the work lanes into ",(0,t.jsx)("code",{children:"work/goals/"})," so it won’t be picked up by automation."]}):(0,t.jsx)(t.Fragment,{children:"This will permanently remove the ticket markdown file. Assignment stubs (if any) will be archived."})}),(0,t.jsxs)("div",{className:"mt-4 flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{className:"rounded border border-[color:var(--ck-border-subtle)] px-3 py-1.5 text-xs text-[color:var(--ck-text-secondary)]",onClick:()=>p(null),disabled:m,children:"Cancel"}),(0,t.jsx)("button",{className:"delete"===h.kind?"rounded bg-[color:var(--ck-accent-red)] px-3 py-1.5 text-xs font-medium text-white":"rounded bg-[color:var(--ck-accent)] px-3 py-1.5 text-xs font-medium text-black",onClick:()=>{let t=h.kind;p(null),x(()=>{("goals"===t?j():N()).then(()=>{d.push({kind:"success",message:"delete"===t?"Ticket deleted.":"Moved to Goals."}),"delete"===t?i.push(e.backHref??"/tickets"):i.refresh()}).catch(e=>b((0,o.errorMessage)(e)))})},disabled:m,children:"Confirm"})]})]})}):null]})}e.s(["TicketDetailClient",()=>i],36288)}]);
@@ -1,10 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,86103,e=>{"use strict";var t=e.i(43476),s=e.i(71645);e.i(22258);var a=e.i(94988),r=e.i(18566),i=e.i(54510),l=e.i(44355);function o({open:e,teamId:s,recipeId:a,onClose:r,onConfirm:i,busy:o}){return(0,t.jsxs)(l.ConfirmationModal,{open:e,onClose:r,title:"Publish changes",confirmLabel:"Publish changes",confirmBusyLabel:"Publishing…",busy:o,onConfirm:i,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,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["This will re-scaffold team ",(0,t.jsx)("code",{className:"font-mono",children:s})," from recipe ",(0,t.jsx)("code",{className:"font-mono",children:a}),"."]}),(0,t.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,t.jsx)("div",{className:"font-medium",children:"Complete overwrite"}),(0,t.jsxs)("div",{className:"mt-1",children:["All existing team workspace files managed by the recipe will be overwritten (for example: ",(0,t.jsx)("code",{className:"font-mono",children:"AGENTS.md"}),","," ",(0,t.jsx)("code",{className:"font-mono",children:"SOUL.md"}),", role templates, and other scaffolded files). Any manual edits in those files will be lost."]})]})]})}var c=e.i(76972),n=e.i(82310),d=e.i(42771);function m(e,t){try{return JSON.parse(e)}catch{return t}}async function x(e){let[t,s]=await Promise.all([(0,d.fetchJson)("/api/recipes",{cache:"no-store"}),fetch(`/api/teams/meta?teamId=${encodeURIComponent(e)}`,{cache:"no-store"})]);return{recipesData:t,metaRes:s}}async function h(e){let t=await (0,d.fetchAll)([`/api/teams/files?teamId=${encodeURIComponent(e)}`,`/api/cron/jobs?teamId=${encodeURIComponent(e)}`,"/api/agents",`/api/teams/skills?teamId=${encodeURIComponent(e)}`,"/api/skills/available"]),s=await Promise.all(t.map(e=>e.text()));return{responses:t,texts:s}}async function p(e,t){t.setTeamFilesLoading(!0),t.setCronLoading(!0),t.setTeamAgentsLoading(!0),t.setSkillsLoading(!0);try{let{responses:s,texts:a}=await h(e),[r,i,l,o,c]=s,[n,d,x,p,u]=a,v=m(n,{});r.ok&&v.ok&&Array.isArray(v.files)&&t.setTeamFiles(v.files.map(e=>({name:String(e.name??""),missing:!!e.missing,required:!!e.required,rationale:"string"==typeof e.rationale?e.rationale:void 0})));let g=m(d,{});i.ok&&g.ok&&Array.isArray(g.jobs)&&t.setCronJobs(g.jobs);let k=m(x,{});if(l.ok&&Array.isArray(k.agents)){let s=k.agents.filter(t=>String(t.id??"").startsWith(`${e}-`));t.setTeamAgents(s.map(e=>({id:String(e.id??""),identityName:"string"==typeof e.identityName?e.identityName:void 0})))}let f=m(p,{});o.ok&&f.ok&&Array.isArray(f.skills)&&t.setSkillsList(f.skills);let y=m(u,{});if(c.ok&&y.ok&&Array.isArray(y.skills)){let e=y.skills;t.setAvailableSkills(e),t.setSelectedSkill(t=>{let s=String(t??"").trim();return s&&e.includes(s)?s:e[0]??""})}}finally{t.setTeamFilesLoading(!1),t.setCronLoading(!1),t.setTeamAgentsLoading(!1),t.setSkillsLoading(!1)}}async function u(e,t){let s=await x(e);t.setRecipes(s.recipesData.recipes??[]);let a=null;try{let e=await s.metaRes.json(),r=e.meta;s.metaRes.ok&&e.ok&&r?.recipeId?(a={recipeId:String(r.recipeId),recipeName:"string"==typeof r.recipeName?r.recipeName:void 0},t.setTeamMetaRecipeHash("string"==typeof r.recipeHash?r.recipeHash:null)):t.setTeamMetaRecipeHash(null)}catch{t.setTeamMetaRecipeHash(null)}if(a)t.setLockedFromId(a.recipeId),t.setLockedFromName(a.recipeName??null),t.setProvenanceMissing(!1),t.setFromId(a.recipeId);else{t.setLockedFromId(null),t.setLockedFromName(null),t.setProvenanceMissing(!0);let a=s.recipesData.recipes??[],r=a.find(t=>"team"===t.kind&&t.id===e),i=a.find(e=>"team"===e.kind),l=r??i;l&&t.setFromId(l.id)}await p(e,{setTeamFiles:t.setTeamFiles,setCronJobs:t.setCronJobs,setTeamAgents:t.setTeamAgents,setSkillsList:t.setSkillsList,setAvailableSkills:t.setAvailableSkills,setSelectedSkill:t.setSelectedSkill,setTeamFilesLoading:t.setTeamFilesLoading,setCronLoading:t.setCronLoading,setTeamAgentsLoading:t.setTeamAgentsLoading,setSkillsLoading:t.setSkillsLoading})}async function v(e){try{let t=await (0,d.fetchJson)("/api/agents",{cache:"no-store"}),s=(Array.isArray(t.agents)?t.agents:[]).filter(t=>String(t.id??"").startsWith(`${e}-`)).map(e=>({id:String(e.id??""),identityName:"string"==typeof e.identityName?e.identityName:void 0}));return{ok:!0,agents:s}}catch{return{ok:!1,agents:[]}}}async function g(e,t,s){try{await (0,d.fetchJson)("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:t.trim(),teamId:e,applyConfig:!0,overwrite:!1,allowExisting:!0,cronInstallChoice:"no"})})}catch(e){s((0,n.errorMessage)(e),"error")}}async function k(e,t,s,a){let r=Date.now();for(;Date.now()-r<a;){try{let a=await v(e);if(a.ok){s(a.agents);let e=!!t&&a.agents.some(e=>e.id===t);if(!t||e)return!0}}catch{}await new Promise(e=>setTimeout(e,500))}return!1}async function f(e){let{teamId:t,toId:s,newRole:a,derivedRole:r,newRoleName:i,content:l,setContent:o,setTeamAgents:c,flashMessage:m,ensureCustomRecipeExists:x}=e;try{await x({overwrite:!1})}catch(t){let e=(0,n.errorMessage)(t);if(!/Recipe id already exists:/i.test(e))throw t}let h=await (0,d.fetchJson)("/api/recipes/team-agents",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("__custom__"===a?{recipeId:s.trim(),op:"add",role:r,name:i}:{recipeId:s.trim(),op:"addLike",baseRole:r,teamId:t,name:i})});if(!h.ok)throw Error("Failed updating agents list");o(String(h.content??l)),await g(t,s,m);let p="string"==typeof h.addedAgentId?h.addedAgentId:"";if(!await k(t,p,c,5e3)&&p){try{fetch("/api/gateway/restart",{method:"POST"})}catch{}await k(t,p,c,1e4)}m(`Updated agents list in ${s}`,"success")}function y(e){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Custom recipe target"}),e.loading?(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"Loading team…"}):null]}),(0,t.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team id"}),(0,t.jsx)("input",{value:e.toId,onChange:t=>e.setToId(t.target.value),disabled:!e.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,t.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,t.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team name"}),(0,t.jsx)("input",{value:e.toName,onChange:t=>e.setToName(t.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,t.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2",children:[(0,t.jsx)("button",{type:"button",disabled:e.saving||!e.teamIdValid||!e.targetIdValid||e.targetIsBuiltin,onClick:()=>e.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:e.saving?"Saving":"Save"}),(0,t.jsx)("button",{type:"button",disabled:e.saving||!e.teamIdValid||!e.targetIdValid||e.targetIsBuiltin||!e.loadedRecipeHash||!e.teamMetaRecipeHash||e.loadedRecipeHash===e.teamMetaRecipeHash,onClick:e.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:e.publishing?"Publishing":"Publish changes"}),(0,t.jsx)("button",{type:"button",disabled:e.saving,onClick:e.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,t.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Notes"}),(0,t.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Parent recipe (locked)"}),(0,t.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:e.fromId,onChange:t=>e.setFromId(t.target.value),children:e.teamRecipes.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.id," (",e.source,")"]},`${e.source}:${e.id}`))}),e.lockedFromId&&(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("code",{children:e.lockedFromId}),e.lockedFromName?` (${e.lockedFromName})`:""]}),!e.lockedFromId&&e.provenanceMissing&&(0,t.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Provenance not found for this team."})]}),(0,t.jsxs)("ul",{className:"mt-4 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("li",{children:"Save writes the custom recipe file identified by Team id."}),(0,t.jsx)("li",{children:"Publish changes re-scaffolds this team from your custom recipe."}),(0,t.jsx)("li",{children:"Delete Team runs openclaw recipes remove-team."})]})]})]}),(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recipe markdown"}),e.recipeLoadError?(0,t.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:e.recipeLoadError}):null,(0,t.jsx)("textarea",{value:e.content,onChange:t=>{e.setContent(t.target.value),e.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 b(e){let{teamId:s,toId:a,recipeAgents:r,newRole:i,setNewRole:l,customRole:o,setCustomRole:c,newRoleName:n,setNewRoleName:d,derivedRole:m,saving:x,teamAgents:h,teamAgentsLoading:p,onAddAgent:u}=e;return(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Agents in this team"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Add/remove agents by updating the ",(0,t.jsx)("code",{children:"agents:"})," list in your custom team recipe (",(0,t.jsx)("code",{children:a}),")."]}),(0,t.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Role"}),(0,t.jsxs)("select",{value:i,onChange:e=>{let t=e.target.value;if(l(t),"__custom__"===t){c(""),d("");return}c("");let s=r.find(e=>e.role===t);d(s?.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,t.jsx)("option",{value:"",children:"Select…"}),r.map(e=>(0,t.jsx)("option",{value:e.role,children:e.name||e.role},e.role)),(0,t.jsx)("option",{value:"__custom__",children:"Other…"})]}),"__custom__"===i?(0,t.jsx)("input",{value:o,onChange:e=>c(e.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,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["This writes to the recipe's ",(0,t.jsx)("code",{children:"agents:"})," list."]})]}),(0,t.jsx)("div",{className:"sm:col-span-2",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Name (optional)"}),(0,t.jsx)("input",{value:n,onChange:e=>d(e.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,t.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:(0,t.jsx)("button",{disabled:x||!m,onClick:u,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,t.jsxs)("div",{className:"mt-6",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Detected installed team agents (read-only)"}),(0,t.jsxs)("ul",{className:"mt-2 space-y-2",children:[h.length?h.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:e.identityName||e.id}),(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:e.id})]}),(0,t.jsx)("a",{className:"text-sm font-medium text-[var(--ck-accent-red)] hover:text-[color:var(--ck-accent-red-hover)]",href:"/agents/"+encodeURIComponent(e.id)+"?returnTo="+encodeURIComponent("/teams/"+s+"?tab=agents"),children:"Edit"})]},e.id)):null,0===h.length&&!p&&(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No team agents detected."}),0===h.length&&p&&(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"})]})]})]})}function j(e){return(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Skills"}),(0,t.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,t.jsxs)("div",{className:"mt-4",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Installed"}),(0,t.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:e.skillsList.length?e.skillsList.map(e=>(0,t.jsx)("li",{children:e},e)):(0,t.jsx)("li",{children:"None installed."})})]}),(0,t.jsxs)("div",{className:"mt-5 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15 p-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Add a skill"}),(0,t.jsxs)("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,t.jsx)("select",{value:e.selectedSkill,onChange:t=>e.setSelectedSkill(t.target.value),disabled:e.installingSkill||e.skillsLoading||!e.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:e.availableSkills.length?e.availableSkills.map(e=>(0,t.jsx)("option",{value:e,children:e},e)):(0,t.jsx)("option",{value:"",children:"No skills found"})}),(0,t.jsx)("button",{type:"button",disabled:e.installingSkill||e.skillsLoading||!e.selectedSkill,onClick:e.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:e.installingSkill?"Adding":"Add"})]}),e.teamSkillError&&(0,t.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:e.teamSkillError}),e.teamSkillMsg&&(0,t.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:e.teamSkillMsg}),(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Uses openclaw recipes install-skill with team-id ",e.teamId,"."]})]})]})}function N(e){let{cronJobs:s,cronLoading:a,saving:r,onCronAction:i}=e;return(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Cron jobs (filtered by team name)"}),(0,t.jsxs)("ul",{className:"mt-3 space-y-3",children:[s.length?s.map(e=>{let s=String(e.id??e.jobId??"").trim(),a=s||String(e.name??"job"),l=String(e.name??e.id??e.jobId??"(unnamed)"),o=e.enabled??e.state?.enabled;return(0,t.jsxs)("li",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:l}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Enabled: ",String(o??"?")]}),(0,t.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,t.jsx)("button",{disabled:r||!s,onClick:()=>i(s,l,"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,t.jsx)("button",{disabled:r||!s,onClick:()=>i(s,l,"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,t.jsx)("button",{disabled:r||!s,onClick:()=>i(s,l,"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"}),s?null:(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"(missing id)"})]})]},a)}):null,0===s.length&&a&&(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading"}),0===s.length&&!a&&(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No cron jobs detected for this team."})]})]})}var w=e.i(72532);function S(e){let{teamFiles:s,teamFilesLoading:a,showOptionalFiles:r,setShowOptionalFiles:i,fileName:l,fileContent:o,setFileContent:c,teamFileError:n,saving:d,onLoadTeamFile:m,onSaveTeamFile:x}=e;return(0,t.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3",children:[(0,t.jsx)(w.FileListWithOptionalToggle,{title:"Team files",files:s,loading:a,showOptionalFiles:r,onShowOptionalChange:i,selectedFileName:l,onSelectFile:m}),(0,t.jsxs)("div",{className:"ck-glass-strong p-4 lg:col-span-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:["Edit: ",l]}),(0,t.jsx)("button",{disabled:d,onClick:x,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:d?"Saving…":"Save file"})]}),n?(0,t.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:n}):null,(0,t.jsx)("textarea",{value:o,onChange:e=>c(e.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 I(e){return`${e._file??""}:${e._line??0}`}function C({teamId:e}){let[a,r]=(0,s.useState)(!1),[i,l]=(0,s.useState)(""),[o,c]=(0,s.useState)([]),[d,m]=(0,s.useState)([]),[x,h]=(0,s.useState)([]),[p,u]=(0,s.useState)("learning"),[v,g]=(0,s.useState)(""),[k,f]=(0,s.useState)(""),[y,b]=(0,s.useState)(!1),[j,N]=(0,s.useState)(null);async function w(){r(!0),l("");try{let t=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(e)}`,{cache:"no-store"}),s=await t.json();if(!t.ok||!s.ok)throw Error(s.error||"Failed to load memory");c(Array.isArray(s.files)?s.files:[]),m(Array.isArray(s.pinnedItems)?s.pinnedItems:[]),h(Array.isArray(s.items)?s.items:[])}catch(e){l((0,n.errorMessage)(e)),c([]),m([]),h([])}finally{r(!1)}}(0,s.useEffect)(()=>{w()},[e]);let S=(0,s.useMemo)(()=>[{label:"decision",value:"decision"},{label:"learning",value:"learning"},{label:"bug",value:"bug"},{label:"customer",value:"customer"},{label:"release",value:"release"}],[]),C=(0,s.useMemo)(()=>new Set(d.map(e=>e._key)),[d]);async function T(t){let s=I(t);if(t._file&&t._line){N(s),l("");try{let s={op:"pin",ts:new Date().toISOString(),actor:`${e}-lead`,key:{file:"team.jsonl",line:t._line},item:{ts:t.ts,author:t.author,type:t.type,content:t.content,source:t.source}},a=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)}),r=await a.json();if(!a.ok||!r.ok)throw Error(r.error||"Failed to pin");await w()}catch(e){l((0,n.errorMessage)(e))}finally{N(null)}}}async function A(t){let s=I(t);if(t._file&&t._line){N(s),l("");try{let s={op:"unpin",ts:new Date().toISOString(),actor:`${e}-lead`,key:{file:"team.jsonl",line:t._line}},a=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s)}),r=await a.json();if(!a.ok||!r.ok)throw Error(r.error||"Failed to unpin");await w()}catch(e){l((0,n.errorMessage)(e))}finally{N(null)}}}return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Team memory (file-first)"}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["Stored in ",(0,t.jsx)("span",{className:"font-mono",children:"shared-context/memory/*.jsonl"}),". Items must be attributable."]})]}),(0,t.jsx)("button",{type:"button",onClick:w,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"})]}),i?(0,t.jsx)("div",{className:"mt-3 rounded border border-red-400/30 bg-red-500/10 p-2 text-sm text-red-100",children:i}):null,(0,t.jsxs)("div",{className:"mt-3 text-xs text-[color:var(--ck-text-secondary)]",children:["Files: ",o.length?o.join(", "):"(none)"]})]}),(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Add memory item"}),(0,t.jsxs)("div",{className:"mt-3 grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,t.jsx)("select",{value:p,onChange:e=>u(e.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:S.map(e=>(0,t.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,t.jsxs)("label",{className:"block",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"source (ticket/pr/path)"}),(0,t.jsx)("input",{value:k,onChange:e=>f(e.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,t.jsxs)("label",{className:"block md:col-span-2",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"content"}),(0,t.jsx)("textarea",{value:v,onChange:e=>g(e.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,t.jsx)("div",{className:"md:col-span-2",children:(0,t.jsx)("button",{type:"button",disabled:y||!v.trim(),onClick:async()=>{b(!0),l("");try{let t={op:"append",ts:new Date().toISOString(),author:`${e}-lead`,type:p,content:v.trim(),source:k.trim()?{text:k.trim()}:void 0,file:"team.jsonl"},s=await fetch(`/api/teams/memory?teamId=${encodeURIComponent(e)}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)}),a=await s.json();if(!s.ok||!a.ok)throw Error(a.error||"Failed to append memory");g(""),f(""),await w()}catch(e){l((0,n.errorMessage)(e))}finally{b(!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:y?"Saving…":"Append to team.jsonl"})})]})]}),(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Pinned memory"}),(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[d.length," pinned"]})]}),a?(0,t.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,(0,t.jsx)("div",{className:"mt-3 space-y-3",children:d.length?d.map(e=>(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.ts}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsx)("span",{className:"rounded bg-white/5 px-2 py-0.5 font-mono",children:e.type}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsx)("span",{className:"font-mono",children:e.author}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsxs)("span",{className:"font-mono",children:["pinned ",e.pinnedAt]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>void A(e),disabled:j===e._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:j===e._key?"Unpinning…":"Unpin"})]}),(0,t.jsx)("div",{className:"mt-2 whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:e.content}),e.source?(0,t.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(e.source,null,2)}):null]},e._key)):(0,t.jsx)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No pinned items yet."})})]}),(0,t.jsxs)("div",{className:"ck-glass p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recent memory"}),(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Showing ",x.length," (max 200)"]})]}),a?(0,t.jsx)("div",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,(0,t.jsx)("div",{className:"mt-3 space-y-3",children:x.length?x.map(e=>{let s=I(e),a=C.has(s);return(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.ts}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsx)("span",{className:"rounded bg-white/5 px-2 py-0.5 font-mono",children:e.type}),(0,t.jsx)("span",{className:"mx-2",children:"•"}),(0,t.jsx)("span",{className:"font-mono",children:e.author})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[e._file?(0,t.jsxs)("span",{className:"text-[10px] text-[color:var(--ck-text-tertiary)] font-mono",children:[e._file,":",e._line]}):null,(0,t.jsx)("button",{type:"button",onClick:()=>void T(e),disabled:a||j===s||!e._file||!e._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:a?"Pinned":j===s?"Pinning…":"Pin"})]})]}),(0,t.jsx)("div",{className:"mt-2 whitespace-pre-wrap text-sm text-[color:var(--ck-text-primary)]",children:e.content}),e.source?(0,t.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(e.source,null,2)}):null]},`${e._file??"?"}:${e._line??0}`)}):(0,t.jsx)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No memory items yet."})})]})]})}var T=e.i(74080);function A({open:e,onClose:a,teamId:r,onInstalled:i}){let l=(0,s.useMemo)(()=>`${r}-swarm-orchestrator`,[r]),[o,c]=(0,s.useState)(l),[n,m]=(0,s.useState)(""),[x,h]=(0,s.useState)("/home/control/swarm-worktrees"),[p,u]=(0,s.useState)("origin/main"),[v,g]=(0,s.useState)(!0),[k,f]=(0,s.useState)(!0),[y,b]=(0,s.useState)(!1),[j,N]=(0,s.useState)(null),[w,S]=(0,s.useState)(null),I=(0,s.useMemo)(()=>({effectiveAgentId:String(o??"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").replace(/--+/g,"-")}),[o]);return e?(0,T.createPortal)((0,t.jsxs)("div",{className:"fixed inset-0 z-[210]",children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:()=>{y||a()}}),(0,t.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,t.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,t.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,t.jsx)("div",{className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:"Add Orchestrator"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-[color:var(--ck-text-secondary)]",children:["This will scaffold a new ",(0,t.jsx)("span",{className:"font-mono text-xs",children:"swarm-orchestrator"})," agent workspace for this team and prefill its config."]}),(0,t.jsx)("label",{className:"mt-4 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Orchestrator agent id"}),(0,t.jsx)("input",{value:o,onChange:e=>c(e.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,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["Default: ",(0,t.jsx)("span",{className:"font-mono",children:l})," (normalized: ",(0,t.jsx)("span",{className:"font-mono",children:I.effectiveAgentId}),")"]}),(0,t.jsx)("label",{className:"mt-4 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Repo directory (SWARM_REPO_DIR)"}),(0,t.jsx)("input",{value:n,onChange:e=>m(e.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,t.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 md:grid-cols-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Worktree root (SWARM_WORKTREE_ROOT)"}),(0,t.jsx)("input",{value:x,onChange:e=>h(e.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,t.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:"Recommend a dedicated folder outside the repo."})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Base ref (SWARM_BASE_REF)"}),(0,t.jsx)("input",{value:p,onChange:e=>u(e.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,t.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,t.jsx)("input",{type:"checkbox",checked:v,onChange:e=>g(e.target.checked),className:"mt-1"}),(0,t.jsxs)("span",{children:["Add this agent to OpenClaw config (recommended).",(0,t.jsx)("br",{}),(0,t.jsxs)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["This will modify ",(0,t.jsx)("span",{className:"font-mono",children:"~/.openclaw/openclaw.json"})," to add ",(0,t.jsx)("span",{className:"font-mono",children:I.effectiveAgentId}),"."]})]})]}),(0,t.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,t.jsx)("input",{type:"checkbox",checked:k,onChange:e=>f(e.target.checked),className:"mt-1"}),(0,t.jsxs)("span",{children:["Make scripts executable (developer convenience).",(0,t.jsx)("br",{}),(0,t.jsxs)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:["Runs ",(0,t.jsx)("span",{className:"font-mono",children:"chmod +x .clawdbot/*.sh"})," in the orchestrator workspace."]})]})]}),j?(0,t.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:j}):null,w?(0,t.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,t.jsx)("span",{className:"font-mono",children:w.orchestratorAgentId})," → ",(0,t.jsx)("span",{className:"font-mono",children:w.workspace})]}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:a,disabled: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 disabled:opacity-50",children:"Cancel"}),(0,t.jsx)("button",{type:"button",disabled:y||!I.effectiveAgentId||!n.trim(),onClick:async()=>{b(!0),N(null),S(null);try{let e=await (0,d.fetchJson)("/api/teams/orchestrator/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:r,orchestratorAgentId:I.effectiveAgentId,repoDir:n.trim(),worktreeRoot:x.trim(),baseRef:p.trim(),applyConfig:v,makeExecutable:k})});if(!e.ok)throw Error(e.error);S({orchestratorAgentId:e.orchestratorAgentId,workspace:e.workspace}),i()}catch(e){N(e instanceof Error?e.message:String(e))}finally{b(!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:y?"Installing…":"Install"})]})]})})})]}),document.body):null}function R({teamId:e}){let[a,r]=(0,s.useState)(!0),[i,l]=(0,s.useState)(null),[o,c]=(0,s.useState)(null),[n,m]=(0,s.useState)(!1),x=(0,s.useCallback)(async()=>{r(!0);try{let t=await (0,d.fetchJson)(`/api/teams/orchestrator?teamId=${encodeURIComponent(e)}`,{cache:"no-store"});l(t),c(new Date().toISOString())}catch(e){l({ok:!1,error:e instanceof Error?e.message:String(e)}),c(new Date().toISOString())}finally{r(!1)}},[e]);return((0,s.useEffect)(()=>{x()},[x]),a)?(0,t.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"Loading orchestrator state…"}):i?i.ok?i.present?(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Agent: ",(0,t.jsx)("span",{className:"font-mono",children:i.agent.id}),i.agent.identityName?` (${i.agent.identityName})`:""]}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Workspace: ",(0,t.jsx)("span",{className:"font-mono",children:i.agent.workspace})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:o?(0,t.jsxs)("span",{children:["Last updated: ",(0,t.jsx)("span",{className:"font-mono",children:o})]}):null}),(0,t.jsx)("button",{type:"button",onClick:()=>void x(),disabled:a,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:a?"Refreshing…":"Refresh"})]})]}),(0,t.jsxs)("div",{className:"mt-5 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"tmux sessions"}),i.tmuxSessions.length?(0,t.jsx)("ul",{className:"mt-2 space-y-2",children:i.tmuxSessions.map(e=>(0,t.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.name}),(0,t.jsxs)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["attached=",String(e.attached),"number"==typeof e.windows?` windows=${e.windows}`:""]})]},e.name))}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No sessions detected (or tmux not running)."})]}),(0,t.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"git worktrees"}),i.worktrees.length?(0,t.jsx)("ul",{className:"mt-2 space-y-2",children:i.worktrees.map(e=>(0,t.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("div",{className:"font-mono text-xs",children:e.path}),(0,t.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[e.branch?e.branch:"(no branch)",e.sha?` @ ${e.sha.slice(0,7)}`:""]})]},e.path))}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No worktrees detected."})]})]}),(0,t.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Active tasks"}),i.activeTasksSummary?(0,t.jsxs)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("div",{className:"font-mono text-xs",children:i.activeTasksSummary.path}),(0,t.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["number"==typeof i.activeTasksSummary.taskCount?`tasks=${i.activeTasksSummary.taskCount}`:"tasks=?",i.activeTasksSummary.rawType?` type=${i.activeTasksSummary.rawType}`:""]})]}):(0,t.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No active-tasks.json found."})]}),(0,t.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"CLI quick actions"}),(0,t.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,t.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"font-mono text-xs",children:"tmux ls"}),(0,t.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(list sessions)"})]}),(0,t.jsxs)("li",{children:[(0,t.jsx)("span",{className:"font-mono text-xs",children:"tmux attach -t <session>"}),(0,t.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(jump into a running swarm)"})]}),(0,t.jsxs)("li",{children:[(0,t.jsxs)("span",{className:"font-mono text-xs",children:["git -C ",i.agent.workspace," worktree list"]}),(0,t.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(inspect worktrees)"})]})]}),(0,t.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,t.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Human approval gate (recommended)"}),(0,t.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,t.jsx)("strong",{children:"human approval step"}),"."]}),(0,t.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("li",{children:"Generate a proposed change/post as a draft."}),(0,t.jsx)("li",{children:"Send the draft to a bound messaging channel (e.g. Telegram) for approval."}),(0,t.jsx)("li",{children:"Only execute the final action after explicit approve/deny."})]})]}),(0,t.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Where to change settings"}),(0,t.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,t.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:i.settingsPaths.map(e=>(0,t.jsx)("li",{className:"font-mono text-xs",children:e},e))})]})]}):(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,t.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No swarm/orchestrator detected for this team."})]}),(0,t.jsx)("button",{type:"button",onClick:()=>m(!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,t.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,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Detection"}),(0,t.jsx)("div",{className:"mt-1 font-mono text-xs",children:i.reason||"(no reason provided)"})]}),(0,t.jsxs)("p",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:["Default convention is ",(0,t.jsx)("code",{children:"<teamId>-swarm-orchestrator"}),". Once installed, this tab will show: tmux sessions, git worktrees/branches, and active task state."]}),(0,t.jsx)(A,{open:n,onClose:()=>m(!1),teamId:e,onInstalled:()=>{m(!1),x()}})]}):(0,t.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,t.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:i.error})]}):(0,t.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"No orchestrator state available."})}var O=e.i(92140);let L=[{id:"recipe",label:"Recipe"},{id:"agents",label:"Agents"},{id:"skills",label:"Skills"},{id:"cron",label:"Cron"},{id:"files",label:"Files"},{id:"orchestrator",label:"Orchestrator"}],$=[{id:"memory",label:"Memory"},{id:"workflows",label:"Workflows"}];function F({teamId:e,initialTab:l}){let m=(0,r.useRouter)(),[x,h]=(0,s.useState)([]),[p,v]=(0,s.useState)(""),[g,k]=(0,s.useState)(null),[w,I]=(0,s.useState)(null),[T,A]=(0,s.useState)(!1),[F,M]=(0,s.useState)(e),[_,P]=(0,s.useState)(e),[E,J]=(0,s.useState)(""),[U,D]=(0,s.useState)(null),[H,W]=(0,s.useState)(()=>["recipe","agents","skills","cron","files","memory","orchestrator","workflows"].includes(l)?l:"recipe"),B=(0,s.useMemo)(()=>[...L,...$],[]),[z,V]=(0,s.useState)(!0),[q,K]=(0,s.useState)(!1),[G,Q]=(0,s.useState)(!1),[X,Y]=(0,s.useState)(!1),[Z,ee]=(0,s.useState)(!1),[et,es]=(0,s.useState)(""),ea=(0,c.useToast)(),[er,ei]=(0,s.useState)(!1),[el,eo]=(0,s.useState)(!1),[ec,en]=(0,s.useState)(null);function ed(e,t="info"){let s=String(e??"").trim();s&&ea.push({kind:t,message:s})}let[em,ex]=(0,s.useState)([]),[eh,ep]=(0,s.useState)(!1),[eu,ev]=(0,s.useState)(""),[eg,ek]=(0,s.useState)(!1),[ef,ey]=(0,s.useState)("SOUL.md"),[eb,ej]=(0,s.useState)(""),[eN,ew]=(0,s.useState)([]),[eS,eI]=(0,s.useState)(!1),[eC,eT]=(0,s.useState)([]),[eA,eR]=(0,s.useState)(!1),eO=(0,s.useMemo)(()=>{let e=String(E??"");if(!e.startsWith("---\n"))return[];let t=e.indexOf("\n---\n",4);if(-1===t)return[];let s=e.slice(4,t+1);try{let e=(0,a.parse)(s)??{};return(Array.isArray(e.agents)?e.agents:[]).map(e=>e).map(e=>({role:String(e.role??"").trim(),name:"string"==typeof e.name?e.name:void 0})).filter(e=>!!e.role)}catch{return[]}},[E]),[eL,e$]=(0,s.useState)(""),[eF,eM]=(0,s.useState)(""),[e_,eP]=(0,s.useState)(""),eE=(0,s.useMemo)(()=>("__custom__"===eL?eF:eL).trim()||"",[eL,eF]),[eJ,eU]=(0,s.useState)([]),[eD,eH]=(0,s.useState)([]),[eW,eB]=(0,s.useState)(!1),[ez,eV]=(0,s.useState)(""),[eq,eK]=(0,s.useState)(!1),[eG,eQ]=(0,s.useState)(""),[eX,eY]=(0,s.useState)(""),eZ=(0,s.useMemo)(()=>x.filter(e=>"team"===e.kind),[x]),e0=(0,s.useMemo)(()=>x.find(e=>e.id===F&&"workspace"===e.source)??x.find(e=>e.id===F)??null,[x,F]),e1=!!e.trim(),e2=!!F.trim(),e3=x.some(e=>e.id===F&&"workspace"===e.source),e5=!!(e0?.source==="builtin"&&!e3);async function e4(){let e=F.trim();if(e){ee(!0),es("");try{let t=await (0,d.fetchJson)(`/api/recipes/${encodeURIComponent(e)}`,{cache:"no-store"}),s=t.recipe;J(s.content),D("string"==typeof t.recipeHash?t.recipeHash:null)}catch(e){es((0,n.errorMessage)(e))}finally{ee(!1)}}}async function e6(e){let t=p.trim(),s=String(e.toId??F).trim(),a=String(e.toName??_).trim(),r=!!e.overwrite,i=!!e.scaffold;if(!t)throw Error("Source recipe id is required");if(!s)throw Error("Custom recipe id is required");return await (0,d.fetchJson)("/api/recipes/clone",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:t,toId:s,toName:a||void 0,overwrite:r,scaffold:i})})}async function e7(e,t){K(!0),ed("");try{let s=await e6({overwrite:e,...t});if(s.scaffold&&!s.scaffold.ok&&ed(`Scaffold failed (recipe was still cloned): ${s.scaffold.error||"Unknown error"}`,"error"),E.trim()&&E.trim()!==s.content.trim()){let e=function(e,t){if(!e.startsWith("---\n"))return e;let s=e.indexOf("\n---\n",4);if(-1===s)return e;let a=e.slice(4,s),r=e.slice(s+5),{next:i,sawTeamBlock:l,patched:o}=function(e,t){let s=[],a=!1,r=!1,i=!1;for(let l of e){if(/^team\s*:\s*$/i.test(l)){a=!0,r=!0,s.push(l);continue}if(a&&/^\S/.test(l)&&(a=!1),a&&/^\s+teamId\s*:/i.test(l)){s.push(` teamId: ${t}`),i=!0;continue}s.push(l)}return{next:s,sawTeamBlock:r,patched:i}}(a.split("\n"),t);if(l&&!o){let e=[];for(let s of i)e.push(s),/^team\s*:\s*$/i.test(s)&&e.push(` teamId: ${t}`);return`---
2
- ${e.join("\n")}
3
- ---
4
- ${r}`}return`---
5
- ${i.join("\n")}
6
- ---
7
- ${r}`}(function(e,t){var s;let a,r;if(!e.startsWith("---\n"))return e;let i=e.indexOf("\n---\n",4);if(-1===i)return e;let l=e.slice(4,i),o=e.slice(i+5),c=(s=l.split("\n"),a=!1,r=s.map(e=>/^id\s*:/i.test(e)?(a=!0,`id: ${t}`):e),a||r.unshift(`id: ${t}`),r);return`---
8
- ${c.join("\n")}
9
- ---
10
- ${o}`}(E,F.trim()),F.trim());await (0,d.fetchJson)(`/api/recipes/${encodeURIComponent(F.trim())}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:e})}),J(e)}else J(s.content);try{let e=await (0,d.fetchJson)(`/api/recipes/${encodeURIComponent(F.trim())}`,{cache:"no-store"});"string"==typeof e.recipeHash&&D(e.recipeHash)}catch{D(null)}ed(`Saved team recipe: ${s.filePath}`,"success")}catch(e){ed((0,n.errorMessage)(e),"error")}finally{K(!1)}}async function e8(t){K(!0),ev("");try{let s=await (0,d.fetchJson)(`/api/teams/file?teamId=${encodeURIComponent(e)}&name=${encodeURIComponent(t)}`,{cache:"no-store"});if(!s.ok)throw Error("Failed to load file");ey(t),ej(String(s.content??""))}catch(e){ev((0,n.errorMessage)(e))}finally{K(!1)}}async function e9(){K(!0),ev("");try{if(!(await (0,d.fetchJson)("/api/teams/file",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,name:ef,content:eb})})).ok)throw Error("Failed to save file")}catch(e){ev((0,n.errorMessage)(e))}finally{K(!1)}}async function te(){K(!0);try{await f({teamId:e,toId:F,newRole:eL,derivedRole:eE,newRoleName:e_,content:E,setContent:J,setTeamAgents:eT,flashMessage:ed,ensureCustomRecipeExists:e6})}catch(e){ed((0,n.errorMessage)(e),"error")}finally{K(!1)}}async function tt(e,t,s){K(!0);try{await (0,d.fetchJson)("/api/cron/job",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:e,action:s})}),ed(`Cron ${s}: ${t}`,"success")}catch(e){ed((0,n.errorMessage)(e),"error")}finally{K(!1)}}async function ts(){eK(!0),eQ(""),eY("");try{await (0,d.fetchJson)("/api/teams/skills/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,skill:ez})}),eQ(`Installed skill: ${ez}`);try{let t=await (0,d.fetchJson)(`/api/teams/skills?teamId=${encodeURIComponent(e)}`,{cache:"no-store"});t.ok&&Array.isArray(t.skills)&&eU(t.skills)}catch{}}catch(e){eY((0,n.errorMessage)(e))}finally{eK(!1)}}return(0,s.useEffect)(()=>{M(e),P(e),J(""),D(null),en(null),eo(!1),ei(!1),l&&["recipe","agents","skills","cron","files","memory","orchestrator","workflows"].includes(l)&&W(l)},[e,l]),(0,s.useEffect)(()=>{let t=!1;return V(!0),u(e,{setRecipes:h,setLockedFromId:k,setLockedFromName:I,setProvenanceMissing:A,setFromId:v,setTeamMetaRecipeHash:en,setTeamFiles:ex,setCronJobs:ew,setTeamAgents:eT,setSkillsList:eU,setAvailableSkills:eH,setSelectedSkill:eV,setTeamFilesLoading:ep,setCronLoading:eI,setTeamAgentsLoading:eR,setSkillsLoading:eB}).then(()=>{t||V(!1)}).catch(e=>{ed((0,n.errorMessage)(e),"error"),t||V(!1)}),()=>{t=!0}},[e]),(0,s.useEffect)(()=>{!F.trim()||E.trim()||Z||e4()},[F]),(0,t.jsxs)("div",{className:"ck-glass w-full p-6 sm:p-8",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Team editor"}),(0,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Bootstrap a ",(0,t.jsx)("strong",{children:"custom team recipe"})," for this installed team, without modifying builtin recipes."]}),(0,t.jsx)("div",{className:"mt-6 flex flex-wrap gap-2",children:B.map(e=>(0,t.jsx)("button",{onClick:()=>W(e.id),className:H===e.id?"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)]":"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)] hover:bg-white/10",children:e.label},e.id))}),"recipe"===H&&(0,t.jsx)(y,{loading:z,fromId:p,setFromId:v,toId:F,setToId:M,toName:_,setToName:P,canEditTargetId:!0,teamRecipes:eZ,lockedFromId:g,lockedFromName:w,provenanceMissing:T,saving:q,teamIdValid:e1,targetIdValid:e2,targetIsBuiltin:e5,loadedRecipeHash:U,teamMetaRecipeHash:ec,publishing:G,content:E,setContent:J,setLoadedRecipeHash:D,recipeLoadError:et,onSaveCustom:e7,onPublishOpen:()=>eo(!0),onDeleteOpen:()=>ei(!0)}),"agents"===H&&(0,t.jsx)(b,{teamId:e,toId:F,recipeAgents:eO,newRole:eL,setNewRole:e$,customRole:eF,setCustomRole:eM,newRoleName:e_,setNewRoleName:eP,derivedRole:eE,saving:q,teamAgents:eC,teamAgentsLoading:eA,onAddAgent:te}),"skills"===H&&(0,t.jsx)(j,{teamId:e,skillsList:eJ,availableSkills:eD,skillsLoading:eW,selectedSkill:ez,setSelectedSkill:eV,installingSkill:eq,teamSkillMsg:eG,teamSkillError:eX,onInstallSkill:ts}),"cron"===H&&(0,t.jsx)(N,{cronJobs:eN,cronLoading:eS,saving:q,onCronAction:tt}),"orchestrator"===H&&(0,t.jsx)(R,{teamId:e}),"memory"===H&&(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(C,{teamId:e})}),"workflows"===H&&(0,t.jsx)("div",{className:"mt-6",children:(0,t.jsx)(O.default,{teamId:e})}),"files"===H&&(0,t.jsx)(S,{teamFiles:em,teamFilesLoading:eh,showOptionalFiles:eg,setShowOptionalFiles:ek,fileName:ef,fileContent:eb,setFileContent:ej,teamFileError:eu,saving:q,onLoadTeamFile:e8,onSaveTeamFile:e9}),(0,t.jsx)(o,{open:el,teamId:e,recipeId:F,busy:G,onClose:()=>eo(!1),onConfirm:async()=>{Q(!0);try{await (0,d.fetchJson)("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:F.trim(),teamId:e,overwrite:!0,applyConfig:!0})});try{let t=await (0,d.fetchJson)(`/api/teams/meta?teamId=${encodeURIComponent(e)}`,{cache:"no-store"});t.ok&&t.meta&&"string"==typeof t.meta.recipeHash&&en(t.meta.recipeHash)}catch{}eo(!1),ed("Published changes to active team","success")}catch(e){ed((0,n.errorMessage)(e),"error")}finally{Q(!1)}}}),(0,t.jsx)(i.DeleteTeamModal,{open:er,teamId:e,busy:X,onClose:()=>ei(!1),onConfirm:async()=>{Y(!0);try{await (0,d.fetchJson)("/api/teams/remove-team",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e})}),ed("Deleted team successfully","success"),ei(!1),setTimeout(()=>m.push("/"),250)}catch(e){ed((0,n.errorMessage)(e),"error")}finally{Y(!1)}}})]})}e.s(["default",()=>F],86103)}]);
@@ -1 +0,0 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,82310,e=>{"use strict";function t(e){return e instanceof Error?e.message:String(e)}e.s(["errorMessage",()=>t])},44355,e=>{"use strict";var t=e.i(43476),r=e.i(74080);function s({open:e,onClose:s,title:a,children:o,error:i,confirmLabel:l,confirmBusyLabel:n,onConfirm:c,confirmDisabled:d,busy:m,confirmButtonClassName:x}){if(!e)return null;let u=m??!1,p=u&&n?n:l,h="confirmation-modal-title";return(0,r.createPortal)((0,t.jsxs)("div",{className:"fixed inset-0 z-[200]",children:[(0,t.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:s,"aria-hidden":"true"}),(0,t.jsx)("div",{className:"fixed inset-0 overflow-y-auto",role:"dialog","aria-modal":"true","aria-labelledby":h,children:(0,t.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,t.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,t.jsx)("h2",{id:h,className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:a}),o,i?(0,t.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:i}):null,(0,t.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:s,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:"Cancel"}),(0,t.jsx)("button",{type:"button",disabled:(d??!1)||u,onClick:c,className:x??"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)] transition-colors hover:bg-[var(--ck-accent-red-hover)] disabled:opacity-50",children:p})]})]})})})]}),document.body)}e.s(["ConfirmationModal",()=>s])},54510,e=>{"use strict";var t=e.i(43476),r=e.i(44355);function s({open:e,onClose:s,title:a,entityLabel:o,bodyText:i,onConfirm:l,busy:n,error:c}){return(0,t.jsx)(r.ConfirmationModal,{open:e,onClose:s,title:a,confirmLabel:"Delete",confirmBusyLabel:"Deleting…",onConfirm:l,busy:n,error:c??void 0,children:(0,t.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:[a," ",(0,t.jsx)("code",{className:"font-mono",children:o}),"? ",i]})})}function a(e){return function(r){let a=r[e.entityLabelKey];return(0,t.jsx)(s,{open:r.open,onClose:r.onClose,title:e.title,entityLabel:a,bodyText:e.bodyText,onConfirm:r.onConfirm,busy:r.busy,error:r.error})}}let o=a({title:"Delete agent",bodyText:"This will remove its workspace/state.",entityLabelKey:"agentId"}),i=a({title:"Delete Team",bodyText:"This will remove the team workspace, agents, and stamped cron jobs.",entityLabelKey:"teamId"}),l=a({title:"Delete recipe",bodyText:"This removes the markdown file from your workspace.",entityLabelKey:"recipeId"}),n=a({title:"Delete cron job",bodyText:"This removes it from the Gateway scheduler. You can recreate it later.",entityLabelKey:"jobLabel"});e.s(["DeleteAgentModal",0,o,"DeleteCronJobModal",0,n,"DeleteRecipeModal",0,l,"DeleteTeamModal",0,i],54510)},72532,e=>{"use strict";var t=e.i(43476);function r({title:e,files:r,loading:s,showOptionalFiles:a,onShowOptionalChange:o,selectedFileName:i,onSelectFile:l,renderItemExtra:n}){let c=a?r:r.filter(e=>e.required||!e.missing);return(0,t.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,t.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:e}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-xs text-[color:var(--ck-text-secondary)]",children:[(0,t.jsx)("input",{type:"checkbox",checked:a,onChange:e=>o(e.target.checked)}),"Show optional"]})]}),(0,t.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Default view hides optional missing files to reduce noise."}),(0,t.jsxs)("ul",{className:"mt-3 space-y-1",children:[s?(0,t.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,c.map(e=>{var r;let s;return(0,t.jsx)("li",{children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>l(e.name),className:(r=e.name,s="w-full rounded-[var(--ck-radius-sm)] px-3 py-2 text-left text-sm",i===r?`${s} bg-white/10 text-[color:var(--ck-text-primary)]`:`${s} text-[color:var(--ck-text-secondary)] hover:bg-white/5`),children:[(0,t.jsx)("span",{className:e.required?"text-[color:var(--ck-text-primary)]":"text-[color:var(--ck-text-secondary)]",children:e.name}),(0,t.jsx)("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:e.required?"required":"optional"}),e.missing?(0,t.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"missing"}):null]}),n?.(e)]})},e.name)})]})]})}e.s(["FileListWithOptionalToggle",()=>r])},92140,e=>{"use strict";var t=e.i(43476),r=e.i(71645),s=e.i(22016),a=e.i(18566),o=e.i(42771),i=e.i(82310);function l(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function n({teamId:e}){let n=(0,a.useRouter)(),[c,d]=(0,r.useState)([]),[m,x]=(0,r.useState)(!0),[u,p]=(0,r.useState)(!1),[h,f]=(0,r.useState)(""),[v,y]=(0,r.useState)(""),[b,w]=(0,r.useState)({}),[k,g]=(0,r.useState)({}),[j,N]=(0,r.useState)(""),[C,S]=(0,r.useState)(""),[I,A]=(0,r.useState)(null),[R,$]=(0,r.useState)(""),[T,U]=(0,r.useState)(""),[D,L]=(0,r.useState)(!1),M=(0,r.useCallback)(async t=>{let r=!!t?.quiet;f(""),r||x(!0);try{let t=await (0,o.fetchJson)(`/api/teams/workflows?teamId=${encodeURIComponent(e)}`,{cache:"no-store"});if(!t.ok)throw Error("Failed to load workflows");let r=(Array.isArray(t.files)?t.files:[]).map(e=>e.endsWith(".workflow.json")?e.slice(0,-14):null).filter(e=>!!e);d(r.map(e=>({id:e,name:e})))}catch(e){f((0,i.errorMessage)(e))}finally{r||x(!1)}},[e]);async function E(){p(!0);try{await M({quiet:!0})}finally{p(!1)}}async function q(t){if(confirm(`Delete workflow “${t}”? This removes the .workflow.json file from the team workspace.`)){f("");try{let r=await (0,o.fetchJson)(`/api/teams/workflows?teamId=${encodeURIComponent(e)}&id=${encodeURIComponent(t)}`,{method:"DELETE"});if(!r.ok)throw Error(r.error||"Failed to delete workflow");await M({quiet:!0}),v===t&&(y(""),N(""),A(null))}catch(e){f((0,i.errorMessage)(e))}}}async function J(t){g(e=>({...e,[t]:!0})),$("");try{let r=await (0,o.fetchJson)(`/api/teams/workflow-runs?teamId=${encodeURIComponent(e)}&workflowId=${encodeURIComponent(t)}`,{cache:"no-store"});if(!r.ok)throw Error(r.error||"Failed to load runs");let s=Array.isArray(r.runIds)?r.runIds.map(e=>String(e||"").trim()).filter(Boolean):Array.isArray(r.files)?r.files.map(e=>"string"==typeof e&&e.endsWith(".run.json")?e.slice(0,-9):null).filter(e=>!!e):[];w(e=>({...e,[t]:s}))}catch(e){$((0,i.errorMessage)(e)),w(e=>({...e,[t]:[]}))}finally{g(e=>({...e,[t]:!1}))}}async function O(t,r){S(t),N(r),A(null),$(""),U("");try{let s=await (0,o.fetchJson)(`/api/teams/workflow-runs?teamId=${encodeURIComponent(e)}&workflowId=${encodeURIComponent(t)}&runId=${encodeURIComponent(r)}`,{cache:"no-store"});if(!s.ok)throw Error(s.error||"Failed to load run");let a=l(s.run)?s.run:null;if(!a)throw Error("Invalid run format");A({id:String(a.id??r),status:"string"==typeof a.status?a.status:void 0,startedAt:"string"==typeof a.startedAt?a.startedAt:void 0,finishedAt:"string"==typeof a.finishedAt?String(a.finishedAt):void 0,meta:a.meta,memoryUsed:a.memoryUsed,approval:a.approval,raw:a})}catch(e){$((0,i.errorMessage)(e)),A(null)}}async function B(t){if(confirm(`Add workflow from template “${t}”?`)){f("");try{let r=await (0,o.fetchJson)("/api/teams/workflow-templates",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,templateId:t})});if(!r.ok)throw Error(r.error||"Failed to apply template");let s=String(r.workflowId??"").trim();if(!s)throw Error("Template applied but workflowId missing");await M({quiet:!0}),n.push(`/teams/${encodeURIComponent(e)}/workflows/${encodeURIComponent(s)}`)}catch(e){f((0,i.errorMessage)(e))}}}(0,r.useEffect)(()=>{M()},[M]);let K=(0,r.useMemo)(()=>{if(!I)return[];let e=I.memoryUsed??(l(I.meta)?I.meta.memoryUsed:void 0);return Array.isArray(e)?e.map(e=>l(e)?e:null).filter(Boolean).map(e=>({ts:String(e.ts??"").trim(),author:String(e.author??"").trim(),type:String(e.type??"").trim(),content:String(e.content??"").trim(),source:e.source})).filter(e=>e.ts&&e.author&&e.type&&e.content):[]},[I]);return m?(0,t.jsx)("div",{className:"ck-glass p-4",children:"Loading workflows…"}):(0,t.jsxs)("div",{className:"ck-glass p-6",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-semibold",children:"Workflows (file-first)"}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-[color:var(--ck-text-secondary)]",children:["Stored in ",(0,t.jsx)("code",{children:"shared-context/workflows/<id>.workflow.json"})," inside the team workspace."]}),(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-start gap-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>{let t=`new-${Date.now()}`;n.push(`/teams/${encodeURIComponent(e)}/workflows/${encodeURIComponent(t)}?draft=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)]",children:"Add workflow"}),(0,t.jsx)("button",{type:"button",onClick:()=>void B("marketing-cadence-v1"),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:"Add example template"}),(0,t.jsx)("button",{type:"button",onClick:E,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-60",children:u?"Refreshing…":"Refresh"})]})]}),h?(0,t.jsx)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-4 text-sm text-red-100",children:h}):null,0===c.length?(0,t.jsx)("p",{className:"mt-4 text-sm text-[color:var(--ck-text-secondary)]",children:"No workflows yet."}):(0,t.jsx)("ul",{className:"mt-4 divide-y divide-white/10 overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10",children:c.map(r=>{let a=v===r.id,o=b[r.id]??[],n=!!k[r.id];return(0,t.jsxs)("li",{className:"bg-white/5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 px-4 py-3",children:[(0,t.jsxs)("button",{type:"button",onClick:async()=>{let e=a?"":r.id;y(e),N(""),A(null),$(""),e&&await J(e)},className:"min-w-0 flex-1 text-left",children:[(0,t.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:r.name||r.id}),(0,t.jsx)("div",{className:"truncate text-xs text-[color:var(--ck-text-tertiary)]",children:r.id}),(0,t.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["Click to ",a?"collapse":"expand"," run details"]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[(0,t.jsx)(s.default,{href:`/teams/${encodeURIComponent(e)}/workflows/${encodeURIComponent(r.id)}`,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-1.5 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Edit"}),(0,t.jsx)("button",{type:"button",onClick:()=>void q(r.id),className:"rounded-[var(--ck-radius-sm)] border border-[color:rgba(255,59,48,0.45)] bg-[color:rgba(255,59,48,0.08)] px-3 py-1.5 text-sm font-medium text-[color:var(--ck-accent-red)] transition-colors hover:bg-[color:rgba(255,59,48,0.12)]",children:"Delete"})]})]}),a?(0,t.jsxs)("div",{className:"border-t border-white/10 bg-black/20 px-4 py-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Runs"}),(0,t.jsx)("button",{type:"button",disabled:n,onClick:()=>void J(r.id),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60",children:n?"Loading…":"Refresh runs"})]}),R?(0,t.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:R}):null,(0,t.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-3 lg:grid-cols-2",children:[(0,t.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:o.length?(0,t.jsx)("div",{className:"space-y-1",children:o.slice(0,8).map(e=>{let s=j===e;return(0,t.jsx)("button",{type:"button",onClick:()=>void O(r.id,e),className:s?"w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-primary)]":"w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:(0,t.jsx)("span",{className:"font-mono",children:e})},e)})}):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"No runs yet."})}),(0,t.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:I?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Run detail"}),(0,t.jsxs)("div",{className:"mt-1 text-[11px] text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:I.id}),I.status?(0,t.jsxs)("span",{children:[" • ",I.status]}):null]})]}),(0,t.jsxs)("div",{className:"border-t border-white/10 pt-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Approval"}),(()=>{let r=I.approval;if(!l(r))return(0,t.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(No approval info recorded.)"});let s=String(r.state??"").trim(),a="string"==typeof r.requestedAt?r.requestedAt:"",o="string"==typeof r.decidedAt?r.decidedAt:"",n="string"==typeof r.decidedBy?r.decidedBy:"",c="string"==typeof r.note?r.note:"",d=l(r.outbound)?r.outbound:null,m="pending"===s||"waiting_for_approval"===I.status;return(0,t.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 text-[11px] text-[color:var(--ck-text-secondary)]",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-mono",children:"state"}),": ",(0,t.jsx)("span",{className:"font-mono text-[color:var(--ck-text-primary)]",children:s||"(unknown)"})]}),a?(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-mono",children:"requestedAt"}),": ",(0,t.jsx)("span",{className:"font-mono",children:a})]}):null,o?(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-mono",children:"decidedAt"}),": ",(0,t.jsx)("span",{className:"font-mono",children:o})]}):null,n?(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"font-mono",children:"decidedBy"}),": ",(0,t.jsx)("span",{className:"font-mono",children:n})]}):null,c?(0,t.jsx)("div",{className:"mt-1 whitespace-pre-wrap text-xs text-[color:var(--ck-text-primary)]",children:c}):null,d?(0,t.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 text-[10px]",children:[(0,t.jsx)("div",{className:"text-[color:var(--ck-text-tertiary)]",children:"Outbound"}),(0,t.jsx)("pre",{className:"mt-1 overflow-auto whitespace-pre-wrap",children:JSON.stringify(d,null,2)})]}):null]}),m?(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:[(0,t.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"approval note (optional)"}),(0,t.jsx)("textarea",{value:T,onChange:e=>U(e.target.value),rows:3,className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"e.g. Ship it / please tweak hook"}),(0,t.jsx)("div",{className:"mt-2 flex flex-wrap gap-2",children:[{action:"approve",label:"Approve"},{action:"request_changes",label:"Request changes"},{action:"cancel",label:"Cancel"}].map(r=>(0,t.jsx)("button",{type:"button",disabled:D,onClick:async()=>{if(C&&j&&confirm(`${r.label} run ${j}?`)){L(!0),$("");try{let t=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:e,workflowId:C,runId:j,action:r.action,note:T||void 0,decidedBy:"ClawKitchen UI"})}),s=await t.json();if(!t.ok||!s.ok)throw Error(s.error||"Failed to apply approval action");await O(C,j)}catch(e){$((0,i.errorMessage)(e))}finally{L(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-60",children:r.label},r.action))})]}):null]})})()]}),(0,t.jsxs)("div",{className:"border-t border-white/10 pt-3",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Memory used in this run"}),K.length?(0,t.jsx)("div",{className:"mt-2 space-y-2",children:K.slice(0,20).map((e,r)=>(0,t.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:[(0,t.jsxs)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:[(0,t.jsx)("span",{className:"font-mono",children:e.ts})," • ",(0,t.jsx)("span",{className:"font-mono",children:e.type})," • ",(0,t.jsx)("span",{className:"font-mono",children:e.author})]}),(0,t.jsx)("div",{className:"mt-1 whitespace-pre-wrap text-xs text-[color:var(--ck-text-primary)]",children:e.content}),void 0!==e.source?(0,t.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(e.source,null,2)}):null]},`${e.ts}-${r}`))}):(0,t.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["(None recorded yet.)",(0,t.jsxs)("div",{className:"mt-1",children:["Next step: have the workflow runner write an explicit ",(0,t.jsx)("span",{className:"font-mono",children:"memoryUsed[]"})," list into the run file."]})]})]})]}):j?(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Loading run…"}):(0,t.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"Select a run to see details."})})]})]}):null]},r.id)})})]})}e.s(["default",()=>n])}]);