feat(phase4-5): add Workflow types and expand Skills ecosystem

Phase 4: Type System Completion (P2)
- Add comprehensive Workflow type definitions:
  - WorkflowStepType: hand, skill, agent, condition, parallel, delay
  - WorkflowStep: individual step configuration
  - Workflow: complete workflow definition
  - WorkflowRunStatus: pending, running, completed, failed, cancelled, paused
  - WorkflowRun: execution instance tracking
  - Request/Response types for API operations
  - Control types for pause/resume/cancel
- Update types/index.ts with workflow exports

Phase 5: Skills Ecosystem Expansion (P2)
- Add 5 new Skills with SKILL.md definitions:
  - git: Git version control operations
  - file-operations: File system operations
  - web-search: Web search capabilities
  - data-analysis: Data analysis and visualization
  - shell-command: Shell command execution
- Skills coverage now at 9/60+ (15%)

Documentation:
- Update SYSTEM_ANALYSIS.md Phase 4 & 5 status
- Mark Phase 4 as completed
- Update Phase 5 progress tracking

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-15 01:51:45 +08:00
parent 9c99ab16d4
commit d60d445cbf
8 changed files with 947 additions and 10 deletions

View File

@@ -38,3 +38,21 @@ export type {
SettingsValidationError,
SettingsResponse,
} from './settings';
// Workflow Types
export type {
WorkflowStepType,
WorkflowStep,
Workflow,
WorkflowRunStatus,
WorkflowRun,
CreateWorkflowRequest,
UpdateWorkflowRequest,
WorkflowListResponse,
WorkflowResponse,
WorkflowRunListResponse,
TriggerWorkflowRequest,
TriggerWorkflowResponse,
WorkflowControlRequest,
WorkflowControlResponse,
} from './workflow';

View File

@@ -0,0 +1,212 @@
/**
* Workflow Type Definitions for OpenFang
*
* This module defines all TypeScript types related to workflow
* management, execution, and monitoring in the OpenFang system.
*
* @module types/workflow
*/
/**
* Types of workflow steps available in OpenFang
*/
export type WorkflowStepType =
| 'hand' // Execute a Hand (autonomous capability)
| 'skill' // Execute a Skill
| 'agent' // Delegate to an Agent
| 'condition' // Conditional branching
| 'parallel' // Parallel execution of sub-steps
| 'delay'; // Time-based delay
/**
* Represents a single step in a workflow
*/
export interface WorkflowStep {
/** Unique identifier for this step */
id: string;
/** Optional display name for the step */
name?: string;
/** Type of the workflow step */
type: WorkflowStepType;
/** Name of the Hand to execute (when type='hand') */
handName?: string;
/** Name of the Skill to execute (when type='skill') */
skillName?: string;
/** ID of the Agent to delegate to (when type='agent') */
agentId?: string;
/** Condition expression to evaluate (when type='condition') */
condition?: string;
/** Parameters to pass to the step execution */
params?: Record<string, unknown>;
/** Timeout duration in seconds */
timeout?: number;
/** Number of retry attempts on failure */
retryCount?: number;
/** Error handling strategy */
onError?: 'continue' | 'stop' | 'retry';
}
/**
* Complete workflow definition
*/
export interface Workflow {
/** Unique identifier for the workflow */
id: string;
/** Display name of the workflow */
name: string;
/** Optional description of what the workflow does */
description?: string;
/** Ordered list of steps to execute */
steps: WorkflowStep[];
/** Workflow version for tracking changes */
version?: string;
/** ISO timestamp of workflow creation */
createdAt?: string;
/** ISO timestamp of last update */
updatedAt?: string;
/** Current lifecycle status of the workflow */
status?: 'draft' | 'active' | 'archived';
}
/**
* Possible states of a workflow run
*/
export type WorkflowRunStatus =
| 'pending' // Waiting to start
| 'running' // Currently executing
| 'completed' // Finished successfully
| 'failed' // Terminated with error
| 'cancelled' // Manually stopped
| 'paused'; // Temporarily suspended
/**
* Represents a single execution instance of a workflow
*/
export interface WorkflowRun {
/** Unique identifier for this run instance */
runId: string;
/** ID of the workflow being executed */
workflowId: string;
/** Current execution status */
status: WorkflowRunStatus;
/** ID of the currently executing step */
step?: string;
/** Index of current step (0-based) */
currentStepIndex?: number;
/** Total number of steps in workflow */
totalSteps?: number;
/** ISO timestamp when run started */
startedAt?: string;
/** ISO timestamp when run completed */
completedAt?: string;
/** Result data from successful execution */
result?: unknown;
/** Error message if run failed */
error?: string;
/** Additional metadata about the run */
metadata?: Record<string, unknown>;
}
/**
* Request payload for creating a new workflow
*/
export interface CreateWorkflowRequest {
/** Display name for the new workflow */
name: string;
/** Optional description */
description?: string;
/** Steps to include in the workflow (IDs will be auto-generated) */
steps: Omit<WorkflowStep, 'id'>[];
}
/**
* Request payload for updating an existing workflow
*/
export interface UpdateWorkflowRequest {
/** New display name */
name?: string;
/** New description */
description?: string;
/** Updated step definitions */
steps?: WorkflowStep[];
/** New lifecycle status */
status?: 'draft' | 'active' | 'archived';
}
/**
* API response for listing workflows
*/
export interface WorkflowListResponse {
/** Array of workflow definitions */
workflows: Workflow[];
/** Total count of workflows */
total: number;
}
/**
* API response for single workflow operations
*/
export interface WorkflowResponse {
/** The workflow data */
workflow: Workflow;
/** Whether the operation succeeded */
success: boolean;
/** Error message if operation failed */
error?: string;
}
/**
* API response for listing workflow runs
*/
export interface WorkflowRunListResponse {
/** Array of workflow run instances */
runs: WorkflowRun[];
/** Total count of runs */
total: number;
}
/**
* Request to trigger a workflow execution
*/
export interface TriggerWorkflowRequest {
/** ID of the workflow to execute */
workflowId: string;
/** Optional parameters to pass to the workflow */
params?: Record<string, unknown>;
/** Whether to run asynchronously (default: true) */
async?: boolean;
}
/**
* API response for workflow trigger operations
*/
export interface TriggerWorkflowResponse {
/** ID of the started run */
runId: string;
/** Whether the trigger was successful */
success: boolean;
/** Error message if trigger failed */
error?: string;
}
/**
* Request to control a running workflow
*/
export interface WorkflowControlRequest {
/** ID of the run to control */
runId: string;
/** Control action to perform */
action: 'pause' | 'resume' | 'cancel';
}
/**
* API response for workflow control operations
*/
export interface WorkflowControlResponse {
/** Whether the control action succeeded */
success: boolean;
/** New status after control action */
newStatus?: WorkflowRunStatus;
/** Error message if action failed */
error?: string;
}