@fieldwangai/agentflow 0.1.122 → 0.1.123
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
|
@@ -8197,6 +8197,175 @@ function prdWorkflowReviewRenderPlannedCode(filePath, codeLines, startLine = 0,
|
|
|
8197
8197
|
</section>`;
|
|
8198
8198
|
}
|
|
8199
8199
|
|
|
8200
|
+
function prdWorkflowReviewParseChangeIntent(lines, startIndex) {
|
|
8201
|
+
const start = String(lines[startIndex] || "")
|
|
8202
|
+
.trim()
|
|
8203
|
+
.match(/^#change\s+(add|modify|remove|move)\s*$/i);
|
|
8204
|
+
if (!start) return null;
|
|
8205
|
+
const change = {
|
|
8206
|
+
operation: start[1].toLowerCase(),
|
|
8207
|
+
target: "",
|
|
8208
|
+
module: "",
|
|
8209
|
+
file: "",
|
|
8210
|
+
symbol: "",
|
|
8211
|
+
base: "",
|
|
8212
|
+
insertNear: "",
|
|
8213
|
+
destination: "",
|
|
8214
|
+
reference: null,
|
|
8215
|
+
proposals: [],
|
|
8216
|
+
};
|
|
8217
|
+
for (let i = startIndex + 1; i < lines.length; i += 1) {
|
|
8218
|
+
const trimmed = String(lines[i] || "").trim();
|
|
8219
|
+
if (/^#changeend\s*$/i.test(trimmed)) {
|
|
8220
|
+
return { change, endIndex: i };
|
|
8221
|
+
}
|
|
8222
|
+
const simple = trimmed.match(
|
|
8223
|
+
/^#(target|module|file|symbol|base|insert-near|destination)\s+(.+?)\s*$/i,
|
|
8224
|
+
);
|
|
8225
|
+
if (simple) {
|
|
8226
|
+
const key = simple[1].toLowerCase();
|
|
8227
|
+
const value = simple[2].trim().replace(/^`|`$/g, "");
|
|
8228
|
+
if (key === "insert-near") change.insertNear = value;
|
|
8229
|
+
else change[key] = value;
|
|
8230
|
+
continue;
|
|
8231
|
+
}
|
|
8232
|
+
const reference = trimmed.match(
|
|
8233
|
+
/^#reference\s+line\s*(\d+)(?:\s*-\s*(\d+))?\s*$/i,
|
|
8234
|
+
);
|
|
8235
|
+
if (reference) {
|
|
8236
|
+
const body = [];
|
|
8237
|
+
let end = i + 1;
|
|
8238
|
+
while (end < lines.length && !/^#referenceend\s*$/i.test(String(lines[end] || "").trim())) {
|
|
8239
|
+
body.push(lines[end]);
|
|
8240
|
+
end += 1;
|
|
8241
|
+
}
|
|
8242
|
+
if (end >= lines.length) return null;
|
|
8243
|
+
change.reference = {
|
|
8244
|
+
startLine: Number(reference[1]),
|
|
8245
|
+
endLine: Number(reference[2] || reference[1]),
|
|
8246
|
+
lines: body,
|
|
8247
|
+
};
|
|
8248
|
+
i = end;
|
|
8249
|
+
continue;
|
|
8250
|
+
}
|
|
8251
|
+
const proposal = trimmed.match(/^#proposal\s+(natural|pseudocode|code)\s*$/i);
|
|
8252
|
+
if (proposal) {
|
|
8253
|
+
const body = [];
|
|
8254
|
+
let end = i + 1;
|
|
8255
|
+
while (end < lines.length && !/^#proposalend\s*$/i.test(String(lines[end] || "").trim())) {
|
|
8256
|
+
body.push(lines[end]);
|
|
8257
|
+
end += 1;
|
|
8258
|
+
}
|
|
8259
|
+
if (end >= lines.length) return null;
|
|
8260
|
+
change.proposals.push({
|
|
8261
|
+
type: proposal[1].toLowerCase(),
|
|
8262
|
+
lines: body,
|
|
8263
|
+
});
|
|
8264
|
+
i = end;
|
|
8265
|
+
}
|
|
8266
|
+
}
|
|
8267
|
+
return null;
|
|
8268
|
+
}
|
|
8269
|
+
|
|
8270
|
+
function prdWorkflowReviewRenderChangeIntent(change) {
|
|
8271
|
+
const operationLabels = {
|
|
8272
|
+
add: "新增",
|
|
8273
|
+
modify: "修改",
|
|
8274
|
+
remove: "删除",
|
|
8275
|
+
move: "移动",
|
|
8276
|
+
};
|
|
8277
|
+
const targetLabels = {
|
|
8278
|
+
module: "模块",
|
|
8279
|
+
file: "文件",
|
|
8280
|
+
class: "类",
|
|
8281
|
+
function: "方法",
|
|
8282
|
+
code: "代码片段",
|
|
8283
|
+
};
|
|
8284
|
+
const proposalLabels = {
|
|
8285
|
+
natural: "自然语言方案",
|
|
8286
|
+
pseudocode: "方案伪代码",
|
|
8287
|
+
code: "拟议代码 · 未写入",
|
|
8288
|
+
};
|
|
8289
|
+
const operation = operationLabels[change.operation] || "变更";
|
|
8290
|
+
const target = targetLabels[change.target] || "目标";
|
|
8291
|
+
const locator = change.module || change.file || "未定位";
|
|
8292
|
+
const safeLocator = htmlEscapeAttribute(locator);
|
|
8293
|
+
const safeSymbol = htmlEscapeAttribute(change.symbol || "");
|
|
8294
|
+
const safeBase = htmlEscapeAttribute(change.base || "");
|
|
8295
|
+
const safeInsertNear = htmlEscapeAttribute(change.insertNear || "");
|
|
8296
|
+
const safeDestination = htmlEscapeAttribute(change.destination || "");
|
|
8297
|
+
const meta = [
|
|
8298
|
+
safeBase ? `<span><strong>基于</strong> <code>${safeBase}</code></span>` : "",
|
|
8299
|
+
safeInsertNear ? `<span><strong>建议位置</strong> <code>${safeInsertNear}</code> 附近</span>` : "",
|
|
8300
|
+
safeDestination ? `<span><strong>移动到</strong> <code>${safeDestination}</code></span>` : "",
|
|
8301
|
+
].filter(Boolean).join("");
|
|
8302
|
+
|
|
8303
|
+
let referenceHtml = "";
|
|
8304
|
+
if (change.reference) {
|
|
8305
|
+
const normalized = prdWorkflowReviewDedentPlannedCode(change.reference.lines);
|
|
8306
|
+
const lineLabel = `L${change.reference.startLine}${
|
|
8307
|
+
change.reference.endLine !== change.reference.startLine
|
|
8308
|
+
? `–L${change.reference.endLine}`
|
|
8309
|
+
: ""
|
|
8310
|
+
}`;
|
|
8311
|
+
const rows = normalized.map((line, index) => (
|
|
8312
|
+
`<span class="change-intent__source-line">`
|
|
8313
|
+
+ `<span class="change-intent__source-number">${change.reference.startLine + index}</span>`
|
|
8314
|
+
+ `<span class="change-intent__source-text">${htmlEscapeAttribute(prdWorkflowReviewNormalizeText(line)) || " "}</span>`
|
|
8315
|
+
+ "</span>"
|
|
8316
|
+
)).join("");
|
|
8317
|
+
referenceHtml = `<details class="change-intent__context" open>
|
|
8318
|
+
<summary><span>当前上下文</span><span class="change-intent__line-anchor">${lineLabel}</span></summary>
|
|
8319
|
+
<pre class="change-intent__source"><code>${rows}</code></pre>
|
|
8320
|
+
</details>`;
|
|
8321
|
+
}
|
|
8322
|
+
|
|
8323
|
+
const proposalsHtml = change.proposals.map((proposal) => {
|
|
8324
|
+
const type = proposal.type;
|
|
8325
|
+
const label = proposalLabels[type] || "方案";
|
|
8326
|
+
const normalized = prdWorkflowReviewDedentPlannedCode(proposal.lines);
|
|
8327
|
+
let body = "";
|
|
8328
|
+
if (type === "natural") {
|
|
8329
|
+
body = `<div class="change-intent__natural">${prdWorkflowReviewMarkdownLinesToHtml(normalized)}</div>`;
|
|
8330
|
+
} else if (type === "code") {
|
|
8331
|
+
const rows = normalized.map((line) => (
|
|
8332
|
+
`<span class="change-intent__proposal-line is-code">`
|
|
8333
|
+
+ '<span class="change-intent__proposal-mark">+</span>'
|
|
8334
|
+
+ `<span class="change-intent__proposal-text">${htmlEscapeAttribute(prdWorkflowReviewNormalizeText(line)) || " "}</span>`
|
|
8335
|
+
+ "</span>"
|
|
8336
|
+
)).join("");
|
|
8337
|
+
body = `<pre class="change-intent__proposal-body is-code"><code>${rows}</code></pre>`;
|
|
8338
|
+
} else {
|
|
8339
|
+
const rows = normalized.map((line) => (
|
|
8340
|
+
`<span class="change-intent__proposal-line">`
|
|
8341
|
+
+ `<span class="change-intent__proposal-text">${htmlEscapeAttribute(prdWorkflowReviewNormalizeText(line)) || " "}</span>`
|
|
8342
|
+
+ "</span>"
|
|
8343
|
+
)).join("");
|
|
8344
|
+
body = `<pre class="change-intent__proposal-body"><code>${rows}</code></pre>`;
|
|
8345
|
+
}
|
|
8346
|
+
return `<section class="change-intent__proposal is-${htmlEscapeAttribute(type)}">
|
|
8347
|
+
<div class="change-intent__proposal-header">
|
|
8348
|
+
<span>准备怎么改</span>
|
|
8349
|
+
<span class="change-intent__proposal-badge">${htmlEscapeAttribute(label)}</span>
|
|
8350
|
+
</div>
|
|
8351
|
+
${body}
|
|
8352
|
+
</section>`;
|
|
8353
|
+
}).join("");
|
|
8354
|
+
|
|
8355
|
+
return `<section class="change-intent is-${htmlEscapeAttribute(change.operation)}" data-operation="${htmlEscapeAttribute(change.operation)}" data-target="${htmlEscapeAttribute(change.target)}">
|
|
8356
|
+
<div class="change-intent__header">
|
|
8357
|
+
<span class="change-intent__operation">${htmlEscapeAttribute(`${operation}${target}`)}</span>
|
|
8358
|
+
<div class="change-intent__locator">
|
|
8359
|
+
<code>${safeLocator}</code>
|
|
8360
|
+
${safeSymbol ? `<span aria-hidden="true">›</span><code>${safeSymbol}</code>` : ""}
|
|
8361
|
+
</div>
|
|
8362
|
+
</div>
|
|
8363
|
+
${meta ? `<div class="change-intent__meta">${meta}</div>` : ""}
|
|
8364
|
+
${referenceHtml}
|
|
8365
|
+
${proposalsHtml}
|
|
8366
|
+
</section>`;
|
|
8367
|
+
}
|
|
8368
|
+
|
|
8200
8369
|
function prdWorkflowReviewMarkdownLinesToHtml(lines) {
|
|
8201
8370
|
const html = [];
|
|
8202
8371
|
let paragraph = [];
|
|
@@ -8238,6 +8407,15 @@ function prdWorkflowReviewMarkdownLinesToHtml(lines) {
|
|
|
8238
8407
|
flushBlocks();
|
|
8239
8408
|
continue;
|
|
8240
8409
|
}
|
|
8410
|
+
if (/^#change\s+/i.test(trimmed)) {
|
|
8411
|
+
const parsed = prdWorkflowReviewParseChangeIntent(lines, i);
|
|
8412
|
+
if (parsed) {
|
|
8413
|
+
flushBlocks();
|
|
8414
|
+
html.push(prdWorkflowReviewRenderChangeIntent(parsed.change));
|
|
8415
|
+
i = parsed.endIndex;
|
|
8416
|
+
continue;
|
|
8417
|
+
}
|
|
8418
|
+
}
|
|
8241
8419
|
const plannedFile = trimmed.match(/^#file\s+(.+?)\s*$/i);
|
|
8242
8420
|
if (plannedFile) {
|
|
8243
8421
|
let codeStart = i + 1;
|
|
@@ -8494,6 +8672,15 @@ export function prdWorkflowReviewHtml(title, markdown, meta = {}) {
|
|
|
8494
8672
|
--planned-header: rgba(158,206,106,.08);
|
|
8495
8673
|
--planned-gutter: #565f89;
|
|
8496
8674
|
--planned-line: rgba(158,206,106,.08);
|
|
8675
|
+
--change-border: rgba(122,162,247,.34);
|
|
8676
|
+
--change-header: rgba(122,162,247,.08);
|
|
8677
|
+
--change-context: #1b1e2b;
|
|
8678
|
+
--change-proposal: #202536;
|
|
8679
|
+
--change-code: rgba(158,206,106,.08);
|
|
8680
|
+
--change-add: #9ece6a;
|
|
8681
|
+
--change-modify: #7dcfff;
|
|
8682
|
+
--change-remove: #f7768e;
|
|
8683
|
+
--change-move: #bb9af7;
|
|
8497
8684
|
--action-bg: #1f2335;
|
|
8498
8685
|
--action-header: #24283b;
|
|
8499
8686
|
--pending-bg: rgba(224,175,104,.10);
|
|
@@ -8530,6 +8717,15 @@ export function prdWorkflowReviewHtml(title, markdown, meta = {}) {
|
|
|
8530
8717
|
--planned-header: rgba(88,117,57,.08);
|
|
8531
8718
|
--planned-gutter: #8990a7;
|
|
8532
8719
|
--planned-line: rgba(88,117,57,.07);
|
|
8720
|
+
--change-border: rgba(46,125,233,.28);
|
|
8721
|
+
--change-header: rgba(46,125,233,.06);
|
|
8722
|
+
--change-context: #eceef3;
|
|
8723
|
+
--change-proposal: #e8eaf0;
|
|
8724
|
+
--change-code: rgba(88,117,57,.08);
|
|
8725
|
+
--change-add: #587539;
|
|
8726
|
+
--change-modify: #007197;
|
|
8727
|
+
--change-remove: #c64343;
|
|
8728
|
+
--change-move: #7847bd;
|
|
8533
8729
|
--action-bg: #f3f3f5;
|
|
8534
8730
|
--action-header: #e9e9ed;
|
|
8535
8731
|
--pending-bg: rgba(177,92,0,.08);
|
|
@@ -8577,6 +8773,40 @@ export function prdWorkflowReviewHtml(title, markdown, meta = {}) {
|
|
|
8577
8773
|
.planned-code__line:hover { background: var(--planned-line); }
|
|
8578
8774
|
.planned-code__number { border-right: 1px solid var(--border-soft); color: var(--planned-gutter); padding: 0 .8rem 0 .5rem; text-align: right; user-select: none; }
|
|
8579
8775
|
.planned-code__text { padding: 0 1rem; white-space: pre; }
|
|
8776
|
+
.change-intent { max-width: 100%; margin: 1rem 0 1.2rem; overflow: hidden; border: 1px solid var(--change-border); border-radius: 12px; background: var(--panel-strong); }
|
|
8777
|
+
.change-intent__header { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--change-border); background: var(--change-header); padding: 12px 14px; }
|
|
8778
|
+
.change-intent__operation { flex: 0 0 auto; border: 1px solid currentColor; border-radius: 999px; padding: 4px 9px; color: var(--change-modify); font-size: 12px; font-weight: 900; line-height: 1.3; }
|
|
8779
|
+
.change-intent.is-add .change-intent__operation { color: var(--change-add); }
|
|
8780
|
+
.change-intent.is-remove .change-intent__operation { color: var(--change-remove); }
|
|
8781
|
+
.change-intent.is-move .change-intent__operation { color: var(--change-move); }
|
|
8782
|
+
.change-intent__locator { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; color: var(--muted); }
|
|
8783
|
+
.change-intent__locator code { border: 0; background: transparent; padding: 0; color: var(--link); font-weight: 800; }
|
|
8784
|
+
.change-intent__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; border-bottom: 1px solid var(--border-soft); padding: 9px 14px; color: var(--muted); font-size: 12px; }
|
|
8785
|
+
.change-intent__meta span { min-width: 0; overflow-wrap: anywhere; }
|
|
8786
|
+
.change-intent__meta strong { color: var(--body); }
|
|
8787
|
+
.change-intent__meta code { border: 0; background: transparent; padding: 0; color: var(--muted); }
|
|
8788
|
+
.change-intent__context { border-bottom: 1px solid var(--border-soft); background: var(--change-context); }
|
|
8789
|
+
.change-intent__context summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; padding: 10px 14px; color: var(--body); font-size: 13px; font-weight: 900; list-style-position: inside; }
|
|
8790
|
+
.change-intent__line-anchor, .change-intent__proposal-badge { margin-left: auto; border: 1px solid var(--border); border-radius: 999px; padding: 3px 8px; color: var(--muted); font: 800 11px/1.35 "SFMono-Regular", Consolas, monospace; white-space: nowrap; }
|
|
8791
|
+
.change-intent__source { margin: 0; border: 0; border-top: 1px solid var(--border-soft); border-radius: 0; padding: 10px 0; background: var(--code-block); }
|
|
8792
|
+
.change-intent__source code, .change-intent__proposal-body code { display: block; }
|
|
8793
|
+
.change-intent__source-line { display: grid; grid-template-columns: 4.25rem minmax(max-content, 1fr); min-height: 1.65em; }
|
|
8794
|
+
.change-intent__source-line:hover { background: var(--planned-line); }
|
|
8795
|
+
.change-intent__source-number { border-right: 1px solid var(--border-soft); color: var(--planned-gutter); padding: 0 .8rem 0 .5rem; text-align: right; user-select: none; }
|
|
8796
|
+
.change-intent__source-text { padding: 0 1rem; white-space: pre; }
|
|
8797
|
+
.change-intent__proposal { background: var(--change-proposal); }
|
|
8798
|
+
.change-intent__proposal + .change-intent__proposal { border-top: 1px solid var(--border-soft); }
|
|
8799
|
+
.change-intent__proposal-header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: var(--heading); font-size: 13px; font-weight: 900; }
|
|
8800
|
+
.change-intent__proposal-badge { color: var(--change-modify); }
|
|
8801
|
+
.change-intent__proposal.is-code .change-intent__proposal-badge { border-color: var(--complete-border); color: var(--change-add); }
|
|
8802
|
+
.change-intent__natural { border-top: 1px solid var(--border-soft); padding: 11px 14px 13px; }
|
|
8803
|
+
.change-intent__natural > *:first-child { margin-top: 0; }
|
|
8804
|
+
.change-intent__natural > *:last-child { margin-bottom: 0; }
|
|
8805
|
+
.change-intent__proposal-body { margin: 0; border: 0; border-top: 1px solid var(--border-soft); border-radius: 0; padding: 11px 14px 13px; background: var(--code-block); }
|
|
8806
|
+
.change-intent__proposal-line { display: block; min-height: 1.65em; }
|
|
8807
|
+
.change-intent__proposal-line.is-code { display: grid; grid-template-columns: 2rem minmax(max-content, 1fr); margin: 0 -14px; padding: 0 14px; background: var(--change-code); }
|
|
8808
|
+
.change-intent__proposal-mark { color: var(--change-add); font-weight: 900; text-align: center; user-select: none; }
|
|
8809
|
+
.change-intent__proposal-text { white-space: pre; }
|
|
8580
8810
|
blockquote { margin: 1rem 0; border-left: 3px solid var(--purple); background: var(--panel-soft); padding: .75rem 1rem; color: var(--body); }
|
|
8581
8811
|
a { color: var(--link); text-decoration-thickness: .08em; text-underline-offset: .16em; overflow-wrap: anywhere; }
|
|
8582
8812
|
.table-wrap { max-width: 100%; overflow-x: auto; margin: 1rem 0 1.25rem; border: 1px solid var(--border-soft); border-radius: 10px; background: var(--panel-strong); }
|
|
@@ -8608,6 +8838,9 @@ export function prdWorkflowReviewHtml(title, markdown, meta = {}) {
|
|
|
8608
8838
|
.action-card__body pre { margin: .9rem 0 1.1rem; }
|
|
8609
8839
|
@media (max-width: 720px) {
|
|
8610
8840
|
main { padding: 28px 14px 48px; }
|
|
8841
|
+
.change-intent__header { align-items: flex-start; flex-direction: column; }
|
|
8842
|
+
.change-intent__locator { width: 100%; }
|
|
8843
|
+
.change-intent__source-line { grid-template-columns: 3.35rem minmax(max-content, 1fr); }
|
|
8611
8844
|
header { display: block; }
|
|
8612
8845
|
.toolbar { justify-content: flex-start; margin-top: 14px; }
|
|
8613
8846
|
article { padding: 18px; }
|
|
@@ -180,7 +180,7 @@ ${n("project:fileTruncated")}`:""]})]}):i.jsx("p",{children:n("project:noNodeFil
|
|
|
180
180
|
</body>
|
|
181
181
|
</html>`}const kT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),AU=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function PU(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 IU(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 uC(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 vT(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(kT.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 ST(e){return{inputNames:uC(e==null?void 0:e.inputs),outputNames:uC(e==null?void 0:e.outputs)}}function RU(e,t,n){const r=ST(t),s=IU(e),o=[];for(const a of s)if(!vT(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();o.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return o}function TU(e,t){const n=ST(t),r=/\$\{([^}]*)\}/g,s=[];let o=0,a;for(;(a=r.exec(e))!==null;){a.index>o&&s.push({kind:"plain",text:e.slice(o,a.index)});const l=a[0],c=vT(a[1],n);s.push({kind:c?"ph-valid":"ph-invalid",text:l}),o=a.index+l.length}return o<e.length&&s.push({kind:"plain",text:e.slice(o)}),s}function MU(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function $U(e){return e.map(t=>{const n=MU(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 LU(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:o?t("flow:placeholder.inputSubtitle",{type:o}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const s=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!s)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:o?t("flow:placeholder.outputSubtitle",{type:o}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of AU)kT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function OU(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(o=>String(o).toLowerCase()).some(o=>o.includes(n))):e}function DU(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),s=document.createElement("div");s.setAttribute("aria-hidden","true"),s.style.visibility="hidden",s.style.position="fixed",s.style.top="0",s.style.left="-99999px",s.style.whiteSpace="pre-wrap",s.style.wordWrap="break-word",s.style.overflow="hidden";const o=e.clientWidth;if(o<=0)return null;s.style.width=`${o}px`,s.style.font=r.font,s.style.lineHeight=r.lineHeight,s.style.padding=r.padding,s.style.border=r.border,s.style.boxSizing=r.boxSizing,s.style.letterSpacing=r.letterSpacing,s.style.textIndent=r.textIndent,s.style.tabSize=r.tabSize||"8",s.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="",s.appendChild(a),document.body.appendChild(s);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),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 Rp({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:d}=zr(),f=m.useId(),p=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(0),[b,g]=m.useState(0),[k,x]=m.useState(null),j=m.useMemo(()=>ho(c),[c]),N=m.useMemo(()=>RU(e,a,d),[e,a,d]),C=N.length>0,I=m.useMemo(()=>TU(e,a),[e,a]),R=m.useMemo(()=>$U(I),[I]),H=m.useMemo(()=>n?null:PU(e,y),[e,y,n]),A=m.useMemo(()=>{if(!H)return[];const z=LU(a,d);return OU(z,H.query)},[H,a,d]);m.useEffect(()=>{g(z=>{const F=Math.max(0,A.length-1);return Math.min(Math.max(0,z),F)})},[A.length]);const L=m.useCallback(()=>{const z=p.current;if(!z||!H||A.length===0){x(null);return}const F=DU(z,y);if(!F){x(null);return}const $=4,W=44,E=13.5*16,Q=Math.min(A.length*W+8,E);let V=F.bottom+$;V+Q>window.innerHeight-8&&(V=Math.max(8,F.top-Q-$));const B=288;let se=F.left;se=Math.max(8,Math.min(se,window.innerWidth-B-8)),x({top:V,left:se})},[H,A.length,y]);m.useLayoutEffect(()=>{if(!H||A.length===0){x(null);return}const z=requestAnimationFrame(()=>L());return()=>cancelAnimationFrame(z)},[H,A.length,y,e,L]),m.useEffect(()=>{if(!H||A.length===0)return;const z=()=>L();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[H,A.length,L]);const D=m.useCallback(z=>{if(!H)return;const{atIndex:F}=H,$=e.slice(0,F)+"${"+z+"}"+e.slice(y);t($);const W=F+z.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(W,W)),v(W)})},[H,e,y,t]),O=m.useCallback(()=>{const z=p.current,F=h.current;!z||!F||(F.scrollTop=z.scrollTop,F.scrollLeft=z.scrollLeft,H&&A.length>0&&queueMicrotask(()=>L()))},[H,A.length,L]),M=m.useCallback(z=>{if(!n&&H&&A.length>0&&(z.key==="ArrowDown"||z.key==="ArrowUp"||z.key==="Enter")){if(z.key==="ArrowDown")z.preventDefault(),g(F=>(F+1)%A.length);else if(z.key==="ArrowUp")z.preventDefault(),g(F=>(F-1+A.length)%A.length);else if(z.key==="Enter"&&!z.shiftKey){z.preventDefault();const F=A[b];F&&D(F.insert)}}},[n,H,A,b,D]),K=m.useCallback(async z=>{if(n||typeof u!="function")return!1;const F=await wT({files:z,body:e,images:j});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const $=p.current;if(!$)return;$.focus();const W=F.body.length;$.setSelectionRange(W,W),v(W)}),!0):!1},[n,j,t,u,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((z,F)=>i.jsxs("span",{className:"af-body-image-chip",title:z.name,children:[i.jsx("img",{src:z.dataUrl,alt:""}),i.jsxs("span",{children:["[",z.label||`image ${F+1}`,"]"]})]},z.id||F))}):null,i.jsxs("div",{className:"af-body-prompt-stack",children:[i.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:R+`
|
|
182
182
|
`}}),i.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?f:void 0,onChange:z=>{t(z.target.value),v(z.target.selectionStart??z.target.value.length)},onSelect:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:M,onPaste:z=>{const F=yT(z);F.length!==0&&(z.preventDefault(),K(F).catch(()=>{}))},onDragOver:z=>{pd(z).length>0&&z.preventDefault()},onDrop:z=>{const F=pd(z);F.length!==0&&(z.preventDefault(),K(F).catch(()=>{}))},onScroll:O})]}),H&&A.length>0&&k?ur.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":d("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:A.map((z,F)=>i.jsx("li",{role:"option","aria-selected":F===b,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===b?" af-composer-mention-item--active":""),onMouseDown:$=>$.preventDefault(),onMouseEnter:()=>g(F),onClick:()=>D(z.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${z.insert}}`}),z.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:z.subtitle}):null]})},`${z.section}-${z.insert}`))}),document.body):null,C?i.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:N.map(z=>z.message).join(" · ")}):null]})}const FU=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Iu(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function dC({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=zr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=f=>r(n.filter((p,h)=>h!==f)),u=(f,p,h)=>{const y=n.map((v,b)=>{if(b!==f)return v;const g={...v,[p]:h};return p==="required"&&h===!0&&(g.showOnNode=!0),g});r(y)},d=e==="input"?"input":"output";return i.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[i.jsxs("div",{className:"af-node-props-io-head",children:[i.jsx("span",{className:"af-node-props-label",children:t}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:s,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),i.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:d})}),n.length===0?i.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?i.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[i.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[i.jsx("span",{children:a("flow:nodeProps.handle")}),i.jsx("span",{children:a("flow:nodeProps.type")}),i.jsx("span",{children:a("flow:nodeProps.name")}),i.jsx("span",{children:a("flow:nodeProps.defaultValue")}),i.jsx("span",{children:a("flow:nodeProps.description")}),i.jsx("span",{children:a("flow:nodeProps.required")}),i.jsx("span",{children:a("flow:nodeProps.showOnNode")}),i.jsx("span",{})]}),n.map((f,p)=>i.jsxs("div",{className:"af-node-props-io-row",children:[i.jsxs("span",{className:"af-node-props-io-handle",title:`${d}-${p}`,children:[d,"-",p]}),i.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:f.type,onChange:h=>u(p,"type",h.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(h=>i.jsx("option",{value:h,children:h},h))}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.name,onChange:h=>u(p,"name",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.default,onChange:h=>u(p,"default",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),i.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:f.description||"",onChange:h=>u(p,"description",h.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:p})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:i.jsx("input",{type:"checkbox",checked:!!f.required,onChange:h=>{o||u(p,"required",h.target.checked)},disabled:s||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),i.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:i.jsx("input",{type:"checkbox",checked:f.showOnNode!==!1,onChange:h=>u(p,"showOnNode",h.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${d}-${p}`))]}):null]})}function zU({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:d,ioSlots:f}){const{t:p}=zr(),[h,y]=m.useState(!1),[v,b]=m.useState(!1),[g,k]=m.useState({status:"idle",message:""}),x=m.useCallback(O=>{t(M=>M&&{...M,...O})},[t]),{cursorList:j,opencodeList:N,claudeCodeList:C,codexList:I,currentNotInLists:R}=m.useMemo(()=>{const O=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],M=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],K=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],z=Array.isArray(s==null?void 0:s.codex)?s.codex:[],F=new Set([...O,...M,...K,...z].map(Iu)),$=((e==null?void 0:e.model)??"").trim(),W=$.startsWith("cursor:")?$.slice(7):$.startsWith("opencode:")?$.slice(9):$.startsWith("codex:")?$.slice(6):$.startsWith("claude-code:")?$.slice(12):$,E=$&&!F.has(W)?$:"";return{cursorList:O,opencodeList:M,claudeCodeList:K,codexList:z,currentNotInLists:E}},[s,e==null?void 0:e.model]);if(!e)return null;const H=String(e.script??""),A=n==="tool_nodejs"||H.trim()!=="",L=typeof c=="function"&&!o&&(e==null?void 0:e.newId),D=async()=>{if(L){k({status:"running",message:p("flow:nodeProps.publishRunning")});try{const O=await c(e,n);k({status:"success",message:O!=null&&O.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:O.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(O){k({status:"error",message:String((O==null?void 0:O.message)||O)})}}};return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),i.jsxs("div",{className:"af-node-props-head-actions",children:[i.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!L||g.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),i.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[d?i.jsx("p",{className:"af-err af-node-props-err",children:d}):null,g.message?i.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),i.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),i.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:O=>x({newId:O.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:O=>x({label:O.target.value}),disabled:o,spellCheck:!1})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),i.jsx("select",{className:"af-node-props-select",value:Vd.includes(e.role)?e.role:p("flow:roles.normal"),onChange:O=>x({role:O.target.value}),disabled:o,children:Vd.map(O=>i.jsx("option",{value:O,children:O},O))})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),i.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),i.jsxs("select",{className:"af-node-props-select",value:(()=>{const O=(e.model||"").trim();return O?R||O:""})(),onChange:O=>x({model:O.target.value}),disabled:o,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),R?i.jsxs("option",{value:R,children:[R,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?i.jsx("optgroup",{label:"Cursor",children:j.map(O=>i.jsx("option",{value:Iu(O),children:O},`c-${O}`))}):null,N.length>0?i.jsx("optgroup",{label:"OpenCode",children:N.map(O=>i.jsx("option",{value:`opencode:${Iu(O)}`,children:O},`o-${O}`))}):null,I.length>0?i.jsx("optgroup",{label:"Codex",children:I.map(O=>i.jsx("option",{value:`codex:${Iu(O)}`,children:O},`codex-${O}`))}):null,C.length>0?i.jsx("optgroup",{label:"Claude Code",children:C.map(O=>i.jsx("option",{value:`claude-code:${Iu(O)}`,children:O},`cc-${O}`))}):null]})]}),i.jsx(dC,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:O=>x({inputs:O}),disabled:o,requiredReadonly:!u}),i.jsx(dC,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:O=>x({outputs:O}),disabled:o,requiredReadonly:!u}),A?i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Rp,{value:H,onChange:O=>x({script:O}),disabled:o,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:f,variant:"drawer"})]}):null,i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:O=>x({scriptRef:O.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),i.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),i.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:O=>x({implementationRef:O.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),i.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:O=>x({implementationMode:O.target.value}),disabled:o,children:[i.jsx("option",{value:"",children:"auto"}),i.jsx("option",{value:"script",children:"script"}),i.jsx("option",{value:"steps",children:"steps"}),i.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:o,children:i.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),i.jsx(Rp,{value:e.body,onChange:O=>x({body:O}),images:e.images,onImagesChange:O=>x({images:O}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:f,variant:"drawer"})]}),i.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[i.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),i.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:O=>{O.target===O.currentTarget&&b(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Rp,{value:H,onChange:O=>x({script:O}),disabled:o,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null,h?i.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:O=>{O.target===O.currentTarget&&y(!1)},children:i.jsxs("div",{className:"af-node-props-expand-panel",children:[i.jsxs("div",{className:"af-node-props-expand-head",children:[i.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Rp,{value:e.body,onChange:O=>x({body:O}),images:e.images,onImagesChange:O=>x({images:O}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function BU({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=zr(),a=m.useId(),l=m.useRef(null),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState("");if(m.useEffect(()=>{if(!e)return;u(""),h(""),f(!1);const g=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),v=y===n;async function b(g){if(g.preventDefault(),!(!v||d)){f(!0),h("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await k.json().catch(()=>({}));if(!k.ok){h(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}s()}catch(k){h(String((k==null?void 0:k.message)||k))}finally{f(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:i.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:b,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:g=>u(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),p?i.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:d,children:o("project:archiveModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||d,children:o(d?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function HU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=zr(),u=m.useId(),d=m.useRef(null),[f,p]=m.useState(""),[h,y]=m.useState(!1),[v,b]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),b(""),y(!1);const j=requestAnimationFrame(()=>{var N;return(N=d.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(j)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function x(j){if(j.preventDefault(),!k||h)return;y(!0),b("");let N=null;try{const C=new AbortController;N=setTimeout(()=>C.abort(),15e3);const I=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:g,flowArchived:s,workspaceId:o}),signal:C.signal}),R=await I.json().catch(()=>({}));if(!I.ok){b(typeof R.error=="string"?R.error:c("project:deleteModal.deleteFailed"));return}try{for(let H=localStorage.length-1;H>=0;H--){const A=localStorage.key(H);A&&(A.startsWith(`af:composer-sessions:${n}:${r}`)||A.startsWith(`af:composer-active-session:${n}:${r}`)||A.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(A)}}catch{}await l()}catch(C){if((C==null?void 0:C.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((C==null?void 0:C.message)||C))}finally{N&&clearTimeout(N),y(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:j=>{j.target===j.currentTarget&&t()},children:i.jsxs("div",{ref:d,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:j=>j.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("project:deleteModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:x,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:f,onChange:j=>p(j.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),v?i.jsx("p",{className:"af-err af-new-pipeline-err",children:v}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:h,children:c("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||h,children:h?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const fC=80,WU=220;function VU(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:o,measured:a,internals:l,...c}=e;return c}function KU(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Tp(e,t,n){const r={nodes:Array.isArray(e)?e.map(VU):[],edges:Array.isArray(t)?t.map(KU):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function rw(e,t){const n=[...e,t];return n.length>fC?n.slice(n.length-fC):n}function qU({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[o,a]=m.useState(0),l=m.useRef([]),c=m.useRef([]),u=m.useRef(null),d=m.useRef(null),f=m.useRef(null),p=m.useRef(null),h=m.useRef(!1),y=m.useCallback(()=>a(N=>N+1),[]),v=m.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),b=m.useCallback(()=>{v();const N=d.current,C=f.current;return d.current=null,f.current=null,!N||!C||N.signature===C.signature?(C&&(u.current=C),!1):(l.current=rw(l.current,N),c.current=[],u.current=C,y(),!0)},[y,v]),g=m.useCallback((N=[],C=[],I={})=>{v(),l.current=[],c.current=[],d.current=null,f.current=null,u.current=Tp(N,C,I),h.current=!1,y()},[y,v]),k=m.useCallback(N=>{h.current=!0,u.current=N,d.current=null,f.current=null,v(),s==null||s(N.value),y()},[y,v,s]),x=m.useCallback(()=>{b();const N=u.current||Tp(e,t,n),C=l.current.pop();return C?(c.current=rw(c.current,N),k(C),!0):(y(),!1)},[y,t,n,b,e,k]),j=m.useCallback(()=>{b();const N=u.current||Tp(e,t,n),C=c.current.pop();return C?(l.current=rw(l.current,N),k(C),!0):(y(),!1)},[y,t,n,b,e,k]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const N=Tp(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&&(d.current||(d.current=u.current),f.current=N,v(),p.current=window.setTimeout(()=>{b()},WU))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!d.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:j,version:o}}function lo(e){return String(e??"").trim()}function pC(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(lo(e).toLowerCase())}function UU(e){return e===!1?!0:["false","no","not_required","waived"].includes(lo(e).toLowerCase())}function YU(e,t=""){return lo((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)||t)}function jT(e){return lo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function NT(e){return jT(e)==="all"}function GU(e,t=[]){const n=lo((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||(e==null?void 0:e.parent));if(n)return n;const r=jT(e),s=YU(e);if(!s||!["android","ios"].includes(r))return"";const o=`-${r}`;if(!s.endsWith(o))return"";const a=s.slice(0,-o.length);return new Set(t.map(l=>lo(l))).has(a)?a:""}function im(e){const t=lo(e==null?void 0:e.label).toLowerCase(),n=lo((e==null?void 0:e.href)||(e==null?void 0:e.url)).toLowerCase();return/\/merge_requests\/\d+/.test(n)||/\bmr\b|merge request|合并请求|实现 mr|修复 mr|提测 mr|集成 mr/i.test(t)?"mr":/\/issues\/\d+/.test(n)||/gitlab issue/i.test(t)?"issue":"other"}function JU(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[im(n)]-t[im(r)])}function XU(e){const t=lo((e==null?void 0:e.noMrReason)||(e==null?void 0:e.no_mr_reason)||(e==null?void 0:e.mrWaiverReason)||(e==null?void 0:e.mr_waiver_reason)||(e==null?void 0:e.implementationNotRequiredReason)||(e==null?void 0:e.implementation_not_required_reason));return/user confirmed self-test completion without implementation mr evidence/i.test(t)?"自测确认,无需实现 MR":t}function QU(e,t=[]){if(NT(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(im);if(n.includes("mr"))return{kind:"linked",label:"MR 已关联",detail:""};const r=(e==null?void 0:e.mrRequired)??(e==null?void 0:e.mr_required)??(e==null?void 0:e.requiresMr)??(e==null?void 0:e.requires_mr);return pC(e==null?void 0:e.implementationNotRequired)||pC(e==null?void 0:e.implementation_not_required)||UU(r)?{kind:"not-required",label:XU(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function ib(e=[]){return e.reduce((t,n)=>t+1+ib(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function fr(e){return String(e||"").trim()}function Lo(e){return fr(e).toLowerCase()}function om(e){return typeof e=="string"?Lo(e):!e||typeof e!="object"||Array.isArray(e)?"":Lo(e.kind||e.type||e.persistence||e.durability)}function CT(e,t="http://localhost"){const n=fr(e);if(!n)return"";try{const r=new URL(n,t);return r.origin==="null"?`${r.protocol}//${r.host}${r.pathname}`:`${r.origin}${r.pathname}`}catch{return n.split(/[?#]/)[0]}}function _T(e={}){const t=fr(e.href||e.url);if(!t)return!1;const n=Lo(e.kind||e.type),r=Lo(e.durability),s=Lo(e.persistence),o=Lo(e.truth||e.stateTruth||e.state_truth),a=Lo(e.authority),l=om(e.source)||om(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(fr).join(" "),u=[e.label,e.title,n,s,a,l,t].map(fr).join(" ");if(r==="temporary"||s==="runtime"&&l&&l!=="ai-doc"||l==="local-draft"||n==="temporary-review"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(u)||/gitlab[-_ ]?(issue|epic|mr)|merge[-_ ]?request|jenkins|tapd|实现\s*mr|修复\s*mr|提测\s*mr|集成\s*mr|安装包|二维码/i.test(c)||/tapd[-_ ]?(baseline|snapshot)|baseline[-_ ]?snapshot|tapd_snapshot|snapshot_v\d+\.md/i.test(`${c} ${t}`))return!1;const p=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),h=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||s==="ai-doc"&&p,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return h&&(r==="durable"||h||y)}function ET(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(fr).join(" ");return/技术方案|tech(?:nical)?[-_ ]?design/i.test(t)?"tech-design":/方案文档|方案已确认|plan(?:[-_ ]?doc)?/i.test(t)?"plan":/代码审查|code[-_ ]?review/i.test(t)?"code-review":/设计文档|design[-_ ]?doc/i.test(t)?"design":"document"}function ZU(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=fr(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(fr(t)?fr(t):ET(e)==="tech-design"&&fr(n)?fr(n):fr(e.title||e.label))}function eY(e={},t="http://localhost"){const n=fr(e.issueKey||e.issue_key||e.issue),r=ET(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const s=fr(e.documentPath||e.document_path||e.path);return s?`path:${s.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${CT(e.href||e.url,t)}`}function hC(e={}){const t=fr(e.href||e.url),n=Lo(e.kind||e.type),r=om(e.source)||om(e.sourceArtifact||e.source_artifact),s=fr(e.label);let o=0;return e.confirmed===!0&&(o+=100),r==="ai-doc"&&(o+=80),n==="ai-doc"&&(o+=70),/^https?:\/\//i.test(t)&&(o+=30),/\/api\/prd-workflow\/review\//.test(t)&&(o+=20),/预览|review/i.test(s)||(o+=10),o}function tY(e,t){const n=hC(t)>hC(e)?t:e,r=n===t?e:t;return{...r,...n,title:mC(e.title)>=mC(t.title)?e.title:t.title,issueKey:e.issueKey||t.issueKey,platform:e.platform||t.platform,documentPath:n.documentPath||r.documentPath,source:n.source||r.source}}function mC(e){const t=fr(e);if(!t)return 0;const n=t.replace(/^Issue\s*\d+\s*/i,"").trim();return/^(方案文档预览|方案文档|技术方案|设计文档|代码审查|Markdown Review|文档预览)$/i.test(n)?10:100+Math.min(t.length,100)}function sw(e,t){const n=new Map,r=[];for(const s of e){const o=t(s);if(!o){r.push(s);continue}const a=n.get(o);if(a===void 0){n.set(o,r.length),r.push(s);continue}r[a]=tY(r[a],s)}return r}function nY(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>_T(o)),r=sw(n,o=>CT(o.href||o.url,t)),s=sw(r,o=>fr(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return sw(s,o=>eY(o,t))}function Lt(e){return String(e||"").trim()}function co(e){return typeof e=="string"?Lt(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":Lt(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function AT(e){return Lt((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function PT(e){return Lt((e==null?void 0:e.canonicalUrl)||(e==null?void 0:e.canonical_url)||(e==null?void 0:e.reviewUrl)||(e==null?void 0:e.review_url)||(e==null?void 0:e.href)||(e==null?void 0:e.url))}function ob(e){const t=Lt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function rY(e={}){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=Lt(e.issueKey||e.issue_key||e.issue),n=Lt(e.action||e.actionId||e.action_id),r=Lt(e.stageKey||e.stage_key||e.stage||e.phase||e.code||n),s=r.toLowerCase(),o=[r,n,e.code,e.type].map(a=>Lt(a).toLowerCase()).filter(Boolean);return t?/^(?:issue-plan|issue-gitlab|implementation|bugfix|integration):/.test(s)?r:o.some(a=>/^code-review(?::|$)/.test(a)||a==="code_review_completed")?`implementation:${t}`:o.some(a=>/plan_draft_local|submit-plan|plan-doc/.test(a)||["plan_mr","plan_approved","issue-plan"].includes(a))?`issue-plan:${t}`:o.some(a=>/gitlab_issue_missing|ensure-gitlab-issue/.test(a)||a==="issue-gitlab")?`issue-gitlab:${t}`:o.some(a=>["fix_mr","bugfix"].includes(a))?`bugfix:${t}`:o.some(a=>["integration_mr","integrated","integration"].includes(a))?`integration:${t}`:o.some(a=>["implementation_mr","implementation_done","implementation_merged","impl_mr","impl_done","impl_merged","runtime_marker","status","implementation"].includes(a))?`implementation:${t}`:r||n:r||n}function sY(e={}){var o,a;if(!e||typeof e!="object"||Array.isArray(e)||Lt(e.type||e.kind).toLowerCase()!=="workflow-report")return!1;const n=!!Lt(e.action||e.actionId||e.action_id||((o=e.actionModel)==null?void 0:o.key)||((a=e.action_model)==null?void 0:a.key)),r=Lt(e.artifactScope||e.artifact_scope||e.scope).toLowerCase()==="global",s=e.aggregateByStage??e.aggregate_by_stage;return!n&&(r||s===!1)}function Tc(e){const t=AT(e);if(/^prd-review:/i.test(t)||Lt((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(PT(e)))return!0;const n=Lt((e==null?void 0:e.href)||(e==null?void 0:e.url)||(e==null?void 0:e.shortUrl)||(e==null?void 0:e.short_url)),r=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),s=Lt(e==null?void 0:e.durability).toLowerCase(),o=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact));return(r==="review"||r==="temporary-review"||s==="temporary"||s==="durable"||o==="local-draft"||o==="ai-doc")&&/\/r\/[A-Za-z0-9_-]{8,32}(?:[?#]|$)/.test(n)}function gC(e){const t=[e==null?void 0:e.label,e==null?void 0:e.kind,e==null?void 0:e.type,e==null?void 0:e.durability,co(e==null?void 0:e.source)].map(Lt).join(" ");return/方案文档/.test(t)?50:/临时/.test(t)?40:/Markdown Review/i.test(t)?20:/预览|review/i.test(t)?10:0}function iY(e){const t=AT(e);if(t)return`key:${t}`;if(Tc(e)){const n=ob(PT(e));if(n)return`review:${n}`}return`link:${Lt(e==null?void 0:e.label)}
|
|
183
|
-
${ob((e==null?void 0:e.href)||(e==null?void 0:e.url))}`}function oY(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const s=iY(r),o=n.get(s);if(o==null){n.set(s,t.length),t.push(r);continue}const a=t[o],l=gC(r)>=gC(a)?Lt(r==null?void 0:r.label)||Lt(a==null?void 0:a.label):Lt(a==null?void 0:a.label)||Lt(r==null?void 0:r.label);t[o]={...a,...r,...l?{label:l}:{}}}return t}function IT(e){const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.durability).toLowerCase(),r=Lt(e==null?void 0:e.persistence).toLowerCase(),s=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(Lt).join(" ");return t==="temporary-review"||n==="temporary"||s==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function aY(e){if(!Tc(e)||IT(e))return!1;const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.durability).toLowerCase(),r=Lt(e==null?void 0:e.persistence).toLowerCase(),s=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(Lt).join(" ");return t==="review"||n==="durable"||s==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function lY(e){if(Tc(e))return!1;const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.persistence).toLowerCase(),r=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),s=[e==null?void 0:e.label,t].map(Lt).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(s)}function cY(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Lt).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function uY(e=[],t={}){const n=oY(Array.isArray(e)?e:[]);if(!cY(t))return n;const r=n.filter(Tc);if(r.length===0)return n;const s=r.filter(aY),a=s.length>0||n.some(lY)?s.at(-1):r.filter(IT).at(-1);return n.filter(l=>!Tc(l)||l===a)}function vi(e,t){const n=[],r=new Map,s=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=Lt(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=ob(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const d=Lt(a.path);return d&&l.push(`path:${d}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=s(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(d=>r.set(d,u));return}n[c]=a,s(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function qr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function am(e){return Array.isArray(e)?e.map(am):qr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,am(e[t])])):e}function eo(e,t){return JSON.stringify(am(e))===JSON.stringify(am(t))}function RT(e){return qr(e==null?void 0:e.instances)?e.instances:{}}function qd(e){return qr(e==null?void 0:e.ui)?e.ui:{}}function Mp(e,t){if(!qr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function dY(e,t){if(!qr(e)||!qr(t)||!qr(e.instances)||!qr(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!qr(e.ui)||!qr(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=Mp(e,["version","instances","edges","ui"]),r=Mp(t,["version","instances","edges","ui"]);if(!eo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return eo(Mp(e.ui,s),Mp(t.ui,s))}function TT(e){const t=Array.isArray(qd(e).groups)?qd(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function yC(e){const t=new Set(Object.keys(RT(e)));for(const n of Array.isArray(e==null?void 0:e.edges)?e.edges:[])n!=null&&n.source&&t.add(String(n.source)),n!=null&&n.target&&t.add(String(n.target));for(const n of TT(e).keys())t.add(n);return t}function wC(e,t){const n=RT(e),r=qd(e),s=TT(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:qr(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:qr(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:s.get(t)||null}}function xC(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(o=>String(o??"")).join("\0"),s=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(o=>String(o??"")).join("\0");return r.localeCompare(s)})}function fY(e,t){if(!dY(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...yC(e),...yC(t)]),r=Array.from(n).filter(s=>!eo(wC(e,s),wC(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!eo(xC(e),xC(t)),displayPageChanged:!eo(qd(e).displayPage||null,qd(t).displayPage||null)}}function pY(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),s=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!s.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function bC(e){return[e==null?void 0:e.source,e==null?void 0:e.target,e==null?void 0:e.sourceHandle,e==null?void 0:e.targetHandle].map(t=>String(t??"")).join("\0")}function kC(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function hY(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[bC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(bC(r));return s?eo(kC(s),kC(r))?s:{...r,selected:s.selected===!0}:r})}function mY(e,t,n){const r=qr(e)?e:{},s=qr(t)?t:{},o=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(s).map(([a,l])=>[a,!o.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}function gY({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:s=0,currentEditVersion:o=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||o!==s||l!==a)?"local-edits":""}function yY({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function MT(e=[]){let t=!1,n=!1,r=!1;for(const s of Array.isArray(e)?e:[]){if((s==null?void 0:s.type)==="position"&&s.position){r=!0,s.dragging===!0&&(t=!0),s.dragging===!1&&(n=!0);continue}if((s==null?void 0:s.type)==="dimensions"&&s.dimensions){r=!0,s.resizing===!0&&(t=!0),s.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(s==null?void 0:s.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function wY(e=[]){const t=MT(e);return t.mutated&&!t.active}function xY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!0||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!0)}function bY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!1||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!1)}function kY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(xY(s)){t.push(s);continue}n.push(s),bY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function ab(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const s=String((r==null?void 0:r.id)||"").trim();if(!(s&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${s}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function vY(e=[]){return ab(e).map(t=>(t==null?void 0:t.type)==="position"&&t.position&&t.dragging===!0?{...t,dragging:!1}:(t==null?void 0:t.type)==="dimensions"&&t.dimensions&&t.resizing===!0?{...t,resizing:!1}:t)}function vC(e,t){return{...t,waiters:[...Array.isArray(e==null?void 0:e.waiters)?e.waiters:[],...Array.isArray(t==null?void 0:t.waiters)?t.waiters:[]]}}function SY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function jY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const NY="af:workspace-graph:v2",SC="agentflow.workspace.sidebarCollapsed",Dl=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],CY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),_Y={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:""}]},EY={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:""}]},AY={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}]},PY={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}]},IY={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}]},RY={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}]},TY=new Set(["png","jpg","jpeg","gif","webp","svg"]),$T=320,LT=180,OT=960,lm=96,DT=900,lb=520,cb=320,$p=52,Za=240,el=160,ub="display-ref:",Ud="0 9 * * *",MY="Asia/Shanghai",$Y="0.1.122";function LY(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",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.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),t}function dv(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
|
|
183
|
+
${ob((e==null?void 0:e.href)||(e==null?void 0:e.url))}`}function oY(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const s=iY(r),o=n.get(s);if(o==null){n.set(s,t.length),t.push(r);continue}const a=t[o],l=gC(r)>=gC(a)?Lt(r==null?void 0:r.label)||Lt(a==null?void 0:a.label):Lt(a==null?void 0:a.label)||Lt(r==null?void 0:r.label);t[o]={...a,...r,...l?{label:l}:{}}}return t}function IT(e){const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.durability).toLowerCase(),r=Lt(e==null?void 0:e.persistence).toLowerCase(),s=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(Lt).join(" ");return t==="temporary-review"||n==="temporary"||s==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function aY(e){if(!Tc(e)||IT(e))return!1;const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.durability).toLowerCase(),r=Lt(e==null?void 0:e.persistence).toLowerCase(),s=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(Lt).join(" ");return t==="review"||n==="durable"||s==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function lY(e){if(Tc(e))return!1;const t=Lt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Lt(e==null?void 0:e.persistence).toLowerCase(),r=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),s=[e==null?void 0:e.label,t].map(Lt).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(s)}function cY(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Lt).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function uY(e=[],t={}){const n=oY(Array.isArray(e)?e:[]);if(!cY(t))return n;const r=n.filter(Tc);if(r.length===0)return n;const s=r.filter(aY),a=s.length>0||n.some(lY)?s.at(-1):r.filter(IT).at(-1);return n.filter(l=>!Tc(l)||l===a)}function vi(e,t){const n=[],r=new Map,s=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=Lt(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=ob(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const d=Lt(a.path);return d&&l.push(`path:${d}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=s(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(d=>r.set(d,u));return}n[c]=a,s(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function qr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function am(e){return Array.isArray(e)?e.map(am):qr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,am(e[t])])):e}function eo(e,t){return JSON.stringify(am(e))===JSON.stringify(am(t))}function RT(e){return qr(e==null?void 0:e.instances)?e.instances:{}}function qd(e){return qr(e==null?void 0:e.ui)?e.ui:{}}function Mp(e,t){if(!qr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function dY(e,t){if(!qr(e)||!qr(t)||!qr(e.instances)||!qr(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!qr(e.ui)||!qr(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=Mp(e,["version","instances","edges","ui"]),r=Mp(t,["version","instances","edges","ui"]);if(!eo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return eo(Mp(e.ui,s),Mp(t.ui,s))}function TT(e){const t=Array.isArray(qd(e).groups)?qd(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function yC(e){const t=new Set(Object.keys(RT(e)));for(const n of Array.isArray(e==null?void 0:e.edges)?e.edges:[])n!=null&&n.source&&t.add(String(n.source)),n!=null&&n.target&&t.add(String(n.target));for(const n of TT(e).keys())t.add(n);return t}function wC(e,t){const n=RT(e),r=qd(e),s=TT(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:qr(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:qr(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:s.get(t)||null}}function xC(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(o=>String(o??"")).join("\0"),s=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(o=>String(o??"")).join("\0");return r.localeCompare(s)})}function fY(e,t){if(!dY(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...yC(e),...yC(t)]),r=Array.from(n).filter(s=>!eo(wC(e,s),wC(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!eo(xC(e),xC(t)),displayPageChanged:!eo(qd(e).displayPage||null,qd(t).displayPage||null)}}function pY(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),s=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!s.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function bC(e){return[e==null?void 0:e.source,e==null?void 0:e.target,e==null?void 0:e.sourceHandle,e==null?void 0:e.targetHandle].map(t=>String(t??"")).join("\0")}function kC(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function hY(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[bC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(bC(r));return s?eo(kC(s),kC(r))?s:{...r,selected:s.selected===!0}:r})}function mY(e,t,n){const r=qr(e)?e:{},s=qr(t)?t:{},o=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(s).map(([a,l])=>[a,!o.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}function gY({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:s=0,currentEditVersion:o=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||o!==s||l!==a)?"local-edits":""}function yY({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function MT(e=[]){let t=!1,n=!1,r=!1;for(const s of Array.isArray(e)?e:[]){if((s==null?void 0:s.type)==="position"&&s.position){r=!0,s.dragging===!0&&(t=!0),s.dragging===!1&&(n=!0);continue}if((s==null?void 0:s.type)==="dimensions"&&s.dimensions){r=!0,s.resizing===!0&&(t=!0),s.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(s==null?void 0:s.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function wY(e=[]){const t=MT(e);return t.mutated&&!t.active}function xY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!0||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!0)}function bY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!1||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!1)}function kY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(xY(s)){t.push(s);continue}n.push(s),bY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function ab(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const s=String((r==null?void 0:r.id)||"").trim();if(!(s&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${s}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function vY(e=[]){return ab(e).map(t=>(t==null?void 0:t.type)==="position"&&t.position&&t.dragging===!0?{...t,dragging:!1}:(t==null?void 0:t.type)==="dimensions"&&t.dimensions&&t.resizing===!0?{...t,resizing:!1}:t)}function vC(e,t){return{...t,waiters:[...Array.isArray(e==null?void 0:e.waiters)?e.waiters:[],...Array.isArray(t==null?void 0:t.waiters)?t.waiters:[]]}}function SY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function jY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const NY="af:workspace-graph:v2",SC="agentflow.workspace.sidebarCollapsed",Dl=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],CY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),_Y={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:""}]},EY={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:""}]},AY={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}]},PY={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}]},IY={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}]},RY={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}]},TY=new Set(["png","jpg","jpeg","gif","webp","svg"]),$T=320,LT=180,OT=960,lm=96,DT=900,lb=520,cb=320,$p=52,Za=240,el=160,ub="display-ref:",Ud="0 9 * * *",MY="Asia/Shanghai",$Y="0.1.123";function LY(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",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.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),t}function dv(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
|
|
184
184
|
...[truncated ${n.length-t} chars]`:n:""}function OY(e){const t=dv(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 fv(e,t=80){return(Array.isArray(e)?e:[]).map(OY).filter(Boolean).slice(-t)}function DY(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const[r,s]of Object.entries(t).slice(-80)){const o=String(r||"").trim();if(!o||!s||typeof s!="object")continue;const a=fv(s.messages,40),l=dv(s.draft||"",2e3);!a.length&&!l||(n[o]={sessionId:String(s.sessionId||`nodechat_${o}`),messages:a,...l?{draft:l}:{},candidateContent:"",running:!1,error:""})}return n}function FY(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=fv(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:dv((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function jC(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:fv(n.messages,100),runSessions:FY(n.runSessions)},nodeChats:DY(t.nodeChats)}}function cm(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 TY.has(n)}function Yd(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 zY(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",r=String((e==null?void 0:e.adminOwnerId)||"").trim();return`af:composer-skills:workspace:${t}:${n}${r?`:admin:${r}`:""}${e!=null&&e.archived?":archived":""}`}function BY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${SC}:${t}`:SC}function HY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function NC(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function WY(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 VY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!WY(e)}function KY(e){const t=String(e||"").trim();if(!t||qY(t))return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),s=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const o=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${o}`:`执行:${o}`}return/^\[stderr\]/.test(t)?t:""}function qY(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 UY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function iw(e,t,n,r="Workspace Run"){var c;const s=String(n||"").trim(),o=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=o==null?void 0:o.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||s||r}function ow(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function Aa(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 CC(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 YY(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 GY(e){const t=YY(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 FT(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 s=window.location.hostname;n.hostname=s&&s!=="0.0.0.0"&&s!=="::"?s:"127.0.0.1"}const r=String(new URLSearchParams(window.location.search).get("workflowShare")||"").trim();return r&&n.pathname.startsWith("/api/prd-workflow/review/")&&!n.searchParams.has("workflowShare")&&n.searchParams.set("workflowShare",r),n.href}catch{return t}}function mc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return FT(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function ua(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 ea(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 pv(e){return ua(e==null?void 0:e.status)==="done"&&ea(e)!=="observation"}function to(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 hh(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function hv(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 JY(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 XY(e,t){const n=to(e,t),r=ua(e==null?void 0:e.status),s=pv(e),a=`${tl(e)} ${hv(e)}`,l=JY(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"||ea(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"||ea(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function QY(e){if(!e||typeof e!="object")return"";const t=ua(e.status),n=ea(e),r=pv(e),o=`${tl(e)} ${hv(e)}`,a=mv(e),l=a.some(f=>/方案|plan|markdown|review|预览/i.test(String(f.label||""))),c=a.some(f=>/gitlab issue/i.test(String(f.label||""))),u=a.some(f=>/gitlab epic/i.test(String(f.label||"")));if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(o))return r?l?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":n==="observation"||t==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":t==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。";if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(o))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(o))return"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。";if(/implementation_ready/.test(o))return"方案文档和 GitLab Issue 已就绪,等待开始实现。";const d=hh(e);return d?d.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":d:""}function um(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 zT="Asia/Shanghai",ZY=new Intl.DateTimeFormat("zh-CN",{timeZone:zT,year:"numeric",month:"2-digit",day:"2-digit"}),eG=new Intl.DateTimeFormat("zh-CN",{timeZone:zT,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function BT(e){const t=um(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function tG(e){const t=BT(e);return t?ZY.format(t).replace(/\//g,"-"):"无时间"}function nG(e){const t=BT(e);return t?eG.format(t):""}function rG(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=tG(n);let o=t[t.length-1];(!o||o.day!==s)&&(o={day:s,items:[]},t.push(o)),o.items.push({item:n,index:r})}),t}function HT(e){const t=ua(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function Ma(e){const t=String(e||"").trim(),n=t.toLowerCase();return n==="android"?"Android":n==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(n)?"双端":t}function sG(e){const t=ua(e==null?void 0:e.status);return ea(e)==="observation"&&t==="done"?"已观察":HT(t)}function WT(e){if(!e||typeof e!="object")return[];const t=[],n=(o,a,l)=>{const c=String(l||"").trim();c&&t.push({key:`${o}:${c}`,type:o,label:String(a||c),value:c})},r=ua(e.status),s=ea(e)==="observation"&&r==="done"?"observed":r;return n("status",HT(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",Ma(e.platform),e.platform),t}function iG(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{WT(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 oG(e,t){const n=String(t||"all");return!n||n==="all"?!0:WT(e).some(r=>r.key===n)}function aG(e){if(!e||typeof e!="object")return[];const t=[],n=(r,s)=>{const o=String(s||"").trim();o&&t.push({label:r,value:o})};return n("Issue",e.issueKey||e.issue_key||e.issue),n("平台",Ma(e.platform)),t}function mv(e){const t=[],n=(c,u,d={})=>{const f=FT(u);f&&t.push({...d,label:String(c||f).trim()||f,href:f})},r=(c,u="链接",d=0)=>{if(d>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((p,h)=>r(p,`${u} ${h+1}`,d+1));return}if(typeof c!="object")return;const f=c.label||c.title||c.name||c.kind||c.type||u;n(f,c.url||c.href||c.path||c.file||c.filePath||c.file_path,c);for(const p of["links","urls","artifacts","outputs","output","results","result","files"])c[p]!=null&&r(c[p],p,d+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),c);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",mc(c),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 o=c=>{const u=String(c||"").trim();try{const d=new URL(u,window.location.origin);return`${d.origin}${d.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=Tc(c),d=String(c.key||c.artifactKey||c.artifact_key||"").trim(),f=d?`key:${d}`:u?`review:${o(c.canonicalUrl||c.canonical_url||c.href)}`:`${c.label}
|
|
185
185
|
${c.href}`,p=l.get(f);if(!p){l.set(f,c);continue}if(u){const h=a(p.label),y=a(c.label);(y>h||y===h&&String(c.label||"").length>String(p.label||"").length)&&l.set(f,c)}}return uY(Array.from(l.values()),e)}function lG(e,t=[]){var a,l,c,u;const n=[],r=new Map,s=String(((l=(a=e==null?void 0:e.overall)==null?void 0:a.requirement)==null?void 0:l.title)||((u=(c=e==null?void 0:e.overall)==null?void 0:c.requirement)==null?void 0:u.name)||"").trim();for(const d of db(e)){const f=_i(d),p=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();f&&p&&r.set(f,p)}const o=(d,f={})=>{if(!d||typeof d!="object")return;const p=(y,v={})=>{if(!y||typeof y!="object")return;const b=String(f.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),g=y.source||y.sourceArtifact||y.source_artifact||d.sourceArtifact||d.source_artifact||d.source||f.source||null,k=ZU({...y,title:y.title||f.documentTitle||(d==null?void 0:d.title)||"",documentTitle:y.documentTitle||y.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(b)||"",requirementTitle:s}),x={label:String(y.label||"ai-doc").trim()||"ai-doc",href:String(y.href||y.url||"").trim(),kind:String(y.kind||y.type||d.kind||d.type||"").trim(),title:k,issueKey:b,platform:f.platform||Ma(d.platform),durability:y.durability||d.durability||f.durability||"",persistence:y.persistence||d.persistence||f.persistence||"",truth:y.truth||y.stateTruth||y.state_truth||ea(d)||f.truth||"",authority:y.authority||d.authority||f.authority||"",confirmed:y.confirmed??d.confirmed??f.confirmed,source:g,documentPath:y.documentPath||y.document_path||y.path||v.documentPath||(g==null?void 0:g.path)||(g==null?void 0:g.documentPath)||(g==null?void 0:g.document_path)||""};x.href&&n.push(x)};for(const y of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!y||typeof y!="object"||p({...y,label:y.label||y.title||y.kind||"ai-doc",href:mc(y)},{documentPath:y.path});for(const y of Array.isArray(d==null?void 0:d.links)?d.links:[])!y||typeof y!="object"||p({...y,label:y.label||y.title||y.kind||"ai-doc",href:mc(y)},{documentPath:y.path});const h=mc(d);h&&p({...d,label:d.label||d.title||d.kind||"ai-doc",href:h},{documentPath:d.path})};o(e);for(const d of Array.isArray(t)?t:[])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),platform:Ma(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||(d==null?void 0:d.title)||"").trim()});for(const d of["actions","workflowActions","workflow_actions","timeline","history","events","runtimeEvents","runtime_events"])for(const f of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(f,{issueKey:String((f==null?void 0:f.issueKey)||(f==null?void 0:f.issue_key)||(f==null?void 0:f.issue)||"").trim(),platform:Ma(f==null?void 0:f.platform),documentTitle:String((f==null?void 0:f.documentTitle)||(f==null?void 0:f.document_title)||(f==null?void 0:f.title)||"").trim()});for(const d of db(e))o(d,{issueKey:_i(d),platform:Ma(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim()});return nY(n,window.location.origin)}function cG(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 _i(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 uG(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)||_i(e,t)||`Issue ${t+1}`).trim()}function dG(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 fG(e){return String((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(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 pG(e){const t=mv(e),n=(s,o)=>{if(Array.isArray(s)){for(const a of s)if(a)if(typeof a=="string")t.push({label:o,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||o,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 o=String(s.href||"").trim();if(!o)return!1;const a=`${s.label}
|
|
186
186
|
${o}`;return r.has(a)?!1:(r.add(a),!0)})}function hG(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 d of u)d&&typeof d=="object"&&c.issues.push({...d,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(dG(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((d,f)=>_i(d,f));return a.forEach((d,f)=>{const p=_i(d,f);l.set(p,{issue:d,children:[]})}),a.forEach((d,f)=>{const p=_i(d,f),h=fG(d)||GU(d,u),y=l.get(p);h&&l.has(h)?l.get(h).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function dm(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 tl(e){return rY(e)}function fm(e){const t=um(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 db(e){var s,o,a,l,c,u,d,f,p,h,y,v;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const g=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const k of g)!k||typeof k!="object"||Array.isArray(k)||(k.issue&&typeof k.issue=="object"?(n(k.issue),Array.isArray(k.children)&&k.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(k))};return[e==null?void 0:e.issues,(s=e==null?void 0:e.raw)==null?void 0:s.issues,(a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.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,(f=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:f.epics,(h=(p=e==null?void 0:e.raw)==null?void 0:p.prd)==null?void 0:h.epicGroups,(v=(y=e==null?void 0:e.raw)==null?void 0:y.prd)==null?void 0:v.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function mG(e,t){const n=String(t||"").trim();return n&&db(e).find((r,s)=>_i(r,s)===n)||null}function gG(e){var t,n,r,s,o,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=(o=e==null?void 0:e.raw)==null?void 0:o.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 yG(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=mG(e,n),s=String(t.platform||(r==null?void 0:r.platform)||"").trim(),o=s&&!t.platform?{...t,platform:s}:t,a=String((r==null?void 0:r.gitlabIssue)||(r==null?void 0:r.gitlab_issue)||o.gitlabIssue||o.gitlab_issue||"").trim(),l=gG(e);if(!a&&!l)return o;const c=tl(o),u=`${c} ${hv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const f=[];a&&f.push({key:`gitlab-issue:${n}:${(s||"all").toLowerCase()}`,label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({key:"gitlab-epic:requirement",label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const p=ua(o.status),h=a&&p==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...a?{gitlabIssue:a,gitlab_issue:a}:{},...l?{gitlabEpic:l,gitlab_epic:l}:{},...h?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:vi(o.artifacts,f)}}function _C(e,t){const n=fm(t),r=fm(e),s=Number.isFinite(n)&&(!Number.isFinite(r)||n>=r)?t:e,o=(s==null?void 0:s.status)||(t==null?void 0:t.status)||(e==null?void 0:e.status);return{...e,...t,title:to(s,0)||to(t,0)||to(e,0),detail:hh(s)||hh(t)||hh(e),status:o,links:vi(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:vi(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:vi(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:vi(e==null?void 0:e.results,t==null?void 0:t.results),events:vi(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 wG(e,t){const n=[],r=new Map,s=new Map,o=new Map,a=f=>{var p,h;return!!(!f||typeof f!="object"||f.auxiliary===!0||f.auxiliary_event===!0||sY(f)||String(f.type||"")==="review-link"||String(f.type||"")==="action-preview"||f.preview===!0||String(f.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((p=f.conflict)==null?void 0:p.previousArtifact)||((h=f.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(f,p)=>({...f,links:vi(f==null?void 0:f.links,p==null?void 0:p.links),artifacts:vi(f==null?void 0:f.artifacts,p==null?void 0:p.artifacts),outputs:vi(f==null?void 0:f.outputs,p==null?void 0:p.outputs),results:vi(f==null?void 0:f.results,p==null?void 0:p.results)}),c=(f,p)=>{if(!f)return;const h=r.get(f);if(h!=null){n[h]=l(n[h],p);return}o.set(f,l(o.get(f)||{},p))},u=(f,p)=>f&&o.has(f)?l(p,o.get(f)):p,d=f=>{if(Array.isArray(f))for(const p of f){const h=tl(p);if(a(p)){c(h,p);continue}const y=String(p.id||p.eventId||p.event_id||p.actionId||p.action_id||"").trim(),v=h||y,b=v?r.get(v)??s.get(y):null;v&&b!=null?(n[b]=u(h,_C(n[b],p)),h&&r.set(h,b),y&&s.set(y,b)):(v&&r.set(v,n.length),y&&s.set(y,n.length),n.push(u(h,p)))}};if(d(e==null?void 0:e.actions),d(e==null?void 0:e.workflowActions),d(e==null?void 0:e.workflow_actions),d(e==null?void 0:e.timeline),d(e==null?void 0:e.history),d(e==null?void 0:e.events),d(e==null?void 0:e.runtimeEvents),d(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const f=dm(t),p=tl(t),h=p?r.get(p):f?s.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=_C(n[h],y))}return n.map((f,p)=>({item:f,index:p,ts:fm(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,p)=>p.ts-f.ts||f.index-p.index).map(f=>yG(e,f.item))}function xG(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:fm(n)})).sort((n,r)=>{const s=Number.isFinite(n.ts),o=Number.isFinite(r.ts);return s&&o?r.ts-n.ts||r.index-n.index:s?-1:o?1:r.index-n.index}).slice(0,8).map(n=>n.item)}function bG(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 kG(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,s=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,o=Number.isFinite(r)&&Number.isFinite(s)?`(+${Aa(r)} / 总 ${Aa(s)})`:"";return`${t+1}. ${n}${o}`}function VT(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 vG(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 SG(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 jG(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 NG(e){var o,a,l;const t=VT(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=SG(t),u=vG(t),d=Fl(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Fl(t.completedAtMs,c==null?void 0:c.completedAtMs),p=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},h=Number.isFinite(d)&&Number.isFinite(f)?Math.max(0,f-d):Fl(p.executionTime,p.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||p.command||"").trim(),v=y?y.split(`
|
|
@@ -347,4 +347,4 @@ The left node panel allows you to freely drag, delete, and adjust connections.`}
|
|
|
347
347
|
transform: scale(1);
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
|
-
`)),document.head.appendChild(b);const g=setTimeout(()=>{_r.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[h,a,c]);const y=Ui(o.open);let v;if(t){const b=t;v=dt.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:d})}else v=dt.createElement("span",{style:f.beacon},dt.createElement("span",{style:f.beaconOuter}),dt.createElement("span",{style:f.beaconInner}));return dt.createElement("button",{ref:p,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function Jle({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return dt.createElement("button",{style:o,type:"button",...t},dt.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof s=="number"?`${s}px`:s,xmlns:"http://www.w3.org/2000/svg"},dt.createElement("g",null,dt.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function Xle(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:d,styles:f,title:p}=l,h={};u.includes("primary")&&(h.primary=dt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(h.skip=dt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=dt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&dt.createElement(Jle,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Ui(d),"aria-describedby":"joyride-tooltip-content"};return dt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},dt.createElement("div",{style:f.tooltipContainer},p&&dt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),dt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},d)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&dt.createElement("div",{style:f.tooltipFooter},dt.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Qle(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(yi.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(yi.BUTTON_CLOSE):n.close(yi.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(yi.BUTTON_PRIMARY);return}n.next(yi.BUTTON_PRIMARY)},d=g=>{g.preventDefault(),n.skip(yi.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:j,nextWithProgress:N,skip:C}=a.locale,I=Ui(g),R=Ui(k),H=Ui(x),A=Ui(j),L=Ui(C);let D=k,O=R;if(t){if(D=j,O=A,a.showProgress&&!s){const M=Ui(N,{step:r+1,steps:o});D=_b(N,r+1,o),O=M}s&&(D=x,O=H)}return{backProps:{"aria-label":I,children:g,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":R,children:k,"data-action":"close",onClick:c,role:"button",title:R},primaryProps:{"aria-label":O,children:D,"data-action":"primary",onClick:u,role:"button",title:O},skipProps:{"aria-label":L,children:C,"data-action":"skip",onClick:d,role:"button",title:L},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=dt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v})}else b=dt.createElement(Xle,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return b}function Zle(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function ece(e,t,n){var r,s;return e?[sle()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[rle({crossAxis:!1,fallbackPlacements:Zle(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function tce(e){var W,E,Q,V,B;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:d,size:f,step:p,target:h,updateState:y}=e,v=m.useRef(null),b=m.useRef({}),g=m.useRef({}),k=p.placement==="center",x=p.placement==="auto",j=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),N=m.useMemo(()=>a$(h)?Uc(h):void 0,[h]),C=m.useMemo(()=>Yc(h),[h]),I=m.useMemo(()=>N?{boundary:N,rootBoundary:"viewport"}:{},[N]),R=k||x?"bottom":p.placement,H=k?"fixed":((W=p.floatingOptions)==null?void 0:W.strategy)??(p.isFixed||C?"fixed":"absolute"),A=m.useMemo(()=>{var se,ue,G,ee;return k?[{name:"center",fn:({rects:te})=>({x:(window.innerWidth-te.floating.width)/2,y:(window.innerHeight-te.floating.height)/2})}]:[V_(({placement:te})=>{var ce;let ne="right";te.startsWith("top")?ne="top":te.startsWith("bottom")?ne="bottom":te.startsWith("left")&&(ne="left");const Z=p.spotlightTarget?0:p.spotlightPadding[ne];return p.offset+Z+((ce=p.floatingOptions)!=null&&ce.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(se=p.floatingOptions)==null?void 0:se.hideArrow]),...ece(x,p,R),nle({padding:10,...I,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(G=p.floatingOptions)!=null&&G.hideArrow?[]:[ile({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ee=p.floatingOptions)==null?void 0:ee.middleware)??[]]},[k,p,x,R,I]),L=W_({...k?{elements:{reference:j}}:{},placement:R,strategy:H,middleware:A}),D=W_({strategy:H,placement:p.beaconPlacement??(x||k?"bottom":p.placement),middleware:m.useMemo(()=>{var se,ue;return[V_(((ue=(se=p.floatingOptions)==null?void 0:se.beaconOptions)==null?void 0:ue.offset)??-18)]},[(Q=(E=p.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:z_});g.current=L.middlewareData,b.current=D.middlewareData,m.useEffect(()=>{var G;const{floating:se,reference:ue}=L.elements;if(!(!ue||!se||s!==Xe.TOOLTIP))return z_(ue,se,L.update,(G=p.floatingOptions)==null?void 0:G.autoUpdate)},[s,L.update,(V=p.floatingOptions)==null?void 0:V.autoUpdate,p.target,L.elements]),m.useEffect(()=>{!k&&h&&L.refs.setReference(h),h&&D.refs.setReference(h)},[D.refs,k,h,L.refs]),m.useEffect(()=>{L.isPositioned&&c("tooltip",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:g.current})},[c,L.isPositioned,L.placement,L.x,L.y]),m.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:b.current})},[c,D.isPositioned,D.placement,D.x,D.y]);const O=p.zIndex+100,M=m.useCallback(se=>{se.type==="mouseenter"&&p.beaconTrigger!=="hover"||y({lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,y]),K=m.useCallback(se=>{se&&(L.refs.setFloating(se),u(se))},[L.refs,u]),{arrow:z,floater:F}=p.styles;let $=null;if(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE){const se=q_({...F,...L.floatingStyles,zIndex:O,opacity:a&&L.isPositioned?1:0,...!a&&{transition:"none"}});$=dt.createElement("div",{ref:K,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:se},dt.createElement(Qle,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!k&&!((B=p.floatingOptions)!=null&&B.hideArrow)&&dt.createElement(Yle,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:L.placement,position:L.middlewareData.arrow,size:p.arrowSize,styles:z}))}else(s===Xe.BEACON||s===Xe.BEACON_BEFORE)&&($=dt.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:q_({...D.floatingStyles,zIndex:O})},dt.createElement(Gle,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:p.locale,nonce:o,onInteract:M,shouldFocus:d,size:f,step:p,styles:p.styles})));return dt.createElement(d$,{element:l},$)}function nce(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:d,updateState:f}=e,[p,h]=m.useState(null);Kle(d.disableFocusTrap?null:p,"[data-action=primary]");const y=Es(d.target),v=s===Xe.TOOLTIP;return!c$(d)||!_r.domElement(y)?null:dt.createElement(tce,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:d,target:y,updateState:f})}function rce({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,d=Lle(c),{index:f,lifecycle:p,status:h}=n,y=h===At.RUNNING,[v,b]=m.useState(!1),g=m.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),m.useEffect(()=>{if(!y)return;const N=C=>{!r||p!==Xe.TOOLTIP||C.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(yi.KEYBOARD):e.close(yi.KEYBOARD))};return document.body.addEventListener("keydown",N,{passive:!0}),()=>{document.body.removeEventListener("keydown",N)}},[e,y,p,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(yi.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(yi.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const j=n.action===$t.START&&!r.skipBeacon&&r.placement!=="center";return dt.createElement(dt.Fragment,null,p!==Xe.INIT&&dt.createElement(nce,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:d,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:s.current.updateState}),dt.createElement(d$,{element:d},dt.createElement(dt.Fragment,null,v&&dt.createElement(Dle,{nonce:l,step:r}),!j&&dt.createElement(Wle,{...r,continuous:o,lifecycle:p,onClickOverlay:x,portalElement:c?d:null,scrolling:n.scrolling,waiting:n.waiting}))))}function sce(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=$le(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>_m(s,"positioned"),[s]),step:o,Tour:Iv()?dt.createElement(rce,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function ice(e){const{Tour:t}=sce(e);return t}function oce(e){return Iv()?dt.createElement(ice,e):null}function ace(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function lce(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function cce(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Up="af:onboarding";function uce({page:e,hasNodes:t=!1}){const{t:n}=zr(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?ace(n):t?lce(n):cce(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(Up),d=u?JSON.parse(u):{};if(d.completed||d[e]){s(!1),a([]);return}localStorage.setItem(Up,JSON.stringify({...d,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=d=>{var y;const f=d.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(y=f.textContent)==null?void 0:y.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(Up)||"{}",b=JSON.parse(v);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(Up,JSON.stringify(b)),a([]),s(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:i.jsx(oce,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}const dce="agentflow:recent-runs:v1",fce="agentflow:recent-runs:poller",pce=3e3,hce=8e3,mce=2e3,Q_=5e3,gce=16e3,Z_=[1e4,3e4,6e4];function yce(e){return Z_[Math.min(Math.max(e-1,0),Z_.length-1)]}function wce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function xce(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function bce(){const{navigate:e,path:t}=Ts(),[n,r]=m.useState([]),[s,o]=m.useState(!1),[a,l]=m.useState(1),[c,u]=m.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),d=m.useRef(()=>{});m.useEffect(()=>{let j=!1,N=!1,C=!1,I=null,R=0,H=0,A=0,L=0,D=null,O=0,M=0;const K=wce(),z=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(dce):null,$=Ce=>{try{F==null||F.postMessage({...Ce,tabId:K,sentAt:Date.now()})}catch{}},W=()=>{const Ce=Date.now()-gce;for(const[_e,Be]of z)Be<Ce&&z.delete(_e);l(1+z.size)},E=(Ce="presence")=>{$({type:Ce,visible:!document.hidden})},Q=Ce=>{if(!j&&(Array.isArray(Ce.runs)&&r(Ce.runs),Ce.syncHealth&&typeof Ce.syncHealth=="object")){const _e=Ce.syncHealth;O=Number(_e.failureCount)||0,M=Number(_e.lastSuccessAt)||0,u(_e)}},V=Ce=>{Q(Ce),$({type:"state",...Ce})},B=()=>{R&&(window.clearTimeout(R),R=0)},se=Ce=>{B(),!(j||!N||document.hidden)&&(R=window.setTimeout(()=>{R=0,ue()},Math.max(0,Ce)))},ue=async()=>{if(j||!N||document.hidden||D)return;const Ce=new AbortController;D=Ce;let _e=!1;const Be=window.setTimeout(()=>{_e=!0,Ce.abort()},hce);try{const ot=await fetch("/api/pipeline-recent-runs",{signal:Ce.signal});if(!ot.ok)throw new Error(`HTTP ${ot.status}`);const gt=await ot.json();if(j||!N||document.hidden)return;O=0,M=Date.now();const Te=Array.isArray(gt.runs)?gt.runs:[];V({runs:Te.filter(st=>st&&st.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),se(pce)}catch(ot){const gt=Ce.signal.aborted&&!_e;if(j||!N||document.hidden||gt)return;O+=1,V({syncHealth:{status:"delayed",failureCount:O,lastSuccessAt:M,message:_e?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ot==null?void 0:ot.message)||ot)}`}}),se(yce(O))}finally{window.clearTimeout(Be),D===Ce&&(D=null)}},G=()=>{B(),D&&(D.abort(),D=null)},ee=()=>{if(G(),I){const Ce=I;I=null,Ce()}N=!1},te=(Ce=mce)=>{H&&window.clearTimeout(H),!(j||document.hidden||N||C)&&(H=window.setTimeout(()=>{H=0,Z()},Ce))},ne=()=>{j||document.hidden||N||(N=!0,se(0))},Z=async()=>{var Ce;if(!(j||document.hidden||N||C)){if(!((Ce=navigator.locks)!=null&&Ce.request)){ne();return}C=!0;try{await navigator.locks.request(fce,{mode:"exclusive",ifAvailable:!0},async _e=>{if(C=!1,!_e||j||document.hidden){te();return}N=!0,se(0),await new Promise(Be=>{I=Be}),I=null,N=!1})}catch{C=!1}finally{te()}}},ce=()=>{if(!j){if(N){O=0,se(0);return}$({type:"retry"}),te(0)}};d.current=ce,F&&(F.onmessage=Ce=>{const _e=Ce.data;if(!(!_e||_e.tabId===K)){if(_e.type==="hello"||_e.type==="presence"){z.set(_e.tabId,Date.now()),W(),_e.type==="hello"&&E();return}if(_e.type==="bye"){z.delete(_e.tabId),W(),te(0);return}if(_e.type==="state"){z.set(_e.tabId,Date.now()),W(),Q(_e);return}_e.type==="retry"&&N&&(O=0,se(0))}});const de=()=>{E(),document.hidden?ee():te(0)},me=()=>{E("bye"),ee()},$e=()=>{E("hello"),te(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",me),window.addEventListener("pageshow",$e),E("hello"),A=window.setInterval(E,Q_),L=window.setInterval(W,Q_),te(0),()=>{j=!0,d.current=()=>{},E("bye"),ee(),H&&window.clearTimeout(H),A&&window.clearInterval(A),L&&window.clearInterval(L),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",me),window.removeEventListener("pageshow",$e),F==null||F.close()}},[]);const f=j=>{const N=new URLSearchParams({flowId:j.flowId,flowSource:j.flowSource||"workspace"});e(`/flow?${N.toString()}`),o(!1)},p=t==="/flow"?new URLSearchParams(window.location.search):null,h=(p==null?void 0:p.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){f(n[0]);return}o(j=>!j)};return i.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[s&&i.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&i.jsxs("div",{className:"af-run-indicator__sync",children:[i.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),i.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&i.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",xce(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:j=>{j.stopPropagation(),d.current()},children:"立即重试"})]}),n.map(j=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(j.flowId===h?" af-run-indicator__item--current":""),onClick:()=>f(j),title:`${j.flowId} · ${j.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:j.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:j.runId.slice(0,12)})]},`${j.flowId}:${j.runId}`))]}),i.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:x,title:k,children:[i.jsx("span",{className:"af-run-indicator__pulse"}),i.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const jw="0.1.122",kce=6e4,vce=30*6e4;function Lc(e){return String(e||"").trim().replace(/^v/i,"")}function Sce(e,t){const n=Lc(e),r=Lc(t);return!!(n&&r&&n!==r)}function jce(e,t){return`agentflow.app-version.snooze:${Lc(e)}:${Lc(t)}`}function Nce(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Cce(){const[e,t]=m.useState(null);if(m.useEffect(()=>{let r=!1,s=!1;const o=async()=>{if(!(s||document.visibilityState==="hidden")){s=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const d=Lc(u.version);if(!Sce(jw,d)){t(null);return}const f=jce(jw,d);if(Nce(f)>Date.now())return;t({clientVersion:Lc(jw),serverVersion:d,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),kce);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",o),o(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",o)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+vce))}catch{}t(null)};return i.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),i.jsxs("div",{className:"af-app-version-notice__copy",children:[i.jsx("strong",{children:"AgentFlow 已更新"}),i.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),i.jsxs("div",{className:"af-app-version-notice__actions",children:[i.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),i.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function f$(e){return e==="/likee-context"||e==="/likee_context"}function _ce(){const{navigate:e}=Ts();return m.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",s=t.get("flowSource")||"";r&&n.set("flowId",r),s&&n.set("flowSource",s),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class Ece extends m.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((s=this.state.error)==null?void 0:s.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return i.jsx("div",{className:"af-auth-screen",children:i.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"error"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow UI Error"}),i.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),i.jsx("pre",{children:t}),n?i.jsx("pre",{children:n}):null]})})}}function Ace({authUser:e}){const{path:t}=Ts();return t==="/projects"||t==="/"?i.jsx(Il,{authUser:e}):t==="/nodes"?i.jsx(Il,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Il,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Il,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Il,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(Yie,{authUser:e}):t==="/mcps"?i.jsx(Lie,{}):t==="/schedules"?i.jsx(zie,{}):t==="/node-studio"?i.jsx(Hie,{}):t==="/flow"?i.jsx(_ce,{}):t==="/workspace"?i.jsx(YJ,{}):t.startsWith("/display")?i.jsx(SM,{}):t==="/settings"?i.jsx(kie,{authUser:e}):t==="/admin/usage"?i.jsx(Aie,{authUser:e}):t==="/feedback"?i.jsx(Iie,{authUser:e}):f$(t)?i.jsx(LM,{}):i.jsx(Il,{})}function Pce({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[o,a]=m.useState(""),[l,c]=m.useState(!1),[u,d]=m.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),d(y.error?String(y.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),d(String(h.message||h))}};m.useEffect(()=>{f()},[]);const p=async h=>{h.preventDefault(),c(!0),d("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");s(""),a(""),window.location.replace(window.location.href);return}catch(y){d(String(y.message||y))}finally{c(!1)}};return t.loading?i.jsx("div",{className:"af-auth-screen",children:i.jsx("div",{className:"af-auth-panel",children:"Loading..."})}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):i.jsx("div",{className:"af-auth-screen",children:i.jsxs("form",{className:"af-auth-panel",onSubmit:p,autoComplete:"on",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow"}),i.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"用户名"}),i.jsx("input",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:h=>s(h.target.value),autoComplete:"username",autoFocus:!0})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"密码"}),i.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?i.jsx("p",{className:"af-auth-error",children:u}):null,i.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function Ice({authUser:e,onLogout:t}){const{path:n}=Ts(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(uce,{page:r?"flow":"projects"}):null,r?null:i.jsx(LD,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(Ace,{authUser:e})}),i.jsx(bce,{})]})}function Rce(){return i.jsx(Ece,{children:i.jsxs(yD,{children:[i.jsx(Tce,{}),i.jsx(Cce,{})]})})}function Tce(){const{path:e}=Ts();return e.startsWith("/display")?i.jsx(SM,{}):f$(e)?i.jsx(LM,{}):i.jsx(Pce,{children:({user:t,onLogout:n})=>i.jsx(Ice,{authUser:t,onLogout:n})})}window.addEventListener("error",e=>{console.error("[AgentFlow UI global error]",e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})});window.addEventListener("unhandledrejection",e=>{console.error("[AgentFlow UI unhandled rejection]",e.reason)});const eE=document.querySelector('link[rel="icon"]');eE&&(eE.href=gP);Nw.createRoot(document.getElementById("root")).render(i.jsx(dt.StrictMode,{children:i.jsx(Rce,{})}));
|
|
350
|
+
`)),document.head.appendChild(b);const g=setTimeout(()=>{_r.domElement(p.current)&&c&&p.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[h,a,c]);const y=Ui(o.open);let v;if(t){const b=t;v=dt.createElement(b,{continuous:n,index:r,isLastStep:s,size:u,step:d})}else v=dt.createElement("span",{style:f.beacon},dt.createElement("span",{style:f.beaconOuter}),dt.createElement("span",{style:f.beaconInner}));return dt.createElement("button",{ref:p,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:f.beaconWrapper,title:y,type:"button"},v)}function Jle({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return dt.createElement("button",{style:o,type:"button",...t},dt.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof s=="number"?`${s}px`:s,xmlns:"http://www.w3.org/2000/svg"},dt.createElement("g",null,dt.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function Xle(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:d,styles:f,title:p}=l,h={};u.includes("primary")&&(h.primary=dt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(h.skip=dt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=dt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&dt.createElement(Jle,{"data-testid":"button-close",styles:f.buttonClose,...n});const y=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Ui(d),"aria-describedby":"joyride-tooltip-content"};return dt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},dt.createElement("div",{style:f.tooltipContainer},p&&dt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),dt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},d)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&dt.createElement("div",{style:f.tooltipFooter},dt.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function Qle(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(yi.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(yi.BUTTON_CLOSE):n.close(yi.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(yi.BUTTON_PRIMARY);return}n.next(yi.BUTTON_PRIMARY)},d=g=>{g.preventDefault(),n.skip(yi.BUTTON_SKIP)},f=()=>{const{back:g,close:k,last:x,next:j,nextWithProgress:N,skip:C}=a.locale,I=Ui(g),R=Ui(k),H=Ui(x),A=Ui(j),L=Ui(C);let D=k,O=R;if(t){if(D=j,O=A,a.showProgress&&!s){const M=Ui(N,{step:r+1,steps:o});D=_b(N,r+1,o),O=M}s&&(D=x,O=H)}return{backProps:{"aria-label":I,children:g,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":R,children:k,"data-action":"close",onClick:c,role:"button",title:R},primaryProps:{"aria-label":O,children:D,"data-action":"primary",onClick:u,role:"button",title:O},skipProps:{"aria-label":L,children:C,"data-action":"skip",onClick:d,role:"button",title:L},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=dt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v})}else b=dt.createElement(Xle,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return b}function Zle(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function ece(e,t,n){var r,s;return e?[sle()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[rle({crossAxis:!1,fallbackPlacements:Zle(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function tce(e){var W,E,Q,V,B;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:d,size:f,step:p,target:h,updateState:y}=e,v=m.useRef(null),b=m.useRef({}),g=m.useRef({}),k=p.placement==="center",x=p.placement==="auto",j=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),N=m.useMemo(()=>a$(h)?Uc(h):void 0,[h]),C=m.useMemo(()=>Yc(h),[h]),I=m.useMemo(()=>N?{boundary:N,rootBoundary:"viewport"}:{},[N]),R=k||x?"bottom":p.placement,H=k?"fixed":((W=p.floatingOptions)==null?void 0:W.strategy)??(p.isFixed||C?"fixed":"absolute"),A=m.useMemo(()=>{var se,ue,G,ee;return k?[{name:"center",fn:({rects:te})=>({x:(window.innerWidth-te.floating.width)/2,y:(window.innerHeight-te.floating.height)/2})}]:[V_(({placement:te})=>{var ce;let ne="right";te.startsWith("top")?ne="top":te.startsWith("bottom")?ne="bottom":te.startsWith("left")&&(ne="left");const Z=p.spotlightTarget?0:p.spotlightPadding[ne];return p.offset+Z+((ce=p.floatingOptions)!=null&&ce.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(se=p.floatingOptions)==null?void 0:se.hideArrow]),...ece(x,p,R),nle({padding:10,...I,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(G=p.floatingOptions)!=null&&G.hideArrow?[]:[ile({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ee=p.floatingOptions)==null?void 0:ee.middleware)??[]]},[k,p,x,R,I]),L=W_({...k?{elements:{reference:j}}:{},placement:R,strategy:H,middleware:A}),D=W_({strategy:H,placement:p.beaconPlacement??(x||k?"bottom":p.placement),middleware:m.useMemo(()=>{var se,ue;return[V_(((ue=(se=p.floatingOptions)==null?void 0:se.beaconOptions)==null?void 0:ue.offset)??-18)]},[(Q=(E=p.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:Q.offset]),whileElementsMounted:z_});g.current=L.middlewareData,b.current=D.middlewareData,m.useEffect(()=>{var G;const{floating:se,reference:ue}=L.elements;if(!(!ue||!se||s!==Xe.TOOLTIP))return z_(ue,se,L.update,(G=p.floatingOptions)==null?void 0:G.autoUpdate)},[s,L.update,(V=p.floatingOptions)==null?void 0:V.autoUpdate,p.target,L.elements]),m.useEffect(()=>{!k&&h&&L.refs.setReference(h),h&&D.refs.setReference(h)},[D.refs,k,h,L.refs]),m.useEffect(()=>{L.isPositioned&&c("tooltip",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:g.current})},[c,L.isPositioned,L.placement,L.x,L.y]),m.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:b.current})},[c,D.isPositioned,D.placement,D.x,D.y]);const O=p.zIndex+100,M=m.useCallback(se=>{se.type==="mouseenter"&&p.beaconTrigger!=="hover"||y({lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,y]),K=m.useCallback(se=>{se&&(L.refs.setFloating(se),u(se))},[L.refs,u]),{arrow:z,floater:F}=p.styles;let $=null;if(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE){const se=q_({...F,...L.floatingStyles,zIndex:O,opacity:a&&L.isPositioned?1:0,...!a&&{transition:"none"}});$=dt.createElement("div",{ref:K,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:se},dt.createElement(Qle,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!k&&!((B=p.floatingOptions)!=null&&B.hideArrow)&&dt.createElement(Yle,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:L.placement,position:L.middlewareData.arrow,size:p.arrowSize,styles:z}))}else(s===Xe.BEACON||s===Xe.BEACON_BEFORE)&&($=dt.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:q_({...D.floatingStyles,zIndex:O})},dt.createElement(Gle,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===f,locale:p.locale,nonce:o,onInteract:M,shouldFocus:d,size:f,step:p,styles:p.styles})));return dt.createElement(d$,{element:l},$)}function nce(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:d,updateState:f}=e,[p,h]=m.useState(null);Kle(d.disableFocusTrap?null:p,"[data-action=primary]");const y=Es(d.target),v=s===Xe.TOOLTIP;return!c$(d)||!_r.domElement(y)?null:dt.createElement(tce,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:h,shouldScroll:c,size:u,step:d,target:y,updateState:f})}function rce({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,d=Lle(c),{index:f,lifecycle:p,status:h}=n,y=h===At.RUNNING,[v,b]=m.useState(!1),g=m.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),m.useEffect(()=>{if(!y)return;const N=C=>{!r||p!==Xe.TOOLTIP||C.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(yi.KEYBOARD):e.close(yi.KEYBOARD))};return document.body.addEventListener("keydown",N,{passive:!0}),()=>{document.body.removeEventListener("keydown",N)}},[e,y,p,r]);const x=m.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(yi.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(yi.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const j=n.action===$t.START&&!r.skipBeacon&&r.placement!=="center";return dt.createElement(dt.Fragment,null,p!==Xe.INIT&&dt.createElement(nce,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:d,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(f!==0||u),step:r,updateState:s.current.updateState}),dt.createElement(d$,{element:d},dt.createElement(dt.Fragment,null,v&&dt.createElement(Dle,{nonce:l,step:r}),!j&&dt.createElement(Wle,{...r,continuous:o,lifecycle:p,onClickOverlay:x,portalElement:c?d:null,scrolling:n.scrolling,waiting:n.waiting}))))}function sce(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=$le(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>_m(s,"positioned"),[s]),step:o,Tour:Iv()?dt.createElement(rce,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function ice(e){const{Tour:t}=sce(e);return t}function oce(e){return Iv()?dt.createElement(ice,e):null}function ace(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function lce(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function cce(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Up="af:onboarding";function uce({page:e,hasNodes:t=!1}){const{t:n}=zr(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?ace(n):t?lce(n):cce(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(Up),d=u?JSON.parse(u):{};if(d.completed||d[e]){s(!1),a([]);return}localStorage.setItem(Up,JSON.stringify({...d,[e]:!0})),a(c),s(!0)},[e,t,c]),m.useEffect(()=>{if(!r)return;const u=d=>{var y;const f=d.target.closest("button");if(!f||!f.closest(".react-joyride__tooltip"))return;const h=(y=f.textContent)==null?void 0:y.trim();if(h===n("onboarding:done")||h===n("onboarding:startCreate")||h===n("onboarding:skip")){const v=localStorage.getItem(Up)||"{}",b=JSON.parse(v);h===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(Up,JSON.stringify(b)),a([]),s(!1),e==="projects"&&(h===n("onboarding:done")||h===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:i.jsx(oce,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}const dce="agentflow:recent-runs:v1",fce="agentflow:recent-runs:poller",pce=3e3,hce=8e3,mce=2e3,Q_=5e3,gce=16e3,Z_=[1e4,3e4,6e4];function yce(e){return Z_[Math.min(Math.max(e-1,0),Z_.length-1)]}function wce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function xce(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function bce(){const{navigate:e,path:t}=Ts(),[n,r]=m.useState([]),[s,o]=m.useState(!1),[a,l]=m.useState(1),[c,u]=m.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),d=m.useRef(()=>{});m.useEffect(()=>{let j=!1,N=!1,C=!1,I=null,R=0,H=0,A=0,L=0,D=null,O=0,M=0;const K=wce(),z=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(dce):null,$=Ce=>{try{F==null||F.postMessage({...Ce,tabId:K,sentAt:Date.now()})}catch{}},W=()=>{const Ce=Date.now()-gce;for(const[_e,Be]of z)Be<Ce&&z.delete(_e);l(1+z.size)},E=(Ce="presence")=>{$({type:Ce,visible:!document.hidden})},Q=Ce=>{if(!j&&(Array.isArray(Ce.runs)&&r(Ce.runs),Ce.syncHealth&&typeof Ce.syncHealth=="object")){const _e=Ce.syncHealth;O=Number(_e.failureCount)||0,M=Number(_e.lastSuccessAt)||0,u(_e)}},V=Ce=>{Q(Ce),$({type:"state",...Ce})},B=()=>{R&&(window.clearTimeout(R),R=0)},se=Ce=>{B(),!(j||!N||document.hidden)&&(R=window.setTimeout(()=>{R=0,ue()},Math.max(0,Ce)))},ue=async()=>{if(j||!N||document.hidden||D)return;const Ce=new AbortController;D=Ce;let _e=!1;const Be=window.setTimeout(()=>{_e=!0,Ce.abort()},hce);try{const ot=await fetch("/api/pipeline-recent-runs",{signal:Ce.signal});if(!ot.ok)throw new Error(`HTTP ${ot.status}`);const gt=await ot.json();if(j||!N||document.hidden)return;O=0,M=Date.now();const Te=Array.isArray(gt.runs)?gt.runs:[];V({runs:Te.filter(st=>st&&st.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),se(pce)}catch(ot){const gt=Ce.signal.aborted&&!_e;if(j||!N||document.hidden||gt)return;O+=1,V({syncHealth:{status:"delayed",failureCount:O,lastSuccessAt:M,message:_e?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ot==null?void 0:ot.message)||ot)}`}}),se(yce(O))}finally{window.clearTimeout(Be),D===Ce&&(D=null)}},G=()=>{B(),D&&(D.abort(),D=null)},ee=()=>{if(G(),I){const Ce=I;I=null,Ce()}N=!1},te=(Ce=mce)=>{H&&window.clearTimeout(H),!(j||document.hidden||N||C)&&(H=window.setTimeout(()=>{H=0,Z()},Ce))},ne=()=>{j||document.hidden||N||(N=!0,se(0))},Z=async()=>{var Ce;if(!(j||document.hidden||N||C)){if(!((Ce=navigator.locks)!=null&&Ce.request)){ne();return}C=!0;try{await navigator.locks.request(fce,{mode:"exclusive",ifAvailable:!0},async _e=>{if(C=!1,!_e||j||document.hidden){te();return}N=!0,se(0),await new Promise(Be=>{I=Be}),I=null,N=!1})}catch{C=!1}finally{te()}}},ce=()=>{if(!j){if(N){O=0,se(0);return}$({type:"retry"}),te(0)}};d.current=ce,F&&(F.onmessage=Ce=>{const _e=Ce.data;if(!(!_e||_e.tabId===K)){if(_e.type==="hello"||_e.type==="presence"){z.set(_e.tabId,Date.now()),W(),_e.type==="hello"&&E();return}if(_e.type==="bye"){z.delete(_e.tabId),W(),te(0);return}if(_e.type==="state"){z.set(_e.tabId,Date.now()),W(),Q(_e);return}_e.type==="retry"&&N&&(O=0,se(0))}});const de=()=>{E(),document.hidden?ee():te(0)},me=()=>{E("bye"),ee()},$e=()=>{E("hello"),te(0)};return document.addEventListener("visibilitychange",de),window.addEventListener("pagehide",me),window.addEventListener("pageshow",$e),E("hello"),A=window.setInterval(E,Q_),L=window.setInterval(W,Q_),te(0),()=>{j=!0,d.current=()=>{},E("bye"),ee(),H&&window.clearTimeout(H),A&&window.clearInterval(A),L&&window.clearInterval(L),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",me),window.removeEventListener("pageshow",$e),F==null||F.close()}},[]);const f=j=>{const N=new URLSearchParams({flowId:j.flowId,flowSource:j.flowSource||"workspace"});e(`/flow?${N.toString()}`),o(!1)},p=t==="/flow"?new URLSearchParams(window.location.search):null,h=(p==null?void 0:p.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){f(n[0]);return}o(j=>!j)};return i.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[s&&i.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&i.jsxs("div",{className:"af-run-indicator__sync",children:[i.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),i.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&i.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",xce(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:j=>{j.stopPropagation(),d.current()},children:"立即重试"})]}),n.map(j=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(j.flowId===h?" af-run-indicator__item--current":""),onClick:()=>f(j),title:`${j.flowId} · ${j.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:j.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:j.runId.slice(0,12)})]},`${j.flowId}:${j.runId}`))]}),i.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:x,title:k,children:[i.jsx("span",{className:"af-run-indicator__pulse"}),i.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const jw="0.1.123",kce=6e4,vce=30*6e4;function Lc(e){return String(e||"").trim().replace(/^v/i,"")}function Sce(e,t){const n=Lc(e),r=Lc(t);return!!(n&&r&&n!==r)}function jce(e,t){return`agentflow.app-version.snooze:${Lc(e)}:${Lc(t)}`}function Nce(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Cce(){const[e,t]=m.useState(null);if(m.useEffect(()=>{let r=!1,s=!1;const o=async()=>{if(!(s||document.visibilityState==="hidden")){s=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const d=Lc(u.version);if(!Sce(jw,d)){t(null);return}const f=jce(jw,d);if(Nce(f)>Date.now())return;t({clientVersion:Lc(jw),serverVersion:d,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),kce);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",o),o(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",o)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+vce))}catch{}t(null)};return i.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),i.jsxs("div",{className:"af-app-version-notice__copy",children:[i.jsx("strong",{children:"AgentFlow 已更新"}),i.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),i.jsxs("div",{className:"af-app-version-notice__actions",children:[i.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),i.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function f$(e){return e==="/likee-context"||e==="/likee_context"}function _ce(){const{navigate:e}=Ts();return m.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",s=t.get("flowSource")||"";r&&n.set("flowId",r),s&&n.set("flowSource",s),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class Ece extends m.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((s=this.state.error)==null?void 0:s.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return i.jsx("div",{className:"af-auth-screen",children:i.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"error"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow UI Error"}),i.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),i.jsx("pre",{children:t}),n?i.jsx("pre",{children:n}):null]})})}}function Ace({authUser:e}){const{path:t}=Ts();return t==="/projects"||t==="/"?i.jsx(Il,{authUser:e}):t==="/nodes"?i.jsx(Il,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Il,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Il,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Il,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(Yie,{authUser:e}):t==="/mcps"?i.jsx(Lie,{}):t==="/schedules"?i.jsx(zie,{}):t==="/node-studio"?i.jsx(Hie,{}):t==="/flow"?i.jsx(_ce,{}):t==="/workspace"?i.jsx(YJ,{}):t.startsWith("/display")?i.jsx(SM,{}):t==="/settings"?i.jsx(kie,{authUser:e}):t==="/admin/usage"?i.jsx(Aie,{authUser:e}):t==="/feedback"?i.jsx(Iie,{authUser:e}):f$(t)?i.jsx(LM,{}):i.jsx(Il,{})}function Pce({children:e}){const[t,n]=m.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=m.useState(""),[o,a]=m.useState(""),[l,c]=m.useState(!1),[u,d]=m.useState(""),f=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),d(y.error?String(y.error):"")}catch(h){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),d(String(h.message||h))}};m.useEffect(()=>{f()},[]);const p=async h=>{h.preventDefault(),c(!0),d("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");s(""),a(""),window.location.replace(window.location.href);return}catch(y){d(String(y.message||y))}finally{c(!1)}};return t.loading?i.jsx("div",{className:"af-auth-screen",children:i.jsx("div",{className:"af-auth-panel",children:"Loading..."})}):t.authenticated?e({user:t.user,onLogout:async()=>{await fetch("/api/auth/logout",{method:"POST"}).catch(()=>{}),n({loading:!1,authenticated:!1,user:null,setupRequired:!1})}}):i.jsx("div",{className:"af-auth-screen",children:i.jsxs("form",{className:"af-auth-panel",onSubmit:p,autoComplete:"on",children:[i.jsxs("div",{className:"af-auth-brand",children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),i.jsxs("div",{children:[i.jsx("h1",{children:"AgentFlow"}),i.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"用户名"}),i.jsx("input",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:h=>s(h.target.value),autoComplete:"username",autoFocus:!0})]}),i.jsxs("label",{className:"af-auth-field",children:[i.jsx("span",{children:"密码"}),i.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:h=>a(h.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?i.jsx("p",{className:"af-auth-error",children:u}):null,i.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function Ice({authUser:e,onLogout:t}){const{path:n}=Ts(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(uce,{page:r?"flow":"projects"}):null,r?null:i.jsx(LD,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(Ace,{authUser:e})}),i.jsx(bce,{})]})}function Rce(){return i.jsx(Ece,{children:i.jsxs(yD,{children:[i.jsx(Tce,{}),i.jsx(Cce,{})]})})}function Tce(){const{path:e}=Ts();return e.startsWith("/display")?i.jsx(SM,{}):f$(e)?i.jsx(LM,{}):i.jsx(Pce,{children:({user:t,onLogout:n})=>i.jsx(Ice,{authUser:t,onLogout:n})})}window.addEventListener("error",e=>{console.error("[AgentFlow UI global error]",e.error||e.message,{filename:e.filename,lineno:e.lineno,colno:e.colno})});window.addEventListener("unhandledrejection",e=>{console.error("[AgentFlow UI unhandled rejection]",e.reason)});const eE=document.querySelector('link[rel="icon"]');eE&&(eE.href=gP);Nw.createRoot(document.getElementById("root")).render(i.jsx(dt.StrictMode,{children:i.jsx(Rce,{})}));
|
|
@@ -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-DgVzYtNU.js"></script>
|
|
19
19
|
<link rel="stylesheet" crossorigin href="/assets/index-BKLuP3ZS.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.123",
|
|
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",
|