@fugood/bricks-cli 2.25.0-beta.51 → 2.25.0-beta.53

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/index.js CHANGED
@@ -39,8 +39,8 @@ ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title
39
39
  Expression Errors (${l.expression.length})
40
40
  `)),l.expression.forEach((e,t)=>{console.log(` ${w.Ay.red(`${t+1}.`)} ${w.Ay.bold(e.field)}`),console.log(` ${e.message}`)})),d.length>0&&(console.log(w.Ay.yellow(`
41
41
  Deprecation Warnings (${d.length})
42
- `)),d.forEach((e,t)=>{console.log(` ${w.Ay.yellow(`${t+1}.`)} ${w.Ay.bold(e.id)}`),console.log(` ${e.data}`)})),console.log("\n"+"─".repeat(60));var u=l.schema.length+l.ref.length+l.calc.length+(l.expression?.length||0);l.valid?console.log(w.Ay.yellow(`⚠ ${d.length} warning(s)`)):console.log(w.Ay.red(`✗ ${u} error(s)`)+(d.length>0?w.Ay.yellow(`, ${d.length} warning(s)`):"")),l.valid||process.exit(1)}catch(e){i.fail(`Failed to validate config: ${e.message}`),process.exit(1)}}),function(e,t){return g.apply(this,arguments)})),O.command("doctor <idOrPath>").description("Diagnose an application config: schema validation plus semantic lint rules (data races, layout mistakes, dead config)").option("-j, --json","Output as JSON").option("-c, --composed","Fetch the composed configuration (remote id only)").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((y=D(function*(e,t){var i=t.json?null:(0,_.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("app",e,t),p=s.report,l=s.exitCode;i?.stop(),t.json?(0,A.GF)({...p,exitCode:l}):console.log(o(p)),0!==l&&process.exit(l)}catch(e){i?i.fail(`Config doctor failed: ${e.message}`):(0,A.OW)(e.message),process.exit(1)}}),function(e,t){return y.apply(this,arguments)})),O.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from an application").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((b=D(function*(e,t){var i=(yield a.e(456).then(a.bind(a,58891))).initProject;yield i("application",e,t)}),function(e,t){return b.apply(this,arguments)}))},55614(e,t,i){i.d(t,{s:()=>D});var n,r,o,s,p,l=i(99436),d=i(35679),u=i(73284),c=i(30155);let m=a("readline");var f=i(47988),h=i(85382),v=i(7586),g=e=>!!e&&"object"==typeof e&&!Array.isArray(e),y=(e={})=>{var t=g(e)?e:{},a=t.plan,i=g(a)?a:{},n=g(t.lock)?t.lock:{},r="string"==typeof a?a:i.type;return{...t,plan:{...i,type:r||"free"},lock:{...n,features:!!n.features}}},b=(n=l(function*(){var e=(0,f.getCurrentProfile)(),t=(0,f.getCurrentProfileSource)(),a=(0,f.getTokenInfo)(e),i=(0,f.getBaseUrl)();if(!a?.token)return{ok:!1,profile:e,profileSource:t,baseUrl:i,auth:{available:!1,source:"missing",workspaceId:null,workspaceName:null,createdAt:null,tokenPreview:null},workspace:null,error:null};try{var n=(0,h.createClient)(i,a.token),r=yield n.workspace();return{ok:!0,profile:e,profileSource:t,baseUrl:i,auth:{available:!0,source:"config",workspaceId:r?._id||a.workspaceId||null,workspaceName:r?.name||a.workspaceName||null,createdAt:a.createdAt||null,tokenPreview:(0,v.$l)(a.token)},workspace:r?{_id:r._id,name:r.name,description:r.description||null}:null,error:null}}catch(n){return{ok:!1,profile:e,profileSource:t,baseUrl:i,auth:{available:!0,source:"config",workspaceId:a.workspaceId||null,workspaceName:a.workspaceName||null,createdAt:a.createdAt||null,tokenPreview:(0,v.$l)(a.token)},workspace:null,error:{message:n.message}}}}),function(){return n.apply(this,arguments)}),D=new d.uB("auth").description("Authentication and token management");D.command("login").description("Login with a one-time passcode from BRICKS Controller (recommended)").argument("[passcode]","One-time passcode from BRICKS Controller").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((r=l(function*(e,t){var a,i=t.profile||(0,f.getCurrentProfile)(),n=t.name,r=e;!r&&(console.log(u.Ay.cyan("Generate a one-time passcode from BRICKS Controller:")),console.log(u.Ay.gray(" 1. Open the link below (or select your workspace first)")),console.log(` ${u.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(u.Ay.gray(' 2. Click "Generate OTP" to create a one-time passcode\n')),(r=yield(a=m.createInterface({input:process.stdin,output:process.stdout}),new Promise(e=>{a.question("Enter passcode: ",t=>{a.close(),e(t.trim())})})))||(console.log(u.Ay.red("Passcode is required")),process.exit(1)));var o=(0,c.default)("Validating passcode...").start();try{var s=(0,h.createPublicClient)((0,f.getBaseUrl)()),p=yield s.checkWorkspaceOTP(r);p.valid||(o.fail(`Invalid passcode: ${p.error||"Unknown error"}`),process.exit(1)),o.text=`Exchanging passcode for token (workspace: ${p.workspaceName})...`;var l=yield s.exchangeWorkspaceOTP(r);l.token||(o.fail("Failed to obtain token"),process.exit(1));var d=(0,h.createClient)((0,f.getBaseUrl)(),l.token),v=yield d.workspace();v||(o.fail("Token validation failed"),process.exit(1)),(0,f.setToken)(i,{token:l.token,name:n||v.name,workspaceId:v._id,workspaceName:v.name,workspaceBilling:y(v.billing)}),(0,f.setCurrentProfile)(i),o.succeed(`Logged in to workspace: ${u.Ay.green(v.name)} (profile: ${u.Ay.cyan(i)})`)}catch(e){o.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e,t){return r.apply(this,arguments)})),D.command("login-token").description("Login with a workspace token directly").option("-t, --token <token>","Workspace token").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((o=l(function*(e){var t=e.profile||(0,f.getCurrentProfile)(),a=e.token,i=e.name;a||(console.error(u.Ay.red("Error: Token is required. Use -t or --token to provide it.")),console.log(u.Ay.gray("\nYou can get a workspace token from BRICKS Controller:")+u.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")),console.log(` ${u.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(u.Ay.gray("Select your workspace and create a new token.\n")),console.log(u.Ay.yellow("Tip: Use `bricks auth login` for a simpler OTP-based login.")),process.exit(1));var n=(0,c.default)("Validating token...").start();try{var r=(0,h.createClient)((0,f.getBaseUrl)(),a),o=yield r.workspace();o||(n.fail("Invalid token or unable to access workspace"),process.exit(1)),(0,f.setToken)(t,{token:a,name:i||o.name,workspaceId:o._id,workspaceName:o.name,workspaceBilling:y(o.billing)}),(0,f.setCurrentProfile)(t),n.succeed(`Logged in to workspace: ${u.Ay.green(o.name)} (profile: ${u.Ay.cyan(t)})`)}catch(e){n.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e){return o.apply(this,arguments)})),D.command("logout").description("Remove saved token").option("-p, --profile <profile>","Profile to remove").option("-a, --all","Remove all profiles").action((s=l(function*(e){var t=e.profile;if(e.all){(0,f.listProfiles)().forEach(e=>(0,f.removeToken)(e.name)),console.log(u.Ay.green("All profiles removed"));return}var a=t||(0,f.getCurrentProfile)();(0,f.getTokenInfo)(a)?((0,f.removeToken)(a),console.log(u.Ay.green(`Logged out from profile: ${a}`))):console.log(u.Ay.yellow(`No token found for profile: ${a}`))}),function(e){return s.apply(this,arguments)})),D.command("status").description("Show current authentication status").option("-j, --json","Output as JSON").action((p=l(function*(e){var t=(0,f.getCurrentProfile)(),a=(0,f.getTokenInfo)(t);if(!a)return e.json?void(0,v.GF)((yield b())):(console.log(u.Ay.yellow("Not logged in")),void console.log(u.Ay.gray("Use `bricks auth login` to login")));if(e.json)return void(0,v.GF)((yield b()));var i=(0,c.default)("Checking connection...").start();try{var n=(0,h.createClient)((0,f.getBaseUrl)(),a.token),r=yield n.workspace();i.stop(),console.log(u.Ay.bold("\nAuthentication Status")),console.log("─".repeat(40)),console.log(`Profile: ${u.Ay.cyan(t)}`),console.log(`Workspace: ${u.Ay.green(r.name)}`),console.log(`Workspace ID: ${u.Ay.gray(r._id)}`);var o=(0,f.getBaseUrl)(),s=a.baseUrl;console.log(`Base URL: ${u.Ay.gray(o)}${s?"":u.Ay.gray(" (global)")}`),console.log(`Logged in: ${u.Ay.gray(a.createdAt)}`),console.log("─".repeat(40))}catch(e){i.fail(`Connection failed: ${e.message}`)}}),function(e){return p.apply(this,arguments)})),D.command("list").description("List all saved profiles").action(()=>{var e=(0,f.listProfiles)();if(0===e.length){console.log(u.Ay.yellow("No saved profiles")),console.log(u.Ay.gray("Use `bricks auth login` to login"));return}console.log(u.Ay.bold("\nSaved Profiles")),console.log("─".repeat(60)),e.forEach(e=>{var t=e.current?u.Ay.green("● "):" ",a=e.current?u.Ay.green(e.name):e.name,i=e.baseUrl?u.Ay.gray(` [${e.baseUrl}]`):"";console.log(`${t}${a.padEnd(15)} ${u.Ay.gray(e.workspaceName||"Unknown")}${i}`)}),console.log("─".repeat(60))}),D.command("use <profile>").description("Switch to a different profile").action(e=>{var t=(0,f.getTokenInfo)(e);if(!t){console.log(u.Ay.red(`Profile not found: ${e}`)),console.log(u.Ay.gray("Use `bricks auth list` to see available profiles"));return}(0,f.setCurrentProfile)(e),console.log(u.Ay.green(`Switched to profile: ${e}`)),t.workspaceName&&console.log(u.Ay.gray(`Workspace: ${t.workspaceName}`))}),D.command("set-url <url>").description("Set the base URL for the current profile").option("-g, --global","Set the global base URL instead of per-profile").action((e,t)=>{if(t.global)(0,f.setBaseUrl)(e),console.log(u.Ay.green(`Global base URL set to: ${e}`));else{var a=(0,f.getCurrentProfile)();(0,f.setBaseUrl)(e,a),console.log(u.Ay.green(`Base URL for profile ${u.Ay.cyan(a)} set to: ${e}`))}})},59845(e,t,a){a.d(t,{Q:()=>$});var i,n,r,o,s,p,l,d,u,c,m,f=a(99436),h=a(35679),v=a(73284),g=a(77598),y=a(48161),b=a(76760),D=a(51455),x=a(27549),w=a(41314),_=a(19557),E=8089,F=(i=f(function*(e,t,a=3e3){return(0,_.uE)(`http://${e}:${t}/buttress/info`,a)}),function(e,t){return i.apply(this,arguments)}),A=b.join(y.homedir(),".bricks-cli","buttress"),C=e=>b.join(e||A,"state.json"),S=()=>{try{return`buttress-${x.machineIdSync()}`}catch{return null}},T=(n=f(function*(e){var t=C(e);try{var a=yield D.readFile(t,"utf8");return JSON.parse(a)}catch(e){if("ENOENT"===e.code)return null;throw e}}),function(e){return n.apply(this,arguments)}),k=(r=f(function*(e,t){var a=t||A,i=C(t);yield D.mkdir(a,{recursive:!0});var n=`${i}.tmp-${process.pid}`;return yield D.writeFile(n,JSON.stringify(e,null,2),"utf8"),yield D.rename(n,i),i}),function(e,t){return r.apply(this,arguments)}),N=(o=f(function*(e){var t=C(e);try{return yield D.unlink(t),!0}catch(e){if("ENOENT"===e.code)return!1;throw e}}),function(e){return o.apply(this,arguments)}),O=(s=f(function*({timeout:e=3e3,verify:t=!0,port:a=E,onStatus:i}={}){i?.(`Scanning UDP ${a} for ${e}ms...`);var n,r=yield(({timeout:e=3e3,idleTimeout:t=0,port:a=E}={})=>new Promise((i,n)=>{var r=new Map,o=w.createSocket("udp4"),s=null,p=null,l=!1,d=()=>{if(!l){l=!0,clearTimeout(s),clearTimeout(p);try{o.close()}catch{}i([...r.values()])}};o.on("error",e=>{if(!l){l=!0,clearTimeout(s),clearTimeout(p);try{o.close()}catch{}n(e)}}),o.on("message",(e,a)=>{try{var i=JSON.parse(e.toString());if("2.0"!==i.v||"ANNOUNCE"!==i.t&&"RESPONSE"!==i.t)return;var n=i.d?.info;if(!n)return;var o={...n,address:a.address},s=o.id||`${a.address}:${o.port}`;r.has(s)||(r.set(s,o),t&&!l&&(clearTimeout(p),p=setTimeout(d,t)))}catch{}}),o.bind(()=>{o.setBroadcast(!0);var t=Buffer.from(JSON.stringify({t:"QUERY",v:"2.0",d:{id:`cli-${(0,_.BW)()}`}}));for(var i of(0,_.a2)())o.send(t,0,t.length,a,i);s=setTimeout(d,e)})}))({timeout:e,port:a});return 0===r.length?[]:t?(i?.(`Verifying ${r.length} server(s)...`),yield Promise.all(r.map((n=f(function*(e){var t=yield F(e.address,e.port,2e3);return t?{...e,...t,address:e.address,verified:!0}:{...e,verified:!1}}),function(e){return n.apply(this,arguments)})))):r}),function(){return s.apply(this,arguments)}),I=(p=f(function*(){var e=yield Promise.resolve().then(a.bind(a,47988)),t=e.getToken,i=e.getBaseUrl,n=e.getCurrentProfile,r=(yield Promise.resolve().then(a.bind(a,85382))).createClient,o=t(n());return o||(console.error(v.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),r(i(),o)}),function(){return p.apply(this,arguments)}),$=new h.uB("buttress").description("Pair and inspect buttress-server bindings for the current workspace").alias("butr");$.command("bind").description("Pair a local buttress-server with the current workspace").option("-s, --server-id <id>","Buttress server id (auto-detected from machine id by default)").option("-n, --name <name>","Friendly name for this buttress server").option("--state-dir <dir>","Override the buttress state directory (defaults to ~/.bricks-cli/buttress)").option("--print","Print state.json to stdout instead of writing to disk (useful for remote setups)").action((l=f(function*(e){var t,i,n,r,o,s,p=(yield Promise.resolve().then(a.bind(a,30155))).default,l=e.serverId||S();l||(console.error(v.Ay.red("Could not detect a local server id. Pass --server-id <id> explicitly.")),process.exit(1));var d=(i=(t=g.generateKeyPairSync("ed25519")).publicKey,n=t.privateKey,r=i.export({type:"spki",format:"der"}),o=n.export({type:"pkcs8",format:"der"}),s=g.createHash("sha256").update(r).digest("hex").slice(0,16),{publicKeySpki:r.toString("base64"),privateKeyPkcs8:o.toString("base64"),kid:s}),u=yield I(),c=p(`Binding buttress server ${v.Ay.cyan(l)}...`).start();try{var m=yield u.bindButtressServer({serverId:l,name:e.name,serverPublicKey:{spkiBase64:d.publicKeySpki,kid:d.kid}});c.stop();var f={workspace:{id:m.workspaceId,name:m.workspaceName,serverId:m.serverId,issuerPublicKey:m.issuerPublicKey.pem,kid:m.issuerPublicKey.kid,boundAt:new Date().toISOString()},serverKeyPair:d};if(e.print){console.warn(v.Ay.yellow("⚠ Output contains the server announce private key. Treat as a secret.")),process.stdout.write(`${JSON.stringify(f,null,2)}
43
- `);return}var h=yield k(f,e.stateDir);console.log(v.Ay.green("✓"),"Buttress server bound to workspace."),console.log(` Workspace: ${v.Ay.bold(m.workspaceName)} (${m.workspaceId})`),console.log(` Server id: ${v.Ay.cyan(m.serverId)}`),console.log(` Issuer kid: ${v.Ay.gray(m.issuerPublicKey.kid)}`),console.log(` Announce kid: ${v.Ay.gray(d.kid)}`),console.log(` State file: ${v.Ay.gray(h)}`),console.log(),console.log(v.Ay.yellow("Restart buttress-server for the binding to take effect."))}catch(e){c.fail(`Bind failed: ${e.message}`),process.exit(1)}}),function(e){return l.apply(this,arguments)})),$.command("unbind").description("Unbind a buttress server from this workspace").option("-s, --server-id <id>","Buttress server id (auto-detected by default)").option("--state-dir <dir>","Override the buttress state directory").option("--keep-local","Do not remove the local state.json file").action((d=f(function*(e){var t=e.serverId||S();t||(console.error(v.Ay.red("Could not detect a local server id. Pass --server-id explicitly.")),process.exit(1));var a=yield I();try{if((yield a.unbindButtressServer({serverId:t}))?console.log(v.Ay.green("✓"),`Unbound ${v.Ay.cyan(t)} from workspace.`):console.log(v.Ay.yellow("!"),`${v.Ay.cyan(t)} was not bound to this workspace.`),!e.keepLocal){var i=C(e.stateDir),n=yield T(e.stateDir);n?.workspace?.serverId===t&&(yield N(e.stateDir),console.log(v.Ay.gray(`Removed local state file: ${i}`)))}}catch(e){console.error(v.Ay.red(`Unbind failed: ${e.message}`)),process.exit(1)}}),function(e){return d.apply(this,arguments)})),$.command("status").description("Show local buttress binding state and the workspace-side bound list").option("--state-dir <dir>","Override the buttress state directory").option("-j, --json","Output as JSON").action((u=f(function*(e){var t=yield T(e.stateDir),a=null;try{var i=yield I();a=yield i.buttressServers()}catch(e){a={error:e.message}}e.json?console.log(JSON.stringify({local:t,remote:a},null,2)):(console.log(v.Ay.bold("\nLocal buttress state")),console.log("─".repeat(60)),t?.workspace?(console.log(` Workspace: ${v.Ay.bold(t.workspace.name)} (${t.workspace.id})`),console.log(` Server id: ${v.Ay.cyan(t.workspace.serverId)}`),console.log(` Issuer kid: ${v.Ay.gray(t.workspace.kid)}`),console.log(` Bound at: ${v.Ay.gray(t.workspace.boundAt)}`),console.log(` File: ${v.Ay.gray(C(e.stateDir))}`)):console.log(v.Ay.gray(" not bound (no state.json found)")),console.log(v.Ay.bold("\nWorkspace-side bound servers")),console.log("─".repeat(60)),Array.isArray(a)?0===a.length?console.log(v.Ay.gray(" none")):a.forEach(e=>{console.log(` ${v.Ay.cyan(e.serverId)} ${v.Ay.gray(e.name||"")} ${v.Ay.gray(e.boundAt||"")}`)}):a?.error&&console.log(v.Ay.red(` failed to fetch: ${a.error}`)))}),function(e){return u.apply(this,arguments)})),$.command("issue-token").description("Issue a long-lived workspace-scoped buttress access token (CLI/CTOR usage)").option("--ttl <seconds>","Time-to-live in seconds (default 30 days)",e=>parseInt(e,10)).option("-j, --json","Output as JSON").action((c=f(function*(e){var t=yield I();try{var a=yield t.issueButtressAccessToken({ttlSeconds:e.ttl});if(e.json)return void console.log(JSON.stringify(a,null,2));console.log(v.Ay.green("✓"),"Buttress access token issued."),console.log(` Workspace: ${a.workspaceId}`),console.log(` Expires: ${a.expiresAt}`),console.log(` jti: ${v.Ay.gray(a.jti)}`),console.log(),console.log(v.Ay.cyan(a.token))}catch(e){console.error(v.Ay.red(`Issue token failed: ${e.message}`)),process.exit(1)}}),function(e){return c.apply(this,arguments)})),$.command("scan").description("Scan LAN for buttress-servers via UDP and verify each via /buttress/info").option("-t, --timeout <ms>","Scan timeout in milliseconds","3000").option("-p, --port <port>","UDP discovery port",String(E)).option("--udp-only","Skip HTTP /buttress/info verification").option("-j, --json","Output as JSON").action((m=f(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=parseInt(e.port,10),p=[],l=t(`Scanning for buttress-servers (${o}ms)...`).start();try{p=yield O({timeout:o,port:s,verify:!e.udpOnly,onStatus:e=>{l.text=e}}),l.stop()}catch(e){l.fail(`Scan failed: ${e.message}`),process.exit(1)}var d=n(),u=r(d)?.workspaceId||null;if(e.json)return void console.log(JSON.stringify({servers:p,workspaceId:u},null,2));if(0===p.length)return void console.log(v.Ay.yellow("No buttress-servers found on the LAN."));for(var c of(console.log(v.Ay.bold(`
42
+ `)),d.forEach((e,t)=>{console.log(` ${w.Ay.yellow(`${t+1}.`)} ${w.Ay.bold(e.id)}`),console.log(` ${e.data}`)})),console.log("\n"+"─".repeat(60));var u=l.schema.length+l.ref.length+l.calc.length+(l.expression?.length||0);l.valid?console.log(w.Ay.yellow(`⚠ ${d.length} warning(s)`)):console.log(w.Ay.red(`✗ ${u} error(s)`)+(d.length>0?w.Ay.yellow(`, ${d.length} warning(s)`):"")),l.valid||process.exit(1)}catch(e){i.fail(`Failed to validate config: ${e.message}`),process.exit(1)}}),function(e,t){return g.apply(this,arguments)})),O.command("doctor <idOrPath>").description("Diagnose an application config: schema validation plus semantic lint rules (data races, layout mistakes, dead config)").option("-j, --json","Output as JSON").option("-c, --composed","Fetch the composed configuration (remote id only)").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((y=D(function*(e,t){var i=t.json?null:(0,_.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("app",e,t),p=s.report,l=s.exitCode;i?.stop(),t.json?(0,A.GF)({...p,exitCode:l}):console.log(o(p)),0!==l&&process.exit(l)}catch(e){i?i.fail(`Config doctor failed: ${e.message}`):(0,A.OW)(e.message),process.exit(1)}}),function(e,t){return y.apply(this,arguments)})),O.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from an application").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((b=D(function*(e,t){var i=(yield a.e(456).then(a.bind(a,58891))).initProject;yield i("application",e,t)}),function(e,t){return b.apply(this,arguments)}))},55614(e,t,i){i.d(t,{s:()=>D});var n,r,o,s,p,l=i(99436),d=i(35679),u=i(73284),c=i(30155);let m=a("readline");var f=i(47988),h=i(85382),v=i(7586),g=e=>!!e&&"object"==typeof e&&!Array.isArray(e),y=(e={})=>{var t=g(e)?e:{},a=t.plan,i=g(a)?a:{},n=g(t.lock)?t.lock:{},r="string"==typeof a?a:i.type;return{...t,plan:{...i,type:r||"free"},lock:{...n,features:!!n.features}}},b=(n=l(function*(){var e=(0,f.getCurrentProfile)(),t=(0,f.getCurrentProfileSource)(),a=(0,f.getTokenInfo)(e),i=(0,f.getBaseUrl)();if(!a?.token)return{ok:!1,profile:e,profileSource:t,baseUrl:i,auth:{available:!1,source:"missing",workspaceId:null,workspaceName:null,createdAt:null,tokenPreview:null},workspace:null,error:null};try{var n=(0,h.createClient)(i,a.token),r=yield n.workspace();return{ok:!0,profile:e,profileSource:t,baseUrl:i,auth:{available:!0,source:"config",workspaceId:r?._id||a.workspaceId||null,workspaceName:r?.name||a.workspaceName||null,createdAt:a.createdAt||null,tokenPreview:(0,v.$l)(a.token)},workspace:r?{_id:r._id,name:r.name,description:r.description||null}:null,error:null}}catch(n){return{ok:!1,profile:e,profileSource:t,baseUrl:i,auth:{available:!0,source:"config",workspaceId:a.workspaceId||null,workspaceName:a.workspaceName||null,createdAt:a.createdAt||null,tokenPreview:(0,v.$l)(a.token)},workspace:null,error:{message:n.message}}}}),function(){return n.apply(this,arguments)}),D=new d.uB("auth").description("Authentication and token management");D.command("login").description("Login with a one-time passcode from BRICKS Controller (recommended)").argument("[passcode]","One-time passcode from BRICKS Controller").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((r=l(function*(e,t){var a,i=t.profile||(0,f.getCurrentProfile)(),n=t.name,r=e;!r&&(console.log(u.Ay.cyan("Generate a one-time passcode from BRICKS Controller:")),console.log(u.Ay.gray(" 1. Open the link below (or select your workspace first)")),console.log(` ${u.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(u.Ay.gray(' 2. Click "Generate OTP" to create a one-time passcode\n')),(r=yield(a=m.createInterface({input:process.stdin,output:process.stdout}),new Promise(e=>{a.question("Enter passcode: ",t=>{a.close(),e(t.trim())})})))||(console.log(u.Ay.red("Passcode is required")),process.exit(1)));var o=(0,c.default)("Validating passcode...").start();try{var s=(0,h.createPublicClient)((0,f.getBaseUrl)()),p=yield s.checkWorkspaceOTP(r);p.valid||(o.fail(`Invalid passcode: ${p.error||"Unknown error"}`),process.exit(1)),o.text=`Exchanging passcode for token (workspace: ${p.workspaceName})...`;var l=yield s.exchangeWorkspaceOTP(r);l.token||(o.fail("Failed to obtain token"),process.exit(1));var d=(0,h.createClient)((0,f.getBaseUrl)(),l.token),v=yield d.workspace();v||(o.fail("Token validation failed"),process.exit(1)),(0,f.setToken)(i,{token:l.token,name:n||v.name,workspaceId:v._id,workspaceName:v.name,workspaceBilling:y(v.billing)}),(0,f.setCurrentProfile)(i),o.succeed(`Logged in to workspace: ${u.Ay.green(v.name)} (profile: ${u.Ay.cyan(i)})`)}catch(e){o.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e,t){return r.apply(this,arguments)})),D.command("login-token").description("Login with a workspace token directly").option("-t, --token <token>","Workspace token").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((o=l(function*(e){var t=e.profile||(0,f.getCurrentProfile)(),a=e.token,i=e.name;a||(console.error(u.Ay.red("Error: Token is required. Use -t or --token to provide it.")),console.log(u.Ay.gray("\nYou can get a workspace token from BRICKS Controller:")+u.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")),console.log(` ${u.Ay.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(u.Ay.gray("Select your workspace and create a new token.\n")),console.log(u.Ay.yellow("Tip: Use `bricks auth login` for a simpler OTP-based login.")),process.exit(1));var n=(0,c.default)("Validating token...").start();try{var r=(0,h.createClient)((0,f.getBaseUrl)(),a),o=yield r.workspace();o||(n.fail("Invalid token or unable to access workspace"),process.exit(1)),(0,f.setToken)(t,{token:a,name:i||o.name,workspaceId:o._id,workspaceName:o.name,workspaceBilling:y(o.billing)}),(0,f.setCurrentProfile)(t),n.succeed(`Logged in to workspace: ${u.Ay.green(o.name)} (profile: ${u.Ay.cyan(t)})`)}catch(e){n.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e){return o.apply(this,arguments)})),D.command("logout").description("Remove saved token").option("-p, --profile <profile>","Profile to remove").option("-a, --all","Remove all profiles").action((s=l(function*(e){var t=e.profile;if(e.all){(0,f.listProfiles)().forEach(e=>(0,f.removeToken)(e.name)),console.log(u.Ay.green("All profiles removed"));return}var a=t||(0,f.getCurrentProfile)();(0,f.getTokenInfo)(a)?((0,f.removeToken)(a),console.log(u.Ay.green(`Logged out from profile: ${a}`))):console.log(u.Ay.yellow(`No token found for profile: ${a}`))}),function(e){return s.apply(this,arguments)})),D.command("status").description("Show current authentication status").option("-j, --json","Output as JSON").action((p=l(function*(e){var t=(0,f.getCurrentProfile)(),a=(0,f.getTokenInfo)(t);if(!a)return e.json?void(0,v.GF)((yield b())):(console.log(u.Ay.yellow("Not logged in")),void console.log(u.Ay.gray("Use `bricks auth login` to login")));if(e.json)return void(0,v.GF)((yield b()));var i=(0,c.default)("Checking connection...").start();try{var n=(0,h.createClient)((0,f.getBaseUrl)(),a.token),r=yield n.workspace();i.stop(),console.log(u.Ay.bold("\nAuthentication Status")),console.log("─".repeat(40)),console.log(`Profile: ${u.Ay.cyan(t)}`),console.log(`Workspace: ${u.Ay.green(r.name)}`),console.log(`Workspace ID: ${u.Ay.gray(r._id)}`);var o=(0,f.getBaseUrl)(),s=a.baseUrl;console.log(`Base URL: ${u.Ay.gray(o)}${s?"":u.Ay.gray(" (global)")}`),console.log(`Logged in: ${u.Ay.gray(a.createdAt)}`),console.log("─".repeat(40))}catch(e){i.fail(`Connection failed: ${e.message}`)}}),function(e){return p.apply(this,arguments)})),D.command("list").description("List all saved profiles").action(()=>{var e=(0,f.listProfiles)();if(0===e.length){console.log(u.Ay.yellow("No saved profiles")),console.log(u.Ay.gray("Use `bricks auth login` to login"));return}console.log(u.Ay.bold("\nSaved Profiles")),console.log("─".repeat(60)),e.forEach(e=>{var t=e.current?u.Ay.green("● "):" ",a=e.current?u.Ay.green(e.name):e.name,i=e.baseUrl?u.Ay.gray(` [${e.baseUrl}]`):"";console.log(`${t}${a.padEnd(15)} ${u.Ay.gray(e.workspaceName||"Unknown")}${i}`)}),console.log("─".repeat(60))}),D.command("use <profile>").description("Switch to a different profile").action(e=>{var t=(0,f.getTokenInfo)(e);if(!t){console.log(u.Ay.red(`Profile not found: ${e}`)),console.log(u.Ay.gray("Use `bricks auth list` to see available profiles"));return}(0,f.setCurrentProfile)(e),console.log(u.Ay.green(`Switched to profile: ${e}`)),t.workspaceName&&console.log(u.Ay.gray(`Workspace: ${t.workspaceName}`))}),D.command("set-url <url>").description("Set the base URL for the current profile").option("-g, --global","Set the global base URL instead of per-profile").action((e,t)=>{if(t.global)(0,f.setBaseUrl)(e),console.log(u.Ay.green(`Global base URL set to: ${e}`));else{var a=(0,f.getCurrentProfile)();(0,f.setBaseUrl)(e,a),console.log(u.Ay.green(`Base URL for profile ${u.Ay.cyan(a)} set to: ${e}`))}})},59845(e,t,a){a.d(t,{Q:()=>I});var i,n,r,o,s,p,l,d,u,c,m,f=a(99436),h=a(35679),v=a(73284),g=a(77598),y=a(48161),b=a(76760),D=a(51455),x=a(27549),w=a(19557),_=8089,E=(i=f(function*(e,t,a=3e3){return(0,w.uE)(`http://${e}:${t}/buttress/info`,a)}),function(e,t){return i.apply(this,arguments)}),F=b.join(y.homedir(),".bricks-cli","buttress"),A=e=>b.join(e||F,"state.json"),C=()=>{try{return`buttress-${x.machineIdSync()}`}catch{return null}},S=(n=f(function*(e){var t=A(e);try{var a=yield D.readFile(t,"utf8");return JSON.parse(a)}catch(e){if("ENOENT"===e.code)return null;throw e}}),function(e){return n.apply(this,arguments)}),T=(r=f(function*(e,t){var a=t||F,i=A(t);yield D.mkdir(a,{recursive:!0});var n=`${i}.tmp-${process.pid}`;return yield D.writeFile(n,JSON.stringify(e,null,2),"utf8"),yield D.rename(n,i),i}),function(e,t){return r.apply(this,arguments)}),k=(o=f(function*(e){var t=A(e);try{return yield D.unlink(t),!0}catch(e){if("ENOENT"===e.code)return!1;throw e}}),function(e){return o.apply(this,arguments)}),N=(s=f(function*({timeout:e=3e3,verify:t=!0,port:a=_,onStatus:i}={}){i?.(`Scanning UDP ${a} for ${e}ms...`);var n,r=yield(({timeout:e=3e3,idleTimeout:t=0,port:a=_}={})=>(0,w.YH)({port:a,timeout:e,idleTimeout:t,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"2.0",d:{id:`cli-${(0,w.BW)()}`}})),parseMessage:(e,t)=>{var a=JSON.parse(e.toString());if("2.0"!==a.v||"ANNOUNCE"!==a.t&&"RESPONSE"!==a.t)return null;var i=a.d?.info;if(!i)return null;var n={...i,address:t.address};return{key:n.id||`${t.address}:${n.port}`,value:n}}}))({timeout:e,port:a});return 0===r.length?[]:t?(i?.(`Verifying ${r.length} server(s)...`),yield Promise.all(r.map((n=f(function*(e){var t=yield E(e.address,e.port,2e3);return t?{...e,...t,address:e.address,verified:!0}:{...e,verified:!1}}),function(e){return n.apply(this,arguments)})))):r}),function(){return s.apply(this,arguments)}),O=(p=f(function*(){var e=yield Promise.resolve().then(a.bind(a,47988)),t=e.getToken,i=e.getBaseUrl,n=e.getCurrentProfile,r=(yield Promise.resolve().then(a.bind(a,85382))).createClient,o=t(n());return o||(console.error(v.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),r(i(),o)}),function(){return p.apply(this,arguments)}),I=new h.uB("buttress").description("Pair and inspect buttress-server bindings for the current workspace").alias("butr");I.command("bind").description("Pair a local buttress-server with the current workspace").option("-s, --server-id <id>","Buttress server id (auto-detected from machine id by default)").option("-n, --name <name>","Friendly name for this buttress server").option("--state-dir <dir>","Override the buttress state directory (defaults to ~/.bricks-cli/buttress)").option("--print","Print state.json to stdout instead of writing to disk (useful for remote setups)").action((l=f(function*(e){var t,i,n,r,o,s,p=(yield Promise.resolve().then(a.bind(a,30155))).default,l=e.serverId||C();l||(console.error(v.Ay.red("Could not detect a local server id. Pass --server-id <id> explicitly.")),process.exit(1));var d=(i=(t=g.generateKeyPairSync("ed25519")).publicKey,n=t.privateKey,r=i.export({type:"spki",format:"der"}),o=n.export({type:"pkcs8",format:"der"}),s=g.createHash("sha256").update(r).digest("hex").slice(0,16),{publicKeySpki:r.toString("base64"),privateKeyPkcs8:o.toString("base64"),kid:s}),u=yield O(),c=p(`Binding buttress server ${v.Ay.cyan(l)}...`).start();try{var m=yield u.bindButtressServer({serverId:l,name:e.name,serverPublicKey:{spkiBase64:d.publicKeySpki,kid:d.kid}});c.stop();var f={workspace:{id:m.workspaceId,name:m.workspaceName,serverId:m.serverId,issuerPublicKey:m.issuerPublicKey.pem,kid:m.issuerPublicKey.kid,boundAt:new Date().toISOString()},serverKeyPair:d};if(e.print){console.warn(v.Ay.yellow("⚠ Output contains the server announce private key. Treat as a secret.")),process.stdout.write(`${JSON.stringify(f,null,2)}
43
+ `);return}var h=yield T(f,e.stateDir);console.log(v.Ay.green("✓"),"Buttress server bound to workspace."),console.log(` Workspace: ${v.Ay.bold(m.workspaceName)} (${m.workspaceId})`),console.log(` Server id: ${v.Ay.cyan(m.serverId)}`),console.log(` Issuer kid: ${v.Ay.gray(m.issuerPublicKey.kid)}`),console.log(` Announce kid: ${v.Ay.gray(d.kid)}`),console.log(` State file: ${v.Ay.gray(h)}`),console.log(),console.log(v.Ay.yellow("Restart buttress-server for the binding to take effect."))}catch(e){c.fail(`Bind failed: ${e.message}`),process.exit(1)}}),function(e){return l.apply(this,arguments)})),I.command("unbind").description("Unbind a buttress server from this workspace").option("-s, --server-id <id>","Buttress server id (auto-detected by default)").option("--state-dir <dir>","Override the buttress state directory").option("--keep-local","Do not remove the local state.json file").action((d=f(function*(e){var t=e.serverId||C();t||(console.error(v.Ay.red("Could not detect a local server id. Pass --server-id explicitly.")),process.exit(1));var a=yield O();try{if((yield a.unbindButtressServer({serverId:t}))?console.log(v.Ay.green("✓"),`Unbound ${v.Ay.cyan(t)} from workspace.`):console.log(v.Ay.yellow("!"),`${v.Ay.cyan(t)} was not bound to this workspace.`),!e.keepLocal){var i=A(e.stateDir),n=yield S(e.stateDir);n?.workspace?.serverId===t&&(yield k(e.stateDir),console.log(v.Ay.gray(`Removed local state file: ${i}`)))}}catch(e){console.error(v.Ay.red(`Unbind failed: ${e.message}`)),process.exit(1)}}),function(e){return d.apply(this,arguments)})),I.command("status").description("Show local buttress binding state and the workspace-side bound list").option("--state-dir <dir>","Override the buttress state directory").option("-j, --json","Output as JSON").action((u=f(function*(e){var t=yield S(e.stateDir),a=null;try{var i=yield O();a=yield i.buttressServers()}catch(e){a={error:e.message}}e.json?console.log(JSON.stringify({local:t,remote:a},null,2)):(console.log(v.Ay.bold("\nLocal buttress state")),console.log("─".repeat(60)),t?.workspace?(console.log(` Workspace: ${v.Ay.bold(t.workspace.name)} (${t.workspace.id})`),console.log(` Server id: ${v.Ay.cyan(t.workspace.serverId)}`),console.log(` Issuer kid: ${v.Ay.gray(t.workspace.kid)}`),console.log(` Bound at: ${v.Ay.gray(t.workspace.boundAt)}`),console.log(` File: ${v.Ay.gray(A(e.stateDir))}`)):console.log(v.Ay.gray(" not bound (no state.json found)")),console.log(v.Ay.bold("\nWorkspace-side bound servers")),console.log("─".repeat(60)),Array.isArray(a)?0===a.length?console.log(v.Ay.gray(" none")):a.forEach(e=>{console.log(` ${v.Ay.cyan(e.serverId)} ${v.Ay.gray(e.name||"")} ${v.Ay.gray(e.boundAt||"")}`)}):a?.error&&console.log(v.Ay.red(` failed to fetch: ${a.error}`)))}),function(e){return u.apply(this,arguments)})),I.command("issue-token").description("Issue a long-lived workspace-scoped buttress access token (CLI/CTOR usage)").option("--ttl <seconds>","Time-to-live in seconds (default 30 days)",e=>parseInt(e,10)).option("-j, --json","Output as JSON").action((c=f(function*(e){var t=yield O();try{var a=yield t.issueButtressAccessToken({ttlSeconds:e.ttl});if(e.json)return void console.log(JSON.stringify(a,null,2));console.log(v.Ay.green("✓"),"Buttress access token issued."),console.log(` Workspace: ${a.workspaceId}`),console.log(` Expires: ${a.expiresAt}`),console.log(` jti: ${v.Ay.gray(a.jti)}`),console.log(),console.log(v.Ay.cyan(a.token))}catch(e){console.error(v.Ay.red(`Issue token failed: ${e.message}`)),process.exit(1)}}),function(e){return c.apply(this,arguments)})),I.command("scan").description("Scan LAN for buttress-servers via UDP and verify each via /buttress/info").option("-t, --timeout <ms>","Scan timeout in milliseconds","3000").option("-p, --port <port>","UDP discovery port",String(_)).option("--udp-only","Skip HTTP /buttress/info verification").option("-j, --json","Output as JSON").action((m=f(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=parseInt(e.port,10),p=[],l=t(`Scanning for buttress-servers (${o}ms)...`).start();try{p=yield N({timeout:o,port:s,verify:!e.udpOnly,onStatus:e=>{l.text=e}}),l.stop()}catch(e){l.fail(`Scan failed: ${e.message}`),process.exit(1)}var d=n(),u=r(d)?.workspaceId||null;if(e.json)return void console.log(JSON.stringify({servers:p,workspaceId:u},null,2));if(0===p.length)return void console.log(v.Ay.yellow("No buttress-servers found on the LAN."));for(var c of(console.log(v.Ay.bold(`
44
44
  Found ${p.length} buttress-server(s)`)),console.log("─".repeat(70)),p)){var m=!1===c.verified?v.Ay.red("unverified"):v.Ay.green("online"),f=c.workspace?.id,h=f&&u&&f===u,g=c.authentication?.bound?v.Ay.yellow("JWT required"):v.Ay.gray("open");console.log(` ${v.Ay.bold(c.name||"Unknown")} ${v.Ay.gray(`(${c.address}:${c.port})`)} [${m}]`),c.id&&console.log(` Server id: ${v.Ay.cyan(c.id)}`),c.version&&console.log(` Version: ${v.Ay.green(c.version)}`);var y=c.authentication?.kid?v.Ay.gray(` (kid: ${c.authentication.kid})`):"";if(console.log(` Auth: ${g}${y}`),f){var b=h?v.Ay.green(`${f} ${v.Ay.bold("(current profile)")}`):v.Ay.gray(f);console.log(` Workspace: ${b}`)}if(Array.isArray(c.generators)&&c.generators.length>0)for(var D of(console.log(" Generators:"),c.generators)){var x=[];"number"==typeof D.score&&x.push(`score ${D.score.toFixed(1)}`),!0===D.hasGpu?x.push("GPU ✓"):!1===D.hasGpu&&x.push("GPU ✗"),"number"==typeof D.usableBytes&&x.push(`${(D.usableBytes/0x40000000).toFixed(1)} GB usable`);var w=x.length>0?` ${v.Ay.gray(x.join(" "))}`:"";console.log(` - ${v.Ay.cyan(D.type)}${w}`)}}console.log("─".repeat(70)),p.some(e=>e.authentication?.bound)&&(console.log(),console.log(v.Ay.gray("To connect to a bound server, run `bricks buttress issue-token` for a workspace access token.")))}),function(e){return m.apply(this,arguments)}))},71335(e,t,a){a.d(t,{oT:()=>d});var i=a(35679),n=a(73284),r=a(47988),o={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},s=e=>{var t=Object.entries(o).find(([,t])=>e===t);return t?t[0]:null},p={prod:"https://activity-log.bricks.tools",beta:"https://activity-log-beta.bricks.tools",dev:"http://localhost:8088"},l=e=>{var t=Object.entries(p).find(([,t])=>e===t);return t?t[0]:null},d=new i.uB("config").description("CLI configuration management");d.command("endpoint").argument("[environment]","Environment to use (prod, beta, dev)").description("Show or set endpoint environment").option("-p, --profile","Set for current profile instead of global").action((e,t)=>{if(!e){var a=(0,r.getBaseUrl)(),i=s(a),d=(0,r.getActivityLogBaseUrl)(),u=l(d);console.log(n.Ay.bold("\nEndpoint Configuration")),console.log("─".repeat(50)),console.log(n.Ay.bold("BRICKS")),console.log(` URL: ${n.Ay.cyan(a)}`),console.log(` Environment: ${i?n.Ay.green(i):n.Ay.yellow("custom")}`),console.log(n.Ay.bold("Activity Log")),console.log(` URL: ${n.Ay.cyan(d)}`),console.log(` Environment: ${u?n.Ay.green(u):n.Ay.yellow("custom")}`),console.log("─".repeat(50)),console.log(n.Ay.gray("\nUsage: bricks config endpoint <prod|beta|dev>"));return}var c=Object.keys(o);c.includes(e)||(console.error(n.Ay.red(`Invalid environment: ${e}`)),console.log(n.Ay.gray(`Valid options: ${c.join(", ")}`)),process.exit(1));var m=o[e],f=p[e],h=t.profile?(0,r.getCurrentProfile)():null;(0,r.setBaseUrl)(m,h),(0,r.setActivityLogBaseUrl)(f,h);var v=t.profile?` (profile: ${(0,r.getCurrentProfile)()})`:"";console.log(n.Ay.green(`✓ Endpoint changed to ${e}${v}`)),console.log(n.Ay.gray(` BRICKS: ${m}`)),console.log(n.Ay.gray(` Activity Log: ${f}`)),console.log(n.Ay.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(n.Ay.gray("Use `bricks auth status` to check your connection."))}),d.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(e=>{var t=(0,r.getBaseUrl)(),a=s(t);if(e.json)return void console.log(JSON.stringify({endpoint:t,environment:a||"custom"},null,2));console.log(n.Ay.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`BRICKS: ${n.Ay.cyan(t)}`),a?console.log(`Environment: ${n.Ay.green(a)}`):console.log(`Environment: ${n.Ay.yellow("custom")}`);var i=(0,r.getActivityLogBaseUrl)(),o=l(i);console.log(`Activity Log: ${n.Ay.cyan(i)} ${o?n.Ay.green(`(${o})`):n.Ay.yellow("(custom)")}`),console.log("─".repeat(50))})},23699(e,t,a){a.d(t,{E:()=>W});var i,n,r,o,s,p,l,d,u,c,m,f,h,v,g,y,b,D=a(68832),x=a(99436),w=a(79896),_=a(35679),E=a(73284),F=a(30155),A=a(88958),C=a(7586),S=a(56493),T=a(8479),k=a(47988),N=a(85382),O=["InSubspace","Global"],I={"https://display.bricks.tools":"https://bank.bricks.tools","https://display-beta.bricks.tools":"https://bank-beta.bricks.tools"},$=e=>{if(e&&!O.includes(e))throw Error(`Invalid meta "${e}" (expected ${O.join(" | ")})`)},j=`
45
45
  propertyId
46
46
  meta
@@ -89,7 +89,7 @@ ${E.Ay.bold("Definition")}`),console.log(JSON.stringify(r.definition,null,2)),co
89
89
  Device: ${n.name||n.device_name}`)),console.log("─".repeat(60)),console.log(`Status: ${o}`),console.log(`ID: ${b.Ay.gray(n._id)}`),console.log(`Device Name: ${n.device_name||b.Ay.gray("N/A")}`),console.log(`Description: ${n.description||b.Ay.gray("N/A")}`),console.log(`Tags: ${n.tags?.join(", ")||b.Ay.gray("None")}`),console.log(`Created: ${b.Ay.gray(n.create_datetime||"N/A")}`),console.log(`Modified: ${b.Ay.gray(n.last_modify_datetime||"N/A")}`),n.entry_detail){var s=n.entry_detail;if(console.log(`
90
90
  ${b.Ay.bold("Entry Details")}`),console.log(`Type: ${s.type||b.Ay.gray("N/A")}`),console.log(`Unique ID: ${b.Ay.gray(s.unique_id||"N/A")}`),console.log(`Version: ${s.operation_version||b.Ay.gray("N/A")}`),console.log(`Mode: ${s.operation_mode||b.Ay.gray("N/A")}`),Array.isArray(s.screen)&&s.screen.length>0)console.log(`
91
91
  ${b.Ay.bold("Screens")} (${s.screen.length})`),s.screen.forEach((e,t)=>{var a=e.resolution,i=a?`${a.width}x${a.height} @${a.scale}x`:"N/A",n=e.master?b.Ay.green(" (master)"):"",r=e.orientation?` [${e.orientation}]`:"",o=e.touch?.available?b.Ay.cyan(` touch:${e.touch.touch_point}pt`):"";console.log(` ${t+1}. ${e.title||"Screen"}${n}${r} - ${i}${o}`)});else if(s.screen?.resolution){var p=s.screen.resolution;console.log(`Resolution: ${p.width}x${p.height} @${p.scale}x`)}var l=null!=s.memory_usage,d=null!=s.disk_usage;if(l||d){if(console.log(`
92
- ${b.Ay.bold("System Resources")}`),l){var u=Array.isArray(s.memory_usage)?s.memory_usage[0]:s.memory_usage,c=Math.round(100*u),m=b.Ay.green;c>80?m=b.Ay.red:c>60&&(m=b.Ay.yellow),console.log(`Memory: ${m(`${c}%`)}`)}if(d){var f=Array.isArray(s.disk_usage)?s.disk_usage[0]:s.disk_usage,h=Math.round(100*f),v=b.Ay.green;h>90?v=b.Ay.red:h>75&&(v=b.Ay.yellow),console.log(`Disk: ${v(`${h}%`)}`)}}var g=[];if(s.sound?.available&&g.push("Sound"),s.camera?.available&&g.push("Camera"),s.audio_in?.available&&g.push("Audio Input"),g.length>0&&(console.log(`
92
+ ${b.Ay.bold("System Resources")}`),l){var u=Array.isArray(s.memory_usage)?s.memory_usage[0]:s.memory_usage;if(Number.isFinite(u)){var c=Math.round(100*u),m=b.Ay.green;c>80?m=b.Ay.red:c>60&&(m=b.Ay.yellow),console.log(`Memory: ${m(`${c}%`)}`)}else console.log(`Memory: ${b.Ay.gray("N/A")}`)}if(d){var f=Array.isArray(s.disk_usage)?s.disk_usage[0]:s.disk_usage;if(Number.isFinite(f)){var h=Math.round(100*f),v=b.Ay.green;h>90?v=b.Ay.red:h>75&&(v=b.Ay.yellow),console.log(`Disk: ${v(`${h}%`)}`)}else console.log(`Disk: ${b.Ay.gray("N/A")}`)}}var g=[];if(s.sound?.available&&g.push("Sound"),s.camera?.available&&g.push("Camera"),s.audio_in?.available&&g.push("Audio Input"),g.length>0&&(console.log(`
93
93
  ${b.Ay.bold("Capabilities")}`),console.log(`Available: ${g.join(", ")}`),s.camera?.channel?.length>0&&s.camera.channel.forEach(e=>{var t=e.resolution?`${e.resolution.width}x${e.resolution.height}`:"";console.log(` Camera: ${e.title||"Camera"} ${t} [${e.orientation||"N/A"}]`)})),s.local_sync){var y=s.local_sync;console.log(`
94
94
  ${b.Ay.bold("Local Sync")}`),console.log(`Role: ${y.is_main?b.Ay.cyan("Main"):"Secondary"}`),null!=y.peer_count&&console.log(`Peers: ${y.peer_count}`),null!=y.mean_latency&&console.log(`Latency: ${y.mean_latency.toFixed(2)}ms`)}if(s.update){var x=s.update;console.log(`
95
95
  ${b.Ay.bold("Update Status")}`),console.log(`Needs Update: ${x.need_update?b.Ay.yellow("Yes"):b.Ay.green("No")}`),x.current_version&&console.log(`App Version: ${x.current_version}`),x.running_mode&&console.log(`Running Mode: ${x.running_mode}`),x.last_update_at&&console.log(`Last Update: ${b.Ay.gray(x.last_update_at)}`)}if(s.watch_dog_timer){var w=s.watch_dog_timer;console.log(`
@@ -103,7 +103,7 @@ ${b.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(b.Ay.red(`Error: $
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=[])=>{var t=new Map,a=new Map,i=new Set;for(var n of e||[])if(n&&"object"==typeof n){var r=n.shortId,o=n.uuid;r&&i.add(r),o&&(i.add(o),t.set(o,n),a.set(o,o),r&&a.set(r,o))}return{byUuid:t,uuidByScope:a,knownScopes:i}},ev=(e=[])=>e?.byUuid&&e?.uuidByScope&&e?.knownScopes?e:eh(e),eg=(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)}),ey=(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)}…`},eb=(e,t)=>{var a=ev(t),i=e.subspaceUuid?a.byUuid.get(e.subspaceUuid):null;return{key:e.rawKey,scope:e.scope,...e.subspaceUuid?{subspaceUuid:e.subspaceUuid}:{},...i?.shortId?{subspaceShortId:i.shortId}:{},name:e.name,value:e.value}},eD=(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)}: ${ey(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)}),ex=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"),ew=Z.command("storage").description("Storage inspection (read-only — CDP cannot mutate device storage)");ee(ew.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 e_=ew.command("system").description("System key-value storage"),eE=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"),eF=(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 eg(i),o=eh(r),s=((e,{scope:t,prefix:a,subspaceIndex:i=[]}={})=>{var n=ev(i),r=t&&"global"!==t?n.uuidByScope.get(t)||t:null;return e.map(([e,t])=>({rawKey:e,value:t,...ef(e)})).filter(e=>("global"!==t||"global"===e.scope)&&(!r||"subspace"===e.scope&&e.subspaceUuid===r)&&(!a||!!e.name.startsWith(a)))})(n,{scope:a.scope,prefix:a.prefix,subspaceIndex:o});if(a.json)return void console.log(JSON.stringify(s.map(e=>eb(e,o)),null,2));if(((e,{label:t,subspaceIndex:a,full:i})=>{var n=ev(a);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 r=null;for(var o of e){var s="subspace"===o.scope?`subspace:${o.subspaceUuid}`:o.scope;if(s!==r)if(r=s,"subspace"===o.scope){var p=n.byUuid.get(o.subspaceUuid),l=p?`${p.shortId}${p.title?` "${p.title}"`:""} `:"";console.log(` ${R.Ay.bold(`subspace ${l}`)}${R.Ay.gray(`(${o.subspaceUuid})`)}`)}else console.log(` ${R.Ay.bold(o.scope||"other")}`);var d=o.name||o.rawKey;console.log(` ${R.Ay.cyan(d)}: ${ey(o.value,{full:i,width:80})}`)}})(s,{label:t,subspaceIndex:o,full:!!a.full}),0===s.length&&a.scope&&"global"!==a.scope&&!o.knownScopes.has(a.scope)){var p=r.map(e=>e.shortId).join(", ");console.log(R.Ay.yellow(` Scope "${a.scope}" did not match a known subspace${p?` (known: ${p})`:""}`))}}),function(e){return i.apply(this,arguments)}))}),function(e){return a.apply(this,arguments)}};eE(ee(e_.command("persist").description("Show persistent system storage entries"))).action(eF(!0,"Persistent Storage")),eE(ee(e_.command("memory").description("Show in-memory system storage entries"))).action(eF(!1,"Memory Storage")),ee(e_.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=eh((yield eg(a))),r=[e];if("global"===t.scope)r.push(`global:${e}`);else{var o=n.uuidByScope.get(t.scope)||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(eb(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 eA=ew.command("data-bank").description("Data bank (Property Bank) stores");ee(eA.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)})),ex(ee(eA.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 eD(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 eC=ew.command("cache").description("Cache stores (generator, generative-media)"),eS=e=>{var t;return t=j(function*(t){var a;yield et(t,(a=j(function*(a){yield a.send("IndexedDB.enable"),yield eD(a,{databaseName:e,objectStoreName:eu,options:t})}),function(e){return a.apply(this,arguments)}))}),function(e){return t.apply(this,arguments)}};ex(ee(eC.command("generator").description("Show generator cache entries"))).action(eS("GENERATOR_CACHE")),ex(ee(eC.command("generative-media").description("Show generative media cache entries"))).action(eS("GENERATIVE_MEDIA_CACHE")),ex(ee(ew.command("generator-cache",{hidden:!0}).description("Alias of `storage cache generator`"))).action(eS("GENERATOR_CACHE"));var eT=Z.command("runtime").description("Runtime and evaluation");ee(eT.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(eT.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 ek=Z.command("simulator").description("Inspect simulated peripherals (Application Simulator / web preview servers only)").command("thermal-printer").description("Simulated thermal printers and their print results"),eN="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.",eO=e=>{if(!e)return"unknown time";var t=new Date(e);return Number.isNaN(t.getTime())?"unknown time":t.toLocaleString()},eI=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(ek.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(eN)),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} ${eO(p.printedAt)} ${R.Ay.gray(eI(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(ek.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(eN)),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: ${eO(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.51",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)=>(0,y.H_)(e,t,{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=[])=>{var t=new Map,a=new Map,i=new Set;for(var n of e||[])if(n&&"object"==typeof n){var r=n.shortId,o=n.uuid;r&&i.add(r),o&&(i.add(o),t.set(o,n),a.set(o,o),r&&a.set(r,o))}return{byUuid:t,uuidByScope:a,knownScopes:i}},ev=(e=[])=>e?.byUuid&&e?.uuidByScope&&e?.knownScopes?e:eh(e),eg=(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)}),ey=(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)}…`},eb=(e,t)=>{var a=ev(t),i=e.subspaceUuid?a.byUuid.get(e.subspaceUuid):null;return{key:e.rawKey,scope:e.scope,...e.subspaceUuid?{subspaceUuid:e.subspaceUuid}:{},...i?.shortId?{subspaceShortId:i.shortId}:{},name:e.name,value:e.value}},eD=(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)}: ${ey(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)}),ex=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"),ew=Z.command("storage").description("Storage inspection (read-only — CDP cannot mutate device storage)");ee(ew.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 e_=ew.command("system").description("System key-value storage"),eE=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"),eF=(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 eg(i),o=eh(r),s=((e,{scope:t,prefix:a,subspaceIndex:i=[]}={})=>{var n=ev(i),r=t&&"global"!==t?n.uuidByScope.get(t)||t:null;return e.map(([e,t])=>({rawKey:e,value:t,...ef(e)})).filter(e=>("global"!==t||"global"===e.scope)&&(!r||"subspace"===e.scope&&e.subspaceUuid===r)&&(!a||!!e.name.startsWith(a)))})(n,{scope:a.scope,prefix:a.prefix,subspaceIndex:o});if(a.json)return void console.log(JSON.stringify(s.map(e=>eb(e,o)),null,2));if(((e,{label:t,subspaceIndex:a,full:i})=>{var n=ev(a);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 r=null;for(var o of e){var s="subspace"===o.scope?`subspace:${o.subspaceUuid}`:o.scope;if(s!==r)if(r=s,"subspace"===o.scope){var p=n.byUuid.get(o.subspaceUuid),l=p?`${p.shortId}${p.title?` "${p.title}"`:""} `:"";console.log(` ${R.Ay.bold(`subspace ${l}`)}${R.Ay.gray(`(${o.subspaceUuid})`)}`)}else console.log(` ${R.Ay.bold(o.scope||"other")}`);var d=o.name||o.rawKey;console.log(` ${R.Ay.cyan(d)}: ${ey(o.value,{full:i,width:80})}`)}})(s,{label:t,subspaceIndex:o,full:!!a.full}),0===s.length&&a.scope&&"global"!==a.scope&&!o.knownScopes.has(a.scope)){var p=r.map(e=>e.shortId).join(", ");console.log(R.Ay.yellow(` Scope "${a.scope}" did not match a known subspace${p?` (known: ${p})`:""}`))}}),function(e){return i.apply(this,arguments)}))}),function(e){return a.apply(this,arguments)}};eE(ee(e_.command("persist").description("Show persistent system storage entries"))).action(eF(!0,"Persistent Storage")),eE(ee(e_.command("memory").description("Show in-memory system storage entries"))).action(eF(!1,"Memory Storage")),ee(e_.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=eh((yield eg(a))),r=[e];if("global"===t.scope)r.push(`global:${e}`);else{var o=n.uuidByScope.get(t.scope)||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(eb(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 eA=ew.command("data-bank").description("Data bank (Property Bank) stores");ee(eA.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)})),ex(ee(eA.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 eD(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 eC=ew.command("cache").description("Cache stores (generator, generative-media)"),eS=e=>{var t;return t=j(function*(t){var a;yield et(t,(a=j(function*(a){yield a.send("IndexedDB.enable"),yield eD(a,{databaseName:e,objectStoreName:eu,options:t})}),function(e){return a.apply(this,arguments)}))}),function(e){return t.apply(this,arguments)}};ex(ee(eC.command("generator").description("Show generator cache entries"))).action(eS("GENERATOR_CACHE")),ex(ee(eC.command("generative-media").description("Show generative media cache entries"))).action(eS("GENERATIVE_MEDIA_CACHE")),ex(ee(ew.command("generator-cache",{hidden:!0}).description("Alias of `storage cache generator`"))).action(eS("GENERATOR_CACHE"));var eT=Z.command("runtime").description("Runtime and evaluation");ee(eT.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(eT.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 ek=Z.command("simulator").description("Inspect simulated peripherals (Application Simulator / web preview servers only)").command("thermal-printer").description("Simulated thermal printers and their print results"),eN="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.",eO=e=>{if(!e)return"unknown time";var t=new Date(e);return Number.isNaN(t.getTime())?"unknown time":t.toLocaleString()},eI=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(ek.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(eN)),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} ${eO(p.printedAt)} ${R.Ay.gray(eI(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(ek.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(eN)),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: ${eO(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.53",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)=>(0,y.H_)(e,t,{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
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,dispatched:o?.dispatched||0,devices:o?.devices||0},json:!0}):(n.succeed(`Action dispatched: ${m.Ay.green(t)}`),o&&(console.log(`Dispatched: ${m.Ay.green(o.dispatched||0)}`),console.log(`Devices: ${m.Ay.gray(o.devices||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:{dispatched:r?.dispatched||0,devices:r?.devices||0},json:!0}):(i.succeed("Devices refreshed"),r&&(console.log(`Dispatched: ${m.Ay.green(r.dispatched||0)}`),console.log(`Devices: ${m.Ay.gray(r.devices||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.
@@ -122,7 +122,7 @@ ${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(456).then(a.bind(a,58891))).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.51",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.51")?"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(456).then(a.bind(a,58891))).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.53",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.53")?"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
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=`
@@ -1014,8 +1014,8 @@ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,argume
1014
1014
  lastSeenAt
1015
1015
  }
1016
1016
  }
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.51","-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
- ${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:()=>l,httpProbeSubnet:()=>d,verifyDevToolsServer:()=>u});var i,n,r=a(99436),o=a(41314),s=a(19557),p="bricks-devtools",l=({timeout:e=3e3,idleTimeout:t=0}={})=>new Promise((a,i)=>{var n=new Map,r=o.createSocket("udp4"),l=null,d=null,u=!1,c=()=>{if(!u){u=!0,clearTimeout(l),clearTimeout(d);try{r.close()}catch{}a([...n.values()])}};r.on("error",e=>{if(!u){u=!0,clearTimeout(l),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-${(0,s.BW)()}`}}));for(var a of(0,s.a2)())r.send(t,0,t.length,19900,a);l=setTimeout(c,e)})}),d=(i=r(function*({port:e=19851,connectTimeout:t=500,concurrency:a=50,timeout:i=0}={}){var n=(0,s.r9)();if(0===n.length)return[];var o=[],p=i>0?Date.now()+i:0,l=[],d=new Set;for(var c of n){var m=c.address.split(".").slice(0,3).join(".");if(!d.has(m)){d.add(m);for(var f=1;f<255;f++)l.push(`${m}.${f}`)}}for(var h=0;h<l.length&&!(p&&Date.now()>=p);h+=a){var v=l.slice(h,h+a);yield Promise.allSettled(v.map(function(){var a=r(function*(a){var i=yield u(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)}),u=(n=r(function*(e,t,a=3e3){return(0,s.uE)(`http://${e}:${t}/devtools/info`,a)}),function(e,t){return n.apply(this,arguments)})},19557(e,t,a){a.d(t,{BW:()=>o,a2:()=>p,r9:()=>s,uE:()=>l});var i,n=a(99436),r=a(48161),o=()=>Math.random().toString(36).slice(2,9),s=()=>{var e=[];for(var t of Object.values(r.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},p=()=>{var e=new Set(["255.255.255.255","127.0.0.1"]);for(var t of s())e.add(t.broadcast);return[...e]},l=(i=n(function*(e,t=3e3){var a;try{var i=new AbortController;a=setTimeout(()=>i.abort(),t);var n=yield fetch(e,{signal:i.signal});if(!n.ok)return null;return yield n.json()}catch{return null}finally{void 0!==a&&clearTimeout(a)}}),function(e){return i.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}
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.53","-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
+ ${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:()=>p,httpProbeSubnet:()=>l,verifyDevToolsServer:()=>d});var i,n,r=a(99436),o=a(19557),s="bricks-devtools",p=({timeout:e=3e3,idleTimeout:t=0}={})=>(0,o.YH)({port:19900,timeout:e,idleTimeout:t,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:s,d:{id:`cli-${(0,o.BW)()}`}})),parseMessage:(e,t)=>{var a=JSON.parse(e.toString());if(a.s!==s||"ANNOUNCE"!==a.t&&"RESPONSE"!==a.t)return null;var i=a.d?.info;if(!i)return null;var n=t.address;return{key:`${n}:${i.port}`,value:{...i,address:n}}}}),l=(i=r(function*({port:e=19851,connectTimeout:t=500,concurrency:a=50,timeout:i=0}={}){var n=(0,o.r9)();if(0===n.length)return[];var s=[],p=i>0?Date.now()+i:0,l=[],u=new Set;for(var c of n){var m=c.address.split(".").slice(0,3).join(".");if(!u.has(m)){u.add(m);for(var f=1;f<255;f++)l.push(`${m}.${f}`)}}for(var h=0;h<l.length&&!(p&&Date.now()>=p);h+=a){var v=l.slice(h,h+a);yield Promise.allSettled(v.map(function(){var a=r(function*(a){var i=yield d(a,e,t);i&&s.push({...i,address:a,port:e})});return function(e){return a.apply(this,arguments)}}()))}return s}),function(){return i.apply(this,arguments)}),d=(n=r(function*(e,t,a=3e3){return(0,o.uE)(`http://${e}:${t}/devtools/info`,a)}),function(e,t){return n.apply(this,arguments)})},19557(e,t,a){a.d(t,{BW:()=>s,YH:()=>l,r9:()=>p,uE:()=>d});var i,n=a(99436),r=a(41314),o=a(48161),s=()=>Math.random().toString(36).slice(2,9),p=()=>{var e=[];for(var t of Object.values(o.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},l=({port:e,timeout:t=3e3,idleTimeout:a=0,buildQuery:i,parseMessage:n})=>new Promise((o,s)=>{var l=new Map,d=r.createSocket("udp4"),u=null,c=null,m=!1,f=()=>{if(!m){m=!0,clearTimeout(u),clearTimeout(c);try{d.close()}catch{}o([...l.values()])}};d.on("error",e=>{if(!m){m=!0,clearTimeout(u),clearTimeout(c);try{d.close()}catch{}s(e)}}),d.on("message",(e,t)=>{try{var i=n(e,t);if(!i||l.has(i.key))return;l.set(i.key,i.value),a&&!m&&(clearTimeout(c),c=setTimeout(f,a))}catch{}}),d.bind(()=>{d.setBroadcast(!0);var a=i();for(var n of(()=>{var e=new Set(["255.255.255.255","127.0.0.1"]);for(var t of p())e.add(t.broadcast);return[...e]})())d.send(a,0,a.length,e,n);u=setTimeout(f,t)})}),d=(i=n(function*(e,t=3e3){var a;try{var i=new AbortController;a=setTimeout(()=>i.abort(),t);var n=yield fetch(e,{signal:i.signal});if(!n.ok)return null;return yield n.json()}catch{return null}finally{void 0!==a&&clearTimeout(a)}}),function(e){return i.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
1019
 
1020
1020
  ${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,{H_:()=>o,Iy:()=>r,S5:()=>p,yd:()=>l});var i=a(73284),n=a(7586),r=(e,t,a)=>({label:e,ok:t,detail:a}),o=(e,t,{id:a,name:i,...n}={})=>({id:e?._id||t,name:i||e?.name||"Unnamed",...n}),s=e=>null==e?i.Ay.gray("N/A"):"object"==typeof e?i.Ay.gray(JSON.stringify(e,null,2)):String(e),p=({action:e,target:t,request:a,checks:r=[],json:o=!1})=>{o?(0,n.GF)({ok:!0,dryRun:!0,action:e,target:t||null,request:a||null,checks:r}):(console.log(i.Ay.bold(`
1021
1021
  Dry Run: ${e}`)),console.log("─".repeat(60)),t&&(console.log(i.Ay.bold("Target")),Object.entries(t).forEach(([e,t])=>{console.log(`${e}: ${s(t)}`)})),a&&(console.log(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugood/bricks-cli",
3
- "version": "2.25.0-beta.51",
3
+ "version": "2.25.0-beta.53",
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": "9a6ddecabc4a2e11fc6ae9a256de730cd3d744ca"
73
+ "gitHead": "b08f881540787ad817115880ebcee1487a0a81ab"
74
74
  }