@iblai/web-containers 2.4.0 → 2.6.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/dist/cjs/_virtual/index2.js +2 -2
- package/dist/cjs/_virtual/index3.js +2 -2
- package/dist/cjs/components/chat/ai-message-bubble.js +2 -1
- package/dist/cjs/components/chat/ai-message-bubble.js.map +1 -1
- package/dist/cjs/components/chat/chat-host-context.js.map +1 -1
- package/dist/cjs/components/chat/client-ui-tools/definitions.js +187 -0
- package/dist/cjs/components/chat/client-ui-tools/definitions.js.map +1 -0
- package/dist/cjs/components/chat/client-ui-tools/panel-list.js +91 -0
- package/dist/cjs/components/chat/client-ui-tools/panel-list.js.map +1 -0
- package/dist/cjs/components/chat/client-ui-tools/panels.js +242 -0
- package/dist/cjs/components/chat/client-ui-tools/panels.js.map +1 -0
- package/dist/cjs/components/chat/client-ui-tools/runner.js +285 -0
- package/dist/cjs/components/chat/client-ui-tools/runner.js.map +1 -0
- package/dist/cjs/components/chat/client-ui-tools/store.js +119 -0
- package/dist/cjs/components/chat/client-ui-tools/store.js.map +1 -0
- package/dist/cjs/components/chat/client-ui-tools/use-client-ui-tools.js +29 -0
- package/dist/cjs/components/chat/client-ui-tools/use-client-ui-tools.js.map +1 -0
- package/dist/cjs/components/chat/index.js +39 -2
- package/dist/cjs/components/chat/index.js.map +1 -1
- package/dist/cjs/components/ui/chart.js +2 -0
- package/dist/cjs/components/ui/chart.js.map +1 -1
- package/dist/cjs/components/workflows/classifier-panel.js +2 -0
- package/dist/cjs/components/workflows/classifier-panel.js.map +1 -1
- package/dist/cjs/components/workflows/workflow-canvas.js +1 -1
- package/dist/cjs/components/workflows/workflow-canvas.js.map +1 -1
- package/dist/cjs/components/workflows/workflow-definition.js +5 -2
- package/dist/cjs/components/workflows/workflow-definition.js.map +1 -1
- package/dist/cjs/components/workflows/workflow-editor.js +87 -241
- package/dist/cjs/components/workflows/workflow-editor.js.map +1 -1
- package/dist/cjs/components/workflows/workflows-list.js +14 -1
- package/dist/cjs/components/workflows/workflows-list.js.map +1 -1
- package/dist/cjs/hooks/use-extension-client-tools.js +98 -0
- package/dist/cjs/hooks/use-extension-client-tools.js.map +1 -0
- package/dist/cjs/i18n/messages/en.json.js +22 -21
- package/dist/cjs/i18n/messages/en.json.js.map +1 -1
- package/dist/cjs/i18n/messages/es.json.js +22 -21
- package/dist/cjs/i18n/messages/es.json.js.map +1 -1
- package/dist/cjs/i18n/messages/fr.json.js +22 -21
- package/dist/cjs/i18n/messages/fr.json.js.map +1 -1
- package/dist/cjs/i18n/messages/zh.json.js +22 -21
- package/dist/cjs/i18n/messages/zh.json.js.map +1 -1
- package/dist/cjs/next/index.js +16 -0
- package/dist/cjs/next/index.js.map +1 -1
- package/dist/cjs/node_modules/.pnpm/css-mediaquery@0.1.2/node_modules/css-mediaquery/index.js +1 -1
- package/dist/cjs/node_modules/.pnpm/matchmediaquery@0.4.2/node_modules/matchmediaquery/index.js +1 -1
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -1
- package/dist/cjs/web-containers/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/components/chat/ai-message-bubble.js +2 -1
- package/dist/esm/components/chat/ai-message-bubble.js.map +1 -1
- package/dist/esm/components/chat/chat-host-context.js.map +1 -1
- package/dist/esm/components/chat/client-ui-tools/definitions.js +183 -0
- package/dist/esm/components/chat/client-ui-tools/definitions.js.map +1 -0
- package/dist/esm/components/chat/client-ui-tools/panel-list.js +89 -0
- package/dist/esm/components/chat/client-ui-tools/panel-list.js.map +1 -0
- package/dist/esm/components/chat/client-ui-tools/panels.js +240 -0
- package/dist/esm/components/chat/client-ui-tools/panels.js.map +1 -0
- package/dist/esm/components/chat/client-ui-tools/runner.js +278 -0
- package/dist/esm/components/chat/client-ui-tools/runner.js.map +1 -0
- package/dist/esm/components/chat/client-ui-tools/store.js +113 -0
- package/dist/esm/components/chat/client-ui-tools/store.js.map +1 -0
- package/dist/esm/components/chat/client-ui-tools/use-client-ui-tools.js +27 -0
- package/dist/esm/components/chat/client-ui-tools/use-client-ui-tools.js.map +1 -0
- package/dist/esm/components/chat/index.js +39 -2
- package/dist/esm/components/chat/index.js.map +1 -1
- package/dist/esm/components/ui/chart.js +2 -1
- package/dist/esm/components/ui/chart.js.map +1 -1
- package/dist/esm/components/workflows/classifier-panel.js +2 -0
- package/dist/esm/components/workflows/classifier-panel.js.map +1 -1
- package/dist/esm/components/workflows/workflow-canvas.js +1 -1
- package/dist/esm/components/workflows/workflow-canvas.js.map +1 -1
- package/dist/esm/components/workflows/workflow-definition.js +5 -2
- package/dist/esm/components/workflows/workflow-definition.js.map +1 -1
- package/dist/esm/components/workflows/workflow-editor.js +88 -242
- package/dist/esm/components/workflows/workflow-editor.js.map +1 -1
- package/dist/esm/components/workflows/workflows-list.js +14 -1
- package/dist/esm/components/workflows/workflows-list.js.map +1 -1
- package/dist/esm/hooks/use-extension-client-tools.js +96 -0
- package/dist/esm/hooks/use-extension-client-tools.js.map +1 -0
- package/dist/esm/i18n/messages/en.json.js +22 -22
- package/dist/esm/i18n/messages/es.json.js +22 -22
- package/dist/esm/i18n/messages/fr.json.js +22 -22
- package/dist/esm/i18n/messages/zh.json.js +22 -22
- package/dist/esm/next/index.js +6 -0
- package/dist/esm/next/index.js.map +1 -1
- package/dist/esm/web-containers/tsconfig.build.tsbuildinfo +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/next/index.d.ts +175 -5
- package/dist/package.json +6 -2
- package/package.json +7 -3
|
@@ -36,6 +36,7 @@ var listChecks = require('../../node_modules/.pnpm/lucide-react@0.528.0_react@19
|
|
|
36
36
|
var chevronUp = require('../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/chevron-up.js');
|
|
37
37
|
var chevronDown = require('../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/chevron-down.js');
|
|
38
38
|
var triangleAlert = require('../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/triangle-alert.js');
|
|
39
|
+
var info = require('../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/info.js');
|
|
39
40
|
var plus = require('../../node_modules/.pnpm/lucide-react@0.528.0_react@19.1.0/node_modules/lucide-react/dist/esm/icons/plus.js');
|
|
40
41
|
|
|
41
42
|
function getCategoryConfig(t) {
|
|
@@ -51,204 +52,30 @@ const nodeCategoryOverride = {
|
|
|
51
52
|
};
|
|
52
53
|
function stepsOf(nodes) {
|
|
53
54
|
const byId = new Map(nodes.map((node) => [node.id, node]));
|
|
54
|
-
return { find: (id) => byId.get(id)
|
|
55
|
+
return { find: (id) => byId.get(id) };
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// repeats the runtime and entry-agent checks once per Agent step.
|
|
73
|
-
const MENTOR_MESSAGES = [
|
|
74
|
-
{
|
|
75
|
-
pattern: /^Mentor existence will be validated at runtime/,
|
|
76
|
-
key: 'workflowsWorkflowEditor.agentCheckedAtRuntime',
|
|
77
|
-
aboutEveryStep: true,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
pattern: /^Node 'mentor' missing required field 'mentor_id'/,
|
|
81
|
-
key: 'workflowsWorkflowEditor.agentStepMissingAgent',
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
pattern: /^Mentor step needs a mentor/,
|
|
85
|
-
key: 'workflowsWorkflowEditor.agentStepMissingAgent',
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
pattern: /^A mentor step cannot use this workflow's own entry mentor/,
|
|
89
|
-
key: 'workflowsWorkflowEditor.agentStepUsesEntryAgent',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
pattern: /^Mentor step '(.+?)' uses a mentor that does not exist on this platform/,
|
|
93
|
-
key: 'workflowsWorkflowEditor.agentStepAgentMissing',
|
|
94
|
-
params: (match, steps) => ({ name: stepName(steps, match[1]) }),
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
pattern: /^Mentor step 'output_variable' must start with a letter/,
|
|
98
|
-
key: 'workflowsWorkflowEditor.agentStepOutputVariableInvalid',
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
pattern: /^Classifier '(.+?)' route '(.+?)' goes straight to End/,
|
|
102
|
-
key: 'workflowsWorkflowEditor.classifierRouteToEnd',
|
|
103
|
-
params: (match, steps, t) => ({
|
|
104
|
-
name: stepName(steps, match[1]),
|
|
105
|
-
path: branchName(steps.find(match[1]), match[2], t),
|
|
106
|
-
}),
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
// Only the nodes[<index>] location says which step stores the variable.
|
|
110
|
-
pattern: /^(?:Mentor step|Classifier) 'output_variable' '(.+?)' is a variable .+? \('(.+?)'\); this step replaces it with its result at nodes\[(\d+)\]\.data\b/,
|
|
111
|
-
key: 'workflowsWorkflowEditor.outputVariableClash',
|
|
112
|
-
params: (match, steps) => {
|
|
113
|
-
var _a;
|
|
114
|
-
const step = steps.at(Number(match[3]));
|
|
115
|
-
if (!step)
|
|
116
|
-
return null;
|
|
117
|
-
return {
|
|
118
|
-
name: ((_a = step.data) === null || _a === void 0 ? void 0 : _a.label) || step.id,
|
|
119
|
-
variable: match[1],
|
|
120
|
-
setter: stepName(steps, match[2]),
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
pattern: /^(?:Mentor step|Classifier) 'output_variable' '(.+?)' is a variable .+? \('(.+?)'\); this step replaces it/,
|
|
126
|
-
key: 'workflowsWorkflowEditor.outputVariableClashUnknownStep',
|
|
127
|
-
params: (match, steps) => ({ variable: match[1], setter: stepName(steps, match[2]) }),
|
|
128
|
-
locationOnly: true,
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
// The model is named as resolved, so "ibl.ai Default" shows up as a slug
|
|
132
|
-
// the author never picked; staff switch decision models on per deployment.
|
|
133
|
-
pattern: /^Classifier '(.+?)' uses '.+?', (?:and ':|which isn't an enabled|which is not a decision)/,
|
|
134
|
-
key: 'workflowsWorkflowEditor.classifierModelUnavailable',
|
|
135
|
-
params: (match, steps) => ({ name: stepName(steps, match[1]) }),
|
|
136
|
-
},
|
|
137
|
-
];
|
|
138
|
-
// The backend ends each message with where it found the problem, e.g.
|
|
139
|
-
// "at nodes[2].data (field: instructions)" or "at workflow_loops (field: edges)".
|
|
140
|
-
const NODE_LOCATION = / at nodes\[(\d+)\](\.data)?(?: \(field: ([^()]+)\))?$/;
|
|
141
|
-
const WORKFLOW_LOCATION = / at workflow_\w+(?: \(field: [^()]+\))?$/;
|
|
142
|
-
const QUOTED = /'([^'\s]+)'/g;
|
|
143
|
-
function problemTarget(message, steps, locationOnly = false, nodeId) {
|
|
144
|
-
const target = textTarget(message, steps, locationOnly);
|
|
145
|
-
// The step the backend names beats one read from the text, which can quote
|
|
146
|
-
// another step; only the text says which field to focus.
|
|
147
|
-
if (!nodeId || !steps.find(nodeId))
|
|
148
|
-
return target;
|
|
149
|
-
return target.stepId === nodeId ? target : { stepId: nodeId };
|
|
150
|
-
}
|
|
151
|
-
function textTarget(message, steps, locationOnly) {
|
|
152
|
-
if (WORKFLOW_LOCATION.test(message))
|
|
153
|
-
return {};
|
|
154
|
-
// The location names the step at fault; a quoted id in the same message can
|
|
155
|
-
// be another step, such as the one that also sets a variable.
|
|
156
|
-
const location = NODE_LOCATION.exec(message);
|
|
157
|
-
if (location) {
|
|
158
|
-
const step = steps.at(Number(location[1]));
|
|
159
|
-
if (!step)
|
|
160
|
-
return {};
|
|
161
|
-
// Outside the step's data the field is its id or type, which no setting shows.
|
|
162
|
-
const field = location[2] ? location[3] : undefined;
|
|
163
|
-
return field ? { stepId: step.id, field } : { stepId: step.id };
|
|
164
|
-
}
|
|
165
|
-
if (locationOnly)
|
|
166
|
-
return {};
|
|
167
|
-
for (const [, quoted] of message.matchAll(QUOTED)) {
|
|
168
|
-
if (steps.find(quoted))
|
|
169
|
-
return { stepId: quoted };
|
|
170
|
-
}
|
|
171
|
-
return {};
|
|
172
|
-
}
|
|
173
|
-
function toProblem({ message, nodeId }, t, steps) {
|
|
174
|
-
for (const { pattern, key, params, aboutEveryStep, locationOnly } of MENTOR_MESSAGES) {
|
|
175
|
-
const match = pattern.exec(message);
|
|
176
|
-
if (!match)
|
|
177
|
-
continue;
|
|
178
|
-
const values = params === null || params === void 0 ? void 0 : params(match, steps, t);
|
|
179
|
-
if (values === null)
|
|
180
|
-
continue;
|
|
181
|
-
const text = t(key, values);
|
|
182
|
-
return aboutEveryStep
|
|
183
|
-
? { text }
|
|
184
|
-
: { text, ...problemTarget(message, steps, locationOnly, nodeId) };
|
|
185
|
-
}
|
|
186
|
-
return { text: message, ...problemTarget(message, steps, false, nodeId) };
|
|
187
|
-
}
|
|
188
|
-
// iblai-dm-pro#3218 lists each message again in error_details /
|
|
189
|
-
// warning_details, in the same order, with the step it is about, and drops the
|
|
190
|
-
// " at nodes[<index>]" ending. A detail whose text differs is not trusted.
|
|
191
|
-
const issuesOf = (messages, details = []) => messages.map((message, index) => {
|
|
192
|
-
const detail = details[index];
|
|
193
|
-
return (detail === null || detail === void 0 ? void 0 : detail.message) === message && detail.node_id
|
|
194
|
-
? { message, nodeId: detail.node_id }
|
|
195
|
-
: { message };
|
|
57
|
+
// Each *_details list repeats its messages in the same order, with the step
|
|
58
|
+
// each is about. A detail whose text differs is not trusted.
|
|
59
|
+
const problemsOf = (messages = [], details = []) => {
|
|
60
|
+
const problems = messages.map((message, index) => {
|
|
61
|
+
const detail = details[index];
|
|
62
|
+
return (detail === null || detail === void 0 ? void 0 : detail.message) === message && detail.node_id
|
|
63
|
+
? { text: message, stepId: detail.node_id }
|
|
64
|
+
: { text: message };
|
|
65
|
+
});
|
|
66
|
+
// Two steps can share a name, so the same words about another step stay.
|
|
67
|
+
return problems.filter((problem, index) => problems.findIndex((other) => other.text === problem.text && other.stepId === problem.stepId) === index);
|
|
68
|
+
};
|
|
69
|
+
const validationProblems = (result) => ({
|
|
70
|
+
errors: problemsOf(result.errors, result.error_details),
|
|
71
|
+
warnings: problemsOf(result.warnings, result.warning_details),
|
|
72
|
+
notices: problemsOf(result.notices, result.notice_details),
|
|
196
73
|
});
|
|
197
|
-
const distinct = (lines) => Array.from(new Set(lines));
|
|
198
|
-
// A repeated line shows once and goes to the first step it was reported for;
|
|
199
|
-
// once that step is fixed, the next check moves it to the next one.
|
|
200
|
-
const distinctProblems = (problems) => problems.filter((problem, index) => problems.findIndex((other) => other.text === problem.text) === index);
|
|
201
74
|
const PROBLEM_LINK = 'cursor-pointer text-left underline-offset-2 hover:underline focus-visible:underline focus-visible:outline-none';
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
{
|
|
205
|
-
pattern: /^Classifier needs instructions/,
|
|
206
|
-
key: 'workflowsClassifierPanel.instructionsRequired',
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
pattern: /^Category \d+ needs a 'label'/,
|
|
210
|
-
key: 'workflowsClassifierPanel.tryErrorCategoryLabel',
|
|
211
|
-
},
|
|
212
|
-
{ pattern: /^Level \d+ needs a 'label'/, key: 'workflowsClassifierPanel.tryErrorLevelLabel' },
|
|
213
|
-
{ pattern: /^Duplicate level label/, key: 'workflowsClassifierPanel.tryErrorDuplicateLevel' },
|
|
214
|
-
{
|
|
215
|
-
pattern: /^('\{\{[^{}]+\}\}') names no step/,
|
|
216
|
-
key: 'workflowsClassifierPanel.tryErrorPlaceholderStep',
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
pattern: /^('\{\{[^{}]+\}\}') is not a valid variable name/,
|
|
220
|
-
key: 'workflowsClassifierPanel.tryErrorPlaceholderVariableName',
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
pattern: /^('\{\{[^{}]+\}\}') names a variable the Start node does not declare/,
|
|
224
|
-
key: 'workflowsClassifierPanel.tryErrorPlaceholderUnknownVariable',
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
pattern: /^('\{\{[^{}]+\}\}') is not a placeholder/,
|
|
228
|
-
key: 'workflowsClassifierPanel.tryErrorNotPlaceholder',
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
pattern: /^('\{\{[^{}]+\}\}') is always empty/,
|
|
232
|
-
key: 'workflowsClassifierPanel.tryErrorPlaceholderEmpty',
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
pattern: /^Example \d+ needs 'text' and a 'category'/,
|
|
236
|
-
key: 'workflowsClassifierPanel.tryErrorExample',
|
|
237
|
-
},
|
|
238
|
-
];
|
|
239
|
-
const CLASSIFIER_MODEL_ERROR = /^Classifier '.+?' uses '.+?', /;
|
|
240
|
-
function classifierErrorText(line, t) {
|
|
241
|
-
if (CLASSIFIER_MODEL_ERROR.test(line))
|
|
242
|
-
return t('workflowsClassifierPanel.tryModelUnavailable');
|
|
243
|
-
for (const { pattern, key } of CLASSIFIER_TRY_MESSAGES) {
|
|
244
|
-
const match = pattern.exec(line);
|
|
245
|
-
if (match)
|
|
246
|
-
return t(key, match[1] ? { placeholder: match[1] } : undefined);
|
|
247
|
-
}
|
|
248
|
-
return t('workflowsClassifierPanel.tryErrorOther');
|
|
249
|
-
}
|
|
250
|
-
function classifierTryFailure(error, t) {
|
|
75
|
+
const distinct = (lines) => Array.from(new Set(lines));
|
|
76
|
+
function classifierTryFailure(error) {
|
|
251
77
|
const { status, data } = (error !== null && error !== void 0 ? error : {});
|
|
78
|
+
const detail = typeof (data === null || data === void 0 ? void 0 : data.detail) === 'string' && data.detail ? data.detail : undefined;
|
|
252
79
|
switch (status) {
|
|
253
80
|
case 400: {
|
|
254
81
|
const rawErrors = data === null || data === void 0 ? void 0 : data.errors;
|
|
@@ -262,16 +89,9 @@ function classifierTryFailure(error, t) {
|
|
|
262
89
|
return { ok: false, reason: 'too-long' };
|
|
263
90
|
if (Array.isArray(data === null || data === void 0 ? void 0 : data.variables))
|
|
264
91
|
return { ok: false, reason: 'variables-too-long' };
|
|
265
|
-
return { ok: false, reason: 'other' };
|
|
92
|
+
return { ok: false, reason: 'other', message: detail };
|
|
266
93
|
}
|
|
267
|
-
|
|
268
|
-
return { ok: false, reason: 'model-unavailable' };
|
|
269
|
-
}
|
|
270
|
-
return {
|
|
271
|
-
ok: false,
|
|
272
|
-
reason: 'invalid',
|
|
273
|
-
errors: distinct(lines.map((line) => classifierErrorText(line, t))),
|
|
274
|
-
};
|
|
94
|
+
return { ok: false, reason: 'invalid', message: detail, errors: distinct(lines) };
|
|
275
95
|
}
|
|
276
96
|
case 402:
|
|
277
97
|
return { ok: false, reason: 'credits' };
|
|
@@ -280,9 +100,8 @@ function classifierTryFailure(error, t) {
|
|
|
280
100
|
case 429:
|
|
281
101
|
return { ok: false, reason: 'spend-cap' };
|
|
282
102
|
case 502: {
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
/not enabled for this account|not available for this account/.test(detail);
|
|
103
|
+
const unavailable = !!detail &&
|
|
104
|
+
/(?:not|isn't) (?:enabled|available) for this (?:account|organization)/.test(detail);
|
|
286
105
|
return { ok: false, reason: unavailable ? 'model-unavailable' : 'model-failed' };
|
|
287
106
|
}
|
|
288
107
|
default:
|
|
@@ -436,6 +255,9 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
436
255
|
const [workflowData, setWorkflowData] = React.useState(null);
|
|
437
256
|
const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false);
|
|
438
257
|
const [validationResult, setValidationResult] = React.useState(null);
|
|
258
|
+
// Half-built steps are normal while building, so a check after a save only
|
|
259
|
+
// updates a banner that is already up; Preview, Publish and Activate show it.
|
|
260
|
+
const [isValidationBannerShown, setIsValidationBannerShown] = React.useState(false);
|
|
439
261
|
const [isValidationBannerOpen, setIsValidationBannerOpen] = React.useState(true);
|
|
440
262
|
const [stepFocusRequest, setStepFocusRequest] = React.useState();
|
|
441
263
|
const isInitialLoad = React.useRef(true);
|
|
@@ -470,20 +292,18 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
470
292
|
// What the canvas last reported, so a save that lands after newer edits
|
|
471
293
|
// leaves them marked Unsaved.
|
|
472
294
|
const latestGraphRef = React.useRef(null);
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const steps = stepsOf(nodes);
|
|
477
|
-
const problems = (issues) => distinctProblems(issues.map((issue) => toProblem(issue, t, steps)));
|
|
478
|
-
const errors = problems(issuesOf(result.errors, result.error_details));
|
|
479
|
-
const kept = new Set(workflowDefinition.withoutNoteConnectivityWarnings(result.warnings, nodes));
|
|
480
|
-
const warnings = problems(issuesOf(result.warnings, result.warning_details).filter(({ message }) => kept.has(message)));
|
|
481
|
-
if (errors.length === 0 && warnings.length === 0) {
|
|
295
|
+
const showValidation = (result, show) => {
|
|
296
|
+
const problems = validationProblems(result);
|
|
297
|
+
if (!problems.errors.length && !problems.warnings.length && !problems.notices.length) {
|
|
482
298
|
setValidationResult(null);
|
|
299
|
+
setIsValidationBannerShown(false);
|
|
483
300
|
return;
|
|
484
301
|
}
|
|
485
|
-
setValidationResult(
|
|
486
|
-
|
|
302
|
+
setValidationResult(problems);
|
|
303
|
+
if (!show)
|
|
304
|
+
return;
|
|
305
|
+
setIsValidationBannerShown(true);
|
|
306
|
+
setIsValidationBannerOpen(show === 'open');
|
|
487
307
|
};
|
|
488
308
|
const showValidationRef = React.useRef(showValidation);
|
|
489
309
|
showValidationRef.current = showValidation;
|
|
@@ -502,7 +322,7 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
502
322
|
org: tenantKey,
|
|
503
323
|
uniqueId: workflowId,
|
|
504
324
|
}).unwrap();
|
|
505
|
-
showValidationRef.current(result
|
|
325
|
+
showValidationRef.current(result);
|
|
506
326
|
}
|
|
507
327
|
catch (_a) {
|
|
508
328
|
// Silent fail for validation
|
|
@@ -600,29 +420,43 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
600
420
|
return { ok: true, output: result.output, model: result.model };
|
|
601
421
|
}
|
|
602
422
|
catch (err) {
|
|
603
|
-
return classifierTryFailure(err
|
|
423
|
+
return classifierTryFailure(err);
|
|
604
424
|
}
|
|
605
425
|
};
|
|
606
426
|
const tryClassifierRef = React.useRef(tryClassifier);
|
|
607
427
|
tryClassifierRef.current = tryClassifier;
|
|
608
428
|
const handleTryClassifier = React.useCallback((nodeId, input) => tryClassifierRef.current(nodeId, input), []);
|
|
609
429
|
const handlePreviewClick = async () => {
|
|
430
|
+
var _a;
|
|
431
|
+
let saved = true;
|
|
610
432
|
try {
|
|
611
433
|
await saveDefinitionIfNeeded();
|
|
612
434
|
}
|
|
613
|
-
catch (
|
|
435
|
+
catch (_b) {
|
|
436
|
+
saved = false;
|
|
614
437
|
sonner.toast.error(t('workflowsWorkflowEditor.failedToSaveWorkflow'));
|
|
615
438
|
}
|
|
616
439
|
setPreviewKey((k) => k + 1);
|
|
617
440
|
setIsPreviewMode(true);
|
|
441
|
+
if (!saved)
|
|
442
|
+
return;
|
|
443
|
+
// A workflow with errors answers "something went wrong", so the banner
|
|
444
|
+
// says why.
|
|
445
|
+
try {
|
|
446
|
+
const result = await validateWorkflow({ org: tenantKey, uniqueId: workflowId }).unwrap();
|
|
447
|
+
showValidation(result, ((_a = result.errors) === null || _a === void 0 ? void 0 : _a.length) ? 'open' : undefined);
|
|
448
|
+
}
|
|
449
|
+
catch (_c) {
|
|
450
|
+
// Preview still runs; Publish reports what is wrong.
|
|
451
|
+
}
|
|
618
452
|
};
|
|
619
453
|
const handleClosePreview = () => setIsPreviewMode(false);
|
|
620
454
|
const handleNewChat = () => setNewChatSignal((signal) => signal + 1);
|
|
621
455
|
// Preview hides step settings (and, on a phone, the whole canvas), so
|
|
622
456
|
// going to a step leaves it.
|
|
623
|
-
const handleShowStep = (nodeId
|
|
457
|
+
const handleShowStep = (nodeId) => {
|
|
624
458
|
setIsPreviewMode(false);
|
|
625
|
-
setStepFocusRequest((previous) => { var _a; return ({ nodeId,
|
|
459
|
+
setStepFocusRequest((previous) => { var _a; return ({ nodeId, nonce: ((_a = previous === null || previous === void 0 ? void 0 : previous.nonce) !== null && _a !== void 0 ? _a : 0) + 1 }); });
|
|
626
460
|
};
|
|
627
461
|
const handleWorkflowStateChange = React.useCallback((state) => {
|
|
628
462
|
var _a, _b;
|
|
@@ -735,21 +569,21 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
735
569
|
? { definition: { nodes: workflowData.nodes, edges: workflowData.edges } }
|
|
736
570
|
: undefined;
|
|
737
571
|
try {
|
|
738
|
-
await publishWorkflow({
|
|
572
|
+
const result = await publishWorkflow({
|
|
739
573
|
org: tenantKey,
|
|
740
574
|
uniqueId: workflowId,
|
|
741
575
|
data,
|
|
742
576
|
}).unwrap();
|
|
743
577
|
if (workflowData)
|
|
744
578
|
markDefinitionSaved(graphString(workflowData));
|
|
745
|
-
|
|
579
|
+
// Warnings and notices never stop publishing, so they show collapsed.
|
|
580
|
+
showValidation(result, 'collapsed');
|
|
746
581
|
sonner.toast.success(t('workflowsWorkflowEditor.workflowPublished'));
|
|
747
582
|
}
|
|
748
583
|
catch (err) {
|
|
749
584
|
const errorData = err === null || err === void 0 ? void 0 : err.data;
|
|
750
585
|
if (errorData && typeof errorData === 'object' && 'is_valid' in errorData) {
|
|
751
|
-
|
|
752
|
-
showValidation(validation, currentNodes());
|
|
586
|
+
showValidation(errorData, 'open');
|
|
753
587
|
sonner.toast.error(t('workflowsWorkflowEditor.workflowHasValidationIssues'));
|
|
754
588
|
}
|
|
755
589
|
else {
|
|
@@ -783,19 +617,18 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
783
617
|
uniqueId: workflowId,
|
|
784
618
|
}).unwrap();
|
|
785
619
|
if (result.is_valid) {
|
|
786
|
-
|
|
620
|
+
showValidation(result, 'collapsed');
|
|
787
621
|
sonner.toast.success(t('workflowsWorkflowEditor.workflowActivated'));
|
|
788
622
|
}
|
|
789
623
|
else {
|
|
790
|
-
showValidation(result,
|
|
624
|
+
showValidation(result, 'open');
|
|
791
625
|
sonner.toast.error(t('workflowsWorkflowEditor.workflowHasValidationIssues'));
|
|
792
626
|
}
|
|
793
627
|
}
|
|
794
628
|
catch (err) {
|
|
795
629
|
const errorData = err === null || err === void 0 ? void 0 : err.data;
|
|
796
630
|
if (errorData && typeof errorData === 'object' && 'is_valid' in errorData) {
|
|
797
|
-
|
|
798
|
-
showValidation(validation, currentNodes());
|
|
631
|
+
showValidation(errorData, 'open');
|
|
799
632
|
sonner.toast.error(t('workflowsWorkflowEditor.workflowHasValidationIssues'));
|
|
800
633
|
}
|
|
801
634
|
else {
|
|
@@ -874,13 +707,18 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
874
707
|
// Named from the canvas as it is now: a step deleted since the check has
|
|
875
708
|
// nothing to show, and a renamed one shows its new name.
|
|
876
709
|
const shownSteps = stepsOf(currentNodes());
|
|
877
|
-
const problemLine = ({ text, stepId
|
|
710
|
+
const problemLine = ({ text, stepId }) => {
|
|
878
711
|
var _a;
|
|
879
712
|
const step = stepId ? shownSteps.find(stepId) : undefined;
|
|
880
713
|
if (!step)
|
|
881
714
|
return jsxRuntime.jsx("span", { children: text });
|
|
882
|
-
return (jsxRuntime.jsx(actionTooltip.ActionTooltip, { label: t('workflowsWorkflowEditor.goToStep', { name: ((_a = step.data) === null || _a === void 0 ? void 0 : _a.label) || step.id }), children: jsxRuntime.jsx("button", { type: "button", "data-step-id": step.id, className: PROBLEM_LINK, onClick: () => handleShowStep(step.id
|
|
715
|
+
return (jsxRuntime.jsx(actionTooltip.ActionTooltip, { label: t('workflowsWorkflowEditor.goToStep', { name: ((_a = step.data) === null || _a === void 0 ? void 0 : _a.label) || step.id }), children: jsxRuntime.jsx("button", { type: "button", "data-step-id": step.id, className: PROBLEM_LINK, onClick: () => handleShowStep(step.id), children: text }) }));
|
|
883
716
|
};
|
|
717
|
+
// Steps nothing reaches are skipped, never refused, so a list of only them
|
|
718
|
+
// is not about warnings or errors.
|
|
719
|
+
const onlyNotices = !!validationResult &&
|
|
720
|
+
validationResult.errors.length === 0 &&
|
|
721
|
+
validationResult.warnings.length === 0;
|
|
884
722
|
canvasShownRef.current = true;
|
|
885
723
|
return (
|
|
886
724
|
// Hosts render the editor below their own top bar: a window-tall editor
|
|
@@ -923,24 +761,32 @@ function WorkflowEditor({ tenantKey, workflowId, username, axdToken, baseWsUrl,
|
|
|
923
761
|
delete: (jsxRuntime.jsxs(dropdownMenu.DropdownMenuItem, { onClick: () => setIsDeleteModalOpen(true), className: "text-red-600", children: [jsxRuntime.jsx(trash2.default, {}), t('workflowsWorkflowEditor.delete')] })),
|
|
924
762
|
};
|
|
925
763
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [menuActions.length > 0 && (jsxRuntime.jsxs(dropdownMenu.DropdownMenu, { children: [jsxRuntime.jsx(actionTooltip.ActionTooltip, { label: t('workflowsWorkflowEditor.moreOptionsLabel'), children: jsxRuntime.jsx(dropdownMenu.DropdownMenuTrigger, { asChild: true, children: jsxRuntime.jsx(button.Button, { variant: "ghost", size: "icon", className: "h-9 w-9 shrink-0 text-muted-foreground hover:text-foreground", "aria-label": t('workflowsWorkflowEditor.moreOptionsLabel'), children: jsxRuntime.jsx(ellipsis.default, {}) }) }) }), jsxRuntime.jsx(dropdownMenu.DropdownMenuContent, { align: "end", children: menuActions.map((key) => (jsxRuntime.jsx(React.Fragment, { children: menuItem[key] }, key))) })] })), inlineActions.map((key) => (jsxRuntime.jsx("div", { ref: headerFit.itemRef(key), "data-header-action": key, className: "shrink-0", children: inlineButton[key] }, key)))] }));
|
|
926
|
-
})()) })] }), validationResult &&
|
|
927
|
-
|
|
764
|
+
})()) })] }), isValidationBannerShown && validationResult && (jsxRuntime.jsx(collapsible.Collapsible, { open: isValidationBannerOpen, onOpenChange: setIsValidationBannerOpen, children: jsxRuntime.jsxs("div", { className: "border-border bg-background border-b px-4 py-2", children: [jsxRuntime.jsx(collapsible.CollapsibleTrigger, { asChild: true, children: jsxRuntime.jsxs("button", { className: "flex w-full items-center justify-between gap-2 text-sm", children: [jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 text-left", children: [jsxRuntime.jsx(listChecks.default, { className: "text-muted-foreground h-4 w-4 shrink-0" }), jsxRuntime.jsx("span", { className: "text-foreground font-medium", children: onlyNotices
|
|
765
|
+
? t('workflowsWorkflowEditor.notConnectedTitle')
|
|
766
|
+
: t('workflowsWorkflowEditor.problemsTitle') }), jsxRuntime.jsx("span", { "aria-hidden": "true", className: "text-muted-foreground", children: "\u00B7" }), jsxRuntime.jsx("span", { className: "text-muted-foreground", children: [
|
|
767
|
+
validationResult.errors.length > 0 &&
|
|
928
768
|
t('workflowsWorkflowEditor.validationErrors', {
|
|
929
769
|
count: validationResult.errors.length,
|
|
930
|
-
}),
|
|
931
|
-
|
|
932
|
-
', ', validationResult.warnings.length > 0 &&
|
|
770
|
+
}),
|
|
771
|
+
validationResult.warnings.length > 0 &&
|
|
933
772
|
t('workflowsWorkflowEditor.validationWarnings', {
|
|
934
773
|
count: validationResult.warnings.length,
|
|
935
|
-
})
|
|
774
|
+
}),
|
|
775
|
+
validationResult.notices.length > 0 &&
|
|
776
|
+
t(onlyNotices
|
|
777
|
+
? 'workflowsWorkflowEditor.notConnectedSteps'
|
|
778
|
+
: 'workflowsWorkflowEditor.validationNotices', { count: validationResult.notices.length }),
|
|
779
|
+
]
|
|
780
|
+
.filter(Boolean)
|
|
781
|
+
.join(', ') })] }), jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [isValidationBannerOpen ? (jsxRuntime.jsx(chevronUp.default, { className: "text-muted-foreground h-4 w-4" })) : (jsxRuntime.jsx(chevronDown.default, { className: "text-muted-foreground h-4 w-4" })), jsxRuntime.jsx("span", { role: "button", tabIndex: 0, className: "text-muted-foreground hover:text-foreground", onClick: (e) => {
|
|
936
782
|
e.stopPropagation();
|
|
937
|
-
|
|
783
|
+
setIsValidationBannerShown(false);
|
|
938
784
|
}, onKeyDown: (e) => {
|
|
939
785
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
940
786
|
e.stopPropagation();
|
|
941
|
-
|
|
787
|
+
setIsValidationBannerShown(false);
|
|
942
788
|
}
|
|
943
|
-
}, children: jsxRuntime.jsx(x.default, { className: "h-4 w-4" }) })] })] }) }), jsxRuntime.jsx(collapsible.CollapsibleContent, { children: jsxRuntime.jsxs("div", { "data-testid": "workflow-validation-list", className: "mt-2 max-h-40 space-y-1 overflow-y-auto pb-1", children: [validationResult.errors.map((error, i) => (jsxRuntime.jsxs("div", { className: "flex items-start gap-2 text-sm text-red-600", children: [jsxRuntime.jsx(circleAlert.default, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), problemLine(error)] }, `error-${i}`))), validationResult.warnings.map((warning, i) => (jsxRuntime.jsxs("div", { className: "flex items-start gap-2 text-sm text-amber-600", children: [jsxRuntime.jsx(triangleAlert.default, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), problemLine(warning)] }, `warning-${i}`)))] }) })] }) })), jsxRuntime.jsxs("div", { className: "flex flex-1 overflow-hidden", children: [!isPreviewMode && (jsxRuntime.jsx(workflowSidebar.WorkflowSidebar, { className: "hidden md:block", onDragStart: setDraggedItem, onItemClick: handleItemClick, nodeTypes: nodeTypeSections })), jsxRuntime.jsxs("div", { className: isPreviewMode
|
|
789
|
+
}, children: jsxRuntime.jsx(x.default, { className: "h-4 w-4" }) })] })] }) }), jsxRuntime.jsx(collapsible.CollapsibleContent, { children: jsxRuntime.jsxs("div", { "data-testid": "workflow-validation-list", className: "mt-2 max-h-40 space-y-1 overflow-y-auto pb-1", children: [validationResult.errors.map((error, i) => (jsxRuntime.jsxs("div", { "data-problem-kind": "error", className: "flex items-start gap-2 text-sm text-red-600", children: [jsxRuntime.jsx(circleAlert.default, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), problemLine(error)] }, `error-${i}`))), validationResult.warnings.map((warning, i) => (jsxRuntime.jsxs("div", { "data-problem-kind": "warning", className: "flex items-start gap-2 text-sm text-amber-600", children: [jsxRuntime.jsx(triangleAlert.default, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), problemLine(warning)] }, `warning-${i}`))), validationResult.notices.map((notice, i) => (jsxRuntime.jsxs("div", { "data-problem-kind": "notice", className: "text-muted-foreground flex items-start gap-2 text-sm", children: [jsxRuntime.jsx(info.default, { className: "mt-0.5 h-3.5 w-3.5 shrink-0" }), problemLine(notice)] }, `notice-${i}`)))] }) })] }) })), jsxRuntime.jsxs("div", { className: "flex flex-1 overflow-hidden", children: [!isPreviewMode && (jsxRuntime.jsx(workflowSidebar.WorkflowSidebar, { className: "hidden md:block", onDragStart: setDraggedItem, onItemClick: handleItemClick, nodeTypes: nodeTypeSections })), jsxRuntime.jsxs("div", { className: isPreviewMode
|
|
944
790
|
? // Kept mounted on phones so Close Preview returns to the same
|
|
945
791
|
// view and undo history.
|
|
946
792
|
'hidden h-full md:block md:w-[60%] md:border-r md:border-gray-200'
|