Computer Use Updates
Rolling release / release (push) Failing after 1m46s

This commit is contained in:
2026-09-13 19:30:17 -04:00
parent c5ccaa490b
commit 599bfe440d
34 changed files with 1033 additions and 573 deletions
+20 -4
View File
@@ -5,11 +5,27 @@ import { spawn } from 'node:child_process';
export const MAX_LONG_EDGE = 1280;
export class FrameNormalizer {
constructor({ helper = path.resolve(new URL('./py/normalize_frame.py', import.meta.url).pathname), python = 'python3', spawnImpl = spawn, tmpDir = '/tmp/jarvis-cu', maxLongEdge = MAX_LONG_EDGE, quality = 70 } = {}) { this.helper = helper; this.python = python; this.spawnImpl = spawnImpl; this.tmpDir = tmpDir; this.maxLongEdge = maxLongEdge; this.quality = quality; }
constructor({ helper = path.resolve(new URL('./py/normalize_frame.py', import.meta.url).pathname), python = 'python3', spawnImpl = spawn, tmpDir = '/tmp/jarvis-cu', maxLongEdge = MAX_LONG_EDGE, quality = 70 } = {}) {
Object.assign(this, { helper, python, spawnImpl, tmpDir, maxLongEdge, quality });
}
async normalize(input, output = path.join(this.tmpDir, `frame-${Date.now()}.webp`), rect) {
await mkdir(path.dirname(output), { recursive: true });
const crop = rect ? rect.map(Number).map((value) => String(Math.round(value))) : [];
await new Promise((resolve, reject) => { const child = this.spawnImpl(this.python, [this.helper, input, output, String(this.maxLongEdge), String(this.quality), ...crop], { stdio: ['ignore', 'pipe', 'pipe'] }); let error = ''; child.stderr?.on('data', (d) => { error += d; }); child.on('error', reject); child.on('close', (code) => code === 0 ? resolve() : reject(new Error(error || `frame normalization exited ${code}`))); });
const info = await stat(output); return { path: output, bytes: info.size, maxLongEdge: this.maxLongEdge, mime: 'image/webp' };
const crop = rect ? rect.map(Number).map(value => String(Math.round(value))) : [];
let metadata = {};
await new Promise((resolve, reject) => {
const child = this.spawnImpl(this.python, [this.helper, input, output, String(this.maxLongEdge), String(this.quality), ...crop], { stdio: ['ignore', 'pipe', 'pipe'] });
let stderr = '', stdout = '';
const timer = setTimeout(() => { child.kill('SIGTERM'); reject(new Error('frame normalization timed out')); }, 8000);
child.stdout?.on('data', data => { stdout += data; });
child.stderr?.on('data', data => { stderr += data; });
child.on('error', error => { clearTimeout(timer); reject(error); });
child.on('close', code => {
clearTimeout(timer);
try { metadata = JSON.parse(stdout || '{}'); } catch {}
code === 0 ? resolve() : reject(new Error(stderr || `frame normalization exited ${code}`));
});
});
const info = await stat(output);
return { ...metadata, path: output, bytes: info.size, maxLongEdge: this.maxLongEdge, mime: 'image/webp' };
}
}