@jiggai/kitchen 0.3.12 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +2 -2
- package/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- 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 +1 -1
- package/.next/server/app/channels.html +2 -2
- package/.next/server/app/channels.rsc +2 -2
- package/.next/server/app/channels.segments/_full.segment.rsc +2 -2
- package/.next/server/app/channels.segments/_head.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_index.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/channels.segments/channels/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/channels.segments/channels.segment.rsc +1 -1
- package/.next/server/app/goals/new.html +2 -2
- package/.next/server/app/goals/new.rsc +2 -2
- package/.next/server/app/goals/new.segments/_full.segment.rsc +2 -2
- package/.next/server/app/goals/new.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_index.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals/new/__PAGE__.segment.rsc +1 -1
- 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.html +1 -1
- package/.next/server/app/goals.rsc +2 -2
- package/.next/server/app/goals.segments/_full.segment.rsc +2 -2
- package/.next/server/app/goals.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_index.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/goals.segments/goals/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/goals.segments/goals.segment.rsc +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +2 -2
- package/.next/server/app/settings.segments/_full.segment.rsc +2 -2
- package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_index.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/server/app/teams/[teamId]/workflows/[workflowId]/page_client-reference-manifest.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__01863a8b._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__01863a8b._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__04f289da._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__04f289da._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__08b4c8f2._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__08b4c8f2._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__0c4fc3d3._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__0c4fc3d3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__1311d7a3._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1311d7a3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__18423bab._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__18423bab._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__1c6c2e43._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__1c6c2e43._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__30cd38e9._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__30cd38e9._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__3cfdf0b3._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__3cfdf0b3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__3fdbc43e._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__3fdbc43e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__4079fa2b._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__4079fa2b._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__453333f5._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__453333f5._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__502825d0._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__502825d0._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__50fe6ff8._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__50fe6ff8._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__51198e25._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__51198e25._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__542a081b._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__542a081b._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__5ceff0f3._.js +3 -3
- package/.next/server/chunks/[root-of-the-server]__5ceff0f3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__63715de8._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__63715de8._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__69c45937._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__69c45937._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__6caa8f2d._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__6caa8f2d._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__6f4e90a0._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__6f4e90a0._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__7459129e._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__7459129e._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__7bf889c1._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__7bf889c1._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__89605574._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__89605574._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__99b12bcb._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__99b12bcb._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__9d0ea07b._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__9d0ea07b._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__a49c534d._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__a49c534d._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__a74a32d5._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__a74a32d5._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__b64936a3._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__b64936a3._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__bbdb6dcb._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__bbdb6dcb._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__bccfb2c0._.js +2 -2
- package/.next/server/chunks/[root-of-the-server]__bccfb2c0._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__c5e88cbb._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__c5e88cbb._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__e063a986._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__e063a986._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__e478ef0d._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__e478ef0d._.js.map +1 -1
- package/.next/server/chunks/[root-of-the-server]__f4cbadf7._.js +1 -1
- package/.next/server/chunks/[root-of-the-server]__f4cbadf7._.js.map +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__3b880807._.js +1 -1
- package/.next/server/chunks/ssr/[root-of-the-server]__3b880807._.js.map +1 -1
- package/.next/server/chunks/ssr/_7f9e89d2._.js +1 -1
- package/.next/server/chunks/ssr/_7f9e89d2._.js.map +1 -1
- package/.next/server/chunks/ssr/b1a17_app_teams_[teamId]_workflows_[workflowId]_workflows-editor-client_tsx_5e714aa2._.js +1 -1
- package/.next/server/chunks/ssr/b1a17_app_teams_[teamId]_workflows_[workflowId]_workflows-editor-client_tsx_5e714aa2._.js.map +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/.next/static/chunks/{4f5e02a609758a0b.js → d7f5083b972391f7.js} +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- /package/.next/static/{hUvZJdetkFjI4DzH44gs9 → cp-U4VbwzSh2raGh9eqcl}/_buildManifest.js +0 -0
- /package/.next/static/{hUvZJdetkFjI4DzH44gs9 → cp-U4VbwzSh2raGh9eqcl}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{hUvZJdetkFjI4DzH44gs9 → cp-U4VbwzSh2raGh9eqcl}/_ssgManifest.js +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports=[13833,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(66063);function f(a){let b=new Set;for(let c of a)b.add(c);return b.size}function g(a,b){return`ck-wf-draft:${a}:${b}`}function h({teamId:a,workflowId:h,draft:i,llmTaskEnabled:j}){let k,l,m,n,o,p,q,r,s,[t,u]=(0,c.useState)("canvas"),[v,w]=(0,c.useState)(!1),[x,y]=(0,c.useState)({kind:"loading"}),[z,A]=(0,c.useState)(""),B=(0,c.useRef)(null),[C,D]=(0,c.useState)(!1),[E,F]=(0,c.useState)(1),G=(0,c.useRef)(null),[H,I]=(0,c.useState)(""),[J,K]=(0,c.useState)(null),[L,M]=(0,c.useState)({kind:"select"}),[N,O]=(0,c.useState)(""),[P,Q]=(0,c.useState)([]),[R,S]=(0,c.useState)(""),[T,U]=(0,c.useState)([]),[V,W]=(0,c.useState)(""),X=(0,c.useMemo)(()=>/Tool not available:\s*gateway/i.test(String(V||"")),[V]),[Y,Z]=(0,c.useState)([]),[$,_]=(0,c.useState)(!1),[aa,ab]=(0,c.useState)(""),[ac,ad]=(0,c.useState)(""),[ae,af]=(0,c.useState)(!1),[ag,ah]=(0,c.useState)(""),[ai,aj]=(0,c.useState)({}),[ak,al]=(0,c.useState)(!1),[am,an]=(0,c.useState)(!1),[ao,ap]=(0,c.useState)(""),[aq,ar]=(0,c.useState)(""),[as,at]=(0,c.useState)(""),[au,av]=(0,c.useState)("llm"),[aw,ax]=(0,c.useState)(""),[ay,az]=(0,c.useState)(""),[aA,aB]=(0,c.useState)("");function aC(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}function aD(a){if(!aC(a))return null;let b=aC(a.match)?a.match:null;if(!b)return null;let c=String(b.channel??"").trim();if(!c)return null;let d=String(a.agentId??"").trim(),e=String(b.accountId??"").trim(),f=aC(b.peer)?b.peer:null,g=f?String(f.kind??"").trim():"",h=f?String(f.id??"").trim():"",i=h||e;if(!i)return null;let j=d||(e?`${c}:account:${e}`:`${c}:${g}:${h}`),k=[c];return d&&k.push(d),e&&k.push(`account:${e}`),g&&h&&k.push(`${g}:${h}`),{id:j,label:k.join(" · "),channel:c,target:i}}(0,c.useEffect)(()=>{(async()=>{try{if(i){let b=sessionStorage.getItem(g(a,h));if(b)return void y({kind:"ready",jsonText:b});let c=JSON.stringify({schema:"clawkitchen.workflow.v1",id:h,name:"New workflow",timezone:"UTC",nodes:[{id:"start",type:"start",name:"start",x:80,y:80,config:{}},{id:"end",type:"end",name:"end",x:520,y:80,config:{}}],edges:[{id:"e1",from:"start",to:"end"}]},null,2)+"\n";y({kind:"ready",jsonText:c});try{sessionStorage.setItem(g(a,h),c)}catch{}return}let b=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}&id=${encodeURIComponent(h)}`,{cache:"no-store"}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to load workflow");y({kind:"ready",jsonText:JSON.stringify(c.workflow,null,2)+"\n"})}catch(a){y({kind:"error",error:a instanceof Error?a.message:String(a)})}})()},[a,h,i]),(0,c.useEffect)(()=>{(async()=>{S("");try{let b=await fetch("/api/agents",{cache:"no-store"}),c=await b.json();if(!b.ok)throw Error(c.error||c.message||"Failed to load agents");let d=(Array.isArray(c.agents)?c.agents:[]).map(a=>({id:String(a.id??"").trim(),identityName:"string"==typeof a.identityName?a.identityName:void 0})).filter(b=>b.id&&b.id.startsWith(`${a}-`));Q(d)}catch(a){S(a instanceof Error?a.message:String(a)),Q([])}})()},[a]),(0,c.useEffect)(()=>{(async()=>{W("");try{let a=await fetch("/api/channels/bindings",{cache:"no-store"}),b=await a.json();if(!a.ok||!1===b.ok)throw Error(b.error||"Failed to load bindings");let c=(Array.isArray(b.bindings)?b.bindings:[]).map(aD).filter(Boolean);U(c)}catch(a){W(a instanceof Error?a.message:String(a)),U([])}})()},[]);let aE=(0,c.useCallback)(async()=>{ah(""),af(!0);try{let a=await fetch("/api/cron/jobs",{cache:"no-store"}),b=await a.json();if(!a.ok||!1===b.ok)throw Error(b.error||"Failed to load cron jobs");let c=Array.isArray(b.jobs)?b.jobs:[],d={};for(let a of c){if(!a||!a.enabled)continue;let b=String(a.agentId??"").trim();if(b){d[b]=!0;continue}if(a.scope&&"agent"===String(a.scope.kind)){let b=String(a.scope.id??"").trim();b&&(d[b]=!0)}}return aj(d),d}catch(a){return ah(a instanceof Error?a.message:String(a)),aj({}),{}}finally{af(!1)}},[]);(0,c.useEffect)(()=>{aE()},[aE]);let aF=(0,c.useMemo)(()=>{if("ready"!==x.kind)return{wf:null,err:""};try{return{wf:JSON.parse(x.jsonText),err:""}}catch(a){return{wf:null,err:a instanceof Error?a.message:String(a)}}},[x]),aG=(0,c.useMemo)(()=>aF.wf?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:[],g=Array.isArray(a.triggers)?a.triggers:[],h=d.map(a=>String(a?.id??"").trim()).filter(Boolean);h.length!==d.length&&b.push("all nodes must have a non-empty id"),f(h)!==h.length&&b.push("node ids must be unique");let i=e.map(a=>String(a?.id??"").trim()).filter(Boolean);i.length!==e.length&&b.push("all edges must have a non-empty id"),f(i)!==i.length&&b.push("edge ids must be unique");let j=new Set(h);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}j.has(c)||b.push(`edge ${String(a.id)} references missing from node: ${c}`),j.has(d)||b.push(`edge ${String(a.id)} references missing to node: ${d}`)}let k=d.filter(a=>"start"===a.type),l=d.filter(a=>"end"===a.type);for(let a of(k.length||c.push("no start node found"),k.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"),g))if("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`);let d=a.tz?String(a.tz).trim():"";d&&"UTC"!==d&&!d.includes("/")&&c.push(`cron trigger ${String(a.id)} tz doesn't look like an IANA timezone: ${String(a.tz)}`)}let m=a.meta&&"object"==typeof a.meta&&!Array.isArray(a.meta)?a.meta:{},n=String(m.approvalTarget??"").trim();for(let a of d){if("human_approval"!==a.type)continue;let b=a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},d=String(b.target??b.chatId??"").trim(),e=String(b.provider??b.channel??"").trim();d||n||c.push(`human_approval node ${String(a.id)} has no target (set node.config.target or workflow.meta.approvalTarget)`),!d||e||String(m.approvalProvider??"").trim()||c.push(`human_approval node ${String(a.id)} has a target but no provider (set node.config.provider or workflow.meta.approvalProvider)`)}return{errors:b,warnings:c}}(aF.wf):{errors:[],warnings:[]},[aF.wf]),aH=(0,c.useMemo)(()=>{let a=aF.wf;if(!a)return{missingAgentOnNodeIds:[],requiredAgentIds:[],agentIdsMissingCron:[],ok:!0};let b=(a.nodes??[]).filter(a=>"start"!==a.type&&"end"!==a.type&&"human_approval"!==a.type),c=b.filter(a=>!String((a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{}).agentId??"").trim()).map(a=>a.id),d=Array.from(new Set(b.map(a=>String((a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{}).agentId??"").trim()).filter(Boolean))),e=d.filter(a=>!ai[a]),f=0===c.length&&0===e.length;return{missingAgentOnNodeIds:c,requiredAgentIds:d,agentIdsMissingCron:e,ok:f}},[aF.wf,ai]);function aI(b){let c=JSON.stringify(b,null,2)+"\n";if(y({kind:"ready",jsonText:c}),i)try{sessionStorage.setItem(g(a,h),c)}catch{}}async function aJ(){if("ready"===x.kind&&aF.wf&&!aF.err&&!aG.errors.length){w(!0),A("");try{let b=await fetch("/api/teams/workflows",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflow:aF.wf})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to save workflow");try{sessionStorage.removeItem(g(a,h))}catch{}}catch(a){A(a instanceof Error?a.message:String(a))}finally{w(!1)}}}if("loading"===x.kind)return(0,b.jsx)("div",{className:"ck-glass w-full p-6",children:"Loading…"});if("error"===x.kind)return(0,b.jsx)("div",{className:"ck-glass w-full p-6",children:x.error});let aK=!1===j?(0,b.jsxs)("div",{className:"mx-3 mb-3 rounded-[var(--ck-radius-sm)] border border-amber-500/30 bg-amber-500/10 p-3 text-sm",children:[(0,b.jsx)("div",{className:"font-medium text-amber-200",children:"LLM support is not enabled"}),(0,b.jsxs)("div",{className:"mt-1 text-[color:var(--ck-text-secondary)]",children:["Workflow LLM nodes require the optional built-in ",(0,b.jsx)("code",{className:"px-1",children:"llm-task"})," plugin."]}),(0,b.jsxs)("div",{className:"mt-2 text-[color:var(--ck-text-secondary)]",children:["Enable it with: ",(0,b.jsx)("code",{className:"px-1",children:"openclaw plugins enable llm-task"})," then run"," ",(0,b.jsx)("code",{className:"px-1",children:"openclaw gateway restart"}),"."]})]}):null;return(0,b.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-1 flex-col",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-3 py-3",children:[(0,b.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,b.jsx)("a",{href:`/teams/${encodeURIComponent(a)}?tab=workflows`,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Back"}),(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsxs)("div",{className:"truncate text-base font-medium text-[color:var(--ck-text-primary)]",children:[h,".workflow.json"]}),(0,b.jsxs)("div",{className:"mt-0.5 text-sm text-[color:var(--ck-text-tertiary)]",children:["Team: ",a]})]})]}),(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:()=>u("canvas"),className:"canvas"===t?"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:()=>u("json"),className:"json"===t?"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:B,type:"file",accept:"application/json,.json",className:"hidden",onChange:async b=>{let c=b.target.files?.[0];if(b.target.value="",c){A("");try{let b=await c.text(),d=JSON.parse(b);if(y({kind:"ready",jsonText:JSON.stringify(d,null,2)+"\n"}),i)try{sessionStorage.setItem(g(a,h),JSON.stringify(d,null,2)+"\n")}catch{}}catch(a){A(a instanceof Error?a.message:String(a))}}}}),(0,b.jsx)("button",{type:"button",disabled:v,onClick:()=>B.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:!aF.wf||!!aF.err||aG.errors.length>0,onClick:function(){if(!aF.wf||aF.err||aG.errors.length)return;let a=`${aF.wf.id||h}.workflow.json`,b=new Blob([JSON.stringify(aF.wf,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)},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",{type:"button",disabled:v||!aF.wf||!!aF.err||aG.errors.length>0,onClick:aJ,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:v?"Saving…":"Save"})]})]}),aK,aF.err?(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: ",aF.err]}):null,!aF.err&&aG.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:aG.errors.map(a=>(0,b.jsx)("li",{children:a},a))})]}):null,aF.err||aG.errors.length||!aG.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:aG.warnings.map(a=>(0,b.jsx)("li",{children:a},a))})]}),z?(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:z}):null,(0,b.jsxs)("div",{className:"flex min-h-0 flex-1 gap-0",children:["json"===t?(0,b.jsx)("textarea",{value:x.jsonText,onChange:b=>{let c=b.target.value;if(y({kind:"ready",jsonText:c}),i)try{sessionStorage.setItem(g(a,h),c)}catch{}},className:"h-full min-h-0 w-full flex-1 resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]"}):(0,b.jsx)("div",{ref:G,className:"relative h-full min-h-0 w-full flex-1 overflow-auto bg-black/20",onWheel:a=>{if(!a.ctrlKey&&!a.metaKey)return;a.preventDefault();let b=a.deltaY>0?-1:1;F(a=>Math.max(.5,Math.min(2.5,Math.round((a+.1*b)*10)/10)))},onClick:a=>{if("add-node"!==L.kind)return;let b=aF.wf;if(!b)return;let c=G.current;if(!c)return;let d=a.target;if(d&&d.closest("[data-wf-node='1']"))return;let e=c.getBoundingClientRect(),f=(a.clientX-e.left+c.scrollLeft)/E,g=(a.clientY-e.top+c.scrollTop)/E,h=L.nodeType.replace(/[^a-z0-9_\-]/gi,"_"),i=new Set(b.nodes.map(a=>a.id)),j=1,k=`${h}_${j}`;for(;i.has(k);)j++,k=`${h}_${j}`;let l=Math.max(0,f-90),m=Math.max(0,g-24),n={id:k,type:L.nodeType,name:k,x:l,y:m,config:{}};aI({...b,nodes:[...b.nodes,n]}),I(k),M({kind:"select"})},children:(0,b.jsxs)("div",{className:"relative",style:{width:2200*E,height:1200*E},children:[(0,b.jsxs)("div",{className:C?"absolute left-3 top-3 z-20 w-[44px] overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/40 p-2 backdrop-blur":"absolute left-3 top-3 z-20 w-[260px] rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/40 p-2 backdrop-blur",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:C?"hidden":"text-[10px] font-medium uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Tools"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)("div",{className:C?"hidden":"flex items-center gap-1",children:[(0,b.jsx)("button",{type:"button",onClick:()=>F(a=>Math.max(.5,Math.round((a-.1)*10)/10)),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Zoom out (Ctrl/Cmd+wheel)",children:"-"}),(0,b.jsxs)("div",{className:"min-w-[42px] text-center text-[10px] text-[color:var(--ck-text-tertiary)]",children:[Math.round(100*E),"%"]}),(0,b.jsx)("button",{type:"button",onClick:()=>F(a=>Math.min(2.5,Math.round((a+.1)*10)/10)),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Zoom in (Ctrl/Cmd+wheel)",children:"+"})]}),(0,b.jsx)("button",{type:"button",onClick:()=>D(a=>!a),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:C?"Expand":"Collapse",children:C?">":"<"})]})]}),C?(0,b.jsx)("div",{className:"mt-2 flex flex-col items-center gap-2",children:[{key:"select",label:"Select",active:"select"===L.kind,onClick:()=>{M({kind:"select"}),O("")},icon:(0,b.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M5 4l7 16 2-7 7-2L5 4Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})},{key:"connect",label:"Connect",active:"connect"===L.kind,onClick:()=>{M(a=>"connect"===a.kind?{kind:"select"}:{kind:"connect"}),O("")},icon:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M10 13a5 5 0 0 1 0-7l1.2-1.2a5 5 0 0 1 7 7L17 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,b.jsx)("path",{d:"M14 11a5 5 0 0 1 0 7L12.8 19.2a5 5 0 1 1-7-7L7 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})},{key:"llm",label:"LLM",active:"add-node"===L.kind&&"llm"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"llm"}),O("")},icon:(0,b.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M12 2l1.5 6.5L20 10l-6.5 1.5L12 18l-1.5-6.5L4 10l6.5-1.5L12 2Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})},{key:"tool",label:"Tool",active:"add-node"===L.kind&&"tool"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"tool"}),O("")},icon:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M14.5 7.5l2 2-8.5 8.5H6v-2l8.5-8.5Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),(0,b.jsx)("path",{d:"M12 6a4 4 0 0 0-5 5l3-3 2 2 3-3A4 4 0 0 0 12 6Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})]})},{key:"condition",label:"If",active:"add-node"===L.kind&&"condition"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"condition"}),O("")},icon:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M7 4v7a3 3 0 0 0 3 3h7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,b.jsx)("path",{d:"M17 10l3 3-3 3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})},{key:"delay",label:"Delay",active:"add-node"===L.kind&&"delay"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"delay"}),O("")},icon:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M12 7v5l3 2",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),(0,b.jsx)("path",{d:"M21 12a9 9 0 1 1-9-9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})},{key:"approval",label:"Approval",active:"add-node"===L.kind&&"human_approval"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"human_approval"}),O("")},icon:(0,b.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M20 6 9 17l-5-5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})},{key:"end",label:"End",active:"add-node"===L.kind&&"end"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"end"}),O("")},icon:(0,b.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M7 7h10v10H7V7Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})}].map(a=>(0,b.jsx)("button",{type:"button",onClick:a.onClick,className:a.active?"flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] bg-white/10 text-[color:var(--ck-text-primary)]":"flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:a.label,"aria-label":a.label,children:a.icon},a.key))}):(0,b.jsxs)("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:()=>{M({kind:"select"}),O("")},className:"select"===L.kind?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",children:"Select"}),(0,b.jsx)("button",{type:"button",onClick:()=>{M({kind:"connect"}),O("")},className:"connect"===L.kind?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Click a node, then click another node to create an edge",children:"Connect"}),[{t:"llm",label:"LLM"},{t:"tool",label:"Tool"},{t:"condition",label:"If"},{t:"delay",label:"Delay"},{t:"human_approval",label:"Approve"},{t:"end",label:"End"}].map(a=>(0,b.jsxs)("button",{type:"button",onClick:()=>{M({kind:"add-node",nodeType:a.t}),O("")},className:"add-node"===L.kind&&L.nodeType===a.t?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Select tool, then click on the canvas to place",children:["+ ",a.label]},a.t))]}),!C&&"connect"===L.kind&&N?(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Connecting from: ",(0,b.jsx)("span",{className:"font-mono",children:N})]}):null,C||"add-node"!==L.kind?null:(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Click on the canvas to place a ",(0,b.jsx)("span",{className:"font-mono",children:L.nodeType})," node."]}),(0,b.jsxs)("div",{className:"mt-3 border-t border-white/10 pt-3",children:[(0,b.jsxs)("div",{className:C?"hidden":"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-[10px] font-medium uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Agents"}),(0,b.jsx)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:"drag → node"})]}),C?(0,b.jsx)("button",{type:"button",onClick:()=>D(!1),className:"mt-2 flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Expand to see agents","aria-label":"Expand to see agents",children:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M16 11a4 4 0 1 0-8 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,b.jsx)("path",{d:"M4 20a8 8 0 0 1 16 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}):(0,b.jsxs)(b.Fragment,{children:[R?(0,b.jsx)("div",{className:"mt-1 text-[11px] text-red-200",children:R}):null,(0,b.jsx)("div",{className:"mt-2 max-h-[140px] space-y-1 overflow-auto",children:P.length?P.map(c=>(0,b.jsx)("div",{draggable:!0,onDragStart:a=>{a.dataTransfer.setData("text/plain",c.id),a.dataTransfer.effectAllowed="copy"},className:"cursor-grab rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:c.id,children:c.identityName?c.identityName:c.id.replace(`${a}-`,"")},c.id)):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"No team agents found."})})]})]})]}),(0,b.jsxs)("div",{className:"relative h-[1200px] w-[2200px]",style:{transform:`scale(${E})`,transformOrigin:"0 0"},children:[(0,b.jsx)("svg",{className:"pointer-events-none absolute inset-0 -z-10",width:2200,height:1200,style:{overflow:"visible"},children:(aF.wf?.edges??[]).map(a=>{let c=aF.wf;if(!c)return null;let d=c.nodes.find(b=>b.id===a.from),e=c.nodes.find(b=>b.id===a.to);if(!d||!e)return null;let f=("number"==typeof d.x?d.x:80)+90,g=("number"==typeof d.y?d.y:80)+24,h=("number"==typeof e.x?e.x:80)+90,i=("number"==typeof e.y?e.y:80)+24;return(0,b.jsx)("line",{x1:f,y1:g,x2:h,y2:i,stroke:"rgba(255,255,255,0.35)",strokeWidth:3},a.id)})}),(aF.wf?.nodes??[]).map((c,d)=>{let e="number"==typeof c.x?c.x:80+220*d,f="number"==typeof c.y?c.y:80,g=H===c.id;return(0,b.jsxs)("div",{role:"button",tabIndex:0,"data-wf-node":"1",draggable:"select"===L.kind||"connect"===L.kind,onDragStart:a=>{"select"===L.kind&&a.dataTransfer.setData("text/plain","")},onDragOver:a=>{a.dataTransfer.types.includes("text/plain")&&a.preventDefault()},onDrop:a=>{let b=aF.wf;if(!b)return;a.preventDefault(),a.stopPropagation();let d=String(a.dataTransfer.getData("text/plain")||"").trim();if(!d)return;let e=b.nodes.map(a=>{if(a.id!==c.id)return a;let b=a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{};return{...a,config:{...b,agentId:d}}});aI({...b,nodes:e}),I(c.id)},onClick:a=>{a.stopPropagation();let b=aF.wf;if("connect"===L.kind){if(!b)return;if(!N){O(c.id),I(c.id);return}let a=c.id;if(O(""),!N||!a||N===a||(b.edges??[]).some(b=>b.from===N&&b.to===a))return;let d=`e${Date.now()}`;aI({...b,edges:[...b.edges??[],{id:d,from:N,to:a}]}),M({kind:"select"});return}I(c.id)},onPointerDown:a=>{if("add-node"===L.kind||0!==a.button)return;let b=G.current;if(!b)return;let d=b.getBoundingClientRect();I(c.id);try{a.currentTarget.setPointerCapture(a.pointerId)}catch{}a.preventDefault();let g=(a.clientX-d.left+b.scrollLeft)/E,h=(a.clientY-d.top+b.scrollTop)/E;K({nodeId:c.id,dx:g-e,dy:h-f})},onPointerUp:a=>{try{a.currentTarget.releasePointerCapture(a.pointerId)}catch{}K(null)},onPointerMove:a=>{if(!J||J.nodeId!==c.id)return;let b=aF.wf;if(!b)return;let d=G.current;if(!d)return;let e=d.getBoundingClientRect(),f=(a.clientX-e.left+d.scrollLeft)/E,g=(a.clientY-e.top+d.scrollTop)/E,h=f-J.dx,i=g-J.dy,j=b.nodes.map(a=>a.id===c.id?{...a,x:h,y:i}:a);y({kind:"ready",jsonText:JSON.stringify({...b,nodes:j},null,2)+"\n"})},className:g?"absolute z-10 cursor-grab rounded-[var(--ck-radius-sm)] border border-white/25 bg-white/10 px-3 py-2 text-xs text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)]":"absolute z-10 cursor-grab rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",style:{left:e,top:f,width:180},children:[(0,b.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:c.name||c.id}),(0,b.jsx)("div",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:c.type}),(()=>{let d=c.config&&"object"==typeof c.config&&!Array.isArray(c.config)?c.config:null,e=d?String(d.agentId??"").trim():"";if(!e)return null;let f=e.replace(`${a}-`,"");return(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-secondary)]",children:["Agent: ",f]})})()]},c.id)}),(()=>{let a=aF.wf;if(!a||!H)return null;let c=a.nodes.find(a=>a.id===H);if(!c)return null;let d="number"==typeof c.x?c.x:80,e="number"==typeof c.y?c.y:80,f=c.config&&"object"==typeof c.config&&!Array.isArray(c.config)?c.config:{},g=String(f.agentId??"").trim();return(0,b.jsxs)("div",{className:"absolute z-10 w-[320px] rounded-[var(--ck-radius-sm)] border border-white/15 bg-black/60 p-3 shadow-[var(--ck-shadow-1)] backdrop-blur",style:{left:d+200,top:e},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-primary)]",children:c.name||c.id}),(0,b.jsx)("button",{type:"button",onClick:()=>I(""),className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Close"})]}),(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:"name"}),(0,b.jsx)("input",{value:String(c.name??""),onChange:b=>{let d=b.target.value;aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,name:d}:a)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Optional"})]}),(0,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:c.type,onChange:b=>{let d=b.target.value;aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,type:d}:a)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,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)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"agentId"}),(0,b.jsx)("input",{value:g,onChange:b=>{let d=String(b.target.value||"").trim(),e={...f,...d?{agentId:d}:{}};d||delete e.agentId,aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:e}:a)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"(drag an agent onto the node or type)"})]}),"human_approval"===c.type?(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"approval config"}),(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:String(f.provider??""),onChange:b=>{let d=String(b.target.value||"").trim(),e={...f,...d?{provider:d}:{}};d||delete e.provider,aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:e}:a)})},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:String(f.target??""),onChange:b=>{let d=String(b.target.value||"").trim(),e={...f,...d?{target:d}:{}};d||delete e.target,aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:e}:a)})},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:"Overrides workflow-level default when set."})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"messageTemplate (optional)"}),(0,b.jsx)("textarea",{value:String(f.messageTemplate??""),onChange:b=>{let d=String(b.target.value||""),e={...f,...d.trim()?{messageTemplate:d}:{}};d.trim()||delete e.messageTemplate,aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:e}:a)})},className:"mt-1 h-[70px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 font-mono text-[10px] text-[color:var(--ck-text-primary)]",placeholder:"Approval needed for {{workflowName}} (run {{runId}})",spellCheck:!1}),(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["Vars: ","{{workflowName}}",", ","{{workflowId}}",", ","{{runId}}",", ","{{nodeId}}"]})]})]})]}):null,(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"config (json)"}),(0,b.jsx)("textarea",{value:JSON.stringify(f,null,2),onChange:b=>{try{let d=JSON.parse(b.target.value);if(!d||"object"!=typeof d||Array.isArray(d))return;aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:d}:a)})}catch{}},className:"mt-1 h-[140px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 font-mono text-[10px] text-[color:var(--ck-text-primary)]",spellCheck:!1}),(0,b.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"(Edits apply when JSON is valid.)"})]})]})]})})()]})]})}),(0,b.jsx)("div",{className:"w-[380px] shrink-0 overflow-auto p-3 text-sm",children:(0,b.jsx)("div",{className:"space-y-3",children:aF.wf?(l=String((k=aF.wf).timezone??"").trim()||"UTC",m=k.triggers??[],o=String((n=k.meta&&"object"==typeof k.meta&&!Array.isArray(k.meta)?k.meta:{}).approvalBindingId??"").trim(),p=String(n.approvalProvider??"telegram").trim()||"telegram",q=String(n.approvalTarget??"").trim(),r=[{label:"(no preset)",expr:""},{label:"Weekdays 09:00 local",expr:"0 9 * * 1-5"},{label:"Mon/Wed/Fri 09:00 local",expr:"0 9 * * 1,3,5"},{label:"Daily 08:00 local",expr:"0 8 * * *"},{label:"Daily 12:00 local",expr:"0 12 * * *"},{label:"Mon 09:30 local",expr:"30 9 * * 1"}],(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Workflow"}),(0,b.jsx)("div",{className:"px-3 pb-3",children:(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[11px] font-medium text-[color:var(--ck-text-tertiary)]",children:"Timezone"}),(0,b.jsx)("input",{value:l,onChange:a=>{let b=String(a.target.value||"").trim()||"UTC";aI({...k,timezone:b})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-sm text-[color:var(--ck-text-primary)]",placeholder:"America/New_York"})]})})]}),(0,b.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Approval Channel"}),(0,b.jsxs)("div",{className:"px-3 pb-3 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:"binding (recommended)"}),(0,b.jsxs)("select",{value:o,onChange:a=>{let b=String(a.target.value||"").trim(),c=T.find(a=>a.id===b);c?aI({...k,meta:{...n,approvalBindingId:c.id,approvalProvider:c.channel,approvalTarget:c.target},nodes:k.nodes.map(a=>"human_approval"===a.type?{...a,config:{...a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},approvalBindingId:c.id,provider:c.channel,target:c.target}}:a)}):aI({...k,meta:{...n,approvalBindingId:""},nodes:k.nodes.map(a=>"human_approval"===a.type?{...a,config:{...a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},approvalBindingId:""}}:a)})},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:"(manual)"}),T.map(a=>(0,b.jsx)("option",{value:a.id,children:a.label},a.id))]}),X?(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-yellow-200",children:["Kitchen looks out of date. Run ",(0,b.jsx)("code",{className:"font-mono",children:"openclaw plugins update"})," then",(0,b.jsx)("code",{className:"ml-1 font-mono",children:"openclaw gateway restart"}),"."]}):null,V?(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-red-200",children:["Failed to load bindings: ",V]}):null,(0,b.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Uses your existing OpenClaw bindings (recommended). Manual provider/target is an advanced override."})]}),(0,b.jsxs)("details",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-secondary)]",children:"Advanced: manual override"}),(0,b.jsxs)("div",{className:"px-2 pb-2 pt-1 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:p,onChange:a=>{let b=String(a.target.value||"").trim()||"telegram";aI({...k,meta:{...n,approvalBindingId:"",approvalProvider:b},nodes:k.nodes.map(a=>"human_approval"===a.type?{...a,config:{...a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},approvalBindingId:"",provider:b}}:a)})},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:q,onChange:a=>{let b=String(a.target.value||"").trim();aI({...k,meta:{...n,approvalBindingId:"",approvalTarget:b},nodes:k.nodes.map(a=>"human_approval"===a.type?{...a,config:{...a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},approvalBindingId:"",target:b}}:a)})},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.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Triggers"}),(0,b.jsxs)("div",{className:"px-3 pb-3",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()}`;aI({...k,triggers:[...m,{kind:"cron",id:a,name:"New trigger",enabled:!0,expr:"0 9 * * 1-5",tz:l}]})},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),n=!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:()=>aI({...k,triggers:m.filter((a,b)=>b!==c)}),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;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,enabled:b}:a)})}}),"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;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,name:b}:a)})},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;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,expr:b}:a)})},className:n?"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"}),n?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:r.some(a=>a.expr===h)?h:"",onChange:a=>{let b=a.target.value;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,expr:b}:a)})},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:r.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;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,tz:b}:a)})},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)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Runs"}),(0,b.jsxs)("div",{className:"px-3 pb-3",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Runs (history)"}),(0,b.jsx)(d.default,{href:`/teams/${encodeURIComponent(a)}/runs`,className:"text-[10px] font-medium text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-secondary)] hover:underline",children:"View all →"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("button",{type:"button",disabled:v,onClick:async()=>{let b=String(k.id??"").trim();if(b){ab(""),_(!0);try{let c=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:b,mode:"enqueue"})}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to enqueue 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);Z(g)}catch(a){ab(a instanceof Error?a.message:String(a))}finally{_(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"+ Queue run"}),(0,b.jsx)("button",{type:"button",disabled:v||ae||!aH.ok,onClick:async()=>{let b=String(k.id??"").trim();if(b){if(aH.missingAgentOnNodeIds.length)return void ab("All nodes must be assigned to an agent.");if(aH.agentIdsMissingCron.length){an(!0),ap("");try{let b=await fetch("/api/cron/worker",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"reconcile",teamId:a})}),c=await b.json();if(!b.ok||!1===c.ok)throw Error(c.error||"Failed to reconcile worker crons");let d=await aE(),e=aH.requiredAgentIds.filter(a=>!d[a]);if(e.length)return void ab(`Cron not set up for: ${e.join(", ")}`)}catch(a){ab(a instanceof Error?a.message:String(a));return}finally{an(!1)}}ab(""),_(!0);try{let c=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:b,mode:"run_now"})}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to create 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);Z(g)}catch(a){ab(a instanceof Error?a.message:String(a))}finally{_(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 px-2 py-1 text-[10px] font-medium text-emerald-50 hover:bg-emerald-500/15 disabled:opacity-50",title:"Enqueue a run for the workflow runner (Kitchen does not execute nodes)",children:"+ Run now"}),ag?(0,b.jsx)("div",{className:"ml-2 text-[10px] text-amber-100/90",title:ag,children:"Cron check unavailable"}):null]})]}),aH.missingAgentOnNodeIds.length?(0,b.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:["All nodes must be assigned to an agent. Missing agentId on: ",aH.missingAgentOnNodeIds.join(", ")]}):aH.agentIdsMissingCron.length?(0,b.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-2 text-xs text-amber-50",children:[(0,b.jsxs)("div",{children:["Cron not set up for: ",aH.agentIdsMissingCron.join(", ")]}),(0,b.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:()=>{ap(""),al(!0)},className:"rounded-[var(--ck-radius-sm)] border border-amber-300/30 bg-amber-500/10 px-2 py-1 text-[10px] font-medium text-amber-50 hover:bg-amber-500/15",children:"Install worker cron(s)"}),(0,b.jsx)("button",{type:"button",onClick:()=>void aE(),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Re-check"})]})]}):null,(0,b.jsx)(e.ConfirmationModal,{open:ak,title:"Install worker cron jobs?",busy:am,error:ao||void 0,confirmLabel:"Install",onClose:()=>{am||al(!1)},onConfirm:async()=>{an(!0),ap("");try{let b=await fetch("/api/cron/worker",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"reconcile",teamId:a})}),c=await b.json();if(!b.ok||!1===c.ok)throw Error(c.error||"Failed to install worker crons");await aE(),al(!1)}catch(a){ap(a instanceof Error?a.message:String(a))}finally{an(!1)}},children:(0,b.jsxs)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:["Kitchen will install (or enable) worker cron jobs for the following agents so this workflow can drain:",(0,b.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 font-mono text-[11px] text-[color:var(--ck-text-primary)]",children:aH.agentIdsMissingCron.join(", ")}),(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Cron cadence: 1 minute. The worker runs: ",(0,b.jsx)("span",{className:"font-mono",children:"openclaw recipes workflows worker-tick"}),"."]})]})}),aa?(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:aa}):null,(0,b.jsx)("div",{className:"mt-2 space-y-1",children:$?(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Loading runs…"}):Y.length?Y.slice(0,8).map(c=>{let e=String(k.id??"").trim(),f=String(c).replace(/\.run\.json$/i,""),g=ac===f,h=e?`/teams/${encodeURIComponent(a)}/runs/${encodeURIComponent(e)}/${encodeURIComponent(f)}`:"#";return(0,b.jsx)(d.default,{href:h,onClick:()=>ad(f),className:g?"block w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] font-mono text-[color:var(--ck-text-primary)]":"block w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] font-mono text-[color:var(--ck-text-secondary)] hover:bg-white/5",title:"Open run detail",children:f},c)}):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No runs yet."})}),(0,b.jsxs)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Nodes"}),(0,b.jsxs)("div",{className:"px-3 pb-3",children:[(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:aq,onChange:a=>ar(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.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:as,onChange:a=>at(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:au,onChange:a=>av(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(aq||"").trim().replace(/[^a-z0-9_\-]/gi,"_");if(!a||k.nodes.some(b=>b.id===a))return;let b=k.nodes.reduce((a,b)=>"number"==typeof b.x?Math.max(a,b.x):a,80),c={id:a,type:au,name:String(as||"").trim()||a,x:b+220,y:80};aI({...k,nodes:[...k.nodes,c]}),I(a),ar(""),at("")},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:k.nodes.map(a=>{let c=H===a.id;return(0,b.jsxs)("button",{type:"button",onClick:()=>I(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)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Edges"}),(0,b.jsxs)("div",{className:"px-3 pb-3",children:[(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:aw,onChange:a=>ax(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)"}),k.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:ay,onChange:a=>az(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)"}),k.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:aA,onChange:a=>aB(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(aw||"").trim(),b=String(ay||"").trim();if(!a||!b||a===b)return;let c={id:`e${Date.now()}`,from:a,to:b,...String(aA||"").trim()?{label:String(aA).trim()}:{}};aI({...k,edges:[...k.edges??[],c]}),aB("")},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:(k.edges??[]).length?(k.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:()=>aI({...k,edges:(k.edges??[]).filter(b=>b.id!==a.id)}),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)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Node inspector"}),(0,b.jsxs)("div",{className:"px-3 pb-3",children:[(0,b.jsx)("div",{className:"flex items-center justify-between gap-2",children:H?(0,b.jsx)("button",{type:"button",onClick:()=>{let a=k.nodes.filter(a=>a.id!==H),b=(k.edges??[]).filter(a=>a.from!==H&&a.to!==H);aI({...k,nodes:a,edges:b}),I("")},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}),H?(s=k.nodes.find(a=>a.id===H))?(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:s.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(s.name??""),onChange:a=>{let b=a.target.value;aI({...k,nodes:k.nodes.map(a=>a.id===s.id?{...a,name:b}:a)})},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:s.type,onChange:a=>{let b=a.target.value;aI({...k,nodes:k.nodes.map(a=>a.id===s.id?{...a,type:b}:a)})},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 s.x?s.x:0,onChange:a=>{let b=Number(a.target.value);aI({...k,nodes:k.nodes.map(a=>a.id===s.id?{...a,x:b}:a)})},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 s.y?s.y:0,onChange:a=>{let b=Number(a.target.value);aI({...k,nodes:k.nodes.map(a=>a.id===s.id?{...a,y:b}:a)})},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(s.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."})]})]})]})]})]})):null})})]})]})}a.s(["default",()=>h],13833)}];
|
|
1
|
+
module.exports=[13833,a=>{"use strict";var b=a.i(87924),c=a.i(72131),d=a.i(38246),e=a.i(66063);function f(a){let b=new Set;for(let c of a)b.add(c);return b.size}function g(a,b){return`ck-wf-draft:${a}:${b}`}function h({teamId:a,workflowId:h,draft:i,llmTaskEnabled:j}){let k,l,m,n,o,p,q,r,s,[t,u]=(0,c.useState)("canvas"),[v,w]=(0,c.useState)(!1),[x,y]=(0,c.useState)({kind:"loading"}),[z,A]=(0,c.useState)(""),B=(0,c.useRef)(null),[C,D]=(0,c.useState)(!1),[E,F]=(0,c.useState)(1),G=(0,c.useRef)(null),[H,I]=(0,c.useState)(""),[J,K]=(0,c.useState)(null),[L,M]=(0,c.useState)({kind:"select"}),[N,O]=(0,c.useState)(""),[P,Q]=(0,c.useState)([]),[R,S]=(0,c.useState)(""),[T,U]=(0,c.useState)([]),[V,W]=(0,c.useState)(""),X=(0,c.useMemo)(()=>/Tool not available:\s*gateway/i.test(String(V||"")),[V]),[Y,Z]=(0,c.useState)([]),[$,_]=(0,c.useState)(!1),[aa,ab]=(0,c.useState)(""),[ac,ad]=(0,c.useState)(""),[ae,af]=(0,c.useState)(!1),[ag,ah]=(0,c.useState)(""),[ai,aj]=(0,c.useState)({}),[ak,al]=(0,c.useState)(!1),[am,an]=(0,c.useState)(!1),[ao,ap]=(0,c.useState)(""),[aq,ar]=(0,c.useState)(""),[as,at]=(0,c.useState)(""),[au,av]=(0,c.useState)("llm"),[aw,ax]=(0,c.useState)(""),[ay,az]=(0,c.useState)(""),[aA,aB]=(0,c.useState)("");function aC(a){return!!a&&"object"==typeof a&&!Array.isArray(a)}function aD(a){if(!aC(a))return null;let b=aC(a.match)?a.match:null;if(!b)return null;let c=String(b.channel??"").trim();if(!c)return null;let d=String(a.agentId??"").trim(),e=String(b.accountId??"").trim(),f=aC(b.peer)?b.peer:null,g=f?String(f.kind??"").trim():"",h=f?String(f.id??"").trim():"",i=h||e;if(!i)return null;let j=d||(e?`${c}:account:${e}`:`${c}:${g}:${h}`),k=[c];return d&&k.push(d),e&&k.push(`account:${e}`),g&&h&&k.push(`${g}:${h}`),{id:j,label:k.join(" · "),channel:c,target:i}}(0,c.useEffect)(()=>{(async()=>{try{if(i){let b=sessionStorage.getItem(g(a,h));if(b)return void y({kind:"ready",jsonText:b});let c=JSON.stringify({schema:"clawkitchen.workflow.v1",id:h,name:"New workflow",timezone:"UTC",nodes:[{id:"start",type:"start",name:"start",x:80,y:80,config:{}},{id:"end",type:"end",name:"end",x:520,y:80,config:{}}],edges:[{id:"e1",from:"start",to:"end"}]},null,2)+"\n";y({kind:"ready",jsonText:c});try{sessionStorage.setItem(g(a,h),c)}catch{}return}let b=await fetch(`/api/teams/workflows?teamId=${encodeURIComponent(a)}&id=${encodeURIComponent(h)}`,{cache:"no-store"}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to load workflow");y({kind:"ready",jsonText:JSON.stringify(c.workflow,null,2)+"\n"})}catch(a){y({kind:"error",error:a instanceof Error?a.message:String(a)})}})()},[a,h,i]),(0,c.useEffect)(()=>{(async()=>{S("");try{let b=await fetch("/api/agents",{cache:"no-store"}),c=await b.json();if(!b.ok)throw Error(c.error||c.message||"Failed to load agents");let d=(Array.isArray(c.agents)?c.agents:[]).map(a=>({id:String(a.id??"").trim(),identityName:"string"==typeof a.identityName?a.identityName:void 0})).filter(b=>b.id&&b.id.startsWith(`${a}-`));Q(d)}catch(a){S(a instanceof Error?a.message:String(a)),Q([])}})()},[a]),(0,c.useEffect)(()=>{(async()=>{W("");try{let a=await fetch("/api/channels/bindings",{cache:"no-store"}),b=await a.json();if(!a.ok||!1===b.ok)throw Error(b.error||"Failed to load bindings");let c=(Array.isArray(b.bindings)?b.bindings:[]).map(aD).filter(Boolean);U(c)}catch(a){W(a instanceof Error?a.message:String(a)),U([])}})()},[]);let aE=(0,c.useCallback)(async()=>{ah(""),af(!0);try{let a=await fetch("/api/cron/jobs",{cache:"no-store"}),b=await a.json();if(!a.ok||!1===b.ok)throw Error(b.error||"Failed to load cron jobs");let c=Array.isArray(b.jobs)?b.jobs:[],d={};for(let a of c){if(!a||!a.enabled)continue;let b=String(a.agentId??"").trim();if(b){d[b]=!0;continue}if(a.scope&&"agent"===String(a.scope.kind)){let b=String(a.scope.id??"").trim();b&&(d[b]=!0)}}return aj(d),d}catch(a){return ah(a instanceof Error?a.message:String(a)),aj({}),{}}finally{af(!1)}},[]);(0,c.useEffect)(()=>{aE()},[aE]);let aF=(0,c.useMemo)(()=>{if("ready"!==x.kind)return{wf:null,err:""};try{return{wf:JSON.parse(x.jsonText),err:""}}catch(a){return{wf:null,err:a instanceof Error?a.message:String(a)}}},[x]),aG=(0,c.useMemo)(()=>aF.wf?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:[],g=Array.isArray(a.triggers)?a.triggers:[],h=d.map(a=>String(a?.id??"").trim()).filter(Boolean);h.length!==d.length&&b.push("all nodes must have a non-empty id"),f(h)!==h.length&&b.push("node ids must be unique");let i=e.map(a=>String(a?.id??"").trim()).filter(Boolean);i.length!==e.length&&b.push("all edges must have a non-empty id"),f(i)!==i.length&&b.push("edge ids must be unique");let j=new Set(h);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}j.has(c)||b.push(`edge ${String(a.id)} references missing from node: ${c}`),j.has(d)||b.push(`edge ${String(a.id)} references missing to node: ${d}`)}let k=d.filter(a=>"start"===a.type),l=d.filter(a=>"end"===a.type);for(let a of(k.length||c.push("no start node found"),k.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"),g))if("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`);let d=a.tz?String(a.tz).trim():"";d&&"UTC"!==d&&!d.includes("/")&&c.push(`cron trigger ${String(a.id)} tz doesn't look like an IANA timezone: ${String(a.tz)}`)}let m=a.meta&&"object"==typeof a.meta&&!Array.isArray(a.meta)?a.meta:{},n=String(m.approvalTarget??"").trim();for(let a of d){if("human_approval"!==a.type)continue;let b=a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},d=String(b.target??b.chatId??"").trim(),e=String(b.provider??b.channel??"").trim();d||n||c.push(`human_approval node ${String(a.id)} has no target (set node.config.target or workflow.meta.approvalTarget)`),!d||e||String(m.approvalProvider??"").trim()||c.push(`human_approval node ${String(a.id)} has a target but no provider (set node.config.provider or workflow.meta.approvalProvider)`)}return{errors:b,warnings:c}}(aF.wf):{errors:[],warnings:[]},[aF.wf]),aH=(0,c.useMemo)(()=>{let a=aF.wf;if(!a)return{missingAgentOnNodeIds:[],requiredAgentIds:[],agentIdsMissingCron:[],ok:!0};let b=(a.nodes??[]).filter(a=>"start"!==a.type&&"end"!==a.type&&"human_approval"!==a.type),c=b.filter(a=>!String((a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{}).agentId??"").trim()).map(a=>a.id),d=Array.from(new Set(b.map(a=>String((a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{}).agentId??"").trim()).filter(Boolean))),e=d.filter(a=>!ai[a]),f=0===c.length&&0===e.length;return{missingAgentOnNodeIds:c,requiredAgentIds:d,agentIdsMissingCron:e,ok:f}},[aF.wf,ai]);function aI(b){let c=JSON.stringify(b,null,2)+"\n";if(y({kind:"ready",jsonText:c}),i)try{sessionStorage.setItem(g(a,h),c)}catch{}}async function aJ(){if("ready"===x.kind&&aF.wf&&!aF.err&&!aG.errors.length){w(!0),A("");try{let b=await fetch("/api/teams/workflows",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflow:aF.wf})}),c=await b.json();if(!b.ok||!c.ok)throw Error(c.error||"Failed to save workflow");try{sessionStorage.removeItem(g(a,h))}catch{}}catch(a){A(a instanceof Error?a.message:String(a))}finally{w(!1)}}}if("loading"===x.kind)return(0,b.jsx)("div",{className:"ck-glass w-full p-6",children:"Loading…"});if("error"===x.kind)return(0,b.jsx)("div",{className:"ck-glass w-full p-6",children:x.error});let aK=!1===j?(0,b.jsxs)("div",{className:"mx-3 mb-3 rounded-[var(--ck-radius-sm)] border border-amber-500/30 bg-amber-500/10 p-3 text-sm",children:[(0,b.jsx)("div",{className:"font-medium text-amber-200",children:"LLM support is not enabled"}),(0,b.jsxs)("div",{className:"mt-1 text-[color:var(--ck-text-secondary)]",children:["Workflow LLM nodes require the optional built-in ",(0,b.jsx)("code",{className:"px-1",children:"llm-task"})," plugin."]}),(0,b.jsxs)("div",{className:"mt-2 text-[color:var(--ck-text-secondary)]",children:["Enable it with: ",(0,b.jsx)("code",{className:"px-1",children:"openclaw plugins enable llm-task"})," then run"," ",(0,b.jsx)("code",{className:"px-1",children:"openclaw gateway restart"}),"."]})]}):null;return(0,b.jsxs)("div",{className:"flex h-full min-h-0 w-full flex-1 flex-col",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 px-3 py-3",children:[(0,b.jsxs)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,b.jsx)("a",{href:`/teams/${encodeURIComponent(a)}?tab=workflows`,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Back"}),(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsxs)("div",{className:"truncate text-base font-medium text-[color:var(--ck-text-primary)]",children:[h,".workflow.json"]}),(0,b.jsxs)("div",{className:"mt-0.5 text-sm text-[color:var(--ck-text-tertiary)]",children:["Team: ",a]})]})]}),(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:()=>u("canvas"),className:"canvas"===t?"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:()=>u("json"),className:"json"===t?"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:B,type:"file",accept:"application/json,.json",className:"hidden",onChange:async b=>{let c=b.target.files?.[0];if(b.target.value="",c){A("");try{let b=await c.text(),d=JSON.parse(b);if(y({kind:"ready",jsonText:JSON.stringify(d,null,2)+"\n"}),i)try{sessionStorage.setItem(g(a,h),JSON.stringify(d,null,2)+"\n")}catch{}}catch(a){A(a instanceof Error?a.message:String(a))}}}}),(0,b.jsx)("button",{type:"button",disabled:v,onClick:()=>B.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:!aF.wf||!!aF.err||aG.errors.length>0,onClick:function(){if(!aF.wf||aF.err||aG.errors.length)return;let a=`${aF.wf.id||h}.workflow.json`,b=new Blob([JSON.stringify(aF.wf,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)},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",{type:"button",disabled:v||!aF.wf||!!aF.err||aG.errors.length>0,onClick:aJ,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:v?"Saving…":"Save"})]})]}),aK,aF.err?(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: ",aF.err]}):null,!aF.err&&aG.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:aG.errors.map(a=>(0,b.jsx)("li",{children:a},a))})]}):null,aF.err||aG.errors.length||!aG.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:aG.warnings.map(a=>(0,b.jsx)("li",{children:a},a))})]}),z?(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:z}):null,(0,b.jsxs)("div",{className:"flex min-h-0 flex-1 gap-0",children:["json"===t?(0,b.jsx)("textarea",{value:x.jsonText,onChange:b=>{let c=b.target.value;if(y({kind:"ready",jsonText:c}),i)try{sessionStorage.setItem(g(a,h),c)}catch{}},className:"h-full min-h-0 w-full flex-1 resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-3 font-mono text-xs text-[color:var(--ck-text-primary)]"}):(0,b.jsx)("div",{ref:G,className:"relative h-full min-h-0 w-full flex-1 overflow-auto bg-black/20",onWheel:a=>{if(!a.ctrlKey&&!a.metaKey)return;a.preventDefault();let b=a.deltaY>0?-1:1;F(a=>Math.max(.5,Math.min(2.5,Math.round((a+.1*b)*10)/10)))},onClick:a=>{if("add-node"!==L.kind)return;let b=aF.wf;if(!b)return;let c=G.current;if(!c)return;let d=a.target;if(d&&d.closest("[data-wf-node='1']"))return;let e=c.getBoundingClientRect(),f=(a.clientX-e.left+c.scrollLeft)/E,g=(a.clientY-e.top+c.scrollTop)/E,h=L.nodeType.replace(/[^a-z0-9_\-]/gi,"_"),i=new Set(b.nodes.map(a=>a.id)),j=1,k=`${h}_${j}`;for(;i.has(k);)j++,k=`${h}_${j}`;let l=Math.max(0,f-90),m=Math.max(0,g-24),n={id:k,type:L.nodeType,name:k,x:l,y:m,config:{}};aI({...b,nodes:[...b.nodes,n]}),I(k),M({kind:"select"})},children:(0,b.jsxs)("div",{className:"relative",style:{width:2200*E,height:1200*E},children:[(0,b.jsxs)("div",{className:C?"absolute left-3 top-3 z-20 w-[44px] overflow-hidden rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/40 p-2 backdrop-blur":"absolute left-3 top-3 z-20 w-[260px] rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/40 p-2 backdrop-blur",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:C?"hidden":"text-[10px] font-medium uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Tools"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)("div",{className:C?"hidden":"flex items-center gap-1",children:[(0,b.jsx)("button",{type:"button",onClick:()=>F(a=>Math.max(.5,Math.round((a-.1)*10)/10)),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Zoom out (Ctrl/Cmd+wheel)",children:"-"}),(0,b.jsxs)("div",{className:"min-w-[42px] text-center text-[10px] text-[color:var(--ck-text-tertiary)]",children:[Math.round(100*E),"%"]}),(0,b.jsx)("button",{type:"button",onClick:()=>F(a=>Math.min(2.5,Math.round((a+.1)*10)/10)),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Zoom in (Ctrl/Cmd+wheel)",children:"+"})]}),(0,b.jsx)("button",{type:"button",onClick:()=>D(a=>!a),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:C?"Expand":"Collapse",children:C?">":"<"})]})]}),C?(0,b.jsx)("div",{className:"mt-2 flex flex-col items-center gap-2",children:[{key:"select",label:"Select",active:"select"===L.kind,onClick:()=>{M({kind:"select"}),O("")},icon:(0,b.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M5 4l7 16 2-7 7-2L5 4Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})},{key:"connect",label:"Connect",active:"connect"===L.kind,onClick:()=>{M(a=>"connect"===a.kind?{kind:"select"}:{kind:"connect"}),O("")},icon:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M10 13a5 5 0 0 1 0-7l1.2-1.2a5 5 0 0 1 7 7L17 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,b.jsx)("path",{d:"M14 11a5 5 0 0 1 0 7L12.8 19.2a5 5 0 1 1-7-7L7 12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})},{key:"llm",label:"LLM",active:"add-node"===L.kind&&"llm"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"llm"}),O("")},icon:(0,b.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M12 2l1.5 6.5L20 10l-6.5 1.5L12 18l-1.5-6.5L4 10l6.5-1.5L12 2Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})},{key:"tool",label:"Tool",active:"add-node"===L.kind&&"tool"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"tool"}),O("")},icon:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M14.5 7.5l2 2-8.5 8.5H6v-2l8.5-8.5Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"}),(0,b.jsx)("path",{d:"M12 6a4 4 0 0 0-5 5l3-3 2 2 3-3A4 4 0 0 0 12 6Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})]})},{key:"condition",label:"If",active:"add-node"===L.kind&&"condition"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"condition"}),O("")},icon:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M7 4v7a3 3 0 0 0 3 3h7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,b.jsx)("path",{d:"M17 10l3 3-3 3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})},{key:"delay",label:"Delay",active:"add-node"===L.kind&&"delay"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"delay"}),O("")},icon:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M12 7v5l3 2",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),(0,b.jsx)("path",{d:"M21 12a9 9 0 1 1-9-9",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})},{key:"approval",label:"Approval",active:"add-node"===L.kind&&"human_approval"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"human_approval"}),O("")},icon:(0,b.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M20 6 9 17l-5-5",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})},{key:"end",label:"End",active:"add-node"===L.kind&&"end"===L.nodeType,onClick:()=>{M({kind:"add-node",nodeType:"end"}),O("")},icon:(0,b.jsx)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:(0,b.jsx)("path",{d:"M7 7h10v10H7V7Z",stroke:"currentColor",strokeWidth:"1.6",strokeLinejoin:"round"})})}].map(a=>(0,b.jsx)("button",{type:"button",onClick:a.onClick,className:a.active?"flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] bg-white/10 text-[color:var(--ck-text-primary)]":"flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:a.label,"aria-label":a.label,children:a.icon},a.key))}):(0,b.jsxs)("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:()=>{M({kind:"select"}),O("")},className:"select"===L.kind?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",children:"Select"}),(0,b.jsx)("button",{type:"button",onClick:()=>{M({kind:"connect"}),O("")},className:"connect"===L.kind?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Click a node, then click another node to create an edge",children:"Connect"}),[{t:"llm",label:"LLM"},{t:"tool",label:"Tool"},{t:"condition",label:"If"},{t:"delay",label:"Delay"},{t:"human_approval",label:"Approve"},{t:"end",label:"End"}].map(a=>(0,b.jsxs)("button",{type:"button",onClick:()=>{M({kind:"add-node",nodeType:a.t}),O("")},className:"add-node"===L.kind&&L.nodeType===a.t?"rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]":"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Select tool, then click on the canvas to place",children:["+ ",a.label]},a.t))]}),!C&&"connect"===L.kind&&N?(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Connecting from: ",(0,b.jsx)("span",{className:"font-mono",children:N})]}):null,C||"add-node"!==L.kind?null:(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-secondary)]",children:["Click on the canvas to place a ",(0,b.jsx)("span",{className:"font-mono",children:L.nodeType})," node."]}),(0,b.jsxs)("div",{className:"mt-3 border-t border-white/10 pt-3",children:[(0,b.jsxs)("div",{className:C?"hidden":"flex items-center justify-between gap-2",children:[(0,b.jsx)("div",{className:"text-[10px] font-medium uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"Agents"}),(0,b.jsx)("div",{className:"text-[10px] text-[color:var(--ck-text-tertiary)]",children:"drag → node"})]}),C?(0,b.jsx)("button",{type:"button",onClick:()=>D(!1),className:"mt-2 flex h-8 w-8 items-center justify-center rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:"Expand to see agents","aria-label":"Expand to see agents",children:(0,b.jsxs)("svg",{viewBox:"0 0 24 24",className:"h-4 w-4",fill:"none","aria-hidden":"true",children:[(0,b.jsx)("path",{d:"M16 11a4 4 0 1 0-8 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"}),(0,b.jsx)("path",{d:"M4 20a8 8 0 0 1 16 0",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}):(0,b.jsxs)(b.Fragment,{children:[R?(0,b.jsx)("div",{className:"mt-1 text-[11px] text-red-200",children:R}):null,(0,b.jsx)("div",{className:"mt-2 max-h-[140px] space-y-1 overflow-auto",children:P.length?P.map(c=>(0,b.jsx)("div",{draggable:!0,onDragStart:a=>{a.dataTransfer.setData("text/plain",c.id),a.dataTransfer.effectAllowed="copy"},className:"cursor-grab rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",title:c.id,children:c.identityName?c.identityName:c.id.replace(`${a}-`,"")},c.id)):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-tertiary)]",children:"No team agents found."})})]})]})]}),(0,b.jsxs)("div",{className:"relative h-[1200px] w-[2200px]",style:{transform:`scale(${E})`,transformOrigin:"0 0"},children:[(0,b.jsx)("svg",{className:"pointer-events-none absolute inset-0 -z-10",width:2200,height:1200,style:{overflow:"visible"},children:(aF.wf?.edges??[]).map(a=>{let c=aF.wf;if(!c)return null;let d=c.nodes.find(b=>b.id===a.from),e=c.nodes.find(b=>b.id===a.to);if(!d||!e)return null;let f=("number"==typeof d.x?d.x:80)+90,g=("number"==typeof d.y?d.y:80)+24,h=("number"==typeof e.x?e.x:80)+90,i=("number"==typeof e.y?e.y:80)+24;return(0,b.jsx)("line",{x1:f,y1:g,x2:h,y2:i,stroke:"rgba(255,255,255,0.35)",strokeWidth:3},a.id)})}),(aF.wf?.nodes??[]).map((c,d)=>{let e="number"==typeof c.x?c.x:80+220*d,f="number"==typeof c.y?c.y:80,g=H===c.id;return(0,b.jsxs)("div",{role:"button",tabIndex:0,"data-wf-node":"1",draggable:"select"===L.kind||"connect"===L.kind,onDragStart:a=>{"select"===L.kind&&a.dataTransfer.setData("text/plain","")},onDragOver:a=>{a.dataTransfer.types.includes("text/plain")&&a.preventDefault()},onDrop:a=>{let b=aF.wf;if(!b)return;a.preventDefault(),a.stopPropagation();let d=String(a.dataTransfer.getData("text/plain")||"").trim();if(!d)return;let e=b.nodes.map(a=>{if(a.id!==c.id)return a;let b=a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{};return{...a,config:{...b,agentId:d}}});aI({...b,nodes:e}),I(c.id)},onClick:a=>{a.stopPropagation();let b=aF.wf;if("connect"===L.kind){if(!b)return;if(!N){O(c.id),I(c.id);return}let a=c.id;if(O(""),!N||!a||N===a||(b.edges??[]).some(b=>b.from===N&&b.to===a))return;let d=`e${Date.now()}`;aI({...b,edges:[...b.edges??[],{id:d,from:N,to:a}]}),M({kind:"select"});return}I(c.id)},onPointerDown:a=>{if("add-node"===L.kind||0!==a.button)return;let b=G.current;if(!b)return;let d=b.getBoundingClientRect();I(c.id);try{a.currentTarget.setPointerCapture(a.pointerId)}catch{}a.preventDefault();let g=(a.clientX-d.left+b.scrollLeft)/E,h=(a.clientY-d.top+b.scrollTop)/E;K({nodeId:c.id,dx:g-e,dy:h-f})},onPointerUp:a=>{try{a.currentTarget.releasePointerCapture(a.pointerId)}catch{}K(null)},onPointerMove:a=>{if(!J||J.nodeId!==c.id)return;let b=aF.wf;if(!b)return;let d=G.current;if(!d)return;let e=d.getBoundingClientRect(),f=(a.clientX-e.left+d.scrollLeft)/E,g=(a.clientY-e.top+d.scrollTop)/E,h=f-J.dx,i=g-J.dy,j=b.nodes.map(a=>a.id===c.id?{...a,x:h,y:i}:a);y({kind:"ready",jsonText:JSON.stringify({...b,nodes:j},null,2)+"\n"})},className:g?"absolute z-10 cursor-grab rounded-[var(--ck-radius-sm)] border border-white/25 bg-white/10 px-3 py-2 text-xs text-[color:var(--ck-text-primary)] shadow-[var(--ck-shadow-1)]":"absolute z-10 cursor-grab rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-3 py-2 text-xs text-[color:var(--ck-text-secondary)] hover:bg-white/10",style:{left:e,top:f,width:180},children:[(0,b.jsx)("div",{className:"font-medium text-[color:var(--ck-text-primary)]",children:c.name||c.id}),(0,b.jsx)("div",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:c.type}),(()=>{let d=c.config&&"object"==typeof c.config&&!Array.isArray(c.config)?c.config:null,e=d?String(d.agentId??"").trim():"";if(!e)return null;let f=e.replace(`${a}-`,"");return(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-secondary)]",children:["Agent: ",f]})})()]},c.id)}),(()=>{let a=aF.wf;if(!a||!H)return null;let c=a.nodes.find(a=>a.id===H);if(!c)return null;let d="number"==typeof c.x?c.x:80,e="number"==typeof c.y?c.y:80,f=c.config&&"object"==typeof c.config&&!Array.isArray(c.config)?c.config:{},g=String(f.agentId??"").trim();return(0,b.jsxs)("div",{className:"absolute z-10 w-[320px] rounded-[var(--ck-radius-sm)] border border-white/15 bg-black/60 p-3 shadow-[var(--ck-shadow-1)] backdrop-blur",style:{left:d+200,top:e},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-primary)]",children:c.name||c.id}),(0,b.jsx)("button",{type:"button",onClick:()=>I(""),className:"text-[10px] text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-primary)]",children:"Close"})]}),(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:"name"}),(0,b.jsx)("input",{value:String(c.name??""),onChange:b=>{let d=b.target.value;aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,name:d}:a)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"Optional"})]}),(0,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:c.type,onChange:b=>{let d=b.target.value;aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,type:d}:a)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",children:[(0,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)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"agentId"}),(0,b.jsx)("input",{value:g,onChange:b=>{let d=String(b.target.value||"").trim(),e={...f,...d?{agentId:d}:{}};d||delete e.agentId,aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:e}:a)})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 px-2 py-1 text-xs text-[color:var(--ck-text-primary)]",placeholder:"(drag an agent onto the node or type)"})]}),"human_approval"===c.type?(0,b.jsxs)("div",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/20 p-2",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"approval config"}),(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:String(f.provider??""),onChange:b=>{let d=String(b.target.value||"").trim(),e={...f,...d?{provider:d}:{}};d||delete e.provider,aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:e}:a)})},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:String(f.target??""),onChange:b=>{let d=String(b.target.value||"").trim(),e={...f,...d?{target:d}:{}};d||delete e.target,aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:e}:a)})},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:"Overrides workflow-level default when set."})]}),(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"messageTemplate (optional)"}),(0,b.jsx)("textarea",{value:String(f.messageTemplate??""),onChange:b=>{let d=String(b.target.value||""),e={...f,...d.trim()?{messageTemplate:d}:{}};d.trim()||delete e.messageTemplate,aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:e}:a)})},className:"mt-1 h-[70px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 font-mono text-[10px] text-[color:var(--ck-text-primary)]",placeholder:"Approval needed for {{workflowName}} (run {{runId}})",spellCheck:!1}),(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:["Vars: ","{{workflowName}}",", ","{{workflowId}}",", ","{{runId}}",", ","{{nodeId}}"]})]})]})]}):null,(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[10px] uppercase tracking-wide text-[color:var(--ck-text-tertiary)]",children:"config (json)"}),(0,b.jsx)("textarea",{value:JSON.stringify(f,null,2),onChange:b=>{try{let d=JSON.parse(b.target.value);if(!d||"object"!=typeof d||Array.isArray(d))return;aI({...a,nodes:a.nodes.map(a=>a.id===c.id?{...a,config:d}:a)})}catch{}},className:"mt-1 h-[140px] w-full resize-none rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/30 p-2 font-mono text-[10px] text-[color:var(--ck-text-primary)]",spellCheck:!1}),(0,b.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"(Edits apply when JSON is valid.)"})]})]})]})})()]})]})}),(0,b.jsx)("div",{className:"w-[380px] shrink-0 overflow-auto p-3 text-sm",children:(0,b.jsx)("div",{className:"space-y-3",children:aF.wf?(l=String((k=aF.wf).timezone??"").trim()||"UTC",m=k.triggers??[],o=String((n=k.meta&&"object"==typeof k.meta&&!Array.isArray(k.meta)?k.meta:{}).approvalBindingId??"").trim(),p=String(n.approvalProvider??"telegram").trim()||"telegram",q=String(n.approvalTarget??"").trim(),r=[{label:"(no preset)",expr:""},{label:"Weekdays 09:00 local",expr:"0 9 * * 1-5"},{label:"Mon/Wed/Fri 09:00 local",expr:"0 9 * * 1,3,5"},{label:"Daily 08:00 local",expr:"0 8 * * *"},{label:"Daily 12:00 local",expr:"0 12 * * *"},{label:"Mon 09:30 local",expr:"30 9 * * 1"}],(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Workflow"}),(0,b.jsx)("div",{className:"px-3 pb-3",children:(0,b.jsxs)("label",{className:"block",children:[(0,b.jsx)("div",{className:"text-[11px] font-medium text-[color:var(--ck-text-tertiary)]",children:"Timezone"}),(0,b.jsx)("input",{value:l,onChange:a=>{let b=String(a.target.value||"").trim()||"UTC";aI({...k,timezone:b})},className:"mt-1 w-full rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 px-2 py-1 text-sm text-[color:var(--ck-text-primary)]",placeholder:"America/New_York"})]})})]}),(0,b.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Approval Channel"}),(0,b.jsxs)("div",{className:"px-3 pb-3 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:"binding (recommended)"}),(0,b.jsxs)("select",{value:o,onChange:a=>{let b=String(a.target.value||"").trim(),c=T.find(a=>a.id===b);c?aI({...k,meta:{...n,approvalBindingId:c.id,approvalProvider:c.channel,approvalTarget:c.target},nodes:k.nodes.map(a=>"human_approval"===a.type?{...a,config:{...a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},approvalBindingId:c.id,provider:c.channel,target:c.target}}:a)}):aI({...k,meta:{...n,approvalBindingId:""},nodes:k.nodes.map(a=>"human_approval"===a.type?{...a,config:{...a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},approvalBindingId:""}}:a)})},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:"(manual)"}),T.map(a=>(0,b.jsx)("option",{value:a.id,children:a.label},a.id))]}),X?(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-yellow-200",children:["Kitchen looks out of date. Run ",(0,b.jsx)("code",{className:"font-mono",children:"openclaw plugins update"})," then",(0,b.jsx)("code",{className:"ml-1 font-mono",children:"openclaw gateway restart"}),"."]}):null,V?(0,b.jsxs)("div",{className:"mt-1 text-[10px] text-red-200",children:["Failed to load bindings: ",V]}):null,(0,b.jsx)("div",{className:"mt-1 text-[10px] text-[color:var(--ck-text-tertiary)]",children:"Uses your existing OpenClaw bindings (recommended). Manual provider/target is an advanced override."})]}),(0,b.jsxs)("details",{className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-2 py-1 text-[11px] font-medium text-[color:var(--ck-text-secondary)]",children:"Advanced: manual override"}),(0,b.jsxs)("div",{className:"px-2 pb-2 pt-1 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:p,onChange:a=>{let b=String(a.target.value||"").trim()||"telegram";aI({...k,meta:{...n,approvalBindingId:"",approvalProvider:b},nodes:k.nodes.map(a=>"human_approval"===a.type?{...a,config:{...a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},approvalBindingId:"",provider:b}}:a)})},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:q,onChange:a=>{let b=String(a.target.value||"").trim();aI({...k,meta:{...n,approvalBindingId:"",approvalTarget:b},nodes:k.nodes.map(a=>"human_approval"===a.type?{...a,config:{...a.config&&"object"==typeof a.config&&!Array.isArray(a.config)?a.config:{},approvalBindingId:"",target:b}}:a)})},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.jsxs)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Triggers"}),(0,b.jsxs)("div",{className:"px-3 pb-3",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()}`;aI({...k,triggers:[...m,{kind:"cron",id:a,name:"New trigger",enabled:!0,expr:"0 9 * * 1-5",tz:l}]})},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),n=!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:()=>aI({...k,triggers:m.filter((a,b)=>b!==c)}),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;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,enabled:b}:a)})}}),"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;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,name:b}:a)})},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;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,expr:b}:a)})},className:n?"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"}),n?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:r.some(a=>a.expr===h)?h:"",onChange:a=>{let b=a.target.value;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,expr:b}:a)})},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:r.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;aI({...k,triggers:m.map((a,d)=>d===c&&"cron"===a.kind?{...a,tz:b}:a)})},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)("details",{open:!0,className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/15",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Runs"}),(0,b.jsxs)("div",{className:"px-3 pb-3",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsx)("div",{className:"text-xs font-medium text-[color:var(--ck-text-secondary)]",children:"Runs (history)"}),(0,b.jsx)(d.default,{href:`/teams/${encodeURIComponent(a)}/runs`,className:"text-[10px] font-medium text-[color:var(--ck-text-tertiary)] hover:text-[color:var(--ck-text-secondary)] hover:underline",children:"View all →"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("button",{type:"button",disabled:v,onClick:async()=>{let b=String(k.id??"").trim();if(b){ab(""),_(!0);try{let c=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:b,mode:"enqueue"})}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to enqueue 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);Z(g)}catch(a){ab(a instanceof Error?a.message:String(a))}finally{_(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10 disabled:opacity-50",children:"+ Queue run"}),(0,b.jsx)("button",{type:"button",disabled:v||ae||!aH.ok,onClick:async()=>{let b=String(k.id??"").trim();if(b){if(aH.missingAgentOnNodeIds.length)return void ab("All nodes must be assigned to an agent.");if(aH.agentIdsMissingCron.length){an(!0),ap("");try{let b=await fetch("/api/cron/worker",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"reconcile",teamId:a})}),c=await b.json();if(!b.ok||!1===c.ok)throw Error(c.error||"Failed to reconcile worker crons");let d=await aE(),e=aH.requiredAgentIds.filter(a=>!d[a]);if(e.length)return void ab(`Cron not set up for: ${e.join(", ")}`)}catch(a){ab(a instanceof Error?a.message:String(a));return}finally{an(!1)}}ab(""),_(!0);try{let c=await fetch("/api/teams/workflow-runs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:a,workflowId:b,mode:"run_now"})}),d=await c.json();if(!c.ok||!d.ok)throw Error(d.error||"Failed to create 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);Z(g)}catch(a){ab(a instanceof Error?a.message:String(a))}finally{_(!1)}}},className:"rounded-[var(--ck-radius-sm)] border border-emerald-400/30 bg-emerald-500/10 px-2 py-1 text-[10px] font-medium text-emerald-50 hover:bg-emerald-500/15 disabled:opacity-50",title:"Enqueue a run for the workflow runner (Kitchen does not execute nodes)",children:"+ Run now"}),ag?(0,b.jsx)("div",{className:"ml-2 text-[10px] text-amber-100/90",title:ag,children:"Cron check unavailable"}):null]})]}),aH.missingAgentOnNodeIds.length?(0,b.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-red-400/30 bg-red-500/10 p-2 text-xs text-red-100",children:["All nodes must be assigned to an agent. Missing agentId on: ",aH.missingAgentOnNodeIds.join(", ")]}):aH.agentIdsMissingCron.length?(0,b.jsxs)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-amber-400/30 bg-amber-500/10 p-2 text-xs text-amber-50",children:[(0,b.jsxs)("div",{children:["Cron not set up for: ",aH.agentIdsMissingCron.join(", ")]}),(0,b.jsxs)("div",{className:"mt-2 flex items-center gap-2",children:[(0,b.jsx)("button",{type:"button",onClick:()=>{ap(""),al(!0)},className:"rounded-[var(--ck-radius-sm)] border border-amber-300/30 bg-amber-500/10 px-2 py-1 text-[10px] font-medium text-amber-50 hover:bg-amber-500/15",children:"Install worker cron(s)"}),(0,b.jsx)("button",{type:"button",onClick:()=>void aE(),className:"rounded-[var(--ck-radius-sm)] border border-white/10 bg-white/5 px-2 py-1 text-[10px] font-medium text-[color:var(--ck-text-primary)] hover:bg-white/10",children:"Re-check"})]})]}):null,(0,b.jsx)(e.ConfirmationModal,{open:ak,title:"Install worker cron jobs?",busy:am,error:ao||void 0,confirmLabel:"Install",onClose:()=>{am||al(!1)},onConfirm:async()=>{an(!0),ap("");try{let b=await fetch("/api/cron/worker",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"reconcile",teamId:a})}),c=await b.json();if(!b.ok||!1===c.ok)throw Error(c.error||"Failed to install worker crons");await aE(),al(!1)}catch(a){ap(a instanceof Error?a.message:String(a))}finally{an(!1)}},children:(0,b.jsxs)("div",{className:"text-sm text-[color:var(--ck-text-secondary)]",children:["Kitchen will install (or enable) worker cron jobs for the following agents so this workflow can drain:",(0,b.jsx)("div",{className:"mt-2 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/25 p-2 font-mono text-[11px] text-[color:var(--ck-text-primary)]",children:aH.agentIdsMissingCron.join(", ")}),(0,b.jsxs)("div",{className:"mt-2 text-xs text-[color:var(--ck-text-tertiary)]",children:["Cron cadence: every 5 minutes. The worker runs: ",(0,b.jsx)("span",{className:"font-mono",children:"openclaw recipes workflows worker-tick"}),"."]})]})}),aa?(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:aa}):null,(0,b.jsx)("div",{className:"mt-2 space-y-1",children:$?(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"Loading runs…"}):Y.length?Y.slice(0,8).map(c=>{let e=String(k.id??"").trim(),f=String(c).replace(/\.run\.json$/i,""),g=ac===f,h=e?`/teams/${encodeURIComponent(a)}/runs/${encodeURIComponent(e)}/${encodeURIComponent(f)}`:"#";return(0,b.jsx)(d.default,{href:h,onClick:()=>ad(f),className:g?"block w-full rounded-[var(--ck-radius-sm)] bg-white/10 px-2 py-1 text-left text-[11px] font-mono text-[color:var(--ck-text-primary)]":"block w-full rounded-[var(--ck-radius-sm)] px-2 py-1 text-left text-[11px] font-mono text-[color:var(--ck-text-secondary)] hover:bg-white/5",title:"Open run detail",children:f},c)}):(0,b.jsx)("div",{className:"text-xs text-[color:var(--ck-text-secondary)]",children:"No runs yet."})}),(0,b.jsxs)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Nodes"}),(0,b.jsxs)("div",{className:"px-3 pb-3",children:[(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:aq,onChange:a=>ar(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.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:as,onChange:a=>at(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:au,onChange:a=>av(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(aq||"").trim().replace(/[^a-z0-9_\-]/gi,"_");if(!a||k.nodes.some(b=>b.id===a))return;let b=k.nodes.reduce((a,b)=>"number"==typeof b.x?Math.max(a,b.x):a,80),c={id:a,type:au,name:String(as||"").trim()||a,x:b+220,y:80};aI({...k,nodes:[...k.nodes,c]}),I(a),ar(""),at("")},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:k.nodes.map(a=>{let c=H===a.id;return(0,b.jsxs)("button",{type:"button",onClick:()=>I(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)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Edges"}),(0,b.jsxs)("div",{className:"px-3 pb-3",children:[(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:aw,onChange:a=>ax(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)"}),k.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:ay,onChange:a=>az(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)"}),k.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:aA,onChange:a=>aB(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(aw||"").trim(),b=String(ay||"").trim();if(!a||!b||a===b)return;let c={id:`e${Date.now()}`,from:a,to:b,...String(aA||"").trim()?{label:String(aA).trim()}:{}};aI({...k,edges:[...k.edges??[],c]}),aB("")},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:(k.edges??[]).length?(k.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:()=>aI({...k,edges:(k.edges??[]).filter(b=>b.id!==a.id)}),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)("details",{open:!0,className:"mt-3 rounded-[var(--ck-radius-sm)] border border-white/10 bg-black/10",children:[(0,b.jsx)("summary",{className:"cursor-pointer list-none px-3 py-2 text-sm font-medium text-[color:var(--ck-text-primary)]",children:"Node inspector"}),(0,b.jsxs)("div",{className:"px-3 pb-3",children:[(0,b.jsx)("div",{className:"flex items-center justify-between gap-2",children:H?(0,b.jsx)("button",{type:"button",onClick:()=>{let a=k.nodes.filter(a=>a.id!==H),b=(k.edges??[]).filter(a=>a.from!==H&&a.to!==H);aI({...k,nodes:a,edges:b}),I("")},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}),H?(s=k.nodes.find(a=>a.id===H))?(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:s.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(s.name??""),onChange:a=>{let b=a.target.value;aI({...k,nodes:k.nodes.map(a=>a.id===s.id?{...a,name:b}:a)})},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:s.type,onChange:a=>{let b=a.target.value;aI({...k,nodes:k.nodes.map(a=>a.id===s.id?{...a,type:b}:a)})},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 s.x?s.x:0,onChange:a=>{let b=Number(a.target.value);aI({...k,nodes:k.nodes.map(a=>a.id===s.id?{...a,x:b}:a)})},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 s.y?s.y:0,onChange:a=>{let b=Number(a.target.value);aI({...k,nodes:k.nodes.map(a=>a.id===s.id?{...a,y:b}:a)})},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(s.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."})]})]})]})]})]})):null})})]})]})}a.s(["default",()=>h],13833)}];
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=b1a17_app_teams_%5BteamId%5D_workflows_%5BworkflowId%5D_workflows-editor-client_tsx_5e714aa2._.js.map
|