@auto-engineer/pipeline 1.131.0 → 1.134.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -15,8 +15,8 @@
15
15
  "jose": "^5.9.6",
16
16
  "nanoid": "^5.0.0",
17
17
  "uuid": "^11.0.0",
18
- "@auto-engineer/file-store": "1.131.0",
19
- "@auto-engineer/message-bus": "1.131.0"
18
+ "@auto-engineer/file-store": "1.134.0",
19
+ "@auto-engineer/message-bus": "1.134.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/cors": "^2.8.17",
@@ -25,7 +25,7 @@
25
25
  "publishConfig": {
26
26
  "access": "public"
27
27
  },
28
- "version": "1.131.0",
28
+ "version": "1.134.0",
29
29
  "scripts": {
30
30
  "build": "tsc && tsx ../../scripts/fix-esm-imports.ts",
31
31
  "test": "vitest run --reporter=dot",
@@ -21,7 +21,7 @@ export function initialState(): AwaitState {
21
21
  };
22
22
  }
23
23
 
24
- export function decide(input: AwaitInput, state: AwaitState): AwaitOutput | AwaitOutput[] {
24
+ export function decide(_input: AwaitInput, state: AwaitState): AwaitOutput | AwaitOutput[] {
25
25
  if (state.status !== 'waiting' || state.pendingKeys.length > 0) {
26
26
  return [];
27
27
  }
@@ -84,7 +84,7 @@ export function evolve(state: SettledState, event: SettledEvent): SettledState {
84
84
  }
85
85
  }
86
86
 
87
- export function decide(input: SettledInput, state: SettledState): SettledOutput | SettledOutput[] {
87
+ export function decide(_input: SettledInput, state: SettledState): SettledOutput | SettledOutput[] {
88
88
  if (state.status !== 'waiting') {
89
89
  return [];
90
90
  }
@@ -84,7 +84,7 @@ export function createPhasedBridge(config: PhasedBridgeConfig) {
84
84
  const key = handler.completion.itemKey({ type: event.type, data });
85
85
  const phase = handler.classifier(item);
86
86
  itemRecords.push({ key, phase, original: item });
87
- itemToExecution.set(key, correlationId + '|' + handler.eventType);
87
+ itemToExecution.set(key, `${correlationId}|${handler.eventType}`);
88
88
  }
89
89
 
90
90
  const execution: PhasedExecution = {
@@ -94,7 +94,7 @@ export function createPhasedBridge(config: PhasedBridgeConfig) {
94
94
  items: itemRecords,
95
95
  state: initialState(),
96
96
  };
97
- executions.set(correlationId + '|' + handler.eventType, execution);
97
+ executions.set(`${correlationId}|${handler.eventType}`, execution);
98
98
 
99
99
  const startInput: PhasedInput = {
100
100
  type: 'StartPhased',
@@ -29,7 +29,7 @@ export async function createPipelineServerV2(config?: { port?: number }): Promis
29
29
  res.json({ commands: engine.registeredCommands() });
30
30
  });
31
31
 
32
- app.get('/events', (req, res) => {
32
+ app.get('/events', (_req, res) => {
33
33
  res.writeHead(200, {
34
34
  'Content-Type': 'text/event-stream',
35
35
  'Cache-Control': 'no-cache',
@@ -351,6 +351,24 @@ describe('PipelineServer', () => {
351
351
  await server.stop();
352
352
  });
353
353
 
354
+ it('should use displayName for dynamically-added command nodes', async () => {
355
+ const handler = {
356
+ name: 'DynamicCmd',
357
+ displayName: 'Dynamic Command',
358
+ events: ['DynamicDone'],
359
+ handle: async () => ({ type: 'DynamicDone', data: {} }),
360
+ };
361
+ const pipeline = define('test').on('DynamicDone').emit('NextCmd', {}).build();
362
+ const server = new PipelineServer({ port: 0 });
363
+ server.registerCommandHandlers([handler]);
364
+ server.registerPipeline(pipeline);
365
+ await server.start();
366
+ const data = await fetchAs<GraphResponse>(`http://localhost:${server.port}/pipeline`);
367
+ const cmdNode = data.nodes.find((n) => n.id === 'cmd:DynamicCmd');
368
+ expect(cmdNode?.label).toBe('Dynamic Command');
369
+ await server.stop();
370
+ });
371
+
354
372
  it('should filter out event nodes when excludeTypes=event', async () => {
355
373
  const pipeline = define('test').on('Start').emit('Cmd', {}).build();
356
374
  const server = new PipelineServer({ port: 0 });
@@ -2225,7 +2243,7 @@ describe('PipelineServer', () => {
2225
2243
  const server = new PipelineServer({ port: 0 });
2226
2244
  server.registerItemKeyExtractor('ManualKeyCmd', (d) => {
2227
2245
  const data = d as Record<string, string>;
2228
- return data['customId'];
2246
+ return data.customId;
2229
2247
  });
2230
2248
  server.registerCommandHandlers([handler]);
2231
2249
  server.registerPipeline(pipeline);
@@ -320,12 +320,7 @@ export class PipelineServer {
320
320
 
321
321
  this.app.get('/pipeline', (req, res) => {
322
322
  void (async () => {
323
- const commandToEvents = this.buildCommandToEvents();
324
- const rawGraph = this.buildCombinedGraph();
325
- const pipelineEvents = this.extractPipelineEvents(rawGraph, commandToEvents);
326
- const graphWithEvents = this.addCommandEventEdgesToGraph(rawGraph, commandToEvents, pipelineEvents);
327
- const graphWithEnrichedEvents = this.enrichEventLabels(graphWithEvents);
328
- const completeGraph = this.markBackLinks(graphWithEnrichedEvents);
323
+ const completeGraph = this.buildFullGraph();
329
324
  const filterOptions = this.parseFilterOptions(req.query);
330
325
  const filteredGraph = filterGraph(completeGraph, filterOptions);
331
326
  const correlationId = (req.query.correlationId as string | undefined) ?? this.currentSessionId;
@@ -559,7 +554,17 @@ export class PipelineServer {
559
554
  combinedGraph.edges.push(...graph.edges);
560
555
  }
561
556
 
562
- return this.enrichCommandLabels(combinedGraph);
557
+ return combinedGraph;
558
+ }
559
+
560
+ private buildFullGraph(): GraphIR {
561
+ const commandToEvents = this.buildCommandToEvents();
562
+ const rawGraph = this.buildCombinedGraph();
563
+ const pipelineEvents = this.extractPipelineEvents(rawGraph, commandToEvents);
564
+ const graphWithEvents = this.addCommandEventEdgesToGraph(rawGraph, commandToEvents, pipelineEvents);
565
+ const graphWithEnrichedCommands = this.enrichCommandLabels(graphWithEvents);
566
+ const graphWithEnrichedEvents = this.enrichEventLabels(graphWithEnrichedCommands);
567
+ return this.markBackLinks(graphWithEnrichedEvents);
563
568
  }
564
569
 
565
570
  private enrichCommandLabels(graph: GraphIR): GraphIR {
@@ -568,7 +573,7 @@ export class PipelineServer {
568
573
  if (node.type !== 'command') {
569
574
  return node;
570
575
  }
571
- const handler = this.commandHandlers.get(node.label);
576
+ const handler = this.commandHandlers.get(node.id.replace('cmd:', ''));
572
577
  if (handler?.displayName === undefined) {
573
578
  return node;
574
579
  }
@@ -585,7 +590,7 @@ export class PipelineServer {
585
590
  if (node.type !== 'event') {
586
591
  return node;
587
592
  }
588
- const displayName = eventDisplayNames.get(node.label);
593
+ const displayName = eventDisplayNames.get(node.id.replace('evt:', ''));
589
594
  if (displayName === undefined) {
590
595
  return node;
591
596
  }
@@ -921,12 +926,7 @@ export class PipelineServer {
921
926
  }
922
927
 
923
928
  private buildMermaidDiagram(filterOptions: FilterOptions): string {
924
- const commandToEvents = this.buildCommandToEvents();
925
- const rawGraph = this.buildCombinedGraph();
926
- const pipelineEvents = this.extractPipelineEvents(rawGraph, commandToEvents);
927
- const graphWithEvents = this.addCommandEventEdgesToGraph(rawGraph, commandToEvents, pipelineEvents);
928
- const graphWithEnrichedEvents = this.enrichEventLabels(graphWithEvents);
929
- const completeGraph = this.markBackLinks(graphWithEnrichedEvents);
929
+ const completeGraph = this.buildFullGraph();
930
930
  const graph = filterGraph(completeGraph, filterOptions);
931
931
  const lines: string[] = ['flowchart LR'];
932
932