diff --git a/docs/apis/api-flow.md b/docs/apis/api-flow.md index f78d96fd..fbd3d660 100644 --- a/docs/apis/api-flow.md +++ b/docs/apis/api-flow.md @@ -1,6 +1,6 @@ # TrustGraph Flow API -This API provides workflow management for TrustGraph components. It manages flow classes +This API provides workflow management for TrustGraph components. It manages flow blueprintes (workflow templates) and flow instances (active running workflows) that orchestrate complex data processing pipelines. @@ -10,26 +10,26 @@ complex data processing pipelines. The request contains the following fields: - `operation`: The operation to perform (see operations below) -- `class_name`: Flow class name (for class operations and start-flow) -- `class_definition`: Flow class definition JSON (for put-class) +- `blueprint_name`: Flow blueprint name (for class operations and start-flow) +- `class_definition`: Flow blueprint definition JSON (for put-class) - `description`: Flow description (for start-flow) - `flow_id`: Flow instance ID (for flow instance operations) ### Response The response contains the following fields: -- `class_names`: Array of flow class names (returned by list-classes) +- `blueprint_names`: Array of flow blueprint names (returned by list-classes) - `flow_ids`: Array of active flow IDs (returned by list-flows) -- `class_definition`: Flow class definition JSON (returned by get-class) +- `class_definition`: Flow blueprint definition JSON (returned by get-class) - `flow`: Flow instance JSON (returned by get-flow) - `description`: Flow description (returned by get-flow) - `error`: Error information if operation fails ## Operations -### Flow Class Operations +### Flow Blueprint Operations -#### LIST-CLASSES - List All Flow Classes +#### LIST-CLASSES - List All Flow Blueprintes Request: ```json @@ -41,17 +41,17 @@ Request: Response: ```json { - "class_names": ["pdf-processor", "text-analyzer", "knowledge-extractor"] + "blueprint_names": ["pdf-processor", "text-analyzer", "knowledge-extractor"] } ``` -#### GET-CLASS - Get Flow Class Definition +#### GET-CLASS - Get Flow Blueprint Definition Request: ```json { "operation": "get-class", - "class_name": "pdf-processor" + "blueprint_name": "pdf-processor" } ``` @@ -62,13 +62,13 @@ Response: } ``` -#### PUT-CLASS - Create/Update Flow Class +#### PUT-CLASS - Create/Update Flow Blueprint Request: ```json { "operation": "put-class", - "class_name": "pdf-processor", + "blueprint_name": "pdf-processor", "class_definition": "{\"interfaces\": {\"text-completion\": {\"request\": \"persistent://tg/request/text-completion\", \"response\": \"persistent://tg/response/text-completion\"}}, \"description\": \"PDF processing workflow\"}" } ``` @@ -78,13 +78,13 @@ Response: {} ``` -#### DELETE-CLASS - Remove Flow Class +#### DELETE-CLASS - Remove Flow Blueprint Request: ```json { "operation": "delete-class", - "class_name": "pdf-processor" + "blueprint_name": "pdf-processor" } ``` @@ -135,7 +135,7 @@ Request: ```json { "operation": "start-flow", - "class_name": "pdf-processor", + "blueprint_name": "pdf-processor", "flow_id": "flow-123", "description": "Processing document batch 1" } @@ -186,7 +186,7 @@ Response: { "id": "unique-request-id", "response": { - "class_names": ["pdf-processor", "text-analyzer"] + "blueprint_names": ["pdf-processor", "text-analyzer"] }, "complete": true } @@ -264,11 +264,11 @@ from trustgraph.api.flow import FlowClient client = FlowClient() -# List all flow classes -classes = await client.list_classes() +# List all flow blueprintes +classes = await client.list_blueprints() -# Get a flow class definition -definition = await client.get_class("pdf-processor") +# Get a flow blueprint definition +definition = await client.get_blueprint("pdf-processor") # Start a flow instance await client.start_flow("pdf-processor", "flow-123", "Processing batch 1") @@ -286,8 +286,8 @@ result = await flow.mcp_tool("file-reader", {"path": "/path/to/file.txt"}) ## Features -- **Flow Classes**: Templates that define workflow structure and interfaces -- **Flow Instances**: Active running workflows based on flow classes +- **Flow Blueprintes**: Templates that define workflow structure and interfaces +- **Flow Instances**: Active running workflows based on flow blueprintes - **Dynamic Management**: Flows can be started/stopped dynamically - **Template Processing**: Uses template replacement for customizing flow instances - **Integration**: Works with TrustGraph ecosystem for data processing pipelines diff --git a/docs/cli/README.md b/docs/cli/README.md index 6a47dbbd..10f74c09 100644 --- a/docs/cli/README.md +++ b/docs/cli/README.md @@ -48,11 +48,11 @@ Most CLI commands support these common options: - [`tg-show-flows`](tg-show-flows.md) - List all configured flows - [`tg-show-flow-state`](tg-show-flow-state.md) - Show current flow states -**Flow Class Management:** -- [`tg-put-flow-class`](tg-put-flow-class.md) - Upload/update flow class definition -- [`tg-get-flow-class`](tg-get-flow-class.md) - Retrieve flow class definition -- [`tg-delete-flow-class`](tg-delete-flow-class.md) - Remove flow class definition -- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes +**Flow Blueprint Management:** +- [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Upload/update flow blueprint definition +- [`tg-get-flow-blueprint`](tg-get-flow-blueprint.md) - Retrieve flow blueprint definition +- [`tg-delete-flow-blueprint`](tg-delete-flow-blueprint.md) - Remove flow blueprint definition +- [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes ### Knowledge Graph Management @@ -115,7 +115,7 @@ Most CLI commands support these common options: ### Basic Document Processing ```bash # Start a flow -tg-start-flow --flow-id my-flow --class-name document-processing +tg-start-flow --flow-id my-flow --blueprint-name document-processing # Load a document tg-load-text --flow-id my-flow --text "Your document content" --title "Test Document" @@ -138,8 +138,8 @@ tg-show-graph --limit 100 ### Flow Management ```bash -# Show available flow classes -tg-show-flow-classes +# Show available flow blueprintes +tg-show-flow-blueprints # Show running flows tg-show-flows diff --git a/docs/cli/tg-delete-flow-class.md b/docs/cli/tg-delete-flow-blueprint.md similarity index 53% rename from docs/cli/tg-delete-flow-class.md rename to docs/cli/tg-delete-flow-blueprint.md index cc3c58d8..c99fd6da 100644 --- a/docs/cli/tg-delete-flow-class.md +++ b/docs/cli/tg-delete-flow-blueprint.md @@ -1,24 +1,24 @@ -# tg-delete-flow-class +# tg-delete-flow-blueprint -Permanently deletes a flow class definition from TrustGraph. +Permanently deletes a flow blueprint definition from TrustGraph. ## Synopsis ```bash -tg-delete-flow-class -n CLASS_NAME [options] +tg-delete-flow-blueprint -n CLASS_NAME [options] ``` ## Description -The `tg-delete-flow-class` command permanently removes a flow class definition from TrustGraph. This operation cannot be undone, so use with caution. +The `tg-delete-flow-blueprint` command permanently removes a flow blueprint definition from TrustGraph. This operation cannot be undone, so use with caution. -**⚠️ Warning**: Deleting a flow class that has active flow instances may cause those instances to become unusable. Always check for active flows before deletion. +**⚠️ Warning**: Deleting a flow blueprint that has active flow instances may cause those instances to become unusable. Always check for active flows before deletion. ## Options ### Required Arguments -- `-n, --class-name CLASS_NAME`: Name of the flow class to delete +- `-n, --blueprint-name CLASS_NAME`: Name of the flow blueprint to delete ### Optional Arguments @@ -26,65 +26,65 @@ The `tg-delete-flow-class` command permanently removes a flow class definition f ## Examples -### Delete a Flow Class +### Delete a Flow Blueprint ```bash -tg-delete-flow-class -n "old-test-flow" +tg-delete-flow-blueprint -n "old-test-flow" ``` ### Delete with Custom API URL ```bash -tg-delete-flow-class -n "deprecated-flow" -u http://staging:8088/ +tg-delete-flow-blueprint -n "deprecated-flow" -u http://staging:8088/ ``` ### Safe Deletion Workflow ```bash -# 1. Check if flow class exists -tg-show-flow-classes | grep "target-flow" +# 1. Check if flow blueprint exists +tg-show-flow-blueprints | grep "target-flow" -# 2. Backup the flow class first -tg-get-flow-class -n "target-flow" > backup-target-flow.json +# 2. Backup the flow blueprint first +tg-get-flow-blueprint -n "target-flow" > backup-target-flow.json # 3. Check for active flow instances tg-show-flows | grep "target-flow" -# 4. Delete the flow class -tg-delete-flow-class -n "target-flow" +# 4. Delete the flow blueprint +tg-delete-flow-blueprint -n "target-flow" # 5. Verify deletion -tg-show-flow-classes | grep "target-flow" || echo "Flow class deleted successfully" +tg-show-flow-blueprints | grep "target-flow" || echo "Flow blueprint deleted successfully" ``` ## Prerequisites -### Flow Class Must Exist -Verify the flow class exists before attempting deletion: +### Flow Blueprint Must Exist +Verify the flow blueprint exists before attempting deletion: ```bash -# List all flow classes -tg-show-flow-classes +# List all flow blueprintes +tg-show-flow-blueprints -# Check specific flow class -tg-show-flow-classes | grep "target-class" +# Check specific flow blueprint +tg-show-flow-blueprints | grep "target-class" ``` ### Check for Active Flow Instances -Before deleting a flow class, check if any flow instances are using it: +Before deleting a flow blueprint, check if any flow instances are using it: ```bash # List all active flows tg-show-flows -# Look for instances using the flow class +# Look for instances using the flow blueprint tg-show-flows | grep "target-class" ``` ## Error Handling -### Flow Class Not Found +### Flow Blueprint Not Found ```bash -Exception: Flow class 'nonexistent-class' not found +Exception: Flow blueprint 'nonexistent-class' not found ``` -**Solution**: Verify the flow class exists with `tg-show-flow-classes`. +**Solution**: Verify the flow blueprint exists with `tg-show-flow-blueprints`. ### Connection Errors ```bash @@ -94,13 +94,13 @@ Exception: Connection refused ### Permission Errors ```bash -Exception: Access denied to delete flow class +Exception: Access denied to delete flow blueprint ``` -**Solution**: Verify user permissions for flow class management. +**Solution**: Verify user permissions for flow blueprint management. ### Active Flow Instances ```bash -Exception: Cannot delete flow class with active instances +Exception: Cannot delete flow blueprint with active instances ``` **Solution**: Stop all flow instances using this class before deletion. @@ -108,37 +108,37 @@ Exception: Cannot delete flow class with active instances ### Cleanup Development Classes ```bash -# Delete test and development flow classes +# Delete test and development flow blueprintes test_classes=("test-flow-v1" "dev-experiment" "prototype-flow") for class in "${test_classes[@]}"; do echo "Deleting $class..." - tg-delete-flow-class -n "$class" + tg-delete-flow-blueprint -n "$class" done ``` ### Migration Cleanup ```bash -# After migrating to new flow classes, remove old ones +# After migrating to new flow blueprintes, remove old ones old_classes=("legacy-flow" "deprecated-processor" "old-pipeline") for class in "${old_classes[@]}"; do # Backup first - tg-get-flow-class -n "$class" > "backup-$class.json" 2>/dev/null + tg-get-flow-blueprint -n "$class" > "backup-$class.json" 2>/dev/null # Delete - tg-delete-flow-class -n "$class" + tg-delete-flow-blueprint -n "$class" echo "Deleted $class" done ``` ### Conditional Deletion ```bash -# Delete flow class only if no active instances exist +# Delete flow blueprint only if no active instances exist flow_class="target-flow" active_instances=$(tg-show-flows | grep "$flow_class" | wc -l) if [ $active_instances -eq 0 ]; then - echo "No active instances found, deleting flow class..." - tg-delete-flow-class -n "$flow_class" + echo "No active instances found, deleting flow blueprint..." + tg-delete-flow-blueprint -n "$flow_class" else echo "Warning: $active_instances active instances found. Cannot delete." tg-show-flows | grep "$flow_class" @@ -154,13 +154,13 @@ flow_class="important-flow" backup_dir="flow-class-backups/$(date +%Y%m%d-%H%M%S)" mkdir -p "$backup_dir" -echo "Backing up flow class: $flow_class" -tg-get-flow-class -n "$flow_class" > "$backup_dir/$flow_class.json" +echo "Backing up flow blueprint: $flow_class" +tg-get-flow-blueprint -n "$flow_class" > "$backup_dir/$flow_class.json" if [ $? -eq 0 ]; then echo "Backup created: $backup_dir/$flow_class.json" echo "Proceeding with deletion..." - tg-delete-flow-class -n "$flow_class" + tg-delete-flow-blueprint -n "$flow_class" else echo "Backup failed. Aborting deletion." exit 1 @@ -174,22 +174,22 @@ fi flow_class="$1" if [ -z "$flow_class" ]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi -echo "Safety checks for deleting flow class: $flow_class" +echo "Safety checks for deleting flow blueprint: $flow_class" -# Check if flow class exists -if ! tg-show-flow-classes | grep -q "$flow_class"; then - echo "ERROR: Flow class '$flow_class' not found" +# Check if flow blueprint exists +if ! tg-show-flow-blueprints | grep -q "$flow_class"; then + echo "ERROR: Flow blueprint '$flow_class' not found" exit 1 fi # Check for active instances active_count=$(tg-show-flows | grep "$flow_class" | wc -l) if [ $active_count -gt 0 ]; then - echo "ERROR: Found $active_count active instances using this flow class" + echo "ERROR: Found $active_count active instances using this flow blueprint" echo "Active instances:" tg-show-flows | grep "$flow_class" exit 1 @@ -198,7 +198,7 @@ fi # Create backup backup_file="backup-$flow_class-$(date +%Y%m%d-%H%M%S).json" echo "Creating backup: $backup_file" -tg-get-flow-class -n "$flow_class" > "$backup_file" +tg-get-flow-blueprint -n "$flow_class" > "$backup_file" if [ $? -ne 0 ]; then echo "ERROR: Failed to create backup" @@ -206,19 +206,19 @@ if [ $? -ne 0 ]; then fi # Confirm deletion -echo "Ready to delete flow class: $flow_class" +echo "Ready to delete flow blueprint: $flow_class" echo "Backup saved as: $backup_file" -read -p "Are you sure you want to delete this flow class? (y/N): " confirm +read -p "Are you sure you want to delete this flow blueprint? (y/N): " confirm if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then - echo "Deleting flow class..." - tg-delete-flow-class -n "$flow_class" + echo "Deleting flow blueprint..." + tg-delete-flow-blueprint -n "$flow_class" # Verify deletion - if ! tg-show-flow-classes | grep -q "$flow_class"; then - echo "Flow class deleted successfully" + if ! tg-show-flow-blueprints | grep -q "$flow_class"; then + echo "Flow blueprint deleted successfully" else - echo "ERROR: Flow class still exists after deletion" + echo "ERROR: Flow blueprint still exists after deletion" exit 1 fi else @@ -229,13 +229,13 @@ fi ## Integration with Other Commands -### Complete Flow Class Lifecycle +### Complete Flow Blueprint Lifecycle ```bash -# 1. List existing flow classes -tg-show-flow-classes +# 1. List existing flow blueprintes +tg-show-flow-blueprints -# 2. Get flow class details -tg-get-flow-class -n "target-flow" +# 2. Get flow blueprint details +tg-get-flow-blueprint -n "target-flow" # 3. Check for active instances tg-show-flows | grep "target-flow" @@ -244,25 +244,25 @@ tg-show-flows | grep "target-flow" tg-stop-flow -i "instance-id" # 5. Create backup -tg-get-flow-class -n "target-flow" > backup.json +tg-get-flow-blueprint -n "target-flow" > backup.json -# 6. Delete flow class -tg-delete-flow-class -n "target-flow" +# 6. Delete flow blueprint +tg-delete-flow-blueprint -n "target-flow" # 7. Verify deletion -tg-show-flow-classes | grep "target-flow" +tg-show-flow-blueprints | grep "target-flow" ``` ### Bulk Deletion with Validation ```bash -# Delete multiple flow classes safely +# Delete multiple flow blueprintes safely classes_to_delete=("old-flow1" "old-flow2" "test-flow") for class in "${classes_to_delete[@]}"; do echo "Processing $class..." # Check if exists - if ! tg-show-flow-classes | grep -q "$class"; then + if ! tg-show-flow-blueprints | grep -q "$class"; then echo " $class not found, skipping" continue fi @@ -274,8 +274,8 @@ for class in "${classes_to_delete[@]}"; do fi # Backup and delete - tg-get-flow-class -n "$class" > "backup-$class.json" - tg-delete-flow-class -n "$class" + tg-get-flow-blueprint -n "$class" > "backup-$class.json" + tg-delete-flow-blueprint -n "$class" echo " $class deleted" done ``` @@ -286,15 +286,15 @@ done ## Related Commands -- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes -- [`tg-get-flow-class`](tg-get-flow-class.md) - Retrieve flow class definitions -- [`tg-put-flow-class`](tg-put-flow-class.md) - Create/update flow class definitions +- [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes +- [`tg-get-flow-blueprint`](tg-get-flow-blueprint.md) - Retrieve flow blueprint definitions +- [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Create/update flow blueprint definitions - [`tg-show-flows`](tg-show-flows.md) - List active flow instances - [`tg-stop-flow`](tg-stop-flow.md) - Stop flow instances ## API Integration -This command uses the [Flow API](../apis/api-flow.md) with the `delete-class` operation to remove flow class definitions. +This command uses the [Flow API](../apis/api-flow.md) with the `delete-class` operation to remove flow blueprint definitions. ## Best Practices @@ -310,10 +310,10 @@ This command uses the [Flow API](../apis/api-flow.md) with the `delete-class` op ### Command Succeeds but Class Still Exists ```bash # Check if deletion actually occurred -tg-show-flow-classes | grep "deleted-class" +tg-show-flow-blueprints | grep "deleted-class" # Verify API connectivity -tg-show-flow-classes > /dev/null && echo "API accessible" +tg-show-flow-blueprints > /dev/null && echo "API accessible" ``` ### Permissions Issues diff --git a/docs/cli/tg-get-flow-class.md b/docs/cli/tg-get-flow-blueprint.md similarity index 52% rename from docs/cli/tg-get-flow-class.md rename to docs/cli/tg-get-flow-blueprint.md index c71b4367..1998c3b1 100644 --- a/docs/cli/tg-get-flow-class.md +++ b/docs/cli/tg-get-flow-blueprint.md @@ -1,24 +1,24 @@ -# tg-get-flow-class +# tg-get-flow-blueprint -Retrieves and displays a flow class definition in JSON format. +Retrieves and displays a flow blueprint definition in JSON format. ## Synopsis ```bash -tg-get-flow-class -n CLASS_NAME [options] +tg-get-flow-blueprint -n CLASS_NAME [options] ``` ## Description -The `tg-get-flow-class` command retrieves a stored flow class definition from TrustGraph and displays it in formatted JSON. This is useful for examining flow class configurations, creating backups, or preparing to modify existing flow classes. +The `tg-get-flow-blueprint` command retrieves a stored flow blueprint definition from TrustGraph and displays it in formatted JSON. This is useful for examining flow blueprint configurations, creating backups, or preparing to modify existing flow blueprintes. -The output can be saved to files for version control, documentation, or as input for creating new flow classes with `tg-put-flow-class`. +The output can be saved to files for version control, documentation, or as input for creating new flow blueprintes with `tg-put-flow-blueprint`. ## Options ### Required Arguments -- `-n, --class-name CLASS_NAME`: Name of the flow class to retrieve +- `-n, --blueprint-name CLASS_NAME`: Name of the flow blueprint to retrieve ### Optional Arguments @@ -26,32 +26,32 @@ The output can be saved to files for version control, documentation, or as input ## Examples -### Display Flow Class Definition +### Display Flow Blueprint Definition ```bash -tg-get-flow-class -n "document-processing" +tg-get-flow-blueprint -n "document-processing" ``` -### Save Flow Class to File +### Save Flow Blueprint to File ```bash -tg-get-flow-class -n "production-flow" > production-flow-backup.json +tg-get-flow-blueprint -n "production-flow" > production-flow-backup.json ``` -### Compare Flow Classes +### Compare Flow Blueprintes ```bash -# Get multiple flow classes for comparison -tg-get-flow-class -n "dev-flow" > dev-flow.json -tg-get-flow-class -n "prod-flow" > prod-flow.json +# Get multiple flow blueprintes for comparison +tg-get-flow-blueprint -n "dev-flow" > dev-flow.json +tg-get-flow-blueprint -n "prod-flow" > prod-flow.json diff dev-flow.json prod-flow.json ``` ### Using Custom API URL ```bash -tg-get-flow-class -n "remote-flow" -u http://production:8088/ +tg-get-flow-blueprint -n "remote-flow" -u http://production:8088/ ``` ## Output Format -The command outputs the flow class definition in formatted JSON: +The command outputs the flow blueprint definition in formatted JSON: ```json { @@ -76,7 +76,7 @@ The command outputs the flow class definition in formatted JSON: ### Key Components #### Description -Human-readable description of the flow class purpose and capabilities. +Human-readable description of the flow blueprint purpose and capabilities. #### Interfaces Service definitions showing: @@ -84,28 +84,28 @@ Service definitions showing: - **Fire-and-Forget Services**: Services with only input queues #### Tags (Optional) -Categorization tags for organizing flow classes. +Categorization tags for organizing flow blueprintes. ## Prerequisites -### Flow Class Must Exist -Verify the flow class exists before retrieval: +### Flow Blueprint Must Exist +Verify the flow blueprint exists before retrieval: ```bash -# Check available flow classes -tg-show-flow-classes +# Check available flow blueprintes +tg-show-flow-blueprints # Look for specific class -tg-show-flow-classes | grep "target-class" +tg-show-flow-blueprints | grep "target-class" ``` ## Error Handling -### Flow Class Not Found +### Flow Blueprint Not Found ```bash -Exception: Flow class 'invalid-class' not found +Exception: Flow blueprint 'invalid-class' not found ``` -**Solution**: Check available classes with `tg-show-flow-classes` and verify the class name. +**Solution**: Check available classes with `tg-show-flow-blueprints` and verify the class name. ### Connection Errors ```bash @@ -115,54 +115,54 @@ Exception: Connection refused ### Permission Errors ```bash -Exception: Access denied to flow class +Exception: Access denied to flow blueprint ``` -**Solution**: Verify user permissions for accessing flow class definitions. +**Solution**: Verify user permissions for accessing flow blueprint definitions. ## Use Cases ### Configuration Backup ```bash -# Backup all flow classes +# Backup all flow blueprintes mkdir -p flow-class-backups/$(date +%Y%m%d) -tg-show-flow-classes | awk '{print $1}' | while read class; do +tg-show-flow-blueprints | awk '{print $1}' | while read class; do if [ "$class" != "flow" ]; then # Skip header - tg-get-flow-class -n "$class" > "flow-class-backups/$(date +%Y%m%d)/$class.json" + tg-get-flow-blueprint -n "$class" > "flow-class-backups/$(date +%Y%m%d)/$class.json" fi done ``` -### Flow Class Migration +### Flow Blueprint Migration ```bash # Export from source environment -tg-get-flow-class -n "production-flow" -u http://source:8088/ > prod-flow.json +tg-get-flow-blueprint -n "production-flow" -u http://source:8088/ > prod-flow.json # Import to target environment -tg-put-flow-class -n "production-flow" -c "$(cat prod-flow.json)" -u http://target:8088/ +tg-put-flow-blueprint -n "production-flow" -c "$(cat prod-flow.json)" -u http://target:8088/ ``` ### Template Creation ```bash -# Get existing flow class as template -tg-get-flow-class -n "base-flow" > template.json +# Get existing flow blueprint as template +tg-get-flow-blueprint -n "base-flow" > template.json # Modify template and create new class sed 's/base-flow/new-flow/g' template.json > new-flow.json -tg-put-flow-class -n "custom-flow" -c "$(cat new-flow.json)" +tg-put-flow-blueprint -n "custom-flow" -c "$(cat new-flow.json)" ``` ### Configuration Analysis ```bash -# Analyze flow class configurations -tg-get-flow-class -n "complex-flow" | jq '.interfaces | keys' -tg-get-flow-class -n "complex-flow" | jq '.interfaces | length' +# Analyze flow blueprint configurations +tg-get-flow-blueprint -n "complex-flow" | jq '.interfaces | keys' +tg-get-flow-blueprint -n "complex-flow" | jq '.interfaces | length' ``` ### Version Control Integration ```bash -# Store flow classes in git +# Store flow blueprintes in git mkdir -p flow-classes -tg-get-flow-class -n "main-flow" > flow-classes/main-flow.json +tg-get-flow-blueprint -n "main-flow" > flow-classes/main-flow.json git add flow-classes/main-flow.json git commit -m "Update main-flow configuration" ``` @@ -172,60 +172,60 @@ git commit -m "Update main-flow configuration" ### Extract Specific Information ```bash # Get only interface names -tg-get-flow-class -n "my-flow" | jq -r '.interfaces | keys[]' +tg-get-flow-blueprint -n "my-flow" | jq -r '.interfaces | keys[]' # Get only description -tg-get-flow-class -n "my-flow" | jq -r '.description' +tg-get-flow-blueprint -n "my-flow" | jq -r '.description' # Get request queues -tg-get-flow-class -n "my-flow" | jq -r '.interfaces | to_entries[] | select(.value.request) | .value.request' +tg-get-flow-blueprint -n "my-flow" | jq -r '.interfaces | to_entries[] | select(.value.request) | .value.request' ``` ### Validate Configuration ```bash # Validate JSON structure -tg-get-flow-class -n "my-flow" | jq . > /dev/null && echo "Valid JSON" || echo "Invalid JSON" +tg-get-flow-blueprint -n "my-flow" | jq . > /dev/null && echo "Valid JSON" || echo "Invalid JSON" # Check required fields -config=$(tg-get-flow-class -n "my-flow") +config=$(tg-get-flow-blueprint -n "my-flow") echo "$config" | jq -e '.description' > /dev/null || echo "Missing description" echo "$config" | jq -e '.interfaces' > /dev/null || echo "Missing interfaces" ``` ## Integration with Other Commands -### Flow Class Lifecycle +### Flow Blueprint Lifecycle ```bash -# 1. Examine existing flow class -tg-get-flow-class -n "old-flow" +# 1. Examine existing flow blueprint +tg-get-flow-blueprint -n "old-flow" # 2. Save backup -tg-get-flow-class -n "old-flow" > old-flow-backup.json +tg-get-flow-blueprint -n "old-flow" > old-flow-backup.json # 3. Modify configuration cp old-flow-backup.json new-flow.json # Edit new-flow.json as needed # 4. Upload new version -tg-put-flow-class -n "updated-flow" -c "$(cat new-flow.json)" +tg-put-flow-blueprint -n "updated-flow" -c "$(cat new-flow.json)" -# 5. Test new flow class +# 5. Test new flow blueprint tg-start-flow -n "updated-flow" -i "test-instance" -d "Testing updated flow" ``` ### Bulk Operations ```bash -# Process multiple flow classes +# Process multiple flow blueprintes flow_classes=("flow1" "flow2" "flow3") for class in "${flow_classes[@]}"; do echo "Processing $class..." - tg-get-flow-class -n "$class" > "backup-$class.json" + tg-get-flow-blueprint -n "$class" > "backup-$class.json" # Modify configuration sed 's/old-pattern/new-pattern/g' "backup-$class.json" > "updated-$class.json" # Upload updated version - tg-put-flow-class -n "$class" -c "$(cat updated-$class.json)" + tg-put-flow-blueprint -n "$class" -c "$(cat updated-$class.json)" done ``` @@ -235,29 +235,29 @@ done ## Related Commands -- [`tg-put-flow-class`](tg-put-flow-class.md) - Upload/update flow class definitions -- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes -- [`tg-delete-flow-class`](tg-delete-flow-class.md) - Remove flow class definitions +- [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Upload/update flow blueprint definitions +- [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes +- [`tg-delete-flow-blueprint`](tg-delete-flow-blueprint.md) - Remove flow blueprint definitions - [`tg-start-flow`](tg-start-flow.md) - Create flow instances from classes ## API Integration -This command uses the [Flow API](../apis/api-flow.md) with the `get-class` operation to retrieve flow class definitions. +This command uses the [Flow API](../apis/api-flow.md) with the `get-class` operation to retrieve flow blueprint definitions. ## Advanced Usage ### Configuration Diff ```bash -# Compare flow class versions -tg-get-flow-class -n "flow-v1" > v1.json -tg-get-flow-class -n "flow-v2" > v2.json +# Compare flow blueprint versions +tg-get-flow-blueprint -n "flow-v1" > v1.json +tg-get-flow-blueprint -n "flow-v2" > v2.json diff -u v1.json v2.json ``` ### Extract Queue Information ```bash -# Get all queue names from flow class -tg-get-flow-class -n "my-flow" | jq -r ' +# Get all queue names from flow blueprint +tg-get-flow-blueprint -n "my-flow" | jq -r ' .interfaces | to_entries[] | if .value | type == "object" then @@ -275,16 +275,16 @@ tg-get-flow-class -n "my-flow" | jq -r ' flow_class="$1" if [ -z "$flow_class" ]; then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi -echo "Validating flow class: $flow_class" +echo "Validating flow blueprint: $flow_class" # Get configuration -config=$(tg-get-flow-class -n "$flow_class" 2>/dev/null) +config=$(tg-get-flow-blueprint -n "$flow_class" 2>/dev/null) if [ $? -ne 0 ]; then - echo "ERROR: Flow class not found" + echo "ERROR: Flow blueprint not found" exit 1 fi @@ -307,32 +307,32 @@ if [ -z "$interfaces" ] || [ "$interfaces" = "null" ]; then exit 1 fi -echo "Flow class validation passed" +echo "Flow blueprint validation passed" ``` ## Best Practices -1. **Regular Backups**: Save flow class definitions before modifications +1. **Regular Backups**: Save flow blueprint definitions before modifications 2. **Version Control**: Store configurations in version control systems -3. **Documentation**: Include meaningful descriptions in flow classes +3. **Documentation**: Include meaningful descriptions in flow blueprintes 4. **Validation**: Validate JSON structure before using configurations 5. **Template Management**: Use existing classes as templates for new ones -6. **Change Tracking**: Document changes when updating flow classes +6. **Change Tracking**: Document changes when updating flow blueprintes ## Troubleshooting ### Empty Output ```bash # If command returns empty output -tg-get-flow-class -n "my-flow" -# Check if flow class exists -tg-show-flow-classes | grep "my-flow" +tg-get-flow-blueprint -n "my-flow" +# Check if flow blueprint exists +tg-show-flow-blueprints | grep "my-flow" ``` ### Invalid JSON Output ```bash # If output appears corrupted -tg-get-flow-class -n "my-flow" | jq . +tg-get-flow-blueprint -n "my-flow" | jq . # Should show parsing error if JSON is invalid ``` diff --git a/docs/cli/tg-invoke-mcp-tool.md b/docs/cli/tg-invoke-mcp-tool.md index 0f6f9fdf..61a061d8 100644 --- a/docs/cli/tg-invoke-mcp-tool.md +++ b/docs/cli/tg-invoke-mcp-tool.md @@ -435,7 +435,7 @@ tg-invoke-mcp-tool -n tool-name -P '{}' tg-show-flows | grep "flow-id" # Verify flow supports MCP tools -tg-get-flow-class -n "flow-class" | jq '.interfaces.mcp_tool' +tg-get-flow-blueprint -n "flow-class" | jq '.interfaces.mcp_tool' ``` ### Connection Issues diff --git a/docs/cli/tg-invoke-prompt.md b/docs/cli/tg-invoke-prompt.md index a8c48ecb..1006be6f 100644 --- a/docs/cli/tg-invoke-prompt.md +++ b/docs/cli/tg-invoke-prompt.md @@ -426,5 +426,5 @@ echo "variable=value" | grep "=" tg-show-flows | grep "flow-id" # Verify flow has prompt service -tg-get-flow-class -n "flow-class" | jq '.interfaces.prompt' +tg-get-flow-blueprint -n "flow-class" | jq '.interfaces.prompt' ``` \ No newline at end of file diff --git a/docs/cli/tg-put-flow-class.md b/docs/cli/tg-put-flow-blueprint.md similarity index 76% rename from docs/cli/tg-put-flow-class.md rename to docs/cli/tg-put-flow-blueprint.md index 7b62b5e4..059d4efa 100644 --- a/docs/cli/tg-put-flow-class.md +++ b/docs/cli/tg-put-flow-blueprint.md @@ -1,25 +1,25 @@ -# tg-put-flow-class +# tg-put-flow-blueprint -Uploads or updates a flow class definition in TrustGraph. +Uploads or updates a flow blueprint definition in TrustGraph. ## Synopsis ```bash -tg-put-flow-class -n CLASS_NAME -c CONFIG_JSON [options] +tg-put-flow-blueprint -n CLASS_NAME -c CONFIG_JSON [options] ``` ## Description -The `tg-put-flow-class` command creates or updates a flow class definition in TrustGraph. Flow classes are templates that define processing pipeline configurations, service interfaces, and resource requirements. These classes are used by `tg-start-flow` to create running flow instances. +The `tg-put-flow-blueprint` command creates or updates a flow blueprint definition in TrustGraph. Flow blueprintes are templates that define processing pipeline configurations, service interfaces, and resource requirements. These classes are used by `tg-start-flow` to create running flow instances. -Flow classes define the structure and capabilities of processing flows, including which services are available and how they connect to Pulsar queues. +Flow blueprintes define the structure and capabilities of processing flows, including which services are available and how they connect to Pulsar queues. ## Options ### Required Arguments -- `-n, --class-name CLASS_NAME`: Name for the flow class -- `-c, --config CONFIG_JSON`: Flow class configuration as raw JSON string +- `-n, --blueprint-name CLASS_NAME`: Name for the flow blueprint +- `-c, --config CONFIG_JSON`: Flow blueprint configuration as raw JSON string ### Optional Arguments @@ -27,16 +27,16 @@ Flow classes define the structure and capabilities of processing flows, includin ## Examples -### Basic Flow Class Creation +### Basic Flow Blueprint Creation ```bash -tg-put-flow-class \ +tg-put-flow-blueprint \ -n "simple-processing" \ -c '{"description": "Simple text processing flow", "interfaces": {"text-completion": {"request": "non-persistent://tg/request/text-completion:simple", "response": "non-persistent://tg/response/text-completion:simple"}}}' ``` -### Document Processing Flow Class +### Document Processing Flow Blueprint ```bash -tg-put-flow-class \ +tg-put-flow-blueprint \ -n "document-analysis" \ -c '{ "description": "Document analysis and RAG processing", @@ -80,14 +80,14 @@ cat > research-flow.json << 'EOF' } EOF -# Upload the flow class -tg-put-flow-class -n "research-analysis" -c "$(cat research-flow.json)" +# Upload the flow blueprint +tg-put-flow-blueprint -n "research-analysis" -c "$(cat research-flow.json)" ``` -### Update Existing Flow Class +### Update Existing Flow Blueprint ```bash -# Modify existing flow class by adding new service -tg-put-flow-class \ +# Modify existing flow blueprint by adding new service +tg-put-flow-blueprint \ -n "existing-flow" \ -c '{ "description": "Updated flow with new capabilities", @@ -104,14 +104,14 @@ tg-put-flow-class \ }' ``` -## Flow Class Configuration Format +## Flow Blueprint Configuration Format ### Required Fields #### Description ```json { - "description": "Human-readable description of the flow class" + "description": "Human-readable description of the flow blueprint" } ``` @@ -180,9 +180,9 @@ persistent://tg/flow/{service}:{flow-identifier} ## Complete Example -### Comprehensive Flow Class +### Comprehensive Flow Blueprint ```bash -tg-put-flow-class \ +tg-put-flow-blueprint \ -n "full-processing-pipeline" \ -c '{ "description": "Complete document processing and analysis pipeline", @@ -234,11 +234,11 @@ tg-put-flow-class \ Successful upload typically produces no output: ```bash -# Upload flow class (no output expected) -tg-put-flow-class -n "my-flow" -c '{"description": "test", "interfaces": {}}' +# Upload flow blueprint (no output expected) +tg-put-flow-blueprint -n "my-flow" -c '{"description": "test", "interfaces": {}}' # Verify upload -tg-show-flow-classes | grep "my-flow" +tg-show-flow-blueprints | grep "my-flow" ``` ## Error Handling @@ -276,27 +276,27 @@ config='{"description": "test flow", "interfaces": {}}' echo "$config" | jq . > /dev/null && echo "Valid JSON" || echo "Invalid JSON" ``` -### Flow Class Verification +### Flow Blueprint Verification ```bash -# After uploading, verify the flow class exists -tg-show-flow-classes | grep "my-flow-class" +# After uploading, verify the flow blueprint exists +tg-show-flow-blueprints | grep "my-flow-class" -# Get the flow class definition to verify content -tg-get-flow-class -n "my-flow-class" +# Get the flow blueprint definition to verify content +tg-get-flow-blueprint -n "my-flow-class" ``` -## Flow Class Lifecycle +## Flow Blueprint Lifecycle ### Development Workflow ```bash -# 1. Create flow class -tg-put-flow-class -n "dev-flow" -c "$dev_config" +# 1. Create flow blueprint +tg-put-flow-blueprint -n "dev-flow" -c "$dev_config" # 2. Test with flow instance tg-start-flow -n "dev-flow" -i "test-instance" -d "Testing" -# 3. Update flow class as needed -tg-put-flow-class -n "dev-flow" -c "$updated_config" +# 3. Update flow blueprint as needed +tg-put-flow-blueprint -n "dev-flow" -c "$updated_config" # 4. Restart flow instance with updates tg-stop-flow -i "test-instance" @@ -309,53 +309,53 @@ tg-start-flow -n "dev-flow" -i "test-instance" -d "Testing updated" ## Related Commands -- [`tg-get-flow-class`](tg-get-flow-class.md) - Retrieve flow class definitions -- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes -- [`tg-delete-flow-class`](tg-delete-flow-class.md) - Remove flow class definitions +- [`tg-get-flow-blueprint`](tg-get-flow-blueprint.md) - Retrieve flow blueprint definitions +- [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes +- [`tg-delete-flow-blueprint`](tg-delete-flow-blueprint.md) - Remove flow blueprint definitions - [`tg-start-flow`](tg-start-flow.md) - Create flow instances from classes ## API Integration -This command uses the [Flow API](../apis/api-flow.md) with the `put-class` operation to store flow class definitions. +This command uses the [Flow API](../apis/api-flow.md) with the `put-class` operation to store flow blueprint definitions. ## Use Cases ### Custom Processing Pipelines ```bash # Create specialized medical analysis flow -tg-put-flow-class -n "medical-nlp" -c "$medical_config" +tg-put-flow-blueprint -n "medical-nlp" -c "$medical_config" ``` ### Development Environments ```bash # Create lightweight development flow -tg-put-flow-class -n "dev-minimal" -c "$minimal_config" +tg-put-flow-blueprint -n "dev-minimal" -c "$minimal_config" ``` ### Production Deployments ```bash # Create robust production flow with all services -tg-put-flow-class -n "production-full" -c "$production_config" +tg-put-flow-blueprint -n "production-full" -c "$production_config" ``` ### Domain-Specific Workflows ```bash # Create legal document analysis flow -tg-put-flow-class -n "legal-analysis" -c "$legal_config" +tg-put-flow-blueprint -n "legal-analysis" -c "$legal_config" ``` ## Best Practices -1. **Descriptive Names**: Use clear, descriptive flow class names +1. **Descriptive Names**: Use clear, descriptive flow blueprint names 2. **Comprehensive Descriptions**: Include detailed descriptions of flow capabilities 3. **Consistent Naming**: Follow consistent queue naming conventions -4. **Version Control**: Store flow class configurations in version control -5. **Testing**: Test flow classes thoroughly before production use -6. **Documentation**: Document flow class purposes and requirements +4. **Version Control**: Store flow blueprint configurations in version control +5. **Testing**: Test flow blueprintes thoroughly before production use +6. **Documentation**: Document flow blueprint purposes and requirements ## Template Examples -### Minimal Flow Class +### Minimal Flow Blueprint ```json { "description": "Minimal text processing flow", @@ -368,7 +368,7 @@ tg-put-flow-class -n "legal-analysis" -c "$legal_config" } ``` -### RAG-Focused Flow Class +### RAG-Focused Flow Blueprint ```json { "description": "Retrieval Augmented Generation flow", @@ -389,7 +389,7 @@ tg-put-flow-class -n "legal-analysis" -c "$legal_config" } ``` -### Document Processing Flow Class +### Document Processing Flow Blueprint ```json { "description": "Document ingestion and processing flow", diff --git a/docs/cli/tg-show-config.md b/docs/cli/tg-show-config.md index 2fa3c64c..ac870a7f 100644 --- a/docs/cli/tg-show-config.md +++ b/docs/cli/tg-show-config.md @@ -43,7 +43,7 @@ Version: 42 { "flows": { "default": { - "class-name": "document-rag+graph-rag", + "blueprint-name": "document-rag+graph-rag", "description": "Default processing flow", "interfaces": { "agent": { @@ -77,7 +77,7 @@ Version: 42 ### Flow Definitions Flow configurations showing: -- **class-name**: The flow class being used +- **blueprint-name**: The flow blueprint being used - **description**: Human-readable flow description - **interfaces**: Pulsar queue names for each service @@ -131,7 +131,7 @@ Exception: Unauthorized ## Related Commands -- [`tg-put-flow-class`](tg-put-flow-class.md) - Update flow class definitions +- [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Update flow blueprint definitions - [`tg-show-flows`](tg-show-flows.md) - List active flows - [`tg-set-prompt`](tg-set-prompt.md) - Configure prompt templates - [`tg-set-token-costs`](tg-set-token-costs.md) - Configure token costs diff --git a/docs/cli/tg-show-flow-blueprints.md b/docs/cli/tg-show-flow-blueprints.md new file mode 100644 index 00000000..40667dda --- /dev/null +++ b/docs/cli/tg-show-flow-blueprints.md @@ -0,0 +1,330 @@ +# tg-show-flow-blueprints + +Lists all defined flow blueprintes in TrustGraph with their descriptions and tags. + +## Synopsis + +```bash +tg-show-flow-blueprints [options] +``` + +## Description + +The `tg-show-flow-blueprints` command displays a formatted table of all flow blueprint definitions currently stored in TrustGraph. Each flow blueprint is shown with its name, description, and associated tags. + +Flow blueprintes are templates that define the structure and services available for creating flow instances. This command helps you understand what flow blueprintes are available for use. + +## Options + +### Optional Arguments + +- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`) + +## Examples + +### List All Flow Blueprintes +```bash +tg-show-flow-blueprints +``` + +Output: +``` ++-----------------+----------------------------------+----------------------+ +| flow blueprint | description | tags | ++-----------------+----------------------------------+----------------------+ +| document-proc | Document processing pipeline | production, nlp | +| data-analysis | Data analysis and visualization | analytics, dev | +| web-scraper | Web content extraction flow | scraping, batch | +| chat-assistant | Conversational AI assistant | ai, interactive | ++-----------------+----------------------------------+----------------------+ +``` + +### Using Custom API URL +```bash +tg-show-flow-blueprints -u http://production:8088/ +``` + +### Filter Flow Blueprintes +```bash +# Show only production-tagged flow blueprintes +tg-show-flow-blueprints | grep "production" + +# Count total flow blueprintes +tg-show-flow-blueprints | grep -c "^|" + +# Show flow blueprintes with specific patterns +tg-show-flow-blueprints | grep -E "(document|text|nlp)" +``` + +## Output Format + +The command displays results in a formatted table with columns: + +- **flow blueprint**: The unique name/identifier of the flow blueprint +- **description**: Human-readable description of the flow blueprint purpose +- **tags**: Comma-separated list of categorization tags + +### Empty Results +If no flow blueprintes exist: +``` +No flows. +``` + +## Use Cases + +### Flow Blueprint Discovery +```bash +# Find available flow blueprintes for document processing +tg-show-flow-blueprints | grep -i document + +# List all AI-related flow blueprintes +tg-show-flow-blueprints | grep -i "ai\|nlp\|chat\|assistant" + +# Find development vs production flow blueprintes +tg-show-flow-blueprints | grep -E "(dev|test|staging)" +tg-show-flow-blueprints | grep "production" +``` + +### Flow Blueprint Management +```bash +# Get list of flow blueprint names for scripting +tg-show-flow-blueprints | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); print $2}' | grep -v "^$" + +# Check if specific flow blueprint exists +if tg-show-flow-blueprints | grep -q "target-flow"; then + echo "Flow blueprint 'target-flow' exists" +else + echo "Flow blueprint 'target-flow' not found" +fi +``` + +### Environment Comparison +```bash +# Compare flow blueprintes between environments +echo "Development environment:" +tg-show-flow-blueprints -u http://dev:8088/ + +echo "Production environment:" +tg-show-flow-blueprints -u http://prod:8088/ +``` + +### Reporting and Documentation +```bash +# Generate flow blueprint inventory report +echo "Flow Blueprint Inventory - $(date)" > flow-inventory.txt +echo "=====================================" >> flow-inventory.txt +tg-show-flow-blueprints >> flow-inventory.txt + +# Create CSV export +echo "flow_class,description,tags" > flow-classes.csv +tg-show-flow-blueprints | awk 'NR>3 && /^\|/ { + gsub(/^\| */, "", $0); gsub(/ *\|$/, "", $0); + gsub(/ *\| */, ",", $0); print $0 +}' >> flow-classes.csv +``` + +## Error Handling + +### Connection Errors +```bash +Exception: Connection refused +``` +**Solution**: Check the API URL and ensure TrustGraph is running. + +### Permission Errors +```bash +Exception: Access denied to list flow blueprintes +``` +**Solution**: Verify user permissions for reading flow blueprint definitions. + +### Network Timeouts +```bash +Exception: Request timeout +``` +**Solution**: Check network connectivity and API server status. + +## Integration with Other Commands + +### Flow Blueprint Lifecycle +```bash +# 1. List available flow blueprintes +tg-show-flow-blueprints + +# 2. Get details of specific flow blueprint +tg-get-flow-blueprint -n "interesting-flow" + +# 3. Start flow instance from class +tg-start-flow -n "interesting-flow" -i "my-instance" + +# 4. Monitor flow instance +tg-show-flows | grep "my-instance" +``` + +### Bulk Operations +```bash +# Process all flow blueprintes +tg-show-flow-blueprints | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \ +while read class_name; do + if [ -n "$class_name" ]; then + echo "Processing flow blueprint: $class_name" + tg-get-flow-blueprint -n "$class_name" > "backup-$class_name.json" + fi +done +``` + +### Automated Validation +```bash +# Check flow blueprint health +echo "Validating flow blueprintes..." +tg-show-flow-blueprints | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \ +while read class_name; do + if [ -n "$class_name" ]; then + echo -n "Checking $class_name... " + if tg-get-flow-blueprint -n "$class_name" > /dev/null 2>&1; then + echo "OK" + else + echo "ERROR" + fi + fi +done +``` + +## Advanced Usage + +### Flow Blueprint Analysis +```bash +# Analyze flow blueprint distribution by tags +tg-show-flow-blueprints | awk 'NR>3 && /^\|/ { + # Extract tags column + split($0, parts, "|"); + tags = parts[4]; + gsub(/^ *| *$/, "", tags); + if (tags) { + split(tags, tag_array, ","); + for (i in tag_array) { + gsub(/^ *| *$/, "", tag_array[i]); + if (tag_array[i]) print tag_array[i]; + } + } +}' | sort | uniq -c | sort -nr +``` + +### Environment Synchronization +```bash +# Sync flow blueprintes between environments +echo "Synchronizing flow blueprintes from dev to staging..." + +# Get list from development +dev_classes=$(tg-show-flow-blueprints -u http://dev:8088/ | \ + awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}') + +# Check each class in staging +for class in $dev_classes; do + if tg-show-flow-blueprints -u http://staging:8088/ | grep -q "$class"; then + echo "$class: Already exists in staging" + else + echo "$class: Missing in staging - needs sync" + # Get from dev and put to staging + tg-get-flow-blueprint -n "$class" -u http://dev:8088/ > temp-class.json + tg-put-flow-blueprint -n "$class" -c "$(cat temp-class.json)" -u http://staging:8088/ + rm temp-class.json + fi +done +``` + +### Monitoring Script +```bash +#!/bin/bash +# monitor-flow-classes.sh +api_url="${1:-http://localhost:8088/}" + +echo "Flow Blueprint Monitoring Report - $(date)" +echo "API URL: $api_url" +echo "----------------------------------------" + +# Total count +total=$(tg-show-flow-blueprints -u "$api_url" | grep -c "^|" 2>/dev/null || echo "0") +echo "Total flow blueprintes: $((total - 3))" # Subtract header rows + +# Tag analysis +echo -e "\nTag distribution:" +tg-show-flow-blueprints -u "$api_url" | awk 'NR>3 && /^\|/ { + split($0, parts, "|"); + tags = parts[4]; + gsub(/^ *| *$/, "", tags); + if (tags) { + split(tags, tag_array, ","); + for (i in tag_array) { + gsub(/^ *| *$/, "", tag_array[i]); + if (tag_array[i]) print tag_array[i]; + } + } +}' | sort | uniq -c | sort -nr + +# Health check +echo -e "\nHealth check:" +healthy=0 +unhealthy=0 +tg-show-flow-blueprints -u "$api_url" | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \ +while read class_name; do + if [ -n "$class_name" ]; then + if tg-get-flow-blueprint -n "$class_name" -u "$api_url" > /dev/null 2>&1; then + healthy=$((healthy + 1)) + else + unhealthy=$((unhealthy + 1)) + echo " ERROR: $class_name" + fi + fi +done + +echo "Healthy: $healthy, Unhealthy: $unhealthy" +``` + +## Environment Variables + +- `TRUSTGRAPH_URL`: Default API URL + +## Related Commands + +- [`tg-get-flow-blueprint`](tg-get-flow-blueprint.md) - Retrieve specific flow blueprint definitions +- [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Create/update flow blueprint definitions +- [`tg-delete-flow-blueprint`](tg-delete-flow-blueprint.md) - Delete flow blueprint definitions +- [`tg-start-flow`](tg-start-flow.md) - Create flow instances from classes +- [`tg-show-flows`](tg-show-flows.md) - List active flow instances + +## API Integration + +This command uses the [Flow API](../apis/api-flow.md) with the `list-classes` operation to retrieve flow blueprint listings. + +## Best Practices + +1. **Regular Inventory**: Periodically review available flow blueprintes +2. **Documentation**: Ensure flow blueprintes have meaningful descriptions +3. **Tagging**: Use consistent tagging for better organization +4. **Cleanup**: Remove unused or deprecated flow blueprintes +5. **Monitoring**: Include flow blueprint health checks in monitoring +6. **Environment Parity**: Keep flow blueprintes synchronized across environments + +## Troubleshooting + +### No Output +```bash +# If command returns no output, check API connectivity +tg-show-flow-blueprints -u http://localhost:8088/ +# Verify TrustGraph is running and accessible +``` + +### Formatting Issues +```bash +# If table formatting is broken, check terminal width +export COLUMNS=120 +tg-show-flow-blueprints +``` + +### Missing Flow Blueprintes +```bash +# If expected flow blueprintes are missing, verify: +# 1. Correct API URL +# 2. Database connectivity +# 3. Flow blueprint definitions are properly stored +``` \ No newline at end of file diff --git a/docs/cli/tg-show-flow-classes.md b/docs/cli/tg-show-flow-classes.md deleted file mode 100644 index f81d9331..00000000 --- a/docs/cli/tg-show-flow-classes.md +++ /dev/null @@ -1,330 +0,0 @@ -# tg-show-flow-classes - -Lists all defined flow classes in TrustGraph with their descriptions and tags. - -## Synopsis - -```bash -tg-show-flow-classes [options] -``` - -## Description - -The `tg-show-flow-classes` command displays a formatted table of all flow class definitions currently stored in TrustGraph. Each flow class is shown with its name, description, and associated tags. - -Flow classes are templates that define the structure and services available for creating flow instances. This command helps you understand what flow classes are available for use. - -## Options - -### Optional Arguments - -- `-u, --api-url URL`: TrustGraph API URL (default: `$TRUSTGRAPH_URL` or `http://localhost:8088/`) - -## Examples - -### List All Flow Classes -```bash -tg-show-flow-classes -``` - -Output: -``` -+-----------------+----------------------------------+----------------------+ -| flow class | description | tags | -+-----------------+----------------------------------+----------------------+ -| document-proc | Document processing pipeline | production, nlp | -| data-analysis | Data analysis and visualization | analytics, dev | -| web-scraper | Web content extraction flow | scraping, batch | -| chat-assistant | Conversational AI assistant | ai, interactive | -+-----------------+----------------------------------+----------------------+ -``` - -### Using Custom API URL -```bash -tg-show-flow-classes -u http://production:8088/ -``` - -### Filter Flow Classes -```bash -# Show only production-tagged flow classes -tg-show-flow-classes | grep "production" - -# Count total flow classes -tg-show-flow-classes | grep -c "^|" - -# Show flow classes with specific patterns -tg-show-flow-classes | grep -E "(document|text|nlp)" -``` - -## Output Format - -The command displays results in a formatted table with columns: - -- **flow class**: The unique name/identifier of the flow class -- **description**: Human-readable description of the flow class purpose -- **tags**: Comma-separated list of categorization tags - -### Empty Results -If no flow classes exist: -``` -No flows. -``` - -## Use Cases - -### Flow Class Discovery -```bash -# Find available flow classes for document processing -tg-show-flow-classes | grep -i document - -# List all AI-related flow classes -tg-show-flow-classes | grep -i "ai\|nlp\|chat\|assistant" - -# Find development vs production flow classes -tg-show-flow-classes | grep -E "(dev|test|staging)" -tg-show-flow-classes | grep "production" -``` - -### Flow Class Management -```bash -# Get list of flow class names for scripting -tg-show-flow-classes | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); print $2}' | grep -v "^$" - -# Check if specific flow class exists -if tg-show-flow-classes | grep -q "target-flow"; then - echo "Flow class 'target-flow' exists" -else - echo "Flow class 'target-flow' not found" -fi -``` - -### Environment Comparison -```bash -# Compare flow classes between environments -echo "Development environment:" -tg-show-flow-classes -u http://dev:8088/ - -echo "Production environment:" -tg-show-flow-classes -u http://prod:8088/ -``` - -### Reporting and Documentation -```bash -# Generate flow class inventory report -echo "Flow Class Inventory - $(date)" > flow-inventory.txt -echo "=====================================" >> flow-inventory.txt -tg-show-flow-classes >> flow-inventory.txt - -# Create CSV export -echo "flow_class,description,tags" > flow-classes.csv -tg-show-flow-classes | awk 'NR>3 && /^\|/ { - gsub(/^\| */, "", $0); gsub(/ *\|$/, "", $0); - gsub(/ *\| */, ",", $0); print $0 -}' >> flow-classes.csv -``` - -## Error Handling - -### Connection Errors -```bash -Exception: Connection refused -``` -**Solution**: Check the API URL and ensure TrustGraph is running. - -### Permission Errors -```bash -Exception: Access denied to list flow classes -``` -**Solution**: Verify user permissions for reading flow class definitions. - -### Network Timeouts -```bash -Exception: Request timeout -``` -**Solution**: Check network connectivity and API server status. - -## Integration with Other Commands - -### Flow Class Lifecycle -```bash -# 1. List available flow classes -tg-show-flow-classes - -# 2. Get details of specific flow class -tg-get-flow-class -n "interesting-flow" - -# 3. Start flow instance from class -tg-start-flow -n "interesting-flow" -i "my-instance" - -# 4. Monitor flow instance -tg-show-flows | grep "my-instance" -``` - -### Bulk Operations -```bash -# Process all flow classes -tg-show-flow-classes | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \ -while read class_name; do - if [ -n "$class_name" ]; then - echo "Processing flow class: $class_name" - tg-get-flow-class -n "$class_name" > "backup-$class_name.json" - fi -done -``` - -### Automated Validation -```bash -# Check flow class health -echo "Validating flow classes..." -tg-show-flow-classes | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \ -while read class_name; do - if [ -n "$class_name" ]; then - echo -n "Checking $class_name... " - if tg-get-flow-class -n "$class_name" > /dev/null 2>&1; then - echo "OK" - else - echo "ERROR" - fi - fi -done -``` - -## Advanced Usage - -### Flow Class Analysis -```bash -# Analyze flow class distribution by tags -tg-show-flow-classes | awk 'NR>3 && /^\|/ { - # Extract tags column - split($0, parts, "|"); - tags = parts[4]; - gsub(/^ *| *$/, "", tags); - if (tags) { - split(tags, tag_array, ","); - for (i in tag_array) { - gsub(/^ *| *$/, "", tag_array[i]); - if (tag_array[i]) print tag_array[i]; - } - } -}' | sort | uniq -c | sort -nr -``` - -### Environment Synchronization -```bash -# Sync flow classes between environments -echo "Synchronizing flow classes from dev to staging..." - -# Get list from development -dev_classes=$(tg-show-flow-classes -u http://dev:8088/ | \ - awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}') - -# Check each class in staging -for class in $dev_classes; do - if tg-show-flow-classes -u http://staging:8088/ | grep -q "$class"; then - echo "$class: Already exists in staging" - else - echo "$class: Missing in staging - needs sync" - # Get from dev and put to staging - tg-get-flow-class -n "$class" -u http://dev:8088/ > temp-class.json - tg-put-flow-class -n "$class" -c "$(cat temp-class.json)" -u http://staging:8088/ - rm temp-class.json - fi -done -``` - -### Monitoring Script -```bash -#!/bin/bash -# monitor-flow-classes.sh -api_url="${1:-http://localhost:8088/}" - -echo "Flow Class Monitoring Report - $(date)" -echo "API URL: $api_url" -echo "----------------------------------------" - -# Total count -total=$(tg-show-flow-classes -u "$api_url" | grep -c "^|" 2>/dev/null || echo "0") -echo "Total flow classes: $((total - 3))" # Subtract header rows - -# Tag analysis -echo -e "\nTag distribution:" -tg-show-flow-classes -u "$api_url" | awk 'NR>3 && /^\|/ { - split($0, parts, "|"); - tags = parts[4]; - gsub(/^ *| *$/, "", tags); - if (tags) { - split(tags, tag_array, ","); - for (i in tag_array) { - gsub(/^ *| *$/, "", tag_array[i]); - if (tag_array[i]) print tag_array[i]; - } - } -}' | sort | uniq -c | sort -nr - -# Health check -echo -e "\nHealth check:" -healthy=0 -unhealthy=0 -tg-show-flow-classes -u "$api_url" | awk 'NR>3 && /^\|/ {gsub(/[| ]/, "", $2); if($2) print $2}' | \ -while read class_name; do - if [ -n "$class_name" ]; then - if tg-get-flow-class -n "$class_name" -u "$api_url" > /dev/null 2>&1; then - healthy=$((healthy + 1)) - else - unhealthy=$((unhealthy + 1)) - echo " ERROR: $class_name" - fi - fi -done - -echo "Healthy: $healthy, Unhealthy: $unhealthy" -``` - -## Environment Variables - -- `TRUSTGRAPH_URL`: Default API URL - -## Related Commands - -- [`tg-get-flow-class`](tg-get-flow-class.md) - Retrieve specific flow class definitions -- [`tg-put-flow-class`](tg-put-flow-class.md) - Create/update flow class definitions -- [`tg-delete-flow-class`](tg-delete-flow-class.md) - Delete flow class definitions -- [`tg-start-flow`](tg-start-flow.md) - Create flow instances from classes -- [`tg-show-flows`](tg-show-flows.md) - List active flow instances - -## API Integration - -This command uses the [Flow API](../apis/api-flow.md) with the `list-classes` operation to retrieve flow class listings. - -## Best Practices - -1. **Regular Inventory**: Periodically review available flow classes -2. **Documentation**: Ensure flow classes have meaningful descriptions -3. **Tagging**: Use consistent tagging for better organization -4. **Cleanup**: Remove unused or deprecated flow classes -5. **Monitoring**: Include flow class health checks in monitoring -6. **Environment Parity**: Keep flow classes synchronized across environments - -## Troubleshooting - -### No Output -```bash -# If command returns no output, check API connectivity -tg-show-flow-classes -u http://localhost:8088/ -# Verify TrustGraph is running and accessible -``` - -### Formatting Issues -```bash -# If table formatting is broken, check terminal width -export COLUMNS=120 -tg-show-flow-classes -``` - -### Missing Flow Classes -```bash -# If expected flow classes are missing, verify: -# 1. Correct API URL -# 2. Database connectivity -# 3. Flow class definitions are properly stored -``` \ No newline at end of file diff --git a/docs/cli/tg-show-flow-state.md b/docs/cli/tg-show-flow-state.md index d0741522..dc24d700 100644 --- a/docs/cli/tg-show-flow-state.md +++ b/docs/cli/tg-show-flow-state.md @@ -1,6 +1,6 @@ # tg-show-flow-state -Displays the processor states for a specific flow and its associated flow class. +Displays the processor states for a specific flow and its associated flow blueprint. ## Synopsis @@ -10,7 +10,7 @@ tg-show-flow-state [options] ## Description -The `tg-show-flow-state` command shows the current state of processors within a specific TrustGraph flow instance and its corresponding flow class. It queries the metrics system to determine which processing components are running and displays their status with visual indicators. +The `tg-show-flow-state` command shows the current state of processors within a specific TrustGraph flow instance and its corresponding flow blueprint. It queries the metrics system to determine which processing components are running and displays their status with visual indicators. This command is essential for monitoring flow health and debugging processing issues. @@ -51,7 +51,7 @@ tg-show-flow-state \ ## Output Format -The command displays processor states for both the flow instance and its flow class: +The command displays processor states for both the flow instance and its flow blueprint: ``` Flow production-flow @@ -75,7 +75,7 @@ Class document-processing-v2 ### Information Displayed - **Flow Section**: Shows the state of processors in the specific flow instance -- **Class Section**: Shows the state of processors in the flow class template +- **Class Section**: Shows the state of processors in the flow blueprint template - **Processor Names**: Individual processing components within the flow ## Use Cases diff --git a/docs/cli/tg-show-flows.md b/docs/cli/tg-show-flows.md index cfdaff90..72a1c809 100644 --- a/docs/cli/tg-show-flows.md +++ b/docs/cli/tg-show-flows.md @@ -135,7 +135,7 @@ Exception: Unauthorized - [`tg-start-flow`](tg-start-flow.md) - Start a new flow instance - [`tg-stop-flow`](tg-stop-flow.md) - Stop a running flow -- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes +- [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes - [`tg-show-flow-state`](tg-show-flow-state.md) - Show detailed flow status - [`tg-show-config`](tg-show-config.md) - Show complete system configuration @@ -186,7 +186,7 @@ tg-show-flows | grep "graph-rag request" ### Flow Information - **id**: Unique flow instance identifier -- **class**: Flow class name used to create the instance +- **class**: Flow blueprint name used to create the instance - **desc**: Human-readable flow description - **queue**: Service interfaces and their Pulsar queue names @@ -196,7 +196,7 @@ Queue names indicate: - **Tenant**: Usually `tg` - **Namespace**: `request`, `response`, or `flow` - **Service**: The specific service name -- **Flow Identifier**: Either flow class or flow ID +- **Flow Identifier**: Either flow blueprint or flow ID ## Best Practices diff --git a/docs/cli/tg-start-flow.md b/docs/cli/tg-start-flow.md index c0b2ad7a..0257d855 100644 --- a/docs/cli/tg-start-flow.md +++ b/docs/cli/tg-start-flow.md @@ -1,6 +1,6 @@ # tg-start-flow -Starts a processing flow using a defined flow class. +Starts a processing flow using a defined flow blueprint. ## Synopsis @@ -10,7 +10,7 @@ tg-start-flow -n CLASS_NAME -i FLOW_ID -d DESCRIPTION [options] ## Description -The `tg-start-flow` command creates and starts a new processing flow instance based on a predefined flow class. Flow classes define the processing pipeline configuration, while flow instances are running implementations of those classes with specific identifiers. +The `tg-start-flow` command creates and starts a new processing flow instance based on a predefined flow blueprint. Flow blueprintes define the processing pipeline configuration, while flow instances are running implementations of those classes with specific identifiers. Once started, a flow provides endpoints for document processing, knowledge queries, and other TrustGraph services through its configured interfaces. @@ -18,7 +18,7 @@ Once started, a flow provides endpoints for document processing, knowledge queri ### Required Arguments -- `-n, --class-name CLASS_NAME`: Name of the flow class to instantiate +- `-n, --blueprint-name CLASS_NAME`: Name of the flow blueprint to instantiate - `-i, --flow-id FLOW_ID`: Unique identifier for the new flow instance - `-d, --description DESCRIPTION`: Human-readable description of the flow @@ -36,7 +36,7 @@ tg-start-flow \ -d "Research document processing pipeline" ``` -### Start Custom Flow Class +### Start Custom Flow Blueprint ```bash tg-start-flow \ -n "medical-analysis" \ @@ -55,15 +55,15 @@ tg-start-flow \ ## Prerequisites -### Flow Class Must Exist -Before starting a flow, the flow class must be available in the system: +### Flow Blueprint Must Exist +Before starting a flow, the flow blueprint must be available in the system: ```bash -# Check available flow classes -tg-show-flow-classes +# Check available flow blueprintes +tg-show-flow-blueprints -# Upload a flow class if needed -tg-put-flow-class -n "my-class" -f flow-definition.json +# Upload a flow blueprint if needed +tg-put-flow-blueprint -n "my-class" -f flow-definition.json ``` ### System Requirements @@ -73,7 +73,7 @@ tg-put-flow-class -n "my-class" -f flow-definition.json ## Flow Lifecycle -1. **Flow Class Definition**: Flow classes define processing pipelines +1. **Flow Blueprint Definition**: Flow blueprintes define processing pipelines 2. **Flow Instance Creation**: `tg-start-flow` creates a running instance 3. **Service Availability**: Flow provides configured service endpoints 4. **Processing**: Documents and queries can be processed through the flow @@ -81,11 +81,11 @@ tg-put-flow-class -n "my-class" -f flow-definition.json ## Error Handling -### Flow Class Not Found +### Flow Blueprint Not Found ```bash -Exception: Flow class 'invalid-class' not found +Exception: Flow blueprint 'invalid-class' not found ``` -**Solution**: Check available flow classes with `tg-show-flow-classes` and ensure the class name is correct. +**Solution**: Check available flow blueprintes with `tg-show-flow-blueprints` and ensure the class name is correct. ### Flow ID Already Exists ```bash @@ -137,8 +137,8 @@ Once started, flows provide service interfaces based on their class definition. - [`tg-stop-flow`](tg-stop-flow.md) - Stop a running flow - [`tg-show-flows`](tg-show-flows.md) - List active flows and their interfaces -- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes -- [`tg-put-flow-class`](tg-put-flow-class.md) - Upload/update flow class definitions +- [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes +- [`tg-put-flow-blueprint`](tg-put-flow-blueprint.md) - Upload/update flow blueprint definitions - [`tg-show-flow-state`](tg-show-flow-state.md) - Check flow status ## API Integration diff --git a/docs/cli/tg-start-library-processing.md b/docs/cli/tg-start-library-processing.md index 534cedac..ee5ceb33 100644 --- a/docs/cli/tg-start-library-processing.md +++ b/docs/cli/tg-start-library-processing.md @@ -434,7 +434,7 @@ Exception: Processing ID already exists ```bash Exception: Flow instance not found ``` -**Solution**: Verify flow exists with `tg-show-flows` or `tg-show-flow-classes`. +**Solution**: Verify flow exists with `tg-show-flows` or `tg-show-flow-blueprints`. ### Insufficient Resources ```bash diff --git a/docs/cli/tg-stop-flow.md b/docs/cli/tg-stop-flow.md index 1e088762..97ad1696 100644 --- a/docs/cli/tg-stop-flow.md +++ b/docs/cli/tg-stop-flow.md @@ -171,7 +171,7 @@ done - [`tg-start-flow`](tg-start-flow.md) - Start a new flow instance - [`tg-show-flows`](tg-show-flows.md) - List active flows - [`tg-show-flow-state`](tg-show-flow-state.md) - Check detailed flow status -- [`tg-show-flow-classes`](tg-show-flow-classes.md) - List available flow classes +- [`tg-show-flow-blueprints`](tg-show-flow-blueprints.md) - List available flow blueprintes ## API Integration diff --git a/docs/tech-specs/flow-class-definition.md b/docs/tech-specs/flow-class-definition.md index c6f0c7b0..9e7ed66b 100644 --- a/docs/tech-specs/flow-class-definition.md +++ b/docs/tech-specs/flow-class-definition.md @@ -1,15 +1,15 @@ -# Flow Class Definition Specification +# Flow Blueprint Definition Specification ## Overview -A flow class defines a complete dataflow pattern template in the TrustGraph system. When instantiated, it creates an interconnected network of processors that handle data ingestion, processing, storage, and querying as a unified system. +A flow blueprint defines a complete dataflow pattern template in the TrustGraph system. When instantiated, it creates an interconnected network of processors that handle data ingestion, processing, storage, and querying as a unified system. ## Structure -A flow class definition consists of five main sections: +A flow blueprint definition consists of five main sections: ### 1. Class Section -Defines shared service processors that are instantiated once per flow class. These processors handle requests from all flow instances of this class. +Defines shared service processors that are instantiated once per flow blueprint. These processors handle requests from all flow instances of this class. ```json "class": { @@ -100,7 +100,7 @@ Maps flow-specific parameter names to centrally-stored parameter definitions: - Reduces duplication of parameter schemas ### 5. Metadata -Additional information about the flow class: +Additional information about the flow blueprint: ```json "description": "Human-readable description", @@ -117,7 +117,7 @@ Additional information about the flow class: - Example: `flow-123`, `customer-A-flow` #### {class} -- Replaced with the flow class name +- Replaced with the flow blueprint name - Creates shared resources across flows of the same class - Example: `standard-rag`, `enterprise-rag` @@ -203,14 +203,14 @@ Parameter names in settings correspond to keys in the flow's `parameters` sectio ## Queue Patterns (Pulsar) -Flow classes use Apache Pulsar for messaging. Queue names follow the Pulsar format: +Flow blueprintes use Apache Pulsar for messaging. Queue names follow the Pulsar format: ``` ://// ``` ### Components: - **persistence**: `persistent` or `non-persistent` (Pulsar persistence mode) -- **tenant**: `tg` for TrustGraph-supplied flow class definitions +- **tenant**: `tg` for TrustGraph-supplied flow blueprint definitions - **namespace**: Indicates the messaging pattern - `flow`: Fire-and-forget services - `request`: Request portion of request/response services @@ -232,7 +232,7 @@ Flow classes use Apache Pulsar for messaging. Queue names follow the Pulsar form ## Dataflow Architecture -The flow class creates a unified dataflow where: +The flow blueprint creates a unified dataflow where: 1. **Document Processing Pipeline**: Flows from ingestion through transformation to storage 2. **Query Services**: Integrated processors that query the same data stores and services @@ -245,7 +245,7 @@ All processors (both `{id}` and `{class}`) work together as a cohesive dataflow Given: - Flow Instance ID: `customer-A-flow` -- Flow Class: `standard-rag` +- Flow Blueprint: `standard-rag` - Flow parameter mappings: - `"model": "llm-model"` - `"temp": "temperature"` diff --git a/docs/tech-specs/flow-configurable-parameters.md b/docs/tech-specs/flow-configurable-parameters.md index b3b0ee5a..a605c114 100644 --- a/docs/tech-specs/flow-configurable-parameters.md +++ b/docs/tech-specs/flow-configurable-parameters.md @@ -1,8 +1,8 @@ -# Flow Class Configurable Parameters Technical Specification +# Flow Blueprint Configurable Parameters Technical Specification ## Overview -This specification describes the implementation of configurable parameters for flow classes in TrustGraph. Parameters enable users to customize processor parameters at flow launch time by providing values that replace parameter placeholders in the flow class definition. +This specification describes the implementation of configurable parameters for flow blueprintes in TrustGraph. Parameters enable users to customize processor parameters at flow launch time by providing values that replace parameter placeholders in the flow blueprint definition. Parameters work through template variable substitution in processor parameters, similar to how `{id}` and `{class}` variables work, but with user-provided values. @@ -21,25 +21,25 @@ The integration supports four primary use cases: - **Template Substitution**: Seamlessly replace parameter placeholders in processor parameters - **UI Integration**: Enable parameter input through both API and UI interfaces - **Type Safety**: Ensure parameter types match expected processor parameter types -- **Documentation**: Self-documenting parameter schemas within flow class definitions -- **Backward Compatibility**: Maintain compatibility with existing flow classes that don't use parameters +- **Documentation**: Self-documenting parameter schemas within flow blueprint definitions +- **Backward Compatibility**: Maintain compatibility with existing flow blueprintes that don't use parameters ## Background -Flow classes in TrustGraph now support processor parameters that can contain either fixed values or parameter placeholders. This creates an opportunity for runtime customization. +Flow blueprintes in TrustGraph now support processor parameters that can contain either fixed values or parameter placeholders. This creates an opportunity for runtime customization. Current processor parameters support: - Fixed values: `"model": "gemma3:12b"` - Parameter placeholders: `"model": "gemma3:{model-size}"` This specification defines how parameters are: -- Declared in flow class definitions +- Declared in flow blueprint definitions - Validated when flows are launched - Substituted in processor parameters - Exposed through APIs and UI By leveraging parameterized processor parameters, TrustGraph can: -- Reduce flow class duplication by using parameters for variations +- Reduce flow blueprint duplication by using parameters for variations - Enable users to tune processor behavior without modifying definitions - Support environment-specific configurations through parameter values - Maintain type safety through parameter schema validation @@ -51,7 +51,7 @@ By leveraging parameterized processor parameters, TrustGraph can: The configurable parameters system requires the following technical components: 1. **Parameter Schema Definition** - - JSON Schema-based parameter definitions within flow class metadata + - JSON Schema-based parameter definitions within flow blueprint metadata - Type definitions including string, number, boolean, enum, and object types - Validation rules including min/max values, patterns, and required fields @@ -92,7 +92,7 @@ The configurable parameters system requires the following technical components: #### Parameter Definitions (Stored in Schema/Config) -Parameter definitions are stored centrally in the schema and config system with type "parameter-types": +Parameter definitions are stored centrally in the schema and config system with type "parameter-type": ```json { @@ -146,9 +146,9 @@ Parameter definitions are stored centrally in the schema and config system with } ``` -#### Flow Class with Parameter References +#### Flow Blueprint with Parameter References -Flow classes define parameter metadata with type references, descriptions, and ordering: +Flow blueprintes define parameter metadata with type references, descriptions, and ordering: ```json { @@ -225,7 +225,7 @@ The `parameters` section maps flow-specific parameter names (keys) to parameter - `controlled-by` (optional): Name of another parameter that controls this parameter's value when in simple mode. When specified, this parameter inherits its value from the controlling parameter unless explicitly overridden This approach allows: -- Reusable parameter type definitions across multiple flow classes +- Reusable parameter type definitions across multiple flow blueprintes - Centralized parameter type management and validation - Flow-specific parameter descriptions and ordering - Enhanced UI experience with descriptive parameter forms @@ -253,7 +253,7 @@ The flow launch API accepts parameters using the flow's parameter names: Note: In this example, `llm-rag-model` is not explicitly provided but will inherit the value "claude-3" from `llm-model` due to its `controlled-by` relationship. Similarly, `chunk-overlap` could inherit a calculated value based on `chunk-size`. The system will: -1. Extract parameter metadata from flow class definition +1. Extract parameter metadata from flow blueprint definition 2. Map flow parameter names to their type definitions (e.g., `llm-model` → `llm-model` type) 3. Resolve controlled-by relationships (e.g., `llm-rag-model` inherits from `llm-model`) 4. Validate user-provided and inherited values against the parameter type definitions @@ -265,14 +265,14 @@ The system will: When a flow is started, the system performs the following parameter resolution steps: -1. **Flow Class Loading**: Load flow class definition and extract parameter metadata -2. **Metadata Extraction**: Extract `type`, `description`, `order`, `advanced`, and `controlled-by` for each parameter defined in the flow class's `parameters` section -3. **Type Definition Lookup**: For each parameter in the flow class: +1. **Flow Blueprint Loading**: Load flow blueprint definition and extract parameter metadata +2. **Metadata Extraction**: Extract `type`, `description`, `order`, `advanced`, and `controlled-by` for each parameter defined in the flow blueprint's `parameters` section +3. **Type Definition Lookup**: For each parameter in the flow blueprint: - Retrieve the parameter type definition from schema/config store using the `type` field - - The type definitions are stored with type "parameter-types" in the config system + - The type definitions are stored with type "parameter-type" in the config system - Each type definition contains the parameter's schema, default value, and validation rules 4. **Default Value Resolution**: - - For each parameter defined in the flow class: + - For each parameter defined in the flow blueprint: - Check if the user provided a value for this parameter - If no user value provided, use the `default` value from the parameter type definition - Build a complete parameter map containing both user-provided and default values @@ -361,7 +361,7 @@ The flow configuration service (`trustgraph-flow/trustgraph/config/service/flow. Resolve parameters by merging user-provided values with defaults. Args: - flow_class: The flow class definition dict + flow_class: The flow blueprint definition dict user_params: User-provided parameters dict Returns: @@ -370,20 +370,20 @@ The flow configuration service (`trustgraph-flow/trustgraph/config/service/flow. ``` This function should: - - Extract parameter metadata from the flow class's `parameters` section + - Extract parameter metadata from the flow blueprint's `parameters` section - For each parameter, fetch its type definition from config store - Apply defaults for any parameters not provided by the user - Handle `controlled-by` inheritance relationships - Return the complete parameter set 2. **Modified `handle_start_flow` Method** - - Call `resolve_parameters` after loading the flow class + - Call `resolve_parameters` after loading the flow blueprint - Use the complete resolved parameter set for template substitution - Store the complete parameter set (not just user-provided) with the flow - Validate that all required parameters have values 3. **Parameter Type Fetching** - - Parameter type definitions are stored in config with type "parameter-types" + - Parameter type definitions are stored in config with type "parameter-type" - Each type definition contains schema, default value, and validation rules - Cache frequently-used parameter types to reduce config lookups @@ -400,12 +400,12 @@ The flow configuration service (`trustgraph-flow/trustgraph/config/service/flow. 4. **Library CLI Commands** - CLI commands that start flows need parameter support: - Accept parameter values via command-line flags or configuration files - - Validate parameters against flow class definitions before submission + - Validate parameters against flow blueprint definitions before submission - Support parameter file input (JSON/YAML) for complex parameter sets - CLI commands that show flows need to display parameter information: - Show parameter values used when the flow was started - - Display available parameters for a flow class + - Display available parameters for a flow blueprint - Show parameter validation schemas and defaults #### Processor Base Class Integration @@ -456,7 +456,7 @@ Substituted in processor: "0.7" (string) ## Migration Plan -1. The system should continue to support flow classes with no parameters +1. The system should continue to support flow blueprintes with no parameters declared. 2. The system should continue to support flows no parameters specified: This works for flows with no parameters, and flows with parameters @@ -482,4 +482,4 @@ A: Just string substitution to remove strange injections and edge-cases. ## References - JSON Schema Specification: https://json-schema.org/ -- Flow Class Definition Spec: docs/tech-specs/flow-class-definition.md +- Flow Blueprint Definition Spec: docs/tech-specs/flow-class-definition.md diff --git a/tests/unit/test_base/test_flow_processor.py b/tests/unit/test_base/test_flow_processor.py index bcda2f84..70835e00 100644 --- a/tests/unit/test_base/test_flow_processor.py +++ b/tests/unit/test_base/test_flow_processor.py @@ -180,7 +180,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): 'test-flow': {'config': 'test-config'} } config_data = { - 'flows-active': { + 'active-flow': { 'test-processor': '{"test-flow": {"config": "test-config"}}' } } @@ -212,7 +212,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # Configuration without flows for this processor config_data = { - 'flows-active': { + 'active-flow': { 'other-processor': '{"other-flow": {"config": "other-config"}}' } } @@ -241,7 +241,7 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): processor = FlowProcessor(**config) processor.id = 'test-processor' - # Configuration without flows-active key + # Configuration without active-flow key config_data = { 'other-data': 'some-value' } @@ -276,16 +276,16 @@ class TestFlowProcessorSimple(IsolatedAsyncioTestCase): # First configuration - start flow1 config_data1 = { - 'flows-active': { + 'active-flow': { 'test-processor': '{"flow1": {"config": "config1"}}' } } - + await processor.on_configure_flows(config_data1, version=1) - + # Second configuration - stop flow1, start flow2 config_data2 = { - 'flows-active': { + 'active-flow': { 'test-processor': '{"flow2": {"config": "config2"}}' } } diff --git a/trustgraph-base/trustgraph/api/flow.py b/trustgraph-base/trustgraph/api/flow.py index 744ad2e7..142a699b 100644 --- a/trustgraph-base/trustgraph/api/flow.py +++ b/trustgraph-base/trustgraph/api/flow.py @@ -28,42 +28,42 @@ class Flow: def id(self, id="default"): return FlowInstance(api=self, id=id) - def list_classes(self): + def list_blueprints(self): # The input consists of system and prompt strings input = { - "operation": "list-classes", + "operation": "list-blueprints", } - return self.request(request = input)["class-names"] + return self.request(request = input)["blueprint-names"] - def get_class(self, class_name): + def get_blueprint(self, blueprint_name): # The input consists of system and prompt strings input = { - "operation": "get-class", - "class-name": class_name, + "operation": "get-blueprint", + "blueprint-name": blueprint_name, } - return json.loads(self.request(request = input)["class-definition"]) + return json.loads(self.request(request = input)["blueprint-definition"]) - def put_class(self, class_name, definition): + def put_blueprint(self, blueprint_name, definition): # The input consists of system and prompt strings input = { - "operation": "put-class", - "class-name": class_name, - "class-definition": json.dumps(definition), + "operation": "put-blueprint", + "blueprint-name": blueprint_name, + "blueprint-definition": json.dumps(definition), } self.request(request = input) - def delete_class(self, class_name): + def delete_blueprint(self, blueprint_name): # The input consists of system and prompt strings input = { - "operation": "delete-class", - "class-name": class_name, + "operation": "delete-blueprint", + "blueprint-name": blueprint_name, } self.request(request = input) @@ -87,13 +87,13 @@ class Flow: return json.loads(self.request(request = input)["flow"]) - def start(self, class_name, id, description, parameters=None): + def start(self, blueprint_name, id, description, parameters=None): # The input consists of system and prompt strings input = { "operation": "start-flow", "flow-id": id, - "class-name": class_name, + "blueprint-name": blueprint_name, "description": description, } diff --git a/trustgraph-base/trustgraph/base/flow_processor.py b/trustgraph-base/trustgraph/base/flow_processor.py index 385e1346..0f170030 100644 --- a/trustgraph-base/trustgraph/base/flow_processor.py +++ b/trustgraph-base/trustgraph/base/flow_processor.py @@ -63,13 +63,13 @@ class FlowProcessor(AsyncProcessor): logger.info(f"Got config version {version}") # Skip over invalid data - if "flows-active" not in config: return + if "active-flow" not in config: return # Check there's configuration information for me - if self.id in config["flows-active"]: + if self.id in config["active-flow"]: # Get my flow config - flow_config = json.loads(config["flows-active"][self.id]) + flow_config = json.loads(config["active-flow"][self.id]) else: diff --git a/trustgraph-base/trustgraph/messaging/translators/flow.py b/trustgraph-base/trustgraph/messaging/translators/flow.py index 8c1a019a..542b65ec 100644 --- a/trustgraph-base/trustgraph/messaging/translators/flow.py +++ b/trustgraph-base/trustgraph/messaging/translators/flow.py @@ -9,8 +9,8 @@ class FlowRequestTranslator(MessageTranslator): def to_pulsar(self, data: Dict[str, Any]) -> FlowRequest: return FlowRequest( operation=data.get("operation"), - class_name=data.get("class-name"), - class_definition=data.get("class-definition"), + blueprint_name=data.get("blueprint-name"), + blueprint_definition=data.get("blueprint-definition"), description=data.get("description"), flow_id=data.get("flow-id"), parameters=data.get("parameters") @@ -21,10 +21,10 @@ class FlowRequestTranslator(MessageTranslator): if obj.operation is not None: result["operation"] = obj.operation - if obj.class_name is not None: - result["class-name"] = obj.class_name - if obj.class_definition is not None: - result["class-definition"] = obj.class_definition + if obj.blueprint_name is not None: + result["blueprint-name"] = obj.blueprint_name + if obj.blueprint_definition is not None: + result["blueprint-definition"] = obj.blueprint_definition if obj.description is not None: result["description"] = obj.description if obj.flow_id is not None: @@ -44,12 +44,12 @@ class FlowResponseTranslator(MessageTranslator): def from_pulsar(self, obj: FlowResponse) -> Dict[str, Any]: result = {} - if obj.class_names is not None: - result["class-names"] = obj.class_names + if obj.blueprint_names is not None: + result["blueprint-names"] = obj.blueprint_names if obj.flow_ids is not None: result["flow-ids"] = obj.flow_ids - if obj.class_definition is not None: - result["class-definition"] = obj.class_definition + if obj.blueprint_definition is not None: + result["blueprint-definition"] = obj.blueprint_definition if obj.flow is not None: result["flow"] = obj.flow if obj.description is not None: diff --git a/trustgraph-base/trustgraph/schema/services/flow.py b/trustgraph-base/trustgraph/schema/services/flow.py index b993b1b3..cf62c84d 100644 --- a/trustgraph-base/trustgraph/schema/services/flow.py +++ b/trustgraph-base/trustgraph/schema/services/flow.py @@ -7,27 +7,27 @@ from ..core.primitives import Error ############################################################################ # Flow service: -# list_classes() -> (classname[]) -# get_class(classname) -> (class) -# put_class(class) -> (class) -# delete_class(classname) -> () +# list_blueprints() -> (blueprintname[]) +# get_blueprint(blueprintname) -> (blueprint) +# put_blueprint(blueprint) -> (blueprint) +# delete_blueprint(blueprintname) -> () # # list_flows() -> (flowid[]) # get_flow(flowid) -> (flow) -# start_flow(flowid, classname) -> () +# start_flow(flowid, blueprintname) -> () # stop_flow(flowid) -> () # Prompt services, abstract the prompt generation @dataclass class FlowRequest: - operation: str = "" # list-classes, get-class, put-class, delete-class + operation: str = "" # list-blueprints, get-blueprint, put-blueprint, delete-blueprint # list-flows, get-flow, start-flow, stop-flow - # get_class, put_class, delete_class, start_flow - class_name: str = "" + # get_blueprint, put_blueprint, delete_blueprint, start_flow + blueprint_name: str = "" - # put_class - class_definition: str = "" + # put_blueprint + blueprint_definition: str = "" # start_flow description: str = "" @@ -40,14 +40,14 @@ class FlowRequest: @dataclass class FlowResponse: - # list_classes - class_names: list[str] = field(default_factory=list) + # list_blueprints + blueprint_names: list[str] = field(default_factory=list) # list_flows flow_ids: list[str] = field(default_factory=list) - # get_class - class_definition: str = "" + # get_blueprint + blueprint_definition: str = "" # get_flow flow: str = "" diff --git a/trustgraph-cli/pyproject.toml b/trustgraph-cli/pyproject.toml index 65921d92..5568bf91 100644 --- a/trustgraph-cli/pyproject.toml +++ b/trustgraph-cli/pyproject.toml @@ -29,13 +29,13 @@ Homepage = "https://github.com/trustgraph-ai/trustgraph" [project.scripts] tg-add-library-document = "trustgraph.cli.add_library_document:main" -tg-delete-flow-class = "trustgraph.cli.delete_flow_class:main" +tg-delete-flow-blueprint = "trustgraph.cli.delete_flow_blueprint:main" tg-delete-mcp-tool = "trustgraph.cli.delete_mcp_tool:main" tg-delete-kg-core = "trustgraph.cli.delete_kg_core:main" tg-delete-tool = "trustgraph.cli.delete_tool:main" tg-dump-msgpack = "trustgraph.cli.dump_msgpack:main" tg-dump-queues = "trustgraph.cli.dump_queues:main" -tg-get-flow-class = "trustgraph.cli.get_flow_class:main" +tg-get-flow-blueprint = "trustgraph.cli.get_flow_blueprint:main" tg-get-kg-core = "trustgraph.cli.get_kg_core:main" tg-graph-to-turtle = "trustgraph.cli.graph_to_turtle:main" tg-init-trustgraph = "trustgraph.cli.init_trustgraph:main" @@ -56,7 +56,7 @@ tg-load-text = "trustgraph.cli.load_text:main" tg-load-turtle = "trustgraph.cli.load_turtle:main" tg-load-knowledge = "trustgraph.cli.load_knowledge:main" tg-load-structured-data = "trustgraph.cli.load_structured_data:main" -tg-put-flow-class = "trustgraph.cli.put_flow_class:main" +tg-put-flow-blueprint = "trustgraph.cli.put_flow_blueprint:main" tg-put-kg-core = "trustgraph.cli.put_kg_core:main" tg-remove-library-document = "trustgraph.cli.remove_library_document:main" tg-save-doc-embeds = "trustgraph.cli.save_doc_embeds:main" @@ -65,7 +65,7 @@ tg-set-prompt = "trustgraph.cli.set_prompt:main" tg-set-token-costs = "trustgraph.cli.set_token_costs:main" tg-set-tool = "trustgraph.cli.set_tool:main" tg-show-config = "trustgraph.cli.show_config:main" -tg-show-flow-classes = "trustgraph.cli.show_flow_classes:main" +tg-show-flow-blueprints = "trustgraph.cli.show_flow_blueprints:main" tg-show-flow-state = "trustgraph.cli.show_flow_state:main" tg-show-flows = "trustgraph.cli.show_flows:main" tg-show-graph = "trustgraph.cli.show_graph:main" diff --git a/trustgraph-cli/trustgraph/cli/delete_flow_class.py b/trustgraph-cli/trustgraph/cli/delete_flow_blueprint.py similarity index 65% rename from trustgraph-cli/trustgraph/cli/delete_flow_class.py rename to trustgraph-cli/trustgraph/cli/delete_flow_blueprint.py index ba0a5a9c..9ff8aeba 100644 --- a/trustgraph-cli/trustgraph/cli/delete_flow_class.py +++ b/trustgraph-cli/trustgraph/cli/delete_flow_blueprint.py @@ -1,5 +1,5 @@ """ -Deletes a flow class +Deletes a flow blueprint """ import argparse @@ -10,16 +10,16 @@ import json default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/') -def delete_flow_class(url, class_name): +def delete_flow_blueprint(url, blueprint_name): api = Api(url).flow() - class_names = api.delete_class(class_name) + blueprint_names = api.delete_blueprint(blueprint_name) def main(): parser = argparse.ArgumentParser( - prog='tg-delete-flow-class', + prog='tg-delete-flow-blueprint', description=__doc__, ) @@ -30,17 +30,17 @@ def main(): ) parser.add_argument( - '-n', '--class-name', - help=f'Flow class name', + '-n', '--blueprint-name', + help=f'Flow blueprint name', ) args = parser.parse_args() try: - delete_flow_class( + delete_flow_blueprint( url=args.api_url, - class_name=args.class_name, + blueprint_name=args.blueprint_name, ) except Exception as e: @@ -48,4 +48,4 @@ def main(): print("Exception:", e, flush=True) if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/trustgraph-cli/trustgraph/cli/get_flow_class.py b/trustgraph-cli/trustgraph/cli/get_flow_blueprint.py similarity index 67% rename from trustgraph-cli/trustgraph/cli/get_flow_class.py rename to trustgraph-cli/trustgraph/cli/get_flow_blueprint.py index 5479e507..817b8f47 100644 --- a/trustgraph-cli/trustgraph/cli/get_flow_class.py +++ b/trustgraph-cli/trustgraph/cli/get_flow_blueprint.py @@ -1,5 +1,5 @@ """ -Outputs a flow class definition in JSON format. +Outputs a flow blueprint definition in JSON format. """ import argparse @@ -10,18 +10,18 @@ import json default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/') -def get_flow_class(url, class_name): +def get_flow_blueprint(url, blueprint_name): api = Api(url).flow() - cls = api.get_class(class_name) + cls = api.get_blueprint(blueprint_name) print(json.dumps(cls, indent=4)) def main(): parser = argparse.ArgumentParser( - prog='tg-get-flow-class', + prog='tg-get-flow-blueprint', description=__doc__, ) @@ -32,18 +32,18 @@ def main(): ) parser.add_argument( - '-n', '--class-name', + '-n', '--blueprint-name', required=True, - help=f'Flow class name', + help=f'Flow blueprint name', ) args = parser.parse_args() try: - get_flow_class( + get_flow_blueprint( url=args.api_url, - class_name=args.class_name, + blueprint_name=args.blueprint_name, ) except Exception as e: @@ -51,4 +51,4 @@ def main(): print("Exception:", e, flush=True) if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/trustgraph-cli/trustgraph/cli/put_flow_class.py b/trustgraph-cli/trustgraph/cli/put_flow_blueprint.py similarity index 69% rename from trustgraph-cli/trustgraph/cli/put_flow_class.py rename to trustgraph-cli/trustgraph/cli/put_flow_blueprint.py index 6a88421d..740a224a 100644 --- a/trustgraph-cli/trustgraph/cli/put_flow_class.py +++ b/trustgraph-cli/trustgraph/cli/put_flow_blueprint.py @@ -1,6 +1,6 @@ """ -Uploads a flow class definition. You can take the output of -tg-get-flow-class and load it back in using this utility. +Uploads a flow blueprint definition. You can take the output of +tg-get-flow-blueprint and load it back in using this utility. """ import argparse @@ -11,16 +11,16 @@ import json default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/') default_token = os.getenv("TRUSTGRAPH_TOKEN", None) -def put_flow_class(url, class_name, config, token=None): +def put_flow_blueprint(url, blueprint_name, config, token=None): api = Api(url, token=token) - class_names = api.flow().put_class(class_name, config) + blueprint_names = api.flow().put_blueprint(blueprint_name, config) def main(): parser = argparse.ArgumentParser( - prog='tg-put-flow-class', + prog='tg-put-flow-blueprint', description=__doc__, ) @@ -37,8 +37,8 @@ def main(): ) parser.add_argument( - '-n', '--class-name', - help=f'Flow class name', + '-n', '--blueprint-name', + help=f'Flow blueprint name', ) parser.add_argument( @@ -50,9 +50,9 @@ def main(): try: - put_flow_class( + put_flow_blueprint( url=args.api_url, - class_name=args.class_name, + blueprint_name=args.blueprint_name, config=json.loads(args.config), token=args.token, ) @@ -62,4 +62,4 @@ def main(): print("Exception:", e, flush=True) if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/trustgraph-cli/trustgraph/cli/show_flow_classes.py b/trustgraph-cli/trustgraph/cli/show_flow_blueprints.py similarity index 83% rename from trustgraph-cli/trustgraph/cli/show_flow_classes.py rename to trustgraph-cli/trustgraph/cli/show_flow_blueprints.py index 123f5380..ca1f5c83 100644 --- a/trustgraph-cli/trustgraph/cli/show_flow_classes.py +++ b/trustgraph-cli/trustgraph/cli/show_flow_blueprints.py @@ -1,5 +1,5 @@ """ -Shows all defined flow classes. +Shows all defined flow blueprints. """ import argparse @@ -16,7 +16,7 @@ def format_parameters(params_metadata, config_api): Format parameter metadata for display Args: - params_metadata: Parameter definitions from flow class + params_metadata: Parameter definitions from flow blueprint config_api: API client to get parameter type information Returns: @@ -41,7 +41,7 @@ def format_parameters(params_metadata, config_api): type_info = param_type if config_api: try: - key = ConfigKey("parameter-types", param_type) + key = ConfigKey("parameter-type", param_type) type_def_value = config_api.get([key])[0].value param_type_def = json.loads(type_def_value) @@ -58,23 +58,23 @@ def format_parameters(params_metadata, config_api): return "\n".join(param_list) -def show_flow_classes(url, token=None): +def show_flow_blueprints(url, token=None): api = Api(url, token=token) flow_api = api.flow() config_api = api.config() - class_names = flow_api.list_classes() + blueprint_names = flow_api.list_blueprints() - if len(class_names) == 0: - print("No flow classes.") + if len(blueprint_names) == 0: + print("No flow blueprints.") return - for class_name in class_names: - cls = flow_api.get_class(class_name) + for blueprint_name in blueprint_names: + cls = flow_api.get_blueprint(blueprint_name) table = [] - table.append(("name", class_name)) + table.append(("name", blueprint_name)) table.append(("description", cls.get("description", ""))) tags = cls.get("tags", []) @@ -97,7 +97,7 @@ def show_flow_classes(url, token=None): def main(): parser = argparse.ArgumentParser( - prog='tg-show-flow-classes', + prog='tg-show-flow-blueprints', description=__doc__, ) @@ -117,7 +117,7 @@ def main(): try: - show_flow_classes( + show_flow_blueprints( url=args.api_url, token=args.token, ) @@ -127,4 +127,4 @@ def main(): print("Exception:", e, flush=True) if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/trustgraph-cli/trustgraph/cli/show_flow_state.py b/trustgraph-cli/trustgraph/cli/show_flow_state.py index 6ca4df8f..d5d87f2c 100644 --- a/trustgraph-cli/trustgraph/cli/show_flow_state.py +++ b/trustgraph-cli/trustgraph/cli/show_flow_state.py @@ -16,15 +16,15 @@ def dump_status(metrics_url, api_url, flow_id, token=None): api = Api(api_url, token=token).flow() flow = api.get(flow_id) - class_name = flow["class-name"] + blueprint_name = flow["blueprint-name"] print() print(f"Flow {flow_id}") show_processors(metrics_url, flow_id) print() - print(f"Class {class_name}") - show_processors(metrics_url, class_name) + print(f"Blueprint {blueprint_name}") + show_processors(metrics_url, blueprint_name) print() diff --git a/trustgraph-cli/trustgraph/cli/show_flows.py b/trustgraph-cli/trustgraph/cli/show_flows.py index b383ff56..828c18f1 100644 --- a/trustgraph-cli/trustgraph/cli/show_flows.py +++ b/trustgraph-cli/trustgraph/cli/show_flows.py @@ -13,7 +13,7 @@ default_token = os.getenv("TRUSTGRAPH_TOKEN", None) def get_interface(config_api, i): - key = ConfigKey("interface-descriptions", i) + key = ConfigKey("interface-description", i) value = config_api.get([key])[0].value @@ -70,13 +70,13 @@ def get_enum_description(param_value, param_type_def): # If not found in enum, return original value return param_value -def format_parameters(flow_params, class_params_metadata, config_api): +def format_parameters(flow_params, blueprint_params_metadata, config_api): """ Format flow parameters with their human-readable descriptions Args: flow_params: The actual parameter values used in the flow - class_params_metadata: The parameter metadata from the flow class definition + blueprint_params_metadata: The parameter metadata from the flow blueprint definition config_api: API client to retrieve parameter type definitions Returns: @@ -89,7 +89,7 @@ def format_parameters(flow_params, class_params_metadata, config_api): # Sort parameters by order if available sorted_params = sorted( - class_params_metadata.items(), + blueprint_params_metadata.items(), key=lambda x: x[1].get("order", 999) ) @@ -105,7 +105,7 @@ def format_parameters(flow_params, class_params_metadata, config_api): if param_type and config_api: try: from trustgraph.api import ConfigKey - key = ConfigKey("parameter-types", param_type) + key = ConfigKey("parameter-type", param_type) type_def_value = config_api.get([key])[0].value param_type_def = json.loads(type_def_value) display_value = get_enum_description(value, param_type_def) @@ -122,9 +122,9 @@ def format_parameters(flow_params, class_params_metadata, config_api): param_list.append(line) - # Add any parameters that aren't in the class metadata (shouldn't happen normally) + # Add any parameters that aren't in the blueprint metadata (shouldn't happen normally) for param_name, value in flow_params.items(): - if param_name not in class_params_metadata: + if param_name not in blueprint_params_metadata: param_list.append(f"• {param_name}: {value} (undefined)") return "\n".join(param_list) if param_list else "None" @@ -135,7 +135,7 @@ def show_flows(url, token=None): config_api = api.config() flow_api = api.flow() - interface_names = config_api.list("interface-descriptions") + interface_names = config_api.list("interface-description") interface_defs = { i: get_interface(config_api, i) @@ -156,24 +156,24 @@ def show_flows(url, token=None): table = [] table.append(("id", id)) - table.append(("class", flow.get("class-name", ""))) + table.append(("blueprint", flow.get("blueprint-name", ""))) table.append(("desc", flow.get("description", ""))) # Display parameters with human-readable descriptions parameters = flow.get("parameters", {}) if parameters: - # Try to get the flow class definition for parameter metadata - class_name = flow.get("class-name", "") - if class_name: + # Try to get the flow blueprint definition for parameter metadata + blueprint_name = flow.get("blueprint-name", "") + if blueprint_name: try: - flow_class = flow_api.get_class(class_name) - class_params_metadata = flow_class.get("parameters", {}) - param_str = format_parameters(parameters, class_params_metadata, config_api) + flow_blueprint = flow_api.get_blueprint(blueprint_name) + blueprint_params_metadata = flow_blueprint.get("parameters", {}) + param_str = format_parameters(parameters, blueprint_params_metadata, config_api) except Exception as e: - # Fallback to JSON if we can't get the class definition + # Fallback to JSON if we can't get the blueprint definition param_str = json.dumps(parameters, indent=2) else: - # No class name, fallback to JSON + # No blueprint name, fallback to JSON param_str = json.dumps(parameters, indent=2) table.append(("parameters", param_str)) diff --git a/trustgraph-cli/trustgraph/cli/show_parameter_types.py b/trustgraph-cli/trustgraph/cli/show_parameter_types.py index e5b842b5..2e0f1be3 100644 --- a/trustgraph-cli/trustgraph/cli/show_parameter_types.py +++ b/trustgraph-cli/trustgraph/cli/show_parameter_types.py @@ -85,7 +85,7 @@ def show_parameter_types(url, token=None): # Get list of all parameter types try: - param_type_names = config_api.list("parameter-types") + param_type_names = config_api.list("parameter-type") except Exception as e: print(f"Error retrieving parameter types: {e}") return @@ -97,7 +97,7 @@ def show_parameter_types(url, token=None): for param_type_name in param_type_names: try: # Get the parameter type definition - key = ConfigKey("parameter-types", param_type_name) + key = ConfigKey("parameter-type", param_type_name) type_def_value = config_api.get([key])[0].value param_type_def = json.loads(type_def_value) @@ -179,7 +179,7 @@ def show_specific_parameter_type(url, param_type_name, token=None): try: # Get the parameter type definition - key = ConfigKey("parameter-types", param_type_name) + key = ConfigKey("parameter-type", param_type_name) type_def_value = config_api.get([key])[0].value param_type_def = json.loads(type_def_value) diff --git a/trustgraph-cli/trustgraph/cli/show_token_costs.py b/trustgraph-cli/trustgraph/cli/show_token_costs.py index 9e7c352a..adc13ad7 100644 --- a/trustgraph-cli/trustgraph/cli/show_token_costs.py +++ b/trustgraph-cli/trustgraph/cli/show_token_costs.py @@ -18,7 +18,7 @@ def show_config(url, token=None): api = Api(url, token=token).config() - models = api.list("token-costs") + models = api.list("token-cost") costs = [] @@ -29,7 +29,7 @@ def show_config(url, token=None): try: values = json.loads(api.get([ - ConfigKey(type="token-costs", key=model), + ConfigKey(type="token-cost", key=model), ])[0].value) costs.append(( model, diff --git a/trustgraph-cli/trustgraph/cli/start_flow.py b/trustgraph-cli/trustgraph/cli/start_flow.py index 4f9954b0..e04e241d 100644 --- a/trustgraph-cli/trustgraph/cli/start_flow.py +++ b/trustgraph-cli/trustgraph/cli/start_flow.py @@ -1,5 +1,5 @@ """ -Starts a processing flow using a defined flow class. +Starts a processing flow using a defined flow blueprint. Parameters can be provided in three ways: 1. As key=value pairs: --param model=gpt-4 --param temp=0.7 @@ -19,12 +19,12 @@ import json default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/') default_token = os.getenv("TRUSTGRAPH_TOKEN", None) -def start_flow(url, class_name, flow_id, description, parameters=None, token=None): +def start_flow(url, blueprint_name, flow_id, description, parameters=None, token=None): api = Api(url, token=token).flow() api.start( - class_name = class_name, + blueprint_name = blueprint_name, id = flow_id, description = description, parameters = parameters, @@ -50,9 +50,9 @@ def main(): ) parser.add_argument( - '-n', '--class-name', + '-n', '--blueprint-name', required=True, - help=f'Flow class name', + help=f'Flow blueprint name', ) parser.add_argument( @@ -115,7 +115,7 @@ def main(): start_flow( url = args.api_url, - class_name = args.class_name, + blueprint_name = args.blueprint_name, flow_id = args.flow_id, description = args.description, parameters = parameters, diff --git a/trustgraph-cli/trustgraph/cli/verify_system_status.py b/trustgraph-cli/trustgraph/cli/verify_system_status.py index 294a3738..8cebc83f 100644 --- a/trustgraph-cli/trustgraph/cli/verify_system_status.py +++ b/trustgraph-cli/trustgraph/cli/verify_system_status.py @@ -194,21 +194,21 @@ def check_processors(url: str, min_processors: int, timeout: int, token: Optiona return False, f"Processor check error: {e}" -def check_flow_classes(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]: - """Check if flow classes are loaded.""" +def check_flow_blueprints(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]: + """Check if flow blueprints are loaded.""" try: api = Api(url, token=token, timeout=timeout) flow_api = api.flow() - classes = flow_api.list_classes() + blueprints = flow_api.list_blueprints() - if classes and len(classes) > 0: - return True, f"Found {len(classes)} flow class(es)" + if blueprints and len(blueprints) > 0: + return True, f"Found {len(blueprints)} flow blueprint(s)" else: - return False, "No flow classes found" + return False, "No flow blueprints found" except Exception as e: - return False, f"Flow classes check error: {e}" + return False, f"Flow blueprints check error: {e}" def check_flows(url: str, timeout: int, token: Optional[str] = None) -> Tuple[bool, str]: @@ -416,8 +416,8 @@ def main(): ) checker.run_check( - "Flow Classes", - check_flow_classes, + "Flow Blueprints", + check_flow_blueprints, args.api_url, args.check_timeout, args.token diff --git a/trustgraph-flow/trustgraph/agent/mcp_tool/service.py b/trustgraph-flow/trustgraph/agent/mcp_tool/service.py index 3858d06b..23789b96 100755 --- a/trustgraph-flow/trustgraph/agent/mcp_tool/service.py +++ b/trustgraph-flow/trustgraph/agent/mcp_tool/service.py @@ -32,7 +32,9 @@ class Service(ToolService): logger.info(f"Got config version {version}") - if "mcp" not in config: return + if "mcp" not in config: + self.mcp_services = {} + return self.mcp_services = { k: json.loads(v) diff --git a/trustgraph-flow/trustgraph/config/service/flow.py b/trustgraph-flow/trustgraph/config/service/flow.py index 42696c31..ab02fa30 100644 --- a/trustgraph-flow/trustgraph/config/service/flow.py +++ b/trustgraph-flow/trustgraph/config/service/flow.py @@ -13,26 +13,26 @@ class FlowConfig: # Cache for parameter type definitions to avoid repeated lookups self.param_type_cache = {} - async def resolve_parameters(self, flow_class, user_params): + async def resolve_parameters(self, flow_blueprint, user_params): """ Resolve parameters by merging user-provided values with defaults. Args: - flow_class: The flow class definition dict + flow_blueprint: The flow blueprint definition dict user_params: User-provided parameters dict (may be None or empty) Returns: Complete parameter dict with user values and defaults merged (all values as strings) """ - # If the flow class has no parameters section, return user params as-is (stringified) - if "parameters" not in flow_class: + # If the flow blueprint has no parameters section, return user params as-is (stringified) + if "parameters" not in flow_blueprint: if not user_params: return {} # Ensure all values are strings return {k: str(v) for k, v in user_params.items()} resolved = {} - flow_params = flow_class["parameters"] + flow_params = flow_blueprint["parameters"] user_params = user_params if user_params else {} # First pass: resolve parameters with explicit values or defaults @@ -49,7 +49,7 @@ class FlowConfig: if param_type not in self.param_type_cache: try: # Fetch parameter type definition from config store - type_def = await self.config.get("parameter-types").get(param_type) + type_def = await self.config.get("parameter-type").get(param_type) if type_def: self.param_type_cache[param_type] = json.loads(type_def) else: @@ -92,7 +92,7 @@ class FlowConfig: else: resolved[param_name] = str(default_value) - # Include any extra parameters from user that weren't in flow class definition + # Include any extra parameters from user that weren't in flow blueprint definition # This allows for forward compatibility (ensure they're strings) for key, value in user_params.items(): if key not in resolved: @@ -100,28 +100,28 @@ class FlowConfig: return resolved - async def handle_list_classes(self, msg): + async def handle_list_blueprints(self, msg): - names = list(await self.config.get("flow-classes").keys()) + names = list(await self.config.get("flow-blueprint").keys()) return FlowResponse( error = None, - class_names = names, + blueprint_names = names, ) - async def handle_get_class(self, msg): + async def handle_get_blueprint(self, msg): return FlowResponse( error = None, - class_definition = await self.config.get( - "flow-classes" - ).get(msg.class_name), + blueprint_definition = await self.config.get( + "flow-blueprint" + ).get(msg.blueprint_name), ) - async def handle_put_class(self, msg): + async def handle_put_blueprint(self, msg): - await self.config.get("flow-classes").put( - msg.class_name, msg.class_definition + await self.config.get("flow-blueprint").put( + msg.blueprint_name, msg.blueprint_definition ) await self.config.inc_version() @@ -132,11 +132,11 @@ class FlowConfig: error = None, ) - async def handle_delete_class(self, msg): + async def handle_delete_blueprint(self, msg): logger.debug(f"Flow config message: {msg}") - await self.config.get("flow-classes").delete(msg.class_name) + await self.config.get("flow-blueprint").delete(msg.blueprint_name) await self.config.inc_version() @@ -148,7 +148,7 @@ class FlowConfig: async def handle_list_flows(self, msg): - names = list(await self.config.get("flows").keys()) + names = list(await self.config.get("flow").keys()) return FlowResponse( error = None, @@ -157,7 +157,7 @@ class FlowConfig: async def handle_get_flow(self, msg): - flow_data = await self.config.get("flows").get(msg.flow_id) + flow_data = await self.config.get("flow").get(msg.flow_id) flow = json.loads(flow_data) return FlowResponse( @@ -169,23 +169,23 @@ class FlowConfig: async def handle_start_flow(self, msg): - if msg.class_name is None: - raise RuntimeError("No class name") + if msg.blueprint_name is None: + raise RuntimeError("No blueprint name") if msg.flow_id is None: raise RuntimeError("No flow ID") - if msg.flow_id in await self.config.get("flows").keys(): + if msg.flow_id in await self.config.get("flow").keys(): raise RuntimeError("Flow already exists") if msg.description is None: raise RuntimeError("No description") - if msg.class_name not in await self.config.get("flow-classes").keys(): - raise RuntimeError("Class does not exist") + if msg.blueprint_name not in await self.config.get("flow-blueprint").keys(): + raise RuntimeError("Blueprint does not exist") cls = json.loads( - await self.config.get("flow-classes").get(msg.class_name) + await self.config.get("flow-blueprint").get(msg.blueprint_name) ) # Resolve parameters by merging user-provided values with defaults @@ -200,7 +200,7 @@ class FlowConfig: def repl_template_with_params(tmp): result = tmp.replace( - "{class}", msg.class_name + "{blueprint}", msg.blueprint_name ).replace( "{id}", msg.flow_id ) @@ -210,7 +210,7 @@ class FlowConfig: return result - for kind in ("class", "flow"): + for kind in ("blueprint", "flow"): for k, v in cls[kind].items(): @@ -223,7 +223,7 @@ class FlowConfig: for k2, v2 in v.items() } - flac = await self.config.get("flows-active").get(processor) + flac = await self.config.get("active-flow").get(processor) if flac is not None: target = json.loads(flac) else: @@ -237,7 +237,7 @@ class FlowConfig: if variant not in target: target[variant] = v - await self.config.get("flows-active").put( + await self.config.get("active-flow").put( processor, json.dumps(target) ) @@ -258,11 +258,11 @@ class FlowConfig: else: interfaces = {} - await self.config.get("flows").put( + await self.config.get("flow").put( msg.flow_id, json.dumps({ "description": msg.description, - "class-name": msg.class_name, + "blueprint-name": msg.blueprint_name, "interfaces": interfaces, "parameters": parameters, }) @@ -281,22 +281,22 @@ class FlowConfig: if msg.flow_id is None: raise RuntimeError("No flow ID") - if msg.flow_id not in await self.config.get("flows").keys(): + if msg.flow_id not in await self.config.get("flow").keys(): raise RuntimeError("Flow ID invalid") - flow = json.loads(await self.config.get("flows").get(msg.flow_id)) + flow = json.loads(await self.config.get("flow").get(msg.flow_id)) - if "class-name" not in flow: - raise RuntimeError("Internal error: flow has no flow class") + if "blueprint-name" not in flow: + raise RuntimeError("Internal error: flow has no flow blueprint") - class_name = flow["class-name"] + blueprint_name = flow["blueprint-name"] parameters = flow.get("parameters", {}) - cls = json.loads(await self.config.get("flow-classes").get(class_name)) + cls = json.loads(await self.config.get("flow-blueprint").get(blueprint_name)) def repl_template(tmp): result = tmp.replace( - "{class}", class_name + "{blueprint}", blueprint_name ).replace( "{id}", msg.flow_id ) @@ -313,7 +313,7 @@ class FlowConfig: variant = repl_template(variant) - flac = await self.config.get("flows-active").get(processor) + flac = await self.config.get("active-flow").get(processor) if flac is not None: target = json.loads(flac) @@ -323,12 +323,12 @@ class FlowConfig: if variant in target: del target[variant] - await self.config.get("flows-active").put( + await self.config.get("active-flow").put( processor, json.dumps(target) ) - if msg.flow_id in await self.config.get("flows").keys(): - await self.config.get("flows").delete(msg.flow_id) + if msg.flow_id in await self.config.get("flow").keys(): + await self.config.get("flow").delete(msg.flow_id) await self.config.inc_version() @@ -342,14 +342,14 @@ class FlowConfig: logger.debug(f"Handling flow message: {msg.operation}") - if msg.operation == "list-classes": - resp = await self.handle_list_classes(msg) - elif msg.operation == "get-class": - resp = await self.handle_get_class(msg) - elif msg.operation == "put-class": - resp = await self.handle_put_class(msg) - elif msg.operation == "delete-class": - resp = await self.handle_delete_class(msg) + if msg.operation == "list-blueprints": + resp = await self.handle_list_blueprints(msg) + elif msg.operation == "get-blueprint": + resp = await self.handle_get_blueprint(msg) + elif msg.operation == "put-blueprint": + resp = await self.handle_put_blueprint(msg) + elif msg.operation == "delete-blueprint": + resp = await self.handle_delete_blueprint(msg) elif msg.operation == "list-flows": resp = await self.handle_list_flows(msg) elif msg.operation == "get-flow": diff --git a/trustgraph-flow/trustgraph/metering/counter.py b/trustgraph-flow/trustgraph/metering/counter.py index 07dea8ba..7851232a 100644 --- a/trustgraph-flow/trustgraph/metering/counter.py +++ b/trustgraph-flow/trustgraph/metering/counter.py @@ -52,7 +52,7 @@ class Processor(FlowProcessor): self.prices = {} - self.config_key = "token-costs" + self.config_key = "token-cost" # Load token costs from the config service async def on_cost_config(self, config, version):