Class: WorkflowStateCoordinator

Infrastructure/WorkflowOrchestration.WorkflowStateCoordinator()

Workflow State Coordinator

Constructor

new WorkflowStateCoordinator()

Source:

Methods

(async) addRecentArticle(article)

Add recent article to tracking

Parameters:
Name Type Description
article Object

Article metadata

Source:

(async) cacheMCPQuery(queryKey, result, ttl)

Cache MCP query result

Parameters:
Name Type Description
queryKey string

Unique identifier for the query

result any

Query result to cache

ttl number

Time to live in seconds (default: 2 hours)

Source:

calculateSimilarity() → {number}

Calculate similarity between two articles

Uses weighted combination of:

  • Title similarity (50%)
  • Topic overlap (30%)
  • MCP query overlap (20%)
Source:
Returns:

Similarity score 0.0-1.0

Type
number

(async) checkDuplicateArticle(title, topics, mcpQueries) → {Object}

Check if article is duplicate based on similarity

Parameters:
Name Type Description
title string

Article title

topics Array.<string>

Article topics

mcpQueries Array.<string>

MCP query keys used for this article

Source:
Returns:

{ isDuplicate: boolean, matchedArticle: Object|null, similarityScore: number }

Type
Object

cleanupExpiredEntries()

Clean up expired cache entries and old articles

Source:

getCachedMCPQuery(queryKey) → {any|null}

Get cached MCP query result

Parameters:
Name Type Description
queryKey string

Unique identifier for the query

Source:
Returns:

Cached result or null if expired/missing

Type
any | null

getRecentArticles(hours) → {Array}

Get recent articles from last N hours

Parameters:
Name Type Default Description
hours number 6

Hours to look back

Source:
Returns:

Recent articles

Type
Array

getWorkflowStatistics() → {Object}

Get workflow statistics

Source:
Returns:

Statistics by workflow

Type
Object

hashObject(obj) → {string}

Hash object for cache comparison

Parameters:
Name Type Description
obj any

Object to hash

Source:
Returns:

SHA-256 hash

Type
string

(async) load()

Load state from disk

Source:

(async) recordWorkflowExecution(workflowName, metadata)

Record workflow execution

Parameters:
Name Type Description
workflowName string

Name of workflow

metadata Object

Execution metadata

Source:

(async) save()

Save state to disk

Source:

setOverlap(set1, set2) → {number}

Calculate set overlap (Jaccard similarity)

Parameters:
Name Type Description
set1 Array

First set

set2 Array

Second set

Source:
Returns:

Overlap 0.0-1.0

Type
number

stringSimilarity(str1, str2) → {number}

Calculate string similarity using Jaccard similarity of word sets

Parameters:
Name Type Description
str1 string

First string

str2 string

Second string

Source:
Returns:

Similarity 0.0-1.0

Type
number