@memberjunction/ng-flow-editor 6.1.0-edge.1 → 6.1.0-edge.3
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/LICENSE +180 -4
- package/dist/lib/agent-editor/agent-flow-transformer.service.d.ts +31 -0
- package/dist/lib/agent-editor/agent-flow-transformer.service.d.ts.map +1 -1
- package/dist/lib/agent-editor/agent-flow-transformer.service.js +85 -22
- package/dist/lib/agent-editor/agent-flow-transformer.service.js.map +1 -1
- package/dist/lib/agent-editor/flow-agent-editor.component.d.ts +46 -1
- package/dist/lib/agent-editor/flow-agent-editor.component.d.ts.map +1 -1
- package/dist/lib/agent-editor/flow-agent-editor.component.js +160 -97
- package/dist/lib/agent-editor/flow-agent-editor.component.js.map +1 -1
- package/dist/lib/components/flow-editor.component.d.ts +53 -5
- package/dist/lib/components/flow-editor.component.d.ts.map +1 -1
- package/dist/lib/components/flow-editor.component.js +354 -177
- package/dist/lib/components/flow-editor.component.js.map +1 -1
- package/dist/lib/components/flow-node.component.d.ts +5 -0
- package/dist/lib/components/flow-node.component.d.ts.map +1 -1
- package/dist/lib/components/flow-node.component.js +79 -44
- package/dist/lib/components/flow-node.component.js.map +1 -1
- package/dist/lib/components/flow-palette.component.d.ts +22 -3
- package/dist/lib/components/flow-palette.component.d.ts.map +1 -1
- package/dist/lib/components/flow-palette.component.js +48 -23
- package/dist/lib/components/flow-palette.component.js.map +1 -1
- package/dist/lib/components/flow-toolbar.component.d.ts +3 -1
- package/dist/lib/components/flow-toolbar.component.d.ts.map +1 -1
- package/dist/lib/components/flow-toolbar.component.js +32 -4
- package/dist/lib/components/flow-toolbar.component.js.map +1 -1
- package/dist/lib/flow-editor.module.d.ts +7 -6
- package/dist/lib/flow-editor.module.d.ts.map +1 -1
- package/dist/lib/flow-editor.module.js +6 -2
- package/dist/lib/flow-editor.module.js.map +1 -1
- package/dist/lib/interfaces/flow-types.d.ts +52 -3
- package/dist/lib/interfaces/flow-types.d.ts.map +1 -1
- package/dist/lib/interfaces/flow-types.js +33 -1
- package/dist/lib/interfaces/flow-types.js.map +1 -1
- package/package.json +10 -9
package/LICENSE
CHANGED
|
@@ -1,7 +1,183 @@
|
|
|
1
|
-
|
|
1
|
+
Business Source License 1.1
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
|
@@ -59,7 +59,38 @@ export declare class AgentFlowTransformerService {
|
|
|
59
59
|
/** Convert a single MJ step entity to a FlowNode (public for direct use when adding nodes) */
|
|
60
60
|
StepToNode(step: MJAIAgentStepEntity, actions?: ActionPickerItem[], agents?: AgentPickerItem[]): FlowNode;
|
|
61
61
|
private pathToConnection;
|
|
62
|
+
/**
|
|
63
|
+
* What an edge says on the canvas, and what it says on inspection.
|
|
64
|
+
*
|
|
65
|
+
* **An edge label answers one question: WHEN is this path taken?** That is the condition. The
|
|
66
|
+
* `Description` is the author's rationale — genuinely useful, and inspection-time content: it is
|
|
67
|
+
* prose, it is arbitrarily long, and rendering it always turned the least important element on the
|
|
68
|
+
* canvas into the most visually dominant one, overlapping nodes and other labels.
|
|
69
|
+
*
|
|
70
|
+
* So the condition is the LABEL (truncated), the description is the DETAIL (the hover tooltip),
|
|
71
|
+
* and an unconditional edge says nothing at all — a plain line already means "then". That last
|
|
72
|
+
* rule removes most of the clutter on a real graph, because most edges are unconditional.
|
|
73
|
+
*/
|
|
62
74
|
private buildPathVisuals;
|
|
75
|
+
/**
|
|
76
|
+
* This path's position among its conditional siblings, in the order the dispatcher checks them.
|
|
77
|
+
*
|
|
78
|
+
* Mirrors the COMPILER, which is where the order is actually decided: `buildDependencies` sorts a
|
|
79
|
+
* fan-out by `Priority` descending, then path ID ascending, and writes that ordinal into
|
|
80
|
+
* `TaskDependency.Sequence` — which is what `ResolveExclusiveGroups` then reads at runtime. A path
|
|
81
|
+
* row has no `Sequence` of its own and deliberately never has: a compiled edge gets a fresh UUID
|
|
82
|
+
* and needs a stored ordinal to stay deterministic across machines, while a design-time path still
|
|
83
|
+
* has its own stable ID to break the tie with. Ranking here by anything else would disagree with
|
|
84
|
+
* the engine precisely on ties — and `Priority` defaults to 0, so ties are the common case.
|
|
85
|
+
*/
|
|
86
|
+
private rankWithinGroup;
|
|
87
|
+
/**
|
|
88
|
+
* Trims a condition to what fits on an edge without covering its neighbours.
|
|
89
|
+
*
|
|
90
|
+
* Breaks on a word boundary when there is one near the limit, so the visible part stays readable
|
|
91
|
+
* rather than ending mid-identifier. The full text is always in `labelDetail`.
|
|
92
|
+
*/
|
|
93
|
+
private truncateLabel;
|
|
63
94
|
/** Populate loop-specific display data on the node's Data payload */
|
|
64
95
|
private populateLoopData;
|
|
65
96
|
/** Resolve the best icon for a loop body, checking picker data first */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-flow-transformer.service.d.ts","sourceRoot":"","sources":["../../../src/lib/agent-editor/agent-flow-transformer.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAuB,kBAAkB,EAAgB,MAAM,0BAA0B,CAAC;;AAG3H,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAAE;AAE1F,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAAE;AAElH,gDAAgD;AAChD,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,EAwDvD,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-flow-transformer.service.d.ts","sourceRoot":"","sources":["../../../src/lib/agent-editor/agent-flow-transformer.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAuB,kBAAkB,EAAgB,MAAM,0BAA0B,CAAC;;AAG3H,uDAAuD;AACvD,MAAM,WAAW,gBAAgB;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAAE;AAE1F,+DAA+D;AAC/D,MAAM,WAAW,eAAe;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAAE;AAElH,gDAAgD;AAChD,eAAO,MAAM,uBAAuB,EAAE,kBAAkB,EAwDvD,CAAC;AASF;;GAEG;AACH,qBACa,2BAA2B;IAEtC,oDAAoD;IACpD,YAAY,CACV,KAAK,EAAE,mBAAmB,EAAE,EAC5B,OAAO,CAAC,EAAE,gBAAgB,EAAE,EAC5B,MAAM,CAAC,EAAE,eAAe,EAAE,GACzB,QAAQ,EAAE;IAIb,0DAA0D;IAC1D,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,EAAE,GAAG,cAAc,EAAE;IAItE,gFAAgF;IAChF,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,GAAG,MAAM;IAiBpD,4DAA4D;IAC5D,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI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O,CAAC,iBAAiB;yCA3fd,2BAA2B;6CAA3B,2BAA2B;CAggBvC"}
|
|
@@ -59,6 +59,12 @@ export const AGENT_STEP_TYPE_CONFIGS = [
|
|
|
59
59
|
]
|
|
60
60
|
}
|
|
61
61
|
];
|
|
62
|
+
/** "1st", "2nd", "3rd", … for the precedence note on an exclusive branch. */
|
|
63
|
+
function ordinal(n) {
|
|
64
|
+
const suffix = n % 100 >= 11 && n % 100 <= 13 ? 'th'
|
|
65
|
+
: ['th', 'st', 'nd', 'rd'][n % 10] ?? 'th';
|
|
66
|
+
return `${n}${suffix}`;
|
|
67
|
+
}
|
|
62
68
|
/**
|
|
63
69
|
* Transforms MJ AIAgentStep/Path entities to/from generic FlowNode/FlowConnection models.
|
|
64
70
|
*/
|
|
@@ -274,8 +280,15 @@ export class AgentFlowTransformerService {
|
|
|
274
280
|
// Multiple unconditional paths are always ambiguous because only the
|
|
275
281
|
// highest-priority one will execute — regardless of whether they have descriptions.
|
|
276
282
|
const hasAmbiguousAlways = isAlwaysPath && unconditionalSiblings.length > 1;
|
|
283
|
+
// Where this path sits in its exclusive group, when it is IN one. Highest Priority wins, ties
|
|
284
|
+
// broken by path ID — and none of that precedence is visible on the canvas today, so someone
|
|
285
|
+
// debugging a fork cannot tell which branch takes it when two conditions are both true.
|
|
286
|
+
const conditionalSiblings = siblingPaths.filter(p => p.Condition && p.Condition.trim().length > 0);
|
|
287
|
+
const rank = hasCondition && conditionalSiblings.length > 1
|
|
288
|
+
? this.rankWithinGroup(path, conditionalSiblings)
|
|
289
|
+
: null;
|
|
277
290
|
// Build label, icon, and visual style
|
|
278
|
-
const visual = this.buildPathVisuals(path, hasCondition, isOnlyPath, hasAmbiguousAlways);
|
|
291
|
+
const visual = this.buildPathVisuals(path, hasCondition, isOnlyPath, hasAmbiguousAlways, rank);
|
|
279
292
|
return {
|
|
280
293
|
ID: path.ID,
|
|
281
294
|
SourceNodeID: path.OriginStepID,
|
|
@@ -297,45 +310,95 @@ export class AgentFlowTransformerService {
|
|
|
297
310
|
}
|
|
298
311
|
};
|
|
299
312
|
}
|
|
300
|
-
|
|
301
|
-
|
|
313
|
+
/**
|
|
314
|
+
* What an edge says on the canvas, and what it says on inspection.
|
|
315
|
+
*
|
|
316
|
+
* **An edge label answers one question: WHEN is this path taken?** That is the condition. The
|
|
317
|
+
* `Description` is the author's rationale — genuinely useful, and inspection-time content: it is
|
|
318
|
+
* prose, it is arbitrarily long, and rendering it always turned the least important element on the
|
|
319
|
+
* canvas into the most visually dominant one, overlapping nodes and other labels.
|
|
320
|
+
*
|
|
321
|
+
* So the condition is the LABEL (truncated), the description is the DETAIL (the hover tooltip),
|
|
322
|
+
* and an unconditional edge says nothing at all — a plain line already means "then". That last
|
|
323
|
+
* rule removes most of the clutter on a real graph, because most edges are unconditional.
|
|
324
|
+
*/
|
|
325
|
+
buildPathVisuals(path, hasCondition, isOnlyPath, hasAmbiguousAlways, rank = null) {
|
|
326
|
+
const rationale = path.Description?.trim();
|
|
327
|
+
// Conditional path — amber dashed, labelled with the RULE.
|
|
302
328
|
if (hasCondition) {
|
|
329
|
+
const condition = path.Condition.trim();
|
|
330
|
+
// The rank prefix is tiny and always fits, so it survives truncation — which matters, because
|
|
331
|
+
// precedence is exactly what a truncated condition would otherwise hide.
|
|
332
|
+
const prefix = rank ? `${rank.position}/${rank.total} ` : '';
|
|
333
|
+
const precedence = rank
|
|
334
|
+
? `\n\nChecked ${ordinal(rank.position)} of ${rank.total}: highest priority wins, ties by path ID.`
|
|
335
|
+
: '';
|
|
303
336
|
return {
|
|
304
|
-
label:
|
|
337
|
+
label: prefix + this.truncateLabel(condition, rank ? 28 : 32),
|
|
338
|
+
labelIcon: 'fa-code-branch',
|
|
339
|
+
labelIconColor: '#f59e0b',
|
|
340
|
+
// Full condition first — a truncated label is only safe if the whole thing is one hover
|
|
341
|
+
// away — then the rationale, then how this branch is chosen against its siblings.
|
|
342
|
+
labelDetail: (rationale ? `${condition}\n\n${rationale}` : condition) + precedence,
|
|
305
343
|
color: '#f59e0b',
|
|
306
344
|
style: 'dashed'
|
|
307
345
|
};
|
|
308
346
|
}
|
|
309
|
-
//
|
|
310
|
-
|
|
311
|
-
return {
|
|
312
|
-
label: path.Description || 'Default',
|
|
313
|
-
labelIcon: 'fa-circle-check',
|
|
314
|
-
labelIconColor: '#16a34a',
|
|
315
|
-
color: '#64748b',
|
|
316
|
-
style: 'solid'
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
// Ambiguous: multiple unconditional paths from the same step
|
|
347
|
+
// Ambiguous: multiple unconditional paths from the same step. This one KEEPS its label, because
|
|
348
|
+
// it is a defect the author needs to see without hovering anything.
|
|
320
349
|
if (hasAmbiguousAlways) {
|
|
321
350
|
return {
|
|
322
|
-
label:
|
|
351
|
+
label: 'Duplicate default',
|
|
323
352
|
labelIcon: 'fa-triangle-exclamation',
|
|
324
353
|
labelIconColor: '#ef4444',
|
|
325
|
-
labelDetail:
|
|
354
|
+
labelDetail: rationale
|
|
355
|
+
? `Duplicate default paths: only the highest-priority one will execute.\n\n${rationale}`
|
|
356
|
+
: 'Duplicate default paths: only the highest-priority one will execute',
|
|
326
357
|
color: '#ef4444',
|
|
327
358
|
style: 'solid'
|
|
328
359
|
};
|
|
329
360
|
}
|
|
330
|
-
//
|
|
361
|
+
// Every other unconditional path — NO LABEL. The line already means "then", and "Default" on
|
|
362
|
+
// every edge of a linear flow is a caption on each arrow of a diagram saying "arrow".
|
|
363
|
+
// The rationale stays reachable on hover.
|
|
331
364
|
return {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
labelIconColor: '#16a34a',
|
|
335
|
-
color: '#16a34a',
|
|
365
|
+
labelDetail: rationale || undefined,
|
|
366
|
+
color: isOnlyPath ? '#64748b' : '#16a34a',
|
|
336
367
|
style: 'solid'
|
|
337
368
|
};
|
|
338
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* This path's position among its conditional siblings, in the order the dispatcher checks them.
|
|
372
|
+
*
|
|
373
|
+
* Mirrors the COMPILER, which is where the order is actually decided: `buildDependencies` sorts a
|
|
374
|
+
* fan-out by `Priority` descending, then path ID ascending, and writes that ordinal into
|
|
375
|
+
* `TaskDependency.Sequence` — which is what `ResolveExclusiveGroups` then reads at runtime. A path
|
|
376
|
+
* row has no `Sequence` of its own and deliberately never has: a compiled edge gets a fresh UUID
|
|
377
|
+
* and needs a stored ordinal to stay deterministic across machines, while a design-time path still
|
|
378
|
+
* has its own stable ID to break the tie with. Ranking here by anything else would disagree with
|
|
379
|
+
* the engine precisely on ties — and `Priority` defaults to 0, so ties are the common case.
|
|
380
|
+
*/
|
|
381
|
+
rankWithinGroup(path, siblings) {
|
|
382
|
+
const ordered = [...siblings].sort((a, b) => (b.Priority ?? 0) - (a.Priority ?? 0) || a.ID.localeCompare(b.ID));
|
|
383
|
+
return {
|
|
384
|
+
position: ordered.findIndex(p => UUIDsEqual(p.ID, path.ID)) + 1,
|
|
385
|
+
total: ordered.length
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
/**
|
|
389
|
+
* Trims a condition to what fits on an edge without covering its neighbours.
|
|
390
|
+
*
|
|
391
|
+
* Breaks on a word boundary when there is one near the limit, so the visible part stays readable
|
|
392
|
+
* rather than ending mid-identifier. The full text is always in `labelDetail`.
|
|
393
|
+
*/
|
|
394
|
+
truncateLabel(text, limit = 32) {
|
|
395
|
+
const flat = text.replace(/\s+/g, ' ').trim();
|
|
396
|
+
if (flat.length <= limit)
|
|
397
|
+
return flat;
|
|
398
|
+
const cut = flat.slice(0, limit);
|
|
399
|
+
const lastSpace = cut.lastIndexOf(' ');
|
|
400
|
+
return `${(lastSpace > limit * 0.6 ? cut.slice(0, lastSpace) : cut).trimEnd()}…`;
|
|
401
|
+
}
|
|
339
402
|
/** Populate loop-specific display data on the node's Data payload */
|
|
340
403
|
populateLoopData(step, data, actions, agents) {
|
|
341
404
|
const bodyType = step.LoopBodyType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-flow-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E,CAAC;QAClB,IAAI,SAAS,CAAC,MAAM,IAAI,MAAM;YAAE,OAAO,SAAS,CAAC;QACjD,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;IAChD,CAAC;qHA7bU,2BAA2B;gEAA3B,2BAA2B,WAA3B,2BAA2B;;iFAA3B,2BAA2B;cADvC,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\nimport { MJAIAgentStepEntity, MJAIAgentStepPathEntity } from '@memberjunction/core-entities';\nimport { FlowNode, FlowConnection, FlowConnectionStyle, FlowNodeTypeConfig, FlowNodePort } from '../interfaces/flow-types';\nimport { UUIDsEqual } from '@memberjunction/global';\n\n/** Picker item shape for Actions with optional icon */\nexport interface ActionPickerItem { ID: string; Name: string; IconClass?: string | null; }\n\n/** Picker item shape for Agents with optional icon and logo */\nexport interface AgentPickerItem { ID: string; Name: string; IconClass?: string | null; LogoURL?: string | null; }\n\n/** Step types mapped to visual configuration */\nexport const AGENT_STEP_TYPE_CONFIGS: FlowNodeTypeConfig[] = [\n {\n Type: 'Action',\n Label: 'Action',\n Icon: 'fa-bolt',\n Color: '#3B82F6',\n Category: 'Steps',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n },\n {\n Type: 'Prompt',\n Label: 'Prompt',\n Icon: 'fa-comment-dots',\n Color: '#8B5CF6',\n Category: 'Steps',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n },\n {\n Type: 'Sub-Agent',\n Label: 'Sub-Agent',\n Icon: 'fa-robot',\n Color: '#10B981',\n Category: 'Steps',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n },\n {\n Type: 'ForEach',\n Label: 'For Each',\n Icon: 'fa-arrows-repeat',\n Color: '#F59E0B',\n Category: 'Loops',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n },\n {\n Type: 'While',\n Label: 'While',\n Icon: 'fa-rotate',\n Color: '#F97316',\n Category: 'Loops',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n }\n];\n\n/**\n * Transforms MJ AIAgentStep/Path entities to/from generic FlowNode/FlowConnection models.\n */\n@Injectable()\nexport class AgentFlowTransformerService {\n\n /** Convert MJ step entities to generic FlowNodes */\n StepsToNodes(\n steps: MJAIAgentStepEntity[],\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): FlowNode[] {\n return steps.map(step => this.StepToNode(step, actions, agents));\n }\n\n /** Convert MJ path entities to generic FlowConnections */\n PathsToConnections(paths: MJAIAgentStepPathEntity[]): FlowConnection[] {\n return paths.map(path => this.pathToConnection(path, paths));\n }\n\n /** Build the subtitle for a step based on its configured action/prompt/agent */\n BuildStepSubtitle(step: MJAIAgentStepEntity): string {\n switch (step.StepType) {\n case 'Action':\n return step.Action ? `Action: ${step.Action}` : 'No action selected';\n case 'Prompt':\n return step.Prompt ? `Prompt: ${step.Prompt}` : 'No prompt selected';\n case 'Sub-Agent':\n return step.SubAgent ? `Agent: ${step.SubAgent}` : 'No sub-agent selected';\n case 'ForEach':\n return this.buildLoopSubtitle(step, 'For Each');\n case 'While':\n return this.buildLoopSubtitle(step, 'While');\n default:\n return step.StepType;\n }\n }\n\n /** Apply FlowNode position changes back to a step entity */\n ApplyNodePosition(step: MJAIAgentStepEntity, node: FlowNode): void {\n step.PositionX = Math.round(node.Position.X);\n step.PositionY = Math.round(node.Position.Y);\n if (node.Size) {\n step.Width = Math.round(node.Size.Width);\n step.Height = Math.round(node.Size.Height);\n }\n }\n\n /** Map FlowNode status from step entity status */\n MapStepStatus(stepStatus: string): FlowNode['Status'] {\n switch (stepStatus) {\n case 'Active': return 'default';\n case 'Disabled': return 'disabled';\n case 'Pending': return 'pending';\n default: return 'default';\n }\n }\n\n /**\n * Returns a short human-readable message describing what's missing,\n * or null if the step is fully configured.\n */\n BuildConfigWarningMessage(step: MJAIAgentStepEntity): string | null {\n switch (step.StepType) {\n case 'Action':\n return !step.ActionID ? 'No action selected' : null;\n case 'Prompt':\n return !step.PromptID ? 'No prompt selected' : null;\n case 'Sub-Agent':\n return !step.SubAgentID ? 'No sub-agent selected' : null;\n case 'ForEach':\n case 'While':\n return this.buildLoopWarningMessage(step);\n default:\n return null;\n }\n }\n\n private buildLoopWarningMessage(step: MJAIAgentStepEntity): string | null {\n const bodyType = step.LoopBodyType;\n if (!bodyType) return 'No loop body type selected';\n switch (bodyType) {\n case 'Action': return !step.ActionID ? 'No action selected for loop body' : null;\n case 'Prompt': return !step.PromptID ? 'No prompt selected for loop body' : null;\n case 'Sub-Agent': return !step.SubAgentID ? 'No sub-agent selected for loop body' : null;\n default: return null;\n }\n }\n\n /**\n * Returns true when a step is missing its required configuration reference\n * (e.g., an Action step with no ActionID, a Prompt step with no PromptID).\n */\n IsStepMissingConfiguration(step: MJAIAgentStepEntity): boolean {\n switch (step.StepType) {\n case 'Action':\n return !step.ActionID;\n case 'Prompt':\n return !step.PromptID;\n case 'Sub-Agent':\n return !step.SubAgentID;\n case 'ForEach':\n case 'While':\n return this.isLoopBodyMissingReference(step);\n default:\n return false;\n }\n }\n\n private isLoopBodyMissingReference(step: MJAIAgentStepEntity): boolean {\n const bodyType = step.LoopBodyType;\n if (!bodyType) return true; // No body type selected at all\n switch (bodyType) {\n case 'Action': return !step.ActionID;\n case 'Prompt': return !step.PromptID;\n case 'Sub-Agent': return !step.SubAgentID;\n default: return false;\n }\n }\n\n /**\n * Resolve the best icon and optional logo URL for a step based on its\n * configured action/agent and available picker data.\n *\n * Resolution chain:\n * - Action step: action's IconClass -> step-type fallback\n * - Sub-Agent step: agent's LogoURL (stored in Data) -> agent's IconClass -> step-type fallback\n * - Other steps: step-type icon\n */\n ResolveStepIcon(\n step: MJAIAgentStepEntity,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): { Icon: string; LogoURL?: string | null } {\n const fallbackIcon = this.getIconForType(step.StepType);\n\n if (step.StepType === 'Action' && step.ActionID && actions) {\n const action = actions.find(a => UUIDsEqual(a.ID, step.ActionID));\n return { Icon: action?.IconClass || fallbackIcon };\n }\n\n if (step.StepType === 'Sub-Agent' && step.SubAgentID && agents) {\n const agent = agents.find(a => UUIDsEqual(a.ID, step.SubAgentID));\n if (agent?.LogoURL) {\n return { Icon: agent.IconClass || fallbackIcon, LogoURL: agent.LogoURL };\n }\n return { Icon: agent?.IconClass || fallbackIcon };\n }\n\n // For loop steps, resolve based on loop body type\n if ((step.StepType === 'ForEach' || step.StepType === 'While') && step.LoopBodyType) {\n return this.resolveLoopBodyIcon(step, actions, agents);\n }\n\n return { Icon: fallbackIcon };\n }\n\n private resolveLoopBodyIcon(\n step: MJAIAgentStepEntity,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): { Icon: string; LogoURL?: string | null } {\n const fallbackIcon = this.getIconForType(step.StepType);\n\n if (step.LoopBodyType === 'Action' && step.ActionID && actions) {\n const action = actions.find(a => UUIDsEqual(a.ID, step.ActionID));\n if (action?.IconClass) return { Icon: fallbackIcon }; // Loop keeps its own icon; body icon handled separately\n }\n\n if (step.LoopBodyType === 'Sub-Agent' && step.SubAgentID && agents) {\n const agent = agents.find(a => UUIDsEqual(a.ID, step.SubAgentID));\n if (agent?.LogoURL) return { Icon: fallbackIcon, LogoURL: agent.LogoURL };\n }\n\n return { Icon: fallbackIcon };\n }\n\n // ── Public Conversion Methods ───────────────────────────────\n\n /** Convert a single MJ step entity to a FlowNode (public for direct use when adding nodes) */\n StepToNode(\n step: MJAIAgentStepEntity,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): FlowNode {\n const stepId = step.ID;\n const ports: FlowNodePort[] = [\n {\n ID: `${stepId}-input`,\n Direction: 'input',\n Side: 'top',\n Multiple: true,\n Disabled: step.StartingStep === true\n },\n {\n ID: `${stepId}-output`,\n Direction: 'output',\n Side: 'bottom',\n Multiple: true\n }\n ];\n\n // Show warning status when the step is missing its required configuration,\n // unless the step is explicitly disabled (respect the user's intent).\n const baseStatus = this.MapStepStatus(step.Status);\n const warningMessage = (baseStatus !== 'disabled') ? this.BuildConfigWarningMessage(step) : null;\n const effectiveStatus = warningMessage ? 'warning' : baseStatus;\n\n // Build loop-specific data for ForEach/While nodes\n const data: Record<string, unknown> = { StepEntityID: stepId };\n if (step.StepType === 'ForEach' || step.StepType === 'While') {\n this.populateLoopData(step, data, actions, agents);\n }\n\n // Resolve icon (and optional logo URL) from picker data\n const resolved = this.ResolveStepIcon(step, actions, agents);\n if (resolved.LogoURL) {\n data['LogoURL'] = resolved.LogoURL;\n }\n\n return {\n ID: stepId,\n Type: step.StepType,\n Label: step.Name,\n Subtitle: this.BuildStepSubtitle(step),\n Icon: resolved.Icon,\n Status: effectiveStatus,\n StatusMessage: warningMessage ?? undefined,\n IsStartNode: step.StartingStep === true,\n Position: {\n X: step.PositionX ?? 0,\n Y: step.PositionY ?? 0\n },\n Size: {\n Width: step.Width ?? 220,\n Height: step.Height ?? 100\n },\n Ports: ports,\n Data: data\n };\n }\n\n private pathToConnection(path: MJAIAgentStepPathEntity, allPaths: MJAIAgentStepPathEntity[]): FlowConnection {\n const hasCondition = path.Condition != null && path.Condition.trim().length > 0;\n const isAlwaysPath = !hasCondition;\n\n // Analyze sibling paths from the same origin step\n const siblingPaths = allPaths.filter(p => UUIDsEqual(p.OriginStepID, path.OriginStepID));\n const isOnlyPath = siblingPaths.length === 1;\n const unconditionalSiblings = siblingPaths.filter(\n p => !p.Condition || p.Condition.trim().length === 0\n );\n // Flag as ambiguous when 2+ unconditional paths exist from the same source.\n // Multiple unconditional paths are always ambiguous because only the\n // highest-priority one will execute — regardless of whether they have descriptions.\n const hasAmbiguousAlways = isAlwaysPath && unconditionalSiblings.length > 1;\n\n // Build label, icon, and visual style\n const visual = this.buildPathVisuals(path, hasCondition, isOnlyPath, hasAmbiguousAlways);\n\n return {\n ID: path.ID,\n SourceNodeID: path.OriginStepID,\n SourcePortID: `${path.OriginStepID}-output`,\n TargetNodeID: path.DestinationStepID,\n TargetPortID: `${path.DestinationStepID}-input`,\n Label: visual.label,\n LabelIcon: visual.labelIcon,\n LabelIconColor: visual.labelIconColor,\n LabelDetail: visual.labelDetail,\n Condition: path.Condition ?? undefined,\n Priority: path.Priority,\n Style: visual.style,\n Color: visual.color,\n Data: {\n PathEntityID: path.ID,\n IsAlwaysPath: !hasCondition,\n HasAmbiguousAlways: hasAmbiguousAlways\n }\n };\n }\n\n private buildPathVisuals(\n path: MJAIAgentStepPathEntity,\n hasCondition: boolean,\n isOnlyPath: boolean,\n hasAmbiguousAlways: boolean\n ): { label?: string; labelIcon?: string; labelIconColor?: string; labelDetail?: string; color: string; style: FlowConnectionStyle } {\n // Conditional path — amber dashed with condition text\n if (hasCondition) {\n return {\n label: path.Description || path.Condition!,\n color: '#f59e0b',\n style: 'dashed'\n };\n }\n\n // Sole unconditional (only exit path) — neutral dark slate with Default indicator\n if (isOnlyPath) {\n return {\n label: path.Description || 'Default',\n labelIcon: 'fa-circle-check',\n labelIconColor: '#16a34a',\n color: '#64748b',\n style: 'solid'\n };\n }\n\n // Ambiguous: multiple unconditional paths from the same step\n if (hasAmbiguousAlways) {\n return {\n label: path.Description || 'Default',\n labelIcon: 'fa-triangle-exclamation',\n labelIconColor: '#ef4444',\n labelDetail: 'Duplicate default paths: only the highest-priority one will execute',\n color: '#ef4444',\n style: 'solid'\n };\n }\n\n // Valid default path (unconditional among conditional siblings) — forest green with checkmark\n return {\n label: path.Description || 'Default',\n labelIcon: 'fa-circle-check',\n labelIconColor: '#16a34a',\n color: '#16a34a',\n style: 'solid'\n };\n }\n\n /** Populate loop-specific display data on the node's Data payload */\n private populateLoopData(\n step: MJAIAgentStepEntity,\n data: Record<string, unknown>,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): void {\n const bodyType = step.LoopBodyType;\n data['LoopBodyType'] = bodyType ?? null;\n data['LoopBodyName'] = bodyType ? this.resolveLoopBodyName(step) : null;\n data['LoopBodyIcon'] = bodyType ? this.resolveLoopBodySpecificIcon(step, actions, agents) : null;\n data['LoopBodyColor'] = bodyType ? this.getBodyTypeColor(bodyType) : null;\n data['LoopIterationSummary'] = this.BuildLoopIterationSummary(step);\n\n // Store logo URL for loop body sub-agents\n if (bodyType === 'Sub-Agent' && step.SubAgentID && agents) {\n const agent = agents.find(a => UUIDsEqual(a.ID, step.SubAgentID));\n if (agent?.LogoURL) {\n data['LoopBodyLogoURL'] = agent.LogoURL;\n }\n }\n\n const config = this.parseLoopConfig(step);\n if (config) {\n data['MaxIterations'] = config['maxIterations'] ?? null;\n data['LoopItemVariable'] = config['itemVariable'] ?? null;\n }\n }\n\n /** Resolve the best icon for a loop body, checking picker data first */\n private resolveLoopBodySpecificIcon(\n step: MJAIAgentStepEntity,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): string {\n const bodyType = step.LoopBodyType;\n const fallback = this.getBodyTypeIcon(bodyType ?? '');\n\n if (bodyType === 'Action' && step.ActionID && actions) {\n const action = actions.find(a => UUIDsEqual(a.ID, step.ActionID));\n return action?.IconClass || fallback;\n }\n if (bodyType === 'Sub-Agent' && step.SubAgentID && agents) {\n const agent = agents.find(a => UUIDsEqual(a.ID, step.SubAgentID));\n return agent?.IconClass || fallback;\n }\n return fallback;\n }\n\n /** Get icon for a loop body type */\n private getBodyTypeIcon(bodyType: string): string {\n switch (bodyType) {\n case 'Action': return 'fa-bolt';\n case 'Prompt': return 'fa-comment-dots';\n case 'Sub-Agent': return 'fa-robot';\n default: return 'fa-circle-nodes';\n }\n }\n\n /** Get color for a loop body type */\n private getBodyTypeColor(bodyType: string): string {\n switch (bodyType) {\n case 'Action': return '#3B82F6';\n case 'Prompt': return '#8B5CF6';\n case 'Sub-Agent': return '#10B981';\n default: return '#6B7280';\n }\n }\n\n private getIconForType(stepType: string): string {\n const config = AGENT_STEP_TYPE_CONFIGS.find(c => c.Type === stepType);\n return config?.Icon ?? 'fa-circle-nodes';\n }\n\n private buildLoopSubtitle(step: MJAIAgentStepEntity, prefix: string): string {\n const bodyType = step.LoopBodyType;\n if (!bodyType) return `${prefix} (no body type)`;\n const bodyName = this.resolveLoopBodyName(step);\n return bodyName ? `${prefix} → ${bodyName}` : `${prefix} → ${bodyType}`;\n }\n\n /** Resolve the display name for the loop body operation */\n private resolveLoopBodyName(step: MJAIAgentStepEntity): string | null {\n switch (step.LoopBodyType) {\n case 'Action': return step.Action ?? null;\n case 'Prompt': return step.Prompt ?? null;\n case 'Sub-Agent': return step.SubAgent ?? null;\n default: return null;\n }\n }\n\n /** Parse the Configuration JSON, returning null on failure */\n private parseLoopConfig(step: MJAIAgentStepEntity): Record<string, unknown> | null {\n if (!step.Configuration) return null;\n try {\n return JSON.parse(step.Configuration) as Record<string, unknown>;\n } catch {\n return null;\n }\n }\n\n /** Build a short iteration summary for display on loop nodes */\n BuildLoopIterationSummary(step: MJAIAgentStepEntity): string {\n const config = this.parseLoopConfig(step);\n if (step.StepType === 'ForEach') {\n const collection = config?.['collectionPath'] as string | undefined;\n return collection ? `over ${collection}` : 'over collection';\n }\n if (step.StepType === 'While') {\n const condition = config?.['condition'] as string | undefined;\n return condition ? `while ${this.truncateCondition(condition)}` : 'while condition';\n }\n return '';\n }\n\n private truncateCondition(condition: string): string {\n const maxLen = 30;\n if (condition.length <= maxLen) return condition;\n return condition.substring(0, maxLen) + '...';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"agent-flow-transformer.service.js","sourceRoot":"","sources":["../../../src/lib/agent-editor/agent-flow-transformer.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MA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SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;IAChD,CAAC;qHA/fU,2BAA2B;gEAA3B,2BAA2B,WAA3B,2BAA2B;;iFAA3B,2BAA2B;cADvC,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\nimport { MJAIAgentStepEntity, MJAIAgentStepPathEntity } from '@memberjunction/core-entities';\nimport { FlowNode, FlowConnection, FlowConnectionStyle, FlowNodeTypeConfig, FlowNodePort } from '../interfaces/flow-types';\nimport { UUIDsEqual } from '@memberjunction/global';\n\n/** Picker item shape for Actions with optional icon */\nexport interface ActionPickerItem { ID: string; Name: string; IconClass?: string | null; }\n\n/** Picker item shape for Agents with optional icon and logo */\nexport interface AgentPickerItem { ID: string; Name: string; IconClass?: string | null; LogoURL?: string | null; }\n\n/** Step types mapped to visual configuration */\nexport const AGENT_STEP_TYPE_CONFIGS: FlowNodeTypeConfig[] = [\n {\n Type: 'Action',\n Label: 'Action',\n Icon: 'fa-bolt',\n Color: '#3B82F6',\n Category: 'Steps',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n },\n {\n Type: 'Prompt',\n Label: 'Prompt',\n Icon: 'fa-comment-dots',\n Color: '#8B5CF6',\n Category: 'Steps',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n },\n {\n Type: 'Sub-Agent',\n Label: 'Sub-Agent',\n Icon: 'fa-robot',\n Color: '#10B981',\n Category: 'Steps',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n },\n {\n Type: 'ForEach',\n Label: 'For Each',\n Icon: 'fa-arrows-repeat',\n Color: '#F59E0B',\n Category: 'Loops',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n },\n {\n Type: 'While',\n Label: 'While',\n Icon: 'fa-rotate',\n Color: '#F97316',\n Category: 'Loops',\n DefaultPorts: [\n { ID: 'input', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'output', Direction: 'output', Side: 'bottom', Multiple: true }\n ]\n }\n];\n\n/** \"1st\", \"2nd\", \"3rd\", … for the precedence note on an exclusive branch. */\nfunction ordinal(n: number): string {\n const suffix = n % 100 >= 11 && n % 100 <= 13 ? 'th'\n : ['th', 'st', 'nd', 'rd'][n % 10] ?? 'th';\n return `${n}${suffix}`;\n}\n\n/**\n * Transforms MJ AIAgentStep/Path entities to/from generic FlowNode/FlowConnection models.\n */\n@Injectable()\nexport class AgentFlowTransformerService {\n\n /** Convert MJ step entities to generic FlowNodes */\n StepsToNodes(\n steps: MJAIAgentStepEntity[],\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): FlowNode[] {\n return steps.map(step => this.StepToNode(step, actions, agents));\n }\n\n /** Convert MJ path entities to generic FlowConnections */\n PathsToConnections(paths: MJAIAgentStepPathEntity[]): FlowConnection[] {\n return paths.map(path => this.pathToConnection(path, paths));\n }\n\n /** Build the subtitle for a step based on its configured action/prompt/agent */\n BuildStepSubtitle(step: MJAIAgentStepEntity): string {\n switch (step.StepType) {\n case 'Action':\n return step.Action ? `Action: ${step.Action}` : 'No action selected';\n case 'Prompt':\n return step.Prompt ? `Prompt: ${step.Prompt}` : 'No prompt selected';\n case 'Sub-Agent':\n return step.SubAgent ? `Agent: ${step.SubAgent}` : 'No sub-agent selected';\n case 'ForEach':\n return this.buildLoopSubtitle(step, 'For Each');\n case 'While':\n return this.buildLoopSubtitle(step, 'While');\n default:\n return step.StepType;\n }\n }\n\n /** Apply FlowNode position changes back to a step entity */\n ApplyNodePosition(step: MJAIAgentStepEntity, node: FlowNode): void {\n step.PositionX = Math.round(node.Position.X);\n step.PositionY = Math.round(node.Position.Y);\n if (node.Size) {\n step.Width = Math.round(node.Size.Width);\n step.Height = Math.round(node.Size.Height);\n }\n }\n\n /** Map FlowNode status from step entity status */\n MapStepStatus(stepStatus: string): FlowNode['Status'] {\n switch (stepStatus) {\n case 'Active': return 'default';\n case 'Disabled': return 'disabled';\n case 'Pending': return 'pending';\n default: return 'default';\n }\n }\n\n /**\n * Returns a short human-readable message describing what's missing,\n * or null if the step is fully configured.\n */\n BuildConfigWarningMessage(step: MJAIAgentStepEntity): string | null {\n switch (step.StepType) {\n case 'Action':\n return !step.ActionID ? 'No action selected' : null;\n case 'Prompt':\n return !step.PromptID ? 'No prompt selected' : null;\n case 'Sub-Agent':\n return !step.SubAgentID ? 'No sub-agent selected' : null;\n case 'ForEach':\n case 'While':\n return this.buildLoopWarningMessage(step);\n default:\n return null;\n }\n }\n\n private buildLoopWarningMessage(step: MJAIAgentStepEntity): string | null {\n const bodyType = step.LoopBodyType;\n if (!bodyType) return 'No loop body type selected';\n switch (bodyType) {\n case 'Action': return !step.ActionID ? 'No action selected for loop body' : null;\n case 'Prompt': return !step.PromptID ? 'No prompt selected for loop body' : null;\n case 'Sub-Agent': return !step.SubAgentID ? 'No sub-agent selected for loop body' : null;\n default: return null;\n }\n }\n\n /**\n * Returns true when a step is missing its required configuration reference\n * (e.g., an Action step with no ActionID, a Prompt step with no PromptID).\n */\n IsStepMissingConfiguration(step: MJAIAgentStepEntity): boolean {\n switch (step.StepType) {\n case 'Action':\n return !step.ActionID;\n case 'Prompt':\n return !step.PromptID;\n case 'Sub-Agent':\n return !step.SubAgentID;\n case 'ForEach':\n case 'While':\n return this.isLoopBodyMissingReference(step);\n default:\n return false;\n }\n }\n\n private isLoopBodyMissingReference(step: MJAIAgentStepEntity): boolean {\n const bodyType = step.LoopBodyType;\n if (!bodyType) return true; // No body type selected at all\n switch (bodyType) {\n case 'Action': return !step.ActionID;\n case 'Prompt': return !step.PromptID;\n case 'Sub-Agent': return !step.SubAgentID;\n default: return false;\n }\n }\n\n /**\n * Resolve the best icon and optional logo URL for a step based on its\n * configured action/agent and available picker data.\n *\n * Resolution chain:\n * - Action step: action's IconClass -> step-type fallback\n * - Sub-Agent step: agent's LogoURL (stored in Data) -> agent's IconClass -> step-type fallback\n * - Other steps: step-type icon\n */\n ResolveStepIcon(\n step: MJAIAgentStepEntity,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): { Icon: string; LogoURL?: string | null } {\n const fallbackIcon = this.getIconForType(step.StepType);\n\n if (step.StepType === 'Action' && step.ActionID && actions) {\n const action = actions.find(a => UUIDsEqual(a.ID, step.ActionID));\n return { Icon: action?.IconClass || fallbackIcon };\n }\n\n if (step.StepType === 'Sub-Agent' && step.SubAgentID && agents) {\n const agent = agents.find(a => UUIDsEqual(a.ID, step.SubAgentID));\n if (agent?.LogoURL) {\n return { Icon: agent.IconClass || fallbackIcon, LogoURL: agent.LogoURL };\n }\n return { Icon: agent?.IconClass || fallbackIcon };\n }\n\n // For loop steps, resolve based on loop body type\n if ((step.StepType === 'ForEach' || step.StepType === 'While') && step.LoopBodyType) {\n return this.resolveLoopBodyIcon(step, actions, agents);\n }\n\n return { Icon: fallbackIcon };\n }\n\n private resolveLoopBodyIcon(\n step: MJAIAgentStepEntity,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): { Icon: string; LogoURL?: string | null } {\n const fallbackIcon = this.getIconForType(step.StepType);\n\n if (step.LoopBodyType === 'Action' && step.ActionID && actions) {\n const action = actions.find(a => UUIDsEqual(a.ID, step.ActionID));\n if (action?.IconClass) return { Icon: fallbackIcon }; // Loop keeps its own icon; body icon handled separately\n }\n\n if (step.LoopBodyType === 'Sub-Agent' && step.SubAgentID && agents) {\n const agent = agents.find(a => UUIDsEqual(a.ID, step.SubAgentID));\n if (agent?.LogoURL) return { Icon: fallbackIcon, LogoURL: agent.LogoURL };\n }\n\n return { Icon: fallbackIcon };\n }\n\n // ── Public Conversion Methods ───────────────────────────────\n\n /** Convert a single MJ step entity to a FlowNode (public for direct use when adding nodes) */\n StepToNode(\n step: MJAIAgentStepEntity,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): FlowNode {\n const stepId = step.ID;\n const ports: FlowNodePort[] = [\n {\n ID: `${stepId}-input`,\n Direction: 'input',\n Side: 'top',\n Multiple: true,\n Disabled: step.StartingStep === true\n },\n {\n ID: `${stepId}-output`,\n Direction: 'output',\n Side: 'bottom',\n Multiple: true\n }\n ];\n\n // Show warning status when the step is missing its required configuration,\n // unless the step is explicitly disabled (respect the user's intent).\n const baseStatus = this.MapStepStatus(step.Status);\n const warningMessage = (baseStatus !== 'disabled') ? this.BuildConfigWarningMessage(step) : null;\n const effectiveStatus = warningMessage ? 'warning' : baseStatus;\n\n // Build loop-specific data for ForEach/While nodes\n const data: Record<string, unknown> = { StepEntityID: stepId };\n if (step.StepType === 'ForEach' || step.StepType === 'While') {\n this.populateLoopData(step, data, actions, agents);\n }\n\n // Resolve icon (and optional logo URL) from picker data\n const resolved = this.ResolveStepIcon(step, actions, agents);\n if (resolved.LogoURL) {\n data['LogoURL'] = resolved.LogoURL;\n }\n\n return {\n ID: stepId,\n Type: step.StepType,\n Label: step.Name,\n Subtitle: this.BuildStepSubtitle(step),\n Icon: resolved.Icon,\n Status: effectiveStatus,\n StatusMessage: warningMessage ?? undefined,\n IsStartNode: step.StartingStep === true,\n Position: {\n X: step.PositionX ?? 0,\n Y: step.PositionY ?? 0\n },\n Size: {\n Width: step.Width ?? 220,\n Height: step.Height ?? 100\n },\n Ports: ports,\n Data: data\n };\n }\n\n private pathToConnection(path: MJAIAgentStepPathEntity, allPaths: MJAIAgentStepPathEntity[]): FlowConnection {\n const hasCondition = path.Condition != null && path.Condition.trim().length > 0;\n const isAlwaysPath = !hasCondition;\n\n // Analyze sibling paths from the same origin step\n const siblingPaths = allPaths.filter(p => UUIDsEqual(p.OriginStepID, path.OriginStepID));\n const isOnlyPath = siblingPaths.length === 1;\n const unconditionalSiblings = siblingPaths.filter(\n p => !p.Condition || p.Condition.trim().length === 0\n );\n // Flag as ambiguous when 2+ unconditional paths exist from the same source.\n // Multiple unconditional paths are always ambiguous because only the\n // highest-priority one will execute — regardless of whether they have descriptions.\n const hasAmbiguousAlways = isAlwaysPath && unconditionalSiblings.length > 1;\n\n // Where this path sits in its exclusive group, when it is IN one. Highest Priority wins, ties\n // broken by path ID — and none of that precedence is visible on the canvas today, so someone\n // debugging a fork cannot tell which branch takes it when two conditions are both true.\n const conditionalSiblings = siblingPaths.filter(p => p.Condition && p.Condition.trim().length > 0);\n const rank = hasCondition && conditionalSiblings.length > 1\n ? this.rankWithinGroup(path, conditionalSiblings)\n : null;\n\n // Build label, icon, and visual style\n const visual = this.buildPathVisuals(path, hasCondition, isOnlyPath, hasAmbiguousAlways, rank);\n\n return {\n ID: path.ID,\n SourceNodeID: path.OriginStepID,\n SourcePortID: `${path.OriginStepID}-output`,\n TargetNodeID: path.DestinationStepID,\n TargetPortID: `${path.DestinationStepID}-input`,\n Label: visual.label,\n LabelIcon: visual.labelIcon,\n LabelIconColor: visual.labelIconColor,\n LabelDetail: visual.labelDetail,\n Condition: path.Condition ?? undefined,\n Priority: path.Priority,\n Style: visual.style,\n Color: visual.color,\n Data: {\n PathEntityID: path.ID,\n IsAlwaysPath: !hasCondition,\n HasAmbiguousAlways: hasAmbiguousAlways\n }\n };\n }\n\n /**\n * What an edge says on the canvas, and what it says on inspection.\n *\n * **An edge label answers one question: WHEN is this path taken?** That is the condition. The\n * `Description` is the author's rationale — genuinely useful, and inspection-time content: it is\n * prose, it is arbitrarily long, and rendering it always turned the least important element on the\n * canvas into the most visually dominant one, overlapping nodes and other labels.\n *\n * So the condition is the LABEL (truncated), the description is the DETAIL (the hover tooltip),\n * and an unconditional edge says nothing at all — a plain line already means \"then\". That last\n * rule removes most of the clutter on a real graph, because most edges are unconditional.\n */\n private buildPathVisuals(\n path: MJAIAgentStepPathEntity,\n hasCondition: boolean,\n isOnlyPath: boolean,\n hasAmbiguousAlways: boolean,\n rank: { position: number; total: number } | null = null\n ): { label?: string; labelIcon?: string; labelIconColor?: string; labelDetail?: string; color: string; style: FlowConnectionStyle } {\n const rationale = path.Description?.trim();\n\n // Conditional path — amber dashed, labelled with the RULE.\n if (hasCondition) {\n const condition = path.Condition!.trim();\n // The rank prefix is tiny and always fits, so it survives truncation — which matters, because\n // precedence is exactly what a truncated condition would otherwise hide.\n const prefix = rank ? `${rank.position}/${rank.total} ` : '';\n const precedence = rank\n ? `\\n\\nChecked ${ordinal(rank.position)} of ${rank.total}: highest priority wins, ties by path ID.`\n : '';\n return {\n label: prefix + this.truncateLabel(condition, rank ? 28 : 32),\n labelIcon: 'fa-code-branch',\n labelIconColor: '#f59e0b',\n // Full condition first — a truncated label is only safe if the whole thing is one hover\n // away — then the rationale, then how this branch is chosen against its siblings.\n labelDetail: (rationale ? `${condition}\\n\\n${rationale}` : condition) + precedence,\n color: '#f59e0b',\n style: 'dashed'\n };\n }\n\n // Ambiguous: multiple unconditional paths from the same step. This one KEEPS its label, because\n // it is a defect the author needs to see without hovering anything.\n if (hasAmbiguousAlways) {\n return {\n label: 'Duplicate default',\n labelIcon: 'fa-triangle-exclamation',\n labelIconColor: '#ef4444',\n labelDetail: rationale\n ? `Duplicate default paths: only the highest-priority one will execute.\\n\\n${rationale}`\n : 'Duplicate default paths: only the highest-priority one will execute',\n color: '#ef4444',\n style: 'solid'\n };\n }\n\n // Every other unconditional path — NO LABEL. The line already means \"then\", and \"Default\" on\n // every edge of a linear flow is a caption on each arrow of a diagram saying \"arrow\".\n // The rationale stays reachable on hover.\n return {\n labelDetail: rationale || undefined,\n color: isOnlyPath ? '#64748b' : '#16a34a',\n style: 'solid'\n };\n }\n\n /**\n * This path's position among its conditional siblings, in the order the dispatcher checks them.\n *\n * Mirrors the COMPILER, which is where the order is actually decided: `buildDependencies` sorts a\n * fan-out by `Priority` descending, then path ID ascending, and writes that ordinal into\n * `TaskDependency.Sequence` — which is what `ResolveExclusiveGroups` then reads at runtime. A path\n * row has no `Sequence` of its own and deliberately never has: a compiled edge gets a fresh UUID\n * and needs a stored ordinal to stay deterministic across machines, while a design-time path still\n * has its own stable ID to break the tie with. Ranking here by anything else would disagree with\n * the engine precisely on ties — and `Priority` defaults to 0, so ties are the common case.\n */\n private rankWithinGroup(\n path: MJAIAgentStepPathEntity,\n siblings: MJAIAgentStepPathEntity[]\n ): { position: number; total: number } {\n const ordered = [...siblings].sort((a, b) =>\n (b.Priority ?? 0) - (a.Priority ?? 0) || a.ID.localeCompare(b.ID)\n );\n return {\n position: ordered.findIndex(p => UUIDsEqual(p.ID, path.ID)) + 1,\n total: ordered.length\n };\n }\n\n /**\n * Trims a condition to what fits on an edge without covering its neighbours.\n *\n * Breaks on a word boundary when there is one near the limit, so the visible part stays readable\n * rather than ending mid-identifier. The full text is always in `labelDetail`.\n */\n private truncateLabel(text: string, limit = 32): string {\n const flat = text.replace(/\\s+/g, ' ').trim();\n if (flat.length <= limit) return flat;\n\n const cut = flat.slice(0, limit);\n const lastSpace = cut.lastIndexOf(' ');\n return `${(lastSpace > limit * 0.6 ? cut.slice(0, lastSpace) : cut).trimEnd()}…`;\n }\n\n /** Populate loop-specific display data on the node's Data payload */\n private populateLoopData(\n step: MJAIAgentStepEntity,\n data: Record<string, unknown>,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): void {\n const bodyType = step.LoopBodyType;\n data['LoopBodyType'] = bodyType ?? null;\n data['LoopBodyName'] = bodyType ? this.resolveLoopBodyName(step) : null;\n data['LoopBodyIcon'] = bodyType ? this.resolveLoopBodySpecificIcon(step, actions, agents) : null;\n data['LoopBodyColor'] = bodyType ? this.getBodyTypeColor(bodyType) : null;\n data['LoopIterationSummary'] = this.BuildLoopIterationSummary(step);\n\n // Store logo URL for loop body sub-agents\n if (bodyType === 'Sub-Agent' && step.SubAgentID && agents) {\n const agent = agents.find(a => UUIDsEqual(a.ID, step.SubAgentID));\n if (agent?.LogoURL) {\n data['LoopBodyLogoURL'] = agent.LogoURL;\n }\n }\n\n const config = this.parseLoopConfig(step);\n if (config) {\n data['MaxIterations'] = config['maxIterations'] ?? null;\n data['LoopItemVariable'] = config['itemVariable'] ?? null;\n }\n }\n\n /** Resolve the best icon for a loop body, checking picker data first */\n private resolveLoopBodySpecificIcon(\n step: MJAIAgentStepEntity,\n actions?: ActionPickerItem[],\n agents?: AgentPickerItem[]\n ): string {\n const bodyType = step.LoopBodyType;\n const fallback = this.getBodyTypeIcon(bodyType ?? '');\n\n if (bodyType === 'Action' && step.ActionID && actions) {\n const action = actions.find(a => UUIDsEqual(a.ID, step.ActionID));\n return action?.IconClass || fallback;\n }\n if (bodyType === 'Sub-Agent' && step.SubAgentID && agents) {\n const agent = agents.find(a => UUIDsEqual(a.ID, step.SubAgentID));\n return agent?.IconClass || fallback;\n }\n return fallback;\n }\n\n /** Get icon for a loop body type */\n private getBodyTypeIcon(bodyType: string): string {\n switch (bodyType) {\n case 'Action': return 'fa-bolt';\n case 'Prompt': return 'fa-comment-dots';\n case 'Sub-Agent': return 'fa-robot';\n default: return 'fa-circle-nodes';\n }\n }\n\n /** Get color for a loop body type */\n private getBodyTypeColor(bodyType: string): string {\n switch (bodyType) {\n case 'Action': return '#3B82F6';\n case 'Prompt': return '#8B5CF6';\n case 'Sub-Agent': return '#10B981';\n default: return '#6B7280';\n }\n }\n\n private getIconForType(stepType: string): string {\n const config = AGENT_STEP_TYPE_CONFIGS.find(c => c.Type === stepType);\n return config?.Icon ?? 'fa-circle-nodes';\n }\n\n private buildLoopSubtitle(step: MJAIAgentStepEntity, prefix: string): string {\n const bodyType = step.LoopBodyType;\n if (!bodyType) return `${prefix} (no body type)`;\n const bodyName = this.resolveLoopBodyName(step);\n return bodyName ? `${prefix} → ${bodyName}` : `${prefix} → ${bodyType}`;\n }\n\n /** Resolve the display name for the loop body operation */\n private resolveLoopBodyName(step: MJAIAgentStepEntity): string | null {\n switch (step.LoopBodyType) {\n case 'Action': return step.Action ?? null;\n case 'Prompt': return step.Prompt ?? null;\n case 'Sub-Agent': return step.SubAgent ?? null;\n default: return null;\n }\n }\n\n /** Parse the Configuration JSON, returning null on failure */\n private parseLoopConfig(step: MJAIAgentStepEntity): Record<string, unknown> | null {\n if (!step.Configuration) return null;\n try {\n return JSON.parse(step.Configuration) as Record<string, unknown>;\n } catch {\n return null;\n }\n }\n\n /** Build a short iteration summary for display on loop nodes */\n BuildLoopIterationSummary(step: MJAIAgentStepEntity): string {\n const config = this.parseLoopConfig(step);\n if (step.StepType === 'ForEach') {\n const collection = config?.['collectionPath'] as string | undefined;\n return collection ? `over ${collection}` : 'over collection';\n }\n if (step.StepType === 'While') {\n const condition = config?.['condition'] as string | undefined;\n return condition ? `while ${this.truncateCondition(condition)}` : 'while condition';\n }\n return '';\n }\n\n private truncateCondition(condition: string): string {\n const maxLen = 30;\n if (condition.length <= maxLen) return condition;\n return condition.substring(0, maxLen) + '...';\n }\n}\n"]}
|