@fugood/bricks-cli 2.26.0-beta.27 → 2.26.0-beta.29

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/9663.js CHANGED
@@ -1 +1 @@
1
- export const __rspack_esm_id=9663;export const __rspack_esm_ids=[9663];export const __webpack_modules__={5018(t){t.exports=function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},44668(t,e,r){var i=r(56347);function o(t,e){for(var r=0;r<e.length;r++){var o=e[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,i(o.key),o)}}t.exports=function(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},23878(t,e,r){var i=r(14319).default;t.exports=function(t,e){if("object"!=i(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=i(o))return o;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},56347(t,e,r){var i=r(14319).default,o=r(23878);t.exports=function(t){var e=o(t,"string");return"symbol"==i(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},14319(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},69995(t,e,r){r.d(e,{H:()=>i});function i(t,e){try{var r=JSON.parse(t).error,i=r?.message??r;if("string"==typeof i&&i)return i}catch{}return t||e}},42208(t,e,r){r.d(e,{RP:()=>a});var i=r(99436),o=r(75720),n="CTOR",s="ctor@bricks.tools",l=`Co-authored-by: ${n} <${s}>`;function u(){return(u=i(function*(t){return!!(yield(0,o.sh)`cd ${t} && git config user.email`.quiet().nothrow().text()).trim()})).apply(this,arguments)}function a(t,e){return c.apply(this,arguments)}function c(){return(c=i(function*(t,e,r=[]){var i=yield function(t){return u.apply(this,arguments)}(t),o=i?[]:["-c",`user.name=${n}`,"-c",`user.email=${s}`],a=[];for(var c of e)a.push("-m",c);return i&&a.push("-m",l),[...o,"commit",...r,...a]})).apply(this,arguments)}},13376(t,e,r){r.d(e,{a:()=>u,p:()=>s});var i=r(99436),o=r(51455),n=".bricks/.last-pushed-commit";function s(t){return l.apply(this,arguments)}function l(){return(l=i(function*(t){try{return(yield(0,o.readFile)(`${t}/${n}`,"utf8")).trim()||null}catch{return null}})).apply(this,arguments)}function u(t,e){return a.apply(this,arguments)}function a(){return(a=i(function*(t,e){e&&(yield(0,o.mkdir)(`${t}/.bricks`,{recursive:!0}),yield(0,o.writeFile)(`${t}/${n}`,e))})).apply(this,arguments)}},69070(t,e,r){r.d(e,{k:()=>s,q:()=>u});var i=r(99436),o=r(26848),n=r(1708);function s(t){return l.apply(this,arguments)}function l(){return(l=i(function*(t){if(!n.stdin.isTTY)return"";var e=(0,o.createInterface)({input:n.stdin,output:n.stdout});try{return(yield e.question(`${t} `)).trim()}finally{e.close()}})).apply(this,arguments)}function u(t){return a.apply(this,arguments)}function a(){return(a=i(function*(t){return(yield s(t))==="y"})).apply(this,arguments)}},75720(t,e,r){r.d(e,{p:()=>d,sh:()=>f});var i,o,n=r(90250),s=r(99436),l=r(5018),u=r(44668),a=r(31421),c=r(73024),d=()=>{var t=process.argv[1];return t&&!(t.includes("$bunfs")||t.includes("~BUN"))&&(0,c.existsSync)(t)?[process.execPath,t]:[process.execPath]},p=u(function t(e){l(this,t),this._cwd=void 0,this._mode="default",this._throw=!0,this._env=void 0,this._promise=null,this.args=e},[{key:"cwd",value:function(t){return this._cwd=t,this}},{key:"quiet",value:function(){return this._mode="quiet",this}},{key:"nothrow",value:function(){return this._throw=!1,this}},{key:"env",value:function(t){return this._env={...this._env,...t},this}},{key:"text",value:(i=s(function*(){return"default"===this._mode&&(this._mode="text"),(yield this.run()).stdout.toString("utf8")}),function(){return i.apply(this,arguments)})},{key:"then",value:function(t,e){return this.run().then(t,e)}},{key:"run",value:function(){return this._promise||(this._promise=this.exec()),this._promise}},{key:"exec",value:(o=s(function*(){var t=n(this.args),e=t[0],r=(function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i})(t).slice(1);if(!e)throw Error("sh: empty command");var i="default"===this._mode?["inherit","pipe","pipe"]:"quiet"===this._mode?["ignore","pipe","pipe"]:["inherit","pipe","pipe"],o=this._env?{...process.env,...this._env}:void 0,s=(0,a.spawn)(e,r,{cwd:this._cwd,stdio:i,env:o}),l=[],u=[];s.stdout?.on("data",t=>{l.push(t),"default"===this._mode&&process.stdout.write(t)}),s.stderr?.on("data",t=>{u.push(t),"default"===this._mode&&process.stderr.write(t)});var c=yield new Promise((t,e)=>{s.on("error",e),s.on("close",(e,r)=>t({code:e,signal:r}))}),d=c.code,p=c.signal,h=d??1,f=Buffer.concat(l),y=Buffer.concat(u);if(0!==h&&this._throw){var m=p?`signal ${p}`:`exit ${h}`,v=Error(`sh: command failed with ${m}: ${this.args.join(" ")}`);throw v.exitCode=h,v.stdout=f,v.stderr=y,v}return{exitCode:h,stdout:f,stderr:y}}),function(){return o.apply(this,arguments)})}]),h=/\s/;function f(t,...e){var r,i,o,n,s,l=(r=[],i="",o=!1,n=()=>{o&&(r.push(i),i="",o=!1)},s=t=>{i+=t,o=!0},(t.forEach((t,r)=>{for(var i=0;i<t.length;i++){var o=t[i];h.test(o)?n():s(o)}r<e.length&&(t=>{if(null!=t){if(Array.isArray(t))return t.forEach((t,e)=>{e>0&&n(),s(String(t))});s(String(t))}})(e[r])}),n(),r.length>=3&&"cd"===r[0]&&"&&"===r[2])?{tokens:r.slice(3),initialCwd:r[1]}:{tokens:r}),u=l.tokens,a=l.initialCwd,c=new p(u);return a&&c.cwd(a),c}},47090(t,e,r){r.r(e),r.d(e,{pull:()=>y});var i=r(99436),o=r(51455),n=r(73024),s=r(76760),l=r(75720),u=r(69995),a=r(42208),c=r(13376),d=r(69070),p=["subspaces","automation-tests"];function h(t,e){return f.apply(this,arguments)}function f(){return(f=i(function*(t,e){if(!(0,n.existsSync)(t))return[];var r,l=[],u=yield(0,o.readdir)(t,{withFileTypes:!0});return yield Promise.all(u.map((r=i(function*(r){var i=(0,s.join)(t,r.name);r.isDirectory()?l.push(...yield h(i,e)):r.isFile()&&r.name.endsWith(".ts")&&l.push((0,s.relative)(e,i))}),function(t){return r.apply(this,arguments)}))),l})).apply(this,arguments)}function y(){return m.apply(this,arguments)}function m(){return(m=i(function*(t={}){var e,n,f=process.cwd(),y=!!t.force,m=0===(yield(0,l.sh)`cd ${f} && git status`.nothrow()).exitCode;if(m){if(yield(0,l.sh)`cd ${f} && git diff --name-only --diff-filter=ACMR`.text())if(y){console.log("Force mode: committing unstaged changes before pull..."),yield(0,l.sh)`cd ${f} && git add .`;var v=yield(0,a.RP)(f,["chore(force-pull): saved unstaged changes before pull"]);yield(0,l.sh)`cd ${f} && git ${v}`}else throw Error("Unstaged changes found, please commit or stash your changes before pulling")}else if(!(yield(0,d.q)("No git repository found, so it will not be safe to pull, continue? (y/n)")))throw Error("Pull cancelled");var g=JSON.parse((yield(0,o.readFile)(`${f}/application.json`,"utf8"))),$="module"===g.type,_=$?"module":"app";console.log(`Pulling ${_} project (${g.id})...`);var w=yield(0,l.sh)`bricks ${_} project-pull ${g.id} --json`.quiet().nothrow();if(0!==w.exitCode){var x=w.stderr.toString()||w.stdout.toString();throw Error((0,u.H)(x,"Pull failed"))}var b=JSON.parse(w.stdout.toString()),k=b.files,S=b.lastCommitId,P=(yield(0,c.p)(f))||S,C=$?"BRICKS_PROJECT_try-pull-module":"BRICKS_PROJECT_try-pull-application",j="";if(m&&!y){if(!(j=(yield(0,l.sh)`cd ${f} && git branch --show-current`.text()).trim()))throw Error("Cannot pull from a detached HEAD");console.log(`Checking commit ${P}...`);var E=(yield(0,l.sh)`cd ${f} && git rev-list -1 ${P}`.nothrow().text()).trim().match(/^[\da-f]{40}$/);if((yield(0,l.sh)`cd ${f} && git rev-parse HEAD`.text()).trim()===S)throw Error("Commit not changed");yield(0,l.sh)`cd ${f} && git branch -D ${C}`.nothrow(),E?yield(0,l.sh)`cd ${f} && git checkout -b ${C} ${P}`:yield(0,l.sh)`cd ${f} && git checkout -b ${C}`}var R=yield(0,o.readFile)(`${f}/.oxfmtrc.json`,"utf8").then(JSON.parse).catch(()=>({trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})),O=new Set(k.map(t=>t.name)),q=[];yield Promise.all(p.map((e=i(function*(t){for(var e of yield h((0,s.join)(f,t),f)){var r=e.split(/[\\/]/).join("/");O.has(r)||q.push(r)}}),function(t){return e.apply(this,arguments)})));var A=q.map(t=>(0,o.unlink)(`${f}/${t}`));try{yield Promise.all(A)}catch(t){throw yield Promise.allSettled(A),t}var F=(yield r.e(7456).then(r.bind(r,79491))).format,M=k.map((n=i(function*(t){var e=t.input;t.formatable&&(e=(yield F(t.name,t.input,R)).code);var r=(0,s.join)(f,t.name);return yield(0,o.mkdir)((0,s.dirname)(r),{recursive:!0}),(0,o.writeFile)(r,e)}),function(t){return n.apply(this,arguments)}));try{yield Promise.all(M)}catch(t){throw yield Promise.allSettled(M),t}if(m){if(yield(0,l.sh)`cd ${f} && git add .`,(yield(0,l.sh)`cd ${f} && git diff --cached --name-only`.text()).trim()){var T=y?`chore(force-pull): apply force pull-${_}`:$?"chore(project): apply file changes from BRICKS module":"chore(project): apply file changes from BRICKS application",B=yield(0,a.RP)(f,[T]);yield(0,l.sh)`cd ${f} && git ${B}`}if(!y){if(yield(0,l.sh)`cd ${f} && git checkout ${j}`,0!==(yield(0,l.sh)`cd ${f} && git merge ${C} --no-edit`.nothrow()).exitCode){yield(0,l.sh)`cd ${f} && git add .`;var N=yield(0,a.RP)(f,[`chore(project): merge with conflicts (resolve in ${j})`],["--no-verify"]);yield(0,l.sh)`cd ${f} && git ${N}`}yield(0,l.sh)`cd ${f} && git branch -D ${C}`.nothrow()}var D=(yield(0,l.sh)`cd ${f} && git rev-parse HEAD`.nothrow().text()).trim();D&&(yield(0,c.a)(f,D))}console.log(`${$?"Module":"App"} project pulled: ${k.length} files${q.length?`, removed ${q.length} orphan .ts file${1===q.length?"":"s"}`:""}${y?" (force)":""}`)})).apply(this,arguments)}}};
1
+ export const __rspack_esm_id=9663;export const __rspack_esm_ids=[9663];export const __webpack_modules__={5018(t){t.exports=function(t,e){if(!(t instanceof e))throw TypeError("Cannot call a class as a function")},t.exports.__esModule=!0,t.exports.default=t.exports},44668(t,e,r){var i=r(56347);function n(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t},t.exports.__esModule=!0,t.exports.default=t.exports},23878(t,e,r){var i=r(14319).default;t.exports=function(t,e){if("object"!=i(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=i(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},56347(t,e,r){var i=r(14319).default,n=r(23878);t.exports=function(t){var e=n(t,"string");return"symbol"==i(e)?e:e+""},t.exports.__esModule=!0,t.exports.default=t.exports},14319(t){function e(r){return t.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},69995(t,e,r){r.d(e,{H:()=>i});function i(t,e){try{var r=JSON.parse(t).error,i=r?.message??r;if("string"==typeof i&&i)return i}catch{}return t||e}},42208(t,e,r){r.d(e,{RP:()=>a});var i=r(99436),n=r(75720),o="CTOR",s="ctor@bricks.tools",l=`Co-authored-by: ${o} <${s}>`;function u(){return(u=i(function*(t){return!!(yield(0,n.sh)`cd ${t} && git config user.email`.quiet().nothrow().text()).trim()})).apply(this,arguments)}function a(t,e){return c.apply(this,arguments)}function c(){return(c=i(function*(t,e,r=[]){var i=yield function(t){return u.apply(this,arguments)}(t),n=i?[]:["-c",`user.name=${o}`,"-c",`user.email=${s}`],a=[];for(var c of e)a.push("-m",c);return i&&a.push("-m",l),[...n,"commit",...r,...a]})).apply(this,arguments)}},19290(t,e,r){r.d(e,{p:()=>o});var i=r(99436),n=r(75720);function o(t){return s.apply(this,arguments)}function s(){return(s=i(function*(t){return((yield(0,n.sh)`cd ${t} && git diff --cached --name-only --diff-filter=ACMR`.text())+(yield(0,n.sh)`cd ${t} && git diff --name-only --diff-filter=ACMR`.text())).trim()})).apply(this,arguments)}},13376(t,e,r){r.d(e,{$j:()=>d,M7:()=>h,ay:()=>u,pe:()=>s});var i=r(99436),n=r(51455),o=".bricks/.last-pushed-commit";function s(t){return l.apply(this,arguments)}function l(){return(l=i(function*(t){try{return(yield(0,n.readFile)(`${t}/${o}`,"utf8")).trim()||null}catch{return null}})).apply(this,arguments)}function u(t,e){return a.apply(this,arguments)}function a(){return(a=i(function*(t,e){e&&(yield(0,n.mkdir)(`${t}/.bricks`,{recursive:!0}),yield(0,n.writeFile)(`${t}/${o}`,e))})).apply(this,arguments)}var c=".bricks/build/.last-synced-server-commit.json";function d(t){return p.apply(this,arguments)}function p(){return(p=i(function*(t){try{var e=JSON.parse((yield(0,n.readFile)(`${t}/${c}`,"utf8"))),r=e.serverCommitId,i=e.localCommitId;return r&&i?{serverCommitId:r,localCommitId:i}:null}catch{return null}})).apply(this,arguments)}function h(t,e){return f.apply(this,arguments)}function f(){return(f=i(function*(t,{serverCommitId:e,localCommitId:r}){e&&r&&(yield(0,n.mkdir)(`${t}/.bricks/build`,{recursive:!0}),yield(0,n.writeFile)(`${t}/${c}`,JSON.stringify({serverCommitId:e,localCommitId:r})))})).apply(this,arguments)}},69070(t,e,r){r.d(e,{k:()=>s,q:()=>u});var i=r(99436),n=r(26848),o=r(1708);function s(t){return l.apply(this,arguments)}function l(){return(l=i(function*(t){if(!o.stdin.isTTY)return"";var e=(0,n.createInterface)({input:o.stdin,output:o.stdout});try{return(yield e.question(`${t} `)).trim()}finally{e.close()}})).apply(this,arguments)}function u(t){return a.apply(this,arguments)}function a(){return(a=i(function*(t){return(yield s(t))==="y"})).apply(this,arguments)}},75720(t,e,r){r.d(e,{p:()=>d,sh:()=>f});var i,n,o=r(90250),s=r(99436),l=r(5018),u=r(44668),a=r(31421),c=r(73024),d=()=>{var t=process.argv[1];return t&&!(t.includes("$bunfs")||t.includes("~BUN"))&&(0,c.existsSync)(t)?[process.execPath,t]:[process.execPath]},p=u(function t(e){l(this,t),this._cwd=void 0,this._mode="default",this._throw=!0,this._env=void 0,this._promise=null,this.args=e},[{key:"cwd",value:function(t){return this._cwd=t,this}},{key:"quiet",value:function(){return this._mode="quiet",this}},{key:"nothrow",value:function(){return this._throw=!1,this}},{key:"env",value:function(t){return this._env={...this._env,...t},this}},{key:"text",value:(i=s(function*(){return"default"===this._mode&&(this._mode="text"),(yield this.run()).stdout.toString("utf8")}),function(){return i.apply(this,arguments)})},{key:"then",value:function(t,e){return this.run().then(t,e)}},{key:"run",value:function(){return this._promise||(this._promise=this.exec()),this._promise}},{key:"exec",value:(n=s(function*(){var t=o(this.args),e=t[0],r=(function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=Array(e);r<e;r++)i[r]=t[r];return i})(t).slice(1);if(!e)throw Error("sh: empty command");var i="default"===this._mode?["inherit","pipe","pipe"]:"quiet"===this._mode?["ignore","pipe","pipe"]:["inherit","pipe","pipe"],n=this._env?{...process.env,...this._env}:void 0,s=(0,a.spawn)(e,r,{cwd:this._cwd,stdio:i,env:n}),l=[],u=[];s.stdout?.on("data",t=>{l.push(t),"default"===this._mode&&process.stdout.write(t)}),s.stderr?.on("data",t=>{u.push(t),"default"===this._mode&&process.stderr.write(t)});var c=yield new Promise((t,e)=>{s.on("error",e),s.on("close",(e,r)=>t({code:e,signal:r}))}),d=c.code,p=c.signal,h=d??1,f=Buffer.concat(l),y=Buffer.concat(u);if(0!==h&&this._throw){var m=p?`signal ${p}`:`exit ${h}`,v=Error(`sh: command failed with ${m}: ${this.args.join(" ")}`);throw v.exitCode=h,v.stdout=f,v.stderr=y,v}return{exitCode:h,stdout:f,stderr:y}}),function(){return n.apply(this,arguments)})}]),h=/\s/;function f(t,...e){var r,i,n,o,s,l=(r=[],i="",n=!1,o=()=>{n&&(r.push(i),i="",n=!1)},s=t=>{i+=t,n=!0},(t.forEach((t,r)=>{for(var i=0;i<t.length;i++){var n=t[i];h.test(n)?o():s(n)}r<e.length&&(t=>{if(null!=t){if(Array.isArray(t))return t.forEach((t,e)=>{e>0&&o(),s(String(t))});s(String(t))}})(e[r])}),o(),r.length>=3&&"cd"===r[0]&&"&&"===r[2])?{tokens:r.slice(3),initialCwd:r[1]}:{tokens:r}),u=l.tokens,a=l.initialCwd,c=new p(u);return a&&c.cwd(a),c}},47090(t,e,r){r.r(e),r.d(e,{pull:()=>m});var i=r(99436),n=r(51455),o=r(73024),s=r(76760),l=r(75720),u=r(69995),a=r(42208),c=r(19290),d=r(13376),p=r(69070),h=["subspaces","automation-tests"];function f(t,e){return y.apply(this,arguments)}function y(){return(y=i(function*(t,e){if(!(0,o.existsSync)(t))return[];var r,l=[],u=yield(0,n.readdir)(t,{withFileTypes:!0});return yield Promise.all(u.map((r=i(function*(r){var i=(0,s.join)(t,r.name);r.isDirectory()?l.push(...yield f(i,e)):r.isFile()&&r.name.endsWith(".ts")&&l.push((0,s.relative)(e,i))}),function(t){return r.apply(this,arguments)}))),l})).apply(this,arguments)}function m(){return v.apply(this,arguments)}function v(){return(v=i(function*(t={}){var e,o,y=process.cwd(),m=!!t.force,v=0===(yield(0,l.sh)`cd ${y} && git status`.nothrow()).exitCode;if(v){if(yield(0,c.p)(y))if(m){console.log("Force mode: committing uncommitted changes before pull..."),yield(0,l.sh)`cd ${y} && git add .`;var g=yield(0,a.RP)(y,["chore(force-pull): saved unstaged changes before pull"]);yield(0,l.sh)`cd ${y} && git ${g}`}else throw Error("Uncommitted changes found, please commit or stash your changes before pulling")}else if(!(yield(0,p.q)("No git repository found, so it will not be safe to pull, continue? (y/n)")))throw Error("Pull cancelled");var $=JSON.parse((yield(0,n.readFile)(`${y}/application.json`,"utf8"))),_="module"===$.type,w=_?"module":"app";console.log(`Pulling ${w} project (${$.id})...`);var x=yield(0,l.sh)`bricks ${w} project-pull ${$.id} --json`.quiet().nothrow();if(0!==x.exitCode){var b=x.stderr.toString()||x.stdout.toString();throw Error((0,u.H)(b,"Pull failed"))}var k=JSON.parse(x.stdout.toString()),S=k.files,C=k.lastCommitId,P=(yield(0,d.pe)(y))||C,j=_?"BRICKS_PROJECT_try-pull-module":"BRICKS_PROJECT_try-pull-application",E="";if(v&&!m){if(!(E=(yield(0,l.sh)`cd ${y} && git branch --show-current`.text()).trim()))throw Error("Cannot pull from a detached HEAD");console.log(`Checking commit ${P}...`);var R=(yield(0,l.sh)`cd ${y} && git rev-list -1 ${P}`.nothrow().text()).trim().match(/^[\da-f]{40}$/);if((yield(0,l.sh)`cd ${y} && git rev-parse HEAD`.text()).trim()===C)throw Error("Commit not changed");yield(0,l.sh)`cd ${y} && git branch -D ${j}`.nothrow(),R?yield(0,l.sh)`cd ${y} && git checkout -b ${j} ${P}`:yield(0,l.sh)`cd ${y} && git checkout -b ${j}`}var M=yield(0,n.readFile)(`${y}/.oxfmtrc.json`,"utf8").then(JSON.parse).catch(()=>({trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})),O=new Set(S.map(t=>t.name)),F=[];yield Promise.all(h.map((e=i(function*(t){for(var e of yield f((0,s.join)(y,t),y)){var r=e.split(/[\\/]/).join("/");O.has(r)||F.push(r)}}),function(t){return e.apply(this,arguments)})));var I=F.map(t=>(0,n.unlink)(`${y}/${t}`));try{yield Promise.all(I)}catch(t){throw yield Promise.allSettled(I),t}var A=(yield r.e(7456).then(r.bind(r,79491))).format,N=S.map((o=i(function*(t){var e=t.input;t.formatable&&(e=(yield A(t.name,t.input,M)).code);var r=(0,s.join)(y,t.name);return yield(0,n.mkdir)((0,s.dirname)(r),{recursive:!0}),(0,n.writeFile)(r,e)}),function(t){return o.apply(this,arguments)}));try{yield Promise.all(N)}catch(t){throw yield Promise.allSettled(N),t}if(v){if(yield(0,l.sh)`cd ${y} && git add .`,(yield(0,l.sh)`cd ${y} && git diff --cached --name-only`.text()).trim()){var q=m?`chore(force-pull): apply force pull-${w}`:_?"chore(project): apply file changes from BRICKS module":"chore(project): apply file changes from BRICKS application",J=yield(0,a.RP)(y,[q]);yield(0,l.sh)`cd ${y} && git ${J}`}if(!m){if(yield(0,l.sh)`cd ${y} && git checkout ${E}`,0!==(yield(0,l.sh)`cd ${y} && git merge ${j} --no-edit`.nothrow()).exitCode){yield(0,l.sh)`cd ${y} && git add .`;var T=yield(0,a.RP)(y,[`chore(project): merge with conflicts (resolve in ${E})`],["--no-verify"]);yield(0,l.sh)`cd ${y} && git ${T}`}yield(0,l.sh)`cd ${y} && git branch -D ${j}`.nothrow()}var B=(yield(0,l.sh)`cd ${y} && git rev-parse HEAD`.nothrow().text()).trim();B&&(yield(0,d.ay)(y,B),yield(0,d.M7)(y,{serverCommitId:C,localCommitId:B}))}console.log(`${_?"Module":"App"} project pulled: ${S.length} files${F.length?`, removed ${F.length} orphan .ts file${1===F.length?"":"s"}`:""}${m?" (force)":""}`)})).apply(this,arguments)}}};
package/lib/index.js CHANGED
@@ -15,7 +15,7 @@ Expecting one of '${a.join("', '")}'`);let o=`${e}Help`;return this.on(o,e=>{let
15
15
  `)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(e=>t.is(e))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function v(e){return e.map(e=>{let t,a;if(!e.startsWith("--inspect"))return e;let o="127.0.0.1",r="9229";return(null!==(a=e.match(/^(--inspect(-brk)?)$/))?t=a[1]:null!==(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=a[1],/^\d+$/.test(a[3])?r=a[3]:o=a[3]):null!==(a=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=a[1],o=a[3],r=a[4]),t&&"0"!==r)?`${t}=${o}:${parseInt(r)+1}`:e})}t.Command=h},43823(e,t){class a extends Error{constructor(e,t,a){super(a),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}t.CommanderError=a,t.InvalidArgumentError=class extends a{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}},99690(e,t,a){let{humanReadableArgName:o}=a(41762);t.Help=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(e=>!e._hidden),a=e._getHelpCommand();return a&&!a._hidden&&t.push(a),this.sortSubcommands&&t.sort((e,t)=>e.name().localeCompare(t.name())),t}compareOptions(e,t){let a=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return a(e).localeCompare(a(t))}visibleOptions(e){let t=e.options.filter(e=>!e.hidden),a=e._getHelpOption();if(a&&!a.hidden){let o=a.short&&e._findOption(a.short),r=a.long&&e._findOption(a.long);o||r?a.long&&!r?t.push(e.createOption(a.long,a.description)):a.short&&!o&&t.push(e.createOption(a.short,a.description)):t.push(a)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let a=e.parent;a;a=a.parent){let e=a.options.filter(e=>!e.hidden);t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return(e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(e=>e.description))?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(e=>o(e)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((e,a)=>Math.max(e,t.subcommandTerm(a).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((e,a)=>Math.max(e,t.optionTerm(a).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((e,a)=>Math.max(e,t.optionTerm(a).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((e,a)=>Math.max(e,t.argumentTerm(a).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let a="";for(let t=e.parent;t;t=t.parent)a=t.name()+" "+a;return a+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0)?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(e=>JSON.stringify(e)).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let a=`(${t.join(", ")})`;return e.description?`${e.description} ${a}`:a}return e.description}formatHelp(e,t){let a=t.padWidth(e,t),o=t.helpWidth||80;function r(e,r){if(r){let i=`${e.padEnd(a+2)}${r}`;return t.wrap(i,o-2,a+2)}return e}function i(e){return e.join("\n").replace(/^/gm," ".repeat(2))}let n=[`Usage: ${t.commandUsage(e)}`,""],p=t.commandDescription(e);p.length>0&&(n=n.concat([t.wrap(p,o,0),""]));let d=t.visibleArguments(e).map(e=>r(t.argumentTerm(e),t.argumentDescription(e)));d.length>0&&(n=n.concat(["Arguments:",i(d),""]));let s=t.visibleOptions(e).map(e=>r(t.optionTerm(e),t.optionDescription(e)));if(s.length>0&&(n=n.concat(["Options:",i(s),""])),this.showGlobalOptions){let a=t.visibleGlobalOptions(e).map(e=>r(t.optionTerm(e),t.optionDescription(e)));a.length>0&&(n=n.concat(["Global Options:",i(a),""]))}let l=t.visibleCommands(e).map(e=>r(t.subcommandTerm(e),t.subcommandDescription(e)));return l.length>0&&(n=n.concat(["Commands:",i(l),""])),n.join("\n")}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,a,o=40){let r=RegExp("[\\n][ \\f\\t\\v\xa0  -    \uFEFF]+");if(e.match(r))return e;let i=t-a;if(i<o)return e;let n=e.slice(0,a),p=e.slice(a).replace("\r\n","\n"),d=" ".repeat(a),s="\\s​",l=RegExp(`
16
16
  |.{1,${i-1}}([${s}]|$)|[^${s}]+?([${s}]|$)`,"g");return n+(p.match(l)||[]).map((e,t)=>"\n"===e?"":(t>0?d:"")+e.trimEnd()).join("\n")}}},92088(e,t,a){let{InvalidArgumentError:o}=a(43823);t.Option=class{constructor(e,t){let a,o,r;this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let i=((r=e.split(/[ |,]+/)).length>1&&!/^[[<]/.test(r[1])&&(a=r.shift()),o=r.shift(),!a&&/^-[^-]$/.test(o)&&(a=o,o=void 0),{shortFlag:a,longFlag:o});this.short=i.shortFlag,this.long=i.longFlag,this.negate=!1,this.long&&(this.negate=this.long.startsWith("--no-")),this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(e){return this.argChoices=e.slice(),this.parseArg=(e,t)=>{if(!this.argChoices.includes(e))throw new o(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(e,t):e},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.name().replace(/^no-/,"").split("-").reduce((e,t)=>e+t[0].toUpperCase()+t.slice(1))}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}},t.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach(e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)}),this.negativeOptions.forEach((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)})}valueFromOption(e,t){let a=t.attributeName();if(!this.dualOptions.has(a))return!0;let o=this.negativeOptions.get(a).presetArg;return t.negate===((void 0!==o&&o)===e)}}},86054(e,t){t.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));let a=e.startsWith("--");a&&(e=e.slice(2),t=t.map(e=>e.slice(2)));let o=[],r=3;return(t.forEach(t=>{if(t.length<=1)return;let a=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);let a=[];for(let t=0;t<=e.length;t++)a[t]=[t];for(let e=0;e<=t.length;e++)a[0][e]=e;for(let o=1;o<=t.length;o++)for(let r=1;r<=e.length;r++){let i=1;i=+(e[r-1]!==t[o-1]),a[r][o]=Math.min(a[r-1][o]+1,a[r][o-1]+1,a[r-1][o-1]+i),r>1&&o>1&&e[r-1]===t[o-2]&&e[r-2]===t[o-1]&&(a[r][o]=Math.min(a[r][o],a[r-2][o-2]+1))}return a[e.length][t.length]}(e,t),i=Math.max(e.length,t.length);(i-a)/i>.4&&(a<r?(r=a,o=[t]):a===r&&o.push(t))}),o.sort((e,t)=>e.localeCompare(t)),a&&(o=o.map(e=>`--${e}`)),o.length>1)?`
17
17
  (Did you mean one of ${o.join(", ")}?)`:1===o.length?`
18
- (Did you mean ${o[0]}?)`:""}},43424(e,t,a){let o=a(3326),r=a(26687);t.normalizeAngle=e=>(e%360+360)%360;let i=(e,t,a,o)=>{let r=e*Math.cos(a)+t*Math.sin(a),i=e*Math.sin(a)+t*Math.cos(a);return o?t/i:e/r},n=(e,t,a,o)=>{let r=t*Math.cos(a)+e*Math.sin(a),i=t*Math.sin(a)+e*Math.cos(a);return o?t/i:e/r};t.getRotateFitScale=(e,a,o=0,r)=>{let p=t.normalizeAngle(o);return p<=90?i(e,a,Math.PI/180*p,r):p>90&&p<=180?n(e,a,Math.PI/180*(p-90),r):p>180&&p<=270?i(e,a,Math.PI/180*(p-180),r):n(e,a,Math.PI/180*(p-270),r)},t.getRotateCropScale=(e,a,o,r)=>1/t.getRotateFitScale(e,a,o,r),t.transformPhysicalRotateViewport=e=>{if(!e)return e;let{x:a,y:o,width:r,height:i,rotate:n,rotateType:p}=e;if("physical-rotate"!==p)return e;let d=t.getRotateCropScale(r,i,n,r>i),s=r*d,l=i*d;return{...e,x:a-(s-r)/2,y:o-(l-i)/2,width:s,height:l}},t.createViewport=(e,t={width:96,height:54},a={})=>{let{color:o}=r(e);return{viewport:!0,x:a.x||0,y:a.y||0,width:a.width||t.width,height:a.height||t.height,type:a.type||"rotate",rotate:a.rotate||0,rotateType:a.rotateType||"fit",scrollType:a.scrollType||"fit",maintainAspectRatio:a.maintainAspectRatio||!1,forceDeviceRatio:a.forceDeviceRatio||!1,content:a.content||`Viewport ${e}`,color:`${o}22`,selectedColor:`${o}66`,textColor:"#ccc",strokeColor:o}},t.getViewportsFromApplication=(e,a,o)=>{if(!e||!e.devices||!a||!a.subspace_map)return{};let r=a.subspace_map[a.root_subspace_id];if(!r||!r.layout)return{};if(o){let a=e.viewport_presets.find(e=>e._id===o);if(a?.viewports)return a.viewports.reduce((e,a)=>(e[a.device_target_name]=t.createViewport(a.device_target_name,r.layout,a.detail),e),{})}return e.devices.reduce((e,a)=>(e[a.device_id]=t.createViewport(a.device_id,r.layout,a.frame),e),{})},t.getDeviceSettingFromApplication=(e,t)=>{if(e&&e.devices)return e.devices.reduce((e,a)=>(e[a.device_id]=a[t],e),{})},t.intersectFrame=(e,t)=>{let a=Math.max(e.x,t.x);if(Math.min(e.x+e.width,t.x+t.width)<=a)return!1;let o=Math.max(e.y,t.y);return!(Math.min(e.y+e.height,t.y+t.height)<=o)},t.transformLayoutByViewport=(e,t)=>{if(!t)return e;let a=((e,t)=>{if("scroll"!==t.type)return null;let{scrollType:a="fit"}=t;return"fit"===a?{type:t.type,scrollType:a,width:Number(e.width),height:Number(e.height),scrollViewport:{width:Number(t.width),height:Number(t.height),x:Number(t.x),y:Number(t.y)}}:"crop"===a?{type:t.type,scrollType:a,width:Number(t.width),height:Number(t.height),originViewport:o(e,["originViewport"])}:null})(e,t);return a||{width:Number(t.width),height:Number(t.height),originViewport:o(e,["originViewport"])}},t.convertFrameByViewport=(e,t)=>{if(!t||"scroll"===t.type&&"fit"===t.scrollType)return e;e.originViewport&&(e.x=e.originViewport.x,e.y=e.originViewport.y,delete e.originViewport),e.originViewport={x:e.x,y:e.y},e.x-=Number(t.x),e.y-=Number(t.y)},t.transformRootSubspaceByViewport=(e,a)=>{if(!a)return e;let o=e.canvasMap?"canvasMap":"canvas_map",r=e[o],i={};for(let e of Object.keys(r)){let o=r[e],n=o.itemList?"itemList":"item_list";i[e]={...o,[n]:o[n].map(e=>{if(!e.frame)return e;let o={...e,frame:{...e.frame}};return t.convertFrameByViewport(o.frame,a),o})}}return{...e,[o]:i}},t.transformListByViewport=(e,a)=>a&&e&&0!==e.length?e.map(e=>{if(!e.frame)return e;let o={...e,frame:{...e.frame}};return t.convertFrameByViewport(o.frame,a),o}):e,t.transformFramesByViewport=(e,a)=>{if(!a||!e||0===Object.keys(e).length)return e;let o={};for(let[r,i]of Object.entries(e)){if(!i.frame){o[r]=i;continue}let e={...i,frame:{...i.frame}};t.convertFrameByViewport(e.frame,a),o[r]=e}return o}},98247(e,t,a){a.d(t,{v:()=>F});var o,r,i,n,p,d,s,l,u=a(99436),c=a(35679),m=a(73284),f=a(47988),h=a(31802),v=a(94979),g=a(16928),y=a(79896);function D(e){var t,a,o,r=2;for("u">typeof Symbol&&(a=Symbol.asyncIterator,o=Symbol.iterator);r--;){if(a&&null!=(t=e[a]))return t.call(e);if(o&&null!=(t=e[o]))return new w(t.call(e));a="@@asyncIterator",o="@@iterator"}throw TypeError("Object is not async iterable")}function w(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return(w=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var a=this.s.return;return void 0===a?Promise.resolve({value:e,done:!0}):t(a.apply(this.s,arguments))},throw:function(e){var a=this.s.return;return void 0===a?Promise.reject(e):t(a.apply(this.s,arguments))}},new w(e)}var b=(o=u(function*(){return(yield Promise.resolve().then(a.bind(a,14636))).default}),function(){return o.apply(this,arguments)}),_=(r=u(function*(){return a.e(6954).then(a.bind(a,88161))}),function(){return r.apply(this,arguments)}),k=(i=u(function*(e){return(yield b())(e).start()}),function(e){return i.apply(this,arguments)}),S=(n=u(function*(){var e=(0,f.getCurrentProfile)(),t=(0,h.getConnectionContext)(e),a=t.auth;return a||(console.error(m.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),{client:(0,(yield _()).createActivityLogClient)(t.activityLogBaseUrl,a),workspaceId:t.tokenInfo?.workspaceId}}),function(){return n.apply(this,arguments)}),$=e=>new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z"),C=(e,t)=>{if(!e)return"";var a="string"==typeof e?e:JSON.stringify(e);return a.length>t?a.slice(0,t-1)+"…":a},E=(p=u(function*(e,t,a){var o=new Date((0,v.p)(a.from)).getTime(),r=a.to?new Date((0,v.p)(a.to)).getTime():Date.now();r>o||(console.error(m.default.red("--to must be after --from")),process.exit(1)),r-o>2592e6&&(console.error(m.default.red("Time range must be 30 days or less")),process.exit(1));var i=a.output||"screenshots";y.mkdirSync(i,{recursive:!0});var n=a.json?null:yield k("Streaming screenshots..."),p=[],d=0;try{var s=!1,l=!1;try{for(var u,c,f=D(e.streamScreenshots(t,a.device,o,r));s=!(c=yield f.next()).done;s=!1){var h=c.value,w=h.timestamp??o+p.length,b=g.resolve(i,`screenshot-${a.device}-${w}.jpg`);if(y.writeFileSync(b,h.body),p.push({timestamp:w,time:new Date(w).toISOString(),path:b}),d+=h.body.length,n&&(n.text=`Streaming screenshots... ${p.length} frames`),a.maxFrames&&p.length>=a.maxFrames)break}}catch(e){l=!0,u=e}finally{try{s&&null!=f.return&&(yield f.return())}finally{if(l)throw u}}}catch(e){n?n.fail(`Failed to stream screenshots: ${e.message}`):console.error(m.default.red(`Failed to stream screenshots: ${e.message}`)),process.exit(1)}if(n&&n.stop(),a.json)return void console.log(JSON.stringify({device:a.device,from:o,to:r,count:p.length,bytes:d,frames:p},null,2));if(0===p.length){console.log(m.default.yellow("No screenshots found in range")),console.log(m.default.gray("Screenshot capture is off by default per device — enable it in the BRICKS Controller\n(device > Activity Log > screenshot capture), or the window predates the plan's retention."));return}var _=p[0],S=p[p.length-1];console.log(m.default.green(`✓ ${p.length} frames saved to ${g.resolve(i)} (${(d/1024).toFixed(1)} KB)`)),console.log(m.default.gray(` ${$(_.time)} → ${$(S.time)}`))}),function(e,t,a){return p.apply(this,arguments)}),F=new c.uB("activity-log").alias("al").description("Activity log queries (read-only)");F.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 return (applied server-side)",parseInt).option("--offset <n>","Skip the first n events (server-side; requires --limit)",parseInt).option("-j, --json","Output as JSON array").option("--jsonl","Output as JSONL (one JSON per line)").action((d=u(function*(e){var t=(yield S()).client,a=(n=(0,v.p)(e.startTime),new Date(p=e.endTime?(0,v.p)(e.endTime):new Date().toISOString())-new Date(n)>2592e6&&(console.error(m.default.red("Time range must be 30 days or less")),process.exit(1)),d={start_time:n,end_time:p},e.device&&(d.device_id=e.device),e.type&&(d.event_type=e.type),e.eventName&&(d.event_name=e.eventName),e.subspace&&(d.subspace_id=e.subspace),e.sender&&(d.sender=e.sender),Number.isInteger(e.limit)&&e.limit>0&&(d.limit=e.limit),Number.isInteger(e.offset)&&e.offset>0&&(null==d.limit&&(console.error(m.default.red("--offset requires --limit")),process.exit(1)),d.offset=e.offset),d);if(e.jsonl){var o=0;try{var r=!1,i=!1;try{for(var n,p,d,s,l,u=D(t.events(a));r=!(l=yield u.next()).done;r=!1){var c=l.value;if(console.log(JSON.stringify(c)),o++,e.limit&&o>=e.limit)break}}catch(e){i=!0,s=e}finally{try{r&&null!=u.return&&(yield u.return())}finally{if(i)throw s}}}catch(e){console.error(m.default.red(`Failed to query events: ${e.message}`)),process.exit(1)}return}var f=yield k("Querying events...");try{var h=yield t.collectEvents(a,{limit:e.limit});if(f.stop(),e.json)return void console.log(JSON.stringify(h,null,2));if(0===h.length)return void console.log(m.default.yellow("No events found"));for(var g of(console.log(m.default.bold(`
18
+ (Did you mean ${o[0]}?)`:""}},43424(e,t,a){let o=a(3326),r=a(26687);t.normalizeAngle=e=>(e%360+360)%360;let i=(e,t,a,o)=>{let r=e*Math.cos(a)+t*Math.sin(a),i=e*Math.sin(a)+t*Math.cos(a);return o?t/i:e/r},n=(e,t,a,o)=>{let r=t*Math.cos(a)+e*Math.sin(a),i=t*Math.sin(a)+e*Math.cos(a);return o?t/i:e/r};t.getRotateFitScale=(e,a,o=0,r)=>{let p=t.normalizeAngle(o);return p<=90?i(e,a,Math.PI/180*p,r):p>90&&p<=180?n(e,a,Math.PI/180*(p-90),r):p>180&&p<=270?i(e,a,Math.PI/180*(p-180),r):n(e,a,Math.PI/180*(p-270),r)},t.getRotateCropScale=(e,a,o,r)=>1/t.getRotateFitScale(e,a,o,r),t.transformPhysicalRotateViewport=e=>{if(!e)return e;let{x:a,y:o,width:r,height:i,rotate:n,rotateType:p}=e;if("physical-rotate"!==p)return e;let d=t.getRotateCropScale(r,i,n,r>i),s=r*d,l=i*d;return{...e,x:a-(s-r)/2,y:o-(l-i)/2,width:s,height:l}},t.createViewport=(e,t={width:96,height:54},a={})=>{let{color:o}=r(e);return{viewport:!0,x:a.x||0,y:a.y||0,width:a.width||t.width,height:a.height||t.height,type:a.type||"rotate",rotate:a.rotate||0,rotateType:a.rotateType||"fit",scrollType:a.scrollType||"fit",maintainAspectRatio:a.maintainAspectRatio||!1,forceDeviceRatio:a.forceDeviceRatio||!1,...a.bindPresetId?{bindPresetId:a.bindPresetId}:{},content:a.content||`Viewport ${e}`,color:`${o}22`,selectedColor:`${o}66`,textColor:"#ccc",strokeColor:o}},t.getViewportsFromApplication=(e,a,o)=>{if(!e||!e.devices||!a||!a.subspace_map)return{};let r=a.subspace_map[a.root_subspace_id];if(!r||!r.layout)return{};if(o){let a=e.viewport_presets.find(e=>e._id===o);if(a?.viewports)return a.viewports.reduce((e,a)=>(e[a.device_target_name]=t.createViewport(a.device_target_name,r.layout,a.detail),e),{})}return e.devices.reduce((e,a)=>(e[a.device_id]=t.createViewport(a.device_id,r.layout,a.frame),e),{})},t.getDeviceSettingFromApplication=(e,t)=>{if(e&&e.devices)return e.devices.reduce((e,a)=>(e[a.device_id]=a[t],e),{})},t.intersectFrame=(e,t)=>{let a=Math.max(e.x,t.x);if(Math.min(e.x+e.width,t.x+t.width)<=a)return!1;let o=Math.max(e.y,t.y);return!(Math.min(e.y+e.height,t.y+t.height)<=o)},t.transformLayoutByViewport=(e,t)=>{if(!t)return e;let a=((e,t)=>{if("scroll"!==t.type)return null;let{scrollType:a="fit"}=t;return"fit"===a?{type:t.type,scrollType:a,width:Number(e.width),height:Number(e.height),scrollViewport:{width:Number(t.width),height:Number(t.height),x:Number(t.x),y:Number(t.y)}}:"crop"===a?{type:t.type,scrollType:a,width:Number(t.width),height:Number(t.height),originViewport:o(e,["originViewport"])}:null})(e,t);return a||{width:Number(t.width),height:Number(t.height),originViewport:o(e,["originViewport"])}},t.convertFrameByViewport=(e,t)=>{if(!t||"scroll"===t.type&&"fit"===t.scrollType)return e;e.originViewport&&(e.x=e.originViewport.x,e.y=e.originViewport.y,delete e.originViewport),e.originViewport={x:e.x,y:e.y},e.x-=Number(t.x),e.y-=Number(t.y)},t.transformRootSubspaceByViewport=(e,a)=>{if(!a)return e;let o=e.canvasMap?"canvasMap":"canvas_map",r=e[o],i={};for(let e of Object.keys(r)){let o=r[e],n=o.itemList?"itemList":"item_list";i[e]={...o,[n]:o[n].map(e=>{if(!e.frame)return e;let o={...e,frame:{...e.frame}};return t.convertFrameByViewport(o.frame,a),o})}}return{...e,[o]:i}},t.transformListByViewport=(e,a)=>a&&e&&0!==e.length?e.map(e=>{if(!e.frame)return e;let o={...e,frame:{...e.frame}};return t.convertFrameByViewport(o.frame,a),o}):e,t.transformFramesByViewport=(e,a)=>{if(!a||!e||0===Object.keys(e).length)return e;let o={};for(let[r,i]of Object.entries(e)){if(!i.frame){o[r]=i;continue}let e={...i,frame:{...i.frame}};t.convertFrameByViewport(e.frame,a),o[r]=e}return o}},98247(e,t,a){a.d(t,{v:()=>F});var o,r,i,n,p,d,s,l,u=a(99436),c=a(35679),m=a(73284),f=a(47988),h=a(31802),v=a(94979),g=a(16928),y=a(79896);function D(e){var t,a,o,r=2;for("u">typeof Symbol&&(a=Symbol.asyncIterator,o=Symbol.iterator);r--;){if(a&&null!=(t=e[a]))return t.call(e);if(o&&null!=(t=e[o]))return new w(t.call(e));a="@@asyncIterator",o="@@iterator"}throw TypeError("Object is not async iterable")}function w(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return(w=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var a=this.s.return;return void 0===a?Promise.resolve({value:e,done:!0}):t(a.apply(this.s,arguments))},throw:function(e){var a=this.s.return;return void 0===a?Promise.reject(e):t(a.apply(this.s,arguments))}},new w(e)}var b=(o=u(function*(){return(yield Promise.resolve().then(a.bind(a,14636))).default}),function(){return o.apply(this,arguments)}),_=(r=u(function*(){return a.e(6954).then(a.bind(a,88161))}),function(){return r.apply(this,arguments)}),k=(i=u(function*(e){return(yield b())(e).start()}),function(e){return i.apply(this,arguments)}),S=(n=u(function*(){var e=(0,f.getCurrentProfile)(),t=(0,h.getConnectionContext)(e),a=t.auth;return a||(console.error(m.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),{client:(0,(yield _()).createActivityLogClient)(t.activityLogBaseUrl,a),workspaceId:t.tokenInfo?.workspaceId}}),function(){return n.apply(this,arguments)}),$=e=>new Date(e).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z"),C=(e,t)=>{if(!e)return"";var a="string"==typeof e?e:JSON.stringify(e);return a.length>t?a.slice(0,t-1)+"…":a},E=(p=u(function*(e,t,a){var o=new Date((0,v.p)(a.from)).getTime(),r=a.to?new Date((0,v.p)(a.to)).getTime():Date.now();r>o||(console.error(m.default.red("--to must be after --from")),process.exit(1)),r-o>2592e6&&(console.error(m.default.red("Time range must be 30 days or less")),process.exit(1));var i=a.output||"screenshots";y.mkdirSync(i,{recursive:!0});var n=a.json?null:yield k("Streaming screenshots..."),p=[],d=0;try{var s=!1,l=!1;try{for(var u,c,f=D(e.streamScreenshots(t,a.device,o,r));s=!(c=yield f.next()).done;s=!1){var h=c.value,w=h.timestamp??o+p.length,b=g.resolve(i,`screenshot-${a.device}-${w}.jpg`);if(y.writeFileSync(b,h.body),p.push({timestamp:w,time:new Date(w).toISOString(),path:b}),d+=h.body.length,n&&(n.text=`Streaming screenshots... ${p.length} frames`),a.maxFrames&&p.length>=a.maxFrames)break}}catch(e){l=!0,u=e}finally{try{s&&null!=f.return&&(yield f.return())}finally{if(l)throw u}}}catch(e){n?n.fail(`Failed to stream screenshots: ${e.message}`):console.error(m.default.red(`Failed to stream screenshots: ${e.message}`)),process.exit(1)}if(n&&n.stop(),a.json)return void console.log(JSON.stringify({device:a.device,from:o,to:r,count:p.length,bytes:d,frames:p},null,2));if(0===p.length){console.log(m.default.yellow("No screenshots found in range")),console.log(m.default.gray("Screenshot capture is off by default per device — enable it in the BRICKS Controller\n(device > Activity Log > screenshot capture), or the window predates the plan's retention."));return}var _=p[0],S=p[p.length-1];console.log(m.default.green(`✓ ${p.length} frames saved to ${g.resolve(i)} (${(d/1024).toFixed(1)} KB)`)),console.log(m.default.gray(` ${$(_.time)} → ${$(S.time)}`))}),function(e,t,a){return p.apply(this,arguments)}),F=new c.uB("activity-log").alias("al").description("Activity log queries (read-only)");F.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 return (applied server-side)",parseInt).option("--offset <n>","Skip the first n events (server-side; requires --limit)",parseInt).option("-j, --json","Output as JSON array").option("--jsonl","Output as JSONL (one JSON per line)").action((d=u(function*(e){var t=(yield S()).client,a=(n=(0,v.p)(e.startTime),new Date(p=e.endTime?(0,v.p)(e.endTime):new Date().toISOString())-new Date(n)>2592e6&&(console.error(m.default.red("Time range must be 30 days or less")),process.exit(1)),d={start_time:n,end_time:p},e.device&&(d.device_id=e.device),e.type&&(d.event_type=e.type),e.eventName&&(d.event_name=e.eventName),e.subspace&&(d.subspace_id=e.subspace),e.sender&&(d.sender=e.sender),Number.isInteger(e.limit)&&e.limit>0&&(d.limit=e.limit),Number.isInteger(e.offset)&&e.offset>0&&(null==d.limit&&(console.error(m.default.red("--offset requires --limit")),process.exit(1)),d.offset=e.offset),d);if(e.jsonl){var o=0;try{var r=!1,i=!1;try{for(var n,p,d,s,l,u=D(t.events(a));r=!(l=yield u.next()).done;r=!1){var c=l.value;if(console.log(JSON.stringify(c)),o++,e.limit&&o>=e.limit)break}}catch(e){i=!0,s=e}finally{try{r&&null!=u.return&&(yield u.return())}finally{if(i)throw s}}}catch(e){console.error(m.default.red(`Failed to query events: ${e.message}`)),process.exit(1)}return}var f=yield k("Querying events...");try{var h=yield t.collectEvents(a,{limit:e.limit});if(f.stop(),e.json)return void console.log(JSON.stringify(h,null,2));if(0===h.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 (${h.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)),h)){var y=$(g.timestamp),w=(g.event_type||"").padEnd(12),b=C(g.device_id,14).padEnd(14),_=C(g.event_name,28).padEnd(28),E=C(g.sender,16).padEnd(16),F=C(g.payload,40);console.log(`${y} ${w} ${b} ${_} ${E} ${m.default.gray(F)}`)}console.log("─".repeat(100))}catch(e){f.fail(`Failed to query events: ${e.message}`),process.exit(1)}}),function(e){return d.apply(this,arguments)})),F.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((s=u(function*(e){var t=(yield S()).client,a=(0,v.p)(e.startTime),o=e.endTime?(0,v.p)(e.endTime):new Date().toISOString();new Date(o)-new Date(a)>2592e6&&(console.error(m.default.red("Time range must be 30 days or less")),process.exit(1));var r={device_id:e.device,start_time:a,end_time:o},i=yield k("Querying screenshots...");try{var n=yield t.collectScreenshots(r);if(i.stop(),e.json)return void console.log(JSON.stringify(n,null,2));if(0===n.length)return void console.log(m.default.yellow("No screenshots found"));console.log(m.default.bold(`
20
20
  Screenshots (${n.length})`)),console.log("─".repeat(56)),console.log(m.default.gray(`${"#".padStart(4)} ${"Timestamp".padEnd(24)} --ts value`)),console.log("─".repeat(56)),n.forEach((e,t)=>{var a=new Date(e.timestamp).getTime();console.log(`${String(t+1).padStart(4)} ${$(e.timestamp).padEnd(24)} ${a}`)}),console.log("─".repeat(56))}catch(e){i.fail(`Failed to query screenshots: ${e.message}`),process.exit(1)}}),function(e){return s.apply(this,arguments)})),F.command("screenshot").description("Download a screenshot image, or a whole window of them with --stream").requiredOption("--device <id>","Device ID").option("--ts <timestamp>","Screenshot timestamp (ISO 8601 or epoch ms) — single frame").option("--stream","Download every frame in a window over one MJPEG request").option("--from <datetime>","Stream start (ISO 8601 or relative: 1h, 30m, 2d)").option("--to <datetime>","Stream end (default: now)").option("--max-frames <n>","Stop the stream after n frames",parseInt).option("--space <id>","Workspace/space ID (auto-detected from profile)").option("-o, --output <path>","Output file path (output directory with --stream)").option("--open","Open with OS default viewer after download").option("-j, --json","Output as JSON (with --stream: a manifest of saved frames)").action((l=u(function*(e){e.stream?(e.ts&&(console.error(m.default.red("--ts cannot be combined with --stream. Use --from/--to.")),process.exit(1)),e.from||(console.error(m.default.red("--stream requires --from <datetime> (--to defaults to now).")),process.exit(1))):e.from||e.to||null!=e.maxFrames?(console.error(m.default.red("--from/--to/--max-frames require --stream.")),process.exit(1)):e.ts||(console.error(m.default.red("Missing --ts <timestamp>. Use --stream --from <datetime> for a window.")),process.exit(1));var t=yield S(),o=t.client,r=t.workspaceId,i=e.space||r;if(i||(console.error(m.default.red("Could not determine workspace ID. Use --space <id> or log in first.")),process.exit(1)),e.stream)return void(yield E(o,i,e));var n=/^\d+$/.test(e.ts)?e.ts:new Date(e.ts).getTime(),p=yield k("Downloading screenshot...");try{var d=yield o.downloadScreenshot(i,e.device,n);p.stop();var s=e.output||`screenshot-${e.device}-${n}.jpg`,l=g.resolve(s);if(y.writeFileSync(l,d),e.json)return void console.log(JSON.stringify({device:e.device,timestamp:Number(n),path:l,bytes:d.length},null,2));var u=(d.length/1024).toFixed(1);if(console.log(m.default.green(`✓ Screenshot saved: ${l} (${u} KB)`)),e.open){var c=(yield Promise.resolve().then(a.t.bind(a,35317,19))).exec,f="darwin"===process.platform?"open":"win32"===process.platform?"start":"xdg-open";c(`${f} "${l}"`)}}catch(e){p.fail(`Failed to download screenshot: ${e.message}`),process.exit(1)}}),function(e){return l.apply(this,arguments)}))},72381(e,t,a){a.d(t,{B:()=>K});var o,r,i,n,p,d,s,l,u,c,m,f,h,v,g,y,D,w,b=a(68832),_=a(99436),k=a(35679),S=a(73284),$=a(14636),C=a(79896),E=a(7586),F=a(56493),x=a(58021),A=a(67996),N=a(43424),O=["color","selectedColor","textColor","strokeColor"],T={x:"number",y:"number",width:"number",height:"number",rotate:"number",type:["rotate","scroll"],rotateType:["crop","fit","physical-rotate"],scrollType:["crop","fit"],maintainAspectRatio:"boolean",forceDeviceRatio:"boolean",mirrorHozizontal:"boolean",mirrorVertical:"boolean",content:"string"},j={mirrorHorizontal:"mirrorHozizontal"},I=Object.keys(T).map(e=>"mirrorHozizontal"===e?"mirrorHorizontal":e),B=e=>`viewport of device ${e}`,P=e=>({testId:e.test_id,cron:e.cron,...e.date_range?{dateRange:{start:e.date_range.start,end:e.date_range.end}}:{},..."boolean"==typeof e.update_screenshot?{updateScreenshot:e.update_screenshot}:{},...e.bind_id?{bindId:e.bind_id}:{}}),V=a(54782),R={"short-edit":{title:"Runtime Editor",file:"shortEditor.html",tokenTypes:["info","query_application","short_edit_application","canvas_control_application","query_media_flow"]},"canvas-control":{title:"Canvas Control",file:"canvasControl.html",tokenTypes:["info","query_application","canvas_control_application"]},"device-control":{title:"Device Control",file:"deviceControl.html",tokenTypes:["info","query_application","query_device","bind_application","control_application_device","create_device","update_device"]},"device-control-create-only":{title:"Device Control (Create Only)",file:"deviceControl.html",tokenTypes:["info","query_application","create_device"]}},M=a(29988),U=a(74049),L=a(10536),q=a(98593),J=a(90003),G=a(70681),H=a(76250),W=(e,t)=>(0,q.H_)(e,t,{currentVersion:e?.current_version||null,unreleasedChanges:!!e?.has_unreleased_changes}),K=new k.uB("app").description("Application management");K.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((o=_(function*(e){var t=(0,F.requireAuth)(),o=e.json?null:(0,$.default)("Creating application...").start();try{var r={name:e.name};e.description&&(r.description=e.description),e.layoutWidth&&(r.layoutWidth=e.layoutWidth),e.layoutHeight&&(r.layoutHeight=e.layoutHeight);var i=yield t.createApplication(r);if(e.json&&!e.init?console.log(JSON.stringify(i,null,2)):!e.json&&(o.succeed(`Application created: ${S.default.green(i.name)}`),console.log(` ID: ${S.default.gray(i._id)}`),i.description&&console.log(` ${S.default.gray(i.description)}`)),e.init){o&&o.stop();var n=(yield Promise.all([a.e(5658),a.e(4456)]).then(a.bind(a,58891))).initProject;yield n("application",i._id,{output:e.output,yes:e.yes,json:e.json})}}catch(t){e.json?console.error(JSON.stringify({error:t.message})):o.fail(`Failed to create application: ${t.message}`),process.exit(1)}}),function(e){return o.apply(this,arguments)})),K.command("share-info <applicationId>").description("Show public share info (releases available for share-new) for an application").option("-j, --json","Output as JSON").action((r=_(function*(e,t){var a=(0,F.requireAuth)(),o=t.json?null:(0,$.default)("Fetching share info...").start();try{var r=yield a.publicApplicationShareInfo({id:e});if(o&&o.stop(),!r)return void(t.json?console.log(JSON.stringify(null)):console.log(S.default.yellow("No share info found for this application")));if(t.json)return void console.log(JSON.stringify(r,null,2));var i=[...r.share?.selected_releases||[]].sort((e,t)=>new Date(t.date||0)-new Date(e.date||0));console.log(S.default.bold(`
21
21
  Share Info: ${r.name||"Unnamed"}`)),console.log("─".repeat(60)),console.log(`App ID: ${S.default.gray(r._id)}`),r.description&&console.log(`Description: ${r.description}`),r.owner?.id_from_user&&console.log(`Owner: ${S.default.gray(r.owner.id_from_user)}`),r.share?.tags?.length&&console.log(`Tags: ${r.share.tags.join(", ")}`),r.share?.type&&console.log(`Type: ${r.share.type}`),console.log(`
@@ -47,7 +47,7 @@ Blueprint Graph: ${e.name}`)),console.log(p.default.gray(`${e._id} \xb7 revision
47
47
  Blueprint Members: ${e.name}`)),console.log("─".repeat(80));var o=Object.entries(a).filter(([,e])=>e.length>0);0===o.length&&console.log(p.default.yellow("No nodes")),o.forEach(([e,t])=>{console.log(`${p.default.bold(m[e])} (${t.length})`),t.forEach(e=>{var t=e.ref?p.default.gray(` (${e.ref})`):"";console.log(` - ${e.name}${t}${v(e)}`)}),console.log()})})),b.command("projection <id>").description("Print the projection text that the blueprint Orchestrator gets as its context").action((r=i(function*(e){var t=(0,l.requireAuth)(),a=(0,d.default)("Fetching blueprint projection...").start();try{var o=yield t.blueprintProjection({id:e});a.stop(),console.log(o)}catch(e){a.fail(`Failed to get blueprint projection: ${e.message}`),process.exit(1)}}),function(e){return r.apply(this,arguments)})),(0,u.H)(b,{resource:"blueprint",fetchById:(e,t)=>e.blueprint({id:t}),search:(e,t,a)=>e.blueprints({keyword:t,paginate:{limit:a}})})},59845(e,t,a){a.d(t,{Q:()=>K});var o,r,i,n,p,d,s,l,u,c,m,f,h,v,g,y,D=a(67996),w=a(99436),b=a(35679),_=a(73284),k=a(76760),S=a(77598),$=a(48161),C=a(51455),E=a(27549),F=a(19557),x=8089,A=(o=w(function*(e,t,a=3e3){return(0,F.uE)(`http://${e}:${t}/buttress/info`,a)}),function(e,t){return o.apply(this,arguments)}),N=["privateKeyPkcs8"],O=["spacekey"],T=["token"],j=k.join($.homedir(),".bricks-cli","buttress"),I=e=>k.join(e||j,"state.json"),B="buttress-functions",P=(r=w(function*(e,t,a){var o,r,i,n=null,p=!0;try{n=JSON.parse((yield C.readFile(e,"utf8"))),p=!1}catch(t){if(t instanceof SyntaxError)throw Error(`${e} is not valid JSON; refusing to overwrite it.`);if("ENOENT"!==t.code)throw t}var d=(i=(r=(o=n)&&"object"==typeof o&&!Array.isArray(o)?o:{}).mcpServers&&"object"==typeof r.mcpServers&&!Array.isArray(r.mcpServers)?r.mcpServers:{},{...r,mcpServers:{...i,[t]:a}});return yield C.writeFile(e,`${JSON.stringify(d,null,2)}
48
48
  `,p?{mode:384}:{}),{file:e,created:p}}),function(e,t,a){return r.apply(this,arguments)}),V=(e,t,a)=>{if(e?.workspace?.serverId!==t)return!1;var o=e.workspace.id;if(!o||!a||String(o)!==String(a))throw Error(`Local Buttress state belongs to workspace ${o||"unknown"}, but the current profile targets ${a||"unknown"}. Switch profiles first.`);return!0},R=()=>{try{return`buttress-${E.machineIdSync()}`}catch{return null}},M=(i=w(function*({client:e,workspaceId:t,serverId:a,name:o}){if(!t)throw Error("A workspace-authenticated client is required to bind Buttress.");var r,i,n,p,d,s,l=yield e.issueDevtoolsAccessToken({});if("string"!=typeof l?.token||!l.token||String(l.workspaceId)!==String(t)||!(Date.parse(l.expiresAt)>Date.now()))throw Error("DevTools token response is incomplete, expired, or belongs to another workspace.");var u=(i=(r=S.generateKeyPairSync("ed25519")).publicKey,n=r.privateKey,p=i.export({type:"spki",format:"der"}),d=n.export({type:"pkcs8",format:"der"}),s=S.createHash("sha256").update(p).digest("hex").slice(0,16),{publicKeySpki:p.toString("base64"),privateKeyPkcs8:d.toString("base64"),kid:s}),c=yield e.bindButtressServer({serverId:a,name:o,serverPublicKey:{spkiBase64:u.publicKeySpki,kid:u.kid}});if(String(c.workspaceId)!==String(t))throw Error("Buttress binding response belongs to another workspace.");return{workspace:{id:c.workspaceId,name:c.workspaceName,serverId:c.serverId,issuerPublicKey:c.issuerPublicKey.pem,kid:c.issuerPublicKey.kid,boundAt:new Date().toISOString()},serverKeyPair:u,devtools:{token:l.token,workspaceId:l.workspaceId,expiresAt:l.expiresAt,...l.jti?{jti:l.jti}:{}}}}),function(e){return i.apply(this,arguments)}),U=(n=w(function*(e){var t=I(e);try{var a=yield C.readFile(t,"utf8");return JSON.parse(a)}catch(e){if(e instanceof SyntaxError)throw Error("Buttress state.json contains invalid JSON.");if("ENOENT"===e.code)return null;throw e}}),function(e){return n.apply(this,arguments)}),L=(p=w(function*(e,t){var a=t||j,o=I(t);yield C.mkdir(a,{recursive:!0,mode:448}),yield C.chmod(a,448);var r=`${o}.tmp-${process.pid}-${S.randomUUID()}`;try{yield C.writeFile(r,JSON.stringify(e,null,2),{encoding:"utf8",mode:384}),yield C.chmod(r,384),yield C.rename(r,o),yield C.chmod(o,384)}catch(e){throw yield C.unlink(r).catch(()=>{}),e}return o}),function(e,t){return p.apply(this,arguments)}),q=(d=w(function*(e){var t=I(e);try{return yield C.unlink(t),!0}catch(e){if("ENOENT"===e.code)return!1;throw e}}),function(e){return d.apply(this,arguments)}),J=(s=w(function*({client:e,serverId:t,workspaceId:a,stateDir:o,keepLocal:r=!1}){var i=r?null:yield U(o),n=!r&&V(i,t,a);return{removed:yield e.unbindButtressServer({serverId:t}),localRemoved:!!n&&(yield q(o))}}),function(e){return s.apply(this,arguments)}),G=(l=w(function*({timeout:e=3e3,verify:t=!0,port:a=x,onStatus:o}={}){o?.(`Scanning UDP ${a} for ${e}ms...`);var r,i=yield(({timeout:e=3e3,idleTimeout:t=0,port:a=x}={})=>(0,F.YH)({port:a,timeout:e,idleTimeout:t,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"2.0",d:{id:`cli-${(0,F.BW)()}`}})),parseMessage:(e,t)=>{var a=(0,F.nl)(e,e=>e?.v==="2.0");if(!a)return null;var o={...a,address:t.address};return{key:o.id||`${t.address}:${o.port}`,value:o}}}))({timeout:e,port:a});return 0===i.length?[]:t?(o?.(`Verifying ${i.length} server(s)...`),yield Promise.all(i.map((r=w(function*(e){var t=yield A(e.address,e.port,2e3);return t?{...e,...t,address:e.address,verified:!0}:{...e,verified:!1}}),function(e){return r.apply(this,arguments)})))):i}),function(){return l.apply(this,arguments)}),H=["bank"],W=(u=w(function*(){var e=(yield Promise.resolve().then(a.bind(a,47988))).getCurrentProfile,t=(0,(yield Promise.resolve().then(a.bind(a,31802))).getConnectionContext)(e()),o=t.auth,r=t.baseUrl;return o||(console.error(_.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),{client:(0,(yield Promise.all([a.e(3332),a.e(8295),a.e(907)]).then(a.bind(a,85382))).createClient)(r,o),workspaceId:o.workspaceId,baseUrl:r}}),function(){return u.apply(this,arguments)}),K=new b.uB("buttress").description("Pair and inspect buttress-server bindings for the current workspace").alias("butr");K.command("bind").description("Pair a local buttress-server and provision workspace DevTools access").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((c=w(function*(e){var t=(yield Promise.resolve().then(a.bind(a,14636))).default,o=e.serverId||R();o||(console.error(_.default.red("Could not detect a local server id. Pass --server-id <id> explicitly.")),process.exit(1));var r=yield W(),i=r.client,n=r.workspaceId,p=t(`Binding buttress server ${_.default.cyan(o)}...`).start();try{var d=e.print?null:yield U(e.stateDir),s=yield M({client:i,workspaceId:n,serverId:o,name:e.name});if(p.stop(),e.print){console.warn(_.default.yellow("⚠ Output contains the announce private key and DevTools token. Treat as a secret.")),process.stdout.write(`${JSON.stringify(s,null,2)}
49
49
  `);return}d?.bank&&d?.workspace?.id===s.workspace.id&&(s.bank=d.bank);var l=yield L(s,e.stateDir);console.log(_.default.green("✓"),"Buttress server bound to workspace."),console.log(` Workspace: ${_.default.bold(s.workspace.name)} (${s.workspace.id})`),console.log(` Server id: ${_.default.cyan(s.workspace.serverId)}`),console.log(` Issuer kid: ${_.default.gray(s.workspace.kid)}`),console.log(` Announce kid: ${_.default.gray(s.serverKeyPair.kid)}`),console.log(` DevTools token expires: ${s.devtools.expiresAt}`),console.log(` State file: ${_.default.gray(l)}`),console.log(),console.log(_.default.yellow("Restart buttress-server for the binding to take effect."))}catch(e){p.fail(`Bind failed: ${e.message}`),process.exit(1)}}),function(e){return c.apply(this,arguments)})),K.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((m=w(function*(e){var t=e.serverId||R();t||(console.error(_.default.red("Could not detect a local server id. Pass --server-id explicitly.")),process.exit(1));var a=yield W(),o=a.client,r=a.workspaceId;try{var i=yield J({client:o,serverId:t,workspaceId:r,stateDir:e.stateDir,keepLocal:e.keepLocal}),n=i.removed,p=i.localRemoved;if(n?console.log(_.default.green("✓"),`Unbound ${_.default.cyan(t)} from workspace.`):console.log(_.default.yellow("!"),`${_.default.cyan(t)} was not bound to this workspace.`),p){var d=I(e.stateDir);console.log(_.default.gray(`Removed local state file: ${d}`))}}catch(e){console.error(_.default.red(`Unbind failed: ${e.message}`)),process.exit(1)}}),function(e){return m.apply(this,arguments)})),K.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((f=w(function*(e){var t=yield U(e.stateDir),a=null;try{var o=(yield W()).client;a=yield o.buttressServers()}catch(e){a={error:e.message}}e.json?console.log(JSON.stringify(((e,t)=>{var a=e;if(e?.serverKeyPair&&"object"==typeof e.serverKeyPair){var o=e.serverKeyPair,r=(o.privateKeyPkcs8,D(o,N));a={...a,serverKeyPair:r}}if(e?.bank&&"object"==typeof e.bank){var i=e.bank,n=(i.spacekey,D(i,O));a={...a,bank:n}}if(e?.devtools&&"object"==typeof e.devtools){var p=e.devtools,d=(p.token,D(p,T));a={...a,devtools:d}}return{local:a,remote:t}})(t,a),null,2)):(console.log(_.default.bold("\nLocal buttress state")),console.log("─".repeat(60)),t?.workspace?(console.log(` Workspace: ${_.default.bold(t.workspace.name)} (${t.workspace.id})`),console.log(` Server id: ${_.default.cyan(t.workspace.serverId)}`),console.log(` Issuer kid: ${_.default.gray(t.workspace.kid)}`),console.log(` Bound at: ${_.default.gray(t.workspace.boundAt)}`),console.log(` File: ${_.default.gray(I(e.stateDir))}`),t.devtools&&console.log(` DevTools token expires: ${t.devtools.expiresAt}`),t.bank&&console.log(` Data Bank: ${_.default.bold(t.bank.spacename)} ${_.default.gray(`(${t.bank.keyName||"key stored"}) @ ${t.bank.endpoint}`)}`)):console.log(_.default.gray(" not bound (no state.json found)")),console.log(_.default.bold("\nWorkspace-side bound servers")),console.log("─".repeat(60)),Array.isArray(a)?0===a.length?console.log(_.default.gray(" none")):a.forEach(e=>{console.log(` ${_.default.cyan(e.serverId)} ${_.default.gray(e.name||"")} ${_.default.gray(e.boundAt||"")}`)}):a?.error&&console.log(_.default.red(` failed to fetch: ${a.error}`)))}),function(e){return f.apply(this,arguments)})),K.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((h=w(function*(e){var t=(yield W()).client;try{var a=yield t.issueButtressAccessToken({ttlSeconds:e.ttl});if(e.json)return void console.log(JSON.stringify(a,null,2));console.log(_.default.green("✓"),"Buttress access token issued."),console.log(` Workspace: ${a.workspaceId}`),console.log(` Expires: ${a.expiresAt}`),console.log(` jti: ${_.default.gray(a.jti)}`),console.log(),console.log(_.default.cyan(a.token))}catch(e){console.error(_.default.red(`Issue token failed: ${e.message}`)),process.exit(1)}}),function(e){return h.apply(this,arguments)})),K.command("bank-key").description("Issue a Data Bank space key for this buttress server's local functions (stored in state.json)").option("--state-dir <dir>","Override the buttress state directory").option("--key-name <name>","Key name prefix registered on the workspace","buttress-server").option("--revoke","Revoke the stored key and remove it from state.json").option("-j, --json","Output as JSON").action((v=w(function*(e){var t,o,r=yield U(e.stateDir);r?.workspace||(console.error(_.default.red("This host is not bound to a workspace. Run `bricks buttress bind` first.")),process.exit(1));var i=yield W(),n=i.client,p=i.workspaceId,d=i.baseUrl;try{V(r,r.workspace.serverId,p)}catch(e){console.error(_.default.red(e.message)),process.exit(1)}if(e.revoke){if(!r.bank?.spacekey)return void console.log(_.default.yellow("!"),"No Data Bank key is stored for this server.");try{yield n.updateWorkspace({revokeBankKey:r.bank.spacekey})}catch(e){console.error(_.default.red(`Revoke failed: ${e.message}`)),process.exit(1)}r.bank;var s=D(r,H);return(yield L(s,e.stateDir),e.json)?void console.log(JSON.stringify({revoked:!0},null,2)):(console.log(_.default.green("✓"),"Data Bank key revoked and removed from state.json."),void console.log(_.default.yellow("Restart buttress-server for the change to take effect.")))}var l=(yield Promise.resolve().then(a.bind(a,14636))).default,u=yield a.e(1936).then(a.bind(a,76627)),c=u.issueWorkspaceBankKey,m=u.BANK_DISABLED_MESSAGE,f=(yield a.e(9387).then(a.bind(a,30182))).resolveBankEndpoint;try{t=f(d)}catch(e){console.error(_.default.red(e.message)),process.exit(1)}var h=l("Issuing Data Bank space key...").start();try{o=yield c(n,{keyName:e.keyName,assertWorkspace:e=>{if(!e?._id||String(e._id)!==String(p))throw Error("The client targets another workspace. Switch profiles and retry.")}}),h.stop()}catch(e){h.fail(`Issue failed: ${e.message}`),e.message===m&&console.error(_.default.gray("Enable it first with `bricks data enable`.")),process.exit(1)}var v=r.bank,g={endpoint:t,...o},y=yield L({...r,bank:g},e.stateDir);(v?.spacekey&&v.spacekey!==g.spacekey&&(yield n.updateWorkspace({revokeBankKey:v.spacekey}).catch(()=>{})),e.json)?console.log(JSON.stringify({endpoint:t,spacename:g.spacename,keyName:g.keyName,issuedAt:g.issuedAt,file:y},null,2)):(console.log(_.default.green("✓"),"Data Bank space key stored for this buttress server."),console.log(` Space: ${_.default.bold(g.spacename)} (${t})`),console.log(` Key name: ${_.default.cyan(g.keyName)}`),console.log(` State file: ${_.default.gray(y)}`),console.log(),console.log(_.default.yellow("Restart buttress-server so local functions pick it up (context.bank).")))}),function(e){return v.apply(this,arguments)})),K.command("mcp-config").description("Print (or write) the .mcp.json entry for a buttress server's local functions (experimental)").option("-u, --url <url>","Buttress server base URL (skips LAN discovery)").option("--ttl <seconds>","Token time-to-live in seconds (default 30 days)",e=>parseInt(e,10)).option("--no-token","Omit the access token (for an unauthenticated server)").option("-n, --name <name>","Server key to write in .mcp.json",B).option("-w, --write [file]","Merge into .mcp.json (defaults to ./.mcp.json)").option("-t, --timeout <ms>","Discovery timeout in milliseconds","3000").option("-j, --json","Output as JSON").action((g=w(function*(e){var t,o,r,i=(yield Promise.resolve().then(a.bind(a,14636))).default,n=yield Promise.resolve().then(a.bind(a,47988)),p=n.getCurrentProfile,d=n.getTokenInfo,s=e.url,l=null;if(!s){var u=i("Scanning for buttress-servers...").start();try{var c,m,f,h=yield G({timeout:parseInt(e.timeout,10),onStatus:e=>{u.text=e}});u.stop();var v=d(p())?.workspaceId||null;f=(m=(c=(h||[]).filter(e=>!1!==e.verified&&e.address)).filter(e=>e.functions?.enabled)).length>0?m:c,l=0===f.length?null:v&&f.find(e=>e.workspace?.id===v)||f[0]}catch(e){u.fail(`Scan failed: ${e.message}`),process.exit(1)}l||(console.error(_.default.red("No buttress-server found on the LAN. Pass --url <base-url> explicitly.")),process.exit(1));var g=d(p())?.workspaceId||null,y=l.workspace?.id;!1===e.token||y&&y===g||(console.error(_.default.red(`Refusing to issue a token for ${l.name||l.address}: it reports workspace ${y||"(none — unbound)"}, not ${g||"(unknown)"}.`)),console.error(_.default.gray("Pass --url <base-url> to target it explicitly, or --no-token for an unauthenticated server.")),process.exit(1)),s=`http://${l.address}:${l.port}`,l.functions?.enabled||console.warn(_.default.yellow(`! ${l.name||s} does not advertise local functions. Enable [functions] in its config.`))}var D=null;if(!1!==e.token)try{var w=(yield W()).client;D=(yield w.issueButtressAccessToken({ttlSeconds:e.ttl})).token}catch(e){console.error(_.default.red(`Could not issue an access token: ${e.message}`)),console.error(_.default.gray("Use --no-token for a server running with allow_unauthenticated = true.")),process.exit(1)}var b=(t=s,o=D,r=String(t).replace(/\/+$/,""),{url:`${r}/functions/mcp`,...o?{headers:{Authorization:`Bearer ${o}`}}:{}}),S=e.name||B;if(e.write){var $=k.resolve("string"==typeof e.write?e.write:".mcp.json");try{var C=(yield P($,S,b)).created;console.log(_.default.green("✓"),`${C?"Created":"Updated"} ${_.default.gray($)} (${_.default.cyan(S)})`),console.log(` Endpoint: ${_.default.cyan(b.url)}`)}catch(e){console.error(_.default.red(e.message)),process.exit(1)}}else e.json?console.log(JSON.stringify({mcpServers:{[S]:b}},null,2)):(console.log(_.default.bold("\nAdd this to your .mcp.json:")),console.log(JSON.stringify({mcpServers:{[S]:b}},null,2)),console.log(),console.log(_.default.gray("Or re-run with --write to merge it automatically.")));D&&console.log(_.default.gray("\nThe entry embeds a workspace access token — treat .mcp.json as a secret and keep it out of version control."))}),function(e){return g.apply(this,arguments)})),K.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(x)).option("--udp-only","Skip HTTP /buttress/info verification").option("-j, --json","Output as JSON").action((y=w(function*(e){var t=(yield Promise.resolve().then(a.bind(a,14636))).default,o=yield Promise.resolve().then(a.bind(a,47988)),r=o.getCurrentProfile,i=o.getTokenInfo,n=parseInt(e.timeout,10),p=parseInt(e.port,10),d=[],s=t(`Scanning for buttress-servers (${n}ms)...`).start();try{d=yield G({timeout:n,port:p,verify:!e.udpOnly,onStatus:e=>{s.text=e}}),s.stop()}catch(e){s.fail(`Scan failed: ${e.message}`),process.exit(1)}var l=r(),u=i(l)?.workspaceId||null;if(e.json)return void console.log(JSON.stringify({servers:d,workspaceId:u},null,2));if(0===d.length)return void console.log(_.default.yellow("No buttress-servers found on the LAN."));for(var c of(console.log(_.default.bold(`
50
- Found ${d.length} buttress-server(s)`)),console.log("─".repeat(70)),d)){var m=!1===c.verified?_.default.red("unverified"):_.default.green("online"),f=c.workspace?.id,h=f&&u&&f===u,v=c.authentication?.bound?_.default.yellow("JWT required"):_.default.gray("open");console.log(` ${_.default.bold(c.name||"Unknown")} ${_.default.gray(`(${c.address}:${c.port})`)} [${m}]`),c.id&&console.log(` Server id: ${_.default.cyan(c.id)}`),c.version&&console.log(` Version: ${_.default.green(c.version)}`);var g=c.authentication?.kid?_.default.gray(` (kid: ${c.authentication.kid})`):"";if(console.log(` Auth: ${v}${g}`),f){var y=h?_.default.green(`${f} ${_.default.bold("(current profile)")}`):_.default.gray(f);console.log(` Workspace: ${y}`)}if(Array.isArray(c.generators)&&c.generators.length>0)for(var D of(console.log(" Generators:"),c.generators)){var w=[];"number"==typeof D.score&&w.push(`score ${D.score.toFixed(1)}`),!0===D.hasGpu?w.push("GPU ✓"):!1===D.hasGpu&&w.push("GPU ✗"),"number"==typeof D.usableBytes&&w.push(`${(D.usableBytes/0x40000000).toFixed(1)} GB usable`);var b=w.length>0?` ${_.default.gray(w.join(" "))}`:"";console.log(` - ${_.default.cyan(D.type)}${b}`)}}console.log("─".repeat(70)),d.some(e=>e.authentication?.bound)&&(console.log(),console.log(_.default.gray("To connect to a bound server, run `bricks buttress issue-token` for a workspace access token.")))}),function(e){return y.apply(this,arguments)}))},71335(e,t,a){a.d(t,{oT:()=>l});var o=a(35679),r=a(73284),i=a(47988),n={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},p=e=>{var t=Object.entries(n).find(([,t])=>e===t);return t?t[0]:null},d={prod:"https://activity-log.bricks.tools",beta:"https://activity-log-beta.bricks.tools",dev:"http://localhost:8088"},s=e=>{var t=Object.entries(d).find(([,t])=>e===t);return t?t[0]:null},l=new o.uB("config").description("CLI configuration management");l.command("endpoint").argument("[environment]","Environment to use (prod, beta, dev)").description("Show or set endpoint environment").option("-p, --profile","Set for current profile instead of global").action((e,t)=>{if(!e){var a=(0,i.getBaseUrl)(),o=p(a),l=(0,i.getActivityLogBaseUrl)(),u=s(l);console.log(r.default.bold("\nEndpoint Configuration")),console.log("─".repeat(50)),console.log(r.default.bold("BRICKS")),console.log(` URL: ${r.default.cyan(a)}`),console.log(` Environment: ${o?r.default.green(o):r.default.yellow("custom")}`),console.log(r.default.bold("Activity Log")),console.log(` URL: ${r.default.cyan(l)}`),console.log(` Environment: ${u?r.default.green(u):r.default.yellow("custom")}`),console.log("─".repeat(50)),console.log(r.default.gray("\nUsage: bricks config endpoint <prod|beta|dev>"));return}var c=Object.keys(n);c.includes(e)||(console.error(r.default.red(`Invalid environment: ${e}`)),console.log(r.default.gray(`Valid options: ${c.join(", ")}`)),process.exit(1));var m=n[e],f=d[e],h=t.profile?(0,i.getCurrentProfile)():null;(0,i.setBaseUrl)(m,h),(0,i.setActivityLogBaseUrl)(f,h);var v=t.profile?` (profile: ${(0,i.getCurrentProfile)()})`:"";console.log(r.default.green(`✓ Endpoint changed to ${e}${v}`)),console.log(r.default.gray(` BRICKS: ${m}`)),console.log(r.default.gray(` Activity Log: ${f}`)),console.log(r.default.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(r.default.gray("Use `bricks auth status` to check your connection."))}),l.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(e=>{var t=(0,i.getBaseUrl)(),a=p(t);if(e.json)return void console.log(JSON.stringify({endpoint:t,environment:a||"custom"},null,2));console.log(r.default.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`BRICKS: ${r.default.cyan(t)}`),a?console.log(`Environment: ${r.default.green(a)}`):console.log(`Environment: ${r.default.yellow("custom")}`);var o=(0,i.getActivityLogBaseUrl)(),n=s(o);console.log(`Activity Log: ${r.default.cyan(o)} ${n?r.default.green(`(${n})`):r.default.yellow("(custom)")}`),console.log("─".repeat(50))})},22175(e,t,a){a.d(t,{g:()=>h});var o,r,i,n,p,d,s,l,u=a(99436),c=a(35679),m=a(73284),f=a(90003),h=new c.uB("ctor").description("BRICKS Project (ctor) tooling: scaffold, sync, compile, deploy, and serve the project"),v=e=>{console.error(m.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((o=u(function*(e,t){var o="module"===t.type?"module":"application",r=(yield Promise.all([a.e(5658),a.e(4456)]).then(a.bind(a,58891))).initProject;yield r(o,e,t)}),function(e,t){return o.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((r=u(function*(e){try{if(e.check){var t=(yield Promise.all([a.e(7111),a.e(1708)]).then(a.bind(a,37495))).checkProjectAssets,o=yield t();if(e.json)return void console.log(JSON.stringify(o,null,2));if(o.upToDate)return void console.log(`Project assets match the bundled snapshot (CLI ${o.cliVersion}).`);var r=(e,{changed:t,missing:a})=>{if(t.length||a.length){for(var o of(console.log(`${e}: ${t.length} changed, ${a.length} missing`),t))console.log(` ~ ${o}`);for(var r of a)console.log(` + ${r}`)}};console.log(`Project assets differ from the bundled snapshot (CLI ${o.cliVersion}):`),r("ctor/",o.lib),r("skills",o.skills),console.log("Run `bricks ctor postinstall --refresh-skills` to update them.");return}var i=(yield Promise.all([a.e(7111),a.e(1708)]).then(a.bind(a,37495))).postinstall;yield i(e)}catch(e){v(e)}}),function(e){return r.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 t=(yield a.e(9663).then(a.bind(a,47090))).pull;yield t(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((n=u(function*(e){try{var t=(yield Promise.all([a.e(2151),a.e(8937),a.e(2517)]).then(a.bind(a,69620))).compile,o=(yield a.e(2557).then(a.bind(a,71772))).push;yield t({check:!0}),yield o(e)}catch(e){v(e)}}),function(e){return n.apply(this,arguments)})),h.command("deploy").description("Compile and create a new release only when requested; use push for normal updates").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","Bump the local patch version; application version must exceed cloud releases").option("--version <version>","Set release version; application version must exceed cloud releases").option("-y, --yes","Skip all prompts").action((p=u(function*(e){try{var t=(yield Promise.all([a.e(2151),a.e(8937),a.e(2517)]).then(a.bind(a,69620))).compile,o=(yield a.e(1215).then(a.bind(a,42914))).deploy;yield t({check:!0}),yield o(e)}catch(e){v(e)}}),function(e){return p.apply(this,arguments)})),h.command("compile").description("Typecheck and build the project config").option("--no-check","Skip the typecheck preflight").action((d=u(function*(e){try{var t=(yield Promise.all([a.e(2151),a.e(8937),a.e(2517)]).then(a.bind(a,69620))).compile;yield t(e)}catch(e){v(e)}}),function(e){return d.apply(this,arguments)})),h.command("simulator").description("Run the BRICKS web-preview simulator for the project").allowUnknownOption(!0).helpOption(!1).action((s=u(function*(e,t){try{var o=(yield a.e(9320).then(a.bind(a,7931))).simulator;yield o(t.args)}catch(e){v(e)}}),function(e,t){return s.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((l=u(function*(e){try{var t=(yield Promise.all([a.e(3781),a.e(39),a.e(6194)]).then(a.bind(a,95417))).startCtorMcpServer;yield t(e.project)}catch(e){v(e)}}),function(e){return l.apply(this,arguments)}))},55609(e,t,a){a.d(t,{E:()=>J});var o,r,i,n,p,d,s,l,u,c,m,f,h,v,g,y,D,w=a(68832),b=a(99436),_=a(79896),k=a(35679),S=a(73284),$=a(7586),C=a(56493),E=a(58021),F=a(47988),x=a(31596),A=a(98593),N=(o=b(function*(){return(yield Promise.resolve().then(a.bind(a,14636))).default}),function(){return o.apply(this,arguments)}),O=(r=b(function*(e,t){return e.json?null:(yield N())(t).start()}),function(e,t){return r.apply(this,arguments)}),T=(i=b(function*(){return a.e(1936).then(a.bind(a,76627))}),function(){return i.apply(this,arguments)}),j=(n=b(function*(){return a.e(9387).then(a.bind(a,30182))}),function(){return n.apply(this,arguments)}),I=({spinner:e,error:t,options:a,action:o,target:r})=>{var i=t.message;i?.includes(x.GE)?i=`${x.GE} Run \`bricks data enable\` first.`:t.isBankAuthError&&(i=`${i}
50
+ Found ${d.length} buttress-server(s)`)),console.log("─".repeat(70)),d)){var m=!1===c.verified?_.default.red("unverified"):_.default.green("online"),f=c.workspace?.id,h=f&&u&&f===u,v=c.authentication?.bound?_.default.yellow("JWT required"):_.default.gray("open");console.log(` ${_.default.bold(c.name||"Unknown")} ${_.default.gray(`(${c.address}:${c.port})`)} [${m}]`),c.id&&console.log(` Server id: ${_.default.cyan(c.id)}`),c.version&&console.log(` Version: ${_.default.green(c.version)}`);var g=c.authentication?.kid?_.default.gray(` (kid: ${c.authentication.kid})`):"";if(console.log(` Auth: ${v}${g}`),f){var y=h?_.default.green(`${f} ${_.default.bold("(current profile)")}`):_.default.gray(f);console.log(` Workspace: ${y}`)}if(Array.isArray(c.generators)&&c.generators.length>0)for(var D of(console.log(" Generators:"),c.generators)){var w=[];"number"==typeof D.score&&w.push(`score ${D.score.toFixed(1)}`),!0===D.hasGpu?w.push("GPU ✓"):!1===D.hasGpu&&w.push("GPU ✗"),"number"==typeof D.usableBytes&&w.push(`${(D.usableBytes/0x40000000).toFixed(1)} GB usable`);var b=w.length>0?` ${_.default.gray(w.join(" "))}`:"";console.log(` - ${_.default.cyan(D.type)}${b}`)}}console.log("─".repeat(70)),d.some(e=>e.authentication?.bound)&&(console.log(),console.log(_.default.gray("To connect to a bound server, run `bricks buttress issue-token` for a workspace access token.")))}),function(e){return y.apply(this,arguments)}))},71335(e,t,a){a.d(t,{oT:()=>l});var o=a(35679),r=a(73284),i=a(47988),n={prod:"https://display.bricks.tools",beta:"https://display-beta.bricks.tools",dev:"http://localhost:3001"},p=e=>{var t=Object.entries(n).find(([,t])=>e===t);return t?t[0]:null},d={prod:"https://activity-log.bricks.tools",beta:"https://activity-log-beta.bricks.tools",dev:"http://localhost:8088"},s=e=>{var t=Object.entries(d).find(([,t])=>e===t);return t?t[0]:null},l=new o.uB("config").description("CLI configuration management");l.command("endpoint").argument("[environment]","Environment to use (prod, beta, dev)").description("Show or set endpoint environment").option("-p, --profile","Set for current profile instead of global").action((e,t)=>{if(!e){var a=(0,i.getBaseUrl)(),o=p(a),l=(0,i.getActivityLogBaseUrl)(),u=s(l);console.log(r.default.bold("\nEndpoint Configuration")),console.log("─".repeat(50)),console.log(r.default.bold("BRICKS")),console.log(` URL: ${r.default.cyan(a)}`),console.log(` Environment: ${o?r.default.green(o):r.default.yellow("custom")}`),console.log(r.default.bold("Activity Log")),console.log(` URL: ${r.default.cyan(l)}`),console.log(` Environment: ${u?r.default.green(u):r.default.yellow("custom")}`),console.log("─".repeat(50)),console.log(r.default.gray("\nUsage: bricks config endpoint <prod|beta|dev>"));return}var c=Object.keys(n);c.includes(e)||(console.error(r.default.red(`Invalid environment: ${e}`)),console.log(r.default.gray(`Valid options: ${c.join(", ")}`)),process.exit(1));var m=n[e],f=d[e],h=t.profile?(0,i.getCurrentProfile)():null;(0,i.setBaseUrl)(m,h),(0,i.setActivityLogBaseUrl)(f,h);var v=t.profile?` (profile: ${(0,i.getCurrentProfile)()})`:"";console.log(r.default.green(`✓ Endpoint changed to ${e}${v}`)),console.log(r.default.gray(` BRICKS: ${m}`)),console.log(r.default.gray(` Activity Log: ${f}`)),console.log(r.default.yellow("\nNote: You may need to re-authenticate if your token is for a different environment.")),console.log(r.default.gray("Use `bricks auth status` to check your connection."))}),l.command("show").description("Show current configuration").option("-j, --json","Output as JSON").action(e=>{var t=(0,i.getBaseUrl)(),a=p(t);if(e.json)return void console.log(JSON.stringify({endpoint:t,environment:a||"custom"},null,2));console.log(r.default.bold("\nBRICKS CLI Configuration")),console.log("─".repeat(50)),console.log(`BRICKS: ${r.default.cyan(t)}`),a?console.log(`Environment: ${r.default.green(a)}`):console.log(`Environment: ${r.default.yellow("custom")}`);var o=(0,i.getActivityLogBaseUrl)(),n=s(o);console.log(`Activity Log: ${r.default.cyan(o)} ${n?r.default.green(`(${n})`):r.default.yellow("(custom)")}`),console.log("─".repeat(50))})},22175(e,t,a){a.d(t,{g:()=>h});var o,r,i,n,p,d,s,l,u=a(99436),c=a(35679),m=a(73284),f=a(90003),h=new c.uB("ctor").description("BRICKS Project (ctor) tooling: scaffold, sync, compile, deploy, and serve the project"),v=e=>{console.error(m.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((o=u(function*(e,t){var o="module"===t.type?"module":"application",r=(yield Promise.all([a.e(5658),a.e(4456)]).then(a.bind(a,58891))).initProject;yield r(o,e,t)}),function(e,t){return o.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((r=u(function*(e){try{if(e.check){var t=(yield Promise.all([a.e(7111),a.e(1708)]).then(a.bind(a,37495))).checkProjectAssets,o=yield t();if(e.json)return void console.log(JSON.stringify(o,null,2));if(o.upToDate)return void console.log(`Project assets match the bundled snapshot (CLI ${o.cliVersion}).`);var r=(e,{changed:t,missing:a})=>{if(t.length||a.length){for(var o of(console.log(`${e}: ${t.length} changed, ${a.length} missing`),t))console.log(` ~ ${o}`);for(var r of a)console.log(` + ${r}`)}};console.log(`Project assets differ from the bundled snapshot (CLI ${o.cliVersion}):`),r("ctor/",o.lib),r("skills",o.skills),console.log("Run `bricks ctor postinstall --refresh-skills` to update them.");return}var i=(yield Promise.all([a.e(7111),a.e(1708)]).then(a.bind(a,37495))).postinstall;yield i(e)}catch(e){v(e)}}),function(e){return r.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 uncommitted changes first").action((i=u(function*(e){try{var t=(yield a.e(9663).then(a.bind(a,47090))).pull;yield t(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 uncommitted 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((n=u(function*(e){try{var t=(yield Promise.all([a.e(2151),a.e(8937),a.e(2517)]).then(a.bind(a,69620))).compile,o=(yield a.e(2557).then(a.bind(a,71772))).push;yield t({check:!0}),yield o(e)}catch(e){v(e)}}),function(e){return n.apply(this,arguments)})),h.command("deploy").description("Compile and create a new release only when requested; use push for normal updates").option("--changelogs <text>","Changelogs text for the release").option("--changelogs-file <path>","Read changelogs from a file").option("--auto-commit","Auto-commit uncommitted changes before deploying").option("--auto-version","Bump the local patch version; application version must exceed cloud releases").option("--version <version>","Set release version; application version must exceed cloud releases").option("-y, --yes","Skip all prompts").action((p=u(function*(e){try{var t=(yield Promise.all([a.e(2151),a.e(8937),a.e(2517)]).then(a.bind(a,69620))).compile,o=(yield a.e(1215).then(a.bind(a,42914))).deploy;yield t({check:!0}),yield o(e)}catch(e){v(e)}}),function(e){return p.apply(this,arguments)})),h.command("compile").description("Typecheck and build the project config").option("--no-check","Skip the typecheck preflight").action((d=u(function*(e){try{var t=(yield Promise.all([a.e(2151),a.e(8937),a.e(2517)]).then(a.bind(a,69620))).compile;yield t(e)}catch(e){v(e)}}),function(e){return d.apply(this,arguments)})),h.command("simulator").description("Run the BRICKS web-preview simulator for the project").allowUnknownOption(!0).helpOption(!1).action((s=u(function*(e,t){try{var o=(yield a.e(9320).then(a.bind(a,7931))).simulator;yield o(t.args)}catch(e){v(e)}}),function(e,t){return s.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((l=u(function*(e){try{var t=(yield Promise.all([a.e(3781),a.e(39),a.e(6194)]).then(a.bind(a,95417))).startCtorMcpServer;yield t(e.project)}catch(e){v(e)}}),function(e){return l.apply(this,arguments)}))},55609(e,t,a){a.d(t,{E:()=>J});var o,r,i,n,p,d,s,l,u,c,m,f,h,v,g,y,D,w=a(68832),b=a(99436),_=a(79896),k=a(35679),S=a(73284),$=a(7586),C=a(56493),E=a(58021),F=a(47988),x=a(31596),A=a(98593),N=(o=b(function*(){return(yield Promise.resolve().then(a.bind(a,14636))).default}),function(){return o.apply(this,arguments)}),O=(r=b(function*(e,t){return e.json?null:(yield N())(t).start()}),function(e,t){return r.apply(this,arguments)}),T=(i=b(function*(){return a.e(1936).then(a.bind(a,76627))}),function(){return i.apply(this,arguments)}),j=(n=b(function*(){return a.e(9387).then(a.bind(a,30182))}),function(){return n.apply(this,arguments)}),I=({spinner:e,error:t,options:a,action:o,target:r})=>{var i=t.message;i?.includes(x.GE)?i=`${x.GE} Run \`bricks data enable\` first.`:t.isBankAuthError&&(i=`${i}
51
51
  The Data Bank key may be invalid or revoked — run \`bricks data login\` to reissue.`),a.json?(0,$.OW)(i,{action:o,...r&&{target:r}}):e?e.fail(i):console.error(S.default.red(i)),process.exit(1)},B=e=>{try{return JSON.parse(e)}catch{return e}},P=(e,t)=>{try{return JSON.parse(e)}catch{throw Error(`Invalid JSON for ${t}`)}},V=e=>e.split(",").map(e=>e.trim()).filter(Boolean),R=e=>e.masked?e.value:(0,$.$l)(e.value),M=e=>({name:e.name,meta:e.meta,value:R(e),enableExpired:!!e.enableExpired,expiredAt:e.expiredAt||null,createAt:e.createAt||null,hasReadLimit:!!e.limitedReadProperties?.length,hasWriteLimit:!!e.limitedWriteProperties?.length}),U=(p=b(function*(e){var t=yield e.workspace();return t?.bank||{}}),function(e){return p.apply(this,arguments)}),L=()=>{var e=(0,F.getCurrentProfile)(),t=(0,C.requireAuthConnection)(e),a=t.baseUrl,o=t.client;return{profile:e,baseUrl:a,client:o,fingerprint:t.fingerprint,bank:t.bank}},q=(d=b(function*(e,{profile:t,baseUrl:a,fingerprint:o,bank:r}){var i=(yield T()).resolveBankCredentials,n=yield j(),p=n.createBankClient,d=n.resolveBankEndpoint,s=yield i(e,{profile:t,expectedProfile:o,bank:r});return p({endpoint:d(a),spacename:s.spacename,spacekey:s.spacekey})}),function(e,t){return d.apply(this,arguments)}),J=new k.uB("data").description("Data Bank (remote properties) management");J.command("status").description("Show Data Bank status for this workspace").option("-j, --json","Output as JSON").action((s=b(function*(e){var t=L(),a=t.client,o=t.bank,r=yield O(e,"Fetching Data Bank status...");try{var i=yield U(a),n={enabled:!!i.enable_remote_update,spacename:i.spacename||null,keys:(i.keys||[]).map(M),cliKey:o?{keyName:o.keyName||null,spacekey:(0,$.$l)(o.spacekey),issuedAt:o.issuedAt||null}:null};if(r&&r.stop(),e.json)return void(0,$.GF)(n);console.log(S.default.bold("\nData Bank")),console.log("─".repeat(60)),console.log(`Enabled: ${n.enabled?S.default.green("Yes"):S.default.red("No")}`),console.log(`Spacename: ${n.spacename||S.default.gray("N/A")}`),console.log(`Keys: ${n.keys.length}`),console.log(`CLI Key: ${n.cliKey?`${n.cliKey.keyName||"Unnamed"} ${S.default.gray(`(${n.cliKey.spacekey})`)}`:S.default.gray("none (issued automatically on first use)")}`),console.log("─".repeat(60)),n.enabled||console.log(S.default.yellow("Run `bricks data enable` to enable Data Bank."))}catch(t){I({spinner:r,error:t,options:e,action:"data.status"})}}),function(e){return s.apply(this,arguments)}));var G=(l=b(function*(e,t){var a=L().client,o=e?"data.enable":"data.disable",r=yield O(t,`${e?"Enabling":"Disabling"} Data Bank...`);try{var i=yield a.updateWorkspace({enableBankRemoteUpdate:e}),n=i?.bank||{};r&&r.stop(),(0,A.yd)({action:o,target:{spacename:n.spacename||null},result:{enabled:!!n.enable_remote_update},json:t.json,message:e?`${S.default.green("Data Bank enabled.")} Spacename: ${S.default.cyan(n.spacename)}`:S.default.green("Data Bank disabled.")})}catch(e){I({spinner:r,error:e,options:t,action:o})}}),function(e,t){return l.apply(this,arguments)});J.command("enable").description("Enable Data Bank on this workspace").option("-j, --json","Output as JSON").action(e=>G(!0,e)),J.command("disable").description("Disable Data Bank on this workspace").option("-j, --json","Output as JSON").action(e=>G(!1,e)),J.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((u=b(function*(e){var t=L(),a=t.client,o=t.profile,r=t.fingerprint,i=t.bank,n=yield O(e,"Issuing Data Bank key...");try{var p=(yield T()).issueBankCredentials,d=yield p(a,{keyName:e.name,profile:o,expectedProfile:r,bank:i});n&&n.stop(),(0,A.yd)({action:"data.login",target:{spacename:d.spacename},result:{keyName:d.keyName,spacekey:(0,$.$l)(d.spacekey),issuedAt:d.issuedAt},json:e.json,message:`${S.default.green("Data Bank key issued and saved.")} ${S.default.gray(`(${d.keyName}, stored in ${F.CONFIG_PATH})`)}`})}catch(t){I({spinner:n,error:t,options:e,action:"data.login"})}}),function(e){return u.apply(this,arguments)})),J.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((c=b(function*(e){var t=L(),a=t.client,o=t.profile,r=t.fingerprint,i=t.bank,n=yield O(e,"Clearing Data Bank key...");try{var p=(yield T()).clearStoredBankCredentials,d=yield p(a,{revoke:e.revoke,profile:o,expectedProfile:r,bank:i}),s=d.cleared,l=d.revoked;n&&n.stop(),(0,A.yd)({action:"data.logout",target:{profile:o},result:{cleared:s,revoked:l},json:e.json,message:s?S.default.green(`Data Bank key removed${l?" and revoked":""}.`):S.default.yellow("No Data Bank key stored for this profile.")})}catch(t){I({spinner:n,error:t,options:e,action:"data.logout"})}}),function(e){return c.apply(this,arguments)}));var H=new k.uB("keys").description("Data Bank space key management");J.addCommand(H),H.command("list").description("List Data Bank space keys (values are masked; --json shows them when readable)").option("-j, --json","Output as JSON (includes full key values when this login may read them)").action((m=b(function*(e){var t=L().client,a=yield O(e,"Fetching space keys...");try{var o=(yield U(t)).keys||[];if(a&&a.stop(),e.json)return void(0,$.GF)(o);if(0===o.length)return void console.log(S.default.yellow("No space keys found"));console.log(S.default.bold("\nData Bank Space Keys")),console.log("─".repeat(60)),o.map(M).forEach(e=>{var t=e.enableExpired?`expires ${e.expiredAt}`:"no expiry",a=[e.hasReadLimit&&"read-limited",e.hasWriteLimit&&"write-limited"].filter(Boolean).join(", ");console.log(`● ${S.default.cyan(e.name||"Unnamed")} ${S.default.gray(`(${e.meta})`)}`),console.log(` Value: ${S.default.gray(e.value)}`),console.log(` Expiry: ${S.default.gray(t)}${a?S.default.gray(`, ${a}`):""}`),console.log()}),console.log("─".repeat(60))}catch(t){I({spinner:a,error:t,options:e,action:"data.keys.list"})}}),function(e){return m.apply(this,arguments)})),H.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((f=b(function*(e,t){var a=L().client,o=yield O(t,"Creating space key...");try{if(t.expireAt&&Number.isNaN(Date.parse(t.expireAt)))throw Error(`Invalid --expire-at date: ${t.expireAt}`);var r=yield U(a),i=new Set((r.keys||[]).map(e=>e.value)),n=yield a.updateWorkspace({newBankKey:{name:e,enableExpired:!!t.expireAt,expiredAt:t.expireAt,limitedReadProps:t.read?V(t.read):void 0,limitedWriteProps:t.write?V(t.write):void 0}}),p=(n?.bank?.keys||[]).filter(e=>!e.masked),d=p.find(e=>!i.has(e.value))||p.filter(t=>t.name===e).at(-1);if(!d)throw Error("Space key was not created");o&&o.stop(),(0,A.yd)({action:"data.keys.new",target:{name:e},result:d,json:t.json,message:S.default.green(`Space key "${e}" created.`)}),t.json||(console.log(S.default.yellow("\n⚠ Copy this key now — it will not be shown again in full:")),console.log(d.value))}catch(a){I({spinner:o,error:a,options:t,action:"data.keys.new",target:{name:e}})}}),function(e,t){return f.apply(this,arguments)})),H.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((h=b(function*(e,t){var a=L().client,o=yield O(t,"Resolving space key...");try{var r=yield U(a),i=((e,t)=>{var a=e.find(e=>e.value===t||e.masked&&t.length>8&&e.value===`…${t.slice(-4)}`);if(a)return{key:a,value:t};var o=e.filter(e=>e.name===t);if(0===o.length)throw Error(`No space key matched "${t}"`);if(o.length>1)throw Error(`Multiple space keys named "${t}"; pass the exact key value instead`);var r=w(o,1)[0];if(r.masked)throw Error(`The value of space key "${t}" is masked for this login; pass the full key value instead`);return{key:r,value:r.value}})(r.keys||[],e),n=i.key,p=i.value;if(o&&o.stop(),!(yield(0,E.n)({message:`Revoke space key "${n.name}" (${R(n)})?`,autoYes:t.yes,json:t.json})))return void console.log(S.default.yellow("Cancelled"));var d=yield a.updateWorkspace({revokeBankKey:p});if((d?.bank?.keys||[]).some(e=>e.value===n.value))throw Error(`Space key "${n.name}" was not revoked; check the key value`);(0,A.yd)({action:"data.keys.revoke",target:{name:n.name,meta:n.meta},result:{revoked:!0},json:t.json,message:S.default.green(`Space key "${n.name}" revoked.`)})}catch(e){I({spinner:o,error:e,options:t,action:"data.keys.revoke"})}}),function(e,t){return h.apply(this,arguments)})),J.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 (${x.YC.join(" | ")})`).option("-j, --json","Output as JSON").action((v=b(function*(e){var t=L(),a=t.client,o=yield O(e,"Fetching properties...");try{(0,x.jR)(e.meta);var r=yield q(a,t),i=yield r.listProperties({keyword:e.keyword,meta:e.meta});if(o&&o.stop(),e.json)return void(0,$.GF)(i||[]);if(!i||0===i.length)return void console.log(S.default.yellow("No Data Bank properties found"));console.log(S.default.bold(`
52
52
  Data Bank Properties (${i.length})`)),console.log("─".repeat(80)),i.forEach(e=>{var t=e.definition?.title;console.log(`● ${S.default.cyan(e.propertyId)} ${S.default.gray(`(${e.meta})`)}${t?` ${t}`:""}`),e.tags?.length&&console.log(` Tags: ${e.tags.join(", ")}`),console.log(` Value: ${(e=>{if(null==e)return S.default.gray("null");var t=JSON.stringify(e);return t.length>60?`${t.slice(0,60)}…`:t})(e.value)}`),console.log(` Updated: ${S.default.gray(e.updateAt)}`),console.log()}),console.log("─".repeat(80))}catch(t){I({spinner:o,error:t,options:e,action:"data.list"})}}),function(e){return v.apply(this,arguments)})),J.command("get <propertyId>").description("Get a Data Bank property").option("-j, --json","Output as JSON").action((g=b(function*(e,t){var a=L(),o=a.client,r=yield O(t,"Fetching property...");try{var i=yield q(o,a),n=yield i.getProperty(e);if(!n)throw Error(`Property not found: ${e}`);if(r&&r.stop(),t.json)return void(0,$.GF)(n);console.log(S.default.bold(`
53
53
  Data Bank Property: ${n.propertyId}`)),console.log("─".repeat(60)),console.log(`Meta: ${n.meta}`),console.log(`Title: ${n.definition?.title||S.default.gray("N/A")}`),console.log(`Tags: ${n.tags?.join(", ")||S.default.gray("None")}`),console.log(`Last Note: ${n.lastUpdateNote||S.default.gray("N/A")}`),console.log(`Updated: ${S.default.gray(n.updateAt)}`),console.log(`Created: ${S.default.gray(n.createAt)}`),console.log(`
@@ -113,10 +113,10 @@ ${v.default.bold("Exposed Properties")} (${r.expose_properties.length})`),r.expo
113
113
  Resolved ${u}`)),console.log("─".repeat(60)),console.log(`Name: ${r.default.cyan(y.name||"Unnamed")}`),console.log(`ID: ${r.default.gray(y._id)}`),console.log(`Selected By: ${g.selectedBy}`),console.log("─".repeat(60));return}if(0===g.matches.length)return void console.log(r.default.yellow(`No ${c} matched "${e}"`));console.log(r.default.bold(`
114
114
  Matching ${m} (${g.matches.length})`)),console.log("─".repeat(80)),g.matches.forEach(e=>{console.log(`${r.default.cyan(e.name||"Unnamed")} ${r.default.gray(e._id)}`)}),console.log("─".repeat(80))}catch(a){f?f.fail(`Failed to resolve ${t}: ${a.message}`):(0,p.OW)(a.message,{resource:t,query:e}),process.exit(1)}}),function(e,t){return l.apply(this,arguments)}))}},76250(e,t,a){a.d(t,{n:()=>d});var o=a(99436),r=a(73284),i=a(14636),n=a(44618),p=a(56493),d=(e,{description:t,entityName:a,fetchEntity:d})=>{var s;e.command("short-refs <id>").description(t).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=o(function*(e,t){var o=(0,p.requireAuth)(),s=(0,i.default)("Fetching short edit references...").start();try{var l=yield d(o,e);if(s.stop(),!l?.short_edit?.enabled)return void console.log(r.default.yellow(`Short Edit is not enabled for this ${a}`));var u=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):[],c=(0,n.V)(l.short_edit.ref_map,{keyword:t.keyword,types:u});if(t.json)return void console.log(JSON.stringify(c,null,2));if(0===c.length)return void console.log(r.default.yellow("No short edit references found"));console.log(r.default.bold(`
115
115
  Short Edit References: ${l.name}`)),c.forEach(e=>{console.log(r.default.cyan(`
116
- ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?r.default.gray(`- ${t.title}`):"";console.log(` ${r.default.green(e)} ${a}`)})}),console.log()}catch(e){s.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,t){return s.apply(this,arguments)}))}},38311(e,t,a){a.d(t,{D:()=>u});var o,r,i,n=a(99436),p=a(35679),d=a(73284),s=(o=n(function*(){var e=(yield Promise.resolve().then(a.bind(a,14636))).default,t=yield a.e(6818).then(a.bind(a,53241)),o=t.detectChannel,r=t.detectInstallMethod,i=yield a.e(9405).then(a.bind(a,21068));return{ora:e,detectChannel:o,detectInstallMethod:r,fetchLatestVersionInfo:i.fetchLatestVersionInfo,runUpdateForMethod:i.runUpdateForMethod}}),function(){return o.apply(this,arguments)}),l=(r=n(function*({message:e,defaultValue:t,autoYes:o}){if(o)return!0;(0,(yield Promise.resolve().then(a.bind(a,8479))).isInteractiveTerminal)()||(console.error(d.default.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{var r=(yield a.e(5658).then(a.bind(a,27521))).confirm;return yield r({message:e,default:t})}catch{return!1}}),function(e){return r.apply(this,arguments)}),u=new p.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=n(function*(e){var t,a=yield s(),o=a.ora,r=a.detectChannel,i=a.detectInstallMethod,p=a.fetchLatestVersionInfo,u=a.runUpdateForMethod,c="2.26.0-beta.27",m=i(),f=e.channel||r({version:c,execPath:m.execPath});console.log(d.default.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${d.default.cyan(c)}`),console.log(`Channel : ${d.default.cyan(f)}`),console.log(`Detected method : ${d.default.cyan(m.method)}`),m.execPath&&"binary"===m.method&&console.log(`Binary path : ${d.default.gray(m.execPath)}`),m.installRoot&&console.log(`Install root : ${d.default.gray(m.installRoot)}`);var h="npm"===m.method||"bun"===m.method?"npm":"cdn",v=o(`Fetching latest version info (${h})...`).start(),g=null,y=null;try{g=(yield p(f,m.method)).version,v.succeed(`Latest ${f} (${h}): ${d.default.green(g)}`)}catch(e){y=e,v.warn(`Could not fetch version info: ${e.message}`)}var D=g&&g===c;if(e.checkUpdate){if(y&&process.exit(2),D)return void console.log(d.default.green("\nUp to date."));g&&(console.log(d.default.yellow(`
116
+ ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?r.default.gray(`- ${t.title}`):"";console.log(` ${r.default.green(e)} ${a}`)})}),console.log()}catch(e){s.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,t){return s.apply(this,arguments)}))}},38311(e,t,a){a.d(t,{D:()=>u});var o,r,i,n=a(99436),p=a(35679),d=a(73284),s=(o=n(function*(){var e=(yield Promise.resolve().then(a.bind(a,14636))).default,t=yield a.e(6818).then(a.bind(a,53241)),o=t.detectChannel,r=t.detectInstallMethod,i=yield a.e(9405).then(a.bind(a,21068));return{ora:e,detectChannel:o,detectInstallMethod:r,fetchLatestVersionInfo:i.fetchLatestVersionInfo,runUpdateForMethod:i.runUpdateForMethod}}),function(){return o.apply(this,arguments)}),l=(r=n(function*({message:e,defaultValue:t,autoYes:o}){if(o)return!0;(0,(yield Promise.resolve().then(a.bind(a,8479))).isInteractiveTerminal)()||(console.error(d.default.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{var r=(yield a.e(5658).then(a.bind(a,27521))).confirm;return yield r({message:e,default:t})}catch{return!1}}),function(e){return r.apply(this,arguments)}),u=new p.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=n(function*(e){var t,a=yield s(),o=a.ora,r=a.detectChannel,i=a.detectInstallMethod,p=a.fetchLatestVersionInfo,u=a.runUpdateForMethod,c="2.26.0-beta.29",m=i(),f=e.channel||r({version:c,execPath:m.execPath});console.log(d.default.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${d.default.cyan(c)}`),console.log(`Channel : ${d.default.cyan(f)}`),console.log(`Detected method : ${d.default.cyan(m.method)}`),m.execPath&&"binary"===m.method&&console.log(`Binary path : ${d.default.gray(m.execPath)}`),m.installRoot&&console.log(`Install root : ${d.default.gray(m.installRoot)}`);var h="npm"===m.method||"bun"===m.method?"npm":"cdn",v=o(`Fetching latest version info (${h})...`).start(),g=null,y=null;try{g=(yield p(f,m.method)).version,v.succeed(`Latest ${f} (${h}): ${d.default.green(g)}`)}catch(e){y=e,v.warn(`Could not fetch version info: ${e.message}`)}var D=g&&g===c;if(e.checkUpdate){if(y&&process.exit(2),D)return void console.log(d.default.green("\nUp to date."));g&&(console.log(d.default.yellow(`
117
117
  Update available: ${c} → ${g}. Run 'bricks update-cli' to install.`)),process.exit(1)),console.log(d.default.yellow("\nCould not determine current version.")),process.exit(2)}if(D&&(console.log(d.default.green("\nAlready running the latest version.")),!(yield l({message:"Reinstall anyway?",defaultValue:!1,autoYes:e.yes}))))return void console.log(d.default.gray("Skipped."));var w=["npm","bun","binary"].includes(m.method);w||console.log(d.default.yellow(`Cannot auto-detect installer (method: ${m.method}); falling back to binary install.`));var b=w?m.method:"binary";if(!(yield l({message:`Update CLI using "${b}" method?`,defaultValue:!0,autoYes:e.yes})))return void console.log(d.default.yellow("Cancelled."));var _=(t=n(function*(e){console.log(d.default.cyan(`
118
118
  → Running ${e} update...`));try{return yield u(e,f,m),!0}catch(t){return console.error(d.default.yellow(`
119
- ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,arguments)}),k=yield _(b);!k&&"binary"!==b&&(console.log(d.default.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield l({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(k=yield _("binary"))),k||(console.error(d.default.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(d.default.green("\nUpdate complete."))}),function(e){return i.apply(this,arguments)}))},1878(e,t,a){a.a(e,async function(e,o){try{a.d(t,{A:()=>x,e:()=>F});var r,i=a(99436),n=a(35679),p=a(73284),d=a(47988),s=a(8479),l=a(55614),u=a(43738),c=a(72381),m=a(32541),f=a(28634),h=a(27594),v=a(12569),g=a(55609),y=a(71335),D=a(68473),w=a(27759),b=a(42400),_=a(98247),k=a(70970),S=a(38311),$=a(59845),C=a(22175),E=e([b]);b=(E.then?(await E)():E)[0];var F=(r=i(function*(){var e,t=(0,s.getUnsupportedBunRuntimeError)();if(t){var o=process.argv.includes("--json")||process.argv.includes("-j");console.error(o?JSON.stringify({error:t}):p.default.red(t)),process.exit(1)}var r=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);if(-1!==r&&process.argv[r+1]){var E=process.argv[r+1];(0,d.setProfileOverride)(E),process.env.BRICKS_PROFILE=E,process.argv.splice(r,2)}n.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.26.0-beta.27","-v, --version","output the version number").enablePositionalOptions(),n.DM.addCommand(l.s),n.DM.addCommand(u._),n.DM.addCommand(c.B),n.DM.addCommand(m.A),n.DM.addCommand(f.p),n.DM.addCommand(h.n),n.DM.addCommand(v.u),n.DM.addCommand(g.E),n.DM.addCommand(y.oT),n.DM.addCommand(D.K),n.DM.addCommand(w.gf),n.DM.addCommand(b.D),n.DM.addCommand(_.v),n.DM.addCommand(k.l),n.DM.addCommand(S.D),n.DM.addCommand($.Q),n.DM.addCommand(C.g),n.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(i(function*(){try{var e=(yield Promise.all([a.e(3332),a.e(8295),a.e(3690),a.e(907),a.e(7294)]).then(a.bind(a,94685))).runInteractiveMode;yield e()}catch(e){console.error(p.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),n.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=i(function*(e){var t=(yield Promise.resolve().then(a.bind(a,47988))).getCurrentProfile,o=(yield Promise.resolve().then(a.bind(a,31802))).getConnectionContext,r=(yield Promise.all([a.e(3332),a.e(8295),a.e(907)]).then(a.bind(a,85382))).createClient,i=(yield Promise.resolve().then(a.bind(a,14636))).default,n=t(),d=o(n),s=d.auth,l=d.baseUrl;s||(console.error(p.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=i("Fetching workspace info...").start();try{var c=r(l,s),m=yield c.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(m,null,2));console.log(p.default.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${p.default.green(m.name)}`),console.log(`ID: ${p.default.gray(m._id)}`),console.log(`Description: ${m.description||p.default.gray("N/A")}`),console.log(`
119
+ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,arguments)}),k=yield _(b);!k&&"binary"!==b&&(console.log(d.default.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield l({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(k=yield _("binary"))),k||(console.error(d.default.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(d.default.green("\nUpdate complete."))}),function(e){return i.apply(this,arguments)}))},1878(e,t,a){a.a(e,async function(e,o){try{a.d(t,{A:()=>x,e:()=>F});var r,i=a(99436),n=a(35679),p=a(73284),d=a(47988),s=a(8479),l=a(55614),u=a(43738),c=a(72381),m=a(32541),f=a(28634),h=a(27594),v=a(12569),g=a(55609),y=a(71335),D=a(68473),w=a(27759),b=a(42400),_=a(98247),k=a(70970),S=a(38311),$=a(59845),C=a(22175),E=e([b]);b=(E.then?(await E)():E)[0];var F=(r=i(function*(){var e,t=(0,s.getUnsupportedBunRuntimeError)();if(t){var o=process.argv.includes("--json")||process.argv.includes("-j");console.error(o?JSON.stringify({error:t}):p.default.red(t)),process.exit(1)}var r=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);if(-1!==r&&process.argv[r+1]){var E=process.argv[r+1];(0,d.setProfileOverride)(E),process.env.BRICKS_PROFILE=E,process.argv.splice(r,2)}n.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.26.0-beta.29","-v, --version","output the version number").enablePositionalOptions(),n.DM.addCommand(l.s),n.DM.addCommand(u._),n.DM.addCommand(c.B),n.DM.addCommand(m.A),n.DM.addCommand(f.p),n.DM.addCommand(h.n),n.DM.addCommand(v.u),n.DM.addCommand(g.E),n.DM.addCommand(y.oT),n.DM.addCommand(D.K),n.DM.addCommand(w.gf),n.DM.addCommand(b.D),n.DM.addCommand(_.v),n.DM.addCommand(k.l),n.DM.addCommand(S.D),n.DM.addCommand($.Q),n.DM.addCommand(C.g),n.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(i(function*(){try{var e=(yield Promise.all([a.e(3332),a.e(8295),a.e(3690),a.e(907),a.e(7294)]).then(a.bind(a,94685))).runInteractiveMode;yield e()}catch(e){console.error(p.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),n.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=i(function*(e){var t=(yield Promise.resolve().then(a.bind(a,47988))).getCurrentProfile,o=(yield Promise.resolve().then(a.bind(a,31802))).getConnectionContext,r=(yield Promise.all([a.e(3332),a.e(8295),a.e(907)]).then(a.bind(a,85382))).createClient,i=(yield Promise.resolve().then(a.bind(a,14636))).default,n=t(),d=o(n),s=d.auth,l=d.baseUrl;s||(console.error(p.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=i("Fetching workspace info...").start();try{var c=r(l,s),m=yield c.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(m,null,2));console.log(p.default.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${p.default.green(m.name)}`),console.log(`ID: ${p.default.gray(m._id)}`),console.log(`Description: ${m.description||p.default.gray("N/A")}`),console.log(`
120
120
  ${p.default.bold("Data")}`),console.log(`Remote Update: ${m.bank?.enable_remote_update?p.default.green("Enabled"):p.default.gray("Disabled")}`),console.log(`Spacename: ${m.bank?.spacename||p.default.gray("N/A")}`),console.log("─".repeat(60))}catch(e){u.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}}),function(t){return e.apply(this,arguments)})),n.DM.on("--help",()=>{console.log(""),console.log(p.default.bold("Examples:")),console.log(""),console.log(p.default.gray(" # Sign in with your BRICKS account (opens the browser)")),console.log(" $ bricks auth login"),console.log(""),console.log(p.default.gray(" # Select a workspace as the active profile")),console.log(" $ bricks auth use-workspace"),console.log(""),console.log(p.default.gray(" # Workspace auth (CI/automation): one-time passcode or token")),console.log(" $ bricks auth login-workspace <passcode>"),console.log(""),console.log(p.default.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(p.default.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(p.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(p.default.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(p.default.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(p.default.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(p.default.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(p.default.gray("Get workspace token from BRICKS Controller:")),console.log(p.default.cyan(" https://control.bricks.tools")),console.log(p.default.gray(" Go to Workspace Settings > API Token"))});var F=process.argv.slice(2);if(0===F.length){if((0,s.shouldStartInteractiveMode)(F))try{var x=(yield Promise.all([a.e(3332),a.e(8295),a.e(3690),a.e(907),a.e(7294)]).then(a.bind(a,94685))).runInteractiveMode;yield x();return}catch(e){console.error(p.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}console.error(p.default.gray("No command provided. Interactive mode requires a TTY, so showing help instead.\n")),n.DM.outputHelp();return}yield n.DM.parseAsync(process.argv)}),function(){return r.apply(this,arguments)});let x=F;o()}catch(e){o(e)}})},31802(e,t,a){a.r(t),a.d(t,{getAuthContext:()=>d,getConnectionContext:()=>p});var o=a(99436),r=a(47988),i=a(63755),n=(e,t)=>{if(!e)throw Error("Not logged in. Run `bricks auth login` first.");if(e.user?.sub!==t)throw Error("OAuth account changed. Re-select the workspace for the current account.");return e},p=e=>{var t=(0,r.getProfileCredentialSnapshot)(e);return{...t,auth:(({tokenInfo:e,oauth:t})=>{if(!e)return null;if("oauth"===e.type){if(!t?.accessToken||!e.oauthSubject||e.oauthSubject!==t.user?.sub||!e.workspaceId)return null;var a,r,p,d,s=e.oauthSubject,l=(r=o(function*(){return n((yield(0,i.EC)()),s).accessToken}),function(){return r.apply(this,arguments)});return{kind:"oauth",workspaceId:e.workspaceId,workspaceName:e.workspaceName,getAccessToken:l,getHeaders:(p=o(function*(){return{authorization:`Bearer ${yield l()}`,"x-bricks-workspace-id":String(e.workspaceId)}}),function(){return p.apply(this,arguments)}),refresh:(d=o(function*(){n((yield(0,i.EC)({forceRefresh:!0})),s)}),function(){return d.apply(this,arguments)})}}return e.token?{kind:"token",token:e.token,workspaceId:e.workspaceId,workspaceName:e.workspaceName,getHeaders:(a=o(function*(){return{authorization:`Bearer ${e.token}`}}),function(){return a.apply(this,arguments)})}:null})(t)}},d=e=>p(e).auth},31596(e,t,a){a.d(t,{GE:()=>r,YC:()=>o,jR:()=>i});var o=["InSubspace","Global"],r="Data Bank is not enabled for this workspace.",i=e=>{if(e&&!o.includes(e))throw Error(`Invalid meta "${e}" (expected ${o.join(" | ")})`)}},56493(e,t,a){a.r(t),a.d(t,{requireAuth:()=>l,requireAuthConnection:()=>s});var o=a(99436),r=a(73284),i=a(47988),n=a(31802),p=a(29988),d=new Set(["$$typeof","asymmetricMatch","catch","constructor","finally","hasOwnProperty","inspect","nodeType","toJSON","toString","valueOf"]),s=(e=(0,i.getCurrentProfile)())=>{var t,a,s,l=(0,n.getConnectionContext)(e),u=l.auth,c=l.baseUrl;return u||(console.error(r.default.red("Not logged in.")),console.error(r.default.gray("Use `bricks auth login` (OAuth) or `bricks auth login-workspace` (workspace token) first.")),process.exit(1)),{...l,client:(t=null,a=o(function*(){return t||=Promise.resolve((0,p.i)()).then(({createClient:e})=>e(c,u))}),s=function(){return a.apply(this,arguments)},new Proxy({},{get:(e,t)=>t===Symbol.toStringTag?"BricksLazyClient":"string"!=typeof t||"then"===t||d.has(t)?void 0:o(function*(...e){var a=yield s(),o=a[t];return"function"==typeof o?o.apply(a,e):o})}))}},l=(e=(0,i.getCurrentProfile)())=>s(e).client},7586(e,t,a){a.d(t,{$l:()=>i,GF:()=>o,OW:()=>r});var o=e=>{console.log(JSON.stringify(e,null,2))},r=(e,t={})=>{console.error(JSON.stringify({ok:!1,error:{message:e,...t}},null,2))},i=(e,t=4)=>e?e.length<=2*t?"*".repeat(e.length):`${e.slice(0,t)}…${e.slice(-t)}`:null},58021(e,t,a){a.d(t,{n:()=>d});var o,r,i=a(99436),n=a(8479),p=(o=i(function*(){return a.e(5658).then(a.bind(a,27521))}),function(){return o.apply(this,arguments)}),d=(r=i(function*({message:e,autoYes:t,json:a}){if(t)return!0;if(a)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 o=(yield p()).confirm;return yield o({message:e,default:!1})}catch{return!1}}),function(e){return r.apply(this,arguments)})},8479(e,t,a){a.r(t),a.d(t,{MINIMUM_BUN_VERSION:()=>o,getUnsupportedBunRuntimeError:()=>i,isInteractiveTerminal:()=>n,shouldStartInteractiveMode:()=>p});var o="1.3.0",r=e=>{var t=String(e).match(/^(\d+)\.(\d+)\.(\d+)/);return t?t.slice(1).map(Number):null},i=(e=process.versions.bun)=>!e||((e,t)=>{var a=r(e),o=r(t);if(!a||!o)return!1;for(var i=0;i<o.length&&!(a[i]>o[i]);i+=1)if(a[i]<o[i])return!1;return!0})(e,o)?null:`Bun ${e} is not supported by BRICKS CLI. Bun ${o} or later is required. Run \`bun upgrade\` and retry.`,n=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&"function"==typeof process.stdin.setRawMode),p=(e=[])=>0===e.length&&n()},47988(e,t,a){a.r(t),a.d(t,{CONFIG_DIR:()=>S,CONFIG_LOCK_PATH:()=>C,CONFIG_PATH:()=>$,OAUTH_REFRESH_LOCK_PATH:()=>E,clearBankCredentials:()=>eM,clearConfig:()=>eq,clearOAuth:()=>eS,clearOAuthIfCurrent:()=>eA,clearOAuthIfCurrentAsync:()=>eN,default:()=>eJ,getActivityLogBaseUrl:()=>eU,getBankCredentials:()=>eV,getBaseUrl:()=>G,getCurrentProfile:()=>ej,getCurrentProfileSource:()=>eI,getOAuth:()=>eb,getProfileAuthKind:()=>ew,getProfileCredentialSnapshot:()=>ee,getProfileCredentialSnapshotAsync:()=>et,getProfileFingerprint:()=>ea,getToken:()=>K,getTokenInfo:()=>z,getTokens:()=>W,initializeConfigAsync:()=>q,installOAuthSessionIfCurrent:()=>ey,installOAuthSessionIfCurrentAsync:()=>eD,invalidateOAuthProfileCredentials:()=>eh,invalidateOAuthProfileCredentialsAsync:()=>ev,listProfiles:()=>eP,removeToken:()=>el,removeTokenIfCurrent:()=>eu,replaceOAuthIfCurrent:()=>eF,replaceOAuthIfCurrentAsync:()=>ex,resolveOAuthProfileTarget:()=>eo,setActivityLogBaseUrl:()=>eL,setBankCredentials:()=>eR,setBaseUrl:()=>H,setCurrentProfile:()=>eB,setDevtoolsTokenIfProfileCurrent:()=>ec,setDevtoolsTokenIfProfileCurrentAsync:()=>em,setOAuth:()=>e_,setOAuthAsync:()=>ek,setProfileOverride:()=>eT,setToken:()=>en,setTokenIfProfileCurrent:()=>ed,setTokenIfProfileCurrentAsync:()=>es,takeOAuthSession:()=>e$,takeOAuthSessionAsync:()=>eC,withOAuthRefreshLock:()=>P});var o,r,i,n,p,d,s,l,u,c,m,f,h,v,g=a(68832),y=a(99436),D=a(83440),w=a(76982),b=a(79896),_=a(16928),k=a(70857),S=_.join(k.homedir(),".bricks-cli"),$=_.join(S,"config.json"),C=`${$}.lock`,E=`${$}.oauth-refresh.lock`,F=new Int32Array(new SharedArrayBuffer(4)),x=e=>new Promise(t=>setTimeout(t,e)),A=e=>{if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"ESRCH"!==e.code}},N=e=>{try{var t=b.readFileSync(e,"utf8"),a=b.statSync(e),o=null;try{var r=JSON.parse(t);Number.isInteger(r?.pid)&&"string"==typeof r?.nonce&&(o=r)}catch{}return{raw:t,stat:a,owner:o}}catch(e){if("ENOENT"===e.code)return null;throw e}},O=e=>{var t,a=N(e);if(!a)return!0;var o=a.owner?!A(a.owner.pid):Date.now()-a.stat.mtimeMs>1e3;if(!o)return!1;var r=`${e}.recovery`;try{t=T(r)}catch(e){if("EEXIST"===e.code)return!1;throw e}try{if(!(a=N(e)))return!0;if(!(o=a.owner?!A(a.owner.pid):Date.now()-a.stat.mtimeMs>1e3))return!1;return b.unlinkSync(e),!0}catch(e){if("ENOENT"===e.code)return!0;throw e}finally{j(r,t)}},T=e=>{var t,a={pid:process.pid,nonce:w.randomUUID()},o=`${e}.${a.pid}.${a.nonce}.candidate`;try{t=b.openSync(o,"wx",384),b.writeFileSync(t,JSON.stringify(a)),b.fsyncSync(t),b.closeSync(t),t=void 0}catch(e){if(void 0!==t)try{b.closeSync(t)}catch{}try{b.unlinkSync(o)}catch{}throw e}try{b.linkSync(o,e)}catch(e){try{b.unlinkSync(o)}catch{}throw e}try{b.unlinkSync(o)}catch(e){"ENOENT"!==e.code&&console.error(`Failed to clean up shared BRICKS lock candidate: ${e.message}`)}return{owner:a}},j=(e,{owner:t})=>{try{var a;(a=N(e))&&a.owner?.nonce===t.nonce&&b.unlinkSync(e)}catch(e){"ENOENT"!==e.code&&console.error(`Failed to release shared BRICKS lock: ${e.message}`)}},I=e=>{b.mkdirSync(S,{recursive:!0});for(var t,a=Date.now()+5e3;!t;)try{t=T(C)}catch(e){if("EEXIST"!==e.code)throw e;if(O(C))continue;if(Date.now()>=a)throw Error(`Timed out waiting for shared BRICKS config lock: ${C}`);Atomics.wait(F,0,0,20)}try{return e()}finally{j(C,t)}},B=(o=y(function*(e){b.mkdirSync(S,{recursive:!0});for(var t,a=Date.now()+5e3;!t;)try{t=T(C)}catch(e){if("EEXIST"!==e.code)throw e;if(O(C))continue;if(Date.now()>=a)throw Error(`Timed out waiting for shared BRICKS config lock: ${C}`);yield x(20)}try{var o=e();if(o&&"function"==typeof o.then)throw Error("Shared BRICKS config lock callbacks must be synchronous");return o}finally{j(C,t)}}),function(e){return o.apply(this,arguments)}),P=(r=y(function*(e,{timeoutMs:t=3e4}={}){b.mkdirSync(S,{recursive:!0});for(var a,o=Date.now()+t;!a;)try{a=T(E)}catch(e){if("EEXIST"!==e.code)throw e;if(O(E))continue;if(Date.now()>=o)throw Error(`Timed out waiting for OAuth refresh lock: ${E}`);yield x(20)}try{return yield e()}finally{j(E,a)}}),function(e){return r.apply(this,arguments)}),V=()=>new D.default({projectName:"bricks-cli",cwd:S,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||=V(),L=(i=y(function*(){if(R)return R;M||=B(()=>R||=V());try{return yield M}finally{M=null}}),function(){return i.apply(this,arguments)}),q=(n=y(function*(){yield L()}),function(){return n.apply(this,arguments)}),J={get:e=>U().get(e),set:(e,t)=>{var a=U();return I(()=>a.set(e,t))},clear:()=>{var e=U();return I(()=>e.clear())},setAsync:(p=y(function*(e,t){var a=yield L();return B(()=>a.set(e,t))}),function(e,t){return p.apply(this,arguments)}),update:(e,t)=>{var a=U();return I(()=>{var o=t(a.get(e));return a.set(e,o),o})},updateAsync:(d=y(function*(e,t){var a=yield L();return B(()=>{var o=t(a.get(e));return a.set(e,o),o})}),function(e,t){return d.apply(this,arguments)}),snapshot:e=>{var t=U().store;return Object.fromEntries(e.map(e=>[e,t[e]]))},snapshotAsync:(s=y(function*(e){var t=(yield L()).store;return Object.fromEntries(e.map(e=>[e,t[e]]))}),function(e){return s.apply(this,arguments)}),transaction:(e,t)=>{var a=U();return I(()=>{var o=t(Object.fromEntries(e.map(e=>[e,a.get(e)])))||{};return Object.keys(o).length>0&&a.set(o),o})},transactionAsync:(l=y(function*(e,t){var a=yield L();return B(()=>{var o=t(Object.fromEntries(e.map(e=>[e,a.get(e)])))||{};return Object.keys(o).length>0&&a.set(o),o})}),function(e,t){return l.apply(this,arguments)})},G=(e=ej())=>{var t=J.get("tokens");return t[e]?.baseUrl||J.get("baseUrl")},H=(e,t)=>{t?J.update("tokens",(a={})=>({...a,[t]:{...a[t],baseUrl:e}})):J.set("baseUrl",e)},W=()=>J.get("tokens"),K=(e="default")=>{var t=J.get("tokens");return t[e]?.token},z=(e="default")=>J.get("tokens")[e],Y=(e,t,a,o)=>{if(!e)return null;var r=null==e.workspaceId?null:String(e.workspaceId);return"oauth"===e.type?e.oauthSubject&&e.oauthSubject===t?.user?.sub?{kind:"oauth",workspaceId:r,oauthSubject:e.oauthSubject,baseUrl:a,activityLogBaseUrl:o}:null:e.token?{kind:"token",workspaceId:r,token:e.token,baseUrl:a,activityLogBaseUrl:o}:null},Q=(e,t,a,o,r)=>{if(!e)return!1;var i=Y(t,a,t?.baseUrl||o,t?.activityLogBaseUrl||r);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)},Z=(e,t,a)=>({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:t,activityLogBaseUrl:a}),X=(e,{tokens:t={},oauth:a,devtoolsTokens:o={},baseUrl:r,activityLogBaseUrl:i})=>{var n=t[e],p=n?.baseUrl||r,d=n?.activityLogBaseUrl||i,s=Y(n,a,p,d);return{profile:e,tokenInfo:n,oauth:a,fingerprint:s,baseline:Z(n,p,d),bank:s&&n?.bank||null,devtoolsTokens:o[e]||{},baseUrl:p,activityLogBaseUrl:d}},ee=(e="default")=>X(e,J.snapshot(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"])),et=(u=y(function*(e="default"){return X(e,(yield J.snapshotAsync(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"])))}),function(){return u.apply(this,arguments)}),ea=(e="default")=>ee(e).fingerprint,eo=(e,t,a)=>{for(var o=J.snapshot(["tokens","baseUrl","activityLogBaseUrl"]),r=o.tokens||{},i=e,n=2;;){var p=r[i];if(!p||"oauth"===p.type&&p.oauthSubject===a&&String(p.workspaceId)===String(t))break;i=`${e}-${n}`,n+=1}var d=r[i];return{profile:i,baseline:Z(d,d?.baseUrl||o.baseUrl,d?.activityLogBaseUrl||o.activityLogBaseUrl)}},er=(e,t,a,o)=>{var r=a[e],i=r?.workspaceId&&t?.workspaceId&&String(r.workspaceId)===String(t.workspaceId),n=r?.type==="oauth"&&t?.type==="oauth"&&!!r.oauthSubject&&r.oauthSubject===t.oauthSubject||r?.type!=="oauth"&&t?.type!=="oauth"&&!!r?.token&&r.token===t?.token,p=i&&n,d={tokens:{...a,[e]:{...r?.baseUrl?{baseUrl:r.baseUrl}:{},...r?.activityLogBaseUrl?{activityLogBaseUrl:r.activityLogBaseUrl}:{},...p&&r?.bank?{bank:r.bank}:{},...t,createdAt:new Date().toISOString()}}};if(!p&&o[e]){var s={...o};delete s[e],d.devtoolsTokens=s}return d},ei=(e,t)=>{if(e&&t?.user?.sub!==e)throw Error("OAuth account changed. Re-select the workspace for the current account.")},en=(e,t,{expectedOAuthSubject:a}={})=>{J.transaction(a?["tokens","devtoolsTokens","oauth"]:["tokens","devtoolsTokens"],({tokens:o={},devtoolsTokens:r={},oauth:i})=>(ei(a,i),er(e,t,o,r)))},ep=(e,t,a,o)=>!!e&&JSON.stringify(e)===JSON.stringify(Z(t,t?.baseUrl||a,t?.activityLogBaseUrl||o)),ed=(e,t,a,{expectedOAuthSubject:o,makeCurrent:r=!1}={})=>{var i=!1;return J.transaction(["tokens","devtoolsTokens","oauth","currentProfile","baseUrl","activityLogBaseUrl"],({tokens:n={},devtoolsTokens:p={},oauth:d,baseUrl:s,activityLogBaseUrl:l})=>{if(!ep(a,n[e],s,l))return{};ei(o,d),i=!0;var u=er(e,t,n,p);return r?{...u,currentProfile:e}:u}),i},es=(c=y(function*(e,t,a,{expectedOAuthSubject:o,makeCurrent:r=!1}={}){var i=!1;return yield J.transactionAsync(["tokens","devtoolsTokens","oauth","currentProfile","baseUrl","activityLogBaseUrl"],({tokens:n={},devtoolsTokens:p={},oauth:d,baseUrl:s,activityLogBaseUrl:l})=>{if(!ep(a,n[e],s,l))return{};ei(o,d),i=!0;var u=er(e,t,n,p);return r?{...u,currentProfile:e}:u}),i}),function(e,t,a){return c.apply(this,arguments)}),el=e=>{J.transaction(["tokens","devtoolsTokens"],({tokens:t={},devtoolsTokens:a={}})=>{var o={...t};delete o[e];var r={tokens:o};if(a[e]){var i={...a};delete i[e],r.devtoolsTokens=i}return r})},eu=(e,t)=>{var a=!1;return J.transaction(["tokens","devtoolsTokens"],({tokens:o={},devtoolsTokens:r={}})=>{if(i=o[e],!i||!t||String(i.workspaceId??"")!==String(t.workspaceId??"")||("oauth"===t.type?"oauth"!==i.type||i.oauthSubject!==t.oauthSubject:t.token?"oauth"===i.type||i.token!==t.token:JSON.stringify(i)!==JSON.stringify(t)))return{};a=!0;var i,n={...o};delete n[e];var p={...r};return delete p[e],{tokens:n,devtoolsTokens:p}}),a},ec=(e,t,a,o)=>{var r=!1;return J.transaction(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"],({tokens:i={},oauth:n,devtoolsTokens:p={},baseUrl:d,activityLogBaseUrl:s})=>Q(t,i[e],n,d,s)?(r=!0,{devtoolsTokens:{...p,[e]:{...p[e],[a]:o}}}):{}),r},em=(m=y(function*(e,t,a,o){var r=!1;return yield J.transactionAsync(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"],({tokens:i={},oauth:n,devtoolsTokens:p={},baseUrl:d,activityLogBaseUrl:s})=>Q(t,i[e],n,d,s)?(r=!0,{devtoolsTokens:{...p,[e]:{...p[e],[a]:o}}}):{}),r}),function(e,t,a,o){return m.apply(this,arguments)}),ef=(e,t)=>{if(e)return t(["tokens","devtoolsTokens"],({tokens:t={},devtoolsTokens:a={}})=>{var o={...t},r=[];for(var i of Object.entries(t)){var n=g(i,2),p=n[0],d=n[1];if(d?.type==="oauth"&&(!d.oauthSubject||d.oauthSubject===e)){r.push(p);var s={...d,oauthSubject:d.oauthSubject||e};delete s.bank,o[p]=s}}var l={...a},u=!1;return r.forEach(e=>{l[e]&&(delete l[e],u=!0)}),{tokens:o,...u?{devtoolsTokens:l}:{}}})},eh=e=>ef(e,J.transaction),ev=e=>ef(e,J.transactionAsync),eg=(e,t,a)=>{if(o=a.oauth,e?.accessToken?!eE(e,o):!!o?.accessToken)return{result:{installed:!1,identityChanged:!1,previous:null},updates:{}};var o,r=a.oauth?.accessToken?a.oauth:null,i=r?.user?.sub,n=!!(i&&t?.user?.sub&&i!==t.user.sub),p={installed:!0,identityChanged:n,previous:r};if(!n)return{result:p,updates:{oauth:t}};var d={...a.tokens||{}},s={...a.devtoolsTokens||{}},l=!1;for(var u of Object.entries(a.tokens||{})){var c=g(u,2),m=c[0],f=c[1];if(f?.type==="oauth"&&(!f.oauthSubject||f.oauthSubject===i)){var h={...f,oauthSubject:f.oauthSubject||i};delete h.bank,d[m]=h,s[m]&&(delete s[m],l=!0)}}return{result:p,updates:{oauth:t,tokens:d,...l?{devtoolsTokens:s}:{}}}},ey=(e,t)=>{var a;return J.transaction(["oauth","tokens","devtoolsTokens"],o=>{var r=eg(e,t,o);return a=r.result,r.updates}),a},eD=(f=y(function*(e,t){var a;return yield J.transactionAsync(["oauth","tokens","devtoolsTokens"],o=>{var r=eg(e,t,o);return a=r.result,r.updates}),a}),function(e,t){return f.apply(this,arguments)}),ew=(e="default")=>{var t=z(e);return t?"oauth"===t.type?"oauth":t.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),ek=e=>J.setAsync("oauth",e),eS=()=>J.set("oauth",{}),e$=()=>{var e=null;return J.update("oauth",t=>(t?.accessToken&&(e=t),{})),e},eC=(h=y(function*(){var e=null;return yield J.updateAsync("oauth",t=>(t?.accessToken&&(e=t),{})),e}),function(){return h.apply(this,arguments)}),eE=(e,t)=>!!e&&!!t&&e.accessToken===t.accessToken&&e.refreshToken===t.refreshToken,eF=(e,t)=>{var a=!1;return J.update("oauth",o=>eE(e,o)?(a=!0,t||{}):o||{}),a},ex=(v=y(function*(e,t){var a=!1;return yield J.updateAsync("oauth",o=>eE(e,o)?(a=!0,t||{}):o||{}),a}),function(e,t){return v.apply(this,arguments)}),eA=e=>eF(e,{}),eN=e=>ex(e,{}),eO=null,eT=e=>{eO=e},ej=()=>eO||process.env.BRICKS_PROFILE||J.get("currentProfile"),eI=()=>eO?"override":process.env.BRICKS_PROFILE?"env":"config",eB=e=>J.set("currentProfile",e),eP=()=>{var e=J.get("tokens"),t=J.get("currentProfile");return Object.keys(e).map(a=>({...e[a],name:a,current:a===t}))},eV=(e="default")=>{var t=J.get("tokens")[e];if(t?.type==="oauth"){var a=eb();if(!t.oauthSubject||t.oauthSubject!==a?.user?.sub)return null}return t?.bank||null},eR=(e,t,{expectedProfile:a}={})=>{var o=!1;return J.transaction(["tokens","oauth","baseUrl","activityLogBaseUrl"],({tokens:r={},oauth:i,baseUrl:n,activityLogBaseUrl:p})=>(!a||Q(a,r[e],i,n,p))&&r[e]?(o=!0,{tokens:{...r,[e]:{...r[e],bank:t}}}):{}),o},eM=(e,{expectedProfile:t,expectedSpacekey:a}={})=>{var o=!1;return J.transaction(["tokens","oauth","baseUrl","activityLogBaseUrl"],({tokens:r={},oauth:i,baseUrl:n,activityLogBaseUrl:p})=>{if(t&&!Q(t,r[e],i,n,p)||!r[e]?.bank||a&&r[e].bank.spacekey!==a)return{};o=!0;var d={...r[e]};return delete d.bank,{tokens:{...r,[e]:d}}}),o},eU=(e=ej())=>{var t=J.get("tokens");return t[e]?.activityLogBaseUrl||J.get("activityLogBaseUrl")},eL=(e,t)=>{t?J.update("tokens",(a={})=>({...a,[t]:{...a[t],activityLogBaseUrl:e}})):J.set("activityLogBaseUrl",e)},eq=()=>{J.clear()};let eJ=J},54782(e,t,a){a.d(t,{Cj:()=>i,vc:()=>r});var o="http://localhost:3006",r=(e,t,a,r=process.env)=>{var i=((e,t=process.env)=>{var a;if(t.BRICKS_CONTROLLER_URL)return t.BRICKS_CONTROLLER_URL.replace(/\/$/,"");try{a=new URL(e)}catch{return null}return"localhost"===a.hostname||"127.0.0.1"===a.hostname?o:/^display(-[a-z0-9]+)?\.bricks\.tools$/.test(a.hostname)?`${a.protocol}//${a.hostname.replace(/^display/,"control")}`:null})(e,r);if(!i)return null;var n=i===o?`dev-${t}`:t,p=Object.entries(a).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).join("&");return`${i}/${n}?${p}`},i=(e,t,a=process.env)=>r(e,"webLauncher.html",{token:t},a)},9683(e,t,a){a.d(t,{Ed:()=>r,RZ:()=>o,mz:()=>i});var o=3e5,r=(e,t=Date.now())=>{if(!e)return{state:"unknown",tone:"gray",glyph:"○",label:"Unknown"};var a=t-new Date(e).getTime();return a<=o?{state:"online",tone:"green",glyph:"●",label:"Online"}:{state:"offline",tone:a<36e5?"yellow":"red",glyph:"○",label:a<36e5?`${Math.floor(a/6e4)}m ago`:a<864e5?`${Math.floor(a/36e5)}h ago`:`${Math.floor(a/864e5)}d ago`}},i=({state:e,glyph:t,label:a})=>`${t} ${"offline"===e?`Offline (${a})`:a}`},75646(e,t,a){a.r(t),a.d(t,{discoverDevToolsServers:()=>d,httpProbeSubnet:()=>s,verifyDevToolsServer:()=>l});var o,r,i=a(99436),n=a(19557),p="bricks-devtools",d=({timeout:e=3e3,idleTimeout:t=0}={})=>(0,n.YH)({port:19900,timeout:e,idleTimeout:t,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:p,d:{id:`cli-${(0,n.BW)()}`}})),parseMessage:(e,t)=>{var a=(0,n.nl)(e,e=>e?.s===p);if(!a)return null;var o=t.address;return{key:`${o}:${a.port}`,value:{...a,address:o}}}}),s=(o=i(function*({port:e=19851,connectTimeout:t=500,concurrency:a=50,timeout:o=0}={}){var r=(0,n.r9)();if(0===r.length)return[];var p=[],d=o>0?Date.now()+o:0,s=[],u=new Set;for(var c of r){var m=c.address.split(".").slice(0,3).join(".");if(!u.has(m)){u.add(m);for(var f=1;f<255;f++)s.push(`${m}.${f}`)}}for(var h=0;h<s.length&&!(d&&Date.now()>=d);h+=a){var v=s.slice(h,h+a);yield Promise.allSettled(v.map(function(){var a=i(function*(a){var o=yield l(a,e,t);o&&p.push({...o,address:a,port:e})});return function(e){return a.apply(this,arguments)}}()))}return p}),function(){return o.apply(this,arguments)}),l=(r=i(function*(e,t,a=3e3){return(0,n.uE)(`http://${e}:${t}/devtools/info`,a)}),function(e,t){return r.apply(this,arguments)})},29988(e,t,a){a.d(t,{U:()=>r,i:()=>o});var o=()=>"u">typeof module&&"function"==typeof module.require?module.require("../gql/client.js"):Promise.all([a.e(3332),a.e(8295),a.e(907)]).then(a.bind(a,85382)),r=()=>"u">typeof module&&"function"==typeof module.require?module.require("../gql/controller-client.js"):Promise.all([a.e(3332),a.e(8295),a.e(7494)]).then(a.bind(a,59957))},19557(e,t,a){a.d(t,{BW:()=>p,YH:()=>u,nl:()=>s,r9:()=>l,uE:()=>c});var o,r=a(99436),i=a(41314),n=a(48161),p=()=>Math.random().toString(36).slice(2,9),d=new Set(["ANNOUNCE","RESPONSE"]),s=(e,t)=>{var a=JSON.parse(e.toString());return t(a)&&d.has(a.t)&&a.d?.info||null},l=()=>{var e=[];for(var t of Object.values(n.networkInterfaces()))for(var a of t)if(function(){if("IPv4"!==a.family||a.internal)return 1;var t=a.address.split(".").map(Number),o=a.netmask.split(".").map(Number),r=t.map((e,t)=>(e|255&~o[t]).toString()).join(".");e.push({address:a.address,broadcast:r})}())continue;return e},u=({port:e,timeout:t=3e3,idleTimeout:a=0,buildQuery:o,parseMessage:r})=>new Promise((n,p)=>{var d=new Map,s=i.createSocket("udp4"),u=null,c=null,m=!1,f=e=>{if(!m){m=!0,clearTimeout(u),clearTimeout(c);try{s.close()}catch{}e?p(e):n([...d.values()])}};s.on("error",f),s.on("message",(e,t)=>{if(!m)try{var o=r(e,t);if(!o||d.has(o.key))return;d.set(o.key,o.value),a&&!m&&(clearTimeout(c),c=setTimeout(f,a))}catch{}});try{s.bind(()=>{if(!m)try{s.setBroadcast(!0);var a=o();for(var r of(()=>{var e=new Set(["255.255.255.255","127.0.0.1"]);for(var t of l())e.add(t.broadcast);return[...e]})())s.send(a,0,a.length,e,r);u=setTimeout(f,t)}catch(e){f(e)}})}catch(e){f(e)}}),c=(o=r(function*(e,t=3e3){var a,o=new AbortController;try{a=setTimeout(()=>o.abort(),t);var r=yield fetch(e,{signal:o.signal});if(!r.ok)return null;return yield r.json()}catch{return null}finally{void 0!==a&&clearTimeout(a),o.abort()}}),function(e){return o.apply(this,arguments)})},63755(e,t,a){a.d(t,{EC:()=>M,IC:()=>U,UY:()=>I,X9:()=>J,Zd:()=>P,b2:()=>j,bo:()=>V,iF:()=>L,n_:()=>$,ph:()=>q});var o,r,i,n,p,d,s,l,u=a(68832),c=a(99436),m=a(76982),f=a(58611),h=a(35317),v=a(79657),g=a(64007),y=a(47988),D=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",k="/callback",S="127.0.0.1",$=()=>!!_,C=(e,t,{signal:a}={})=>(()=>{var e=process.env.HTTPS_PROXY||process.env.https_proxy;if(!e)return v.Ay;var t=new g(e);return(e,a={})=>(0,v.Ay)(e,{...a,agent:t})})()(`https://${D}${e}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(t).toString(),signal:a}),E=(o=c(function*(e){var t;try{t=yield e.json()}catch(e){if(e?.name==="AbortError")throw e;t={}}if(!e.ok){var a=Error(t.error_description||t.error||`HTTP ${e.status}`);throw a.code=t.error,a}return t}),function(e){return o.apply(this,arguments)}),F=(r=c(function*(e,t,{signal:a}={}){var o=new AbortController,r=()=>o.abort();a?.addEventListener("abort",r,{once:!0}),a?.aborted&&r();var i=setTimeout(()=>o.abort(),15e3);try{return yield E((yield C(e,t,{signal:o.signal})))}finally{clearTimeout(i),a?.removeEventListener("abort",r)}}),function(e,t){return r.apply(this,arguments)}),x=e=>String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;"),A=({title:e,heading:t,message:a})=>`<!doctype html>
121
121
  <html lang="en">
122
122
  <head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugood/bricks-cli",
3
- "version": "2.26.0-beta.27",
3
+ "version": "2.26.0-beta.29",
4
4
  "description": "BRICKS CLI - Command-line interface for BRICKS Workspace API",
5
5
  "keywords": [
6
6
  "bricks",
@@ -56,11 +56,11 @@
56
56
  "@babel/parser": "7.28.5",
57
57
  "@babel/traverse": "7.28.5",
58
58
  "@babel/types": "7.28.5",
59
- "@fugood/bricks-config-core": "^2.26.0-beta.27",
60
- "@fugood/bricks-core-generated": "^2.26.0-beta.27",
59
+ "@fugood/bricks-config-core": "^2.26.0-beta.29",
60
+ "@fugood/bricks-core-generated": "^2.26.0-beta.29",
61
61
  "@fugood/bricks-devtools-core": "^2.26.0-beta.24",
62
62
  "@fugood/bricks-system-properties-definition": "^2.25.3",
63
- "@fugood/property-bank-calc-generated": "^2.26.0-beta.27",
63
+ "@fugood/property-bank-calc-generated": "^2.26.0-beta.29",
64
64
  "@huggingface/gguf": "^0.3.2",
65
65
  "@iarna/toml": "^3.0.0",
66
66
  "@inquirer/prompts": "^7.0.0",
@@ -89,5 +89,5 @@
89
89
  "engines": {
90
90
  "node": ">=18.0.0"
91
91
  },
92
- "gitHead": "4ebffe22afded3c8f37cbc82352a982a37788d84"
92
+ "gitHead": "3dabdfe9d9915babdc8a34ea4287c5139ac76a73"
93
93
  }