@buoy-gg/mcp 7.0.67 → 7.0.68

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,13 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as d}from"module";const R=d(import.meta.url);import{runInit as m}from"./chunk-7XCEVM3W.mjs";import{SyncClient as u,createMcpServer as w,stopAllHidStreamsNow as f,stopAllRecordingsNow as g}from"./chunk-LDULNQCZ.mjs";import"./chunk-2MSKDRYW.mjs";import"./chunk-VKWX4XAY.mjs";import"./chunk-AMU2EOGE.mjs";import"./chunk-OPHPYPJD.mjs";import"./chunk-MTTWR4T7.mjs";import{StdioServerTransport as b}from"@modelcontextprotocol/sdk/server/stdio.js";console.log=(...e)=>console.error(...e);console.info=(...e)=>console.error(...e);console.debug=(...e)=>console.error(...e);async function v(){const e=process.env.BUOY_BROKER_PORT;const s=new u({url:process.env.BUOY_BROKER_URL,port:e?Number(e):void 0,autoSpawnBroker:process.env.BUOY_NO_SPAWN!=="1"});const r=w(s);const o=new b;let n=false;const c=t=>{if(n)return;n=true;process.stderr.write(`[buoy-mcp] shutting down (${t})
3
- `);g();f();setTimeout(()=>process.exit(0),2e3).unref();void(async()=>{await s.stop().catch(()=>{});await r.close().catch(()=>{});process.exit(0)})()};process.stdin.once("end",()=>c("stdin closed"));process.stdin.once("close",()=>c("stdin closed"));r.server.onclose=()=>c("transport closed");process.on("SIGINT",()=>c("SIGINT"));process.on("SIGTERM",()=>c("SIGTERM"));process.on("SIGHUP",()=>c("SIGHUP"));await r.connect(o);process.stderr.write(`[buoy-mcp] serving MCP over stdio; connecting to broker\u2026
4
- `);s.start().then(t=>process.stderr.write(`[buoy-mcp] broker ${t}
5
- `)).catch(t=>process.stderr.write(`[buoy-mcp] broker connection failed: ${t?.message??t} \u2014 tools will report no devices until it recovers
6
- `))}async function y(){const e=process.env.BUOY_BROKER_PORT;const s=new u({url:process.env.BUOY_BROKER_URL,port:e?Number(e):void 0,autoSpawnBroker:false});try{const r=await Promise.race([s.start().then(()=>true,()=>false),new Promise(o=>setTimeout(()=>o(false),4e3))]);if(!r)return false;for(let o=0;o<10;o++){if(s.connectedDevices().some(n=>n.tier==="pro"))return true;await new Promise(n=>setTimeout(n,300))}return false}finally{await Promise.race([s.stop().catch(()=>{}),new Promise(r=>setTimeout(r,2e3))])}}if(process.argv[2]==="web-bench"){void(async()=>{try{const e=process.argv.slice(3);const s=e.find(a=>!a.startsWith("--"));if(!s)throw new Error("usage: buoy-mcp web-bench <config.json> [--json]");const{readFileSync:r}=await import("fs");const{runWebBench:o,formatWebBenchMarkdown:n}=await import("./webBench-QCHYXYCA.mjs");const{readEntitlement:c}=await import("./camera-F5Q7WMHF.mjs");if(!c().isPro&&!await y()){throw new Error("web-bench is a Buoy Pro feature. Sign in to Buoy Desktop with a Pro account, or open an app signed in to Pro. See https://buoy.gg/pricing.")}const t=JSON.parse(r(s,"utf8"));const i=await o({...t,durationMs:t.durationMs??t.perCaseDurationMs},a=>process.stderr.write(`[web-bench] ${a}
7
- `));const p=i.status==="failed"||i.browserLeftRunning?1:0;const l=(e.includes("--json")?JSON.stringify(i,null,2):n(i))+"\n";setTimeout(()=>process.exit(p),5e3).unref();process.stdout.write(l,()=>process.exit(p))}catch(e){process.stderr.write(`[buoy-mcp] web-bench failed: ${e?.message??e}
8
- `,()=>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:s,formatFlowResults:r}=await import("./flowRun-WBOCHITQ.mjs");const o=e(process.argv.slice(4));const n=await s(o);const c=o.json?JSON.stringify(n,null,2):r(n);const t=n.every(i=>i.passed)?0:1;setTimeout(()=>process.exit(t),5e3).unref();process.stdout.write(`${c}
9
- `,()=>process.exit(t))}catch(e){process.stderr.write(`[buoy-mcp] flow run failed: ${e?.message??e}
10
- `,()=>process.exit(1));setTimeout(()=>process.exit(1),5e3).unref()}})()}else if(process.argv[2]==="farmd"){void import("./simFarm-OFT42BGC.mjs").then(e=>e.runFarmd()).catch(e=>{process.stderr.write(`[buoy-mcp] farmd failed: ${e?.message??e}
11
- `);process.exit(1)})}else if(process.argv[2]==="init"){try{const e=process.argv.slice(3);let s="auto";if(e.includes("--local"))s="local";else if(e.includes("--npx"))s="npx";const r=e.indexOf("--registry");const o=r!==-1?e[r+1]:void 0;m({mode:s,registry:o});process.exit(0)}catch(e){process.stderr.write(`[buoy-mcp] init failed: ${e?.message??e}
12
- `);process.exit(1)}}else{v().catch(e=>{process.stderr.write(`[buoy-mcp] fatal: ${e?.message??e}
2
+ import{createRequire as R}from"module";const N=R(import.meta.url);import{runInit as S}from"./chunk-PDYZSHOS.mjs";import{SyncClient as b,createMcpServer as B,stopAllHidStreamsNow as O,stopAllRecordingsNow as T}from"./chunk-KXEKQVCL.mjs";import"./chunk-SPQBWBV6.mjs";import"./chunk-D4P6PPYP.mjs";import"./chunk-OUCB2Y5J.mjs";import"./chunk-FOMLVT7K.mjs";import"./chunk-OP23W722.mjs";import"./chunk-DVRR7W22.mjs";import"./chunk-MTTWR4T7.mjs";import{StdioServerTransport as k}from"@modelcontextprotocol/sdk/server/stdio.js";var P=console.log;console.log=(...e)=>console.error(...e);console.info=(...e)=>console.error(...e);console.debug=(...e)=>console.error(...e);async function $(){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 t=B(r);const c=new k;let n=false;const o=s=>{if(n)return;n=true;process.stderr.write(`[buoy-mcp] shutting down (${s})
3
+ `);T();O();setTimeout(()=>process.exit(0),2e3).unref();void(async()=>{await r.stop().catch(()=>{});await t.close().catch(()=>{});process.exit(0)})()};process.stdin.once("end",()=>o("stdin closed"));process.stdin.once("close",()=>o("stdin closed"));t.server.onclose=()=>o("transport closed");process.on("SIGINT",()=>o("SIGINT"));process.on("SIGTERM",()=>o("SIGTERM"));process.on("SIGHUP",()=>o("SIGHUP"));await t.connect(c);process.stderr.write(`[buoy-mcp] serving MCP over stdio; connecting to broker\u2026
4
+ `);r.start().then(s=>process.stderr.write(`[buoy-mcp] broker ${s}
5
+ `)).catch(s=>process.stderr.write(`[buoy-mcp] broker connection failed: ${s?.message??s} \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:t}=await import("./policy-D342AXEF.mjs");try{const c=await Promise.race([r.start().then(()=>true,()=>false),new Promise(o=>setTimeout(()=>o(false),4e3))]);if(!c)return{account:false,pro:false};let n=r.isAdmitted();for(let o=0;o<10;o++){const s=r.connectedDevices();if(s.some(i=>t(i)))return{account:true,pro:true};n||=s.some(i=>i.tier==="free");await new Promise(i=>setTimeout(i,300))}return{account:n,pro:false}}finally{await Promise.race([r.stop().catch(()=>{}),new Promise(c=>setTimeout(c,2e3))])}}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:t}=await import("fs");const{runWebBench:c,formatWebBenchMarkdown:n}=await import("./webBench-BEMJWKB3.mjs");const{readEntitlement:o,entitlementHasPro:s}=await import("./camera-KL6KTSFE.mjs");const{freeWebBench:i,lockedLines:y,nothingLocked:h}=await import("./freeView-3LHV3RBG.mjs");const l=o();const d=s(l)?{account:true,pro:true}:await E();const m=s(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(t(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 c({...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}
7
+ `));const f=y(w);if(f)process.stderr.write(`${f}
8
+ `);const g=u.status==="failed"||u.browserLeftRunning?1:0;const x=(e.includes("--json")?JSON.stringify(u,null,2):n(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}
9
+ `,()=>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:t}=await import("./flowRun-F3PQIRPB.mjs");const c=e(process.argv.slice(4));const n=await r(c);const o=c.json?JSON.stringify(n,null,2):t(n);const s=n.every(i=>i.passed)?0:1;setTimeout(()=>process.exit(s),5e3).unref();process.stdout.write(`${o}
10
+ `,()=>process.exit(s))}catch(e){process.stderr.write(`[buoy-mcp] flow run failed: ${e?.message??e}
11
+ `,()=>process.exit(1));setTimeout(()=>process.exit(1),5e3).unref()}})()}else if(process.argv[2]==="farm"){console.log=P;void import("./src-N7WTCDAL.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
+ ${r.next}`:""}
13
+ `);process.exit(1)})}else if(process.argv[2]==="farmd"){void import("./simFarm-V7TBSSV2.mjs").then(e=>e.runFarmd()).catch(e=>{process.stderr.write(`[buoy-mcp] farmd failed: ${e?.message??e}
14
+ `);process.exit(1)})}else if(process.argv[2]==="init"){try{const e=process.argv.slice(3);let r="auto";if(e.includes("--local"))r="local";else if(e.includes("--npx"))r="npx";const t=e.indexOf("--registry");const c=t!==-1?e[t+1]:void 0;S({mode:r,registry:c});process.exit(0)}catch(e){process.stderr.write(`[buoy-mcp] init failed: ${e?.message??e}
15
+ `);process.exit(1)}}else{$().catch(e=>{process.stderr.write(`[buoy-mcp] fatal: ${e?.message??e}
13
16
  `);process.exit(1)})}
@@ -0,0 +1,2 @@
1
+ import{createRequire as v}from"module";const E=v(import.meta.url);import{SyncClient as y,createMcpServer as R}from"./chunk-KXEKQVCL.mjs";import"./chunk-SPQBWBV6.mjs";import"./chunk-D4P6PPYP.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
+ `)){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};
@@ -0,0 +1 @@
1
+ import{createRequire as e}from"module";const a=e(import.meta.url);import{freeComparison as r,freeJsTop as o,freeRanking as i,freeWebBench as t,lockedLines as n,nothingLocked as s,resetLockedPitchForTests as c,withLockedLines as m}from"./chunk-OP23W722.mjs";import"./chunk-MTTWR4T7.mjs";export{r as freeComparison,o as freeJsTop,i as freeRanking,t as freeWebBench,n as lockedLines,s as nothingLocked,c as resetLockedPitchForTests,m as withLockedLines};
package/dist/index.d.mts CHANGED
@@ -184,6 +184,13 @@ declare class SyncClient {
184
184
  * doesn't apply to.
185
185
  */
186
186
  private refuseBuoyPanelTap;
187
+ /**
188
+ * Whether a result for this device may carry Pro's why-data (render names,
189
+ * script names, JS origins). True for a Pro key or the Weekend Pass. A free
190
+ * tool works on a free app too; this decides how much of its result it
191
+ * gets (access/freeView.ts).
192
+ */
193
+ fullResultsFor(deviceId: string): boolean;
187
194
  /**
188
195
  * Whether this device was seen on a tier good enough for the current call,
189
196
  * connected or not. For host controls that keep working after the app
package/dist/index.d.ts CHANGED
@@ -184,6 +184,13 @@ declare class SyncClient {
184
184
  * doesn't apply to.
185
185
  */
186
186
  private refuseBuoyPanelTap;
187
+ /**
188
+ * Whether a result for this device may carry Pro's why-data (render names,
189
+ * script names, JS origins). True for a Pro key or the Weekend Pass. A free
190
+ * tool works on a free app too; this decides how much of its result it
191
+ * gets (access/freeView.ts).
192
+ */
193
+ fullResultsFor(deviceId: string): boolean;
187
194
  /**
188
195
  * Whether this device was seen on a tier good enough for the current call,
189
196
  * connected or not. For host controls that keep working after the app