@fugood/bricks-cli 2.25.0-beta.77 → 2.25.0-beta.79

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
@@ -17,18 +17,18 @@ Expecting one of '${t.join("', '")}'`);let p=`${e}Help`;return this.on(p,e=>{let
17
17
  (Did you mean one of ${p.join(", ")}?)`:1===p.length?`
18
18
  (Did you mean ${p[0]}?)`:""}},98247(e,a,t){t.d(a,{v:()=>S});var p,o,i,d,r,n,l,s=t(99436),u=t(35679),m=t(73284),c=t(47988),f=t(31802),h=t(94979),v=t(16928),g=t(79896);function D(e){function a(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var a=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:a}})}return(D=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return a(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):a(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):a(t.apply(this.s,arguments))}},new D(e)}var y=(p=s(function*(){return(yield Promise.resolve().then(t.bind(t,30155))).default}),function(){return p.apply(this,arguments)}),w=(o=s(function*(){return t.e(9583).then(t.bind(t,92642))}),function(){return o.apply(this,arguments)}),b=(i=s(function*(e){return(yield y())(e).start()}),function(e){return i.apply(this,arguments)}),_=(d=s(function*(){var e=(0,c.getCurrentProfile)(),a=(0,f.getConnectionContext)(e),t=a.auth;return t||(console.error(m.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),{client:(0,(yield w()).createActivityLogClient)(a.activityLogBaseUrl,t),workspaceId:a.tokenInfo?.workspaceId}}),function(){return d.apply(this,arguments)}),C=e=>new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z"),F=(e,a)=>{if(!e)return"";var t="string"==typeof e?e:JSON.stringify(e);return t.length>a?t.slice(0,a-1)+"…":t},S=new u.uB("activity-log").alias("al").description("Activity log queries (read-only)");S.command("events").description("Query activity log events (all types)").requiredOption("--start-time <datetime>","Start time (ISO 8601 or relative: 1h, 30m, 2d)").option("--end-time <datetime>","End time (default: now)").option("--device <id>","Filter by device ID").option("--type <type>","Filter by event type: general, data, local_sync").option("--event-name <name>","Filter by event name").option("--subspace <id>","Filter by subspace ID").option("--sender <id>","Filter by sender").option("--limit <n>","Max events to display",parseInt).option("-j, --json","Output as JSON array").option("--jsonl","Output as JSONL (one JSON per line)").action((r=s(function*(e){var a=(yield _()).client,t=(d=(0,h.p)(e.startTime),new Date(r=e.endTime?(0,h.p)(e.endTime):new Date().toISOString())-new Date(d)>2592e6&&(console.error(m.default.red("Time range must be 30 days or less")),process.exit(1)),n={start_time:d,end_time:r},e.device&&(n.device_id=e.device),e.type&&(n.event_type=e.type),e.eventName&&(n.event_name=e.eventName),e.subspace&&(n.subspace_id=e.subspace),e.sender&&(n.sender=e.sender),n);if(e.jsonl){var p=0;try{var o=!1,i=!1;try{for(var d,r,n,l,s,u=function(e){var a,t,p,o=2;for("u">typeof Symbol&&(t=Symbol.asyncIterator,p=Symbol.iterator);o--;){if(t&&null!=(a=e[t]))return a.call(e);if(p&&null!=(a=e[p]))return new D(a.call(e));t="@@asyncIterator",p="@@iterator"}throw TypeError("Object is not async iterable")}(a.events(t));o=!(s=yield u.next()).done;o=!1){var c=s.value;if(console.log(JSON.stringify(c)),p++,e.limit&&p>=e.limit)break}}catch(e){i=!0,l=e}finally{try{o&&null!=u.return&&(yield u.return())}finally{if(i)throw l}}}catch(e){console.error(m.default.red(`Failed to query events: ${e.message}`)),process.exit(1)}return}var f=yield b("Querying events...");try{var v=yield a.collectEvents(t,{limit:e.limit});if(f.stop(),e.json)return void console.log(JSON.stringify(v,null,2));if(0===v.length)return void console.log(m.default.yellow("No events found"));for(var g of(console.log(m.default.bold(`
19
19
  Activity Log Events (${v.length})`)),console.log("─".repeat(100)),console.log(m.default.gray(`${"Timestamp".padEnd(24)} ${"Type".padEnd(12)} ${"Device".padEnd(14)} ${"Event Name".padEnd(28)} ${"Sender".padEnd(16)} Payload`)),console.log("─".repeat(100)),v)){var y=C(g.timestamp),w=(g.event_type||"").padEnd(12),S=F(g.device_id,14).padEnd(14),E=F(g.event_name,28).padEnd(28),k=F(g.sender,16).padEnd(16),A=F(g.payload,40);console.log(`${y} ${w} ${S} ${E} ${k} ${m.default.gray(A)}`)}console.log("─".repeat(100))}catch(e){f.fail(`Failed to query events: ${e.message}`),process.exit(1)}}),function(e){return r.apply(this,arguments)})),S.command("screenshots").description("List screenshot timestamps for a device").requiredOption("--device <id>","Device ID (required)").requiredOption("--start-time <datetime>","Start time (ISO 8601 or relative: 1h, 30m, 2d)").option("--end-time <datetime>","End time (default: now)").option("-j, --json","Output as JSON").action((n=s(function*(e){var a=(yield _()).client,t=(0,h.p)(e.startTime),p=e.endTime?(0,h.p)(e.endTime):new Date().toISOString();new Date(p)-new Date(t)>2592e6&&(console.error(m.default.red("Time range must be 30 days or less")),process.exit(1));var o={device_id:e.device,start_time:t,end_time:p},i=yield b("Querying screenshots...");try{var d=yield a.collectScreenshots(o);if(i.stop(),e.json)return void console.log(JSON.stringify(d,null,2));if(0===d.length)return void console.log(m.default.yellow("No screenshots found"));console.log(m.default.bold(`
20
- Screenshots (${d.length})`)),console.log("─".repeat(56)),console.log(m.default.gray(`${"#".padStart(4)} ${"Timestamp".padEnd(24)} --ts value`)),console.log("─".repeat(56)),d.forEach((e,a)=>{var t=new Date(e.timestamp).getTime();console.log(`${String(a+1).padStart(4)} ${C(e.timestamp).padEnd(24)} ${t}`)}),console.log("─".repeat(56))}catch(e){i.fail(`Failed to query screenshots: ${e.message}`),process.exit(1)}}),function(e){return n.apply(this,arguments)})),S.command("screenshot").description("Download a screenshot image").requiredOption("--device <id>","Device ID").requiredOption("--ts <timestamp>","Screenshot timestamp (ISO 8601 or epoch ms)").option("--space <id>","Workspace/space ID (auto-detected from profile)").option("-o, --output <path>","Output file path").option("--open","Open with OS default viewer after download").action((l=s(function*(e){var a=yield _(),p=a.client,o=a.workspaceId,i=e.space||o;i||(console.error(m.default.red("Could not determine workspace ID. Use --space <id> or log in first.")),process.exit(1));var d=/^\d+$/.test(e.ts)?e.ts:new Date(e.ts).getTime(),r=yield b("Downloading screenshot...");try{var n=yield p.downloadScreenshot(i,e.device,d);r.stop();var l=e.output||`screenshot-${e.device}-${d}.jpg`,s=v.resolve(l);g.writeFileSync(s,n);var u=(n.length/1024).toFixed(1);if(console.log(m.default.green(`✓ Screenshot saved: ${s} (${u} KB)`)),e.open){var c=(yield Promise.resolve().then(t.t.bind(t,35317,19))).exec,f="darwin"===process.platform?"open":"win32"===process.platform?"start":"xdg-open";c(`${f} "${s}"`)}}catch(e){r.fail(`Failed to download screenshot: ${e.message}`),process.exit(1)}}),function(e){return l.apply(this,arguments)}))},17422(e,a,t){t.d(a,{B:()=>x});var p,o,i,d,r,n,l,s,u,m,c,f,h,v,g,D,y,w=t(99436),b=t(35679),_=t(73284),C=t(30155),F=t(79896),S=t(44618),E=t(7586),k=t(56493),A=t(68168),N=t(74049),$=t(98593),O=(e,a)=>(0,$.H_)(e,a,{currentVersion:e?.current_version||null,unreleasedChanges:!!e?.has_unreleased_changes}),x=new b.uB("app").description("Application management");x.command("new").description("Create a new application").requiredOption("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("--layout-width <width>","Layout width",parseInt).option("--layout-height <height>","Layout height",parseInt).option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action((p=w(function*(e){var a=(0,k.requireAuth)(),p=e.json?null:(0,C.default)("Creating application...").start();try{var o={name:e.name};e.description&&(o.description=e.description),e.layoutWidth&&(o.layoutWidth=e.layoutWidth),e.layoutHeight&&(o.layoutHeight=e.layoutHeight);var i=yield a.createApplication(o);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):!e.json&&(p.succeed(`Application created: ${_.default.green(i.name)}`),console.log(` ID: ${_.default.gray(i._id)}`),i.description&&console.log(` ${_.default.gray(i.description)}`)),e.init){p&&p.stop();var d=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield d("application",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(a){e.json?console.error(JSON.stringify({error:a.message})):p.fail(`Failed to create application: ${a.message}`),process.exit(1)}}),function(e){return p.apply(this,arguments)})),x.command("share-info <applicationId>").description("Show public share info (releases available for share-new) for an application").option("-j, --json","Output as JSON").action((o=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Fetching share info...").start();try{var o=yield t.publicApplicationShareInfo({id:e});if(p&&p.stop(),!o)return void(a.json?console.log(JSON.stringify(null)):console.log(_.default.yellow("No share info found for this application")));if(a.json)return void console.log(JSON.stringify(o,null,2));var i=[...o.share?.selected_releases||[]].sort((e,a)=>new Date(a.date||0)-new Date(e.date||0));console.log(_.default.bold(`
20
+ Screenshots (${d.length})`)),console.log("─".repeat(56)),console.log(m.default.gray(`${"#".padStart(4)} ${"Timestamp".padEnd(24)} --ts value`)),console.log("─".repeat(56)),d.forEach((e,a)=>{var t=new Date(e.timestamp).getTime();console.log(`${String(a+1).padStart(4)} ${C(e.timestamp).padEnd(24)} ${t}`)}),console.log("─".repeat(56))}catch(e){i.fail(`Failed to query screenshots: ${e.message}`),process.exit(1)}}),function(e){return n.apply(this,arguments)})),S.command("screenshot").description("Download a screenshot image").requiredOption("--device <id>","Device ID").requiredOption("--ts <timestamp>","Screenshot timestamp (ISO 8601 or epoch ms)").option("--space <id>","Workspace/space ID (auto-detected from profile)").option("-o, --output <path>","Output file path").option("--open","Open with OS default viewer after download").action((l=s(function*(e){var a=yield _(),p=a.client,o=a.workspaceId,i=e.space||o;i||(console.error(m.default.red("Could not determine workspace ID. Use --space <id> or log in first.")),process.exit(1));var d=/^\d+$/.test(e.ts)?e.ts:new Date(e.ts).getTime(),r=yield b("Downloading screenshot...");try{var n=yield p.downloadScreenshot(i,e.device,d);r.stop();var l=e.output||`screenshot-${e.device}-${d}.jpg`,s=v.resolve(l);g.writeFileSync(s,n);var u=(n.length/1024).toFixed(1);if(console.log(m.default.green(`✓ Screenshot saved: ${s} (${u} KB)`)),e.open){var c=(yield Promise.resolve().then(t.t.bind(t,35317,19))).exec,f="darwin"===process.platform?"open":"win32"===process.platform?"start":"xdg-open";c(`${f} "${s}"`)}}catch(e){r.fail(`Failed to download screenshot: ${e.message}`),process.exit(1)}}),function(e){return l.apply(this,arguments)}))},17422(e,a,t){t.d(a,{B:()=>T});var p,o,i,d,r,n,l,s,u,m,c,f,h,v,g,D,y,w=t(99436),b=t(35679),_=t(73284),C=t(30155),F=t(79896),S=t(44618),E=t(7586),k=t(56493),A=t(68168),N=t(74049),$=t(98593),O=t(90003),x=(e,a)=>(0,$.H_)(e,a,{currentVersion:e?.current_version||null,unreleasedChanges:!!e?.has_unreleased_changes}),T=new b.uB("app").description("Application management");T.command("new").description("Create a new application").requiredOption("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("--layout-width <width>","Layout width",parseInt).option("--layout-height <height>","Layout height",parseInt).option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action((p=w(function*(e){var a=(0,k.requireAuth)(),p=e.json?null:(0,C.default)("Creating application...").start();try{var o={name:e.name};e.description&&(o.description=e.description),e.layoutWidth&&(o.layoutWidth=e.layoutWidth),e.layoutHeight&&(o.layoutHeight=e.layoutHeight);var i=yield a.createApplication(o);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):!e.json&&(p.succeed(`Application created: ${_.default.green(i.name)}`),console.log(` ID: ${_.default.gray(i._id)}`),i.description&&console.log(` ${_.default.gray(i.description)}`)),e.init){p&&p.stop();var d=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield d("application",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(a){e.json?console.error(JSON.stringify({error:a.message})):p.fail(`Failed to create application: ${a.message}`),process.exit(1)}}),function(e){return p.apply(this,arguments)})),T.command("share-info <applicationId>").description("Show public share info (releases available for share-new) for an application").option("-j, --json","Output as JSON").action((o=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Fetching share info...").start();try{var o=yield t.publicApplicationShareInfo({id:e});if(p&&p.stop(),!o)return void(a.json?console.log(JSON.stringify(null)):console.log(_.default.yellow("No share info found for this application")));if(a.json)return void console.log(JSON.stringify(o,null,2));var i=[...o.share?.selected_releases||[]].sort((e,a)=>new Date(a.date||0)-new Date(e.date||0));console.log(_.default.bold(`
21
21
  Share Info: ${o.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`App ID: ${_.default.gray(o._id)}`),o.description&&console.log(`Description: ${o.description}`),o.owner?.id_from_user&&console.log(`Owner: ${_.default.gray(o.owner.id_from_user)}`),o.share?.tags?.length&&console.log(`Tags: ${o.share.tags.join(", ")}`),o.share?.type&&console.log(`Type: ${o.share.type}`),console.log(`
22
22
  ${_.default.bold("Selected Releases")} (${i.length})`),0===i.length?console.log(_.default.gray(" None")):i.forEach(e=>{console.log(`
23
- ${_.default.cyan(e.name||"(unnamed)")} ${_.default.gray(e.date||"")}`),console.log(` Version ID: ${_.default.green(e.version)}`),console.log(` Release ID: ${_.default.gray(e._id)}`),e.note&&console.log(` Note: ${_.default.gray(e.note)}`)}),console.log("\n"+"─".repeat(60)),console.log(_.default.gray("Use:"),`bricks app share-new --app-id ${o._id} --version <name>`),console.log(_.default.gray("Or: "),"bricks app share-new --version-id <Version ID>")}catch(e){a.json?console.error(JSON.stringify({error:e.message})):p.fail(`Failed to fetch share info: ${e.message}`),process.exit(1)}}),function(e,a){return o.apply(this,arguments)})),x.command("share-new").description("Create a new application from a shared release version").option("--app-id <id>","Source shared application ID (requires --version)").option("--version <name>","Release name to use from the source app (requires --app-id)").option("--version-id <id>","Share version ID (from `app share-info`); skips lookup").option("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("--skip-if-exists","Return existing application if one already exists with this share version").option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action((i=w(function*(e){var a=(0,k.requireAuth)(),p=e.json?null:(0,C.default)("Creating application from shared version...").start();try{if(!e.versionId&&!(e.appId&&e.version))throw Error("Provide --version-id, or both --app-id and --version. Run `bricks app share-info <appId>` to discover values.");var o=e.versionId;if(!o){p&&(p.text="Resolving share version...");var i=yield a.publicApplicationShareInfo({id:e.appId}),d=i?.share?.selected_releases||[],r=d.find(a=>a.name===e.version);if(!r){var n=d.map(e=>e.name).filter(Boolean).join(", ")||"none";throw Error(`Release "${e.version}" not found on app ${e.appId}. Available: ${n}`)}o=r.version,p&&(p.text="Creating application from shared version...")}var l={shareVersionId:o};e.name&&(l.name=e.name),e.description&&(l.description=e.description),e.skipIfExists&&(l.skipIfExists=!0);var s=yield a.createApplicationWithShareVersion(l);if(e.json&&!e.init?console.log(JSON.stringify(s,null,2)):!e.json&&(p.succeed(`Application created: ${_.default.green(s.name)}`),console.log(` ID: ${_.default.gray(s._id)}`),s.description&&console.log(` ${_.default.gray(s.description)}`)),e.init){p&&p.stop();var u=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield u("application",s._id,{output:e.output,yes:e.yes,json:e.json})}}catch(a){e.json?console.error(JSON.stringify({error:a.message})):p.fail(`Failed to create application from shared version: ${a.message}`),process.exit(1)}}),function(e){return i.apply(this,arguments)})),x.command("list").description("List all applications").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action((d=w(function*(e){var a=(0,k.requireAuth)(),t=(0,C.default)("Fetching applications...").start();try{var p=yield a.applications({keyword:e.keyword});if(t.stop(),e.json)return void console.log(JSON.stringify(p,null,2));if(!p||0===p.length)return void console.log(_.default.yellow("No applications found"));console.log(_.default.bold("\nApplications")),console.log("─".repeat(80)),p.forEach(e=>{var a=e.has_unreleased_changes?_.default.yellow("●"):_.default.green("●"),t=e.current_version?`v${e.current_version}`:_.default.gray("no version");console.log(`${a} ${_.default.cyan(e.name)} ${_.default.gray(t)}`),console.log(` ID: ${_.default.gray(e._id)}`),e.description&&console.log(` ${_.default.gray(e.description)}`),console.log()})}catch(e){t.fail(`Failed to list applications: ${e.message}`),process.exit(1)}}),function(e){return d.apply(this,arguments)})),x.command("get <id>").description("Get application details").option("-c, --composed","Get composed configuration").option("-j, --json","Output as JSON").action((r=w(function*(e,a){var t=(0,k.requireAuth)(),p=(0,C.default)("Fetching application...").start();try{var o=yield t.application({id:e,composed:a.composed});if(p.stop(),o||(console.log(_.default.red("Application not found")),process.exit(1)),a.json)return void console.log(JSON.stringify(o,null,2));if(console.log(_.default.bold(`
23
+ ${_.default.cyan(e.name||"(unnamed)")} ${_.default.gray(e.date||"")}`),console.log(` Version ID: ${_.default.green(e.version)}`),console.log(` Release ID: ${_.default.gray(e._id)}`),e.note&&console.log(` Note: ${_.default.gray(e.note)}`)}),console.log("\n"+"─".repeat(60)),console.log(_.default.gray("Use:"),`bricks app share-new --app-id ${o._id} --version <name>`),console.log(_.default.gray("Or: "),"bricks app share-new --version-id <Version ID>")}catch(e){a.json?console.error(JSON.stringify({error:e.message})):p.fail(`Failed to fetch share info: ${e.message}`),process.exit(1)}}),function(e,a){return o.apply(this,arguments)})),T.command("share-new").description("Create a new application from a shared release version").option("--app-id <id>","Source shared application ID (requires --version)").option("--version <name>","Release name to use from the source app (requires --app-id)").option("--version-id <id>","Share version ID (from `app share-info`); skips lookup").option("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("--skip-if-exists","Return existing application if one already exists with this share version").option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action((i=w(function*(e){var a=(0,k.requireAuth)(),p=e.json?null:(0,C.default)("Creating application from shared version...").start();try{if(!e.versionId&&!(e.appId&&e.version))throw Error("Provide --version-id, or both --app-id and --version. Run `bricks app share-info <appId>` to discover values.");var o=e.versionId;if(!o){p&&(p.text="Resolving share version...");var i=yield a.publicApplicationShareInfo({id:e.appId}),d=i?.share?.selected_releases||[],r=d.find(a=>a.name===e.version);if(!r){var n=d.map(e=>e.name).filter(Boolean).join(", ")||"none";throw Error(`Release "${e.version}" not found on app ${e.appId}. Available: ${n}`)}o=r.version,p&&(p.text="Creating application from shared version...")}var l={shareVersionId:o};e.name&&(l.name=e.name),e.description&&(l.description=e.description),e.skipIfExists&&(l.skipIfExists=!0);var s=yield a.createApplicationWithShareVersion(l);if(e.json&&!e.init?console.log(JSON.stringify(s,null,2)):!e.json&&(p.succeed(`Application created: ${_.default.green(s.name)}`),console.log(` ID: ${_.default.gray(s._id)}`),s.description&&console.log(` ${_.default.gray(s.description)}`)),e.init){p&&p.stop();var u=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield u("application",s._id,{output:e.output,yes:e.yes,json:e.json})}}catch(a){e.json?console.error(JSON.stringify({error:a.message})):p.fail(`Failed to create application from shared version: ${a.message}`),process.exit(1)}}),function(e){return i.apply(this,arguments)})),T.command("list").description("List all applications").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action((d=w(function*(e){var a=(0,k.requireAuth)(),t=(0,C.default)("Fetching applications...").start();try{var p=yield a.applications({keyword:e.keyword});if(t.stop(),e.json)return void console.log(JSON.stringify(p,null,2));if(!p||0===p.length)return void console.log(_.default.yellow("No applications found"));console.log(_.default.bold("\nApplications")),console.log("─".repeat(80)),p.forEach(e=>{var a=e.has_unreleased_changes?_.default.yellow("●"):_.default.green("●"),t=e.current_version?`v${e.current_version}`:_.default.gray("no version");console.log(`${a} ${_.default.cyan(e.name)} ${_.default.gray(t)}`),console.log(` ID: ${_.default.gray(e._id)}`),e.description&&console.log(` ${_.default.gray(e.description)}`),console.log()})}catch(e){t.fail(`Failed to list applications: ${e.message}`),process.exit(1)}}),function(e){return d.apply(this,arguments)})),T.command("get <id>").description("Get application details").option("-c, --composed","Get composed configuration").option("-j, --json","Output as JSON").action((r=w(function*(e,a){var t=(0,k.requireAuth)(),p=(0,C.default)("Fetching application...").start();try{var o=yield t.application({id:e,composed:a.composed});if(p.stop(),o||(console.log(_.default.red("Application not found")),process.exit(1)),a.json)return void console.log(JSON.stringify(o,null,2));if(console.log(_.default.bold(`
24
24
  Application: ${o.name}`)),console.log("─".repeat(60)),console.log(`ID: ${_.default.gray(o._id)}`),console.log(`Description: ${o.description||_.default.gray("N/A")}`),console.log(`Tags: ${o.tags?.join(", ")||_.default.gray("None")}`),console.log(`Created: ${_.default.gray(o.create_datetime)}`),console.log(`Modified: ${_.default.gray(o.last_modify_datetime)}`),console.log(`
25
25
  ${_.default.bold("Version")}`),o.current_version){if(console.log(`Current: v${o.current_version}`),o.current_version_details){var i=o.current_version_details;i.name&&console.log(`Release Name: ${i.name}`),i.note&&console.log(`Release Note: ${_.default.gray(i.note)}`),i.create_datetime&&console.log(`Released At: ${_.default.gray(i.create_datetime)}`)}}else console.log(`Current: ${_.default.gray("No version")}`);if(console.log(`Unreleased: ${o.has_unreleased_changes?_.default.yellow("Yes"):_.default.green("No")}`),console.log(`
26
26
  ${_.default.bold("Features")}`),console.log(`Short Edit: ${o.short_edit?.enabled?_.default.green("Enabled"):_.default.gray("Disabled")}`),o.short_edit?.enabled&&o.short_edit.ref_map){var d=Object.keys(o.short_edit.ref_map).length;console.log(` References: ${d} editable properties`)}console.log(`Automation: ${o.canvas_control?.enable_schedule?_.default.green("Scheduled"):_.default.gray("No schedule")}`),o.lock?.enabled&&console.log(`Locked: ${_.default.yellow("Yes")}`),o.sync_key&&console.log(`Sync Key: ${_.default.gray(o.sync_key)}`),o.devices?.length>0?(console.log(`
27
27
  ${_.default.bold("Bound Devices")} (${o.devices.length})`),o.devices.forEach(e=>{var a="active"===e.status?_.default.green("●"):_.default.gray("○"),t=e.frame?_.default.gray(` [${e.frame.x||0},${e.frame.y||0} ${e.frame.width}x${e.frame.height}]`):"";console.log(` ${a} ${e.device_id}${t}`)})):console.log(`
28
- ${_.default.bold("Bound Devices")}: ${_.default.gray("None")}`),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get application: ${e.message}`),process.exit(1)}}),function(e,a){return r.apply(this,arguments)})),x.command("resolve <query>").description("Resolve an application 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((n=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Resolving application...").start();try{var o=yield(0,A.Y)(()=>t.application({id:e})),i=o?[o]:yield t.applications({keyword:e,paginate:{limit:a.limit}}),d=(0,A.K)({resource:"application",query:e,items:i||[],fields:["_id","name"],selectedBy:o?"id":null});if(p&&p.stop(),a.json)return void(0,E.GF)(d);if(d.resolved){var r=d.resolved;console.log(_.default.bold("\nResolved Application")),console.log("─".repeat(60)),console.log(`Name: ${_.default.cyan(r.name||"Unnamed")}`),console.log(`ID: ${_.default.gray(r._id)}`),console.log(`Selected By: ${d.selectedBy}`),console.log("─".repeat(60));return}if(0===d.matches.length)return void console.log(_.default.yellow(`No applications matched "${e}"`));console.log(_.default.bold(`
29
- Matching Applications (${d.matches.length})`)),console.log("─".repeat(80)),d.matches.forEach(e=>{console.log(`${_.default.cyan(e.name||"Unnamed")} ${_.default.gray(e._id)}`)}),console.log("─".repeat(80))}catch(a){p?p.fail(`Failed to resolve application: ${a.message}`):(0,E.OW)(a.message,{resource:"application",query:e}),process.exit(1)}}),function(e,a){return n.apply(this,arguments)})),x.command("update <id>").description("Update application name, description, and/or configuration").option("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("-c, --config <json>","Application config as JSON string").option("-f, --file <path>","Application 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((l=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Updating application...").start();try{var o=yield t.updateApplication((0,$.jB)(e,a));a.json?(0,$.yd)({action:"application.update",target:O(o,e),result:{lastCommitId:a.lastCommitId||null},json:!0}):(p.succeed(`Application updated: ${_.default.green(o.name)}`),o.has_unreleased_changes&&console.log(_.default.yellow("Note: Application has unreleased changes")))}catch(t){a.json?(0,E.OW)(t.message,{action:"application.update",target:{id:e}}):p.fail(`Failed to update application: ${t.message}`),process.exit(1)}}),function(e,a){return l.apply(this,arguments)})),x.command("short-edit <id>").description("Short edit application properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action((s=w(function*(e,a){var t=(0,k.requireAuth)(),p=(0,C.default)("Applying short edit...").start();try{var o=JSON.parse(a.list);Array.isArray(o)||(p.fail("List must be a JSON array"),process.exit(1));var i=yield t.shortEditApplication({id:e,list:o});p.succeed(`Short edit applied to: ${_.default.green(i.name)}`)}catch(e){p.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,a){return s.apply(this,arguments)})),x.command("short-refs <id>").description("List short edit references for an application").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((u=w(function*(e,a){var t=(0,k.requireAuth)(),p=(0,C.default)("Fetching short edit references...").start();try{var o=yield t.application({id:e});if(p.stop(),!o?.short_edit?.enabled)return void console.log(_.default.yellow("Short Edit is not enabled for this application"));var i=a.types?a.types.split(",").map(e=>e.trim()).filter(Boolean):[],d=(0,S.V)(o.short_edit.ref_map,{keyword:a.keyword,types:i});if(a.json)return void console.log(JSON.stringify(d,null,2));if(0===d.length)return void console.log(_.default.yellow("No short edit references found"));console.log(_.default.bold(`
28
+ ${_.default.bold("Bound Devices")}: ${_.default.gray("None")}`),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get application: ${e.message}`),process.exit(1)}}),function(e,a){return r.apply(this,arguments)})),T.command("resolve <query>").description("Resolve an application 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((n=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Resolving application...").start();try{var o=yield(0,A.Y)(()=>t.application({id:e})),i=o?[o]:yield t.applications({keyword:e,paginate:{limit:a.limit}}),d=(0,A.K)({resource:"application",query:e,items:i||[],fields:["_id","name"],selectedBy:o?"id":null});if(p&&p.stop(),a.json)return void(0,E.GF)(d);if(d.resolved){var r=d.resolved;console.log(_.default.bold("\nResolved Application")),console.log("─".repeat(60)),console.log(`Name: ${_.default.cyan(r.name||"Unnamed")}`),console.log(`ID: ${_.default.gray(r._id)}`),console.log(`Selected By: ${d.selectedBy}`),console.log("─".repeat(60));return}if(0===d.matches.length)return void console.log(_.default.yellow(`No applications matched "${e}"`));console.log(_.default.bold(`
29
+ Matching Applications (${d.matches.length})`)),console.log("─".repeat(80)),d.matches.forEach(e=>{console.log(`${_.default.cyan(e.name||"Unnamed")} ${_.default.gray(e._id)}`)}),console.log("─".repeat(80))}catch(a){p?p.fail(`Failed to resolve application: ${a.message}`):(0,E.OW)(a.message,{resource:"application",query:e}),process.exit(1)}}),function(e,a){return n.apply(this,arguments)})),T.command("update <id>").description("Update application name, description, and/or configuration").option("-n, --name <name>","Application name").option("-d, --description <description>","Application description").option("-c, --config <json>","Application config as JSON string").option("-f, --file <path>","Application 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((l=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Updating application...").start();try{var o=yield t.updateApplication((0,$.jB)(e,a));a.json?(0,$.yd)({action:"application.update",target:x(o,e),result:{lastCommitId:a.lastCommitId||null},json:!0}):(p.succeed(`Application updated: ${_.default.green(o.name)}`),o.has_unreleased_changes&&console.log(_.default.yellow("Note: Application has unreleased changes")))}catch(t){a.json?(0,E.OW)(t.message,{action:"application.update",target:{id:e}}):p.fail(`Failed to update application: ${t.message}`),process.exit(1)}}),function(e,a){return l.apply(this,arguments)})),T.command("short-edit <id>").description("Short edit application properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action((s=w(function*(e,a){var t=(0,k.requireAuth)(),p=(0,C.default)("Applying short edit...").start();try{var o=JSON.parse(a.list);Array.isArray(o)||(p.fail("List must be a JSON array"),process.exit(1));var i=yield t.shortEditApplication({id:e,list:o});p.succeed(`Short edit applied to: ${_.default.green(i.name)}`)}catch(e){p.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,a){return s.apply(this,arguments)})),T.command("short-refs <id>").description("List short edit references for an application").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((u=w(function*(e,a){var t=(0,k.requireAuth)(),p=(0,C.default)("Fetching short edit references...").start();try{var o=yield t.application({id:e});if(p.stop(),!o?.short_edit?.enabled)return void console.log(_.default.yellow("Short Edit is not enabled for this application"));var i=a.types?a.types.split(",").map(e=>e.trim()).filter(Boolean):[],d=(0,S.V)(o.short_edit.ref_map,{keyword:a.keyword,types:i});if(a.json)return void console.log(JSON.stringify(d,null,2));if(0===d.length)return void console.log(_.default.yellow("No short edit references found"));console.log(_.default.bold(`
30
30
  Short Edit References: ${o.name}`)),d.forEach(e=>{console.log(_.default.cyan(`
31
- ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:a})=>{var t=a?.title?_.default.gray(`- ${a.title}`):"";console.log(` ${_.default.green(e)} ${t}`)})}),console.log()}catch(e){p.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,a){return u.apply(this,arguments)})),x.command("bind <id>").description("Bind devices to application").option("-b, --bind <devices>","Device IDs to bind (comma-separated)").option("-u, --unbind <devices>","Device IDs to unbind (comma-separated)").option("--dry-run","Validate inputs and show the binding plan without applying it").option("-j, --json","Output as JSON").action((m=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Updating device bindings...").start();try{var o=yield t.application({id:e});if(!o)throw Error("Application not found");var i=a.bind?a.bind.split(",").map(e=>e.trim()):[],d=a.unbind?a.unbind.split(",").map(e=>e.trim()):[],r={id:e};if(i.length>0&&(r.bindDevices=i),d.length>0&&(r.unbindDevices=d),a.dryRun){p&&p.stop(),(0,$.S5)({action:"application.bind",target:O(o,e),request:{bindDevices:i,unbindDevices:d},checks:[(0,$.Iy)("application exists",!0,`${o.name} (${o._id})`),(0,$.Iy)("device changes provided",i.length+d.length>0,`bind=${i.length}, unbind=${d.length}`)],json:a.json});return}yield t.bindApplication(r),a.json?(0,$.yd)({action:"application.bind",target:O(o,e),result:{bindDevices:i,unbindDevices:d},json:!0}):p.succeed("Device bindings updated")}catch(t){a.json?(0,E.OW)(t.message,{action:"application.bind",target:{id:e}}):p.fail(`Failed to update bindings: ${t.message}`),process.exit(1)}}),function(e,a){return m.apply(this,arguments)})),x.command("remove <id>").description("Remove an application").option("--dry-run","Validate the target and show the removal plan without deleting it").option("-j, --json","Output as JSON").action((c=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Removing application...").start();try{var o=yield t.application({id:e});if(!o)throw Error("Application not found");var i=O(o,e);if(a.dryRun){p&&p.stop(),(0,$.S5)({action:"application.remove",target:i,request:{id:e},checks:[(0,$.Iy)("application exists",!0,`${i.name} (${i.id})`)],json:a.json});return}var d=yield t.removeApplication({id:e});a.json?(0,$.yd)({action:"application.remove",target:i,result:{removed:!!d},json:!0}):p.succeed(`Application removed: ${_.default.green(i.name)}`)}catch(t){a.json?(0,E.OW)(t.message,{action:"application.remove",target:{id:e}}):p.fail(`Failed to remove application: ${t.message}`),process.exit(1)}}),function(e,a){return c.apply(this,arguments)})),x.command("trigger <id> <testId>").description("Trigger automation test on application").option("--play","Play the test",!0).option("--stop","Stop the test").option("--setup-at-launch","Setup to run at app launch").option("-g, --match-group <group>","Match group").action((f=w(function*(e,a,t){var p=(0,k.requireAuth)(),o=(0,C.default)("Triggering automation...").start();try{yield p.triggerApplicationCanvasControl({id:e,testId:a,play:!t.stop&&t.play,setupAtLaunch:t.setupAtLaunch,matchGroup:t.matchGroup}),o.succeed(`Automation triggered: ${_.default.green(a)}`)}catch(e){o.fail(`Failed to trigger automation: ${e.message}`),process.exit(1)}}),function(e,a,t){return f.apply(this,arguments)})),x.command("release <id>").description("Release application to BRICKS platform").requiredOption("-c, --config <path|json>","Application config file path or JSON string").option("-n, --name <name>","Update application 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((h=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Releasing application...").start();try{var o=(0,N.Ku)(a.config),i=o.config,d=o.source,r=o.sizeBytes,n=yield t.application({id:e});if(!n)throw Error("Application not found");if(n.lock?.enabled)throw Error("Application is locked");var l=a.version||a.name||n.name||"Untitled",s=(0,N.w9)(a.changelogs);if(a.dryRun){p&&p.stop(),(0,$.S5)({action:"application.release",target:O(n,e),request:{name:a.name||null,version:l,changelogs:a.changelogs||null,configSource:d,configSizeBytes:r},checks:[(0,$.Iy)("application exists",!0,`${n.name} (${n._id})`),(0,$.Iy)("application is unlocked",!n.lock?.enabled),(0,$.Iy)("release config loaded",!0,`${r} bytes`)],json:a.json});return}var u=yield t.releaseApplication({id:e,config:i,...a.name?{name:a.name}:{},releaseCurrentVersion:l,releaseCurrentVersionNote:s});a.json?(0,$.yd)({action:"application.release",target:O(u||n,e),result:{name:a.name||null,version:l,configSource:d,configSizeBytes:r},json:!0}):p.succeed(`Application released: ${_.default.green(u?.name||n.name)}`)}catch(t){a.json?(0,E.OW)(t.message,{action:"application.release",target:{id:e}}):p.fail(`Failed to release application: ${t.message}`),process.exit(1)}}),function(e,a){return h.apply(this,arguments)})),x.command("project-pull <id>").description("Pull application source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((v=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Pulling application project...").start();try{var o=yield t.applicationProject({id:e,buildApplicationOnly:!0});o||(p?p.fail("Application project not found"):console.error(JSON.stringify({error:"Application project not found"})),process.exit(1)),a.json?console.log(JSON.stringify(o)):(p.succeed(`Application project fetched: ${_.default.green(o.files?.length||0)} files`),console.log(JSON.stringify(o,null,2)))}catch(e){a.json?console.error(JSON.stringify({error:e.message})):p.fail(`Failed to pull application project: ${e.message}`),process.exit(1)}}),function(e,a){return v.apply(this,arguments)})),x.command("check-config <path>").description("Validate application config against BRICKS schema").option("-j, --json","Output as JSON").option("--validate-automation","Also validate automation_map and test_map references (skips commented/unfinished steps)").option("--no-validate-expressions","Skip validating PROPERTY_BANK_EXPRESSION strings against the runtime expression rules").action((g=w(function*(e,a){F.existsSync(e)||(console.error(_.default.red(`Config file not found: ${e}`)),process.exit(1));var p=(0,C.default)("Validating config...").start();try{var o=F.readFileSync(e,"utf-8"),i=JSON.parse(o),d=yield Promise.all([t.e(9866),t.e(6645),t.e(9430),t.e(1010),t.e(7511),t.e(7574)]).then(t.t.bind(t,38890,19)),r=d.checkConfig,n=d.checkConfigDeprecatedFeatures,l=r(i,{checkAutomation:!!a.validateAutomation,checkCalc:!0,checkExpressions:!1!==a.validateExpressions}),s=n(i);if(p.stop(),a.json){console.log(JSON.stringify({...l,deprecations:s},null,2)),l.valid||process.exit(1);return}if(l.valid&&0===s.length)return void console.log(_.default.green("✓ Config is valid"));console.log(_.default.bold("\nConfig Validation Report")),console.log("─".repeat(60)),l.schema.length>0&&(console.log(_.default.red(`
31
+ ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:a})=>{var t=a?.title?_.default.gray(`- ${a.title}`):"";console.log(` ${_.default.green(e)} ${t}`)})}),console.log()}catch(e){p.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,a){return u.apply(this,arguments)})),T.command("bind <id>").description("Bind devices to application").option("-b, --bind <devices>","Device IDs to bind (comma-separated)").option("-u, --unbind <devices>","Device IDs to unbind (comma-separated)").option("--dry-run","Validate inputs and show the binding plan without applying it").option("-j, --json","Output as JSON").action((m=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Updating device bindings...").start();try{var o=yield t.application({id:e});if(!o)throw Error("Application not found");var i=a.bind?a.bind.split(",").map(e=>e.trim()):[],d=a.unbind?a.unbind.split(",").map(e=>e.trim()):[],r={id:e};if(i.length>0&&(r.bindDevices=i),d.length>0&&(r.unbindDevices=d),a.dryRun){p&&p.stop(),(0,$.S5)({action:"application.bind",target:x(o,e),request:{bindDevices:i,unbindDevices:d},checks:[(0,$.Iy)("application exists",!0,`${o.name} (${o._id})`),(0,$.Iy)("device changes provided",i.length+d.length>0,`bind=${i.length}, unbind=${d.length}`)],json:a.json});return}yield t.bindApplication(r),a.json?(0,$.yd)({action:"application.bind",target:x(o,e),result:{bindDevices:i,unbindDevices:d},json:!0}):p.succeed("Device bindings updated")}catch(t){a.json?(0,E.OW)(t.message,{action:"application.bind",target:{id:e}}):p.fail(`Failed to update bindings: ${t.message}`),process.exit(1)}}),function(e,a){return m.apply(this,arguments)})),T.command("remove <id>").description("Remove an application").option("--dry-run","Validate the target and show the removal plan without deleting it").option("-j, --json","Output as JSON").action((c=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Removing application...").start();try{var o=yield t.application({id:e});if(!o)throw Error("Application not found");var i=x(o,e);if(a.dryRun){p&&p.stop(),(0,$.S5)({action:"application.remove",target:i,request:{id:e},checks:[(0,$.Iy)("application exists",!0,`${i.name} (${i.id})`)],json:a.json});return}var d=yield t.removeApplication({id:e});a.json?(0,$.yd)({action:"application.remove",target:i,result:{removed:!!d},json:!0}):p.succeed(`Application removed: ${_.default.green(i.name)}`)}catch(t){a.json?(0,E.OW)(t.message,{action:"application.remove",target:{id:e}}):p.fail(`Failed to remove application: ${t.message}`),process.exit(1)}}),function(e,a){return c.apply(this,arguments)})),T.command("trigger <id> <testId>").description("Trigger automation test on application").option("--play","Play the test",!0).option("--stop","Stop the test").option("--setup-at-launch","Setup to run at app launch").option("-g, --match-group <group>","Match group").action((f=w(function*(e,a,t){var p=(0,k.requireAuth)(),o=(0,C.default)("Triggering automation...").start();try{yield p.triggerApplicationCanvasControl({id:e,testId:a,play:!t.stop&&t.play,setupAtLaunch:t.setupAtLaunch,matchGroup:t.matchGroup}),o.succeed(`Automation triggered: ${_.default.green(a)}`)}catch(e){o.fail(`Failed to trigger automation: ${e.message}`),process.exit(1)}}),function(e,a,t){return f.apply(this,arguments)})),T.command("release <id>").description("Release application to BRICKS platform").requiredOption("-c, --config <path|json>","Application config file path or JSON string").option("-n, --name <name>","Update application 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((h=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Releasing application...").start();try{var o=(0,N.Ku)(a.config),i=o.config,d=o.source,r=o.sizeBytes,n=yield t.application({id:e});if(!n)throw Error("Application not found");if(n.lock?.enabled)throw Error("Application is locked");var l=a.version||a.name||n.name||"Untitled",s=(0,N.w9)(a.changelogs);if(a.dryRun){p&&p.stop(),(0,$.S5)({action:"application.release",target:x(n,e),request:{name:a.name||null,version:l,changelogs:a.changelogs||null,configSource:d,configSizeBytes:r},checks:[(0,$.Iy)("application exists",!0,`${n.name} (${n._id})`),(0,$.Iy)("application is unlocked",!n.lock?.enabled),(0,$.Iy)("release config loaded",!0,`${r} bytes`)],json:a.json});return}var u=yield t.releaseApplication({id:e,config:i,...a.name?{name:a.name}:{},releaseCurrentVersion:l,releaseCurrentVersionNote:s});a.json?(0,$.yd)({action:"application.release",target:x(u||n,e),result:{name:a.name||null,version:l,configSource:d,configSizeBytes:r},json:!0}):p.succeed(`Application released: ${_.default.green(u?.name||n.name)}`)}catch(t){a.json?(0,E.OW)(t.message,{action:"application.release",target:{id:e}}):p.fail(`Failed to release application: ${t.message}`),process.exit(1)}}),function(e,a){return h.apply(this,arguments)})),T.command("project-pull <id>").description("Pull application source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((v=w(function*(e,a){var t=(0,k.requireAuth)(),p=a.json?null:(0,C.default)("Pulling application project...").start();try{var o=yield t.applicationProject({id:e,buildApplicationOnly:!0});o||(p?p.fail("Application project not found"):console.error(JSON.stringify({error:"Application project not found"})),process.exit(1)),a.json?console.log(JSON.stringify(o)):(p.succeed(`Application project fetched: ${_.default.green(o.files?.length||0)} files`),console.log(JSON.stringify(o,null,2)))}catch(e){a.json?console.error(JSON.stringify({error:e.message})):p.fail(`Failed to pull application project: ${e.message}`),process.exit(1)}}),function(e,a){return v.apply(this,arguments)})),T.command("check-config <path>").description("Validate application config against BRICKS schema").option("-j, --json","Output as JSON").option("--validate-automation","Also validate automation_map and test_map references (skips commented/unfinished steps)").option("--no-validate-expressions","Skip validating PROPERTY_BANK_EXPRESSION strings against the runtime expression rules").action((g=w(function*(e,a){F.existsSync(e)||(console.error(_.default.red(`Config file not found: ${e}`)),process.exit(1));var p=(0,C.default)("Validating config...").start();try{var o=F.readFileSync(e,"utf-8"),i=JSON.parse(o),d=yield Promise.all([t.e(9866),t.e(6645),t.e(9430),t.e(1010),t.e(7511),t.e(7574)]).then(t.t.bind(t,38890,19)),r=d.checkConfig,n=d.checkConfigDeprecatedFeatures,l=r(i,{checkAutomation:!!a.validateAutomation,checkCalc:!0,checkExpressions:!1!==a.validateExpressions}),s=n(i);if(p.stop(),a.json){console.log(JSON.stringify({...l,deprecations:s},null,2)),l.valid||process.exit(1);return}if(l.valid&&0===s.length)return void console.log(_.default.green("✓ Config is valid"));console.log(_.default.bold("\nConfig Validation Report")),console.log("─".repeat(60)),l.schema.length>0&&(console.log(_.default.red(`
32
32
  Schema Errors (${l.schema.length})
33
33
  `)),l.schema.forEach((e,a)=>{var t=e.instancePath||e.dataPath||"/";console.log(` ${_.default.red(`${a+1}.`)} ${_.default.bold(t)}`),console.log(` ${e.message}`),e.params?.pattern&&console.log(` ${_.default.gray(`pattern: ${e.params.pattern}`)}`)})),l.ref.length>0&&(console.log(_.default.red(`
34
34
  Reference Errors (${l.ref.length})
@@ -38,11 +38,11 @@ ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:a})=>{var t=a?.title
38
38
  Expression Errors (${l.expression.length})
39
39
  `)),l.expression.forEach((e,a)=>{console.log(` ${_.default.red(`${a+1}.`)} ${_.default.bold(e.field)}`),console.log(` ${e.message}`)})),s.length>0&&(console.log(_.default.yellow(`
40
40
  Deprecation Warnings (${s.length})
41
- `)),s.forEach((e,a)=>{console.log(` ${_.default.yellow(`${a+1}.`)} ${_.default.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(_.default.yellow(`⚠ ${s.length} warning(s)`)):console.log(_.default.red(`✗ ${u} error(s)`)+(s.length>0?_.default.yellow(`, ${s.length} warning(s)`):"")),l.valid||process.exit(1)}catch(e){p.fail(`Failed to validate config: ${e.message}`),process.exit(1)}}),function(e,a){return g.apply(this,arguments)})),x.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((D=w(function*(e,a){var p=a.json?null:(0,C.default)("Running config doctor...").start();try{var o=yield Promise.all([t.e(9866),t.e(6645),t.e(9430),t.e(1010),t.e(7511),t.e(563)]).then(t.bind(t,63322)),i=o.runConfigDoctor,d=o.renderConfigDoctorReport,r=yield i("app",e,a),n=r.report,l=r.exitCode;p?.stop(),a.json?(0,E.GF)({...n,exitCode:l}):console.log(d(n)),0!==l&&process.exit(l)}catch(e){p?p.fail(`Config doctor failed: ${e.message}`):(0,E.OW)(e.message),process.exit(1)}}),function(e,a){return D.apply(this,arguments)})),x.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from an application (deprecated: use `bricks ctor init`)").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((y=w(function*(e,a){a.json||console.error(_.default.yellow("Note: `bricks app ctor-init` is deprecated. Use `bricks ctor init <id>` instead."));var p=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield p("application",e,a)}),function(e,a){return y.apply(this,arguments)}))},55614(e,a,p){p.d(a,{s:()=>j});var o,i,d,r,n,l,s,u,m,c,f,h,v=p(68832),g=p(99436),D=p(35679),y=p(73284),w=p(30155);let b=t("readline");var _=p(47988),C=p(63755),F=p(31802),S=p(7586),E=p(29988),k=(o=g(function*(e){var a=v((yield Promise.all([p.e(9215).then(p.bind(p,8498)),p.e(1946).then(p.bind(p,51649)),p.e(1001).then(p.bind(p,52928))])),3),t=a[0].render,o=a[1].default,i=a[2].WorkspacePicker;return new Promise(a=>{var p,d=e=>{p.unmount(),a(e)};p=t(o.createElement(i,{workspaces:e,onSelect:d,onCancel:()=>d(null)}))})}),function(e){return o.apply(this,arguments)}),A=e=>!!e&&"object"==typeof e&&!Array.isArray(e),N=(e={})=>{var a=A(e)?e:{},t=a.plan,p=A(t)?t:{},o=A(a.lock)?a.lock:{},i="string"==typeof t?t:p.type;return{...a,plan:{...p,type:i||"free"},lock:{...o,features:!!o.features}}},$=(i=g(function*(){var e;try{e=yield(0,C.EC)()}catch(e){console.error(y.default.red(e.message)),process.exit(1)}return e?.user?.sub||(console.error(y.default.red("Not signed in. Run `bricks auth login` first.")),process.exit(1)),e}),function(){return i.apply(this,arguments)}),O=(e,a)=>{if(!e)throw Error("Not signed in. Run `bricks auth login` first.");if(e.user?.sub!==a)throw Error("OAuth account changed. Re-select the workspace for the current account.");return e},x=(d=g(function*(e){return O((yield(0,C.EC)()),e).accessToken}),function(e){return d.apply(this,arguments)}),T=(r=g(function*(e,a){return("u">typeof module&&"function"==typeof module.require?module.require("../gql/controller-client.js"):yield Promise.all([p.e(3332),p.e(8295),p.e(7494)]).then(p.bind(p,59957))).createControllerClient(e,()=>x(a))}),function(e,a){return r.apply(this,arguments)}),B=(n=g(function*(e,a={}){var t,p,o=(yield $()).user.sub,i=(0,_.getCurrentProfile)(),d=(0,F.getConnectionContext)(i),r=d.tokenInfo,n=d.baseUrl,l={...r?.baseUrl?{baseUrl:r.baseUrl}:{},...r?.activityLogBaseUrl?{activityLogBaseUrl:r.activityLogBaseUrl}:{}},s=(0,w.default)("Loading your workspaces...").start();try{var u=yield T(n,o);t=yield u.workspaces(),s.stop()}catch(e){if(s.fail(`Failed to load workspaces: ${e.message}`),a.optional)return void console.log(y.default.gray("Select a workspace later with `bricks auth use-workspace`"));process.exit(1)}if(!t.length){if(console.log(y.default.yellow("Your account has no accessible workspaces.")),a.optional)return;process.exit(1)}if(e){var m=String(e).toLowerCase();if(!(p=t.find(e=>String(e._id).toLowerCase()===m))){var c=t.filter(e=>(e.name||"").toLowerCase()===m);c.length>1&&(console.error(y.default.red(`Workspace name is ambiguous: ${e}`)),c.forEach(e=>{console.error(y.default.gray(` ${e.name}: ${e._id}`))}),console.error(y.default.gray("Retry with the workspace ID.")),process.exit(1)),p=v(c,1)[0]}p||(console.error(y.default.red(`Workspace not found: ${e}`)),console.log(y.default.gray("Use `bricks auth workspaces` to list available workspaces")),process.exit(1))}else if(1===t.length)p=v(t,1)[0],console.log(y.default.gray(`Only one workspace available: ${p.name}`));else if(process.stdin.isTTY&&process.stdout.isTTY||(console.error(y.default.red("Cannot prompt for a workspace in a non-interactive terminal. Pass its ID.")),console.error(y.default.gray("Use `bricks auth workspaces --json` to list workspace IDs.")),process.exit(1)),!(p=yield k(t))){if(a.optional)return void console.log(y.default.gray("Skipped. Select a workspace later with `bricks auth use-workspace`"));console.error(y.default.red("Workspace selection cancelled")),process.exit(1)}var f=a.profile||String(p.name||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"workspace",h=(0,_.resolveOAuthProfileTarget)(f,p._id,o),g=h.profile,D=h.baseline;a.profile&&g!==a.profile&&(console.error(y.default.red(`Profile name is already used by a different profile: ${a.profile}`)),console.log(y.default.gray(`Pick another name, or free it with \`bricks auth remove ${a.profile}\``)),process.exit(1));var b=(0,w.default)(`Selecting ${p.name}...`).start();try{var S=p;if(O((yield(0,C.EC)()),o),!(0,_.setTokenIfProfileCurrent)(g,{type:"oauth",oauthSubject:o,name:S.name,workspaceId:S._id,workspaceName:S.name,workspaceBilling:N(S.billing),...l},D,{expectedOAuthSubject:o,makeCurrent:!0}))throw Error(`Profile ${g} changed while selecting the workspace. Retry.`);b.succeed(`Using workspace ${y.default.green(S.name)} (profile: ${y.default.cyan(g)})`)}catch(e){b.fail(`Failed to select workspace: ${e.message}`),process.exit(1)}}),function(e){return n.apply(this,arguments)}),I=(l=g(function*(){var e=(0,_.getCurrentProfile)(),a=(0,_.getCurrentProfileSource)(),t=(0,F.getConnectionContext)(e),p=t.tokenInfo,o=t.baseUrl,i=t.oauth,d=t.auth,r=p?.type==="oauth"?"oauth":p?.token?"token":null,n=i?.user?.sub?{loggedIn:!0,email:i.user.email||null,sub:i.user.sub,expiresAt:i.expiresAt||null}:{loggedIn:!1};if(!d)return{ok:!1,profile:e,profileSource:a,baseUrl:o,oauth:n,auth:{available:!1,source:"missing",kind:r,workspaceId:p?.workspaceId||null,workspaceName:p?.workspaceName||null,createdAt:p?.createdAt||null,tokenPreview:null},workspace:null,error:null};try{var l=(0,(yield(0,E.i)()).createClient)(o,d),s=yield l.workspace();return{ok:!0,profile:e,profileSource:a,baseUrl:o,oauth:n,auth:{available:!0,source:"config",kind:d.kind,workspaceId:s?._id||p.workspaceId||null,workspaceName:s?.name||p.workspaceName||null,createdAt:p.createdAt||null,tokenPreview:"token"===d.kind?(0,S.$l)(d.token):null},workspace:s?{_id:s._id,name:s.name,description:s.description||null}:null,error:null}}catch(t){return{ok:!1,profile:e,profileSource:a,baseUrl:o,oauth:n,auth:{available:!0,source:"config",kind:d.kind,workspaceId:p.workspaceId||null,workspaceName:p.workspaceName||null,createdAt:p.createdAt||null,tokenPreview:"token"===d.kind?(0,S.$l)(d.token):null},workspace:null,error:{message:t.message}}}}),function(){return l.apply(this,arguments)}),j=new D.uB("auth").description("Authentication and token management");j.command("login").description("Sign in with your BRICKS account (opens the browser, OAuth)").argument("[passcode]","Deprecated — passcode login moved to `bricks auth login-workspace`").option("-p, --profile <profile>","Deprecated passcode login profile name").option("-n, --name <name>","Deprecated passcode login display name").option("--no-browser","Use the device-code flow instead of opening a local browser").action((s=g(function*(e,a){if(e)return console.log(y.default.yellow("`bricks auth login <passcode>` is deprecated; use `bricks auth login-workspace <passcode>`.")),V(e,a);(a.profile||a.name)&&(console.log(y.default.yellow("-p/--profile and -n/--name apply to passcode login and are ignored for OAuth sign-in.")),console.log(y.default.gray("Name the workspace profile with `bricks auth use-workspace -p`."))),(0,C.n_)()||(console.error(y.default.red("OAuth login is not configured in this build.")),console.error(y.default.gray("Set BRICKS_OAUTH_CLIENT_ID, or use workspace auth: bricks auth login-workspace")),process.exit(1));var t,p,o=(0,_.getOAuth)();try{if(!1!==a.browser&&(0,C.X9)()){var i,d=(0,w.default)("Waiting for the browser sign-in...").start();try{t=yield(0,C.b2)({onAuthorizeUrl:(i=g(function*(e){var a=yield(0,C.ph)(e);d.text="Waiting for the browser sign-in...",d.stop(),a?console.log(y.default.gray("Opened the browser. If it did not appear, open:")):console.log(y.default.gray("Could not open a browser automatically. Open:")),console.log(` ${y.default.underline.blue(e)}
41
+ `)),s.forEach((e,a)=>{console.log(` ${_.default.yellow(`${a+1}.`)} ${_.default.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(_.default.yellow(`⚠ ${s.length} warning(s)`)):console.log(_.default.red(`✗ ${u} error(s)`)+(s.length>0?_.default.yellow(`, ${s.length} warning(s)`):"")),l.valid||process.exit(1)}catch(e){p.fail(`Failed to validate config: ${e.message}`),process.exit(1)}}),function(e,a){return g.apply(this,arguments)})),T.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((D=w(function*(e,a){var p=a.json?null:(0,C.default)("Running config doctor...").start();try{var o=yield Promise.all([t.e(9866),t.e(6645),t.e(9430),t.e(1010),t.e(7511),t.e(563)]).then(t.bind(t,63322)),i=o.runConfigDoctor,d=o.renderConfigDoctorReport,r=yield i("app",e,a),n=r.report,l=r.exitCode;p?.stop(),a.json?(0,E.GF)({...n,exitCode:l}):console.log(d(n)),0!==l&&process.exit(l)}catch(e){p?p.fail(`Config doctor failed: ${e.message}`):(0,E.OW)(e.message),process.exit(1)}}),function(e,a){return D.apply(this,arguments)})),(0,O.x)(T.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from an application (deprecated: use `bricks ctor init`)")).action((y=w(function*(e,a){a.json||console.error(_.default.yellow("Note: `bricks app ctor-init` is deprecated. Use `bricks ctor init <id>` instead."));var p=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield p("application",e,a)}),function(e,a){return y.apply(this,arguments)}))},55614(e,a,p){p.d(a,{s:()=>j});var o,i,d,r,n,l,s,u,m,c,f,h,v=p(68832),g=p(99436),D=p(35679),y=p(73284),w=p(30155);let b=t("readline");var _=p(47988),C=p(63755),F=p(31802),S=p(7586),E=p(29988),k=(o=g(function*(e){var a=v((yield Promise.all([p.e(9215).then(p.bind(p,8498)),p.e(1946).then(p.bind(p,51649)),p.e(1001).then(p.bind(p,52928))])),3),t=a[0].render,o=a[1].default,i=a[2].WorkspacePicker;return new Promise(a=>{var p,d=e=>{p.unmount(),a(e)};p=t(o.createElement(i,{workspaces:e,onSelect:d,onCancel:()=>d(null)}))})}),function(e){return o.apply(this,arguments)}),A=e=>!!e&&"object"==typeof e&&!Array.isArray(e),N=(e={})=>{var a=A(e)?e:{},t=a.plan,p=A(t)?t:{},o=A(a.lock)?a.lock:{},i="string"==typeof t?t:p.type;return{...a,plan:{...p,type:i||"free"},lock:{...o,features:!!o.features}}},$=(i=g(function*(){var e;try{e=yield(0,C.EC)()}catch(e){console.error(y.default.red(e.message)),process.exit(1)}return e?.user?.sub||(console.error(y.default.red("Not signed in. Run `bricks auth login` first.")),process.exit(1)),e}),function(){return i.apply(this,arguments)}),O=(e,a)=>{if(!e)throw Error("Not signed in. Run `bricks auth login` first.");if(e.user?.sub!==a)throw Error("OAuth account changed. Re-select the workspace for the current account.");return e},x=(d=g(function*(e){return O((yield(0,C.EC)()),e).accessToken}),function(e){return d.apply(this,arguments)}),T=(r=g(function*(e,a){return("u">typeof module&&"function"==typeof module.require?module.require("../gql/controller-client.js"):yield Promise.all([p.e(3332),p.e(8295),p.e(7494)]).then(p.bind(p,59957))).createControllerClient(e,()=>x(a))}),function(e,a){return r.apply(this,arguments)}),B=(n=g(function*(e,a={}){var t,p,o=(yield $()).user.sub,i=(0,_.getCurrentProfile)(),d=(0,F.getConnectionContext)(i),r=d.tokenInfo,n=d.baseUrl,l={...r?.baseUrl?{baseUrl:r.baseUrl}:{},...r?.activityLogBaseUrl?{activityLogBaseUrl:r.activityLogBaseUrl}:{}},s=(0,w.default)("Loading your workspaces...").start();try{var u=yield T(n,o);t=yield u.workspaces(),s.stop()}catch(e){if(s.fail(`Failed to load workspaces: ${e.message}`),a.optional)return void console.log(y.default.gray("Select a workspace later with `bricks auth use-workspace`"));process.exit(1)}if(!t.length){if(console.log(y.default.yellow("Your account has no accessible workspaces.")),a.optional)return;process.exit(1)}if(e){var m=String(e).toLowerCase();if(!(p=t.find(e=>String(e._id).toLowerCase()===m))){var c=t.filter(e=>(e.name||"").toLowerCase()===m);c.length>1&&(console.error(y.default.red(`Workspace name is ambiguous: ${e}`)),c.forEach(e=>{console.error(y.default.gray(` ${e.name}: ${e._id}`))}),console.error(y.default.gray("Retry with the workspace ID.")),process.exit(1)),p=v(c,1)[0]}p||(console.error(y.default.red(`Workspace not found: ${e}`)),console.log(y.default.gray("Use `bricks auth workspaces` to list available workspaces")),process.exit(1))}else if(1===t.length)p=v(t,1)[0],console.log(y.default.gray(`Only one workspace available: ${p.name}`));else if(process.stdin.isTTY&&process.stdout.isTTY||(console.error(y.default.red("Cannot prompt for a workspace in a non-interactive terminal. Pass its ID.")),console.error(y.default.gray("Use `bricks auth workspaces --json` to list workspace IDs.")),process.exit(1)),!(p=yield k(t))){if(a.optional)return void console.log(y.default.gray("Skipped. Select a workspace later with `bricks auth use-workspace`"));console.error(y.default.red("Workspace selection cancelled")),process.exit(1)}var f=a.profile||String(p.name||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"workspace",h=(0,_.resolveOAuthProfileTarget)(f,p._id,o),g=h.profile,D=h.baseline;a.profile&&g!==a.profile&&(console.error(y.default.red(`Profile name is already used by a different profile: ${a.profile}`)),console.log(y.default.gray(`Pick another name, or free it with \`bricks auth remove ${a.profile}\``)),process.exit(1));var b=(0,w.default)(`Selecting ${p.name}...`).start();try{var S=p;if(O((yield(0,C.EC)()),o),!(0,_.setTokenIfProfileCurrent)(g,{type:"oauth",oauthSubject:o,name:S.name,workspaceId:S._id,workspaceName:S.name,workspaceBilling:N(S.billing),...l},D,{expectedOAuthSubject:o,makeCurrent:!0}))throw Error(`Profile ${g} changed while selecting the workspace. Retry.`);b.succeed(`Using workspace ${y.default.green(S.name)} (profile: ${y.default.cyan(g)})`)}catch(e){b.fail(`Failed to select workspace: ${e.message}`),process.exit(1)}}),function(e){return n.apply(this,arguments)}),I=(l=g(function*(){var e=(0,_.getCurrentProfile)(),a=(0,_.getCurrentProfileSource)(),t=(0,F.getConnectionContext)(e),p=t.tokenInfo,o=t.baseUrl,i=t.oauth,d=t.auth,r=p?.type==="oauth"?"oauth":p?.token?"token":null,n=i?.user?.sub?{loggedIn:!0,email:i.user.email||null,sub:i.user.sub,expiresAt:i.expiresAt||null}:{loggedIn:!1};if(!d)return{ok:!1,profile:e,profileSource:a,baseUrl:o,oauth:n,auth:{available:!1,source:"missing",kind:r,workspaceId:p?.workspaceId||null,workspaceName:p?.workspaceName||null,createdAt:p?.createdAt||null,tokenPreview:null},workspace:null,error:null};try{var l=(0,(yield(0,E.i)()).createClient)(o,d),s=yield l.workspace();return{ok:!0,profile:e,profileSource:a,baseUrl:o,oauth:n,auth:{available:!0,source:"config",kind:d.kind,workspaceId:s?._id||p.workspaceId||null,workspaceName:s?.name||p.workspaceName||null,createdAt:p.createdAt||null,tokenPreview:"token"===d.kind?(0,S.$l)(d.token):null},workspace:s?{_id:s._id,name:s.name,description:s.description||null}:null,error:null}}catch(t){return{ok:!1,profile:e,profileSource:a,baseUrl:o,oauth:n,auth:{available:!0,source:"config",kind:d.kind,workspaceId:p.workspaceId||null,workspaceName:p.workspaceName||null,createdAt:p.createdAt||null,tokenPreview:"token"===d.kind?(0,S.$l)(d.token):null},workspace:null,error:{message:t.message}}}}),function(){return l.apply(this,arguments)}),j=new D.uB("auth").description("Authentication and token management");j.command("login").description("Sign in with your BRICKS account (opens the browser, OAuth)").argument("[passcode]","Deprecated — passcode login moved to `bricks auth login-workspace`").option("-p, --profile <profile>","Deprecated passcode login profile name").option("-n, --name <name>","Deprecated passcode login display name").option("--no-browser","Use the device-code flow instead of opening a local browser").action((s=g(function*(e,a){if(e)return console.log(y.default.yellow("`bricks auth login <passcode>` is deprecated; use `bricks auth login-workspace <passcode>`.")),V(e,a);(a.profile||a.name)&&(console.log(y.default.yellow("-p/--profile and -n/--name apply to passcode login and are ignored for OAuth sign-in.")),console.log(y.default.gray("Name the workspace profile with `bricks auth use-workspace -p`."))),(0,C.n_)()||(console.error(y.default.red("OAuth login is not configured in this build.")),console.error(y.default.gray("Set BRICKS_OAUTH_CLIENT_ID, or use workspace auth: bricks auth login-workspace")),process.exit(1));var t,p,o=(0,_.getOAuth)();try{if(!1!==a.browser&&(0,C.X9)()){var i,d=(0,w.default)("Waiting for the browser sign-in...").start();try{t=yield(0,C.b2)({onAuthorizeUrl:(i=g(function*(e){var a=yield(0,C.ph)(e);d.text="Waiting for the browser sign-in...",d.stop(),a?console.log(y.default.gray("Opened the browser. If it did not appear, open:")):console.log(y.default.gray("Could not open a browser automatically. Open:")),console.log(` ${y.default.underline.blue(e)}
42
42
  `),d.start()}),function(e){return i.apply(this,arguments)})}),d.stop()}catch(e){d.fail(`Login failed: ${e.message}`),console.log(y.default.gray("Tip: over SSH/headless, use `bricks auth login --no-browser`")),process.exit(1)}}else{var r=yield(0,C.UY)();console.log(y.default.bold("\nConfirm the sign-in in any browser:")),console.log(` ${y.default.underline.blue(r.verification_uri_complete||r.verification_uri)}`),console.log(` Code: ${y.default.cyan(r.user_code)}
43
43
  `);var n=(0,w.default)("Waiting for confirmation...").start();try{t=yield(0,C.Zd)(r),n.stop()}catch(e){n.fail(e.message),process.exit(1)}}}catch(e){console.error(y.default.red(`Login failed: ${e.message}`)),process.exit(1)}try{p=(0,C.bo)(t)}catch(e){console.error(y.default.red(`Login failed: ${e.message}`)),process.exit(1)}var l=yield(0,_.installOAuthSessionIfCurrentAsync)(o,p);if(!l.installed){console.error(y.default.red("A newer sign-in or sign-out completed while this login was open. Please retry.")),process.exit(1);return}l.previous?.refreshToken&&l.previous.refreshToken!==p.refreshToken&&(yield(0,C.IC)(l.previous.refreshToken));var s=p.user.email||p.user.name||p.user.sub||"unknown";l.identityChanged&&console.log(y.default.yellow(`Signed in as a different account (was: ${l.previous.user.email||l.previous.user.sub}). Existing profiles were kept.`)),console.log(y.default.green(`Signed in as ${y.default.bold(s)}`));var u=(0,_.listProfiles)().some(e=>"oauth"===e.type&&e.oauthSubject===p.user.sub);!u&&process.stdout.isTTY&&process.stdin.isTTY?yield B(null,{optional:!0}):u||console.log(y.default.gray("Next: select a workspace with `bricks auth use-workspace`"))}),function(e,a){return s.apply(this,arguments)}));var V=(u=g(function*(e,a){var t,p=a.profile||(0,_.getCurrentProfile)(),o=(0,F.getConnectionContext)(p),i=o.baseUrl,d=o.baseline,r=a.name,n=a.token;if(n){var l=(0,w.default)("Validating token...").start();try{var s=(0,(yield(0,E.i)()).createClient)(i,n),u=yield s.workspace();if(u||(l.fail("Invalid token or unable to access workspace"),process.exit(1)),!(0,_.setTokenIfProfileCurrent)(p,{token:n,name:r||u.name,workspaceId:u._id,workspaceName:u.name,workspaceBilling:N(u.billing)},d,{makeCurrent:!0}))throw Error(`Profile ${p} changed while logging in. Retry.`);l.succeed(`Logged in to workspace: ${y.default.green(u.name)} (profile: ${y.default.cyan(p)})`)}catch(e){l.fail(`Login failed: ${e.message}`),process.exit(1)}return}var m=e;!m&&(console.log(y.default.cyan("Generate a one-time passcode from BRICKS Controller:")),console.log(y.default.gray(" 1. Open the link below (or select your workspace first)")),console.log(` ${y.default.underline.blue("https://control.bricks.tools/#/?action=manage-tokens")}`),console.log(y.default.gray(' 2. Click "Generate OTP" to create a one-time passcode\n')),(m=yield(t=b.createInterface({input:process.stdin,output:process.stdout}),new Promise(e=>{t.question("Enter passcode: ",a=>{t.close(),e(a.trim())})})))||(console.log(y.default.red("Passcode is required")),process.exit(1)));var c=(0,w.default)("Validating passcode...").start();try{var f=yield(0,E.i)(),h=f.createClient,v=(0,f.createPublicClient)(i),g=yield v.checkWorkspaceOTP(m);g.valid||(c.fail(`Invalid passcode: ${g.error||"Unknown error"}`),process.exit(1)),c.text=`Exchanging passcode for token (workspace: ${g.workspaceName})...`;var D=yield v.exchangeWorkspaceOTP(m);D.token||(c.fail("Failed to obtain token"),process.exit(1));var C=h(i,D.token),S=yield C.workspace();if(S||(c.fail("Token validation failed"),process.exit(1)),!(0,_.setTokenIfProfileCurrent)(p,{token:D.token,name:r||S.name,workspaceId:S._id,workspaceName:S.name,workspaceBilling:N(S.billing)},d,{makeCurrent:!0}))throw Error(`Profile ${p} changed while logging in. Retry.`);c.succeed(`Logged in to workspace: ${y.default.green(S.name)} (profile: ${y.default.cyan(p)})`)}catch(e){c.fail(`Login failed: ${e.message}`),process.exit(1)}}),function(e,a){return u.apply(this,arguments)});j.command("login-workspace").description("Workspace auth: login with a one-time passcode or a workspace token").argument("[passcode]","One-time passcode from BRICKS Controller").option("-t, --token <token>","Workspace token (instead of a passcode)").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action(V),j.command("login-token",{hidden:!0}).description("Deprecated: use `bricks auth login-workspace --token <token>`").option("-t, --token <token>","Workspace token").option("-p, --profile <profile>","Profile name to save the token").option("-n, --name <name>","Profile display name").action((m=g(function*(e){console.log(y.default.yellow("`bricks auth login-token` is deprecated; use `bricks auth login-workspace --token <token>`")),e.token||(console.error(y.default.red("Error: Token is required. Use -t or --token to provide it.")),process.exit(1)),yield V(null,e)}),function(e){return m.apply(this,arguments)})),j.command("workspaces").description("List workspaces your BRICKS account can access (OAuth)").option("-j, --json","Output as JSON").action((c=g(function*(e){var a=yield $(),t=(0,F.getConnectionContext)((0,_.getCurrentProfile)());if(t.oauth?.user?.sub!==a.user.sub){console.error(y.default.red("OAuth account changed. Retry the command.")),process.exit(1);return}var p=e.json?null:(0,w.default)("Loading workspaces...").start();try{var o=yield T(t.baseUrl,a.user.sub),i=yield o.workspaces();if(p?.stop(),e.json)return void(0,S.GF)(i);if(!i.length)return void console.log(y.default.yellow("Your account has no accessible workspaces."));var d=(0,_.listProfiles)();console.log(y.default.bold("\nWorkspaces")),console.log("─".repeat(60)),i.forEach(e=>{var t=d.find(t=>"oauth"===t.type&&t.oauthSubject===a.user.sub&&String(t.workspaceId)===String(e._id)),p=t?.current?y.default.green("● "):" ",o=t?y.default.gray(` (profile: ${t.name})`):"";console.log(`${p}${e.name.padEnd(24)} ${y.default.gray(e._id)}${o}`)}),console.log("─".repeat(60))}catch(e){p?.fail(`Failed to load workspaces: ${e.message}`),process.exit(1)}}),function(e){return c.apply(this,arguments)})),j.command("use-workspace").description("Select a workspace as the active profile (OAuth)").argument("[workspace]","Workspace id or name (interactive picker when omitted)").option("-p, --profile <profile>","Profile name to create or update").action(B),j.command("logout").description("Sign out of OAuth or remove the current workspace-token profile").option("-a, --all","Also remove all saved profiles (full reset)").option("-p, --profile <profile>","Deprecated: use `bricks auth remove <profile>`").action((f=g(function*(e){if(e.profile){var a=(0,_.getTokenInfo)(e.profile);return a?(0,_.removeTokenIfCurrent)(e.profile,a)?void console.log(y.default.yellow(`Removed profile: ${e.profile} (--profile is deprecated; use \`bricks auth remove ${e.profile}\`)`)):void console.log(y.default.yellow(`Profile changed while removing: ${e.profile}. Retry.`)):void console.log(y.default.yellow(`No profile found: ${e.profile}`))}if(e.all){yield(0,C.iF)();var t=[];(0,_.listProfiles)().forEach(({name:e,current:a,...p})=>{(0,_.removeTokenIfCurrent)(e,p)||t.push(e)}),0===t.length?console.log(y.default.green("All profiles removed")):console.log(y.default.yellow(`Profiles changed while removing and were kept: ${t.join(", ")}. Retry.`));return}var p=(0,_.getCurrentProfile)(),o=(0,_.getTokenInfo)(p);o&&"oauth"!==o.type?(0,_.removeTokenIfCurrent)(p,o)?console.log(y.default.green(`Logged out from profile: ${p}`)):console.log(y.default.yellow(`Profile changed while logging out: ${p}. Retry.`)):(yield(0,C.iF)())?(console.log(y.default.green("Signed out of your BRICKS account")),console.log(y.default.gray("Profiles were kept; OAuth profiles are inactive until next login"))):(console.log(y.default.yellow("No OAuth session to sign out of")),console.log(y.default.gray("To remove a workspace-token profile: bricks auth remove <profile>")))}),function(e){return f.apply(this,arguments)})),j.command("remove <profile>").description("Remove a saved profile (any kind)").action(e=>{var a=(0,_.getTokenInfo)(e);if(!a)return void console.log(y.default.yellow(`No profile found: ${e}`));var t=(0,_.getCurrentProfile)()===e;(0,_.removeTokenIfCurrent)(e,a)?(console.log(y.default.green(`Removed profile: ${e}`)),t&&console.log(y.default.gray("It was the current profile — switch with `bricks auth use <profile>`"))):console.log(y.default.yellow(`Profile changed while removing: ${e}. Retry.`))}),j.command("status").description("Show current authentication status").option("-j, --json","Output as JSON").action((h=g(function*(e){if(e.json)return void(0,S.GF)((yield I()));var a=(0,_.getCurrentProfile)(),t=(0,F.getConnectionContext)(a),p=t.tokenInfo,o=t.oauth,i=t.auth,d=t.baseUrl,r=p?.type==="oauth"?"oauth":p?.token?"token":null;if(o?.user){var n=o.expiresAt?new Date(o.expiresAt).getTime()-Date.now():0;console.log(`${y.default.bold("Account:")} ${y.default.green(o.user.email||o.user.sub)} ${y.default.gray(`(${n>0?"token refreshes automatically":"token expired (refreshes on next use)"})`)}`)}else console.log(`${y.default.bold("Account:")} ${y.default.gray("not signed in (OAuth)")}`);if(!i){console.log(y.default.yellow("\nNo usable credential for the current profile")),"oauth"===r?o?.user?.sub&&p?.oauthSubject!==o.user.sub?console.log(y.default.gray("Profile belongs to another or legacy account — run `bricks auth use-workspace`")):console.log(y.default.gray("Profile uses OAuth — run `bricks auth login`")):console.log(y.default.gray("Use `bricks auth login` (OAuth) or `bricks auth login-workspace`"));return}var l=(0,w.default)("Checking connection...").start();try{var s=(0,(yield(0,E.i)()).createClient)(d,i),u=yield s.workspace();l.stop(),console.log(y.default.bold("\nAuthentication Status")),console.log("─".repeat(40)),console.log(`Profile: ${y.default.cyan(a)} ${y.default.gray(`(${i.kind})`)}`),console.log(`Workspace: ${y.default.green(u.name)}`),console.log(`Workspace ID: ${y.default.gray(u._id)}`);var m=p.baseUrl;console.log(`Base URL: ${y.default.gray(d)}${m?"":y.default.gray(" (global)")}`),console.log(`Logged in: ${y.default.gray(p.createdAt)}`),console.log("─".repeat(40))}catch(e){l.fail(`Connection failed: ${e.message}`)}}),function(e){return h.apply(this,arguments)})),j.command("list").description("List all saved profiles").action(()=>{var e=(0,_.listProfiles)(),a=(0,_.getOAuth)();if(a?.user&&console.log(`${y.default.bold("Account:")} ${y.default.green(a.user.email||a.user.sub)}`),0===e.length){console.log(y.default.yellow("No saved profiles")),console.log(y.default.gray("Use `bricks auth login` to sign in, then `bricks auth use-workspace`"));return}console.log(y.default.bold("\nSaved Profiles")),console.log("─".repeat(60)),e.forEach(e=>{var a=e.current?y.default.green("● "):" ",t=e.current?y.default.green(e.name):e.name,p="oauth"===e.type?y.default.blue("oauth"):y.default.gray("token"),o=e.baseUrl?y.default.gray(` [${e.baseUrl}]`):"";console.log(`${a}${t.padEnd(15)} ${p} ${y.default.gray(e.workspaceName||"Unknown")}${o}`)}),console.log("─".repeat(60))}),j.command("use <profile>").description("Switch to a different profile").action(e=>{var a=(0,_.getTokenInfo)(e);if(!a){console.log(y.default.red(`Profile not found: ${e}`)),console.log(y.default.gray("Use `bricks auth list` to see available profiles"));return}(0,_.setCurrentProfile)(e),console.log(y.default.green(`Switched to profile: ${e}`)),a.workspaceName&&console.log(y.default.gray(`Workspace: ${a.workspaceName}`)),"oauth"!==a.type||(0,F.getAuthContext)(e)||console.log(y.default.yellow("This OAuth profile is inactive — run `bricks auth login`, then select it with `bricks auth use-workspace`"))}),j.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,a)=>{if(a.global)(0,_.setBaseUrl)(e),console.log(y.default.green(`Global base URL set to: ${e}`));else{var t=(0,_.getCurrentProfile)();(0,_.setBaseUrl)(e,t),console.log(y.default.green(`Base URL for profile ${y.default.cyan(t)} set to: ${e}`))}})},59845(e,a,t){t.d(a,{Q:()=>V});var p,o,i,d,r,n,l,s,u,m,c,f,h=t(99436),v=t(35679),g=t(73284),D=t(67996),y=t(77598),w=t(48161),b=t(76760),_=t(51455),C=t(27549),F=t(19557),S=8089,E=(p=h(function*(e,a,t=3e3){return(0,F.uE)(`http://${e}:${a}/buttress/info`,t)}),function(e,a){return p.apply(this,arguments)}),k=["privateKeyPkcs8"],A=b.join(w.homedir(),".bricks-cli","buttress"),N=e=>b.join(e||A,"state.json"),$=()=>{try{return`buttress-${C.machineIdSync()}`}catch{return null}},O=(o=h(function*(e){var a=N(e);try{var t=yield _.readFile(a,"utf8");return JSON.parse(t)}catch(e){if("ENOENT"===e.code)return null;throw e}}),function(e){return o.apply(this,arguments)}),x=(i=h(function*(e,a){var t=a||A,p=N(a);yield _.mkdir(t,{recursive:!0,mode:448}),yield _.chmod(t,448);var o=`${p}.tmp-${process.pid}-${y.randomUUID()}`;try{yield _.writeFile(o,JSON.stringify(e,null,2),{encoding:"utf8",mode:384}),yield _.chmod(o,384),yield _.rename(o,p),yield _.chmod(p,384)}catch(e){throw yield _.unlink(o).catch(()=>{}),e}return p}),function(e,a){return i.apply(this,arguments)}),T=(d=h(function*(e){var a=N(e);try{return yield _.unlink(a),!0}catch(e){if("ENOENT"===e.code)return!1;throw e}}),function(e){return d.apply(this,arguments)}),B=(r=h(function*({client:e,serverId:a,workspaceId:t,stateDir:p,keepLocal:o=!1}){var i=o?null:yield O(p),d=!o&&((e,a,t)=>{if(e?.workspace?.serverId!==a)return!1;var p=e.workspace.id;if(!p||!t||String(p)!==String(t))throw Error(`Local Buttress state belongs to workspace ${p||"unknown"}, but the current profile targets ${t||"unknown"}. Switch profiles first.`);return!0})(i,a,t);return{removed:yield e.unbindButtressServer({serverId:a}),localRemoved:!!d&&(yield T(p))}}),function(e){return r.apply(this,arguments)}),I=(n=h(function*({timeout:e=3e3,verify:a=!0,port:t=S,onStatus:p}={}){p?.(`Scanning UDP ${t} for ${e}ms...`);var o,i=yield(({timeout:e=3e3,idleTimeout:a=0,port:t=S}={})=>(0,F.YH)({port:t,timeout:e,idleTimeout:a,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"2.0",d:{id:`cli-${(0,F.BW)()}`}})),parseMessage:(e,a)=>{var t=(0,F.nl)(e,e=>e?.v==="2.0");if(!t)return null;var p={...t,address:a.address};return{key:p.id||`${a.address}:${p.port}`,value:p}}}))({timeout:e,port:t});return 0===i.length?[]:a?(p?.(`Verifying ${i.length} server(s)...`),yield Promise.all(i.map((o=h(function*(e){var a=yield E(e.address,e.port,2e3);return a?{...e,...a,address:e.address,verified:!0}:{...e,verified:!1}}),function(e){return o.apply(this,arguments)})))):i}),function(){return n.apply(this,arguments)}),j=(l=h(function*(){var e=(yield Promise.resolve().then(t.bind(t,47988))).getCurrentProfile,a=(0,(yield Promise.resolve().then(t.bind(t,31802))).getConnectionContext)(e()),p=a.auth,o=a.baseUrl;return p||(console.error(g.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),{client:(0,(yield Promise.all([t.e(3332),t.e(8295),t.e(907)]).then(t.bind(t,85382))).createClient)(o,p),workspaceId:p.workspaceId}}),function(){return l.apply(this,arguments)}),V=new v.uB("buttress").description("Pair and inspect buttress-server bindings for the current workspace").alias("butr");V.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((s=h(function*(e){var a,p,o,i,d,r,n=(yield Promise.resolve().then(t.bind(t,30155))).default,l=e.serverId||$();l||(console.error(g.default.red("Could not detect a local server id. Pass --server-id <id> explicitly.")),process.exit(1));var s=(p=(a=y.generateKeyPairSync("ed25519")).publicKey,o=a.privateKey,i=p.export({type:"spki",format:"der"}),d=o.export({type:"pkcs8",format:"der"}),r=y.createHash("sha256").update(i).digest("hex").slice(0,16),{publicKeySpki:i.toString("base64"),privateKeyPkcs8:d.toString("base64"),kid:r}),u=(yield j()).client,m=n(`Binding buttress server ${g.default.cyan(l)}...`).start();try{var c=yield u.bindButtressServer({serverId:l,name:e.name,serverPublicKey:{spkiBase64:s.publicKeySpki,kid:s.kid}});m.stop();var f={workspace:{id:c.workspaceId,name:c.workspaceName,serverId:c.serverId,issuerPublicKey:c.issuerPublicKey.pem,kid:c.issuerPublicKey.kid,boundAt:new Date().toISOString()},serverKeyPair:s};if(e.print){console.warn(g.default.yellow("⚠ Output contains the server announce private key. Treat as a secret.")),process.stdout.write(`${JSON.stringify(f,null,2)}
44
44
  `);return}var h=yield x(f,e.stateDir);console.log(g.default.green("✓"),"Buttress server bound to workspace."),console.log(` Workspace: ${g.default.bold(c.workspaceName)} (${c.workspaceId})`),console.log(` Server id: ${g.default.cyan(c.serverId)}`),console.log(` Issuer kid: ${g.default.gray(c.issuerPublicKey.kid)}`),console.log(` Announce kid: ${g.default.gray(s.kid)}`),console.log(` State file: ${g.default.gray(h)}`),console.log(),console.log(g.default.yellow("Restart buttress-server for the binding to take effect."))}catch(e){m.fail(`Bind failed: ${e.message}`),process.exit(1)}}),function(e){return s.apply(this,arguments)})),V.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((u=h(function*(e){var a=e.serverId||$();a||(console.error(g.default.red("Could not detect a local server id. Pass --server-id explicitly.")),process.exit(1));var t=yield j(),p=t.client,o=t.workspaceId;try{var i=yield B({client:p,serverId:a,workspaceId:o,stateDir:e.stateDir,keepLocal:e.keepLocal}),d=i.removed,r=i.localRemoved;if(d?console.log(g.default.green("✓"),`Unbound ${g.default.cyan(a)} from workspace.`):console.log(g.default.yellow("!"),`${g.default.cyan(a)} was not bound to this workspace.`),r){var n=N(e.stateDir);console.log(g.default.gray(`Removed local state file: ${n}`))}}catch(e){console.error(g.default.red(`Unbind failed: ${e.message}`)),process.exit(1)}}),function(e){return u.apply(this,arguments)})),V.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((m=h(function*(e){var a=yield O(e.stateDir),t=null;try{var p=(yield j()).client;t=yield p.buttressServers()}catch(e){t={error:e.message}}e.json?console.log(JSON.stringify(((e,a)=>{if(!e?.serverKeyPair||"object"!=typeof e.serverKeyPair)return{local:e,remote:a};var t=e.serverKeyPair,p=(t.privateKeyPkcs8,D(t,k));return{local:{...e,serverKeyPair:p},remote:a}})(a,t),null,2)):(console.log(g.default.bold("\nLocal buttress state")),console.log("─".repeat(60)),a?.workspace?(console.log(` Workspace: ${g.default.bold(a.workspace.name)} (${a.workspace.id})`),console.log(` Server id: ${g.default.cyan(a.workspace.serverId)}`),console.log(` Issuer kid: ${g.default.gray(a.workspace.kid)}`),console.log(` Bound at: ${g.default.gray(a.workspace.boundAt)}`),console.log(` File: ${g.default.gray(N(e.stateDir))}`)):console.log(g.default.gray(" not bound (no state.json found)")),console.log(g.default.bold("\nWorkspace-side bound servers")),console.log("─".repeat(60)),Array.isArray(t)?0===t.length?console.log(g.default.gray(" none")):t.forEach(e=>{console.log(` ${g.default.cyan(e.serverId)} ${g.default.gray(e.name||"")} ${g.default.gray(e.boundAt||"")}`)}):t?.error&&console.log(g.default.red(` failed to fetch: ${t.error}`)))}),function(e){return m.apply(this,arguments)})),V.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=h(function*(e){var a=(yield j()).client;try{var t=yield a.issueButtressAccessToken({ttlSeconds:e.ttl});if(e.json)return void console.log(JSON.stringify(t,null,2));console.log(g.default.green("✓"),"Buttress access token issued."),console.log(` Workspace: ${t.workspaceId}`),console.log(` Expires: ${t.expiresAt}`),console.log(` jti: ${g.default.gray(t.jti)}`),console.log(),console.log(g.default.cyan(t.token))}catch(e){console.error(g.default.red(`Issue token failed: ${e.message}`)),process.exit(1)}}),function(e){return c.apply(this,arguments)})),V.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(S)).option("--udp-only","Skip HTTP /buttress/info verification").option("-j, --json","Output as JSON").action((f=h(function*(e){var a=(yield Promise.resolve().then(t.bind(t,30155))).default,p=yield Promise.resolve().then(t.bind(t,47988)),o=p.getCurrentProfile,i=p.getTokenInfo,d=parseInt(e.timeout,10),r=parseInt(e.port,10),n=[],l=a(`Scanning for buttress-servers (${d}ms)...`).start();try{n=yield I({timeout:d,port:r,verify:!e.udpOnly,onStatus:e=>{l.text=e}}),l.stop()}catch(e){l.fail(`Scan failed: ${e.message}`),process.exit(1)}var s=o(),u=i(s)?.workspaceId||null;if(e.json)return void console.log(JSON.stringify({servers:n,workspaceId:u},null,2));if(0===n.length)return void console.log(g.default.yellow("No buttress-servers found on the LAN."));for(var m of(console.log(g.default.bold(`
45
- Found ${n.length} buttress-server(s)`)),console.log("─".repeat(70)),n)){var c=!1===m.verified?g.default.red("unverified"):g.default.green("online"),f=m.workspace?.id,h=f&&u&&f===u,v=m.authentication?.bound?g.default.yellow("JWT required"):g.default.gray("open");console.log(` ${g.default.bold(m.name||"Unknown")} ${g.default.gray(`(${m.address}:${m.port})`)} [${c}]`),m.id&&console.log(` Server id: ${g.default.cyan(m.id)}`),m.version&&console.log(` Version: ${g.default.green(m.version)}`);var D=m.authentication?.kid?g.default.gray(` (kid: ${m.authentication.kid})`):"";if(console.log(` Auth: ${v}${D}`),f){var y=h?g.default.green(`${f} ${g.default.bold("(current profile)")}`):g.default.gray(f);console.log(` Workspace: ${y}`)}if(Array.isArray(m.generators)&&m.generators.length>0)for(var w of(console.log(" Generators:"),m.generators)){var b=[];"number"==typeof w.score&&b.push(`score ${w.score.toFixed(1)}`),!0===w.hasGpu?b.push("GPU ✓"):!1===w.hasGpu&&b.push("GPU ✗"),"number"==typeof w.usableBytes&&b.push(`${(w.usableBytes/0x40000000).toFixed(1)} GB usable`);var _=b.length>0?` ${g.default.gray(b.join(" "))}`:"";console.log(` - ${g.default.cyan(w.type)}${_}`)}}console.log("─".repeat(70)),n.some(e=>e.authentication?.bound)&&(console.log(),console.log(g.default.gray("To connect to a bound server, run `bricks buttress issue-token` for a workspace access token.")))}),function(e){return f.apply(this,arguments)}))},71335(e,a,t){t.d(a,{oT:()=>s});var p=t(35679),o=t(73284),i=t(47988),d={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},r=e=>{var a=Object.entries(d).find(([,a])=>e===a);return a?a[0]:null},n={prod:"https://activity-log.bricks.tools",beta:"https://activity-log-beta.bricks.tools",dev:"http://localhost:8088"},l=e=>{var a=Object.entries(n).find(([,a])=>e===a);return a?a[0]:null},s=new p.uB("config").description("CLI configuration management");s.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,a)=>{if(!e){var t=(0,i.getBaseUrl)(),p=r(t),s=(0,i.getActivityLogBaseUrl)(),u=l(s);console.log(o.default.bold("\nEndpoint Configuration")),console.log("─".repeat(50)),console.log(o.default.bold("BRICKS")),console.log(` URL: ${o.default.cyan(t)}`),console.log(` Environment: ${p?o.default.green(p):o.default.yellow("custom")}`),console.log(o.default.bold("Activity Log")),console.log(` URL: ${o.default.cyan(s)}`),console.log(` Environment: ${u?o.default.green(u):o.default.yellow("custom")}`),console.log("─".repeat(50)),console.log(o.default.gray("\nUsage: bricks config endpoint <prod|beta|dev>"));return}var m=Object.keys(d);m.includes(e)||(console.error(o.default.red(`Invalid environment: ${e}`)),console.log(o.default.gray(`Valid options: ${m.join(", ")}`)),process.exit(1));var c=d[e],f=n[e],h=a.profile?(0,i.getCurrentProfile)():null;(0,i.setBaseUrl)(c,h),(0,i.setActivityLogBaseUrl)(f,h);var v=a.profile?` (profile: ${(0,i.getCurrentProfile)()})`:"";console.log(o.default.green(`✓ Endpoint changed to ${e}${v}`)),console.log(o.default.gray(` BRICKS: ${c}`)),console.log(o.default.gray(` Activity Log: ${f}`)),console.log(o.default.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(o.default.gray("Use `bricks auth status` to check your connection."))}),s.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(e=>{var a=(0,i.getBaseUrl)(),t=r(a);if(e.json)return void console.log(JSON.stringify({endpoint:a,environment:t||"custom"},null,2));console.log(o.default.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`BRICKS: ${o.default.cyan(a)}`),t?console.log(`Environment: ${o.default.green(t)}`):console.log(`Environment: ${o.default.yellow("custom")}`);var p=(0,i.getActivityLogBaseUrl)(),d=l(p);console.log(`Activity Log: ${o.default.cyan(p)} ${d?o.default.green(`(${d})`):o.default.yellow("(custom)")}`),console.log("─".repeat(50))})},22175(e,a,t){t.d(a,{g:()=>f});var p,o,i,d,r,n,l,s,u=t(99436),m=t(35679),c=t(73284),f=new m.uB("ctor").description("BRICKS Project (ctor) tooling: scaffold, sync, compile, deploy, and serve the project"),h=e=>{console.error(c.default.red(e?.message||String(e))),process.exit(1)};f.command("init <id>").description("Initialize a BRICKS Project from an application or module").option("--type <type>","Project type: app or module","app").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((p=u(function*(e,a){var p="module"===a.type?"module":"application",o=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield o(p,e,a)}),function(e,a){return p.apply(this,arguments)})),f.command("postinstall").description("Regenerate the ctor/ library, MCP config, and skills (run from a project)").option("--skip-copy-project","Skip copying the ctor/ library into the project").option("--refresh-skills","Also overwrite bundled skill files whose content changed (default keeps existing skills)").option("--check","Compare the bundled ctor/skills assets against the project without writing (always exits 0; read the output)").option("-j, --json","With --check, output the comparison as JSON").action((o=u(function*(e){try{if(e.check){var a=(yield Promise.all([t.e(7111),t.e(1708)]).then(t.bind(t,37495))).checkProjectAssets,p=yield a();if(e.json)return void console.log(JSON.stringify(p,null,2));if(p.upToDate)return void console.log(`Project assets match the bundled snapshot (CLI ${p.cliVersion}).`);var o=(e,{changed:a,missing:t})=>{if(a.length||t.length){for(var p of(console.log(`${e}: ${a.length} changed, ${t.length} missing`),a))console.log(` ~ ${p}`);for(var o of t)console.log(` + ${o}`)}};console.log(`Project assets differ from the bundled snapshot (CLI ${p.cliVersion}):`),o("ctor/",p.lib),o("skills",p.skills),console.log("Run `bricks ctor postinstall --refresh-skills` to update them.");return}var i=(yield Promise.all([t.e(7111),t.e(1708)]).then(t.bind(t,37495))).postinstall;yield i(e)}catch(e){h(e)}}),function(e){return o.apply(this,arguments)})),f.command("pull").description("Pull the latest project files from BRICKS (3-way git merge)").option("-f, --force","Force pull, committing any unstaged changes first").action((i=u(function*(e){try{var a=(yield t.e(9663).then(t.bind(t,47090))).pull;yield a(e)}catch(e){h(e)}}),function(e){return i.apply(this,arguments)})),f.command("push").description("Compile and push config to BRICKS without creating a release").option("--auto-commit","Auto-commit unstaged changes before pushing").option("--no-check","Skip the conflict guard (don't pass --last-commit-id)").option("--no-validate","Skip server-side config schema validation").option("-y, --yes","Skip all prompts").action((d=u(function*(e){try{var a=(yield Promise.all([t.e(6645),t.e(2151),t.e(7648),t.e(3593),t.e(9590)]).then(t.bind(t,85909))).compile,p=(yield t.e(2557).then(t.bind(t,71772))).push;yield a({check:!0}),yield p(e)}catch(e){h(e)}}),function(e){return d.apply(this,arguments)})),f.command("deploy").description("Compile and release the project to BRICKS").option("--changelogs <text>","Changelogs text for the release").option("--changelogs-file <path>","Read changelogs from a file").option("--auto-commit","Auto-commit unstaged changes before deploying").option("--auto-version","Auto-bump patch version before deploying").option("--version <version>","Set explicit version for the release").option("-y, --yes","Skip all prompts").action((r=u(function*(e){try{var a=(yield Promise.all([t.e(6645),t.e(2151),t.e(7648),t.e(3593),t.e(9590)]).then(t.bind(t,85909))).compile,p=(yield t.e(1215).then(t.bind(t,42914))).deploy;yield a({check:!0}),yield p(e)}catch(e){h(e)}}),function(e){return r.apply(this,arguments)})),f.command("compile").description("Typecheck and build the project config").option("--no-check","Skip the typecheck preflight").action((n=u(function*(e){try{var a=(yield Promise.all([t.e(6645),t.e(2151),t.e(7648),t.e(3593),t.e(9590)]).then(t.bind(t,85909))).compile;yield a(e)}catch(e){h(e)}}),function(e){return n.apply(this,arguments)})),f.command("simulator").description("Run the BRICKS web-preview simulator for the project").allowUnknownOption(!0).helpOption(!1).action((l=u(function*(e,a){try{var p=(yield t.e(9320).then(t.bind(t,7931))).simulator;yield p(a.args)}catch(e){h(e)}}),function(e,a){return l.apply(this,arguments)})),f.command("mcp").description("Start the project-local bricks-ctor MCP server (STDIO)").option("--project <dir>","Project root (default: current directory)").action((s=u(function*(e){try{var a=(yield Promise.all([t.e(9866),t.e(4479),t.e(4685),t.e(6194)]).then(t.bind(t,95417))).startCtorMcpServer;yield a(e.project)}catch(e){h(e)}}),function(e){return s.apply(this,arguments)}))},55609(e,a,t){t.d(a,{E:()=>W});var p,o,i,d,r,n,l,s,u,m,c,f,h,v,g,D,y,w,b,_=t(68832),C=t(99436),F=t(79896),S=t(35679),E=t(73284),k=t(7586),A=t(56493),N=t(8479),$=t(47988),O=t(31596),x=t(98593),T=(p=C(function*(){return(yield Promise.resolve().then(t.bind(t,30155))).default}),function(){return p.apply(this,arguments)}),B=(o=C(function*(e,a){return e.json?null:(yield T())(a).start()}),function(e,a){return o.apply(this,arguments)}),I=(i=C(function*(){return t.e(5658).then(t.bind(t,27521))}),function(){return i.apply(this,arguments)}),j=(d=C(function*(){return t.e(1936).then(t.bind(t,76627))}),function(){return d.apply(this,arguments)}),V=(r=C(function*(){return t.e(9387).then(t.bind(t,30182))}),function(){return r.apply(this,arguments)}),P=(n=C(function*({message:e,autoYes:a,json:t}){if(a)return!0;if(t)throw Error("Confirmation required: pass -y/--yes together with --json");if(!(0,N.isInteractiveTerminal)())throw Error("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.");try{var p=(yield I()).confirm;return yield p({message:e,default:!1})}catch{return!1}}),function(e){return n.apply(this,arguments)}),R=({spinner:e,error:a,options:t,action:p,target:o})=>{var i=a.message;i?.includes(O.GE)?i=`${O.GE} Run \`bricks data enable\` first.`:a.isBankAuthError&&(i=`${i}
45
+ Found ${n.length} buttress-server(s)`)),console.log("─".repeat(70)),n)){var c=!1===m.verified?g.default.red("unverified"):g.default.green("online"),f=m.workspace?.id,h=f&&u&&f===u,v=m.authentication?.bound?g.default.yellow("JWT required"):g.default.gray("open");console.log(` ${g.default.bold(m.name||"Unknown")} ${g.default.gray(`(${m.address}:${m.port})`)} [${c}]`),m.id&&console.log(` Server id: ${g.default.cyan(m.id)}`),m.version&&console.log(` Version: ${g.default.green(m.version)}`);var D=m.authentication?.kid?g.default.gray(` (kid: ${m.authentication.kid})`):"";if(console.log(` Auth: ${v}${D}`),f){var y=h?g.default.green(`${f} ${g.default.bold("(current profile)")}`):g.default.gray(f);console.log(` Workspace: ${y}`)}if(Array.isArray(m.generators)&&m.generators.length>0)for(var w of(console.log(" Generators:"),m.generators)){var b=[];"number"==typeof w.score&&b.push(`score ${w.score.toFixed(1)}`),!0===w.hasGpu?b.push("GPU ✓"):!1===w.hasGpu&&b.push("GPU ✗"),"number"==typeof w.usableBytes&&b.push(`${(w.usableBytes/0x40000000).toFixed(1)} GB usable`);var _=b.length>0?` ${g.default.gray(b.join(" "))}`:"";console.log(` - ${g.default.cyan(w.type)}${_}`)}}console.log("─".repeat(70)),n.some(e=>e.authentication?.bound)&&(console.log(),console.log(g.default.gray("To connect to a bound server, run `bricks buttress issue-token` for a workspace access token.")))}),function(e){return f.apply(this,arguments)}))},71335(e,a,t){t.d(a,{oT:()=>s});var p=t(35679),o=t(73284),i=t(47988),d={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},r=e=>{var a=Object.entries(d).find(([,a])=>e===a);return a?a[0]:null},n={prod:"https://activity-log.bricks.tools",beta:"https://activity-log-beta.bricks.tools",dev:"http://localhost:8088"},l=e=>{var a=Object.entries(n).find(([,a])=>e===a);return a?a[0]:null},s=new p.uB("config").description("CLI configuration management");s.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,a)=>{if(!e){var t=(0,i.getBaseUrl)(),p=r(t),s=(0,i.getActivityLogBaseUrl)(),u=l(s);console.log(o.default.bold("\nEndpoint Configuration")),console.log("─".repeat(50)),console.log(o.default.bold("BRICKS")),console.log(` URL: ${o.default.cyan(t)}`),console.log(` Environment: ${p?o.default.green(p):o.default.yellow("custom")}`),console.log(o.default.bold("Activity Log")),console.log(` URL: ${o.default.cyan(s)}`),console.log(` Environment: ${u?o.default.green(u):o.default.yellow("custom")}`),console.log("─".repeat(50)),console.log(o.default.gray("\nUsage: bricks config endpoint <prod|beta|dev>"));return}var m=Object.keys(d);m.includes(e)||(console.error(o.default.red(`Invalid environment: ${e}`)),console.log(o.default.gray(`Valid options: ${m.join(", ")}`)),process.exit(1));var c=d[e],f=n[e],h=a.profile?(0,i.getCurrentProfile)():null;(0,i.setBaseUrl)(c,h),(0,i.setActivityLogBaseUrl)(f,h);var v=a.profile?` (profile: ${(0,i.getCurrentProfile)()})`:"";console.log(o.default.green(`✓ Endpoint changed to ${e}${v}`)),console.log(o.default.gray(` BRICKS: ${c}`)),console.log(o.default.gray(` Activity Log: ${f}`)),console.log(o.default.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(o.default.gray("Use `bricks auth status` to check your connection."))}),s.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(e=>{var a=(0,i.getBaseUrl)(),t=r(a);if(e.json)return void console.log(JSON.stringify({endpoint:a,environment:t||"custom"},null,2));console.log(o.default.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`BRICKS: ${o.default.cyan(a)}`),t?console.log(`Environment: ${o.default.green(t)}`):console.log(`Environment: ${o.default.yellow("custom")}`);var p=(0,i.getActivityLogBaseUrl)(),d=l(p);console.log(`Activity Log: ${o.default.cyan(p)} ${d?o.default.green(`(${d})`):o.default.yellow("(custom)")}`),console.log("─".repeat(50))})},22175(e,a,t){t.d(a,{g:()=>h});var p,o,i,d,r,n,l,s,u=t(99436),m=t(35679),c=t(73284),f=t(90003),h=new m.uB("ctor").description("BRICKS Project (ctor) tooling: scaffold, sync, compile, deploy, and serve the project"),v=e=>{console.error(c.default.red(e?.message||String(e))),process.exit(1)};(0,f.x)(h.command("init <id>").description("Initialize a BRICKS Project from an application or module").option("--type <type>","Project type: app or module","app")).action((p=u(function*(e,a){var p="module"===a.type?"module":"application",o=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield o(p,e,a)}),function(e,a){return p.apply(this,arguments)})),h.command("postinstall").description("Regenerate the ctor/ library, MCP config, and skills (run from a project)").option("--skip-copy-project","Skip copying the ctor/ library into the project").option("--refresh-skills","Also overwrite bundled skill files whose content changed (default keeps existing skills)").option("--check","Compare the bundled ctor/skills assets against the project without writing (always exits 0; read the output)").option("-j, --json","With --check, output the comparison as JSON").action((o=u(function*(e){try{if(e.check){var a=(yield Promise.all([t.e(7111),t.e(1708)]).then(t.bind(t,37495))).checkProjectAssets,p=yield a();if(e.json)return void console.log(JSON.stringify(p,null,2));if(p.upToDate)return void console.log(`Project assets match the bundled snapshot (CLI ${p.cliVersion}).`);var o=(e,{changed:a,missing:t})=>{if(a.length||t.length){for(var p of(console.log(`${e}: ${a.length} changed, ${t.length} missing`),a))console.log(` ~ ${p}`);for(var o of t)console.log(` + ${o}`)}};console.log(`Project assets differ from the bundled snapshot (CLI ${p.cliVersion}):`),o("ctor/",p.lib),o("skills",p.skills),console.log("Run `bricks ctor postinstall --refresh-skills` to update them.");return}var i=(yield Promise.all([t.e(7111),t.e(1708)]).then(t.bind(t,37495))).postinstall;yield i(e)}catch(e){v(e)}}),function(e){return o.apply(this,arguments)})),h.command("pull").description("Pull the latest project files from BRICKS (3-way git merge)").option("-f, --force","Force pull, committing any unstaged changes first").action((i=u(function*(e){try{var a=(yield t.e(9663).then(t.bind(t,47090))).pull;yield a(e)}catch(e){v(e)}}),function(e){return i.apply(this,arguments)})),h.command("push").description("Compile and push config to BRICKS without creating a release").option("--auto-commit","Auto-commit unstaged changes before pushing").option("--no-check","Skip the conflict guard (don't pass --last-commit-id)").option("--no-validate","Skip server-side config schema validation").option("-y, --yes","Skip all prompts").action((d=u(function*(e){try{var a=(yield Promise.all([t.e(6645),t.e(2151),t.e(7648),t.e(3593),t.e(9590)]).then(t.bind(t,85909))).compile,p=(yield t.e(2557).then(t.bind(t,71772))).push;yield a({check:!0}),yield p(e)}catch(e){v(e)}}),function(e){return d.apply(this,arguments)})),h.command("deploy").description("Compile and release the project to BRICKS").option("--changelogs <text>","Changelogs text for the release").option("--changelogs-file <path>","Read changelogs from a file").option("--auto-commit","Auto-commit unstaged changes before deploying").option("--auto-version","Auto-bump patch version before deploying").option("--version <version>","Set explicit version for the release").option("-y, --yes","Skip all prompts").action((r=u(function*(e){try{var a=(yield Promise.all([t.e(6645),t.e(2151),t.e(7648),t.e(3593),t.e(9590)]).then(t.bind(t,85909))).compile,p=(yield t.e(1215).then(t.bind(t,42914))).deploy;yield a({check:!0}),yield p(e)}catch(e){v(e)}}),function(e){return r.apply(this,arguments)})),h.command("compile").description("Typecheck and build the project config").option("--no-check","Skip the typecheck preflight").action((n=u(function*(e){try{var a=(yield Promise.all([t.e(6645),t.e(2151),t.e(7648),t.e(3593),t.e(9590)]).then(t.bind(t,85909))).compile;yield a(e)}catch(e){v(e)}}),function(e){return n.apply(this,arguments)})),h.command("simulator").description("Run the BRICKS web-preview simulator for the project").allowUnknownOption(!0).helpOption(!1).action((l=u(function*(e,a){try{var p=(yield t.e(9320).then(t.bind(t,7931))).simulator;yield p(a.args)}catch(e){v(e)}}),function(e,a){return l.apply(this,arguments)})),h.command("mcp").description("Start the project-local bricks-ctor MCP server (STDIO)").option("--project <dir>","Project root (default: current directory)").action((s=u(function*(e){try{var a=(yield Promise.all([t.e(9866),t.e(4479),t.e(4685),t.e(6194)]).then(t.bind(t,95417))).startCtorMcpServer;yield a(e.project)}catch(e){v(e)}}),function(e){return s.apply(this,arguments)}))},55609(e,a,t){t.d(a,{E:()=>W});var p,o,i,d,r,n,l,s,u,m,c,f,h,v,g,D,y,w,b,_=t(68832),C=t(99436),F=t(79896),S=t(35679),E=t(73284),k=t(7586),A=t(56493),N=t(8479),$=t(47988),O=t(31596),x=t(98593),T=(p=C(function*(){return(yield Promise.resolve().then(t.bind(t,30155))).default}),function(){return p.apply(this,arguments)}),B=(o=C(function*(e,a){return e.json?null:(yield T())(a).start()}),function(e,a){return o.apply(this,arguments)}),I=(i=C(function*(){return t.e(5658).then(t.bind(t,27521))}),function(){return i.apply(this,arguments)}),j=(d=C(function*(){return t.e(1936).then(t.bind(t,76627))}),function(){return d.apply(this,arguments)}),V=(r=C(function*(){return t.e(9387).then(t.bind(t,30182))}),function(){return r.apply(this,arguments)}),P=(n=C(function*({message:e,autoYes:a,json:t}){if(a)return!0;if(t)throw Error("Confirmation required: pass -y/--yes together with --json");if(!(0,N.isInteractiveTerminal)())throw Error("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.");try{var p=(yield I()).confirm;return yield p({message:e,default:!1})}catch{return!1}}),function(e){return n.apply(this,arguments)}),R=({spinner:e,error:a,options:t,action:p,target:o})=>{var i=a.message;i?.includes(O.GE)?i=`${O.GE} Run \`bricks data enable\` first.`:a.isBankAuthError&&(i=`${i}
46
46
  The Data Bank key may be invalid or revoked — run \`bricks data login\` to reissue.`),t.json?(0,k.OW)(i,{action:p,...o&&{target:o}}):e?e.fail(i):console.error(E.default.red(i)),process.exit(1)},M=e=>{try{return JSON.parse(e)}catch{return e}},U=(e,a)=>{try{return JSON.parse(e)}catch{throw Error(`Invalid JSON for ${a}`)}},L=e=>e.split(",").map(e=>e.trim()).filter(Boolean),q=e=>({name:e.name,meta:e.meta,value:(0,k.$l)(e.value),enableExpired:!!e.enableExpired,expiredAt:e.expiredAt||null,createAt:e.createAt||null,hasReadLimit:!!e.limitedReadProperties?.length,hasWriteLimit:!!e.limitedWriteProperties?.length}),J=(l=C(function*(e){var a=yield e.workspace();return a?.bank||{}}),function(e){return l.apply(this,arguments)}),G=()=>{var e=(0,$.getCurrentProfile)(),a=(0,A.requireAuthConnection)(e),t=a.baseUrl,p=a.client;return{profile:e,baseUrl:t,client:p,fingerprint:a.fingerprint,bank:a.bank}},H=(s=C(function*(e,{profile:a,baseUrl:t,fingerprint:p,bank:o}){var i=(yield j()).resolveBankCredentials,d=yield V(),r=d.createBankClient,n=d.resolveBankEndpoint,l=yield i(e,{profile:a,expectedProfile:p,bank:o});return r({endpoint:n(t),spacename:l.spacename,spacekey:l.spacekey})}),function(e,a){return s.apply(this,arguments)}),W=new S.uB("data").description("Data Bank (remote properties) management");W.command("status").description("Show Data Bank status for this workspace").option("-j, --json","Output as JSON").action((u=C(function*(e){var a=G(),t=a.client,p=a.bank,o=yield B(e,"Fetching Data Bank status...");try{var i=yield J(t),d={enabled:!!i.enable_remote_update,spacename:i.spacename||null,keys:(i.keys||[]).map(q),cliKey:p?{keyName:p.keyName||null,spacekey:(0,k.$l)(p.spacekey),issuedAt:p.issuedAt||null}:null};if(o&&o.stop(),e.json)return void(0,k.GF)(d);console.log(E.default.bold("\nData Bank")),console.log("─".repeat(60)),console.log(`Enabled: ${d.enabled?E.default.green("Yes"):E.default.red("No")}`),console.log(`Spacename: ${d.spacename||E.default.gray("N/A")}`),console.log(`Keys: ${d.keys.length}`),console.log(`CLI Key: ${d.cliKey?`${d.cliKey.keyName||"Unnamed"} ${E.default.gray(`(${d.cliKey.spacekey})`)}`:E.default.gray("none (issued automatically on first use)")}`),console.log("─".repeat(60)),d.enabled||console.log(E.default.yellow("Run `bricks data enable` to enable Data Bank."))}catch(a){R({spinner:o,error:a,options:e,action:"data.status"})}}),function(e){return u.apply(this,arguments)}));var K=(m=C(function*(e,a){var t=G().client,p=e?"data.enable":"data.disable",o=yield B(a,`${e?"Enabling":"Disabling"} Data Bank...`);try{var i=yield t.updateWorkspace({enableBankRemoteUpdate:e}),d=i?.bank||{};o&&o.stop(),(0,x.yd)({action:p,target:{spacename:d.spacename||null},result:{enabled:!!d.enable_remote_update},json:a.json,message:e?`${E.default.green("Data Bank enabled.")} Spacename: ${E.default.cyan(d.spacename)}`:E.default.green("Data Bank disabled.")})}catch(e){R({spinner:o,error:e,options:a,action:p})}}),function(e,a){return m.apply(this,arguments)});W.command("enable").description("Enable Data Bank on this workspace").option("-j, --json","Output as JSON").action(e=>K(!0,e)),W.command("disable").description("Disable Data Bank on this workspace").option("-j, --json","Output as JSON").action(e=>K(!1,e)),W.command("login").description("Issue a Data Bank space key and save it to the active profile").option("--name <keyName>","Space key name","bricks-cli").option("-j, --json","Output as JSON").action((c=C(function*(e){var a=G(),t=a.client,p=a.profile,o=a.fingerprint,i=a.bank,d=yield B(e,"Issuing Data Bank key...");try{var r=(yield j()).issueBankCredentials,n=yield r(t,{keyName:e.name,profile:p,expectedProfile:o,bank:i});d&&d.stop(),(0,x.yd)({action:"data.login",target:{spacename:n.spacename},result:{keyName:n.keyName,spacekey:(0,k.$l)(n.spacekey),issuedAt:n.issuedAt},json:e.json,message:`${E.default.green("Data Bank key issued and saved.")} ${E.default.gray(`(${n.keyName}, stored in ${$.CONFIG_PATH})`)}`})}catch(a){R({spinner:d,error:a,options:e,action:"data.login"})}}),function(e){return c.apply(this,arguments)})),W.command("logout").description("Remove the stored Data Bank key from the active profile").option("--revoke","Also revoke the key on the workspace").option("-j, --json","Output as JSON").action((f=C(function*(e){var a=G(),t=a.client,p=a.profile,o=a.fingerprint,i=a.bank,d=yield B(e,"Clearing Data Bank key...");try{var r=(yield j()).clearStoredBankCredentials,n=yield r(t,{revoke:e.revoke,profile:p,expectedProfile:o,bank:i}),l=n.cleared,s=n.revoked;d&&d.stop(),(0,x.yd)({action:"data.logout",target:{profile:p},result:{cleared:l,revoked:s},json:e.json,message:l?E.default.green(`Data Bank key removed${s?" and revoked":""}.`):E.default.yellow("No Data Bank key stored for this profile.")})}catch(a){R({spinner:d,error:a,options:e,action:"data.logout"})}}),function(e){return f.apply(this,arguments)}));var z=new S.uB("keys").description("Data Bank space key management");W.addCommand(z),z.command("list").description("List Data Bank space keys (values are masked; use --json for full values)").option("-j, --json","Output as JSON (includes full key values)").action((h=C(function*(e){var a=G().client,t=yield B(e,"Fetching space keys...");try{var p=(yield J(a)).keys||[];if(t&&t.stop(),e.json)return void(0,k.GF)(p);if(0===p.length)return void console.log(E.default.yellow("No space keys found"));console.log(E.default.bold("\nData Bank Space Keys")),console.log("─".repeat(60)),p.map(q).forEach(e=>{var a=e.enableExpired?`expires ${e.expiredAt}`:"no expiry",t=[e.hasReadLimit&&"read-limited",e.hasWriteLimit&&"write-limited"].filter(Boolean).join(", ");console.log(`● ${E.default.cyan(e.name||"Unnamed")} ${E.default.gray(`(${e.meta})`)}`),console.log(` Value: ${E.default.gray(e.value)}`),console.log(` Expiry: ${E.default.gray(a)}${t?E.default.gray(`, ${t}`):""}`),console.log()}),console.log("─".repeat(60))}catch(a){R({spinner:t,error:a,options:e,action:"data.keys.list"})}}),function(e){return h.apply(this,arguments)})),z.command("new <name>").description("Create a new Data Bank space key").option("--expire-at <date>","Expiry time (ISO date, between 1 hour and 90 days from now)").option("--read <propertyIds>","Limit readable properties (comma separated)").option("--write <propertyIds>","Limit writable properties (comma separated)").option("-j, --json","Output as JSON").action((v=C(function*(e,a){var t=G().client,p=yield B(a,"Creating space key...");try{if(a.expireAt&&Number.isNaN(Date.parse(a.expireAt)))throw Error(`Invalid --expire-at date: ${a.expireAt}`);var o=yield J(t),i=new Set((o.keys||[]).map(e=>e.value)),d=yield t.updateWorkspace({newBankKey:{name:e,enableExpired:!!a.expireAt,expiredAt:a.expireAt,limitedReadProps:a.read?L(a.read):void 0,limitedWriteProps:a.write?L(a.write):void 0}}),r=d?.bank?.keys||[],n=r.find(e=>!i.has(e.value))||r.filter(a=>a.name===e).at(-1);if(!n)throw Error("Space key was not created");p&&p.stop(),(0,x.yd)({action:"data.keys.new",target:{name:e},result:n,json:a.json,message:E.default.green(`Space key "${e}" created.`)}),a.json||(console.log(E.default.yellow("\n⚠ Copy this key now — it will not be shown again in full:")),console.log(n.value))}catch(t){R({spinner:p,error:t,options:a,action:"data.keys.new",target:{name:e}})}}),function(e,a){return v.apply(this,arguments)})),z.command("revoke <keyOrName>").description("Revoke a Data Bank space key by value or name").option("-y, --yes","Skip confirmation prompt").option("-j, --json","Output as JSON").action((g=C(function*(e,a){var t=G().client,p=yield B(a,"Resolving space key...");try{var o=(yield J(t)).keys||[],i=o.filter(a=>a.value===e);if(0===i.length&&(i=o.filter(a=>a.name===e)),0===i.length)throw Error(`No space key matched "${e}"`);if(i.length>1)throw Error(`Multiple space keys named "${e}"; pass the exact key value instead`);var d=i,r=_(d,1)[0];if(p&&p.stop(),!(yield P({message:`Revoke space key "${r.name}" (${(0,k.$l)(r.value)})?`,autoYes:a.yes,json:a.json})))return void console.log(E.default.yellow("Cancelled"));yield t.updateWorkspace({revokeBankKey:r.value}),(0,x.yd)({action:"data.keys.revoke",target:{name:r.name,meta:r.meta},result:{revoked:!0},json:a.json,message:E.default.green(`Space key "${r.name}" revoked.`)})}catch(e){R({spinner:p,error:e,options:a,action:"data.keys.revoke"})}}),function(e,a){return g.apply(this,arguments)})),W.command("list").description("List Data Bank properties").option("-k, --keyword <keyword>","Filter by definition title / description or tags").option("-m, --meta <meta>",`Filter by meta (${O.YC.join(" | ")})`).option("-j, --json","Output as JSON").action((D=C(function*(e){var a=G(),t=a.client,p=yield B(e,"Fetching properties...");try{(0,O.jR)(e.meta);var o=yield H(t,a),i=yield o.listProperties({keyword:e.keyword,meta:e.meta});if(p&&p.stop(),e.json)return void(0,k.GF)(i||[]);if(!i||0===i.length)return void console.log(E.default.yellow("No Data Bank properties found"));console.log(E.default.bold(`
47
47
  Data Bank Properties (${i.length})`)),console.log("─".repeat(80)),i.forEach(e=>{var a=e.definition?.title;console.log(`● ${E.default.cyan(e.propertyId)} ${E.default.gray(`(${e.meta})`)}${a?` ${a}`:""}`),e.tags?.length&&console.log(` Tags: ${e.tags.join(", ")}`),console.log(` Value: ${(e=>{if(null==e)return E.default.gray("null");var a=JSON.stringify(e);return a.length>60?`${a.slice(0,60)}…`:a})(e.value)}`),console.log(` Updated: ${E.default.gray(e.updateAt)}`),console.log()}),console.log("─".repeat(80))}catch(a){R({spinner:p,error:a,options:e,action:"data.list"})}}),function(e){return D.apply(this,arguments)})),W.command("get <propertyId>").description("Get a Data Bank property").option("-j, --json","Output as JSON").action((y=C(function*(e,a){var t=G(),p=t.client,o=yield B(a,"Fetching property...");try{var i=yield H(p,t),d=yield i.getProperty(e);if(!d)throw Error(`Property not found: ${e}`);if(o&&o.stop(),a.json)return void(0,k.GF)(d);console.log(E.default.bold(`
48
48
  Data Bank Property: ${d.propertyId}`)),console.log("─".repeat(60)),console.log(`Meta: ${d.meta}`),console.log(`Title: ${d.definition?.title||E.default.gray("N/A")}`),console.log(`Tags: ${d.tags?.join(", ")||E.default.gray("None")}`),console.log(`Last Note: ${d.lastUpdateNote||E.default.gray("N/A")}`),console.log(`Updated: ${E.default.gray(d.updateAt)}`),console.log(`Created: ${E.default.gray(d.createAt)}`),console.log(`
@@ -84,24 +84,24 @@ Device Group: ${o.name}`)),console.log("─".repeat(60)),console.log(`ID:
84
84
  ${c.default.bold("Devices")} (${o.devices.length})`),o.devices.forEach(e=>{var a=e.device_target_name||e.device_id;console.log(` - ${a} ${c.default.gray(`(${e.device_id})`)}`)})),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get group: ${e.message}`),process.exit(1)}}),function(e,a){return o.apply(this,arguments)})),_.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((i=u(function*(e,a){var t=(0,v.requireAuth)(),p=a.json?null:(0,f.default)("Resolving device group...").start();try{var o=yield(0,g.Y)(()=>t.deviceGroup({id:e})),i=o?[o]:yield t.deviceGroups({paginate:{limit:a.limit}}),d=o?i:(i||[]).filter(a=>a.name?.toLowerCase().includes(e.trim().toLowerCase())),r=(0,g.K)({resource:"group",query:e,items:d||[],fields:["_id","name"],selectedBy:o?"id":null});if(p&&p.stop(),a.json)return void(0,h.GF)(r);if(r.resolved){var n=r.resolved;console.log(c.default.bold("\nResolved Device Group")),console.log("─".repeat(60)),console.log(`Name: ${c.default.cyan(n.name||"Unnamed")}`),console.log(`ID: ${c.default.gray(n._id)}`),console.log(`Selected By: ${r.selectedBy}`),console.log("─".repeat(60));return}if(0===r.matches.length)return void console.log(c.default.yellow(`No device groups matched "${e}"`));console.log(c.default.bold(`
85
85
  Matching Device Groups (${r.matches.length})`)),console.log("─".repeat(80)),r.matches.forEach(e=>{console.log(`${c.default.cyan(e.name||"Unnamed")} ${c.default.gray(e._id)}`)}),console.log("─".repeat(80))}catch(a){p?p.fail(`Failed to resolve device group: ${a.message}`):(0,h.OW)(a.message,{resource:"group",query:e}),process.exit(1)}}),function(e,a){return i.apply(this,arguments)})),_.command("devices <id>").description("List devices in a group with status").option("-j, --json","Output as JSON").action((d=u(function*(e,a){var t=(0,v.requireAuth)(),p=(0,f.default)("Fetching devices...").start();try{var o=yield t.devicesByGroup({id:e});if(p.stop(),a.json)return void console.log(JSON.stringify(o,null,2));if(!o||0===o.length)return void console.log(c.default.yellow("No devices in this group"));console.log(c.default.bold("\nDevices in Group")),console.log("─".repeat(80)),o.forEach(e=>{var a=e.device||{},t=a.entry_detail?.watch_dog_timer?.last_alive_time,p=y(t),o=a.name||a.device_name||e.target_name||a._id||"Unknown",i=a.entry_detail?.application?.name||c.default.gray("No app");console.log(`${p} ${c.default.cyan(o.padEnd(30))} ${i}`)}),console.log("─".repeat(80))}catch(e){p.fail(`Failed to get devices: ${e.message}`),process.exit(1)}}),function(e,a){return d.apply(this,arguments)})),_.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((r=u(function*(e,a,t){var p=(0,v.requireAuth)(),o=t.json?null:(0,f.default)(`Dispatching ${a}...`).start();b.includes(a)||(t.json?(0,h.OW)(`Invalid action. Valid actions: ${b.join(", ")}`,{action:"group.dispatch",target:{id:e}}):o.fail(`Invalid action. Valid actions: ${b.join(", ")}`),process.exit(1));try{var i=yield p.deviceGroup({id:e});if(!i)throw Error("Device group not found");if(t.dryRun){o&&o.stop(),(0,D.S5)({action:"group.dispatch",target:w(i,e),request:{action:a},checks:[(0,D.Iy)("group exists",!0,`${i.name} (${i._id})`),(0,D.Iy)("action is valid",!0)],json:t.json});return}var d=yield p.dispatchDeviceGroupAction({id:e,action:a});t.json?(0,D.yd)({action:"group.dispatch",target:w(i,e),result:{action:a,dispatched:d?.dispatched||0,devices:d?.devices||0},json:!0}):(o.succeed(`Action dispatched: ${c.default.green(a)}`),d&&(console.log(`Dispatched: ${c.default.green(d.dispatched||0)}`),console.log(`Devices: ${c.default.gray(d.devices||0)}`)))}catch(a){t.json?(0,h.OW)(a.message,{action:"group.dispatch",target:{id:e}}):o.fail(`Failed to dispatch action: ${a.message}`),process.exit(1)}}),function(e,a,t){return r.apply(this,arguments)})),_.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((n=u(function*(e,a){var t=(0,v.requireAuth)(),p=a.json?null:(0,f.default)("Refreshing devices...").start();try{var o=yield t.deviceGroup({id:e});if(!o)throw Error("Device group not found");if(a.dryRun){p&&p.stop(),(0,D.S5)({action:"group.refresh",target:w(o,e),request:{action:"refresh"},checks:[(0,D.Iy)("group exists",!0,`${o.name} (${o._id})`)],json:a.json});return}var i=yield t.dispatchDeviceGroupAction({id:e,action:"refresh"});a.json?(0,D.yd)({action:"group.refresh",target:w(o,e),result:{dispatched:i?.dispatched||0,devices:i?.devices||0},json:!0}):(p.succeed("Devices refreshed"),i&&(console.log(`Dispatched: ${c.default.green(i.dispatched||0)}`),console.log(`Devices: ${c.default.gray(i.devices||0)}`)))}catch(t){a.json?(0,h.OW)(t.message,{action:"group.refresh",target:{id:e}}):p.fail(`Failed to refresh: ${t.message}`),process.exit(1)}}),function(e,a){return n.apply(this,arguments)})),_.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,a){var t,p=(0,v.requireAuth)(),o=1e3*parseInt(a.interval,10);console.log(c.default.bold("\nDevice Group Monitor")),console.log(c.default.gray(`Polling every ${a.interval}s. Press Ctrl+C to stop.
86
86
  `));var i=(t=u(function*(){try{var a=yield Promise.all([p.deviceGroup({id:e}),p.devicesByGroup({id:e})]),t=s(a,2),o=t[0],i=t[1];if(process.stdout.write("\x1b[2J\x1b[0f"),console.log(c.default.bold(`Device Group: ${o.name}`)+c.default.gray(` - ${new Date().toLocaleTimeString()}`)),console.log("─".repeat(80)),!i||0===i.length)return void console.log(c.default.yellow("No devices in this group"));var d=0,r=0;i.forEach(e=>{var a=e.device||{},t=a.entry_detail?.watch_dog_timer?.last_alive_time,p=y(t),o=a.name||a.device_name||e.target_name||a._id||"Unknown",i=a.entry_detail?.application?.name||c.default.gray("No app");t&&Date.now()-new Date(t).getTime()<=3e5?d++:r++,console.log(`${p} ${c.default.cyan(o.padEnd(30))} ${i}`)}),console.log("─".repeat(80)),console.log(`Online: ${c.default.green(d)} Offline: ${c.default.red(r)}`),console.log(`
87
- ${c.default.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(c.default.red(`Error: ${e.message}`))}}),function(){return t.apply(this,arguments)});yield i(),setInterval(i,o)}),function(e,a){return l.apply(this,arguments)}))},68473(e,a,t){t.d(a,{K:()=>u});var p,o,i=t(99436),d=t(35679),r=t(73284),n=t(47988),l=t(31802),s=(p=i(function*(e){return(0,(yield Promise.all([t.e(9866),t.e(3332),t.e(6645),t.e(4479),t.e(7648),t.e(853),t.e(1010),t.e(8117)]).then(t.bind(t,98372))).startStdioServer)(e)}),function(e){return p.apply(this,arguments)}),u=new d.uB("mcp").description("MCP server management");u.command("start").description("Start the BRICKS MCP server in STDIO mode").option("-t, --token <token>","API token (overrides saved token)").action((o=i(function*(e){var a=(0,n.getCurrentProfile)(),t=(0,l.getConnectionContext)(a),p=t.auth,o=t.baseUrl,i=t.activityLogBaseUrl,d=e.token?null:p,u=e.token||(d?.kind==="token"?d.token:null);u||d||(console.error(r.default.red("Error: No API credential found.")),console.error(r.default.gray("Please login first with: bricks auth login")),console.error(r.default.gray("Or provide a token with: bricks mcp start --token <token>")),process.exit(1));try{yield s({...u?{token:u}:{getAuthHeaders:d.getHeaders},baseUrl:o,activityLogBaseUrl:i})}catch(e){console.error(r.default.red(`Failed to start MCP server: ${e.message}`)),process.exit(1)}}),function(e){return o.apply(this,arguments)}))},12569(e,a,t){t.d(a,{u:()=>y});var p,o,i,d,r,n,l,s,u,m=t(68832),c=t(99436),f=t(35679),h=()=>(s||(s=Promise.all([Promise.resolve().then(t.bind(t,73284)),Promise.resolve().then(t.bind(t,30155)),Promise.resolve().then(t.bind(t,56493)),t.e(831).then(t.bind(t,60450))]).then(([e,a,t,p])=>({chalk:e.default,ora:a.default,requireAuth:t.requireAuth,isMediaEnabled:p.isMediaEnabled,buildScreenshotUrl:p.buildScreenshotUrl}))),s),v=(p=c(function*(e,a){var t=yield e.workspace();if(!a.isMediaEnabled(t))throw Error("Media workspace not enabled for this workspace")}),function(e,a){return p.apply(this,arguments)}),g=e=>{var a=e.meta||{};if(!a.originalFileUploaded)return{ready:!1,label:"Uploading"};if("Video"===e.fileType){if(!a.videoThumbOriginalFileKey)return{ready:!1,label:"Processing"};if(!a.convertedFileUploaded)return{ready:!1,label:"Transcoding"}}return{ready:!0,label:"Ready"}},D=(e,a)=>e.ready?a.green(e.label):a.yellow(e.label),y=new f.uB("media").description("Media Flow support");y.command("boxes").description("List Media Flow boxes").option("-j, --json","Output as JSON").action((o=c(function*(e){var a=yield h(),t=a.chalk,p=a.requireAuth(),o=a.ora("Fetching media boxes...").start();try{yield v(p,a);var i=yield p.mediaBoxes();if(o.stop(),e.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(t.yellow("No media boxes found"));console.log(t.bold("\nMedia Boxes")),console.log("─".repeat(80)),i.forEach(e=>{console.log(`${t.cyan(e.name||"Unnamed")} ${t.gray(e.id)}`),e.description&&console.log(` ${e.description}`),e.tags?.length&&console.log(` Tags: ${e.tags.join(", ")}`),null!=e.size&&console.log(` Size: ${e.size}`),console.log()})}catch(e){o.fail(`Failed to list media boxes: ${e.message}`),process.exit(1)}}),function(e){return o.apply(this,arguments)})),y.command("box <id>").description("Get Media Flow box details").option("-j, --json","Output as JSON").action((i=c(function*(e,a){var t=yield h(),p=t.chalk,o=t.requireAuth(),i=t.ora("Fetching media box...").start();try{yield v(o,t);var d=yield o.mediaBox({id:e});if(i.stop(),d||(console.log(p.red("Media box not found")),process.exit(1)),a.json)return void console.log(JSON.stringify(d,null,2));console.log(p.bold(`
87
+ ${c.default.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(c.default.red(`Error: ${e.message}`))}}),function(){return t.apply(this,arguments)});yield i(),setInterval(i,o)}),function(e,a){return l.apply(this,arguments)}))},68473(e,a,t){t.d(a,{K:()=>u});var p,o,i=t(99436),d=t(35679),r=t(73284),n=t(47988),l=t(31802),s=(p=i(function*(e){return(0,(yield Promise.all([t.e(9866),t.e(3332),t.e(6645),t.e(4479),t.e(7648),t.e(853),t.e(1010),t.e(7233)]).then(t.bind(t,63288))).startStdioServer)(e)}),function(e){return p.apply(this,arguments)}),u=new d.uB("mcp").description("MCP server management");u.command("start").description("Start the BRICKS MCP server in STDIO mode").option("-t, --token <token>","API token (overrides saved token)").action((o=i(function*(e){var a=(0,n.getCurrentProfile)(),t=(0,l.getConnectionContext)(a),p=t.auth,o=t.baseUrl,i=t.activityLogBaseUrl,d=e.token?null:p,u=e.token||(d?.kind==="token"?d.token:null);u||d||(console.error(r.default.red("Error: No API credential found.")),console.error(r.default.gray("Please login first with: bricks auth login")),console.error(r.default.gray("Or provide a token with: bricks mcp start --token <token>")),process.exit(1));try{yield s({...u?{token:u}:{getAuthHeaders:d.getHeaders},baseUrl:o,activityLogBaseUrl:i})}catch(e){console.error(r.default.red(`Failed to start MCP server: ${e.message}`)),process.exit(1)}}),function(e){return o.apply(this,arguments)}))},12569(e,a,t){t.d(a,{u:()=>y});var p,o,i,d,r,n,l,s,u,m=t(68832),c=t(99436),f=t(35679),h=()=>(s||(s=Promise.all([Promise.resolve().then(t.bind(t,73284)),Promise.resolve().then(t.bind(t,30155)),Promise.resolve().then(t.bind(t,56493)),t.e(831).then(t.bind(t,60450))]).then(([e,a,t,p])=>({chalk:e.default,ora:a.default,requireAuth:t.requireAuth,isMediaEnabled:p.isMediaEnabled,buildScreenshotUrl:p.buildScreenshotUrl}))),s),v=(p=c(function*(e,a){var t=yield e.workspace();if(!a.isMediaEnabled(t))throw Error("Media workspace not enabled for this workspace")}),function(e,a){return p.apply(this,arguments)}),g=e=>{var a=e.meta||{};if(!a.originalFileUploaded)return{ready:!1,label:"Uploading"};if("Video"===e.fileType){if(!a.videoThumbOriginalFileKey)return{ready:!1,label:"Processing"};if(!a.convertedFileUploaded)return{ready:!1,label:"Transcoding"}}return{ready:!0,label:"Ready"}},D=(e,a)=>e.ready?a.green(e.label):a.yellow(e.label),y=new f.uB("media").description("Media Flow support");y.command("boxes").description("List Media Flow boxes").option("-j, --json","Output as JSON").action((o=c(function*(e){var a=yield h(),t=a.chalk,p=a.requireAuth(),o=a.ora("Fetching media boxes...").start();try{yield v(p,a);var i=yield p.mediaBoxes();if(o.stop(),e.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(t.yellow("No media boxes found"));console.log(t.bold("\nMedia Boxes")),console.log("─".repeat(80)),i.forEach(e=>{console.log(`${t.cyan(e.name||"Unnamed")} ${t.gray(e.id)}`),e.description&&console.log(` ${e.description}`),e.tags?.length&&console.log(` Tags: ${e.tags.join(", ")}`),null!=e.size&&console.log(` Size: ${e.size}`),console.log()})}catch(e){o.fail(`Failed to list media boxes: ${e.message}`),process.exit(1)}}),function(e){return o.apply(this,arguments)})),y.command("box <id>").description("Get Media Flow box details").option("-j, --json","Output as JSON").action((i=c(function*(e,a){var t=yield h(),p=t.chalk,o=t.requireAuth(),i=t.ora("Fetching media box...").start();try{yield v(o,t);var d=yield o.mediaBox({id:e});if(i.stop(),d||(console.log(p.red("Media box not found")),process.exit(1)),a.json)return void console.log(JSON.stringify(d,null,2));console.log(p.bold(`
88
88
  Media Box: ${d.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${p.gray(d.id)}`),console.log(`Description: ${d.description||p.gray("N/A")}`),console.log(`Tags: ${d.tags?.join(", ")||p.gray("None")}`),null!=d.size&&console.log(`Size: ${d.size}`),d.passcodes?.length&&(console.log(`
89
89
  ${p.bold("Passcodes")}`),d.passcodes.forEach(e=>{console.log(`- ${e.name||"Passcode"}: ${e.code}`)})),console.log("─".repeat(60))}catch(e){i.fail(`Failed to get media box: ${e.message}`),process.exit(1)}}),function(e,a){return i.apply(this,arguments)})),y.command("files <boxId>").description("List Media Flow files in a box").option("-t, --types <types>","Comma-separated file types to include").option("-u, --user-tag <tag>","Filter by user tag (repeatable)",(e,a)=>[...a,e],[]).option("-l, --limit <limit>","Limit results",e=>Number.parseInt(e,10)).option("-o, --offset <offset>","Offset results",e=>Number.parseInt(e,10)).option("-j, --json","Output as JSON").action((d=c(function*(e,a){var t=yield h(),p=t.chalk,o=t.requireAuth(),i=t.ora("Fetching media files...").start();try{yield v(o,t);var d=a.types?a.types.split(",").map(e=>e.trim()).filter(Boolean):void 0,r=a.userTag?.length?a.userTag:void 0,n=yield o.mediaFiles({boxId:e,includeTypes:d,userTags:r,limit:a.limit,offset:a.offset});if(i.stop(),a.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(p.yellow("No media files found"));console.log(p.bold(`
90
90
  Media Files (${n.length})`)),console.log("─".repeat(100)),n.forEach(e=>{var a=g(e);console.log(`${p.cyan(e.name||"Unnamed")} ${p.gray(e.id)}`),console.log(` Type: ${e.fileType} Status: ${D(a,p)}`),e.userTags?.length&&console.log(` Tags: ${e.userTags.join(", ")}`),e.updatedAt&&console.log(` Updated: ${new Date(e.updatedAt).toLocaleString()}`),console.log()})}catch(e){i.fail(`Failed to list media files: ${e.message}`),process.exit(1)}}),function(e,a){return d.apply(this,arguments)})),y.command("file <id>").description("Get Media Flow file details").option("-j, --json","Output as JSON").action((r=c(function*(e,a){var t=yield h(),p=t.chalk,o=t.requireAuth(),i=t.ora("Fetching media file...").start();try{yield v(o,t);var d=yield o.mediaFile({id:e});if(i.stop(),d||(console.log(p.red("Media file not found")),process.exit(1)),a.json)return void console.log(JSON.stringify(d,null,2));var r=g(d);console.log(p.bold(`
91
91
  Media File: ${d.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`ID: ${p.gray(d.id)}`),console.log(`Box ID: ${p.gray(d.boxId)}`),console.log(`Type: ${d.fileType}`),console.log(`Status: ${D(r,p)}`),console.log(`Description: ${d.description||p.gray("N/A")}`),console.log(`Tags: ${d.userTags?.join(", ")||p.gray("None")}`),console.log(`Created: ${p.gray(d.createdAt||"N/A")}`),console.log(`Updated: ${p.gray(d.updatedAt||"N/A")}`);var n=t.buildScreenshotUrl(d),l=t.buildScreenshotUrl(d,{preferThumbnail:!0});d.meta?.originalFileKey&&console.log(`Original Key: ${p.gray(d.meta.originalFileKey)}`),n&&console.log(`Original URL: ${p.gray(n)}`),l&&l!==n&&console.log(`Thumbnail URL: ${p.gray(l)}`),console.log("─".repeat(60))}catch(e){i.fail(`Failed to get media file: ${e.message}`),process.exit(1)}}),function(e,a){return r.apply(this,arguments)}));var w=e=>{var a=e.match(/^(\d+)x(\d+)(?::(\w+))?$/);if(!a)throw Error(`Invalid image version spec: "${e}". Expected format: WxH or WxH:STRATEGY`);return{width:parseInt(a[1],10),height:parseInt(a[2],10),strategy:(a[3]||"FILL").toUpperCase(),copypreview:!1}},b=(n=c(function*(e,a,t,p,o){var i=new FormData;for(var d of Object.entries(a)){var r=m(d,2),n=r[0],l=r[1];i.append(n,l)}i.append("file",new Blob([t],{type:o}),p);var s=yield fetch(e,{method:"POST",body:i});if(!s.ok&&204!==s.status){var u=yield s.text().catch(()=>"");throw Error(`S3 upload failed (${s.status}): ${u}`)}}),function(e,a,t,p,o){return n.apply(this,arguments)});y.command("upload <boxId> <files...>").description("Upload file(s) to a Media Flow box").option("-d, --description <text>","File description","").option("-t, --user-tag <tag>","User tag (repeatable, max 15)",(e,a)=>[...a,e],[]).option("--image-version <spec>","Image resize spec as WxH or WxH:STRATEGY (repeatable)",(e,a)=>[...a,e],[]).option("--image-version-type <type>","Image output format: jpg or png").option("--enable-ai-analysis","Enable AI analysis on uploaded files").option("--ai-instruction <text>","Custom AI analysis instruction").option("--concurrency <n>","Max concurrent uploads",e=>parseInt(e,10),3).option("-j, --json","Output as JSON").action((l=c(function*(e,a,p){var o=yield h(),i=yield(!u&&(u=Promise.all([Promise.resolve().then(t.t.bind(t,51455,19)),Promise.resolve().then(t.t.bind(t,76760,19)),t.e(2247).then(t.t.bind(t,86090,19)),t.e(5212).then(t.bind(t,76983))]).then(([e,a,t,p])=>({readFile:e.readFile,stat:e.stat,basename:a.basename,resolve:a.resolve,lookup:t.lookup,runWithConcurrency:p.runWithConcurrency}))),u),d=o.chalk,r=o.requireAuth(),n=o.ora("Preparing upload...").start();try{if(yield v(r,o),p.userTag.length>15)throw Error("Maximum 15 user tags allowed");var l,s,m=p.imageVersion.map(w),f=p.enableAiAnalysis||!!p.aiInstruction,g=yield Promise.all(a.map((l=c(function*(e){var a=i.resolve(e),t=yield i.stat(a).catch(()=>null);if(!t||!t.isFile())throw Error(`Not a file: ${e}`);var p=i.basename(a),o=i.lookup(p)||"application/octet-stream";return{filePath:a,fileName:p,contentType:o,size:t.size}}),function(e){return l.apply(this,arguments)})));n.stop();var D=g.length;console.log(d.bold(`
92
92
  Uploading ${D} file${D>1?"s":""} to box ${d.gray(e)}...
93
- `));var y=[];yield i.runWithConcurrency(g,p.concurrency,(s=c(function*(a,t){var n=`[${t+1}/${D}] ${a.fileName}`,l=o.ora(`${n} — requesting upload...`).start();try{var s,u,c=(s=a.contentType)&&"image/svg+xml"!==s?s.startsWith("image/")?"IMAGE":s.startsWith("video/")?"VIDEO":s.startsWith("audio/")?"AUDIO":"FILE":"FILE",h={imageVersions:"IMAGE"===c?m:[],imageVersionType:"IMAGE"===c?p.imageVersionType:void 0,enableAiAnalysis:f,aiCustomInstruction:p.aiInstruction||void 0},v=yield r.createMediaFileUploadRequest({name:a.fileName,description:p.description,boxId:e,fileType:c,contentType:a.contentType,userTags:p.userTag.length?p.userTag:[],meta:h});l.text=`${n} — uploading to storage...`;var g=JSON.parse(v.meta.uploadInfo),w=yield i.readFile(a.filePath);yield b(g.url,{AWSAccessKeyId:g.AWSAccessKeyId,"Content-Type":g["Content-Type"],key:g.key,Signature:g.Signature,Policy:g.Policy,acl:g.acl},w,a.fileName,a.contentType),l.succeed(`${n} ${d.green("✓")} ${d.gray(`(${c}, ${(u=a.size)<1024?`${u} B`:u<1048576?`${(u/1024).toFixed(1)} KB`:u<0x40000000?`${(u/1048576).toFixed(1)} MB`:`${(u/0x40000000).toFixed(1)} GB`})`)}`),y.push({file:a.fileName,id:v.id,status:"success",fileType:c,size:a.size})}catch(e){l.fail(`${n} — ${e.message}`),y.push({file:a.fileName,id:null,status:"failed",error:e.message})}}),function(e,a){return s.apply(this,arguments)}));var _=y.filter(e=>"success"===e.status).length,C=y.filter(e=>"failed"===e.status).length;p.json?console.log(JSON.stringify({boxId:e,results:y,summary:{total:D,success:_,failed:C}},null,2)):(console.log(),0===C?console.log(d.green(`Uploaded ${_}/${D} files`)):console.log(d.yellow(`Uploaded ${_}/${D} files (${C} failed)`))),C>0&&process.exit(1)}catch(e){n.fail(`Upload failed: ${e.message}`),process.exit(1)}}),function(e,a,t){return l.apply(this,arguments)}))},32541(e,a,t){t.d(a,{A:()=>k});var p,o,i,d,r,n,l,s,u,m,c,f,h,v=t(99436),g=t(35679),D=t(73284),y=t(30155),w=t(44618),b=t(7586),_=t(56493),C=t(68168),F=t(74049),S=t(98593),E=(e,a)=>(0,S.H_)(e,a,{currentVersion:e?.current_version||null,public:!!e?.is_public}),k=new g.uB("module").description("Module management");k.command("new").description("Create a new module").requiredOption("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("--layout-width <width>","Layout width",parseInt).option("--layout-height <height>","Layout height",parseInt).option("--public","Make module available to all users").option("--allow-modify","Allow users to modify imported module config").option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action((p=v(function*(e){var a=(0,_.requireAuth)(),p=e.json?null:(0,y.default)("Creating module...").start();try{var o={name:e.name};e.description&&(o.description=e.description),e.layoutWidth&&(o.layoutWidth=e.layoutWidth),e.layoutHeight&&(o.layoutHeight=e.layoutHeight),e.public&&(o.isPublic=!0),e.allowModify&&(o.isAllowModify=!0);var i=yield a.createModule(o);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):e.json||(p.succeed(`Module created: ${D.default.green(i.name)}`),console.log(` ID: ${D.default.gray(i._id)}`),i.description&&console.log(` ${D.default.gray(i.description)}`),console.log(` Public: ${i.is_public?D.default.green("Yes"):D.default.gray("No")}`),console.log(` Allow Modify: ${i.is_allow_modify?D.default.green("Yes"):D.default.gray("No")}`)),e.init){p&&p.stop();var d=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield d("module",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(a){e.json?console.error(JSON.stringify({error:a.message})):p.fail(`Failed to create module: ${a.message}`),process.exit(1)}}),function(e){return p.apply(this,arguments)})),k.command("list").description("List all modules").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action((o=v(function*(e){var a=(0,_.requireAuth)(),t=(0,y.default)("Fetching modules...").start();try{var p=yield a.modules({keyword:e.keyword});if(t.stop(),e.json)return void console.log(JSON.stringify(p,null,2));if(!p||0===p.length)return void console.log(D.default.yellow("No modules found"));console.log(D.default.bold("\nModules")),console.log("─".repeat(80)),p.forEach(e=>{var a=e.current_version?`v${e.current_version}`:D.default.gray("no version");console.log(`● ${D.default.cyan(e.name)} ${D.default.gray(a)}`),console.log(` ID: ${D.default.gray(e._id)}`),e.description&&console.log(` ${D.default.gray(e.description)}`),console.log()})}catch(e){t.fail(`Failed to list modules: ${e.message}`),process.exit(1)}}),function(e){return o.apply(this,arguments)})),k.command("list-public").description("Search public modules").requiredOption("-k, --keyword <keyword>","Search keyword (min 2 characters)").option("-j, --json","Output as JSON").action((i=v(function*(e){var a=(0,_.requireAuth)(),t=(0,y.default)("Searching public modules...").start();try{var p=yield a.publicModules({keyword:e.keyword});if(t.stop(),e.json)return void console.log(JSON.stringify(p,null,2));if(!p||0===p.length)return void console.log(D.default.yellow("No public modules found"));console.log(D.default.bold("\nPublic Modules")),console.log("─".repeat(80)),p.forEach(e=>{var a=e.current_version?`v${e.current_version}`:D.default.gray("no version");console.log(`● ${D.default.cyan(e.name)} ${D.default.gray(a)}`),console.log(` ID: ${D.default.gray(e._id)}`),e.description&&console.log(` ${D.default.gray(e.description)}`),console.log()})}catch(e){t.fail(`Failed to search public modules: ${e.message}`),process.exit(1)}}),function(e){return i.apply(this,arguments)})),k.command("get <id>").description("Get module details").option("-j, --json","Output as JSON").action((d=v(function*(e,a){var t=(0,_.requireAuth)(),p=(0,y.default)("Fetching module...").start();try{var o=yield t.module({id:e});if(p.stop(),o||(console.log(D.default.red("Module not found")),process.exit(1)),a.json)return void console.log(JSON.stringify(o,null,2));if(console.log(D.default.bold(`
93
+ `));var y=[];yield i.runWithConcurrency(g,p.concurrency,(s=c(function*(a,t){var n=`[${t+1}/${D}] ${a.fileName}`,l=o.ora(`${n} — requesting upload...`).start();try{var s,u,c=(s=a.contentType)&&"image/svg+xml"!==s?s.startsWith("image/")?"IMAGE":s.startsWith("video/")?"VIDEO":s.startsWith("audio/")?"AUDIO":"FILE":"FILE",h={imageVersions:"IMAGE"===c?m:[],imageVersionType:"IMAGE"===c?p.imageVersionType:void 0,enableAiAnalysis:f,aiCustomInstruction:p.aiInstruction||void 0},v=yield r.createMediaFileUploadRequest({name:a.fileName,description:p.description,boxId:e,fileType:c,contentType:a.contentType,userTags:p.userTag.length?p.userTag:[],meta:h});l.text=`${n} — uploading to storage...`;var g=JSON.parse(v.meta.uploadInfo),w=yield i.readFile(a.filePath);yield b(g.url,{AWSAccessKeyId:g.AWSAccessKeyId,"Content-Type":g["Content-Type"],key:g.key,Signature:g.Signature,Policy:g.Policy,acl:g.acl},w,a.fileName,a.contentType),l.succeed(`${n} ${d.green("✓")} ${d.gray(`(${c}, ${(u=a.size)<1024?`${u} B`:u<1048576?`${(u/1024).toFixed(1)} KB`:u<0x40000000?`${(u/1048576).toFixed(1)} MB`:`${(u/0x40000000).toFixed(1)} GB`})`)}`),y.push({file:a.fileName,id:v.id,status:"success",fileType:c,size:a.size})}catch(e){l.fail(`${n} — ${e.message}`),y.push({file:a.fileName,id:null,status:"failed",error:e.message})}}),function(e,a){return s.apply(this,arguments)}));var _=y.filter(e=>"success"===e.status).length,C=y.filter(e=>"failed"===e.status).length;p.json?console.log(JSON.stringify({boxId:e,results:y,summary:{total:D,success:_,failed:C}},null,2)):(console.log(),0===C?console.log(d.green(`Uploaded ${_}/${D} files`)):console.log(d.yellow(`Uploaded ${_}/${D} files (${C} failed)`))),C>0&&process.exit(1)}catch(e){n.fail(`Upload failed: ${e.message}`),process.exit(1)}}),function(e,a,t){return l.apply(this,arguments)}))},32541(e,a,t){t.d(a,{A:()=>A});var p,o,i,d,r,n,l,s,u,m,c,f,h,v=t(99436),g=t(35679),D=t(73284),y=t(30155),w=t(44618),b=t(7586),_=t(56493),C=t(68168),F=t(74049),S=t(98593),E=t(90003),k=(e,a)=>(0,S.H_)(e,a,{currentVersion:e?.current_version||null,public:!!e?.is_public}),A=new g.uB("module").description("Module management");A.command("new").description("Create a new module").requiredOption("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("--layout-width <width>","Layout width",parseInt).option("--layout-height <height>","Layout height",parseInt).option("--public","Make module available to all users").option("--allow-modify","Allow users to modify imported module config").option("--init","Initialize a BRICKS Project after creation").option("-o, --output <dir>","Output directory for --init (default: current directory)").option("-y, --yes","Skip prompts for --init").option("-j, --json","Output as JSON").action((p=v(function*(e){var a=(0,_.requireAuth)(),p=e.json?null:(0,y.default)("Creating module...").start();try{var o={name:e.name};e.description&&(o.description=e.description),e.layoutWidth&&(o.layoutWidth=e.layoutWidth),e.layoutHeight&&(o.layoutHeight=e.layoutHeight),e.public&&(o.isPublic=!0),e.allowModify&&(o.isAllowModify=!0);var i=yield a.createModule(o);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):e.json||(p.succeed(`Module created: ${D.default.green(i.name)}`),console.log(` ID: ${D.default.gray(i._id)}`),i.description&&console.log(` ${D.default.gray(i.description)}`),console.log(` Public: ${i.is_public?D.default.green("Yes"):D.default.gray("No")}`),console.log(` Allow Modify: ${i.is_allow_modify?D.default.green("Yes"):D.default.gray("No")}`)),e.init){p&&p.stop();var d=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield d("module",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(a){e.json?console.error(JSON.stringify({error:a.message})):p.fail(`Failed to create module: ${a.message}`),process.exit(1)}}),function(e){return p.apply(this,arguments)})),A.command("list").description("List all modules").option("-k, --keyword <keyword>","Filter by keyword").option("-j, --json","Output as JSON").action((o=v(function*(e){var a=(0,_.requireAuth)(),t=(0,y.default)("Fetching modules...").start();try{var p=yield a.modules({keyword:e.keyword});if(t.stop(),e.json)return void console.log(JSON.stringify(p,null,2));if(!p||0===p.length)return void console.log(D.default.yellow("No modules found"));console.log(D.default.bold("\nModules")),console.log("─".repeat(80)),p.forEach(e=>{var a=e.current_version?`v${e.current_version}`:D.default.gray("no version");console.log(`● ${D.default.cyan(e.name)} ${D.default.gray(a)}`),console.log(` ID: ${D.default.gray(e._id)}`),e.description&&console.log(` ${D.default.gray(e.description)}`),console.log()})}catch(e){t.fail(`Failed to list modules: ${e.message}`),process.exit(1)}}),function(e){return o.apply(this,arguments)})),A.command("list-public").description("Search public modules").requiredOption("-k, --keyword <keyword>","Search keyword (min 2 characters)").option("-j, --json","Output as JSON").action((i=v(function*(e){var a=(0,_.requireAuth)(),t=(0,y.default)("Searching public modules...").start();try{var p=yield a.publicModules({keyword:e.keyword});if(t.stop(),e.json)return void console.log(JSON.stringify(p,null,2));if(!p||0===p.length)return void console.log(D.default.yellow("No public modules found"));console.log(D.default.bold("\nPublic Modules")),console.log("─".repeat(80)),p.forEach(e=>{var a=e.current_version?`v${e.current_version}`:D.default.gray("no version");console.log(`● ${D.default.cyan(e.name)} ${D.default.gray(a)}`),console.log(` ID: ${D.default.gray(e._id)}`),e.description&&console.log(` ${D.default.gray(e.description)}`),console.log()})}catch(e){t.fail(`Failed to search public modules: ${e.message}`),process.exit(1)}}),function(e){return i.apply(this,arguments)})),A.command("get <id>").description("Get module details").option("-j, --json","Output as JSON").action((d=v(function*(e,a){var t=(0,_.requireAuth)(),p=(0,y.default)("Fetching module...").start();try{var o=yield t.module({id:e});if(p.stop(),o||(console.log(D.default.red("Module not found")),process.exit(1)),a.json)return void console.log(JSON.stringify(o,null,2));if(console.log(D.default.bold(`
94
94
  Module: ${o.name}`)),console.log("─".repeat(60)),console.log(`ID: ${D.default.gray(o._id)}`),console.log(`Description: ${o.description||D.default.gray("N/A")}`),console.log(`Tags: ${o.tags?.join(", ")||D.default.gray("None")}`),console.log(`Created: ${D.default.gray(o.create_datetime)}`),console.log(`Modified: ${D.default.gray(o.last_modify_datetime)}`),console.log(`
95
95
  ${D.default.bold("Version")}`),console.log(`Current: ${o.current_version?`v${o.current_version}`:D.default.gray("No version")}`),console.log(`Unreleased: ${o.has_unreleased_changes?D.default.yellow("Yes"):D.default.green("No")}`),console.log(`
96
96
  ${D.default.bold("Settings")}`),console.log(`Public: ${o.is_public?D.default.green("Yes"):D.default.gray("No")}`),console.log(`Allow Modify: ${o.is_allow_modify?D.default.green("Yes"):D.default.gray("No")}`),console.log(`Short Edit: ${o.short_edit?.enabled?D.default.green("Enabled"):D.default.gray("Disabled")}`),o.short_edit?.enabled&&o.short_edit.ref_map){var i=Object.keys(o.short_edit.ref_map).length;console.log(` References: ${i} editable properties`)}o.use_count?.total_count!=null&&(console.log(`
97
97
  ${D.default.bold("Usage")}`),console.log(`Used In: ${o.use_count.total_count} application(s)`)),o.expose_properties?.length>0&&(console.log(`
98
- ${D.default.bold("Exposed Properties")} (${o.expose_properties.length})`),o.expose_properties.forEach(e=>{console.log(` - ${D.default.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get module: ${e.message}`),process.exit(1)}}),function(e,a){return d.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((r=v(function*(e,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Resolving module...").start();try{var o=yield(0,C.Y)(()=>t.module({id:e})),i=o?[o]:yield t.modules({keyword:e,paginate:{limit:a.limit}}),d=(0,C.K)({resource:"module",query:e,items:i||[],fields:["_id","name"],selectedBy:o?"id":null});if(p&&p.stop(),a.json)return void(0,b.GF)(d);if(d.resolved){var r=d.resolved;console.log(D.default.bold("\nResolved Module")),console.log("─".repeat(60)),console.log(`Name: ${D.default.cyan(r.name||"Unnamed")}`),console.log(`ID: ${D.default.gray(r._id)}`),console.log(`Selected By: ${d.selectedBy}`),console.log("─".repeat(60));return}if(0===d.matches.length)return void console.log(D.default.yellow(`No modules matched "${e}"`));console.log(D.default.bold(`
99
- Matching Modules (${d.matches.length})`)),console.log("─".repeat(80)),d.matches.forEach(e=>{console.log(`${D.default.cyan(e.name||"Unnamed")} ${D.default.gray(e._id)}`)}),console.log("─".repeat(80))}catch(a){p?p.fail(`Failed to resolve module: ${a.message}`):(0,b.OW)(a.message,{resource:"module",query:e}),process.exit(1)}}),function(e,a){return r.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((n=v(function*(e,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Updating module...").start();try{var o=yield t.updateModule((0,S.jB)(e,a));a.json?(0,S.yd)({action:"module.update",target:E(o,e),result:{lastCommitId:a.lastCommitId||null},json:!0}):(p.succeed(`Module updated: ${D.default.green(o.name)}`),o.has_unreleased_changes&&console.log(D.default.yellow("Note: Module has unreleased changes")))}catch(t){a.json?(0,b.OW)(t.message,{action:"module.update",target:{id:e}}):p.fail(`Failed to update module: ${t.message}`),process.exit(1)}}),function(e,a){return n.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,a){var t=(0,_.requireAuth)(),p=(0,y.default)("Applying short edit...").start();try{var o=JSON.parse(a.list);Array.isArray(o)||(p.fail("List must be a JSON array"),process.exit(1));var i=yield t.shortEditModule({id:e,list:o});p.succeed(`Short edit applied to: ${D.default.green(i.name)}`)}catch(e){p.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,a){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((s=v(function*(e,a){var t=(0,_.requireAuth)(),p=(0,y.default)("Fetching short edit references...").start();try{var o=yield t.module({id:e});if(p.stop(),!o?.short_edit?.enabled)return void console.log(D.default.yellow("Short Edit is not enabled for this module"));var i=a.types?a.types.split(",").map(e=>e.trim()).filter(Boolean):[],d=(0,w.V)(o.short_edit.ref_map,{keyword:a.keyword,types:i});if(a.json)return void console.log(JSON.stringify(d,null,2));if(0===d.length)return void console.log(D.default.yellow("No short edit references found"));console.log(D.default.bold(`
98
+ ${D.default.bold("Exposed Properties")} (${o.expose_properties.length})`),o.expose_properties.forEach(e=>{console.log(` - ${D.default.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){p.fail(`Failed to get module: ${e.message}`),process.exit(1)}}),function(e,a){return d.apply(this,arguments)})),A.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((r=v(function*(e,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Resolving module...").start();try{var o=yield(0,C.Y)(()=>t.module({id:e})),i=o?[o]:yield t.modules({keyword:e,paginate:{limit:a.limit}}),d=(0,C.K)({resource:"module",query:e,items:i||[],fields:["_id","name"],selectedBy:o?"id":null});if(p&&p.stop(),a.json)return void(0,b.GF)(d);if(d.resolved){var r=d.resolved;console.log(D.default.bold("\nResolved Module")),console.log("─".repeat(60)),console.log(`Name: ${D.default.cyan(r.name||"Unnamed")}`),console.log(`ID: ${D.default.gray(r._id)}`),console.log(`Selected By: ${d.selectedBy}`),console.log("─".repeat(60));return}if(0===d.matches.length)return void console.log(D.default.yellow(`No modules matched "${e}"`));console.log(D.default.bold(`
99
+ Matching Modules (${d.matches.length})`)),console.log("─".repeat(80)),d.matches.forEach(e=>{console.log(`${D.default.cyan(e.name||"Unnamed")} ${D.default.gray(e._id)}`)}),console.log("─".repeat(80))}catch(a){p?p.fail(`Failed to resolve module: ${a.message}`):(0,b.OW)(a.message,{resource:"module",query:e}),process.exit(1)}}),function(e,a){return r.apply(this,arguments)})),A.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((n=v(function*(e,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Updating module...").start();try{var o=yield t.updateModule((0,S.jB)(e,a));a.json?(0,S.yd)({action:"module.update",target:k(o,e),result:{lastCommitId:a.lastCommitId||null},json:!0}):(p.succeed(`Module updated: ${D.default.green(o.name)}`),o.has_unreleased_changes&&console.log(D.default.yellow("Note: Module has unreleased changes")))}catch(t){a.json?(0,b.OW)(t.message,{action:"module.update",target:{id:e}}):p.fail(`Failed to update module: ${t.message}`),process.exit(1)}}),function(e,a){return n.apply(this,arguments)})),A.command("short-edit <id>").description("Short edit module properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action((l=v(function*(e,a){var t=(0,_.requireAuth)(),p=(0,y.default)("Applying short edit...").start();try{var o=JSON.parse(a.list);Array.isArray(o)||(p.fail("List must be a JSON array"),process.exit(1));var i=yield t.shortEditModule({id:e,list:o});p.succeed(`Short edit applied to: ${D.default.green(i.name)}`)}catch(e){p.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,a){return l.apply(this,arguments)})),A.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((s=v(function*(e,a){var t=(0,_.requireAuth)(),p=(0,y.default)("Fetching short edit references...").start();try{var o=yield t.module({id:e});if(p.stop(),!o?.short_edit?.enabled)return void console.log(D.default.yellow("Short Edit is not enabled for this module"));var i=a.types?a.types.split(",").map(e=>e.trim()).filter(Boolean):[],d=(0,w.V)(o.short_edit.ref_map,{keyword:a.keyword,types:i});if(a.json)return void console.log(JSON.stringify(d,null,2));if(0===d.length)return void console.log(D.default.yellow("No short edit references found"));console.log(D.default.bold(`
100
100
  Short Edit References: ${o.name}`)),d.forEach(e=>{console.log(D.default.cyan(`
101
- ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:a})=>{var t=a?.title?D.default.gray(`- ${a.title}`):"";console.log(` ${D.default.green(e)} ${t}`)})}),console.log()}catch(e){p.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,a){return s.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,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Removing module...").start();try{var o=yield t.module({id:e});if(!o)throw Error("Module not found");var i=E(o,e);if(a.dryRun){p&&p.stop(),(0,S.S5)({action:"module.remove",target:i,request:{id:e},checks:[(0,S.Iy)("module exists",!0,`${i.name} (${i.id})`)],json:a.json});return}var d=yield t.removeModule({id:e});a.json?(0,S.yd)({action:"module.remove",target:i,result:{removed:!!d},json:!0}):p.succeed(`Module removed: ${D.default.green(i.name)}`)}catch(t){a.json?(0,b.OW)(t.message,{action:"module.remove",target:{id:e}}):p.fail(`Failed to remove module: ${t.message}`),process.exit(1)}}),function(e,a){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((m=v(function*(e,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Releasing module...").start();try{var o=(0,F.Ku)(a.config),i=o.config,d=o.source,r=o.sizeBytes,n=yield t.module({id:e});if(!n)throw Error("Module not found");if(n.is_public)throw Error("Public module deployment is temporarily not recommended");var l=a.version||a.name||n.name||"Untitled",s=(0,F.w9)(a.changelogs);if(a.dryRun){p&&p.stop(),(0,S.S5)({action:"module.release",target:E(n,e),request:{name:a.name||null,version:l,changelogs:a.changelogs||null,configSource:d,configSizeBytes:r},checks:[(0,S.Iy)("module exists",!0,`${n.name} (${n._id})`),(0,S.Iy)("module is private",!n.is_public),(0,S.Iy)("release config loaded",!0,`${r} bytes`)],json:a.json});return}var u=yield t.releaseModule({id:e,config:i,...a.name?{name:a.name}:{},releaseCurrentVersion:l,releaseCurrentVersionNote:s});a.json?(0,S.yd)({action:"module.release",target:E(u||n,e),result:{name:a.name||null,version:l,configSource:d,configSizeBytes:r},json:!0}):p.succeed(`Module released: ${D.default.green(u?.name||n.name)}`)}catch(t){a.json?(0,b.OW)(t.message,{action:"module.release",target:{id:e}}):p.fail(`Failed to release module: ${t.message}`),process.exit(1)}}),function(e,a){return m.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((c=v(function*(e,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Pulling module project...").start();try{var o=yield t.moduleProject({id:e,buildApplicationOnly:!0});o||(p?p.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),a.json?console.log(JSON.stringify(o)):(p.succeed(`Module project fetched: ${D.default.green(o.files?.length||0)} files`),console.log(JSON.stringify(o,null,2)))}catch(e){a.json?console.error(JSON.stringify({error:e.message})):p.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}}),function(e,a){return c.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,a){var p=a.json?null:(0,y.default)("Running config doctor...").start();try{var o=yield Promise.all([t.e(9866),t.e(6645),t.e(9430),t.e(1010),t.e(7511),t.e(563)]).then(t.bind(t,63322)),i=o.runConfigDoctor,d=o.renderConfigDoctorReport,r=yield i("module",e,a),n=r.report,l=r.exitCode;p?.stop(),a.json?(0,b.GF)({...n,exitCode:l}):console.log(d(n)),0!==l&&process.exit(l)}catch(e){p?p.fail(`Config doctor failed: ${e.message}`):(0,b.OW)(e.message),process.exit(1)}}),function(e,a){return f.apply(this,arguments)})),k.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module (deprecated: use `bricks ctor init --type 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,a){a.json||console.error(D.default.yellow("Note: `bricks module ctor-init` is deprecated. Use `bricks ctor init <id> --type module` instead."));var p=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield p("module",e,a)}),function(e,a){return h.apply(this,arguments)}))},38311(e,a,t){t.d(a,{D:()=>u});var p,o,i,d=t(99436),r=t(35679),n=t(73284),l=(p=d(function*(){var e=(yield Promise.resolve().then(t.bind(t,30155))).default,a=yield t.e(6818).then(t.bind(t,53241)),p=a.detectChannel,o=a.detectInstallMethod,i=yield t.e(9405).then(t.bind(t,21068));return{ora:e,detectChannel:p,detectInstallMethod:o,fetchLatestVersionInfo:i.fetchLatestVersionInfo,runUpdateForMethod:i.runUpdateForMethod}}),function(){return p.apply(this,arguments)}),s=(o=d(function*({message:e,defaultValue:a,autoYes:p}){if(p)return!0;(0,(yield Promise.resolve().then(t.bind(t,8479))).isInteractiveTerminal)()||(console.error(n.default.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{var o=(yield t.e(5658).then(t.bind(t,27521))).confirm;return yield o({message:e,default:a})}catch{return!1}}),function(e){return o.apply(this,arguments)}),u=new r.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((i=d(function*(e){var a,t=yield l(),p=t.ora,o=t.detectChannel,i=t.detectInstallMethod,r=t.fetchLatestVersionInfo,u=t.runUpdateForMethod,m="2.25.0-beta.77",c=i(),f=e.channel||o({version:m,execPath:c.execPath});console.log(n.default.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${n.default.cyan(m)}`),console.log(`Channel : ${n.default.cyan(f)}`),console.log(`Detected method : ${n.default.cyan(c.method)}`),c.execPath&&"binary"===c.method&&console.log(`Binary path : ${n.default.gray(c.execPath)}`),c.installRoot&&console.log(`Install root : ${n.default.gray(c.installRoot)}`);var h="npm"===c.method||"bun"===c.method?"npm":"cdn",v=p(`Fetching latest version info (${h})...`).start(),g=null,D=null;try{g=(yield r(f,c.method)).version,v.succeed(`Latest ${f} (${h}): ${n.default.green(g)}`)}catch(e){D=e,v.warn(`Could not fetch version info: ${e.message}`)}var y=g&&g===m;if(e.checkUpdate){if(D&&process.exit(2),y)return void console.log(n.default.green("\nUp to date."));g&&(console.log(n.default.yellow(`
101
+ ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:a})=>{var t=a?.title?D.default.gray(`- ${a.title}`):"";console.log(` ${D.default.green(e)} ${t}`)})}),console.log()}catch(e){p.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,a){return s.apply(this,arguments)})),A.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,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Removing module...").start();try{var o=yield t.module({id:e});if(!o)throw Error("Module not found");var i=k(o,e);if(a.dryRun){p&&p.stop(),(0,S.S5)({action:"module.remove",target:i,request:{id:e},checks:[(0,S.Iy)("module exists",!0,`${i.name} (${i.id})`)],json:a.json});return}var d=yield t.removeModule({id:e});a.json?(0,S.yd)({action:"module.remove",target:i,result:{removed:!!d},json:!0}):p.succeed(`Module removed: ${D.default.green(i.name)}`)}catch(t){a.json?(0,b.OW)(t.message,{action:"module.remove",target:{id:e}}):p.fail(`Failed to remove module: ${t.message}`),process.exit(1)}}),function(e,a){return u.apply(this,arguments)})),A.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((m=v(function*(e,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Releasing module...").start();try{var o=(0,F.Ku)(a.config),i=o.config,d=o.source,r=o.sizeBytes,n=yield t.module({id:e});if(!n)throw Error("Module not found");if(n.is_public)throw Error("Public module deployment is temporarily not recommended");var l=a.version||a.name||n.name||"Untitled",s=(0,F.w9)(a.changelogs);if(a.dryRun){p&&p.stop(),(0,S.S5)({action:"module.release",target:k(n,e),request:{name:a.name||null,version:l,changelogs:a.changelogs||null,configSource:d,configSizeBytes:r},checks:[(0,S.Iy)("module exists",!0,`${n.name} (${n._id})`),(0,S.Iy)("module is private",!n.is_public),(0,S.Iy)("release config loaded",!0,`${r} bytes`)],json:a.json});return}var u=yield t.releaseModule({id:e,config:i,...a.name?{name:a.name}:{},releaseCurrentVersion:l,releaseCurrentVersionNote:s});a.json?(0,S.yd)({action:"module.release",target:k(u||n,e),result:{name:a.name||null,version:l,configSource:d,configSizeBytes:r},json:!0}):p.succeed(`Module released: ${D.default.green(u?.name||n.name)}`)}catch(t){a.json?(0,b.OW)(t.message,{action:"module.release",target:{id:e}}):p.fail(`Failed to release module: ${t.message}`),process.exit(1)}}),function(e,a){return m.apply(this,arguments)})),A.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((c=v(function*(e,a){var t=(0,_.requireAuth)(),p=a.json?null:(0,y.default)("Pulling module project...").start();try{var o=yield t.moduleProject({id:e,buildApplicationOnly:!0});o||(p?p.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),a.json?console.log(JSON.stringify(o)):(p.succeed(`Module project fetched: ${D.default.green(o.files?.length||0)} files`),console.log(JSON.stringify(o,null,2)))}catch(e){a.json?console.error(JSON.stringify({error:e.message})):p.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}}),function(e,a){return c.apply(this,arguments)})),A.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,a){var p=a.json?null:(0,y.default)("Running config doctor...").start();try{var o=yield Promise.all([t.e(9866),t.e(6645),t.e(9430),t.e(1010),t.e(7511),t.e(563)]).then(t.bind(t,63322)),i=o.runConfigDoctor,d=o.renderConfigDoctorReport,r=yield i("module",e,a),n=r.report,l=r.exitCode;p?.stop(),a.json?(0,b.GF)({...n,exitCode:l}):console.log(d(n)),0!==l&&process.exit(l)}catch(e){p?p.fail(`Config doctor failed: ${e.message}`):(0,b.OW)(e.message),process.exit(1)}}),function(e,a){return f.apply(this,arguments)})),(0,E.x)(A.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module (deprecated: use `bricks ctor init --type module`)")).action((h=v(function*(e,a){a.json||console.error(D.default.yellow("Note: `bricks module ctor-init` is deprecated. Use `bricks ctor init <id> --type module` instead."));var p=(yield Promise.all([t.e(5658),t.e(4456)]).then(t.bind(t,58891))).initProject;yield p("module",e,a)}),function(e,a){return h.apply(this,arguments)}))},90003(e,a,t){t.d(a,{x:()=>p});var p=e=>e.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)")},38311(e,a,t){t.d(a,{D:()=>u});var p,o,i,d=t(99436),r=t(35679),n=t(73284),l=(p=d(function*(){var e=(yield Promise.resolve().then(t.bind(t,30155))).default,a=yield t.e(6818).then(t.bind(t,53241)),p=a.detectChannel,o=a.detectInstallMethod,i=yield t.e(9405).then(t.bind(t,21068));return{ora:e,detectChannel:p,detectInstallMethod:o,fetchLatestVersionInfo:i.fetchLatestVersionInfo,runUpdateForMethod:i.runUpdateForMethod}}),function(){return p.apply(this,arguments)}),s=(o=d(function*({message:e,defaultValue:a,autoYes:p}){if(p)return!0;(0,(yield Promise.resolve().then(t.bind(t,8479))).isInteractiveTerminal)()||(console.error(n.default.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{var o=(yield t.e(5658).then(t.bind(t,27521))).confirm;return yield o({message:e,default:a})}catch{return!1}}),function(e){return o.apply(this,arguments)}),u=new r.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((i=d(function*(e){var a,t=yield l(),p=t.ora,o=t.detectChannel,i=t.detectInstallMethod,r=t.fetchLatestVersionInfo,u=t.runUpdateForMethod,m="2.25.0-beta.79",c=i(),f=e.channel||o({version:m,execPath:c.execPath});console.log(n.default.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${n.default.cyan(m)}`),console.log(`Channel : ${n.default.cyan(f)}`),console.log(`Detected method : ${n.default.cyan(c.method)}`),c.execPath&&"binary"===c.method&&console.log(`Binary path : ${n.default.gray(c.execPath)}`),c.installRoot&&console.log(`Install root : ${n.default.gray(c.installRoot)}`);var h="npm"===c.method||"bun"===c.method?"npm":"cdn",v=p(`Fetching latest version info (${h})...`).start(),g=null,D=null;try{g=(yield r(f,c.method)).version,v.succeed(`Latest ${f} (${h}): ${n.default.green(g)}`)}catch(e){D=e,v.warn(`Could not fetch version info: ${e.message}`)}var y=g&&g===m;if(e.checkUpdate){if(D&&process.exit(2),y)return void console.log(n.default.green("\nUp to date."));g&&(console.log(n.default.yellow(`
102
102
  Update available: ${m} → ${g}. Run 'bricks update-cli' to install.`)),process.exit(1)),console.log(n.default.yellow("\nCould not determine current version.")),process.exit(2)}if(y&&(console.log(n.default.green("\nAlready running the latest version.")),!(yield s({message:"Reinstall anyway?",defaultValue:!1,autoYes:e.yes}))))return void console.log(n.default.gray("Skipped."));var w=["npm","bun","binary"].includes(c.method);w||console.log(n.default.yellow(`Cannot auto-detect installer (method: ${c.method}); falling back to binary install.`));var b=w?c.method:"binary";if(!(yield s({message:`Update CLI using "${b}" method?`,defaultValue:!0,autoYes:e.yes})))return void console.log(n.default.yellow("Cancelled."));var _=(a=d(function*(e){console.log(n.default.cyan(`
103
103
  → Running ${e} update...`));try{return yield u(e,f,c),!0}catch(a){return console.error(n.default.yellow(`
104
- ${e} update failed: ${a.message}`)),!1}}),function(e){return a.apply(this,arguments)}),C=yield _(b);!C&&"binary"!==b&&(console.log(n.default.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield s({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(C=yield _("binary"))),C||(console.error(n.default.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(n.default.green("\nUpdate complete."))}),function(e){return i.apply(this,arguments)}))},1878(e,a,t){t.a(e,async function(e,p){try{t.d(a,{A:()=>A,e:()=>k});var o,i=t(99436),d=t(35679),r=t(73284),n=t(47988),l=t(8479),s=t(55614),u=t(1983),m=t(17422),c=t(32541),f=t(28634),h=t(12569),v=t(55609),g=t(71335),D=t(68473),y=t(80274),w=t(42400),b=t(98247),_=t(70970),C=t(38311),F=t(59845),S=t(22175),E=e([w]);w=(E.then?(await E)():E)[0];var k=(o=i(function*(){var e,a=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==a&&process.argv[a+1]&&((0,n.setProfileOverride)(process.argv[a+1]),process.argv.splice(a,2)),d.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.0-beta.77","-v, --version","output the version number").enablePositionalOptions(),d.DM.addCommand(s.s),d.DM.addCommand(u._),d.DM.addCommand(m.B),d.DM.addCommand(c.A),d.DM.addCommand(f.p),d.DM.addCommand(h.u),d.DM.addCommand(v.E),d.DM.addCommand(g.oT),d.DM.addCommand(D.K),d.DM.addCommand(y.gf),d.DM.addCommand(w.D),d.DM.addCommand(b.v),d.DM.addCommand(_.l),d.DM.addCommand(C.D),d.DM.addCommand(F.Q),d.DM.addCommand(S.g),d.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(i(function*(){try{var e=(yield Promise.all([t.e(3332),t.e(8295),t.e(3690),t.e(907),t.e(7294)]).then(t.bind(t,94685))).runInteractiveMode;yield e()}catch(e){console.error(r.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),d.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=i(function*(e){var a=(yield Promise.resolve().then(t.bind(t,47988))).getCurrentProfile,p=(yield Promise.resolve().then(t.bind(t,31802))).getConnectionContext,o=(yield Promise.all([t.e(3332),t.e(8295),t.e(907)]).then(t.bind(t,85382))).createClient,i=(yield Promise.resolve().then(t.bind(t,30155))).default,d=a(),n=p(d),l=n.auth,s=n.baseUrl;l||(console.error(r.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=i("Fetching workspace info...").start();try{var m=o(s,l),c=yield m.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(c,null,2));console.log(r.default.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${r.default.green(c.name)}`),console.log(`ID: ${r.default.gray(c._id)}`),console.log(`Description: ${c.description||r.default.gray("N/A")}`),console.log(`
104
+ ${e} update failed: ${a.message}`)),!1}}),function(e){return a.apply(this,arguments)}),C=yield _(b);!C&&"binary"!==b&&(console.log(n.default.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield s({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(C=yield _("binary"))),C||(console.error(n.default.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(n.default.green("\nUpdate complete."))}),function(e){return i.apply(this,arguments)}))},1878(e,a,t){t.a(e,async function(e,p){try{t.d(a,{A:()=>A,e:()=>k});var o,i=t(99436),d=t(35679),r=t(73284),n=t(47988),l=t(8479),s=t(55614),u=t(1983),m=t(17422),c=t(32541),f=t(28634),h=t(12569),v=t(55609),g=t(71335),D=t(68473),y=t(80274),w=t(42400),b=t(98247),_=t(70970),C=t(38311),F=t(59845),S=t(22175),E=e([w]);w=(E.then?(await E)():E)[0];var k=(o=i(function*(){var e,a=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==a&&process.argv[a+1]&&((0,n.setProfileOverride)(process.argv[a+1]),process.argv.splice(a,2)),d.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.0-beta.79","-v, --version","output the version number").enablePositionalOptions(),d.DM.addCommand(s.s),d.DM.addCommand(u._),d.DM.addCommand(m.B),d.DM.addCommand(c.A),d.DM.addCommand(f.p),d.DM.addCommand(h.u),d.DM.addCommand(v.E),d.DM.addCommand(g.oT),d.DM.addCommand(D.K),d.DM.addCommand(y.gf),d.DM.addCommand(w.D),d.DM.addCommand(b.v),d.DM.addCommand(_.l),d.DM.addCommand(C.D),d.DM.addCommand(F.Q),d.DM.addCommand(S.g),d.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(i(function*(){try{var e=(yield Promise.all([t.e(3332),t.e(8295),t.e(3690),t.e(907),t.e(7294)]).then(t.bind(t,94685))).runInteractiveMode;yield e()}catch(e){console.error(r.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),d.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=i(function*(e){var a=(yield Promise.resolve().then(t.bind(t,47988))).getCurrentProfile,p=(yield Promise.resolve().then(t.bind(t,31802))).getConnectionContext,o=(yield Promise.all([t.e(3332),t.e(8295),t.e(907)]).then(t.bind(t,85382))).createClient,i=(yield Promise.resolve().then(t.bind(t,30155))).default,d=a(),n=p(d),l=n.auth,s=n.baseUrl;l||(console.error(r.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=i("Fetching workspace info...").start();try{var m=o(s,l),c=yield m.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(c,null,2));console.log(r.default.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${r.default.green(c.name)}`),console.log(`ID: ${r.default.gray(c._id)}`),console.log(`Description: ${c.description||r.default.gray("N/A")}`),console.log(`
105
105
  ${r.default.bold("Data")}`),console.log(`Remote Update: ${c.bank?.enable_remote_update?r.default.green("Enabled"):r.default.gray("Disabled")}`),console.log(`Spacename: ${c.bank?.spacename||r.default.gray("N/A")}`),console.log("─".repeat(60))}catch(e){u.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}}),function(a){return e.apply(this,arguments)})),d.DM.on("--help",()=>{console.log(""),console.log(r.default.bold("Examples:")),console.log(""),console.log(r.default.gray(" # Sign in with your BRICKS account (opens the browser)")),console.log(" $ bricks auth login"),console.log(""),console.log(r.default.gray(" # Select a workspace as the active profile")),console.log(" $ bricks auth use-workspace"),console.log(""),console.log(r.default.gray(" # Workspace auth (CI/automation): one-time passcode or token")),console.log(" $ bricks auth login-workspace <passcode>"),console.log(""),console.log(r.default.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(r.default.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(r.default.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(r.default.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(r.default.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(r.default.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(r.default.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(r.default.gray("Get workspace token from BRICKS Controller:")),console.log(r.default.cyan(" https://control.bricks.tools")),console.log(r.default.gray(" Go to Workspace Settings > API Token"))});var p=process.argv.slice(2);if(0===p.length){if((0,l.shouldStartInteractiveMode)(p))try{var o=(yield Promise.all([t.e(3332),t.e(8295),t.e(3690),t.e(907),t.e(7294)]).then(t.bind(t,94685))).runInteractiveMode;yield o();return}catch(e){console.error(r.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}console.error(r.default.gray("No command provided. Interactive mode requires a TTY, so showing help instead.\n")),d.DM.outputHelp();return}yield d.DM.parseAsync(process.argv)}),function(){return o.apply(this,arguments)});let A=k;p()}catch(e){p(e)}})},31802(e,a,t){t.r(a),t.d(a,{getAuthContext:()=>n,getConnectionContext:()=>r});var p=t(99436),o=t(47988),i=t(63755),d=(e,a)=>{if(!e)throw Error("Not logged in. Run `bricks auth login` first.");if(e.user?.sub!==a)throw Error("OAuth account changed. Re-select the workspace for the current account.");return e},r=e=>{var a=(0,o.getProfileCredentialSnapshot)(e);return{...a,auth:(({tokenInfo:e,oauth:a})=>{if(!e)return null;if("oauth"===e.type){if(!a?.accessToken||!e.oauthSubject||e.oauthSubject!==a.user?.sub||!e.workspaceId)return null;var t,o,r,n=e.oauthSubject;return{kind:"oauth",workspaceId:e.workspaceId,workspaceName:e.workspaceName,getHeaders:(o=p(function*(){var a=d((yield(0,i.EC)()),n);return{authorization:`Bearer ${a.accessToken}`,"x-bricks-workspace-id":String(e.workspaceId)}}),function(){return o.apply(this,arguments)}),refresh:(r=p(function*(){d((yield(0,i.EC)({forceRefresh:!0})),n)}),function(){return r.apply(this,arguments)})}}return e.token?{kind:"token",token:e.token,workspaceId:e.workspaceId,workspaceName:e.workspaceName,getHeaders:(t=p(function*(){return{authorization:`Bearer ${e.token}`}}),function(){return t.apply(this,arguments)})}:null})(a)}},n=e=>r(e).auth},31596(e,a,t){t.d(a,{GE:()=>o,YC:()=>p,jR:()=>i});var p=["InSubspace","Global"],o="Data Bank is not enabled for this workspace.",i=e=>{if(e&&!p.includes(e))throw Error(`Invalid meta "${e}" (expected ${p.join(" | ")})`)}},56493(e,a,t){t.r(a),t.d(a,{requireAuth:()=>s,requireAuthConnection:()=>l});var p=t(99436),o=t(73284),i=t(47988),d=t(31802),r=t(29988),n=new Set(["$$typeof","asymmetricMatch","catch","constructor","finally","hasOwnProperty","inspect","nodeType","toJSON","toString","valueOf"]),l=(e=(0,i.getCurrentProfile)())=>{var a,t,l,s=(0,d.getConnectionContext)(e),u=s.auth,m=s.baseUrl;return u||(console.error(o.default.red("Not logged in.")),console.error(o.default.gray("Use `bricks auth login` (OAuth) or `bricks auth login-workspace` (workspace token) first.")),process.exit(1)),{...s,client:(a=null,t=p(function*(){return a||=Promise.resolve((0,r.i)()).then(({createClient:e})=>e(m,u))}),l=function(){return t.apply(this,arguments)},new Proxy({},{get:(e,a)=>a===Symbol.toStringTag?"BricksLazyClient":"string"!=typeof a||"then"===a||n.has(a)?void 0:p(function*(...e){var t=yield l(),p=t[a];return"function"==typeof p?p.apply(t,e):p})}))}},s=(e=(0,i.getCurrentProfile)())=>l(e).client},7586(e,a,t){t.d(a,{$l:()=>i,GF:()=>p,OW:()=>o});var p=e=>{console.log(JSON.stringify(e,null,2))},o=(e,a={})=>{console.error(JSON.stringify({ok:!1,error:{message:e,...a}},null,2))},i=(e,a=4)=>e?e.length<=2*a?"*".repeat(e.length):`${e.slice(0,a)}…${e.slice(-a)}`:null},8479(e,a,t){t.r(a),t.d(a,{isInteractiveTerminal:()=>p,shouldStartInteractiveMode:()=>o});var p=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&"function"==typeof process.stdin.setRawMode),o=(e=[])=>0===e.length&&p()},47988(e,a,t){t.r(a),t.d(a,{CONFIG_DIR:()=>F,CONFIG_LOCK_PATH:()=>E,CONFIG_PATH:()=>S,OAUTH_REFRESH_LOCK_PATH:()=>k,clearBankCredentials:()=>eM,clearConfig:()=>eq,clearOAuth:()=>eF,clearOAuthIfCurrent:()=>e$,clearOAuthIfCurrentAsync:()=>eO,default:()=>eJ,getActivityLogBaseUrl:()=>eU,getBankCredentials:()=>eP,getBaseUrl:()=>G,getCurrentProfile:()=>eB,getCurrentProfileSource:()=>eI,getOAuth:()=>eb,getProfileAuthKind:()=>ew,getProfileCredentialSnapshot:()=>ee,getProfileCredentialSnapshotAsync:()=>ea,getProfileFingerprint:()=>et,getToken:()=>K,getTokenInfo:()=>z,getTokens:()=>W,initializeConfigAsync:()=>q,installOAuthSessionIfCurrent:()=>eD,installOAuthSessionIfCurrentAsync:()=>ey,invalidateOAuthProfileCredentials:()=>eh,invalidateOAuthProfileCredentialsAsync:()=>ev,listProfiles:()=>eV,removeToken:()=>es,removeTokenIfCurrent:()=>eu,replaceOAuthIfCurrent:()=>eA,replaceOAuthIfCurrentAsync:()=>eN,resolveOAuthProfileTarget:()=>ep,setActivityLogBaseUrl:()=>eL,setBankCredentials:()=>eR,setBaseUrl:()=>H,setCurrentProfile:()=>ej,setDevtoolsTokenIfProfileCurrent:()=>em,setDevtoolsTokenIfProfileCurrentAsync:()=>ec,setOAuth:()=>e_,setOAuthAsync:()=>eC,setProfileOverride:()=>eT,setToken:()=>ed,setTokenIfProfileCurrent:()=>en,setTokenIfProfileCurrentAsync:()=>el,takeOAuthSession:()=>eS,takeOAuthSessionAsync:()=>eE,withOAuthRefreshLock:()=>V});var p,o,i,d,r,n,l,s,u,m,c,f,h,v,g=t(68832),D=t(99436),y=t(83440),w=t(76982),b=t(79896),_=t(16928),C=t(70857),F=_.join(C.homedir(),".bricks-cli"),S=_.join(F,"config.json"),E=`${S}.lock`,k=`${S}.oauth-refresh.lock`,A=new Int32Array(new SharedArrayBuffer(4)),N=e=>new Promise(a=>setTimeout(a,e)),$=e=>{if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"ESRCH"!==e.code}},O=e=>{try{var a=b.readFileSync(e,"utf8"),t=b.statSync(e),p=null;try{var o=JSON.parse(a);Number.isInteger(o?.pid)&&"string"==typeof o?.nonce&&(p=o)}catch{}return{raw:a,stat:t,owner:p}}catch(e){if("ENOENT"===e.code)return null;throw e}},x=e=>{var a,t=O(e);if(!t)return!0;var p=t.owner?!$(t.owner.pid):Date.now()-t.stat.mtimeMs>1e3;if(!p)return!1;var o=`${e}.recovery`;try{a=T(o)}catch(e){if("EEXIST"===e.code)return!1;throw e}try{if(!(t=O(e)))return!0;if(!(p=t.owner?!$(t.owner.pid):Date.now()-t.stat.mtimeMs>1e3))return!1;return b.unlinkSync(e),!0}catch(e){if("ENOENT"===e.code)return!0;throw e}finally{B(o,a)}},T=e=>{var a,t={pid:process.pid,nonce:w.randomUUID()},p=`${e}.${t.pid}.${t.nonce}.candidate`;try{a=b.openSync(p,"wx",384),b.writeFileSync(a,JSON.stringify(t)),b.fsyncSync(a),b.closeSync(a),a=void 0}catch(e){if(void 0!==a)try{b.closeSync(a)}catch{}try{b.unlinkSync(p)}catch{}throw e}try{b.linkSync(p,e)}catch(e){try{b.unlinkSync(p)}catch{}throw e}try{b.unlinkSync(p)}catch(e){"ENOENT"!==e.code&&console.error(`Failed to clean up shared BRICKS lock candidate: ${e.message}`)}return{owner:t}},B=(e,{owner:a})=>{try{var t;(t=O(e))&&t.owner?.nonce===a.nonce&&b.unlinkSync(e)}catch(e){"ENOENT"!==e.code&&console.error(`Failed to release shared BRICKS lock: ${e.message}`)}},I=e=>{b.mkdirSync(F,{recursive:!0});for(var a,t=Date.now()+5e3;!a;)try{a=T(E)}catch(e){if("EEXIST"!==e.code)throw e;if(x(E))continue;if(Date.now()>=t)throw Error(`Timed out waiting for shared BRICKS config lock: ${E}`);Atomics.wait(A,0,0,20)}try{return e()}finally{B(E,a)}},j=(p=D(function*(e){b.mkdirSync(F,{recursive:!0});for(var a,t=Date.now()+5e3;!a;)try{a=T(E)}catch(e){if("EEXIST"!==e.code)throw e;if(x(E))continue;if(Date.now()>=t)throw Error(`Timed out waiting for shared BRICKS config lock: ${E}`);yield N(20)}try{var p=e();if(p&&"function"==typeof p.then)throw Error("Shared BRICKS config lock callbacks must be synchronous");return p}finally{B(E,a)}}),function(e){return p.apply(this,arguments)}),V=(o=D(function*(e,{timeoutMs:a=3e4}={}){b.mkdirSync(F,{recursive:!0});for(var t,p=Date.now()+a;!t;)try{t=T(k)}catch(e){if("EEXIST"!==e.code)throw e;if(x(k))continue;if(Date.now()>=p)throw Error(`Timed out waiting for OAuth refresh lock: ${k}`);yield N(20)}try{return yield e()}finally{B(k,t)}}),function(e){return o.apply(this,arguments)}),P=()=>new y.default({projectName:"bricks-cli",cwd:F,configFileMode:384,schema:{oauth:{type:"object",default:{},properties:{accessToken:{type:"string"},refreshToken:{type:["string","null"]},expiresAt:{type:"string"},user:{type:"object"},audience:{type:"string"}}},tokens:{type:"object",default:{},additionalProperties:{type:"object",properties:{type:{type:"string",enum:["oauth"]},oauthSubject:{type:"string"},token:{type:"string"},name:{type:"string"},workspaceId:{type:"string"},workspaceName:{type:"string"},workspaceBilling:{type:"object"},createdAt:{type:"string"},baseUrl:{type:"string"},activityLogBaseUrl:{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"}}}}}}}),R=null,M=null,U=()=>R||=P(),L=(i=D(function*(){if(R)return R;M||=j(()=>R||=P());try{return yield M}finally{M=null}}),function(){return i.apply(this,arguments)}),q=(d=D(function*(){yield L()}),function(){return d.apply(this,arguments)}),J={get:e=>U().get(e),set:(e,a)=>{var t=U();return I(()=>t.set(e,a))},clear:()=>{var e=U();return I(()=>e.clear())},setAsync:(r=D(function*(e,a){var t=yield L();return j(()=>t.set(e,a))}),function(e,a){return r.apply(this,arguments)}),update:(e,a)=>{var t=U();return I(()=>{var p=a(t.get(e));return t.set(e,p),p})},updateAsync:(n=D(function*(e,a){var t=yield L();return j(()=>{var p=a(t.get(e));return t.set(e,p),p})}),function(e,a){return n.apply(this,arguments)}),snapshot:e=>{var a=U().store;return Object.fromEntries(e.map(e=>[e,a[e]]))},snapshotAsync:(l=D(function*(e){var a=(yield L()).store;return Object.fromEntries(e.map(e=>[e,a[e]]))}),function(e){return l.apply(this,arguments)}),transaction:(e,a)=>{var t=U();return I(()=>{var p=a(Object.fromEntries(e.map(e=>[e,t.get(e)])))||{};return Object.keys(p).length>0&&t.set(p),p})},transactionAsync:(s=D(function*(e,a){var t=yield L();return j(()=>{var p=a(Object.fromEntries(e.map(e=>[e,t.get(e)])))||{};return Object.keys(p).length>0&&t.set(p),p})}),function(e,a){return s.apply(this,arguments)})},G=(e=eB())=>{var a=J.get("tokens");return a[e]?.baseUrl||J.get("baseUrl")},H=(e,a)=>{a?J.update("tokens",(t={})=>({...t,[a]:{...t[a],baseUrl:e}})):J.set("baseUrl",e)},W=()=>J.get("tokens"),K=(e="default")=>{var a=J.get("tokens");return a[e]?.token},z=(e="default")=>J.get("tokens")[e],Y=(e,a,t,p)=>{if(!e)return null;var o=null==e.workspaceId?null:String(e.workspaceId);return"oauth"===e.type?e.oauthSubject&&e.oauthSubject===a?.user?.sub?{kind:"oauth",workspaceId:o,oauthSubject:e.oauthSubject,baseUrl:t,activityLogBaseUrl:p}:null:e.token?{kind:"token",workspaceId:o,token:e.token,baseUrl:t,activityLogBaseUrl:p}:null},Z=(e,a,t,p,o)=>{if(!e)return!1;var i=Y(a,t,a?.baseUrl||p,a?.activityLogBaseUrl||o);return!!i&&i.kind===e.kind&&i.workspaceId===e.workspaceId&&i.baseUrl===e.baseUrl&&i.activityLogBaseUrl===e.activityLogBaseUrl&&("oauth"===i.kind?i.oauthSubject===e.oauthSubject:i.token===e.token)},Q=(e,a,t)=>({exists:void 0!==e,kind:e?.type==="oauth"?"oauth":e?.token?"token":"incomplete",workspaceId:e?.workspaceId==null?null:String(e.workspaceId),credential:e?.type==="oauth"?e.oauthSubject||null:e?.token||null,baseUrl:a,activityLogBaseUrl:t}),X=(e,{tokens:a={},oauth:t,devtoolsTokens:p={},baseUrl:o,activityLogBaseUrl:i})=>{var d=a[e],r=d?.baseUrl||o,n=d?.activityLogBaseUrl||i,l=Y(d,t,r,n);return{profile:e,tokenInfo:d,oauth:t,fingerprint:l,baseline:Q(d,r,n),bank:l&&d?.bank||null,devtoolsTokens:p[e]||{},baseUrl:r,activityLogBaseUrl:n}},ee=(e="default")=>X(e,J.snapshot(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"])),ea=(u=D(function*(e="default"){return X(e,(yield J.snapshotAsync(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"])))}),function(){return u.apply(this,arguments)}),et=(e="default")=>ee(e).fingerprint,ep=(e,a,t)=>{for(var p=J.snapshot(["tokens","baseUrl","activityLogBaseUrl"]),o=p.tokens||{},i=e,d=2;;){var r=o[i];if(!r||"oauth"===r.type&&r.oauthSubject===t&&String(r.workspaceId)===String(a))break;i=`${e}-${d}`,d+=1}var n=o[i];return{profile:i,baseline:Q(n,n?.baseUrl||p.baseUrl,n?.activityLogBaseUrl||p.activityLogBaseUrl)}},eo=(e,a,t,p)=>{var o=t[e],i=o?.workspaceId&&a?.workspaceId&&String(o.workspaceId)===String(a.workspaceId),d=o?.type==="oauth"&&a?.type==="oauth"&&!!o.oauthSubject&&o.oauthSubject===a.oauthSubject||o?.type!=="oauth"&&a?.type!=="oauth"&&!!o?.token&&o.token===a?.token,r=i&&d,n={tokens:{...t,[e]:{...o?.baseUrl?{baseUrl:o.baseUrl}:{},...o?.activityLogBaseUrl?{activityLogBaseUrl:o.activityLogBaseUrl}:{},...r&&o?.bank?{bank:o.bank}:{},...a,createdAt:new Date().toISOString()}}};if(!r&&p[e]){var l={...p};delete l[e],n.devtoolsTokens=l}return n},ei=(e,a)=>{if(e&&a?.user?.sub!==e)throw Error("OAuth account changed. Re-select the workspace for the current account.")},ed=(e,a,{expectedOAuthSubject:t}={})=>{J.transaction(t?["tokens","devtoolsTokens","oauth"]:["tokens","devtoolsTokens"],({tokens:p={},devtoolsTokens:o={},oauth:i})=>(ei(t,i),eo(e,a,p,o)))},er=(e,a,t,p)=>!!e&&JSON.stringify(e)===JSON.stringify(Q(a,a?.baseUrl||t,a?.activityLogBaseUrl||p)),en=(e,a,t,{expectedOAuthSubject:p,makeCurrent:o=!1}={})=>{var i=!1;return J.transaction(["tokens","devtoolsTokens","oauth","currentProfile","baseUrl","activityLogBaseUrl"],({tokens:d={},devtoolsTokens:r={},oauth:n,baseUrl:l,activityLogBaseUrl:s})=>{if(!er(t,d[e],l,s))return{};ei(p,n),i=!0;var u=eo(e,a,d,r);return o?{...u,currentProfile:e}:u}),i},el=(m=D(function*(e,a,t,{expectedOAuthSubject:p,makeCurrent:o=!1}={}){var i=!1;return yield J.transactionAsync(["tokens","devtoolsTokens","oauth","currentProfile","baseUrl","activityLogBaseUrl"],({tokens:d={},devtoolsTokens:r={},oauth:n,baseUrl:l,activityLogBaseUrl:s})=>{if(!er(t,d[e],l,s))return{};ei(p,n),i=!0;var u=eo(e,a,d,r);return o?{...u,currentProfile:e}:u}),i}),function(e,a,t){return m.apply(this,arguments)}),es=e=>{J.transaction(["tokens","devtoolsTokens"],({tokens:a={},devtoolsTokens:t={}})=>{var p={...a};delete p[e];var o={tokens:p};if(t[e]){var i={...t};delete i[e],o.devtoolsTokens=i}return o})},eu=(e,a)=>{var t=!1;return J.transaction(["tokens","devtoolsTokens"],({tokens:p={},devtoolsTokens:o={}})=>{if(i=p[e],!i||!a||String(i.workspaceId??"")!==String(a.workspaceId??"")||("oauth"===a.type?"oauth"!==i.type||i.oauthSubject!==a.oauthSubject:a.token?"oauth"===i.type||i.token!==a.token:JSON.stringify(i)!==JSON.stringify(a)))return{};t=!0;var i,d={...p};delete d[e];var r={...o};return delete r[e],{tokens:d,devtoolsTokens:r}}),t},em=(e,a,t,p)=>{var o=!1;return J.transaction(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"],({tokens:i={},oauth:d,devtoolsTokens:r={},baseUrl:n,activityLogBaseUrl:l})=>Z(a,i[e],d,n,l)?(o=!0,{devtoolsTokens:{...r,[e]:{...r[e],[t]:p}}}):{}),o},ec=(c=D(function*(e,a,t,p){var o=!1;return yield J.transactionAsync(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"],({tokens:i={},oauth:d,devtoolsTokens:r={},baseUrl:n,activityLogBaseUrl:l})=>Z(a,i[e],d,n,l)?(o=!0,{devtoolsTokens:{...r,[e]:{...r[e],[t]:p}}}):{}),o}),function(e,a,t,p){return c.apply(this,arguments)}),ef=(e,a)=>{if(e)return a(["tokens","devtoolsTokens"],({tokens:a={},devtoolsTokens:t={}})=>{var p={...a},o=[];for(var i of Object.entries(a)){var d=g(i,2),r=d[0],n=d[1];if(n?.type==="oauth"&&(!n.oauthSubject||n.oauthSubject===e)){o.push(r);var l={...n,oauthSubject:n.oauthSubject||e};delete l.bank,p[r]=l}}var s={...t},u=!1;return o.forEach(e=>{s[e]&&(delete s[e],u=!0)}),{tokens:p,...u?{devtoolsTokens:s}:{}}})},eh=e=>ef(e,J.transaction),ev=e=>ef(e,J.transactionAsync),eg=(e,a,t)=>{if(p=t.oauth,e?.accessToken?!ek(e,p):!!p?.accessToken)return{result:{installed:!1,identityChanged:!1,previous:null},updates:{}};var p,o=t.oauth?.accessToken?t.oauth:null,i=o?.user?.sub,d=!!(i&&a?.user?.sub&&i!==a.user.sub),r={installed:!0,identityChanged:d,previous:o};if(!d)return{result:r,updates:{oauth:a}};var n={...t.tokens||{}},l={...t.devtoolsTokens||{}},s=!1;for(var u of Object.entries(t.tokens||{})){var m=g(u,2),c=m[0],f=m[1];if(f?.type==="oauth"&&(!f.oauthSubject||f.oauthSubject===i)){var h={...f,oauthSubject:f.oauthSubject||i};delete h.bank,n[c]=h,l[c]&&(delete l[c],s=!0)}}return{result:r,updates:{oauth:a,tokens:n,...s?{devtoolsTokens:l}:{}}}},eD=(e,a)=>{var t;return J.transaction(["oauth","tokens","devtoolsTokens"],p=>{var o=eg(e,a,p);return t=o.result,o.updates}),t},ey=(f=D(function*(e,a){var t;return yield J.transactionAsync(["oauth","tokens","devtoolsTokens"],p=>{var o=eg(e,a,p);return t=o.result,o.updates}),t}),function(e,a){return f.apply(this,arguments)}),ew=(e="default")=>{var a=z(e);return a?"oauth"===a.type?"oauth":a.token?"token":null:null},eb=()=>{var e=J.get("oauth");return e&&Object.keys(e).length>0?e:null},e_=e=>J.set("oauth",e),eC=e=>J.setAsync("oauth",e),eF=()=>J.set("oauth",{}),eS=()=>{var e=null;return J.update("oauth",a=>(a?.accessToken&&(e=a),{})),e},eE=(h=D(function*(){var e=null;return yield J.updateAsync("oauth",a=>(a?.accessToken&&(e=a),{})),e}),function(){return h.apply(this,arguments)}),ek=(e,a)=>!!e&&!!a&&e.accessToken===a.accessToken&&e.refreshToken===a.refreshToken,eA=(e,a)=>{var t=!1;return J.update("oauth",p=>ek(e,p)?(t=!0,a||{}):p||{}),t},eN=(v=D(function*(e,a){var t=!1;return yield J.updateAsync("oauth",p=>ek(e,p)?(t=!0,a||{}):p||{}),t}),function(e,a){return v.apply(this,arguments)}),e$=e=>eA(e,{}),eO=e=>eN(e,{}),ex=null,eT=e=>{ex=e},eB=()=>ex||process.env.BRICKS_PROFILE||J.get("currentProfile"),eI=()=>ex?"override":process.env.BRICKS_PROFILE?"env":"config",ej=e=>J.set("currentProfile",e),eV=()=>{var e=J.get("tokens"),a=J.get("currentProfile");return Object.keys(e).map(t=>({...e[t],name:t,current:t===a}))},eP=(e="default")=>{var a=J.get("tokens")[e];if(a?.type==="oauth"){var t=eb();if(!a.oauthSubject||a.oauthSubject!==t?.user?.sub)return null}return a?.bank||null},eR=(e,a,{expectedProfile:t}={})=>{var p=!1;return J.transaction(["tokens","oauth","baseUrl","activityLogBaseUrl"],({tokens:o={},oauth:i,baseUrl:d,activityLogBaseUrl:r})=>(!t||Z(t,o[e],i,d,r))&&o[e]?(p=!0,{tokens:{...o,[e]:{...o[e],bank:a}}}):{}),p},eM=(e,{expectedProfile:a,expectedSpacekey:t}={})=>{var p=!1;return J.transaction(["tokens","oauth","baseUrl","activityLogBaseUrl"],({tokens:o={},oauth:i,baseUrl:d,activityLogBaseUrl:r})=>{if(a&&!Z(a,o[e],i,d,r)||!o[e]?.bank||t&&o[e].bank.spacekey!==t)return{};p=!0;var n={...o[e]};return delete n.bank,{tokens:{...o,[e]:n}}}),p},eU=(e=eB())=>{var a=J.get("tokens");return a[e]?.activityLogBaseUrl||J.get("activityLogBaseUrl")},eL=(e,a)=>{a?J.update("tokens",(t={})=>({...t,[a]:{...t[a],activityLogBaseUrl:e}})):J.set("activityLogBaseUrl",e)},eq=()=>{J.clear()};let eJ=J},75646(e,a,t){t.r(a),t.d(a,{discoverDevToolsServers:()=>n,httpProbeSubnet:()=>l,verifyDevToolsServer:()=>s});var p,o,i=t(99436),d=t(19557),r="bricks-devtools",n=({timeout:e=3e3,idleTimeout:a=0}={})=>(0,d.YH)({port:19900,timeout:e,idleTimeout:a,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:r,d:{id:`cli-${(0,d.BW)()}`}})),parseMessage:(e,a)=>{var t=(0,d.nl)(e,e=>e?.s===r);if(!t)return null;var p=a.address;return{key:`${p}:${t.port}`,value:{...t,address:p}}}}),l=(p=i(function*({port:e=19851,connectTimeout:a=500,concurrency:t=50,timeout:p=0}={}){var o=(0,d.r9)();if(0===o.length)return[];var r=[],n=p>0?Date.now()+p:0,l=[],u=new Set;for(var m of o){var c=m.address.split(".").slice(0,3).join(".");if(!u.has(c)){u.add(c);for(var f=1;f<255;f++)l.push(`${c}.${f}`)}}for(var h=0;h<l.length&&!(n&&Date.now()>=n);h+=t){var v=l.slice(h,h+t);yield Promise.allSettled(v.map(function(){var t=i(function*(t){var p=yield s(t,e,a);p&&r.push({...p,address:t,port:e})});return function(e){return t.apply(this,arguments)}}()))}return r}),function(){return p.apply(this,arguments)}),s=(o=i(function*(e,a,t=3e3){return(0,d.uE)(`http://${e}:${a}/devtools/info`,t)}),function(e,a){return o.apply(this,arguments)})},29988(e,a,t){t.d(a,{i:()=>p});var p=()=>"u">typeof module&&"function"==typeof module.require?module.require("../gql/client.js"):Promise.all([t.e(3332),t.e(8295),t.e(907)]).then(t.bind(t,85382))},19557(e,a,t){t.d(a,{BW:()=>r,YH:()=>u,nl:()=>l,r9:()=>s,uE:()=>m});var p,o=t(99436),i=t(41314),d=t(48161),r=()=>Math.random().toString(36).slice(2,9),n=new Set(["ANNOUNCE","RESPONSE"]),l=(e,a)=>{var t=JSON.parse(e.toString());return a(t)&&n.has(t.t)&&t.d?.info||null},s=()=>{var e=[];for(var a of Object.values(d.networkInterfaces()))for(var t of a)if(function(){if("IPv4"!==t.family||t.internal)return 1;var a=t.address.split(".").map(Number),p=t.netmask.split(".").map(Number),o=a.map((e,a)=>(e|255&~p[a]).toString()).join(".");e.push({address:t.address,broadcast:o})}())continue;return e},u=({port:e,timeout:a=3e3,idleTimeout:t=0,buildQuery:p,parseMessage:o})=>new Promise((d,r)=>{var n=new Map,l=i.createSocket("udp4"),u=null,m=null,c=!1,f=()=>{if(!c){c=!0,clearTimeout(u),clearTimeout(m);try{l.close()}catch{}d([...n.values()])}};l.on("error",e=>{if(!c){c=!0,clearTimeout(u),clearTimeout(m);try{l.close()}catch{}r(e)}}),l.on("message",(e,a)=>{try{var p=o(e,a);if(!p||n.has(p.key))return;n.set(p.key,p.value),t&&!c&&(clearTimeout(m),m=setTimeout(f,t))}catch{}}),l.bind(()=>{l.setBroadcast(!0);var t=p();for(var o of(()=>{var e=new Set(["255.255.255.255","127.0.0.1"]);for(var a of s())e.add(a.broadcast);return[...e]})())l.send(t,0,t.length,e,o);u=setTimeout(f,a)})}),m=(p=o(function*(e,a=3e3){var t;try{var p=new AbortController;t=setTimeout(()=>p.abort(),a);var o=yield fetch(e,{signal:p.signal});if(!o.ok)return null;return yield o.json()}catch{return null}finally{void 0!==t&&clearTimeout(t)}}),function(e){return p.apply(this,arguments)})},63755(e,a,t){t.d(a,{EC:()=>M,IC:()=>U,UY:()=>I,X9:()=>J,Zd:()=>V,b2:()=>B,bo:()=>P,iF:()=>L,n_:()=>S,ph:()=>q});var p,o,i,d,r,n,l,s,u=t(68832),m=t(99436),c=t(76982),f=t(58611),h=t(35317),v=t(79657),g=t(64007),D=t(47988),y=process.env.BRICKS_OAUTH_DOMAIN||"auth0.bricks.tools",w=process.env.BRICKS_OAUTH_AUDIENCE||"https://display.bricks.tools",b="openid profile email offline_access",_=process.env.BRICKS_OAUTH_CLIENT_ID||"Atyy2gp0suIWE33rj8LtJ0pJpIGHiGaT",C="/callback",F="127.0.0.1",S=()=>!!_,E=(e,a,{signal:t}={})=>(()=>{var e=process.env.HTTPS_PROXY||process.env.https_proxy;if(!e)return v.Ay;var a=new g(e);return(e,t={})=>(0,v.Ay)(e,{...t,agent:a})})()(`https://${y}${e}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(a).toString(),signal:t}),k=(p=m(function*(e){var a;try{a=yield e.json()}catch(e){if(e?.name==="AbortError")throw e;a={}}if(!e.ok){var t=Error(a.error_description||a.error||`HTTP ${e.status}`);throw t.code=a.error,t}return a}),function(e){return p.apply(this,arguments)}),A=(o=m(function*(e,a){var t=new AbortController,p=setTimeout(()=>t.abort(),15e3);try{return yield k((yield E(e,a,{signal:t.signal})))}finally{clearTimeout(p)}}),function(e,a){return o.apply(this,arguments)}),N=e=>String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;"),$=({title:e,heading:a,message:t})=>`<!doctype html>
106
106
  <html lang="en">
107
107
  <head>