-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.ts
More file actions
151 lines (140 loc) · 3.19 KB
/
types.ts
File metadata and controls
151 lines (140 loc) · 3.19 KB
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
/**
* Supported test runners that wright can auto-detect and invoke.
*/
export type TestRunner =
| 'pytest'
| 'playwright'
| 'jest'
| 'vitest'
| 'go-test'
| 'cargo-test'
| 'custom'
/**
* Supported package managers for dependency installation.
*/
export type PackageManager =
| 'npm'
| 'pnpm'
| 'yarn'
| 'pip'
| 'uv'
| 'poetry'
| 'cargo'
| 'go'
| 'none'
/**
* A job in the wright queue. Represents a single dev automation task:
* clone a repo, apply changes via Claude, run tests, create a PR.
*/
export interface Job {
id: string
repo_url: string
branch: string
task: string
/** Auto-detected from repo if null */
test_runner?: TestRunner
/** Auto-detected from repo if null */
package_manager?: PackageManager
max_loops: number
max_budget_usd: number
status: 'queued' | 'claimed' | 'running' | 'succeeded' | 'failed'
worker_id?: string
pr_url?: string
total_cost_usd: number
/** Current attempt number (1-based) */
attempt: number
/** Maximum retries on worker crash */
max_attempts: number
/** GitHub token for repo access */
github_token: string
/** For revision jobs: the existing feature branch to push to (e.g. wright/14da897c) */
feature_branch?: string
/** For revision jobs: the ID of the original job this is revising */
parent_job_id?: string
// Telegram integration
telegram_chat_id?: number
telegram_message_id?: number
// Timestamps
created_at: string
claimed_at?: string
started_at?: string
completed_at?: string
heartbeat_at?: string
// Error details on failure
error?: string
}
/**
* Aggregated test results from a single test run.
*/
export interface TestResults {
passed: number
failed: number
errors: number
skipped: number
total: number
/** Duration in seconds */
duration: number
failures: TestFailure[]
/** Raw test runner output (truncated) */
raw?: string
}
/**
* A single test failure with diagnostic information.
*/
export interface TestFailure {
name: string
message: string
stdout?: string
}
/**
* Configuration for the dev loop (Ralph Loop).
*/
export interface DevLoopConfig {
job: Job
supabaseUrl: string
supabaseServiceKey: string
/** Claude model to use */
model: string
/** Max turns per Claude session within a single loop */
maxTurnsPerLoop: number
/** Timeout per test run in seconds */
testTimeoutSeconds: number
/** Anthropic API key (uses env ANTHROPIC_API_KEY if not set) */
anthropicApiKey?: string
/** Abort controller for graceful cancellation (e.g. SIGTERM) */
abortController?: AbortController
}
/**
* Result of a completed dev loop.
*/
export interface DevLoopResult {
success: boolean
loopsCompleted: number
totalCostUsd: number
finalTestResults: TestResults
prUrl?: string
commitSha?: string
error?: string
}
/**
* Event emitted during job processing for observability.
*/
export interface JobEvent {
id: string
job_id: string
event_type:
| 'claimed'
| 'cloned'
| 'loop_start'
| 'edit'
| 'test_run'
| 'test_pass'
| 'test_fail'
| 'pr_created'
| 'completed'
| 'error'
| 'budget_exceeded'
loop_number?: number
payload?: Record<string, unknown>
created_at: string
}