@fieldwangai/agentflow 0.1.79 → 0.1.80
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/bin/lib/ui-server.mjs
CHANGED
|
@@ -2029,6 +2029,17 @@ function displayShareOutputUrl(shareId, baseUrl = "") {
|
|
|
2029
2029
|
}
|
|
2030
2030
|
}
|
|
2031
2031
|
|
|
2032
|
+
function requestPublicBaseUrl(req) {
|
|
2033
|
+
const origin = String(req?.headers?.origin || "").trim();
|
|
2034
|
+
if (/^https?:\/\//i.test(origin)) return origin;
|
|
2035
|
+
const forwardedHost = String(req?.headers?.["x-forwarded-host"] || "").split(",")[0].trim();
|
|
2036
|
+
const host = forwardedHost || String(req?.headers?.host || "").trim();
|
|
2037
|
+
if (!host) return "";
|
|
2038
|
+
const forwardedProto = String(req?.headers?.["x-forwarded-proto"] || "").split(",")[0].trim();
|
|
2039
|
+
const proto = /^https?$/i.test(forwardedProto) ? forwardedProto.toLowerCase() : "http";
|
|
2040
|
+
return `${proto}://${host}`;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2032
2043
|
function normalizeRunEnvKey(key) {
|
|
2033
2044
|
const text = String(key || "").trim();
|
|
2034
2045
|
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(text) ? text : "";
|
|
@@ -5074,6 +5085,8 @@ async function runWorkspaceGraph(root, scopedRoot, payload, userCtx = {}, opts =
|
|
|
5074
5085
|
env.AGENTFLOW_PUBLIC_BASE_URL ||
|
|
5075
5086
|
env.AGENTFLOW_BASE_URL ||
|
|
5076
5087
|
env.PUBLIC_BASE_URL ||
|
|
5088
|
+
payload.requestBaseUrl ||
|
|
5089
|
+
payload.requestOrigin ||
|
|
5077
5090
|
"";
|
|
5078
5091
|
|
|
5079
5092
|
const graphPath = workspaceGraphPath(scopedRoot);
|
|
@@ -6787,6 +6800,7 @@ export function startUiServer({
|
|
|
6787
6800
|
};
|
|
6788
6801
|
if (wantsStream) {
|
|
6789
6802
|
const graphPath = workspaceGraphPath(scoped.root);
|
|
6803
|
+
const runPayload = { ...payload, requestBaseUrl: requestPublicBaseUrl(req) };
|
|
6790
6804
|
res.writeHead(200, {
|
|
6791
6805
|
"Content-Type": "application/x-ndjson; charset=utf-8",
|
|
6792
6806
|
"Cache-Control": "no-cache",
|
|
@@ -6796,7 +6810,7 @@ export function startUiServer({
|
|
|
6796
6810
|
try { res.write(JSON.stringify(event) + "\n"); } catch (_) {}
|
|
6797
6811
|
};
|
|
6798
6812
|
try {
|
|
6799
|
-
const result = await runWorkspaceGraph(root, scoped.root,
|
|
6813
|
+
const result = await runWorkspaceGraph(root, scoped.root, runPayload, userCtx, {
|
|
6800
6814
|
onEvent: writeEvent,
|
|
6801
6815
|
signal: controller.signal,
|
|
6802
6816
|
onActiveChild: setActiveChild,
|
|
@@ -6835,7 +6849,7 @@ export function startUiServer({
|
|
|
6835
6849
|
return;
|
|
6836
6850
|
}
|
|
6837
6851
|
try {
|
|
6838
|
-
const result = await runWorkspaceGraph(root, scoped.root, payload, userCtx, {
|
|
6852
|
+
const result = await runWorkspaceGraph(root, scoped.root, { ...payload, requestBaseUrl: requestPublicBaseUrl(req) }, userCtx, {
|
|
6839
6853
|
signal: controller.signal,
|
|
6840
6854
|
onActiveChild: setActiveChild,
|
|
6841
6855
|
});
|
|
@@ -9,22 +9,22 @@ input:
|
|
|
9
9
|
- type: text
|
|
10
10
|
name: title
|
|
11
11
|
default: ""
|
|
12
|
-
description: "
|
|
12
|
+
description: "可选。分享页标题;只影响打开分享页后的页面标题,不影响输出 URL。为空时使用 AgentFlow Display。"
|
|
13
13
|
showOnNode: true
|
|
14
14
|
- type: text
|
|
15
15
|
name: layout
|
|
16
16
|
default: "single"
|
|
17
|
-
description: "
|
|
18
|
-
showOnNode:
|
|
17
|
+
description: "可选。分享页布局:single、gallery、slides、document、canvas。通常保持默认 single。"
|
|
18
|
+
showOnNode: false
|
|
19
19
|
- type: text
|
|
20
20
|
name: nodeIds
|
|
21
21
|
default: ""
|
|
22
|
-
description: "可选。逗号或空格分隔的 Display 节点 ID
|
|
22
|
+
description: "可选。逗号或空格分隔的 Display 节点 ID;为空时自动分享连接到本节点的上游 Display 节点。"
|
|
23
23
|
showOnNode: false
|
|
24
24
|
- type: text
|
|
25
25
|
name: baseUrl
|
|
26
26
|
default: ""
|
|
27
|
-
description: "
|
|
27
|
+
description: "可选。分享站点地址,例如 https://agentflow.example.com;为空时优先使用环境变量,其次使用当前访问地址。"
|
|
28
28
|
showOnNode: false
|
|
29
29
|
output:
|
|
30
30
|
- type: node
|
|
@@ -43,4 +43,4 @@ output:
|
|
|
43
43
|
default: ""
|
|
44
44
|
showOnNode: false
|
|
45
45
|
---
|
|
46
|
-
Create a share link for connected Display nodes.
|
|
46
|
+
Create a share link for connected Display nodes. Connect a Display node to this node, optionally set title, and use the url output.
|
|
@@ -125,7 +125,7 @@ script: node -e "console.log('TODO: scripts/x.mjs')"
|
|
|
125
125
|
|
|
126
126
|
`).trimEnd()}function xw(e){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function u7(e){const t=String(e||"");let n="",r=0;Vg.lastIndex=0;let s;for(;s=Vg.exec(t);)n+=xw(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${xw(s[0])}</span>`,r=s.index+s[0].length;return n+=xw(t.slice(r)),n||" "}function d7(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,o=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(c,2),8);return Math.ceil(d*r+s+o+a+l)}function jR({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:d}){var Sr,fr;const{t:p}=Fn(),u=(e==null?void 0:e.inputs)??[],f=(e==null?void 0:e.outputs)??[],m=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=o7(e),w=(e==null?void 0:e.isRunMode)??!1,k=!!(e!=null&&e.readOnly),y=(e==null?void 0:e.isExecuting)??!1,b=(e==null?void 0:e.isDim)??!1,x=(e==null?void 0:e.nodeStatus)??null,j=(e==null?void 0:e.nodeElapsed)??null,E=(e==null?void 0:e.definitionId)||"",N=E.startsWith("provide_"),T=E==="provide_bool",O=E==="provide_str",z=E==="provide_file",K=E==="provide_password",B=E==="agent_subAgent",$=E==="control_agent_toBool",D=(B||$)&&!w,R=T?a7(f[0]):!1,M=N?String(((Sr=f[0])==null?void 0:Sr.value)??((fr=f[0])==null?void 0:fr.default)??(e==null?void 0:e.body)??""):"",I=String((e==null?void 0:e.body)||""),F=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||p("flow:node.fallbackLabel"),P=!N&&!D&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",L=zs(e==null?void 0:e.images),_=T||O||z||K||D||!!P,Q=h.useRef(!1),Z=h.useRef(!1),V=h.useRef(null),oe=h.useRef(null),ue=h.useRef(null),[ye,ke]=h.useState(M),[ce,_e]=h.useState(!1),[ae,de]=h.useState(I),[be,je]=h.useState(!1);h.useEffect(()=>{Q.current||ke(M)},[n,M]),h.useEffect(()=>{Z.current||de(I)},[n,I]),h.useEffect(()=>{const ve=oe.current;if(!ve)return;const Fe=d7(ve,ae);ve.style.minHeight=`${Fe}px`,ve.style.height="",ue.current&&(ue.current.style.minHeight=`${Fe}px`,ue.current.style.height="")},[ae]),h.useEffect(()=>{const ve=V.current,Fe=e==null?void 0:e.onNodeContentResize;if(!D||!ve||!Fe||typeof ResizeObserver>"u")return;let Qt=0;const ln=()=>{window.cancelAnimationFrame(Qt),Qt=window.requestAnimationFrame(()=>Fe(n))},Hn=new ResizeObserver(ln);return Hn.observe(ve),ln(),()=>{window.cancelAnimationFrame(Qt),Hn.disconnect()}},[e==null?void 0:e.onNodeContentResize,D,n]);const Ue=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],rt=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],qe=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],De=((e==null?void 0:e.model)??"").trim(),Bt=m==="agent"&&!E.startsWith("tool_nodejs"),Ye=new Set(Ue.map(la)),St=new Set(rt.map(la)),zn=new Set(qe.map(la)),We=De?De.startsWith("cursor:")||De.startsWith("opencode:")||De.startsWith("claude-code:")?De:zn.has(De)?`claude-code:${De}`:St.has(De)?`opencode:${De}`:Ye.has(De)?`cursor:${De}`:De:"",fn=De&&!We.startsWith("cursor:")&&!We.startsWith("opencode:")&&!We.startsWith("claude-code:")&&!Ye.has(De)&&!St.has(De)&&!zn.has(De),kn=De.startsWith("cursor:")?De.slice(7):De.startsWith("opencode:")?De.slice(9):De.startsWith("claude-code:")?De.slice(12):De,Nn=ve=>{if(k)return;const Fe=ve.target.value;d&&d(n,Fe)},fe=ve=>{ve.stopPropagation(),!k&&r&&r(n)},Ae=ve=>{ve.stopPropagation(),s&&s()},Ve=ve=>{ve.stopPropagation(),!k&&(o==null||o(n,ve.target.value==="true"?"true":"false"))},at=ve=>{if(ve.stopPropagation(),k)return;const Fe=ve.target.value;ke(Fe),Q.current||o==null||o(n,Fe)},it=ve=>{ve.stopPropagation(),Q.current=!0},Tt=ve=>{if(ve.stopPropagation(),k)return;Q.current=!1;const Fe=ve.currentTarget.value;ke(Fe),o==null||o(n,Fe)},ft=()=>{k||o==null||o(n,ye)},wn=ve=>{if(ve.stopPropagation(),k)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,ye);return}const Fe=window.prompt("文件路径",ye);Fe!=null&&(ke(Fe),o==null||o(n,Fe))},an=ve=>{ve.stopPropagation(),_e(Fe=>!Fe)},In=ve=>{if(de(ve),a==null||a(n,ve),l){const Fe=HU(L,ve);(Fe.length!==L.length||Fe.some((Qt,ln)=>{var Hn;return Qt.id!==((Hn=L[ln])==null?void 0:Hn.id)}))&&l(n,Fe)}},pn=ve=>{if(ve.stopPropagation(),k)return;const Fe=ve.target.value;Z.current?de(Fe):In(Fe)},Xn=ve=>{ve.stopPropagation(),!k&&(Z.current=!0,je(!0))},Jn=ve=>{if(ve.stopPropagation(),k)return;Z.current=!1,je(!1);const Fe=ve.currentTarget.value;In(Fe)},Ir=()=>{k||(Z.current=!1,je(!1),In(ae))},mr=async ve=>{if(k)return;const Fe=await wR({files:ve,body:ae,images:L});Fe&&(de(Fe.body),a==null||a(n,Fe.body),l==null||l(n,Fe.images))},gr=(ve,Fe)=>{if(ve.stopPropagation(),k)return;const Qt=L.filter(Hn=>Hn.id!==Fe.id),ln=c7(ae,Fe.label);de(ln),a==null||a(n,ln),l==null||l(n,Qt)},Yt=ve=>{if(k)return;const Fe=xR(ve);Fe.length!==0&&(ve.preventDefault(),ve.stopPropagation(),mr(Fe).catch(()=>{}))},Wt=ve=>{if(k)return;const Fe=Kg(ve);Fe.length!==0&&(ve.preventDefault(),ve.stopPropagation(),mr(Fe).catch(()=>{}))},dr=()=>{const ve=oe.current,Fe=ue.current;!ve||!Fe||(Fe.scrollTop=ve.scrollTop,Fe.scrollLeft=ve.scrollLeft)};return i.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(y?" af-flow-node--executing":"")+(x==="success"?" af-flow-node--done":"")+(x==="failed"?" af-flow-node--failed":"")+(x==="running"&&!y?" af-flow-node--running-disk":"")+(b?" af-flow-node--dim":"")+(D?" af-flow-node--inline-body-editor":"")+(O?" af-flow-node--provide-text":"")+(K?" af-flow-node--provide-password":"")+" af-flow-node--"+m.replace(/[^a-z0-9_-]/g,""),"data-schema":m,children:[i.jsxs("div",{className:"af-flow-node__chrome",children:[i.jsx("span",{className:"af-flow-node__title af-flow-node__title--chrome",title:`${F}${n?` (${n})`:""}${g?` · ${g}`:""}`,children:F}),!w&&Bt&&i.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Cr,onMouseDown:Cr,onClick:Cr,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:We,onChange:Nn,onPointerDown:Cr,onMouseDown:Cr,onClick:Cr,"aria-label":p("flow:node.model"),title:kn||p("flow:node.defaultModel"),disabled:k,children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),fn&&i.jsx("option",{value:De,children:De}),Ue.length>0&&i.jsx("optgroup",{label:"Cursor",children:Ue.map(ve=>i.jsx("option",{value:`cursor:${la(ve)}`,children:la(ve)},`c-${ve}`))}),rt.length>0&&i.jsx("optgroup",{label:"OpenCode",children:rt.map(ve=>i.jsx("option",{value:`opencode:${la(ve)}`,children:la(ve)},`o-${ve}`))}),qe.length>0&&i.jsx("optgroup",{label:"Claude Code",children:qe.map(ve=>i.jsx("option",{value:`claude-code:${la(ve)}`,children:la(ve)},`cc-${ve}`))})]}),i.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),y&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),x==="running"&&!y&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:p("flow:node.diskRunning"),children:"RUNNING"}),x==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:j!=null&&String(j).trim()!==""?j:"--"}),x==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!w&&N&&!T&&!O&&!z&&!K&&i.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:Ae,"aria-label":p("flow:node.expandProvide"),title:p("flow:node.expandProvide"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!w&&i.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:k,onClick:fe,"aria-label":p("flow:node.deleteNode"),title:p("flow:node.deleteNode"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-flow-node__body",children:[i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:u.map((ve,Fe)=>{if(ve.showOnNode===!1)return null;const Qt=p("flow:node.inputTooltip",{name:ve.name||`#${Fe}`,type:ve.type})+(ve.default!=null&&ve.default!==""?p("flow:node.defaultSuffix",{value:ve.default}):""),ln=ve.name||`#${Fe+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:Qt,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[ln,ve.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(ms,{type:"target",position:Ze.Left,id:`input-${Fe}`,className:"af-flow-node__handle",style:{background:Un(ve.type)},title:Qt})]},`in-${Fe}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[T?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(R?" af-flow-node__bool-select--true":""),value:R?"true":"false",onChange:Ve,onPointerDown:Cr,onMouseDown:Cr,onClick:Cr,"aria-label":"Boolean value",title:R?"true":"false",disabled:k,children:[i.jsx("option",{value:"false",children:"false"}),i.jsx("option",{value:"true",children:"true"})]}):O?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ye,onChange:at,onCompositionStart:it,onCompositionEnd:Tt,onBlur:ft,onPointerDown:Cr,onMouseDown:Cr,onClick:Cr,placeholder:"输入文本",rows:2,readOnly:k}):z?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Cr,onMouseDown:Cr,onClick:Cr,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:ye,onChange:at,onCompositionStart:it,onCompositionEnd:Tt,onBlur:ft,placeholder:"选择或输入文件路径",title:ye||"选择或输入文件路径",readOnly:k}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:k,onClick:wn,"aria-label":"选择文件",title:"选择文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):K?i.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:Cr,onMouseDown:Cr,onClick:Cr,children:[i.jsx("input",{className:"af-flow-node__password-input nodrag",type:ce?"text":"password",value:ye,onChange:at,onCompositionStart:it,onCompositionEnd:Tt,onBlur:ft,placeholder:"输入密码或密钥",title:ce?ye:"密码已隐藏",autoComplete:"off",readOnly:k}),i.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:k,onClick:an,"aria-label":ce?"隐藏密码":"预览密码",title:ce?"隐藏密码":"预览密码",children:i.jsx("span",{className:"material-symbols-outlined",children:ce?"visibility_off":"visibility"})})]}):D?i.jsxs("div",{ref:V,className:"af-flow-node__prompt-stack nodrag"+(be?" af-flow-node__prompt-stack--composing":""),children:[i.jsx("pre",{ref:ue,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:u7(ae)+`
|
|
127
127
|
`}}),i.jsx("textarea",{ref:oe,className:"af-flow-node__prompt-editor nodrag",value:ae,onChange:pn,onCompositionStart:Xn,onCompositionEnd:Jn,onBlur:Ir,onPaste:Yt,onDrop:Wt,onScroll:dr,onDragOver:ve=>{Kg(ve).length>0&&ve.preventDefault()},placeholder:$?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:k})]}):null,D&&L.length>0?i.jsx("div",{className:"af-flow-node__image-chips",children:L.map((ve,Fe)=>i.jsxs("span",{className:"af-flow-node__image-chip",title:ve.name,children:[i.jsx("img",{src:ve.dataUrl,alt:""}),i.jsxs("span",{children:["[",ve.label||`image ${Fe+1}`,"]"]}),i.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:k,onClick:Qt=>gr(Qt,ve),onPointerDown:Cr,onMouseDown:Cr,"aria-label":`删除 ${ve.label||`image ${Fe+1}`}`,title:"删除图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ve.id||Fe))}):null,P?i.jsx("span",{className:"af-flow-node__prompt-preview",title:P,children:P}):null,_?null:i.jsx("span",{className:"af-flow-node__body-title",title:F,children:F})]}),i.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:f.map((ve,Fe)=>{if(ve.showOnNode===!1)return null;const Qt=p("flow:node.outputTooltip",{name:ve.name||`#${Fe}`,type:ve.type})+(ve.default!=null&&ve.default!==""?p("flow:node.defaultSuffix",{value:ve.default}):""),ln=ve.name||`#${Fe+1}`;return i.jsxs("div",{className:"af-flow-node__port-row",title:Qt,children:[i.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[ln,ve.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(ms,{type:"source",position:Ze.Right,id:`output-${Fe}`,className:"af-flow-node__handle",style:{background:Un(ve.type)},title:Qt})]},`out-${Fe}`)})})]})]})}const zc="flowNode";function CR(e){if(!e||!(e instanceof Element))return!1;if(e.closest('[contenteditable="true"]'))return!0;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable)}function qg(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function f7(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function ER({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=Fn(),a=h.useId(),l=h.useRef(null),[c,d]=h.useState(""),[p,u]=h.useState(!1),[f,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),m(""),u(!1);const y=requestAnimationFrame(()=>{var b;return(b=l.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),w=g===n;async function k(y){if(y.preventDefault(),!(!w||p)){u(!0),m("");try{const b=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),x=await b.json().catch(()=>({}));if(!b.ok){m(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}s()}catch(b){m(String((b==null?void 0:b.message)||b))}finally{u(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:i.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:k,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!w})]}),f?i.jsx("p",{className:"af-err af-new-pipeline-err",children:f}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!w||p,children:o(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function P1({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:o=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:c,onConfirm:d,onCancel:p}){const{t:u}=Fn(),f=h.useId(),m=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var x;return(x=m.current)==null?void 0:x.focus()});function b(x){x.key==="Escape"&&p(),x.key==="Enter"&&d()}return window.addEventListener("keydown",b),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",b)}},[e,p,d]),!e)return null;const g=r??u("common:common.confirm","确定"),w=s??u("common:common.cancel","取消"),k=t??u("common:common.confirmTitle","请确认");return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&p()},children:i.jsxs("div",{ref:m,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:k}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:p,"aria-label":w,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[i.jsx("p",{className:"af-new-pipeline-lead",children:n}),i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:p,children:w}),a&&c?i.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:c,children:a}):null,i.jsx("button",{type:"button",className:o?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function _R({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:o}){const{t:a}=Fn(),l=h.useId(),c=h.useRef(null),[d,p]=h.useState(""),[u,f]=h.useState(!1),[m,g]=h.useState("");if(h.useEffect(()=>{if(!e)return;p(""),g(""),f(!1);const b=requestAnimationFrame(()=>{var x;return(x=c.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(b)},[e,n]),!e)return null;const w=d.trim(),k=w===n;async function y(b){if(b.preventDefault(),!k||u)return;f(!0),g("");let x=null;try{const j=new AbortController;x=setTimeout(()=>j.abort(),15e3);const E=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:w,flowArchived:s}),signal:j.signal}),N=await E.json().catch(()=>({}));if(!E.ok){g(typeof N.error=="string"?N.error:a("project:deleteModal.deleteFailed"));return}try{for(let T=localStorage.length-1;T>=0;T--){const O=localStorage.key(T);O&&(O.startsWith(`af:composer-sessions:${n}:${r}`)||O.startsWith(`af:composer-active-session:${n}:${r}`)||O.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(O)}}catch{}await o()}catch(j){if((j==null?void 0:j.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((j==null?void 0:j.message)||j))}finally{x&&clearTimeout(x),f(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:b=>{b.target===b.currentTarget&&t()},children:i.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:b=>b.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:b=>p(b.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":w.length>0&&!k})]}),m?i.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:u,children:a("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||u,children:a(u?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function p7({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Xi({keys:e}){return i.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>i.jsxs("span",{children:[n>0?i.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,i.jsx(p7,{children:t})]},n))})}function AR({open:e,onClose:t}){const{t:n}=Fn(),r=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const o=f7()?"⌘":"Ctrl";return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:i.jsxs("div",{ref:r,className:"af-shortcuts-panel",role:"dialog","aria-modal":"true","aria-labelledby":"af-shortcuts-title",tabIndex:-1,onMouseDown:a=>a.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-shortcuts-panel__body",children:[i.jsxs("section",{className:"af-shortcuts-section",children:[i.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),i.jsxs("ul",{className:"af-shortcuts-list",children:[i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),i.jsx(Xi,{keys:[o,"S"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),i.jsx(Xi,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Xi,{keys:[o,"K"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),i.jsx(Xi,{keys:["A"]})]})]})]}),i.jsxs("section",{className:"af-shortcuts-section",children:[i.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),i.jsxs("ul",{className:"af-shortcuts-list",children:[i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),i.jsx(Xi,{keys:["V"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),i.jsx(Xi,{keys:["H"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),i.jsx(Xi,{keys:["Space"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),i.jsx(Xi,{keys:["F"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),i.jsx(Xi,{keys:[o,"A"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),i.jsx(Xi,{keys:[o,"Z"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),i.jsx(Xi,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function h7(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),o=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:o.includes(n)?15:0}function PR({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Fn(),[o,a]=h.useState(""),[l,c]=h.useState(0),d=h.useRef(null),p=h.useRef(null);h.useEffect(()=>{if(!e)return;a(""),c(0);const g=requestAnimationFrame(()=>{var w;return(w=d.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(g)},[e]);const u=h.useMemo(()=>{const g=(r||[]).map(y=>{var b,x,j;return{id:y.id,label:((b=y.data)==null?void 0:b.label)||"",definitionId:((x=y.data)==null?void 0:x.definitionId)||"",schemaType:((j=y.data)==null?void 0:j.schemaType)||""}}),w=o.trim(),k=g.map(y=>({e:y,s:h7(y,w)})).filter(y=>y.s>0);return k.sort((y,b)=>b.s-y.s||y.e.id.localeCompare(b.e.id)),k.slice(0,50).map(y=>y.e)},[r,o]);if(h.useEffect(()=>{l>=u.length&&c(0)},[u.length,l]),h.useEffect(()=>{var w;const g=(w=p.current)==null?void 0:w.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const f=g=>{const w=u[g];w&&(n(w.id),t())},m=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),c(w=>Math.min(u.length-1,w+1));return}if(g.key==="ArrowUp"){g.preventDefault(),c(w=>Math.max(0,w-1));return}g.key==="Enter"&&(g.preventDefault(),f(l))};return i.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:i.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-jump-panel__input-wrap",children:[i.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:o,onChange:g=>{a(g.target.value),c(0)},onKeyDown:m,spellCheck:!1,autoComplete:"off"}),i.jsx("span",{className:"af-jump-panel__count",children:u.length})]}),u.length===0?i.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):i.jsx("ul",{ref:p,className:"af-jump-panel__list",role:"listbox",children:u.map((g,w)=>i.jsxs("li",{"data-idx":w,role:"option","aria-selected":w===l,className:"af-jump-panel__item"+(w===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(w),onMouseDown:k=>{k.preventDefault(),f(w)},children:[i.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&i.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&i.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),i.jsxs("div",{className:"af-jump-panel__hint",children:[i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"↑"}),i.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),i.jsxs("span",{children:[i.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function m7({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:o,fileName:a,onSaved:l,onAiEdit:c}){const{t:d}=Fn(),p=h.useId(),u=h.useRef(null),f=h.useRef(null),[m,g]=h.useState(""),[w,k]=h.useState(""),[y,b]=h.useState(!1),[x,j]=h.useState(!1),[E,N]=h.useState(!1),[T,O]=h.useState(""),[z,K]=h.useState("");if(h.useEffect(()=>{if(!e||!o)return;g(""),k(""),O(""),K(""),b(!0),j(!1),N(!1);const I=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:o});(async()=>{try{const P=await fetch(`/api/pipeline-file-content?${I}`),L=await P.json();if(!P.ok)throw new Error(L.error||"HTTP "+P.status);g(L.content||""),k(L.content||"")}catch(P){O(P.message||String(P))}finally{b(!1)}})();const F=requestAnimationFrame(()=>{var P;return(P=u.current)==null?void 0:P.focus()});return()=>cancelAnimationFrame(F)},[e,o,n,r,s]),!e)return null;const B=m!==w;async function $(I){if(I.preventDefault(),!x){j(!0),O(""),K("");try{const F=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:o}),P=await fetch(`/api/pipeline-file-save?${F}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),L=await P.json();if(!P.ok)throw new Error(L.error||"HTTP "+P.status);k(m),K(d("flow:fileEdit.saved")),l&&l()}catch(F){O(F.message||String(F))}finally{j(!1)}}}async function D(){if(!(!c||E||!m)){N(!0),O("");try{const I=await c(m);typeof I=="string"&&I&&g(I)}catch(I){O(I.message||String(I))}finally{N(!1)}}}function R(){g(w),O(""),K("")}const M=m.length>1e5;return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:I=>{I.target===I.currentTarget&&t()},children:i.jsxs("div",{ref:u,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:I=>I.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:a||o}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-file-edit-body",children:y?i.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):T&&!m?i.jsx("div",{className:"af-file-edit-error",children:T}):i.jsxs(i.Fragment,{children:[M&&i.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),i.jsx("textarea",{ref:f,className:"af-file-edit-textarea",value:m,onChange:I=>g(I.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(T||z)&&!y&&i.jsx("div",{className:`af-file-edit-status${z?" af-file-edit-status--success":""}`,children:z||T}),i.jsxs("div",{className:"af-file-edit-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:R,disabled:!B||x||E,children:d("flow:fileEdit.reset")}),c&&i.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:D,disabled:E||x||!m,children:d(E?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),i.jsx("button",{type:"button",className:"af-btn-primary",onClick:$,disabled:!B||x||E,children:d(x?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const IR=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),g7=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function y7(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const s=n.slice(r+2);return s.includes("}")?null:{atIndex:r,query:s}}function x7(e){const t=/\$\{([^}]*)\}/g,n=[];let r;for(;(r=t.exec(e))!==null;)n.push({start:r.index,end:r.index+r[0].length,key:r[1]});return n}function I1(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e){const r=(n==null?void 0:n.name)!=null?String(n.name).trim():"";r&&t.add(r)}return t}function TR(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const s=r.slice(6).trim();return s!==""&&t.has(s)}if(r.startsWith("output.")){const s=r.slice(7).trim();return s!==""&&n.has(s)}if(IR.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const s=`${r}.md`;if(t.has(s)||n.has(s))return!0}return!1}function RR(e){return{inputNames:I1(e==null?void 0:e.inputs),outputNames:I1(e==null?void 0:e.outputs)}}function w7(e,t,n){const r=RR(t),s=x7(e),o=[];for(const a of s)if(!TR(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();o.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return o}function b7(e,t){const n=RR(t),r=/\$\{([^}]*)\}/g,s=[];let o=0,a;for(;(a=r.exec(e))!==null;){a.index>o&&s.push({kind:"plain",text:e.slice(o,a.index)});const l=a[0],c=TR(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),o=a.index+l.length}return o<e.length&&s.push({kind:"plain",text:e.slice(o)}),s}function v7(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function k7(e){return e.map(t=>{const n=v7(t.text);return t.kind==="ph-invalid"?`<span class="af-body-ph-invalid">${n}</span>`:t.kind==="ph-valid"?`<span class="af-body-ph-valid">${n}</span>`:n}).join("")}function S7(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:o?t("flow:placeholder.inputSubtitle",{type:o}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:o?t("flow:placeholder.outputSubtitle",{type:o}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of g7)IR.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function N7(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(o=>String(o).toLowerCase()).some(o=>o.includes(n))):e}function j7(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const o=e.clientWidth;if(o<=0)return null;s.style.width=`${o}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),d=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function dm({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:d}){const{t:p}=Fn(),u=h.useId(),f=h.useRef(null),m=h.useRef(null),[g,w]=h.useState(0),[k,y]=h.useState(0),[b,x]=h.useState(null),j=h.useMemo(()=>zs(c),[c]),E=h.useMemo(()=>w7(e,a,p),[e,a,p]),N=E.length>0,T=h.useMemo(()=>b7(e,a),[e,a]),O=h.useMemo(()=>k7(T),[T]),z=h.useMemo(()=>n?null:y7(e,g),[e,g,n]),K=h.useMemo(()=>{if(!z)return[];const I=S7(a,p);return N7(I,z.query)},[z,a,p]);h.useEffect(()=>{y(I=>{const F=Math.max(0,K.length-1);return Math.min(Math.max(0,I),F)})},[K.length]);const B=h.useCallback(()=>{const I=f.current;if(!I||!z||K.length===0){x(null);return}const F=j7(I,g);if(!F){x(null);return}const P=4,L=44,_=13.5*16,Q=Math.min(K.length*L+8,_);let Z=F.bottom+P;Z+Q>window.innerHeight-8&&(Z=Math.max(8,F.top-Q-P));const V=288;let oe=F.left;oe=Math.max(8,Math.min(oe,window.innerWidth-V-8)),x({top:Z,left:oe})},[z,K.length,g]);h.useLayoutEffect(()=>{if(!z||K.length===0){x(null);return}const I=requestAnimationFrame(()=>B());return()=>cancelAnimationFrame(I)},[z,K.length,g,e,B]),h.useEffect(()=>{if(!z||K.length===0)return;const I=()=>B();return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[z,K.length,B]);const $=h.useCallback(I=>{if(!z)return;const{atIndex:F}=z,P=e.slice(0,F)+"${"+I+"}"+e.slice(g);t(P);const L=F+I.length+3;queueMicrotask(()=>{const _=f.current;_&&(_.focus(),_.setSelectionRange(L,L)),w(L)})},[z,e,g,t]),D=h.useCallback(()=>{const I=f.current,F=m.current;!I||!F||(F.scrollTop=I.scrollTop,F.scrollLeft=I.scrollLeft,z&&K.length>0&&queueMicrotask(()=>B()))},[z,K.length,B]),R=h.useCallback(I=>{if(!n&&z&&K.length>0&&(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Enter")){if(I.key==="ArrowDown")I.preventDefault(),y(F=>(F+1)%K.length);else if(I.key==="ArrowUp")I.preventDefault(),y(F=>(F-1+K.length)%K.length);else if(I.key==="Enter"&&!I.shiftKey){I.preventDefault();const F=K[k];F&&$(F.insert)}}},[n,z,K,k,$]),M=h.useCallback(async I=>{if(n||typeof d!="function")return!1;const F=await wR({files:I,body:e,images:j});return F?(t(F.body),d(F.images),queueMicrotask(()=>{const P=f.current;if(!P)return;P.focus();const L=F.body.length;P.setSelectionRange(L,L),w(L)}),!0):!1},[n,j,t,d,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((I,F)=>i.jsxs("span",{className:"af-body-image-chip",title:I.name,children:[i.jsx("img",{src:I.dataUrl,alt:""}),i.jsxs("span",{children:["[",I.label||`image ${F+1}`,"]"]})]},I.id||F))}):null,i.jsxs("div",{className:"af-body-prompt-stack",children:[i.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:O+`
|
|
128
|
-
`}}),i.jsx("textarea",{ref:f,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":N,"aria-describedby":N?u:void 0,onChange:I=>{t(I.target.value),w(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??0)},onClick:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??0)},onKeyUp:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??F.value.length)},onKeyDown:R,onPaste:I=>{const F=xR(I);F.length!==0&&(I.preventDefault(),M(F).catch(()=>{}))},onDragOver:I=>{Kg(I).length>0&&I.preventDefault()},onDrop:I=>{const F=Kg(I);F.length!==0&&(I.preventDefault(),M(F).catch(()=>{}))},onScroll:D})]}),z&&K.length>0&&b?Or.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":p("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:b.top,left:b.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:K.map((I,F)=>i.jsx("li",{role:"option","aria-selected":F===k,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===k?" af-composer-mention-item--active":""),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>y(F),onClick:()=>$(I.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,N?i.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:E.map(I=>I.message).join(" · ")}):null]})}const MR=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function fm(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function T1({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=Fn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((f,m)=>m!==u)),d=(u,f,m)=>{const g=n.map((w,k)=>{if(k!==u)return w;const y={...w,[f]:m};return f==="required"&&m===!0&&(y.showOnNode=!0),y});r(g)},p=e==="input"?"input":"output";return i.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[i.jsxs("div",{className:"af-node-props-io-head",children:[i.jsx("span",{className:"af-node-props-label",children:t}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),i.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?i.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?i.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[i.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[i.jsx("span",{children:a("flow:nodeProps.handle")}),i.jsx("span",{children:a("flow:nodeProps.type")}),i.jsx("span",{children:a("flow:nodeProps.name")}),i.jsx("span",{children:a("flow:nodeProps.defaultValue")}),i.jsx("span",{children:a("flow:nodeProps.description")}),i.jsx("span",{children:a("flow:nodeProps.required")}),i.jsx("span",{children:a("flow:nodeProps.showOnNode")}),i.jsx("span",{})]}),n.map((u,f)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${f}`,children:[p,"-",f]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(f,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:f}),children:["node","text","file","bool"].map(m=>i.jsx("option",{value:m,children:m},m))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(f,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:f})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(f,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:f})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.description||"",onChange:m=>d(f,"description",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:f})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{o||d(f,"required",m.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:f})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(f,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:f})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(f),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:f}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${f}`))]}):null]})}function LR({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:p,ioSlots:u}){const{t:f}=Fn(),[m,g]=h.useState(!1),[w,k]=h.useState(!1),[y,b]=h.useState({status:"idle",message:""}),x=h.useCallback($=>{t(D=>D&&{...D,...$})},[t]),{cursorList:j,opencodeList:E,claudeCodeList:N,currentNotInLists:T}=h.useMemo(()=>{const $=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],D=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],R=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],M=new Set([...$,...D,...R].map(fm)),I=((e==null?void 0:e.model)??"").trim(),F=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,P=I&&!M.has(F)?I:"";return{cursorList:$,opencodeList:D,claudeCodeList:R,currentNotInLists:P}},[s,e==null?void 0:e.model]);if(!e)return null;const O=String(e.script??""),z=n==="tool_nodejs"||O.trim()!=="",K=typeof c=="function"&&!o&&(e==null?void 0:e.newId),B=async()=>{if(K){b({status:"running",message:f("flow:nodeProps.publishRunning")});try{const $=await c(e,n);b({status:"success",message:$!=null&&$.definitionId?f("flow:nodeProps.publishSuccessWithId",{id:$.definitionId}):f("flow:nodeProps.publishSuccess")})}catch($){b({status:"error",message:String(($==null?void 0:$.message)||$)})}}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:f("flow:nodeProps.title")}),i.jsxs("div",{className:"af-node-props-head-actions",children:[i.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:B,disabled:!K||y.status==="running",title:f("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?f("flow:nodeProps.publishing"):f("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:f("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?i.jsx("p",{className:"af-err af-node-props-err",children:p}):null,y.message?i.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.nodeType")}),i.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:f("flow:node.displayNameHint")})]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:$=>x({newId:$.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":f("flow:nodeProps.instanceId")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.displayName"),"(LABEL)"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:$=>x({label:$.target.value}),disabled:o,spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:Al.includes(e.role)?e.role:f("flow:roles.normal"),onChange:$=>x({role:$.target.value}),disabled:o,children:Al.map($=>i.jsx("option",{value:$,children:$},$))})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:f("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const $=(e.model||"").trim();return $?T||$:""})(),onChange:$=>x({model:$.target.value}),disabled:o,"aria-label":f("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),T?i.jsxs("option",{value:T,children:[T,f("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?i.jsx("optgroup",{label:"Cursor",children:j.map($=>i.jsx("option",{value:fm($),children:$},`c-${$}`))}):null,E.length>0?i.jsx("optgroup",{label:"OpenCode",children:E.map($=>i.jsx("option",{value:fm($),children:$},`o-${$}`))}):null,N.length>0?i.jsx("optgroup",{label:"Claude Code",children:N.map($=>i.jsx("option",{value:`claude-code:${fm($)}`,children:$},`cc-${$}`))}):null]})]}),i.jsx(T1,{kind:"input",label:f("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:$=>x({inputs:$}),disabled:o,requiredReadonly:!d}),i.jsx(T1,{kind:"output",label:f("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:$=>x({outputs:$}),disabled:o,requiredReadonly:!d}),z?i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:f("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":f("flow:nodeProps.expandEditScript"),title:f("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(dm,{value:O,onChange:$=>x({script:$}),disabled:o,placeholder:f("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:$=>x({scriptRef:$.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:$=>x({implementationRef:$.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),i.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:$=>x({implementationMode:$.target.value}),disabled:o,children:[i.jsx("option",{value:"",children:"auto"}),i.jsx("option",{value:"script",children:"script"}),i.jsx("option",{value:"steps",children:"steps"}),i.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":f("flow:nodeProps.expandEdit"),title:f("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(dm,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:o,placeholder:f("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||f("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),w?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editScript"),onMouseDown:$=>{$.target===$.currentTarget&&k(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":f("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(dm,{value:O,onChange:$=>x({script:$}),disabled:o,placeholder:f("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editUserPrompt"),onMouseDown:$=>{$.target===$.currentTarget&&g(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":f("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(dm,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:o,placeholder:f("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function vk(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function C7(e){const t=vk(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function $R(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function R1({text:e}){const{t}=Fn(),n=e||"";return n.trim()?i.jsx("div",{className:"af-run-ctx-md",children:i.jsx(eh,{children:n})}):i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function M1({o:e}){var r;const{t}=Fn(),n=vk(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const o=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return i.jsxs("div",{className:"af-run-ctx-media",children:[i.jsx("img",{className:"af-run-ctx-img",src:o,alt:e.slot||"output",loading:"lazy"}),e.truncated?i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return i.jsx("pre",{className:"af-run-ctx-pre",children:$R(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?i.jsx("div",{className:"af-run-ctx-md",children:i.jsx(eh,{children:s})}):i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return i.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function L1(e){return C7(e)}function $1(e){var r;if(!e)return null;const t=vk(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?$R(String(n)):String(n)}function O1({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const o=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:o,title:r?n:t,"aria-label":r?n:t,children:i.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const D1=2e4,OR="af:run-node-ctx-width";function qm(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function ul(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):ul(qm())}function E7(){try{const e=localStorage.getItem(OR);if(e==null)return ul(qm());const t=parseInt(e,10);return Number.isFinite(t)?ul(t):ul(qm())}catch{return ul(qm())}}async function F1(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const o=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await o.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!o.ok)throw new Error(l.error||"HTTP "+o.status);return l}function _7(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function A7({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:o}=Fn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(E7),p=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,f]=h.useState(!0),[m,g]=h.useState(""),[w,k]=h.useState([]),[y,b]=h.useState(null),[x,j]=h.useState(null),E=h.useRef(null),N=h.useRef(null),T=h.useRef(0),O=h.useRef(0);h.useLayoutEffect(()=>{const P=window.matchMedia("(max-width: 960px)"),L=()=>l(P.matches);return P.addEventListener("change",L),()=>P.removeEventListener("change",L)},[]),h.useEffect(()=>{function P(){d(L=>ul(L))}return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const z=h.useCallback(()=>{d(P=>{const L=ul(P);try{localStorage.setItem(OR,String(L))}catch{}return L})},[]),K=h.useCallback(P=>{if(a||P.button!==0)return;P.preventDefault();const L=P.currentTarget;p.current={active:!0,pointerId:P.pointerId,startX:P.clientX,startW:c},L.setPointerCapture(P.pointerId)},[a,c]),B=h.useCallback(P=>{const L=p.current;if(!L.active||P.pointerId!==L.pointerId)return;const _=L.startX-P.clientX;d(ul(L.startW+_))},[]),$=h.useCallback(P=>{const L=p.current;if(!(!L.active||P.pointerId!==L.pointerId)){L.active=!1;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}z()}},[z]),D=h.useCallback(()=>{const P=p.current;P.active&&(P.active=!1,z())},[z]),R=h.useCallback(P=>{const L=Array.isArray(P)?P:[];k(L),b(_=>_&&L.some(Q=>Q.execId===_)?_:L.length>0?L[L.length-1].execId:null)},[]),M=h.useCallback(()=>{if(!e||!t)return;const P=++T.current,L=new AbortController,_=window.setTimeout(()=>L.abort(),D1);(async()=>{try{const Q=await F1(t,e,n,L.signal);if(P!==T.current)return;R(Array.isArray(Q.rounds)?Q.rounds:[])}catch{}finally{window.clearTimeout(_)}})()},[e,t,n,R]);h.useEffect(()=>{if(!e||!t){f(!1),g(""),k([]);return}const P=++O.current;f(!0),g(""),k([]),b(null);const L=new AbortController,_=window.setTimeout(()=>L.abort(),D1);return(async()=>{try{const Q=await F1(t,e,n,L.signal);if(P!==O.current)return;R(Array.isArray(Q.rounds)?Q.rounds:[])}catch(Q){if(P!==O.current)return;const Z=(Q==null?void 0:Q.name)==="AbortError"?"requestTimeout":Q.message||String(Q);g(Z)}finally{window.clearTimeout(_),P===O.current&&f(!1)}})(),()=>{L.abort(),O.current++,T.current++}},[e,t,n,R]),h.useEffect(()=>{r&&M()},[r,M]),h.useEffect(()=>{clearInterval(N.current);const P=w.length>0?w[w.length-1]:null;return(r==="running"&&w.length===0||!!(P&&P.status==="running"))&&e&&t&&(N.current=setInterval(()=>M(),2e3)),()=>clearInterval(N.current)},[w,e,t,n,r,M]),h.useEffect(()=>{E.current&&(E.current.scrollTop=0)},[y]);const I=w.find(P=>P.execId===y),F=a?void 0:{width:`${c}px`};return i.jsxs("aside",{className:"af-run-ctx-panel",style:F,"aria-label":o("flow:runContext.title"),children:[a?null:i.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":o("flow:runContext.resizeHandle"),onPointerDown:K,onPointerMove:B,onPointerUp:$,onPointerCancel:$,onLostPointerCapture:D}),i.jsxs("div",{className:"af-run-ctx-panel__main",children:[i.jsxs("div",{className:"af-run-ctx-head",children:[i.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":o("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o("common:common.loading")}),m&&i.jsx("div",{className:"af-run-ctx-error",children:_7(o,m)}),!u&&!m&&w.length===0&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),w.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+I7((I==null?void 0:I.status)||""),children:[i.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),i.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:P=>{const L=P.target.value;b(L==="latest"?"latest":Number(L))},children:[...w].reverse().map(P=>{const L=P.execId==="latest"?o("flow:runContext.latest"):`#${P.execId}`,_=T7(o,P.status),Q=P.finishedAt?` · ${P7(P.finishedAt)}`:"";return i.jsx("option",{value:String(P.execId),children:`${L} · ${_}${Q}`},P.execId)})})]}),I&&i.jsxs("div",{className:"af-run-ctx-body",ref:E,children:[I.inputs&&I.inputs.length>0&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((P,L)=>i.jsxs("div",{className:"af-run-ctx-output-slot",children:[i.jsx("div",{className:"af-run-ctx-slot-head",children:i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot})}),i.jsx("pre",{className:"af-run-ctx-slot-text",children:P.value})]},`${P.slot}-${L}`))]}),I.prompt!=null&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("prompt"),title:o("flow:nodeProps.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(R1,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("output"),title:o("flow:nodeProps.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((P,L)=>{const _=L1(P),Q=$1(P);return i.jsxs("div",{className:"af-run-ctx-output-slot",children:[i.jsxs("div",{className:"af-run-ctx-slot-head",children:[i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?i.jsx("span",{className:"af-run-ctx-format-badge",title:o("flow:runContext.detectedContentType"),children:_}):null,i.jsx(O1,{text:Q,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),i.jsx(M1,{o:P})]},`${P.slot}-${L}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o("flow:runContext.roundNoContent")})]})]})]}),x&&I&&i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:P=>{P.target===P.currentTarget&&j(null)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:x==="prompt"?"Prompt":"Outputs"}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>j(null),"aria-label":o("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[x==="prompt"&&I.prompt!=null&&i.jsx(R1,{text:I.prompt}),x==="output"&&I.outputs&&I.outputs.map((P,L)=>{const _=L1(P),Q=$1(P);return i.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[i.jsxs("div",{className:"af-run-ctx-slot-head",children:[i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?i.jsx("span",{className:"af-run-ctx-format-badge",children:_}):null,i.jsx(O1,{text:Q,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),i.jsx(M1,{o:P})]},`${P.slot}-${L}`)})]})]})})]})}function P7(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function I7(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function T7(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function R7({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:o,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=Fn(),[d,p]=h.useState({}),[u,f]=h.useState(null),[m,g]=h.useState({}),[w,k]=h.useState(!0),[y,b]=h.useState(!1),[x,j]=h.useState(""),[E,N]=h.useState(!1),[T,O]=h.useState(null),z=h.useRef(null),K=h.useRef(!0),B=h.useRef({});h.useMemo(()=>{var _,Q,Z;const L={};for(const V of r){const oe=(Z=(Q=(_=V.data)==null?void 0:_.outputs)==null?void 0:Q[0])==null?void 0:Z.default;oe!=null&&oe!==""&&(L[V.id]=String(oe))}return B.current=L,L},[r]);const $=h.useMemo(()=>{var _;const L={};for(const Q of o){if(!((_=Q.data)!=null&&_.inputs))continue;const Z=Q.data.inputs;for(let V=0;V<Z.length;V++){const oe=Z[V];if(!(oe!=null&&oe.name))continue;const ue=s.find(ke=>ke.target===Q.id&&ke.targetHandle===`input-${V}`);if(!(ue!=null&&ue.source))continue;r.find(ke=>ke.id===ue.source)&&(L[ue.source]=oe.name)}}return L},[o,s,r]);h.useEffect(()=>(K.current=!0,()=>{K.current=!1}),[]),h.useEffect(()=>{if(!e){k(!1);return}k(!0);const L=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&L.set("archived","1"),fetch(`/api/flow/run-config?${L.toString()}`).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.json()}).then(_=>{var Z;if(!K.current)return;p(_.presets||{}),f(_.activePreset||null);const Q=_.activePreset&&((Z=_.presets)!=null&&Z[_.activePreset])?_.presets[_.activePreset]:{};g({...B.current,...Q}),k(!1)}).catch(()=>{K.current&&(g(B.current),k(!1))})},[e,t,n]),h.useEffect(()=>{var _;if(!a)return;const L={};for(const[Q,Z]of Object.entries(m)){const V=$[Q];if(!V)continue;const oe=r.find(ye=>ye.id===Q);if(!oe)continue;(((_=oe.data)==null?void 0:_.definitionId)||"").startsWith("provide_file")?L[V]={type:"file",path:Z}:L[V]={type:"str",value:Z}}a(L)},[m,$,r,a]);const D=h.useCallback((L,_)=>{g(Q=>({...Q,[L]:_}))},[]),R=h.useCallback(L=>{L!==u&&(f(L),L&&d[L]?g({...B.current,...d[L]}):g(B.current))},[u,d]),M=h.useCallback(async()=>{if(x.trim()){b(!0);try{const L={...d,[x.trim()]:m},_={flowId:e,flowSource:t,archived:n,presets:L,activePreset:x.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)})).ok&&(p(L),f(x.trim()),j(""),N(!1))}finally{b(!1)}}},[e,t,n,d,m,x]),I=h.useCallback(async()=>{if(u){b(!0);try{const L={...d};delete L[u];const _=Object.keys(L)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:L,activePreset:_})})).ok&&(p(L),f(_),_&&L[_]?g({...B.current,...L[_]}):g(B.current))}finally{b(!1)}}},[e,t,n,d,u]),F=h.useCallback(async()=>{if(u){b(!0);try{const L={...d,[u]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:L,activePreset:u})})).ok&&p(L)}finally{b(!1)}}},[e,t,n,d,u,m]),P=Object.keys(d);return P.length>0,w?i.jsx("aside",{className:"af-run-config-panel",children:i.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):i.jsxs("aside",{className:"af-run-config-panel",children:[i.jsxs("div",{className:"af-run-config-preset",children:[i.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),i.jsxs("div",{className:"af-run-config-preset-row",children:[i.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:L=>R(L.target.value||null),disabled:y,children:[i.jsx("option",{value:"",children:c("flow:runConfig.default")}),P.map(L=>i.jsx("option",{value:L,children:L},L))]}),i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>N(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:F,disabled:y,title:c("flow:runConfig.savePreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:y,title:c("flow:runConfig.deletePreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),E&&i.jsxs("div",{className:"af-run-config-save-dialog",children:[i.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:x,onChange:L=>j(L.target.value),disabled:y}),i.jsxs("div",{className:"af-run-config-save-actions",children:[i.jsx("button",{type:"button",className:"af-btn-primary",onClick:M,disabled:y||!x.trim(),children:c(y?"common.saving":"common.save")}),i.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{N(!1),j("")},disabled:y,children:c("common.cancel")})]})]}),i.jsxs("div",{className:"af-run-config-inputs",children:[i.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?i.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):i.jsx("div",{className:"af-run-config-input-list",children:r.map(L=>{var ke,ce;const _=((ke=L.data)==null?void 0:ke.definitionId)||"",Q=_.startsWith("provide_file"),Z=_==="provide_bool",V=((ce=L.data)==null?void 0:ce.label)||L.id,oe=L.id,ue=m[oe]||"",ye=["true","1","yes","on"].includes(String(ue).trim().toLowerCase());return i.jsxs("div",{className:"af-run-config-input-item",children:[i.jsxs("div",{className:"af-run-config-input-head",children:[i.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(Q?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:Q?"description":Z?"toggle_on":"text_fields"}),i.jsx("span",{className:"af-run-config-input-label",children:V}),Z?null:i.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>O({instanceId:oe,label:V,content:ue}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx("div",{className:"af-run-config-input-id",children:oe}),Z?i.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ye?" af-run-config-bool-toggle--true":""),onClick:()=>D(oe,ye?"false":"true"),"aria-pressed":ye,children:ye?"true":"false"}):i.jsx("input",{type:"text",className:"af-run-config-input-field",value:ue,onChange:_e=>D(oe,_e.target.value),placeholder:c(Q?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},oe)})})]}),T&&Or.createPortal(i.jsx("div",{className:"af-provide-edit-overlay",children:i.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-provide-edit-modal__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),i.jsx("span",{className:"af-provide-edit-modal__title",children:T.label}),i.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>O(null),"aria-label":c("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-provide-edit-modal__body",children:i.jsx("textarea",{ref:z,className:"af-provide-edit-modal__textarea",defaultValue:T.content,autoFocus:!0})}),i.jsxs("div",{className:"af-provide-edit-modal__foot",children:[i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!T||!z.current||(D(T.instanceId,z.current.value),O(null))},children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>O(null),children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const DR={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},M7={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function L7(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function $7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function O7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function z1(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(DR))if(r.includes(e))return n;return"other"}function D7({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=M7[e.tag]||"#a8a8a8",o=e.payload,a=o&&typeof o=="object",l=a?typeof o.text=="string"?o.text:"":String(o||""),c=a?o.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(o).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const g=o[m];return g==null?`${m}:null`:typeof g=="object"?`${m}:{…}`:`${m}:${String(g).slice(0,30)}`}).join(" "):"",[o,l,a]),p=h.useCallback(u=>{u.stopPropagation();const f=a?JSON.stringify(o,null,2):String(o);try{navigator.clipboard.writeText(f)}catch{}},[o,a]);return i.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[i.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[i.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:$7(e.ts)}),i.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),i.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&i.jsx("button",{type:"button",onClick:p,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&i.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&i.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?i.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?i.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(o,null,2)}):null]})]})}function F7({open:e,onClose:t,flowId:n}){var O;const[r,s]=h.useState([]),[o,a]=h.useState(!1),[l,c]=h.useState(null),[d,p]=h.useState(null),[u,f]=h.useState(!1),[m,g]=h.useState(!0),[w,k]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,b]=h.useState(""),x=h.useRef(null),j=h.useCallback(async()=>{a(!0);try{const z=m&&n?`?flowId=${encodeURIComponent(n)}`:"",B=await(await fetch(`/api/composer-logs${z}`)).json();s(Array.isArray(B.sessions)?B.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),E=h.useCallback(async z=>{if(!z){p(null);return}f(!0);try{const B=await(await fetch(`/api/composer-logs/${encodeURIComponent(z)}`)).json();p(B)}catch{p(null)}finally{f(!1)}},[]);h.useEffect(()=>{e&&j()},[e,j]),h.useEffect(()=>{if(!(!e||!l))return E(l),x.current=setInterval(()=>E(l),2e3),()=>{x.current&&clearInterval(x.current),x.current=null}},[e,l,E]);const N=h.useMemo(()=>{const z=(d==null?void 0:d.events)||[],K=y.trim().toLowerCase();return z.filter(B=>{const $=z1(B.tag,B.payload);return!w[$]&&$!=="other"?!1:K?[B.tag,JSON.stringify(B.payload||"")].join(" ").toLowerCase().includes(K):!0})},[d,w,y]),T=h.useMemo(()=>{const z=(d==null?void 0:d.events)||[],K={};for(const B of z){const $=z1(B.tag,B.payload);K[$]=(K[$]||0)+1}return K},[d]);return e?i.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[i.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[i.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),i.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),i.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:m,onChange:z=>g(z.target.checked),disabled:!n}),"仅显示当前 flow"]}),i.jsx("button",{type:"button",onClick:j,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),i.jsx("span",{style:{flex:1}}),i.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[o&&i.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!o&&r.length===0&&i.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(z=>{const K=l===z.sessionId;return i.jsxs("div",{onClick:()=>c(z.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:K?"rgba(124,77,255,0.18)":"transparent",borderLeft:K?"3px solid #7c4dff":"3px solid transparent"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:O7(z.mtime)}),i.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:z.flowId||"(no flow)"}),z.promptPreview&&i.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:z.promptPreview}),i.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[L7(z.size)," · ",z.model||"default"]})]},z.sessionId)})]}),i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(DR).map(z=>i.jsxs("button",{type:"button",onClick:()=>k(K=>({...K,[z]:!K[z]})),style:{background:w[z]?"rgba(124,77,255,0.25)":"transparent",color:w[z]?"#e8deff":"#6a6a6a",border:`1px solid ${w[z]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[z," ",T[z]!=null?`(${T[z]})`:""]},z)),i.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:z=>b(z.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&i.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&i.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&N.length===0&&i.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((O=d.events)==null?void 0:O.length)||0," total)"]}),N.map((z,K)=>i.jsx(D7,{event:z,defaultExpanded:z.tag==="error"},`${z.ts}_${K}`))]})]})]})]}):null}const z7="0.1.79";function H1(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function ww(e,t){return t==="running"?H1(e):e==null||!Number.isFinite(e)||e<=0?"--":H1(e)}const FR=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function H7(e){var b,x,j,E,N,T,O,z,K,B,$;const{setNodes:t}=Ol(),n=J0(),{modelLists:r,onModelChange:s}=h.useContext(FR),o=h.useRef(null),a=!!((b=e.data)!=null&&b.readOnly),l=(x=e.data)!=null&&x.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,c=((j=e.data)==null?void 0:j.definitionId)==="agent_subAgent"&&!((E=e.data)!=null&&E.isRunMode)&&!a,d=h.useCallback(D=>{const R=()=>n(D);window.requestAnimationFrame(R),window.setTimeout(R,80)},[n]),p=h.useCallback((D,R)=>{const M=G1(R);M&&(t(I=>I.map(F=>{var _,Q,Z,V,oe,ue;if(F.id!==D)return F;const P=Number(((Q=(_=F.data)==null?void 0:_.displaySize)==null?void 0:Q.width)||F.width||((Z=F.measured)==null?void 0:Z.width)||0),L=Number(((oe=(V=F.data)==null?void 0:V.displaySize)==null?void 0:oe.height)||F.height||((ue=F.measured)==null?void 0:ue.height)||0);return Math.abs(P-M.width)<2&&Math.abs(L-M.height)<2?F:{...F,width:M.width,height:M.height,data:{...F.data,displaySize:M}}})),d(D))},[d,t]),u=h.useCallback(D=>{if(a)return;const R=o.current;if(!R)return;const M=R.getBoundingClientRect();p(D,{width:Math.max(M.width,R.scrollWidth),height:Math.max(M.height,R.scrollHeight)})},[p,a]),f=h.useCallback(D=>{var oe,ue,ye,ke,ce,_e;if(!c)return;D.preventDefault(),D.stopPropagation();const R=o.current,M=R==null?void 0:R.getBoundingClientRect(),I=Number(((ue=(oe=e.data)==null?void 0:oe.displaySize)==null?void 0:ue.width)||e.width||((ye=e.measured)==null?void 0:ye.width)||(M==null?void 0:M.width)||WR),F=Number(((ce=(ke=e.data)==null?void 0:ke.displaySize)==null?void 0:ce.height)||e.height||((_e=e.measured)==null?void 0:_e.height)||(M==null?void 0:M.height)||kv),P=D.clientX,L=D.clientY,_=e.id;let Q=0;const Z=ae=>{const de=G1({width:I+ae.clientX-P,height:F+ae.clientY-L});de&&(window.cancelAnimationFrame(Q),Q=window.requestAnimationFrame(()=>p(_,de)))},V=()=>{window.cancelAnimationFrame(Q),window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(_)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[p,(T=(N=e.data)==null?void 0:N.displaySize)==null?void 0:T.height,(z=(O=e.data)==null?void 0:O.displaySize)==null?void 0:z.width,e.height,e.id,(K=e.measured)==null?void 0:K.height,(B=e.measured)==null?void 0:B.width,e.width,d,c]),m=h.useCallback(D=>{t(R=>R.filter(M=>M.id!==D))},[t]),g=h.useCallback(()=>{var I,F,P,L,_,Q,Z,V;const D=((I=e.data)==null?void 0:I.definitionId)||"",R=((F=e.data)==null?void 0:F.label)||e.id,M=((_=(L=(P=e.data)==null?void 0:P.outputs)==null?void 0:L[0])==null?void 0:_.value)||((V=(Z=(Q=e.data)==null?void 0:Q.outputs)==null?void 0:Z[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:R,definitionId:D,content:M},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),w=h.useCallback((D,R)=>{t(M=>M.map(I=>{var P;if(I.id!==D)return I;const F=Array.isArray((P=I.data)==null?void 0:P.outputs)&&I.data.outputs.length?I.data.outputs.map((L,_)=>_===0?{...L,default:R,value:R}:L):[{type:"bool",name:"value",default:R,value:R}];return{...I,data:{...I.data,body:"",outputs:F}}}))},[t]),k=h.useCallback((D,R)=>{t(M=>M.map(I=>I.id===D?{...I,data:{...I.data,body:R}}:I))},[t]),y=h.useCallback((D,R)=>{t(M=>M.map(I=>I.id===D?{...I,data:{...I.data,images:zs(R)}}:I))},[t]);return i.jsxs("div",{ref:o,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[i.jsx(jR,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:g,onProvideValueChange:w,onNodeBodyChange:k,onNodeImagesChange:y,modelLists:r,onModelChange:s}),c?i.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":(($=e.data)==null?void 0:$.resizeLabel)||"Resize node",role:"separator",onPointerDown:f}):null]})}const B7={[zc]:H7},Pf=["CONTROL","TOOL","PROVIDE","AGENT"],W7=1200,B1="af-flow-node--sync-flash",W1="af-flow-edge--sync-flash";function V1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function K1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function kk(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function V7(e){const t=kk(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function pm(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function zR(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function HR(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function bw(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function U1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function q1(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function K7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function U7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function BR(e,t,n,r,s){const o=V7(e),a={id:t,type:zc,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:o,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return Rp(a,r,s)}const WR=320,q7=220,Y7=1600,kv=104,G7=900;function Y1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function G1(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:Y1(t,q7,Y7)||WR,height:Y1(n,kv,G7)||kv}}function X7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,o)=>(s==null?void 0:s.showOnNode)===!1?"":[o,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function X1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),o=s.get(n),a=s.get(r),l=vd(o,e.sourceHandle||"output-0","source"),c=vd(a,e.targetHandle||"input-0","target");return!l||!c?!1:Pl(l,c)}function J7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const o=t.find(l=>l.id===n),a=vd(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:NR(a)}:null}function Q7(e,t,n){var a;const r=BR(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",o=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<o.length;l+=1){const c=o[l];if(n.handleType==="source"?Pl(n.slot,c):Pl(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function Z7(e,t){return t?e.map((n,r)=>{const s=Q7(n,e,t);if(!s)return null;const o=kk(n);return{def:n,order:r,category:o,categoryRank:Pf.indexOf(o),slot:s.slot,slotIndex:s.slotIndex,displayLabel:zR(s.hydrated.data||n),description:HR(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return s-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const eq=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function tq(e){const t=new Set,n=[];let r;const s=new RegExp(eq.source,"g");for(;(r=s.exec(e))!==null;){const o=r[1];t.has(o)||(t.add(o),n.push(o))}return n}function J1(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function da(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function hm(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const o=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=o.map(da),d=a.map(da);return l.map(da).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function nq(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function vw(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function rq({steps:e}){const{t}=Fn();return!e||e.length===0?null:i.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,o=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
|
|
128
|
+
`}}),i.jsx("textarea",{ref:f,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":N,"aria-describedby":N?u:void 0,onChange:I=>{t(I.target.value),w(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??0)},onClick:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??0)},onKeyUp:I=>{const F=I.target;F instanceof HTMLTextAreaElement&&w(F.selectionStart??F.value.length)},onKeyDown:R,onPaste:I=>{const F=xR(I);F.length!==0&&(I.preventDefault(),M(F).catch(()=>{}))},onDragOver:I=>{Kg(I).length>0&&I.preventDefault()},onDrop:I=>{const F=Kg(I);F.length!==0&&(I.preventDefault(),M(F).catch(()=>{}))},onScroll:D})]}),z&&K.length>0&&b?Or.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":p("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:b.top,left:b.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:K.map((I,F)=>i.jsx("li",{role:"option","aria-selected":F===k,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===k?" af-composer-mention-item--active":""),onMouseDown:P=>P.preventDefault(),onMouseEnter:()=>y(F),onClick:()=>$(I.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,N?i.jsx("p",{id:u,className:"af-body-ph-issues",role:"status",children:E.map(I=>I.message).join(" · ")}):null]})}const MR=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function fm(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function T1({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=Fn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=u=>r(n.filter((f,m)=>m!==u)),d=(u,f,m)=>{const g=n.map((w,k)=>{if(k!==u)return w;const y={...w,[f]:m};return f==="required"&&m===!0&&(y.showOnNode=!0),y});r(g)},p=e==="input"?"input":"output";return i.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[i.jsxs("div",{className:"af-node-props-io-head",children:[i.jsx("span",{className:"af-node-props-label",children:t}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),i.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?i.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?i.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[i.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[i.jsx("span",{children:a("flow:nodeProps.handle")}),i.jsx("span",{children:a("flow:nodeProps.type")}),i.jsx("span",{children:a("flow:nodeProps.name")}),i.jsx("span",{children:a("flow:nodeProps.defaultValue")}),i.jsx("span",{children:a("flow:nodeProps.description")}),i.jsx("span",{children:a("flow:nodeProps.required")}),i.jsx("span",{children:a("flow:nodeProps.showOnNode")}),i.jsx("span",{})]}),n.map((u,f)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${f}`,children:[p,"-",f]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:u.type,onChange:m=>d(f,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:f}),children:["node","text","file","bool"].map(m=>i.jsx("option",{value:m,children:m},m))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.name,onChange:m=>d(f,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:f})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.default,onChange:m=>d(f,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:f})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:u.description||"",onChange:m=>d(f,"description",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:f})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!u.required,onChange:m=>{o||d(f,"required",m.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:f})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:u.showOnNode!==!1,onChange:m=>d(f,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:f})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(f),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:f}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${f}`))]}):null]})}function LR({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:d=!1,error:p,ioSlots:u}){const{t:f}=Fn(),[m,g]=h.useState(!1),[w,k]=h.useState(!1),[y,b]=h.useState({status:"idle",message:""}),x=h.useCallback($=>{t(D=>D&&{...D,...$})},[t]),{cursorList:j,opencodeList:E,claudeCodeList:N,currentNotInLists:T}=h.useMemo(()=>{const $=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],D=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],R=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],M=new Set([...$,...D,...R].map(fm)),I=((e==null?void 0:e.model)??"").trim(),F=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,P=I&&!M.has(F)?I:"";return{cursorList:$,opencodeList:D,claudeCodeList:R,currentNotInLists:P}},[s,e==null?void 0:e.model]);if(!e)return null;const O=String(e.script??""),z=n==="tool_nodejs"||O.trim()!=="",K=typeof c=="function"&&!o&&(e==null?void 0:e.newId),B=async()=>{if(K){b({status:"running",message:f("flow:nodeProps.publishRunning")});try{const $=await c(e,n);b({status:"success",message:$!=null&&$.definitionId?f("flow:nodeProps.publishSuccessWithId",{id:$.definitionId}):f("flow:nodeProps.publishSuccess")})}catch($){b({status:"error",message:String(($==null?void 0:$.message)||$)})}}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:f("flow:nodeProps.title")}),i.jsxs("div",{className:"af-node-props-head-actions",children:[i.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:B,disabled:!K||y.status==="running",title:f("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?f("flow:nodeProps.publishing"):f("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:f("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?i.jsx("p",{className:"af-err af-node-props-err",children:p}):null,y.message?i.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.nodeType")}),i.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:f("flow:node.displayNameHint")})]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:$=>x({newId:$.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":f("flow:nodeProps.instanceId")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.displayName"),"(LABEL)"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:$=>x({label:$.target.value}),disabled:o,spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:Al.includes(e.role)?e.role:f("flow:roles.normal"),onChange:$=>x({role:$.target.value}),disabled:o,children:Al.map($=>i.jsx("option",{value:$,children:$},$))})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:f("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const $=(e.model||"").trim();return $?T||$:""})(),onChange:$=>x({model:$.target.value}),disabled:o,"aria-label":f("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),T?i.jsxs("option",{value:T,children:[T,f("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?i.jsx("optgroup",{label:"Cursor",children:j.map($=>i.jsx("option",{value:fm($),children:$},`c-${$}`))}):null,E.length>0?i.jsx("optgroup",{label:"OpenCode",children:E.map($=>i.jsx("option",{value:fm($),children:$},`o-${$}`))}):null,N.length>0?i.jsx("optgroup",{label:"Claude Code",children:N.map($=>i.jsx("option",{value:`claude-code:${fm($)}`,children:$},`cc-${$}`))}):null]})]}),i.jsx(T1,{kind:"input",label:f("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:$=>x({inputs:$}),disabled:o,requiredReadonly:!d}),i.jsx(T1,{kind:"output",label:f("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:$=>x({outputs:$}),disabled:o,requiredReadonly:!d}),z?i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:f("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":f("flow:nodeProps.expandEditScript"),title:f("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(dm,{value:O,onChange:$=>x({script:$}),disabled:o,placeholder:f("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:u,variant:"drawer"})]}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:$=>x({scriptRef:$.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:$=>x({implementationRef:$.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),i.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:$=>x({implementationMode:$.target.value}),disabled:o,children:[i.jsx("option",{value:"",children:"auto"}),i.jsx("option",{value:"script",children:"script"}),i.jsx("option",{value:"steps",children:"steps"}),i.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":f("flow:nodeProps.expandEdit"),title:f("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(dm,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:o,placeholder:f("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:u,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:f("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||f("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),w?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editScript"),onMouseDown:$=>{$.target===$.currentTarget&&k(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":f("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(dm,{value:O,onChange:$=>x({script:$}),disabled:o,placeholder:f("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null,m?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editUserPrompt"),onMouseDown:$=>{$.target===$.currentTarget&&g(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":f("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(dm,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:o,placeholder:f("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:u,variant:"expand"})]})}):null]})}function vk(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function C7(e){const t=vk(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function $R(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function R1({text:e}){const{t}=Fn(),n=e||"";return n.trim()?i.jsx("div",{className:"af-run-ctx-md",children:i.jsx(eh,{children:n})}):i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function M1({o:e}){var r;const{t}=Fn(),n=vk(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const o=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return i.jsxs("div",{className:"af-run-ctx-media",children:[i.jsx("img",{className:"af-run-ctx-img",src:o,alt:e.slot||"output",loading:"lazy"}),e.truncated?i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return i.jsx("pre",{className:"af-run-ctx-pre",children:$R(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?i.jsx("div",{className:"af-run-ctx-md",children:i.jsx(eh,{children:s})}):i.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return i.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function L1(e){return C7(e)}function $1(e){var r;if(!e)return null;const t=vk(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?$R(String(n)):String(n)}function O1({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const o=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:o,title:r?n:t,"aria-label":r?n:t,children:i.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const D1=2e4,OR="af:run-node-ctx-width";function qm(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function ul(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):ul(qm())}function E7(){try{const e=localStorage.getItem(OR);if(e==null)return ul(qm());const t=parseInt(e,10);return Number.isFinite(t)?ul(t):ul(qm())}catch{return ul(qm())}}async function F1(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const o=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await o.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!o.ok)throw new Error(l.error||"HTTP "+o.status);return l}function _7(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function A7({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:o}=Fn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[c,d]=h.useState(E7),p=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[u,f]=h.useState(!0),[m,g]=h.useState(""),[w,k]=h.useState([]),[y,b]=h.useState(null),[x,j]=h.useState(null),E=h.useRef(null),N=h.useRef(null),T=h.useRef(0),O=h.useRef(0);h.useLayoutEffect(()=>{const P=window.matchMedia("(max-width: 960px)"),L=()=>l(P.matches);return P.addEventListener("change",L),()=>P.removeEventListener("change",L)},[]),h.useEffect(()=>{function P(){d(L=>ul(L))}return window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]);const z=h.useCallback(()=>{d(P=>{const L=ul(P);try{localStorage.setItem(OR,String(L))}catch{}return L})},[]),K=h.useCallback(P=>{if(a||P.button!==0)return;P.preventDefault();const L=P.currentTarget;p.current={active:!0,pointerId:P.pointerId,startX:P.clientX,startW:c},L.setPointerCapture(P.pointerId)},[a,c]),B=h.useCallback(P=>{const L=p.current;if(!L.active||P.pointerId!==L.pointerId)return;const _=L.startX-P.clientX;d(ul(L.startW+_))},[]),$=h.useCallback(P=>{const L=p.current;if(!(!L.active||P.pointerId!==L.pointerId)){L.active=!1;try{P.currentTarget.releasePointerCapture(P.pointerId)}catch{}z()}},[z]),D=h.useCallback(()=>{const P=p.current;P.active&&(P.active=!1,z())},[z]),R=h.useCallback(P=>{const L=Array.isArray(P)?P:[];k(L),b(_=>_&&L.some(Q=>Q.execId===_)?_:L.length>0?L[L.length-1].execId:null)},[]),M=h.useCallback(()=>{if(!e||!t)return;const P=++T.current,L=new AbortController,_=window.setTimeout(()=>L.abort(),D1);(async()=>{try{const Q=await F1(t,e,n,L.signal);if(P!==T.current)return;R(Array.isArray(Q.rounds)?Q.rounds:[])}catch{}finally{window.clearTimeout(_)}})()},[e,t,n,R]);h.useEffect(()=>{if(!e||!t){f(!1),g(""),k([]);return}const P=++O.current;f(!0),g(""),k([]),b(null);const L=new AbortController,_=window.setTimeout(()=>L.abort(),D1);return(async()=>{try{const Q=await F1(t,e,n,L.signal);if(P!==O.current)return;R(Array.isArray(Q.rounds)?Q.rounds:[])}catch(Q){if(P!==O.current)return;const Z=(Q==null?void 0:Q.name)==="AbortError"?"requestTimeout":Q.message||String(Q);g(Z)}finally{window.clearTimeout(_),P===O.current&&f(!1)}})(),()=>{L.abort(),O.current++,T.current++}},[e,t,n,R]),h.useEffect(()=>{r&&M()},[r,M]),h.useEffect(()=>{clearInterval(N.current);const P=w.length>0?w[w.length-1]:null;return(r==="running"&&w.length===0||!!(P&&P.status==="running"))&&e&&t&&(N.current=setInterval(()=>M(),2e3)),()=>clearInterval(N.current)},[w,e,t,n,r,M]),h.useEffect(()=>{E.current&&(E.current.scrollTop=0)},[y]);const I=w.find(P=>P.execId===y),F=a?void 0:{width:`${c}px`};return i.jsxs("aside",{className:"af-run-ctx-panel",style:F,"aria-label":o("flow:runContext.title"),children:[a?null:i.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":o("flow:runContext.resizeHandle"),onPointerDown:K,onPointerMove:B,onPointerUp:$,onPointerCancel:$,onLostPointerCapture:D}),i.jsxs("div",{className:"af-run-ctx-panel__main",children:[i.jsxs("div",{className:"af-run-ctx-head",children:[i.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":o("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),u&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o("common:common.loading")}),m&&i.jsx("div",{className:"af-run-ctx-error",children:_7(o,m)}),!u&&!m&&w.length===0&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),w.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+I7((I==null?void 0:I.status)||""),children:[i.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),i.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:P=>{const L=P.target.value;b(L==="latest"?"latest":Number(L))},children:[...w].reverse().map(P=>{const L=P.execId==="latest"?o("flow:runContext.latest"):`#${P.execId}`,_=T7(o,P.status),Q=P.finishedAt?` · ${P7(P.finishedAt)}`:"";return i.jsx("option",{value:String(P.execId),children:`${L} · ${_}${Q}`},P.execId)})})]}),I&&i.jsxs("div",{className:"af-run-ctx-body",ref:E,children:[I.inputs&&I.inputs.length>0&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((P,L)=>i.jsxs("div",{className:"af-run-ctx-output-slot",children:[i.jsx("div",{className:"af-run-ctx-slot-head",children:i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot})}),i.jsx("pre",{className:"af-run-ctx-slot-text",children:P.value})]},`${P.slot}-${L}`))]}),I.prompt!=null&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("prompt"),title:o("flow:nodeProps.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(R1,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&i.jsxs("section",{className:"af-run-ctx-section",children:[i.jsxs("h3",{className:"af-run-ctx-section-title",children:[i.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",i.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("output"),title:o("flow:nodeProps.expand"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((P,L)=>{const _=L1(P),Q=$1(P);return i.jsxs("div",{className:"af-run-ctx-output-slot",children:[i.jsxs("div",{className:"af-run-ctx-slot-head",children:[i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?i.jsx("span",{className:"af-run-ctx-format-badge",title:o("flow:runContext.detectedContentType"),children:_}):null,i.jsx(O1,{text:Q,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),i.jsx(M1,{o:P})]},`${P.slot}-${L}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&i.jsx("div",{className:"af-run-ctx-placeholder",children:o("flow:runContext.roundNoContent")})]})]})]}),x&&I&&i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:P=>{P.target===P.currentTarget&&j(null)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:x==="prompt"?"Prompt":"Outputs"}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>j(null),"aria-label":o("common:common.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[x==="prompt"&&I.prompt!=null&&i.jsx(R1,{text:I.prompt}),x==="output"&&I.outputs&&I.outputs.map((P,L)=>{const _=L1(P),Q=$1(P);return i.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[i.jsxs("div",{className:"af-run-ctx-slot-head",children:[i.jsx("div",{className:"af-run-ctx-slot-name",children:P.slot}),_?i.jsx("span",{className:"af-run-ctx-format-badge",children:_}):null,i.jsx(O1,{text:Q,title:o("common:common.copy"),copiedLabel:o("common:common.copied")})]}),i.jsx(M1,{o:P})]},`${P.slot}-${L}`)})]})]})})]})}function P7(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function I7(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function T7(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function R7({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:o,onCliInputsChange:a,onBackToEdit:l}){const{t:c}=Fn(),[d,p]=h.useState({}),[u,f]=h.useState(null),[m,g]=h.useState({}),[w,k]=h.useState(!0),[y,b]=h.useState(!1),[x,j]=h.useState(""),[E,N]=h.useState(!1),[T,O]=h.useState(null),z=h.useRef(null),K=h.useRef(!0),B=h.useRef({});h.useMemo(()=>{var _,Q,Z;const L={};for(const V of r){const oe=(Z=(Q=(_=V.data)==null?void 0:_.outputs)==null?void 0:Q[0])==null?void 0:Z.default;oe!=null&&oe!==""&&(L[V.id]=String(oe))}return B.current=L,L},[r]);const $=h.useMemo(()=>{var _;const L={};for(const Q of o){if(!((_=Q.data)!=null&&_.inputs))continue;const Z=Q.data.inputs;for(let V=0;V<Z.length;V++){const oe=Z[V];if(!(oe!=null&&oe.name))continue;const ue=s.find(ke=>ke.target===Q.id&&ke.targetHandle===`input-${V}`);if(!(ue!=null&&ue.source))continue;r.find(ke=>ke.id===ue.source)&&(L[ue.source]=oe.name)}}return L},[o,s,r]);h.useEffect(()=>(K.current=!0,()=>{K.current=!1}),[]),h.useEffect(()=>{if(!e){k(!1);return}k(!0);const L=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&L.set("archived","1"),fetch(`/api/flow/run-config?${L.toString()}`).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.json()}).then(_=>{var Z;if(!K.current)return;p(_.presets||{}),f(_.activePreset||null);const Q=_.activePreset&&((Z=_.presets)!=null&&Z[_.activePreset])?_.presets[_.activePreset]:{};g({...B.current,...Q}),k(!1)}).catch(()=>{K.current&&(g(B.current),k(!1))})},[e,t,n]),h.useEffect(()=>{var _;if(!a)return;const L={};for(const[Q,Z]of Object.entries(m)){const V=$[Q];if(!V)continue;const oe=r.find(ye=>ye.id===Q);if(!oe)continue;(((_=oe.data)==null?void 0:_.definitionId)||"").startsWith("provide_file")?L[V]={type:"file",path:Z}:L[V]={type:"str",value:Z}}a(L)},[m,$,r,a]);const D=h.useCallback((L,_)=>{g(Q=>({...Q,[L]:_}))},[]),R=h.useCallback(L=>{L!==u&&(f(L),L&&d[L]?g({...B.current,...d[L]}):g(B.current))},[u,d]),M=h.useCallback(async()=>{if(x.trim()){b(!0);try{const L={...d,[x.trim()]:m},_={flowId:e,flowSource:t,archived:n,presets:L,activePreset:x.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)})).ok&&(p(L),f(x.trim()),j(""),N(!1))}finally{b(!1)}}},[e,t,n,d,m,x]),I=h.useCallback(async()=>{if(u){b(!0);try{const L={...d};delete L[u];const _=Object.keys(L)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:L,activePreset:_})})).ok&&(p(L),f(_),_&&L[_]?g({...B.current,...L[_]}):g(B.current))}finally{b(!1)}}},[e,t,n,d,u]),F=h.useCallback(async()=>{if(u){b(!0);try{const L={...d,[u]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:L,activePreset:u})})).ok&&p(L)}finally{b(!1)}}},[e,t,n,d,u,m]),P=Object.keys(d);return P.length>0,w?i.jsx("aside",{className:"af-run-config-panel",children:i.jsx("div",{className:"af-run-config-loading",children:c("common.loading")})}):i.jsxs("aside",{className:"af-run-config-panel",children:[i.jsxs("div",{className:"af-run-config-preset",children:[i.jsx("label",{className:"af-run-config-preset-label",children:c("flow:runConfig.preset")}),i.jsxs("div",{className:"af-run-config-preset-row",children:[i.jsxs("select",{className:"af-run-config-preset-select",value:u||"",onChange:L=>R(L.target.value||null),disabled:y,children:[i.jsx("option",{value:"",children:c("flow:runConfig.default")}),P.map(L=>i.jsx("option",{value:L,children:L},L))]}),i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>N(!0),disabled:y,title:c("flow:runConfig.newPreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),u&&i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:F,disabled:y,title:c("flow:runConfig.savePreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),u&&i.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:y,title:c("flow:runConfig.deletePreset"),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),E&&i.jsxs("div",{className:"af-run-config-save-dialog",children:[i.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:c("flow:runConfig.presetNamePlaceholder"),value:x,onChange:L=>j(L.target.value),disabled:y}),i.jsxs("div",{className:"af-run-config-save-actions",children:[i.jsx("button",{type:"button",className:"af-btn-primary",onClick:M,disabled:y||!x.trim(),children:c(y?"common.saving":"common.save")}),i.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{N(!1),j("")},disabled:y,children:c("common.cancel")})]})]}),i.jsxs("div",{className:"af-run-config-inputs",children:[i.jsx("div",{className:"af-run-config-inputs-header",children:c("flow:runConfig.inputParams")}),r.length===0?i.jsx("div",{className:"af-run-config-empty",children:c("flow:runConfig.noProvideNodes")}):i.jsx("div",{className:"af-run-config-input-list",children:r.map(L=>{var ke,ce;const _=((ke=L.data)==null?void 0:ke.definitionId)||"",Q=_.startsWith("provide_file"),Z=_==="provide_bool",V=((ce=L.data)==null?void 0:ce.label)||L.id,oe=L.id,ue=m[oe]||"",ye=["true","1","yes","on"].includes(String(ue).trim().toLowerCase());return i.jsxs("div",{className:"af-run-config-input-item",children:[i.jsxs("div",{className:"af-run-config-input-head",children:[i.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(Q?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:Q?"description":Z?"toggle_on":"text_fields"}),i.jsx("span",{className:"af-run-config-input-label",children:V}),Z?null:i.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>O({instanceId:oe,label:V,content:ue}),"aria-label":c("flow:runConfig.expandInput"),title:c("flow:runConfig.expandInput"),children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx("div",{className:"af-run-config-input-id",children:oe}),Z?i.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(ye?" af-run-config-bool-toggle--true":""),onClick:()=>D(oe,ye?"false":"true"),"aria-pressed":ye,children:ye?"true":"false"}):i.jsx("input",{type:"text",className:"af-run-config-input-field",value:ue,onChange:_e=>D(oe,_e.target.value),placeholder:c(Q?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},oe)})})]}),T&&Or.createPortal(i.jsx("div",{className:"af-provide-edit-overlay",children:i.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[i.jsxs("div",{className:"af-provide-edit-modal__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),i.jsx("span",{className:"af-provide-edit-modal__title",children:T.label}),i.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>O(null),"aria-label":c("common:close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx("div",{className:"af-provide-edit-modal__body",children:i.jsx("textarea",{ref:z,className:"af-provide-edit-modal__textarea",defaultValue:T.content,autoFocus:!0})}),i.jsxs("div",{className:"af-provide-edit-modal__foot",children:[i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!T||!z.current||(D(T.instanceId,z.current.value),O(null))},children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),c("flow:provideEdit.save")]}),i.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>O(null),children:[i.jsx("span",{className:"material-symbols-outlined",children:"close"}),c("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const DR={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},M7={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function L7(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function $7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function O7(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function z1(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(DR))if(r.includes(e))return n;return"other"}function D7({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=M7[e.tag]||"#a8a8a8",o=e.payload,a=o&&typeof o=="object",l=a?typeof o.text=="string"?o.text:"":String(o||""),c=a?o.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(o).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const g=o[m];return g==null?`${m}:null`:typeof g=="object"?`${m}:{…}`:`${m}:${String(g).slice(0,30)}`}).join(" "):"",[o,l,a]),p=h.useCallback(u=>{u.stopPropagation();const f=a?JSON.stringify(o,null,2):String(o);try{navigator.clipboard.writeText(f)}catch{}},[o,a]);return i.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(u=>!u),children:[i.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[i.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:$7(e.ts)}),i.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),i.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&i.jsx("button",{type:"button",onClick:p,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&i.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[c&&Object.keys(c).length>0&&i.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(c,null,2)}),l?i.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?i.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(o,null,2)}):null]})]})}function F7({open:e,onClose:t,flowId:n}){var O;const[r,s]=h.useState([]),[o,a]=h.useState(!1),[l,c]=h.useState(null),[d,p]=h.useState(null),[u,f]=h.useState(!1),[m,g]=h.useState(!0),[w,k]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,b]=h.useState(""),x=h.useRef(null),j=h.useCallback(async()=>{a(!0);try{const z=m&&n?`?flowId=${encodeURIComponent(n)}`:"",B=await(await fetch(`/api/composer-logs${z}`)).json();s(Array.isArray(B.sessions)?B.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),E=h.useCallback(async z=>{if(!z){p(null);return}f(!0);try{const B=await(await fetch(`/api/composer-logs/${encodeURIComponent(z)}`)).json();p(B)}catch{p(null)}finally{f(!1)}},[]);h.useEffect(()=>{e&&j()},[e,j]),h.useEffect(()=>{if(!(!e||!l))return E(l),x.current=setInterval(()=>E(l),2e3),()=>{x.current&&clearInterval(x.current),x.current=null}},[e,l,E]);const N=h.useMemo(()=>{const z=(d==null?void 0:d.events)||[],K=y.trim().toLowerCase();return z.filter(B=>{const $=z1(B.tag,B.payload);return!w[$]&&$!=="other"?!1:K?[B.tag,JSON.stringify(B.payload||"")].join(" ").toLowerCase().includes(K):!0})},[d,w,y]),T=h.useMemo(()=>{const z=(d==null?void 0:d.events)||[],K={};for(const B of z){const $=z1(B.tag,B.payload);K[$]=(K[$]||0)+1}return K},[d]);return e?i.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[i.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[i.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),i.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),i.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[i.jsx("input",{type:"checkbox",checked:m,onChange:z=>g(z.target.checked),disabled:!n}),"仅显示当前 flow"]}),i.jsx("button",{type:"button",onClick:j,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),i.jsx("span",{style:{flex:1}}),i.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),i.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[o&&i.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!o&&r.length===0&&i.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(z=>{const K=l===z.sessionId;return i.jsxs("div",{onClick:()=>c(z.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:K?"rgba(124,77,255,0.18)":"transparent",borderLeft:K?"3px solid #7c4dff":"3px solid transparent"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:O7(z.mtime)}),i.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:z.flowId||"(no flow)"}),z.promptPreview&&i.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:z.promptPreview}),i.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[L7(z.size)," · ",z.model||"default"]})]},z.sessionId)})]}),i.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[i.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(DR).map(z=>i.jsxs("button",{type:"button",onClick:()=>k(K=>({...K,[z]:!K[z]})),style:{background:w[z]?"rgba(124,77,255,0.25)":"transparent",color:w[z]?"#e8deff":"#6a6a6a",border:`1px solid ${w[z]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[z," ",T[z]!=null?`(${T[z]})`:""]},z)),i.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:z=>b(z.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),i.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&i.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),u&&!d&&i.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&N.length===0&&i.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((O=d.events)==null?void 0:O.length)||0," total)"]}),N.map((z,K)=>i.jsx(D7,{event:z,defaultExpanded:z.tag==="error"},`${z.ts}_${K}`))]})]})]})]}):null}const z7="0.1.80";function H1(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function ww(e,t){return t==="running"?H1(e):e==null||!Number.isFinite(e)||e<=0?"--":H1(e)}const FR=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function H7(e){var b,x,j,E,N,T,O,z,K,B,$;const{setNodes:t}=Ol(),n=J0(),{modelLists:r,onModelChange:s}=h.useContext(FR),o=h.useRef(null),a=!!((b=e.data)!=null&&b.readOnly),l=(x=e.data)!=null&&x.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,c=((j=e.data)==null?void 0:j.definitionId)==="agent_subAgent"&&!((E=e.data)!=null&&E.isRunMode)&&!a,d=h.useCallback(D=>{const R=()=>n(D);window.requestAnimationFrame(R),window.setTimeout(R,80)},[n]),p=h.useCallback((D,R)=>{const M=G1(R);M&&(t(I=>I.map(F=>{var _,Q,Z,V,oe,ue;if(F.id!==D)return F;const P=Number(((Q=(_=F.data)==null?void 0:_.displaySize)==null?void 0:Q.width)||F.width||((Z=F.measured)==null?void 0:Z.width)||0),L=Number(((oe=(V=F.data)==null?void 0:V.displaySize)==null?void 0:oe.height)||F.height||((ue=F.measured)==null?void 0:ue.height)||0);return Math.abs(P-M.width)<2&&Math.abs(L-M.height)<2?F:{...F,width:M.width,height:M.height,data:{...F.data,displaySize:M}}})),d(D))},[d,t]),u=h.useCallback(D=>{if(a)return;const R=o.current;if(!R)return;const M=R.getBoundingClientRect();p(D,{width:Math.max(M.width,R.scrollWidth),height:Math.max(M.height,R.scrollHeight)})},[p,a]),f=h.useCallback(D=>{var oe,ue,ye,ke,ce,_e;if(!c)return;D.preventDefault(),D.stopPropagation();const R=o.current,M=R==null?void 0:R.getBoundingClientRect(),I=Number(((ue=(oe=e.data)==null?void 0:oe.displaySize)==null?void 0:ue.width)||e.width||((ye=e.measured)==null?void 0:ye.width)||(M==null?void 0:M.width)||WR),F=Number(((ce=(ke=e.data)==null?void 0:ke.displaySize)==null?void 0:ce.height)||e.height||((_e=e.measured)==null?void 0:_e.height)||(M==null?void 0:M.height)||kv),P=D.clientX,L=D.clientY,_=e.id;let Q=0;const Z=ae=>{const de=G1({width:I+ae.clientX-P,height:F+ae.clientY-L});de&&(window.cancelAnimationFrame(Q),Q=window.requestAnimationFrame(()=>p(_,de)))},V=()=>{window.cancelAnimationFrame(Q),window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(_)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[p,(T=(N=e.data)==null?void 0:N.displaySize)==null?void 0:T.height,(z=(O=e.data)==null?void 0:O.displaySize)==null?void 0:z.width,e.height,e.id,(K=e.measured)==null?void 0:K.height,(B=e.measured)==null?void 0:B.width,e.width,d,c]),m=h.useCallback(D=>{t(R=>R.filter(M=>M.id!==D))},[t]),g=h.useCallback(()=>{var I,F,P,L,_,Q,Z,V;const D=((I=e.data)==null?void 0:I.definitionId)||"",R=((F=e.data)==null?void 0:F.label)||e.id,M=((_=(L=(P=e.data)==null?void 0:P.outputs)==null?void 0:L[0])==null?void 0:_.value)||((V=(Z=(Q=e.data)==null?void 0:Q.outputs)==null?void 0:Z[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:R,definitionId:D,content:M},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),w=h.useCallback((D,R)=>{t(M=>M.map(I=>{var P;if(I.id!==D)return I;const F=Array.isArray((P=I.data)==null?void 0:P.outputs)&&I.data.outputs.length?I.data.outputs.map((L,_)=>_===0?{...L,default:R,value:R}:L):[{type:"bool",name:"value",default:R,value:R}];return{...I,data:{...I.data,body:"",outputs:F}}}))},[t]),k=h.useCallback((D,R)=>{t(M=>M.map(I=>I.id===D?{...I,data:{...I.data,body:R}}:I))},[t]),y=h.useCallback((D,R)=>{t(M=>M.map(I=>I.id===D?{...I,data:{...I.data,images:zs(R)}}:I))},[t]);return i.jsxs("div",{ref:o,className:"af-flow-node-shell"+(c?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[i.jsx(jR,{...e,data:{...e.data,onNodeContentResize:u},deleteNode:m,onProvideExpand:g,onProvideValueChange:w,onNodeBodyChange:k,onNodeImagesChange:y,modelLists:r,onModelChange:s}),c?i.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":(($=e.data)==null?void 0:$.resizeLabel)||"Resize node",role:"separator",onPointerDown:f}):null]})}const B7={[zc]:H7},Pf=["CONTROL","TOOL","PROVIDE","AGENT"],W7=1200,B1="af-flow-node--sync-flash",W1="af-flow-edge--sync-flash";function V1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function K1(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function kk(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function V7(e){const t=kk(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function pm(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function zR(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function HR(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function bw(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function U1(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function q1(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function K7(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function U7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function BR(e,t,n,r,s){const o=V7(e),a={id:t,type:zc,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:o,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return Rp(a,r,s)}const WR=320,q7=220,Y7=1600,kv=104,G7=900;function Y1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function G1(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:Y1(t,q7,Y7)||WR,height:Y1(n,kv,G7)||kv}}function X7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,o)=>(s==null?void 0:s.showOnNode)===!1?"":[o,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function X1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),o=s.get(n),a=s.get(r),l=vd(o,e.sourceHandle||"output-0","source"),c=vd(a,e.targetHandle||"input-0","target");return!l||!c?!1:Pl(l,c)}function J7(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const o=t.find(l=>l.id===n),a=vd(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:NR(a)}:null}function Q7(e,t,n){var a;const r=BR(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",o=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<o.length;l+=1){const c=o[l];if(n.handleType==="source"?Pl(n.slot,c):Pl(c,n.slot))return{slot:c,slotIndex:l,hydrated:r}}return null}function Z7(e,t){return t?e.map((n,r)=>{const s=Q7(n,e,t);if(!s)return null;const o=kk(n);return{def:n,order:r,category:o,categoryRank:Pf.indexOf(o),slot:s.slot,slotIndex:s.slotIndex,displayLabel:zR(s.hydrated.data||n),description:HR(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return s-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const eq=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function tq(e){const t=new Set,n=[];let r;const s=new RegExp(eq.source,"g");for(;(r=s.exec(e))!==null;){const o=r[1];t.has(o)||(t.add(o),n.push(o))}return n}function J1(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function da(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function hm(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const o=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],c=o.map(da),d=a.map(da);return l.map(da).includes(s)&&!c.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!c.includes(s)?`opencode:${s}`:s}function nq(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function vw(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function rq({steps:e}){const{t}=Fn();return!e||e.length===0?null:i.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,o=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
|
|
129
129
|
`),a=n.status||"pending";return i.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:o,children:[i.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),i.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?i.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?i.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?i.jsx("span",{className:"af-composer-step-chip-model",children:nq(s)}):null]}):null})]},n.index)})})}function sq(e,t){const n=e.trim(),r=t.trim();return r?n?!!(n===r||n.endsWith(r)||r.length>=8&&n.includes(r)):!1:!0}function iq(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",o=t[t.length-1];o&&o.kind===s?o.text+=s==="error"||s==="result"?`
|
|
130
130
|
${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function oq(e,t){return e==="thinking"?t("flow:composer.thinking"):e==="result"?t("flow:composer.result"):e==="assistant"?t("flow:composer.reply"):e==="error"?t("flow:composer.error"):String(e)}function aq(e){return e==="thinking"?"af-composer-ai-block af-composer-ai-block--thinking":e==="result"?"af-composer-ai-block af-composer-ai-block--result":e==="assistant"?"af-composer-ai-block af-composer-ai-block--reply":e==="error"?"af-composer-ai-block af-composer-ai-block--error":"af-composer-ai-block af-composer-ai-block--reply"}function Q1({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:o}=Fn(),a=h.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return h.useEffect(()=>{if(!s||!a.current)return;const c=a.current;requestAnimationFrame(()=>{c.scrollTop=c.scrollHeight})},[e,t,s]),i.jsxs("div",{ref:a,className:l,children:[e.map((c,d)=>c.type==="user"?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:o("flow:composer.yourQuestion")}),i.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`composer-u-${d}-${c.text.slice(0,48)}`):i.jsx("div",{className:"af-composer-thread-assistant",children:i.jsx(Z1,{segments:c.segments,running:!1})},`composer-a-${d}`)),i.jsx("div",{className:"af-composer-thread-assistant",children:i.jsx(Z1,{segments:t,running:n})})]})}function Z1({segments:e,running:t=!1}){const{t:n}=Fn(),r=e.filter(u=>u.kind==="assistant").map(u=>u.text).join(""),s=e.filter(u=>u.kind==="result").map(u=>u.text).join(""),o=sq(r,s),a=e.filter(u=>u.kind==="error").map(u=>u.text).join(`
|
|
131
131
|
`),l=e.filter(u=>u.kind!=="error"),c=o?l.filter(u=>u.kind!=="result"):l,d=iq(c),p=!!(d.length>0||a);return i.jsxs(i.Fragment,{children:[d.map((u,f)=>i.jsxs("section",{className:aq(u.kind),children:[i.jsx("div",{className:"af-composer-ai-block-label",children:oq(u.kind,n)}),i.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`${u.kind}-${f}`)),t&&!p?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),i.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?i.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[i.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),i.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function lq({fitViewEpoch:e}){const{fitView:t}=Ol(),n=h.useRef(t);return n.current=t,h.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function cq({onReady:e}){const t=J0();return h.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function eC(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function tC(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}const Ym=1500,nC=500,uq=262144,dq=2e3;function kw(e){return typeof e!="string"?"":e.length<=dq?e:`[log line truncated, ${e.length} chars]`}const fq=Ym;function pq(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const o=JSON.parse(s);return o&&o.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${o.instanceId||""}${o.label?` · ${o.label}`:""} 开始`}:o&&o.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${o.instanceId||""} 完成${o.elapsed?` (${o.elapsed})`:""}`}:o&&o.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${o.instanceId||""} 失败${o.error?`: ${o.error}`:""}`}:o&&o.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${o.uuid||""}`}:{ts:n,type:"info",text:kw(s)}}catch{return{ts:n,type:"info",text:kw(s)}}return{ts:n,type:"log",text:kw(`[${r}] ${s}`)}}function rC(e){if(!e)return[];const t=[],n=e.split(`
|
|
@@ -145,7 +145,7 @@ ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function oq(e,t){return
|
|
|
145
145
|
`);for(let l=0;l<a.length;l+=1){const c=a[l],d=a[l+1];if(o){c==='"'&&d==='"'?(s+='"',l+=1):c==='"'?o=!1:s+=c;continue}c==='"'?o=!0:c===t?(r.push(s.trim()),s=""):c===`
|
|
146
146
|
`?(r.push(s.trim()),n.push(r),r=[],s=""):s+=c}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function Po(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Vq(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(o=>Object.keys(o))));return{columns:s.map(o=>({key:o,label:o,align:"left"})),rows:e.map(o=>s.map(a=>Po(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((o,a)=>Po(o)||`Column ${a+1}`);return{columns:s.map((o,a)=>({key:String(a),label:o,align:"left"})),rows:e.slice(1).map(o=>s.map((a,l)=>Po(o[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((s,o)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||o),label:String(s.label||s.title||s.name||s.key||`Column ${o+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(o),label:Po(s)||`Column ${o+1}`,align:"left"});return r.length===0&&n.every(s=>s&&typeof s=="object"&&!Array.isArray(s))&&(r=Array.from(new Set(n.flatMap(s=>Object.keys(s)))).map(s=>({key:s,label:s,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((s,o)=>({key:String(o),label:Po(s)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((o,a)=>Po(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((o,a)=>Po(s[a])):s&&typeof s=="object"?r.map(o=>Po(s[o.key])):r.map((o,a)=>a===0?Po(s):""))}}function Kq(e){const t=String(e||"").trim();if(!t)return{columns:[],rows:[],error:""};const n=t.match(/^```(?:json|table|csv|tsv|markdown|md)?\s*\n?([\s\S]*?)```\s*$/i),r=n?n[1].trim():t;try{const l=Vq(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
|
|
147
147
|
`).split(`
|
|
148
|
-
`).filter(l=>l.trim());if(s.length>=2&&ga(s[0]).length>1&&KR(s[1])){const l=ga(s[0]),c=UR(s[1]);return{columns:l.map((d,p)=>({key:String(p),label:d,align:c[p]||"left"})),rows:s.slice(2).map(d=>ga(d)),error:""}}const o=r.includes(" ")?" ":",",a=Wq(r,o);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function Nk({content:e}){const t=h.useMemo(()=>Kq(e),[e]);return t.error||t.columns.length===0?i.jsxs("div",{className:"af-work-display-table-empty",children:[i.jsx("strong",{children:"Table data error"}),i.jsx("span",{children:t.error||"No columns found"})]}):i.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:i.jsxs("table",{className:"af-work-display-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:t.columns.map((n,r)=>i.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),i.jsx("tbody",{children:t.rows.map((n,r)=>i.jsx("tr",{children:t.columns.map((s,o)=>i.jsx("td",{style:{textAlign:s.align||"left"},children:Po(n[o])},`${s.key}-${o}`))},r))})]})})}function jk({content:e}){const t=h.useRef(null),n=h.useMemo(()=>$q(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let o=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),Sq(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{o||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),o||s({loading:!1,error:""}))}).catch(d=>{o||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,p;o=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(p=a==null?void 0:a.dispose)==null||p.call(a)}},[n]),!n.ok||r.error?i.jsxs("div",{className:"af-work-display-chart-error",children:[i.jsx("strong",{children:"Chart configuration error"}),i.jsx("span",{children:r.error||n.error})]}):i.jsxs("div",{className:"af-work-display-chart",children:[i.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?i.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const Uq="af:workspace-graph:v2",Su=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],qq=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),Yq={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},Gq={id:"workspace_scheduled_run",displayName:"Scheduled Run",label:"Scheduled Run",description:"Run the downstream workspace subgraph on a schedule.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},Xq={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},Jq={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},Qq=new Set(["png","jpg","jpeg","gif","webp","svg"]),XR=320,JR=180,QR=960,Yg=96,ZR=900,gm=52,Bc=240,Wc=160,Nv="display-ref:",Mp="0 9 * * *",Zq="Asia/Shanghai",eY="0.1.
|
|
148
|
+
`).filter(l=>l.trim());if(s.length>=2&&ga(s[0]).length>1&&KR(s[1])){const l=ga(s[0]),c=UR(s[1]);return{columns:l.map((d,p)=>({key:String(p),label:d,align:c[p]||"left"})),rows:s.slice(2).map(d=>ga(d)),error:""}}const o=r.includes(" ")?" ":",",a=Wq(r,o);return a.length>0&&a[0].length>1?{columns:a[0].map((c,d)=>c||`Column ${d+1}`).map((c,d)=>({key:String(d),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function Nk({content:e}){const t=h.useMemo(()=>Kq(e),[e]);return t.error||t.columns.length===0?i.jsxs("div",{className:"af-work-display-table-empty",children:[i.jsx("strong",{children:"Table data error"}),i.jsx("span",{children:t.error||"No columns found"})]}):i.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:i.jsxs("table",{className:"af-work-display-table",children:[i.jsx("thead",{children:i.jsx("tr",{children:t.columns.map((n,r)=>i.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),i.jsx("tbody",{children:t.rows.map((n,r)=>i.jsx("tr",{children:t.columns.map((s,o)=>i.jsx("td",{style:{textAlign:s.align||"left"},children:Po(n[o])},`${s.key}-${o}`))},r))})]})})}function jk({content:e}){const t=h.useRef(null),n=h.useMemo(()=>$q(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let o=!1,a=null,l=null,c=null;return s({loading:!0,error:""}),Sq(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{o||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),o||s({loading:!1,error:""}))}).catch(d=>{o||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,p;o=!0,c&&window.removeEventListener("resize",c),(d=l==null?void 0:l.disconnect)==null||d.call(l),(p=a==null?void 0:a.dispose)==null||p.call(a)}},[n]),!n.ok||r.error?i.jsxs("div",{className:"af-work-display-chart-error",children:[i.jsx("strong",{children:"Chart configuration error"}),i.jsx("span",{children:r.error||n.error})]}):i.jsxs("div",{className:"af-work-display-chart",children:[i.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?i.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const Uq="af:workspace-graph:v2",Su=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],qq=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),Yq={id:"workspace_run",displayName:"Run",label:"Run",description:"Run the downstream workspace subgraph connected from this node.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},Gq={id:"workspace_scheduled_run",displayName:"Scheduled Run",label:"Scheduled Run",description:"Run the downstream workspace subgraph on a schedule.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},Xq={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},Jq={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},Qq=new Set(["png","jpg","jpeg","gif","webp","svg"]),XR=320,JR=180,QR=960,Yg=96,ZR=900,gm=52,Bc=240,Wc=160,Nv="display-ref:",Mp="0 9 * * *",Zq="Asia/Shanghai",eY="0.1.80";function tY(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Ro(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function Gg(e){if(!e)return!1;const t=String(e.type||"");if(t&&/^image\//i.test(t))return!0;const n=String(e.name||"").toLowerCase().split(".").pop();return Qq.has(n)}function Xg(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const s=Ro(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function nY(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function rY(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function sY(e){var t;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)return Number(e.selectionStart??0)!==Number(e.selectionEnd??0);if(e instanceof Element&&e.closest('[contenteditable="true"]')){const n=(t=window.getSelection)==null?void 0:t.call(window);return!!(n&&!n.isCollapsed)}return!1}function iY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!sY(e)}function oY(e){const t=String(e||"").trim();if(!t)return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const o=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${o}`:`执行:${o}`}return/^\[stderr\]/.test(t)?t:""}function aY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function xc(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function lY(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,s=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,o=Number.isFinite(r)&&Number.isFinite(s)?`(+${xc(r)} / 总 ${xc(s)})`:"";return`${t+1}. ${n}${o}`}function e2(e){if(String((e==null?void 0:e.type)||"")!=="raw")return null;const t=String((e==null?void 0:e.text)||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function Nu(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function cY(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n||String((e==null?void 0:e.name)||(e==null?void 0:e.tool)||"tool_call")}function uY(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n&&t[n]&&typeof t[n]=="object"?t[n]:{}}function dY(e,t){var s;const n=String(((s=t==null?void 0:t.args)==null?void 0:s.command)||"");return/ck_fetch\.py/.test(n)?"CK 查询":/collect_important_mails\.py|list_mails_by_date\.py|read_mail_content\.py/.test(n)?"邮件脚本":/npm\s+run\s+build|build:web-ui/.test(n)?"前端构建":/python3/.test(n)?"Python 脚本":{shellToolCall:"Shell 命令",readToolCall:"读取文件/上下文",grepToolCall:"搜索代码",globToolCall:"查找文件",editToolCall:"编辑文件",writeToolCall:"写入文件"}[e]||e||"工具调用"}function fY(e){var o,a,l;const t=e2(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Nu(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=uY(t),d=cY(t),p=Nu(t.startedAtMs,c==null?void 0:c.startedAtMs),u=Nu(t.completedAtMs,c==null?void 0:c.completedAtMs),f=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},m=Number.isFinite(p)&&Number.isFinite(u)?Math.max(0,u-p):Nu(f.executionTime,f.localExecutionTimeMs),g=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||f.command||"").trim(),w=g?g.split(`
|
|
149
149
|
`).find(Boolean)||g:"";return{kind:"tool",label:dY(d,c),durationMs:Number.isFinite(m)?m:null,at:s,detail:w?w.slice(0,90):""}}if(n==="result"){const c=Nu(t.duration_ms,t.duration_api_ms);return{kind:"total",label:"运行总耗时",durationMs:Number.isFinite(c)?c:null,at:s,detail:t.is_error?"失败结束":"成功结束"}}return n==="connection"?{kind:"network",label:r==="reconnecting"?"连接重连":r==="reconnected"?"连接恢复":"连接事件",durationMs:null,at:s,detail:""}:n==="retry"?{kind:"network",label:r==="resuming"?"会话恢复":r==="starting"?"开始重试":"重试事件",durationMs:null,at:s,detail:""}:null}function cC(e,t,n,r){const s=(Array.isArray(e)?e:[]).map(k=>typeof k=="string"?{text:k}:k).filter(k=>k&&String(k.text||"").trim()),o=Array.isArray(t)?t:[],a=[...o].reverse().find(k=>(k==null?void 0:k.kind)==="total"&&Number.isFinite(Number(k.durationMs))),l=[...s].reverse().find(k=>Number.isFinite(Number(k.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,d=Nu(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),p=s.filter(k=>k.kind==="model").reduce((k,y)=>k+(Number(y.stepMs)||0),0),u=o.filter(k=>(k==null?void 0:k.kind)==="tool"),f=u.reduce((k,y)=>k+(Number(y.durationMs)||0),0),m=o.filter(k=>(k==null?void 0:k.kind)==="network").length,g=[...s.filter(k=>Number(k.stepMs)>=1e3).map(k=>({label:k.text,durationMs:Number(k.stepMs),detail:"Activity 间隔"})),...u.filter(k=>Number(k.durationMs)>=1e3).map(k=>({label:k.label,durationMs:Number(k.durationMs),detail:k.detail||"工具实际执行"}))].sort((k,y)=>y.durationMs-k.durationMs).slice(0,6),w=["耗时概览"];return Number.isFinite(d)&&w.push(`- 当前总耗时:${xc(d)}`),p>0&&w.push(`- 模型相关间隔:约 ${xc(p)}(按 Activity 间隔估算)`),u.length>0&&w.push(`- 工具实际执行:${xc(f)}(${u.length} 次完成事件)`),m>0&&w.push(`- 网络/会话恢复事件:${m} 次`),g.length>0&&(w.push(""),w.push("慢步骤"),g.forEach((k,y)=>{const b=k.detail?` · ${k.detail}`:"";w.push(`${y+1}. ${k.label}:${xc(k.durationMs)}${b}`)})),s.length>0&&(w.push(""),w.push("最近 Activity"),s.slice(-10).forEach((k,y)=>{w.push(lY(k,y))})),u.length>0&&(w.push(""),w.push("最近工具完成"),u.slice(-8).forEach((k,y)=>{const b=Number.isFinite(Number(k.durationMs))?` ${xc(k.durationMs)}`:"",x=k.detail?` · ${k.detail}`:"";w.push(`${y+1}. ${k.label}${b}${x}`)})),w.join(`
|
|
150
150
|
`)}function uC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=e2(e);if((t==null?void 0:t.type)!=="thinking")return"";const n=String((t==null?void 0:t.subtype)||"");return n&&n!=="delta"?"":String((t==null?void 0:t.text)||(t==null?void 0:t.delta)||(t==null?void 0:t.thinking)||"").trim()}function t2(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function n2(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Ck(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function r2(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function pY(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function hY(e){const t=String(e??"").trim();return t?t.includes("${")?t:r2(t):""}function s2(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const s=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),o=s?`${s}/${n}`:`\${flowDir}/${n}`,a=Array.isArray(t.args)?t.args.map(hY).filter(Boolean):[];return[pY(t,n),r2(o),...a].join(" ")}return String(t.command||"").trim()}function If(e){const t=String(Ck(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"||t==="workspace_scheduled_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function dC(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Jg(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Tf(e){return Jg(e)}function jv(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function ym(e,t){const n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim(),r=String((e==null?void 0:e.type)||"").trim();return n||r||`#${t+1}`}function fC(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),s=String((t==null?void 0:t.type)||"").trim(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function pC(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),s=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:s,kind:t}}function Sw(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(l=>[l.id,l])),o=vd(s.get(n),e.sourceHandle||"output-0","source"),a=vd(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&Pl(o,a))}function mY(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),s=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!s)return null;const o=t.find(l=>l.id===n),a=vd(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:NR(a)}:null}function gY(e,t){return t?e.map((n,r)=>{const s=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let o=0;o<s.length;o+=1){const a=s[o];if(!(t.handleType==="source"?Pl(t.slot,a):Pl(a,t.slot)))continue;const c=If(n);return{def:n,order:r,category:c,categoryRank:Su.indexOf(c),slot:a,slotIndex:o,displayLabel:Tf(n),description:jv(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return s-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function yY(e,t,n){var o,a,l,c;if(!n)return[];const r=[],s=n.handleType==="source";for(const d of e||[]){if(!d||d.id===n.nodeId)continue;const p=Array.isArray(s?(o=d.data)==null?void 0:o.inputs:(a=d.data)==null?void 0:a.outputs)?s?d.data.inputs:d.data.outputs:[];for(let u=0;u<p.length;u+=1){const f=p[u];if((f==null?void 0:f.showOnNode)===!1||!(s?Pl(n.slot,f):Pl(f,n.slot)))continue;const g=s?{source:n.nodeId,sourceHandle:n.handleId,target:d.id,targetHandle:`input-${u}`}:{source:d.id,sourceHandle:`output-${u}`,target:n.nodeId,targetHandle:n.handleId},w=(t||[]).some(k=>k.target===g.target&&k.targetHandle===g.targetHandle);r.push({node:d,nodeId:d.id,nodeLabel:((l=d.data)==null?void 0:l.label)||d.id,definitionId:((c=d.data)==null?void 0:c.definitionId)||"",slot:f,slotIndex:u,handleId:s?g.targetHandle:g.sourceHandle,connection:g,occupied:w})}}return r.sort((d,p)=>{var w,k,y,b,x,j,E,N;const u=Number(((k=(w=d.node)==null?void 0:w.position)==null?void 0:k.y)||0),f=Number(((b=(y=p.node)==null?void 0:y.position)==null?void 0:b.y)||0),m=Number(((j=(x=d.node)==null?void 0:x.position)==null?void 0:j.x)||0),g=Number(((N=(E=p.node)==null?void 0:E.position)==null?void 0:N.x)||0);return u-f||m-g||d.slotIndex-p.slotIndex||String(d.nodeId).localeCompare(String(p.nodeId))})}function Wu(e,t=!1){if(t)return"folder";const n=String(e||"").toLowerCase().split(".").pop();return n==="md"||n==="markdown"?"article":n==="html"?"web":["csv","tsv"].includes(n)?"table":["js","jsx","ts","tsx","mjs","cjs"].includes(n)?"code":["yaml","yml","json"].includes(n)?"data_object":"draft"}function xY(e,t){const n=String(e||"node").replace(/^(agent|control|provide|tool|display)_/i,"").replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"node",r=new Set(t.map(s=>s.id));for(let s=1;s<1e4;s++){const o=`${n}_${s}`;if(!r.has(o))return o}return`${n}_${Date.now().toString(36)}`}function wY(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function bY(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return Mp;const n=Math.max(1,Math.min(1440,Math.round(t)));return n<60?`*/${n} * * * *`:n===60?"0 * * * *":n<1440&&n%60===0?`0 */${n/60} * * *`:Mp}function dl(e,t=0,n=0,r=59){const s=Math.max(n,Math.min(r,Number.parseInt(String(e??t),10)||t));return String(s).padStart(2,"0")}function Ek(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${dl(t[1],9,0,23)}:${dl(t[2],0,0,59)}`:"09:00"}function Rf(e,t,n,r,s){const o=Ek(t),[a,l]=o.split(":").map(d=>Number.parseInt(d,10)),c=String(e||"daily");if(c==="weekly"){const d=Math.max(0,Math.min(6,Number.parseInt(String(n??1),10)||1));return`${l} ${a} * * ${d}`}if(c==="monthly"){const d=Math.max(1,Math.min(31,Number.parseInt(String(r??1),10)||1));return`${l} ${a} ${d} * *`}return c==="custom"?String(s||"").trim()||Mp:`${l} ${a} * * *`}function vY(e){const n=String(e||Mp).trim().split(/\s+/);if(n.length!==5)return{scheduleType:"custom",time:"09:00",weekday:1,monthDay:1};const[r,s,o,a,l]=n,c=Number.parseInt(r,10),d=Number.parseInt(s,10),p=Number.isFinite(c)&&Number.isFinite(d)&&r===String(c)&&s===String(d),u=p?`${dl(d,9,0,23)}:${dl(c,0,0,59)}`:"09:00";return p&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:u,weekday:1,monthDay:1}:p&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:u,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:p&&/^\d+$/.test(o)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:u,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(o,10)))}:{scheduleType:"custom",time:u,weekday:1,monthDay:1}}function _k(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=bY(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=vY(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=Ek(t.time||a.time||"09:00"),d=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),p=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),u=Rf(l,c,d,p,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:d,monthDay:p,cron:u,timezone:Zq,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function kY(e){const t=_k(JSON.stringify(e||{}));return JSON.stringify(t)}function SY(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function NY(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function hC(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function Nw(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.scheduleNodeId)||(n==null?void 0:n.runNodeId)||"").trim();r&&(t[r]={nextAt:hC(n.nextRunAt),lastAt:hC(n.lastTriggeredAt),lastStatus:String(n.lastStatus||(n.enabled?"armed":"disabled")),lastError:String(n.lastError||""),lastRunId:String(n.lastRunId||""),targetRunNodeId:String(n.targetRunNodeId||n.runNodeId||""),cron:String(n.cron||""),timezone:String(n.timezone||"")})}return t}function Qf(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function Qg(e){return e>0?`Group ${e+1}`:"Group"}function jY(e){return(Array.isArray(e)?e:[]).map((n,r)=>{const s=String((n==null?void 0:n.id)||`group_${r+1}`).trim(),o=Number(n==null?void 0:n.x),a=Number(n==null?void 0:n.y),l=Number(n==null?void 0:n.width),c=Number(n==null?void 0:n.height);return!s||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(c)?null:{id:s,title:String((n==null?void 0:n.title)||Qg(r)).trim()||Qg(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(Bc,Math.round(l)),height:Math.max(Wc,Math.round(c))}}).filter(Boolean)}function CY(e){var n;return jY((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:zc,position:{x:r.x,y:r.y},width:r.width,height:r.height,selected:!1,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:r.title,title:r.title,color:r.color,nodeSize:{width:r.width,height:r.height}}}))}function Cv(e){const t=Number(e==null?void 0:e.width),n=Number(e==null?void 0:e.height);return!Number.isFinite(t)||!Number.isFinite(n)?null:{width:Math.max(Bc,Math.round(t)),height:Math.max(Wc,Math.round(n))}}function xm(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:wY(t),required:!!(t!=null&&t.required),description:String((t==null?void 0:t.description)||""),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function i2(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,o)=>(s==null?void 0:s.showOnNode)===!1?"":[o,String((s==null?void 0:s.type)||""),String((s==null?void 0:s.name)||""),s!=null&&s.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function EY(e){var s,o,a,l;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{};return[i2(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((o=e==null?void 0:e.measured)==null?void 0:o.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(l=(a=t==null?void 0:t.runningRunNodeIds)==null?void 0:a.has)!=null&&l.call(a,e==null?void 0:e.id)?"running-run":""].join("::")}function jw(e,t){var m,g;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=a2(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(m=e==null?void 0:e.ui)!=null&&m.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(g=e==null?void 0:e.ui)!=null&&g.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const w of s)w!=null&&w.source&&l.add(String(w.source)),w!=null&&w.target&&l.add(String(w.target));const d=Array.from(l).map(w=>{const k=r[w]||{},y=k.definitionId||w,b=t.find(B=>B.id===y),x=Ck(b)||y,j=t.find(B=>B.id===x)||b,E=k.marketplaceRef||n2(b),N=s2(b),T=o[w]&&typeof o[w].x=="number"&&typeof o[w].y=="number"?o[w]:{x:320+l.size*20,y:180+l.size*12},O=!!$n(x),z=a[w]&&typeof a[w].width=="number"&&typeof a[w].height=="number"?{width:a[w].width,height:a[w].height}:null,K=nd(z,{display:O});return{id:w,type:zc,position:T,...K?{width:K.width,height:K.height}:{},data:{label:k.label||Jg(b)||Jg(j)||w,definitionId:x,...E?{marketplaceRef:E}:{},...b!=null&&b.packageId?{marketplacePackageId:b.packageId}:{},...b!=null&&b.version?{marketplaceVersion:b.version}:{},schemaType:t2(x,j||b),role:k.role||"normal",model:k.model||void 0,body:k.body||"",script:k.script||N||"",scriptRef:k.scriptRef||"",implementationRef:k.implementationRef||"",implementationMode:k.implementationMode||"",displayReloadKey:k.displayReloadKey||"",...K?{nodeSize:K}:{},...O&&K?{displaySize:K}:{}}}}).map(w=>Rp(w,r,t)),p=CY(e),u=s.filter(w=>(w==null?void 0:w.source)&&(w==null?void 0:w.target)).filter(w=>!p.some(k=>k.id===String(w.source)||k.id===String(w.target))).map((w,k)=>({id:w.id||`we-${w.source}-${w.target}-${k}`,source:String(w.source),target:String(w.target),sourceHandle:w.sourceHandle??void 0,targetHandle:w.targetHandle??void 0,markerEnd:{type:Ns.ArrowClosed}})),f=[...p,...d];return{nodes:f,edges:kR(u,f),instances:r}}function mC(e){return`${Nv}${e}`}function Cw(e){const t=String(e||"");return t.startsWith(Nv)?t.slice(Nv.length):t}function o2(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function Ev(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(u=>{var f;return $n((f=u==null?void 0:u.data)==null?void 0:f.definitionId)}).map(u=>[u.id,u])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],o=new Set;for(const u of r){const f=String(u||"").trim();!f||o.has(f)||!n.has(f)||(o.add(f),s.push(f))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((u,f)=>{const m=l[u];a[u]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+f*36,y:120+f*28}});const c={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(u=>{const f=nd(d[u],{display:!0});f&&(c[u]=f)});const p=o2(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...p?{viewport:p}:{}}}function _Y(e,t=[]){return Ev(e,t)}function AY(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function PY(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.left="-9999px",r.style.top="0",document.body.appendChild(r),r.focus(),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function gC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function nd(e,{display:t=!1}={}){if(!e||typeof e!="object")return null;const n=Number(e.width),r=Number(e.height);return!Number.isFinite(n)||!Number.isFinite(r)||n<=0||r<=0?null:t?{width:Math.round(n),height:Math.round(r)}:{width:gC(n,JR,QR)||XR,height:gC(r,Yg,ZR)||Yg}}function ju(e){var s,o,a,l,c,d,p,u,f,m,g;const t=!!$n((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((u=(p=e==null?void 0:e.data)==null?void 0:p.displaySize)==null?void 0:u.height)||((m=(f=e==null?void 0:e.data)==null?void 0:f.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return nd({width:n,height:r},{display:t})}function wm(e,t,n){var p,u,f,m,g,w,k,y,b,x,j,E,N;const r=(e||[]).filter(T=>!Qf(T)),s=(e||[]).filter(Qf),o=a2(th(r,n||{})),a=t.map(T=>({source:T.source,target:T.target,sourceHandle:T.sourceHandle??null,targetHandle:T.targetHandle??null})).filter(T=>!s.some(O=>O.id===T.source||O.id===T.target)),l={},c={},d=[];for(const T of r){l[T.id]={x:((p=T.position)==null?void 0:p.x)||0,y:((u=T.position)==null?void 0:u.y)||0};const O=ju(T);O&&(c[T.id]=O)}for(const T of s){const O=Number(((m=(f=T.data)==null?void 0:f.nodeSize)==null?void 0:m.width)||T.width||((g=T.measured)==null?void 0:g.width)||0),z=Number(((k=(w=T.data)==null?void 0:w.nodeSize)==null?void 0:k.height)||T.height||((y=T.measured)==null?void 0:y.height)||0);d.push({id:T.id,title:String(((b=T.data)==null?void 0:b.title)||((x=T.data)==null?void 0:x.label)||"Group"),color:String(((j=T.data)==null?void 0:j.color)||"purple"),x:Number(((E=T.position)==null?void 0:E.x)||0),y:Number(((N=T.position)==null?void 0:N.y)||0),width:Math.max(Bc,Math.round(O||Bc)),height:Math.max(Wc,Math.round(z||Wc))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:d}}}function a2(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!$n(s)||s.startsWith("provide_")||!Array.isArray(r==null?void 0:r.output)){t[n]=r;continue}t[n]={...r,output:r.output.map(a=>({...a,value:"",default:""}))}}return t}function $n(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Ac(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=$n(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),o=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&o(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&o(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&o(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function kd(e,t=""){const n=String(e||"").trim();if(!n||n.length>260||/[\r\n<>]/.test(n)||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n))return"";const r=n.replace(/^\/+/,"");if(r.includes("..")||r.startsWith("."))return"";const s=r.split("?")[0].split("#")[0].toLowerCase().split(".").pop()||"";return({html:new Set(["html","htm"]),markdown:new Set(["md","markdown","txt"]),mermaid:new Set(["mmd","mermaid","txt"]),ascii:new Set(["txt","log"]),chart:new Set(["json"]),table:new Set(["json","csv","tsv"])}[t]||new Set(["html","htm","md","markdown","txt","json","csv","tsv"])).has(s)?r:""}function IY(e){let t=String(e||"").replace(/\r\n/g,`
|
|
151
151
|
`).trim();return t.includes(`
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,0,0"
|
|
16
16
|
rel="stylesheet"
|
|
17
17
|
/>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-BpJR_bek.js"></script>
|
|
19
19
|
<link rel="stylesheet" crossorigin href="/assets/index-C7Z_ECuU.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fieldwangai/agentflow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.80",
|
|
4
4
|
"description": "Orchestration system for long-running complex agent tasks using Cursor, OpenCode, or Claude Code as execution backends",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/agentflow.mjs",
|