@memberjunction/ng-task-graph-editor 6.1.0-edge.2 → 6.1.0-edge.4
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/README.md +197 -0
- package/dist/lib/debug-variables.d.ts +27 -0
- package/dist/lib/debug-variables.d.ts.map +1 -0
- package/dist/lib/debug-variables.js +96 -0
- package/dist/lib/debug-variables.js.map +1 -0
- package/dist/lib/pane-split.d.ts +11 -0
- package/dist/lib/pane-split.d.ts.map +1 -0
- package/dist/lib/pane-split.js +36 -0
- package/dist/lib/pane-split.js.map +1 -0
- package/dist/lib/task-graph-canvas-adapter.d.ts +41 -3
- package/dist/lib/task-graph-canvas-adapter.d.ts.map +1 -1
- package/dist/lib/task-graph-canvas-adapter.js +175 -36
- package/dist/lib/task-graph-canvas-adapter.js.map +1 -1
- package/dist/lib/task-graph-debug-toolbar.component.d.ts +27 -0
- package/dist/lib/task-graph-debug-toolbar.component.d.ts.map +1 -0
- package/dist/lib/task-graph-debug-toolbar.component.js +153 -0
- package/dist/lib/task-graph-debug-toolbar.component.js.map +1 -0
- package/dist/lib/task-graph-debugger.component.d.ts +96 -0
- package/dist/lib/task-graph-debugger.component.d.ts.map +1 -0
- package/dist/lib/task-graph-debugger.component.js +371 -0
- package/dist/lib/task-graph-debugger.component.js.map +1 -0
- package/dist/lib/task-graph-editor.component.d.ts +40 -3
- package/dist/lib/task-graph-editor.component.d.ts.map +1 -1
- package/dist/lib/task-graph-editor.component.js +83 -10
- package/dist/lib/task-graph-editor.component.js.map +1 -1
- package/dist/lib/task-graph-editor.module.d.ts +9 -5
- package/dist/lib/task-graph-editor.module.d.ts.map +1 -1
- package/dist/lib/task-graph-editor.module.js +52 -5
- package/dist/lib/task-graph-editor.module.js.map +1 -1
- package/dist/lib/task-graph-run-prefs.d.ts +34 -0
- package/dist/lib/task-graph-run-prefs.d.ts.map +1 -0
- package/dist/lib/task-graph-run-prefs.js +67 -0
- package/dist/lib/task-graph-run-prefs.js.map +1 -0
- package/dist/lib/task-graph-run-view.component.d.ts +180 -3
- package/dist/lib/task-graph-run-view.component.d.ts.map +1 -1
- package/dist/lib/task-graph-run-view.component.js +560 -23
- package/dist/lib/task-graph-run-view.component.js.map +1 -1
- package/dist/lib/task-graph-runtime-source.d.ts +7 -1
- package/dist/lib/task-graph-runtime-source.d.ts.map +1 -1
- package/dist/lib/task-graph-runtime-source.js +14 -2
- package/dist/lib/task-graph-runtime-source.js.map +1 -1
- package/dist/lib/task-graph-variables.component.d.ts +23 -0
- package/dist/lib/task-graph-variables.component.d.ts.map +1 -0
- package/dist/lib/task-graph-variables.component.js +192 -0
- package/dist/lib/task-graph-variables.component.js.map +1 -0
- package/dist/lib/workflow-debug-host.d.ts +23 -0
- package/dist/lib/workflow-debug-host.d.ts.map +1 -0
- package/dist/lib/workflow-debug-host.js +101 -0
- package/dist/lib/workflow-debug-host.js.map +1 -0
- package/dist/public-api.d.ts +7 -0
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +7 -0
- package/dist/public-api.js.map +1 -1
- package/package.json +11 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-graph-canvas-adapter.d.ts","sourceRoot":"","sources":["../../src/lib/task-graph-canvas-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAKH,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEjI;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,YAAY,GAAG,WAAW,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG,YAAY,GAAG,aAAa,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-cor
|
|
|
26
26
|
export function IsAuthorableNodeType(type) {
|
|
27
27
|
return type === 'AgentTask' || type === 'ActionTask' || type === 'HumanTask';
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Port ids are scoped to their NODE, and must be.
|
|
31
|
+
*
|
|
32
|
+
* The canvas resolves a connection by looking its `fOutputId` / `fInputId` up among all registered
|
|
33
|
+
* ports — a flat, graph-wide namespace. Giving every node ports literally called `in` and `out` made
|
|
34
|
+
* every node's ports collide with every other node's, so a connection could not name which node's
|
|
35
|
+
* port it meant. The result was a workflow that drew its boxes correctly and **no edges at all**:
|
|
36
|
+
* nothing errored, because an unresolvable port is simply a connection with nowhere to attach.
|
|
37
|
+
*
|
|
38
|
+
* The Flow Agent editor — the other consumer of this canvas, whose edges have always drawn — scopes
|
|
39
|
+
* its ports the same way (`${stepId}-input` / `${stepId}-output`). This is that convention, named,
|
|
40
|
+
* so a future producer cannot reintroduce the collision by writing the obvious literal.
|
|
41
|
+
*/
|
|
42
|
+
export function InputPortID(tempId) {
|
|
43
|
+
return `${tempId}-in`;
|
|
44
|
+
}
|
|
45
|
+
export function OutputPortID(tempId) {
|
|
46
|
+
return `${tempId}-out`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Palette defaults. These carry the bare names because a palette entry describes a node TYPE, not a
|
|
50
|
+
* placed node — there is no id to scope them to yet. {@link SpecToNodes} assigns the real, scoped
|
|
51
|
+
* ids when a node is actually placed on the canvas.
|
|
52
|
+
*/
|
|
29
53
|
const TASK_GRAPH_PORTS = [
|
|
30
54
|
{ ID: 'in', Direction: 'input', Side: 'top', Multiple: true },
|
|
31
55
|
{ ID: 'out', Direction: 'output', Side: 'bottom', Multiple: true },
|
|
@@ -94,6 +118,10 @@ export function RuntimeStateToNodeStatus(state) {
|
|
|
94
118
|
case 'Failed': return 'error';
|
|
95
119
|
case 'Blocked': return 'warning';
|
|
96
120
|
case 'Cancelled': return 'disabled';
|
|
121
|
+
// Its own state, not a shade of disabled: a branch the workflow did not take is a normal
|
|
122
|
+
// outcome. Falling through to 'default' — which is what happened before — drew it as an
|
|
123
|
+
// ordinary node, so a conditional workflow looked like it had run every branch.
|
|
124
|
+
case 'Skipped': return 'skipped';
|
|
97
125
|
case 'Deferred': return 'pending';
|
|
98
126
|
case 'Pending': return 'pending';
|
|
99
127
|
default: return 'default';
|
|
@@ -181,45 +209,58 @@ export function GetDependents(spec, tempId) {
|
|
|
181
209
|
function edgeId(fromTempId, toTempId) {
|
|
182
210
|
return `${fromTempId}->${toTempId}`;
|
|
183
211
|
}
|
|
184
|
-
|
|
185
|
-
* Projects the spec onto canvas nodes.
|
|
186
|
-
*
|
|
187
|
-
* Positions are left at the origin: layout is the canvas's job (Dagre), and a spec carries no
|
|
188
|
-
* geometry precisely because a task graph is a *logical* structure. An agent that emitted one never
|
|
189
|
-
* had an opinion about where the boxes go.
|
|
190
|
-
*/
|
|
191
|
-
/**
|
|
192
|
-
* Projects the spec onto canvas nodes.
|
|
193
|
-
*
|
|
194
|
-
* `positions` carries geometry the spec cannot hold. `TaskGraphSpec` is an execution contract with
|
|
195
|
-
* no layout field, so without a caller-held map every re-projection would return every node to the
|
|
196
|
-
* origin — which is what previously forced a full re-arrange (and a viewport re-zoom) after every
|
|
197
|
-
* single edit. Unknown ids fall back to the origin, which is also the correct starting state for a
|
|
198
|
-
* graph that has never been laid out.
|
|
199
|
-
*/
|
|
200
|
-
export function SpecToNodes(spec, runtime, positions) {
|
|
212
|
+
export function SpecToNodes(spec, runtime, positions, debug) {
|
|
201
213
|
const entryIds = new Set(GetEntryTempIds(spec));
|
|
214
|
+
const breakpoints = new Set(debug?.breakpoints ?? []);
|
|
202
215
|
return (spec.tasks ?? []).map((task) => {
|
|
203
216
|
const type = GetTaskNodeType(task);
|
|
204
217
|
const known = positions?.get(task.tempId);
|
|
218
|
+
const awaiting = isAwaitingUser(task.tempId, entryIds, runtime, debug);
|
|
219
|
+
const nextToRun = isNextToRun(task, runtime, debug, entryIds);
|
|
220
|
+
const running = runtime?.[task.tempId] === 'In Progress';
|
|
205
221
|
return {
|
|
206
222
|
ID: task.tempId,
|
|
207
223
|
Type: type,
|
|
208
224
|
Label: task.name,
|
|
209
225
|
Subtitle: TaskSubtitle(task, type),
|
|
210
226
|
Icon: GetNodeTypeConfig(type)?.Icon ?? 'fa-circle-nodes',
|
|
227
|
+
IconColor: awaiting || nextToRun || running ? 'var(--mj-brand-primary)' : undefined,
|
|
228
|
+
// Keep the real runtime status. Mapping "paused here" to `running` drew a spinner
|
|
229
|
+
// on a step that is waiting for the operator — it read as "this is executing".
|
|
211
230
|
Status: RuntimeStateToNodeStatus(runtime?.[task.tempId]),
|
|
212
231
|
StatusMessage: task.description,
|
|
213
232
|
IsStartNode: entryIds.has(task.tempId),
|
|
233
|
+
Badges: NodeDebugBadges(task.tempId, breakpoints, debug, runtime, entryIds),
|
|
214
234
|
Position: known ? { ...known } : { X: 0, Y: 0 },
|
|
215
235
|
Ports: [
|
|
216
|
-
{ ID:
|
|
217
|
-
{ ID:
|
|
236
|
+
{ ID: InputPortID(task.tempId), Direction: 'input', Side: 'top', Multiple: true },
|
|
237
|
+
{ ID: OutputPortID(task.tempId), Direction: 'output', Side: 'bottom', Multiple: true },
|
|
218
238
|
],
|
|
219
|
-
Data: { TempId: task.tempId },
|
|
239
|
+
Data: { TempId: task.tempId, AwaitingUser: awaiting, NextToRun: nextToRun },
|
|
220
240
|
};
|
|
221
241
|
});
|
|
222
242
|
}
|
|
243
|
+
/** Badge pills for an armed breakpoint and the step the graph actually stopped on. */
|
|
244
|
+
export function NodeDebugBadges(taskID, breakpoints, debug, runtime, entryIds) {
|
|
245
|
+
const badges = [];
|
|
246
|
+
if (isAwaitingUser(taskID, entryIds ?? new Set(), runtime, debug)) {
|
|
247
|
+
badges.push({
|
|
248
|
+
Label: 'Waiting on you — Continue or Step to run this step',
|
|
249
|
+
Value: 'Waiting here',
|
|
250
|
+
Icon: 'fa-pause',
|
|
251
|
+
Color: 'var(--mj-brand-primary)',
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
if (breakpoints.has(taskID)) {
|
|
255
|
+
badges.push({
|
|
256
|
+
Label: 'Breakpoint',
|
|
257
|
+
Value: 'break',
|
|
258
|
+
Icon: 'fa-circle',
|
|
259
|
+
Color: 'var(--mj-status-error)',
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return badges.length > 0 ? badges : undefined;
|
|
263
|
+
}
|
|
223
264
|
/**
|
|
224
265
|
* The one line under a node's name: who or what runs it.
|
|
225
266
|
*
|
|
@@ -259,32 +300,130 @@ function LoopBodyLabel(op) {
|
|
|
259
300
|
* validator reports them as `UnknownDependency`, and rendering a connection to nowhere would be a
|
|
260
301
|
* second, worse way of saying the same thing.
|
|
261
302
|
*/
|
|
262
|
-
export function SpecToConnections(spec) {
|
|
303
|
+
export function SpecToConnections(spec, runtime, debug) {
|
|
263
304
|
const known = new Set((spec.tasks ?? []).map((t) => t.tempId));
|
|
305
|
+
const entryIds = new Set(GetEntryTempIds(spec));
|
|
264
306
|
const connections = [];
|
|
265
307
|
for (const task of spec.tasks ?? []) {
|
|
266
308
|
for (const dep of GetDependencies(task)) {
|
|
267
309
|
if (!known.has(dep.tempId))
|
|
268
310
|
continue;
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
LabelIcon: conditional ? 'fa-code-branch' : undefined,
|
|
280
|
-
Condition: dep.condition ?? undefined,
|
|
281
|
-
Style: conditional ? 'dashed' : 'solid',
|
|
282
|
-
Data: { FromTempId: dep.tempId, ToTempId: task.tempId },
|
|
283
|
-
});
|
|
311
|
+
const override = dep.id ? debug?.edgeOverrides?.[dep.id] : undefined;
|
|
312
|
+
const eitherSkipped = runtime
|
|
313
|
+
&& (runtime[task.tempId] === 'Skipped' || runtime[dep.tempId] === 'Skipped');
|
|
314
|
+
// RUN MODE DRAWS ONLY THE PATH TAKEN — except an operator-forced edge, which must stay
|
|
315
|
+
// visible or the history lies about why a branch ran (or did not).
|
|
316
|
+
if (eitherSkipped && !override)
|
|
317
|
+
continue;
|
|
318
|
+
const destQueued = isNextToRun(task, runtime, debug, entryIds);
|
|
319
|
+
const flowing = destQueued || isFlowingEdge(dep.tempId, task.tempId, runtime, debug);
|
|
320
|
+
connections.push(ProjectConnection(dep, task.tempId, override, debug?.showConditions === true, flowing, !flowing && isTraveledEdge(dep.tempId, task.tempId, runtime)));
|
|
284
321
|
}
|
|
285
322
|
}
|
|
286
323
|
return connections;
|
|
287
324
|
}
|
|
325
|
+
/** One canvas connection, including the override styling that must never look like a real verdict. */
|
|
326
|
+
export function ProjectConnection(dep, toTempId, override, showConditions = false, flowing = false, traveled = false) {
|
|
327
|
+
const conditional = !!dep.condition?.trim();
|
|
328
|
+
const forced = override === 'true' || override === 'false';
|
|
329
|
+
const conditionLabel = dep.condition?.trim()
|
|
330
|
+
? TruncateCondition(dep.condition.trim())
|
|
331
|
+
: undefined;
|
|
332
|
+
return {
|
|
333
|
+
ID: edgeId(dep.tempId, toTempId),
|
|
334
|
+
SourceNodeID: dep.tempId,
|
|
335
|
+
SourcePortID: OutputPortID(dep.tempId),
|
|
336
|
+
TargetNodeID: toTempId,
|
|
337
|
+
TargetPortID: InputPortID(toTempId),
|
|
338
|
+
Label: forced
|
|
339
|
+
? (override === 'true' ? 'forced yes' : 'forced no')
|
|
340
|
+
: (conditional ? (showConditions && conditionLabel ? conditionLabel : 'if') : undefined),
|
|
341
|
+
LabelDetail: forced
|
|
342
|
+
? `Operator set this path to ${override}${dep.condition ? ` — ${dep.condition}` : ''}`
|
|
343
|
+
: (dep.condition ?? undefined),
|
|
344
|
+
LabelIcon: forced ? 'fa-hand' : (conditional ? 'fa-code-branch' : undefined),
|
|
345
|
+
LabelIconColor: forced ? 'var(--mj-status-warning)' : undefined,
|
|
346
|
+
Condition: dep.condition ?? undefined,
|
|
347
|
+
// Dotted is the override. Dashed means "only sometimes" until the path is taken —
|
|
348
|
+
// after that the condition stays on the label, but the stroke is solid so a finished
|
|
349
|
+
// branch does not still look tentative.
|
|
350
|
+
Style: forced ? 'dotted' : (conditional && !traveled ? 'dashed' : 'solid'),
|
|
351
|
+
Color: flowing
|
|
352
|
+
? 'var(--mj-brand-primary)'
|
|
353
|
+
: (forced ? 'var(--mj-status-warning)' : (traveled ? 'var(--mj-status-success)' : undefined)),
|
|
354
|
+
StrokeWidth: flowing ? 4.5 : (traveled || forced ? 3 : undefined),
|
|
355
|
+
Animated: flowing,
|
|
356
|
+
Data: { FromTempId: dep.tempId, ToTempId: toTempId, EdgeID: dep.id },
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const TERMINAL_RUNTIME = new Set(['Complete', 'Failed', 'Cancelled', 'Skipped']);
|
|
360
|
+
function isPausedHere(taskID, runtime, debug) {
|
|
361
|
+
if (debug?.pausedAtTaskID !== taskID)
|
|
362
|
+
return false;
|
|
363
|
+
const state = runtime?.[taskID];
|
|
364
|
+
return !state || !TERMINAL_RUNTIME.has(state);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* The step the operator has to act on: the breakpoint we stopped at, or — at start-paused
|
|
368
|
+
* before any claim — the entry node.
|
|
369
|
+
*/
|
|
370
|
+
function isAwaitingUser(taskID, entryIds, runtime, debug) {
|
|
371
|
+
if (isPausedHere(taskID, runtime, debug))
|
|
372
|
+
return true;
|
|
373
|
+
if (!debug?.paused || debug.pausedAtTaskID)
|
|
374
|
+
return false;
|
|
375
|
+
if (!entryIds.has(taskID))
|
|
376
|
+
return false;
|
|
377
|
+
const state = runtime?.[taskID];
|
|
378
|
+
return !state || !TERMINAL_RUNTIME.has(state);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* The next claimable step: prerequisites are done (or it is an entry) and the engine has not
|
|
382
|
+
* started it. Distinct from "waiting on you" — this one is waiting on the dispatcher.
|
|
383
|
+
*/
|
|
384
|
+
function isNextToRun(task, runtime, debug, entryIds) {
|
|
385
|
+
if (isAwaitingUser(task.tempId, entryIds ?? new Set(), runtime, debug))
|
|
386
|
+
return false;
|
|
387
|
+
const state = runtime?.[task.tempId];
|
|
388
|
+
if (state === 'In Progress' || (state && TERMINAL_RUNTIME.has(state)))
|
|
389
|
+
return false;
|
|
390
|
+
const incoming = GetDependencies(task);
|
|
391
|
+
if (incoming.length === 0)
|
|
392
|
+
return true;
|
|
393
|
+
const live = incoming.filter((d) => runtime?.[d.tempId] !== 'Skipped');
|
|
394
|
+
if (live.length === 0)
|
|
395
|
+
return false;
|
|
396
|
+
return live.every((d) => runtime?.[d.tempId] === 'Complete');
|
|
397
|
+
}
|
|
398
|
+
function isFlowingEdge(fromTempId, toTempId, runtime, debug) {
|
|
399
|
+
if (isPausedHere(toTempId, runtime, debug))
|
|
400
|
+
return true;
|
|
401
|
+
if (debug?.activeEdgeIDs?.includes(edgeId(fromTempId, toTempId)))
|
|
402
|
+
return true;
|
|
403
|
+
if (!runtime)
|
|
404
|
+
return false;
|
|
405
|
+
return runtime[fromTempId] === 'Complete' && runtime[toTempId] === 'In Progress';
|
|
406
|
+
}
|
|
407
|
+
const TAKEN_ORIGIN = new Set(['Complete', 'Failed', 'Cancelled']);
|
|
408
|
+
const TAKEN_DEST = new Set(['In Progress', 'Complete', 'Failed', 'Cancelled']);
|
|
409
|
+
/**
|
|
410
|
+
* Path already taken — origin finished AND dest has actually started. Pending dests are still
|
|
411
|
+
* candidates (a gate has not fired), so they stay dashed until one is claimed and the rest skip.
|
|
412
|
+
*/
|
|
413
|
+
function isTraveledEdge(fromTempId, toTempId, runtime) {
|
|
414
|
+
if (!runtime)
|
|
415
|
+
return false;
|
|
416
|
+
const fromState = runtime[fromTempId];
|
|
417
|
+
const toState = runtime[toTempId];
|
|
418
|
+
if (!fromState || !TAKEN_ORIGIN.has(fromState))
|
|
419
|
+
return false;
|
|
420
|
+
if (!toState || !TAKEN_DEST.has(toState))
|
|
421
|
+
return false;
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
function TruncateCondition(text, max = 28) {
|
|
425
|
+
return text.length <= max ? text : `${text.slice(0, max - 1)}…`;
|
|
426
|
+
}
|
|
288
427
|
/**
|
|
289
428
|
* Adds a dependency to the spec, returning a NEW spec.
|
|
290
429
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-graph-canvas-adapter.js","sourceRoot":"","sources":["../../src/lib/task-graph-canvas-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACH,QAAQ,EACR,mBAAmB,EACnB,QAAQ,GAKX,MAAM,8BAA8B,CAAC;AA6BtC;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAyB;IAC1D,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,WAAW,CAAC;AACjF,CAAC;AAKD,MAAM,gBAAgB,GAAuC;IACzD,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC7D,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;CACrE,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAuC;IACrE;QACI,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,OAAO;QACjB,YAAY,EAAE,gBAAgB;KACjC;IACD;QACI,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,OAAO;QACjB,YAAY,EAAE,gBAAgB;KACjC;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CAAC,OAAO,CAAC,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,UAAU,CAAC,IAAmB,EAAE,MAAM,GAAG,MAAM;IAC3D,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC;QAAE,CAAC,EAAE,CAAC;IACvC,OAAO,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * @fileoverview Projects a `TaskGraphSpec` onto the generic canvas shapes, and back.\n *\n * **Kept pure and separate from the component on purpose.** Everything interesting about rendering a\n * task graph — which node is an entry point, which edge is conditional, how a runtime status maps to\n * a visual one, whether removing a node orphans an edge — is decidable from data alone. Putting it\n * in a component would make it reachable only through a TestBed, and the resulting tests would be\n * about Angular rather than about graphs.\n *\n * **The direction flip, again.** A `TaskGraphSpec` edge points *backwards* (`dependsOn`: \"I wait for\n * X\"); a canvas connection points *forwards* (source → target). Same edge, opposite authoring\n * convention — the graph is written by whoever knows the prerequisites, the canvas drawn by whoever\n * follows the arrows. This is the second place in the program that inversion appears (Save as\n * Workflow is the first), which is why it is stated rather than left implicit.\n *\n * @module @memberjunction/ng-task-graph-editor\n */\nimport {\n ConfigOf,\n NormalizeDependency,\n TaskNode,\n type TaskNodeBase,\n type TaskGraphSpec,\n type TaskGraphSpecNode,\n type TaskGraphDependency,\n} from '@memberjunction/ai-core-plus';\nimport type { FlowConnection, FlowNode, FlowNodeStatus, FlowNodeTypeConfig, FlowPosition } from '@memberjunction/ng-flow-editor';\n\n/**\n * The shapes this canvas can DRAW.\n *\n * Three of the spec's seven `kind`s, and the choice is the canvas's: these are the shapes a person\n * authors. `Prompt`, `ForEach`, `While` and `External` are expressible in the spec but have no\n * authoring affordance here — a palette entry that cannot be configured would be worse than none.\n *\n * **Drawing and RENDERING are different questions**, which this type used to conflate. A run's\n * graph is displayed on the same canvas, and it contains kinds nobody can draw — so mapping them\n * all to `AgentTask` made a fully-configured ForEach render as \"AGENT STEP · No agent chosen yet\",\n * which is not merely imprecise: it says the step is broken. See {@link TaskGraphRenderType}.\n */\nexport type TaskGraphNodeType = 'AgentTask' | 'ActionTask' | 'HumanTask';\n\n/**\n * The shapes this canvas can SHOW — a superset of what it can draw.\n *\n * Display-only kinds exist because a task graph is rendered in two places: the editor, where a\n * person builds one, and a run view, where one that already ran is shown. The second must be able\n * to depict every kind the dispatcher can execute, whether or not the palette offers it.\n */\nexport type TaskGraphRenderType = TaskGraphNodeType | 'PromptTask' | 'ForEachTask' | 'WhileTask' | 'ExternalTask';\n\n/** A palette entry, pinned to one of the three authorable shapes. */\nexport type TaskGraphNodeTypeConfig = FlowNodeTypeConfig & { Type: TaskGraphNodeType };\n\n/**\n * Whether a shape is one a person can actually author here.\n *\n * The authoring paths — the palette, `NewTaskFromNodeType`, the properties panel — only handle the\n * three drawable shapes. Rendering handles more. This is the seam between the two, stated as a type\n * guard so the compiler enforces it rather than a cast pretending the distinction does not exist.\n */\nexport function IsAuthorableNodeType(type: TaskGraphRenderType): type is TaskGraphNodeType {\n return type === 'AgentTask' || type === 'ActionTask' || type === 'HumanTask';\n}\n\n/** A rendering entry — every shape the canvas can depict, authorable or not. */\nexport type TaskGraphRenderTypeConfig = FlowNodeTypeConfig & { Type: TaskGraphRenderType };\n\nconst TASK_GRAPH_PORTS: FlowNodeTypeConfig['DefaultPorts'] = [\n { ID: 'in', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'out', Direction: 'output', Side: 'bottom', Multiple: true },\n];\n\n/** What the palette offers — one entry per assignment shape the spec supports. */\nexport const TASK_GRAPH_NODE_TYPES: readonly TaskGraphNodeTypeConfig[] = [\n {\n Type: 'AgentTask',\n Label: 'Agent Step',\n Icon: 'fa-robot',\n Color: '#4A6FA5',\n Category: 'Steps',\n DefaultPorts: TASK_GRAPH_PORTS,\n },\n {\n Type: 'ActionTask',\n Label: 'Action Step',\n Icon: 'fa-bolt',\n Color: '#3B82F6',\n Category: 'Steps',\n DefaultPorts: TASK_GRAPH_PORTS,\n },\n {\n Type: 'HumanTask',\n Label: 'Person Step',\n Icon: 'fa-user-check',\n Color: '#7B1FA2',\n Category: 'Steps',\n DefaultPorts: TASK_GRAPH_PORTS,\n },\n];\n\n/**\n * Everything the canvas can DEPICT: the palette, plus the kinds that only ever arrive from a run.\n *\n * Deliberately a superset rather than an extension of the palette — adding these to\n * `TASK_GRAPH_NODE_TYPES` would put un-configurable entries in the authoring toolbox.\n */\nexport const TASK_GRAPH_RENDER_TYPES: readonly TaskGraphRenderTypeConfig[] = [\n ...TASK_GRAPH_NODE_TYPES,\n { Type: 'PromptTask', Label: 'Prompt Step', Icon: 'fa-comment-dots', Color: '#8B5CF6', Category: 'Steps', DefaultPorts: TASK_GRAPH_PORTS },\n { Type: 'ForEachTask', Label: 'For Each Step', Icon: 'fa-repeat', Color: '#D97706', Category: 'Steps', DefaultPorts: TASK_GRAPH_PORTS },\n { Type: 'WhileTask', Label: 'While Step', Icon: 'fa-rotate', Color: '#D97706', Category: 'Steps', DefaultPorts: TASK_GRAPH_PORTS },\n { Type: 'ExternalTask', Label: 'External Step', Icon: 'fa-arrow-up-right-from-square', Color: '#0891B2', Category: 'Steps', DefaultPorts: TASK_GRAPH_PORTS },\n];\n\n/**\n * The config for a node type, or null when the type is not one of ours.\n *\n * Searches the RENDER set, so a run's ForEach resolves to its own icon and label instead of\n * silently falling back to the agent shape.\n */\nexport function GetNodeTypeConfig(type: string): TaskGraphRenderTypeConfig | null {\n return TASK_GRAPH_RENDER_TYPES.find((c) => c.Type === type) ?? null;\n}\n\n/** Live per-task state for the runtime overlay, keyed by `tempId`. */\nexport type TaskGraphRuntimeStatus = Record<string, TaskGraphRuntimeState>;\n\n/** What a task is doing right now, in the durable engine's own vocabulary. */\nexport type TaskGraphRuntimeState =\n | 'Pending'\n | 'In Progress'\n | 'Complete'\n | 'Failed'\n | 'Blocked'\n | 'Cancelled'\n | 'Deferred';\n\n/**\n * Maps a durable task state onto the canvas's visual vocabulary.\n *\n * Two mappings are worth explaining. `Blocked` renders as a **warning**, not an error: nothing went\n * wrong, the graph simply cannot reach it — showing it as a failure would send someone hunting for a\n * bug that does not exist. `Deferred` renders as `pending` because, to the person watching, waiting\n * on a schedule and waiting on a prerequisite look and mean the same thing.\n */\nexport function RuntimeStateToNodeStatus(state: TaskGraphRuntimeState | undefined): FlowNodeStatus {\n switch (state) {\n case 'In Progress': return 'running';\n case 'Complete': return 'success';\n case 'Failed': return 'error';\n case 'Blocked': return 'warning';\n case 'Cancelled': return 'disabled';\n case 'Deferred': return 'pending';\n case 'Pending': return 'pending';\n default: return 'default';\n }\n}\n\n/**\n * True when the node is a person's step.\n *\n * One field decides it now: spec v2 gives every node exactly one `kind`, so \"is this a person's\n * step\" stopped being an inference over three optional flags and became a comparison.\n */\nexport function IsHumanTask(node: TaskGraphSpecNode): boolean {\n return node.kind === 'Human';\n}\n\n/**\n * Which of the three shapes a node is, for rendering.\n *\n * An unassigned node (just added, nothing picked yet) reads as an agent step: it is the commonest\n * intent, and the validator is already telling the author, in words, that it needs an assignee.\n * Guessing \"person\" instead — which is what the old `!agentName` rule did — put a step in the\n * graph that claimed to be waiting on someone when nobody had said so.\n */\nexport function GetTaskNodeType(node: TaskGraphSpecNode): TaskGraphRenderType {\n switch (node.kind) {\n case 'Human': return 'HumanTask';\n case 'Action': return 'ActionTask';\n case 'Prompt': return 'PromptTask';\n case 'ForEach': return 'ForEachTask';\n case 'While': return 'WhileTask';\n case 'External': return 'ExternalTask';\n // An unassigned node — just added, nothing picked — reads as an agent step: the commonest\n // intent, and the validator is already saying in words that it needs an assignee.\n default: return 'AgentTask';\n }\n}\n\n/**\n * Builds the task a palette entry stands for.\n *\n * Pure, and here rather than in the component, because \"what does clicking *Person Step* actually\n * put in the graph\" is a fact about the spec — testable without a TestBed, and the one place the\n * assignment xor is honoured on creation.\n *\n * `defaultAgentName` / `defaultActionName` are what the host has to offer. When it has nothing, the\n * step is created unassigned on purpose: inventing an agent name that may not exist would produce a\n * graph that passes the canvas and fails at submission, whereas an unassigned step is reported\n * immediately by the same validator the engine runs.\n */\nexport function NewTaskFromNodeType(\n spec: TaskGraphSpec,\n type: TaskGraphNodeType,\n defaults: { agentName?: string; actionName?: string } = {},\n): TaskGraphSpecNode {\n const base: TaskNodeBase = {\n tempId: NextTempId(spec),\n name: NEW_TASK_NAMES[type],\n description: '',\n dependsOn: [],\n };\n switch (type) {\n case 'HumanTask': return TaskNode.Human(base);\n // A step created before the host has any names to offer is created with an empty one on\n // purpose: the validator reports it immediately, whereas inventing a name would produce a\n // graph that passes here and fails at submission.\n case 'ActionTask': return TaskNode.Action(base, { actionName: defaults.actionName ?? '' });\n default: return TaskNode.Agent(base, { agentName: defaults.agentName ?? '' });\n }\n}\n\n/** Default step names, so a new box says what it is before the author renames it. */\nconst NEW_TASK_NAMES: Record<TaskGraphNodeType, string> = {\n AgentTask: 'New agent step',\n ActionTask: 'New action step',\n HumanTask: 'New person step',\n};\n\n/** Entry points: nodes nothing else has to finish first. Same rule the traversal engine uses. */\nexport function GetEntryTempIds(spec: TaskGraphSpec): string[] {\n return (spec.tasks ?? []).filter((t) => (t.dependsOn ?? []).length === 0).map((t) => t.tempId);\n}\n\n/** Every dependency of a node, in normalized object form. */\nexport function GetDependencies(node: TaskGraphSpecNode): TaskGraphDependency[] {\n return (node.dependsOn ?? []).map(NormalizeDependency);\n}\n\n/** The `tempId`s that depend on `tempId` — i.e. what breaks if it is removed. */\nexport function GetDependents(spec: TaskGraphSpec, tempId: string): string[] {\n return (spec.tasks ?? [])\n .filter((t) => GetDependencies(t).some((d) => d.tempId === tempId))\n .map((t) => t.tempId);\n}\n\n/** Deterministic id for a canvas edge, so re-renders don't churn selection. */\nfunction edgeId(fromTempId: string, toTempId: string): string {\n return `${fromTempId}->${toTempId}`;\n}\n\n/**\n * Projects the spec onto canvas nodes.\n *\n * Positions are left at the origin: layout is the canvas's job (Dagre), and a spec carries no\n * geometry precisely because a task graph is a *logical* structure. An agent that emitted one never\n * had an opinion about where the boxes go.\n */\n/**\n * Projects the spec onto canvas nodes.\n *\n * `positions` carries geometry the spec cannot hold. `TaskGraphSpec` is an execution contract with\n * no layout field, so without a caller-held map every re-projection would return every node to the\n * origin — which is what previously forced a full re-arrange (and a viewport re-zoom) after every\n * single edit. Unknown ids fall back to the origin, which is also the correct starting state for a\n * graph that has never been laid out.\n */\nexport function SpecToNodes(\n spec: TaskGraphSpec,\n runtime?: TaskGraphRuntimeStatus,\n positions?: ReadonlyMap<string, FlowPosition>,\n): FlowNode[] {\n const entryIds = new Set(GetEntryTempIds(spec));\n\n return (spec.tasks ?? []).map((task) => {\n const type = GetTaskNodeType(task);\n const known = positions?.get(task.tempId);\n return {\n ID: task.tempId,\n Type: type,\n Label: task.name,\n Subtitle: TaskSubtitle(task, type),\n Icon: GetNodeTypeConfig(type)?.Icon ?? 'fa-circle-nodes',\n Status: RuntimeStateToNodeStatus(runtime?.[task.tempId]),\n StatusMessage: task.description,\n IsStartNode: entryIds.has(task.tempId),\n Position: known ? { ...known } : { X: 0, Y: 0 },\n Ports: [\n { ID: 'in', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'out', Direction: 'output', Side: 'bottom', Multiple: true },\n ],\n Data: { TempId: task.tempId },\n };\n });\n}\n\n/**\n * The one line under a node's name: who or what runs it.\n *\n * An unassigned step says so rather than showing nothing — a blank subtitle looks like a step that\n * is fine, and this one is the reason the validation banner is complaining.\n */\nexport function TaskSubtitle(task: TaskGraphSpecNode, type: TaskGraphRenderType = GetTaskNodeType(task)): string {\n switch (type) {\n case 'HumanTask': return 'Waiting on a person';\n case 'ActionTask': return ConfigOf(task, 'Action')?.actionName || 'No action chosen yet';\n case 'PromptTask': return ConfigOf(task, 'Prompt')?.promptName || 'No prompt chosen yet';\n // A loop's subtitle is what it REPEATS — the one fact that makes the node readable.\n case 'ForEachTask': return LoopBodyLabel(ConfigOf(task, 'ForEach')) ?? 'Repeats for each item';\n case 'WhileTask': return LoopBodyLabel(ConfigOf(task, 'While')) ?? 'Repeats until its condition is false';\n case 'ExternalTask': return ConfigOf(task, 'External')?.domain || 'Completed by an outside system';\n // Only a genuinely unassigned node reaches this now. It used to catch Prompt, ForEach,\n // While and External too — so a fully-configured loop displayed \"No agent chosen yet\",\n // which reads as a broken step rather than an unrecognised one.\n default: return ConfigOf(task, 'Agent')?.agentName || 'No agent chosen yet';\n }\n}\n\n/** What a loop repeats, when it says. */\nfunction LoopBodyLabel(\n op: { action?: { name: string }; subAgent?: { name: string }; prompt?: { name: string } } | null | undefined,\n): string | null {\n if (!op) return null;\n const body = op.action?.name ?? op.subAgent?.name ?? op.prompt?.name;\n return body ? `Repeats: ${body}` : null;\n}\n\n/**\n * Projects the spec's dependencies onto canvas connections, reversing their direction.\n *\n * A conditional edge is drawn dashed and labeled with its condition, because the difference between\n * \"always\" and \"only sometimes\" is the single most consequential thing about an edge and the one a\n * reader is most likely to miss when scanning a diagram.\n *\n * Edges naming a task that is not in the graph are skipped rather than drawn dangling — the\n * validator reports them as `UnknownDependency`, and rendering a connection to nowhere would be a\n * second, worse way of saying the same thing.\n */\nexport function SpecToConnections(spec: TaskGraphSpec): FlowConnection[] {\n const known = new Set((spec.tasks ?? []).map((t) => t.tempId));\n const connections: FlowConnection[] = [];\n\n for (const task of spec.tasks ?? []) {\n for (const dep of GetDependencies(task)) {\n if (!known.has(dep.tempId)) continue;\n\n const conditional = !!dep.condition?.trim();\n connections.push({\n ID: edgeId(dep.tempId, task.tempId),\n // Reversed: dependsOn points back at the prerequisite, the drawn arrow points forward.\n SourceNodeID: dep.tempId,\n SourcePortID: 'out',\n TargetNodeID: task.tempId,\n TargetPortID: 'in',\n Label: conditional ? 'if' : undefined,\n LabelDetail: dep.condition ?? undefined,\n LabelIcon: conditional ? 'fa-code-branch' : undefined,\n Condition: dep.condition ?? undefined,\n Style: conditional ? 'dashed' : 'solid',\n Data: { FromTempId: dep.tempId, ToTempId: task.tempId },\n });\n }\n }\n return connections;\n}\n\n/**\n * Adds a dependency to the spec, returning a NEW spec.\n *\n * Immutable because the component emits the result to a host that may keep it, diff it, or reject\n * it; mutating the input would let a canceled edit leak into the host's copy anyway. A duplicate\n * edge is a no-op rather than an error — dragging the same connection twice is a slip, not a\n * request to corrupt the graph.\n */\nexport function AddDependency(spec: TaskGraphSpec, fromTempId: string, toTempId: string, condition?: string): TaskGraphSpec {\n return {\n ...spec,\n tasks: (spec.tasks ?? []).map((task) => {\n if (task.tempId !== toTempId) return task;\n const existing = GetDependencies(task);\n if (existing.some((d) => d.tempId === fromTempId)) return task;\n const next: TaskGraphDependency | string = condition?.trim()\n ? { tempId: fromTempId, condition }\n : fromTempId;\n return { ...task, dependsOn: [...(task.dependsOn ?? []), next] };\n }),\n };\n}\n\n/** Removes a dependency, returning a NEW spec. */\nexport function RemoveDependency(spec: TaskGraphSpec, fromTempId: string, toTempId: string): TaskGraphSpec {\n return {\n ...spec,\n tasks: (spec.tasks ?? []).map((task) =>\n task.tempId !== toTempId\n ? task\n : { ...task, dependsOn: (task.dependsOn ?? []).filter((d) => NormalizeDependency(d).tempId !== fromTempId) },\n ),\n };\n}\n\n/**\n * Removes a task AND every edge into it, returning a NEW spec.\n *\n * Severing the inbound edges is not a convenience — leaving them would produce a graph whose\n * `dependsOn` names a task that no longer exists, which the validator rejects as\n * `UnknownDependency`. Deleting a box on a canvas should not make the graph invalid.\n */\nexport function RemoveTask(spec: TaskGraphSpec, tempId: string): TaskGraphSpec {\n return {\n ...spec,\n tasks: (spec.tasks ?? [])\n .filter((t) => t.tempId !== tempId)\n .map((t) => ({ ...t, dependsOn: (t.dependsOn ?? []).filter((d) => NormalizeDependency(d).tempId !== tempId) })),\n };\n}\n\n/** Adds a task, returning a NEW spec. */\nexport function AddTask(spec: TaskGraphSpec, task: TaskGraphSpecNode): TaskGraphSpec {\n return { ...spec, tasks: [...(spec.tasks ?? []), task] };\n}\n\n/** Replaces a task in place by `tempId`, returning a NEW spec. */\nexport function UpdateTask(spec: TaskGraphSpec, tempId: string, next: TaskGraphSpecNode): TaskGraphSpec {\n return { ...spec, tasks: (spec.tasks ?? []).map((t) => (t.tempId === tempId ? next : t)) };\n}\n\n/**\n * Would adding `from → to` create a cycle?\n *\n * Answered before the edge exists, so the canvas can refuse it rather than create an invalid graph\n * and report it afterwards. A self-edge is the degenerate case and is caught first.\n *\n * Iterative rather than recursive: the graph may come from an LLM, and a deeply-chained spec should\n * produce a refusal, not a stack overflow.\n */\nexport function WouldCreateCycle(spec: TaskGraphSpec, fromTempId: string, toTempId: string): boolean {\n if (fromTempId === toTempId) return true;\n\n // A cycle appears iff `from` is already reachable from `to` by following dependsOn edges —\n // i.e. `to` already (transitively) waits on `from`.\n const dependenciesOf = new Map<string, string[]>(\n (spec.tasks ?? []).map((t) => [t.tempId, GetDependencies(t).map((d) => d.tempId)]),\n );\n\n const stack = [...(dependenciesOf.get(fromTempId) ?? [])];\n const seen = new Set<string>();\n while (stack.length > 0) {\n const current = stack.pop()!;\n if (current === toTempId) return true;\n if (seen.has(current)) continue;\n seen.add(current);\n stack.push(...(dependenciesOf.get(current) ?? []));\n }\n return false;\n}\n\n/** A unique `tempId` for a newly added task, stable and readable. */\nexport function NextTempId(spec: TaskGraphSpec, prefix = 'task'): string {\n const taken = new Set((spec.tasks ?? []).map((t) => t.tempId));\n let n = (spec.tasks ?? []).length + 1;\n while (taken.has(`${prefix}${n}`)) n++;\n return `${prefix}${n}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"task-graph-canvas-adapter.js","sourceRoot":"","sources":["../../src/lib/task-graph-canvas-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EACH,QAAQ,EACR,mBAAmB,EACnB,QAAQ,GAKX,MAAM,8BAA8B,CAAC;AA6BtC;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAyB;IAC1D,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,WAAW,CAAC;AACjF,CAAC;AAKD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACtC,OAAO,GAAG,MAAM,KAAK,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAc;IACvC,OAAO,GAAG,MAAM,MAAM,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,gBAAgB,GAAuC;IACzD,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC7D,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;CACrE,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAuC;IACrE;QACI,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,YAAY;QACnB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,OAAO;QACjB,YAAY,EAAE,gBAAgB;KACjC;IACD;QACI,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,OAAO;QACjB,YAAY,EAA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M,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACtC,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC;QAAE,CAAC,EAAE,CAAC;IACvC,OAAO,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * @fileoverview Projects a `TaskGraphSpec` onto the generic canvas shapes, and back.\n *\n * **Kept pure and separate from the component on purpose.** Everything interesting about rendering a\n * task graph — which node is an entry point, which edge is conditional, how a runtime status maps to\n * a visual one, whether removing a node orphans an edge — is decidable from data alone. Putting it\n * in a component would make it reachable only through a TestBed, and the resulting tests would be\n * about Angular rather than about graphs.\n *\n * **The direction flip, again.** A `TaskGraphSpec` edge points *backwards* (`dependsOn`: \"I wait for\n * X\"); a canvas connection points *forwards* (source → target). Same edge, opposite authoring\n * convention — the graph is written by whoever knows the prerequisites, the canvas drawn by whoever\n * follows the arrows. This is the second place in the program that inversion appears (Save as\n * Workflow is the first), which is why it is stated rather than left implicit.\n *\n * @module @memberjunction/ng-task-graph-editor\n */\nimport {\n ConfigOf,\n NormalizeDependency,\n TaskNode,\n type TaskNodeBase,\n type TaskGraphSpec,\n type TaskGraphSpecNode,\n type TaskGraphDependency,\n} from '@memberjunction/ai-core-plus';\nimport type { FlowConnection, FlowNode, FlowNodeStatus, FlowNodeTypeConfig, FlowPosition } from '@memberjunction/ng-flow-editor';\n\n/**\n * The shapes this canvas can DRAW.\n *\n * Three of the spec's seven `kind`s, and the choice is the canvas's: these are the shapes a person\n * authors. `Prompt`, `ForEach`, `While` and `External` are expressible in the spec but have no\n * authoring affordance here — a palette entry that cannot be configured would be worse than none.\n *\n * **Drawing and RENDERING are different questions**, which this type used to conflate. A run's\n * graph is displayed on the same canvas, and it contains kinds nobody can draw — so mapping them\n * all to `AgentTask` made a fully-configured ForEach render as \"AGENT STEP · No agent chosen yet\",\n * which is not merely imprecise: it says the step is broken. See {@link TaskGraphRenderType}.\n */\nexport type TaskGraphNodeType = 'AgentTask' | 'ActionTask' | 'HumanTask';\n\n/**\n * The shapes this canvas can SHOW — a superset of what it can draw.\n *\n * Display-only kinds exist because a task graph is rendered in two places: the editor, where a\n * person builds one, and a run view, where one that already ran is shown. The second must be able\n * to depict every kind the dispatcher can execute, whether or not the palette offers it.\n */\nexport type TaskGraphRenderType = TaskGraphNodeType | 'PromptTask' | 'ForEachTask' | 'WhileTask' | 'ExternalTask';\n\n/** A palette entry, pinned to one of the three authorable shapes. */\nexport type TaskGraphNodeTypeConfig = FlowNodeTypeConfig & { Type: TaskGraphNodeType };\n\n/**\n * Whether a shape is one a person can actually author here.\n *\n * The authoring paths — the palette, `NewTaskFromNodeType`, the properties panel — only handle the\n * three drawable shapes. Rendering handles more. This is the seam between the two, stated as a type\n * guard so the compiler enforces it rather than a cast pretending the distinction does not exist.\n */\nexport function IsAuthorableNodeType(type: TaskGraphRenderType): type is TaskGraphNodeType {\n return type === 'AgentTask' || type === 'ActionTask' || type === 'HumanTask';\n}\n\n/** A rendering entry — every shape the canvas can depict, authorable or not. */\nexport type TaskGraphRenderTypeConfig = FlowNodeTypeConfig & { Type: TaskGraphRenderType };\n\n/**\n * Port ids are scoped to their NODE, and must be.\n *\n * The canvas resolves a connection by looking its `fOutputId` / `fInputId` up among all registered\n * ports — a flat, graph-wide namespace. Giving every node ports literally called `in` and `out` made\n * every node's ports collide with every other node's, so a connection could not name which node's\n * port it meant. The result was a workflow that drew its boxes correctly and **no edges at all**:\n * nothing errored, because an unresolvable port is simply a connection with nowhere to attach.\n *\n * The Flow Agent editor — the other consumer of this canvas, whose edges have always drawn — scopes\n * its ports the same way (`${stepId}-input` / `${stepId}-output`). This is that convention, named,\n * so a future producer cannot reintroduce the collision by writing the obvious literal.\n */\nexport function InputPortID(tempId: string): string {\n return `${tempId}-in`;\n}\n\nexport function OutputPortID(tempId: string): string {\n return `${tempId}-out`;\n}\n\n/**\n * Palette defaults. These carry the bare names because a palette entry describes a node TYPE, not a\n * placed node — there is no id to scope them to yet. {@link SpecToNodes} assigns the real, scoped\n * ids when a node is actually placed on the canvas.\n */\nconst TASK_GRAPH_PORTS: FlowNodeTypeConfig['DefaultPorts'] = [\n { ID: 'in', Direction: 'input', Side: 'top', Multiple: true },\n { ID: 'out', Direction: 'output', Side: 'bottom', Multiple: true },\n];\n\n/** What the palette offers — one entry per assignment shape the spec supports. */\nexport const TASK_GRAPH_NODE_TYPES: readonly TaskGraphNodeTypeConfig[] = [\n {\n Type: 'AgentTask',\n Label: 'Agent Step',\n Icon: 'fa-robot',\n Color: '#4A6FA5',\n Category: 'Steps',\n DefaultPorts: TASK_GRAPH_PORTS,\n },\n {\n Type: 'ActionTask',\n Label: 'Action Step',\n Icon: 'fa-bolt',\n Color: '#3B82F6',\n Category: 'Steps',\n DefaultPorts: TASK_GRAPH_PORTS,\n },\n {\n Type: 'HumanTask',\n Label: 'Person Step',\n Icon: 'fa-user-check',\n Color: '#7B1FA2',\n Category: 'Steps',\n DefaultPorts: TASK_GRAPH_PORTS,\n },\n];\n\n/**\n * Everything the canvas can DEPICT: the palette, plus the kinds that only ever arrive from a run.\n *\n * Deliberately a superset rather than an extension of the palette — adding these to\n * `TASK_GRAPH_NODE_TYPES` would put un-configurable entries in the authoring toolbox.\n */\nexport const TASK_GRAPH_RENDER_TYPES: readonly TaskGraphRenderTypeConfig[] = [\n ...TASK_GRAPH_NODE_TYPES,\n { Type: 'PromptTask', Label: 'Prompt Step', Icon: 'fa-comment-dots', Color: '#8B5CF6', Category: 'Steps', DefaultPorts: TASK_GRAPH_PORTS },\n { Type: 'ForEachTask', Label: 'For Each Step', Icon: 'fa-repeat', Color: '#D97706', Category: 'Steps', DefaultPorts: TASK_GRAPH_PORTS },\n { Type: 'WhileTask', Label: 'While Step', Icon: 'fa-rotate', Color: '#D97706', Category: 'Steps', DefaultPorts: TASK_GRAPH_PORTS },\n { Type: 'ExternalTask', Label: 'External Step', Icon: 'fa-arrow-up-right-from-square', Color: '#0891B2', Category: 'Steps', DefaultPorts: TASK_GRAPH_PORTS },\n];\n\n/**\n * The config for a node type, or null when the type is not one of ours.\n *\n * Searches the RENDER set, so a run's ForEach resolves to its own icon and label instead of\n * silently falling back to the agent shape.\n */\nexport function GetNodeTypeConfig(type: string): TaskGraphRenderTypeConfig | null {\n return TASK_GRAPH_RENDER_TYPES.find((c) => c.Type === type) ?? null;\n}\n\n/** Live per-task state for the runtime overlay, keyed by `tempId`. */\nexport type TaskGraphRuntimeStatus = Record<string, TaskGraphRuntimeState>;\n\n/** What a task is doing right now, in the durable engine's own vocabulary. */\nexport type TaskGraphRuntimeState =\n | 'Pending'\n | 'In Progress'\n | 'Complete'\n | 'Failed'\n | 'Blocked'\n | 'Cancelled'\n | 'Deferred'\n // A branch the workflow did not take. Absent from this union until now, which is why it fell\n // through to the default rendering and a not-taken step drew as an ordinary one.\n | 'Skipped';\n\n/**\n * Maps a durable task state onto the canvas's visual vocabulary.\n *\n * Two mappings are worth explaining. `Blocked` renders as a **warning**, not an error: nothing went\n * wrong, the graph simply cannot reach it — showing it as a failure would send someone hunting for a\n * bug that does not exist. `Deferred` renders as `pending` because, to the person watching, waiting\n * on a schedule and waiting on a prerequisite look and mean the same thing.\n */\nexport function RuntimeStateToNodeStatus(state: TaskGraphRuntimeState | undefined): FlowNodeStatus {\n switch (state) {\n case 'In Progress': return 'running';\n case 'Complete': return 'success';\n case 'Failed': return 'error';\n case 'Blocked': return 'warning';\n case 'Cancelled': return 'disabled';\n // Its own state, not a shade of disabled: a branch the workflow did not take is a normal\n // outcome. Falling through to 'default' — which is what happened before — drew it as an\n // ordinary node, so a conditional workflow looked like it had run every branch.\n case 'Skipped': return 'skipped';\n case 'Deferred': return 'pending';\n case 'Pending': return 'pending';\n default: return 'default';\n }\n}\n\n/**\n * True when the node is a person's step.\n *\n * One field decides it now: spec v2 gives every node exactly one `kind`, so \"is this a person's\n * step\" stopped being an inference over three optional flags and became a comparison.\n */\nexport function IsHumanTask(node: TaskGraphSpecNode): boolean {\n return node.kind === 'Human';\n}\n\n/**\n * Which of the three shapes a node is, for rendering.\n *\n * An unassigned node (just added, nothing picked yet) reads as an agent step: it is the commonest\n * intent, and the validator is already telling the author, in words, that it needs an assignee.\n * Guessing \"person\" instead — which is what the old `!agentName` rule did — put a step in the\n * graph that claimed to be waiting on someone when nobody had said so.\n */\nexport function GetTaskNodeType(node: TaskGraphSpecNode): TaskGraphRenderType {\n switch (node.kind) {\n case 'Human': return 'HumanTask';\n case 'Action': return 'ActionTask';\n case 'Prompt': return 'PromptTask';\n case 'ForEach': return 'ForEachTask';\n case 'While': return 'WhileTask';\n case 'External': return 'ExternalTask';\n // An unassigned node — just added, nothing picked — reads as an agent step: the commonest\n // intent, and the validator is already saying in words that it needs an assignee.\n default: return 'AgentTask';\n }\n}\n\n/**\n * Builds the task a palette entry stands for.\n *\n * Pure, and here rather than in the component, because \"what does clicking *Person Step* actually\n * put in the graph\" is a fact about the spec — testable without a TestBed, and the one place the\n * assignment xor is honoured on creation.\n *\n * `defaultAgentName` / `defaultActionName` are what the host has to offer. When it has nothing, the\n * step is created unassigned on purpose: inventing an agent name that may not exist would produce a\n * graph that passes the canvas and fails at submission, whereas an unassigned step is reported\n * immediately by the same validator the engine runs.\n */\nexport function NewTaskFromNodeType(\n spec: TaskGraphSpec,\n type: TaskGraphNodeType,\n defaults: { agentName?: string; actionName?: string } = {},\n): TaskGraphSpecNode {\n const base: TaskNodeBase = {\n tempId: NextTempId(spec),\n name: NEW_TASK_NAMES[type],\n description: '',\n dependsOn: [],\n };\n switch (type) {\n case 'HumanTask': return TaskNode.Human(base);\n // A step created before the host has any names to offer is created with an empty one on\n // purpose: the validator reports it immediately, whereas inventing a name would produce a\n // graph that passes here and fails at submission.\n case 'ActionTask': return TaskNode.Action(base, { actionName: defaults.actionName ?? '' });\n default: return TaskNode.Agent(base, { agentName: defaults.agentName ?? '' });\n }\n}\n\n/** Default step names, so a new box says what it is before the author renames it. */\nconst NEW_TASK_NAMES: Record<TaskGraphNodeType, string> = {\n AgentTask: 'New agent step',\n ActionTask: 'New action step',\n HumanTask: 'New person step',\n};\n\n/** Entry points: nodes nothing else has to finish first. Same rule the traversal engine uses. */\nexport function GetEntryTempIds(spec: TaskGraphSpec): string[] {\n return (spec.tasks ?? []).filter((t) => (t.dependsOn ?? []).length === 0).map((t) => t.tempId);\n}\n\n/** Every dependency of a node, in normalized object form. */\nexport function GetDependencies(node: TaskGraphSpecNode): TaskGraphDependency[] {\n return (node.dependsOn ?? []).map(NormalizeDependency);\n}\n\n/** The `tempId`s that depend on `tempId` — i.e. what breaks if it is removed. */\nexport function GetDependents(spec: TaskGraphSpec, tempId: string): string[] {\n return (spec.tasks ?? [])\n .filter((t) => GetDependencies(t).some((d) => d.tempId === tempId))\n .map((t) => t.tempId);\n}\n\n/** Deterministic id for a canvas edge, so re-renders don't churn selection. */\nfunction edgeId(fromTempId: string, toTempId: string): string {\n return `${fromTempId}->${toTempId}`;\n}\n\n/**\n * Projects the spec onto canvas nodes.\n *\n * Positions are left at the origin: layout is the canvas's job (Dagre), and a spec carries no\n * geometry precisely because a task graph is a *logical* structure. An agent that emitted one never\n * had an opinion about where the boxes go.\n */\n/**\n * Projects the spec onto canvas nodes.\n *\n * `positions` carries geometry the spec cannot hold. `TaskGraphSpec` is an execution contract with\n * no layout field, so without a caller-held map every re-projection would return every node to the\n * origin — which is what previously forced a full re-arrange (and a viewport re-zoom) after every\n * single edit. Unknown ids fall back to the origin, which is also the correct starting state for a\n * graph that has never been laid out.\n */\n/**\n * Debug overlay the run view hands the adapter. Paint only — the widget never calls an operation.\n *\n * Breakpoints and the paused-at step become badges. Overrides restyle connections (dotted, never\n * dashed — dashed already means \"this edge is conditional\"). Held/forced edges stay visible even\n * when a skip cascade would otherwise drop them, so the run history cannot lie about why a branch\n * ran.\n */\nexport type TaskGraphDebugOverlay = {\n breakpoints?: readonly string[];\n pausedAtTaskID?: string | null;\n /** Graph is claim-gated. With no paused-at step, the entry node is what is waiting. */\n paused?: boolean;\n edgeOverrides?: Readonly<Record<string, 'true' | 'false'>>;\n /** Show the condition expression on the connection label, not just the word \"if\". */\n showConditions?: boolean;\n /** Edge IDs (or from→to) currently flowing — painted animated + brand. */\n activeEdgeIDs?: readonly string[];\n};\n\nexport function SpecToNodes(\n spec: TaskGraphSpec,\n runtime?: TaskGraphRuntimeStatus,\n positions?: ReadonlyMap<string, FlowPosition>,\n debug?: TaskGraphDebugOverlay,\n): FlowNode[] {\n const entryIds = new Set(GetEntryTempIds(spec));\n const breakpoints = new Set(debug?.breakpoints ?? []);\n\n return (spec.tasks ?? []).map((task) => {\n const type = GetTaskNodeType(task);\n const known = positions?.get(task.tempId);\n const awaiting = isAwaitingUser(task.tempId, entryIds, runtime, debug);\n const nextToRun = isNextToRun(task, runtime, debug, entryIds);\n const running = runtime?.[task.tempId] === 'In Progress';\n return {\n ID: task.tempId,\n Type: type,\n Label: task.name,\n Subtitle: TaskSubtitle(task, type),\n Icon: GetNodeTypeConfig(type)?.Icon ?? 'fa-circle-nodes',\n IconColor: awaiting || nextToRun || running ? 'var(--mj-brand-primary)' : undefined,\n // Keep the real runtime status. Mapping \"paused here\" to `running` drew a spinner\n // on a step that is waiting for the operator — it read as \"this is executing\".\n Status: RuntimeStateToNodeStatus(runtime?.[task.tempId]),\n StatusMessage: task.description,\n IsStartNode: entryIds.has(task.tempId),\n Badges: NodeDebugBadges(task.tempId, breakpoints, debug, runtime, entryIds),\n Position: known ? { ...known } : { X: 0, Y: 0 },\n Ports: [\n { ID: InputPortID(task.tempId), Direction: 'input', Side: 'top', Multiple: true },\n { ID: OutputPortID(task.tempId), Direction: 'output', Side: 'bottom', Multiple: true },\n ],\n Data: { TempId: task.tempId, AwaitingUser: awaiting, NextToRun: nextToRun },\n };\n });\n}\n\n/** Badge pills for an armed breakpoint and the step the graph actually stopped on. */\nexport function NodeDebugBadges(\n taskID: string,\n breakpoints: ReadonlySet<string>,\n debug?: TaskGraphDebugOverlay,\n runtime?: TaskGraphRuntimeStatus,\n entryIds?: ReadonlySet<string>,\n): FlowNode['Badges'] {\n const badges: NonNullable<FlowNode['Badges']> = [];\n if (isAwaitingUser(taskID, entryIds ?? new Set(), runtime, debug)) {\n badges.push({\n Label: 'Waiting on you — Continue or Step to run this step',\n Value: 'Waiting here',\n Icon: 'fa-pause',\n Color: 'var(--mj-brand-primary)',\n });\n }\n if (breakpoints.has(taskID)) {\n badges.push({\n Label: 'Breakpoint',\n Value: 'break',\n Icon: 'fa-circle',\n Color: 'var(--mj-status-error)',\n });\n }\n return badges.length > 0 ? badges : undefined;\n}\n\n/**\n * The one line under a node's name: who or what runs it.\n *\n * An unassigned step says so rather than showing nothing — a blank subtitle looks like a step that\n * is fine, and this one is the reason the validation banner is complaining.\n */\nexport function TaskSubtitle(task: TaskGraphSpecNode, type: TaskGraphRenderType = GetTaskNodeType(task)): string {\n switch (type) {\n case 'HumanTask': return 'Waiting on a person';\n case 'ActionTask': return ConfigOf(task, 'Action')?.actionName || 'No action chosen yet';\n case 'PromptTask': return ConfigOf(task, 'Prompt')?.promptName || 'No prompt chosen yet';\n // A loop's subtitle is what it REPEATS — the one fact that makes the node readable.\n case 'ForEachTask': return LoopBodyLabel(ConfigOf(task, 'ForEach')) ?? 'Repeats for each item';\n case 'WhileTask': return LoopBodyLabel(ConfigOf(task, 'While')) ?? 'Repeats until its condition is false';\n case 'ExternalTask': return ConfigOf(task, 'External')?.domain || 'Completed by an outside system';\n // Only a genuinely unassigned node reaches this now. It used to catch Prompt, ForEach,\n // While and External too — so a fully-configured loop displayed \"No agent chosen yet\",\n // which reads as a broken step rather than an unrecognised one.\n default: return ConfigOf(task, 'Agent')?.agentName || 'No agent chosen yet';\n }\n}\n\n/** What a loop repeats, when it says. */\nfunction LoopBodyLabel(\n op: { action?: { name: string }; subAgent?: { name: string }; prompt?: { name: string } } | null | undefined,\n): string | null {\n if (!op) return null;\n const body = op.action?.name ?? op.subAgent?.name ?? op.prompt?.name;\n return body ? `Repeats: ${body}` : null;\n}\n\n/**\n * Projects the spec's dependencies onto canvas connections, reversing their direction.\n *\n * A conditional edge is drawn dashed and labeled with its condition, because the difference between\n * \"always\" and \"only sometimes\" is the single most consequential thing about an edge and the one a\n * reader is most likely to miss when scanning a diagram.\n *\n * Edges naming a task that is not in the graph are skipped rather than drawn dangling — the\n * validator reports them as `UnknownDependency`, and rendering a connection to nowhere would be a\n * second, worse way of saying the same thing.\n */\nexport function SpecToConnections(\n spec: TaskGraphSpec,\n runtime?: TaskGraphRuntimeStatus,\n debug?: TaskGraphDebugOverlay,\n): FlowConnection[] {\n const known = new Set((spec.tasks ?? []).map((t) => t.tempId));\n const entryIds = new Set(GetEntryTempIds(spec));\n const connections: FlowConnection[] = [];\n\n for (const task of spec.tasks ?? []) {\n for (const dep of GetDependencies(task)) {\n if (!known.has(dep.tempId)) continue;\n\n const override = dep.id ? debug?.edgeOverrides?.[dep.id] : undefined;\n const eitherSkipped = runtime\n && (runtime[task.tempId] === 'Skipped' || runtime[dep.tempId] === 'Skipped');\n // RUN MODE DRAWS ONLY THE PATH TAKEN — except an operator-forced edge, which must stay\n // visible or the history lies about why a branch ran (or did not).\n if (eitherSkipped && !override) continue;\n\n const destQueued = isNextToRun(task, runtime, debug, entryIds);\n const flowing = destQueued || isFlowingEdge(dep.tempId, task.tempId, runtime, debug);\n connections.push(ProjectConnection(\n dep,\n task.tempId,\n override,\n debug?.showConditions === true,\n flowing,\n !flowing && isTraveledEdge(dep.tempId, task.tempId, runtime),\n ));\n }\n }\n return connections;\n}\n\n/** One canvas connection, including the override styling that must never look like a real verdict. */\nexport function ProjectConnection(\n dep: TaskGraphDependency,\n toTempId: string,\n override?: 'true' | 'false',\n showConditions: boolean = false,\n flowing: boolean = false,\n traveled: boolean = false,\n): FlowConnection {\n const conditional = !!dep.condition?.trim();\n const forced = override === 'true' || override === 'false';\n const conditionLabel = dep.condition?.trim()\n ? TruncateCondition(dep.condition.trim())\n : undefined;\n\n return {\n ID: edgeId(dep.tempId, toTempId),\n SourceNodeID: dep.tempId,\n SourcePortID: OutputPortID(dep.tempId),\n TargetNodeID: toTempId,\n TargetPortID: InputPortID(toTempId),\n Label: forced\n ? (override === 'true' ? 'forced yes' : 'forced no')\n : (conditional ? (showConditions && conditionLabel ? conditionLabel : 'if') : undefined),\n LabelDetail: forced\n ? `Operator set this path to ${override}${dep.condition ? ` — ${dep.condition}` : ''}`\n : (dep.condition ?? undefined),\n LabelIcon: forced ? 'fa-hand' : (conditional ? 'fa-code-branch' : undefined),\n LabelIconColor: forced ? 'var(--mj-status-warning)' : undefined,\n Condition: dep.condition ?? undefined,\n // Dotted is the override. Dashed means \"only sometimes\" until the path is taken —\n // after that the condition stays on the label, but the stroke is solid so a finished\n // branch does not still look tentative.\n Style: forced ? 'dotted' : (conditional && !traveled ? 'dashed' : 'solid'),\n Color: flowing\n ? 'var(--mj-brand-primary)'\n : (forced ? 'var(--mj-status-warning)' : (traveled ? 'var(--mj-status-success)' : undefined)),\n StrokeWidth: flowing ? 4.5 : (traveled || forced ? 3 : undefined),\n Animated: flowing,\n Data: { FromTempId: dep.tempId, ToTempId: toTempId, EdgeID: dep.id },\n };\n}\n\nconst TERMINAL_RUNTIME = new Set<TaskGraphRuntimeState>(['Complete', 'Failed', 'Cancelled', 'Skipped']);\n\nfunction isPausedHere(\n taskID: string,\n runtime?: TaskGraphRuntimeStatus,\n debug?: Pick<TaskGraphDebugOverlay, 'pausedAtTaskID'>,\n): boolean {\n if (debug?.pausedAtTaskID !== taskID) return false;\n const state = runtime?.[taskID];\n return !state || !TERMINAL_RUNTIME.has(state);\n}\n\n/**\n * The step the operator has to act on: the breakpoint we stopped at, or — at start-paused\n * before any claim — the entry node.\n */\nfunction isAwaitingUser(\n taskID: string,\n entryIds: ReadonlySet<string>,\n runtime?: TaskGraphRuntimeStatus,\n debug?: TaskGraphDebugOverlay,\n): boolean {\n if (isPausedHere(taskID, runtime, debug)) return true;\n if (!debug?.paused || debug.pausedAtTaskID) return false;\n if (!entryIds.has(taskID)) return false;\n const state = runtime?.[taskID];\n return !state || !TERMINAL_RUNTIME.has(state);\n}\n\n/**\n * The next claimable step: prerequisites are done (or it is an entry) and the engine has not\n * started it. Distinct from \"waiting on you\" — this one is waiting on the dispatcher.\n */\nfunction isNextToRun(\n task: TaskGraphSpecNode,\n runtime?: TaskGraphRuntimeStatus,\n debug?: TaskGraphDebugOverlay,\n entryIds?: ReadonlySet<string>,\n): boolean {\n if (isAwaitingUser(task.tempId, entryIds ?? new Set(), runtime, debug)) return false;\n const state = runtime?.[task.tempId];\n if (state === 'In Progress' || (state && TERMINAL_RUNTIME.has(state))) return false;\n const incoming = GetDependencies(task);\n if (incoming.length === 0) return true;\n const live = incoming.filter((d) => runtime?.[d.tempId] !== 'Skipped');\n if (live.length === 0) return false;\n return live.every((d) => runtime?.[d.tempId] === 'Complete');\n}\n\nfunction isFlowingEdge(\n fromTempId: string,\n toTempId: string,\n runtime?: TaskGraphRuntimeStatus,\n debug?: TaskGraphDebugOverlay,\n): boolean {\n if (isPausedHere(toTempId, runtime, debug)) return true;\n if (debug?.activeEdgeIDs?.includes(edgeId(fromTempId, toTempId))) return true;\n if (!runtime) return false;\n return runtime[fromTempId] === 'Complete' && runtime[toTempId] === 'In Progress';\n}\n\nconst TAKEN_ORIGIN = new Set<TaskGraphRuntimeState>(['Complete', 'Failed', 'Cancelled']);\nconst TAKEN_DEST = new Set<TaskGraphRuntimeState>(['In Progress', 'Complete', 'Failed', 'Cancelled']);\n\n/**\n * Path already taken — origin finished AND dest has actually started. Pending dests are still\n * candidates (a gate has not fired), so they stay dashed until one is claimed and the rest skip.\n */\nfunction isTraveledEdge(\n fromTempId: string,\n toTempId: string,\n runtime?: TaskGraphRuntimeStatus,\n): boolean {\n if (!runtime) return false;\n const fromState = runtime[fromTempId];\n const toState = runtime[toTempId];\n if (!fromState || !TAKEN_ORIGIN.has(fromState)) return false;\n if (!toState || !TAKEN_DEST.has(toState)) return false;\n return true;\n}\n\nfunction TruncateCondition(text: string, max: number = 28): string {\n return text.length <= max ? text : `${text.slice(0, max - 1)}…`;\n}\n\n/**\n * Adds a dependency to the spec, returning a NEW spec.\n *\n * Immutable because the component emits the result to a host that may keep it, diff it, or reject\n * it; mutating the input would let a canceled edit leak into the host's copy anyway. A duplicate\n * edge is a no-op rather than an error — dragging the same connection twice is a slip, not a\n * request to corrupt the graph.\n */\nexport function AddDependency(spec: TaskGraphSpec, fromTempId: string, toTempId: string, condition?: string): TaskGraphSpec {\n return {\n ...spec,\n tasks: (spec.tasks ?? []).map((task) => {\n if (task.tempId !== toTempId) return task;\n const existing = GetDependencies(task);\n if (existing.some((d) => d.tempId === fromTempId)) return task;\n const next: TaskGraphDependency | string = condition?.trim()\n ? { tempId: fromTempId, condition }\n : fromTempId;\n return { ...task, dependsOn: [...(task.dependsOn ?? []), next] };\n }),\n };\n}\n\n/** Removes a dependency, returning a NEW spec. */\nexport function RemoveDependency(spec: TaskGraphSpec, fromTempId: string, toTempId: string): TaskGraphSpec {\n return {\n ...spec,\n tasks: (spec.tasks ?? []).map((task) =>\n task.tempId !== toTempId\n ? task\n : { ...task, dependsOn: (task.dependsOn ?? []).filter((d) => NormalizeDependency(d).tempId !== fromTempId) },\n ),\n };\n}\n\n/**\n * Removes a task AND every edge into it, returning a NEW spec.\n *\n * Severing the inbound edges is not a convenience — leaving them would produce a graph whose\n * `dependsOn` names a task that no longer exists, which the validator rejects as\n * `UnknownDependency`. Deleting a box on a canvas should not make the graph invalid.\n */\nexport function RemoveTask(spec: TaskGraphSpec, tempId: string): TaskGraphSpec {\n return {\n ...spec,\n tasks: (spec.tasks ?? [])\n .filter((t) => t.tempId !== tempId)\n .map((t) => ({ ...t, dependsOn: (t.dependsOn ?? []).filter((d) => NormalizeDependency(d).tempId !== tempId) })),\n };\n}\n\n/** Adds a task, returning a NEW spec. */\nexport function AddTask(spec: TaskGraphSpec, task: TaskGraphSpecNode): TaskGraphSpec {\n return { ...spec, tasks: [...(spec.tasks ?? []), task] };\n}\n\n/** Replaces a task in place by `tempId`, returning a NEW spec. */\nexport function UpdateTask(spec: TaskGraphSpec, tempId: string, next: TaskGraphSpecNode): TaskGraphSpec {\n return { ...spec, tasks: (spec.tasks ?? []).map((t) => (t.tempId === tempId ? next : t)) };\n}\n\n/**\n * Would adding `from → to` create a cycle?\n *\n * Answered before the edge exists, so the canvas can refuse it rather than create an invalid graph\n * and report it afterwards. A self-edge is the degenerate case and is caught first.\n *\n * Iterative rather than recursive: the graph may come from an LLM, and a deeply-chained spec should\n * produce a refusal, not a stack overflow.\n */\nexport function WouldCreateCycle(spec: TaskGraphSpec, fromTempId: string, toTempId: string): boolean {\n if (fromTempId === toTempId) return true;\n\n // A cycle appears iff `from` is already reachable from `to` by following dependsOn edges —\n // i.e. `to` already (transitively) waits on `from`.\n const dependenciesOf = new Map<string, string[]>(\n (spec.tasks ?? []).map((t) => [t.tempId, GetDependencies(t).map((d) => d.tempId)]),\n );\n\n const stack = [...(dependenciesOf.get(fromTempId) ?? [])];\n const seen = new Set<string>();\n while (stack.length > 0) {\n const current = stack.pop()!;\n if (current === toTempId) return true;\n if (seen.has(current)) continue;\n seen.add(current);\n stack.push(...(dependenciesOf.get(current) ?? []));\n }\n return false;\n}\n\n/** A unique `tempId` for a newly added task, stable and readable. */\nexport function NextTempId(spec: TaskGraphSpec, prefix = 'task'): string {\n const taken = new Set((spec.tasks ?? []).map((t) => t.tempId));\n let n = (spec.tasks ?? []).length + 1;\n while (taken.has(`${prefix}${n}`)) n++;\n return `${prefix}${n}`;\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VS Code-style debug chrome: Continue / Pause / Step Over / Step Into / Stop.
|
|
3
|
+
*
|
|
4
|
+
* Intent only. The host owns Pause/Resume/Step Remote Operations. This widget never imports
|
|
5
|
+
* a transport, so the same bar can sit in the test harness and on the Explorer run console.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from '@angular/core';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
export declare class TaskGraphDebugToolbarComponent {
|
|
10
|
+
/** Graph is claim-gated. Continue / Step show; Pause hides. */
|
|
11
|
+
Paused: boolean;
|
|
12
|
+
/** A control is in flight — buttons disable, they do not vanish. */
|
|
13
|
+
Busy: boolean;
|
|
14
|
+
/** False when the graph has settled or there is nothing to drive. */
|
|
15
|
+
Enabled: boolean;
|
|
16
|
+
/** Every step is terminal — Play/Step hide; Finished is the state. */
|
|
17
|
+
Settled: boolean;
|
|
18
|
+
Pause: EventEmitter<void>;
|
|
19
|
+
Resume: EventEmitter<void>;
|
|
20
|
+
Step: EventEmitter<void>;
|
|
21
|
+
StepWave: EventEmitter<void>;
|
|
22
|
+
Cancel: EventEmitter<void>;
|
|
23
|
+
OnHotkey(event: KeyboardEvent): void;
|
|
24
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TaskGraphDebugToolbarComponent, never>;
|
|
25
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<TaskGraphDebugToolbarComponent, "mj-task-graph-debug-toolbar", never, { "Paused": { "alias": "Paused"; "required": false; }; "Busy": { "alias": "Busy"; "required": false; }; "Enabled": { "alias": "Enabled"; "required": false; }; "Settled": { "alias": "Settled"; "required": false; }; }, { "Pause": "Pause"; "Resume": "Resume"; "Step": "Step"; "StepWave": "StepWave"; "Cancel": "Cancel"; }, never, never, true, never>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=task-graph-debug-toolbar.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-graph-debug-toolbar.component.d.ts","sourceRoot":"","sources":["../../src/lib/task-graph-debug-toolbar.component.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAsC,YAAY,EAA+B,MAAM,eAAe,CAAC;;AAE9G,qBAOa,8BAA8B;IACvC,+DAA+D;IAC/C,MAAM,UAAS;IAC/B,oEAAoE;IACpD,IAAI,UAAS;IAC7B,qEAAqE;IACrD,OAAO,UAAQ;IAC/B,sEAAsE;IACtD,OAAO,UAAS;IAEf,KAAK,qBAA4B;IACjC,MAAM,qBAA4B;IAClC,IAAI,qBAA4B;IAChC,QAAQ,qBAA4B;IACpC,MAAM,qBAA4B;IAG5C,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;yCAjBlC,8BAA8B;2CAA9B,8BAA8B;CAyC1C"}
|