All files / src/core-entities enums.ts

100% Statements 55/55
100% Branches 18/18
100% Functions 9/9
100% Lines 55/55

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157                                  48x   48x   48x   48x   48x   48x   48x   48x   48x   48x   48x             48x   48x   48x   48x   48x   48x   48x   48x   48x   48x   48x   48x   48x   48x           48x   48x   48x   48x   48x                 48x   48x   48x           48x   48x   48x   48x   48x   48x               48x 48x 48x             48x 48x 48x 48x 48x 48x 48x               48x 48x 48x           48x 48x 48x    
/**
 * Centralized enums for OpenAPI documentation and type safety.
 * These enums are used by entities and exposed via Swagger for agent understanding.
 */
 
/**
 * AIAction lifecycle states.
 *
 * Workflow for review_first strategy:
 * - proposed → approve → approved_for_apply → apply → applied_pending_review → confirm → confirmed_kept
 * - proposed → discard → rejected_before_apply
 * - applied_pending_review → revert → confirmed_reverted
 *
 * Workflow for apply_revert strategy:
 * - proposed → auto-apply → applied_pending_review → confirm → confirmed_kept
 * - applied_pending_review → revert → confirmed_reverted
 */
export enum AIActionStatus {
  /** Initial state when action is parsed from LLM response */
  PROPOSED = 'proposed',
  /** Waiting for additional context before execution */
  AWAITING_CONTEXT = 'awaiting_context',
  /** Waiting for handover to another session/agent */
  AWAITING_HANDOVER = 'awaiting_handover',
  /** User approved the action for execution */
  APPROVED_FOR_APPLY = 'approved_for_apply',
  /** User discarded the action before execution */
  REJECTED_BEFORE_APPLY = 'rejected_before_apply',
  /** Action executed, awaiting user review (confirm or revert) */
  APPLIED_PENDING_REVIEW = 'applied_pending_review',
  /** User confirmed to keep the changes permanently */
  CONFIRMED_KEPT = 'confirmed_kept',
  /** User reverted the changes to original state */
  CONFIRMED_REVERTED = 'confirmed_reverted',
  /** Execution failed with error */
  EXECUTION_FAILED = 'execution_failed',
  /** Revert attempt failed */
  REVERT_FAILED = 'revert_failed',
}
 
/**
 * Types of actions the AI can propose and execute.
 * Each type has specific parameters and execution logic.
 */
export enum AIActionType {
  /** Create a new file with content */
  CREATE_FILE = 'create_file',
  /** Overwrite an existing file with new content */
  OVERWRITE_FILE = 'overwrite_file',
  /** Delete an existing file */
  DELETE_FILE = 'delete_file',
  /** Execute a shell command */
  RUN_COMMAND = 'run_command',
  /** Request additional context from workspace */
  REQUEST_CONTEXT = 'request_context',
  /** Final explanation/response to user (no file changes) */
  FINAL = 'final',
  /** Apply a small targeted edit to a file */
  QUICK_EDIT = 'quick_edit',
  /** Apply a diff patch to a file */
  APPLY_DIFF = 'apply_diff',
  /** Apply a token-based patch using TokenPatch library */
  PATCH = 'patch',
  /** Create a new follow-up session */
  NEW_SESSION = 'new_session',
  /** Write to the TODO/task list file */
  WRITE_TODO = 'write_todo',
  /** Execute TypeScript/JavaScript code in sandbox */
  EXECUTE_CODE = 'execute_code',
  /** Ask user a question with optional selection buttons */
  ASK_USER = 'ask_user',
}
 
/**
 * Session lifecycle states.
 */
export enum SessionStatus {
  /** Session is currently active and accepting inputs */
  ACTIVE = 'active',
  /** Session completed successfully */
  COMPLETED = 'completed',
  /** Session was manually aborted by user */
  ABORTED = 'aborted',
  /** Session failed with error */
  FAILED = 'failed',
}
 
/**
 * Execution strategy determines how actions are processed.
 *
 * - review_first: Actions stay as 'proposed' until user approves. Safe mode.
 * - apply_revert: Actions are auto-applied, user reviews after. Fast mode with revert safety.
 */
export enum ExecutionStrategy {
  /** Manual approval required before execution. User reviews proposals first. */
  REVIEW_FIRST = 'review_first',
  /** Auto-execute actions, then user confirms or reverts. Faster workflow. */
  APPLY_REVERT = 'apply_revert',
}
 
/**
 * Sub-agent run execution states.
 */
export enum SubAgentRunStatus {
  /** Sub-agent is currently executing */
  RUNNING = 'running',
  /** Sub-agent completed successfully */
  COMPLETED = 'completed',
  /** Sub-agent execution failed */
  FAILED = 'failed',
  /** Sub-agent exceeded time limit */
  TIMEOUT = 'timeout',
  /** Sub-agent was manually cancelled */
  CANCELLED = 'cancelled',
}
 
/**
 * Context template types.
 * - main: Full template that renders complete context
 * - partial: Reusable partial template for inclusion
 */
export enum TemplateType {
  MAIN = 'main',
  PARTIAL = 'partial',
}
 
/**
 * LLM reasoning effort levels (for models that support it).
 * Higher levels produce more thorough reasoning but slower responses.
 */
export enum ReasoningEffort {
  XHIGH = 'xhigh',
  HIGH = 'high',
  MEDIUM = 'medium',
  LOW = 'low',
  MINIMAL = 'minimal',
  NONE = 'none',
}
 
/**
 * Tool hook execution timing.
 * - before: Execute before the tool runs (can modify inputs or block)
 * - after: Execute after the tool runs (can modify outputs or log)
 */
export enum ToolHookTiming {
  BEFORE = 'before',
  AFTER = 'after',
}
 
/**
 * Message role in conversation (for synced conversations from external sources).
 */
export enum MessageRole {
  USER = 'user',
  MODEL = 'model',
}