| 1234567891011121314151617181920212223242526272829303132333435363738 |
- // 251 langgraph pytest via SHELL channel v2 (POST /api/shell direct, bash) - R117 retry
- const BASE = process.env.OPENCODE_251_BASE || 'http://192.168.16.251:4096';
- const AUTH = 'Basic ' + Buffer.from('opencode:' + (process.env.OPENCODE_SERVER_PASSWORD || 'IwinTrue@123')).toString('base64');
- const capMs = parseInt(process.env.DISPATCH_CAP_MS || '720000', 10);
- const CMD = 'cd /sc-data/cfc/cfc-langgraph && git fetch origin 2>&1 | tail -2; git reset --hard origin/cfclub 2>&1 | tail -2; timeout 650 .venv/bin/python -m pytest tests --ignore=tests/qna --ignore=tests/test_chat.py -q --tb=line; echo EXIT=$?';
- async function j(url, opt) {
- const r = await fetch(url, Object.assign({ headers: { 'Authorization': AUTH, 'Content-Type': 'application/json' } }, opt));
- const t = await r.text();
- try { return { status: r.status, json: JSON.parse(t) }; } catch { return { status: r.status, text: t }; }
- }
- async function main() {
- const cr = await j(BASE + '/api/shell', { method: 'POST', body: JSON.stringify({ command: CMD }) });
- const shellId = (cr.json.data && cr.json.data.id) || cr.json.id;
- if (!shellId) throw new Error('no shell id on create: ' + JSON.stringify(cr.json).slice(0, 200));
- console.log('SHELL_ID', shellId, 'status', cr.json.data && cr.json.data.status);
- const start = Date.now();
- let last = '';
- while (Date.now() - start < capMs) {
- await new Promise(r => setTimeout(r, 8000));
- const st = await j(BASE + '/api/shell/' + shellId);
- const status = (st.json && ((st.json.data && st.json.data.status) || st.json.status)) || '?';
- if (status !== last) { console.log('SHELL_STATUS', status, '@', Math.round((Date.now() - start) / 1000) + 's'); last = status; }
- if (status && status !== 'running' && status !== 'pending' && status !== 'queued') {
- const out = await j(BASE + '/api/shell/' + shellId + '/output');
- const o = (out.json && out.json.data && out.json.data.output) || '';
- console.log('OUTPUT_BEGIN');
- console.log(o.slice(-6000));
- console.log('OUTPUT_END');
- return;
- }
- }
- console.log('SHELL_TIMEOUT after ' + capMs + 'ms');
- }
- main().catch(e => { console.error('ERR', e.message); process.exit(1); });
|