@jiggai/kitchen 0.1.8 → 0.1.10-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +5 -0
- package/.next/build-manifest.json +6 -6
- package/.next/prerender-manifest.json +3 -27
- package/.next/required-server-files.js +4 -4
- package/.next/required-server-files.json +4 -4
- package/.next/routes-manifest.json +30 -0
- package/.next/server/app/_global-error/page/build-manifest.json +4 -4
- package/.next/server/app/_global-error/page.js +2 -2
- package/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found/page/build-manifest.json +4 -4
- package/.next/server/app/_not-found/page.js +10 -9
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +4 -4
- package/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +3 -3
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/agents/[agentId]/page/build-manifest.json +4 -4
- package/.next/server/app/agents/[agentId]/page.js +7 -7
- package/.next/server/app/agents/[agentId]/page.js.nft.json +1 -1
- package/.next/server/app/agents/[agentId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/add/route.js +1 -1
- package/.next/server/app/api/agents/add/route.js.nft.json +1 -1
- package/.next/server/app/api/agents/files/route.js.nft.json +1 -1
- package/.next/server/app/api/agents/identity/route.js +1 -1
- package/.next/server/app/api/agents/identity/route.js.nft.json +1 -1
- package/.next/server/app/api/agents/route.js +1 -1
- package/.next/server/app/api/agents/route.js.nft.json +1 -1
- package/.next/server/app/api/gateway/restart/route.js +1 -1
- package/.next/server/app/api/gateway/restart/route.js.nft.json +1 -1
- package/.next/server/app/api/goals/[id]/promote/route.js.nft.json +1 -1
- package/.next/server/app/api/goals/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/goals/route.js.nft.json +1 -1
- package/.next/server/app/api/recipes/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/recipes/clone/route.js.nft.json +1 -1
- package/.next/server/app/api/recipes/delete/route.js.nft.json +1 -1
- package/.next/server/app/api/recipes/route.js +1 -1
- package/.next/server/app/api/recipes/route.js.nft.json +1 -1
- package/.next/server/app/api/recipes/team-agents/route.js.nft.json +1 -1
- package/.next/server/app/api/scaffold/route.js.nft.json +1 -1
- package/.next/server/app/api/swarms/start/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/swarms/start/route/build-manifest.json +11 -0
- package/.next/server/app/api/swarms/start/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/swarms/start/route.js +6 -0
- package/.next/server/app/api/swarms/start/route.js.map +5 -0
- package/.next/server/app/api/swarms/start/route.js.nft.json +1 -0
- package/.next/server/app/api/swarms/start/route_client-reference-manifest.js +2 -0
- package/.next/server/app/api/swarms/status/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/swarms/status/route/build-manifest.json +11 -0
- package/.next/server/app/api/swarms/status/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/swarms/status/route.js +6 -0
- package/.next/server/app/api/swarms/status/route.js.map +5 -0
- package/.next/server/app/api/swarms/status/route.js.nft.json +1 -0
- package/.next/server/app/api/swarms/status/route_client-reference-manifest.js +2 -0
- package/.next/server/app/api/teams/orchestrator/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/teams/orchestrator/route/build-manifest.json +11 -0
- package/.next/server/app/api/teams/orchestrator/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/teams/orchestrator/route.js +6 -0
- package/.next/server/app/api/teams/orchestrator/route.js.map +5 -0
- package/.next/server/app/api/teams/orchestrator/route.js.nft.json +1 -0
- package/.next/server/app/api/teams/orchestrator/route_client-reference-manifest.js +2 -0
- package/.next/server/app/api/teams/remove-team/route.js +1 -1
- package/.next/server/app/api/teams/remove-team/route.js.nft.json +1 -1
- package/.next/server/app/api/teams/skills/install/route.js +1 -1
- package/.next/server/app/api/teams/skills/install/route.js.nft.json +1 -1
- package/.next/server/app/api/teams/workflow-runs/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/teams/workflow-runs/route/build-manifest.json +11 -0
- package/.next/server/app/api/teams/workflow-runs/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/teams/workflow-runs/route.js +7 -0
- package/.next/server/app/api/teams/workflow-runs/route.js.map +5 -0
- package/.next/server/app/api/teams/workflow-runs/route.js.nft.json +1 -0
- package/.next/server/app/api/teams/workflow-runs/route_client-reference-manifest.js +2 -0
- package/.next/server/app/api/teams/workflows/route/app-paths-manifest.json +3 -0
- package/.next/server/app/api/teams/workflows/route/build-manifest.json +11 -0
- package/.next/server/app/api/teams/workflows/route/server-reference-manifest.json +4 -0
- package/.next/server/app/api/teams/workflows/route.js +6 -0
- package/.next/server/app/api/teams/workflows/route.js.map +5 -0
- package/.next/server/app/api/teams/workflows/route.js.nft.json +1 -0
- package/.next/server/app/api/teams/workflows/route_client-reference-manifest.js +2 -0
- package/.next/server/app/api/tickets/move/route.js +1 -1
- package/.next/server/app/api/tickets/move/route.js.nft.json +1 -1
- package/.next/server/app/channels/page/build-manifest.json +4 -4
- package/.next/server/app/channels/page.js +7 -7
- package/.next/server/app/channels/page.js.nft.json +1 -1
- package/.next/server/app/channels/page_client-reference-manifest.js +1 -1
- package/.next/server/app/channels.html +2 -2
- package/.next/server/app/channels.rsc +5 -5
- package/.next/server/app/channels.segments/_full.segment.rsc +5 -5
- package/.next/server/app/channels.segments/_head.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_index.segment.rsc +3 -3
- package/.next/server/app/channels.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/channels.segments/channels/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/channels.segments/channels.segment.rsc +1 -1
- package/.next/server/app/cron-jobs/page/build-manifest.json +4 -4
- package/.next/server/app/cron-jobs/page.js +7 -7
- package/.next/server/app/cron-jobs/page.js.nft.json +1 -1
- package/.next/server/app/cron-jobs/page_client-reference-manifest.js +1 -1
- package/.next/server/app/cron-jobs.html +1 -1
- package/.next/server/app/cron-jobs.rsc +6 -6
- package/.next/server/app/cron-jobs.segments/_full.segment.rsc +6 -6
- package/.next/server/app/cron-jobs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_index.segment.rsc +3 -3
- package/.next/server/app/cron-jobs.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/cron-jobs.segments/cron-jobs/__PAGE__.segment.rsc +3 -3
- package/.next/server/app/cron-jobs.segments/cron-jobs.segment.rsc +1 -1
- package/.next/server/app/goals/[id]/page/build-manifest.json +4 -4
- package/.next/server/app/goals/[id]/page.js +7 -7
- package/.next/server/app/goals/[id]/page.js.nft.json +1 -1
- package/.next/server/app/goals/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/goals/new/page/build-manifest.json +4 -4
- package/.next/server/app/goals/new/page.js +7 -7
- package/.next/server/app/goals/new/page.js.nft.json +1 -1
- package/.next/server/app/goals/new/page_client-reference-manifest.js +1 -1
- package/.next/server/app/goals/new.html +2 -2
- package/.next/server/app/goals/new.rsc +5 -5
- package/.next/server/app/goals/new.segments/_full.segment.rsc +5 -5
- package/.next/server/app/goals/new.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_index.segment.rsc +3 -3
- package/.next/server/app/goals/new.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/goals/new.segments/goals/new/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/goals/new.segments/goals/new.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals.segment.rsc +1 -1
- package/.next/server/app/goals/page/build-manifest.json +4 -4
- package/.next/server/app/goals/page.js +7 -7
- package/.next/server/app/goals/page.js.nft.json +1 -1
- package/.next/server/app/goals/page_client-reference-manifest.js +1 -1
- package/.next/server/app/goals.html +1 -1
- package/.next/server/app/goals.rsc +5 -5
- package/.next/server/app/goals.segments/_full.segment.rsc +5 -5
- package/.next/server/app/goals.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_index.segment.rsc +3 -3
- package/.next/server/app/goals.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/goals.segments/goals/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/goals.segments/goals.segment.rsc +1 -1
- package/.next/server/app/page/build-manifest.json +4 -4
- package/.next/server/app/page.js +7 -7
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/recipes/[id]/page/build-manifest.json +4 -4
- package/.next/server/app/recipes/[id]/page.js +8 -8
- package/.next/server/app/recipes/[id]/page.js.nft.json +1 -1
- package/.next/server/app/recipes/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/recipes/page/build-manifest.json +4 -4
- package/.next/server/app/recipes/page.js +8 -8
- package/.next/server/app/recipes/page.js.nft.json +1 -1
- package/.next/server/app/recipes/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page/build-manifest.json +4 -4
- package/.next/server/app/settings/page.js +7 -7
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +5 -5
- package/.next/server/app/settings.segments/_full.segment.rsc +5 -5
- package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_index.segment.rsc +3 -3
- package/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
- package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/server/app/teams/[teamId]/page/build-manifest.json +4 -4
- package/.next/server/app/teams/[teamId]/page.js +8 -8
- package/.next/server/app/teams/[teamId]/page.js.nft.json +1 -1
- package/.next/server/app/teams/[teamId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/tickets/[ticket]/page/build-manifest.json +4 -4
- package/.next/server/app/tickets/[ticket]/page.js +7 -7
- package/.next/server/app/tickets/[ticket]/page.js.nft.json +1 -1
- package/.next/server/app/tickets/[ticket]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/tickets/page/build-manifest.json +4 -4
- package/.next/server/app/tickets/page.js +7 -7
- package/.next/server/app/tickets/page.js.nft.json +1 -1
- package/.next/server/app/tickets/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +5 -0
- package/.next/server/chunks/[root-of-the-server]__065a27a4._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__065a27a4._.js.map +1 -0
- package/.next/server/chunks/{[root-of-the-server]__94d68aa3._.js → [root-of-the-server]__1989d64f._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__94d68aa3._.js.map → [root-of-the-server]__1989d64f._.js.map} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__c4ffbb03._.js → [root-of-the-server]__21b72903._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__c4ffbb03._.js.map → [root-of-the-server]__21b72903._.js.map} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__0c01c5c7._.js → [root-of-the-server]__262d8a6e._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__0c01c5c7._.js.map → [root-of-the-server]__262d8a6e._.js.map} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__b11231a9._.js → [root-of-the-server]__2f2c799d._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__b11231a9._.js.map → [root-of-the-server]__2f2c799d._.js.map} +1 -1
- package/.next/server/chunks/[root-of-the-server]__6f85770b._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__6f85770b._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__7cf49621._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__7cf49621._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__a27f8405._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__a27f8405._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__a5226713._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__a5226713._.js.map +1 -0
- package/.next/server/chunks/[root-of-the-server]__c7f92fce._.js +3 -0
- package/.next/server/chunks/[root-of-the-server]__c7f92fce._.js.map +1 -0
- package/.next/server/chunks/{[root-of-the-server]__d737ca42._.js → [root-of-the-server]__e8bfeaba._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__d737ca42._.js.map → [root-of-the-server]__e8bfeaba._.js.map} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__4eda99a9._.js → [root-of-the-server]__ebaa0038._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__4eda99a9._.js.map → [root-of-the-server]__ebaa0038._.js.map} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__b59b3cdd._.js → [root-of-the-server]__f5546a39._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__b59b3cdd._.js.map → [root-of-the-server]__f5546a39._.js.map} +1 -1
- package/.next/server/chunks/{[root-of-the-server]__e6184ba3._.js → [root-of-the-server]__fdda9176._.js} +2 -2
- package/.next/server/chunks/{[root-of-the-server]__e6184ba3._.js.map → [root-of-the-server]__fdda9176._.js.map} +1 -1
- package/.next/server/chunks/_next-internal_server_app_api_swarms_start_route_actions_b79e9029.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_swarms_start_route_actions_b79e9029.js.map +1 -0
- package/.next/server/chunks/_next-internal_server_app_api_swarms_status_route_actions_54826df0.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_swarms_status_route_actions_54826df0.js.map +1 -0
- package/.next/server/chunks/_next-internal_server_app_api_teams_orchestrator_route_actions_1949c463.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_teams_orchestrator_route_actions_1949c463.js.map +1 -0
- package/.next/server/chunks/_next-internal_server_app_api_teams_workflow-runs_route_actions_8327ac7d.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_teams_workflow-runs_route_actions_8327ac7d.js.map +1 -0
- package/.next/server/chunks/_next-internal_server_app_api_teams_workflows_route_actions_43dd6e07.js +3 -0
- package/.next/server/chunks/_next-internal_server_app_api_teams_workflows_route_actions_43dd6e07.js.map +1 -0
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_1fe98a49.js +14 -0
- package/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_1fe98a49.js.map +1 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__0d4cb2ba._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__0fd02d84._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__4393e897._.js.map → [root-of-the-server]__0fd02d84._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__285ae6b7._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__46e08d44._.js.map → [root-of-the-server]__285ae6b7._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__2bef6884._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__15600e29._.js.map → [root-of-the-server]__2bef6884._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__3efd25c4._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__2a6f1e3e._.js.map → [root-of-the-server]__3efd25c4._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__491e06fa._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__491e06fa._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__550d78f8._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__bc3b27b0._.js.map → [root-of-the-server]__550d78f8._.js.map} +1 -1
- package/.next/server/chunks/ssr/{[root-of-the-server]__e2e52c6e._.js → [root-of-the-server]__78cdd31e._.js} +2 -2
- package/.next/server/chunks/ssr/[root-of-the-server]__8ecc89e4._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__507d2fc9._.js.map → [root-of-the-server]__8ecc89e4._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__92524828._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__247198dc._.js.map → [root-of-the-server]__92524828._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__9e1ab064._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__9e1ab064._.js.map +1 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__a36a058d._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__8d24c9c3._.js.map → [root-of-the-server]__a36a058d._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__a8eca9e1._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__82ce3aee._.js.map → [root-of-the-server]__a8eca9e1._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__aa8e2649._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__f75a61bf._.js.map → [root-of-the-server]__aa8e2649._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__b2617fbf._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__fd669584._.js.map → [root-of-the-server]__b2617fbf._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__b5f65083._.js +3 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__b5f65083._.js.map +1 -0
- package/.next/server/chunks/ssr/[root-of-the-server]__e5d416d5._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__3ad3e5b1._.js.map → [root-of-the-server]__e5d416d5._.js.map} +1 -1
- package/.next/server/chunks/ssr/{[root-of-the-server]__b9356576._.js → [root-of-the-server]__f62d412e._.js} +2 -2
- package/.next/server/chunks/ssr/{[root-of-the-server]__b9356576._.js.map → [root-of-the-server]__f62d412e._.js.map} +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__fbe5ff69._.js +3 -0
- package/.next/server/chunks/ssr/{[root-of-the-server]__3575e6da._.js.map → [root-of-the-server]__fbe5ff69._.js.map} +1 -1
- package/.next/server/chunks/ssr/{_8c45edba._.js → _0bdae23a._.js} +3 -3
- package/.next/server/chunks/ssr/{node_modules_next_dist_esm_build_templates_app-page_68c68167.js.map → _0bdae23a._.js.map} +1 -1
- package/.next/server/chunks/ssr/{_0808c2b9._.js → _347e2d56._.js} +3 -3
- package/.next/server/chunks/ssr/_347e2d56._.js.map +1 -0
- package/.next/server/chunks/ssr/{_68793c1f._.js → _49fb12c2._.js} +3 -3
- package/.next/server/chunks/ssr/_49fb12c2._.js.map +1 -0
- package/.next/server/chunks/ssr/{_3c8b2df6._.js → _536983a4._.js} +3 -3
- package/.next/server/chunks/ssr/_536983a4._.js.map +1 -0
- package/.next/server/chunks/ssr/{_cd23c5af._.js → _5b282394._.js} +3 -3
- package/.next/server/chunks/ssr/_5b282394._.js.map +1 -0
- package/.next/server/chunks/ssr/{_6e70b5a4._.js → _5cc24343._.js} +3 -3
- package/.next/server/chunks/ssr/_5cc24343._.js.map +1 -0
- package/.next/server/chunks/ssr/{_92140ca3._.js → _7eac37fb._.js} +3 -3
- package/.next/server/chunks/ssr/_7eac37fb._.js.map +1 -0
- package/.next/server/chunks/ssr/{_8c8207c1._.js → _8062e992._.js} +3 -3
- package/.next/server/chunks/ssr/_8062e992._.js.map +1 -0
- package/.next/server/chunks/ssr/{_25e6aab8._.js → _99994c05._.js} +3 -3
- package/.next/server/chunks/ssr/_99994c05._.js.map +1 -0
- package/.next/server/chunks/ssr/{_b5e9afcc._.js → _aafc99aa._.js} +3 -3
- package/.next/server/chunks/ssr/_aafc99aa._.js.map +1 -0
- package/.next/server/chunks/ssr/{_39e6e769._.js → _b7f3caf7._.js} +3 -3
- package/.next/server/chunks/ssr/_b7f3caf7._.js.map +1 -0
- package/.next/server/chunks/ssr/_c2041f88._.js +4 -0
- package/.next/server/chunks/ssr/_c2041f88._.js.map +1 -0
- package/.next/server/chunks/ssr/{_3158c108._.js → _f4d8af3b._.js} +3 -3
- package/.next/server/chunks/ssr/_f4d8af3b._.js.map +1 -0
- package/.next/server/chunks/ssr/{node_modules_next_dist_12287b3d._.js → node_modules_next_dist_8a37abed._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_next_dist_12287b3d._.js.map → node_modules_next_dist_8a37abed._.js.map} +1 -1
- package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_9774470f._.js → node_modules_next_dist_client_components_2fffaa3a._.js} +2 -2
- package/.next/server/chunks/ssr/{node_modules_next_dist_client_components_9774470f._.js.map → node_modules_next_dist_client_components_2fffaa3a._.js.map} +1 -1
- package/.next/server/chunks/ssr/{node_modules_next_dist_esm_build_templates_app-page_68c68167.js → node_modules_next_dist_esm_build_templates_app-page_b5ef32b4.js} +3 -3
- package/.next/server/chunks/ssr/node_modules_next_dist_esm_build_templates_app-page_b5ef32b4.js.map +1 -0
- package/.next/server/chunks/ssr/src_app_HomeClient_tsx_f9f7568d._.js +1 -1
- package/.next/server/chunks/ssr/src_app_HomeClient_tsx_f9f7568d._.js.map +1 -1
- package/.next/server/chunks/ssr/src_app_global-error_tsx_aa661ba4._.js +3 -0
- package/.next/server/chunks/ssr/src_app_global-error_tsx_aa661ba4._.js.map +1 -0
- package/.next/server/chunks/ssr/src_app_not-found_tsx_3f23d179._.js +3 -0
- package/.next/server/chunks/ssr/src_app_not-found_tsx_3f23d179._.js.map +1 -0
- package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_tsx_2900b91d._.js +2 -2
- package/.next/server/chunks/ssr/src_app_teams_[teamId]_team-editor_tsx_2900b91d._.js.map +1 -1
- package/.next/server/middleware-build-manifest.js +4 -4
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/{40f7fde35327d214.js → 423ca3a7f09c1470.js} +1 -1
- package/.next/static/chunks/{82abf2d65f5428ae.js → 68a088aa49e6124a.js} +3 -3
- package/.next/static/chunks/96b0d0ef92ef0eca.css +3 -0
- package/.next/static/chunks/a92e9d0c91b71b55.js +1 -0
- package/.next/static/chunks/bd3fcd39d918f9b4.js +10 -0
- package/.next/static/chunks/c84580993f22c17a.js +1 -0
- package/.next/static/chunks/f3e3461eda4a8d62.js +1 -0
- package/.next/static/chunks/{turbopack-ae1340e658f67df8.js → turbopack-6c658f991a22d28a.js} +1 -1
- package/package.json +2 -2
- package/public/android-chrome-192x192.png +0 -0
- package/public/android-chrome-512x512.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/chef.jpg +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/src/app/HomeClient.tsx +1 -1
- package/src/app/api/cron/jobs/route.ts +12 -4
- package/src/app/api/swarms/start/route.ts +118 -0
- package/src/app/api/swarms/status/route.ts +50 -0
- package/src/app/api/teams/orchestrator/route.ts +218 -0
- package/src/app/api/teams/workflow-runs/route.ts +431 -0
- package/src/app/api/teams/workflows/route.ts +88 -0
- package/src/app/cron-jobs/page.tsx +1 -1
- package/src/app/global-error.tsx +50 -0
- package/src/app/not-found.tsx +8 -0
- package/src/app/recipes/page.tsx +1 -1
- package/src/app/settings/page.tsx +1 -1
- package/src/app/teams/[teamId]/OrchestratorPanel.tsx +228 -0
- package/src/app/teams/[teamId]/page.tsx +25 -29
- package/src/app/teams/[teamId]/team-editor.tsx +1656 -8
- package/src/app/tickets/[ticket]/page.tsx +3 -0
- package/src/app/tickets/page.tsx +3 -0
- package/src/components/AppShell.tsx +245 -31
- package/src/lib/workflows/README.md +11 -0
- package/src/lib/workflows/runs-storage.ts +71 -0
- package/src/lib/workflows/runs-types.ts +32 -0
- package/src/lib/workflows/storage.ts +82 -0
- package/src/lib/workflows/types.ts +50 -0
- package/src/lib/workflows/validate.ts +70 -0
- package/.next/server/app/tickets.html +0 -1
- package/.next/server/app/tickets.meta +0 -15
- package/.next/server/app/tickets.rsc +0 -19
- package/.next/server/app/tickets.segments/_full.segment.rsc +0 -19
- package/.next/server/app/tickets.segments/_head.segment.rsc +0 -6
- package/.next/server/app/tickets.segments/_index.segment.rsc +0 -6
- package/.next/server/app/tickets.segments/_tree.segment.rsc +0 -4
- package/.next/server/app/tickets.segments/tickets/__PAGE__.segment.rsc +0 -8
- package/.next/server/app/tickets.segments/tickets.segment.rsc +0 -4
- package/.next/server/chunks/ssr/[root-of-the-server]__15600e29._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__247198dc._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__2a6f1e3e._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__346f79e5._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__346f79e5._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__3575e6da._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__3ad3e5b1._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__3bc7ad0a._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__4393e897._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__46e08d44._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__507d2fc9._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__82ce3aee._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__8d24c9c3._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__a457c799._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__a457c799._.js.map +0 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__bc3b27b0._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__f75a61bf._.js +0 -3
- package/.next/server/chunks/ssr/[root-of-the-server]__fd669584._.js +0 -3
- package/.next/server/chunks/ssr/_0808c2b9._.js.map +0 -1
- package/.next/server/chunks/ssr/_25e6aab8._.js.map +0 -1
- package/.next/server/chunks/ssr/_3158c108._.js.map +0 -1
- package/.next/server/chunks/ssr/_39e6e769._.js.map +0 -1
- package/.next/server/chunks/ssr/_3c8b2df6._.js.map +0 -1
- package/.next/server/chunks/ssr/_68793c1f._.js.map +0 -1
- package/.next/server/chunks/ssr/_6e70b5a4._.js.map +0 -1
- package/.next/server/chunks/ssr/_8c45edba._.js.map +0 -1
- package/.next/server/chunks/ssr/_8c8207c1._.js.map +0 -1
- package/.next/server/chunks/ssr/_92140ca3._.js.map +0 -1
- package/.next/server/chunks/ssr/_b5e9afcc._.js.map +0 -1
- package/.next/server/chunks/ssr/_cd23c5af._.js.map +0 -1
- package/.next/server/chunks/ssr/_d27483a1._.js +0 -4
- package/.next/server/chunks/ssr/_d27483a1._.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_45780354.js +0 -3
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_forbidden_45780354.js.map +0 -1
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_ece394eb.js +0 -3
- package/.next/server/chunks/ssr/node_modules_next_dist_client_components_builtin_global-error_ece394eb.js.map +0 -1
- package/.next/static/chunks/8484c54dc9a377e8.js +0 -10
- package/.next/static/chunks/8662fcc3cdff66f3.js +0 -1
- package/.next/static/chunks/a4e69b85b74277a7.css +0 -3
- package/.next/static/chunks/a9ed074e89b16a5e.js +0 -1
- /package/.next/server/chunks/ssr/{[root-of-the-server]__3bc7ad0a._.js.map → [root-of-the-server]__0d4cb2ba._.js.map} +0 -0
- /package/.next/server/chunks/ssr/{[root-of-the-server]__e2e52c6e._.js.map → [root-of-the-server]__78cdd31e._.js.map} +0 -0
- /package/.next/static/{2hgbnJUmLMe9COlc5rJd3 → LkBl31uBDAuYl-0TzH69D}/_buildManifest.js +0 -0
- /package/.next/static/{2hgbnJUmLMe9COlc5rJd3 → LkBl31uBDAuYl-0TzH69D}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{2hgbnJUmLMe9COlc5rJd3 → LkBl31uBDAuYl-0TzH69D}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports=[35279,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(1760),e=a.i(50944),f=a.i(35112);function g({open:a,teamId:c,onClose:d,onConfirm:e,busy:g}){return a?(0,f.createPortal)((0,b.jsxs)("div",{className:"fixed inset-0 z-[200]",children:[(0,b.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:d}),(0,b.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,b.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,b.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,b.jsx)("div",{className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:"Delete Team"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Delete team ",(0,b.jsx)("code",{className:"font-mono",children:c}),"? This will remove the team workspace, agents, and stamped cron jobs."]}),(0,b.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:d,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Cancel"}),(0,b.jsx)("button",{type:"button",disabled:g,onClick:e,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:g?"Deleting…":"Delete"})]})]})})})]}),document.body):null}function h({open:a,teamId:c,recipeId:d,onClose:e,onConfirm:g,busy:h}){return a?(0,f.createPortal)((0,b.jsxs)("div",{className:"fixed inset-0 z-[200]",children:[(0,b.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:e}),(0,b.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,b.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,b.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,b.jsx)("div",{className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:"Publish changes"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["This will re-scaffold team ",(0,b.jsx)("code",{className:"font-mono",children:c})," from recipe ",(0,b.jsx)("code",{className:"font-mono",children:d}),"."]}),(0,b.jsxs)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-3 text-sm text-amber-100",children:[(0,b.jsx)("div",{className:"font-medium",children:"Complete overwrite"}),(0,b.jsxs)("div",{className:"mt-1",children:["All existing team workspace files managed by the recipe will be overwritten (for example: ",(0,b.jsx)("code",{className:"font-mono",children:"AGENTS.md"}),","," ",(0,b.jsx)("code",{className:"font-mono",children:"SOUL.md"}),", role templates, and other scaffolded files). Any manual edits in those files will be lost."]})]}),(0,b.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:e,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,b.jsx)("button",{type:"button",disabled:h,onClick:g,className:"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:h?"Publishing…":"Publish changes"})]})]})})})]}),document.body):null}var i=a.i(61889);function j({teamId:a}){let f=(0,e.useRouter)(),[j,k]=(0,c.useState)([]),[l,m]=(0,c.useState)(""),[n,o]=(0,c.useState)(null),[p,q]=(0,c.useState)(null),[r,s]=(0,c.useState)(!1),[t,u]=(0,c.useState)(a),[v,w]=(0,c.useState)(a),[x,y]=(0,c.useState)(""),[z,A]=(0,c.useState)(null),[B,C]=(0,c.useState)("recipe"),[D,E]=(0,c.useState)(!0),[F,G]=(0,c.useState)(!1),[H,I]=(0,c.useState)(!1),[J,K]=(0,c.useState)(!1),[L,M]=(0,c.useState)(!1),[N,O]=(0,c.useState)(""),P=(0,i.useToast)(),[Q,R]=(0,c.useState)(!1),[S,T]=(0,c.useState)(!1),[U,V]=(0,c.useState)(null);function W(a,b="info"){let c=String(a??"").trim();c&&P.push({kind:b,message:c})}let[X,Y]=(0,c.useState)([]),[Z,$]=(0,c.useState)(!1),[_,aa]=(0,c.useState)(""),[ab,ac]=(0,c.useState)(!1),[ad,ae]=(0,c.useState)("SOUL.md"),[af,ag]=(0,c.useState)(""),[ah,ai]=(0,c.useState)([]),[aj,ak]=(0,c.useState)(!1),[al,am]=(0,c.useState)([]),[an,ao]=(0,c.useState)(!1),ap=(0,c.useMemo)(()=>{let a=String(x??"");if(!a.startsWith("---\n"))return[];let b=a.indexOf("\n---\n",4);if(-1===b)return[];let c=a.slice(4,b+1);try{let a=(0,d.parse)(c)??{};return(Array.isArray(a.agents)?a.agents:[]).map(a=>a).map(a=>({role:String(a.role??"").trim(),name:"string"==typeof a.name?a.name:void 0})).filter(a=>!!a.role)}catch{return[]}},[x]),[aq,ar]=(0,c.useState)(""),[as,at]=(0,c.useState)(""),[au,av]=(0,c.useState)(""),aw=(0,c.useMemo)(()=>{let a=("__custom__"===aq?as:aq).trim();return a||""},[aq,as]),[ax,ay]=(0,c.useState)([]),[az,aA]=(0,c.useState)([]),[aB,aC]=(0,c.useState)(!1),[aD,aE]=(0,c.useState)(""),[aF,aG]=(0,c.useState)(!1),[aH,aI]=(0,c.useState)(""),[aJ,aK]=(0,c.useState)(""),aL=(0,c.useMemo)(()=>j.filter(a=>"team"===a.kind),[j]),aM=(0,c.useMemo)(()=>j.find(a=>a.id===t&&"workspace"===a.source)??j.find(a=>a.id===t)??null,[j,t]),aN=!!a.trim(),aO=!!t.trim(),aP=j.some(a=>a.id===t&&"workspace"===a.source),aQ=!!(aM?.source==="builtin"&&!aP);async function aR(){let a=t.trim();if(a){M(!0),O("");try{let b=await fetch(`/api/recipes/${encodeURIComponent(a)}`,{cache:"no-store"}),c=await b.json();if(!b.ok)throw Error(c.error||`Recipe not found: ${a}. Save first to create it.`);let d=c.recipe;y(d.content),A("string"==typeof c.recipeHash?c.recipeHash:null)}catch(a){O(a instanceof Error?a.message:String(a))}finally{M(!1)}}}async function aS(a){let b=l.trim(),c=String(a.toId??t).trim(),d=String(a.toName??v).trim(),e=!!a.overwrite,f=!!a.scaffold;if(!b)throw Error("Source recipe id is required");if(!c)throw Error("Custom recipe id is required");let g=await fetch("/api/recipes/clone",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:b,toId:c,toName:d||void 0,overwrite:e,scaffold:f})}),h=await g.json();if(!g.ok)throw Error(h.error||"Save failed");return h}async function aT(a,b){G(!0),W("");try{let c=await aS({overwrite:a,...b});if(c.scaffold&&!c.scaffold.ok&&W(`Scaffold failed (recipe was still cloned): ${c.scaffold.error||"Unknown error"}`,"error"),x.trim()&&x.trim()!==c.content.trim()){let a=function(a,b){if(!a.startsWith("---\n"))return a;let c=a.indexOf("\n---\n",4);if(-1===c)return a;let d=a.slice(4,c),e=a.slice(c+5),f=d.split("\n"),g=[],h=!1,i=!1,j=!1;for(let a=0;a<f.length;a++){let c=f[a];if(/^team\s*:\s*$/i.test(c)){h=!0,i=!0,g.push(c);continue}if(h&&/^\S/.test(c)&&(h=!1),h&&/^\s+teamId\s*:/i.test(c)){g.push(` teamId: ${b}`),j=!0;continue}g.push(c)}if(i&&!j){let a=[];for(let c=0;c<g.length;c++)a.push(g[c]),/^team\s*:\s*$/i.test(g[c])&&(a.push(` teamId: ${b}`),j=!0);return`---
|
|
1
|
+
module.exports=[35279,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(1760),e=a.i(50944),f=a.i(35112);function g({open:a,teamId:c,onClose:d,onConfirm:e,busy:g}){return a?(0,f.createPortal)((0,b.jsxs)("div",{className:"fixed inset-0 z-[200]",children:[(0,b.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:d}),(0,b.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,b.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,b.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,b.jsx)("div",{className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:"Delete Team"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Delete team ",(0,b.jsx)("code",{className:"font-mono",children:c}),"? This will remove the team workspace, agents, and stamped cron jobs."]}),(0,b.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:d,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Cancel"}),(0,b.jsx)("button",{type:"button",disabled:g,onClick:e,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:g?"Deleting…":"Delete"})]})]})})})]}),document.body):null}function h({open:a,teamId:c,recipeId:d,onClose:e,onConfirm:g,busy:h}){return a?(0,f.createPortal)((0,b.jsxs)("div",{className:"fixed inset-0 z-[200]",children:[(0,b.jsx)("div",{className:"fixed inset-0 bg-black/60",onClick:e}),(0,b.jsx)("div",{className:"fixed inset-0 overflow-y-auto",children:(0,b.jsx)("div",{className:"flex min-h-full items-center justify-center p-4",children:(0,b.jsxs)("div",{className:"w-full max-w-lg rounded-2xl border border-white/10 bg-[color:var(--ck-bg-glass-strong)] p-5 shadow-[var(--ck-shadow-2)]",children:[(0,b.jsx)("div",{className:"text-lg font-semibold text-[color:var(--ck-text-primary)]",children:"Publish changes"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["This will re-scaffold team ",(0,b.jsx)("code",{className:"font-mono",children:c})," from recipe ",(0,b.jsx)("code",{className:"font-mono",children:d}),"."]}),(0,b.jsxs)("div",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-3 text-sm text-amber-100",children:[(0,b.jsx)("div",{className:"font-medium",children:"Complete overwrite"}),(0,b.jsxs)("div",{className:"mt-1",children:["All existing team workspace files managed by the recipe will be overwritten (for example: ",(0,b.jsx)("code",{className:"font-mono",children:"AGENTS.md"}),","," ",(0,b.jsx)("code",{className:"font-mono",children:"SOUL.md"}),", role templates, and other scaffolded files). Any manual edits in those files will be lost."]})]}),(0,b.jsxs)("div",{className:"mt-6 flex items-center justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:e,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,b.jsx)("button",{type:"button",disabled:h,onClick:g,className:"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:h?"Publishing…":"Publish changes"})]})]})})})]}),document.body):null}var i=a.i(61889);function j({teamId:a}){let[d,e]=(0,c.useState)(!0),[f,g]=(0,c.useState)(null),[h,i]=(0,c.useState)(null),j=(0,c.useCallback)(async()=>{e(!0);try{let b=await fetch(`/api/teams/orchestrator?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),c=await b.json();g(c),i(new Date().toISOString())}catch(a){g({ok:!1,error:a instanceof Error?a.message:String(a)}),i(new Date().toISOString())}finally{e(!1)}},[a]);return((0,c.useEffect)(()=>{j()},[j]),d)?(0,b.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"Loading orchestrator state…"}):f?f.ok?f.present?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Agent: ",(0,b.jsx)("span",{className:"font-mono",children:f.agent.id}),f.agent.identityName?` (${f.agent.identityName})`:""]}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Workspace: ",(0,b.jsx)("span",{className:"font-mono",children:f.agent.workspace})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:h?(0,b.jsxs)("span",{children:["Last updated: ",(0,b.jsx)("span",{className:"font-mono",children:h})]}):null}),(0,b.jsx)("button",{type:"button",onClick:()=>void j(),disabled:d,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)] transition-colors hover:bg-white/10 active:bg-white/15 disabled:opacity-50",children:d?"Refreshing…":"Refresh"})]})]}),(0,b.jsxs)("div",{className:"mt-5 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,b.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"tmux sessions"}),f.tmuxSessions.length?(0,b.jsx)("ul",{className:"mt-2 space-y-2",children:f.tmuxSessions.map(a=>(0,b.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.name}),(0,b.jsxs)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["attached=",String(a.attached),"number"==typeof a.windows?` windows=${a.windows}`:""]})]},a.name))}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No sessions detected (or tmux not running)."})]}),(0,b.jsxs)("section",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"git worktrees"}),f.worktrees.length?(0,b.jsx)("ul",{className:"mt-2 space-y-2",children:f.worktrees.map(a=>(0,b.jsxs)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"font-mono text-xs",children:a.path}),(0,b.jsxs)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:[a.branch?a.branch:"(no branch)",a.sha?` @ ${a.sha.slice(0,7)}`:""]})]},a.path))}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No worktrees detected."})]})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Active tasks"}),f.activeTasksSummary?(0,b.jsxs)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"font-mono text-xs",children:f.activeTasksSummary.path}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["number"==typeof f.activeTasksSummary.taskCount?`tasks=${f.activeTasksSummary.taskCount}`:"tasks=?",f.activeTasksSummary.rawType?` type=${f.activeTasksSummary.rawType}`:""]})]}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No active-tasks.json found."})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"CLI quick actions"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"The orchestrator is designed to be driven from the CLI (and usually tmux). Common commands:"}),(0,b.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-mono text-xs",children:"tmux ls"}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(list sessions)"})]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("span",{className:"font-mono text-xs",children:"tmux attach -t <session>"}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(jump into a running swarm)"})]}),(0,b.jsxs)("li",{children:[(0,b.jsxs)("span",{className:"font-mono text-xs",children:["git -C ",f.agent.workspace," worktree list"]}),(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"(inspect worktrees)"})]})]}),(0,b.jsx)("p",{className:"mt-3 text-xs text-[color:var(--ck-text-tertiary)]",children:"Note: ClawKitchen is read-only here; it surfaces status and pointers, but does not run or attach to tmux."})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Human approval gate (recommended)"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["For workflows that publish, deploy, or send outbound messages, keep a ",(0,b.jsx)("strong",{children:"human approval step"}),"."]}),(0,b.jsxs)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("li",{children:"Generate a proposed change/post as a draft."}),(0,b.jsx)("li",{children:"Send the draft to a bound messaging channel (e.g. Telegram) for approval."}),(0,b.jsx)("li",{children:"Only execute the final action after explicit approve/deny."})]})]}),(0,b.jsxs)("section",{className:"mt-4 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Where to change settings"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"These are the common knobs for a swarm/orchestrator scaffold (read-only references):"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:f.settingsPaths.map(a=>(0,b.jsx)("li",{className:"font-mono text-xs",children:a},a))})]})]}):(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsx)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No swarm/orchestrator detected for this team."}),(0,b.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-tertiary)]",children:"Detection"}),(0,b.jsx)("div",{className:"mt-1 font-mono text-xs",children:f.reason||"(no reason provided)"})]}),(0,b.jsxs)("p",{className:"mt-3 text-sm text-[color:var(--ck-text-secondary)]",children:["Once an orchestrator agent is installed (e.g. ",(0,b.jsx)("code",{children:"<teamId>-swarm-orchestrator"}),"), this tab will show: tmux sessions, git worktrees/branches, and active task state."]})]}):(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Orchestrator"}),(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:f.error})]}):(0,b.jsx)("div",{className:"mt-6 ck-glass-strong p-4",children:"No orchestrator state available."})}function k(a){let b=new Set;for(let c of a)b.add(c);return b.size}function l({teamId:a,initialTab:f}){let l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=(0,e.useRouter)(),[B,C]=(0,c.useState)([]),[D,E]=(0,c.useState)(""),[F,G]=(0,c.useState)(null),[H,I]=(0,c.useState)(null),[J,K]=(0,c.useState)(!1),[L,M]=(0,c.useState)(a),[N,O]=(0,c.useState)(a),[P,Q]=(0,c.useState)(""),[R,S]=(0,c.useState)(null),[T,U]=(0,c.useState)("recipe");(0,c.useEffect)(()=>{f&&["recipe","agents","skills","cron","workflows","files","orchestrator"].includes(f)&&U(f)},[f]);let[V,W]=(0,c.useState)(!0),[X,Y]=(0,c.useState)(!1),[Z,$]=(0,c.useState)(!1),[_,aa]=(0,c.useState)(!1),[ab,ac]=(0,c.useState)(!1),[ad,ae]=(0,c.useState)(""),af=(0,i.useToast)(),[ag,ah]=(0,c.useState)(!1),[ai,aj]=(0,c.useState)(!1),[ak,al]=(0,c.useState)(null);function am(a,b="info"){let c=String(a??"").trim();c&&af.push({kind:b,message:c})}let[an,ao]=(0,c.useState)([]),[ap,aq]=(0,c.useState)(!1),[ar,as]=(0,c.useState)(""),[at,au]=(0,c.useState)(!1),[av,aw]=(0,c.useState)("SOUL.md"),[ax,ay]=(0,c.useState)(""),[az,aA]=(0,c.useState)([]),[aB,aC]=(0,c.useState)(!1),[aD,aE]=(0,c.useState)([]),[aF,aG]=(0,c.useState)(!1),[aH,aI]=(0,c.useState)(""),[aJ,aK]=(0,c.useState)(""),[aL,aM]=(0,c.useState)(""),[aN,aO]=(0,c.useState)(!1),[aP,aQ]=(0,c.useState)("canvas"),[aR,aS]=(0,c.useState)(""),[aT,aU]=(0,c.useState)(null),[aV,aW]=(0,c.useState)(""),[aX,aY]=(0,c.useState)(""),[aZ,a$]=(0,c.useState)("llm"),[a_,a0]=(0,c.useState)(""),[a1,a2]=(0,c.useState)(""),[a3,a4]=(0,c.useState)(""),[a5,a6]=(0,c.useState)(!1),[a7,a8]=(0,c.useState)(!1),[a9,ba]=(0,c.useState)("new-workflow"),[bb,bc]=(0,c.useState)("New workflow"),[bd,be]=(0,c.useState)([]),[bf,bg]=(0,c.useState)(!1),[bh,bi]=(0,c.useState)(""),[bj,bk]=(0,c.useState)(""),[bl,bm]=(0,c.useState)(null),[bn,bo]=(0,c.useState)([]),[bp,bq]=(0,c.useState)(!1),br=(0,c.useRef)(null),bs=(0,c.useRef)(null),bt=(0,c.useMemo)(()=>{let a=String(aL||"").trim();if(!a)return null;try{return JSON.parse(a)}catch{return null}},[aL]),bu=(0,c.useMemo)(()=>{let a=String(aL||"").trim();if(!a)return"";try{return JSON.parse(a),""}catch(a){return a instanceof Error?a.message:"Invalid JSON"}},[aL]),bv=(0,c.useMemo)(()=>{if(!bt)return{errors:[],warnings:[]};try{return function(a){let b=[],c=[];"clawkitchen.workflow.v1"!==a.schema&&b.push(`schema must be clawkitchen.workflow.v1 (got ${String(a.schema)})`),String(a.id||"").trim()||b.push("id is required"),String(a.name||"").trim()||b.push("name is required");let d=Array.isArray(a.nodes)?a.nodes:[],e=Array.isArray(a.edges)?a.edges:[],f=Array.isArray(a.triggers)?a.triggers:[],g=d.map(a=>String(a?.id??"").trim()).filter(Boolean);g.length!==d.length&&b.push("all nodes must have a non-empty id"),k(g)!==g.length&&b.push("node ids must be unique");let h=e.map(a=>String(a?.id??"").trim()).filter(Boolean);h.length!==e.length&&b.push("all edges must have a non-empty id"),k(h)!==h.length&&b.push("edge ids must be unique");let i=new Set(g);for(let a of e){let c=String(a?.from??"").trim(),d=String(a?.to??"").trim();if(!c||!d){b.push(`edge ${String(a?.id??"(missing id)")} must have from/to`);continue}i.has(c)||b.push(`edge ${String(a.id)} references missing from node: ${c}`),i.has(d)||b.push(`edge ${String(a.id)} references missing to node: ${d}`)}let j=d.filter(a=>"start"===a.type),l=d.filter(a=>"end"===a.type);for(let a of(j.length||c.push("no start node found"),j.length>1&&c.push("multiple start nodes found (MVP supports this, but execution semantics may be ambiguous)"),l.length||c.push("no end node found"),f))"cron"===a.kind&&((String(a.id||"").trim()||b.push("cron trigger missing id"),String(a.expr||"").trim())?5!==String(a.expr||"").trim().split(/\s+/).filter(Boolean).length&&c.push(`cron trigger ${String(a.id)} expr is not 5-field: ${String(a.expr)}`):b.push(`cron trigger ${String(a.id||"(missing id)")} missing expr`),a.tz&&!String(a.tz).includes("/")&&c.push(`cron trigger ${String(a.id)} tz doesn't look like an IANA timezone: ${String(a.tz)}`));return{errors:b,warnings:c}}(bt)}catch(a){return{errors:[a instanceof Error?a.message:String(a)],warnings:[]}}},[bt]);(0,c.useEffect)(()=>{let b=String(bt?.id??"").trim();if(!b){be([]),bk(""),bm(null),bi("");return}let c=!1;return(async()=>{bg(!0),bi("");try{let d=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(a)}&workflowId=${encodeURIComponent(b)}`,{cache:"no-store"}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to list runs");let f=(Array.isArray(e.files)?e.files:[]).map(a=>String(a??"").trim()).filter(a=>!!a);if(c)return;be(f),bj&&!f.some(a=>a===`${bj}.run.json`)&&(bk(""),bm(null))}catch(a){if(c)return;bi(a instanceof Error?a.message:String(a))}finally{c||bg(!1)}})(),()=>{c=!0}},[a,bt?.id,bj]),(0,c.useEffect)(()=>{if(aT)return window.addEventListener("pointermove",a),window.addEventListener("pointerup",b),()=>{window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",b)};function a(a){if(!aT||!bt)return;let b=bt.nodes.find(a=>a.id===aT.nodeId);if(!b)return;let c=Math.max(0,Math.round(a.clientX-aT.containerLeft-aT.dx)),d=Math.max(0,Math.round(a.clientY-aT.containerTop-aT.dy));aM(JSON.stringify({...bt,nodes:bt.nodes.map(a=>a.id===b.id?{...a,x:c,y:d}:a)},null,2)+"\n")}function b(){aU(null)}},[aT,bt]);let bw=(0,c.useMemo)(()=>{let a=String(P??"");if(!a.startsWith("---\n"))return[];let b=a.indexOf("\n---\n",4);if(-1===b)return[];let c=a.slice(4,b+1);try{let a=(0,d.parse)(c)??{};return(Array.isArray(a.agents)?a.agents:[]).map(a=>a).map(a=>({role:String(a.role??"").trim(),name:"string"==typeof a.name?a.name:void 0})).filter(a=>!!a.role)}catch{return[]}},[P]),[bx,by]=(0,c.useState)(""),[bz,bA]=(0,c.useState)(""),[bB,bC]=(0,c.useState)(""),bD=(0,c.useMemo)(()=>{let a=("__custom__"===bx?bz:bx).trim();return a||""},[bx,bz]),[bE,bF]=(0,c.useState)([]),[bG,bH]=(0,c.useState)([]),[bI,bJ]=(0,c.useState)(!1),[bK,bL]=(0,c.useState)(""),[bM,bN]=(0,c.useState)(!1),[bO,bP]=(0,c.useState)(""),[bQ,bR]=(0,c.useState)(""),bS=(0,c.useMemo)(()=>B.filter(a=>"team"===a.kind),[B]),bT=(0,c.useMemo)(()=>B.find(a=>a.id===L&&"workspace"===a.source)??B.find(a=>a.id===L)??null,[B,L]),bU=!!a.trim(),bV=!!L.trim(),bW=B.some(a=>a.id===L&&"workspace"===a.source),bX=!!(bT?.source==="builtin"&&!bW);async function bY(){let a=L.trim();if(a){ac(!0),ae("");try{let b=await fetch(`/api/recipes/${encodeURIComponent(a)}`,{cache:"no-store"}),c=await b.json();if(!b.ok)throw Error(c.error||`Recipe not found: ${a}. Save first to create it.`);let d=c.recipe;Q(d.content),S("string"==typeof c.recipeHash?c.recipeHash:null)}catch(a){ae(a instanceof Error?a.message:String(a))}finally{ac(!1)}}}async function bZ(a){let b=D.trim(),c=String(a.toId??L).trim(),d=String(a.toName??N).trim(),e=!!a.overwrite,f=!!a.scaffold;if(!b)throw Error("Source recipe id is required");if(!c)throw Error("Custom recipe id is required");let g=await fetch("/api/recipes/clone",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({fromId:b,toId:c,toName:d||void 0,overwrite:e,scaffold:f})}),h=await g.json();if(!g.ok)throw Error(h.error||"Save failed");return h}async function b$(a,b){Y(!0),am("");try{let c=await bZ({overwrite:a,...b});if(c.scaffold&&!c.scaffold.ok&&am(`Scaffold failed (recipe was still cloned): ${c.scaffold.error||"Unknown error"}`,"error"),P.trim()&&P.trim()!==c.content.trim()){let a=function(a,b){if(!a.startsWith("---\n"))return a;let c=a.indexOf("\n---\n",4);if(-1===c)return a;let d=a.slice(4,c),e=a.slice(c+5),f=d.split("\n"),g=[],h=!1,i=!1,j=!1;for(let a=0;a<f.length;a++){let c=f[a];if(/^team\s*:\s*$/i.test(c)){h=!0,i=!0,g.push(c);continue}if(h&&/^\S/.test(c)&&(h=!1),h&&/^\s+teamId\s*:/i.test(c)){g.push(` teamId: ${b}`),j=!0;continue}g.push(c)}if(i&&!j){let a=[];for(let c=0;c<g.length;c++)a.push(g[c]),/^team\s*:\s*$/i.test(g[c])&&(a.push(` teamId: ${b}`),j=!0);return`---
|
|
2
2
|
${a.join("\n")}
|
|
3
3
|
---
|
|
4
4
|
${e}`}return`---
|
|
@@ -7,6 +7,6 @@ ${g.join("\n")}
|
|
|
7
7
|
${e}`}(function(a,b){if(!a.startsWith("---\n"))return a;let c=a.indexOf("\n---\n",4);if(-1===c)return a;let d=a.slice(4,c),e=a.slice(c+5),f=d.split("\n"),g=!1,h=f.map(a=>/^id\s*:/i.test(a)?(g=!0,`id: ${b}`):a);return g||h.unshift(`id: ${b}`),`---
|
|
8
8
|
${h.join("\n")}
|
|
9
9
|
---
|
|
10
|
-
${e}`}(x,t.trim()),t.trim()),b=await fetch(`/api/recipes/${encodeURIComponent(t.trim())}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:a})}),c=await b.json();if(!b.ok)throw Error(c.error||"Save failed");y(a)}else y(c.content);try{let a=await fetch(`/api/recipes/${encodeURIComponent(t.trim())}`,{cache:"no-store"}),b=await a.json();a.ok&&"string"==typeof b.recipeHash&&A(b.recipeHash)}catch{A(null)}W(`Saved team recipe: ${c.filePath}`,"success")}catch(a){W(a instanceof Error?a.message:String(a),"error")}finally{G(!1)}}async function aU(b){G(!0),aa("");try{let c=await fetch(`/api/teams/file?teamId=${encodeURIComponent(a)}&name=${encodeURIComponent(b)}`,{cache:"no-store"}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to load file");ae(b),ag(String(d.content??""))}catch(a){aa(a instanceof Error?a.message:String(a))}finally{G(!1)}}async function aV(){G(!0),aa("");try{let b=await fetch("/api/teams/file",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,name:ad,content:af})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to save file")}catch(a){aa(a instanceof Error?a.message:String(a))}finally{G(!1)}}return((0,c.useEffect)(()=>{u(a),w(a),y(""),A(null),V(null),T(!1),R(!1)},[a]),(0,c.useEffect)(()=>{(async()=>{E(!0);try{let[b,c]=await Promise.all([fetch("/api/recipes",{cache:"no-store"}),fetch(`/api/teams/meta?teamId=${encodeURIComponent(a)}`,{cache:"no-store"})]),d=(await b.json()).recipes??[];k(d);let e=null;try{let a=await c.json();if(c.ok&&a.ok&&a.meta&&a.meta.recipeId){let b=a.meta;e={recipeId:String(b.recipeId),recipeName:"string"==typeof b.recipeName?b.recipeName:void 0};let c="string"==typeof b.recipeHash?b.recipeHash:null;V(c)}else V(null)}catch{}if(e)o(e.recipeId),q(e.recipeName??null),s(!1),m(e.recipeId);else{o(null),q(null),s(!0);let b=d.find(b=>"team"===b.kind&&b.id===a),c=d.find(a=>"team"===a.kind),e=b??c;e&&m(e.id)}E(!1),(async()=>{$(!0),ak(!0),ao(!0),aC(!0);try{let[b,c,d,e,f]=await Promise.all([fetch(`/api/teams/files?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),fetch(`/api/cron/jobs?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),fetch("/api/agents",{cache:"no-store"}),fetch(`/api/teams/skills?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),fetch("/api/skills/available",{cache:"no-store"})]);try{let a=await b.json();if(b.ok&&a.ok){let b=Array.isArray(a.files)?a.files:[];Y(b.map(a=>({name:String(a.name??""),missing:!!a.missing,required:!!a.required,rationale:"string"==typeof a.rationale?a.rationale:void 0})))}}catch{}try{let a=await c.json();if(c.ok&&a.ok){let b=Array.isArray(a.jobs)?a.jobs:[];ai(b)}}catch{}try{let b=await d.json();if(d.ok){let c=(Array.isArray(b.agents)?b.agents:[]).filter(b=>String(b.id??"").startsWith(`${a}-`));am(c.map(a=>({id:String(a.id??""),identityName:"string"==typeof a.identityName?a.identityName:void 0})))}}catch{}try{let a=await e.json();e.ok&&a.ok&&ay(Array.isArray(a.skills)?a.skills:[])}catch{}try{let a=await f.json();if(f.ok&&a.ok){let b=Array.isArray(a.skills)?a.skills:[];aA(b),aE(a=>{let c=String(a??"").trim();return c&&b.includes(c)?c:b[0]??""})}}catch{}}finally{$(!1),ak(!1),ao(!1),aC(!1)}})()}catch(a){W(a instanceof Error?a.message:String(a),"error")}finally{E(!1)}})()},[a]),(0,c.useEffect)(()=>{!t.trim()||x.trim()||L||aR()},[t]),D)?(0,b.jsx)("div",{className:"ck-glass mx-auto max-w-4xl p-6",children:"Loading…"}):(0,b.jsxs)("div",{className:"ck-glass mx-auto max-w-6xl p-6 sm:p-8",children:[(0,b.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Team editor"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Bootstrap a ",(0,b.jsx)("strong",{children:"custom team recipe"})," for this installed team, without modifying builtin recipes."]}),(0,b.jsx)("div",{className:"mt-6 flex flex-wrap gap-2",children:[{id:"recipe",label:"Recipe"},{id:"agents",label:"Agents"},{id:"skills",label:"Skills"},{id:"cron",label:"Cron"},{id:"files",label:"Files"}].map(a=>(0,b.jsx)("button",{onClick:()=>C(a.id),className:B===a.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:a.label},a.id))}),"recipe"===B?(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Custom recipe target"}),(0,b.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team id"}),(0,b.jsx)("input",{value:t,onChange:a=>u(a.target.value),disabled:!1,className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["This is the ",(0,b.jsx)("b",{children:"custom recipe id"})," that will be created/overwritten when you save."]}),(0,b.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team name"}),(0,b.jsx)("input",{value:v,onChange:a=>w(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2",children:[(0,b.jsx)("button",{type:"button",disabled:F||!aN||!aO||aQ,onClick:()=>aT(!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)] transition-colors hover:bg-[var(--ck-accent-red-hover)] active:bg-[var(--ck-accent-red-active)] disabled:opacity-50",children:F?"Saving…":"Save"}),(0,b.jsx)("button",{type:"button",disabled:F||!aN||!aO||aQ||!z||!U||z===U,onClick:()=>T(!0),className:"rounded-[var(--ck-radius-sm)] bg-emerald-600 px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] transition-colors hover:bg-emerald-500 active:bg-emerald-700 disabled:opacity-50",children:H?"Publishing…":"Publish changes"}),(0,b.jsx)("button",{type:"button",disabled:F,onClick:()=>R(!0),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:"Delete Team"})]})]}),(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Notes"}),(0,b.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Parent recipe (locked)"}),(0,b.jsx)("select",{disabled:!0,className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70",value:l,onChange:a=>m(a.target.value),children:aL.map(a=>(0,b.jsxs)("option",{value:a.id,children:[a.id," (",a.source,")"]},`${a.source}:${a.id}`))}),n?(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("code",{children:n}),p?` (${p})`:""]}):r?(0,b.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Provenance not found for this team. The parent recipe above is a best-guess."}):null]}),(0,b.jsxs)("ul",{className:"mt-4 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("strong",{children:"Save"})," writes/overwrites the custom recipe file identified by “Team id”."]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("strong",{children:"Publish changes"})," re-scaffolds this team from your current custom recipe and applies config (complete overwrite)."]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("strong",{children:"Delete Team"})," runs the safe uninstall command (",(0,b.jsx)("code",{children:"openclaw recipes remove-team"}),")."]})]})]})]}):null,"agents"===B?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Agents in this team"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Add/remove agents by updating the ",(0,b.jsx)("code",{children:"agents:"})," list in your custom team recipe (",(0,b.jsx)("code",{children:t}),")."]}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Role"}),(0,b.jsxs)("select",{value:aq,onChange:a=>{let b=a.target.value;if(ar(b),"__custom__"===b){at(""),av("");return}at("");let c=ap.find(a=>a.role===b);av(c?.name||"")},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",children:[(0,b.jsx)("option",{value:"",children:"Select…"}),ap.map(a=>(0,b.jsx)("option",{value:a.role,children:a.name||a.role},a.role)),(0,b.jsx)("option",{value:"__custom__",children:"Other…"})]}),"__custom__"===aq?(0,b.jsx)("input",{value:as,onChange:a=>at(a.target.value),placeholder:"role (e.g. researcher)",className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}):null,(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["This writes to the recipe’s ",(0,b.jsx)("code",{children:"agents:"})," list."]})]}),(0,b.jsx)("div",{className:"sm:col-span-2",children:(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Name (optional)"}),(0,b.jsx)("input",{value:au,onChange:a=>av(a.target.value),placeholder:"Onchain Researcher",className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"})]})})]}),(0,b.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:(0,b.jsx)("button",{disabled:F||!aw,onClick:async()=>{G(!0);try{try{await aS({overwrite:!1})}catch(b){let a=b instanceof Error?b.message:String(b);if(!/Recipe id already exists:/i.test(a))throw b}let d=await fetch("/api/recipes/team-agents",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("__custom__"===aq?{recipeId:t.trim(),op:"add",role:aw,name:au}:{recipeId:t.trim(),op:"addLike",baseRole:aw,teamId:a,name:au})}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed updating agents list");y(String(e.content??x));try{let b=await fetch("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:t.trim(),teamId:a,applyConfig:!0,overwrite:!1,allowExisting:!0,cronInstallChoice:"no"})}),c=await b.json();if(!b.ok)throw Error(c.error||"Failed to apply config / scaffold team")}catch(a){W(a instanceof Error?a.message:String(a),"error")}let f="string"==typeof e.addedAgentId?e.addedAgentId:"";async function b(){let b=await fetch("/api/agents",{cache:"no-store"}),c=await b.json();if(!b.ok)return{ok:!1,hasExpected:!1,agents:[]};let d=(Array.isArray(c.agents)?c.agents:[]).filter(b=>String(b.id??"").startsWith(`${a}-`)).map(a=>({id:String(a.id??""),identityName:"string"==typeof a.identityName?a.identityName:void 0})),e=!!f&&d.some(a=>a.id===f);return{ok:!0,hasExpected:e,agents:d}}async function c(a){let c=Date.now();for(;Date.now()-c<a;){try{let a=await b();if(a.ok&&(am(a.agents),!f||a.hasExpected))return!0}catch{}await new Promise(a=>setTimeout(a,500))}return!1}if(!await c(5e3)&&f){try{fetch("/api/gateway/restart",{method:"POST"})}catch{}await c(1e4)}W(`Updated agents list in ${t}`,"success")}catch(a){W(a instanceof Error?a.message:String(a),"error")}finally{G(!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:"Add agent"})}),(0,b.jsxs)("div",{className:"mt-6",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Detected installed team agents (read-only)"}),(0,b.jsx)("ul",{className:"mt-2 space-y-2",children:al.length?al.map(c=>(0,b.jsxs)("li",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:c.identityName||c.id}),(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:c.id})]}),(0,b.jsx)("a",{className:"text-sm font-medium text-[color:var(--ck-accent-red)] hover:text-[color:var(--ck-accent-red-hover)]",href:`/agents/${encodeURIComponent(c.id)}?returnTo=${encodeURIComponent(`/teams/${a}?tab=agents`)}`,children:"Edit"})]},c.id)):an?(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No team agents detected."})})]})]}):null,"skills"===B?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Skills"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Skills installed in this ",(0,b.jsx)("strong",{children:"team"})," workspace (",(0,b.jsx)("code",{children:"skills/"}),"). These are available to all agents in the team. For agent-specific skills, open the agent from the Agents tab."]}),(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Installed"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:ax.length?ax.map(a=>(0,b.jsx)("li",{children:a},a)):(0,b.jsx)("li",{children:"None installed."})})]}),(0,b.jsxs)("div",{className:"mt-5 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15 p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Add a skill"}),(0,b.jsxs)("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,b.jsx)("select",{value:aD,onChange:a=>aE(a.target.value),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)]",disabled:aF||aB||!az.length,children:az.length?az.map(a=>(0,b.jsx)("option",{value:a,children:a},a)):(0,b.jsx)("option",{value:"",children:"No skills found"})}),(0,b.jsx)("button",{type:"button",disabled:aF||aB||!aD,onClick:async()=>{aG(!0),aI(""),aK("");try{let b=await fetch("/api/teams/skills/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,skill:aD})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to install skill");aI(`Installed skill: ${aD}`);let d=await fetch(`/api/teams/skills?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),e=await d.json();d.ok&&e.ok&&ay(Array.isArray(e.skills)?e.skills:[])}catch(a){aK(a instanceof Error?a.message:String(a))}finally{aG(!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:aF?"Adding…":"Add"})]}),aJ?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:aJ}):null,aH?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 p-3 text-sm text-emerald-100",children:aH}):null,(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["This uses ",(0,b.jsxs)("code",{children:["openclaw recipes install-skill <skill> --team-id ",a," --yes"]}),"."]})]})]}):null,"cron"===B?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Cron jobs (filtered by team name)"}),(0,b.jsx)("ul",{className:"mt-3 space-y-3",children:ah.length?ah.map(a=>{let c=String(a.id??a.jobId??"").trim(),d=c||String(a.name??"job"),e=String(a.name??a.id??a.jobId??"(unnamed)"),f=a.enabled??a.state?.enabled;async function g(a){G(!0);try{let b=await fetch("/api/cron/job",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:c,action:a})}),d=await b.json();if(!b.ok||!d.ok)throw Error(d.error||"Cron action failed");W(`Cron ${a}: ${e}`,"success")}catch(a){W(a instanceof Error?a.message:String(a),"error")}finally{G(!1)}}return(0,b.jsxs)("li",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:e}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Enabled: ",String(f??"?")]}),(0,b.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,b.jsx)("button",{disabled:F||!c,onClick:()=>g("run"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Run"}),(0,b.jsx)("button",{disabled:F||!c,onClick:()=>g("enable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Enable"}),(0,b.jsx)("button",{disabled:F||!c,onClick:()=>g("disable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Disable"}),c?null:(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"(missing id)"})]})]},d)}):aj?(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No cron jobs detected for this team."})})]}):null,"files"===B?(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3",children:[(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Team files"}),(0,b.jsxs)("label",{className:"flex items-center gap-2 text-xs text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("input",{type:"checkbox",checked:ab,onChange:a=>ac(a.target.checked)}),"Show optional"]})]}),(0,b.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Default view hides optional missing files to reduce noise."}),(0,b.jsxs)("ul",{className:"mt-3 space-y-1",children:[Z?(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,X.filter(a=>!!ab||a.required||!a.missing).map(a=>(0,b.jsx)("li",{children:(0,b.jsxs)("button",{onClick:()=>aU(a.name),className:ad===a.name?"w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-3 py-2 text-left text-sm text-[color:var(--ck-text-primary)]":"w-full rounded-[var(--ck-radius-sm)] px-3 py-2 text-left text-sm text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:[(0,b.jsx)("span",{className:a.required?"text-[color:var(--ck-text-primary)]":"text-[color:var(--ck-text-secondary)]",children:a.name}),(0,b.jsx)("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:a.required?"required":"optional"}),a.missing?(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"missing"}):null]})},a.name))]})]}),(0,b.jsxs)("div",{className:"ck-glass-strong p-4 lg:col-span-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:["Edit: ",ad]}),(0,b.jsx)("button",{disabled:F,onClick:aV,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:F?"Saving…":"Save file"})]}),_?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:_}):null,(0,b.jsx)("textarea",{value:af,onChange:a=>ag(a.target.value),className:"mt-3 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1})]})]}):null,"recipe"===B?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recipe markdown"}),N?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:N}):null,(0,b.jsx)("textarea",{value:x,onChange:a=>{y(a.target.value),A(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})]}):null,(0,b.jsx)(h,{open:S,teamId:a,recipeId:t,busy:H,onClose:()=>T(!1),onConfirm:async()=>{I(!0);try{let b=await fetch("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:t.trim(),teamId:a,overwrite:!0,applyConfig:!0})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Publish failed");try{let b=await fetch(`/api/teams/meta?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),c=await b.json();b.ok&&c.ok&&c.meta&&"string"==typeof c.meta.recipeHash&&V(c.meta.recipeHash)}catch{}T(!1),W("Published changes to active team","success")}catch(a){W(a instanceof Error?a.message:String(a),"error")}finally{I(!1)}}}),(0,b.jsx)(g,{open:Q,teamId:a,busy:J,onClose:()=>R(!1),onConfirm:async()=>{K(!0);try{let b=await fetch("/api/teams/remove-team",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Delete failed");W("Deleted team successfully","success"),R(!1),setTimeout(()=>f.push("/"),250)}catch(a){W(a instanceof Error?a.message:String(a),"error")}finally{K(!1)}}})]})}a.s(["default",()=>j],35279)}];
|
|
10
|
+
${e}`}(P,L.trim()),L.trim()),b=await fetch(`/api/recipes/${encodeURIComponent(L.trim())}`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({content:a})}),c=await b.json();if(!b.ok)throw Error(c.error||"Save failed");Q(a)}else Q(c.content);try{let a=await fetch(`/api/recipes/${encodeURIComponent(L.trim())}`,{cache:"no-store"}),b=await a.json();a.ok&&"string"==typeof b.recipeHash&&S(b.recipeHash)}catch{S(null)}am(`Saved team recipe: ${c.filePath}`,"success")}catch(a){am(a instanceof Error?a.message:String(a),"error")}finally{Y(!1)}}async function b_(b){Y(!0),as("");try{let c=await fetch(`/api/teams/file?teamId=${encodeURIComponent(a)}&name=${encodeURIComponent(b)}`,{cache:"no-store"}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to load file");aw(b),ay(String(d.content??""))}catch(a){as(a instanceof Error?a.message:String(a))}finally{Y(!1)}}async function b0(){Y(!0),as("");try{let b=await fetch("/api/teams/file",{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,name:av,content:ax})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to save file")}catch(a){as(a instanceof Error?a.message:String(a))}finally{Y(!1)}}return((0,c.useEffect)(()=>{M(a),O(a),Q(""),S(null),al(null),aj(!1),ah(!1)},[a]),(0,c.useEffect)(()=>{(async()=>{W(!0);try{let[b,c]=await Promise.all([fetch("/api/recipes",{cache:"no-store"}),fetch(`/api/teams/meta?teamId=${encodeURIComponent(a)}`,{cache:"no-store"})]),d=(await b.json()).recipes??[];C(d);let e=null;try{let a=await c.json();if(c.ok&&a.ok&&a.meta&&a.meta.recipeId){let b=a.meta;e={recipeId:String(b.recipeId),recipeName:"string"==typeof b.recipeName?b.recipeName:void 0};let c="string"==typeof b.recipeHash?b.recipeHash:null;al(c)}else al(null)}catch{}if(e)G(e.recipeId),I(e.recipeName??null),K(!1),E(e.recipeId);else{G(null),I(null),K(!0);let b=d.find(b=>"team"===b.kind&&b.id===a),c=d.find(a=>"team"===a.kind),e=b??c;e&&E(e.id)}W(!1),(async()=>{aq(!0),aC(!0),aG(!0),bq(!0),bJ(!0);try{let[b,c,d,e,f,g]=await Promise.all([fetch(`/api/teams/files?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),fetch(`/api/cron/jobs?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),fetch("/api/agents",{cache:"no-store"}),fetch(`/api/teams/skills?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),fetch("/api/skills/available",{cache:"no-store"}),fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}`,{cache:"no-store"})]);try{let a=await b.json();if(b.ok&&a.ok){let b=Array.isArray(a.files)?a.files:[];ao(b.map(a=>({name:String(a.name??""),missing:!!a.missing,required:!!a.required,rationale:"string"==typeof a.rationale?a.rationale:void 0})))}}catch{}try{let a=await c.json();if(c.ok&&a.ok){let b=Array.isArray(a.jobs)?a.jobs:[];aA(b)}}catch{}try{let a=await g.json();if(g.ok&&a.ok){let b=(Array.isArray(a.files)?a.files:[]).map(a=>String(a??"").trim()).filter(a=>!!a);aE(b),aK(a=>{let c=String(a??"").trim();return c&&b.includes(c)?c:b[0]??""})}}catch{}try{let b=await d.json();if(d.ok){let c=(Array.isArray(b.agents)?b.agents:[]).filter(b=>String(b.id??"").startsWith(`${a}-`));bo(c.map(a=>({id:String(a.id??""),identityName:"string"==typeof a.identityName?a.identityName:void 0})))}}catch{}try{let a=await e.json();e.ok&&a.ok&&bF(Array.isArray(a.skills)?a.skills:[])}catch{}try{let a=await f.json();if(f.ok&&a.ok){let b=Array.isArray(a.skills)?a.skills:[];bH(b),bL(a=>{let c=String(a??"").trim();return c&&b.includes(c)?c:b[0]??""})}}catch{}}finally{aq(!1),aC(!1),aG(!1),bq(!1),bJ(!1)}})()}catch(a){am(a instanceof Error?a.message:String(a),"error")}finally{W(!1)}})()},[a]),(0,c.useEffect)(()=>{!L.trim()||P.trim()||ab||bY()},[L]),V)?(0,b.jsx)("div",{className:"ck-glass w-full p-6",children:"Loading…"}):(0,b.jsxs)("div",{className:"ck-glass w-full p-6 sm:p-8",children:[(0,b.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",children:"Team editor"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Bootstrap a ",(0,b.jsx)("strong",{children:"custom team recipe"})," for this installed team, without modifying builtin recipes."]}),(0,b.jsx)("div",{className:"mt-6 flex flex-wrap gap-2",children:[{id:"recipe",label:"Recipe"},{id:"agents",label:"Agents"},{id:"skills",label:"Skills"},{id:"cron",label:"Cron"},{id:"workflows",label:"Workflows"},{id:"files",label:"Files"},{id:"orchestrator",label:"Orchestrator"}].map(c=>(0,b.jsx)("button",{onClick:()=>{U(c.id);try{A.replace(`/teams/${encodeURIComponent(a)}?tab=${encodeURIComponent(c.id)}`,{scroll:!1})}catch{}},className:T===c.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:c.label},c.id))}),"recipe"===T?(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Custom recipe target"}),(0,b.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team id"}),(0,b.jsx)("input",{value:L,onChange:a=>M(a.target.value),disabled:!1,className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70"}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["This is the ",(0,b.jsx)("b",{children:"custom recipe id"})," that will be created/overwritten when you save."]}),(0,b.jsx)("label",{className:"mt-3 block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Team name"}),(0,b.jsx)("input",{value:N,onChange:a=>O(a.target.value),className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-2",children:[(0,b.jsx)("button",{type:"button",disabled:X||!bU||!bV||bX,onClick:()=>b$(!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)] transition-colors hover:bg-[var(--ck-accent-red-hover)] active:bg-[var(--ck-accent-red-active)] disabled:opacity-50",children:X?"Saving…":"Save"}),(0,b.jsx)("button",{type:"button",disabled:X||!bU||!bV||bX||!R||!ak||R===ak,onClick:()=>aj(!0),className:"rounded-[var(--ck-radius-sm)] bg-emerald-600 px-3 py-2 text-sm font-medium text-white shadow-[var(--ck-shadow-1)] transition-colors hover:bg-emerald-500 active:bg-emerald-700 disabled:opacity-50",children:Z?"Publishing…":"Publish changes"}),(0,b.jsx)("button",{type:"button",disabled:X,onClick:()=>ah(!0),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:"Delete Team"})]})]}),(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Notes"}),(0,b.jsxs)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Parent recipe (locked)"}),(0,b.jsx)("select",{disabled:!0,className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)] disabled:opacity-70",value:D,onChange:a=>E(a.target.value),children:bS.map(a=>(0,b.jsxs)("option",{value:a.id,children:[a.id," (",a.source,")"]},`${a.source}:${a.id}`))}),F?(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("code",{children:F}),H?` (${H})`:""]}):J?(0,b.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Provenance not found for this team. The parent recipe above is a best-guess."}):null]}),(0,b.jsxs)("ul",{className:"mt-4 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:[(0,b.jsxs)("li",{children:[(0,b.jsx)("strong",{children:"Save"})," writes/overwrites the custom recipe file identified by “Team id”."]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("strong",{children:"Publish changes"})," re-scaffolds this team from your current custom recipe and applies config (complete overwrite)."]}),(0,b.jsxs)("li",{children:[(0,b.jsx)("strong",{children:"Delete Team"})," runs the safe uninstall command (",(0,b.jsx)("code",{children:"openclaw recipes remove-team"}),")."]})]})]})]}):null,"agents"===T?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Agents in this team"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Add/remove agents by updating the ",(0,b.jsx)("code",{children:"agents:"})," list in your custom team recipe (",(0,b.jsx)("code",{children:L}),")."]}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Role"}),(0,b.jsxs)("select",{value:bx,onChange:a=>{let b=a.target.value;if(by(b),"__custom__"===b){bA(""),bC("");return}bA("");let c=bw.find(a=>a.role===b);bC(c?.name||"")},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",children:[(0,b.jsx)("option",{value:"",children:"Select…"}),bw.map(a=>(0,b.jsx)("option",{value:a.role,children:a.name||a.role},a.role)),(0,b.jsx)("option",{value:"__custom__",children:"Other…"})]}),"__custom__"===bx?(0,b.jsx)("input",{value:bz,onChange:a=>bA(a.target.value),placeholder:"role (e.g. researcher)",className:"mt-2 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"}):null,(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:["This writes to the recipe’s ",(0,b.jsx)("code",{children:"agents:"})," list."]})]}),(0,b.jsx)("div",{className:"sm:col-span-2",children:(0,b.jsxs)("div",{children:[(0,b.jsx)("label",{className:"block text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Name (optional)"}),(0,b.jsx)("input",{value:bB,onChange:a=>bC(a.target.value),placeholder:"Onchain Researcher",className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]"})]})})]}),(0,b.jsx)("div",{className:"mt-3 flex flex-wrap gap-2",children:(0,b.jsx)("button",{disabled:X||!bD,onClick:async()=>{Y(!0);try{try{await bZ({overwrite:!1})}catch(b){let a=b instanceof Error?b.message:String(b);if(!/Recipe id already exists:/i.test(a))throw b}let d=await fetch("/api/recipes/team-agents",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify("__custom__"===bx?{recipeId:L.trim(),op:"add",role:bD,name:bB}:{recipeId:L.trim(),op:"addLike",baseRole:bD,teamId:a,name:bB})}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed updating agents list");Q(String(e.content??P));try{let b=await fetch("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:L.trim(),teamId:a,applyConfig:!0,overwrite:!1,allowExisting:!0,cronInstallChoice:"no"})}),c=await b.json();if(!b.ok)throw Error(c.error||"Failed to apply config / scaffold team")}catch(a){am(a instanceof Error?a.message:String(a),"error")}let f="string"==typeof e.addedAgentId?e.addedAgentId:"";async function b(){let b=await fetch("/api/agents",{cache:"no-store"}),c=await b.json();if(!b.ok)return{ok:!1,hasExpected:!1,agents:[]};let d=(Array.isArray(c.agents)?c.agents:[]).filter(b=>String(b.id??"").startsWith(`${a}-`)).map(a=>({id:String(a.id??""),identityName:"string"==typeof a.identityName?a.identityName:void 0})),e=!!f&&d.some(a=>a.id===f);return{ok:!0,hasExpected:e,agents:d}}async function c(a){let c=Date.now();for(;Date.now()-c<a;){try{let a=await b();if(a.ok&&(bo(a.agents),!f||a.hasExpected))return!0}catch{}await new Promise(a=>setTimeout(a,500))}return!1}if(!await c(5e3)&&f){try{fetch("/api/gateway/restart",{method:"POST"})}catch{}await c(1e4)}am(`Updated agents list in ${L}`,"success")}catch(a){am(a instanceof Error?a.message:String(a),"error")}finally{Y(!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:"Add agent"})}),(0,b.jsxs)("div",{className:"mt-6",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Detected installed team agents (read-only)"}),(0,b.jsx)("ul",{className:"mt-2 space-y-2",children:bn.length?bn.map(c=>(0,b.jsxs)("li",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)("div",{className:"truncate text-sm font-medium text-[color:var(--ck-text-primary)]",children:c.identityName||c.id}),(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:c.id})]}),(0,b.jsx)("a",{className:"text-sm font-medium text-[color:var(--ck-accent-red)] hover:text-[color:var(--ck-accent-red-hover)]",href:`/agents/${encodeURIComponent(c.id)}?returnTo=${encodeURIComponent(`/teams/${a}?tab=agents`)}`,children:"Edit"})]},c.id)):bp?(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No team agents detected."})})]})]}):null,"skills"===T?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Skills"}),(0,b.jsxs)("p",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:["Skills installed in this ",(0,b.jsx)("strong",{children:"team"})," workspace (",(0,b.jsx)("code",{children:"skills/"}),"). These are available to all agents in the team. For agent-specific skills, open the agent from the Agents tab."]}),(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Installed"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5 text-sm text-[color:var(--ck-text-secondary)]",children:bE.length?bE.map(a=>(0,b.jsx)("li",{children:a},a)):(0,b.jsx)("li",{children:"None installed."})})]}),(0,b.jsxs)("div",{className:"mt-5 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15 p-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Add a skill"}),(0,b.jsxs)("div",{className:"mt-2 flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,b.jsx)("select",{value:bK,onChange:a=>bL(a.target.value),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)]",disabled:bM||bI||!bG.length,children:bG.length?bG.map(a=>(0,b.jsx)("option",{value:a,children:a},a)):(0,b.jsx)("option",{value:"",children:"No skills found"})}),(0,b.jsx)("button",{type:"button",disabled:bM||bI||!bK,onClick:async()=>{bN(!0),bP(""),bR("");try{let b=await fetch("/api/teams/skills/install",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,skill:bK})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to install skill");bP(`Installed skill: ${bK}`);let d=await fetch(`/api/teams/skills?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),e=await d.json();d.ok&&e.ok&&bF(Array.isArray(e.skills)?e.skills:[])}catch(a){bR(a instanceof Error?a.message:String(a))}finally{bN(!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:bM?"Adding…":"Add"})]}),bQ?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:bQ}):null,bO?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 p-3 text-sm text-emerald-100",children:bO}):null,(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["This uses ",(0,b.jsxs)("code",{children:["openclaw recipes install-skill <skill> --team-id ",a," --yes"]}),"."]})]})]}):null,"cron"===T?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Cron jobs (filtered by team name)"}),(0,b.jsx)("ul",{className:"mt-3 space-y-3",children:az.length?az.map(a=>{let c=String(a.id??a.jobId??"").trim(),d=c||String(a.name??"job"),e=String(a.name??a.id??a.jobId??"(unnamed)"),f=a.enabled??a.state?.enabled;async function g(a){Y(!0);try{let b=await fetch("/api/cron/job",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({id:c,action:a})}),d=await b.json();if(!b.ok||!d.ok)throw Error(d.error||"Cron action failed");am(`Cron ${a}: ${e}`,"success")}catch(a){am(a instanceof Error?a.message:String(a),"error")}finally{Y(!1)}}return(0,b.jsxs)("li",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3",children:[(0,b.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:e}),(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Enabled: ",String(f??"?")]}),(0,b.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,b.jsx)("button",{disabled:X||!c,onClick:()=>g("run"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Run"}),(0,b.jsx)("button",{disabled:X||!c,onClick:()=>g("enable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Enable"}),(0,b.jsx)("button",{disabled:X||!c,onClick:()=>g("disable"),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2.5 py-1.5 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"Disable"}),c?null:(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"(missing id)"})]})]},d)}):aB?(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No cron jobs detected for this team."})})]}):null,"workflows"===T?(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3",children:[(0,b.jsxs)("div",{className:a5?"ck-glass-strong p-4":"ck-glass-strong p-4 lg:col-span-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Workflows (file-first)"}),(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Stored in ",(0,b.jsx)("code",{children:"shared-context/workflows/<id>.workflow.json"})," inside the team workspace."]}),aH?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:aH}):null,(0,b.jsxs)("div",{className:"mt-3 flex flex-wrap gap-2",children:[(0,b.jsx)("button",{disabled:aN,onClick:()=>{ba("new-workflow"),bc("New workflow"),a8(!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:"Add workflow"}),0===aD.length?(0,b.jsx)("button",{disabled:aN,onClick:async()=>{aO(!0),aI("");try{let b={schema:"clawkitchen.workflow.v1",id:"marketing-cadence",name:"Marketing Cadence (v1)",version:1,timezone:"America/New_York",triggers:[{kind:"cron",id:"content-cadence",name:"Content cadence",enabled:!0,expr:"0 9 * * 1,3,5",tz:"America/New_York"},{kind:"cron",id:"seasonal-scan",name:"Seasonal scan",enabled:!0,expr:"0 8 * * *",tz:"America/New_York"},{kind:"cron",id:"weekly-recap",name:"Weekly recap",enabled:!1,expr:"30 9 * * 1",tz:"America/New_York"}],nodes:[{id:"start",type:"start",name:"Start",x:80,y:80},{id:"research",type:"llm",name:"Research",x:320,y:80},{id:"draft_assets",type:"llm",name:"Draft assets",x:560,y:80},{id:"qc_brand",type:"llm",name:"QC brand",x:800,y:80},{id:"approval",type:"human_approval",name:"Approval",x:1040,y:80},{id:"post_x",type:"tool",name:"Post: X",x:1040,y:240},{id:"post_instagram",type:"tool",name:"Post: Instagram",x:1040,y:360},{id:"post_tiktok",type:"tool",name:"Post: TikTok",x:1040,y:480},{id:"post_youtube",type:"tool",name:"Post: YouTube",x:1040,y:600},{id:"writeback",type:"tool",name:"Writeback",x:800,y:600},{id:"end",type:"end",name:"End",x:560,y:600}],edges:[{id:"e1",from:"start",to:"research"},{id:"e2",from:"research",to:"draft_assets"},{id:"e3",from:"draft_assets",to:"qc_brand"},{id:"e4",from:"qc_brand",to:"approval"},{id:"e5",from:"approval",to:"post_x",label:"approve"},{id:"e6",from:"post_x",to:"post_instagram"},{id:"e7",from:"post_instagram",to:"post_tiktok"},{id:"e8",from:"post_tiktok",to:"post_youtube"},{id:"e9",from:"post_youtube",to:"writeback"},{id:"e10",from:"writeback",to:"end"}],meta:{templateId:"marketing-cadence-v1",approvalGateRequired:!0}},c=await fetch("/api/teams/workflows",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflow:b})}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to write workflow");let e=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),f=await e.json();if(e.ok&&f.ok){let a=(Array.isArray(f.files)?f.files:[]).map(a=>String(a??"").trim()).filter(a=>!!a);aE(a),aK("marketing-cadence.workflow.json"),aM(JSON.stringify(b,null,2)+"\n"),a6(!0)}am("Created workflow template: marketing-cadence","success")}catch(a){aI(a instanceof Error?a.message:String(a))}finally{aO(!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:aN?"Working…":"Create Marketing Cadence template"}):null,(0,b.jsx)("button",{disabled:aN,onClick:async()=>{aO(!0),aI("");try{let b=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to list workflows");let d=(Array.isArray(c.files)?c.files:[]).map(a=>String(a??"").trim()).filter(a=>!!a);aE(d),am("Refreshed workflow list","success")}catch(a){aI(a instanceof Error?a.message:String(a))}finally{aO(!1)}},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:"Refresh"})]}),a7?(0,b.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/70 p-4",children:(0,b.jsxs)("div",{className:"ck-glass-strong w-full max-w-lg rounded-[var(--ck-radius-lg)] border border-white/10 p-4 shadow-[var(--ck-shadow-2)]",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Create workflow"}),(0,b.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-tertiary)]",children:"Creates a new file under shared-context/workflows/ for this team."}),(0,b.jsxs)("div",{className:"mt-4 grid grid-cols-1 gap-3",children:[(0,b.jsxs)("label",{className:"grid gap-1",children:[(0,b.jsx)("span",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Workflow id"}),(0,b.jsx)("input",{value:a9,onChange:a=>ba(a.target.value),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",placeholder:"e.g. marketing-cadence"}),(0,b.jsx)("span",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"lowercase letters, numbers, dashes"})]}),(0,b.jsxs)("label",{className:"grid gap-1",children:[(0,b.jsx)("span",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Name"}),(0,b.jsx)("input",{value:bb,onChange:a=>bc(a.target.value),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 px-3 py-2 text-sm text-[color:var(--ck-text-primary)]",placeholder:"New workflow"})]})]}),(0,b.jsxs)("div",{className:"mt-4 flex flex-wrap justify-end gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:()=>a8(!1),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,b.jsx)("button",{type:"button",onClick:()=>{let a=String(a9||"").trim();if(!a)return void am("Workflow id is required","error");let b={schema:"clawkitchen.workflow.v1",id:a,name:String(bb||a),version:1,timezone:"America/New_York",triggers:[],nodes:[{id:"start",type:"start",name:"Start",x:120,y:120},{id:"end",type:"end",name:"End",x:420,y:120}],edges:[{id:"e1",from:"start",to:"end"}],meta:{}};aK(`${a}.workflow.json`),aM(JSON.stringify(b,null,2)+"\n"),a8(!1),a6(!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)]",children:"Create"})]})]})}):null,(0,b.jsx)("div",{className:"mt-4 text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Files"}),(0,b.jsxs)("ul",{className:"mt-2 space-y-1",children:[aF?(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,aD.length?aD.map(c=>{let d=aJ===c;return(0,b.jsxs)("li",{className:"flex items-center justify-between gap-3 rounded-[var(--ck-radius-sm)] px-2 py-1 hover:bg-white/5",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>aK(c),className:"flex min-w-0 items-center gap-2 text-left",children:[(0,b.jsx)("span",{className:d?"text-green-400":"text-white/25",children:d?"✓":"•"}),(0,b.jsx)("span",{className:d?"truncate text-base font-medium text-[color:var(--ck-text-primary)]":"truncate text-base text-[color:var(--ck-text-secondary)]",children:c})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("button",{type:"button",disabled:aN,onClick:async()=>{aK(c),aO(!0),aI("");try{let b=String(c).replace(/\.workflow\.json$/i,""),d=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{cache:"no-store"}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to load workflow");aM(JSON.stringify(e.workflow,null,2)+"\n"),a6(!0)}catch(a){aI(a instanceof Error?a.message:String(a))}finally{aO(!1)}},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:"Edit"}),(0,b.jsx)("button",{type:"button",disabled:aN,onClick:async()=>{if(confirm(`Delete workflow ${c}?`)){aO(!0),aI("");try{let b=String(c).replace(/\.workflow\.json$/i,""),d=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}&id=${encodeURIComponent(b)}`,{method:"DELETE"}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to delete workflow");let f=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),g=await f.json();if(f.ok&&g.ok){let a=(Array.isArray(g.files)?g.files:[]).map(a=>String(a??"").trim()).filter(a=>!!a);aE(a)}aJ===c&&(aK(""),aM("")),am(`Deleted workflow: ${c}`,"success")}catch(a){aI(a instanceof Error?a.message:String(a))}finally{aO(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 px-3 py-2 text-sm font-medium text-red-100 shadow-[var(--ck-shadow-1)] hover:bg-red-500/20 disabled:opacity-50",children:"Delete"})]})]},c)}):aF?null:(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"No workflows yet."})]})]}),a5?(0,b.jsx)("div",{className:"fixed inset-0 z-50 bg-black/70",children:(0,b.jsxs)("div",{className:"ck-glass-strong h-full w-full overflow-hidden border border-white/10 shadow-[var(--ck-shadow-2)]",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 bg-black/20 p-3",children:[(0,b.jsxs)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:["Workflow editor",aJ?` — ${aJ}`:""]}),(0,b.jsx)("button",{type:"button",onClick:()=>a6(!1),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-xs font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Close"})]}),(0,b.jsx)("div",{className:"h-[calc(100%-3rem)] overflow-auto p-4",children:(0,b.jsxs)("div",{className:"ck-glass-strong p-4 lg:col-span-2",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Workflow editor"}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsxs)("div",{className:"flex overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10",children:[(0,b.jsx)("button",{type:"button",onClick:()=>aQ("canvas"),className:"canvas"===aP?"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,b.jsx)("button",{type:"button",onClick:()=>aQ("json"),className:"json"===aP?"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,b.jsx)("input",{ref:bs,type:"file",accept:"application/json,.json",className:"hidden",onChange:async a=>{let b=a.target.files?.[0];if(a.target.value="",b){aI("");try{let a=await b.text(),c=JSON.parse(a);aM(JSON.stringify(c,null,2)+"\n"),aK(""),am(`Imported workflow JSON: ${c.id||b.name}`,"success")}catch(a){aI(a instanceof Error?a.message:String(a))}}}}),(0,b.jsx)("button",{type:"button",disabled:aN,onClick:()=>bs.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,b.jsx)("button",{type:"button",disabled:aN||!bt||!!bu||bv.errors.length>0,onClick:()=>{aI("");try{if(!bt)throw Error("No workflow loaded");if(bu)throw Error(`Invalid JSON: ${bu}`);if(bv.errors.length)throw Error("Fix workflow validation errors before exporting");let a=`${bt.id||"workflow"}.workflow.json`,b=new Blob([JSON.stringify(bt,null,2)+"\n"],{type:"application/json"}),c=URL.createObjectURL(b),d=document.createElement("a");d.href=c,d.download=a,document.body.appendChild(d),d.click(),d.remove(),URL.revokeObjectURL(c),am(`Exported: ${a}`,"success")}catch(a){aI(a instanceof Error?a.message:String(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)] hover:bg-white/10 disabled:opacity-50",children:"Export"}),(0,b.jsx)("button",{disabled:aN||!bt||!!bu||bv.errors.length>0,onClick:async()=>{aO(!0),aI("");try{if(!bt)throw Error("No workflow loaded");if(bu)throw Error(`Invalid JSON: ${bu}`);if(bv.errors.length)throw Error("Fix workflow validation errors before saving");let b=await fetch("/api/teams/workflows",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflow:bt})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to save workflow");am(`Saved workflow: ${bt.id}`,"success");let d=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),e=await d.json();if(d.ok&&e.ok){let a=(Array.isArray(e.files)?e.files:[]).map(a=>String(a??"").trim()).filter(a=>!!a);aE(a),aK(`${bt.id}.workflow.json`)}}catch(a){aI(a instanceof Error?a.message:String(a))}finally{aO(!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:aN?"Saving…":"Save"})]})]}),bu?(0,b.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: ",bu]}):null,!bu&&bv.errors.length?(0,b.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,b.jsx)("div",{className:"font-medium",children:"Workflow validation errors"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:bv.errors.map(a=>(0,b.jsx)("li",{children:a},a))})]}):null,bu||bv.errors.length||!bv.warnings.length?null:(0,b.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,b.jsx)("div",{className:"font-medium",children:"Workflow validation warnings"}),(0,b.jsx)("ul",{className:"mt-2 list-disc space-y-1 pl-5",children:bv.warnings.map(a=>(0,b.jsx)("li",{children:a},a))})]}),"canvas"===aP?(0,b.jsxs)("div",{className:"mt-3 grid grid-cols-1 gap-3 lg:grid-cols-4",children:[(0,b.jsxs)("div",{className:"lg:col-span-3",children:[(0,b.jsx)("div",{ref:br,className:"relative h-[calc(100vh-20rem)] min-h-[55vh] w-full overflow-auto rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20",children:(0,b.jsxs)("div",{className:"relative h-[900px] w-[1400px]",children:[(0,b.jsx)("svg",{className:"absolute inset-0",width:1400,height:900,children:(bt?.edges??[]).map(a=>{if(!bt)return null;let c=bt.nodes.find(b=>b.id===a.from),d=bt.nodes.find(b=>b.id===a.to);if(!c||!d)return null;let e=("number"==typeof c.x?c.x:80)+90,f=("number"==typeof c.y?c.y:80)+24,g=("number"==typeof d.x?d.x:80)+90,h=("number"==typeof d.y?d.y:80)+24;return(0,b.jsxs)("g",{children:[(0,b.jsx)("line",{x1:e,y1:f,x2:g,y2:h,stroke:"rgba(255,255,255,0.18)",strokeWidth:2}),a.label?(0,b.jsx)("text",{x:(e+g)/2,y:(f+h)/2-6,fill:"rgba(255,255,255,0.55)",fontSize:10,textAnchor:"middle",children:a.label}):null]},a.id)})}),(bt?.nodes??[]).map((a,c)=>{let d="number"==typeof a.x?a.x:80+220*c,e="number"==typeof a.y?a.y:80,f=aR===a.id;return(0,b.jsxs)("div",{role:"button",tabIndex:0,onClick:()=>aS(a.id),onPointerDown:b=>{if(0!==b.button)return;let c=br.current;if(!c)return;let f=c.getBoundingClientRect(),g=b.clientX-f.left-d,h=b.clientY-f.top-e;aS(a.id),aU({nodeId:a.id,dx:g,dy:h,containerLeft:f.left,containerTop:f.top})},className:f?"absolute 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 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:d,top:e,width:180},children:[(0,b.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:a.name||a.id}),(0,b.jsx)("div",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:a.type})]},a.id)})]})}),(0,b.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Tip: click a node to inspect it; drag to reposition. Positions are stored in the workflow JSON (file-first)."})]}),(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 lg:col-span-1",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Workflow"}),bt?(l=String(bt.timezone??"").trim()||"UTC",m=bt.triggers??[],o=String((n=bt.meta&&"object"==typeof bt.meta&&!Array.isArray(bt.meta)?bt.meta:{}).approvalProvider??"telegram").trim()||"telegram",p=String(n.approvalTarget??"").trim(),q=[{label:"(no preset)",expr:""},{label:"Mon/Wed/Fri 09:00 local",expr:"0 9 * * 1,3,5"},{label:"Daily 08:00 local",expr:"0 8 * * *"},{label:"Mon 09:30 local",expr:"30 9 * * 1"}],(0,b.jsxs)("div",{className:"mt-2 space-y-4",children:[(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"timezone"}),(0,b.jsx)("input",{value:l,onChange:a=>{let b=String(a.target.value||"").trim()||"UTC";aM(JSON.stringify({...bt,timezone:b},null,2)+"\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)]",placeholder:"America/New_York"})]}),(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"approval channel (mvp)"}),(0,b.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"provider"}),(0,b.jsx)("input",{value:o,onChange:a=>{let b=String(a.target.value||"").trim()||"telegram",c={...n,approvalProvider:b};aM(JSON.stringify({...bt,meta:c},null,2)+"\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)]",placeholder:"telegram"})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"target"}),(0,b.jsx)("input",{value:p,onChange:a=>{let b=String(a.target.value||"").trim(),c={...n,approvalTarget:b};aM(JSON.stringify({...bt,meta:c},null,2)+"\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)]",placeholder:"(e.g. Telegram chat id)"}),(0,b.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"If set, sample runs that reach a human-approval node will send an approval packet via the gateway message tool."})]})]})]}),(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"triggers"}),(0,b.jsx)("button",{type:"button",onClick:()=>{let a=`t${Date.now()}`;aM(JSON.stringify({...bt,triggers:[...m,{kind:"cron",id:a,name:"New trigger",enabled:!0,expr:"0 9 * * 1-5",tz:l}]},null,2)+"\n")},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,b.jsx)("div",{className:"mt-2 space-y-2",children:m.length?m.map((a,c)=>{let d=a.kind,e=String(a.id??""),f=String(a.name??""),g=!!a.enabled,h=String(a.expr??""),i=String(a.tz??l),j=h.trim().split(/\s+/).filter(Boolean),k=!h.trim()||5===j.length;return(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:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-primary)]",children:f||e||`trigger-${c+1}`}),(0,b.jsx)("button",{type:"button",onClick:()=>{aM(JSON.stringify({...bt,triggers:m.filter((a,b)=>b!==c)},null,2)+"\n")},className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Remove"})]}),"cron"===d?null:(0,b.jsxs)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:["Unsupported trigger kind: ",String(d)]}),(0,b.jsxs)("div",{className:"mt-2 grid grid-cols-1 gap-2",children:[(0,b.jsxs)("label",{className:"flex items-center gap-2 text-xs text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("input",{type:"checkbox",checked:g,onChange:a=>{let b=a.target.checked;aM(JSON.stringify({...bt,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,enabled:b}:a)},null,2)+"\n")}}),"Enabled"]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name"}),(0,b.jsx)("input",{value:f,onChange:a=>{let b=a.target.value;aM(JSON.stringify({...bt,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,name:b}:a)},null,2)+"\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)]",placeholder:"Content cadence"})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"schedule (cron)"}),(0,b.jsx)("input",{value:h,onChange:a=>{let b=a.target.value;aM(JSON.stringify({...bt,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,expr:b}:a)},null,2)+"\n")},className:k?"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"}),k?null:(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-red-200",children:["Cron should be 5 fields (min hour dom month dow). You entered ",j.length,"."]}),(0,b.jsxs)("div",{className:"mt-1 grid grid-cols-1 gap-1",children:[(0,b.jsx)("select",{value:q.some(a=>a.expr===h)?h:"",onChange:a=>{let b=a.target.value;b&&aM(JSON.stringify({...bt,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,expr:b}:a)},null,2)+"\n")},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:q.map(a=>(0,b.jsx)("option",{value:a.expr,children:a.label},a.label))}),(0,b.jsx)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Presets set the cron; edit freely for advanced schedules."})]})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"timezone override"}),(0,b.jsx)("input",{value:i,onChange:a=>{let b=String(a.target.value||"").trim()||l;aM(JSON.stringify({...bt,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,tz:b}:a)},null,2)+"\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)]",placeholder:l})]})]})]},`${e}-${c}`)}):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No triggers yet."})})]}),(0,b.jsxs)("div",{className:"border-t border-white/10 pt-3",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Runs (history)"}),(0,b.jsx)("div",{className:"flex items-center gap-2",children:(0,b.jsx)("button",{type:"button",disabled:aN,onClick:async()=>{let b=String(bt.id??"").trim();if(b){bi("");try{let c=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:b,mode:"sample"})}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to create sample run");let e=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(a)}&workflowId=${encodeURIComponent(b)}`,{cache:"no-store"}),f=await e.json();if(!e.ok||!f.ok)throw Error(f.error||"Failed to refresh runs");let g=(Array.isArray(f.files)?f.files:[]).map(a=>String(a??"").trim()).filter(a=>!!a);be(g),am("Created sample run","success")}catch(a){bi(a instanceof Error?a.message:String(a))}}},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:"+ Sample run"})})]}),bh?(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:bh}):null,(0,b.jsx)("div",{className:"mt-2 space-y-1",children:bf?(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Loading runs…"}):bd.length?bd.slice(0,8).map(c=>{let d=String(c).replace(/\.run\.json$/i,""),e=bj===d;return(0,b.jsx)("button",{type:"button",onClick:async()=>{let b=String(bt.id??"").trim();if(b){bk(d),bm(null),bi("");try{let c=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(a)}&workflowId=${encodeURIComponent(b)}&runId=${encodeURIComponent(d)}`,{cache:"no-store"}),e=await c.json();if(!c.ok||!e.ok)throw Error(e.error||"Failed to load run");bm(e.run)}catch(a){bi(a instanceof Error?a.message:String(a))}}},className:e?"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:d},c)}):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No runs yet."})}),bl?(t=Array.isArray(s=(r=bl&&"object"==typeof bl?bl:{}).nodes)?s:[],(0,b.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-[11px] font-medium text-[color:var(--ck-text-primary)]",children:"Run detail"}),(0,b.jsxs)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:String(r?.status??"")}),r?.startedAt?(0,b.jsxs)("span",{children:[" · ",String(r.startedAt)]}):null]})]}),r?.summary?(0,b.jsx)("div",{className:"mt-1 text-[11px] text-[color:var(--ck-text-secondary)]",children:String(r.summary)}):null,(u=String(r?.status??""),x=String((w=(v=r.approval)&&"object"==typeof v?v:{}).state??""),y=String(w.nodeId??""),"waiting_for_approval"===u&&"pending"===x&&y?(0,b.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-amber-300/30 bg-amber-500/10 p-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-amber-100",children:"approval required"}),(0,b.jsxs)("div",{className:"mt-1 text-[11px] text-amber-50",children:["Waiting on ",(0,b.jsx)("span",{className:"font-mono",children:y})]}),(0,b.jsxs)("div",{className:"mt-2 flex flex-wrap gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:async()=>{let b=String(bt.id??"").trim(),c=String(r.id??"").trim();if(b&&c){bi("");try{let d=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:b,runId:c,action:"approve"})}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to approve");let f=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(a)}&workflowId=${encodeURIComponent(b)}&runId=${encodeURIComponent(c)}`,{cache:"no-store"}),g=await f.json();if(!f.ok||!g.ok)throw Error(g.error||"Failed to reload run");bm(g.run),am("Approved","success")}catch(a){bi(a instanceof Error?a.message:String(a))}}},className:"rounded-[var(--ck-radius-sm)] border border-emerald-300/30 bg-emerald-500/10 px-2 py-1 text-[10px] font-medium text-emerald-50 hover:bg-emerald-500/20",children:"Approve & continue"}),(0,b.jsx)("button",{type:"button",onClick:async()=>{let b=String(bt.id??"").trim(),c=String(r.id??"").trim();if(b&&c){bi("");try{let d=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:b,runId:c,action:"request_changes"})}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to request changes");let f=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(a)}&workflowId=${encodeURIComponent(b)}&runId=${encodeURIComponent(c)}`,{cache:"no-store"}),g=await f.json();if(!f.ok||!g.ok)throw Error(g.error||"Failed to reload run");bm(g.run),am("Requested changes","success")}catch(a){bi(a instanceof Error?a.message:String(a))}}},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:"Request changes"}),(0,b.jsx)("button",{type:"button",onClick:async()=>{let b=String(bt.id??"").trim(),c=String(r.id??"").trim();if(b&&c){bi("");try{let d=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:b,runId:c,action:"cancel"})}),e=await d.json();if(!d.ok||!e.ok)throw Error(e.error||"Failed to cancel");let f=await fetch(`/api/teams/workflow-runs?teamId=${encodeURIComponent(a)}&workflowId=${encodeURIComponent(b)}&runId=${encodeURIComponent(c)}`,{cache:"no-store"}),g=await f.json();if(!f.ok||!g.ok)throw Error(g.error||"Failed to reload run");bm(g.run),am("Canceled","success")}catch(a){bi(a instanceof Error?a.message:String(a))}}},className:"rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 px-2 py-1 text-[10px] font-medium text-red-50 hover:bg-red-500/20",children:"Cancel"})]}),(0,b.jsx)("div",{className:"mt-2 text-[10px] text-amber-100/80",children:"Note: this is currently an in-app approval stub; channel delivery/resume wiring still TBD."})]}):null),(0,b.jsxs)("div",{className:"mt-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"per-node results"}),t.length?(0,b.jsx)("div",{className:"mt-1 space-y-1",children:t.slice(0,50).map((a,c)=>{let d=a&&"object"==typeof a?a:{},e=String(d.status??""),f="success"===e?"text-emerald-200":"error"===e?"text-red-200":"running"===e||"waiting"===e?"text-amber-200":"text-[color:var(--ck-text-secondary)]",g=String(d.nodeId??""),h=d.error,i=d.output;return(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 p-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-[11px] text-[color:var(--ck-text-primary)]",children:(0,b.jsx)("span",{className:"font-mono",children:g})}),(0,b.jsx)("div",{className:`text-[10px] font-medium ${f}`,children:e})]}),h?(0,b.jsx)("div",{className:"mt-1 text-[10px] text-red-100",children:"string"==typeof h?h:"object"==typeof h&&h&&"message"in h?String(h.message??""):String(h)}):null,void 0!==i?(0,b.jsx)("pre",{className:"mt-1 max-h-[120px] 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(i,null,2)}):null]},`${g||"node"}-${c}`)})}):(0,b.jsx)("div",{className:"mt-1 text-xs text-[color:var(--ck-text-secondary)]",children:"No node results recorded on this run yet."})]}),(0,b.jsxs)("details",{className:"mt-2",children:[(0,b.jsx)("summary",{className:"cursor-pointer select-none text-[10px] text-[color:var(--ck-text-tertiary)]",children:"raw JSON"}),(0,b.jsx)("pre",{className:"mt-2 max-h-[220px] 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(bl,null,2)})]})]})):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:"Nodes"}),(0,b.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,b.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"id"}),(0,b.jsx)("input",{value:aV,onChange:a=>aW(a.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,b.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Tip: ids are file-first + portable; use lowercase letters, numbers, and underscores."})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name (optional)"}),(0,b.jsx)("input",{value:aX,onChange:a=>aY(a.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,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,b.jsxs)("select",{value:aZ,onChange:a=>a$(a.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,b.jsx)("option",{value:"start",children:"start"}),(0,b.jsx)("option",{value:"end",children:"end"}),(0,b.jsx)("option",{value:"llm",children:"llm"}),(0,b.jsx)("option",{value:"tool",children:"tool"}),(0,b.jsx)("option",{value:"condition",children:"condition"}),(0,b.jsx)("option",{value:"delay",children:"delay"}),(0,b.jsx)("option",{value:"human_approval",children:"human_approval"})]})]}),(0,b.jsx)("button",{type:"button",onClick:()=>{let a=String(aV||"").trim().replace(/[^a-z0-9_\-]/gi,"_");if(!a)return void am("Node id is required","error");if(bt.nodes.some(b=>b.id===a))return void am(`Node id already exists: ${a}`,"error");let b=bt.nodes.reduce((a,b)=>"number"==typeof b.x?Math.max(a,b.x):a,80),c={id:a,type:aZ,name:String(aX||"").trim()||a,x:b+220,y:80};aM(JSON.stringify({...bt,nodes:[...bt.nodes,c]},null,2)+"\n"),aS(a),aW(""),aY("")},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,b.jsx)("div",{className:"mt-2 space-y-1",children:bt.nodes.map(a=>{let c=aR===a.id;return(0,b.jsxs)("button",{type:"button",onClick:()=>aS(a.id),className:c?"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.id}),(0,b.jsx)("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:a.type})]},a.id)})})]}),(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:"Edges"}),(0,b.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,b.jsxs)("div",{className:"grid grid-cols-1 gap-2",children:[(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"from"}),(0,b.jsxs)("select",{value:a_,onChange:a=>a0(a.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,b.jsx)("option",{value:"",children:"(select)"}),bt.nodes.map(a=>(0,b.jsx)("option",{value:a.id,children:a.id},a.id))]})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"to"}),(0,b.jsxs)("select",{value:a1,onChange:a=>a2(a.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,b.jsx)("option",{value:"",children:"(select)"}),bt.nodes.map(a=>(0,b.jsx)("option",{value:a.id,children:a.id},a.id))]})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"label (optional)"}),(0,b.jsx)("input",{value:a3,onChange:a=>a4(a.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,b.jsx)("button",{type:"button",onClick:()=>{let a=String(a_||"").trim(),b=String(a1||"").trim();if(!a||!b)return void am("Edge requires from + to","error");if(a===b)return void am("Edge from/to must be different","error");let c={id:`e${Date.now()}`,from:a,to:b,...String(a3||"").trim()?{label:String(a3).trim()}:{}};aM(JSON.stringify({...bt,edges:[...bt.edges??[],c]},null,2)+"\n"),a4("")},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,b.jsx)("div",{className:"mt-2 space-y-2",children:(bt.edges??[]).length?(bt.edges??[]).map(a=>(0,b.jsx)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2",children:(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsxs)("div",{className:"text-[11px] text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("span",{className:"font-mono",children:a.from})," → ",(0,b.jsx)("span",{className:"font-mono",children:a.to}),a.label?(0,b.jsxs)("span",{className:"ml-2 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["(",a.label,")"]}):null]}),(0,b.jsx)("button",{type:"button",onClick:()=>{aM(JSON.stringify({...bt,edges:(bt.edges??[]).filter(b=>b.id!==a.id)},null,2)+"\n")},className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Remove"})]})},a.id)):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No edges yet."})})]}),(0,b.jsxs)("div",{className:"border-t border-white/10 pt-3",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Node inspector"}),aR?(0,b.jsx)("button",{type:"button",onClick:()=>{let a=bt.nodes.filter(a=>a.id!==aR),b=(bt.edges??[]).filter(a=>a.from!==aR&&a.to!==aR);aM(JSON.stringify({...bt,nodes:a,edges:b},null,2)+"\n"),aS("")},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]}),aR?(z=bt.nodes.find(a=>a.id===aR))?(0,b.jsxs)("div",{className:"mt-3 space-y-3",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"id"}),(0,b.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:z.id})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"name"}),(0,b.jsx)("input",{value:String(z.name??""),onChange:a=>{let b=a.target.value;aM(JSON.stringify({...bt,nodes:bt.nodes.map(a=>a.id===z.id?{...a,name:b}:a)},null,2)+"\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)]",placeholder:"Optional"})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"type"}),(0,b.jsxs)("select",{value:z.type,onChange:a=>{let b=a.target.value;aM(JSON.stringify({...bt,nodes:bt.nodes.map(a=>a.id===z.id?{...a,type:b}:a)},null,2)+"\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)]",children:[(0,b.jsx)("option",{value:"start",children:"start"}),(0,b.jsx)("option",{value:"end",children:"end"}),(0,b.jsx)("option",{value:"llm",children:"llm"}),(0,b.jsx)("option",{value:"tool",children:"tool"}),(0,b.jsx)("option",{value:"condition",children:"condition"}),(0,b.jsx)("option",{value:"delay",children:"delay"}),(0,b.jsx)("option",{value:"human_approval",children:"human_approval"})]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"x"}),(0,b.jsx)("input",{type:"number",value:"number"==typeof z.x?z.x:0,onChange:a=>{let b=Number(a.target.value);aM(JSON.stringify({...bt,nodes:bt.nodes.map(a=>a.id===z.id?{...a,x:b}:a)},null,2)+"\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)]"})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"y"}),(0,b.jsx)("input",{type:"number",value:"number"==typeof z.y?z.y:0,onChange:a=>{let b=Number(a.target.value);aM(JSON.stringify({...bt,nodes:bt.nodes.map(a=>a.id===z.id?{...a,y:b}:a)},null,2)+"\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)]"})]})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"config"}),(0,b.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(z.config??{},null,2)})]})]}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"No node selected."}):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"Select a node."})]})]})):(0,b.jsx)("div",{className:"mt-2 text-sm text-[color:var(--ck-text-secondary)]",children:"Load or create a workflow to edit triggers."})]})]}):(0,b.jsx)("textarea",{value:aL,onChange:a=>aM(a.target.value),className:"mt-3 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1,placeholder:"Select a workflow from the left (or create the template)."})]})})]})}):null]}):null,"files"===T?(0,b.jsxs)("div",{className:"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-3",children:[(0,b.jsxs)("div",{className:"ck-glass-strong p-4",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Team files"}),(0,b.jsxs)("label",{className:"flex items-center gap-2 text-xs text-[color:var(--ck-text-secondary)]",children:[(0,b.jsx)("input",{type:"checkbox",checked:at,onChange:a=>au(a.target.checked)}),"Show optional"]})]}),(0,b.jsx)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"Default view hides optional missing files to reduce noise."}),(0,b.jsxs)("ul",{className:"mt-3 space-y-1",children:[ap?(0,b.jsx)("li",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:"Loading…"}):null,an.filter(a=>!!at||a.required||!a.missing).map(a=>(0,b.jsx)("li",{children:(0,b.jsxs)("button",{onClick:()=>b_(a.name),className:av===a.name?"w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-3 py-2 text-left text-sm text-[color:var(--ck-text-primary)]":"w-full rounded-[var(--ck-radius-sm)] px-3 py-2 text-left text-sm text-[color:var(--ck-text-secondary)] hover:bg-white/5",children:[(0,b.jsx)("span",{className:a.required?"text-[color:var(--ck-text-primary)]":"text-[color:var(--ck-text-secondary)]",children:a.name}),(0,b.jsx)("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:a.required?"required":"optional"}),a.missing?(0,b.jsx)("span",{className:"ml-2 text-xs text-[color:var(--ck-text-tertiary)]",children:"missing"}):null]})},a.name))]})]}),(0,b.jsxs)("div",{className:"ck-glass-strong p-4 lg:col-span-2",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsxs)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:["Edit: ",av]}),(0,b.jsx)("button",{disabled:X,onClick:b0,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:X?"Saving…":"Save file"})]}),ar?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:ar}):null,(0,b.jsx)("textarea",{value:ax,onChange:a=>ay(a.target.value),className:"mt-3 h-[55vh] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]",spellCheck:!1})]})]}):null,"orchestrator"===T?(0,b.jsx)(j,{teamId:a}):null,"recipe"===T?(0,b.jsxs)("div",{className:"mt-6 ck-glass-strong p-4",children:[(0,b.jsx)("div",{className:"text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Recipe markdown"}),ad?(0,b.jsx)("div",{className:"mt-3 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-3 text-sm text-red-100",children:ad}):null,(0,b.jsx)("textarea",{value:P,onChange:a=>{Q(a.target.value),S(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})]}):null,(0,b.jsx)(h,{open:ai,teamId:a,recipeId:L,busy:Z,onClose:()=>aj(!1),onConfirm:async()=>{$(!0);try{let b=await fetch("/api/scaffold",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({kind:"team",recipeId:L.trim(),teamId:a,overwrite:!0,applyConfig:!0})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Publish failed");try{let b=await fetch(`/api/teams/meta?teamId=${encodeURIComponent(a)}`,{cache:"no-store"}),c=await b.json();b.ok&&c.ok&&c.meta&&"string"==typeof c.meta.recipeHash&&al(c.meta.recipeHash)}catch{}aj(!1),am("Published changes to active team","success")}catch(a){am(a instanceof Error?a.message:String(a),"error")}finally{$(!1)}}}),(0,b.jsx)(g,{open:ag,teamId:a,busy:_,onClose:()=>ah(!1),onConfirm:async()=>{aa(!0);try{let b=await fetch("/api/teams/remove-team",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Delete failed");am("Deleted team successfully","success"),ah(!1),setTimeout(()=>A.push("/"),250)}catch(a){am(a instanceof Error?a.message:String(a),"error")}finally{aa(!1)}}})]})}a.s(["default",()=>l],35279)}];
|
|
11
11
|
|
|
12
12
|
//# sourceMappingURL=src_app_teams_%5BteamId%5D_team-editor_tsx_2900b91d._.js.map
|