Lobby
This commit is contained in:
1 parent
73a2db8bb8
commit
44cf31ce6b
231 files changed
+3396887
-1109081
No files matched your search
@@ -0,0 +1,51 @@
|
||||
// Клиент Studio MCP без настройки сессии: node tools/mcp/run.js steps.json
|
||||
// steps: [{ tool, args, waitAfter }]; studio_id подставляется сам (первый подключённый Studio).
|
||||
// Снимки (screen_capture) сохраняются рядом со steps.json как img_<время>.jpeg.
|
||||
const { spawn } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const stepsFile = process.argv[2];
|
||||
const steps = JSON.parse(fs.readFileSync(stepsFile, 'utf8').replace(/^/, ''));
|
||||
const outDir = path.dirname(path.resolve(stepsFile));
|
||||
const p = spawn('cmd.exe', ['/c', path.join(process.env.LOCALAPPDATA, 'Roblox', 'mcp.bat')], { stdio: ['pipe', 'pipe', 'pipe'] });
|
||||
let buf = '', id = 0;
|
||||
const pending = {};
|
||||
p.stdout.on('data', d => {
|
||||
buf += d.toString('utf8');
|
||||
let i;
|
||||
while ((i = buf.indexOf('\n')) >= 0) {
|
||||
const line = buf.slice(0, i).trim();
|
||||
buf = buf.slice(i + 1);
|
||||
if (!line) continue;
|
||||
try { const m = JSON.parse(line); if (m.id != null && pending[m.id]) { pending[m.id](m); delete pending[m.id]; } } catch (e) {}
|
||||
}
|
||||
});
|
||||
p.stderr.on('data', () => {});
|
||||
const rpc = (method, params) => { const myId = ++id; p.stdin.write(JSON.stringify({ jsonrpc: '2.0', id: myId, method, params }) + '\n'); return new Promise(r => (pending[myId] = r)); };
|
||||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||
const done = code => { try { p.stdin.end(); } catch (e) {} p.kill(); process.exit(code); };
|
||||
(async () => {
|
||||
setTimeout(() => { console.log('TIMEOUT'); done(1); }, 290000);
|
||||
await rpc('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'fishing-tools', version: '1' } });
|
||||
p.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
|
||||
await sleep(8000);
|
||||
const ls = await rpc('tools/call', { name: 'list_roblox_studios', arguments: {} });
|
||||
let SID;
|
||||
try { SID = JSON.parse(ls.result.content[0].text).studios[0].id; } catch (e) {}
|
||||
if (!SID) { console.log('NO STUDIO CONNECTED: ' + JSON.stringify(ls.result || ls.error)); done(1); return; }
|
||||
for (const s of steps) {
|
||||
const r = await rpc('tools/call', { name: s.tool, arguments: Object.assign({ studio_id: SID }, s.args || {}) });
|
||||
const res = r.result || r.error;
|
||||
const text = res && res.content ? res.content.map(c => {
|
||||
if (c.type === 'image' && c.data) {
|
||||
const f = path.join(outDir, 'img_' + Date.now() + '.' + ((c.mimeType || 'image/jpeg').split('/')[1] || 'jpeg'));
|
||||
fs.writeFileSync(f, Buffer.from(c.data, 'base64'));
|
||||
return 'IMAGE ' + f;
|
||||
}
|
||||
return c.text || '[' + c.type + ']';
|
||||
}).join('\n') : JSON.stringify(res);
|
||||
console.log('=== ' + s.tool + (res && res.isError ? ' (ERROR)' : '') + '\n' + text);
|
||||
if (s.waitAfter) await sleep(s.waitAfter);
|
||||
}
|
||||
done(0);
|
||||
})();
|
||||
Reference in new issue
Block a user