@buoy-gg/mcp 7.0.72 → 7.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as S}from"module";const N=S(import.meta.url);import{SyncClient as b,createMcpServer as R,stopAllHidStreamsNow as B,stopAllRecordingsNow as O}from"./chunk-ZJAAYXQM.mjs";import{runInit as T}from"./chunk-E3ECF6L6.mjs";import"./chunk-FJI4FST7.mjs";import"./chunk-GG4ZR76D.mjs";import"./chunk-SXYS37FL.mjs";import"./chunk-OUCB2Y5J.mjs";import"./chunk-FOMLVT7K.mjs";import"./chunk-OP23W722.mjs";import"./chunk-DVRR7W22.mjs";import"./chunk-MTTWR4T7.mjs";import{StdioServerTransport as $}from"@modelcontextprotocol/sdk/server/stdio.js";var k=console.log;console.log=(...e)=>console.error(...e);console.info=(...e)=>console.error(...e);console.debug=(...e)=>console.error(...e);async function P(){const e=process.env.BUOY_BROKER_PORT;const r=new b({url:process.env.BUOY_BROKER_URL,port:e?Number(e):void 0,autoSpawnBroker:process.env.BUOY_NO_SPAWN!=="1"});const n=R(r);const t=new $;let c=false;const s=o=>{if(c)return;c=true;process.stderr.write(`[buoy-mcp] shutting down (${o})
2
+ import{createRequire as S}from"module";const N=S(import.meta.url);import{SyncClient as b,createMcpServer as R,stopAllHidStreamsNow as B,stopAllRecordingsNow as O}from"./chunk-S4JHE46Q.mjs";import{runInit as T}from"./chunk-OADIHE3T.mjs";import"./chunk-AHIKIVTB.mjs";import"./chunk-DZRRLTOD.mjs";import"./chunk-MJDNVDJI.mjs";import"./chunk-OUCB2Y5J.mjs";import"./chunk-FOMLVT7K.mjs";import"./chunk-OP23W722.mjs";import"./chunk-DVRR7W22.mjs";import"./chunk-MTTWR4T7.mjs";import{StdioServerTransport as $}from"@modelcontextprotocol/sdk/server/stdio.js";var k=console.log;console.log=(...e)=>console.error(...e);console.info=(...e)=>console.error(...e);console.debug=(...e)=>console.error(...e);async function P(){const e=process.env.BUOY_BROKER_PORT;const r=new b({url:process.env.BUOY_BROKER_URL,port:e?Number(e):void 0,autoSpawnBroker:process.env.BUOY_NO_SPAWN!=="1"});const n=R(r);const t=new $;let c=false;const s=o=>{if(c)return;c=true;process.stderr.write(`[buoy-mcp] shutting down (${o})
3
3
  `);O();B();setTimeout(()=>process.exit(0),2e3).unref();void(async()=>{await r.stop().catch(()=>{});await n.close().catch(()=>{});process.exit(0)})()};process.stdin.once("end",()=>s("stdin closed"));process.stdin.once("close",()=>s("stdin closed"));n.server.onclose=()=>s("transport closed");process.on("SIGINT",()=>s("SIGINT"));process.on("SIGTERM",()=>s("SIGTERM"));process.on("SIGHUP",()=>s("SIGHUP"));await n.connect(t);process.stderr.write(`[buoy-mcp] serving MCP over stdio; connecting to broker\u2026
4
4
  `);r.start().then(o=>process.stderr.write(`[buoy-mcp] broker ${o}
5
5
  `)).catch(o=>process.stderr.write(`[buoy-mcp] broker connection failed: ${o?.message??o} \u2014 tools will report no devices until it recovers
6
- `))}async function E(){const e=process.env.BUOY_BROKER_PORT;const r=new b({url:process.env.BUOY_BROKER_URL,port:e?Number(e):void 0,autoSpawnBroker:false});const{hasProAccess:n}=await import("./policy-D342AXEF.mjs");try{const t=await Promise.race([r.start().then(()=>true,()=>false),new Promise(s=>setTimeout(()=>s(false),4e3))]);if(!t)return{account:false,pro:false};let c=r.isAdmitted();for(let s=0;s<10;s++){const o=r.connectedDevices();if(o.some(i=>n(i)))return{account:true,pro:true};c||=o.some(i=>i.tier==="free");await new Promise(i=>setTimeout(i,300))}return{account:c,pro:false}}finally{await Promise.race([r.stop().catch(()=>{}),new Promise(t=>setTimeout(t,2e3))])}}if(process.argv[2]==="web"){void import("./main-3BG6EIXP.mjs").then(e=>e.runWebServer()).catch(e=>{process.stderr.write(`[buoy-web] fatal: ${e?.message??e}
6
+ `))}async function E(){const e=process.env.BUOY_BROKER_PORT;const r=new b({url:process.env.BUOY_BROKER_URL,port:e?Number(e):void 0,autoSpawnBroker:false});const{hasProAccess:n}=await import("./policy-D342AXEF.mjs");try{const t=await Promise.race([r.start().then(()=>true,()=>false),new Promise(s=>setTimeout(()=>s(false),4e3))]);if(!t)return{account:false,pro:false};let c=r.isAdmitted();for(let s=0;s<10;s++){const o=r.connectedDevices();if(o.some(i=>n(i)))return{account:true,pro:true};c||=o.some(i=>i.tier==="free");await new Promise(i=>setTimeout(i,300))}return{account:c,pro:false}}finally{await Promise.race([r.stop().catch(()=>{}),new Promise(t=>setTimeout(t,2e3))])}}if(process.argv[2]==="web"){void import("./main-DJT43WTJ.mjs").then(e=>e.runWebServer()).catch(e=>{process.stderr.write(`[buoy-web] fatal: ${e?.message??e}
7
7
  `);process.exit(1)})}else if(process.argv[2]==="web-bench"){void(async()=>{try{const e=process.argv.slice(3);const r=e.find(a=>!a.startsWith("--"));if(!r)throw new Error("usage: buoy-mcp web-bench <config.json> [--json]");const{readFileSync:n}=await import("fs");const{runWebBench:t,formatWebBenchMarkdown:c}=await import("./webBench-BEMJWKB3.mjs");const{readEntitlement:s,entitlementHasPro:o}=await import("./camera-KL6KTSFE.mjs");const{freeWebBench:i,lockedLines:y,nothingLocked:h}=await import("./freeView-3LHV3RBG.mjs");const l=s();const d=o(l)?{account:true,pro:true}:await E();const m=o(l)||d.pro;if(!l.admitted&&!d.account){throw new Error("web-bench needs a Buoy account. A free one works. Sign in to Buoy Desktop, or run `npx buoy login` in the project.")}const p=JSON.parse(n(r,"utf8"));if(p.traceDir&&!m)throw new Error("traceDir (Chrome traces) needs Buoy Pro. See https://buoy.gg/pricing.");let w=h();const u=await t({...p,durationMs:p.durationMs??p.perCaseDurationMs,redact:m?void 0:a=>{const v=i(a);w=v.locked;return v.result}},a=>process.stderr.write(`[web-bench] ${a}
8
8
  `));const f=y(w);if(f)process.stderr.write(`${f}
9
9
  `);const g=u.status==="failed"||u.browserLeftRunning?1:0;const x=(e.includes("--json")?JSON.stringify(u,null,2):c(u))+"\n";setTimeout(()=>process.exit(g),5e3).unref();process.stdout.write(x,()=>process.exit(g))}catch(e){process.stderr.write(`[buoy-mcp] web-bench failed: ${e?.message??e}
10
- `,()=>process.exit(1));setTimeout(()=>process.exit(1),5e3).unref()}})()}else if(process.argv[2]==="flow"&&process.argv[3]==="run"){void(async()=>{try{const{parseFlowRunArgs:e,runFlows:r,formatFlowResults:n}=await import("./flowRun-BQKJKYSR.mjs");const t=e(process.argv.slice(4));const c=await r(t);const s=t.json?JSON.stringify(c,null,2):n(c);const o=c.every(i=>i.passed)?0:1;setTimeout(()=>process.exit(o),5e3).unref();process.stdout.write(`${s}
10
+ `,()=>process.exit(1));setTimeout(()=>process.exit(1),5e3).unref()}})()}else if(process.argv[2]==="flow"&&process.argv[3]==="run"){void(async()=>{try{const{parseFlowRunArgs:e,runFlows:r,formatFlowResults:n}=await import("./flowRun-GTYQQXHF.mjs");const t=e(process.argv.slice(4));const c=await r(t);const s=t.json?JSON.stringify(c,null,2):n(c);const o=c.every(i=>i.passed)?0:1;setTimeout(()=>process.exit(o),5e3).unref();process.stdout.write(`${s}
11
11
  `,()=>process.exit(o))}catch(e){process.stderr.write(`[buoy-mcp] flow run failed: ${e?.message??e}
12
- `,()=>process.exit(1));setTimeout(()=>process.exit(1),5e3).unref()}})()}else if(process.argv[2]==="farm"){console.log=k;void import("./src-WMG32XDB.mjs").then(e=>e.runFarmCommand(process.argv.slice(3),{prog:"npx @buoy-gg/mcp farm",entry:process.argv[1]})).catch(e=>{const r=e;process.stderr.write(`${r?.message??e}${r?.next?`
12
+ `,()=>process.exit(1));setTimeout(()=>process.exit(1),5e3).unref()}})()}else if(process.argv[2]==="farm"){console.log=k;void import("./src-ZFIIN4L2.mjs").then(e=>e.runFarmCommand(process.argv.slice(3),{prog:"npx @buoy-gg/mcp farm",entry:process.argv[1]})).catch(e=>{const r=e;process.stderr.write(`${r?.message??e}${r?.next?`
13
13
  ${r.next}`:""}
14
- `);process.exit(1)})}else if(process.argv[2]==="farmd"){void import("./simFarm-EDOP6VEC.mjs").then(e=>e.runFarmd()).catch(e=>{process.stderr.write(`[buoy-mcp] farmd failed: ${e?.message??e}
15
- `);process.exit(1)})}else if(process.argv[2]==="init"){void(async()=>{try{const e=process.argv.slice(3);let r="auto";if(e.includes("--local"))r="local";else if(e.includes("--npx"))r="npx";const n=e.indexOf("--registry");const t=n!==-1?e[n+1]:void 0;if(e.includes("--web")){const{runWebInit:c}=await import("./init-FGX3CMMQ.mjs");c({mode:r,registry:t})}else T({mode:r,registry:t});process.exit(0)}catch(e){process.stderr.write(`[buoy-mcp] init failed: ${e?.message??e}
14
+ `);process.exit(1)})}else if(process.argv[2]==="farmd"){void import("./simFarm-5MWIXNER.mjs").then(e=>e.runFarmd()).catch(e=>{process.stderr.write(`[buoy-mcp] farmd failed: ${e?.message??e}
15
+ `);process.exit(1)})}else if(process.argv[2]==="init"){void(async()=>{try{const e=process.argv.slice(3);let r="auto";if(e.includes("--local"))r="local";else if(e.includes("--npx"))r="npx";const n=e.indexOf("--registry");const t=n!==-1?e[n+1]:void 0;if(e.includes("--web")){const{runWebInit:c}=await import("./init-FDDGVIXA.mjs");c({mode:r,registry:t})}else T({mode:r,registry:t});process.exit(0)}catch(e){process.stderr.write(`[buoy-mcp] init failed: ${e?.message??e}
16
16
  `);process.exit(1)}})()}else{P().catch(e=>{process.stderr.write(`[buoy-mcp] fatal: ${e?.message??e}
17
17
  `);process.exit(1)})}
@@ -1,2 +1,2 @@
1
- import{createRequire as v}from"module";const E=v(import.meta.url);import{SyncClient as y,createMcpServer as R}from"./chunk-ZJAAYXQM.mjs";import"./chunk-FJI4FST7.mjs";import"./chunk-GG4ZR76D.mjs";import"./chunk-SXYS37FL.mjs";import"./chunk-OUCB2Y5J.mjs";import"./chunk-FOMLVT7K.mjs";import"./chunk-OP23W722.mjs";import"./chunk-DVRR7W22.mjs";import"./chunk-MTTWR4T7.mjs";import{promises as S}from"fs";import $ from"path";import{Client as _}from"@modelcontextprotocol/sdk/client/index.js";import{InMemoryTransport as B}from"@modelcontextprotocol/sdk/inMemory.js";function I(e){const o={names:[]};for(let n=0;n<e.length;n++){const t=e[n];if(t==="--device")o.deviceId=e[++n];else if(t==="--update-snapshots")o.updateSnapshots=true;else if(t==="--json")o.json=true;else if(t==="--wait")o.waitMs=Number(e[++n])*1e3;else if(t==="--all")continue;else if(!t.startsWith("--"))o.names.push(t);else throw new Error(`Unknown option ${t}.`)}return o}async function P(){const e=$.join(process.cwd(),".buoy","flows");return(await S.readdir(e).catch(()=>[])).filter(o=>o.endsWith(".json")).map(o=>o.replace(/\.json$/,"")).sort()}async function g(e,o=n=>process.stderr.write(`${n}
1
+ import{createRequire as v}from"module";const E=v(import.meta.url);import{SyncClient as y,createMcpServer as R}from"./chunk-S4JHE46Q.mjs";import"./chunk-AHIKIVTB.mjs";import"./chunk-DZRRLTOD.mjs";import"./chunk-MJDNVDJI.mjs";import"./chunk-OUCB2Y5J.mjs";import"./chunk-FOMLVT7K.mjs";import"./chunk-OP23W722.mjs";import"./chunk-DVRR7W22.mjs";import"./chunk-MTTWR4T7.mjs";import{promises as S}from"fs";import $ from"path";import{Client as _}from"@modelcontextprotocol/sdk/client/index.js";import{InMemoryTransport as B}from"@modelcontextprotocol/sdk/inMemory.js";function I(e){const o={names:[]};for(let n=0;n<e.length;n++){const t=e[n];if(t==="--device")o.deviceId=e[++n];else if(t==="--update-snapshots")o.updateSnapshots=true;else if(t==="--json")o.json=true;else if(t==="--wait")o.waitMs=Number(e[++n])*1e3;else if(t==="--all")continue;else if(!t.startsWith("--"))o.names.push(t);else throw new Error(`Unknown option ${t}.`)}return o}async function P(){const e=$.join(process.cwd(),".buoy","flows");return(await S.readdir(e).catch(()=>[])).filter(o=>o.endsWith(".json")).map(o=>o.replace(/\.json$/,"")).sort()}async function g(e,o=n=>process.stderr.write(`${n}
2
2
  `)){const n=e.names.length?e.names:await P();if(n.length===0)throw new Error('No saved flows. Save one with run_flow and save:"name", or pass a flow name.');const t=process.env.BUOY_BROKER_PORT;const s=new y({url:process.env.BUOY_BROKER_URL,port:t?Number(t):void 0,autoSpawnBroker:process.env.BUOY_NO_SPAWN!=="1"});const w=R(s);const[d,f]=B.createLinkedPair();const i=new _({name:"buoy-flow-run",version:"1"});try{await w.connect(f);await i.connect(d);await s.start();const a=Date.now()+(e.waitMs??6e4);while(Date.now()<a&&!s.connectedDevices().some(r=>(r.isPro||r.tier==="free")&&(!e.deviceId||r.deviceId===e.deviceId))){await new Promise(r=>setTimeout(r,500))}if(!s.connectedDevices().some(r=>r.isPro||r.tier==="free")){throw new Error("No app on a Buoy account is connected. Start the app (with Buoy) on a simulator or device, then run again.")}const m=[];for(const r of n){const u=Date.now();o(`\u25B6 ${r}`);const p=await i.callTool({name:"run_flow",arguments:{flow:r,include:"none",...e.deviceId?{deviceId:e.deviceId}:{},...e.updateSnapshots?{updateSnapshots:true}:{}}},void 0,{timeout:10*6e4});const h=(p.content??[]).filter(c=>c.type==="text").map(c=>c.text).join("\n");const l=p.isError!==true;m.push({name:r,passed:l,ms:Date.now()-u,report:h});o(`${l?"\u2713":"\u2717"} ${r} (${((Date.now()-u)/1e3).toFixed(1)}s)`)}return m}finally{await i.close().catch(()=>void 0);await Promise.race([s.stop().catch(()=>void 0),new Promise(a=>setTimeout(a,2e3))])}}function j(e){const o=e.filter(t=>!t.passed);const n=[`${e.length-o.length} of ${e.length} flows passed.`];for(const t of o){n.push("",`\u2717 ${t.name}`,t.report.trim(),` Rerun: npx @buoy-gg/mcp flow run ${t.name}`)}return n.join("\n")}export{j as formatFlowResults,I as parseFlowRunArgs,g as runFlows};