@fieldwangai/agentflow 0.1.96 → 0.1.97
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
|
@@ -3923,6 +3923,31 @@ function workspaceSafeNodeOutputRelPath(value) {
|
|
|
3923
3923
|
return clean;
|
|
3924
3924
|
}
|
|
3925
3925
|
|
|
3926
|
+
function workspaceDescribeNodeOutputsDir(nodeRunDir, maxEntries = 30) {
|
|
3927
|
+
const outputsDir = path.resolve(nodeRunDir || "", "outputs");
|
|
3928
|
+
if (!nodeRunDir || !fs.existsSync(outputsDir)) return "Current node outputs directory is missing.";
|
|
3929
|
+
const entries = [];
|
|
3930
|
+
const walk = (dir, rel = "") => {
|
|
3931
|
+
if (entries.length >= maxEntries) return;
|
|
3932
|
+
let children = [];
|
|
3933
|
+
try {
|
|
3934
|
+
children = fs.readdirSync(dir, { withFileTypes: true });
|
|
3935
|
+
} catch {
|
|
3936
|
+
return;
|
|
3937
|
+
}
|
|
3938
|
+
for (const child of children) {
|
|
3939
|
+
if (entries.length >= maxEntries) break;
|
|
3940
|
+
const childRel = rel ? path.posix.join(rel, child.name) : child.name;
|
|
3941
|
+
entries.push(child.isDirectory() ? `${childRel}/` : childRel);
|
|
3942
|
+
if (child.isDirectory()) walk(path.join(dir, child.name), childRel);
|
|
3943
|
+
}
|
|
3944
|
+
};
|
|
3945
|
+
walk(outputsDir);
|
|
3946
|
+
if (!entries.length) return "Current node outputs directory is empty.";
|
|
3947
|
+
const suffix = entries.length >= maxEntries ? `\n...showing first ${maxEntries} entries` : "";
|
|
3948
|
+
return `Current node outputs entries:\n${entries.map((entry) => `- outputs/${entry}`).join("\n")}${suffix}`;
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3926
3951
|
function workspacePublishNodeOutputFile(runPackage, relPath) {
|
|
3927
3952
|
if (!String(relPath || "").trim()) return "";
|
|
3928
3953
|
const clean = workspaceSafeNodeOutputRelPath(relPath);
|
|
@@ -3939,6 +3964,7 @@ function workspacePublishNodeOutputFile(runPackage, relPath) {
|
|
|
3939
3964
|
throw new Error(
|
|
3940
3965
|
`Agent returned resultFile but did not create it under this node's outputs: ${clean}\n` +
|
|
3941
3966
|
`Expected file: ${src}\n` +
|
|
3967
|
+
`${workspaceDescribeNodeOutputsDir(nodeRunDir)}\n` +
|
|
3942
3968
|
`Write outputs using a relative path from the node cwd, or use AGENTFLOW_OUTPUTS_DIR.`
|
|
3943
3969
|
);
|
|
3944
3970
|
}
|
|
@@ -4160,6 +4186,8 @@ function workspaceOutputProtocolRequirements(graph, nodeId) {
|
|
|
4160
4186
|
"",
|
|
4161
4187
|
`请把${resultKindText}结果写入 \`${resultFile}\`。${resultGuidance}`,
|
|
4162
4188
|
`必须先在当前执行目录下创建 \`${resultFile}\`,不要写到绝对路径或其它 run 目录;然后再返回下面的 agentflow envelope。`,
|
|
4189
|
+
`只在最终回复里写 \`resultFile: ${resultFile}\` 不会创建文件;必须通过工具或脚本实际写入该文件。`,
|
|
4190
|
+
`返回前请确认 \`${resultFile}\` 已存在且非空(例如执行 \`test -s ${resultFile}\` 或等价检查);如果无法创建文件,不要返回成功 envelope。`,
|
|
4163
4191
|
downstreamInputRequirements ? `\n${downstreamInputRequirements}` : "",
|
|
4164
4192
|
...(slots.length ? [`额外输出:${slots.map((name) => `\`${name}\``).join("、")}。短值可写在 \`outParams\`,文件值写成 \`outParams.<name>File\`。`] : []),
|
|
4165
4193
|
"最终只输出下面的 agentflow envelope,不要输出解释、进度或其它文字:",
|
|
@@ -7057,6 +7085,24 @@ function prdWorkflowSafeStateId(value) {
|
|
|
7057
7085
|
.slice(0, 128) || "unknown";
|
|
7058
7086
|
}
|
|
7059
7087
|
|
|
7088
|
+
function prdWorkflowReviewIdFromRequest(tapdId, payload = {}, durability = "temporary") {
|
|
7089
|
+
if (durability === "temporary") return `r-${crypto.randomBytes(5).toString("hex")}`;
|
|
7090
|
+
const requested = String(payload.reviewId || payload.review_id || "").trim();
|
|
7091
|
+
if (!requested) return `review_${Date.now().toString(36)}_${crypto.randomBytes(4).toString("hex")}`;
|
|
7092
|
+
const safeRequested = prdWorkflowSafeStateId(requested);
|
|
7093
|
+
if (safeRequested.length <= 48) return safeRequested;
|
|
7094
|
+
const stage = String(payload.stage || payload.stageKey || payload.stage_key || "review").trim();
|
|
7095
|
+
const action = String(payload.action || payload.actionId || payload.action_id || "").trim();
|
|
7096
|
+
const issueKey = String(payload.issueKey || payload.issue_key || payload.issue || "").trim();
|
|
7097
|
+
const stageHead = prdWorkflowSafeStateId(stage.split(":")[0] || stage || "review").slice(0, 20);
|
|
7098
|
+
const digest = crypto
|
|
7099
|
+
.createHash("sha256")
|
|
7100
|
+
.update(JSON.stringify({ tapdId: String(tapdId || ""), requested, stage, action, issueKey }))
|
|
7101
|
+
.digest("hex")
|
|
7102
|
+
.slice(0, 10);
|
|
7103
|
+
return prdWorkflowSafeStateId(["review", tapdId, stageHead, digest].filter(Boolean).join("-")).slice(0, 64);
|
|
7104
|
+
}
|
|
7105
|
+
|
|
7060
7106
|
function prdWorkflowStatePath(scopedRoot, tapdId) {
|
|
7061
7107
|
const rootDir = scopedRoot || process.cwd();
|
|
7062
7108
|
return path.join(rootDir, ".workspace", "prd-flow", "workflow-state", `${prdWorkflowSafeStateId(tapdId)}.json`);
|
|
@@ -7447,12 +7493,7 @@ function prdWorkflowCreateReview(scopedRoot, tapdId, payload = {}, urlBase = "")
|
|
|
7447
7493
|
if (!content.trim()) throw new Error("Missing review markdown");
|
|
7448
7494
|
const title = String(payload.title || payload.label || "PRD Workflow Review").trim().slice(0, 160) || "PRD Workflow Review";
|
|
7449
7495
|
const durability = String(payload.durability || (payload.durable === true || payload.permanent === true ? "durable" : "temporary")).trim().toLowerCase() || "temporary";
|
|
7450
|
-
const
|
|
7451
|
-
const reviewId = durability === "temporary"
|
|
7452
|
-
? `r-${crypto.randomBytes(5).toString("hex")}`
|
|
7453
|
-
: requestedReviewId
|
|
7454
|
-
? prdWorkflowSafeStateId(requestedReviewId)
|
|
7455
|
-
: `review_${Date.now().toString(36)}_${crypto.randomBytes(4).toString("hex")}`;
|
|
7496
|
+
const reviewId = prdWorkflowReviewIdFromRequest(tapdId, payload, durability);
|
|
7456
7497
|
const paths = prdWorkflowReviewPaths(scopedRoot, tapdId, reviewId);
|
|
7457
7498
|
const ttlDaysRaw = Number(payload.ttlDays || payload.ttl_days || (durability === "temporary" ? 7 : 0));
|
|
7458
7499
|
const ttlDays = Number.isFinite(ttlDaysRaw) && ttlDaysRaw > 0 ? ttlDaysRaw : 0;
|
|
@@ -179,7 +179,7 @@ ${n("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:n("project:noNodeFil
|
|
|
179
179
|
<\/script>
|
|
180
180
|
</body>
|
|
181
181
|
</html>`}const AI=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),m7=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function g7(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 y7(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 Ij(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 PI(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(AI.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 II(e){return{inputNames:Ij(e==null?void 0:e.inputs),outputNames:Ij(e==null?void 0:e.outputs)}}function x7(e,t,n){const r=II(t),s=y7(e),i=[];for(const a of s)if(!PI(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();i.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return i}function w7(e,t){const n=II(t),r=/\$\{([^}]*)\}/g,s=[];let i=0,a;for(;(a=r.exec(e))!==null;){a.index>i&&s.push({kind:"plain",text:e.slice(i,a.index)});const l=a[0],c=PI(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),i=a.index+l.length}return i<e.length&&s.push({kind:"plain",text:e.slice(i)}),s}function b7(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function k7(e){return e.map(t=>{const n=b7(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 v7(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 i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:i?t("flow:placeholder.inputSubtitle",{type:i}):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 i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:i?t("flow:placeholder.outputSubtitle",{type:i}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of m7)AI.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function S7(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(i=>String(i).toLowerCase()).some(i=>i.includes(n))):e}function N7(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 i=e.clientWidth;if(i<=0)return null;s.style.width=`${i}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),u=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:u}}function Hf({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:p}=Pr(),d=m.useId(),f=m.useRef(null),h=m.useRef(null),[g,k]=m.useState(0),[w,y]=m.useState(0),[v,x]=m.useState(null),C=m.useMemo(()=>Gi(c),[c]),N=m.useMemo(()=>x7(e,a,p),[e,a,p]),j=N.length>0,E=m.useMemo(()=>w7(e,a),[e,a]),P=m.useMemo(()=>k7(E),[E]),O=m.useMemo(()=>n?null:g7(e,g),[e,g,n]),H=m.useMemo(()=>{if(!O)return[];const D=v7(a,p);return S7(D,O.query)},[O,a,p]);m.useEffect(()=>{y(D=>{const M=Math.max(0,H.length-1);return Math.min(Math.max(0,D),M)})},[H.length]);const W=m.useCallback(()=>{const D=f.current;if(!D||!O||H.length===0){x(null);return}const M=N7(D,g);if(!M){x(null);return}const I=4,z=44,_=13.5*16,U=Math.min(H.length*z+8,_);let B=M.bottom+I;B+U>window.innerHeight-8&&(B=Math.max(8,M.top-U-I));const L=288;let ee=M.left;ee=Math.max(8,Math.min(ee,window.innerWidth-L-8)),x({top:B,left:ee})},[O,H.length,g]);m.useLayoutEffect(()=>{if(!O||H.length===0){x(null);return}const D=requestAnimationFrame(()=>W());return()=>cancelAnimationFrame(D)},[O,H.length,g,e,W]),m.useEffect(()=>{if(!O||H.length===0)return;const D=()=>W();return window.addEventListener("scroll",D,!0),window.addEventListener("resize",D),()=>{window.removeEventListener("scroll",D,!0),window.removeEventListener("resize",D)}},[O,H.length,W]);const F=m.useCallback(D=>{if(!O)return;const{atIndex:M}=O,I=e.slice(0,M)+"${"+D+"}"+e.slice(g);t(I);const z=M+D.length+3;queueMicrotask(()=>{const _=f.current;_&&(_.focus(),_.setSelectionRange(z,z)),k(z)})},[O,e,g,t]),$=m.useCallback(()=>{const D=f.current,M=h.current;!D||!M||(M.scrollTop=D.scrollTop,M.scrollLeft=D.scrollLeft,O&&H.length>0&&queueMicrotask(()=>W()))},[O,H.length,W]),R=m.useCallback(D=>{if(!n&&O&&H.length>0&&(D.key==="ArrowDown"||D.key==="ArrowUp"||D.key==="Enter")){if(D.key==="ArrowDown")D.preventDefault(),y(M=>(M+1)%H.length);else if(D.key==="ArrowUp")D.preventDefault(),y(M=>(M-1+H.length)%H.length);else if(D.key==="Enter"&&!D.shiftKey){D.preventDefault();const M=H[w];M&&F(M.insert)}}},[n,O,H,w,F]),K=m.useCallback(async D=>{if(n||typeof u!="function")return!1;const M=await CI({files:D,body:e,images:C});return M?(t(M.body),u(M.images),queueMicrotask(()=>{const I=f.current;if(!I)return;I.focus();const z=M.body.length;I.setSelectionRange(z,z),k(z)}),!0):!1},[n,C,t,u,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[C.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:C.map((D,M)=>o.jsxs("span",{className:"af-body-image-chip",title:D.name,children:[o.jsx("img",{src:D.dataUrl,alt:""}),o.jsxs("span",{children:["[",D.label||`image ${M+1}`,"]"]})]},D.id||M))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:P+`
|
|
182
|
-
`}}),o.jsx("textarea",{ref:f,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":j,"aria-describedby":j?d:void 0,onChange:D=>{t(D.target.value),k(D.target.selectionStart??D.target.value.length)},onSelect:D=>{const M=D.target;M instanceof HTMLTextAreaElement&&k(M.selectionStart??0)},onClick:D=>{const M=D.target;M instanceof HTMLTextAreaElement&&k(M.selectionStart??0)},onKeyUp:D=>{const M=D.target;M instanceof HTMLTextAreaElement&&k(M.selectionStart??M.value.length)},onKeyDown:R,onPaste:D=>{const M=jI(D);M.length!==0&&(D.preventDefault(),K(M).catch(()=>{}))},onDragOver:D=>{ju(D).length>0&&D.preventDefault()},onDrop:D=>{const M=ju(D);M.length!==0&&(D.preventDefault(),K(M).catch(()=>{}))},onScroll:$})]}),O&&H.length>0&&v?Cr.createPortal(o.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:v.top,left:v.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:H.map((D,M)=>o.jsx("li",{role:"option","aria-selected":M===w,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(M===w?" af-composer-mention-item--active":""),onMouseDown:I=>I.preventDefault(),onMouseEnter:()=>y(M),onClick:()=>F(D.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${D.insert}}`}),D.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:D.subtitle}):null]})},`${D.section}-${D.insert}`))}),document.body):null,j?o.jsx("p",{id:d,className:"af-body-ph-issues",role:"status",children:N.map(D=>D.message).join(" · ")}):null]})}const j7=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Uc(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Tj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Pr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=d=>r(n.filter((f,h)=>h!==d)),u=(d,f,h)=>{const g=n.map((k,w)=>{if(w!==d)return k;const y={...k,[f]:h};return f==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},p=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.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")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.description")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((d,f)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${f}`,children:[p,"-",f]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:d.type,onChange:h=>u(f,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:f}),children:["node","text","file","bool"].map(h=>o.jsx("option",{value:h,children:h},h))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:d.name,onChange:h=>u(f,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:f})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:d.default,onChange:h=>u(f,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:f})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:d.description||"",onChange:h=>u(f,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:f})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!d.required,onChange:h=>{i||u(f,"required",h.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:f})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:d.showOnNode!==!1,onChange:h=>u(f,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:f})})}),o.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:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${f}`))]}):null]})}function C7({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:p,ioSlots:d}){const{t:f}=Pr(),[h,g]=m.useState(!1),[k,w]=m.useState(!1),[y,v]=m.useState({status:"idle",message:""}),x=m.useCallback($=>{t(R=>R&&{...R,...$})},[t]),{cursorList:C,opencodeList:N,claudeCodeList:j,codexList:E,currentNotInLists:P}=m.useMemo(()=>{const $=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],R=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],K=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],D=Array.isArray(s==null?void 0:s.codex)?s.codex:[],M=new Set([...$,...R,...K,...D].map(Uc)),I=((e==null?void 0:e.model)??"").trim(),z=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("codex:")?I.slice(6):I.startsWith("claude-code:")?I.slice(12):I,_=I&&!M.has(z)?I:"";return{cursorList:$,opencodeList:R,claudeCodeList:K,codexList:D,currentNotInLists:_}},[s,e==null?void 0:e.model]);if(!e)return null;const O=String(e.script??""),H=n==="tool_nodejs"||O.trim()!=="",W=typeof c=="function"&&!i&&(e==null?void 0:e.newId),F=async()=>{if(W){v({status:"running",message:f("flow:nodeProps.publishRunning")});try{const $=await c(e,n);v({status:"success",message:$!=null&&$.definitionId?f("flow:nodeProps.publishSuccessWithId",{id:$.definitionId}):f("flow:nodeProps.publishSuccess")})}catch($){v({status:"error",message:String(($==null?void 0:$.message)||$)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:f("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:F,disabled:!W||y.status==="running",title:f("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?f("flow:nodeProps.publishing"):f("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:f("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?o.jsx("p",{className:"af-err af-node-props-err",children:p}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:f("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:f("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:$=>x({newId:$.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":f("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:$=>x({label:$.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:rd.includes(e.role)?e.role:f("flow:roles.normal"),onChange:$=>x({role:$.target.value}),disabled:i,children:rd.map($=>o.jsx("option",{value:$,children:$},$))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:f("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const $=(e.model||"").trim();return $?P||$:""})(),onChange:$=>x({model:$.target.value}),disabled:i,"aria-label":f("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),P?o.jsxs("option",{value:P,children:[P,f("flow:nodeProps.yamlValueNotInList")]}):null,C.length>0?o.jsx("optgroup",{label:"Cursor",children:C.map($=>o.jsx("option",{value:Uc($),children:$},`c-${$}`))}):null,N.length>0?o.jsx("optgroup",{label:"OpenCode",children:N.map($=>o.jsx("option",{value:`opencode:${Uc($)}`,children:$},`o-${$}`))}):null,E.length>0?o.jsx("optgroup",{label:"Codex",children:E.map($=>o.jsx("option",{value:`codex:${Uc($)}`,children:$},`codex-${$}`))}):null,j.length>0?o.jsx("optgroup",{label:"Claude Code",children:j.map($=>o.jsx("option",{value:`claude-code:${Uc($)}`,children:$},`cc-${$}`))}):null]})]}),o.jsx(Tj,{kind:"input",label:f("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:$=>x({inputs:$}),disabled:i,requiredReadonly:!u}),o.jsx(Tj,{kind:"output",label:f("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:$=>x({outputs:$}),disabled:i,requiredReadonly:!u}),H?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:f("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>w(!0),"aria-label":f("flow:nodeProps.expandEditScript"),title:f("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Hf,{value:O,onChange:$=>x({script:$}),disabled:i,placeholder:f("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:d,variant:"drawer"})]}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),o.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:$=>x({scriptRef:$.target.value}),disabled:i,spellCheck:!1,autoComplete:"off"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),o.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:$=>x({implementationRef:$.target.value}),disabled:i,spellCheck:!1,autoComplete:"off"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),o.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:$=>x({implementationMode:$.target.value}),disabled:i,children:[o.jsx("option",{value:"",children:"auto"}),o.jsx("option",{value:"script",children:"script"}),o.jsx("option",{value:"steps",children:"steps"}),o.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:f("flow:node.userPrompt")}),o.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:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Hf,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:f("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:d,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:f("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||f("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),k?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editScript"),onMouseDown:$=>{$.target===$.currentTarget&&w(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>w(!1),"aria-label":f("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Hf,{value:O,onChange:$=>x({script:$}),disabled:i,placeholder:f("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:d,variant:"expand"})]})}):null,h?o.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:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":f("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Hf,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:f("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:d,variant:"expand"})]})}):null]})}function _7({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=Pr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[p,d]=m.useState(!1),[f,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),d(!1);const y=requestAnimationFrame(()=>{var v;return(v=l.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),k=g===n;async function w(y){if(y.preventDefault(),!(!k||p)){d(!0),h("");try{const v=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),x=await v.json().catch(()=>({}));if(!v.ok){h(typeof x.error=="string"?x.error:i("project:archiveModal.archiveFailed"));return}s()}catch(v){h(String((v==null?void 0:v.message)||v))}finally{d(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.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:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:w,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:y=>u(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),f?o.jsx("p",{className:"af-err af-new-pipeline-err",children:f}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!k||p,children:i(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function E7({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=Pr(),l=m.useId(),c=m.useRef(null),[u,p]=m.useState(""),[d,f]=m.useState(!1),[h,g]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),g(""),f(!1);const v=requestAnimationFrame(()=>{var x;return(x=c.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(v)},[e,n]),!e)return null;const k=u.trim(),w=k===n;async function y(v){if(v.preventDefault(),!w||d)return;f(!0),g("");let x=null;try{const C=new AbortController;x=setTimeout(()=>C.abort(),15e3);const N=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:k,flowArchived:s}),signal:C.signal}),j=await N.json().catch(()=>({}));if(!N.ok){g(typeof j.error=="string"?j.error:a("project:deleteModal.deleteFailed"));return}try{for(let E=localStorage.length-1;E>=0;E--){const P=localStorage.key(E);P&&(P.startsWith(`af:composer-sessions:${n}:${r}`)||P.startsWith(`af:composer-active-session:${n}:${r}`)||P.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(P)}}catch{}await i()}catch(C){if((C==null?void 0:C.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((C==null?void 0:C.message)||C))}finally{x&&clearTimeout(x),f(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:u,onChange:v=>p(v.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":k.length>0&&!w})]}),h?o.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:d,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!w||d,children:a(d?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}const Rj=80,A7=220;function P7(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:i,measured:a,internals:l,...c}=e;return c}function I7(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Wf(e,t,n){const r={nodes:Array.isArray(e)?e.map(P7):[],edges:Array.isArray(t)?t.map(I7):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function ey(e,t){const n=[...e,t];return n.length>Rj?n.slice(n.length-Rj):n}function T7({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[i,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),p=m.useRef(null),d=m.useRef(null),f=m.useRef(null),h=m.useRef(!1),g=m.useCallback(()=>a(N=>N+1),[]),k=m.useCallback(()=>{f.current&&(window.clearTimeout(f.current),f.current=null)},[]),w=m.useCallback(()=>{k();const N=p.current,j=d.current;return p.current=null,d.current=null,!N||!j||N.signature===j.signature?(j&&(u.current=j),!1):(l.current=ey(l.current,N),c.current=[],u.current=j,g(),!0)},[g,k]),y=m.useCallback((N=[],j=[],E={})=>{k(),l.current=[],c.current=[],p.current=null,d.current=null,u.current=Wf(N,j,E),h.current=!1,g()},[g,k]),v=m.useCallback(N=>{h.current=!0,u.current=N,p.current=null,d.current=null,k(),s==null||s(N.value),g()},[g,k,s]),x=m.useCallback(()=>{w();const N=u.current||Wf(e,t,n),j=l.current.pop();return j?(c.current=ey(c.current,N),v(j),!0):(g(),!1)},[g,t,n,w,e,v]),C=m.useCallback(()=>{w();const N=u.current||Wf(e,t,n),j=c.current.pop();return j?(l.current=ey(l.current,N),v(j),!0):(g(),!1)},[g,t,n,w,e,v]);return m.useEffect(()=>()=>k(),[k]),m.useEffect(()=>{if(!r)return;const N=Wf(e,t,n);if(!u.current){u.current=N;return}if(h.current){h.current=!1,u.current=N;return}N.signature!==u.current.signature&&(p.current||(p.current=u.current),d.current=N,k(),f.current=window.setTimeout(()=>{w()},A7))},[k,t,r,n,w,e]),{canUndo:l.current.length>0||!!p.current,canRedo:c.current.length>0,resetHistory:y,undo:x,redo:C,version:i}}const R7="af:workspace-graph:v2",Mj="agentflow.workspace.sidebarCollapsed",dl=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],M7=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),$7={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:""}]},L7={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:""}]},O7={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}]},D7={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}]},F7={id:"control_cd_workspace",displayName:"加载知识库",label:"加载知识库",description:"Select one or more knowledge sources and pass knowledgeContext to downstream nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"path",default:"",showOnNode:!1},{type:"text",name:"label",default:"",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"knowledgeContext",default:"",showOnNode:!0},{type:"text",name:"workspaceContext",default:"",showOnNode:!1},{type:"file",name:"cwd",default:"",showOnNode:!1}]},z7={id:"workspace_one_click_task",displayName:"一键任务",label:"一键任务",description:"输入任务,选择 Skills、workspace 上下文和输出类型后直接运行。",type:"agent",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1},{type:"bool",name:"includeWorkspaceContext",default:"true",showOnNode:!1},{type:"text",name:"displayType",default:"markdown",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"content",default:"",showOnNode:!0},{type:"text",name:"displayType",default:"markdown",showOnNode:!1}]},B7=new Set(["png","jpg","jpeg","gif","webp","svg"]),TI=320,RI=180,MI=960,gh=96,$I=900,ew=520,tw=320,Vf=52,Ta=240,Ra=160,nw="display-ref:",id="0 9 * * *",H7="Asia/Shanghai",W7="0.1.96";function V7(){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 $r(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 tk(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
|
|
182
|
+
`}}),o.jsx("textarea",{ref:f,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":j,"aria-describedby":j?d:void 0,onChange:D=>{t(D.target.value),k(D.target.selectionStart??D.target.value.length)},onSelect:D=>{const M=D.target;M instanceof HTMLTextAreaElement&&k(M.selectionStart??0)},onClick:D=>{const M=D.target;M instanceof HTMLTextAreaElement&&k(M.selectionStart??0)},onKeyUp:D=>{const M=D.target;M instanceof HTMLTextAreaElement&&k(M.selectionStart??M.value.length)},onKeyDown:R,onPaste:D=>{const M=jI(D);M.length!==0&&(D.preventDefault(),K(M).catch(()=>{}))},onDragOver:D=>{ju(D).length>0&&D.preventDefault()},onDrop:D=>{const M=ju(D);M.length!==0&&(D.preventDefault(),K(M).catch(()=>{}))},onScroll:$})]}),O&&H.length>0&&v?Cr.createPortal(o.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:v.top,left:v.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:H.map((D,M)=>o.jsx("li",{role:"option","aria-selected":M===w,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(M===w?" af-composer-mention-item--active":""),onMouseDown:I=>I.preventDefault(),onMouseEnter:()=>y(M),onClick:()=>F(D.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${D.insert}}`}),D.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:D.subtitle}):null]})},`${D.section}-${D.insert}`))}),document.body):null,j?o.jsx("p",{id:d,className:"af-body-ph-issues",role:"status",children:N.map(D=>D.message).join(" · ")}):null]})}const j7=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Uc(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Tj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Pr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=d=>r(n.filter((f,h)=>h!==d)),u=(d,f,h)=>{const g=n.map((k,w)=>{if(w!==d)return k;const y={...k,[f]:h};return f==="required"&&h===!0&&(y.showOnNode=!0),y});r(g)},p=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.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")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:p})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.description")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((d,f)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${p}-${f}`,children:[p,"-",f]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:d.type,onChange:h=>u(f,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:f}),children:["node","text","file","bool"].map(h=>o.jsx("option",{value:h,children:h},h))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:d.name,onChange:h=>u(f,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:f})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:d.default,onChange:h=>u(f,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:f})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:d.description||"",onChange:h=>u(f,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:f})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!d.required,onChange:h=>{i||u(f,"required",h.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:f})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:d.showOnNode!==!1,onChange:h=>u(f,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:f})})}),o.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:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${p}-${f}`))]}):null]})}function C7({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:p,ioSlots:d}){const{t:f}=Pr(),[h,g]=m.useState(!1),[k,w]=m.useState(!1),[y,v]=m.useState({status:"idle",message:""}),x=m.useCallback($=>{t(R=>R&&{...R,...$})},[t]),{cursorList:C,opencodeList:N,claudeCodeList:j,codexList:E,currentNotInLists:P}=m.useMemo(()=>{const $=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],R=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],K=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],D=Array.isArray(s==null?void 0:s.codex)?s.codex:[],M=new Set([...$,...R,...K,...D].map(Uc)),I=((e==null?void 0:e.model)??"").trim(),z=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("codex:")?I.slice(6):I.startsWith("claude-code:")?I.slice(12):I,_=I&&!M.has(z)?I:"";return{cursorList:$,opencodeList:R,claudeCodeList:K,codexList:D,currentNotInLists:_}},[s,e==null?void 0:e.model]);if(!e)return null;const O=String(e.script??""),H=n==="tool_nodejs"||O.trim()!=="",W=typeof c=="function"&&!i&&(e==null?void 0:e.newId),F=async()=>{if(W){v({status:"running",message:f("flow:nodeProps.publishRunning")});try{const $=await c(e,n);v({status:"success",message:$!=null&&$.definitionId?f("flow:nodeProps.publishSuccessWithId",{id:$.definitionId}):f("flow:nodeProps.publishSuccess")})}catch($){v({status:"error",message:String(($==null?void 0:$.message)||$)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:f("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:F,disabled:!W||y.status==="running",title:f("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?f("flow:nodeProps.publishing"):f("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:f("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[p?o.jsx("p",{className:"af-err af-node-props-err",children:p}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:f("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:f("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:$=>x({newId:$.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":f("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:$=>x({label:$.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:rd.includes(e.role)?e.role:f("flow:roles.normal"),onChange:$=>x({role:$.target.value}),disabled:i,children:rd.map($=>o.jsx("option",{value:$,children:$},$))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:f("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const $=(e.model||"").trim();return $?P||$:""})(),onChange:$=>x({model:$.target.value}),disabled:i,"aria-label":f("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),P?o.jsxs("option",{value:P,children:[P,f("flow:nodeProps.yamlValueNotInList")]}):null,C.length>0?o.jsx("optgroup",{label:"Cursor",children:C.map($=>o.jsx("option",{value:Uc($),children:$},`c-${$}`))}):null,N.length>0?o.jsx("optgroup",{label:"OpenCode",children:N.map($=>o.jsx("option",{value:`opencode:${Uc($)}`,children:$},`o-${$}`))}):null,E.length>0?o.jsx("optgroup",{label:"Codex",children:E.map($=>o.jsx("option",{value:`codex:${Uc($)}`,children:$},`codex-${$}`))}):null,j.length>0?o.jsx("optgroup",{label:"Claude Code",children:j.map($=>o.jsx("option",{value:`claude-code:${Uc($)}`,children:$},`cc-${$}`))}):null]})]}),o.jsx(Tj,{kind:"input",label:f("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:$=>x({inputs:$}),disabled:i,requiredReadonly:!u}),o.jsx(Tj,{kind:"output",label:f("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:$=>x({outputs:$}),disabled:i,requiredReadonly:!u}),H?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[f("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:f("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>w(!0),"aria-label":f("flow:nodeProps.expandEditScript"),title:f("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Hf,{value:O,onChange:$=>x({script:$}),disabled:i,placeholder:f("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:d,variant:"drawer"})]}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),o.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:$=>x({scriptRef:$.target.value}),disabled:i,spellCheck:!1,autoComplete:"off"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),o.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:$=>x({implementationRef:$.target.value}),disabled:i,spellCheck:!1,autoComplete:"off"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),o.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:$=>x({implementationMode:$.target.value}),disabled:i,children:[o.jsx("option",{value:"",children:"auto"}),o.jsx("option",{value:"script",children:"script"}),o.jsx("option",{value:"steps",children:"steps"}),o.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:f("flow:node.userPrompt")}),o.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:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Hf,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:f("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:d,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:f("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||f("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),k?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":f("flow:nodeProps.editScript"),onMouseDown:$=>{$.target===$.currentTarget&&w(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>w(!1),"aria-label":f("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Hf,{value:O,onChange:$=>x({script:$}),disabled:i,placeholder:f("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:d,variant:"expand"})]})}):null,h?o.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:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:f("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":f("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Hf,{value:e.body,onChange:$=>x({body:$}),images:e.images,onImagesChange:$=>x({images:$}),disabled:i,placeholder:f("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:d,variant:"expand"})]})}):null]})}function _7({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=Pr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[p,d]=m.useState(!1),[f,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),d(!1);const y=requestAnimationFrame(()=>{var v;return(v=l.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=c.trim(),k=g===n;async function w(y){if(y.preventDefault(),!(!k||p)){d(!0),h("");try{const v=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),x=await v.json().catch(()=>({}));if(!v.ok){h(typeof x.error=="string"?x.error:i("project:archiveModal.archiveFailed"));return}s()}catch(v){h(String((v==null?void 0:v.message)||v))}finally{d(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.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:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:w,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:y=>u(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),f?o.jsx("p",{className:"af-err af-new-pipeline-err",children:f}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!k||p,children:i(p?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function E7({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=Pr(),l=m.useId(),c=m.useRef(null),[u,p]=m.useState(""),[d,f]=m.useState(!1),[h,g]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),g(""),f(!1);const v=requestAnimationFrame(()=>{var x;return(x=c.current)==null?void 0:x.focus()});return()=>cancelAnimationFrame(v)},[e,n]),!e)return null;const k=u.trim(),w=k===n;async function y(v){if(v.preventDefault(),!w||d)return;f(!0),g("");let x=null;try{const C=new AbortController;x=setTimeout(()=>C.abort(),15e3);const N=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:k,flowArchived:s}),signal:C.signal}),j=await N.json().catch(()=>({}));if(!N.ok){g(typeof j.error=="string"?j.error:a("project:deleteModal.deleteFailed"));return}try{for(let E=localStorage.length-1;E>=0;E--){const P=localStorage.key(E);P&&(P.startsWith(`af:composer-sessions:${n}:${r}`)||P.startsWith(`af:composer-active-session:${n}:${r}`)||P.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(P)}}catch{}await i()}catch(C){if((C==null?void 0:C.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((C==null?void 0:C.message)||C))}finally{x&&clearTimeout(x),f(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:u,onChange:v=>p(v.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":k.length>0&&!w})]}),h?o.jsx("p",{className:"af-err af-new-pipeline-err",children:h}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:d,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!w||d,children:a(d?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}const Rj=80,A7=220;function P7(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:i,measured:a,internals:l,...c}=e;return c}function I7(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Wf(e,t,n){const r={nodes:Array.isArray(e)?e.map(P7):[],edges:Array.isArray(t)?t.map(I7):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function ey(e,t){const n=[...e,t];return n.length>Rj?n.slice(n.length-Rj):n}function T7({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[i,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),p=m.useRef(null),d=m.useRef(null),f=m.useRef(null),h=m.useRef(!1),g=m.useCallback(()=>a(N=>N+1),[]),k=m.useCallback(()=>{f.current&&(window.clearTimeout(f.current),f.current=null)},[]),w=m.useCallback(()=>{k();const N=p.current,j=d.current;return p.current=null,d.current=null,!N||!j||N.signature===j.signature?(j&&(u.current=j),!1):(l.current=ey(l.current,N),c.current=[],u.current=j,g(),!0)},[g,k]),y=m.useCallback((N=[],j=[],E={})=>{k(),l.current=[],c.current=[],p.current=null,d.current=null,u.current=Wf(N,j,E),h.current=!1,g()},[g,k]),v=m.useCallback(N=>{h.current=!0,u.current=N,p.current=null,d.current=null,k(),s==null||s(N.value),g()},[g,k,s]),x=m.useCallback(()=>{w();const N=u.current||Wf(e,t,n),j=l.current.pop();return j?(c.current=ey(c.current,N),v(j),!0):(g(),!1)},[g,t,n,w,e,v]),C=m.useCallback(()=>{w();const N=u.current||Wf(e,t,n),j=c.current.pop();return j?(l.current=ey(l.current,N),v(j),!0):(g(),!1)},[g,t,n,w,e,v]);return m.useEffect(()=>()=>k(),[k]),m.useEffect(()=>{if(!r)return;const N=Wf(e,t,n);if(!u.current){u.current=N;return}if(h.current){h.current=!1,u.current=N;return}N.signature!==u.current.signature&&(p.current||(p.current=u.current),d.current=N,k(),f.current=window.setTimeout(()=>{w()},A7))},[k,t,r,n,w,e]),{canUndo:l.current.length>0||!!p.current,canRedo:c.current.length>0,resetHistory:y,undo:x,redo:C,version:i}}const R7="af:workspace-graph:v2",Mj="agentflow.workspace.sidebarCollapsed",dl=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],M7=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),$7={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:""}]},L7={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:""}]},O7={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}]},D7={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}]},F7={id:"control_cd_workspace",displayName:"加载知识库",label:"加载知识库",description:"Select one or more knowledge sources and pass knowledgeContext to downstream nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"path",default:"",showOnNode:!1},{type:"text",name:"label",default:"",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"knowledgeContext",default:"",showOnNode:!0},{type:"text",name:"workspaceContext",default:"",showOnNode:!1},{type:"file",name:"cwd",default:"",showOnNode:!1}]},z7={id:"workspace_one_click_task",displayName:"一键任务",label:"一键任务",description:"输入任务,选择 Skills、workspace 上下文和输出类型后直接运行。",type:"agent",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1},{type:"bool",name:"includeWorkspaceContext",default:"true",showOnNode:!1},{type:"text",name:"displayType",default:"markdown",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"content",default:"",showOnNode:!0},{type:"text",name:"displayType",default:"markdown",showOnNode:!1}]},B7=new Set(["png","jpg","jpeg","gif","webp","svg"]),TI=320,RI=180,MI=960,gh=96,$I=900,ew=520,tw=320,Vf=52,Ta=240,Ra=160,nw="display-ref:",id="0 9 * * *",H7="Asia/Shanghai",W7="0.1.97";function V7(){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 $r(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 tk(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
|
|
183
183
|
...[truncated ${n.length-t} chars]`:n:""}function K7(e){const t=tk(e==null?void 0:e.text,4e3);return t?{role:(e==null?void 0:e.role)==="user"?"user":"assistant",...e!=null&&e.kind?{kind:String(e.kind)}:{},text:t,...e!=null&&e.error?{error:!0}:{},at:Number.isFinite(Number(e==null?void 0:e.at))?Number(e.at):Date.now()}:null}function nk(e,t=80){return(Array.isArray(e)?e:[]).map(K7).filter(Boolean).slice(-t)}function q7(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const[r,s]of Object.entries(t).slice(-80)){const i=String(r||"").trim();if(!i||!s||typeof s!="object")continue;const a=nk(s.messages,40),l=tk(s.draft||"",2e3);!a.length&&!l||(n[i]={sessionId:String(s.sessionId||`nodechat_${i}`),messages:a,...l?{draft:l}:{},candidateContent:"",running:!1,error:""})}return n}function U7(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=nk(t==null?void 0:t.messages,80);if(!r.length)return null;const s=String((t==null?void 0:t.status)||"done");return{id:n,label:tk((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function $j(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=t.composer&&typeof t.composer=="object"&&!Array.isArray(t.composer)?t.composer:{};return{composer:{activeSessionId:String(n.activeSessionId||"workspace").trim()||"workspace",messages:nk(n.messages,100),runSessions:U7(n.runSessions)},nodeChats:q7(t.nodeChats)}}function yh(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 B7.has(n)}function od(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=$r(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function Y7(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 G7(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${Mj}:${t}`:Mj}function J7(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function Lj(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function X7(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 Q7(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!X7(e)}function Z7(e){const t=String(e||"").trim();if(!t||eq(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 i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function eq(e){return/^\[stderr\]/.test(e)?/Reading additional input from stdin/i.test(e)||/rmcp::transport::worker/i.test(e)||/Transport channel closed/i.test(e)||/http\/request failed/i.test(e)||/AuthRequiredError/i.test(e)||/No access token was provided/i.test(e)||/api\.githubcopilot\.com/i.test(e):!1}function tq(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function ty(e,t,n,r="Workspace Run"){var c;const s=String(n||"").trim(),i=Array.isArray(e)?e.find(u=>String((u==null?void 0:u.id)||"")===s):null,a=t&&typeof t=="object"?t[s]:null;return String(((c=i==null?void 0:i.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||s||r}function ny(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function ca(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 Oj(e){const t=String(e||"").trim().toLowerCase();return{unselected:"未选择需求",unavailable:"未连接",json_unsupported:"待升级",command_failed:"读取失败",uninitialized:"未初始化",preflight_blocked:"环境阻塞",tech_design_missing:"缺技术方案",tech_design_draft_review:"方案待确认",tech_design_confirmed:"方案已确认",baseline_missing:"缺基线",plan_missing:"缺计划",plan_draft_review:"计划待确认",issue_binding_missing:"待绑定 Issue",ready_for_implementation:"待实现",implementation_ready:"待实现",implementing:"实现中",implementation_in_progress:"实现中",implementation_review:"实现待审",self_test_ready:"待自测",bugfix:"修 Bug",fix_ready:"待修复",fix_in_progress:"修复中",testing:"已提测",done:"完成",blocked:"阻塞",conflict:"冲突",requirement_changed:"需求变更"}[t]||t||"未知"}function nq(e){const t=String(e||"").trim().toLowerCase();return!t||["unselected","unavailable","json_unsupported","command_failed","uninitialized","preflight_blocked"].includes(t)?-1:/done|complete|closed|finished/.test(t)?3:/bug|fix|testing|test|self_test|submit_test/.test(t)?2:/implement|development|ready_for_implementation|issue_binding|gitlab|mr/.test(t)?1:0}function rq(e){const t=nq(e);return["方案确定","开发","Bug 修复","完成"].map((n,r)=>{let s="pending";return t>r?s="done":t===r&&(s=r===3?"done":"current"),{label:n,status:s}})}function LI(e){const t=String(e||"").trim();if(!/^https?:\/\//i.test(t))return t;try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const r=window.location.hostname;n.hostname=r&&r!=="0.0.0.0"&&r!=="::"?r:"127.0.0.1"}return n.href}catch{return t}}function OI(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return LI(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function Vo(e){const t=String(e||"").trim().toLowerCase();return["done","success","completed","passed"].includes(t)?"done":["current","running","active","next"].includes(t)?"current":["observed","observation"].includes(t)?"observed":["superseded","stale","replaced"].includes(t)?"superseded":["blocked","failed","error","conflict"].includes(t)?"blocked":"pending"}function Ma(e){if(!e||typeof e!="object")return"";const t=String(e.truth||e.stateTruth||e.state_truth||"").trim().toLowerCase();return t||(String(e.idempotencyKey||e.idempotency_key||"").trim().startsWith("snapshot-action:")||String(e.source||"")==="prd-flow-client"&&String(e.type||"")==="workflow-action"?"observation":String(e.type||"")==="review-link"?"runtime_event":"")}function rk(e){return Vo(e==null?void 0:e.status)==="done"&&Ma(e)!=="observation"}function Fi(e,t){return!e||typeof e!="object"?`Action ${t+1}`:String(e.title||e.label||e.name||e.actionLabel||e.action_label||e.id||e.action||`Action ${t+1}`)}function jp(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function sk(e){return!e||typeof e!="object"?"":[e.code,e.action,e.actionId,e.action_id,e.stage,e.stageKey,e.stage_key,e.type,e.title].map(t=>String(t||"")).join(" ").toLowerCase()}function sq(e,t="当前任务"){const r=[e==null?void 0:e.issueLabel,e==null?void 0:e.issue_label,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.name].map(s=>String(s||"")).join(" ").match(/\b(Issue\d+|Bug\d+)\b/i);return r?r[1].replace(/^issue/i,"Issue").replace(/^bug/i,"Bug"):t}function iq(e,t){const n=Fi(e,t),r=Vo(e==null?void 0:e.status),s=rk(e),a=`${$a(e)} ${sk(e)}`,l=sq(e);if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(a)){if(s)return`${l} 方案已确认`;if(r==="observed"||r==="superseded"||Ma(e)==="observation")return`${l} 方案状态已观察`;if(r==="current"&&/^确认\s+/.test(n))return n}if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(a)){if(s)return`已为 ${l} 创建/绑定 GitLab Issue`;if(r==="observed"||r==="superseded"||Ma(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function oq(e){if(!e||typeof e!="object")return"";const t=Vo(e.status),n=Ma(e),r=rk(e),i=`${$a(e)} ${sk(e)}`,a=ik(e),l=a.some(d=>/方案|plan|markdown|review|预览/i.test(String(d.label||""))),c=a.some(d=>/gitlab issue/i.test(String(d.label||""))),u=a.some(d=>/gitlab epic/i.test(String(d.label||"")));if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(i))return r?l?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":n==="observation"||t==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":t==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。";if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(i))return r?c&&u?"GitLab Issue 和 Epic 已绑定;可从下方打开关联链接。":c?"GitLab Issue 已绑定;可从下方打开关联链接。":"GitLab Issue 绑定步骤已完成。":n==="observation"||t==="observed"?"客户端上报了 GitLab Issue 阶段;是否已绑定以 GitLab/ai-doc 事实为准。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":"方案文档已归档,等待创建或绑定 GitLab Issue。";if(/implementation_in_progress|impl_in_progress/.test(i))return"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。";if(/implementation_ready/.test(i))return"方案文档和 GitLab Issue 已就绪,等待开始实现。";const p=jp(e);return p?p.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":p:""}function xh(e){return!e||typeof e!="object"?"":String(e.time||e.at||e.observedAt||e.observed_at||e.reportedAt||e.reported_at||e.startedAt||e.started_at||e.completedAt||e.completed_at||e.updatedAt||e.updated_at||e.createdAt||e.created_at||"")}const DI="Asia/Shanghai",aq=new Intl.DateTimeFormat("zh-CN",{timeZone:DI,year:"numeric",month:"2-digit",day:"2-digit"}),lq=new Intl.DateTimeFormat("zh-CN",{timeZone:DI,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function FI(e){const t=xh(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function cq(e){const t=FI(e);return t?aq.format(t).replace(/\//g,"-"):"无时间"}function uq(e){const t=FI(e);return t?lq.format(t):""}function dq(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=cq(n);let i=t[t.length-1];(!i||i.day!==s)&&(i={day:s,items:[]},t.push(i)),i.items.push({item:n,index:r})}),t}function zI(e){const t=Vo(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function fq(e){const t=Vo(e==null?void 0:e.status);return Ma(e)==="observation"&&t==="done"?"已观察":zI(t)}function BI(e){if(!e||typeof e!="object")return[];const t=[],n=(i,a,l)=>{const c=String(l||"").trim();c&&t.push({key:`${i}:${c}`,type:i,label:String(a||c),value:c})},r=Vo(e.status),s=Ma(e)==="observation"&&r==="done"?"observed":r;return n("status",zI(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",e.platform,e.platform),t}function pq(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{BI(n).forEach(r=>{const s=t.get(r.key);t.set(r.key,{...r,count:((s==null?void 0:s.count)||0)+1})})}),Array.from(t.values()).sort((n,r)=>{const s={status:0,issue:1,platform:2,source:3,actor:4};return(s[n.type]??9)-(s[r.type]??9)||r.count-n.count||n.label.localeCompare(r.label)})}function hq(e,t){const n=String(t||"all");return!n||n==="all"?!0:BI(e).some(r=>r.key===n)}function mq(e){if(!e||typeof e!="object")return[];const t=[],n=(r,s)=>{const i=String(s||"").trim();i&&t.push({label:r,value:i})};return n("Issue",e.issueKey||e.issue_key||e.issue),n("端",e.platform),t}function ik(e){const t=[],n=(c,u)=>{const p=LI(u);p&&t.push({label:String(c||p).trim()||p,href:p})},r=(c,u="链接",p=0)=>{if(p>3||c==null)return;if(typeof c=="string"){(/^(https?:\/\/|file:\/\/)/i.test(c)||c.startsWith("/"))&&n(u,c);return}if(Array.isArray(c)){c.forEach((f,h)=>r(f,`${u} ${h+1}`,p+1));return}if(typeof c!="object")return;const d=c.label||c.title||c.name||c.kind||c.type||u;n(d,c.url||c.href||c.path||c.file||c.filePath||c.file_path);for(const f of["links","urls","artifacts","outputs","output","results","result","files"])c[f]!=null&&r(c[f],f,p+1)},s=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const c of s)typeof c=="string"?n("链接",c):n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"链接",(c==null?void 0:c.url)||(c==null?void 0:c.href));for(const c of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"Artifact",OI(c));n("TAPD",(e==null?void 0:e.tapdUrl)||(e==null?void 0:e.tapd_url)),n("ai-doc",(e==null?void 0:e.docUrl)||(e==null?void 0:e.doc_url)||(e==null?void 0:e.aiDocUrl)||(e==null?void 0:e.ai_doc_url)),n("Plan",(e==null?void 0:e.planDocUrl)||(e==null?void 0:e.plan_doc_url)||(e==null?void 0:e.planUrl)||(e==null?void 0:e.plan_url)),n("Issue",(e==null?void 0:e.issueUrl)||(e==null?void 0:e.issue_url)),n("GitLab Issue",(e==null?void 0:e.gitlabIssue)||(e==null?void 0:e.gitlab_issue)),n("GitLab Epic",(e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)),n("MR",(e==null?void 0:e.mrUrl)||(e==null?void 0:e.mr_url)||(e==null?void 0:e.mergeRequestUrl)||(e==null?void 0:e.merge_request_url)),n("实现 MR",(e==null?void 0:e.implMr)||(e==null?void 0:e.impl_mr)),n("修复 MR",(e==null?void 0:e.fixMr)||(e==null?void 0:e.fix_mr)),n("提测 MR",(e==null?void 0:e.testMr)||(e==null?void 0:e.test_mr)),n("集成 MR",(e==null?void 0:e.integrationMr)||(e==null?void 0:e.integration_mr)),n("Jenkins",(e==null?void 0:e.jenkinsUrl)||(e==null?void 0:e.jenkins_url)||(e==null?void 0:e.jenkinsBuildUrl)||(e==null?void 0:e.jenkins_build_url)),n("安装包",(e==null?void 0:e.jenkinsPackageUrl)||(e==null?void 0:e.jenkins_package_url)),n("二维码",(e==null?void 0:e.jenkinsQrUrl)||(e==null?void 0:e.jenkins_qr_url)),n("调整",(e==null?void 0:e.editUrl)||(e==null?void 0:e.edit_url)||(e==null?void 0:e.adjustUrl)||(e==null?void 0:e.adjust_url)),n("链接",(e==null?void 0:e.url)||(e==null?void 0:e.href)),r(e==null?void 0:e.urls,"URL"),r(e==null?void 0:e.outputs,"产物"),r(e==null?void 0:e.output,"产物"),r(e==null?void 0:e.results,"结果"),r(e==null?void 0:e.result,"结果"),r(e==null?void 0:e.files,"文件");const i=c=>{const u=String(c||"").trim();try{const p=new URL(u,window.location.origin);return`${p.origin}${p.pathname}`}catch{return u.split(/[?#]/)[0]}},a=c=>{const u=String(c||"");return/方案文档/.test(u)?50:/临时/.test(u)?40:/Markdown Review/i.test(u)?20:/预览|review/i.test(u)?10:0},l=new Map;for(const c of t){const u=/\/api\/prd-workflow\/review\//.test(String(c.href||"")),p=u?`review:${i(c.href)}`:`${c.label}
|
|
184
184
|
${c.href}`,d=l.get(p);if(!d){l.set(p,c);continue}if(u){const f=a(d.label),h=a(c.label);(h>f||h===f&&String(c.label||"").length>String(d.label||"").length)&&l.set(p,c)}}return Array.from(l.values())}function gq(e){return!e||typeof e!="object"?{}:{marker:e.marker||e.flag||"",command:e.command||e.nextCommand||e.next_command||"",runtimeOnly:e.runtimeOnly===!0||e.runtime_only===!0,markerOnly:e.markerOnly===!0||e.marker_only===!0,url:e.url||e.href||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",mr:e.mr||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",testEnv:e.testEnv||e.test_environment||"",summary:e.summary||e.detail||e.description||"",links:Array.isArray(e.links)?e.links:[],artifacts:Array.isArray(e.artifacts)?e.artifacts:[],outputs:Array.isArray(e.outputs)?e.outputs:[],results:Array.isArray(e.results)?e.results:[]}}function wo(e,t=0){return String((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||(e==null?void 0:e.iid)||(e==null?void 0:e.title)||`issue-${t+1}`).trim()}function Dj(e,t=0){return String((e==null?void 0:e.title)||(e==null?void 0:e.name)||(e==null?void 0:e.label)||(e==null?void 0:e.summary)||wo(e,t)||`Issue ${t+1}`).trim()}function yq(e){return String((e==null?void 0:e.epicKey)||(e==null?void 0:e.epic_key)||(e==null?void 0:e.epic)||(e==null?void 0:e.epicTitle)||(e==null?void 0:e.epic_title)||(e==null?void 0:e.parentEpic)||(e==null?void 0:e.parent_epic)||"未归类").trim()}function xq(e){return String((e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parent)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||"").trim()}function Fj(e){const t=ik(e),n=(s,i)=>{if(Array.isArray(s)){for(const a of s)if(a)if(typeof a=="string")t.push({label:i,href:a});else{const l=a.url||a.href||a.webUrl||a.web_url||a.mrUrl||a.mr_url||a.issueUrl||a.issue_url;l&&t.push({label:a.label||a.title||a.platform||a.kind||i,href:l})}}};n(e==null?void 0:e.mrs,"MR"),n(e==null?void 0:e.mergeRequests,"MR"),n(e==null?void 0:e.merge_requests,"MR"),n(e==null?void 0:e.implMrs,"MR"),n(e==null?void 0:e.impl_mrs,"MR"),n(e==null?void 0:e.platformMrs,"MR"),n(e==null?void 0:e.platform_mrs,"MR");const r=new Set;return t.filter(s=>{const i=String(s.href||"").trim();if(!i)return!1;const a=`${s.label}
|
|
185
185
|
${i}`;return r.has(a)?!1:(r.add(a),!0)})}function wq(e){const t=Array.isArray(e==null?void 0:e.epics)?e.epics:Array.isArray(e==null?void 0:e.epicGroups)?e.epicGroups:Array.isArray(e==null?void 0:e.epic_groups)?e.epic_groups:[],n=[],r=new Map,s=(a,l="")=>{const c=String(a||"未归类").trim()||"未归类";return r.has(c)?l&&r.get(c).title===c&&(r.get(c).title=String(l)):r.set(c,{key:c,title:String(l||c),issues:[]}),r.get(c)};for(const a of t){const l=String((a==null?void 0:a.key)||(a==null?void 0:a.id)||(a==null?void 0:a.title)||(a==null?void 0:a.name)||"未归类").trim(),c=s(l,(a==null?void 0:a.title)||(a==null?void 0:a.name)||l),u=Array.isArray(a==null?void 0:a.issues)?a.issues:Array.isArray(a==null?void 0:a.children)?a.children:Array.isArray(a==null?void 0:a.items)?a.items:[];for(const p of u)p&&typeof p=="object"&&c.issues.push({...p,epicKey:l})}for(const a of Array.isArray(e==null?void 0:e.issues)?e.issues:[])a&&typeof a=="object"&&n.push(a);for(const a of n)s(yq(a)).issues.push(a);const i=a=>{const l=new Map,c=[];return a.forEach((u,p)=>{const d=wo(u,p);l.set(d,{issue:u,children:[]})}),a.forEach((u,p)=>{const d=wo(u,p),f=xq(u),h=l.get(d);f&&l.has(f)?l.get(f).children.push(h):c.push(h)}),c};return Array.from(r.values()).map(a=>({...a,issues:i(a.issues)}))}function ad(e){return String((e==null?void 0:e.actionId)||(e==null?void 0:e.action_id)||(e==null?void 0:e.action)||(e==null?void 0:e.id)||"").trim()}function $a(e){if(!e||typeof e!="object")return"";const t=String(e.issueKey||e.issue_key||e.issue||"").trim(),n=String(e.action||e.actionId||e.action_id||ad(e)||"").trim(),r=String(e.stageKey||e.stage_key||e.stage||e.phase||e.code||e.pointer||n).trim(),s=[r,n,e.code,e.type,e.title].map(i=>String(i||"")).join(" ").toLowerCase();if(t){if(/plan_draft_local|submit-plan|plan-doc/.test(s))return`issue-plan:${t}`;if(/gitlab_issue_missing|ensure-gitlab-issue/.test(s))return`issue-gitlab:${t}`}return r}function wh(e){const t=xh(e)||String((e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)||""),n=Date.parse(t);return Number.isFinite(n)?n:NaN}function bq(e){var s,i,a,l,c,u,p,d,f,h,g,k;const t=[],n=w=>{w&&typeof w=="object"&&!Array.isArray(w)&&t.push(w)},r=w=>{if(!w||typeof w!="object"||Array.isArray(w))return;const y=Array.isArray(w.issues)?w.issues:Array.isArray(w.children)?w.children:Array.isArray(w.items)?w.items:[];for(const v of y)!v||typeof v!="object"||Array.isArray(v)||(v.issue&&typeof v.issue=="object"?(n(v.issue),Array.isArray(v.children)&&v.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(v))};return[e==null?void 0:e.issues,(s=e==null?void 0:e.raw)==null?void 0:s.issues,(a=(i=e==null?void 0:e.raw)==null?void 0:i.prd)==null?void 0:a.issues].forEach(w=>{Array.isArray(w)&&w.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(d=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:d.epics,(h=(f=e==null?void 0:e.raw)==null?void 0:f.prd)==null?void 0:h.epicGroups,(k=(g=e==null?void 0:e.raw)==null?void 0:g.prd)==null?void 0:k.epic_groups].forEach(w=>{Array.isArray(w)&&w.forEach(r)}),t}function kq(e,t){const n=String(t||"").trim();return n&&bq(e).find((r,s)=>wo(r,s)===n)||null}function vq(e){var t,n,r,s,i,a,l,c;return String((e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)||((t=e==null?void 0:e.prd)==null?void 0:t.gitlabEpic)||((n=e==null?void 0:e.prd)==null?void 0:n.gitlab_epic)||((r=e==null?void 0:e.raw)==null?void 0:r.gitlabEpic)||((s=e==null?void 0:e.raw)==null?void 0:s.gitlab_epic)||((a=(i=e==null?void 0:e.raw)==null?void 0:i.prd)==null?void 0:a.gitlabEpic)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.gitlab_epic)||"").trim()}function Sq(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=kq(e,n),s=String((r==null?void 0:r.gitlabIssue)||(r==null?void 0:r.gitlab_issue)||t.gitlabIssue||t.gitlab_issue||"").trim(),i=vq(e);if(!s&&!i)return t;const a=$a(t),l=`${a} ${sk(t)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(l))return t;const u=[];s&&u.push({label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:s}),i&&u.push({label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:i});const p=Vo(t.status),d=s&&p==="done"&&/^issue-gitlab:/.test(a)&&/需要.*GitLab Issue/.test(String(t.title||t.label||""));return{...t,...s?{gitlabIssue:s,gitlab_issue:s}:{},...i?{gitlabEpic:i,gitlab_epic:i}:{},...d?{title:String(t.title||t.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(t.label||t.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:li(t.artifacts,u)}}function li(e,t){const n=[],r=new Set,s=i=>{if(!i)return;const a=typeof i=="string"?i:JSON.stringify(i);r.has(a)||(r.add(a),n.push(i))};return(Array.isArray(e)?e:[]).forEach(s),(Array.isArray(t)?t:[]).forEach(s),n}function zj(e,t){const n=wh(t),r=wh(e),s=Number.isFinite(n)&&(!Number.isFinite(r)||n>=r)?t:e,i=(s==null?void 0:s.status)||(t==null?void 0:t.status)||(e==null?void 0:e.status);return{...e,...t,title:Fi(s,0)||Fi(t,0)||Fi(e,0),detail:jp(s)||jp(t)||jp(e),status:i,links:li(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:li(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:li(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:li(e==null?void 0:e.results,t==null?void 0:t.results),events:li(e==null?void 0:e.events,t==null?void 0:t.events),createdAt:(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(t==null?void 0:t.createdAt)||(t==null?void 0:t.created_at),startedAt:(e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(t==null?void 0:t.startedAt)||(t==null?void 0:t.started_at),updatedAt:(s==null?void 0:s.updatedAt)||(s==null?void 0:s.updated_at)||(t==null?void 0:t.updatedAt)||(t==null?void 0:t.updated_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)}}function Nq(e,t){const n=[],r=new Map,s=new Map,i=new Map,a=d=>{var f,h;return!!(!d||typeof d!="object"||d.auxiliary===!0||d.auxiliary_event===!0||String(d.type||"")==="review-link"||String(d.type||"")==="action-preview"||d.preview===!0||String(d.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((f=d.conflict)==null?void 0:f.previousArtifact)||((h=d.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(d,f)=>({...d,links:li(d==null?void 0:d.links,f==null?void 0:f.links),artifacts:li(d==null?void 0:d.artifacts,f==null?void 0:f.artifacts),outputs:li(d==null?void 0:d.outputs,f==null?void 0:f.outputs),results:li(d==null?void 0:d.results,f==null?void 0:f.results)}),c=(d,f)=>{if(!d)return;const h=r.get(d);if(h!=null){n[h]=l(n[h],f);return}i.set(d,l(i.get(d)||{},f))},u=(d,f)=>d&&i.has(d)?l(f,i.get(d)):f,p=d=>{if(Array.isArray(d))for(const f of d){const h=$a(f);if(a(f)){c(h,f);continue}const g=String(f.id||f.eventId||f.event_id||f.actionId||f.action_id||"").trim(),k=h||g,w=k?r.get(k)??s.get(g):null;k&&w!=null?(n[w]=u(h,zj(n[w],f)),h&&r.set(h,w),g&&s.set(g,w)):(k&&r.set(k,n.length),g&&s.set(g,n.length),n.push(u(h,f)))}};if(p(e==null?void 0:e.actions),p(e==null?void 0:e.workflowActions),p(e==null?void 0:e.workflow_actions),p(e==null?void 0:e.timeline),p(e==null?void 0:e.history),p(e==null?void 0:e.events),p(e==null?void 0:e.runtimeEvents),p(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const d=ad(t),f=$a(t),h=f?r.get(f):d?s.get(d):null,g={...t,status:t.status||"next",kind:"next_action"};h!=null?n[h]=zj(n[h],g):n.push(g)}return n.map((d,f)=>({item:d,index:f,ts:wh(d)})).sort((d,f)=>{const h=Number.isFinite(d.ts),g=Number.isFinite(f.ts);return h&&g?f.ts-d.ts||d.index-f.index:h?-1:g?1:d.index-f.index}).map(d=>Sq(e,d.item))}function jq(e){return(Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[]).filter(n=>n&&typeof n=="object").map((n,r)=>({item:n,index:r,ts:wh(n)})).sort((n,r)=>{const s=Number.isFinite(n.ts),i=Number.isFinite(r.ts);return s&&i?r.ts-n.ts||r.index-n.index:s?-1:i?1:r.index-n.index}).slice(0,8).map(n=>n.item)}function Cq(e,t){const n=String(t||"all");if(n==="all")return!0;const r=[e==null?void 0:e.status,e==null?void 0:e.type,e==null?void 0:e.kind,e==null?void 0:e.title,e==null?void 0:e.detail,e==null?void 0:e.error,JSON.stringify((e==null?void 0:e.links)||[]),JSON.stringify((e==null?void 0:e.artifacts)||[])].join(" ").toLowerCase();return n==="errors"?/error|failed|conflict|blocked|stale|revision|冲突|失败/.test(r):n==="review"?/review|temporary-review|临时/.test(r):n==="external"?/mr|merge request|gitlab|jenkins|package|build|tapd/.test(r):!0}function _q(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,i=Number.isFinite(r)&&Number.isFinite(s)?`(+${ca(r)} / 总 ${ca(s)})`:"";return`${t+1}. ${n}${i}`}function HI(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 fl(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function Eq(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 Aq(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 Pq(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 Iq(e){var i,a,l;const t=HI(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=fl(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=Aq(t),u=Eq(t),p=fl(t.startedAtMs,c==null?void 0:c.startedAtMs),d=fl(t.completedAtMs,c==null?void 0:c.completedAtMs),f=((i=c==null?void 0:c.result)==null?void 0:i.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},h=Number.isFinite(p)&&Number.isFinite(d)?Math.max(0,d-p):fl(f.executionTime,f.localExecutionTimeMs),g=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||f.command||"").trim(),k=g?g.split(`
|
|
@@ -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-BPagP6GD.js"></script>
|
|
19
19
|
<link rel="stylesheet" crossorigin href="/assets/index-DKaacU6h.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.97",
|
|
4
4
|
"description": "Orchestration system for long-running complex agent tasks using Cursor, OpenCode, Claude Code, or Codex as execution backends",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/agentflow.mjs",
|