@yiyi_zhang/reactflow-ui 0.3.0 → 0.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -22
- package/dist/AiWorkflowIDE.d.ts +217 -0
- package/dist/WorkflowIDE.d.ts +22 -3
- package/dist/ai-BJwQZcGK.js +15168 -0
- package/dist/ai.d.ts +30 -0
- package/dist/arc-BUGZGgtu.js +83 -0
- package/dist/architectureDiagram-3BPJPVTR-ZcgvTwSO.js +4692 -0
- package/dist/blockDiagram-GPEHLZMM-DtVtOBbH.js +2418 -0
- package/dist/c4Diagram-AAUBKEIU-tBS5Rcvm.js +1577 -0
- package/dist/channel-CURI9jmI.js +5 -0
- package/dist/chunk-2J33WTMH-D7gashNz.js +19 -0
- package/dist/chunk-4BX2VUAB-DE3VjyiZ.js +8 -0
- package/dist/chunk-55IACEB6-GYZ_m2MY.js +8 -0
- package/dist/chunk-727SXJPM-D4WVyvOg.js +1528 -0
- package/dist/chunk-AQP2D5EJ-Os2Uwqya.js +1387 -0
- package/dist/chunk-FMBD7UC4-B3CSVzS4.js +19 -0
- package/dist/chunk-ND2GUHAM-CNj_s1aK.js +68 -0
- package/dist/chunk-QZHKN3VN-DoV8iUKo.js +15 -0
- package/dist/classDiagram-4FO5ZUOK-Dr9C18x4.js +16 -0
- package/dist/classDiagram-v2-Q7XG4LA2-Dr9C18x4.js +16 -0
- package/dist/components/AiNative/AgentTimeline.d.ts +18 -0
- package/dist/components/AiNative/AiCommandCenter.d.ts +40 -0
- package/dist/components/AiNative/AiConfigPanel.d.ts +9 -0
- package/dist/components/AiNative/BusinessCanvas.d.ts +15 -0
- package/dist/components/AiNative/CanvasPreview.d.ts +16 -0
- package/dist/components/AiNative/ClarificationCard.d.ts +9 -0
- package/dist/components/AiNative/FailureSummaryCard.d.ts +20 -0
- package/dist/components/AiNative/LibraryPanel.d.ts +9 -0
- package/dist/components/AiNative/MermaidBlock.d.ts +6 -0
- package/dist/components/AiNative/PlanCard.d.ts +15 -0
- package/dist/components/AiNative/ProposalPreviewCard.d.ts +21 -0
- package/dist/components/AiNative/RecommendationCard.d.ts +10 -0
- package/dist/components/AiNative/RepairCard.d.ts +17 -0
- package/dist/components/AiNative/ReviewBar.d.ts +21 -0
- package/dist/components/AiNative/WorkflowRunCard.d.ts +14 -0
- package/dist/components/Controls/ModeSlider.d.ts +2 -0
- package/dist/components/ExecutionSummaryPanel.d.ts +4 -0
- package/dist/components/WorkflowRunPanel.d.ts +12 -0
- package/dist/components/nodes/NodeWrapper.d.ts +2 -1
- package/dist/cose-bilkent-S5V4N54A-CgQlI-io.js +2609 -0
- package/dist/cytoscape.esm-kVAWcYoG.js +18755 -0
- package/dist/dagre-BM42HDAG-CFMIuOmS.js +445 -0
- package/dist/defaultLocale-BgPVtth8.js +171 -0
- package/dist/diagram-2AECGRRQ-C5jZp2YX.js +217 -0
- package/dist/diagram-5GNKFQAL-DRUVcHpp.js +123 -0
- package/dist/diagram-KO2AKTUF-BOl4aaej.js +461 -0
- package/dist/diagram-LMA3HP47-ZeckPR2Q.js +142 -0
- package/dist/diagram-OG6HWLK6-qUWeLfa-.js +528 -0
- package/dist/erDiagram-TEJ5UH35-Bw_CWS13.js +899 -0
- package/dist/flowDiagram-I6XJVG4X-D3xEvQA-.js +1628 -0
- package/dist/ganttDiagram-6RSMTGT7-D8GvenY3.js +2707 -0
- package/dist/gitGraphDiagram-PVQCEYII-BWrN_HOm.js +815 -0
- package/dist/graph-BRoPeNF3.js +1545 -0
- package/dist/hooks/useNodeExecution.d.ts +1 -1
- package/dist/hooks/useNodeLayout.d.ts +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/infoDiagram-5YYISTIA-Da8FG5tB.js +24 -0
- package/dist/init-DjUOC4st.js +16 -0
- package/dist/ishikawaDiagram-YF4QCWOH-Bg2_mKEc.js +621 -0
- package/dist/journeyDiagram-JHISSGLW-sFIxGfua.js +834 -0
- package/dist/kanban-definition-UN3LZRKU-CGmopzHd.js +724 -0
- package/dist/katex-DoRnZ_sp.js +11682 -0
- package/dist/layout-D9EpM4Fg.js +1728 -0
- package/dist/linear-BA49eco4.js +259 -0
- package/dist/mermaid.core-XSpZEAKP.js +16137 -0
- package/dist/mindmap-definition-RKZ34NQL-Bqf76QGB.js +827 -0
- package/dist/ordinal-B6-f3MAq.js +61 -0
- package/dist/pieDiagram-4H26LBE5-hHiP8HzL.js +163 -0
- package/dist/quadrantDiagram-W4KKPZXB-DSccwH8B.js +1024 -0
- package/dist/reactflow-ui-ai.es.js +12 -0
- package/dist/reactflow-ui.css +1 -1
- package/dist/reactflow-ui.es.js +8198 -7039
- package/dist/reactflow-ui.umd.js +52 -17
- package/dist/requirementDiagram-4Y6WPE33-DIpyoYZ_.js +882 -0
- package/dist/sankeyDiagram-5OEKKPKP-DsaPqq8D.js +847 -0
- package/dist/sequenceDiagram-3UESZ5HK-BNg7orie.js +2891 -0
- package/dist/services/ai/agentRunner.d.ts +51 -0
- package/dist/services/ai/contextEngine.d.ts +83 -0
- package/dist/services/ai/draftPersistence.d.ts +22 -0
- package/dist/services/ai/errorMessages.d.ts +16 -0
- package/dist/services/ai/intentClassifier.d.ts +17 -0
- package/dist/services/ai/protocolAdapter.d.ts +114 -0
- package/dist/services/ai/ruleEngine.d.ts +57 -0
- package/dist/services/ai/schemaRegistry.d.ts +51 -0
- package/dist/services/ai/systemPrompt.d.ts +30 -0
- package/dist/services/ai/toolDefs.d.ts +9 -0
- package/dist/services/ai/toolExecutor.d.ts +83 -0
- package/dist/services/ai/toolRegistry.d.ts +38 -0
- package/dist/services/ai/transport.d.ts +58 -0
- package/dist/services/aiService.d.ts +27 -5
- package/dist/stateDiagram-AJRCARHV-Rv1mSmnJ.js +263 -0
- package/dist/stateDiagram-v2-BHNVJYJU-BME16k02.js +16 -0
- package/dist/store/aiStore.d.ts +199 -0
- package/dist/store/ideStoresContext.d.ts +39 -0
- package/dist/store/libraryStore.d.ts +25 -0
- package/dist/timeline-definition-PNZ67QCA-CmmzdVk-.js +1055 -0
- package/dist/types/aiEvents.d.ts +38 -0
- package/dist/types/conductor.d.ts +23 -2
- package/dist/types/workflow.d.ts +36 -0
- package/dist/types/workflowLibrary.d.ts +27 -0
- package/dist/utils/executionAnalyzer.d.ts +32 -0
- package/dist/utils/nodeMeta.d.ts +6 -0
- package/dist/utils/proposalPreview.d.ts +19 -0
- package/dist/utils/taskTypeMeta.d.ts +18 -0
- package/dist/utils/workflowToMermaid.d.ts +7 -0
- package/dist/vennDiagram-CIIHVFJN-BQt00w9Q.js +1557 -0
- package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
- package/dist/wardleyDiagram-YWT4CUSO-LZpiODGN.js +675 -0
- package/dist/xychartDiagram-2RQKCTM6-BpJlv_mc.js +1342 -0
- package/package.json +14 -4
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AI Interaction Service (OpenAI Standard)
|
|
3
|
+
*
|
|
4
|
+
* @deprecated 这是 WorkflowIDE 内置 AI Copilot 的遗留实现(仅 OpenAI 协议、文本解析 diff)。
|
|
5
|
+
* 新代码请使用 `AiConfig` + `services/ai/protocolAdapter`(双协议、原生 tool-call、
|
|
6
|
+
* 传输层反转)。两套实现将在后续版本收敛为一套,详见 `docs/design/` 下的架构规划。
|
|
3
7
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
model: string;
|
|
8
|
-
}
|
|
8
|
+
import type { AiConfig } from './ai/protocolAdapter';
|
|
9
|
+
/** @deprecated 使用 `AiConfig`(从 `services/ai/protocolAdapter` 或 `/ai` 入口导入)代替。保留为类型别名以避免破坏现有集成代码。 */
|
|
10
|
+
export type AIServiceConfig = AiConfig;
|
|
9
11
|
export interface ChatMessage {
|
|
10
12
|
role: 'system' | 'user' | 'assistant';
|
|
11
13
|
content: string;
|
|
@@ -18,6 +20,26 @@ export declare const callAICopilot: (messages: ChatMessage[], config?: Partial<A
|
|
|
18
20
|
* 流式调用 - 通过 onToken 回调逐 token 返回内容
|
|
19
21
|
*/
|
|
20
22
|
export declare const callAICopilotStream: (messages: ChatMessage[], config: Partial<AIServiceConfig> | undefined, onToken: (token: string) => void, onDone?: () => void, signal?: AbortSignal) => Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* 生成任务 inputParameters 的 AI prompt(P4.1)
|
|
25
|
+
*/
|
|
26
|
+
export declare const generateTaskParametersPrompt: (taskType: string, taskRef: string, workflowInputParams: string[], upstreamTasks: Array<{
|
|
27
|
+
ref: string;
|
|
28
|
+
type: string;
|
|
29
|
+
name: string;
|
|
30
|
+
}>, currentParams: Record<string, any>) => string;
|
|
31
|
+
/**
|
|
32
|
+
* System Prompt for execution analysis / fault diagnosis(P4.3)
|
|
33
|
+
*/
|
|
34
|
+
export declare const EXECUTION_ANALYSIS_SYSTEM_PROMPT = "\nYou are a Netflix Conductor workflow debugging expert.\nWhen given a failed workflow execution, you analyze the task inputs, outputs, and errors to diagnose root causes.\n\nFocus on:\n1. JSONPath expressions that failed to resolve (NullPointerException, PathNotFoundException)\n2. Wrong or missing parameter fields for the task type\n3. Type mismatches between upstream output and task input\n4. Timeout and retry configuration issues\n5. HTTP error codes and what they imply about the request parameters\n\nAlways respond in Chinese. Be concise and actionable.\nIf you suggest a fix, describe specifically which task and which parameter field to change.\n";
|
|
35
|
+
/**
|
|
36
|
+
* AI 自动生成任务 inputParameters(P4.1)
|
|
37
|
+
*/
|
|
38
|
+
export declare const generateTaskParameters: (taskType: string, taskRef: string, workflowInputParams: string[], upstreamTasks: Array<{
|
|
39
|
+
ref: string;
|
|
40
|
+
type: string;
|
|
41
|
+
name: string;
|
|
42
|
+
}>, currentParams: Record<string, any>, config?: Partial<AIServiceConfig>) => Promise<Record<string, any>>;
|
|
21
43
|
/**
|
|
22
44
|
* System Prompt for Conductor Workflow Modeling
|
|
23
45
|
*/
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { s as A, a as W, S as N } from "./chunk-AQP2D5EJ-Os2Uwqya.js";
|
|
2
|
+
import { _ as f, c as t, d as H, l as S, e as P, k as z, R as _, S as U, O as C, u as F } from "./mermaid.core-XSpZEAKP.js";
|
|
3
|
+
import { G as O } from "./graph-BRoPeNF3.js";
|
|
4
|
+
import { l as J } from "./layout-D9EpM4Fg.js";
|
|
5
|
+
var X = /* @__PURE__ */ f((e) => e.append("circle").attr("class", "start-state").attr("r", t().state.sizeUnit).attr("cx", t().state.padding + t().state.sizeUnit).attr("cy", t().state.padding + t().state.sizeUnit), "drawStartState"), D = /* @__PURE__ */ f((e) => e.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", t().state.textHeight).attr("class", "divider").attr("x2", t().state.textHeight * 2).attr("y1", 0).attr("y2", 0), "drawDivider"), Y = /* @__PURE__ */ f((e, i) => {
|
|
6
|
+
const d = e.append("text").attr("x", 2 * t().state.padding).attr("y", t().state.textHeight + 2 * t().state.padding).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.id), c = d.node().getBBox();
|
|
7
|
+
return e.insert("rect", ":first-child").attr("x", t().state.padding).attr("y", t().state.padding).attr("width", c.width + 2 * t().state.padding).attr("height", c.height + 2 * t().state.padding).attr("rx", t().state.radius), d;
|
|
8
|
+
}, "drawSimpleState"), I = /* @__PURE__ */ f((e, i) => {
|
|
9
|
+
const d = /* @__PURE__ */ f(function(o, m, y) {
|
|
10
|
+
const v = o.append("tspan").attr("x", 2 * t().state.padding).text(m);
|
|
11
|
+
y || v.attr("dy", t().state.textHeight);
|
|
12
|
+
}, "addTspan"), n = e.append("text").attr("x", 2 * t().state.padding).attr("y", t().state.textHeight + 1.3 * t().state.padding).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.descriptions[0]).node().getBBox(), l = n.height, p = e.append("text").attr("x", t().state.padding).attr(
|
|
13
|
+
"y",
|
|
14
|
+
l + t().state.padding * 0.4 + t().state.dividerMargin + t().state.textHeight
|
|
15
|
+
).attr("class", "state-description");
|
|
16
|
+
let a = !0, s = !0;
|
|
17
|
+
i.descriptions.forEach(function(o) {
|
|
18
|
+
a || (d(p, o, s), s = !1), a = !1;
|
|
19
|
+
});
|
|
20
|
+
const B = e.append("line").attr("x1", t().state.padding).attr("y1", t().state.padding + l + t().state.dividerMargin / 2).attr("y2", t().state.padding + l + t().state.dividerMargin / 2).attr("class", "descr-divider"), x = p.node().getBBox(), g = Math.max(x.width, n.width);
|
|
21
|
+
return B.attr("x2", g + 3 * t().state.padding), e.insert("rect", ":first-child").attr("x", t().state.padding).attr("y", t().state.padding).attr("width", g + 2 * t().state.padding).attr("height", x.height + l + 2 * t().state.padding).attr("rx", t().state.radius), e;
|
|
22
|
+
}, "drawDescrState"), $ = /* @__PURE__ */ f((e, i, d) => {
|
|
23
|
+
const c = t().state.padding, n = 2 * t().state.padding, l = e.node().getBBox(), p = l.width, a = l.x, s = e.append("text").attr("x", 0).attr("y", t().state.titleShift).attr("font-size", t().state.fontSize).attr("class", "state-title").text(i.id), x = s.node().getBBox().width + n;
|
|
24
|
+
let g = Math.max(x, p);
|
|
25
|
+
g === p && (g = g + n);
|
|
26
|
+
let o;
|
|
27
|
+
const m = e.node().getBBox();
|
|
28
|
+
i.doc, o = a - c, x > p && (o = (p - g) / 2 + c), Math.abs(a - m.x) < c && x > p && (o = a - (x - p) / 2);
|
|
29
|
+
const y = 1 - t().state.textHeight;
|
|
30
|
+
return e.insert("rect", ":first-child").attr("x", o).attr("y", y).attr("class", d ? "alt-composit" : "composit").attr("width", g).attr(
|
|
31
|
+
"height",
|
|
32
|
+
m.height + t().state.textHeight + t().state.titleShift + 1
|
|
33
|
+
).attr("rx", "0"), s.attr("x", o + c), x <= p && s.attr("x", a + (g - n) / 2 - x / 2 + c), e.insert("rect", ":first-child").attr("x", o).attr(
|
|
34
|
+
"y",
|
|
35
|
+
t().state.titleShift - t().state.textHeight - t().state.padding
|
|
36
|
+
).attr("width", g).attr("height", t().state.textHeight * 3).attr("rx", t().state.radius), e.insert("rect", ":first-child").attr("x", o).attr(
|
|
37
|
+
"y",
|
|
38
|
+
t().state.titleShift - t().state.textHeight - t().state.padding
|
|
39
|
+
).attr("width", g).attr("height", m.height + 3 + 2 * t().state.textHeight).attr("rx", t().state.radius), e;
|
|
40
|
+
}, "addTitleAndBox"), q = /* @__PURE__ */ f((e) => (e.append("circle").attr("class", "end-state-outer").attr("r", t().state.sizeUnit + t().state.miniPadding).attr(
|
|
41
|
+
"cx",
|
|
42
|
+
t().state.padding + t().state.sizeUnit + t().state.miniPadding
|
|
43
|
+
).attr(
|
|
44
|
+
"cy",
|
|
45
|
+
t().state.padding + t().state.sizeUnit + t().state.miniPadding
|
|
46
|
+
), e.append("circle").attr("class", "end-state-inner").attr("r", t().state.sizeUnit).attr("cx", t().state.padding + t().state.sizeUnit + 2).attr("cy", t().state.padding + t().state.sizeUnit + 2)), "drawEndState"), Z = /* @__PURE__ */ f((e, i) => {
|
|
47
|
+
let d = t().state.forkWidth, c = t().state.forkHeight;
|
|
48
|
+
if (i.parentId) {
|
|
49
|
+
let n = d;
|
|
50
|
+
d = c, c = n;
|
|
51
|
+
}
|
|
52
|
+
return e.append("rect").style("stroke", "black").style("fill", "black").attr("width", d).attr("height", c).attr("x", t().state.padding).attr("y", t().state.padding);
|
|
53
|
+
}, "drawForkJoinState"), j = /* @__PURE__ */ f((e, i, d, c) => {
|
|
54
|
+
let n = 0;
|
|
55
|
+
const l = c.append("text");
|
|
56
|
+
l.style("text-anchor", "start"), l.attr("class", "noteText");
|
|
57
|
+
let p = e.replace(/\r\n/g, "<br/>");
|
|
58
|
+
p = p.replace(/\n/g, "<br/>");
|
|
59
|
+
const a = p.split(z.lineBreakRegex);
|
|
60
|
+
let s = 1.25 * t().state.noteMargin;
|
|
61
|
+
for (const B of a) {
|
|
62
|
+
const x = B.trim();
|
|
63
|
+
if (x.length > 0) {
|
|
64
|
+
const g = l.append("tspan");
|
|
65
|
+
if (g.text(x), s === 0) {
|
|
66
|
+
const o = g.node().getBBox();
|
|
67
|
+
s += o.height;
|
|
68
|
+
}
|
|
69
|
+
n += s, g.attr("x", i + t().state.noteMargin), g.attr("y", d + n + 1.25 * t().state.noteMargin);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { textWidth: l.node().getBBox().width, textHeight: n };
|
|
73
|
+
}, "_drawLongText"), K = /* @__PURE__ */ f((e, i) => {
|
|
74
|
+
i.attr("class", "state-note");
|
|
75
|
+
const d = i.append("rect").attr("x", 0).attr("y", t().state.padding), c = i.append("g"), { textWidth: n, textHeight: l } = j(e, 0, 0, c);
|
|
76
|
+
return d.attr("height", l + 2 * t().state.noteMargin), d.attr("width", n + t().state.noteMargin * 2), d;
|
|
77
|
+
}, "drawNote"), L = /* @__PURE__ */ f(function(e, i) {
|
|
78
|
+
const d = i.id, c = {
|
|
79
|
+
id: d,
|
|
80
|
+
label: i.id,
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0
|
|
83
|
+
}, n = e.append("g").attr("id", d).attr("class", "stateGroup");
|
|
84
|
+
i.type === "start" && X(n), i.type === "end" && q(n), (i.type === "fork" || i.type === "join") && Z(n, i), i.type === "note" && K(i.note.text, n), i.type === "divider" && D(n), i.type === "default" && i.descriptions.length === 0 && Y(n, i), i.type === "default" && i.descriptions.length > 0 && I(n, i);
|
|
85
|
+
const l = n.node().getBBox();
|
|
86
|
+
return c.width = l.width + 2 * t().state.padding, c.height = l.height + 2 * t().state.padding, c;
|
|
87
|
+
}, "drawState"), G = 0, Q = /* @__PURE__ */ f(function(e, i, d) {
|
|
88
|
+
const c = /* @__PURE__ */ f(function(s) {
|
|
89
|
+
switch (s) {
|
|
90
|
+
case N.relationType.AGGREGATION:
|
|
91
|
+
return "aggregation";
|
|
92
|
+
case N.relationType.EXTENSION:
|
|
93
|
+
return "extension";
|
|
94
|
+
case N.relationType.COMPOSITION:
|
|
95
|
+
return "composition";
|
|
96
|
+
case N.relationType.DEPENDENCY:
|
|
97
|
+
return "dependency";
|
|
98
|
+
}
|
|
99
|
+
}, "getRelationType");
|
|
100
|
+
i.points = i.points.filter((s) => !Number.isNaN(s.y));
|
|
101
|
+
const n = i.points, l = _().x(function(s) {
|
|
102
|
+
return s.x;
|
|
103
|
+
}).y(function(s) {
|
|
104
|
+
return s.y;
|
|
105
|
+
}).curve(U), p = e.append("path").attr("d", l(n)).attr("id", "edge" + G).attr("class", "transition");
|
|
106
|
+
let a = "";
|
|
107
|
+
if (t().state.arrowMarkerAbsolute && (a = C(!0)), p.attr(
|
|
108
|
+
"marker-end",
|
|
109
|
+
"url(" + a + "#" + c(N.relationType.DEPENDENCY) + "End)"
|
|
110
|
+
), d.title !== void 0) {
|
|
111
|
+
const s = e.append("g").attr("class", "stateLabel"), { x: B, y: x } = F.calcLabelPosition(i.points), g = z.getRows(d.title);
|
|
112
|
+
let o = 0;
|
|
113
|
+
const m = [];
|
|
114
|
+
let y = 0, v = 0;
|
|
115
|
+
for (let u = 0; u <= g.length; u++) {
|
|
116
|
+
const h = s.append("text").attr("text-anchor", "middle").text(g[u]).attr("x", B).attr("y", x + o), w = h.node().getBBox();
|
|
117
|
+
y = Math.max(y, w.width), v = Math.min(v, w.x), S.info(w.x, B, x + o), o === 0 && (o = h.node().getBBox().height, S.info("Title height", o, x)), m.push(h);
|
|
118
|
+
}
|
|
119
|
+
let k = o * g.length;
|
|
120
|
+
if (g.length > 1) {
|
|
121
|
+
const u = (g.length - 1) * o * 0.5;
|
|
122
|
+
m.forEach((h, w) => h.attr("y", x + w * o - u)), k = o * g.length;
|
|
123
|
+
}
|
|
124
|
+
const r = s.node().getBBox();
|
|
125
|
+
s.insert("rect", ":first-child").attr("class", "box").attr("x", B - y / 2 - t().state.padding / 2).attr("y", x - k / 2 - t().state.padding / 2 - 3.5).attr("width", y + t().state.padding).attr("height", k + t().state.padding), S.info(r);
|
|
126
|
+
}
|
|
127
|
+
G++;
|
|
128
|
+
}, "drawEdge"), b, T = {}, V = /* @__PURE__ */ f(function() {
|
|
129
|
+
}, "setConf"), tt = /* @__PURE__ */ f(function(e) {
|
|
130
|
+
e.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z");
|
|
131
|
+
}, "insertMarkers"), et = /* @__PURE__ */ f(function(e, i, d, c) {
|
|
132
|
+
b = t().state;
|
|
133
|
+
const n = t().securityLevel;
|
|
134
|
+
let l;
|
|
135
|
+
n === "sandbox" && (l = H("#i" + i));
|
|
136
|
+
const p = n === "sandbox" ? H(l.nodes()[0].contentDocument.body) : H("body"), a = n === "sandbox" ? l.nodes()[0].contentDocument : document;
|
|
137
|
+
S.debug("Rendering diagram " + e);
|
|
138
|
+
const s = p.select(`[id='${i}']`);
|
|
139
|
+
tt(s);
|
|
140
|
+
const B = c.db.getRootDoc(), x = s.append("g").attr("id", i + "-root");
|
|
141
|
+
R(B, x, void 0, !1, p, a, c);
|
|
142
|
+
const g = b.padding, o = s.node().getBBox(), m = o.width + g * 2, y = o.height + g * 2, v = m * 1.75;
|
|
143
|
+
P(s, y, v, b.useMaxWidth), s.attr(
|
|
144
|
+
"viewBox",
|
|
145
|
+
`${o.x - b.padding} ${o.y - b.padding} ` + m + " " + y
|
|
146
|
+
);
|
|
147
|
+
}, "draw"), at = /* @__PURE__ */ f((e) => e ? e.length * b.fontSizeFactor : 1, "getLabelWidth"), R = /* @__PURE__ */ f((e, i, d, c, n, l, p) => {
|
|
148
|
+
const a = new O({
|
|
149
|
+
compound: !0,
|
|
150
|
+
multigraph: !0
|
|
151
|
+
});
|
|
152
|
+
let s, B = !0;
|
|
153
|
+
for (s = 0; s < e.length; s++)
|
|
154
|
+
if (e[s].stmt === "relation") {
|
|
155
|
+
B = !1;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
d ? a.setGraph({
|
|
159
|
+
rankdir: "LR",
|
|
160
|
+
multigraph: !0,
|
|
161
|
+
compound: !0,
|
|
162
|
+
// acyclicer: 'greedy',
|
|
163
|
+
ranker: "tight-tree",
|
|
164
|
+
ranksep: B ? 1 : b.edgeLengthFactor,
|
|
165
|
+
nodeSep: B ? 1 : 50,
|
|
166
|
+
isMultiGraph: !0
|
|
167
|
+
// ranksep: 5,
|
|
168
|
+
// nodesep: 1
|
|
169
|
+
}) : a.setGraph({
|
|
170
|
+
rankdir: "TB",
|
|
171
|
+
multigraph: !0,
|
|
172
|
+
compound: !0,
|
|
173
|
+
// isCompound: true,
|
|
174
|
+
// acyclicer: 'greedy',
|
|
175
|
+
// ranker: 'longest-path'
|
|
176
|
+
ranksep: B ? 1 : b.edgeLengthFactor,
|
|
177
|
+
nodeSep: B ? 1 : 50,
|
|
178
|
+
ranker: "tight-tree",
|
|
179
|
+
// ranker: 'network-simplex'
|
|
180
|
+
isMultiGraph: !0
|
|
181
|
+
}), a.setDefaultEdgeLabel(function() {
|
|
182
|
+
return {};
|
|
183
|
+
});
|
|
184
|
+
const x = p.db.getStates(), g = p.db.getRelations(), o = Object.keys(x);
|
|
185
|
+
for (const r of o) {
|
|
186
|
+
const u = x[r];
|
|
187
|
+
d && (u.parentId = d);
|
|
188
|
+
let h;
|
|
189
|
+
if (u.doc) {
|
|
190
|
+
let w = i.append("g").attr("id", u.id).attr("class", "stateGroup");
|
|
191
|
+
h = R(u.doc, w, u.id, !c, n, l, p);
|
|
192
|
+
{
|
|
193
|
+
w = $(w, u, c);
|
|
194
|
+
let E = w.node().getBBox();
|
|
195
|
+
h.width = E.width, h.height = E.height + b.padding / 2, T[u.id] = { y: b.compositTitleSize };
|
|
196
|
+
}
|
|
197
|
+
} else
|
|
198
|
+
h = L(i, u, a);
|
|
199
|
+
if (u.note) {
|
|
200
|
+
const w = {
|
|
201
|
+
descriptions: [],
|
|
202
|
+
id: u.id + "-note",
|
|
203
|
+
note: u.note,
|
|
204
|
+
type: "note"
|
|
205
|
+
}, E = L(i, w, a);
|
|
206
|
+
u.note.position === "left of" ? (a.setNode(h.id + "-note", E), a.setNode(h.id, h)) : (a.setNode(h.id, h), a.setNode(h.id + "-note", E)), a.setParent(h.id, h.id + "-group"), a.setParent(h.id + "-note", h.id + "-group");
|
|
207
|
+
} else
|
|
208
|
+
a.setNode(h.id, h);
|
|
209
|
+
}
|
|
210
|
+
S.debug("Count=", a.nodeCount(), a);
|
|
211
|
+
let m = 0;
|
|
212
|
+
g.forEach(function(r) {
|
|
213
|
+
m++, S.debug("Setting edge", r), a.setEdge(
|
|
214
|
+
r.id1,
|
|
215
|
+
r.id2,
|
|
216
|
+
{
|
|
217
|
+
relation: r,
|
|
218
|
+
width: at(r.title),
|
|
219
|
+
height: b.labelHeight * z.getRows(r.title).length,
|
|
220
|
+
labelpos: "c"
|
|
221
|
+
},
|
|
222
|
+
"id" + m
|
|
223
|
+
);
|
|
224
|
+
}), J(a), S.debug("Graph after layout", a.nodes());
|
|
225
|
+
const y = i.node();
|
|
226
|
+
a.nodes().forEach(function(r) {
|
|
227
|
+
r !== void 0 && a.node(r) !== void 0 ? (S.warn("Node " + r + ": " + JSON.stringify(a.node(r))), n.select("#" + y.id + " #" + r).attr(
|
|
228
|
+
"transform",
|
|
229
|
+
"translate(" + (a.node(r).x - a.node(r).width / 2) + "," + (a.node(r).y + (T[r] ? T[r].y : 0) - a.node(r).height / 2) + " )"
|
|
230
|
+
), n.select("#" + y.id + " #" + r).attr("data-x-shift", a.node(r).x - a.node(r).width / 2), l.querySelectorAll("#" + y.id + " #" + r + " .divider").forEach((h) => {
|
|
231
|
+
const w = h.parentElement;
|
|
232
|
+
let E = 0, M = 0;
|
|
233
|
+
w && (w.parentElement && (E = w.parentElement.getBBox().width), M = parseInt(w.getAttribute("data-x-shift"), 10), Number.isNaN(M) && (M = 0)), h.setAttribute("x1", 0 - M + 8), h.setAttribute("x2", E - M - 8);
|
|
234
|
+
})) : S.debug("No Node " + r + ": " + JSON.stringify(a.node(r)));
|
|
235
|
+
});
|
|
236
|
+
let v = y.getBBox();
|
|
237
|
+
a.edges().forEach(function(r) {
|
|
238
|
+
r !== void 0 && a.edge(r) !== void 0 && (S.debug("Edge " + r.v + " -> " + r.w + ": " + JSON.stringify(a.edge(r))), Q(i, a.edge(r), a.edge(r).relation));
|
|
239
|
+
}), v = y.getBBox();
|
|
240
|
+
const k = {
|
|
241
|
+
id: d || "root",
|
|
242
|
+
label: d || "root",
|
|
243
|
+
width: 0,
|
|
244
|
+
height: 0
|
|
245
|
+
};
|
|
246
|
+
return k.width = v.width + 2 * b.padding, k.height = v.height + 2 * b.padding, S.debug("Doc rendered", k, a), k;
|
|
247
|
+
}, "renderDoc"), it = {
|
|
248
|
+
setConf: V,
|
|
249
|
+
draw: et
|
|
250
|
+
}, ot = {
|
|
251
|
+
parser: W,
|
|
252
|
+
get db() {
|
|
253
|
+
return new N(1);
|
|
254
|
+
},
|
|
255
|
+
renderer: it,
|
|
256
|
+
styles: A,
|
|
257
|
+
init: /* @__PURE__ */ f((e) => {
|
|
258
|
+
e.state || (e.state = {}), e.state.arrowMarkerAbsolute = e.arrowMarkerAbsolute;
|
|
259
|
+
}, "init")
|
|
260
|
+
};
|
|
261
|
+
export {
|
|
262
|
+
ot as diagram
|
|
263
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { s as a, b as t, a as r, S as s } from "./chunk-AQP2D5EJ-Os2Uwqya.js";
|
|
2
|
+
import { _ as i } from "./mermaid.core-XSpZEAKP.js";
|
|
3
|
+
var _ = {
|
|
4
|
+
parser: r,
|
|
5
|
+
get db() {
|
|
6
|
+
return new s(2);
|
|
7
|
+
},
|
|
8
|
+
renderer: t,
|
|
9
|
+
styles: a,
|
|
10
|
+
init: /* @__PURE__ */ i((e) => {
|
|
11
|
+
e.state || (e.state = {}), e.state.arrowMarkerAbsolute = e.arrowMarkerAbsolute;
|
|
12
|
+
}, "init")
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
_ as diagram
|
|
16
|
+
};
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Store — state management for AI workflow assistant
|
|
3
|
+
*
|
|
4
|
+
* Manages: conversation history, proposed workflow (for review),
|
|
5
|
+
* AI configuration, and usage metrics.
|
|
6
|
+
*
|
|
7
|
+
* Exposed as both a factory (`createAiStore`, for per-`<AiWorkflowIDE>`-instance
|
|
8
|
+
* isolation via IdeStoresContext — see store/ideStoresContext.tsx) and a default
|
|
9
|
+
* singleton (for callers outside that context, e.g. WorkflowIDE's shared canvas).
|
|
10
|
+
*/
|
|
11
|
+
import type { AiConfig } from '../services/ai/protocolAdapter';
|
|
12
|
+
import type { WorkflowDef } from '../types/conductor';
|
|
13
|
+
import type { DiffSummary } from '../services/ai/toolExecutor';
|
|
14
|
+
import type { WorkflowLevel } from '../types/workflowLibrary';
|
|
15
|
+
export interface AiChatMessage {
|
|
16
|
+
id: string;
|
|
17
|
+
role: 'user' | 'assistant';
|
|
18
|
+
content: string;
|
|
19
|
+
/** If this message triggered a proposal, link it here */
|
|
20
|
+
proposalId?: string;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ProposedChange {
|
|
24
|
+
id: string;
|
|
25
|
+
proposedDef: WorkflowDef;
|
|
26
|
+
diff: DiffSummary;
|
|
27
|
+
/** Inferred workflow level based on sub-workflow references */
|
|
28
|
+
inferredLevel?: WorkflowLevel;
|
|
29
|
+
/** Message that triggered this proposal */
|
|
30
|
+
messageId: string;
|
|
31
|
+
/**
|
|
32
|
+
* JSON snapshot of the canvas workflowDef at the moment the proposal was created.
|
|
33
|
+
* Used to detect stale proposals when the user has edited the canvas during review.
|
|
34
|
+
*/
|
|
35
|
+
baselineHash: string;
|
|
36
|
+
}
|
|
37
|
+
export interface RepairAction {
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
type: 'rerun_from' | 'skip' | 'retry_workflow' | 'modify_def';
|
|
41
|
+
taskRef?: string;
|
|
42
|
+
risk?: 'low' | 'medium' | 'high';
|
|
43
|
+
description?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface RepairProposal {
|
|
46
|
+
id: string;
|
|
47
|
+
diagnosis: string;
|
|
48
|
+
actions: RepairAction[];
|
|
49
|
+
messageId: string;
|
|
50
|
+
}
|
|
51
|
+
export interface PlanStep {
|
|
52
|
+
step: number;
|
|
53
|
+
action: string;
|
|
54
|
+
tool?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface PendingPlan {
|
|
57
|
+
id: string;
|
|
58
|
+
title: string;
|
|
59
|
+
steps: PlanStep[];
|
|
60
|
+
summary?: string;
|
|
61
|
+
messageId: string;
|
|
62
|
+
}
|
|
63
|
+
export interface AiMetrics {
|
|
64
|
+
totalProposals: number;
|
|
65
|
+
acceptedProposals: number;
|
|
66
|
+
rejectedProposals: number;
|
|
67
|
+
/** Cumulative token usage for this session (M4.4). Only incremented when the
|
|
68
|
+
* provider reports usage — best-effort, not every provider/proxy includes it. */
|
|
69
|
+
totalPromptTokens: number;
|
|
70
|
+
totalCompletionTokens: number;
|
|
71
|
+
}
|
|
72
|
+
export interface ClarificationOption {
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
description: string;
|
|
76
|
+
icon?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface PendingClarification {
|
|
79
|
+
id: string;
|
|
80
|
+
question: string;
|
|
81
|
+
context?: string;
|
|
82
|
+
options: ClarificationOption[];
|
|
83
|
+
messageId: string;
|
|
84
|
+
}
|
|
85
|
+
export interface WorkflowRecommendation {
|
|
86
|
+
workflowName: string;
|
|
87
|
+
matchReason: string;
|
|
88
|
+
matchScore: 'exact' | 'partial' | 'similar';
|
|
89
|
+
}
|
|
90
|
+
export interface PendingRecommendation {
|
|
91
|
+
id: string;
|
|
92
|
+
userIntent: string;
|
|
93
|
+
recommendations: WorkflowRecommendation[];
|
|
94
|
+
messageId: string;
|
|
95
|
+
}
|
|
96
|
+
interface AiState {
|
|
97
|
+
config: AiConfig;
|
|
98
|
+
messages: AiChatMessage[];
|
|
99
|
+
isStreaming: boolean;
|
|
100
|
+
streamingText: string;
|
|
101
|
+
chatPanelOpen: boolean;
|
|
102
|
+
/** The current pending proposal (only one at a time) */
|
|
103
|
+
pendingProposal: ProposedChange | null;
|
|
104
|
+
/** AI-generated multi-step plan awaiting user approval */
|
|
105
|
+
pendingPlan: PendingPlan | null;
|
|
106
|
+
/** AI-generated repair proposal for run-mode failures */
|
|
107
|
+
pendingRepair: RepairProposal | null;
|
|
108
|
+
metrics: AiMetrics;
|
|
109
|
+
/** Context-aware chips shown after the user accepts a proposal */
|
|
110
|
+
followUpChips: string[] | null;
|
|
111
|
+
/** Undo stack: previous WorkflowDef snapshots (max 5, oldest first) */
|
|
112
|
+
undoStack: WorkflowDef[];
|
|
113
|
+
/** Pending clarification question awaiting user selection */
|
|
114
|
+
pendingClarification: PendingClarification | null;
|
|
115
|
+
/** Pending workflow recommendation awaiting user selection */
|
|
116
|
+
pendingRecommendation: PendingRecommendation | null;
|
|
117
|
+
/**
|
|
118
|
+
* Message queued for the AI pipeline from outside AiCommandCenter
|
|
119
|
+
* (e.g. proposal acceptance, canvas node click). AiCommandCenter
|
|
120
|
+
* picks this up via useEffect and calls runner.send(), then clears it.
|
|
121
|
+
*/
|
|
122
|
+
pendingAutoSend: string | null;
|
|
123
|
+
/** Current in-flight step label (e.g. "正在搜索工作流库…"), set by AgentRunner */
|
|
124
|
+
toolStatus: string;
|
|
125
|
+
/** Last message that failed to send, offered back via a retry button */
|
|
126
|
+
retryInput: string | null;
|
|
127
|
+
/**
|
|
128
|
+
* Append-only log of completed steps for the current agent turn (M2.2 AgentTimeline).
|
|
129
|
+
* Cleared at the start of each `send()`. Self-heal retries log their own entry so
|
|
130
|
+
* the correction is visible rather than silent.
|
|
131
|
+
*/
|
|
132
|
+
timelineEntries: TimelineEntry[];
|
|
133
|
+
}
|
|
134
|
+
export interface TimelineEntry {
|
|
135
|
+
id: string;
|
|
136
|
+
label: string;
|
|
137
|
+
icon: 'done' | 'warning';
|
|
138
|
+
}
|
|
139
|
+
interface AiActions {
|
|
140
|
+
setConfig: (config: Partial<AiConfig>) => void;
|
|
141
|
+
addMessage: (msg: Omit<AiChatMessage, 'id' | 'timestamp'>) => string;
|
|
142
|
+
updateMessage: (id: string, content: string) => void;
|
|
143
|
+
setStreaming: (isStreaming: boolean) => void;
|
|
144
|
+
setStreamingText: (text: string) => void;
|
|
145
|
+
appendStreamingText: (delta: string) => void;
|
|
146
|
+
clearMessages: () => void;
|
|
147
|
+
setChatPanelOpen: (open: boolean) => void;
|
|
148
|
+
toggleChatPanel: () => void;
|
|
149
|
+
setProposal: (proposal: Omit<ProposedChange, 'id' | 'baselineHash'>) => string;
|
|
150
|
+
clearProposal: () => void;
|
|
151
|
+
recordAccept: () => void;
|
|
152
|
+
recordReject: () => void;
|
|
153
|
+
getMetrics: () => AiMetrics;
|
|
154
|
+
/** Accumulates token usage reported by the provider for one model turn (M4.4) */
|
|
155
|
+
recordUsage: (usage: {
|
|
156
|
+
promptTokens?: number;
|
|
157
|
+
completionTokens?: number;
|
|
158
|
+
}) => void;
|
|
159
|
+
setFollowUpChips: (chips: string[]) => void;
|
|
160
|
+
clearFollowUpChips: () => void;
|
|
161
|
+
setPlan: (plan: Omit<PendingPlan, 'id'>) => string;
|
|
162
|
+
clearPlan: () => void;
|
|
163
|
+
setRepair: (repair: Omit<RepairProposal, 'id'>) => string;
|
|
164
|
+
clearRepair: () => void;
|
|
165
|
+
/** Push the given def onto the undo stack (called before applying a proposal) */
|
|
166
|
+
pushUndo: (def: WorkflowDef) => void;
|
|
167
|
+
/** Pop and return the most recent undo snapshot, or null if stack is empty */
|
|
168
|
+
popUndo: () => WorkflowDef | null;
|
|
169
|
+
clearUndo: () => void;
|
|
170
|
+
canUndo: () => boolean;
|
|
171
|
+
setClarification: (c: Omit<PendingClarification, 'id'>) => string;
|
|
172
|
+
clearClarification: () => void;
|
|
173
|
+
setRecommendation: (r: Omit<PendingRecommendation, 'id'>) => string;
|
|
174
|
+
clearRecommendation: () => void;
|
|
175
|
+
/** Queue a message to be sent through the AI pipeline by AiCommandCenter */
|
|
176
|
+
setPendingAutoSend: (msg: string | null) => void;
|
|
177
|
+
/** Restore conversation + pending proposal from a persisted draft (M1.4) */
|
|
178
|
+
hydrateFromDraft: (messages: AiChatMessage[], pendingProposal: ProposedChange | null) => void;
|
|
179
|
+
setToolStatus: (status: string) => void;
|
|
180
|
+
setRetryInput: (input: string | null) => void;
|
|
181
|
+
addTimelineEntry: (label: string, icon?: 'done' | 'warning') => void;
|
|
182
|
+
clearTimeline: () => void;
|
|
183
|
+
}
|
|
184
|
+
export type AiStore = AiState & AiActions;
|
|
185
|
+
/**
|
|
186
|
+
* Creates an independent AiStore instance.
|
|
187
|
+
*
|
|
188
|
+
* @param persistKey localStorage key for provider/baseUrl/model + metrics (never
|
|
189
|
+
* the apiKey or conversation itself). Pass `false` to keep this
|
|
190
|
+
* instance fully in-memory — no localStorage writes at all.
|
|
191
|
+
* Defaults to a stable shared key so existing single-instance
|
|
192
|
+
* integrations keep their persisted config across reloads;
|
|
193
|
+
* pass a unique key per instance when embedding multiple
|
|
194
|
+
* `<AiWorkflowIDE>` on the same page to avoid them clobbering
|
|
195
|
+
* each other's persisted config.
|
|
196
|
+
*/
|
|
197
|
+
export declare function createAiStore(persistKey?: string | false): import("zustand").UseBoundStore<import("zustand").StoreApi<AiStore>>;
|
|
198
|
+
declare const useAiStore: import("zustand").UseBoundStore<import("zustand").StoreApi<AiStore>>;
|
|
199
|
+
export default useAiStore;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IdeStoresContext — per-`<AiWorkflowIDE>`-instance state isolation (M3.2)
|
|
3
|
+
*
|
|
4
|
+
* Before this, aiStore/libraryStore/toolRegistry were module-level singletons:
|
|
5
|
+
* two `<AiWorkflowIDE>` mounted on the same page shared one conversation, one
|
|
6
|
+
* pending proposal, one workflow library, one set of custom tools — the second
|
|
7
|
+
* instance would silently stomp the first. AiWorkflowIDE now creates a fresh
|
|
8
|
+
* set of these per mount (via createAiStore/createLibraryStore/new ToolRegistry)
|
|
9
|
+
* and provides them through this context; every AiNative component and the
|
|
10
|
+
* AgentRunner it constructs read from `useIdeStores()` instead of importing the
|
|
11
|
+
* default singletons directly.
|
|
12
|
+
*
|
|
13
|
+
* `workflowStore` (the canvas/task-graph state) is NOT part of this context yet —
|
|
14
|
+
* it remains a shared singleton because it's also consumed by WorkflowIDE's much
|
|
15
|
+
* larger component tree (nodes, panels) that this pass didn't migrate. That's a
|
|
16
|
+
* documented follow-up, not an oversight: see docs/design/双IDE组件架构审查.md §2.
|
|
17
|
+
*/
|
|
18
|
+
import type { ReactNode } from 'react';
|
|
19
|
+
import type { UseBoundStore, StoreApi } from 'zustand';
|
|
20
|
+
import type { AiStore } from './aiStore';
|
|
21
|
+
import type { LibraryStore } from './libraryStore';
|
|
22
|
+
import type { ToolRegistry } from '../services/ai/toolRegistry';
|
|
23
|
+
export interface IdeStores {
|
|
24
|
+
aiStore: UseBoundStore<StoreApi<AiStore>>;
|
|
25
|
+
libraryStore: UseBoundStore<StoreApi<LibraryStore>>;
|
|
26
|
+
toolRegistry: ToolRegistry;
|
|
27
|
+
}
|
|
28
|
+
export declare function IdeStoresProvider({ stores, children }: {
|
|
29
|
+
stores: IdeStores;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
/** Reads the per-instance stores. Throws if used outside `<AiWorkflowIDE>` — every AiNative component is always rendered under it. */
|
|
33
|
+
export declare function useIdeStores(): IdeStores;
|
|
34
|
+
/**
|
|
35
|
+
* Non-throwing variant for components shared with WorkflowIDE (e.g. WorkflowDesigner),
|
|
36
|
+
* which renders both under `<AiWorkflowIDE>` (provider present) and standalone under
|
|
37
|
+
* `<WorkflowIDE>` (no provider — falls back to the module singleton there instead).
|
|
38
|
+
*/
|
|
39
|
+
export declare function useIdeStoresOptional(): IdeStores | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Library Store — sub-workflow catalog state
|
|
3
|
+
*
|
|
4
|
+
* Kept separate from aiStore to avoid circular dependencies (aiStore imports
|
|
5
|
+
* types from toolExecutor, which used to read this store directly; since M2.1
|
|
6
|
+
* toolExecutor is pure and AgentRunner passes library items in explicitly, but
|
|
7
|
+
* the separate store is still worth keeping for its narrow, focused shape).
|
|
8
|
+
*
|
|
9
|
+
* Populated by AiWorkflowIDE when the workflowLibrary prop changes.
|
|
10
|
+
* Read by AgentRunner (search_workflow_library / system prompt catalog) via
|
|
11
|
+
* whichever instance the owning `<AiWorkflowIDE>` created — see createLibraryStore.
|
|
12
|
+
*/
|
|
13
|
+
import type { WorkflowLibraryItem } from '../types/workflowLibrary';
|
|
14
|
+
interface LibraryState {
|
|
15
|
+
items: WorkflowLibraryItem[];
|
|
16
|
+
}
|
|
17
|
+
interface LibraryActions {
|
|
18
|
+
setLibrary: (items: WorkflowLibraryItem[]) => void;
|
|
19
|
+
clearLibrary: () => void;
|
|
20
|
+
}
|
|
21
|
+
export type LibraryStore = LibraryState & LibraryActions;
|
|
22
|
+
/** Creates an independent LibraryStore instance (no persistence — populated fresh from props each mount). */
|
|
23
|
+
export declare function createLibraryStore(): import("zustand").UseBoundStore<import("zustand").StoreApi<LibraryStore>>;
|
|
24
|
+
declare const useLibraryStore: import("zustand").UseBoundStore<import("zustand").StoreApi<LibraryStore>>;
|
|
25
|
+
export default useLibraryStore;
|