@openbkn/workshop 0.2.3 → 0.3.0-rc.1
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 +1 -1
- package/dist/{ActionConfirm-ITBip2Ic.js → ActionConfirm-BX1dlrAM.js} +5 -5
- package/dist/{ActionFailure-CWifUJ2j.js → ActionFailure-xcSfKJYC.js} +2 -2
- package/dist/{AgentChat-C1uyzwuA.js → AgentChat-DHdX_6W7.js} +407 -383
- package/dist/AppListPage-DsUvFo6B.js +1549 -0
- package/dist/{AskDrawer-Bw1NM5v_.js → AskDrawer-j-CR4yXP.js} +4 -4
- package/dist/{ComputedView-_CaPjqhY.js → ComputedView-dWFlHngu.js} +1035 -1016
- package/dist/{ConclusionApply-CG5wSeVp.js → ConclusionApply-BAoZpxl-.js} +4 -4
- package/dist/{CypherEditor-DbLHQoJJ.js → CypherEditor-CZ5Z4SGH.js} +47 -47
- package/dist/{LandingList-BMPCXj6K.js → LandingList-BUO6-at_.js} +5 -5
- package/dist/{MenuUnfoldOutlined-BoARCVho.js → MenuUnfoldOutlined-DAeIeIap.js} +3 -3
- package/dist/{ModelTrial-DZjC0E8E.js → ModelTrial-C7XvLVY7.js} +4 -4
- package/dist/{PageRenderer-Debi-U0v.js → PageRenderer-CkmvW4aO.js} +21264 -20549
- package/dist/{ScenarioApply-BNFfjIwR.js → ScenarioApply-COdlyvrC.js} +6 -6
- package/dist/{SimulateForm-CEqqMjks.js → SimulateForm-B_9laTIl.js} +4 -4
- package/dist/{Subgraph-C0VjOnZf.js → Subgraph-CDY3wvCA.js} +3 -3
- package/dist/WorkshopLabPage-BtYnBpk4.js +12020 -0
- package/dist/{WorkshopRunPage-BlyM18id.js → WorkshopRunPage-DHMJ3b8k.js} +24 -24
- package/dist/{abnfDiagram-WEYOIA3C-wqYhe75a.js → abnfDiagram-WEYOIA3C-Blje2Kbf.js} +3 -3
- package/dist/{action-type-tool.service-CtCfESYq.js → action-type-tool.service-BN-W_Az_.js} +1 -1
- package/dist/{architectureDiagram-ZHVYKT53-BYJ2H7bS.js → architectureDiagram-ZHVYKT53-B_FkRXc3.js} +3 -3
- package/dist/{bkn-agent-execution.service-ogW6NIAz.js → bkn-agent-execution.service-CJalMVIc.js} +1 -1
- package/dist/{blockDiagram-RJAE7QA3-DZfrfHRw.js → blockDiagram-RJAE7QA3-CYJLthoI.js} +3 -3
- package/dist/{c4Diagram-XDPPPE54--S7sRxgd.js → c4Diagram-XDPPPE54-CmMaN3M4.js} +2 -2
- package/dist/{channel-Ca2_7Xkz.js → channel-Dp24Bgua.js} +1 -1
- package/dist/{chunk-2E7WHVMD-BMnl6-jy.js → chunk-2E7WHVMD-DrnpfYKB.js} +1 -1
- package/dist/{chunk-2Q5K7J3B-BNVTYluA.js → chunk-2Q5K7J3B-BXqKcHlQ.js} +1 -1
- package/dist/{chunk-4EMNKR2T-CKorQf5z.js → chunk-4EMNKR2T-DYgY_0_y.js} +1 -1
- package/dist/{chunk-55XCU76K-C4xutPQ4.js → chunk-55XCU76K-Bja7bE8g.js} +1 -1
- package/dist/{chunk-5VM5RSS4-BM5F2WnL.js → chunk-5VM5RSS4-CGTnbRRi.js} +1 -1
- package/dist/{chunk-JWPE2WC7-CSU5SIs8.js → chunk-JWPE2WC7-2AyjxdJR.js} +1 -1
- package/dist/{chunk-VQ5W62QI-Dtk59D_l.js → chunk-VQ5W62QI-B3PGCKOg.js} +1 -1
- package/dist/{chunk-XXDRQBXY-DzVLFl9c.js → chunk-XXDRQBXY-RrIsI-B5.js} +1 -1
- package/dist/{chunk-ZCHMQSOR-cdQdJeDJ.js → chunk-ZCHMQSOR-COJTBW1i.js} +2 -2
- package/dist/{classDiagram-v2-4MYWR3UA-CABAzYlW.js → classDiagram-v2-4MYWR3UA-DolLxH6t.js} +5 -5
- package/dist/{cose-bilkent-JH36ORCC-Ca8GJbqv.js → cose-bilkent-JH36ORCC-DMSYgFxc.js} +2 -2
- package/dist/customComponents-DasaZ6pq.js +1 -1
- package/dist/customComponents.en-US-CkabuCXg.js +1 -1
- package/dist/{customParseFormat-H00Ur3YB.js → customParseFormat-C9WAjjqH.js} +1 -1
- package/dist/{cynefinDiagram-WF24UDRP-iIy_O6OH.js → cynefinDiagram-WF24UDRP-DrksRWCn.js} +2 -2
- package/dist/{dagre-NK4GIZVX-lW5Hra0G.js → dagre-NK4GIZVX-CFRT2dAc.js} +2 -2
- package/dist/{dayjs.min-C8_4Wqpb.js → dayjs.min-CziT8yW9.js} +1 -1
- package/dist/{diagram-CBK3MWTC-l5LVSm6X.js → diagram-CBK3MWTC-DzZ_sQCl.js} +3 -3
- package/dist/{diagram-I5XIIV2D-ChpwB8Wz.js → diagram-I5XIIV2D-RYNBUOF4.js} +2 -2
- package/dist/{diagram-ODIL2UCW-DBavGl7R.js → diagram-ODIL2UCW-DqJETE9R.js} +3 -3
- package/dist/{diagram-PFBEJUXE-B3fNIQm9.js → diagram-PFBEJUXE-BekIE7hh.js} +2 -2
- package/dist/{diagram-RJA3I4VV-Dmj0Shdh.js → diagram-RJA3I4VV-DAIwlMxl.js} +2 -2
- package/dist/{diagram-TYUNFSNR-D98rsKpY.js → diagram-TYUNFSNR-CLJ0Ou9i.js} +6 -6
- package/dist/{ebnfDiagram-V4P3TTPT-Bxr2oP9U.js → ebnfDiagram-V4P3TTPT-CRs8ppfT.js} +3 -3
- package/dist/{elk-QONTBCTQ-CvFT6Pst.js → elk-QONTBCTQ-Bqoh6AYY.js} +5 -5
- package/dist/{erDiagram-KYQIGQAA-dgeEoLzk.js → erDiagram-KYQIGQAA-BSp8Z7uQ.js} +4 -4
- package/dist/{flowDiagram-IUGLLWBU-ChsJgBPn.js → flowDiagram-IUGLLWBU-WKILTCDc.js} +7 -7
- package/dist/{ganttDiagram-R7GPNTJY-C9WcR8Tf.js → ganttDiagram-R7GPNTJY-CaTn_Mmr.js} +4 -4
- package/dist/generateCypher-BE_4YCWB.js +1032 -0
- package/dist/{gitGraphDiagram-PDYL7XHY-CeZTDs7V.js → gitGraphDiagram-PDYL7XHY-DGPs-RF6.js} +3 -3
- package/dist/{infoDiagram-MVDRKAX5-CzfcVWVf.js → infoDiagram-MVDRKAX5-HIQg7U3R.js} +1 -1
- package/dist/{ishikawaDiagram-HPEHV2GE-BK4ExPHB.js → ishikawaDiagram-HPEHV2GE-C84x8n2j.js} +2 -2
- package/dist/{journeyDiagram-BOSHW7O7-DXJ-ihrY.js → journeyDiagram-BOSHW7O7-CvYDNxSY.js} +4 -4
- package/dist/{kanban-definition-FNSA4HC5-C9rAkIZN.js → kanban-definition-FNSA4HC5-B586ryFD.js} +2 -2
- package/dist/{mermaid.core-uROF3Ult.js → mermaid.core-3J01L12Z.js} +5803 -5740
- package/dist/{mindmap-definition-6OY57UG3-DC9FfvxT.js → mindmap-definition-6OY57UG3-Donc6BMy.js} +3 -3
- package/dist/{models-D5Mffixi.js → models-Rf3LB8wS.js} +1 -1
- package/dist/{object-metric-numeric-DIgqXqB5.js → object-metric-numeric-BcgaJ6EW.js} +1 -1
- package/dist/{object-metric.service-B3PtIPEA.js → object-metric.service-CKiaFYcp.js} +2 -2
- package/dist/{pegDiagram-ECIUJNBX-CUCvcOc0.js → pegDiagram-ECIUJNBX-CYVi7x6D.js} +3 -3
- package/dist/{pieDiagram-GNMPY74T-DprBId-p.js → pieDiagram-GNMPY74T-4iWKYTTS.js} +2 -2
- package/dist/{prompt-D9VtVs5i.js → prompt-BQzBLrua.js} +110 -100
- package/dist/{quadrantDiagram-D57K4MC3-CcvW9eIV.js → quadrantDiagram-D57K4MC3-Bm6Cyi1I.js} +1 -1
- package/dist/{railroadDiagram-Y72NRBL7-DH43paGB.js → railroadDiagram-Y72NRBL7-Du6iN-Jz.js} +3 -3
- package/dist/{requirementDiagram-EQYSW5RA-CBY8WT39.js → requirementDiagram-EQYSW5RA-BGxpuSlc.js} +3 -3
- package/dist/{sankeyDiagram-SY24JHO5-DD80tYLM.js → sankeyDiagram-SY24JHO5-CsHmu__D.js} +2 -2
- package/dist/{sequenceDiagram-BLEHNHQU-Bo9dDD6b.js → sequenceDiagram-BLEHNHQU-DBNi943L.js} +3 -3
- package/dist/{sizeCapture-INFHLROL-BQTwKEEH.js → sizeCapture-INFHLROL-CcGr2ilA.js} +1 -1
- package/dist/{stateDiagram-v2-A6IESKWZ-um_LWxkE.js → stateDiagram-v2-A6IESKWZ-C78tVzaF.js} +4 -4
- package/dist/{swimlanes-B3ENRKFQ-DyYkLRSQ.js → swimlanes-B3ENRKFQ-BROc4LGM.js} +3 -3
- package/dist/{swimlanesDiagram-AYQRV4AK-DlAG_Vwl.js → swimlanesDiagram-AYQRV4AK-C0RDY4m2.js} +3 -3
- package/dist/{text-BqSVQKS6.js → text-CzC6K33E.js} +7 -3
- package/dist/{text.en-US-BhAxy_LE.js → text.en-US-D8mxBP0p.js} +6 -2
- package/dist/{timeline-definition-JXYKGLGB-DVH8Jsv4.js → timeline-definition-JXYKGLGB-C6WGe4xl.js} +1 -1
- package/dist/toolMatchLines-DrXpUwcl.js +4675 -0
- package/dist/{useLabData-fKy_tVvS.js → useLabData-B-3UW8zF.js} +8007 -7251
- package/dist/{usecaseDiagram-WPOLBNNX-DvsgvjCb.js → usecaseDiagram-WPOLBNNX-yMP7SDIg.js} +3 -3
- package/dist/{vennDiagram-Q3Y3IDCW-BQcWfjtm.js → vennDiagram-Q3Y3IDCW-bZW2LzBB.js} +2 -2
- package/dist/{wardleyDiagram-IVAIDKWA-M_Wv4tRx.js → wardleyDiagram-IVAIDKWA-DBbog93x.js} +2 -2
- package/dist/{workshop-app-wZ37Phc-.js → workshop-app-ByYXbgcn.js} +5008 -4707
- package/dist/workshop-app.css +1 -1
- package/dist/workshop-app.js +1 -1
- package/dist/{xychartDiagram-4URNHDU4-DBviJ7Ux.js → xychartDiagram-4URNHDU4-CVLJNXOt.js} +1 -1
- package/dist-cli/workshop.js +182 -140
- package/package.json +1 -1
- package/skill/SKILL.en-US.md +5 -0
- package/skill/SKILL.md +3 -0
- package/dist/AppFormModal-ByNEloW-.js +0 -4282
- package/dist/AppListPage-D2NVBJs7.js +0 -1465
- package/dist/WorkshopLabPage-C7hssyUo.js +0 -11364
- package/dist/generateCypher-kvNYDLY4.js +0 -399
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
import { O as q, L as F, Q as _ } from "./workshop-app-wZ37Phc-.js";
|
|
2
|
-
import { a6 as G, O as H, a7 as V, a8 as I, a9 as W, aa as K } from "./useLabData-fKy_tVvS.js";
|
|
3
|
-
import { f as C, M as z } from "./PageRenderer-Debi-U0v.js";
|
|
4
|
-
import { u as B, g as Q, a as X, s as Z, f as ee, i as te, p as re, S as ne } from "./prompt-D9VtVs5i.js";
|
|
5
|
-
function oe(r, n) {
|
|
6
|
-
if (!Array.isArray(n)) throw new Error("patch 必须是数组");
|
|
7
|
-
const e = { value: structuredClone(r) };
|
|
8
|
-
for (const t of n)
|
|
9
|
-
switch (t?.op) {
|
|
10
|
-
case "add":
|
|
11
|
-
x(e, t.path, structuredClone(t.value));
|
|
12
|
-
break;
|
|
13
|
-
case "replace":
|
|
14
|
-
N(e, t.path), x(e, t.path, structuredClone(t.value));
|
|
15
|
-
break;
|
|
16
|
-
case "remove":
|
|
17
|
-
N(e, t.path);
|
|
18
|
-
break;
|
|
19
|
-
case "move":
|
|
20
|
-
x(e, t.path, N(e, t.from));
|
|
21
|
-
break;
|
|
22
|
-
case "test": {
|
|
23
|
-
const [o, s] = j(e, t.path), i = o[s];
|
|
24
|
-
if (JSON.stringify(i) !== JSON.stringify(t.value))
|
|
25
|
-
throw new Error(
|
|
26
|
-
`patch 校验不符:${t.path} 是 ${JSON.stringify(i)},不是 ${JSON.stringify(t.value)}`
|
|
27
|
-
);
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
default:
|
|
31
|
-
throw new Error(`不支持的 patch 操作:${JSON.stringify(t)}`);
|
|
32
|
-
}
|
|
33
|
-
return e.value;
|
|
34
|
-
}
|
|
35
|
-
const se = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
36
|
-
function ae(r) {
|
|
37
|
-
if (typeof r != "string" || !r.startsWith("/")) throw new Error(`patch 路径无效:${r}`);
|
|
38
|
-
const n = r.slice(1).split("/").map((e) => e.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
39
|
-
if (n.some((e) => se.has(e))) throw new Error(`patch 路径无效:${r}`);
|
|
40
|
-
return n;
|
|
41
|
-
}
|
|
42
|
-
function j(r, n) {
|
|
43
|
-
const e = ae(n);
|
|
44
|
-
let t = r, o = "value";
|
|
45
|
-
for (const s of e) {
|
|
46
|
-
if (t = t[o], typeof t != "object" || t === null) throw new Error(`patch 路径不存在:${n}`);
|
|
47
|
-
o = s;
|
|
48
|
-
}
|
|
49
|
-
return [t, o];
|
|
50
|
-
}
|
|
51
|
-
function x(r, n, e) {
|
|
52
|
-
const [t, o] = j(r, n);
|
|
53
|
-
if (Array.isArray(t)) {
|
|
54
|
-
const s = o === "-" ? t.length : Number(o);
|
|
55
|
-
if (!Number.isInteger(s) || s < 0 || s > t.length)
|
|
56
|
-
throw new Error(`patch 下标越界:${n}`);
|
|
57
|
-
t.splice(s, 0, e);
|
|
58
|
-
} else
|
|
59
|
-
t[o] = e;
|
|
60
|
-
}
|
|
61
|
-
function N(r, n) {
|
|
62
|
-
const [e, t] = j(r, n);
|
|
63
|
-
if (Array.isArray(e)) {
|
|
64
|
-
const s = Number(t);
|
|
65
|
-
if (!Number.isInteger(s) || s < 0 || s >= e.length)
|
|
66
|
-
throw new Error(`patch 下标越界:${n}`);
|
|
67
|
-
return e.splice(s, 1)[0];
|
|
68
|
-
}
|
|
69
|
-
if (!(t in e)) throw new Error(`patch 路径不存在:${n}`);
|
|
70
|
-
const o = e[t];
|
|
71
|
-
return delete e[t], o;
|
|
72
|
-
}
|
|
73
|
-
const h = (r) => typeof r == "object" && r !== null && !Array.isArray(r);
|
|
74
|
-
function ie(r, n) {
|
|
75
|
-
const e = h(r) ? r : {}, t = h(n) ? Object.keys(n) : [], o = q.find(
|
|
76
|
-
(i) => t.length > 0 && t.every((a) => F[i].includes(a))
|
|
77
|
-
), s = q.includes(e.type) ? e.type : o ?? "dashboard";
|
|
78
|
-
return { ...z[s], ...e, type: s };
|
|
79
|
-
}
|
|
80
|
-
function ce(r, n) {
|
|
81
|
-
if (!h(r)) return r;
|
|
82
|
-
const e = {
|
|
83
|
-
variables: [],
|
|
84
|
-
...G(r),
|
|
85
|
-
apiVersion: H
|
|
86
|
-
};
|
|
87
|
-
if (!Array.isArray(e.pages) && h(e.regions)) {
|
|
88
|
-
e.pages = [
|
|
89
|
-
{
|
|
90
|
-
id: "main",
|
|
91
|
-
title: typeof e.title == "string" ? e.title : "页面",
|
|
92
|
-
layout: e.layout,
|
|
93
|
-
regions: e.regions,
|
|
94
|
-
...e.detail ? { detail: e.detail } : {}
|
|
95
|
-
}
|
|
96
|
-
];
|
|
97
|
-
for (const a of ["version", "title", "layout", "regions", "detail"]) delete e[a];
|
|
98
|
-
}
|
|
99
|
-
Array.isArray(e.pages) && (e.pages = e.pages.map(
|
|
100
|
-
(a) => h(a) ? {
|
|
101
|
-
regions: {},
|
|
102
|
-
...a,
|
|
103
|
-
layout: ie(a.layout, a.regions)
|
|
104
|
-
} : a
|
|
105
|
-
));
|
|
106
|
-
const t = h(e.app) ? e.app : {}, o = Array.isArray(e.pages) && h(e.pages[0]) ? e.pages[0].title : void 0;
|
|
107
|
-
e.app = {
|
|
108
|
-
id: "app",
|
|
109
|
-
name: typeof o == "string" ? o : "应用",
|
|
110
|
-
...t
|
|
111
|
-
}, e.dependencies = { knowledgeNetwork: { id: n.id, name: n.name } };
|
|
112
|
-
const s = h(e.theme) ? e.theme : {}, i = C[typeof s.name == "string" ? s.name : ""] ?? C.default;
|
|
113
|
-
return e.theme = { ...i, ...s }, e;
|
|
114
|
-
}
|
|
115
|
-
function J(r) {
|
|
116
|
-
if (typeof r != "object" || r === null) return !1;
|
|
117
|
-
const n = r;
|
|
118
|
-
return n.spec !== void 0 || n.patch !== void 0 || "apiVersion" in n || "pages" in n;
|
|
119
|
-
}
|
|
120
|
-
class P extends Error {
|
|
121
|
-
constructor(n) {
|
|
122
|
-
super(n.join(";")), this.errors = n;
|
|
123
|
-
}
|
|
124
|
-
errors;
|
|
125
|
-
}
|
|
126
|
-
function le(r, n) {
|
|
127
|
-
return `${r?.scheduleModel ? `当前调度模型:
|
|
128
|
-
${JSON.stringify(r.scheduleModel)}
|
|
129
|
-
|
|
130
|
-
` : ""}用户对调度的描述:${n}
|
|
131
|
-
|
|
132
|
-
按“调度模型”一节只输出 {"scheduleModel": ..., "needs": [...]},不要输出 spec 或 patch。`;
|
|
133
|
-
}
|
|
134
|
-
function ue(r) {
|
|
135
|
-
if (typeof r != "object" || r === null || J(r)) return null;
|
|
136
|
-
const n = r.component;
|
|
137
|
-
if (typeof n != "object" || n === null) return null;
|
|
138
|
-
const { explicit: e, reason: t } = n;
|
|
139
|
-
return { explicit: e === !0, reason: typeof t == "string" ? t.trim() : "" };
|
|
140
|
-
}
|
|
141
|
-
const L = 16384;
|
|
142
|
-
function Y(r) {
|
|
143
|
-
return r.replace(/<think>[\s\S]*?<\/think>/g, "");
|
|
144
|
-
}
|
|
145
|
-
function pe(r) {
|
|
146
|
-
const n = Y(r), e = n.indexOf("{"), t = n.lastIndexOf("}");
|
|
147
|
-
if (e < 0 || t <= e) throw new Error("no JSON object");
|
|
148
|
-
return JSON.parse(n.slice(e, t + 1));
|
|
149
|
-
}
|
|
150
|
-
function de(r, n) {
|
|
151
|
-
if (typeof r != "object" || r === null) throw new Error("输出不是 JSON 对象");
|
|
152
|
-
const e = r;
|
|
153
|
-
if (e.patch !== void 0) {
|
|
154
|
-
if (!n) throw new Error("还没有页面,不能输出 patch,请输出完整的 spec");
|
|
155
|
-
return { mode: "patch", spec: oe(n, e.patch) };
|
|
156
|
-
}
|
|
157
|
-
return e.spec !== void 0 ? { mode: "spec", spec: e.spec } : { mode: "spec", spec: r };
|
|
158
|
-
}
|
|
159
|
-
function fe(r, n) {
|
|
160
|
-
if (typeof r != "object" || r === null || Array.isArray(r)) return r;
|
|
161
|
-
const e = { ...r };
|
|
162
|
-
return delete e.scheduleModel, n?.scheduleModel ? { ...e, scheduleModel: n.scheduleModel } : e;
|
|
163
|
-
}
|
|
164
|
-
function me(r, n) {
|
|
165
|
-
const e = (o) => (o?.pages ?? []).flatMap(
|
|
166
|
-
(s) => Object.values(s.regions).flat().map((i) => i?.type)
|
|
167
|
-
), t = new Set(e(r));
|
|
168
|
-
return [
|
|
169
|
-
...new Set(
|
|
170
|
-
e(n).filter(
|
|
171
|
-
(o) => typeof o == "string" && !t.has(o) && ne.includes(o)
|
|
172
|
-
)
|
|
173
|
-
)
|
|
174
|
-
];
|
|
175
|
-
}
|
|
176
|
-
async function be(r) {
|
|
177
|
-
const {
|
|
178
|
-
model: n,
|
|
179
|
-
kn: e,
|
|
180
|
-
current: t,
|
|
181
|
-
instruction: o,
|
|
182
|
-
target: s,
|
|
183
|
-
signal: i,
|
|
184
|
-
maxAttempts: a = 3,
|
|
185
|
-
onStep: d,
|
|
186
|
-
scenarios: S = !0,
|
|
187
|
-
ruleTools: g,
|
|
188
|
-
scheduleOnly: c = !1
|
|
189
|
-
} = r, f = performance.now(), w = [
|
|
190
|
-
{
|
|
191
|
-
role: "user",
|
|
192
|
-
content: c ? le(t, o) : B(t, o, s?.note)
|
|
193
|
-
}
|
|
194
|
-
];
|
|
195
|
-
let p = [], l = t;
|
|
196
|
-
const m = c ? `${o} scheduleGantt` : o, y = await Q(t, m, s ? [s.type] : []), O = c || X(t, m).includes("scheduleGantt"), k = c || g !== void 0 && O, b = Z(e, ee(e, t, o), y, {
|
|
197
|
-
scenarios: S,
|
|
198
|
-
...g ? { ruleTools: g } : c ? { ruleTools: [] } : {},
|
|
199
|
-
scheduling: O,
|
|
200
|
-
newComponents: !c && t !== null
|
|
201
|
-
});
|
|
202
|
-
let A = c;
|
|
203
|
-
for (let E = 1; E <= a; E++) {
|
|
204
|
-
d?.({ kind: "generating", attempt: E });
|
|
205
|
-
const { text: M } = await _({
|
|
206
|
-
model: n,
|
|
207
|
-
system: b,
|
|
208
|
-
messages: w,
|
|
209
|
-
maxOutputTokens: L,
|
|
210
|
-
maxRetries: 0,
|
|
211
|
-
abortSignal: i
|
|
212
|
-
});
|
|
213
|
-
try {
|
|
214
|
-
const u = pe(M), v = !c && t ? ue(u) : null;
|
|
215
|
-
if (v)
|
|
216
|
-
return d?.({ kind: "valid", mode: "component" }), { ok: !0, component: v, attempts: E, ms: performance.now() - f };
|
|
217
|
-
if (c || k && te(u) && !J(u)) {
|
|
218
|
-
A = !0;
|
|
219
|
-
const T = re(u, e, g ?? [], t?.scheduleModel);
|
|
220
|
-
if (T.ok)
|
|
221
|
-
return d?.({ kind: "valid", mode: "schedule" }), {
|
|
222
|
-
ok: !0,
|
|
223
|
-
schedule: T.proposal,
|
|
224
|
-
attempts: E,
|
|
225
|
-
ms: performance.now() - f
|
|
226
|
-
};
|
|
227
|
-
throw new P(T.errors);
|
|
228
|
-
}
|
|
229
|
-
A = !1;
|
|
230
|
-
const { mode: U, spec: D } = de(u, l);
|
|
231
|
-
l = ce(fe(D, t), e);
|
|
232
|
-
const $ = V(l, e), R = S ? [] : me(t, $.ok ? $.app : null);
|
|
233
|
-
if ($.ok && R.length > 0)
|
|
234
|
-
p = [
|
|
235
|
-
`方案推演需要企业版,当前环境不提供:去掉新加的方案类组件(${R.join("、")})`
|
|
236
|
-
];
|
|
237
|
-
else {
|
|
238
|
-
if ($.ok)
|
|
239
|
-
return d?.({ kind: "valid", mode: U }), {
|
|
240
|
-
ok: !0,
|
|
241
|
-
spec: $.app,
|
|
242
|
-
attempts: E,
|
|
243
|
-
ms: performance.now() - f
|
|
244
|
-
};
|
|
245
|
-
p = $.errors;
|
|
246
|
-
}
|
|
247
|
-
} catch (u) {
|
|
248
|
-
p = u instanceof P ? u.errors : [u instanceof Error ? u.message : String(u)];
|
|
249
|
-
}
|
|
250
|
-
d?.({ kind: "invalid", errors: p }), w.push(
|
|
251
|
-
{ role: "assistant", content: M },
|
|
252
|
-
{
|
|
253
|
-
role: "user",
|
|
254
|
-
content: A ? `上次输出的调度模型答案不合法:
|
|
255
|
-
- ${p.slice(0, 20).join(`
|
|
256
|
-
- `)}
|
|
257
|
-
请修正后重新输出 {"scheduleModel": ..., "needs": [...]}。` : `上次输出不合法:
|
|
258
|
-
- ${p.slice(0, 20).join(`
|
|
259
|
-
- `)}
|
|
260
|
-
请修正:可以输出完整的 {"spec": ...}${l ? ',或输出相对你上次结果的 {"patch": [...]}' : ""}。`
|
|
261
|
-
}
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
return {
|
|
265
|
-
ok: !1,
|
|
266
|
-
errors: p,
|
|
267
|
-
attempts: a,
|
|
268
|
-
ms: performance.now() - f
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
function ye(r) {
|
|
272
|
-
const n = Object.values(r.objectTypes).filter((t) => !K(t.id)).map(
|
|
273
|
-
(t) => `- ${t.id}(${t.name})主键 ${t.primaryKeys.join("、") || "无"}
|
|
274
|
-
${t.properties.map((o) => `${o.name}:${o.type}(${o.label})`).join(",")}`
|
|
275
|
-
), e = r.relations.map(
|
|
276
|
-
(t) => `- ${t.id}(${t.name}):(${t.source})-[:${t.id}]->(${t.target})`
|
|
277
|
-
);
|
|
278
|
-
return `对象类(id(名称)、主键、属性名:类型(显示名)):
|
|
279
|
-
${n.join(`
|
|
280
|
-
`)}
|
|
281
|
-
|
|
282
|
-
关系类(方向从左到右):
|
|
283
|
-
${e.join(`
|
|
284
|
-
`)}`;
|
|
285
|
-
}
|
|
286
|
-
function he(r, n) {
|
|
287
|
-
const e = n.filter((t) => W.includes(t.kind));
|
|
288
|
-
return `你为业务应用的数据源编写只读 Cypher 查询,在知识网络「${r.name}」上运行。
|
|
289
|
-
|
|
290
|
-
规则:
|
|
291
|
-
- 只写一条只读查询:MATCH … [WHERE …] [WITH …] RETURN … [ORDER BY …] LIMIT n。不能用 CREATE、MERGE、SET、DELETE、REMOVE、CALL。
|
|
292
|
-
- 标签、关系类型和属性名都用下面的 id,并用反引号括起来,如 (a:\`对象类id\`)-[:\`关系id\`]->(b:\`对象类id\`)、a.\`属性名\`;关系方向必须与清单一致,反向时写 <-[:…]-。
|
|
293
|
-
- 属性名只能用清单里该对象类的属性,原样写,不要猜。
|
|
294
|
-
- RETURN 的每一列都用 AS 起简短的英文别名(字母开头,可含字母、数字、下划线),别名就是数据源的列名。
|
|
295
|
-
- 要能当主键的列:通常返回主对象的主键,每行唯一。
|
|
296
|
-
- 可以用 count、sum、avg、min、max 聚合;聚合时非聚合列就是分组键。
|
|
297
|
-
- 结果最多 10000 行,一定要写 LIMIT。
|
|
298
|
-
- 需要跟随页面变量时,用 $变量名 作为参数,只能用下面列出的变量;不要把变量值直接写进查询。
|
|
299
|
-
- 日期属性(date、datetime、timestamp)通常以 ISO 文本存储,可与 'YYYY-MM-DD' 或日期变量比较大小;查询结果为空时,可能是这个属性的存储格式不同,在说明里提一句。
|
|
300
|
-
|
|
301
|
-
页面变量(可作 $参数):
|
|
302
|
-
${e.map((t) => `- $${t.name}:${t.label}(${t.kind})`).join(`
|
|
303
|
-
`) || "(无)"}
|
|
304
|
-
|
|
305
|
-
${ye(r)}
|
|
306
|
-
|
|
307
|
-
只输出 JSON:{"query": "…", "explanation": "一句话说明经过哪些关系、怎么聚合"}。`;
|
|
308
|
-
}
|
|
309
|
-
function ge(r) {
|
|
310
|
-
const n = Y(r), e = n.match(/\{[\s\S]*\}/);
|
|
311
|
-
if (e)
|
|
312
|
-
try {
|
|
313
|
-
const o = JSON.parse(e[0]);
|
|
314
|
-
if (typeof o.query == "string" && o.query.trim())
|
|
315
|
-
return {
|
|
316
|
-
query: o.query.trim(),
|
|
317
|
-
explanation: typeof o.explanation == "string" ? o.explanation : ""
|
|
318
|
-
};
|
|
319
|
-
} catch {
|
|
320
|
-
}
|
|
321
|
-
const t = n.match(/```(?:cypher)?\s*([\s\S]*?)```/);
|
|
322
|
-
if (t) return { query: t[1].trim(), explanation: "" };
|
|
323
|
-
throw new Error("回复里没有找到查询");
|
|
324
|
-
}
|
|
325
|
-
async function Ae(r) {
|
|
326
|
-
const { model: n, kn: e, variables: t, values: o, instruction: s, current: i, query: a, signal: d, onStep: S } = r, g = r.maxAttempts ?? 3, c = [
|
|
327
|
-
{
|
|
328
|
-
role: "user",
|
|
329
|
-
content: i?.trim() ? `当前查询:
|
|
330
|
-
${i}
|
|
331
|
-
|
|
332
|
-
修改要求:${s}` : s
|
|
333
|
-
}
|
|
334
|
-
];
|
|
335
|
-
let f = { query: "", error: "" };
|
|
336
|
-
for (let w = 1; w <= g; w++) {
|
|
337
|
-
S?.({ kind: "generating", attempt: w });
|
|
338
|
-
const { text: p } = await _({
|
|
339
|
-
model: n,
|
|
340
|
-
system: he(e, t),
|
|
341
|
-
messages: c,
|
|
342
|
-
maxOutputTokens: L,
|
|
343
|
-
maxRetries: 0,
|
|
344
|
-
abortSignal: d
|
|
345
|
-
});
|
|
346
|
-
let l = "";
|
|
347
|
-
try {
|
|
348
|
-
const m = ge(p);
|
|
349
|
-
l = m.query;
|
|
350
|
-
const y = I(l).filter(
|
|
351
|
-
(k) => !t.some((b) => b.name === k)
|
|
352
|
-
);
|
|
353
|
-
if (y.length > 0)
|
|
354
|
-
throw new Error(`参数 ${y.map((k) => `$${k}`).join("、")} 不是页面变量`);
|
|
355
|
-
S?.({ kind: "running", query: l });
|
|
356
|
-
const O = await a(l, we(l, o), d);
|
|
357
|
-
return {
|
|
358
|
-
ok: !0,
|
|
359
|
-
query: l,
|
|
360
|
-
explanation: m.explanation,
|
|
361
|
-
result: O,
|
|
362
|
-
attempts: w
|
|
363
|
-
};
|
|
364
|
-
} catch (m) {
|
|
365
|
-
if (d?.aborted) throw m;
|
|
366
|
-
const y = Se(m);
|
|
367
|
-
f = { query: l, error: y }, S?.({ kind: "failed", error: y }), c.push(
|
|
368
|
-
{ role: "assistant", content: p },
|
|
369
|
-
{
|
|
370
|
-
role: "user",
|
|
371
|
-
content: `运行失败:${y}
|
|
372
|
-
请对照对象类、属性和关系方向修正,仍只输出 JSON。`
|
|
373
|
-
}
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
return { ok: !1, error: f.error, query: f.query, attempts: g };
|
|
378
|
-
}
|
|
379
|
-
function we(r, n) {
|
|
380
|
-
return Object.fromEntries(
|
|
381
|
-
I(r).map((e) => {
|
|
382
|
-
const t = n[e];
|
|
383
|
-
return Array.isArray(t) ? [e, t.map(String)] : [e, t == null ? null : String(t)];
|
|
384
|
-
})
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
function Se(r) {
|
|
388
|
-
const n = r.response?.data;
|
|
389
|
-
return n && (typeof n.details == "string" || typeof n.description == "string") ? [n.description, n.details].filter((e) => typeof e == "string").join(":") : r instanceof Error ? r.message : String(r);
|
|
390
|
-
}
|
|
391
|
-
export {
|
|
392
|
-
L as M,
|
|
393
|
-
be as a,
|
|
394
|
-
ye as d,
|
|
395
|
-
Se as e,
|
|
396
|
-
Ae as g,
|
|
397
|
-
we as p,
|
|
398
|
-
Y as w
|
|
399
|
-
};
|