-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtasks.py
More file actions
474 lines (468 loc) · 16.2 KB
/
Copy pathtasks.py
File metadata and controls
474 lines (468 loc) · 16.2 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
"""Mini Windows GUI evaluation tasks for the Daytona computer-use guide."""
from __future__ import annotations
from dataclasses import dataclass
@dataclass
class Task:
id: str
instruction: str
setup: list[str]
verify: str
oracle: list[str]
timeout_s: int = 300
TASKS: list[Task] = [
Task(
id="notepad-write-save",
instruction=(
"Open Notepad. Type exactly this sentence, with no extra characters: "
"Daytona Windows GUI evals can save exact text. "
"Save the file exactly as C:\\evals\\report.txt."
),
setup=[
r"""
$ErrorActionPreference = 'Stop'
$root = 'C:\evals'
$null = New-Item -ItemType Directory -Path $root -Force
Remove-Item -LiteralPath (Join-Path $root 'report.txt') -Force -ErrorAction SilentlyContinue
Write-Output 'setup-ok'
""".strip()
],
verify=r"""
$path = 'C:\evals\report.txt'
$expected = 'Daytona Windows GUI evals can save exact text.'
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
Write-Output 'FAIL'
Write-Output 'report.txt was not created'
exit 0
}
$actual = [System.IO.File]::ReadAllText($path)
if ($actual -ceq $expected) {
Write-Output 'PASS'
} else {
Write-Output 'FAIL'
Write-Output ('report.txt content mismatch; length=' + $actual.Length)
}
""".strip(),
oracle=[
r"""
$ErrorActionPreference = 'Stop'
$root = 'C:\evals'
$path = Join-Path $root 'report.txt'
$null = New-Item -ItemType Directory -Path $root -Force
Set-Content -LiteralPath $path -Value 'Daytona Windows GUI evals can save exact text.' -NoNewline -Encoding UTF8
""".strip()
],
),
Task(
id="explorer-folder-tree",
instruction=(
"Use File Explorer to create this folder tree exactly: "
"C:\\evals\\projects\\alpha\\docs and C:\\evals\\projects\\beta\\docs."
),
setup=[
r"""
$ErrorActionPreference = 'Stop'
$root = 'C:\evals'
$null = New-Item -ItemType Directory -Path $root -Force
Remove-Item -LiteralPath (Join-Path $root 'projects') -Recurse -Force -ErrorAction SilentlyContinue
Write-Output 'setup-ok'
""".strip()
],
verify=r"""
$required = @(
'C:\evals\projects\alpha\docs',
'C:\evals\projects\beta\docs'
)
$missing = @()
foreach ($path in $required) {
if (-not (Test-Path -LiteralPath $path -PathType Container)) {
$missing += $path
}
}
if ($missing.Count -eq 0) {
Write-Output 'PASS'
} else {
Write-Output 'FAIL'
Write-Output ('missing directories: ' + ($missing -join ', '))
}
""".strip(),
oracle=[
r"""
$ErrorActionPreference = 'Stop'
$null = New-Item -ItemType Directory -Path 'C:\evals\projects\alpha\docs' -Force
$null = New-Item -ItemType Directory -Path 'C:\evals\projects\beta\docs' -Force
""".strip()
],
),
Task(
id="env-var-gui",
instruction=(
"Use the Windows System Properties Environment Variables dialog to add a User variable. "
"Set the variable name exactly to EVALS_PROBE and the value exactly to 42. "
"Do not create a System variable."
),
setup=[
r"""
$ErrorActionPreference = 'Stop'
$null = New-Item -ItemType Directory -Path 'C:\evals' -Force
[Environment]::SetEnvironmentVariable('EVALS_PROBE', $null, 'User')
try { [Environment]::SetEnvironmentVariable('EVALS_PROBE', $null, 'Machine') } catch { }
Remove-ItemProperty -Path 'HKCU:\Environment' -Name 'EVALS_PROBE' -ErrorAction SilentlyContinue
Write-Output 'setup-ok'
""".strip()
],
verify=r"""
$props = Get-ItemProperty -Path 'HKCU:\Environment' -Name 'EVALS_PROBE' -ErrorAction SilentlyContinue
if ($null -eq $props) {
Write-Output 'FAIL'
Write-Output 'EVALS_PROBE is missing from HKCU:\Environment'
exit 0
}
$value = $props.EVALS_PROBE
$machineValue = [Environment]::GetEnvironmentVariable('EVALS_PROBE', 'Machine')
if ($machineValue -ceq '42') {
Write-Output 'FAIL'
Write-Output 'EVALS_PROBE was also created as a System variable with value 42'
} elseif ($value -ceq '42') {
Write-Output 'PASS'
} else {
Write-Output 'FAIL'
Write-Output ('EVALS_PROBE value was ' + [string]$value)
}
""".strip(),
oracle=[
r"""
$ErrorActionPreference = 'Stop'
[Environment]::SetEnvironmentVariable('EVALS_PROBE', '42', 'User')
Set-ItemProperty -Path 'HKCU:\Environment' -Name 'EVALS_PROBE' -Value '42'
""".strip()
],
),
Task(
id="zip-roundtrip",
instruction=(
"Use File Explorer's context menu to compress the folder C:\\evals\\to-archive "
"into a zip file saved exactly as C:\\evals\\archive.zip."
),
setup=[
r"""
$ErrorActionPreference = 'Stop'
$root = 'C:\evals'
$source = Join-Path $root 'to-archive'
$null = New-Item -ItemType Directory -Path $root -Force
Remove-Item -LiteralPath (Join-Path $root 'archive.zip') -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath $source -Recurse -Force -ErrorAction SilentlyContinue
$null = New-Item -ItemType Directory -Path $source -Force
Set-Content -LiteralPath (Join-Path $source 'alpha.txt') -Value 'alpha file' -Encoding UTF8
Set-Content -LiteralPath (Join-Path $source 'beta.txt') -Value 'beta file' -Encoding UTF8
Set-Content -LiteralPath (Join-Path $source 'gamma.txt') -Value 'gamma file' -Encoding UTF8
Write-Output 'setup-ok'
""".strip()
],
verify=r"""
$ErrorActionPreference = 'Stop'
$zip = 'C:\evals\archive.zip'
if (-not (Test-Path -LiteralPath $zip -PathType Leaf)) {
Write-Output 'FAIL'
Write-Output 'archive.zip was not created'
exit 0
}
$temp = Join-Path $env:TEMP ('daytona-zip-check-' + [guid]::NewGuid().ToString('N'))
try {
$null = New-Item -ItemType Directory -Path $temp -Force
Expand-Archive -LiteralPath $zip -DestinationPath $temp -Force
$expected = @{
'alpha.txt' = 'alpha file'
'beta.txt' = 'beta file'
'gamma.txt' = 'gamma file'
}
$files = @(Get-ChildItem -LiteralPath $temp -Recurse -File)
$actualNames = @($files | Select-Object -ExpandProperty Name | Sort-Object)
$expectedNames = @($expected.Keys | Sort-Object)
$nameDiff = @(Compare-Object -ReferenceObject $expectedNames -DifferenceObject $actualNames)
$badContent = @()
foreach ($file in $files) {
if ($expected.ContainsKey($file.Name)) {
$content = [System.IO.File]::ReadAllText($file.FullName).Trim()
if ($content -cne $expected[$file.Name]) {
$badContent += $file.Name
}
}
}
if ($actualNames.Count -eq 3 -and $nameDiff.Count -eq 0 -and $badContent.Count -eq 0) {
Write-Output 'PASS'
} else {
Write-Output 'FAIL'
Write-Output ('zip filenames were: ' + ($actualNames -join ', '))
if ($badContent.Count -gt 0) {
Write-Output ('files with wrong content: ' + ($badContent -join ', '))
}
}
} catch {
Write-Output 'FAIL'
Write-Output ('zip could not be expanded: ' + $_.Exception.Message)
} finally {
Remove-Item -LiteralPath $temp -Recurse -Force -ErrorAction SilentlyContinue
}
""".strip(),
oracle=[
r"""
$ErrorActionPreference = 'Stop'
$zip = 'C:\evals\archive.zip'
Remove-Item -LiteralPath $zip -Force -ErrorAction SilentlyContinue
Compress-Archive -LiteralPath 'C:\evals\to-archive' -DestinationPath $zip -Force
""".strip()
],
),
Task(
id="calc-to-notepad",
instruction=(
"Use Calculator to compute 847 * 63. Then open Notepad, type only the result, "
"and save the file exactly as C:\\evals\\result.txt."
),
setup=[
r"""
$ErrorActionPreference = 'Stop'
$root = 'C:\evals'
$null = New-Item -ItemType Directory -Path $root -Force
Remove-Item -LiteralPath (Join-Path $root 'result.txt') -Force -ErrorAction SilentlyContinue
Write-Output 'setup-ok'
""".strip()
],
verify=r"""
$path = 'C:\evals\result.txt'
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
Write-Output 'FAIL'
Write-Output 'result.txt was not created'
exit 0
}
$actual = [System.IO.File]::ReadAllText($path).Trim()
if ($actual -ceq '53361') {
Write-Output 'PASS'
} else {
Write-Output 'FAIL'
Write-Output ('result.txt contained: ' + $actual)
}
""".strip(),
oracle=[
r"""
$ErrorActionPreference = 'Stop'
$path = 'C:\evals\result.txt'
$null = New-Item -ItemType Directory -Path (Split-Path -Parent $path) -Force
Set-Content -LiteralPath $path -Value '53361' -NoNewline -Encoding UTF8
""".strip()
],
),
Task(
id="mspaint-save",
instruction=(
"Open Paint, draw anything visible on the canvas, and save it as a PNG file "
"exactly at C:\\evals\\drawing.png."
),
setup=[
r"""
$ErrorActionPreference = 'Stop'
$root = 'C:\evals'
$null = New-Item -ItemType Directory -Path $root -Force
Remove-Item -LiteralPath (Join-Path $root 'drawing.png') -Force -ErrorAction SilentlyContinue
Write-Output 'setup-ok'
""".strip()
],
verify=r"""
$path = 'C:\evals\drawing.png'
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
Write-Output 'FAIL'
Write-Output 'drawing.png was not created'
exit 0
}
$file = Get-Item -LiteralPath $path
if ($file.Length -le 1024) {
Write-Output 'FAIL'
Write-Output ('drawing.png was too small: ' + $file.Length + ' bytes')
exit 0
}
$stream = [System.IO.File]::OpenRead($path)
try {
$header = New-Object byte[] 8
$read = $stream.Read($header, 0, 8)
} finally {
$stream.Dispose()
}
$expected = [byte[]](137, 80, 78, 71, 13, 10, 26, 10)
$matches = ($read -eq 8)
for ($i = 0; $i -lt 8; $i++) {
if ($header[$i] -ne $expected[$i]) { $matches = $false }
}
if (-not $matches) {
Write-Output 'FAIL'
Write-Output 'drawing.png did not have PNG magic bytes'
exit 0
}
Add-Type -AssemblyName System.Drawing
$bitmap = New-Object System.Drawing.Bitmap -ArgumentList $path
try {
$colors = New-Object 'System.Collections.Generic.HashSet[int]'
$hasNonWhitePixel = $false
for ($x = 0; $x -lt $bitmap.Width; $x++) {
for ($y = 0; $y -lt $bitmap.Height; $y++) {
$color = $bitmap.GetPixel($x, $y)
$null = $colors.Add($color.ToArgb())
if (-not ($color.R -gt 245 -and $color.G -gt 245 -and $color.B -gt 245)) {
$hasNonWhitePixel = $true
}
}
}
if ($colors.Count -ge 2 -and $hasNonWhitePixel) {
Write-Output 'PASS'
} else {
Write-Output 'FAIL'
Write-Output 'drawing.png appears blank'
}
} finally {
$bitmap.Dispose()
}
""".strip(),
oracle=[
r"""
$ErrorActionPreference = 'Stop'
$path = 'C:\evals\drawing.png'
$null = New-Item -ItemType Directory -Path (Split-Path -Parent $path) -Force
Add-Type -AssemblyName System.Drawing
$bitmap = New-Object System.Drawing.Bitmap -ArgumentList 256, 256
try {
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$colors = @('#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f')
for ($i = 0; $i -lt $colors.Count; $i++) {
$brush = New-Object System.Drawing.SolidBrush ([System.Drawing.ColorTranslator]::FromHtml($colors[$i]))
try {
$graphics.FillRectangle($brush, 0, $i * 32, 256, 32)
} finally {
$brush.Dispose()
}
}
} finally {
$graphics.Dispose()
}
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$pen = New-Object System.Drawing.Pen -ArgumentList ([System.Drawing.Color]::Black), 4
$graphics.DrawEllipse($pen, 32, 32, 192, 192)
$graphics.DrawLine($pen, 0, 255, 255, 0)
} finally {
if ($pen) { $pen.Dispose() }
$graphics.Dispose()
}
$bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
} finally {
$bitmap.Dispose()
}
""".strip()
],
),
Task(
id="powershell-interactive",
instruction=(
"Open a visible Windows PowerShell window using the Windows GUI. In that window, "
"type a command that writes Get-Date output to C:\\evals\\when.txt, then press Enter."
),
setup=[
r"""
$ErrorActionPreference = 'Stop'
$root = 'C:\evals'
$null = New-Item -ItemType Directory -Path $root -Force
Remove-Item -LiteralPath (Join-Path $root 'when.txt') -Force -ErrorAction SilentlyContinue
Write-Output 'setup-ok'
""".strip()
],
verify=r"""
$path = 'C:\evals\when.txt'
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
Write-Output 'FAIL'
Write-Output 'when.txt was not created'
exit 0
}
$content = [System.IO.File]::ReadAllText($path).Trim()
$parsed = [datetime]::MinValue
if ([datetime]::TryParse($content, [Globalization.CultureInfo]::CurrentCulture, [Globalization.DateTimeStyles]::AllowWhiteSpaces, [ref]$parsed)) {
Write-Output 'PASS'
} else {
Write-Output 'FAIL'
Write-Output 'when.txt did not contain parseable Get-Date output'
}
""".strip(),
oracle=[
r"""
$ErrorActionPreference = 'Stop'
$path = 'C:\evals\when.txt'
$null = New-Item -ItemType Directory -Path (Split-Path -Parent $path) -Force
Get-Date | Out-File -LiteralPath $path -Encoding UTF8
""".strip()
],
),
Task(
id="find-and-fix",
instruction=(
"Use File Explorer search under C:\\evals\\cfg to find the nested settings.ini "
"file containing the exact line colour=blu. Open that file in Notepad, change only "
"that line to colour=blue, and save it. There are decoy files; leave them unchanged."
),
setup=[
r"""
$ErrorActionPreference = 'Stop'
$root = 'C:\evals\cfg'
Remove-Item -LiteralPath $root -Recurse -Force -ErrorAction SilentlyContinue
$targetDir = 'C:\evals\cfg\prod\desktop\primary'
$decoyDirA = 'C:\evals\cfg\prod\desktop\backup'
$decoyDirB = 'C:\evals\cfg\archive\mobile\legacy'
$null = New-Item -ItemType Directory -Path $targetDir -Force
$null = New-Item -ItemType Directory -Path $decoyDirA -Force
$null = New-Item -ItemType Directory -Path $decoyDirB -Force
Set-Content -LiteralPath (Join-Path $targetDir 'settings.ini') -Value @('[display]', 'profile=primary', 'colour=blu', 'scale=100') -Encoding UTF8
Set-Content -LiteralPath (Join-Path $decoyDirA 'settings.ini') -Value @('[display]', 'profile=backup', 'colour=green', 'scale=100') -Encoding UTF8
Set-Content -LiteralPath (Join-Path $decoyDirB 'settings.ini') -Value @('[display]', 'profile=legacy', 'color=blu', 'scale=125') -Encoding UTF8
Set-Content -LiteralPath (Join-Path $root 'readme.txt') -Value 'Search the settings files. Only one has the exact colour typo.' -Encoding UTF8
Write-Output 'setup-ok'
""".strip()
],
verify=r"""
$target = 'C:\evals\cfg\prod\desktop\primary\settings.ini'
if (-not (Test-Path -LiteralPath $target -PathType Leaf)) {
Write-Output 'FAIL'
Write-Output 'target settings.ini was missing'
exit 0
}
$targetLines = @(Get-Content -LiteralPath $target)
$expectedTarget = @('[display]', 'profile=primary', 'colour=blue', 'scale=100')
$expectedBackup = @('[display]', 'profile=backup', 'colour=green', 'scale=100')
$expectedLegacy = @('[display]', 'profile=legacy', 'color=blu', 'scale=125')
$backup = 'C:\evals\cfg\prod\desktop\backup\settings.ini'
$legacy = 'C:\evals\cfg\archive\mobile\legacy\settings.ini'
$problems = @()
if (($targetLines -join "`n") -cne ($expectedTarget -join "`n")) {
$problems += 'target settings.ini was not changed exactly as expected'
}
if (-not (Test-Path -LiteralPath $backup -PathType Leaf) -or ((@(Get-Content -LiteralPath $backup) -join "`n") -cne ($expectedBackup -join "`n"))) {
$problems += 'backup decoy changed'
}
if (-not (Test-Path -LiteralPath $legacy -PathType Leaf) -or ((@(Get-Content -LiteralPath $legacy) -join "`n") -cne ($expectedLegacy -join "`n"))) {
$problems += 'legacy decoy changed'
}
if ($problems.Count -eq 0) {
Write-Output 'PASS'
} else {
Write-Output 'FAIL'
$problems | ForEach-Object { Write-Output $_ }
}
""".strip(),
oracle=[
r"""
$ErrorActionPreference = 'Stop'
$target = 'C:\evals\cfg\prod\desktop\primary\settings.ini'
$updated = @(Get-Content -LiteralPath $target | ForEach-Object {
if ($_ -ceq 'colour=blu') { 'colour=blue' } else { $_ }
})
Set-Content -LiteralPath $target -Value $updated -Encoding UTF8
""".strip()
],
),
]