@fugood/bricks-cli 2.25.0-beta.45 → 2.25.0-beta.48
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/lib/10.js +1 -1
- package/lib/117.js +7 -7
- package/lib/511.js +1 -1
- package/lib/index.js +23 -21
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -98,16 +98,16 @@ ${b.Ay.bold("Bound Application")}`),console.log(`Name: ${n.bound_applica
|
|
|
98
98
|
${b.Ay.bold("Environment Variables")}`),Object.entries(n.env.variables).forEach(([e,t])=>{console.log(` ${b.Ay.cyan(e)}: ${t}`)})),console.log("─".repeat(60))}catch(e){i.fail(`Failed to get device: ${e.message}`),process.exit(1)}}),function(e,t){return o.apply(this,arguments)})),N.command("resolve <query>").description("Resolve a device name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action((s=g(function*(e,t){var a=(0,_.o)(),i=t.json?null:(0,D.default)("Resolving device...").start();try{var n=yield(0,E.Y)(()=>a.device({id:e})),r=n||!e?n?[n]:[]:yield a.devices({keyword:e,paginate:{limit:t.limit}}),o=(0,E.K)({resource:"device",query:e,items:n?[n]:r||[],fields:["_id","name","device_name"],selectedBy:n?"id":null});if(i&&i.stop(),t.json)return void(0,w.GF)(o);if(o.resolved){var s=o.resolved;console.log(b.Ay.bold("\nResolved Device")),console.log("─".repeat(60)),console.log(`Name: ${b.Ay.cyan(s.name||s.device_name||"Unnamed")}`),console.log(`ID: ${b.Ay.gray(s._id)}`),console.log(`Selected By: ${o.selectedBy}`),console.log("─".repeat(60));return}if(0===o.matches.length)return void console.log(b.Ay.yellow(`No devices matched "${e}"`));console.log(b.Ay.bold(`
|
|
99
99
|
Matching Devices (${o.matches.length})`)),console.log("─".repeat(80)),o.matches.forEach(e=>{console.log(`${b.Ay.cyan(e.name||e.device_name||"Unnamed")} ${b.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){i?i.fail(`Failed to resolve device: ${t.message}`):(0,w.OW)(t.message,{resource:"device",query:e}),process.exit(1)}}),function(e,t){return s.apply(this,arguments)})),N.command("bind <passcode>").description("Bind a new device using passcode").option("-n, --name <name>","Device name").option("--dry-run","Validate inputs and show the device binding plan without creating a device").option("-j, --json","Output as JSON").action((p=g(function*(e,t){var a=(0,_.o)(),i=t.json?null:(0,D.default)("Checking passcode...").start();try{var n=yield a.checkBindDevicePasscode({passcode:e});n||(t.json?(0,w.OW)("Invalid passcode or expired",{action:"device.bind"}):i.fail("Invalid passcode or expired"),process.exit(1));var r={name:t.name||n.payload?.deviceName||"CLI Device",deviceName:n.payload?.deviceName||null};if(t.dryRun){i&&i.stop(),(0,F.S5)({action:"device.bind",target:r,request:{passcodePreview:(0,w.$l)(e),requestedName:t.name||null,inferredName:n.payload?.deviceName||null},checks:[(0,F.Iy)("passcode is valid",!0),(0,F.Iy)("device name resolved",!0,r.name)],json:t.json});return}i&&(i.text="Binding device...");var o=yield a.createDevice({bindPasscode:e,name:r.name,deviceName:n.payload?.deviceName});t.json?(0,F.yd)({action:"device.bind",target:S(o,o._id),result:{inferredName:n.payload?.deviceName||null},json:!0}):(i.succeed(`Device bound successfully: ${b.Ay.green(o.name)}`),console.log(b.Ay.gray(`Device ID: ${o._id}`)))}catch(e){t.json?(0,w.OW)(e.message,{action:"device.bind"}):i.fail(`Failed to bind device: ${e.message}`),process.exit(1)}}),function(e,t){return p.apply(this,arguments)})),N.command("remove <id>").description("Remove a device").option("--dry-run","Validate the target and show the removal plan without deleting it").option("-j, --json","Output as JSON").action((l=g(function*(e,t){var a=(0,_.o)(),i=t.json?null:(0,D.default)("Removing device...").start();try{var n=yield T(a,e),r=S(n,e);if(t.dryRun){i&&i.stop(),(0,F.S5)({action:"device.remove",target:r,request:{id:e},checks:[(0,F.Iy)("device exists",!0,`${r.name} (${r.id})`)],json:t.json});return}var o=yield a.removeDevice({id:e});t.json?(0,F.yd)({action:"device.remove",target:r,result:{removed:!!o},json:!0}):i.succeed(`Device removed: ${b.Ay.green(r.name)}`)}catch(a){t.json?(0,w.OW)(a.message,{action:"device.remove",target:{id:e}}):i.fail(`Failed to remove device: ${a.message}`),process.exit(1)}}),function(e,t){return l.apply(this,arguments)})),N.command("control <id> <type>").description("Control a device").option("-p, --payload <json>","Event payload as JSON").option("--dry-run","Validate inputs and show the control request without sending it").option("-j, --json","Output as JSON").action((d=g(function*(e,t,a){try{var i;a.payload&&(i=JSON.parse(a.payload)),yield k({id:e,type:t,eventPayload:i,options:a,progressMessage:`Sending ${t} to device...`,successMessage:`Control event sent: ${b.Ay.green(t)}`,failureMessage:"Failed to control device"})}catch(i){a.json?(0,w.OW)(i.message,{action:"device.control",target:{id:e},type:t}):console.error(b.Ay.red(`Failed to control device: ${i.message}`)),process.exit(1)}}),function(e,t,a){return d.apply(this,arguments)})),N.command("refresh <id>").description("Refresh device application").option("--dry-run","Validate inputs and show the refresh request without sending it").option("-j, --json","Output as JSON").action((u=g(function*(e,t){yield k({id:e,type:"refresh",options:t,progressMessage:"Refreshing device...",successMessage:"Device refreshed",failureMessage:"Failed to refresh device"})}),function(e,t){return u.apply(this,arguments)})),N.command("clear-cache <id>").description("Clear device cache").option("--dry-run","Validate inputs and show the cache-clear request without sending it").option("-j, --json","Output as JSON").action((c=g(function*(e,t){yield k({id:e,type:"clear-cache",options:t,progressMessage:"Clearing cache...",successMessage:"Cache cleared",failureMessage:"Failed to clear cache"})}),function(e,t){return c.apply(this,arguments)})),N.command("screenshot <id>").description("Take device screenshot and save to file").option("-o, --output <path>","Output file path").option("--no-take","Only fetch existing screenshot without taking a new one").action((m=g(function*(e,t){var a=(0,_.o)(),i=(0,D.default)("Fetching workspace info...").start();try{var n=yield a.workspace();n?.media_resource?.enable_media_workspace||(i.fail("Media workspace is not enabled for this workspace"),process.exit(1)),n.media_resource.system_media_box_id||(i.fail("No media box configured for this workspace"),process.exit(1)),!1!==t.take&&(i.text="Sending screenshot request to device...",yield a.controlDevice({id:e,type:"take-screenshot"}),i.text="Waiting for device to capture screenshot...",yield new Promise(e=>setTimeout(e,3e3))),i.text="Fetching screenshot...";var r=yield(0,x.he)(a,n,e,t.output);if(r.error&&(i.fail(r.error),process.exit(1)),i.succeed("Screenshot saved"),console.log(),console.log(b.Ay.bold("Screenshot saved to:")),console.log(b.Ay.cyan(r.path)),console.log(),r.file?.meta){var o=r.file.meta,s=o.originalWidth,p=o.originalHeight,l=o.originalFileSize;if(s&&p&&console.log(`${b.Ay.gray("Size:")} ${s}x${p}`),l){var d=(l/1024).toFixed(1);console.log(`${b.Ay.gray("File:")} ${d} KB`)}}r.file?.updatedAt&&console.log(`${b.Ay.gray("Updated:")} ${new Date(r.file.updatedAt).toLocaleString()}`)}catch(e){i.fail(`Failed to get screenshot: ${e.message}`),process.exit(1)}}),function(e,t){return m.apply(this,arguments)})),N.command("metrics <id>").description("Show device metrics (uptime, memory, disk)").option("--start-date <date>","Start date/time (ISO 8601 or relative e.g. 1h, 2d, default: today)").option("--end-date <date>","End date/time (ISO 8601 or relative e.g. 1h, 2d, default: now)").option("-j, --json","Output as JSON").action((f=g(function*(e,t){var a=(0,_.o)(),i=(0,D.default)("Fetching device metrics...").start();try{var n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).toISOString(),o=t.startDate?(0,A.p)(t.startDate):r,s=t.endDate?(0,A.p)(t.endDate):n.toISOString(),p=yield a.deviceUsage({deviceId:e,startDate:o,endDate:s});if(i.stop(),!p||0===p.length)return void console.log(b.Ay.yellow("No metrics data found for this device"));if(t.json)return void console.log(JSON.stringify(p,null,2));for(var l of(console.log(b.Ay.bold(`
|
|
100
100
|
Device Metrics: ${e}`)),console.log("─".repeat(60)),console.log(b.Ay.gray(`${"Date".padEnd(12)} ${"Uptime Events".padEnd(15)} ${"Avg Memory".padEnd(12)} ${"Avg Disk".padEnd(10)}`)),console.log("─".repeat(60)),p)){var d=(l.date||"").padEnd(12),u=String(l.uptime?.length||0).padEnd(15),c="N/A";if(l.memory_usage?.length){var m=0,f=0;for(var h of l.memory_usage){var g=h.values||[],y=v(g,2),x=y[0],w=y[1];null!=x&&null!=w&&w>0&&(m+=x,f+=w)}f>0&&(c=`${(m/f*100).toFixed(1)}%`)}var E="N/A";if(l.disk_usage?.length){var F=0,C=0;for(var S of l.disk_usage){var T=S.values||[],k=v(T,2),N=k[0],O=k[1];null!=N&&null!=O&&O>0&&(F+=N,C+=O)}C>0&&(E=`${(F/C*100).toFixed(1)}%`)}console.log(`${d} ${u} ${c.padEnd(12)} ${E.padEnd(10)}`)}console.log("─".repeat(60))}catch(e){i.fail(`Failed to get device metrics: ${e.message}`),process.exit(1)}}),function(e,t){return f.apply(this,arguments)})),N.command("monitor").description("Monitor device status (polls every 60s)").option("-g, --group <id>","Monitor devices in a group").option("-i, --interval <seconds>","Polling interval in seconds","60").action((h=g(function*(e){var t,a=(0,_.o)(),i=1e3*parseInt(e.interval,10);console.log(b.Ay.bold("\nDevice Monitor")),console.log(b.Ay.gray(`Polling every ${e.interval}s. Press Ctrl+C to stop.
|
|
101
|
-
`));var n=(t=g(function*(){try{var t;if(t=e.group?yield a.devicesByGroup({id:e.group}):yield a.devices({}),process.stdout.write("\x1b[2J\x1b[0f"),console.log(b.Ay.bold("Device Monitor")+b.Ay.gray(` - ${new Date().toLocaleTimeString()}`)),console.log("─".repeat(80)),!t||0===t.length)return void console.log(b.Ay.yellow("No devices found"));t.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=C(t),i=e.name||e.device_name||e.device_target_name,n=e.entry_detail?.application?.name||b.Ay.gray("No app");console.log(`${a} ${b.Ay.cyan(i.padEnd(25))} ${n}`)}),console.log(`
|
|
101
|
+
`));var n=(t=g(function*(){try{var t;if(t=e.group?yield a.devicesByGroup({id:e.group}):yield a.devices({}),process.stdout.write("\x1b[2J\x1b[0f"),console.log(b.Ay.bold("Device Monitor")+b.Ay.gray(` - ${new Date().toLocaleTimeString()}`)),console.log("─".repeat(80)),!t||0===t.length)return void console.log(b.Ay.yellow("No devices found"));t.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=C(t),i=e.name||e.device_name||e.device_target_name||"Unnamed",n=e.entry_detail?.application?.name||b.Ay.gray("No app");console.log(`${a} ${b.Ay.cyan(i.padEnd(25))} ${n}`)}),console.log(`
|
|
102
102
|
${b.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(b.Ay.red(`Error: ${e.message}`))}}),function(){return t.apply(this,arguments)});yield n(),setInterval(n,i)}),function(e){return h.apply(this,arguments)}))},80274(e,t,a){a.d(t,{gf:()=>Z});var i,n,r,o,s,p,l,d,u,c,m,f,h,v,g,y,b,D,x,w,_,E,F,A,C,S,T,k,N,O,I,$=a(68832),j=a(99436),B=a(35679),R=a(73284),V=a(51455),P=a(76760),L=a(75646),M=(i=j(function*(e,t,a=3e3){var i;try{var n=new AbortController;i=setTimeout(()=>n.abort(),a);var r=yield fetch(`http://${e}:${t}/json/list`,{signal:n.signal});if(!r.ok)return null;return yield r.json()}catch{return null}finally{void 0!==i&&clearTimeout(i)}}),function(e,t){return i.apply(this,arguments)}),U=e=>{if(!e)return null;var t=e.match(/\/ws\/(.+)$/);return t?decodeURIComponent(t[1]):null},q=(n=j(function*(e,t=1e3){for(var a=[],i=e,n=0;n<10;n++){var r=P.join(i,".bricks","devtools.json");try{var o=yield V.readFile(r,"utf8"),s=JSON.parse(o),p=yield(0,L.verifyDevToolsServer)(s.address||"localhost",s.port,t);p&&a.push({name:s.name||"BRICKS Simulator",address:s.address||"localhost",port:s.port,protocols:["cdp"],hasPasscode:!1,source:"project",projectPath:i,...p})}catch{}var l=P.dirname(i);if(l===i)break;i=l}return a}),function(e){return n.apply(this,arguments)}),G=(r=j(function*({timeout:e=3e3,verify:t=!1,udpOnly:a=!1,project:i=!0,port:n=19851,cwd:r=process.cwd(),onStatus:o}={}){var s,p=(0,L.discoverDevToolsServers)({timeout:e,idleTimeout:800}),l=a?Promise.resolve([]):(o?.("Scanning via UDP + HTTP probe..."),(0,L.httpProbeSubnet)({port:n,timeout:e})),d=i?q(r,1e3):Promise.resolve([]),u=$((yield Promise.all([p,l,d])),3),c=(e=>{var t=new Map;for(var a of e){var i=a.deviceId||`${a.address}:${a.port}`,n=t.get(i);if(!n){t.set(i,{...a,addresses:[a.address],protocols:[...a.protocols||[]]});continue}for(var r of(n.addresses.includes(a.address)||n.addresses.push(a.address),"127.0.0.1"===n.address&&"127.0.0.1"!==a.address&&(n.address=a.address),a.protocols||[]))n.protocols.includes(r)||n.protocols.push(r);for(var o of Object.entries(a)){var s=$(o,2),p=s[0],l=s[1];null!=l&&"address"!==p&&"addresses"!==p&&"protocols"!==p&&(void 0===n[p]||null===n[p])&&(n[p]=l)}}return[...t.values()]})([...u[0],...u[1],...u[2]]);if(0===c.length)return[];if(t){o?.(`Verifying ${c.length} server(s)...`);var m,f=yield Promise.all(c.map((m=j(function*(e){var t=yield(0,L.verifyDevToolsServer)(e.address,e.port);return{...e,...t||{},address:e.address,port:e.port,verified:!!t,version:t?.version||e.version}}),function(e){return m.apply(this,arguments)})));c.splice(0,c.length,...f)}return o?.("Checking chrome://inspect support..."),yield Promise.all(c.map((s=j(function*(e){var t=yield M(e.address,e.port);if(t){e.chromeInspect=!0;var a=U(t[0]?.webSocketDebuggerUrl);a&&(e.passcode=a)}}),function(e){return s.apply(this,arguments)}))),c}),function(){return r.apply(this,arguments)}),z="2.24",Y="19851",J="127.0.0.1",Q=e=>{if(!e)return{host:void 0,port:void 0};var t=e.match(/^\[([^\]]+)\](?::(\d+))?$/);if(t)return{host:t[1],port:t[2]};var a=e.lastIndexOf(":");if(a>0&&e.indexOf(":")===a){var i=e.slice(a+1);if(/^\d+$/.test(i))return{host:e.slice(0,a),port:i}}return{host:e,port:void 0}},W=e=>{if(!e)return!1;for(var t=e.replace(/^v/,"").split(".").map(Number),a=z.split(".").map(Number),i=0;i<a.length&&!((t[i]||0)>a[i]);i++)if((t[i]||0)<a[i])return!1;return!0},H=e=>e?.auth?.workspaceJwt?.enabled?"workspace-jwt":e?.auth?.passcode||e?.hasPasscode?"passcode":e?.auth?"locked":"open",K=e=>"workspace-jwt"===e?R.Ay.green(e):"passcode"===e?R.Ay.yellow(e):"locked"===e?R.Ay.red(e):R.Ay.gray(e),X=(o=j(function*({info:e,cdpOptions:t,force:i=!1}){if(t.passcode||!e?.auth?.workspaceJwt?.enabled)return null;var n=yield Promise.resolve().then(a.bind(a,47988)),r=n.getCurrentProfile,o=n.getTokenInfo,s=n.getBaseUrl,p=(yield Promise.resolve().then(a.bind(a,85382))).createClient,l=(yield a.e(305).then(a.bind(a,7944))).getOrIssueDevtoolsToken,d=r(),u=o(d);if(!u?.token||!u?.workspaceId||e.workspaceId&&String(u.workspaceId)!==String(e.workspaceId))return null;var c=p(s(),u.token);return(yield l({profile:d,client:c,workspaceId:e.workspaceId||void 0,force:i})).token}),function(e){return o.apply(this,arguments)}),Z=new B.uB("devtools").description("DevTools server discovery, inspection, and CDP commands").option("-a, --address <address>",`DevTools server address, host or host:port (default: ${J})`).option("-p, --port <port>",`Server port for CDP commands (default: ${Y})`).option("--passcode <passcode>","Device passcode for CDP commands"),ee=e=>e.option("-a, --address <address>","DevTools server address, host or host:port").option("-p, --port <port>",`Server port (default: ${Y})`).option("--passcode <passcode>","Device passcode").option("-j, --json","Output as JSON"),et=(s=j(function*(e,t){var i,n,r,o=(yield Promise.resolve().then(a.bind(a,30155))).default,s=(yield Promise.resolve().then(a.bind(a,75646))).verifyDevToolsServer,p=(yield a.e(178).then(a.bind(a,28193))).createCdpClient,l=(i=Z.opts(),n=Q(e.address??i.address),{...e,address:n.host??J,port:e.port??i.port??n.port??Y,passcode:e.passcode??i.passcode}),d=parseInt(l.port,10),u=o("Connecting to DevTools...").start();try{var c=yield s(l.address,d);c||(u.fail(`Cannot reach DevTools server at ${l.address}:${d}`),process.exit(1)),c.version&&!W(c.version)&&(u.fail(`CDP requires app version >= ${z} (device: ${c.version})`),process.exit(1));var m=yield X({info:c,cdpOptions:l});r=p(l.address,d,{passcode:l.passcode,accessToken:m});try{yield r.connect()}catch(e){if(r.close(),!m||!/403|Forbidden/i.test(e.message))throw e;m=yield X({info:c,cdpOptions:l,force:!0}),r=p(l.address,d,{passcode:l.passcode,accessToken:m}),yield r.connect()}u.stop(),yield t(r)}catch(e){u.isSpinning&&u.stop(),console.error(R.Ay.red(e.message)),process.exit(1)}finally{r?.close()}}),function(e,t){return s.apply(this,arguments)}),ea=e=>{if(!e)return{};for(var t={},a=0;a<e.length;a+=2)t[e[a]]=e[a+1];return t},ei=e=>{if(!e)return null;var t=e.nodeName||e.localName||"unknown",a=e.id||e.shortId;a&&(t+=`#${a}`),e.title&&(t+=` "${e.title}"`);var i=[];return e.nodeId&&i.push(`node ${e.nodeId}`),e.shortId&&e.shortId!==a&&i.push(e.shortId),e.brickId&&e.brickId!==e.shortId&&i.push(e.brickId),e.templateKey&&i.push(e.templateKey),i.length>0?`${t} (${i.join(", ")})`:t},en=(e,t="",a=!0,i=!0)=>{var n=[],r=i?"":a?" ":"│ ",o=e.nodeName||"#unknown";if(9===e.nodeType)o="#document";else if(3===e.nodeType){var s=e.nodeValue||"";o=R.Ay.gray(`"${s}"`)}else if(1===e.nodeType){var p=ea(e.attributes),l=p.id||p["short-id"];l&&(o+=R.Ay.gray(`#${l}`)),p.title&&(o+=` ${R.Ay.green(`"${p.title}"`)}`),void 0!==p.w&&void 0!==p.h&&(o+=R.Ay.blue(` ${p.w}\xd7${p.h}`),void 0!==p.x&&void 0!==p.y&&(o+=R.Ay.blue(` @${p.x},${p.y}`)));var d=[];void 0!==p.hide&&d.push(R.Ay.red("hidden")),void 0!==p.pressable&&d.push(R.Ay.yellow("pressable")),void 0!==p.editable&&d.push(R.Ay.yellow("editable")),d.length>0&&(o+=` [${d.join(", ")}]`)}n.push(`${t}${i?"":a?"└─ ":"├─ "}${o}`);var u=e.children||[];return u.forEach((e,a)=>{n.push(...en(e,t+r,a===u.length-1,!1))}),n};Z.command("issue-token").description("Issue a workspace-scoped DevTools access token and save it to the CLI config (used automatically by devtools commands)").option("--ttl <seconds>","Time-to-live in seconds (default 30 days)",e=>parseInt(e,10)).option("-j, --json","Output as JSON").action((p=j(function*(e){var t=yield Promise.resolve().then(a.bind(a,47988)),i=t.getCurrentProfile,n=t.getTokenInfo,r=t.getBaseUrl,o=t.CONFIG_PATH,s=(yield Promise.resolve().then(a.bind(a,85382))).createClient,p=(yield a.e(305).then(a.bind(a,7944))).getOrIssueDevtoolsToken,l=i(),d=n(l);d?.token||(console.error(R.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=s(r(),d.token);try{var c=yield p({profile:l,client:u,ttlSeconds:e.ttl,force:!0});if(e.json)return void console.log(JSON.stringify({profile:l,workspaceId:c.workspaceId,expiresAt:c.expiresAt,jti:c.jti},null,2));console.log(R.Ay.green("✓"),"DevTools access token issued and saved."),console.log(` Profile: ${l}`),console.log(` Workspace: ${c.workspaceId}`),console.log(` Expires: ${c.expiresAt}`),console.log(` jti: ${R.Ay.gray(c.jti)}`),console.log(R.Ay.gray(` Saved to ${o}`))}catch(e){console.error(R.Ay.red(`Issue token failed: ${e.message}`)),process.exit(1)}}),function(e){return p.apply(this,arguments)})),Z.command("scan").description("Scan LAN for DevTools servers via UDP + HTTP").option("-t, --timeout <ms>","Scan timeout in milliseconds","3000").option("-j, --json","Output as JSON").option("--verify","Verify each discovered server via HTTP").option("--udp-only","Skip HTTP subnet probe (UDP only)").option("--no-project","Exclude local BRICKS project preview servers").option("-p, --port <port>","Port for HTTP probe","19851").action((l=j(function*(e){var t=(yield Promise.resolve().then(a.bind(a,30155))).default,i=yield Promise.resolve().then(a.bind(a,47988)),n=i.getCurrentProfile,r=i.getTokenInfo,o=parseInt(e.timeout,10),s=t(`Scanning for DevTools servers (${o}ms)...`).start();try{var p=yield G({timeout:o,verify:!!e.verify,udpOnly:!!e.udpOnly,project:!!e.project,port:parseInt(e.port,10),onStatus:e=>{s.text=e}});if(0===p.length){e.json?(s.stop(),console.log(JSON.stringify([],null,2))):s.info("No DevTools servers found on the network."),process.exit(0);return}s.stop(),e.json&&(console.log(JSON.stringify(p,null,2)),process.exit(0));var l=n(),d=r(l),u=d?.workspaceId||null;console.log(R.Ay.bold(`
|
|
103
103
|
Found ${p.length} DevTools server(s)`)),console.log("─".repeat(80));var c=function*(e){var t=!1===e.verified?R.Ay.red("unverified"):R.Ay.green("online"),a=H(e),i=K(a),n=(e.protocols||[]).map(e=>R.Ay.cyan(e)).join(", "),r=e.workspaceId&&u&&e.workspaceId===u,o=e.addresses||[e.address],s=o.filter(t=>t!==e.address),p=s.length>0?`${e.address}:${e.port} +${s.length} more`:`${e.address}:${e.port}`;if(console.log(` ${R.Ay.bold(e.name||"Unknown")} ${R.Ay.gray(`(${p})`)} [${t}]`),s.length>0&&console.log(` Addresses: ${o.map(e=>R.Ay.gray(e)).join(", ")}`),e.version&&console.log(` Version: ${R.Ay.green(e.version)}`),e.chromeInspect){var l=e.passcode?R.Ay.cyan(e.passcode):R.Ay.gray("no passcode");console.log(` Chrome Inspect: ${R.Ay.green("supported")} (passcode: ${l})`)}var d=` Protocols: ${n||R.Ay.gray("none")} Auth: ${i}`;if(e.deviceId&&(d+=` Device: ${R.Ay.gray(e.deviceId)}`),console.log(d),e.workspaceId){var c=r?R.Ay.green(`${e.workspaceId} (current profile)`):R.Ay.gray(e.workspaceId);console.log(` Workspace: ${c}`)}};for(var m of p)yield*c(m);console.log("─".repeat(80));var f=p[0],h=`${f.address}:${f.port||19851}`,v=H(f),g=f.passcode?`/ws/${encodeURIComponent(f.passcode)}`:"workspace-jwt"===v?"/ws/<workspace-token>":"/ws/<passcode>";console.log(R.Ay.gray(`
|
|
104
104
|
Connect via: http://${h}/devtools-frontend/inspector.html?ws=${h}${g}`)),console.log(R.Ay.gray(`Legacy: devtools://devtools/bundled/inspector.html?ws=${h}${g}`)),process.exit(0)}catch(e){s.fail(`Scan failed: ${e.message}`),process.exit(1)}}),function(e){return l.apply(this,arguments)})),Z.command("open <address>").description("Show DevTools server information").option("-p, --port <port>",`Server port (default: ${Y})`).option("--info","Show connection URLs").action((d=j(function*(e,t){var i=(yield Promise.resolve().then(a.bind(a,30155))).default,n=(yield Promise.resolve().then(a.bind(a,75646))).verifyDevToolsServer,r=Q(e),o=r.host??J,s=parseInt(t.port??r.port??Y,10),p=`${o}:${s}`,l=i(`Fetching server info from ${p}...`).start(),d=yield n(o,s);d||(l.fail(`Could not reach DevTools server at ${p}`),process.exit(1)),l.stop();var u=yield M(o,s),c=u?U(u?.[0]?.webSocketDebuggerUrl):null,m=H(d),f=c?`/ws/${encodeURIComponent(c)}`:"workspace-jwt"===m?"/ws/<workspace-token>":"/ws/<passcode>";if(t.info){console.log(R.Ay.bold("Connection URLs")),console.log("─".repeat(60)),console.log(` Web UI: ${R.Ay.cyan(`http://${p}`)}`),console.log(` CDP: ${R.Ay.cyan(`http://${p}/devtools-frontend/inspector.html?ws=${p}${f}`)}`),console.log(` CDP legacy: ${R.Ay.cyan(`devtools://devtools/bundled/inspector.html?ws=${p}${f}`)}`),console.log(` MCP: ${R.Ay.cyan(`http://${p}/mcp`)}`),console.log(` MCP SSE: ${R.Ay.cyan(`http://${p}/sse`)}`),console.log(` Info: ${R.Ay.cyan(`http://${p}/devtools/info`)}`),console.log("─".repeat(60)),console.log(),console.log(R.Ay.bold("Authorization")),d.auth?.workspaceJwt?.enabled&&console.log(` Workspace JWT: ${R.Ay.green("enabled")} (kid: ${d.auth.workspaceJwt.kid})`),c&&console.log(` Passcode: ${R.Ay.cyan(c)}`),console.log(" MCP and MCP SSE require a Bearer token header:"),console.log(` ${R.Ay.gray(`Authorization: Bearer ${d.auth?.workspaceJwt?.enabled?"<workspace-token>":c||"<passcode>"}`)}`);return}if(console.log(R.Ay.bold("DevTools Server")),console.log("─".repeat(60)),console.log(` Name: ${R.Ay.cyan(d.name||"Unknown")}`),console.log(` Version: ${d.version?R.Ay.green(d.version):R.Ay.gray("N/A")}`),console.log(` Device ID: ${R.Ay.gray(d.deviceId||"N/A")}`),console.log(` Workspace: ${R.Ay.gray(d.workspaceId||"N/A")}`),console.log(` Protocols: ${(d.protocols||[]).map(e=>R.Ay.cyan(e)).join(", ")||R.Ay.gray("none")}`),console.log(` Auth: ${K(m)}`),console.log(` Port: ${d.port}`),u){var h=c?R.Ay.cyan(c):R.Ay.gray("no passcode");console.log(` Inspect: ${R.Ay.green("chrome://inspect supported")} (passcode: ${h})`)}else console.log(` Inspect: ${R.Ay.gray("chrome://inspect not available")}`);console.log("─".repeat(60)),d.version&&!W(d.version)&&console.log(R.Ay.yellow(`
|
|
105
105
|
CDP commands require version >= ${z}`)),console.log(R.Ay.gray(`
|
|
106
|
-
Use --info to see connection URLs`))}),function(e,t){return d.apply(this,arguments)})),ee(Z.command("screenshot").description("Capture device screenshot").option("-o, --output <path>","Output file path")).action((u=j(function*(e){var t;yield et(e,(t=j(function*(t){var i=yield t.send("Page.captureScreenshot",{format:"png"});i.data||(console.error(R.Ay.red("No screenshot data received")),process.exit(1));var n=yield Promise.resolve().then(a.t.bind(a,73024,19)),r=yield Promise.resolve().then(a.t.bind(a,76760,19)),o=e.output||`screenshot-${Date.now()}.png`,s=r.resolve(o);n.writeFileSync(s,Buffer.from(i.data,"base64")),console.log(R.Ay.green(`Screenshot saved to ${s}`))}),function(e){return t.apply(this,arguments)}))}),function(e){return u.apply(this,arguments)}));var er=Z.command("brick").description("Brick component inspection");ee(er.command("tree").description("Print brick component tree").option("-d, --depth <depth>","Max depth (-1 for full)","3")).action((c=j(function*(e){var t;yield et(e,(t=j(function*(t){yield t.send("DOM.enable");var a=parseInt(e.depth,10),i=(yield t.send("DOM.getDocument",{depth:a})).root;e.json?console.log(JSON.stringify(i,null,2)):console.log(en(i).join("\n"))}),function(e){return t.apply(this,arguments)}))}),function(e){return c.apply(this,arguments)})),ee(er.command("query <selector>").description("Find brick by CSS selector")).action((m=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=(yield a.send("DOM.getDocument",{depth:0})).root,n=(yield a.send("DOM.querySelector",{nodeId:i.nodeId,selector:e})).nodeId;if(0===n)return void console.log(R.Ay.yellow("No element found"));var r=yield a.send("DOM.describeNode",{nodeId:n}),o=ea((yield a.send("DOM.getAttributes",{nodeId:n})).attributes);if(t.json)return void console.log(JSON.stringify({nodeId:n,...r.node,attributes:o},null,2));if(console.log(R.Ay.bold(`Node ${n}: ${r.node?.nodeName||"unknown"}`)),Object.keys(o).length>0)for(var s of(console.log(R.Ay.bold("Attributes:")),Object.entries(o))){var p=$(s,2),l=p[0],d=p[1];console.log(` ${R.Ay.cyan(l)}: ${d}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return m.apply(this,arguments)})),ee(er.command("query-all <selector>").description("Find all bricks matching CSS selector")).action((f=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=(yield a.send("DOM.getDocument",{depth:0})).root,n=(yield a.send("DOM.querySelectorAll",{nodeId:i.nodeId,selector:e})).nodeIds;if(t.json)return void console.log(JSON.stringify({nodeIds:n,count:n.length},null,2));for(var r of(console.log(R.Ay.bold(`Found ${n.length} element(s)`)),n)){var o=yield a.send("DOM.describeNode",{nodeId:r}),s=ea((yield a.send("DOM.getAttributes",{nodeId:r})).attributes),p=s.id||s["short-id"]||"";console.log(` ${r}: ${o.node?.nodeName}${p?R.Ay.gray(`#${p}`):""}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return f.apply(this,arguments)})),ee(er.command("attributes <nodeId>").description("Get brick attributes")).action((h=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=ea((yield a.send("DOM.getAttributes",{nodeId:i})).attributes);if(t.json)return void console.log(JSON.stringify(n,null,2));if(0===Object.keys(n).length)return void console.log(R.Ay.gray("No attributes"));for(var r of Object.entries(n)){var o=$(r,2),s=o[0],p=o[1];console.log(` ${R.Ay.cyan(s)}: ${p}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return h.apply(this,arguments)})),ee(er.command("box-model <nodeId>").description("Get brick dimensions and position")).action((v=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=(yield a.send("DOM.getBoxModel",{nodeId:i})).model;t.json?console.log(JSON.stringify(n,null,2)):(console.log(R.Ay.bold(`Box Model for node ${i}`)),console.log(` Width: ${n.width}`),console.log(` Height: ${n.height}`),n.content&&console.log(` Content: [${n.content.join(", ")}]`),n.padding&&console.log(` Padding: [${n.padding.join(", ")}]`),n.border&&console.log(` Border: [${n.border.join(", ")}]`),n.margin&&console.log(` Margin: [${n.margin.join(", ")}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return v.apply(this,arguments)})),ee(er.command("resolve <nodeId>").description("Resolve brick to JavaScript object with properties")).action((g=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=(yield a.send("DOM.resolveNode",{nodeId:i})).object;if(t.json)return void console.log(JSON.stringify(n,null,2));if(console.log(R.Ay.bold(`Resolved node ${i}`)),console.log(` Type: ${n.type}`),n.className&&console.log(` Class: ${n.className}`),n.description&&console.log(` Description: ${n.description}`),n.objectId&&console.log(` Object ID: ${R.Ay.gray(n.objectId)}`),n.preview?.properties)for(var r of(console.log(R.Ay.bold(" Properties:")),n.preview.properties))console.log(` ${R.Ay.cyan(r.name)}: ${r.value}`)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return g.apply(this,arguments)})),ee(er.command("focus <nodeId>").description("Focus a brick element")).action((y=j(function*(e,t){var a;yield et(t,(a=j(function*(t){yield t.send("DOM.enable");var a=parseInt(e,10);yield t.send("DOM.focus",{nodeId:a}),console.log(R.Ay.green(`Focused node ${a}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return y.apply(this,arguments)}));var eo=Z.command("input").description("Input emulation");ee(eo.command("tap <x> <y>").description("Tap/click at coordinates")).action((b=j(function*(e,t,a){var i;yield et(a,(i=j(function*(i){var n=parseFloat(e),r=parseFloat(t),o=yield i.send("Input.dispatchMouseEvent",{type:"mousePressed",x:n,y:r,button:"left",clickCount:1});yield i.send("Input.dispatchMouseEvent",{type:"mouseReleased",x:n,y:r,button:"left",clickCount:1}),(({x:e,y:t,tapResult:a,json:i})=>{if(i)return console.log(JSON.stringify({x:e,y:t,...a||{}},null,2));console.log(R.Ay.green(`Tapped at (${e}, ${t})`));var n=ei(a?.element||a?.tappedElement||a?.hitElement);if(!n)return console.log(R.Ay.yellow(" Element: none"));console.log(` Element: ${n}`);var r=a?.hitElement,o=a?.tappedElement;if(r&&o&&r.nodeId!==o.nodeId){var s=ei(r);s&&console.log(` Hit: ${s}`)}a&&!1===a.dispatched&&console.log(R.Ay.yellow(" Action: no pressable handler"))})({x:n,y:r,tapResult:o,json:a.json})}),function(e){return i.apply(this,arguments)}))}),function(e,t,a){return b.apply(this,arguments)})),ee(eo.command("type <text>").description("Insert text into focused element")).action((D=j(function*(e,t){var a;yield et(t,(a=j(function*(t){yield t.send("Input.insertText",{text:e}),console.log(R.Ay.green(`Typed: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return D.apply(this,arguments)})),ee(eo.command("key <key>").description("Dispatch key event (e.g., Enter, Escape, Tab)")).action((x=j(function*(e,t){var a;yield et(t,(a=j(function*(t){yield t.send("Input.dispatchKeyEvent",{type:"keyDown",key:e}),yield t.send("Input.dispatchKeyEvent",{type:"keyUp",key:e}),console.log(R.Ay.green(`Key: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return x.apply(this,arguments)}));var es=Z.command("network").description("Network inspection");ee(es.command("list").description("Capture snapshot of network activity").option("--duration <ms>","Capture duration in milliseconds","2000")).action((w=j(function*(e){var t;yield et(e,(t=j(function*(t){var a=new Map,i=parseInt(e.duration,10);t.on("Network.requestWillBeSent",e=>{a.set(e.requestId,{method:e.request.method,url:e.request.url,requestId:e.requestId,timestamp:e.timestamp})}),t.on("Network.responseReceived",e=>{var t=a.get(e.requestId);t&&(t.status=e.response.status,t.mimeType=e.response.mimeType)}),t.on("Network.loadingFailed",e=>{var t=a.get(e.requestId);t&&(t.error=e.errorText)}),yield t.send("Network.enable"),yield new Promise(e=>setTimeout(e,i)),yield t.send("Network.disable");var n=[...a.values()];if(e.json)return void console.log(JSON.stringify(n,null,2));if(console.log(R.Ay.bold(`Network Activity (captured ${(i/1e3).toFixed(1)}s, ${n.length} requests)`)),0===n.length)return void console.log(R.Ay.gray(" No network activity captured"));for(var r of n){var o=r.error?R.Ay.red("ERR"):r.status?r.status<300?R.Ay.green(r.status):r.status<400?R.Ay.yellow(r.status):R.Ay.red(r.status):R.Ay.gray("..."),s=r.url.length>60?r.url.substring(0,57)+"...":r.url;console.log(` ${o} ${R.Ay.bold(r.method.padEnd(6))} ${s} ${R.Ay.gray(`(${r.requestId})`)}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return w.apply(this,arguments)})),ee(es.command("get <requestId>").description("Get response body for a network request")).action((_=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("Network.enable");var i=yield a.send("Network.getResponseBody",{requestId:e}),n=i.body,r=i.base64Encoded;t.json?console.log(JSON.stringify({body:n,base64Encoded:r},null,2)):r?console.log(R.Ay.gray(`[base64 encoded, ${n.length} chars]`)):console.log(n)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return _.apply(this,arguments)}));var ep="bricks://app",el="DATA-",ed="properties",eu="entries",ec=e=>{if(null==e||"object"!=typeof e)return{value:e};if("value"in e)return{value:e.value};if("unserializableValue"in e)return{value:e.unserializableValue};if(e.objectId){var t=e.preview?.properties;return Array.isArray(t)&&t.length>0?{value:t.reduce((e,t)=>(e[t.name]=t.value,e),{}),byRef:!0}:{value:e.description||`[${e.type}]`,byRef:!0}}return{value:"undefined"===e.type?void 0:e.description}},em=e=>{var t=e.startsWith(el)?e.slice(el.length):e,a=t.indexOf(":");return a<0?{shortId:t,title:null}:{shortId:t.slice(0,a),title:t.slice(a+1)}},ef=e=>{if(e.startsWith("global:"))return{scope:"global",name:e.slice(7)};if(e.startsWith("subspace:")){var t=e.slice(9),a=t.indexOf(":");return a>0?{scope:"subspace",subspaceUuid:t.slice(0,a),name:t.slice(a+1)}:{scope:"subspace",subspaceUuid:t,name:""}}return{scope:null,name:e}},eh=(E=j(function*(e){try{var t=yield e.send("Runtime.evaluate",{expression:"JSON.stringify(Object.values(system.subspaces()).map((s) => ({ shortId: s.shortId, uuid: s.uuid, title: s.title })))",objectGroup:"console",returnByValue:!0}),a=t.result;if(t.exceptionDetails||"string"!=typeof a?.value)return[];return JSON.parse(a.value)}catch{return[]}}),function(e){return E.apply(this,arguments)}),ev=(e,{full:t=!1,width:a=100}={})=>{var i="string"==typeof e?e:JSON.stringify(e);return void 0===i?R.Ay.gray("undefined"):t||i.length<=a?i:`${i.substring(0,a)}…`},eg=(e,t)=>{var a=e.subspaceUuid?t.find(t=>t.uuid===e.subspaceUuid):null;return{key:e.rawKey,scope:e.scope,...e.subspaceUuid?{subspaceUuid:e.subspaceUuid}:{},...a?.shortId?{subspaceShortId:a.shortId}:{},name:e.name,value:e.value}},ey=(F=j(function*(e,{databaseName:t,objectStoreName:a,options:i}){var n=parseInt(i.skip??"0",10)||0,r=parseInt(i.limit??"25",10)||25,o=null;try{o=(yield e.send("IndexedDB.getMetadata",{securityOrigin:ep,databaseName:t,objectStoreName:a})).entriesCount}catch{}var s=yield e.send("IndexedDB.requestData",{securityOrigin:ep,databaseName:t,objectStoreName:a,indexName:"",skipCount:n,pageSize:r,returnByValue:!0}),p=s.objectStoreDataEntries,l=s.hasMore,d=!1,u=p.map(e=>{var t=ec(e.key).value,a=ec(e.value),i=a.value;return a.byRef&&(d=!0),{key:t,value:i}});if(i.json)return void console.log(JSON.stringify({database:t,objectStore:a,skip:n,limit:r,total:o,hasMore:!!l,entries:u},null,2));var c=null==o?"":` of ${o}`,m=n>0?`, skipped ${n}`:"";for(var f of(console.log(R.Ay.bold(`${t} / ${a} (${u.length}${c} entries${m})`)),console.log("─".repeat(60)),0===u.length&&console.log(R.Ay.gray(" No entries")),u)){var h=f.key,v=f.value,g="string"==typeof h?h:JSON.stringify(h);console.log(` ${R.Ay.cyan(g)}: ${ev(v,{full:!!i.full})}`)}l&&console.log(R.Ay.gray(" …more entries available — use -l/--limit and -s/--skip")),d&&console.log(R.Ay.yellow("\n Some values came back as object handles (device app without by-value reads).\n Update the device app to see full values."))}),function(e,t){return F.apply(this,arguments)}),eb=e=>e.option("-l, --limit <count>","Max items to fetch","25").option("-s, --skip <count>","Items to skip","0").option("--full","Do not truncate values"),eD=Z.command("storage").description("Storage inspection (read-only — CDP cannot mutate device storage)");ee(eD.command("list").description("Overview of all storage stores with entry counts")).action((A=j(function*(e){var t;yield et(e,(t=j(function*(t){yield t.send("DOMStorage.enable"),yield t.send("IndexedDB.enable");var a,i=(a=j(function*(e){return(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:ep,isLocalStorage:e}})).entries.length}),function(e){return a.apply(this,arguments)}),n=yield i(!0),r=yield i(!1),o=(yield t.send("IndexedDB.requestDatabaseNames",{securityOrigin:ep})).databaseNames,s=[];for(var p of o){var l=p.startsWith(el)?ed:eu,d=null;try{d=(yield t.send("IndexedDB.getMetadata",{securityOrigin:ep,databaseName:p,objectStoreName:l})).entriesCount}catch{}s.push({name:p,objectStoreName:l,entriesCount:d})}var u=s.filter(e=>e.name.startsWith(el)).map(e=>({...e,...em(e.name)})),c=s.filter(e=>!e.name.startsWith(el));if(e.json)return void console.log(JSON.stringify({system:{persist:n,memory:r},dataBanks:u,caches:c},null,2));var m=e=>null==e?R.Ay.gray("? entries"):`${e} entries`;for(var f of(console.log(R.Ay.bold("Storage Overview")+R.Ay.gray(" (read-only)")),console.log("─".repeat(60)),console.log(` ${R.Ay.bold("System storage")}${R.Ay.gray(" → storage system persist|memory")}`),console.log(` persist ${m(n)}`),console.log(` memory ${m(r)}`),console.log(` ${R.Ay.bold("Data banks")}${R.Ay.gray(" → storage data-bank get <S_xxxx|title>")}`),0===u.length&&console.log(R.Ay.gray(" none")),u)){var h=f.title?` "${f.title}"`:"";console.log(` ${R.Ay.cyan(f.shortId)}${h} ${m(f.entriesCount)}`)}for(var v of(console.log(` ${R.Ay.bold("Caches")}${R.Ay.gray(" → storage cache generator|generative-media")}`),0===c.length&&console.log(R.Ay.gray(" none")),c))console.log(` ${R.Ay.cyan(v.name)} ${m(v.entriesCount)}`);console.log("─".repeat(60))}),function(e){return t.apply(this,arguments)}))}),function(e){return A.apply(this,arguments)}));var ex=eD.command("system").description("System key-value storage"),ew=e=>e.option("--scope <scope>","Filter by scope: global or a subspace S_xxxx/UUID").option("--prefix <prefix>","Filter by key-name prefix (within the scope)").option("--full","Do not truncate values"),e_=(e,t)=>{var a;return a=j(function*(a){var i;yield et(a,(i=j(function*(i){yield i.send("DOMStorage.enable");var n=(yield i.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:ep,isLocalStorage:e}})).entries,r=yield eh(i),o=((e,{scope:t,prefix:a,subspaceIndex:i=[]}={})=>{var n=t&&"global"!==t?i.find(e=>e.shortId===t||e.uuid===t)?.uuid||t:null;return e.map(([e,t])=>({rawKey:e,value:t,...ef(e)})).filter(e=>("global"!==t||"global"===e.scope)&&(!n||"subspace"===e.scope&&e.subspaceUuid===n)&&(!a||!!e.name.startsWith(a)))})(n,{scope:a.scope,prefix:a.prefix,subspaceIndex:r});if(a.json)return void console.log(JSON.stringify(o.map(e=>eg(e,r)),null,2));if(((e,{label:t,subspaceIndex:a,full:i})=>{if(console.log(R.Ay.bold(`${t} (${e.length} items)`)),console.log("─".repeat(60)),0===e.length)return console.log(R.Ay.gray(" No entries"));var n=null,r=function(e){var t="subspace"===e.scope?`subspace:${e.subspaceUuid}`:e.scope;if(t!==n)if(n=t,"subspace"===e.scope){var r=a.find(t=>t.uuid===e.subspaceUuid),o=r?`${r.shortId}${r.title?` "${r.title}"`:""} `:"";console.log(` ${R.Ay.bold(`subspace ${o}`)}${R.Ay.gray(`(${e.subspaceUuid})`)}`)}else console.log(` ${R.Ay.bold(e.scope||"other")}`);var s=e.name||e.rawKey;console.log(` ${R.Ay.cyan(s)}: ${ev(e.value,{full:i,width:80})}`)};for(var o of e)r(o)})(o,{label:t,subspaceIndex:r,full:!!a.full}),0===o.length&&a.scope&&"global"!==a.scope&&!r.some(e=>e.shortId===a.scope||e.uuid===a.scope)){var s=r.map(e=>e.shortId).join(", ");console.log(R.Ay.yellow(` Scope "${a.scope}" did not match a known subspace${s?` (known: ${s})`:""}`))}}),function(e){return i.apply(this,arguments)}))}),function(e){return a.apply(this,arguments)}};ew(ee(ex.command("persist").description("Show persistent system storage entries"))).action(e_(!0,"Persistent Storage")),ew(ee(ex.command("memory").description("Show in-memory system storage entries"))).action(e_(!1,"Memory Storage")),ee(ex.command("get <key>").description("Show a single system storage value (full, untruncated)").option("--scope <scope>","Key scope: global (default) or a subspace S_xxxx/UUID","global").option("--memory","Read from in-memory storage instead of persistent")).action((C=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOMStorage.enable");var i=(yield a.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:ep,isLocalStorage:!t.memory}})).entries,n=yield eh(a),r=[e];if("global"===t.scope)r.push(`global:${e}`);else{var o=n.find(e=>e.shortId===t.scope||e.uuid===t.scope)?.uuid||t.scope;r.push(`subspace:${o}:${e}`)}var s=i.map(([e,t])=>({rawKey:e,value:t,...ef(e)})).find(e=>r.includes(e.rawKey));if(!s){var p=i.map(([e])=>e).filter(t=>t.toLowerCase().includes(e.toLowerCase())).slice(0,5);if(p.length>0)for(var l of(console.error(R.Ay.yellow("Similar keys:")),p))console.error(` ${l}`);throw Error(`Key not found: ${r[r.length-1]}`)}if(t.json)return void console.log(JSON.stringify(eg(s,n),null,2));if("string"==typeof s.value)try{console.log(JSON.stringify(JSON.parse(s.value),null,2));return}catch{}console.log("string"==typeof s.value?s.value:JSON.stringify(s.value,null,2))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return C.apply(this,arguments)}));var eE=eD.command("data-bank").description("Data bank (Property Bank) stores");ee(eE.command("list").description("List data banks")).action((S=j(function*(e){var t;yield et(e,(t=j(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestDatabaseNames",{securityOrigin:ep})).databaseNames,i=[];for(var n of a.filter(e=>e.startsWith(el))){var r=null;try{r=(yield t.send("IndexedDB.getMetadata",{securityOrigin:ep,databaseName:n,objectStoreName:ed})).entriesCount}catch{}i.push({name:n,...em(n),entriesCount:r})}if(e.json)return void console.log(JSON.stringify(i,null,2));for(var o of(console.log(R.Ay.bold(`Data Banks (${i.length})`)),console.log("─".repeat(60)),0===i.length&&console.log(R.Ay.gray(" No data banks")),i)){var s=o.title?` ${R.Ay.green(`"${o.title}"`)}`:"",p=null===o.entriesCount||void 0===o.entriesCount?"":R.Ay.gray(` ${o.entriesCount} entries`);console.log(` ${R.Ay.cyan(o.shortId)}${s}${p}`)}console.log(R.Ay.gray("\nInspect: bricks devtools storage data-bank get <S_xxxx|title>"))}),function(e){return t.apply(this,arguments)}))}),function(e){return S.apply(this,arguments)})),eb(ee(eE.command("get <bank> [store]").description(`Show data bank entries — <bank> accepts a subspace S_xxxx, a title keyword, or the full DATA-* database name; [store] defaults to "${ed}"`))).action((T=j(function*(e,t,a){var i;yield et(a,(i=j(function*(i){yield i.send("IndexedDB.enable");var n=(yield i.send("IndexedDB.requestDatabaseNames",{securityOrigin:ep})).databaseNames,r=((e,t)=>{var a=e.filter(e=>e.startsWith(el)),i=a.find(e=>e===t||e===`${el}${t}`);if(i)return{match:i};if(t.startsWith("S_")){var n=a.filter(e=>em(e).shortId===t);if(1===n.length)return{match:n[0]};if(n.length>1)return{candidates:n}}var r=t.toLowerCase(),o=a.filter(e=>e.slice(el.length).toLowerCase().includes(r));return 1===o.length?{match:o[0]}:{candidates:o}})(n,e);if(!r.match){var o=n.filter(e=>e.startsWith(el)),s=(r.candidates?.length||0)>1,p=s?r.candidates:o;for(var l of(console.error(R.Ay.yellow(s?`Data bank "${e}" is ambiguous. Candidates:`:`Data bank "${e}" not found. Available:`)),p)){var d=em(l),u=d.shortId,c=d.title;console.error(` ${u}${c?` "${c}"`:""}`)}process.exit(1)}yield ey(i,{databaseName:r.match,objectStoreName:t||ed,options:a})}),function(e){return i.apply(this,arguments)}))}),function(e,t,a){return T.apply(this,arguments)}));var eF=eD.command("cache").description("Cache stores (generator, generative-media)"),eA=e=>{var t;return t=j(function*(t){var a;yield et(t,(a=j(function*(a){yield a.send("IndexedDB.enable"),yield ey(a,{databaseName:e,objectStoreName:eu,options:t})}),function(e){return a.apply(this,arguments)}))}),function(e){return t.apply(this,arguments)}};eb(ee(eF.command("generator").description("Show generator cache entries"))).action(eA("GENERATOR_CACHE")),eb(ee(eF.command("generative-media").description("Show generative media cache entries"))).action(eA("GENERATIVE_MEDIA_CACHE")),eb(ee(eD.command("generator-cache",{hidden:!0}).description("Alias of `storage cache generator`"))).action(eA("GENERATOR_CACHE"));var eC=Z.command("runtime").description("Runtime and evaluation");ee(eC.command("eval <expression>").description("Evaluate JavaScript expression").option("--await","Await promise result")).action((k=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("Runtime.enable");var i=yield a.send("Runtime.evaluate",{expression:e,objectGroup:"console",returnByValue:!0,awaitPromise:!!t.await,generatePreview:!0});if(t.json)return void console.log(JSON.stringify(i,null,2));i.exceptionDetails&&(console.error(R.Ay.red(`Error: ${i.exceptionDetails.text}`)),i.exceptionDetails.exception?.description&&console.error(R.Ay.red(i.exceptionDetails.exception.description)),process.exit(1));var n=i.result;"undefined"===n.type?console.log(R.Ay.gray("undefined")):void 0!==n.value?console.log("object"==typeof n.value?JSON.stringify(n.value,null,2):String(n.value)):n.description?console.log(n.description):console.log(R.Ay.gray(`[${n.type}${n.subtype?`:${n.subtype}`:""}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return k.apply(this,arguments)})),ee(eC.command("properties <objectId>").description("Get properties of a remote object")).action((N=j(function*(e,t){var a;yield et(t,(a=j(function*(a){var i=(yield a.send("Runtime.getProperties",{objectId:e,ownProperties:!0})).result;if(t.json)return void console.log(JSON.stringify(i,null,2));for(var n of(console.log(R.Ay.bold(`Properties of ${e}`)),i))if(n.enumerable){var r=n.value,o=r?.description||r?.value?.toString()||R.Ay.gray(`[${r?.type}]`);console.log(` ${R.Ay.cyan(n.name)}: ${o}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return N.apply(this,arguments)}));var eS=Z.command("simulator").description("Inspect simulated peripherals (Application Simulator / web preview servers only)").command("thermal-printer").description("Simulated thermal printers and their print results"),eT="This DevTools server does not expose simulator inspection. Connect to an Application Simulator preview (e.g. the CTOR project simulator) running a preview build with the Simulator CDP domain.",ek=e=>{if(!e)return"unknown time";var t=new Date(e);return Number.isNaN(t.getTime())?"unknown time":t.toLocaleString()},eN=e=>{if(e.raw)return"raw data";var t=(e=>{if(!e?.length)return"";var t=[];for(var a of e){var i=t[t.length-1];i&&i.type===a?i.count+=1:t.push({type:a,count:1})}return t.map(({type:e,count:t})=>t>1?`${e}\xd7${t}`:e).join(", ")})(e.commandTypes);return`${e.commandCount} command(s)${t?`: ${t}`:""}`};ee(eS.command("list").description("List simulated thermal printers and their print history").option("--commands","Include full print command payloads (use with -j)")).action((O=j(function*(e){var t;yield et(e,(t=j(function*(t){var a=yield t.send("Simulator.listThermalPrinters",{includeCommands:!!e.commands}),i=a?.printers;if(Array.isArray(i)||(console.error(R.Ay.red(eT)),process.exit(1)),e.json)return void console.log(JSON.stringify(i,null,2));if(0===i.length){console.log(R.Ay.yellow("No simulated thermal printers registered.")),console.log(R.Ay.gray("A printer appears once the application configures GENERATOR_THERMAL_PRINTER."));return}for(var n of(console.log(R.Ay.bold(`Simulated Thermal Printers (${i.length})`)),console.log("─".repeat(60)),i)){var r=n.errored?R.Ay.red("fault"):n.connected?R.Ay.green("connected"):R.Ay.gray("idle");console.log(` ${R.Ay.bold(n.label||n.driver)} ${R.Ay.gray(`(${n.driver})`)} [${r}]`),console.log(` Printer ID: ${R.Ay.cyan(n.id)}`),n.connectString&&console.log(` Connect: ${R.Ay.gray(n.connectString)}`);var o=n.printHistory||[];if(0===o.length){console.log(R.Ay.gray(" No print results yet."));continue}var s="memory"===n.printHistorySource?R.Ay.gray(" (restored from memory)"):"";for(var p of(console.log(` Print results, newest first${s}:`),o))console.log(` --index ${p.index} ${ek(p.printedAt)} ${R.Ay.gray(eN(p))}`)}console.log("─".repeat(60)),console.log(R.Ay.gray("Save one as PNG: bricks devtools simulator thermal-printer print-result"))}),function(e){return t.apply(this,arguments)}))}),function(e){return O.apply(this,arguments)})),ee(eS.command("print-result").description("Render a simulated print result to a PNG image").option("--printer <id>","Printer ID (see `list`; defaults to the only registered printer)").option("-i, --index <n>","Print history index, 0 = latest","0").option("--scale <factor>","Image scale factor (1-4)","2").option("-o, --output <path>","Output file path")).action((I=j(function*(e){var t;yield et(e,(t=j(function*(t){var i=yield t.send("Simulator.captureThermalPrinterPrintResult",{id:e.printer,index:parseInt(e.index,10)||0,scale:parseFloat(e.scale)||2},3e4);i?.data||(console.error(R.Ay.red(eT)),process.exit(1));var n=yield Promise.resolve().then(a.t.bind(a,73024,19)),r=yield Promise.resolve().then(a.t.bind(a,76760,19)),o=e.output||`print-result-${Date.now()}.png`,s=r.resolve(o);(n.writeFileSync(s,Buffer.from(i.data,"base64")),e.json)?console.log(JSON.stringify({path:s,id:i.id,driver:i.driver,label:i.label,index:i.index,printedAt:i.printedAt,width:i.width,height:i.height},null,2)):(console.log(R.Ay.green(`Print result saved to ${s}`)),console.log(` Printer: ${i.label} ${R.Ay.gray(`(${i.driver}, ${i.id})`)}`),console.log(` Printed: ${ek(i.printedAt)} (--index ${i.index})`),i.width&&i.height&&console.log(` Size: ${i.width}\xd7${i.height}`))}),function(e){return t.apply(this,arguments)}))}),function(e){return I.apply(this,arguments)}))},11405(e,t,a){a.d(t,{l:()=>v});var i,n,r,o=a(99436),s=a(35679),p=a(7586),l=a(85382),d=a(8479),u=a(47988),c=(i=o(function*(){try{return yield Promise.all([a.e(587),a.e(647),a.e(10),a.e(117)]).then(a.bind(a,98372)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),m=(e,t,a)=>({severity:e,code:t,message:a}),f=(n=o(function*({version:e="2.25.0-beta.45",mcpCheck:t=c}={}){var a=(0,u.getCurrentProfile)(),i=(0,u.getCurrentProfileSource)(),n=(0,u.getTokenInfo)(a),r=(0,u.getBaseUrl)(),o=(0,u.getActivityLogBaseUrl)(),s=[],f={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:u.CONFIG_PATH,baseUrl:r,activityLogBaseUrl:o},auth:{available:!!n?.token,source:n?.token?"config":"missing",workspaceId:n?.workspaceId||null,workspaceName:n?.workspaceName||null,createdAt:n?.createdAt||null,tokenPreview:(0,p.$l)(n?.token)},connectivity:{workspace:{ok:!1,skipped:!n?.token,error:null}},capabilities:{zeroArgMode:(0,d.z)()?"interactive":"help",mcp:{available:!1,error:null}},issues:s};if(n?.token)try{var h=yield(0,l.createClient)(r,n.token).workspace();f.connectivity.workspace={ok:!0,skipped:!1,error:null,id:h?._id||n.workspaceId||null,name:h?.name||n.workspaceName||null},f.auth.workspaceId=h?._id||f.auth.workspaceId,f.auth.workspaceName=h?.name||f.auth.workspaceName}catch(e){f.connectivity.workspace={ok:!1,skipped:!1,error:e.message},s.push(m("error","workspace_unreachable",`Workspace query failed for ${r}: ${e.message}`))}else s.push(m("warning","auth_missing","No saved token for the current profile."));var v=yield t();return f.capabilities.mcp={available:v.available,error:v.error||null},v.available||s.push(m("warning","mcp_unavailable",`MCP stdio server is unavailable: ${v.error||"Unknown error"}`)),f.ok=0===s.length,f}),function(){return n.apply(this,arguments)}),h=(e,t,a)=>`${e.padEnd(14)} ${t}${a?` ${a}`:""}`,v=new s.uB("doctor").description("Check CLI configuration, auth state, and workspace reachability").option("-j, --json","Output as JSON").action((r=o(function*(e){try{var t=yield f();if(e.json)return void(0,p.GF)(t);console.log((e=>{var t=[];if(t.push("BRICKS CLI Doctor"),t.push("─".repeat(60)),t.push(h("CLI","OK",`bricks v${e.cli.version}`)),t.push(h("Profile","OK",`${e.profile.name} (${e.profile.source})`)),t.push(h("BRICKS API","OK",e.config.baseUrl)),t.push(h("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace";t.push(h("Auth","OK",`${a} (${e.auth.source}, ${e.auth.tokenPreview})`))}else t.push(h("Auth","WARN","No saved token for the current profile"));if(e.connectivity.workspace.skipped)t.push(h("Workspace","WARN","Skipped because no token is available"));else if(e.connectivity.workspace.ok){var i=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";t.push(h("Workspace","OK",i))}else t.push(h("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?t.push(h("MCP","OK","STDIO server import is available")):t.push(h("MCP","WARN",e.capabilities.mcp.error)),t.push(h("Zero-arg mode",((e,t=!1)=>e?"OK":t?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(t.push("─".repeat(60)),t.push("Issues"),e.issues.forEach(e=>{t.push(`- [${e.severity}] ${e.message}`)})),t.join("\n")})(t))}catch(t){e.json?(0,p.OW)(t.message):console.error(`Doctor failed: ${t.message}`),process.exit(1)}}),function(e){return r.apply(this,arguments)}))},28634(e,t,a){a.d(t,{p:()=>w});var i,n,r,o,s,p,l,d=a(68832),u=a(99436),c=a(35679),m=a(73284),f=a(30155),h=a(7586),v=a(56493),g=a(68168),y=a(98593),b=e=>{if(!e)return m.Ay.gray("○");var t=Date.now()-new Date(e).getTime();return t<=3e5?m.Ay.green("●"):60>Math.floor(t/6e4)?m.Ay.yellow("○"):m.Ay.red("○")},D=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",deviceCount:e?.devices?.length||0}),x=["refresh","clear-cache","system-menu-open","system-menu-close","system-info-open","system-info-close","local-sync-panel-open","local-sync-panel-close","debug-panel-open","debug-panel-close","logging-on","logging-off","test-panel-open","test-panel-close"],w=new c.uB("group").description("Device Group management");w.command("list").description("List all device groups").option("-j, --json","Output as JSON").action((i=u(function*(e){var t=(0,v.o)(),a=(0,f.default)("Fetching device groups...").start();try{var i=yield t.deviceGroups({});if(a.stop(),e.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(m.Ay.yellow("No device groups found"));console.log(m.Ay.bold("\nDevice Groups")),console.log("─".repeat(80)),i.forEach(e=>{var t=e.devices?.length||0;console.log(`● ${m.Ay.cyan(e.name)} ${m.Ay.gray(`(${t} devices)`)}`),console.log(` ID: ${m.Ay.gray(e._id)}`),e.description&&console.log(` ${m.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list groups: ${e.message}`),process.exit(1)}}),function(e){return i.apply(this,arguments)})),w.command("get <id>").description("Get device group details").option("-j, --json","Output as JSON").action((n=u(function*(e,t){var a=(0,v.o)(),i=(0,f.default)("Fetching device group...").start();try{var n=yield a.deviceGroup({id:e});if(i.stop(),n||(console.log(m.Ay.red("Device group not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(n,null,2));console.log(m.Ay.bold(`
|
|
106
|
+
Use --info to see connection URLs`))}),function(e,t){return d.apply(this,arguments)})),ee(Z.command("screenshot").description("Capture device screenshot").option("-o, --output <path>","Output file path")).action((u=j(function*(e){var t;yield et(e,(t=j(function*(t){var i=yield t.send("Page.captureScreenshot",{format:"png"});i.data||(console.error(R.Ay.red("No screenshot data received")),process.exit(1));var n=yield Promise.resolve().then(a.t.bind(a,73024,19)),r=yield Promise.resolve().then(a.t.bind(a,76760,19)),o=e.output||`screenshot-${Date.now()}.png`,s=r.resolve(o);n.writeFileSync(s,Buffer.from(i.data,"base64")),console.log(R.Ay.green(`Screenshot saved to ${s}`))}),function(e){return t.apply(this,arguments)}))}),function(e){return u.apply(this,arguments)}));var er=Z.command("brick").description("Brick component inspection");ee(er.command("tree").description("Print brick component tree").option("-d, --depth <depth>","Max depth (-1 for full)","3")).action((c=j(function*(e){var t;yield et(e,(t=j(function*(t){yield t.send("DOM.enable");var a=parseInt(e.depth,10),i=(yield t.send("DOM.getDocument",{depth:a})).root;e.json?console.log(JSON.stringify(i,null,2)):console.log(en(i).join("\n"))}),function(e){return t.apply(this,arguments)}))}),function(e){return c.apply(this,arguments)})),ee(er.command("query <selector>").description("Find brick by CSS selector")).action((m=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=(yield a.send("DOM.getDocument",{depth:0})).root,n=(yield a.send("DOM.querySelector",{nodeId:i.nodeId,selector:e})).nodeId;if(0===n)return void console.log(R.Ay.yellow("No element found"));var r=yield a.send("DOM.describeNode",{nodeId:n}),o=ea((yield a.send("DOM.getAttributes",{nodeId:n})).attributes);if(t.json)return void console.log(JSON.stringify({nodeId:n,...r.node,attributes:o},null,2));if(console.log(R.Ay.bold(`Node ${n}: ${r.node?.nodeName||"unknown"}`)),Object.keys(o).length>0)for(var s of(console.log(R.Ay.bold("Attributes:")),Object.entries(o))){var p=$(s,2),l=p[0],d=p[1];console.log(` ${R.Ay.cyan(l)}: ${d}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return m.apply(this,arguments)})),ee(er.command("query-all <selector>").description("Find all bricks matching CSS selector")).action((f=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=(yield a.send("DOM.getDocument",{depth:0})).root,n=(yield a.send("DOM.querySelectorAll",{nodeId:i.nodeId,selector:e})).nodeIds;if(t.json)return void console.log(JSON.stringify({nodeIds:n,count:n.length},null,2));for(var r of(console.log(R.Ay.bold(`Found ${n.length} element(s)`)),n)){var o=yield a.send("DOM.describeNode",{nodeId:r}),s=ea((yield a.send("DOM.getAttributes",{nodeId:r})).attributes),p=s.id||s["short-id"]||"";console.log(` ${r}: ${o.node?.nodeName}${p?R.Ay.gray(`#${p}`):""}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return f.apply(this,arguments)})),ee(er.command("attributes <nodeId>").description("Get brick attributes")).action((h=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=ea((yield a.send("DOM.getAttributes",{nodeId:i})).attributes);if(t.json)return void console.log(JSON.stringify(n,null,2));if(0===Object.keys(n).length)return void console.log(R.Ay.gray("No attributes"));for(var r of Object.entries(n)){var o=$(r,2),s=o[0],p=o[1];console.log(` ${R.Ay.cyan(s)}: ${p}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return h.apply(this,arguments)})),ee(er.command("box-model <nodeId>").description("Get brick dimensions and position")).action((v=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=(yield a.send("DOM.getBoxModel",{nodeId:i})).model;t.json?console.log(JSON.stringify(n,null,2)):(console.log(R.Ay.bold(`Box Model for node ${i}`)),console.log(` Width: ${n.width}`),console.log(` Height: ${n.height}`),n.content&&console.log(` Content: [${n.content.join(", ")}]`),n.padding&&console.log(` Padding: [${n.padding.join(", ")}]`),n.border&&console.log(` Border: [${n.border.join(", ")}]`),n.margin&&console.log(` Margin: [${n.margin.join(", ")}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return v.apply(this,arguments)})),ee(er.command("resolve <nodeId>").description("Resolve brick to JavaScript object with properties")).action((g=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=(yield a.send("DOM.resolveNode",{nodeId:i})).object;if(t.json)return void console.log(JSON.stringify(n,null,2));if(console.log(R.Ay.bold(`Resolved node ${i}`)),console.log(` Type: ${n.type}`),n.className&&console.log(` Class: ${n.className}`),n.description&&console.log(` Description: ${n.description}`),n.objectId&&console.log(` Object ID: ${R.Ay.gray(n.objectId)}`),n.preview?.properties)for(var r of(console.log(R.Ay.bold(" Properties:")),n.preview.properties))console.log(` ${R.Ay.cyan(r.name)}: ${r.value}`)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return g.apply(this,arguments)})),ee(er.command("focus <nodeId>").description("Focus a brick element")).action((y=j(function*(e,t){var a;yield et(t,(a=j(function*(t){yield t.send("DOM.enable");var a=parseInt(e,10);yield t.send("DOM.focus",{nodeId:a}),console.log(R.Ay.green(`Focused node ${a}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return y.apply(this,arguments)}));var eo=Z.command("input").description("Input emulation");ee(eo.command("tap <x> <y>").description("Tap/click at coordinates")).action((b=j(function*(e,t,a){var i;yield et(a,(i=j(function*(i){var n=parseFloat(e),r=parseFloat(t),o=yield i.send("Input.dispatchMouseEvent",{type:"mousePressed",x:n,y:r,button:"left",clickCount:1});yield i.send("Input.dispatchMouseEvent",{type:"mouseReleased",x:n,y:r,button:"left",clickCount:1}),(({x:e,y:t,tapResult:a,json:i})=>{if(i)return console.log(JSON.stringify({x:e,y:t,...a||{}},null,2));console.log(R.Ay.green(`Tapped at (${e}, ${t})`));var n=ei(a?.element||a?.tappedElement||a?.hitElement);if(!n)return console.log(R.Ay.yellow(" Element: none"));console.log(` Element: ${n}`);var r=a?.hitElement,o=a?.tappedElement;if(r&&o&&r.nodeId!==o.nodeId){var s=ei(r);s&&console.log(` Hit: ${s}`)}a&&!1===a.dispatched&&console.log(R.Ay.yellow(" Action: no pressable handler"))})({x:n,y:r,tapResult:o,json:a.json})}),function(e){return i.apply(this,arguments)}))}),function(e,t,a){return b.apply(this,arguments)})),ee(eo.command("type <text>").description("Insert text into focused element")).action((D=j(function*(e,t){var a;yield et(t,(a=j(function*(t){yield t.send("Input.insertText",{text:e}),console.log(R.Ay.green(`Typed: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return D.apply(this,arguments)})),ee(eo.command("key <key>").description("Dispatch key event (e.g., Enter, Escape, Tab)")).action((x=j(function*(e,t){var a;yield et(t,(a=j(function*(t){yield t.send("Input.dispatchKeyEvent",{type:"keyDown",key:e}),yield t.send("Input.dispatchKeyEvent",{type:"keyUp",key:e}),console.log(R.Ay.green(`Key: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return x.apply(this,arguments)}));var es=Z.command("network").description("Network inspection");ee(es.command("list").description("Capture snapshot of network activity").option("--duration <ms>","Capture duration in milliseconds","2000")).action((w=j(function*(e){var t;yield et(e,(t=j(function*(t){var a=new Map,i=parseInt(e.duration,10);t.on("Network.requestWillBeSent",e=>{a.set(e.requestId,{method:e.request.method,url:e.request.url,requestId:e.requestId,timestamp:e.timestamp})}),t.on("Network.responseReceived",e=>{var t=a.get(e.requestId);t&&(t.status=e.response.status,t.mimeType=e.response.mimeType)}),t.on("Network.loadingFailed",e=>{var t=a.get(e.requestId);t&&(t.error=e.errorText)}),yield t.send("Network.enable"),yield new Promise(e=>setTimeout(e,i)),yield t.send("Network.disable");var n=[...a.values()];if(e.json)return void console.log(JSON.stringify(n,null,2));if(console.log(R.Ay.bold(`Network Activity (captured ${(i/1e3).toFixed(1)}s, ${n.length} requests)`)),0===n.length)return void console.log(R.Ay.gray(" No network activity captured"));for(var r of n){var o=r.error?R.Ay.red("ERR"):r.status?r.status<300?R.Ay.green(r.status):r.status<400?R.Ay.yellow(r.status):R.Ay.red(r.status):R.Ay.gray("..."),s=r.url.length>60?r.url.substring(0,57)+"...":r.url;console.log(` ${o} ${R.Ay.bold(r.method.padEnd(6))} ${s} ${R.Ay.gray(`(${r.requestId})`)}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return w.apply(this,arguments)})),ee(es.command("get <requestId>").description("Get response body for a network request")).action((_=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("Network.enable");var i=yield a.send("Network.getResponseBody",{requestId:e}),n=i.body,r=i.base64Encoded;t.json?console.log(JSON.stringify({body:n,base64Encoded:r},null,2)):r?console.log(R.Ay.gray(`[base64 encoded, ${n.length} chars]`)):console.log(n)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return _.apply(this,arguments)}));var ep="bricks://app",el="DATA-",ed="properties",eu="entries",ec=e=>{if(null==e||"object"!=typeof e)return{value:e};if("value"in e)return{value:e.value};if("unserializableValue"in e)return{value:e.unserializableValue};if(e.objectId){var t=e.preview?.properties;return Array.isArray(t)&&t.length>0?{value:t.reduce((e,t)=>(e[t.name]=t.value,e),{}),byRef:!0}:{value:e.description||`[${e.type}]`,byRef:!0}}return{value:"undefined"===e.type?void 0:e.description}},em=e=>{var t=e.startsWith(el)?e.slice(el.length):e,a=t.indexOf(":");return a<0?{shortId:t,title:null}:{shortId:t.slice(0,a),title:t.slice(a+1)}},ef=e=>{if(e.startsWith("global:"))return{scope:"global",name:e.slice(7)};if(e.startsWith("subspace:")){var t=e.slice(9),a=t.indexOf(":");return a>0?{scope:"subspace",subspaceUuid:t.slice(0,a),name:t.slice(a+1)}:{scope:"subspace",subspaceUuid:t,name:""}}return{scope:null,name:e}},eh=(E=j(function*(e){try{var t=yield e.send("Runtime.evaluate",{expression:"JSON.stringify(Object.values(system.subspaces()).map((s) => ({ shortId: s.shortId, uuid: s.uuid, title: s.title })))",objectGroup:"console",returnByValue:!0}),a=t.result;if(t.exceptionDetails||"string"!=typeof a?.value)return[];return JSON.parse(a.value)}catch{return[]}}),function(e){return E.apply(this,arguments)}),ev=(e,{full:t=!1,width:a=100}={})=>{var i="string"==typeof e?e:JSON.stringify(e);return void 0===i?R.Ay.gray("undefined"):t||i.length<=a?i:`${i.substring(0,a)}…`},eg=(e,t)=>{var a=e.subspaceUuid?t.find(t=>t.uuid===e.subspaceUuid):null;return{key:e.rawKey,scope:e.scope,...e.subspaceUuid?{subspaceUuid:e.subspaceUuid}:{},...a?.shortId?{subspaceShortId:a.shortId}:{},name:e.name,value:e.value}},ey=(F=j(function*(e,{databaseName:t,objectStoreName:a,options:i}){var n=parseInt(i.skip??"0",10)||0,r=parseInt(i.limit??"25",10)||25,o=null;try{o=(yield e.send("IndexedDB.getMetadata",{securityOrigin:ep,databaseName:t,objectStoreName:a})).entriesCount}catch{}var s=yield e.send("IndexedDB.requestData",{securityOrigin:ep,databaseName:t,objectStoreName:a,indexName:"",skipCount:n,pageSize:r,returnByValue:!0}),p=s.objectStoreDataEntries,l=s.hasMore,d=!1,u=p.map(e=>{var t=ec(e.key).value,a=ec(e.value),i=a.value;return a.byRef&&(d=!0),{key:t,value:i}});if(i.json)return void console.log(JSON.stringify({database:t,objectStore:a,skip:n,limit:r,total:o,hasMore:!!l,entries:u},null,2));var c=null==o?"":` of ${o}`,m=n>0?`, skipped ${n}`:"";for(var f of(console.log(R.Ay.bold(`${t} / ${a} (${u.length}${c} entries${m})`)),console.log("─".repeat(60)),0===u.length&&console.log(R.Ay.gray(" No entries")),u)){var h=f.key,v=f.value,g="string"==typeof h?h:JSON.stringify(h);console.log(` ${R.Ay.cyan(g)}: ${ev(v,{full:!!i.full})}`)}l&&console.log(R.Ay.gray(" …more entries available — use -l/--limit and -s/--skip")),d&&console.log(R.Ay.yellow("\n Some values came back as object handles (device app without by-value reads).\n Update the device app to see full values."))}),function(e,t){return F.apply(this,arguments)}),eb=e=>e.option("-l, --limit <count>","Max items to fetch","25").option("-s, --skip <count>","Items to skip","0").option("--full","Do not truncate values"),eD=Z.command("storage").description("Storage inspection (read-only — CDP cannot mutate device storage)");ee(eD.command("list").description("Overview of all storage stores with entry counts")).action((A=j(function*(e){var t;yield et(e,(t=j(function*(t){yield t.send("DOMStorage.enable"),yield t.send("IndexedDB.enable");var a,i=(a=j(function*(e){return(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:ep,isLocalStorage:e}})).entries.length}),function(e){return a.apply(this,arguments)}),n=yield i(!0),r=yield i(!1),o=(yield t.send("IndexedDB.requestDatabaseNames",{securityOrigin:ep})).databaseNames,s=[];for(var p of o){var l=p.startsWith(el)?ed:eu,d=null;try{d=(yield t.send("IndexedDB.getMetadata",{securityOrigin:ep,databaseName:p,objectStoreName:l})).entriesCount}catch{}s.push({name:p,objectStoreName:l,entriesCount:d})}var u=s.filter(e=>e.name.startsWith(el)).map(e=>({...e,...em(e.name)})),c=s.filter(e=>!e.name.startsWith(el));if(e.json)return void console.log(JSON.stringify({system:{persist:n,memory:r},dataBanks:u,caches:c},null,2));var m=e=>null==e?R.Ay.gray("? entries"):`${e} entries`;for(var f of(console.log(R.Ay.bold("Storage Overview")+R.Ay.gray(" (read-only)")),console.log("─".repeat(60)),console.log(` ${R.Ay.bold("System storage")}${R.Ay.gray(" → storage system persist|memory")}`),console.log(` persist ${m(n)}`),console.log(` memory ${m(r)}`),console.log(` ${R.Ay.bold("Data banks")}${R.Ay.gray(" → storage data-bank get <S_xxxx|title>")}`),0===u.length&&console.log(R.Ay.gray(" none")),u)){var h=f.title?` "${f.title}"`:"";console.log(` ${R.Ay.cyan(f.shortId)}${h} ${m(f.entriesCount)}`)}for(var v of(console.log(` ${R.Ay.bold("Caches")}${R.Ay.gray(" → storage cache generator|generative-media")}`),0===c.length&&console.log(R.Ay.gray(" none")),c))console.log(` ${R.Ay.cyan(v.name)} ${m(v.entriesCount)}`);console.log("─".repeat(60))}),function(e){return t.apply(this,arguments)}))}),function(e){return A.apply(this,arguments)}));var ex=eD.command("system").description("System key-value storage"),ew=e=>e.option("--scope <scope>","Filter by scope: global or a subspace S_xxxx/UUID").option("--prefix <prefix>","Filter by key-name prefix (within the scope)").option("--full","Do not truncate values"),e_=(e,t)=>{var a;return a=j(function*(a){var i;yield et(a,(i=j(function*(i){yield i.send("DOMStorage.enable");var n=(yield i.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:ep,isLocalStorage:e}})).entries,r=yield eh(i),o=((e,{scope:t,prefix:a,subspaceIndex:i=[]}={})=>{var n=t&&"global"!==t?i.find(e=>e.shortId===t||e.uuid===t)?.uuid||t:null;return e.map(([e,t])=>({rawKey:e,value:t,...ef(e)})).filter(e=>("global"!==t||"global"===e.scope)&&(!n||"subspace"===e.scope&&e.subspaceUuid===n)&&(!a||!!e.name.startsWith(a)))})(n,{scope:a.scope,prefix:a.prefix,subspaceIndex:r});if(a.json)return void console.log(JSON.stringify(o.map(e=>eg(e,r)),null,2));if(((e,{label:t,subspaceIndex:a,full:i})=>{if(console.log(R.Ay.bold(`${t} (${e.length} items)`)),console.log("─".repeat(60)),0===e.length)return console.log(R.Ay.gray(" No entries"));var n=null,r=function(e){var t="subspace"===e.scope?`subspace:${e.subspaceUuid}`:e.scope;if(t!==n)if(n=t,"subspace"===e.scope){var r=a.find(t=>t.uuid===e.subspaceUuid),o=r?`${r.shortId}${r.title?` "${r.title}"`:""} `:"";console.log(` ${R.Ay.bold(`subspace ${o}`)}${R.Ay.gray(`(${e.subspaceUuid})`)}`)}else console.log(` ${R.Ay.bold(e.scope||"other")}`);var s=e.name||e.rawKey;console.log(` ${R.Ay.cyan(s)}: ${ev(e.value,{full:i,width:80})}`)};for(var o of e)r(o)})(o,{label:t,subspaceIndex:r,full:!!a.full}),0===o.length&&a.scope&&"global"!==a.scope&&!r.some(e=>e.shortId===a.scope||e.uuid===a.scope)){var s=r.map(e=>e.shortId).join(", ");console.log(R.Ay.yellow(` Scope "${a.scope}" did not match a known subspace${s?` (known: ${s})`:""}`))}}),function(e){return i.apply(this,arguments)}))}),function(e){return a.apply(this,arguments)}};ew(ee(ex.command("persist").description("Show persistent system storage entries"))).action(e_(!0,"Persistent Storage")),ew(ee(ex.command("memory").description("Show in-memory system storage entries"))).action(e_(!1,"Memory Storage")),ee(ex.command("get <key>").description("Show a single system storage value (full, untruncated)").option("--scope <scope>","Key scope: global (default) or a subspace S_xxxx/UUID","global").option("--memory","Read from in-memory storage instead of persistent")).action((C=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("DOMStorage.enable");var i=(yield a.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:ep,isLocalStorage:!t.memory}})).entries,n=yield eh(a),r=[e];if("global"===t.scope)r.push(`global:${e}`);else{var o=n.find(e=>e.shortId===t.scope||e.uuid===t.scope)?.uuid||t.scope;r.push(`subspace:${o}:${e}`)}var s=i.map(([e,t])=>({rawKey:e,value:t,...ef(e)})).find(e=>r.includes(e.rawKey));if(!s){var p=i.map(([e])=>e).filter(t=>t.toLowerCase().includes(e.toLowerCase())).slice(0,5);if(p.length>0)for(var l of(console.error(R.Ay.yellow("Similar keys:")),p))console.error(` ${l}`);throw Error(`Key not found: ${r[r.length-1]}`)}if(t.json)return void console.log(JSON.stringify(eg(s,n),null,2));if("string"==typeof s.value)try{console.log(JSON.stringify(JSON.parse(s.value),null,2));return}catch{}console.log("string"==typeof s.value?s.value:JSON.stringify(s.value,null,2))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return C.apply(this,arguments)}));var eE=eD.command("data-bank").description("Data bank (Property Bank) stores");ee(eE.command("list").description("List data banks")).action((S=j(function*(e){var t;yield et(e,(t=j(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestDatabaseNames",{securityOrigin:ep})).databaseNames,i=[];for(var n of a.filter(e=>e.startsWith(el))){var r=null;try{r=(yield t.send("IndexedDB.getMetadata",{securityOrigin:ep,databaseName:n,objectStoreName:ed})).entriesCount}catch{}i.push({name:n,...em(n),entriesCount:r})}if(e.json)return void console.log(JSON.stringify(i,null,2));for(var o of(console.log(R.Ay.bold(`Data Banks (${i.length})`)),console.log("─".repeat(60)),0===i.length&&console.log(R.Ay.gray(" No data banks")),i)){var s=o.title?` ${R.Ay.green(`"${o.title}"`)}`:"",p=null===o.entriesCount||void 0===o.entriesCount?"":R.Ay.gray(` ${o.entriesCount} entries`);console.log(` ${R.Ay.cyan(o.shortId)}${s}${p}`)}console.log(R.Ay.gray("\nInspect: bricks devtools storage data-bank get <S_xxxx|title>"))}),function(e){return t.apply(this,arguments)}))}),function(e){return S.apply(this,arguments)})),eb(ee(eE.command("get <bank> [store]").description(`Show data bank entries — <bank> accepts a subspace S_xxxx, a title keyword, or the full DATA-* database name; [store] defaults to "${ed}"`))).action((T=j(function*(e,t,a){var i;yield et(a,(i=j(function*(i){yield i.send("IndexedDB.enable");var n=(yield i.send("IndexedDB.requestDatabaseNames",{securityOrigin:ep})).databaseNames,r=((e,t)=>{var a=e.filter(e=>e.startsWith(el)),i=a.find(e=>e===t||e===`${el}${t}`);if(i)return{match:i};if(t.startsWith("S_")){var n=a.filter(e=>em(e).shortId===t);if(1===n.length)return{match:n[0]};if(n.length>1)return{candidates:n}}var r=t.toLowerCase(),o=a.filter(e=>e.slice(el.length).toLowerCase().includes(r));return 1===o.length?{match:o[0]}:{candidates:o}})(n,e);if(!r.match){var o=n.filter(e=>e.startsWith(el)),s=(r.candidates?.length||0)>1,p=s?r.candidates:o;for(var l of(console.error(R.Ay.yellow(s?`Data bank "${e}" is ambiguous. Candidates:`:`Data bank "${e}" not found. Available:`)),p)){var d=em(l),u=d.shortId,c=d.title;console.error(` ${u}${c?` "${c}"`:""}`)}process.exit(1)}yield ey(i,{databaseName:r.match,objectStoreName:t||ed,options:a})}),function(e){return i.apply(this,arguments)}))}),function(e,t,a){return T.apply(this,arguments)}));var eF=eD.command("cache").description("Cache stores (generator, generative-media)"),eA=e=>{var t;return t=j(function*(t){var a;yield et(t,(a=j(function*(a){yield a.send("IndexedDB.enable"),yield ey(a,{databaseName:e,objectStoreName:eu,options:t})}),function(e){return a.apply(this,arguments)}))}),function(e){return t.apply(this,arguments)}};eb(ee(eF.command("generator").description("Show generator cache entries"))).action(eA("GENERATOR_CACHE")),eb(ee(eF.command("generative-media").description("Show generative media cache entries"))).action(eA("GENERATIVE_MEDIA_CACHE")),eb(ee(eD.command("generator-cache",{hidden:!0}).description("Alias of `storage cache generator`"))).action(eA("GENERATOR_CACHE"));var eC=Z.command("runtime").description("Runtime and evaluation");ee(eC.command("eval <expression>").description("Evaluate JavaScript expression").option("--await","Await promise result")).action((k=j(function*(e,t){var a;yield et(t,(a=j(function*(a){yield a.send("Runtime.enable");var i=yield a.send("Runtime.evaluate",{expression:e,objectGroup:"console",returnByValue:!0,awaitPromise:!!t.await,generatePreview:!0});if(t.json)return void console.log(JSON.stringify(i,null,2));i.exceptionDetails&&(console.error(R.Ay.red(`Error: ${i.exceptionDetails.text}`)),i.exceptionDetails.exception?.description&&console.error(R.Ay.red(i.exceptionDetails.exception.description)),process.exit(1));var n=i.result;"undefined"===n.type?console.log(R.Ay.gray("undefined")):void 0!==n.value?console.log("object"==typeof n.value?JSON.stringify(n.value,null,2):String(n.value)):n.description?console.log(n.description):console.log(R.Ay.gray(`[${n.type}${n.subtype?`:${n.subtype}`:""}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return k.apply(this,arguments)})),ee(eC.command("properties <objectId>").description("Get properties of a remote object")).action((N=j(function*(e,t){var a;yield et(t,(a=j(function*(a){var i=(yield a.send("Runtime.getProperties",{objectId:e,ownProperties:!0})).result;if(t.json)return void console.log(JSON.stringify(i,null,2));for(var n of(console.log(R.Ay.bold(`Properties of ${e}`)),i))if(n.enumerable){var r=n.value,o=r?.description||r?.value?.toString()||R.Ay.gray(`[${r?.type}]`);console.log(` ${R.Ay.cyan(n.name)}: ${o}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return N.apply(this,arguments)}));var eS=Z.command("simulator").description("Inspect simulated peripherals (Application Simulator / web preview servers only)").command("thermal-printer").description("Simulated thermal printers and their print results"),eT="This DevTools server does not expose simulator inspection. Connect to an Application Simulator preview (e.g. the CTOR project simulator) running a preview build with the Simulator CDP domain.",ek=e=>{if(!e)return"unknown time";var t=new Date(e);return Number.isNaN(t.getTime())?"unknown time":t.toLocaleString()},eN=e=>{if(e.raw)return"raw data";var t=(e=>{if(!e?.length)return"";var t=[];for(var a of e){var i=t[t.length-1];i&&i.type===a?i.count+=1:t.push({type:a,count:1})}return t.map(({type:e,count:t})=>t>1?`${e}\xd7${t}`:e).join(", ")})(e.commandTypes);return`${e.commandCount} command(s)${t?`: ${t}`:""}`};ee(eS.command("list").description("List simulated thermal printers and their print history").option("--commands","Include full print command payloads (use with -j)")).action((O=j(function*(e){var t;yield et(e,(t=j(function*(t){var a=yield t.send("Simulator.listThermalPrinters",{includeCommands:!!e.commands}),i=a?.printers;if(Array.isArray(i)||(console.error(R.Ay.red(eT)),process.exit(1)),e.json)return void console.log(JSON.stringify(i,null,2));if(0===i.length){console.log(R.Ay.yellow("No simulated thermal printers registered.")),console.log(R.Ay.gray("A printer appears once the application configures GENERATOR_THERMAL_PRINTER."));return}for(var n of(console.log(R.Ay.bold(`Simulated Thermal Printers (${i.length})`)),console.log("─".repeat(60)),i)){var r=n.errored?R.Ay.red("fault"):n.connected?R.Ay.green("connected"):R.Ay.gray("idle");console.log(` ${R.Ay.bold(n.label||n.driver)} ${R.Ay.gray(`(${n.driver})`)} [${r}]`),console.log(` Printer ID: ${R.Ay.cyan(n.id)}`),n.connectString&&console.log(` Connect: ${R.Ay.gray(n.connectString)}`);var o=n.printHistory||[];if(0===o.length){console.log(R.Ay.gray(" No print results yet."));continue}var s="memory"===n.printHistorySource?R.Ay.gray(" (restored from memory)"):"";for(var p of(console.log(` Print results, newest first${s}:`),o))console.log(` --index ${p.index} ${ek(p.printedAt)} ${R.Ay.gray(eN(p))}`)}console.log("─".repeat(60)),console.log(R.Ay.gray("Save one as PNG: bricks devtools simulator thermal-printer print-result"))}),function(e){return t.apply(this,arguments)}))}),function(e){return O.apply(this,arguments)})),ee(eS.command("print-result").description("Render a simulated print result to a PNG image").option("--printer <id>","Printer ID (see `list`; defaults to the only registered printer)").option("-i, --index <n>","Print history index, 0 = latest","0").option("--scale <factor>","Image scale factor (1-4)","2").option("-o, --output <path>","Output file path")).action((I=j(function*(e){var t;yield et(e,(t=j(function*(t){var i=yield t.send("Simulator.captureThermalPrinterPrintResult",{id:e.printer,index:parseInt(e.index,10)||0,scale:parseFloat(e.scale)||2},3e4);i?.data||(console.error(R.Ay.red(eT)),process.exit(1));var n=yield Promise.resolve().then(a.t.bind(a,73024,19)),r=yield Promise.resolve().then(a.t.bind(a,76760,19)),o=e.output||`print-result-${Date.now()}.png`,s=r.resolve(o);(n.writeFileSync(s,Buffer.from(i.data,"base64")),e.json)?console.log(JSON.stringify({path:s,id:i.id,driver:i.driver,label:i.label,index:i.index,printedAt:i.printedAt,width:i.width,height:i.height},null,2)):(console.log(R.Ay.green(`Print result saved to ${s}`)),console.log(` Printer: ${i.label} ${R.Ay.gray(`(${i.driver}, ${i.id})`)}`),console.log(` Printed: ${ek(i.printedAt)} (--index ${i.index})`),i.width&&i.height&&console.log(` Size: ${i.width}\xd7${i.height}`))}),function(e){return t.apply(this,arguments)}))}),function(e){return I.apply(this,arguments)}))},11405(e,t,a){a.d(t,{l:()=>v});var i,n,r,o=a(99436),s=a(35679),p=a(7586),l=a(85382),d=a(8479),u=a(47988),c=(i=o(function*(){try{return yield Promise.all([a.e(587),a.e(647),a.e(10),a.e(117)]).then(a.bind(a,98372)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),m=(e,t,a)=>({severity:e,code:t,message:a}),f=(n=o(function*({version:e="2.25.0-beta.48",mcpCheck:t=c}={}){var a=(0,u.getCurrentProfile)(),i=(0,u.getCurrentProfileSource)(),n=(0,u.getTokenInfo)(a),r=(0,u.getBaseUrl)(),o=(0,u.getActivityLogBaseUrl)(),s=[],f={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:u.CONFIG_PATH,baseUrl:r,activityLogBaseUrl:o},auth:{available:!!n?.token,source:n?.token?"config":"missing",workspaceId:n?.workspaceId||null,workspaceName:n?.workspaceName||null,createdAt:n?.createdAt||null,tokenPreview:(0,p.$l)(n?.token)},connectivity:{workspace:{ok:!1,skipped:!n?.token,error:null}},capabilities:{zeroArgMode:(0,d.z)()?"interactive":"help",mcp:{available:!1,error:null}},issues:s};if(n?.token)try{var h=yield(0,l.createClient)(r,n.token).workspace();f.connectivity.workspace={ok:!0,skipped:!1,error:null,id:h?._id||n.workspaceId||null,name:h?.name||n.workspaceName||null},f.auth.workspaceId=h?._id||f.auth.workspaceId,f.auth.workspaceName=h?.name||f.auth.workspaceName}catch(e){f.connectivity.workspace={ok:!1,skipped:!1,error:e.message},s.push(m("error","workspace_unreachable",`Workspace query failed for ${r}: ${e.message}`))}else s.push(m("warning","auth_missing","No saved token for the current profile."));var v=yield t();return f.capabilities.mcp={available:v.available,error:v.error||null},v.available||s.push(m("warning","mcp_unavailable",`MCP stdio server is unavailable: ${v.error||"Unknown error"}`)),f.ok=0===s.length,f}),function(){return n.apply(this,arguments)}),h=(e,t,a)=>`${e.padEnd(14)} ${t}${a?` ${a}`:""}`,v=new s.uB("doctor").description("Check CLI configuration, auth state, and workspace reachability").option("-j, --json","Output as JSON").action((r=o(function*(e){try{var t=yield f();if(e.json)return void(0,p.GF)(t);console.log((e=>{var t=[];if(t.push("BRICKS CLI Doctor"),t.push("─".repeat(60)),t.push(h("CLI","OK",`bricks v${e.cli.version}`)),t.push(h("Profile","OK",`${e.profile.name} (${e.profile.source})`)),t.push(h("BRICKS API","OK",e.config.baseUrl)),t.push(h("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace";t.push(h("Auth","OK",`${a} (${e.auth.source}, ${e.auth.tokenPreview})`))}else t.push(h("Auth","WARN","No saved token for the current profile"));if(e.connectivity.workspace.skipped)t.push(h("Workspace","WARN","Skipped because no token is available"));else if(e.connectivity.workspace.ok){var i=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";t.push(h("Workspace","OK",i))}else t.push(h("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?t.push(h("MCP","OK","STDIO server import is available")):t.push(h("MCP","WARN",e.capabilities.mcp.error)),t.push(h("Zero-arg mode",((e,t=!1)=>e?"OK":t?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(t.push("─".repeat(60)),t.push("Issues"),e.issues.forEach(e=>{t.push(`- [${e.severity}] ${e.message}`)})),t.join("\n")})(t))}catch(t){e.json?(0,p.OW)(t.message):console.error(`Doctor failed: ${t.message}`),process.exit(1)}}),function(e){return r.apply(this,arguments)}))},28634(e,t,a){a.d(t,{p:()=>w});var i,n,r,o,s,p,l,d=a(68832),u=a(99436),c=a(35679),m=a(73284),f=a(30155),h=a(7586),v=a(56493),g=a(68168),y=a(98593),b=e=>{if(!e)return m.Ay.gray("○");var t=Date.now()-new Date(e).getTime();return t<=3e5?m.Ay.green("●"):60>Math.floor(t/6e4)?m.Ay.yellow("○"):m.Ay.red("○")},D=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",deviceCount:e?.devices?.length||0}),x=["refresh","clear-cache","system-menu-open","system-menu-close","system-info-open","system-info-close","local-sync-panel-open","local-sync-panel-close","debug-panel-open","debug-panel-close","logging-on","logging-off","test-panel-open","test-panel-close"],w=new c.uB("group").description("Device Group management");w.command("list").description("List all device groups").option("-j, --json","Output as JSON").action((i=u(function*(e){var t=(0,v.o)(),a=(0,f.default)("Fetching device groups...").start();try{var i=yield t.deviceGroups({});if(a.stop(),e.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(m.Ay.yellow("No device groups found"));console.log(m.Ay.bold("\nDevice Groups")),console.log("─".repeat(80)),i.forEach(e=>{var t=e.devices?.length||0;console.log(`● ${m.Ay.cyan(e.name)} ${m.Ay.gray(`(${t} devices)`)}`),console.log(` ID: ${m.Ay.gray(e._id)}`),e.description&&console.log(` ${m.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list groups: ${e.message}`),process.exit(1)}}),function(e){return i.apply(this,arguments)})),w.command("get <id>").description("Get device group details").option("-j, --json","Output as JSON").action((n=u(function*(e,t){var a=(0,v.o)(),i=(0,f.default)("Fetching device group...").start();try{var n=yield a.deviceGroup({id:e});if(i.stop(),n||(console.log(m.Ay.red("Device group not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(n,null,2));console.log(m.Ay.bold(`
|
|
107
107
|
Device Group: ${n.name}`)),console.log("─".repeat(60)),console.log(`ID: ${m.Ay.gray(n._id)}`),console.log(`Description: ${n.description||m.Ay.gray("N/A")}`),console.log(`Tags: ${n.tags?.join(", ")||m.Ay.gray("None")}`),console.log(`Created: ${m.Ay.gray(n.create_datetime)}`),console.log(`Modified: ${m.Ay.gray(n.last_modify_datetime)}`),n.devices?.length>0&&(console.log(`
|
|
108
108
|
${m.Ay.bold("Devices")} (${n.devices.length})`),n.devices.forEach(e=>{var t=e.device_target_name||e.device_id;console.log(` - ${t} ${m.Ay.gray(`(${e.device_id})`)}`)})),console.log("─".repeat(60))}catch(e){i.fail(`Failed to get group: ${e.message}`),process.exit(1)}}),function(e,t){return n.apply(this,arguments)})),w.command("resolve <query>").description("Resolve a device group name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action((r=u(function*(e,t){var a=(0,v.o)(),i=t.json?null:(0,f.default)("Resolving device group...").start();try{var n=yield(0,g.Y)(()=>a.deviceGroup({id:e})),r=n?[n]:yield a.deviceGroups({paginate:{limit:t.limit}}),o=n?r:(r||[]).filter(t=>t.name?.toLowerCase().includes(e.trim().toLowerCase())),s=(0,g.K)({resource:"group",query:e,items:o||[],fields:["_id","name"],selectedBy:n?"id":null});if(i&&i.stop(),t.json)return void(0,h.GF)(s);if(s.resolved){var p=s.resolved;console.log(m.Ay.bold("\nResolved Device Group")),console.log("─".repeat(60)),console.log(`Name: ${m.Ay.cyan(p.name||"Unnamed")}`),console.log(`ID: ${m.Ay.gray(p._id)}`),console.log(`Selected By: ${s.selectedBy}`),console.log("─".repeat(60));return}if(0===s.matches.length)return void console.log(m.Ay.yellow(`No device groups matched "${e}"`));console.log(m.Ay.bold(`
|
|
109
|
-
Matching Device Groups (${s.matches.length})`)),console.log("─".repeat(80)),s.matches.forEach(e=>{console.log(`${m.Ay.cyan(e.name||"Unnamed")} ${m.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){i?i.fail(`Failed to resolve device group: ${t.message}`):(0,h.OW)(t.message,{resource:"group",query:e}),process.exit(1)}}),function(e,t){return r.apply(this,arguments)})),w.command("devices <id>").description("List devices in a group with status").option("-j, --json","Output as JSON").action((o=u(function*(e,t){var a=(0,v.o)(),i=(0,f.default)("Fetching devices...").start();try{var n=yield a.devicesByGroup({id:e});if(i.stop(),t.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(m.Ay.yellow("No devices in this group"));console.log(m.Ay.bold("\nDevices in Group")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,
|
|
110
|
-
`));var r=(a=u(function*(){try{var t=yield Promise.all([i.deviceGroup({id:e}),i.devicesByGroup({id:e})]),a=d(t,2),n=a[0],r=a[1];if(process.stdout.write("\x1b[2J\x1b[0f"),console.log(m.Ay.bold(`Device Group: ${n.name}`)+m.Ay.gray(` - ${new Date().toLocaleTimeString()}`)),console.log("─".repeat(80)),!r||0===r.length)return void console.log(m.Ay.yellow("No devices in this group"));var o=0,s=0;r.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,
|
|
109
|
+
Matching Device Groups (${s.matches.length})`)),console.log("─".repeat(80)),s.matches.forEach(e=>{console.log(`${m.Ay.cyan(e.name||"Unnamed")} ${m.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){i?i.fail(`Failed to resolve device group: ${t.message}`):(0,h.OW)(t.message,{resource:"group",query:e}),process.exit(1)}}),function(e,t){return r.apply(this,arguments)})),w.command("devices <id>").description("List devices in a group with status").option("-j, --json","Output as JSON").action((o=u(function*(e,t){var a=(0,v.o)(),i=(0,f.default)("Fetching devices...").start();try{var n=yield a.devicesByGroup({id:e});if(i.stop(),t.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(m.Ay.yellow("No devices in this group"));console.log(m.Ay.bold("\nDevices in Group")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.device||{},a=t.entry_detail?.watch_dog_timer?.last_alive_time,i=b(a),n=t.name||t.device_name||e.target_name||t._id||"Unknown",r=t.entry_detail?.application?.name||m.Ay.gray("No app");console.log(`${i} ${m.Ay.cyan(n.padEnd(30))} ${r}`)}),console.log("─".repeat(80))}catch(e){i.fail(`Failed to get devices: ${e.message}`),process.exit(1)}}),function(e,t){return o.apply(this,arguments)})),w.command("dispatch <id> <action>").description("Dispatch action to all devices in group").option("--dry-run","Validate inputs and show the dispatch plan without sending it").option("-j, --json","Output as JSON").action((s=u(function*(e,t,a){var i=(0,v.o)(),n=a.json?null:(0,f.default)(`Dispatching ${t}...`).start();x.includes(t)||(a.json?(0,h.OW)(`Invalid action. Valid actions: ${x.join(", ")}`,{action:"group.dispatch",target:{id:e}}):n.fail(`Invalid action. Valid actions: ${x.join(", ")}`),process.exit(1));try{var r=yield i.deviceGroup({id:e});if(!r)throw Error("Device group not found");if(a.dryRun){n&&n.stop(),(0,y.S5)({action:"group.dispatch",target:D(r,e),request:{action:t},checks:[(0,y.Iy)("group exists",!0,`${r.name} (${r._id})`),(0,y.Iy)("action is valid",!0)],json:a.json});return}var o=yield i.dispatchDeviceGroupAction({id:e,action:t});a.json?(0,y.yd)({action:"group.dispatch",target:D(r,e),result:{action:t,success:o?.success||0,failed:o?.failed||0},json:!0}):(n.succeed(`Action dispatched: ${m.Ay.green(t)}`),o&&(console.log(`Success: ${m.Ay.green(o.success||0)}`),console.log(`Failed: ${m.Ay.red(o.failed||0)}`)))}catch(t){a.json?(0,h.OW)(t.message,{action:"group.dispatch",target:{id:e}}):n.fail(`Failed to dispatch action: ${t.message}`),process.exit(1)}}),function(e,t,a){return s.apply(this,arguments)})),w.command("refresh <id>").description("Refresh all devices in group").option("--dry-run","Validate inputs and show the refresh plan without sending it").option("-j, --json","Output as JSON").action((p=u(function*(e,t){var a=(0,v.o)(),i=t.json?null:(0,f.default)("Refreshing devices...").start();try{var n=yield a.deviceGroup({id:e});if(!n)throw Error("Device group not found");if(t.dryRun){i&&i.stop(),(0,y.S5)({action:"group.refresh",target:D(n,e),request:{action:"refresh"},checks:[(0,y.Iy)("group exists",!0,`${n.name} (${n._id})`)],json:t.json});return}var r=yield a.dispatchDeviceGroupAction({id:e,action:"refresh"});t.json?(0,y.yd)({action:"group.refresh",target:D(n,e),result:{success:r?.success||0,failed:r?.failed||0},json:!0}):(i.succeed("Devices refreshed"),r&&(console.log(`Success: ${m.Ay.green(r.success||0)}`),console.log(`Failed: ${m.Ay.red(r.failed||0)}`)))}catch(a){t.json?(0,h.OW)(a.message,{action:"group.refresh",target:{id:e}}):i.fail(`Failed to refresh: ${a.message}`),process.exit(1)}}),function(e,t){return p.apply(this,arguments)})),w.command("monitor <id>").description("Monitor devices in group (polls every 60s)").option("-i, --interval <seconds>","Polling interval in seconds","60").action((l=u(function*(e,t){var a,i=(0,v.o)(),n=1e3*parseInt(t.interval,10);console.log(m.Ay.bold("\nDevice Group Monitor")),console.log(m.Ay.gray(`Polling every ${t.interval}s. Press Ctrl+C to stop.
|
|
110
|
+
`));var r=(a=u(function*(){try{var t=yield Promise.all([i.deviceGroup({id:e}),i.devicesByGroup({id:e})]),a=d(t,2),n=a[0],r=a[1];if(process.stdout.write("\x1b[2J\x1b[0f"),console.log(m.Ay.bold(`Device Group: ${n.name}`)+m.Ay.gray(` - ${new Date().toLocaleTimeString()}`)),console.log("─".repeat(80)),!r||0===r.length)return void console.log(m.Ay.yellow("No devices in this group"));var o=0,s=0;r.forEach(e=>{var t=e.device||{},a=t.entry_detail?.watch_dog_timer?.last_alive_time,i=b(a),n=t.name||t.device_name||e.target_name||t._id||"Unknown",r=t.entry_detail?.application?.name||m.Ay.gray("No app");a&&Date.now()-new Date(a).getTime()<=3e5?o++:s++,console.log(`${i} ${m.Ay.cyan(n.padEnd(30))} ${r}`)}),console.log("─".repeat(80)),console.log(`Online: ${m.Ay.green(o)} Offline: ${m.Ay.red(s)}`),console.log(`
|
|
111
111
|
${m.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(m.Ay.red(`Error: ${e.message}`))}}),function(){return a.apply(this,arguments)});yield r(),setInterval(r,n)}),function(e,t){return l.apply(this,arguments)}))},429(e,t,a){a.d(t,{K:()=>p});var i,n=a(99436),r=a(35679),o=a(73284),s=a(47988),p=new r.uB("mcp").description("MCP server management");p.command("start").description("Start the BRICKS MCP server in STDIO mode").option("-t, --token <token>","API token (overrides saved token)").action((i=n(function*(e){var t=(0,s.getCurrentProfile)(),i=e.token||(0,s.getToken)(t);i||(console.error(o.Ay.red("Error: No API token found.")),console.error(o.Ay.gray("Please login first with: bricks auth login <passcode>")),console.error(o.Ay.gray("Or provide a token with: bricks mcp start --token <token>")),process.exit(1));try{var n=(yield Promise.all([a.e(587),a.e(647),a.e(10),a.e(117)]).then(a.bind(a,98372))).startStdioServer;yield n({token:i})}catch(e){console.error(o.Ay.red(`Failed to start MCP server: ${e.message}`)),process.exit(1)}}),function(e){return i.apply(this,arguments)}))},37818(e,t,i){i.d(t,{u:()=>F});var n,r,o,s,p,l,d,u,c=i(68832),m=i(99436);let f=a("fs/promises");var h=i(16928),v=i(35679),g=i(73284),y=i(30155),b=i(86090),D=i(56493),x=i(60450),w=(n=m(function*(e){var t=yield e.workspace();if(!(0,x.wR)(t))throw Error("Media workspace not enabled for this workspace")}),function(e){return n.apply(this,arguments)}),_=e=>{var t=e.meta||{};if(!t.originalFileUploaded)return{ready:!1,label:"Uploading"};if("Video"===e.fileType){if(!t.videoThumbOriginalFileKey)return{ready:!1,label:"Processing"};if(!t.convertedFileUploaded)return{ready:!1,label:"Transcoding"}}return{ready:!0,label:"Ready"}},E=e=>e.ready?g.Ay.green(e.label):g.Ay.yellow(e.label),F=new v.uB("media").description("Media Flow support");F.command("boxes").description("List Media Flow boxes").option("-j, --json","Output as JSON").action((r=m(function*(e){var t=(0,D.o)(),a=(0,y.default)("Fetching media boxes...").start();try{yield w(t);var i=yield t.mediaBoxes();if(a.stop(),e.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(g.Ay.yellow("No media boxes found"));console.log(g.Ay.bold("\nMedia Boxes")),console.log("─".repeat(80)),i.forEach(e=>{console.log(`${g.Ay.cyan(e.name||"Unnamed")} ${g.Ay.gray(e.id)}`),e.description&&console.log(` ${e.description}`),e.tags?.length&&console.log(` Tags: ${e.tags.join(", ")}`),null!=e.size&&console.log(` Size: ${e.size}`),console.log()})}catch(e){a.fail(`Failed to list media boxes: ${e.message}`),process.exit(1)}}),function(e){return r.apply(this,arguments)})),F.command("box <id>").description("Get Media Flow box details").option("-j, --json","Output as JSON").action((o=m(function*(e,t){var a=(0,D.o)(),i=(0,y.default)("Fetching media box...").start();try{yield w(a);var n=yield a.mediaBox({id:e});if(i.stop(),n||(console.log(g.Ay.red("Media box not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(n,null,2));console.log(g.Ay.bold(`
|
|
112
112
|
Media Box: ${n.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${g.Ay.gray(n.id)}`),console.log(`Description: ${n.description||g.Ay.gray("N/A")}`),console.log(`Tags: ${n.tags?.join(", ")||g.Ay.gray("None")}`),null!=n.size&&console.log(`Size: ${n.size}`),n.passcodes?.length&&(console.log(`
|
|
113
113
|
${g.Ay.bold("Passcodes")}`),n.passcodes.forEach(e=>{console.log(`- ${e.name||"Passcode"}: ${e.code}`)})),console.log("─".repeat(60))}catch(e){i.fail(`Failed to get media box: ${e.message}`),process.exit(1)}}),function(e,t){return o.apply(this,arguments)})),F.command("files <boxId>").description("List Media Flow files in a box").option("-t, --types <types>","Comma-separated file types to include").option("-u, --user-tag <tag>","Filter by user tag (repeatable)",(e,t)=>[...t,e],[]).option("-l, --limit <limit>","Limit results",e=>Number.parseInt(e,10)).option("-o, --offset <offset>","Offset results",e=>Number.parseInt(e,10)).option("-j, --json","Output as JSON").action((s=m(function*(e,t){var a=(0,D.o)(),i=(0,y.default)("Fetching media files...").start();try{yield w(a);var n=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):void 0,r=t.userTag?.length?t.userTag:void 0,o=yield a.mediaFiles({boxId:e,includeTypes:n,userTags:r,limit:t.limit,offset:t.offset});if(i.stop(),t.json)return void console.log(JSON.stringify(o,null,2));if(!o||0===o.length)return void console.log(g.Ay.yellow("No media files found"));console.log(g.Ay.bold(`
|
|
@@ -122,10 +122,10 @@ ${y.Ay.bold("Usage")}`),console.log(`Used In: ${n.use_count.total_count} ap
|
|
|
122
122
|
${y.Ay.bold("Exposed Properties")} (${n.expose_properties.length})`),n.expose_properties.forEach(e=>{console.log(` - ${y.Ay.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){i.fail(`Failed to get module: ${e.message}`),process.exit(1)}}),function(e,t){return o.apply(this,arguments)})),k.command("resolve <query>").description("Resolve a module name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action((s=v(function*(e,t){var a=(0,F.o)(),i=t.json?null:(0,b.default)("Resolving module...").start();try{var n=yield(0,A.Y)(()=>a.module({id:e})),r=n?[n]:yield a.modules({keyword:e,paginate:{limit:t.limit}}),o=(0,A.K)({resource:"module",query:e,items:r||[],fields:["_id","name"],selectedBy:n?"id":null});if(i&&i.stop(),t.json)return void(0,E.GF)(o);if(o.resolved){var s=o.resolved;console.log(y.Ay.bold("\nResolved Module")),console.log("─".repeat(60)),console.log(`Name: ${y.Ay.cyan(s.name||"Unnamed")}`),console.log(`ID: ${y.Ay.gray(s._id)}`),console.log(`Selected By: ${o.selectedBy}`),console.log("─".repeat(60));return}if(0===o.matches.length)return void console.log(y.Ay.yellow(`No modules matched "${e}"`));console.log(y.Ay.bold(`
|
|
123
123
|
Matching Modules (${o.matches.length})`)),console.log("─".repeat(80)),o.matches.forEach(e=>{console.log(`${y.Ay.cyan(e.name||"Unnamed")} ${y.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){i?i.fail(`Failed to resolve module: ${t.message}`):(0,E.OW)(t.message,{resource:"module",query:e}),process.exit(1)}}),function(e,t){return s.apply(this,arguments)})),k.command("update <id>").description("Update module name, description, and/or configuration").option("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("-c, --config <json>","Module config as JSON string").option("-f, --file <path>","Module config from file").option("--validate","Validate configuration (default: true when config is set)",!0).option("--no-validate","Skip server-side config validation").option("--last-commit-id <id>","Reject if server config.bricks_project_last_commit_id does not match this value").option("-j, --json","Output as JSON").action((p=v(function*(e,t){var a=(0,F.o)(),i=t.json?null:(0,b.default)("Updating module...").start();try{var n={id:e};t.name&&(n.name=t.name),t.description&&(n.description=t.description),t.config?n.config=t.config:t.file&&(n.config=D.readFileSync(t.file,"utf-8")),void 0!==n.config&&(n.validateConfig=!1!==t.validate),t.lastCommitId&&(n.lastCommitId=t.lastCommitId);var r=yield a.updateModule(n);t.json?(0,S.yd)({action:"module.update",target:T(r,e),result:{lastCommitId:t.lastCommitId||null},json:!0}):(i.succeed(`Module updated: ${y.Ay.green(r.name)}`),r.has_unreleased_changes&&console.log(y.Ay.yellow("Note: Module has unreleased changes")))}catch(a){t.json?(0,E.OW)(a.message,{action:"module.update",target:{id:e}}):i.fail(`Failed to update module: ${a.message}`),process.exit(1)}}),function(e,t){return p.apply(this,arguments)})),k.command("short-edit <id>").description("Short edit module properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action((l=v(function*(e,t){var a=(0,F.o)(),i=(0,b.default)("Applying short edit...").start();try{var n=JSON.parse(t.list);Array.isArray(n)||(i.fail("List must be a JSON array"),process.exit(1));var r=yield a.shortEditModule({id:e,list:n});i.succeed(`Short edit applied to: ${y.Ay.green(r.name)}`)}catch(e){i.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,t){return l.apply(this,arguments)})),k.command("short-refs <id>").description("List short edit references for a module").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action((d=v(function*(e,t){var a=(0,F.o)(),i=(0,b.default)("Fetching short edit references...").start();try{var n=yield a.module({id:e});if(i.stop(),!n?.short_edit?.enabled)return void console.log(y.Ay.yellow("Short Edit is not enabled for this module"));var r=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):[],o=(0,_.V)(n.short_edit.ref_map,{keyword:t.keyword,types:r});if(t.json)return void console.log(JSON.stringify(o,null,2));if(0===o.length)return void console.log(y.Ay.yellow("No short edit references found"));console.log(y.Ay.bold(`
|
|
124
124
|
Short Edit References: ${n.name}`)),o.forEach(e=>{console.log(y.Ay.cyan(`
|
|
125
|
-
${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?y.Ay.gray(`- ${t.title}`):"";console.log(` ${y.Ay.green(e)} ${a}`)})}),console.log()}catch(e){i.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,t){return d.apply(this,arguments)})),k.command("remove <id>").description("Remove a module").option("--dry-run","Validate the target and show the removal plan without deleting it").option("-j, --json","Output as JSON").action((u=v(function*(e,t){var a=(0,F.o)(),i=t.json?null:(0,b.default)("Removing module...").start();try{var n=yield a.module({id:e});if(!n)throw Error("Module not found");var r=T(n,e);if(t.dryRun){i&&i.stop(),(0,S.S5)({action:"module.remove",target:r,request:{id:e},checks:[(0,S.Iy)("module exists",!0,`${r.name} (${r.id})`)],json:t.json});return}var o=yield a.removeModule({id:e});t.json?(0,S.yd)({action:"module.remove",target:r,result:{removed:!!o},json:!0}):i.succeed(`Module removed: ${y.Ay.green(r.name)}`)}catch(a){t.json?(0,E.OW)(a.message,{action:"module.remove",target:{id:e}}):i.fail(`Failed to remove module: ${a.message}`),process.exit(1)}}),function(e,t){return u.apply(this,arguments)})),k.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("-n, --name <name>","Update module name as part of the release").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action((c=v(function*(e,t){var a=(0,F.o)(),i=t.json?null:(0,b.default)("Releasing module...").start();try{var n=(0,C.Ku)(t.config),r=n.config,o=n.source,s=n.sizeBytes,p=yield a.module({id:e});if(!p)throw Error("Module not found");if(p.is_public)throw Error("Public module deployment is temporarily not recommended");var l=t.version||t.name||p.name||"Untitled",d=(0,C.w9)(t.changelogs);if(t.dryRun){i&&i.stop(),(0,S.S5)({action:"module.release",target:T(p,e),request:{name:t.name||null,version:l,changelogs:t.changelogs||null,configSource:o,configSizeBytes:s},checks:[(0,S.Iy)("module exists",!0,`${p.name} (${p._id})`),(0,S.Iy)("module is private",!p.is_public),(0,S.Iy)("release config loaded",!0,`${s} bytes`)],json:t.json});return}var u=yield a.releaseModule({id:e,config:r,...t.name?{name:t.name}:{},releaseCurrentVersion:l,releaseCurrentVersionNote:d});t.json?(0,S.yd)({action:"module.release",target:T(u||p,e),result:{name:t.name||null,version:l,configSource:o,configSizeBytes:s},json:!0}):i.succeed(`Module released: ${y.Ay.green(u?.name||p.name)}`)}catch(a){t.json?(0,E.OW)(a.message,{action:"module.release",target:{id:e}}):i.fail(`Failed to release module: ${a.message}`),process.exit(1)}}),function(e,t){return c.apply(this,arguments)})),k.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((m=v(function*(e,t){var a=(0,F.o)(),i=t.json?null:(0,b.default)("Pulling module project...").start();try{var n=yield a.moduleProject({id:e,buildApplicationOnly:!0});n||(i?i.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(n)):(i.succeed(`Module project fetched: ${y.Ay.green(n.files?.length||0)} files`),console.log(JSON.stringify(n,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):i.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}}),function(e,t){return m.apply(this,arguments)})),k.command("doctor <idOrPath>").description("Diagnose a module config: schema validation plus semantic lint rules (data races, layout mistakes, dead config)").option("-j, --json","Output as JSON").option("--strict","Exit with code 1 when warnings are found").option("--only <codes>","Run only these rule codes (comma-separated)").option("--ignore <codes>","Skip these rule codes (comma-separated)").option("--validate-automation","Also validate automation_map and test_map references").action((f=v(function*(e,t){var i=t.json?null:(0,b.default)("Running config doctor...").start();try{var n=yield Promise.all([a.e(587),a.e(341),a.e(10),a.e(511),a.e(223)]).then(a.bind(a,63322)),r=n.runConfigDoctor,o=n.renderConfigDoctorReport,s=yield r("module",e,t),p=s.report,l=s.exitCode;i?.stop(),t.json?(0,E.GF)({...p,exitCode:l}):console.log(o(p)),0!==l&&process.exit(l)}catch(e){i?i.fail(`Config doctor failed: ${e.message}`):(0,E.OW)(e.message),process.exit(1)}}),function(e,t){return f.apply(this,arguments)})),k.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((h=v(function*(e,t){var i=(yield a.e(602).then(a.bind(a,6553))).initProject;yield i("module",e,t)}),function(e,t){return h.apply(this,arguments)}))},86141(e,t,a){a.d(t,{D:()=>V});var i,n,r,o,s,p,l,d,u,c=a(99436),m=a(35679),f=a(73284),h=a(30155),v=a(88958),g=a(73024),y=a(76760),b=a(48161),D=e=>{if(!e)return e;try{return g.realpathSync(e)}catch{return e}},x=a(68832),w=a(31421),_=a(51455),E="@fugood/bricks-cli",F="win32"===process.platform,A=(e,t)=>`https://cdn.bricks.tools/bricks-cli/${e}/${t}`,C=e=>"beta"===e?"beta":"latest",S=(i=c(function*(e){var t=yield fetch(e);if(!t.ok)throw Error(`Failed to fetch ${e}: HTTP ${t.status}`);return t}),function(e){return i.apply(this,arguments)}),T=(n=c(function*(e){return(yield S(A(e,"version.json"))).json()}),function(e){return n.apply(this,arguments)}),k=(r=c(function*(e){var t=C(e),a=yield S(`https://registry.npmjs.org/-/package/${E}/dist-tags`),i=(yield a.json())[t];if(!i)throw Error(`No '${t}' dist-tag for ${E}`);return{version:i}}),function(e){return r.apply(this,arguments)}),N=(o=c(function*(e,t){return"npm"===t||"bun"===t?k(e):T(e)}),function(e,t){return o.apply(this,arguments)}),O=(e,t,a={})=>{var i=(0,w.spawnSync)(e,t,{stdio:"inherit",...a});if(i.error){if("ENOENT"===i.error.code)throw Error(`Command not found: ${e}`);throw i.error}if(0!==i.status){var n=Error(`${e} exited with code ${i.status}`);throw n.code=i.status,n}},I=(s=c(function*(e,t){var a=yield S(e),i=Buffer.from((yield a.arrayBuffer())),n=y.join(b.tmpdir(),`bricks-cli-update-${process.pid}-${t}`);return yield _.writeFile(n,i),F||(yield _.chmod(n,493)),n}),function(e,t){return s.apply(this,arguments)}),$=(p=c(function*(e,{installDir:t}={}){var a=F?"install.ps1":"install.sh",i=yield I(A(e,a),a);try{var n=F?["powershell",["-NoProfile","-ExecutionPolicy","Bypass","-File",i,..."beta"===e?["-Beta"]:[],...t?["-InstallDir",t]:[]]]:["sh",[i,..."beta"===e?["--beta"]:[],...t?[`--dir=${t}`]:[]]],r=x(n,2),o=r[0],s=r[1];O(o,s)}finally{yield _.unlink(i).catch(()=>{})}}),function(e){return p.apply(this,arguments)}),j=(l=c(function*(e,t,a={}){if("npm"===e)return void O("npm",["install","-g",`${E}@${C(t)}`]);if("bun"===e)return void O("bun",["install","-g",`${E}@${C(t)}`]);if("binary"===e)return $(t,{installDir:a.installDir});throw Error(`Unsupported update method: ${e}`)}),function(e,t){return l.apply(this,arguments)}),B=a(8479),R=(d=c(function*({message:e,defaultValue:t,autoYes:a}){if(a)return!0;(0,B.z)()||(console.error(f.Ay.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{return yield(0,v.lJ)({message:e,default:t})}catch{return!1}}),function(e){return d.apply(this,arguments)}),V=new m.uB("update-cli").description("Update the BRICKS CLI to the latest version").option("-y, --yes","Skip confirmation prompts").option("--channel <channel>","Override channel (release|beta)").option("--check-update","Only check whether a newer version is available and exit").action((u=c(function*(e){var t,a="2.25.0-beta.45",i=(({execPath:e=process.execPath,scriptPath:t=process.argv[1],homeDir:a=b.homedir(),realpath:i=D}={})=>{let n;var r=(n=e)?y.basename(n).replace(/\.exe$/i,""):"";if("bricks"===r||"bricks-beta"===r)return{method:"binary",execPath:e,installDir:y.dirname(e)};var o=i(t),s=((e,t)=>{if(!e)return null;var a=y.sep,i=`${a}node_modules${a}${t.replace(/\//g,a)}${a}`,n=e.indexOf(i);return -1===n?null:e.slice(0,n)})(o,"@fugood/bricks-cli");if(s){var p=y.sep,l=y.join(a,".bun","install","global");return s===l||s.startsWith(l+p)?{method:"bun",installRoot:s}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(s)?{method:"pnpm",installRoot:s}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(s)?{method:"yarn",installRoot:s}:{method:"npm",installRoot:s.endsWith(`${p}lib`)?s.slice(0,-`${p}lib`.length):s}}return{method:"unknown",execPath:e,scriptPath:o}})(),n=e.channel||(({version:e,execPath:t}={})=>{var a=t||process.execPath;return a&&/[\\/]bricks-beta(?:\.exe)?$/i.test(a)||/-(beta|alpha|rc|next)\b/i.test(e||"2.25.0-beta.45")?"beta":"release"})({version:a,execPath:i.execPath});console.log(f.Ay.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${f.Ay.cyan(a)}`),console.log(`Channel : ${f.Ay.cyan(n)}`),console.log(`Detected method : ${f.Ay.cyan(i.method)}`),i.execPath&&"binary"===i.method&&console.log(`Binary path : ${f.Ay.gray(i.execPath)}`),i.installRoot&&console.log(`Install root : ${f.Ay.gray(i.installRoot)}`);var r="npm"===i.method||"bun"===i.method?"npm":"cdn",o=(0,h.default)(`Fetching latest version info (${r})...`).start(),s=null,p=null;try{s=(yield N(n,i.method)).version,o.succeed(`Latest ${n} (${r}): ${f.Ay.green(s)}`)}catch(e){p=e,o.warn(`Could not fetch version info: ${e.message}`)}var l=s&&s===a;if(e.checkUpdate){if(p&&process.exit(2),l)return void console.log(f.Ay.green("\nUp to date."));s&&(console.log(f.Ay.yellow(`
|
|
125
|
+
${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?y.Ay.gray(`- ${t.title}`):"";console.log(` ${y.Ay.green(e)} ${a}`)})}),console.log()}catch(e){i.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,t){return d.apply(this,arguments)})),k.command("remove <id>").description("Remove a module").option("--dry-run","Validate the target and show the removal plan without deleting it").option("-j, --json","Output as JSON").action((u=v(function*(e,t){var a=(0,F.o)(),i=t.json?null:(0,b.default)("Removing module...").start();try{var n=yield a.module({id:e});if(!n)throw Error("Module not found");var r=T(n,e);if(t.dryRun){i&&i.stop(),(0,S.S5)({action:"module.remove",target:r,request:{id:e},checks:[(0,S.Iy)("module exists",!0,`${r.name} (${r.id})`)],json:t.json});return}var o=yield a.removeModule({id:e});t.json?(0,S.yd)({action:"module.remove",target:r,result:{removed:!!o},json:!0}):i.succeed(`Module removed: ${y.Ay.green(r.name)}`)}catch(a){t.json?(0,E.OW)(a.message,{action:"module.remove",target:{id:e}}):i.fail(`Failed to remove module: ${a.message}`),process.exit(1)}}),function(e,t){return u.apply(this,arguments)})),k.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("-n, --name <name>","Update module name as part of the release").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action((c=v(function*(e,t){var a=(0,F.o)(),i=t.json?null:(0,b.default)("Releasing module...").start();try{var n=(0,C.Ku)(t.config),r=n.config,o=n.source,s=n.sizeBytes,p=yield a.module({id:e});if(!p)throw Error("Module not found");if(p.is_public)throw Error("Public module deployment is temporarily not recommended");var l=t.version||t.name||p.name||"Untitled",d=(0,C.w9)(t.changelogs);if(t.dryRun){i&&i.stop(),(0,S.S5)({action:"module.release",target:T(p,e),request:{name:t.name||null,version:l,changelogs:t.changelogs||null,configSource:o,configSizeBytes:s},checks:[(0,S.Iy)("module exists",!0,`${p.name} (${p._id})`),(0,S.Iy)("module is private",!p.is_public),(0,S.Iy)("release config loaded",!0,`${s} bytes`)],json:t.json});return}var u=yield a.releaseModule({id:e,config:r,...t.name?{name:t.name}:{},releaseCurrentVersion:l,releaseCurrentVersionNote:d});t.json?(0,S.yd)({action:"module.release",target:T(u||p,e),result:{name:t.name||null,version:l,configSource:o,configSizeBytes:s},json:!0}):i.succeed(`Module released: ${y.Ay.green(u?.name||p.name)}`)}catch(a){t.json?(0,E.OW)(a.message,{action:"module.release",target:{id:e}}):i.fail(`Failed to release module: ${a.message}`),process.exit(1)}}),function(e,t){return c.apply(this,arguments)})),k.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((m=v(function*(e,t){var a=(0,F.o)(),i=t.json?null:(0,b.default)("Pulling module project...").start();try{var n=yield a.moduleProject({id:e,buildApplicationOnly:!0});n||(i?i.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(n)):(i.succeed(`Module project fetched: ${y.Ay.green(n.files?.length||0)} files`),console.log(JSON.stringify(n,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):i.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}}),function(e,t){return m.apply(this,arguments)})),k.command("doctor <idOrPath>").description("Diagnose a module config: schema validation plus semantic lint rules (data races, layout mistakes, dead config)").option("-j, --json","Output as JSON").option("--strict","Exit with code 1 when warnings are found").option("--only <codes>","Run only these rule codes (comma-separated)").option("--ignore <codes>","Skip these rule codes (comma-separated)").option("--validate-automation","Also validate automation_map and test_map references").action((f=v(function*(e,t){var i=t.json?null:(0,b.default)("Running config doctor...").start();try{var n=yield Promise.all([a.e(587),a.e(341),a.e(10),a.e(511),a.e(223)]).then(a.bind(a,63322)),r=n.runConfigDoctor,o=n.renderConfigDoctorReport,s=yield r("module",e,t),p=s.report,l=s.exitCode;i?.stop(),t.json?(0,E.GF)({...p,exitCode:l}):console.log(o(p)),0!==l&&process.exit(l)}catch(e){i?i.fail(`Config doctor failed: ${e.message}`):(0,E.OW)(e.message),process.exit(1)}}),function(e,t){return f.apply(this,arguments)})),k.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((h=v(function*(e,t){var i=(yield a.e(602).then(a.bind(a,6553))).initProject;yield i("module",e,t)}),function(e,t){return h.apply(this,arguments)}))},86141(e,t,a){a.d(t,{D:()=>V});var i,n,r,o,s,p,l,d,u,c=a(99436),m=a(35679),f=a(73284),h=a(30155),v=a(88958),g=a(73024),y=a(76760),b=a(48161),D=e=>{if(!e)return e;try{return g.realpathSync(e)}catch{return e}},x=a(68832),w=a(31421),_=a(51455),E="@fugood/bricks-cli",F="win32"===process.platform,A=(e,t)=>`https://cdn.bricks.tools/bricks-cli/${e}/${t}`,C=e=>"beta"===e?"beta":"latest",S=(i=c(function*(e){var t=yield fetch(e);if(!t.ok)throw Error(`Failed to fetch ${e}: HTTP ${t.status}`);return t}),function(e){return i.apply(this,arguments)}),T=(n=c(function*(e){return(yield S(A(e,"version.json"))).json()}),function(e){return n.apply(this,arguments)}),k=(r=c(function*(e){var t=C(e),a=yield S(`https://registry.npmjs.org/-/package/${E}/dist-tags`),i=(yield a.json())[t];if(!i)throw Error(`No '${t}' dist-tag for ${E}`);return{version:i}}),function(e){return r.apply(this,arguments)}),N=(o=c(function*(e,t){return"npm"===t||"bun"===t?k(e):T(e)}),function(e,t){return o.apply(this,arguments)}),O=(e,t,a={})=>{var i=(0,w.spawnSync)(e,t,{stdio:"inherit",...a});if(i.error){if("ENOENT"===i.error.code)throw Error(`Command not found: ${e}`);throw i.error}if(0!==i.status){var n=Error(`${e} exited with code ${i.status}`);throw n.code=i.status,n}},I=(s=c(function*(e,t){var a=yield S(e),i=Buffer.from((yield a.arrayBuffer())),n=y.join(b.tmpdir(),`bricks-cli-update-${process.pid}-${t}`);return yield _.writeFile(n,i),F||(yield _.chmod(n,493)),n}),function(e,t){return s.apply(this,arguments)}),$=(p=c(function*(e,{installDir:t}={}){var a=F?"install.ps1":"install.sh",i=yield I(A(e,a),a);try{var n=F?["powershell",["-NoProfile","-ExecutionPolicy","Bypass","-File",i,..."beta"===e?["-Beta"]:[],...t?["-InstallDir",t]:[]]]:["sh",[i,..."beta"===e?["--beta"]:[],...t?[`--dir=${t}`]:[]]],r=x(n,2),o=r[0],s=r[1];O(o,s)}finally{yield _.unlink(i).catch(()=>{})}}),function(e){return p.apply(this,arguments)}),j=(l=c(function*(e,t,a={}){if("npm"===e)return void O("npm",["install","-g",`${E}@${C(t)}`]);if("bun"===e)return void O("bun",["install","-g",`${E}@${C(t)}`]);if("binary"===e)return $(t,{installDir:a.installDir});throw Error(`Unsupported update method: ${e}`)}),function(e,t){return l.apply(this,arguments)}),B=a(8479),R=(d=c(function*({message:e,defaultValue:t,autoYes:a}){if(a)return!0;(0,B.z)()||(console.error(f.Ay.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{return yield(0,v.lJ)({message:e,default:t})}catch{return!1}}),function(e){return d.apply(this,arguments)}),V=new m.uB("update-cli").description("Update the BRICKS CLI to the latest version").option("-y, --yes","Skip confirmation prompts").option("--channel <channel>","Override channel (release|beta)").option("--check-update","Only check whether a newer version is available and exit").action((u=c(function*(e){var t,a="2.25.0-beta.48",i=(({execPath:e=process.execPath,scriptPath:t=process.argv[1],homeDir:a=b.homedir(),realpath:i=D}={})=>{let n;var r=(n=e)?y.basename(n).replace(/\.exe$/i,""):"";if("bricks"===r||"bricks-beta"===r)return{method:"binary",execPath:e,installDir:y.dirname(e)};var o=i(t),s=((e,t)=>{if(!e)return null;var a=y.sep,i=`${a}node_modules${a}${t.replace(/\//g,a)}${a}`,n=e.indexOf(i);return -1===n?null:e.slice(0,n)})(o,"@fugood/bricks-cli");if(s){var p=y.sep,l=y.join(a,".bun","install","global");return s===l||s.startsWith(l+p)?{method:"bun",installRoot:s}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(s)?{method:"pnpm",installRoot:s}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(s)?{method:"yarn",installRoot:s}:{method:"npm",installRoot:s.endsWith(`${p}lib`)?s.slice(0,-`${p}lib`.length):s}}return{method:"unknown",execPath:e,scriptPath:o}})(),n=e.channel||(({version:e,execPath:t}={})=>{var a=t||process.execPath;return a&&/[\\/]bricks-beta(?:\.exe)?$/i.test(a)||/-(beta|alpha|rc|next)\b/i.test(e||"2.25.0-beta.48")?"beta":"release"})({version:a,execPath:i.execPath});console.log(f.Ay.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${f.Ay.cyan(a)}`),console.log(`Channel : ${f.Ay.cyan(n)}`),console.log(`Detected method : ${f.Ay.cyan(i.method)}`),i.execPath&&"binary"===i.method&&console.log(`Binary path : ${f.Ay.gray(i.execPath)}`),i.installRoot&&console.log(`Install root : ${f.Ay.gray(i.installRoot)}`);var r="npm"===i.method||"bun"===i.method?"npm":"cdn",o=(0,h.default)(`Fetching latest version info (${r})...`).start(),s=null,p=null;try{s=(yield N(n,i.method)).version,o.succeed(`Latest ${n} (${r}): ${f.Ay.green(s)}`)}catch(e){p=e,o.warn(`Could not fetch version info: ${e.message}`)}var l=s&&s===a;if(e.checkUpdate){if(p&&process.exit(2),l)return void console.log(f.Ay.green("\nUp to date."));s&&(console.log(f.Ay.yellow(`
|
|
126
126
|
Update available: ${a} → ${s}. Run 'bricks update-cli' to install.`)),process.exit(1)),console.log(f.Ay.yellow("\nCould not determine current version.")),process.exit(2)}if(l&&(console.log(f.Ay.green("\nAlready running the latest version.")),!(yield R({message:"Reinstall anyway?",defaultValue:!1,autoYes:e.yes}))))return void console.log(f.Ay.gray("Skipped."));var d=["npm","bun","binary"].includes(i.method);d||console.log(f.Ay.yellow(`Cannot auto-detect installer (method: ${i.method}); falling back to binary install.`));var u=d?i.method:"binary";if(!(yield R({message:`Update CLI using "${u}" method?`,defaultValue:!0,autoYes:e.yes})))return void console.log(f.Ay.yellow("Cancelled."));var m=(t=c(function*(e){console.log(f.Ay.cyan(`
|
|
127
127
|
→ Running ${e} update...`));try{return yield j(e,n,i),!0}catch(t){return console.error(f.Ay.yellow(`
|
|
128
|
-
${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,arguments)}),v=yield m(u);!v&&"binary"!==u&&(console.log(f.Ay.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield R({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(v=yield m("binary"))),v||(console.error(f.Ay.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(f.Ay.green("\nUpdate complete."))}),function(e){return u.apply(this,arguments)}))},92642(e,t,a){a.d(t,{W:()=>
|
|
128
|
+
${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,arguments)}),v=yield m(u);!v&&"binary"!==u&&(console.log(f.Ay.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield R({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(v=yield m("binary"))),v||(console.error(f.Ay.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(f.Ay.green("\nUpdate complete."))}),function(e){return u.apply(this,arguments)}))},92642(e,t,a){a.d(t,{W:()=>_});var i,n,r,o=a(99436),s=a(5018),p=a(44668),l=a(4275),d=a(32235),u=a(62192),c=a(79657),m=a(64007);function f(e){var t,a,i,n=2;for("u">typeof Symbol&&(a=Symbol.asyncIterator,i=Symbol.iterator);n--;){if(a&&null!=(t=e[a]))return t.call(e);if(i&&null!=(t=e[i]))return new h(t.call(e));a="@@asyncIterator",i="@@iterator"}throw TypeError("Object is not async iterable")}function h(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return(h=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var a=this.s.return;return void 0===a?Promise.resolve({value:e,done:!0}):t(a.apply(this.s,arguments))},throw:function(e){var a=this.s.return;return void 0===a?Promise.reject(e):t(a.apply(this.s,arguments))}},new h(e)}function*v(e){if(e.errors?.length)throw Error(e.errors.map(e=>e.message).join("\n"));if(e.data){for(var t of Object.values(e.data))if(Array.isArray(t))for(var a of t)yield a}if(Array.isArray(e.incremental)){for(var i of e.incremental)if(Array.isArray(i.items))for(var n of i.items)yield n}}function g(){return(g=l(function*(e){var t=e.headers.get("content-type")||"";if(t.includes("application/json")){var a=yield d(e.json());if(a.errors?.length)throw Error(a.errors.map(e=>e.message).join("\n"));var i=Object.keys(a.data||{})[0];if(i&&Array.isArray(a.data[i]))for(var n of a.data[i])yield n;return}var r=t.match(/boundary="?([^";]+)"?/),o=r?r[1]:"-",s=`--${o}`,p="",l=!1,c=new TextDecoder,m=e=>{for(var t=0;-1!==(t=e.indexOf(s,t));){if(0===t||"\n"===e[t-1])return t;t+=s.length}return -1},h=function*(){for(var e;-1!==(e=m(p));){var t=p.slice(0,e);(p=p.slice(e+s.length)).startsWith("\r\n")?p=p.slice(2):p.startsWith("\n")&&(p=p.slice(1));var a=t.indexOf("\r\n\r\n"),i=-1!==a?t.slice(a+4).trim():t.trim();if(i){var n=void 0;try{n=JSON.parse(i)}catch{continue}if(yield*v(n),!1===n.hasNext){l=!0;return}}}};try{var g=!1,y=!1;try{for(var b,D,x=f(e.body);g=!(D=yield d(x.next())).done;g=!1){var w=D.value;if(p+=c.decode(w,{stream:!0}),yield*u(f(h()),d),l)break}}catch(e){y=!0,b=e}finally{try{g&&null!=x.return&&(yield d(x.return()))}finally{if(y)throw b}}}catch(e){if(!e.message?.includes("Premature close")||!l)throw e}if(!l&&p.trim()){var _,E=p.indexOf("\r\n\r\n"),F=-1!==E?p.slice(E+4).trim():p.trim();if(F&&!F.startsWith("--")){try{_=JSON.parse(F)}catch{}_&&(yield*u(f(v(_)),d),!1===_.hasNext&&(l=!0))}}e.body?.destroy()})).apply(this,arguments)}var y=`
|
|
129
129
|
query AL_events($filter: EventsFilter!) {
|
|
130
130
|
events(filter: $filter) @stream {
|
|
131
131
|
device_id
|
|
@@ -137,13 +137,13 @@ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,argume
|
|
|
137
137
|
timestamp
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
`,
|
|
140
|
+
`,b=`
|
|
141
141
|
query AL_screenshots($filter: ScreenshotFilter!) {
|
|
142
142
|
screenshots(filter: $filter) @stream {
|
|
143
143
|
timestamp
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
`;function
|
|
146
|
+
`;function D(e){var t,a,i,n=2;for("u">typeof Symbol&&(a=Symbol.asyncIterator,i=Symbol.iterator);n--;){if(a&&null!=(t=e[a]))return t.call(e);if(i&&null!=(t=e[i]))return new x(t.call(e));a="@@asyncIterator",i="@@iterator"}throw TypeError("Object is not async iterable")}function x(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return(x=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var a=this.s.return;return void 0===a?Promise.resolve({value:e,done:!0}):t(a.apply(this.s,arguments))},throw:function(e){var a=this.s.return;return void 0===a?Promise.reject(e):t(a.apply(this.s,arguments))}},new x(e)}var w=p(function e(t,a){s(this,e),this.baseUrl=t,this.token=a,this.graphqlUrl=`${t}/api/graphql`,this.fetch=function(e){var t=process.env.HTTPS_PROXY||process.env.https_proxy;if(!t||!e.startsWith("https://"))return c.Ay;var a=new m(t);return(e,t={})=>(0,c.Ay)(e,{...t,agent:a})}(t)},[{key:"streamQuery",value:function(e,t){var a=this;return l(function*(e,t,{signal:i}={}){var n=yield d(a.fetch(a.graphqlUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.token}`,Accept:'multipart/mixed; boundary="-", application/json'},body:JSON.stringify({query:e,variables:t}),signal:i}));if(!n.ok){var r=yield d(n.text().catch(()=>""));throw Error(`Activity-log query failed (${n.status}): ${r}`)}yield*u(D(function(e){return g.apply(this,arguments)}(n)),d)}).apply(this,arguments)}},{key:"events",value:function(e,t){var a=this;return l(function*(){yield*u(D(a.streamQuery(y,{filter:e},t)),d)})()}},{key:"screenshots",value:function(e,t){var a=this;return l(function*(){yield*u(D(a.streamQuery(b,{filter:e},t)),d)})()}},{key:"collectEvents",value:(i=o(function*(e,{limit:t,signal:a}={}){var i=[],n=!1,r=!1;try{for(var o,s,p=D(this.events(e,{signal:a}));n=!(s=yield p.next()).done;n=!1){var l=s.value;if(i.push(l),t&&i.length>=t)break}}catch(e){r=!0,o=e}finally{try{n&&null!=p.return&&(yield p.return())}finally{if(r)throw o}}return i}),function(e){return i.apply(this,arguments)})},{key:"collectScreenshots",value:(n=o(function*(e,{signal:t}={}){var a=[],i=!1,n=!1;try{for(var r,o,s=D(this.screenshots(e,{signal:t}));i=!(o=yield s.next()).done;i=!1){var p=o.value;a.push(p)}}catch(e){n=!0,r=e}finally{try{i&&null!=s.return&&(yield s.return())}finally{if(n)throw r}}return a}),function(e){return n.apply(this,arguments)})},{key:"downloadScreenshot",value:(r=o(function*(e,t,a,{signal:i}={}){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(t)}/screenshot?ts=${encodeURIComponent(a)}`,r=yield this.fetch(n,{headers:{Authorization:`Bearer ${this.token}`},signal:i});if(!r.ok){var o=yield r.text().catch(()=>"");throw Error(`Screenshot fetch failed (${r.status}): ${o}`)}return Buffer.from((yield r.arrayBuffer()))}),function(e,t,a){return r.apply(this,arguments)})}]),_=(e,t)=>new w(e,t)},85382(e,t,a){a.r(t),a.d(t,{BricksClient:()=>F,BricksPublicClient:()=>_,createClient:()=>A,createFetchForUrl:()=>w,createPublicClient:()=>E});var i,n,r,o,s=a(99436),p=a(5018),l=a(44668),d=a(54506),u=a(78549),c=a(94370),m=a(79657),f=a(64007),h=a(43741),v=a(89293),g=d.ApolloClient,y=d.InMemoryCache,b=d.HttpLink,D=u.o,x={query:"query",mutation:"mutate"};function w(e){var t=process.env.HTTPS_PROXY||process.env.https_proxy;if(!t||!e.startsWith("https://"))return m.Ay;var a=new f(t);return(e,t={})=>(0,m.Ay)(e,{...t,agent:a})}var _=l(function e(t){p(this,e),this.baseUrl=t,this.endpoint="/api/graphql-nonauth";var a=new b({uri:`${t}${this.endpoint}`,fetch:w(t)});this.apolloClient=new g({link:a,cache:new y,defaultOptions:{query:{errorPolicy:"all",fetchPolicy:"no-cache"}}})},[{key:"checkWorkspaceOTP",value:(i=s(function*(e){var t=(0,c.default)`
|
|
147
147
|
query checkWorkspaceOTP($passcode: String!) {
|
|
148
148
|
checkWorkspaceOTP(passcode: $passcode)
|
|
149
149
|
}
|
|
@@ -741,18 +741,20 @@ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,argume
|
|
|
741
741
|
`,d=(0,i.default)`
|
|
742
742
|
query CLI_devicesByGroup($id: ID) {
|
|
743
743
|
devicesByGroup(id: $id) {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
744
|
+
target_name
|
|
745
|
+
device {
|
|
746
|
+
_id
|
|
747
|
+
name
|
|
748
|
+
device_name
|
|
749
|
+
entry_detail {
|
|
750
|
+
watch_dog_timer {
|
|
751
|
+
alive
|
|
752
|
+
last_alive_time
|
|
753
|
+
}
|
|
754
|
+
application {
|
|
755
|
+
_id
|
|
756
|
+
name
|
|
757
|
+
}
|
|
756
758
|
}
|
|
757
759
|
}
|
|
758
760
|
}
|
|
@@ -1014,7 +1016,7 @@ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,argume
|
|
|
1014
1016
|
lastSeenAt
|
|
1015
1017
|
}
|
|
1016
1018
|
}
|
|
1017
|
-
`},1878(e,t,a){a.a(e,async function(e,i){try{a.d(t,{A:()=>C,e:()=>A});var n,r=a(99436),o=a(35679),s=a(73284),p=a(47988),l=a(8479),d=a(55614),u=a(1983),c=a(17422),m=a(32541),f=a(28634),h=a(37818),v=a(23699),g=a(71335),y=a(429),b=a(80274),D=a(42400),x=a(98247),w=a(11405),_=a(86141),E=a(59845),F=e([D]);D=(F.then?(await F)():F)[0];var A=(n=r(function*(){var e,t=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==t&&process.argv[t+1]&&((0,p.setProfileOverride)(process.argv[t+1]),process.argv.splice(t,2)),o.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.0-beta.
|
|
1019
|
+
`},1878(e,t,a){a.a(e,async function(e,i){try{a.d(t,{A:()=>C,e:()=>A});var n,r=a(99436),o=a(35679),s=a(73284),p=a(47988),l=a(8479),d=a(55614),u=a(1983),c=a(17422),m=a(32541),f=a(28634),h=a(37818),v=a(23699),g=a(71335),y=a(429),b=a(80274),D=a(42400),x=a(98247),w=a(11405),_=a(86141),E=a(59845),F=e([D]);D=(F.then?(await F)():F)[0];var A=(n=r(function*(){var e,t=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==t&&process.argv[t+1]&&((0,p.setProfileOverride)(process.argv[t+1]),process.argv.splice(t,2)),o.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.0-beta.48","-v, --version","output the version number").enablePositionalOptions(),o.DM.addCommand(d.s),o.DM.addCommand(u._),o.DM.addCommand(c.B),o.DM.addCommand(m.A),o.DM.addCommand(f.p),o.DM.addCommand(h.u),o.DM.addCommand(v.E),o.DM.addCommand(g.oT),o.DM.addCommand(y.K),o.DM.addCommand(b.gf),o.DM.addCommand(D.D),o.DM.addCommand(x.v),o.DM.addCommand(w.l),o.DM.addCommand(_.D),o.DM.addCommand(E.Q),o.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(r(function*(){try{var e=(yield Promise.all([a.e(3),a.e(940)]).then(a.bind(a,92319))).runInteractiveMode;yield e()}catch(e){console.error(s.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),o.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=r(function*(e){var t=yield Promise.resolve().then(a.bind(a,47988)),i=t.getToken,n=t.getBaseUrl,r=t.getCurrentProfile,o=(yield Promise.resolve().then(a.bind(a,85382))).createClient,p=(yield Promise.resolve().then(a.bind(a,30155))).default,l=r(),d=i(l);d||(console.error(s.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=p("Fetching workspace info...").start();try{var c=o(n(),d),m=yield c.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(m,null,2));console.log(s.Ay.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${s.Ay.green(m.name)}`),console.log(`ID: ${s.Ay.gray(m._id)}`),console.log(`Description: ${m.description||s.Ay.gray("N/A")}`),console.log(`
|
|
1018
1020
|
${s.Ay.bold("Data")}`),console.log(`Remote Update: ${m.bank?.enable_remote_update?s.Ay.green("Enabled"):s.Ay.gray("Disabled")}`),console.log(`Spacename: ${m.bank?.spacename||s.Ay.gray("N/A")}`),console.log("─".repeat(60))}catch(e){u.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}}),function(t){return e.apply(this,arguments)})),o.DM.on("--help",()=>{console.log(""),console.log(s.Ay.bold("Examples:")),console.log(""),console.log(s.Ay.gray(" # Login with a one-time passcode (recommended)")),console.log(" $ bricks auth login <passcode>"),console.log(""),console.log(s.Ay.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(s.Ay.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(s.Ay.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(s.Ay.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(s.Ay.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(s.Ay.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(s.Ay.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(s.Ay.gray("Get workspace token from BRICKS Controller:")),console.log(s.Ay.cyan(" https://control.bricks.tools")),console.log(s.Ay.gray(" Go to Workspace Settings > API Token"))});var i=process.argv.slice(2);if(0===i.length){if((0,l.b)(i))try{var n=(yield Promise.all([a.e(3),a.e(940)]).then(a.bind(a,92319))).runInteractiveMode;yield n();return}catch(e){console.error(s.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}console.error(s.Ay.gray("No command provided. Interactive mode requires a TTY, so showing help instead.\n")),o.DM.outputHelp();return}yield o.DM.parseAsync(process.argv)}),function(){return n.apply(this,arguments)});let C=A;i()}catch(e){i(e)}})},56493(e,t,a){a.d(t,{o:()=>o});var i=a(73284),n=a(47988),r=a(85382),o=()=>{var e=(0,n.getCurrentProfile)(),t=(0,n.getToken)(e);return t||(console.error(i.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,r.createClient)((0,n.getBaseUrl)(),t)}},7586(e,t,a){a.d(t,{$l:()=>r,GF:()=>i,OW:()=>n});var i=e=>{console.log(JSON.stringify(e,null,2))},n=(e,t={})=>{console.error(JSON.stringify({ok:!1,error:{message:e,...t}},null,2))},r=(e,t=4)=>e?e.length<=2*t?"*".repeat(e.length):`${e.slice(0,t)}…${e.slice(-t)}`:null},8479(e,t,a){a.d(t,{b:()=>n,z:()=>i});var i=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&"function"==typeof process.stdin.setRawMode),n=(e=[])=>0===e.length&&i()},47988(e,t,a){a.r(t),a.d(t,{CONFIG_DIR:()=>o,CONFIG_PATH:()=>s,clearBankCredentials:()=>E,clearConfig:()=>C,default:()=>S,getActivityLogBaseUrl:()=>F,getBankCredentials:()=>w,getBaseUrl:()=>l,getCurrentProfile:()=>y,getCurrentProfileSource:()=>b,getToken:()=>c,getTokenInfo:()=>m,getTokens:()=>u,listProfiles:()=>x,removeToken:()=>h,setActivityLogBaseUrl:()=>A,setBankCredentials:()=>_,setBaseUrl:()=>d,setCurrentProfile:()=>D,setProfileOverride:()=>g,setToken:()=>f});var i=a(83440),n=a(16928),r=a(70857),o=n.join(r.homedir(),".bricks-cli"),s=n.join(o,"config.json"),p=new i.default({projectName:"bricks-cli",cwd:o,schema:{tokens:{type:"object",default:{},additionalProperties:{type:"object",properties:{token:{type:"string"},name:{type:"string"},workspaceId:{type:"string"},workspaceName:{type:"string"},workspaceBilling:{type:"object"},createdAt:{type:"string"},baseUrl:{type:"string"},bank:{type:"object"}}}},currentProfile:{type:"string",default:"default"},baseUrl:{type:"string",default:"https://display.bricks.tools"},activityLogBaseUrl:{type:"string",default:"https://activity-log.bricks.tools"},devtoolsTokens:{type:"object",default:{},additionalProperties:{type:"object",additionalProperties:{type:"object",properties:{token:{type:"string"},expiresAt:{type:"string"},jti:{type:"string"},workspaceId:{type:"string"}}}}}}}),l=()=>{var e=y(),t=p.get("tokens");return t[e]?.baseUrl||p.get("baseUrl")},d=(e,t)=>{if(!t)return void p.set("baseUrl",e);var a=p.get("tokens");a[t]||(a[t]={}),a[t].baseUrl=e,p.set("tokens",a)},u=()=>p.get("tokens"),c=(e="default")=>{var t=p.get("tokens");return t[e]?.token},m=(e="default")=>p.get("tokens")[e],f=(e,t)=>{var a=p.get("tokens"),i=a[e];a[e]={...i?.baseUrl?{baseUrl:i.baseUrl}:{},...i?.activityLogBaseUrl?{activityLogBaseUrl:i.activityLogBaseUrl}:{},...t,createdAt:new Date().toISOString()},p.set("tokens",a)},h=e=>{var t=p.get("tokens");delete t[e],p.set("tokens",t)},v=null,g=e=>{v=e},y=()=>v||process.env.BRICKS_PROFILE||p.get("currentProfile"),b=()=>v?"override":process.env.BRICKS_PROFILE?"env":"config",D=e=>p.set("currentProfile",e),x=()=>{var e=p.get("tokens"),t=p.get("currentProfile");return Object.keys(e).map(a=>({...e[a],name:a,current:a===t}))},w=(e="default")=>{var t=p.get("tokens");return t[e]?.bank||null},_=(e,t)=>{var a=p.get("tokens");a[e]||(a[e]={}),a[e].bank=t,p.set("tokens",a)},E=e=>{var t=p.get("tokens");return!!t[e]?.bank&&(delete t[e].bank,p.set("tokens",t),!0)},F=()=>{var e=y(),t=p.get("tokens");return t[e]?.activityLogBaseUrl||p.get("activityLogBaseUrl")},A=(e,t)=>{if(!t)return void p.set("activityLogBaseUrl",e);var a=p.get("tokens");a[t]||(a[t]={}),a[t].activityLogBaseUrl=e,p.set("tokens",a)},C=()=>{p.clear()};let S=p},75646(e,t,a){a.r(t),a.d(t,{discoverDevToolsServers:()=>d,httpProbeSubnet:()=>u,verifyDevToolsServer:()=>c});var i,n,r=a(99436),o=a(41314),s=a(48161),p="bricks-devtools",l=()=>{var e=[];for(var t of Object.values(s.networkInterfaces()))for(var a of t)if(function(){if("IPv4"!==a.family||a.internal)return 1;var t=a.address.split(".").map(Number),i=a.netmask.split(".").map(Number),n=t.map((e,t)=>(e|255&~i[t]).toString()).join(".");e.push({address:a.address,broadcast:n})}())continue;return e},d=({timeout:e=3e3,idleTimeout:t=0}={})=>new Promise((a,i)=>{var n=new Map,r=o.createSocket("udp4"),s=null,d=null,u=!1,c=()=>{if(!u){u=!0,clearTimeout(s),clearTimeout(d);try{r.close()}catch{}a([...n.values()])}};r.on("error",e=>{if(!u){u=!0,clearTimeout(s),clearTimeout(d);try{r.close()}catch{}i(e)}}),r.on("message",(e,a)=>{try{var i=JSON.parse(e.toString());if(i.s!==p||"ANNOUNCE"!==i.t&&"RESPONSE"!==i.t)return;var r=i.d?.info;if(!r)return;var o=a.address,s=`${o}:${r.port}`;n.has(s)||(n.set(s,{...r,address:o}),t&&!u&&(clearTimeout(d),d=setTimeout(c,t)))}catch{}}),r.bind(()=>{r.setBroadcast(!0);var t=Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:p,d:{id:`cli-${Math.random().toString(36).substring(2,9)}`}})),a=new Set(["255.255.255.255","127.0.0.1"]);for(var i of l())a.add(i.broadcast);for(var n of a)r.send(t,0,t.length,19900,n);s=setTimeout(c,e)})}),u=(i=r(function*({port:e=19851,connectTimeout:t=500,concurrency:a=50,timeout:i=0}={}){var n=l();if(0===n.length)return[];var o=[],s=i>0?Date.now()+i:0,p=[],d=new Set;for(var u of n){var m=u.address.split(".").slice(0,3).join(".");if(!d.has(m)){d.add(m);for(var f=1;f<255;f++)p.push(`${m}.${f}`)}}for(var h=0;h<p.length&&!(s&&Date.now()>=s);h+=a){var v=p.slice(h,h+a);yield Promise.allSettled(v.map(function(){var a=r(function*(a){var i=yield c(a,e,t);i&&o.push({...i,address:a,port:e})});return function(e){return a.apply(this,arguments)}}()))}return o}),function(){return i.apply(this,arguments)}),c=(n=r(function*(e,t,a=3e3){var i;try{var n=new AbortController;i=setTimeout(()=>n.abort(),a);var r=yield fetch(`http://${e}:${t}/devtools/info`,{signal:n.signal});if(!r.ok)return null;return yield r.json()}catch{return null}finally{void 0!==i&&clearTimeout(i)}}),function(e,t){return n.apply(this,arguments)})},74049(e,t,a){a.d(t,{Ku:()=>s,w9:()=>o});var i=a(79896),n=a(16928),r=new Set(["CTOR","CTOR Desktop"]),o=e=>{var t,a=`Release by ${(t=process.env.BRICKS_RELEASE_SIGN)&&r.has(t)?t:"BRICKS CLI"}`;return e?`${e}
|
|
1019
1021
|
|
|
1020
1022
|
${a}`:a},s=e=>{if(e.endsWith(".json")||e.includes("/")){if(!i.existsSync(e))throw Error(`Config file not found: ${e}`);var t=i.readFileSync(e,"utf-8");return{config:t,source:{type:"file",path:n.resolve(e)},sizeBytes:Buffer.byteLength(t)}}return{config:e,source:{type:"inline"},sizeBytes:Buffer.byteLength(e)}}},68168(e,t,a){a.d(t,{K:()=>o,Y:()=>s});var i,n=a(99436),r=e=>String(e||"").trim().toLowerCase(),o=({resource:e,query:t,items:a,fields:i,selectedBy:n=null})=>{var o=r(t),s=a.filter(e=>i.some(t=>r(t.split(".").reduce((e,t)=>e?.[t],e)??null)===o)),p=null,l=n;return"id"===n?p=a[0]||null:1===s.length?(p=s[0],l="exact"):1===a.length&&(p=a[0],l="single"),{resource:e,query:t,exactMatchCount:s.length,matchCount:a.length,selectedBy:l,ambiguous:a.length>1&&!p,resolved:p,matches:a}},s=(i=n(function*(e){try{return yield e()}catch(e){if(/not found/i.test(e.message))return null;throw e}}),function(e){return i.apply(this,arguments)})},60450(e,t,a){a.d(t,{Gu:()=>m,he:()=>h,wR:()=>u});var i,n,r,o=a(99436),s=a(79657),p=a(73024),l=a(76760),d=a(48161),u=e=>e?.media_resource?.enable_media_workspace===!0,c=(i=o(function*(e,t,a){var i=yield e.mediaFiles({boxId:t,userTags:[`bricks_screenshot_${a}`],limit:1});return i?.[0]||null}),function(e,t,a){return i.apply(this,arguments)}),m=(e,{preferThumbnail:t=!1}={})=>{if(!e?.meta?.storageEndpoint)return null;var a=e.meta,i=a.storageEndpoint,n=a.originalFileKey,r=(t?(e=>{var t=e?.meta;if(!t)return null;if("Video"===e.fileType&&t.videoThumbOriginalFileKey)return t.videoThumbOriginalFileKey;var a=t.imageVersions||[];if(!Array.isArray(a)||0===a.length)return null;var i=a.filter(e=>e?.strategy==="BOUNDED"&&"number"==typeof e.width).sort((e,t)=>e.width-t.width);return(i[0]||a[0])?.key||null})(e):null)||n;return r?`${i}/${r}`:null},f=(n=o(function*(e,t=null){var a=yield(0,s.Ay)(e);if(!a.ok)throw Error(`Failed to download screenshot: ${a.statusText}`);var i=yield a.buffer(),n=t||l.join(d.tmpdir(),`bricks-screenshot-${Date.now()}.png`),r=l.dirname(n);return p.existsSync(r)||p.mkdirSync(r,{recursive:!0}),p.writeFileSync(n,i),n}),function(e){return n.apply(this,arguments)}),h=(r=o(function*(e,t,a,i=null,n={}){var r=u(t)&&t.media_resource?.system_media_box_id||null;if(!r)return{error:"Media workspace not enabled for this workspace"};var o=yield c(e,r,a);if(!o)return{error:"No screenshot available for this device"};var s=m(o,n);return s?{path:yield f(s,i),file:o,url:s}:{error:"Could not build screenshot URL"}}),function(e,t,a){return r.apply(this,arguments)})},44618(e,t,a){a.d(t,{V:()=>r});var i={S:"Subspace",B:"Brick",C:"Canvas",A:"Animation",G:"Generator",D:"Data",F:"Data Calc",N:"Calc Node",T:"Test",TC:"Test Case",AT:"Automation Map"},n=e=>e?.split("_")?.[0]||"",r=(e,{keyword:t,types:a}={})=>{var r=t?.trim().toLowerCase()||"",o=a?.length>0?new Set(a.flatMap(e=>{var t=String(e).trim().toUpperCase();return t?[t]:[]})):null;return Object.entries(Object.entries(e||{}).filter(([,e])=>e&&!e.hide).filter(([e,t])=>{var a=n(e);if(o&&!o.has(a))return!1;if(!r)return!0;var i=t?.title?String(t.title).toLowerCase():"";return e.toLowerCase().includes(r)||i.includes(r)}).reduce((e,[t,a])=>{var i=n(t);return e[i]||(e[i]=[]),e[i].push({shortId:t,ref:a}),e},{})).map(([e,t])=>({prefix:e,label:i[e]||e,refs:t.sort((e,t)=>{var a=e.ref?.title||e.shortId,i=t.ref?.title||t.shortId;return String(a).localeCompare(String(i))})})).sort((e,t)=>e.label.localeCompare(t.label))}},94979(e,t,a){a.d(t,{p:()=>r});var i=/^(\d+)(s|m|h|d|w)$/,n={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function r(e){var t=e.match(i);if(t){var a=parseInt(t[1],10),r=n[t[2]];return new Date(Date.now()-a*r).toISOString()}var o=new Date(e);if(isNaN(o.getTime()))throw Error(`Invalid time format: "${e}". Use ISO 8601 or relative (e.g. 1h, 30m, 2d)`);return o.toISOString()}},98593(e,t,a){a.d(t,{Iy:()=>r,S5:()=>s,yd:()=>p});var i=a(73284),n=a(7586),r=(e,t,a)=>({label:e,ok:t,detail:a}),o=e=>null==e?i.Ay.gray("N/A"):"object"==typeof e?i.Ay.gray(JSON.stringify(e,null,2)):String(e),s=({action:e,target:t,request:a,checks:r=[],json:s=!1})=>{s?(0,n.GF)({ok:!0,dryRun:!0,action:e,target:t||null,request:a||null,checks:r}):(console.log(i.Ay.bold(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-cli",
|
|
3
|
-
"version": "2.25.0-beta.
|
|
3
|
+
"version": "2.25.0-beta.48",
|
|
4
4
|
"description": "BRICKS CLI - Command-line interface for BRICKS Workspace API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bricks",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=18.0.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "6403fb9aece6b9ee45a72a963ddc75aec5ae3e04"
|
|
74
74
|
}
|