@fugood/bricks-cli 2.25.0-beta.17 → 2.25.0-beta.19

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/117.js CHANGED
@@ -2469,7 +2469,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
2469
2469
  timestamp
2470
2470
  }
2471
2471
  }
2472
- `,tz=H(function e(i,t){J(this,e),this.baseUrl=i,this.token=t,this.graphqlUrl=`${i}/api/graphql`},[{key:"graphql",value:(o=v(function*(e,i){var t=yield(0,B.Ay)(this.graphqlUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,Accept:"application/json"},body:JSON.stringify({query:e,variables:i})});if(!t.ok){var n=yield t.text().catch(()=>"");throw Error(`Activity-log query failed (${t.status}): ${n}`)}var a=yield t.json();if(a.errors?.length)throw Error(a.errors.map(e=>e.message).join("\n"));return a.data}),function(e,i){return o.apply(this,arguments)})},{key:"events",value:(r=v(function*(e,{limit:i,offset:t}={}){var n={...e};return null!=i&&(n.limit=i),null!=t&&(n.offset=t),(yield this.graphql(tG,{filter:n})).events}),function(e){return r.apply(this,arguments)})},{key:"screenshots",value:(s=v(function*(e){return(yield this.graphql(tL,{filter:e})).screenshots}),function(e){return s.apply(this,arguments)})},{key:"downloadScreenshot",value:(d=v(function*(e,i,t){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(i)}/screenshot?ts=${encodeURIComponent(t)}`,a=yield(0,B.Ay)(n,{headers:{Authorization:`Bearer ${this.token}`}});if(!a.ok){var o=yield a.text().catch(()=>"");throw Error(`Screenshot fetch failed (${a.status}): ${o}`)}return Buffer.from((yield a.arrayBuffer()))}),function(e,i,t){return d.apply(this,arguments)})}]);process.env.STAGE,process.env.URL_BASE;var tH="bricks-mcp",tJ={bricks:process.env.BRICKS_API_SERVER||"https://display-beta.bricks.tools",media:process.env.MEDIA_API_SERVER||"https://media-beta.bricks.tools",activityLog:process.env.ACTIVITY_LOG_API_SERVER||"https://activity-log-beta.bricks.tools"};process.env.AUTH0_DOMAIN,process.env.CACHE_URL;var tX=t(1639);let tQ=({type:e,title:i,template_key:t})=>{var n,a,o=(0,tX.M4)(e);switch(e){case"subspace":n={title:i,layout:{width:"number",height:"number"},root_canvas_id:"CANVAS_<UUID>",canvas_map:{},brick_map:{},animation_map:{},generator_map:{},property_bank_map:{},property_bank_calc_map:{}},a={"canvas_map.CANVAS_<UUID>.item_list":[{type:"subspace",subspace_id:"SUBSPACE_<UUID>",$note:"If not a root subspace, it can be linked to canvas in other subspace"}]};break;case"canvas":var r=V(j.Ji);n={title:i,item_list:[],property:{$definitions:Object.fromEntries(Object.entries(r.propTypes).map(([e,i])=>[e,{...i,description:r.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(r.eventTypes).map(([e])=>[e,{description:r.brickEventDescriptions[e]}]))}},a={property_bank_map:{[(0,tX.M4)("property_bank")]:{title:`Canvas ID: ${i}`,type:"string",value:o,routing:"read-only",kind:"auto-generated-item-id",idType:"canvas"}}};break;case"brick":var s=V(j.dK.Basic),d=V(j.brickMapping[t]);if(!d)throw Error(`Brick ${t} not found`);var c={...d,propTypes:{...s.propTypes,...d.propTypes},brickPropDescriptions:{...s.brickPropDescriptions,...d.brickPropDescriptions},eventTypes:{...s.eventTypes,...d.eventTypes},brickEventDescriptions:{...s.brickEventDescriptions,...d.brickEventDescriptions}};n={title:i,template_key:t,property:{$definitions:Object.fromEntries(Object.entries(c.propTypes).map(([e,i])=>[e,{...i,description:c.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(c.eventTypes).map(([e])=>[e,{description:c.brickEventDescriptions[e]}]))},outlet:{$definitions:Object.fromEntries(Object.entries(c.outletTypes).map(([e])=>[e,{description:c.brickOutletDescriptions[e]}]))},state_group:{"BRICK_STATE_GROUP_<UUID>":{}}},a={canvas_map:{"CANVAS_<UUID WHICH NEED DISPLAY THIS BRICK>":{item_list:[{type:"brick",brick_id:o,frame:{x:"number",y:"number",width:"number",height:"number",standby_mode:"custom|top|left|right|bottom",standby_delay:"number",standby_easing:{default:{method:"ease",duration:"number"}}}}]}}};break;case"state_group":n={title:i,description:"State Group Description",conds:[{type:"property_bank|inner_state",key:"PROPERTY_BANK#<Data Node ID>|[current_canvas|BRICK_<OUTLET NAME>]|",method:"==|!=|>|>=|<|<=",value:"value_to_compare"}],override:{property:!1,event:!1,outlet:!1},commented:!1,break:!1,property:{},outlet:{},animation:{}};case"generator":var l=V(j.generatorMapping[t]);if(!l)throw Error(`Generator ${t} not found`);n={title:i,template_key:t,property:{$definitions:Object.fromEntries(Object.entries(l.propTypes).map(([e,i])=>[e,{...i,description:l.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(l.eventTypes).map(([e])=>[e,{description:l.brickEventDescriptions[e]}]))},outlet:{$definitions:Object.fromEntries(Object.entries(l.outletTypes).map(([e])=>[e,{description:l.brickOutletDescriptions[e]}]))}};break;case"animation":n={title:i,type:"timing|decay|spring",property:"opacity|transform.translateX|transform.scale|etc",config:{$note:"Config for the animation"},compose_type:"parallel|sequence",item_list:[{animation_id:"ANIMATION_<SUB ANIMATION UUID>"}]};break;case"property_bank":n={title:i,description:"Property Bank Description",linkedFrom:"SUBSPACE_<UUID WHICH IS CROSS SUBSPACE>",type:"string|number|bool|object|array|any",kind:"color|datetime|id|media-resource-*|lottie-file-uri",unit:"grid|px|ms",routing:"read-only|default",value:"fit-to-type",event_map:{$note:`Available events: ${Object.keys(j.qJ.eventTypes).join(", ")}`},local_sync:{update_mode:"all|main-only|minor-only|dont-sync"},$remote_update_additional:{$note:"Configure remote update behavior",enable_remote_update:!0,bank_type:"create|create-device-specific"}};break;case"property_bank_command":break;case"property_bank_calc":var p=(0,tX.M4)("property_bank_command"),u=(0,tX.M4)("property_bank_command"),m=(0,tX.M4)("property_bank_command"),_="const { arg_name } = inputs;\n\nreturn { arg_name };";n={title:i,map:{$note:"Required, actual implementation","PROPERTY_BANK_DATA_NODE_<UUID>":{type:"data-node",properties:{},in:{change:null},out:{value:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID>",port:"value"}]},$note:"Use this to input data to the sandbox"},"PROPERTY_BANK_COMMAND_NODE_<UUID FIRST>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:null,path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${p}`,port:"obj | inputs"}]}},"PROPERTY_BANK_COMMAND_NODE_<UUID SECOND>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PREVIOUS>",port:"result"}],path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID SECOND>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${p}`,port:"obj | inputs"}]}},[p]:{type:"command-node-sandbox",title:"Command: SANDBOX_RUN_JAVASCRIPT",properties:{command:"SANDBOX_RUN_JAVASCRIPT",args:{code:_,enable_async:!1}},in:{code:null,inputs:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID FINAL>",port:"result"}]},out:{result:[{id:m,port:"result"},{id:u,port:"result"}]}},[m]:{type:"command-node-sandbox",title:"Command: SANDBOX_GET_ERROR",properties:{command:"SANDBOX_GET_ERROR"},in:{result:[{id:p,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR>",port:"change"}],$note:"Set `result` as null if there is no error"}},[u]:{type:"command-node-sandbox",title:"Command: SANDBOX_GET_RETURN_VALUE",properties:{command:"SANDBOX_GET_RETURN_VALUE"},in:{result:[{id:p,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT> | null",port:"change"}]}},"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT>":{type:"data-node",properties:{},in:{change:[{id:u,port:"result"}]},out:{value:null},$note:"Put full result into data node"},"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>":{type:"command-node-object",title:"Command: OBJECT_GET",properties:{command:"OBJECT_GET",args:{path:"obj_key"}},in:{obj:[{id:u,port:"obj"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>",port:"change"}]},$note:"Parse result object into data node"},"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>":{type:"data-node",properties:{},in:{change:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>",port:"result"}]},out:{value:null},$note:"Put partial result into data node"}},editor_info:{},type:"script",script_config:{title:i,enable_async:!1,inputs:{"PROPERTY_BANK_DATA_NODE_<UUID>":"arg_name"},disabled_triggers:{},error:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR> | null",output:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | null",outputs:{obj_key:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>"},code:_,$note:"Required, info for GUI editor"}}}return T({id:o,example:n,extraInfo:a})};var tZ="2.25.0-beta.17";function t0(){return t1.apply(this,arguments)}function t1(){return(t1=v(function*(e={}){var i,t=e.token||process.env.BRICKS_API_TOKEN;if(!t)throw console.error("Error: API token is required"),console.error("Please provide a token via options or set BRICKS_API_TOKEN environment variable"),Error("API token is required");var n=function(e){try{var i=e.queryStringParameters?.token;if(!i){var t=new Headers(e.headers);i=t.get("authorization")?.replace("Bearer ","")}if(!i)return{success:!1,message:"Authentication failed: No token provided"};var n=function(e){try{var i=e.split(".");if(i.length<3)return null;var t=JSON.parse(Buffer.from(i[0],"base64url").toString());if(!D.includes(t?.alg))return null;return JSON.parse(Buffer.from(i[1],"base64url").toString())}catch{return null}}(i);if(!n)return{success:!1,message:"Authentication failed: Invalid token"};var a=A.includes(n.iss)?"user":"workspace";if("workspace"===a){var o=Array.isArray(n.t)?n.t:[];n.permissions=o.reduce((e,i)=>{var t=k[i];return t&&e.push(t),e},[])}else n.permissions=Object.keys(I);return{success:!0,token:i,tokenInfo:n,tokenType:a}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}({queryStringParameters:{token:t}});if(!n.success)throw console.error("Error: Invalid BRICKS_API_TOKEN"),console.error(n.message),Error("Invalid BRICKS_API_TOKEN");var a=new h._({name:tH,version:tZ}),o={...n,client:function(e,i,t){switch(t){case"user":return new iR(e,i);case"workspace":return new ti(e,i);default:throw Error(`Invalid token type: ${t}.`)}}(tJ.bricks,n.token,n.tokenType)};a.prompt("getting-started","Getting started with BRICKS",{},v(function*(){return{messages:[{role:"user",content:{type:"text",text:`Welcome to BRICKS — start here.
2472
+ `,tz=H(function e(i,t){J(this,e),this.baseUrl=i,this.token=t,this.graphqlUrl=`${i}/api/graphql`},[{key:"graphql",value:(o=v(function*(e,i){var t=yield(0,B.Ay)(this.graphqlUrl,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.token}`,Accept:"application/json"},body:JSON.stringify({query:e,variables:i})});if(!t.ok){var n=yield t.text().catch(()=>"");throw Error(`Activity-log query failed (${t.status}): ${n}`)}var a=yield t.json();if(a.errors?.length)throw Error(a.errors.map(e=>e.message).join("\n"));return a.data}),function(e,i){return o.apply(this,arguments)})},{key:"events",value:(r=v(function*(e,{limit:i,offset:t}={}){var n={...e};return null!=i&&(n.limit=i),null!=t&&(n.offset=t),(yield this.graphql(tG,{filter:n})).events}),function(e){return r.apply(this,arguments)})},{key:"screenshots",value:(s=v(function*(e){return(yield this.graphql(tL,{filter:e})).screenshots}),function(e){return s.apply(this,arguments)})},{key:"downloadScreenshot",value:(d=v(function*(e,i,t){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(i)}/screenshot?ts=${encodeURIComponent(t)}`,a=yield(0,B.Ay)(n,{headers:{Authorization:`Bearer ${this.token}`}});if(!a.ok){var o=yield a.text().catch(()=>"");throw Error(`Screenshot fetch failed (${a.status}): ${o}`)}return Buffer.from((yield a.arrayBuffer()))}),function(e,i,t){return d.apply(this,arguments)})}]);process.env.STAGE,process.env.URL_BASE;var tH="bricks-mcp",tJ={bricks:process.env.BRICKS_API_SERVER||"https://display-beta.bricks.tools",media:process.env.MEDIA_API_SERVER||"https://media-beta.bricks.tools",activityLog:process.env.ACTIVITY_LOG_API_SERVER||"https://activity-log-beta.bricks.tools"};process.env.AUTH0_DOMAIN,process.env.CACHE_URL;var tX=t(1639);let tQ=({type:e,title:i,template_key:t})=>{var n,a,o=(0,tX.M4)(e);switch(e){case"subspace":n={title:i,layout:{width:"number",height:"number"},root_canvas_id:"CANVAS_<UUID>",canvas_map:{},brick_map:{},animation_map:{},generator_map:{},property_bank_map:{},property_bank_calc_map:{}},a={"canvas_map.CANVAS_<UUID>.item_list":[{type:"subspace",subspace_id:"SUBSPACE_<UUID>",$note:"If not a root subspace, it can be linked to canvas in other subspace"}]};break;case"canvas":var r=V(j.Ji);n={title:i,item_list:[],property:{$definitions:Object.fromEntries(Object.entries(r.propTypes).map(([e,i])=>[e,{...i,description:r.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(r.eventTypes).map(([e])=>[e,{description:r.brickEventDescriptions[e]}]))}},a={property_bank_map:{[(0,tX.M4)("property_bank")]:{title:`Canvas ID: ${i}`,type:"string",value:o,routing:"read-only",kind:"auto-generated-item-id",idType:"canvas"}}};break;case"brick":var s=V(j.dK.Basic),d=V(j.brickMapping[t]);if(!d)throw Error(`Brick ${t} not found`);var c={...d,propTypes:{...s.propTypes,...d.propTypes},brickPropDescriptions:{...s.brickPropDescriptions,...d.brickPropDescriptions},eventTypes:{...s.eventTypes,...d.eventTypes},brickEventDescriptions:{...s.brickEventDescriptions,...d.brickEventDescriptions}};n={title:i,template_key:t,property:{$definitions:Object.fromEntries(Object.entries(c.propTypes).map(([e,i])=>[e,{...i,description:c.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(c.eventTypes).map(([e])=>[e,{description:c.brickEventDescriptions[e]}]))},outlet:{$definitions:Object.fromEntries(Object.entries(c.outletTypes).map(([e])=>[e,{description:c.brickOutletDescriptions[e]}]))},state_group:{"BRICK_STATE_GROUP_<UUID>":{}}},a={canvas_map:{"CANVAS_<UUID WHICH NEED DISPLAY THIS BRICK>":{item_list:[{type:"brick",brick_id:o,frame:{x:"number",y:"number",width:"number",height:"number",standby_mode:"custom|top|left|right|bottom",standby_delay:"number",standby_easing:{default:{method:"ease",duration:"number"}}}}]}}};break;case"state_group":n={title:i,description:"State Group Description",conds:[{type:"property_bank|inner_state",key:"PROPERTY_BANK#<Data Node ID>|[current_canvas|BRICK_<OUTLET NAME>]|",method:"==|!=|>|>=|<|<=",value:"value_to_compare"}],override:{property:!1,event:!1,outlet:!1},commented:!1,break:!1,property:{},outlet:{},animation:{}};case"generator":var l=V(j.generatorMapping[t]);if(!l)throw Error(`Generator ${t} not found`);n={title:i,template_key:t,property:{$definitions:Object.fromEntries(Object.entries(l.propTypes).map(([e,i])=>[e,{...i,description:l.brickPropDescriptions[e]}]))},event_map:{$definitions:Object.fromEntries(Object.entries(l.eventTypes).map(([e])=>[e,{description:l.brickEventDescriptions[e]}]))},outlet:{$definitions:Object.fromEntries(Object.entries(l.outletTypes).map(([e])=>[e,{description:l.brickOutletDescriptions[e]}]))}};break;case"animation":n={title:i,type:"timing|decay|spring",property:"opacity|transform.translateX|transform.scale|etc",config:{$note:"Config for the animation"},compose_type:"parallel|sequence",item_list:[{animation_id:"ANIMATION_<SUB ANIMATION UUID>"}]};break;case"property_bank":n={title:i,description:"Property Bank Description",linkedFrom:"SUBSPACE_<UUID WHICH IS CROSS SUBSPACE>",type:"string|number|bool|object|array|any",kind:"color|datetime|id|media-resource-*|lottie-file-uri",unit:"grid|px|ms",routing:"read-only|default",value:"fit-to-type",event_map:{$note:`Available events: ${Object.keys(j.qJ.eventTypes).join(", ")}`},local_sync:{update_mode:"all|main-only|minor-only|dont-sync"},$remote_update_additional:{$note:"Configure remote update behavior",enable_remote_update:!0,bank_type:"create|create-device-specific"}};break;case"property_bank_command":break;case"property_bank_calc":var p=(0,tX.M4)("property_bank_command"),u=(0,tX.M4)("property_bank_command"),m=(0,tX.M4)("property_bank_command"),_="const { arg_name } = inputs;\n\nreturn { arg_name };";n={title:i,map:{$note:"Required, actual implementation","PROPERTY_BANK_DATA_NODE_<UUID>":{type:"data-node",properties:{},in:{change:null},out:{value:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID>",port:"value"}]},$note:"Use this to input data to the sandbox"},"PROPERTY_BANK_COMMAND_NODE_<UUID FIRST>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:null,path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${p}`,port:"obj | inputs"}]}},"PROPERTY_BANK_COMMAND_NODE_<UUID SECOND>":{type:"command-node-object",title:"Command: OBJECT_SET",properties:{command:"OBJECT_SET",args:{path:"arg_name"}},in:{obj:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PREVIOUS>",port:"result"}],path:null,value:[{id:"PROPERTY_BANK_DATA_NODE_<UUID SECOND>",port:"value"}]},out:{result:[{id:`PROPERTY_BANK_COMMAND_NODE_<UUID NEXT> | ${p}`,port:"obj | inputs"}]}},[p]:{type:"command-node-sandbox",title:"Command: SANDBOX_RUN_JAVASCRIPT",properties:{command:"SANDBOX_RUN_JAVASCRIPT",args:{code:_,enable_async:!1}},in:{code:null,inputs:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID FINAL>",port:"result"}]},out:{result:[{id:m,port:"result"},{id:u,port:"result"}]}},[m]:{type:"command-node-sandbox",title:"Command: SANDBOX_GET_ERROR",properties:{command:"SANDBOX_GET_ERROR"},in:{result:[{id:p,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR>",port:"change"}],$note:"Set `result` as null if there is no error"}},[u]:{type:"command-node-sandbox",title:"Command: SANDBOX_GET_RETURN_VALUE",properties:{command:"SANDBOX_GET_RETURN_VALUE"},in:{result:[{id:p,port:"result"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT> | null",port:"change"}]}},"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT>":{type:"data-node",properties:{},in:{change:[{id:u,port:"result"}]},out:{value:null},$note:"Put full result into data node"},"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>":{type:"command-node-object",title:"Command: OBJECT_GET",properties:{command:"OBJECT_GET",args:{path:"obj_key"}},in:{obj:[{id:u,port:"obj"}]},out:{result:[{id:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>",port:"change"}]},$note:"Parse result object into data node"},"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>":{type:"data-node",properties:{},in:{change:[{id:"PROPERTY_BANK_COMMAND_NODE_<UUID PARSE RESULT>",port:"result"}]},out:{value:null},$note:"Put partial result into data node"}},editor_info:{},type:"script",script_config:{title:i,enable_async:!1,inputs:{"PROPERTY_BANK_DATA_NODE_<UUID>":"arg_name"},disabled_triggers:{},error:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE ERROR> | null",output:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE RESULT> | null",outputs:{obj_key:"PROPERTY_BANK_DATA_NODE_<UUID RECEIVE PARTIAL RESULT>"},code:_,$note:"Required, info for GUI editor"}}}return T({id:o,example:n,extraInfo:a})};var tZ="2.25.0-beta.19";function t0(){return t1.apply(this,arguments)}function t1(){return(t1=v(function*(e={}){var i,t=e.token||process.env.BRICKS_API_TOKEN;if(!t)throw console.error("Error: API token is required"),console.error("Please provide a token via options or set BRICKS_API_TOKEN environment variable"),Error("API token is required");var n=function(e){try{var i=e.queryStringParameters?.token;if(!i){var t=new Headers(e.headers);i=t.get("authorization")?.replace("Bearer ","")}if(!i)return{success:!1,message:"Authentication failed: No token provided"};var n=function(e){try{var i=e.split(".");if(i.length<3)return null;var t=JSON.parse(Buffer.from(i[0],"base64url").toString());if(!D.includes(t?.alg))return null;return JSON.parse(Buffer.from(i[1],"base64url").toString())}catch{return null}}(i);if(!n)return{success:!1,message:"Authentication failed: Invalid token"};var a=A.includes(n.iss)?"user":"workspace";if("workspace"===a){var o=Array.isArray(n.t)?n.t:[];n.permissions=o.reduce((e,i)=>{var t=k[i];return t&&e.push(t),e},[])}else n.permissions=Object.keys(I);return{success:!0,token:i,tokenInfo:n,tokenType:a}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}({queryStringParameters:{token:t}});if(!n.success)throw console.error("Error: Invalid BRICKS_API_TOKEN"),console.error(n.message),Error("Invalid BRICKS_API_TOKEN");var a=new h._({name:tH,version:tZ}),o={...n,client:function(e,i,t){switch(t){case"user":return new iR(e,i);case"workspace":return new ti(e,i);default:throw Error(`Invalid token type: ${t}.`)}}(tJ.bricks,n.token,n.tokenType)};a.prompt("getting-started","Getting started with BRICKS",{},v(function*(){return{messages:[{role:"user",content:{type:"text",text:`Welcome to BRICKS — start here.
2473
2473
 
2474
2474
  Before doing any complex work (application design, deployments, etc.),
2475
2475
  always consult the official docs rather than guessing.
package/lib/602.js CHANGED
@@ -1,3 +1,3 @@
1
- export const __rspack_esm_id=602;export const __rspack_esm_ids=[602];export const __webpack_modules__={65650(e,t,r){e.exports=r(78942).Symbol},65111(e){e.exports=function(e,t){for(var r=-1,i=null==e?0:e.length,o=Array(i);++r<i;)o[r]=t(e[r],r,e);return o}},44187(e){e.exports=function(e,t,r,i){var o=-1,n=null==e?0:e.length;for(i&&n&&(r=e[++o]);++o<n;)r=t(r,e[o],o,e);return r}},39546(e){var t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;e.exports=function(e){return e.match(t)||[]}},87379(e,t,r){var i=r(65650),o=r(8870),n=r(29005),u=i?i.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":u&&u in Object(e)?o(e):n(e)}},51035(e){e.exports=function(e){return function(t){return null==e?void 0:e[t]}}},52291(e,t,r){var i=r(65650),o=r(65111),n=r(53142),u=r(51187),a=1/0,c=i?i.prototype:void 0,l=c?c.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(n(t))return o(t,e)+"";if(u(t))return l?l.call(t):"";var r=t+"";return"0"==r&&1/t==-a?"-0":r}},93640(e,t,r){var i=r(44187),o=r(45881),n=r(39850),u=RegExp("['’]","g");e.exports=function(e){return function(t){return i(n(o(t).replace(u,"")),e,"")}}},69968(e,t,r){e.exports=r(51035)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"})},74967(e){e.exports="object"==typeof global&&global&&global.Object===Object&&global},8870(e,t,r){var i=r(65650),o=Object.prototype,n=o.hasOwnProperty,u=o.toString,a=i?i.toStringTag:void 0;e.exports=function(e){var t=n.call(e,a),r=e[a];try{e[a]=void 0;var i=!0}catch(e){}var o=u.call(e);return i&&(t?e[a]=r:delete e[a]),o}},15813(e){var t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;e.exports=function(e){return t.test(e)}},29005(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},78942(e,t,r){var i=r(74967),o="object"==typeof self&&self&&self.Object===Object&&self;e.exports=i||o||Function("return this")()},10482(e){var t="\\ud800-\\udfff",r="\\u2700-\\u27bf",i="a-z\\xdf-\\xf6\\xf8-\\xff",o="A-Z\\xc0-\\xd6\\xd8-\\xde",n="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",u="['’]",a="["+n+"]",c="["+i+"]",l="[^"+t+n+"\\d+"+r+i+o+"]",s="(?:\\ud83c[\\udde6-\\uddff]){2}",d="[\\ud800-\\udbff][\\udc00-\\udfff]",f="["+o+"]",p="(?:"+c+"|"+l+")",g="(?:"+f+"|"+l+")",y="(?:"+u+"(?:d|ll|m|re|s|t|ve))?",x="(?:"+u+"(?:D|LL|M|RE|S|T|VE))?",m="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",h="[\\ufe0e\\ufe0f]?",v="(?:\\u200d(?:"+["[^"+t+"]",s,d].join("|")+")"+h+m+")*",b="(?:"+["["+r+"]",s,d].join("|")+")"+(h+m+v),A=RegExp([f+"?"+c+"+"+y+"(?="+[a,f,"$"].join("|")+")",g+"+"+x+"(?="+[a,f+p,"$"].join("|")+")",f+"?"+p+"+"+y,f+"+"+x,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])|\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])|\\d+",b].join("|"),"g");e.exports=function(e){return e.match(A)||[]}},45881(e,t,r){var i=r(69968),o=r(95243),n=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,u=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");e.exports=function(e){return(e=o(e))&&e.replace(n,i).replace(u,"")}},53142(e){e.exports=Array.isArray},80547(e){e.exports=function(e){return null!=e&&"object"==typeof e}},51187(e,t,r){var i=r(87379),o=r(80547);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==i(e)}},10750(e,t,r){e.exports=r(93640)(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})},95243(e,t,r){var i=r(52291);e.exports=function(e){return null==e?"":i(e)}},39850(e,t,r){var i=r(39546),o=r(15813),n=r(95243),u=r(10482);e.exports=function(e,t,r){return(e=n(e),void 0===(t=r?void 0:t))?o(e)?u(e):i(e):e.match(t)||[]}},6553(e,t,r){r.r(t),r.d(t,{initProject:()=>A});var i,o,n,u,a=r(99436),c=r(16928),l=r(73284),s=r(30155),d=r(10750),f=r(88958),p=r(56493),g=r(79896),y=r(35317),x=e=>{try{return(0,y.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},m=(e,t,r)=>new Promise((i,o)=>{var n=[e,...t].join(" "),u=(0,y.spawn)(n,[],{cwd:r,stdio:"pipe",shell:!0}),a=[];u.stderr.on("data",e=>a.push(e)),u.on("close",e=>{0===e?i():o(Error(Buffer.concat(a).toString().trim()||`Command failed with code ${e}`))}),u.on("error",o)}),h=(i=a(function*(e,t){try{var i=(yield r.e(456).then(r.bind(r,79491))).format;return(yield i(t,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,t){return i.apply(this,arguments)}),v=(o=a(function*(e,t,r){var i,o=r.client,n=r.output,u=r.outputAsTarget;if(!o)throw Error("client is required");if(!n)throw Error("output directory is required");var l=(e=>{for(var t=c.resolve(e);;){if(g.existsSync(c.join(t,"application.json"))||g.existsSync(c.join(t,"module.json")))return t;var r=c.dirname(t);if(r===t)return null;t=r}})(u?c.dirname(c.resolve(n)):n);if(l)throw Error(`Cannot initialize a new BRICKS project inside an existing project (${l}). Choose a directory outside the project.`);var s="application"===e,f=s?o.queries.applicationProject:o.queries.moduleProject,p=(yield o.query(f,{id:t,buildApplicationOnly:!1,setupGitHubActions:!1!==r.githubActions,setupAgents:!1!==r.agents,setupClaudeCode:!1!==r.claude,setupGeminiCLI:!0===r.gemini}))[s?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject"];if(!p?.files)throw Error(`${e} project not found`);var y="bricks-ctor",v=p.files.find(e=>"application.json"===e.name);if(v)try{var b=JSON.parse(v.input);y=d(b.name||"bricks-ctor")}catch{}var A=u?c.resolve(n):c.resolve(n,y);if(g.existsSync(A))throw Error(`Directory already exists: ${A}`);g.mkdirSync(A,{recursive:!0}),(yield Promise.all(p.files.map((i=a(function*(e){var t=c.join(A,e.name),r=e.input;return e.formatable&&(r=yield h(r,t)),{...e,filePath:t,content:r}}),function(e){return i.apply(this,arguments)})))).forEach(e=>{var t=c.dirname(e.filePath);g.existsSync(t)||g.mkdirSync(t,{recursive:!0}),g.writeFileSync(e.filePath,e.content)});var j=x("bun"),S=x("git"),E=!1,O=!1;if(!1!==r.install&&j)try{yield m("bun",["install"],A),E=!0}catch{}if(!1!==r.git&&S)try{yield m("git",["init"],A),yield m("git",["add","."],A),yield m("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],A),O=!0}catch{}return{success:!0,path:A,files:p.files.length,bunInstalled:E,gitInitialized:O}}),function(e,t,r){return o.apply(this,arguments)}),b=(n=a(function*(e,t){console.log(l.Ay.bold.cyan(`
1
+ export const __rspack_esm_id=602;export const __rspack_esm_ids=[602];export const __webpack_modules__={65650(e,t,r){e.exports=r(78942).Symbol},65111(e){e.exports=function(e,t){for(var r=-1,i=null==e?0:e.length,o=Array(i);++r<i;)o[r]=t(e[r],r,e);return o}},44187(e){e.exports=function(e,t,r,i){var o=-1,n=null==e?0:e.length;for(i&&n&&(r=e[++o]);++o<n;)r=t(r,e[o],o,e);return r}},39546(e){var t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;e.exports=function(e){return e.match(t)||[]}},87379(e,t,r){var i=r(65650),o=r(8870),n=r(29005),u=i?i.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":u&&u in Object(e)?o(e):n(e)}},51035(e){e.exports=function(e){return function(t){return null==e?void 0:e[t]}}},52291(e,t,r){var i=r(65650),o=r(65111),n=r(53142),u=r(51187),a=1/0,c=i?i.prototype:void 0,l=c?c.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(n(t))return o(t,e)+"";if(u(t))return l?l.call(t):"";var r=t+"";return"0"==r&&1/t==-a?"-0":r}},93640(e,t,r){var i=r(44187),o=r(45881),n=r(39850),u=RegExp("['’]","g");e.exports=function(e){return function(t){return i(n(o(t).replace(u,"")),e,"")}}},69968(e,t,r){e.exports=r(51035)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"})},74967(e){e.exports="object"==typeof global&&global&&global.Object===Object&&global},8870(e,t,r){var i=r(65650),o=Object.prototype,n=o.hasOwnProperty,u=o.toString,a=i?i.toStringTag:void 0;e.exports=function(e){var t=n.call(e,a),r=e[a];try{e[a]=void 0;var i=!0}catch(e){}var o=u.call(e);return i&&(t?e[a]=r:delete e[a]),o}},15813(e){var t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;e.exports=function(e){return t.test(e)}},29005(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},78942(e,t,r){var i=r(74967),o="object"==typeof self&&self&&self.Object===Object&&self;e.exports=i||o||Function("return this")()},10482(e){var t="\\ud800-\\udfff",r="\\u2700-\\u27bf",i="a-z\\xdf-\\xf6\\xf8-\\xff",o="A-Z\\xc0-\\xd6\\xd8-\\xde",n="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",u="['’]",a="["+n+"]",c="["+i+"]",l="[^"+t+n+"\\d+"+r+i+o+"]",s="(?:\\ud83c[\\udde6-\\uddff]){2}",d="[\\ud800-\\udbff][\\udc00-\\udfff]",f="["+o+"]",p="(?:"+c+"|"+l+")",g="(?:"+f+"|"+l+")",y="(?:"+u+"(?:d|ll|m|re|s|t|ve))?",x="(?:"+u+"(?:D|LL|M|RE|S|T|VE))?",m="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",h="[\\ufe0e\\ufe0f]?",v="(?:\\u200d(?:"+["[^"+t+"]",s,d].join("|")+")"+h+m+")*",b="(?:"+["["+r+"]",s,d].join("|")+")"+(h+m+v),j=RegExp([f+"?"+c+"+"+y+"(?="+[a,f,"$"].join("|")+")",g+"+"+x+"(?="+[a,f+p,"$"].join("|")+")",f+"?"+p+"+"+y,f+"+"+x,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])|\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])|\\d+",b].join("|"),"g");e.exports=function(e){return e.match(j)||[]}},45881(e,t,r){var i=r(69968),o=r(95243),n=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,u=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");e.exports=function(e){return(e=o(e))&&e.replace(n,i).replace(u,"")}},53142(e){e.exports=Array.isArray},80547(e){e.exports=function(e){return null!=e&&"object"==typeof e}},51187(e,t,r){var i=r(87379),o=r(80547);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==i(e)}},10750(e,t,r){e.exports=r(93640)(function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})},95243(e,t,r){var i=r(52291);e.exports=function(e){return null==e?"":i(e)}},39850(e,t,r){var i=r(39546),o=r(15813),n=r(95243),u=r(10482);e.exports=function(e,t,r){return(e=n(e),void 0===(t=r?void 0:t))?o(e)?u(e):i(e):e.match(t)||[]}},6553(e,t,r){r.r(t),r.d(t,{initProject:()=>j});var i,o,n,u,a=r(99436),c=r(16928),l=r(73284),s=r(30155),d=r(10750),f=r(88958),p=r(56493),g=r(79896),y=r(35317),x=e=>{try{return(0,y.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},m=(e,t,r)=>new Promise((i,o)=>{var n=[e,...t].join(" "),u=(0,y.spawn)(n,[],{cwd:r,stdio:"pipe",shell:!0}),a=[];u.stderr.on("data",e=>a.push(e)),u.on("close",e=>{0===e?i():o(Error(Buffer.concat(a).toString().trim()||`Command failed with code ${e}`))}),u.on("error",o)}),h=(i=a(function*(e,t){try{var i=(yield r.e(456).then(r.bind(r,79491))).format;return(yield i(t,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,t){return i.apply(this,arguments)}),v=(o=a(function*(e,t,r){var i,o=r.client,n=r.output,u=r.outputAsTarget;if(!o)throw Error("client is required");if(!n)throw Error("output directory is required");var l=(e=>{for(var t=c.resolve(e);;){if(g.existsSync(c.join(t,"application.json"))||g.existsSync(c.join(t,"module.json")))return t;var r=c.dirname(t);if(r===t)return null;t=r}})(u?c.dirname(c.resolve(n)):n);if(l)throw Error(`Cannot initialize a new BRICKS project inside an existing project (${l}). Choose a directory outside the project.`);var s="application"===e,f=s?o.queries.applicationProject:o.queries.moduleProject,p=(yield o.query(f,{id:t,buildApplicationOnly:!1,setupGitHubActions:!1!==r.githubActions,setupAgents:!1!==r.agents,setupClaudeCode:!1!==r.claude,setupGeminiCLI:!0===r.gemini}))[s?"applicationProject":"moduleProject"];if(!p?.files)throw Error(`${e} project not found`);var y="bricks-ctor",v=p.files.find(e=>"application.json"===e.name);if(v)try{var b=JSON.parse(v.input);y=d(b.name||"bricks-ctor")}catch{}var j=u?c.resolve(n):c.resolve(n,y);if(g.existsSync(j))throw Error(`Directory already exists: ${j}`);g.mkdirSync(j,{recursive:!0}),(yield Promise.all(p.files.map((i=a(function*(e){var t=c.join(j,e.name),r=e.input;return e.formatable&&(r=yield h(r,t)),{...e,filePath:t,content:r}}),function(e){return i.apply(this,arguments)})))).forEach(e=>{var t=c.dirname(e.filePath);g.existsSync(t)||g.mkdirSync(t,{recursive:!0}),g.writeFileSync(e.filePath,e.content)});var A=x("bun"),S=x("git"),E=!1,O=!1;if(!1!==r.install&&A)try{yield m("bun",["install"],j),E=!0}catch{}if(!1!==r.git&&S)try{yield m("git",["init"],j),yield m("git",["add","."],j),yield m("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],j),O=!0}catch{}return{success:!0,path:j,files:p.files.length,bunInstalled:E,gitInitialized:O}}),function(e,t,r){return o.apply(this,arguments)}),b=(n=a(function*(e,t){console.log(l.Ay.bold.cyan(`
2
2
  Initialize BRICKS Project: ${t}
3
- `));var r=yield(0,f.kv)({message:"Select files to include:",choices:[{name:"GitHub Actions workflow (.github/workflows/ci.yml)",value:"githubActions",checked:!1!==e.githubActions},{name:"AGENTS.md",value:"agents",checked:!1!==e.agents},{name:"CLAUDE.md",value:"claude",checked:!1!==e.claude},{name:"GEMINI.md",value:"gemini",checked:!0===e.gemini}]}),i=yield(0,f.kv)({message:"Select post-generation steps:",choices:[{name:"Run bun install",value:"install",checked:!1!==e.install},{name:"Initialize git repository",value:"git",checked:!1!==e.git}]}),o=e.output?c.resolve(e.output):c.join(process.cwd(),t),n=yield(0,f.hF)({message:"Output directory:",default:o});return{githubActions:r.includes("githubActions"),agents:r.includes("agents"),claude:r.includes("claude"),gemini:r.includes("gemini"),install:i.includes("install"),git:i.includes("git"),output:n,outputAsTarget:!0}}),function(e,t){return n.apply(this,arguments)}),A=(u=a(function*(e,t,r){var i=(0,p.o)(),o=r.json,n=r.yes||o,u="application"===e,a=u?i.queries.applicationProject:i.queries.moduleProject,f=o?null:(0,s.default)(`Fetching ${e} info...`).start(),g="bricks-ctor";try{var y=(yield i.query(a,{id:t,buildApplicationOnly:!0}))[u?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject"];if(y?.files){var x=y.files.find(e=>"application.json"===e.name);if(x)try{var m=JSON.parse(x.input);g=d(m.name||"bricks-ctor")}catch{}}f&&f.stop()}catch{f&&f.stop()}var h={...r};if(!n)try{var A=yield b(r,g);h={...r,...A}}catch{console.log(l.Ay.yellow("\nCancelled")),process.exit(0)}f=o?null:(0,s.default)(`Fetching ${e} project...`).start();var j=!!h.output;try{var S=yield v(e,t,{client:i,output:j?h.output:process.cwd(),outputAsTarget:j||!0===h.outputAsTarget,install:h.install,git:h.git,githubActions:h.githubActions,agents:h.agents,claude:h.claude,gemini:h.gemini});f&&f.succeed(`Project created: ${l.Ay.green(S.path)} (${S.files} files)`),o?console.log(JSON.stringify(S)):(console.log(""),console.log(l.Ay.bold.green("Project initialized successfully!")),console.log(""),console.log(l.Ay.bold("Next steps:")),console.log(l.Ay.gray(` cd ${c.basename(S.path)}`)),S.bunInstalled||console.log(l.Ay.gray(" bun install")),console.log(l.Ay.gray(" bun preview")),console.log(""),console.log(l.Ay.gray(`For more information, see ${c.basename(S.path)}/README.md`)))}catch(t){o?console.error(JSON.stringify({error:t.message})):f?f.fail(`Failed to initialize ${e} project: ${t.message}`):console.error(l.Ay.red(`Failed to initialize ${e} project: ${t.message}`)),process.exit(1)}}),function(e,t,r){return u.apply(this,arguments)})}};
3
+ `));var r=yield(0,f.kv)({message:"Select files to include:",choices:[{name:"GitHub Actions workflow (.github/workflows/ci.yml)",value:"githubActions",checked:!1!==e.githubActions},{name:"AGENTS.md",value:"agents",checked:!1!==e.agents},{name:"CLAUDE.md",value:"claude",checked:!1!==e.claude},{name:"GEMINI.md",value:"gemini",checked:!0===e.gemini}]}),i=yield(0,f.kv)({message:"Select post-generation steps:",choices:[{name:"Run bun install",value:"install",checked:!1!==e.install},{name:"Initialize git repository",value:"git",checked:!1!==e.git}]}),o=e.output?c.resolve(e.output):c.join(process.cwd(),t),n=yield(0,f.hF)({message:"Output directory:",default:o});return{githubActions:r.includes("githubActions"),agents:r.includes("agents"),claude:r.includes("claude"),gemini:r.includes("gemini"),install:i.includes("install"),git:i.includes("git"),output:n,outputAsTarget:!0}}),function(e,t){return n.apply(this,arguments)}),j=(u=a(function*(e,t,r){var i=(0,p.o)(),o=r.json,n=r.yes||o,u="application"===e,a=u?i.queries.applicationProject:i.queries.moduleProject,f=o?null:(0,s.default)(`Fetching ${e} info...`).start(),g="bricks-ctor";try{var y=(yield i.query(a,{id:t,buildApplicationOnly:!0}))[u?"applicationProject":"moduleProject"];if(y?.files){var x=y.files.find(e=>"application.json"===e.name);if(x)try{var m=JSON.parse(x.input);g=d(m.name||"bricks-ctor")}catch{}}f&&f.stop()}catch{f&&f.stop()}var h={...r};if(!n)try{var j=yield b(r,g);h={...r,...j}}catch{console.log(l.Ay.yellow("\nCancelled")),process.exit(0)}f=o?null:(0,s.default)(`Fetching ${e} project...`).start();var A=!!h.output;try{var S=yield v(e,t,{client:i,output:A?h.output:process.cwd(),outputAsTarget:A||!0===h.outputAsTarget,install:h.install,git:h.git,githubActions:h.githubActions,agents:h.agents,claude:h.claude,gemini:h.gemini});f&&f.succeed(`Project created: ${l.Ay.green(S.path)} (${S.files} files)`),o?console.log(JSON.stringify(S)):(console.log(""),console.log(l.Ay.bold.green("Project initialized successfully!")),console.log(""),console.log(l.Ay.bold("Next steps:")),console.log(l.Ay.gray(` cd ${c.basename(S.path)}`)),S.bunInstalled||console.log(l.Ay.gray(" bun install")),console.log(l.Ay.gray(" bun preview")),console.log(""),console.log(l.Ay.gray(`For more information, see ${c.basename(S.path)}/README.md`)))}catch(t){o?console.error(JSON.stringify({error:t.message})):f?f.fail(`Failed to initialize ${e} project: ${t.message}`):console.error(l.Ay.red(`Failed to initialize ${e} project: ${t.message}`)),process.exit(1)}}),function(e,t,r){return u.apply(this,arguments)})}};
package/lib/940.js CHANGED
@@ -1 +1 @@
1
- import*as e from"ink";import*as l from"react";import{Fragment as r,jsx as t,jsxs as n}from"react/jsx-runtime";export const __rspack_esm_id=940;export const __rspack_esm_ids=[940];export const __webpack_modules__={8498(l){l.exports=e},51649(e){e.exports=l},92319(e,l,i){i.r(l),i.d(l,{AppList:()=>O,CONTROL_ACTIONS:()=>T,MainMenu:()=>I,Header:()=>y,ModuleDetail:()=>R,ONLINE_THRESHOLD_MS:()=>p,ShortEditEditor:()=>q,MediaFileList:()=>F,App:()=>es,DeviceDetail:()=>L,VIEWS:()=>m,runInteractiveMode:()=>ex,DeviceList:()=>C,MediaBoxList:()=>$,Loading:()=>D,DeviceControl:()=>k,ProjectInitView:()=>eu,GroupDetail:()=>G,ModuleList:()=>P,MediaBoxDetail:()=>V,GroupList:()=>N,Footer:()=>b,DeviceStatus:()=>E,AppDetail:()=>M,DeviceScreenshot:()=>w,MediaFileDetail:()=>j});var o,a,c=i(99436),d=i(51649),u=i(8498),s=i(68832),h=i(85382),x=i(23258),g=i(60450),m={MAIN:"main",DEVICES:"devices",DEVICE_DETAIL:"device_detail",DEVICE_CONTROL:"device_control",DEVICE_SCREENSHOT:"device_screenshot",APPS:"apps",APP_DETAIL:"app_detail",APP_SHORT_EDIT:"app_short_edit",APP_PROJECT_INIT:"app_project_init",MODULES:"modules",MODULE_DETAIL:"module_detail",MODULE_SHORT_EDIT:"module_short_edit",MODULE_PROJECT_INIT:"module_project_init",GROUPS:"groups",GROUP_DETAIL:"group_detail",MEDIA_BOXES:"media_boxes",MEDIA_BOX_DETAIL:"media_box_detail",MEDIA_FILES:"media_files",MEDIA_FILE_DETAIL:"media_file_detail",ACTIVITY_LOG:"activity_log"},T=[{label:"Refresh Application",value:"refresh"},{label:"Clear Cache",value:"clear-cache"},{label:"Take Screenshot",value:"take-screenshot"},{label:"Open System Menu",value:"system-menu-open"},{label:"Close System Menu",value:"system-menu-close"},{label:"Open Debug Panel",value:"debug-panel-open"},{label:"Close Debug Panel",value:"debug-panel-close"},{label:"Enable Logging",value:"logging-on"},{label:"Disable Logging",value:"logging-off"},{label:"← Back",value:"back"}],p=3e5,f=i(47882),v=(e,l=!0)=>{var r=Math.floor(60),t=s((0,d.useState)(r),2),n=t[0],i=t[1],o=s((0,d.useState)(null),2),a=o[0],c=o[1],u=(0,d.useRef)(e);(0,d.useEffect)(()=>{u.current=e},[e]);var h=(0,d.useCallback)(()=>{i(r),c(Date.now())},[r]);return(0,d.useEffect)(()=>{if(l){var e=setInterval(()=>{i(e=>e<=1?(u.current?.(),c(Date.now()),r):e-1)},1e3);return()=>clearInterval(e)}},[l,r]),(0,d.useEffect)(()=>{l&&(i(r),c(Date.now()))},[l,r]),{countdown:n,lastRefreshTime:a,resetCountdown:h}},_=({countdown:e,lastRefreshTime:l})=>t(u.Box,{children:n(u.Text,{color:"gray",children:["Next refresh in ",n(u.Text,{color:"cyan",children:[e,"s"]}),l&&n(u.Text,{color:"gray",children:[" (last: ",l?new Date(l).toLocaleTimeString():null,")"]})]})}),y=({workspace:e,view:l})=>n(u.Box,{flexDirection:"column",marginBottom:1,children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),t(u.Text,{color:"gray",children:" - Interactive Mode"})]}),n(u.Box,{children:[t(u.Text,{color:"gray",children:"Workspace: "}),t(u.Text,{color:"green",children:e?.name||"Not connected"}),t(u.Text,{color:"gray",children:" | View: "}),t(u.Text,{color:"yellow",children:l})]}),t(u.Text,{color:"gray",children:"─".repeat(60)})]}),b=()=>n(u.Box,{marginTop:1,flexDirection:"column",children:[t(u.Text,{color:"gray",children:"─".repeat(60)}),n(u.Text,{color:"gray",children:["Press ",t(u.Text,{color:"cyan",children:"q"})," to quit, ",t(u.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),D=({text:e})=>n(u.Box,{children:[t(u.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(u.Text,{children:[" ",e||"Loading..."]})]}),E=({lastAliveTime:e})=>{if(!e)return t(u.Text,{color:"gray",children:"○ Unknown"});var l=Date.now()-new Date(e).getTime();if(l<=p)return t(u.Text,{color:"green",children:"● Online"});var r=Math.floor(l/6e4);if(r<60)return n(u.Text,{color:"yellow",children:["○ Offline (",r,"m ago)"]});var i=Math.floor(r/60);if(i<24)return n(u.Text,{color:"red",children:["○ Offline (",i,"h ago)"]});var o=Math.floor(i/24);return n(u.Text,{color:"red",children:["○ Offline (",o,"d ago)"]})},S=i(48724),I=({onSelect:e,mediaEnabled:l,activityLogEnabled:r})=>{var i=[{label:"Devices",value:m.DEVICES},{label:"Applications",value:m.APPS},{label:"Modules",value:m.MODULES},{label:"Device Groups",value:m.GROUPS},...l?[{label:"Media Flow",value:m.MEDIA_BOXES}]:[],...r?[{label:"Activity Log",value:m.ACTIVITY_LOG}]:[],{label:"Exit",value:"exit"}];return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),t(S.Ay,{items:i,onSelect:e})]})},A="1"===process.env.BRICKS_CLI_DISTRIBUTION,B=e=>{var l=s((0,d.useState)(null),2),r=l[0],n=l[1];return((0,d.useEffect)(()=>{if(!A){var e=!0;return i.e(166).then(i.bind(i,29557)).then(l=>{e&&n(()=>l.default)}).catch(()=>{e&&n(!1)}),()=>{e=!1}}},[]),A||!1===r)?t(u.Text,{color:"gray",children:"Image preview is not available in this CLI build."}):r?t(r,{...e}):t(D,{text:"Preparing image preview..."})},C=({devices:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(D,{text:"Loading devices..."});if(!e?.length)return n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"yellow",children:"No devices found"}),t(_,{countdown:i,lastRefreshTime:o})]});var a=[...e.map(e=>{var l=(e=>{if(!e)return"○ Unknown";var l=Date.now()-new Date(e).getTime();if(l<=p)return"● Online";var r=Math.floor(l/6e4);if(r<60)return`○ ${r}m ago`;var t=Math.floor(r/60);if(t<24)return`○ ${t}h ago`;var n=Math.floor(t/24);return`○ ${n}d ago`})(e.entry_detail?.watch_dog_timer?.last_alive_time);return{label:`${l} - ${e.name||e.device_name}`,value:e._id,device:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Box,{marginBottom:1,children:[n(u.Text,{bold:!0,children:["Devices (",e.length,")"]}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:i,lastRefreshTime:o})]}),t(S.Ay,{items:a,onSelect:r})]})},L=({device:e,loading:l,error:r,onSelect:i,mediaEnabled:o,countdown:a,lastRefreshTime:c})=>{if(l)return t(D,{text:"Loading device..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Device not found"});var d=[{label:"Control Device",value:"control"},...o?[{label:"View Screenshot",value:"screenshot"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],s=e.entry_detail,h=s?.screen,x=s?.update,g=s?.local_sync;return n(u.Box,{flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:a,lastRefreshTime:c})]}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{color:"gray",children:"Status: "}),t(E,{lastAliveTime:s?.watch_dog_timer?.last_alive_time})]}),n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),s?.application&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Application"}),n(u.Text,{color:"gray",children:[" Name: ",s.application.name]}),n(u.Text,{color:"gray",children:[" Mode: ",s.operation_mode||"N/A"]})]}),h&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Screen"}),h.resolution&&n(u.Text,{color:"gray",children:[" ","Resolution: ",h.resolution.width,"x",h.resolution.height,h.resolution.scale&&` @${h.resolution.scale}x`]}),h.orientation&&n(u.Text,{color:"gray",children:[" Orientation: ",h.orientation]}),h.touch&&n(u.Text,{color:"gray",children:[" ","Touch:"," ",h.touch.available?`Yes (${h.touch.touch_point} points)`:"No"]})]}),(s?.memory_usage||s?.disk_usage)&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"System"}),s.memory_usage&&n(u.Text,{color:"gray",children:[" Memory: ",Math.round(100*s.memory_usage),"%"]}),s.disk_usage&&n(u.Text,{color:"gray",children:[" Disk: ",Math.round(100*s.disk_usage),"%"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Capabilities"}),n(u.Text,{color:"gray",children:[" ","Sound: ",s?.sound?.available?"✓":"✗"," | ","Camera: ",s?.camera?.available?"✓":"✗"," | ","Audio In: ",s?.audio_in?.available?"✓":"✗"]})]}),g&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Local Sync"}),n(u.Text,{color:"gray",children:[" ","Role: ",g.is_main?"Main":"Peer",g.peer_count>0&&` | Peers: ${g.peer_count}`,g.mean_latency&&` | Latency: ${g.mean_latency}ms`]})]}),x&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Update"}),n(u.Text,{color:x.need_update?"yellow":"gray",children:[" ","Status: ",x.need_update?"⚠ Update available":"✓ Up to date"]}),x.current_version&&n(u.Text,{color:"gray",children:[" Version: ",x.current_version]})]})]}),t(S.Ay,{items:d,onSelect:i})]})},k=({device:e,onSelect:l,controlling:r,controlResult:i})=>n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),r&&t(D,{text:"Sending command..."}),i&&t(u.Text,{color:i.success?"green":"red",children:i.message}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:T,onSelect:l})})]}),w=({device:e,screenshot:l,loading:r,error:i,onSelect:o})=>{var a=l?.file?.meta,c=a?.originalWidth!=null&&a?.originalHeight!=null,d=a?.originalFileSize!=null;return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),r&&t(D,{text:"Loading screenshot..."}),i&&t(u.Box,{marginY:1,children:t(u.Text,{color:"red",children:String(i)})}),!r&&!i&&l&&n(u.Box,{flexDirection:"column",children:[t(u.Box,{height:30,children:t(B,{src:l.path,width:80,alt:"Device screenshot"})}),n(u.Box,{marginY:1,flexDirection:"column",children:[t(u.Text,{bold:!0,color:"white",children:"Screenshot Details"}),n(u.Box,{marginY:1,children:[t(u.Text,{color:"green",children:"Screenshot saved to: "}),t(u.Text,{color:"cyan",children:String(l.path||"")})]}),c&&n(u.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),d&&n(u.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),l.file?.updatedAt&&n(u.Text,{color:"gray",children:["Updated: ",new Date(l.file.updatedAt).toLocaleString()]})]})]}),!r&&!i&&!l&&t(u.Box,{marginY:1,children:t(u.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})})]})},O=({apps:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading applications..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No applications found"});var i=[...e.map(e=>({label:`${e.has_unreleased_changes?"●":"○"} ${e.name}`,value:e._id,app:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),t(S.Ay,{items:i,onSelect:r})]})},M=({app:e,loading:l,error:r,onSelect:i})=>{if(l)return t(D,{text:"Loading application..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Application not found"});var o=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],a=e.devices?.length||0,c=e.devices?.filter(e=>"online"===e.status)?.length||0;return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Version"}),n(u.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(u.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]}),e.current_version_details&&n(u.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Devices"}),n(u.Text,{color:"gray",children:[" ","Total: ",a,a>0&&` (${c} online)`]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Features"}),n(u.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"\uD83D\uDD12 Locked":"\uD83D\uDD13 Unlocked"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:o,onSelect:i})]})},P=({modules:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading modules..."});var i=[...(e||[]).map(e=>({label:`${e.current_version?"●":"○"} ${e.name}`,value:e._id,module:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&t(u.Text,{color:"yellow",children:"No modules found"}),t(S.Ay,{items:i,onSelect:r})]})},R=({module:e,loading:l,error:r,onSelect:i})=>{if(l)return t(D,{text:"Loading module..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Module not found"});var o=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Version"}),n(u.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(u.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Usage"}),n(u.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Settings"}),n(u.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),n(u.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),n(u.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Exposed Properties"}),n(u.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:o,onSelect:i})]})},N=({groups:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(D,{text:"Loading device groups..."});var a=[...(e||[]).map(e=>({label:`📁 ${e.name} (${e.devices?.length||0} devices)`,value:e._id,group:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Box,{marginBottom:1,children:[n(u.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:i,lastRefreshTime:o})]}),!e?.length&&t(u.Text,{color:"yellow",children:"No device groups found"}),t(S.Ay,{items:a,onSelect:r})]})},U=({loading:e,groupDevices:l})=>e?t(D,{text:"Loading devices..."}):l?.length?n(r,{children:[l.slice(0,10).map(e=>n(u.Box,{children:[t(u.Text,{color:"gray",children:" "}),t(E,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),n(u.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),l.length>10&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","... and ",l.length-10," more"]})]}):t(u.Text,{color:"gray",children:" No devices in this group"}),G=({group:e,groupDevices:l,loading:r,error:i,onSelect:o,countdown:a,lastRefreshTime:c})=>r&&!e?t(D,{text:"Loading device group..."}):i?n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",i]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):e?n(u.Box,{flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:a,lastRefreshTime:c})]}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[n(u.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),t(U,{loading:r,groupDevices:l})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})]}):t(u.Text,{color:"red",children:"Device group not found"}),$=({boxes:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading media boxes..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No media boxes found"});var i=[...e.map(e=>({label:`📦 ${e.name||"Unnamed"}`,value:e.id,box:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),t(S.Ay,{items:i,onSelect:r})]})},V=({box:e,loading:l,error:r,onSelect:i})=>l&&!e?t(D,{text:"Loading media box..."}):r?n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]}):e?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&n(u.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&n(u.Box,{flexDirection:"column",marginTop:1,children:[n(u.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>n(u.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(u.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]}):t(u.Text,{color:"red",children:"Media box not found"}),F=({files:e,loading:l,onSelect:r,box:i})=>{if(l)return t(D,{text:"Loading media files..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No media files found"});var o=[...e.map(e=>{var l;return{label:`${"Image"===(l=e.fileType)?"\uD83D\uDDBC":"Video"===l?"\uD83C\uDF9E":"Audio"===l?"\uD83C\uDFB5":"\uD83D\uDCC4"} ${e.name||"Unnamed"}`,value:e.id,file:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",i?.name?` - ${i.name}`:""]}),t(S.Ay,{items:o,onSelect:r})]})},j=({file:e,loading:l,error:r,onSelect:i})=>{if(l&&!e)return t(D,{text:"Loading media file..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Media file not found"});var o=e.meta,a=(0,g.Gu)(e),c=(0,g.Gu)(e,{preferThumbnail:!0}),d=!!(c&&c!==a);return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e.id]}),n(u.Text,{color:"gray",children:["Box ID: ",e.boxId]}),n(u.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),o?.originalWidth!=null&&o?.originalHeight!=null&&n(u.Text,{color:"gray",children:["Size: ",o.originalWidth,"x",o.originalHeight]}),o?.originalFileSize!=null&&n(u.Text,{color:"gray",children:["File: ",(Number(o.originalFileSize)/1024).toFixed(1)," KB"]}),a&&n(u.Text,{color:"gray",children:["Original URL: ",a]}),d&&n(u.Text,{color:"gray",children:["Thumbnail URL: ",c]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(u.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]})},H=i(92642),Y=(e,l)=>{if(!e)return"";var r="string"==typeof e?e:JSON.stringify(e);return r.length>l?r.slice(0,l-1)+"…":r},z=({onBack:e})=>{var l=s((0,d.useState)([]),2),r=l[0],i=l[1],o=s((0,d.useState)(!0),2),a=o[0],h=o[1],g=s((0,d.useState)(null),2),m=g[0],T=g[1];return(0,d.useEffect)(()=>{var e,l=(0,x.getCurrentProfile)(),r=(0,x.getToken)(l),t=(0,x.getActivityLogBaseUrl)();if(!r){T("Not logged in. Run `bricks auth login` first."),h(!1);return}if(!t){T("Activity log URL not configured."),h(!1);return}var n=(0,H.W)(t,r),o=new Date(Date.now()-36e5).toISOString(),a=new Date().toISOString(),d=new AbortController;return(e=c(function*(){try{var e=yield n.collectEvents({start_time:o,end_time:a},{limit:50,signal:d.signal});i(e)}catch(e){"AbortError"!==e.name&&T(e.message)}h(!1)}),function(){return e.apply(this,arguments)})(),()=>d.abort()},[]),n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Activity Log (last 1h)"}),a&&t(D,{text:"Fetching events..."}),m&&n(u.Text,{color:"red",children:["Error: ",m]}),!a&&!m&&0===r.length&&t(u.Text,{color:"yellow",children:"No events found in the last hour"}),!a&&r.length>0&&n(u.Box,{flexDirection:"column",marginBottom:1,children:[n(u.Text,{color:"gray",children:["Timestamp".padEnd(22)," ","Type".padEnd(12)," ","Device".padEnd(14)," ","Event Name".padEnd(24)," Sender"]}),r.map((e,l)=>n(u.Text,{children:[new Date(e.timestamp).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z").padEnd(22)," ",Y(e.event_type||"",12).padEnd(12)," ",Y(e.device_id||"",14).padEnd(14)," ",Y(e.event_name||"",24).padEnd(24)," ",Y(e.sender||"",16)]},l)),r.length>=50&&n(u.Text,{color:"yellow",children:["Showing first ",50," events"]})]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:l=>"back"===l.value&&e()})]})},X=i(29253),J=i(44618),W=["B","C","G","D"],q=({instanceType:e,instance:l,client:r,onDone:i,onCancel:o})=>{var a,h=(0,u.useApp)().exit,x=s((0,d.useState)("select_ref"),2),g=x[0],m=x[1],T=s((0,d.useState)(""),2),p=T[0],f=T[1],v=s((0,d.useState)("search"),2),_=v[0],y=v[1],b=s((0,d.useState)(null),2),E=b[0],I=b[1],A=s((0,d.useState)(null),2),B=A[0],C=A[1],L=s((0,d.useState)(""),2),k=L[0],w=L[1],O=s((0,d.useState)(""),2),M=O[0],P=O[1],R=s((0,d.useState)(null),2),N=R[0],U=R[1],G=l?.short_edit?.ref_map||{},$=Object.entries(G).filter(([,e])=>e&&!e.hide),V=(0,J.V)(G,{keyword:p,types:W}),F=V.flatMap(e=>[{label:e.label,value:`__header_${e.prefix}__`,isHeader:!0},...e.refs.map(({shortId:e,ref:l})=>({label:`${l.title||e} (${e})`,value:e,ref:l}))]),j=[...p?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],H=F.length>0?[...F,...j]:j,Y=H.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,u.useInput)((e,l)=>{l.tab&&"select_ref"===g?y(e=>"search"===e?"list":"search"):(l.escape&&("select_ref"===g&&o(),"input_path"===g&&m("select_ref"),"input_content"===g&&m("input_path"),"confirm"===g&&m("input_content"),"done"===g&&o()),"q"===e&&"input_path"!==g&&"input_content"!==g&&("select_ref"!==g||"search"!==_)&&h())},{isActive:!0});var z=(a=c(function*(){if(r&&l?._id&&E){m("submitting"),U(null);try{var t={shortId:E,path:k.trim(),content:(e=>{var l=e.trim();if(""===l)return null;try{return JSON.parse(l)}catch{return l}})(M),forwardDataLink:!0};B?.inner_ref?.pid&&(t.innerRefParentShortId=B.inner_ref.pid),"application"===e?yield r.shortEditApplication({id:l._id,list:[t]}):yield r.shortEditModule({id:l._id,list:[t]}),yield i(),m("done")}catch(e){U(e.message),m("confirm")}}}),function(){return a.apply(this,arguments)});return l?.short_edit?.enabled?0===$.length?n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"yellow",children:"No Short Edit references found."}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):"select_ref"===g?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,children:"Short Edit References"}),t(u.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),n(u.Box,{marginTop:1,flexDirection:"column",children:[t(u.Text,{color:"gray",children:"Search (title or shortId)"}),t(X.A,{value:p,placeholder:"type to filter, Enter to focus list",onChange:e=>f(e),onSubmit:()=>y("list"),focus:"search"===_}),t(u.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),n(u.Box,{marginTop:1,children:[0===V.length&&t(u.Text,{color:"yellow",children:"No references match your search."}),t(S.Ay,{items:H,isFocused:"list"===_,initialIndex:Y>-1?Y:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:l,isHeader:r})=>r?t(u.Box,{marginTop:1,children:t(u.Text,{bold:!0,color:"white",children:e})}):n(u.Text,{color:l?"blue":void 0,children:[l?"❯":" "," ",e]}),onSelect:e=>{if("__back__"===e.value)return void o();if("__clear_search__"===e.value){f(""),y("search");return}e.isHeader||(I(e.value),C(e.ref),m("input_path"))}})]})]}):"input_path"===g?n(u.Box,{flexDirection:"column",children:[n(u.Text,{children:["Reference:"," ",n(u.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),t(u.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(X.A,{value:k,placeholder:"path",onChange:e=>{w(e),N&&U(null)},onSubmit:e=>{var l=e.trim();l?(w(l),m("input_content")):U("Path is required")},focus:!0})]}):"input_content"===g?n(u.Box,{flexDirection:"column",children:[n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k})]}),t(u.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(X.A,{value:M,placeholder:"content",onChange:e=>{P(e),N&&U(null)},onSubmit:()=>m("confirm"),focus:!0})]}):"submitting"===g?t(D,{text:"Applying short edit..."}):"done"===g?n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"green",children:"Short edit applied successfully."}),t(S.Ay,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(m("select_ref"),I(null),C(null),w(""),P(""),U(null)):o()}})]}):n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),n(u.Text,{children:["Reference:"," ",n(u.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k})]}),n(u.Text,{children:["Content: ",t(u.Text,{color:"cyan",children:M||"<empty>"})]}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(S.Ay,{items:[{label:"Apply",value:"apply"},{label:"Edit Path",value:"edit_path"},{label:"Edit Content",value:"edit_content"},{label:"← Back",value:"back"}],onSelect:e=>{"apply"===e.value&&z(),"edit_path"===e.value&&m("input_path"),"edit_content"===e.value&&m("input_content"),"back"===e.value&&o()}})]}):n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]})},K=i(16928),Z=i(79896),Q=i(35317),ee=i(10750),el="options",er="output_dir",et="confirm",en="generating",ei="post_install",eo="done",ea=e=>{try{return(0,Q.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},ec=(e,l,r)=>new Promise((t,n)=>{var i=[e,...l].join(" "),o=(0,Q.spawn)(i,[],{cwd:r,stdio:"pipe",shell:!0});o.on("close",e=>{0===e?t():n(Error(`Command failed with code ${e}`))}),o.on("error",n)}),ed=(o=c(function*(e,l){try{var r=(yield i.e(456).then(i.bind(i,79491))).format;return(yield r(l,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,l){return o.apply(this,arguments)}),eu=({type:e,instance:l,client:r,onDone:i,onCancel:o})=>{var a,h=(0,u.useApp)().exit,x=s((0,d.useState)(el),2),g=x[0],m=x[1],T=s((0,d.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),2),p=T[0],v=T[1],_=s((0,d.useState)(process.cwd()),2),y=_[0],b=_[1],D=s((0,d.useState)(""),2),E=D[0],I=D[1],A=s((0,d.useState)(null),2),B=A[0],C=A[1],L=s((0,d.useState)(null),2),k=L[0],w=L[1],O=ee(l?.name||"bricks-ctor"),M=K.resolve(y,O),P=(0,d.useCallback)(e=>{"back"===e.value?o():"continue"===e.value?m(er):v(l=>({...l,[e.value]:!l[e.value]}))},[o]),R=(0,d.useCallback)(()=>{Z.existsSync(M)?C(`Directory already exists: ${M}`):(C(null),m(et))},[M]),N=(0,d.useCallback)((a=c(function*(t){if("back"===t.value)return void m(er);if("cancel"===t.value)return void o();if("confirm"===t.value){m(en);try{I("Fetching project from BRICKS...");var n,i="application"===e,a=i?r.queries.applicationProject:r.queries.moduleProject,d=(yield r.query(a,{id:l._id,buildApplicationOnly:!1,setupGitHubActions:p.setupGitHubActions,setupAgents:p.setupAgents,setupClaudeCode:p.setupClaudeCode,setupGeminiCLI:p.setupGeminiCLI}))[i?"UNSTABLE_applicationProject":"UNSTABLE_moduleProject"];if(!d?.files)throw Error("Failed to fetch project files");I("Creating project directory..."),Z.mkdirSync(M,{recursive:!0}),I(`Writing ${d.files.length} files...`),(yield Promise.all(d.files.map((n=c(function*(e){var l=K.join(M,e.name),r=e.input;return e.formatable&&(r=yield ed(r,l)),{...e,filePath:l,content:r}}),function(e){return n.apply(this,arguments)})))).forEach(e=>{var l=K.dirname(e.filePath);Z.existsSync(l)||Z.mkdirSync(l,{recursive:!0}),Z.writeFileSync(e.filePath,e.content)}),m(ei);var u={path:M,files:d.files.length,bunInstalled:!1,gitInitialized:!1};if(p.runBunInstall&&ea("bun")){I("Installing dependencies (bun install)...");try{yield ec("bun",["install"],M),u.bunInstalled=!0}catch{}}if(p.initGit&&ea("git")){I("Initializing git repository...");try{yield ec("git",["init"],M),yield ec("git",["add","."],M),yield ec("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],M),u.gitInitialized=!0}catch{}}w(u),m(eo)}catch(e){C(e.message),m(el)}}}),function(e){return a.apply(this,arguments)}),[r,l,e,p,M,o]),U=(0,d.useCallback)(e=>{"exit"===e.value?h():i()},[h,i]);if(g===el){var G=[{label:`${p.setupGitHubActions?"[x]":"[ ]"} GitHub Actions workflow`,value:"setupGitHubActions"},{label:`${p.setupAgents?"[x]":"[ ]"} AGENTS.md`,value:"setupAgents"},{label:`${p.setupClaudeCode?"[x]":"[ ]"} CLAUDE.md`,value:"setupClaudeCode"},{label:`${p.setupGeminiCLI?"[x]":"[ ]"} GEMINI.md`,value:"setupGeminiCLI"},{label:`${p.runBunInstall?"[x]":"[ ]"} Run bun install after generation`,value:"runBunInstall"},{label:`${p.initGit?"[x]":"[ ]"} Initialize git repository`,value:"initGit"},{label:"→ Continue",value:"continue"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",l?.name||"Untitled"]}),t(u.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),B&&n(u.Text,{color:"red",marginBottom:1,children:["Error: ",B]}),t(S.Ay,{items:G,onSelect:P})]})}return g===er?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Output Directory"}),t(u.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),B&&t(u.Text,{color:"red",marginBottom:1,children:B}),n(u.Box,{children:[t(u.Text,{children:"Directory: "}),t(X.A,{value:y,onChange:b,onSubmit:R})]}),n(u.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",M]})]}):g===et?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{children:["Name: ",t(u.Text,{color:"green",children:l?.name||"Untitled"})]}),n(u.Text,{children:["Type: ",t(u.Text,{color:"yellow",children:e})]}),n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:M})]}),t(u.Text,{color:"gray",marginTop:1,children:"Options:"}),n(u.Text,{color:"gray",children:[" - GitHub Actions: ",p.setupGitHubActions?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - AGENTS.md: ",p.setupAgents?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - CLAUDE.md: ",p.setupClaudeCode?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - GEMINI.md: ",p.setupGeminiCLI?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Run bun install: ",p.runBunInstall?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Initialize git: ",p.initGit?"Yes":"No"]})]}),t(S.Ay,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:N})]}):g===en||g===ei?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),n(u.Box,{marginY:1,children:[t(u.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(u.Text,{children:[" ",E]})]})]}):g===eo&&k?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:k.path})]}),n(u.Text,{children:["Files: ",t(u.Text,{color:"green",children:k.files})]}),n(u.Text,{children:["Dependencies:"," ",t(u.Text,{color:k.bunInstalled?"green":"yellow",children:k.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),n(u.Text,{children:["Git:"," ",t(u.Text,{color:k.gitInitialized?"green":"yellow",children:k.gitInitialized?"Initialized":"Not initialized"})]})]}),t(u.Text,{bold:!0,marginY:1,children:"Next steps:"}),n(u.Text,{color:"gray",children:[" cd ",O]}),!k.bunInstalled&&t(u.Text,{color:"gray",children:" bun install"}),t(u.Text,{color:"gray",children:" bun preview"}),n(u.Text,{color:"gray",marginTop:1,children:["For more information, see ",O,"/README.md"]}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:U})})]}):null};let es=()=>{var e,l,r,i,o,a,T,p,f=(0,u.useApp)().exit,_=s((0,d.useState)(m.MAIN),2),E=_[0],S=_[1],A=s((0,d.useState)(null),2),B=A[0],U=A[1],H=s((0,d.useState)(null),2),Y=H[0],X=H[1],J=s((0,d.useState)(!0),2),W=J[0],K=J[1],Z=s((0,d.useState)(null),2),Q=Z[0],ee=Z[1],el=s((0,d.useState)([]),2),er=el[0],et=el[1],en=s((0,d.useState)(null),2),ei=en[0],eo=en[1],ea=s((0,d.useState)([]),2),ec=ea[0],ed=ea[1],es=s((0,d.useState)(null),2),eh=es[0],ex=es[1],eg=s((0,d.useState)([]),2),em=eg[0],eT=eg[1],ep=s((0,d.useState)(null),2),ef=ep[0],ev=ep[1],e_=s((0,d.useState)([]),2),ey=e_[0],eb=e_[1],eD=s((0,d.useState)(null),2),eE=eD[0],eS=eD[1],eI=s((0,d.useState)([]),2),eA=eI[0],eB=eI[1],eC=s((0,d.useState)(!1),2),eL=eC[0],ek=eC[1],ew=s((0,d.useState)(null),2),eO=ew[0],eM=ew[1],eP=s((0,d.useState)(null),2),eR=eP[0],eN=eP[1],eU=s((0,d.useState)(null),2),eG=eU[0],e$=eU[1],eV=s((0,d.useState)(null),2),eF=eV[0],ej=eV[1],eH=s((0,d.useState)([]),2),eY=eH[0],ez=eH[1],eX=s((0,d.useState)(null),2),eJ=eX[0],eW=eX[1],eq=s((0,d.useState)([]),2),eK=eq[0],eZ=eq[1],eQ=s((0,d.useState)(null),2),e0=eQ[0],e1=eQ[1],e2=E===m.DEVICES,e4=E===m.DEVICE_DETAIL,e6=E===m.GROUPS,e5=E===m.GROUP_DETAIL;(0,d.useEffect)(()=>{var e=(0,x.getCurrentProfile)(),l=(0,x.getToken)(e);if(!l){ee("Not logged in. Run `bricks auth login` first."),K(!1);return}var r=(0,h.createClient)((0,x.getBaseUrl)(),l);U(r),r.workspace().then(e=>{X(e),K(!1)}).catch(e=>{ee(e.message),K(!1)})},[]),(0,u.useInput)((e,l)=>{"q"===e&&f(),l.escape&&(E===m.DEVICE_CONTROL?(S(m.DEVICE_DETAIL),eM(null)):E===m.DEVICE_SCREENSHOT?(S(m.DEVICE_DETAIL),e$(null),ej(null)):E===m.DEVICE_DETAIL?(S(m.DEVICES),eo(null)):E===m.APP_DETAIL?(S(m.APPS),ex(null)):E===m.MODULE_DETAIL?(S(m.MODULES),ev(null)):E===m.GROUP_DETAIL?(S(m.GROUPS),eS(null),eB([])):E===m.MEDIA_FILE_DETAIL?(S(m.MEDIA_FILES),e1(null)):E===m.MEDIA_FILES?(S(m.MEDIA_BOX_DETAIL),e1(null)):E===m.MEDIA_BOX_DETAIL?(S(m.MEDIA_BOXES),eW(null),eZ([])):E===m.MEDIA_BOXES?S(m.MAIN):E!==m.MAIN&&S(m.MAIN))},{isActive:E!==m.APP_SHORT_EDIT&&E!==m.MODULE_SHORT_EDIT&&E!==m.APP_PROJECT_INIT&&E!==m.MODULE_PROJECT_INIT});var e9=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.devices({});et(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),e8=(0,d.useCallback)((e=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.device({id:e});eo(l)}catch(e){eN(e.message)}K(!1)}}),function(l){return e.apply(this,arguments)}),[B]),e3=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.applications({});ed(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),e7=(0,d.useCallback)((l=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.application({id:e});ex(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return l.apply(this,arguments)}),[B]),le=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.modules({});eT(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),ll=(0,d.useCallback)((r=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.module({id:e});ev(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return r.apply(this,arguments)}),[B]),lr=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.deviceGroups({});eb(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),lt=(0,d.useCallback)((i=c(function*(e){if(B){K(!0),eN(null);try{var l=yield Promise.all([B.deviceGroup({id:e}),B.devicesByGroup({id:e})]),r=s(l,2),t=r[0],n=r[1];eS(t),eB(n||[])}catch(e){eN(e.message)}K(!1)}}),function(e){return i.apply(this,arguments)}),[B]),ln=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.mediaBoxes();ez(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),li=(0,d.useCallback)((o=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.mediaBox({id:e});eW(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return o.apply(this,arguments)}),[B]),lo=(0,d.useCallback)((a=c(function*(e){if(B){K(!0);try{var l=yield B.mediaFiles({boxId:e});eZ(l||[])}catch(e){ee(e.message)}K(!1)}}),function(e){return a.apply(this,arguments)}),[B]),la=(0,d.useCallback)((T=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.mediaFile({id:e});e1(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return T.apply(this,arguments)}),[B]),lc=(0,d.useCallback)((p=c(function*(e){if(B&&ei){ek(!0),eM(null);try{yield B.controlDevice({id:ei._id,type:e}),eM({success:!0,message:`Command sent: ${e}`})}catch(e){eM({success:!1,message:e.message})}ek(!1)}}),function(e){return p.apply(this,arguments)}),[B,ei]),ld=(0,d.useCallback)(c(function*(e=!1){if(B&&ei&&Y){K(!0),ej(null),e$(null);try{e&&(yield B.controlDevice({id:ei._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var l=yield(0,g.he)(B,Y,ei._id,null,{preferThumbnail:!0});l.error?ej(l.error):e$(l)}catch(e){ej(e.message)}K(!1)}}),[B,ei,Y]),lu=v((0,d.useCallback)(()=>{B&&e9()},[B,e9]),e2),ls=v((0,d.useCallback)(()=>{B&&ei&&e8(ei._id)},[B,ei,e8]),e4),lh=v((0,d.useCallback)(()=>{B&&lr()},[B,lr]),e6),lx=v((0,d.useCallback)(()=>{B&&eE&&lt(eE._id)},[B,eE,lt]),e5);return W&&!Y?n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),t(D,{text:"Connecting to workspace..."})]}):Q&&!Y?n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),n(u.Text,{color:"red",children:["Error: ",Q]}),t(b,{})]}):n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),E===m.MAIN&&t(I,{onSelect:e=>{"exit"===e.value?f():(S(e.value),e.value===m.DEVICES?e9():e.value===m.APPS?e3():e.value===m.MODULES?le():e.value===m.GROUPS?lr():e.value===m.MEDIA_BOXES&&ln())},mediaEnabled:(0,g.wR)(Y),activityLogEnabled:!!(0,x.getActivityLogBaseUrl)()}),E===m.DEVICES&&t(C,{devices:er,loading:W,onSelect:e=>{if("back"===e.value)return void S(m.MAIN);if("refresh"===e.value){e9(),lu.resetCountdown();return}eo(null),K(!0),S(m.DEVICE_DETAIL),e8(e.value)},countdown:lu.countdown,lastRefreshTime:lu.lastRefreshTime}),E===m.DEVICE_DETAIL&&t(L,{device:ei,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.DEVICES),eo(null);return}if("refresh"===e.value){e8(ei._id),ls.resetCountdown();return}"control"===e.value&&(S(m.DEVICE_CONTROL),eM(null)),"screenshot"===e.value&&(S(m.DEVICE_SCREENSHOT),e$(null),ej(null),ld(!1))},mediaEnabled:(0,g.wR)(Y),countdown:ls.countdown,lastRefreshTime:ls.lastRefreshTime}),E===m.DEVICE_CONTROL&&t(k,{device:ei,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),eM(null);return}lc(e.value)},controlling:eL,controlResult:eO}),E===m.DEVICE_SCREENSHOT&&t(w,{device:ei,screenshot:eG,loading:W,error:eF,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),e$(null),ej(null);return}"refresh"===e.value?ld(!1):"take"===e.value&&ld(!0)}}),E===m.APPS&&t(O,{apps:ec,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?e3():(ex(null),K(!0),S(m.APP_DETAIL),e7(e.value))}}),E===m.APP_DETAIL&&t(M,{app:eh,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.APPS),ex(null);return}"refresh"===e.value?e7(eh._id):("short_edit"===e.value&&(S(m.APP_SHORT_EDIT),eN(null)),"project_init"===e.value&&(S(m.APP_PROJECT_INIT),eN(null)))}}),E===m.APP_SHORT_EDIT&&t(q,{instanceType:"application",instance:eh,client:B,onDone:c(function*(){return e7(eh._id)}),onCancel:()=>S(m.APP_DETAIL)}),E===m.APP_PROJECT_INIT&&t(eu,{type:"application",instance:eh,client:B,onDone:()=>S(m.APP_DETAIL),onCancel:()=>S(m.APP_DETAIL)}),E===m.MODULES&&t(P,{modules:em,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?le():(ev(null),K(!0),S(m.MODULE_DETAIL),ll(e.value))}}),E===m.MODULE_DETAIL&&t(R,{module:ef,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MODULES),ev(null);return}"refresh"===e.value?ll(ef._id):("short_edit"===e.value&&(S(m.MODULE_SHORT_EDIT),eN(null)),"project_init"===e.value&&(S(m.MODULE_PROJECT_INIT),eN(null)))}}),E===m.MODULE_SHORT_EDIT&&t(q,{instanceType:"module",instance:ef,client:B,onDone:c(function*(){return ll(ef._id)}),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.MODULE_PROJECT_INIT&&t(eu,{type:"module",instance:ef,client:B,onDone:()=>S(m.MODULE_DETAIL),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.GROUPS&&t(N,{groups:ey,loading:W,onSelect:e=>{if("back"===e.value)return void S(m.MAIN);if("refresh"===e.value){lr(),lh.resetCountdown();return}eS(null),eB([]),K(!0),S(m.GROUP_DETAIL),lt(e.value)},countdown:lh.countdown,lastRefreshTime:lh.lastRefreshTime}),E===m.GROUP_DETAIL&&t(G,{group:eE,groupDevices:eA,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.GROUPS),eS(null),eB([]);return}"refresh"===e.value&&(lt(eE._id),lx.resetCountdown())},countdown:lx.countdown,lastRefreshTime:lx.lastRefreshTime}),E===m.ACTIVITY_LOG&&t(z,{onBack:()=>S(m.MAIN)}),E===m.MEDIA_BOXES&&t($,{boxes:eY,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?ln():(eW(null),eZ([]),K(!0),S(m.MEDIA_BOX_DETAIL),li(e.value))}}),E===m.MEDIA_BOX_DETAIL&&t(V,{box:eJ,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MEDIA_BOXES),eW(null),eZ([]);return}"refresh"===e.value?li(eJ.id):"files"===e.value&&(eZ([]),e1(null),S(m.MEDIA_FILES),lo(eJ.id))}}),E===m.MEDIA_FILES&&t(F,{files:eK,box:eJ,loading:W,onSelect:e=>{if("back"===e.value){S(m.MEDIA_BOX_DETAIL),e1(null);return}"refresh"===e.value?lo(eJ.id):(e1(null),K(!0),S(m.MEDIA_FILE_DETAIL),la(e.value))}}),E===m.MEDIA_FILE_DETAIL&&t(j,{file:e0,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MEDIA_FILES),e1(null);return}"refresh"===e.value&&la(e0.id)}}),t(b,{})]})};var eh="1"===process.env.BRICKS_CLI_DISTRIBUTION,ex=(a=c(function*(){if(eh)return void(0,u.render)(t(es,{}));var e=(yield i.e(166).then(i.bind(i,29557))).TerminalInfoProvider;(0,u.render)(t(e,{children:t(es,{})}))}),function(){return a.apply(this,arguments)})}};
1
+ import*as e from"ink";import*as l from"react";import{Fragment as r,jsx as t,jsxs as n}from"react/jsx-runtime";export const __rspack_esm_id=940;export const __rspack_esm_ids=[940];export const __webpack_modules__={8498(l){l.exports=e},51649(e){e.exports=l},92319(e,l,i){i.r(l),i.d(l,{AppList:()=>O,CONTROL_ACTIONS:()=>T,MainMenu:()=>I,Header:()=>y,ModuleDetail:()=>R,ONLINE_THRESHOLD_MS:()=>p,ShortEditEditor:()=>q,MediaFileList:()=>F,App:()=>es,DeviceDetail:()=>k,VIEWS:()=>m,runInteractiveMode:()=>ex,DeviceList:()=>C,MediaBoxList:()=>$,Loading:()=>D,DeviceControl:()=>L,ProjectInitView:()=>eu,GroupDetail:()=>G,ModuleList:()=>P,MediaBoxDetail:()=>V,GroupList:()=>N,Footer:()=>b,DeviceStatus:()=>E,AppDetail:()=>M,DeviceScreenshot:()=>w,MediaFileDetail:()=>j});var o,a,c=i(99436),d=i(51649),u=i(8498),s=i(68832),h=i(85382),x=i(23258),g=i(60450),m={MAIN:"main",DEVICES:"devices",DEVICE_DETAIL:"device_detail",DEVICE_CONTROL:"device_control",DEVICE_SCREENSHOT:"device_screenshot",APPS:"apps",APP_DETAIL:"app_detail",APP_SHORT_EDIT:"app_short_edit",APP_PROJECT_INIT:"app_project_init",MODULES:"modules",MODULE_DETAIL:"module_detail",MODULE_SHORT_EDIT:"module_short_edit",MODULE_PROJECT_INIT:"module_project_init",GROUPS:"groups",GROUP_DETAIL:"group_detail",MEDIA_BOXES:"media_boxes",MEDIA_BOX_DETAIL:"media_box_detail",MEDIA_FILES:"media_files",MEDIA_FILE_DETAIL:"media_file_detail",ACTIVITY_LOG:"activity_log"},T=[{label:"Refresh Application",value:"refresh"},{label:"Clear Cache",value:"clear-cache"},{label:"Take Screenshot",value:"take-screenshot"},{label:"Open System Menu",value:"system-menu-open"},{label:"Close System Menu",value:"system-menu-close"},{label:"Open Debug Panel",value:"debug-panel-open"},{label:"Close Debug Panel",value:"debug-panel-close"},{label:"Enable Logging",value:"logging-on"},{label:"Disable Logging",value:"logging-off"},{label:"← Back",value:"back"}],p=3e5,f=i(47882),v=(e,l=!0)=>{var r=Math.floor(60),t=s((0,d.useState)(r),2),n=t[0],i=t[1],o=s((0,d.useState)(null),2),a=o[0],c=o[1],u=(0,d.useRef)(e);(0,d.useEffect)(()=>{u.current=e},[e]);var h=(0,d.useCallback)(()=>{i(r),c(Date.now())},[r]);return(0,d.useEffect)(()=>{if(l){var e=setInterval(()=>{i(e=>e<=1?(u.current?.(),c(Date.now()),r):e-1)},1e3);return()=>clearInterval(e)}},[l,r]),(0,d.useEffect)(()=>{l&&(i(r),c(Date.now()))},[l,r]),{countdown:n,lastRefreshTime:a,resetCountdown:h}},_=({countdown:e,lastRefreshTime:l})=>t(u.Box,{children:n(u.Text,{color:"gray",children:["Next refresh in ",n(u.Text,{color:"cyan",children:[e,"s"]}),l&&n(u.Text,{color:"gray",children:[" (last: ",l?new Date(l).toLocaleTimeString():null,")"]})]})}),y=({workspace:e,view:l})=>n(u.Box,{flexDirection:"column",marginBottom:1,children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:"BRICKS CLI"}),t(u.Text,{color:"gray",children:" - Interactive Mode"})]}),n(u.Box,{children:[t(u.Text,{color:"gray",children:"Workspace: "}),t(u.Text,{color:"green",children:e?.name||"Not connected"}),t(u.Text,{color:"gray",children:" | View: "}),t(u.Text,{color:"yellow",children:l})]}),t(u.Text,{color:"gray",children:"─".repeat(60)})]}),b=()=>n(u.Box,{marginTop:1,flexDirection:"column",children:[t(u.Text,{color:"gray",children:"─".repeat(60)}),n(u.Text,{color:"gray",children:["Press ",t(u.Text,{color:"cyan",children:"q"})," to quit, ",t(u.Text,{color:"cyan",children:"Esc"})," to go back"]})]}),D=({text:e})=>n(u.Box,{children:[t(u.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(u.Text,{children:[" ",e||"Loading..."]})]}),E=({lastAliveTime:e})=>{if(!e)return t(u.Text,{color:"gray",children:"○ Unknown"});var l=Date.now()-new Date(e).getTime();if(l<=p)return t(u.Text,{color:"green",children:"● Online"});var r=Math.floor(l/6e4);if(r<60)return n(u.Text,{color:"yellow",children:["○ Offline (",r,"m ago)"]});var i=Math.floor(r/60);if(i<24)return n(u.Text,{color:"red",children:["○ Offline (",i,"h ago)"]});var o=Math.floor(i/24);return n(u.Text,{color:"red",children:["○ Offline (",o,"d ago)"]})},S=i(48724),I=({onSelect:e,mediaEnabled:l,activityLogEnabled:r})=>{var i=[{label:"Devices",value:m.DEVICES},{label:"Applications",value:m.APPS},{label:"Modules",value:m.MODULES},{label:"Device Groups",value:m.GROUPS},...l?[{label:"Media Flow",value:m.MEDIA_BOXES}]:[],...r?[{label:"Activity Log",value:m.ACTIVITY_LOG}]:[],{label:"Exit",value:"exit"}];return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Main Menu"}),t(S.Ay,{items:i,onSelect:e})]})},A="1"===process.env.BRICKS_CLI_DISTRIBUTION,B=e=>{var l=s((0,d.useState)(null),2),r=l[0],n=l[1];return((0,d.useEffect)(()=>{if(!A){var e=!0;return i.e(166).then(i.bind(i,29557)).then(l=>{e&&n(()=>l.default)}).catch(()=>{e&&n(!1)}),()=>{e=!1}}},[]),A||!1===r)?t(u.Text,{color:"gray",children:"Image preview is not available in this CLI build."}):r?t(r,{...e}):t(D,{text:"Preparing image preview..."})},C=({devices:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(D,{text:"Loading devices..."});if(!e?.length)return n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"yellow",children:"No devices found"}),t(_,{countdown:i,lastRefreshTime:o})]});var a=[...e.map(e=>{var l=(e=>{if(!e)return"○ Unknown";var l=Date.now()-new Date(e).getTime();if(l<=p)return"● Online";var r=Math.floor(l/6e4);if(r<60)return`○ ${r}m ago`;var t=Math.floor(r/60);if(t<24)return`○ ${t}h ago`;var n=Math.floor(t/24);return`○ ${n}d ago`})(e.entry_detail?.watch_dog_timer?.last_alive_time);return{label:`${l} - ${e.name||e.device_name}`,value:e._id,device:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Box,{marginBottom:1,children:[n(u.Text,{bold:!0,children:["Devices (",e.length,")"]}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:i,lastRefreshTime:o})]}),t(S.Ay,{items:a,onSelect:r})]})},k=({device:e,loading:l,error:r,onSelect:i,mediaEnabled:o,countdown:a,lastRefreshTime:c})=>{if(l)return t(D,{text:"Loading device..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Device not found"});var d=[{label:"Control Device",value:"control"},...o?[{label:"View Screenshot",value:"screenshot"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],s=e.entry_detail,h=s?.screen,x=s?.update,g=s?.local_sync;return n(u.Box,{flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||e.device_name}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:a,lastRefreshTime:c})]}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{color:"gray",children:"Status: "}),t(E,{lastAliveTime:s?.watch_dog_timer?.last_alive_time})]}),n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),s?.application&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Application"}),n(u.Text,{color:"gray",children:[" Name: ",s.application.name]}),n(u.Text,{color:"gray",children:[" Mode: ",s.operation_mode||"N/A"]})]}),h&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Screen"}),h.resolution&&n(u.Text,{color:"gray",children:[" ","Resolution: ",h.resolution.width,"x",h.resolution.height,h.resolution.scale&&` @${h.resolution.scale}x`]}),h.orientation&&n(u.Text,{color:"gray",children:[" Orientation: ",h.orientation]}),h.touch&&n(u.Text,{color:"gray",children:[" ","Touch:"," ",h.touch.available?`Yes (${h.touch.touch_point} points)`:"No"]})]}),(s?.memory_usage||s?.disk_usage)&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"System"}),s.memory_usage&&n(u.Text,{color:"gray",children:[" Memory: ",Math.round(100*s.memory_usage),"%"]}),s.disk_usage&&n(u.Text,{color:"gray",children:[" Disk: ",Math.round(100*s.disk_usage),"%"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Capabilities"}),n(u.Text,{color:"gray",children:[" ","Sound: ",s?.sound?.available?"✓":"✗"," | ","Camera: ",s?.camera?.available?"✓":"✗"," | ","Audio In: ",s?.audio_in?.available?"✓":"✗"]})]}),g&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Local Sync"}),n(u.Text,{color:"gray",children:[" ","Role: ",g.is_main?"Main":"Peer",g.peer_count>0&&` | Peers: ${g.peer_count}`,g.mean_latency&&` | Latency: ${g.mean_latency}ms`]})]}),x&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Update"}),n(u.Text,{color:x.need_update?"yellow":"gray",children:[" ","Status: ",x.need_update?"⚠ Update available":"✓ Up to date"]}),x.current_version&&n(u.Text,{color:"gray",children:[" Version: ",x.current_version]})]})]}),t(S.Ay,{items:d,onSelect:i})]})},L=({device:e,onSelect:l,controlling:r,controlResult:i})=>n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Control: ",e?.name||e?.device_name]}),r&&t(D,{text:"Sending command..."}),i&&t(u.Text,{color:i.success?"green":"red",children:i.message}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:T,onSelect:l})})]}),w=({device:e,screenshot:l,loading:r,error:i,onSelect:o})=>{var a=l?.file?.meta,c=a?.originalWidth!=null&&a?.originalHeight!=null,d=a?.originalFileSize!=null;return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Screenshot: ",e?.name||e?.device_name||"Unknown"]}),r&&t(D,{text:"Loading screenshot..."}),i&&t(u.Box,{marginY:1,children:t(u.Text,{color:"red",children:String(i)})}),!r&&!i&&l&&n(u.Box,{flexDirection:"column",children:[t(u.Box,{height:30,children:t(B,{src:l.path,width:80,alt:"Device screenshot"})}),n(u.Box,{marginY:1,flexDirection:"column",children:[t(u.Text,{bold:!0,color:"white",children:"Screenshot Details"}),n(u.Box,{marginY:1,children:[t(u.Text,{color:"green",children:"Screenshot saved to: "}),t(u.Text,{color:"cyan",children:String(l.path||"")})]}),c&&n(u.Text,{color:"gray",children:["Size: ",String(a.originalWidth),"x",String(a.originalHeight)]}),d&&n(u.Text,{color:"gray",children:["File: ",(Number(a.originalFileSize)/1024).toFixed(1)," KB"]}),l.file?.updatedAt&&n(u.Text,{color:"gray",children:["Updated: ",new Date(l.file.updatedAt).toLocaleString()]})]})]}),!r&&!i&&!l&&t(u.Box,{marginY:1,children:t(u.Text,{color:"yellow",children:"No screenshot available. Try taking a new one."})}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:[{label:"Take New Screenshot",value:"take"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})})]})},O=({apps:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading applications..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No applications found"});var i=[...e.map(e=>({label:`${e.has_unreleased_changes?"●":"○"} ${e.name}`,value:e._id,app:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Applications (",e.length,")"]}),t(S.Ay,{items:i,onSelect:r})]})},M=({app:e,loading:l,error:r,onSelect:i})=>{if(l)return t(D,{text:"Loading application..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Application not found"});var o=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],a=e.devices?.length||0,c=e.devices?.filter(e=>"online"===e.status)?.length||0;return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Version"}),n(u.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(u.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]}),e.current_version_details&&n(u.Text,{color:"gray",children:[" ","Released: v",e.current_version_details.version||"N/A"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Devices"}),n(u.Text,{color:"gray",children:[" ","Total: ",a,a>0&&` (${c} online)`]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Features"}),n(u.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:"gray",children:[" ","Canvas Control: ",e.canvas_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:"gray",children:[" ","Device Control: ",e.device_control?.enabled?"✓ Enabled":"✗ Disabled"]}),n(u.Text,{color:e.lock?.enabled?"yellow":"gray",children:[" ","Lock: ",e.lock?.enabled?"\uD83D\uDD12 Locked":"\uD83D\uDD13 Unlocked"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:o,onSelect:i})]})},P=({modules:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading modules..."});var i=[...(e||[]).map(e=>({label:`${e.current_version?"●":"○"} ${e.name}`,value:e._id,module:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Modules (",e?.length||0,")"]}),!e?.length&&t(u.Text,{color:"yellow",children:"No modules found"}),t(S.Ay,{items:i,onSelect:r})]})},R=({module:e,loading:l,error:r,onSelect:i})=>{if(l)return t(D,{text:"Loading module..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Module not found"});var o=[{label:"⚡ Initialize Project",value:"project_init"},...e.short_edit?.enabled&&e.short_edit.ref_map?[{label:"Short Edit",value:"short_edit"}]:[],{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Version"}),n(u.Text,{color:"gray",children:[" ","Current: ",e.current_version?`v${e.current_version}`:"N/A"]}),n(u.Text,{color:e.has_unreleased_changes?"yellow":"gray",children:[" ","Changes:"," ",e.has_unreleased_changes?"● Unreleased changes":"○ No pending changes"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Usage"}),n(u.Text,{color:"gray",children:[" ","Used in: ",e.use_count?.total_count||0," application(s)"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Settings"}),n(u.Text,{color:"gray",children:[" ","Public: ",e.is_public?"✓ Yes":"✗ No"]}),n(u.Text,{color:"gray",children:[" ","Modifiable: ",e.is_allow_modify?"✓ Yes":"✗ No"]}),n(u.Text,{color:"gray",children:[" ","Short Edit: ",e.short_edit?.enabled?"✓ Enabled":"✗ Disabled"]})]}),e.expose_properties?.length>0&&n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Exposed Properties"}),n(u.Text,{color:"gray",children:[" ",e.expose_properties.length," properties exposed"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:o,onSelect:i})]})},N=({groups:e,loading:l,onSelect:r,countdown:i,lastRefreshTime:o})=>{if(l)return t(D,{text:"Loading device groups..."});var a=[...(e||[]).map(e=>({label:`📁 ${e.name} (${e.devices?.length||0} devices)`,value:e._id,group:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Box,{marginBottom:1,children:[n(u.Text,{bold:!0,children:["Device Groups (",e?.length||0,")"]}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:i,lastRefreshTime:o})]}),!e?.length&&t(u.Text,{color:"yellow",children:"No device groups found"}),t(S.Ay,{items:a,onSelect:r})]})},U=({loading:e,groupDevices:l})=>e?t(D,{text:"Loading devices..."}):l?.length?n(r,{children:[l.slice(0,10).map(e=>n(u.Box,{children:[t(u.Text,{color:"gray",children:" "}),t(E,{lastAliveTime:e.entry_detail?.watch_dog_timer?.last_alive_time}),n(u.Text,{color:"gray",children:[" ",e.name||e.device_name]}),e.device_target_name&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","(",e.device_target_name,")"]})]},e._id)),l.length>10&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","... and ",l.length-10," more"]})]}):t(u.Text,{color:"gray",children:" No devices in this group"}),G=({group:e,groupDevices:l,loading:r,error:i,onSelect:o,countdown:a,lastRefreshTime:c})=>r&&!e?t(D,{text:"Loading device group..."}):i?n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",i]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):e?n(u.Box,{flexDirection:"column",children:[n(u.Box,{children:[t(u.Text,{bold:!0,color:"cyan",children:e.name}),t(u.Text,{color:"gray",children:" - "}),t(_,{countdown:a,lastRefreshTime:c})]}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e._id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[n(u.Text,{bold:!0,color:"white",children:["Devices (",e.devices?.length||0,")"]}),t(U,{loading:r,groupDevices:l})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.create_datetime&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.create_datetime).toLocaleString()]}),e.last_modify_datetime&&n(u.Text,{color:"gray",children:[" ","Modified: ",new Date(e.last_modify_datetime).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:o})]}):t(u.Text,{color:"red",children:"Device group not found"}),$=({boxes:e,loading:l,onSelect:r})=>{if(l)return t(D,{text:"Loading media boxes..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No media boxes found"});var i=[...e.map(e=>({label:`📦 ${e.name||"Unnamed"}`,value:e.id,box:e})),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Media Boxes (",e.length,")"]}),t(S.Ay,{items:i,onSelect:r})]})},V=({box:e,loading:l,error:r,onSelect:i})=>l&&!e?t(D,{text:"Loading media box..."}):r?n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]}):e?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e.id]}),e.tags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.tags.join(", ")]}),null!=e.size&&n(u.Text,{color:"gray",children:["Size: ",e.size]}),e.passcodes?.length>0&&n(u.Box,{flexDirection:"column",marginTop:1,children:[n(u.Text,{bold:!0,color:"white",children:["Passcodes (",e.passcodes.length,")"]}),e.passcodes.slice(0,5).map(e=>n(u.Text,{color:"gray",children:[" ",e.name||"Passcode",": ",e.code]},e.id)),e.passcodes.length>5&&n(u.Text,{color:"gray",dimColor:!0,children:[" ","... and ",e.passcodes.length-5," more"]})]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(u.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"List Files",value:"files"},{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]}):t(u.Text,{color:"red",children:"Media box not found"}),F=({files:e,loading:l,onSelect:r,box:i})=>{if(l)return t(D,{text:"Loading media files..."});if(!e?.length)return t(u.Text,{color:"yellow",children:"No media files found"});var o=[...e.map(e=>{var l;return{label:`${"Image"===(l=e.fileType)?"\uD83D\uDDBC":"Video"===l?"\uD83C\uDF9E":"Audio"===l?"\uD83C\uDFB5":"\uD83D\uDCC4"} ${e.name||"Unnamed"}`,value:e.id,file:e}}),{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,marginBottom:1,children:["Media Files (",e.length,")",i?.name?` - ${i.name}`:""]}),t(S.Ay,{items:o,onSelect:r})]})},j=({file:e,loading:l,error:r,onSelect:i})=>{if(l&&!e)return t(D,{text:"Loading media file..."});if(r)return n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"red",children:["Error: ",r]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:i})]});if(!e)return t(u.Text,{color:"red",children:"Media file not found"});var o=e.meta,a=(0,g.Gu)(e),c=(0,g.Gu)(e,{preferThumbnail:!0}),d=!!(c&&c!==a);return n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:e.name||"Unnamed"}),e.description&&t(u.Text,{color:"gray",children:e.description}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{color:"gray",children:["ID: ",e.id]}),n(u.Text,{color:"gray",children:["Box ID: ",e.boxId]}),n(u.Text,{color:"gray",children:["Type: ",e.fileType]}),e.userTags?.length>0&&n(u.Text,{color:"gray",children:["Tags: ",e.userTags.join(", ")]}),o?.originalWidth!=null&&o?.originalHeight!=null&&n(u.Text,{color:"gray",children:["Size: ",o.originalWidth,"x",o.originalHeight]}),o?.originalFileSize!=null&&n(u.Text,{color:"gray",children:["File: ",(Number(o.originalFileSize)/1024).toFixed(1)," KB"]}),a&&n(u.Text,{color:"gray",children:["Original URL: ",a]}),d&&n(u.Text,{color:"gray",children:["Thumbnail URL: ",c]}),n(u.Box,{flexDirection:"column",marginTop:1,children:[t(u.Text,{bold:!0,color:"white",children:"Timestamps"}),e.createdAt&&n(u.Text,{color:"gray",children:[" Created: ",new Date(e.createdAt).toLocaleString()]}),e.updatedAt&&n(u.Text,{color:"gray",children:[" Modified: ",new Date(e.updatedAt).toLocaleString()]})]})]}),t(S.Ay,{items:[{label:"↻ Refresh",value:"refresh"},{label:"← Back",value:"back"}],onSelect:i})]})},H=i(92642),Y=(e,l)=>{if(!e)return"";var r="string"==typeof e?e:JSON.stringify(e);return r.length>l?r.slice(0,l-1)+"…":r},z=({onBack:e})=>{var l=s((0,d.useState)([]),2),r=l[0],i=l[1],o=s((0,d.useState)(!0),2),a=o[0],h=o[1],g=s((0,d.useState)(null),2),m=g[0],T=g[1];return(0,d.useEffect)(()=>{var e,l=(0,x.getCurrentProfile)(),r=(0,x.getToken)(l),t=(0,x.getActivityLogBaseUrl)();if(!r){T("Not logged in. Run `bricks auth login` first."),h(!1);return}if(!t){T("Activity log URL not configured."),h(!1);return}var n=(0,H.W)(t,r),o=new Date(Date.now()-36e5).toISOString(),a=new Date().toISOString(),d=new AbortController;return(e=c(function*(){try{var e=yield n.collectEvents({start_time:o,end_time:a},{limit:50,signal:d.signal});i(e)}catch(e){"AbortError"!==e.name&&T(e.message)}h(!1)}),function(){return e.apply(this,arguments)})(),()=>d.abort()},[]),n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Activity Log (last 1h)"}),a&&t(D,{text:"Fetching events..."}),m&&n(u.Text,{color:"red",children:["Error: ",m]}),!a&&!m&&0===r.length&&t(u.Text,{color:"yellow",children:"No events found in the last hour"}),!a&&r.length>0&&n(u.Box,{flexDirection:"column",marginBottom:1,children:[n(u.Text,{color:"gray",children:["Timestamp".padEnd(22)," ","Type".padEnd(12)," ","Device".padEnd(14)," ","Event Name".padEnd(24)," Sender"]}),r.map((e,l)=>n(u.Text,{children:[new Date(e.timestamp).toISOString().replace("T"," ").replace(/\.\d+Z$/,"Z").padEnd(22)," ",Y(e.event_type||"",12).padEnd(12)," ",Y(e.device_id||"",14).padEnd(14)," ",Y(e.event_name||"",24).padEnd(24)," ",Y(e.sender||"",16)]},l)),r.length>=50&&n(u.Text,{color:"yellow",children:["Showing first ",50," events"]})]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:l=>"back"===l.value&&e()})]})},X=i(29253),J=i(44618),W=["B","C","G","D"],q=({instanceType:e,instance:l,client:r,onDone:i,onCancel:o})=>{var a,h=(0,u.useApp)().exit,x=s((0,d.useState)("select_ref"),2),g=x[0],m=x[1],T=s((0,d.useState)(""),2),p=T[0],f=T[1],v=s((0,d.useState)("search"),2),_=v[0],y=v[1],b=s((0,d.useState)(null),2),E=b[0],I=b[1],A=s((0,d.useState)(null),2),B=A[0],C=A[1],k=s((0,d.useState)(""),2),L=k[0],w=k[1],O=s((0,d.useState)(""),2),M=O[0],P=O[1],R=s((0,d.useState)(null),2),N=R[0],U=R[1],G=l?.short_edit?.ref_map||{},$=Object.entries(G).filter(([,e])=>e&&!e.hide),V=(0,J.V)(G,{keyword:p,types:W}),F=V.flatMap(e=>[{label:e.label,value:`__header_${e.prefix}__`,isHeader:!0},...e.refs.map(({shortId:e,ref:l})=>({label:`${l.title||e} (${e})`,value:e,ref:l}))]),j=[...p?[{label:"↻ Clear Search",value:"__clear_search__"}]:[],{label:"← Back",value:"__back__"}],H=F.length>0?[...F,...j]:j,Y=H.findIndex(e=>!e.isHeader&&!e.value?.startsWith("__"));(0,u.useInput)((e,l)=>{l.tab&&"select_ref"===g?y(e=>"search"===e?"list":"search"):(l.escape&&("select_ref"===g&&o(),"input_path"===g&&m("select_ref"),"input_content"===g&&m("input_path"),"confirm"===g&&m("input_content"),"done"===g&&o()),"q"===e&&"input_path"!==g&&"input_content"!==g&&("select_ref"!==g||"search"!==_)&&h())},{isActive:!0});var z=(a=c(function*(){if(r&&l?._id&&E){m("submitting"),U(null);try{var t={shortId:E,path:L.trim(),content:(e=>{var l=e.trim();if(""===l)return null;try{return JSON.parse(l)}catch{return l}})(M),forwardDataLink:!0};B?.inner_ref?.pid&&(t.innerRefParentShortId=B.inner_ref.pid),"application"===e?yield r.shortEditApplication({id:l._id,list:[t]}):yield r.shortEditModule({id:l._id,list:[t]}),yield i(),m("done")}catch(e){U(e.message),m("confirm")}}}),function(){return a.apply(this,arguments)});return l?.short_edit?.enabled?0===$.length?n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"yellow",children:"No Short Edit references found."}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]}):"select_ref"===g?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,children:"Short Edit References"}),t(u.Text,{color:"gray",dimColor:!0,children:"Showing: Brick, Canvas, Generator, Data"}),n(u.Box,{marginTop:1,flexDirection:"column",children:[t(u.Text,{color:"gray",children:"Search (title or shortId)"}),t(X.A,{value:p,placeholder:"type to filter, Enter to focus list",onChange:e=>f(e),onSubmit:()=>y("list"),focus:"search"===_}),t(u.Text,{color:"gray",dimColor:!0,children:"Press Tab to switch focus"})]}),n(u.Box,{marginTop:1,children:[0===V.length&&t(u.Text,{color:"yellow",children:"No references match your search."}),t(S.Ay,{items:H,isFocused:"list"===_,initialIndex:Y>-1?Y:0,indicatorComponent:()=>null,itemComponent:({label:e,isSelected:l,isHeader:r})=>r?t(u.Box,{marginTop:1,children:t(u.Text,{bold:!0,color:"white",children:e})}):n(u.Text,{color:l?"blue":void 0,children:[l?"❯":" "," ",e]}),onSelect:e=>{if("__back__"===e.value)return void o();if("__clear_search__"===e.value){f(""),y("search");return}e.isHeader||(I(e.value),C(e.ref),m("input_path"))}})]})]}):"input_path"===g?n(u.Box,{flexDirection:"column",children:[n(u.Text,{children:["Reference:"," ",n(u.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),t(u.Text,{marginTop:1,children:"Enter property path (e.g. title, property.backgroundColor)"}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(X.A,{value:L,placeholder:"path",onChange:e=>{w(e),N&&U(null)},onSubmit:e=>{var l=e.trim();l?(w(l),m("input_content")):U("Path is required")},focus:!0})]}):"input_content"===g?n(u.Box,{flexDirection:"column",children:[n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:L})]}),t(u.Text,{marginTop:1,children:"Enter new content (JSON or plain text). Empty to clear."}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(X.A,{value:M,placeholder:"content",onChange:e=>{P(e),N&&U(null)},onSubmit:()=>m("confirm"),focus:!0})]}):"submitting"===g?t(D,{text:"Applying short edit..."}):"done"===g?n(u.Box,{flexDirection:"column",children:[t(u.Text,{color:"green",children:"Short edit applied successfully."}),t(S.Ay,{items:[{label:"Edit another property",value:"again"},{label:"← Back",value:"back"}],onSelect:e=>{"again"===e.value?(m("select_ref"),I(null),C(null),w(""),P(""),U(null)):o()}})]}):n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,marginBottom:1,children:"Confirm Short Edit"}),n(u.Text,{children:["Reference:"," ",n(u.Text,{color:"cyan",children:[B?.title||E," (",E,")"]})]}),n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:L})]}),n(u.Text,{children:["Content: ",t(u.Text,{color:"cyan",children:M||"<empty>"})]}),N&&n(u.Text,{color:"red",children:["Error: ",N]}),t(S.Ay,{items:[{label:"Apply",value:"apply"},{label:"Edit Path",value:"edit_path"},{label:"Edit Content",value:"edit_content"},{label:"← Back",value:"back"}],onSelect:e=>{"apply"===e.value&&z(),"edit_path"===e.value&&m("input_path"),"edit_content"===e.value&&m("input_content"),"back"===e.value&&o()}})]}):n(u.Box,{flexDirection:"column",children:[n(u.Text,{color:"yellow",children:["Short Edit is not enabled for this ",e,"."]}),t(S.Ay,{items:[{label:"← Back",value:"back"}],onSelect:o})]})},K=i(16928),Z=i(79896),Q=i(35317),ee=i(10750),el="options",er="output_dir",et="confirm",en="generating",ei="post_install",eo="done",ea=e=>{try{return(0,Q.execSync)(`which ${e}`,{stdio:"ignore"}),!0}catch{return!1}},ec=(e,l,r)=>new Promise((t,n)=>{var i=[e,...l].join(" "),o=(0,Q.spawn)(i,[],{cwd:r,stdio:"pipe",shell:!0});o.on("close",e=>{0===e?t():n(Error(`Command failed with code ${e}`))}),o.on("error",n)}),ed=(o=c(function*(e,l){try{var r=(yield i.e(456).then(i.bind(i,79491))).format;return(yield r(l,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,l){return o.apply(this,arguments)}),eu=({type:e,instance:l,client:r,onDone:i,onCancel:o})=>{var a,h=(0,u.useApp)().exit,x=s((0,d.useState)(el),2),g=x[0],m=x[1],T=s((0,d.useState)({setupGitHubActions:!0,setupAgents:!0,setupClaudeCode:!0,setupGeminiCLI:!1,runBunInstall:!0,initGit:!0}),2),p=T[0],v=T[1],_=s((0,d.useState)(process.cwd()),2),y=_[0],b=_[1],D=s((0,d.useState)(""),2),E=D[0],I=D[1],A=s((0,d.useState)(null),2),B=A[0],C=A[1],k=s((0,d.useState)(null),2),L=k[0],w=k[1],O=ee(l?.name||"bricks-ctor"),M=K.resolve(y,O),P=(0,d.useCallback)(e=>{"back"===e.value?o():"continue"===e.value?m(er):v(l=>({...l,[e.value]:!l[e.value]}))},[o]),R=(0,d.useCallback)(()=>{Z.existsSync(M)?C(`Directory already exists: ${M}`):(C(null),m(et))},[M]),N=(0,d.useCallback)((a=c(function*(t){if("back"===t.value)return void m(er);if("cancel"===t.value)return void o();if("confirm"===t.value){m(en);try{I("Fetching project from BRICKS...");var n,i="application"===e,a=i?r.queries.applicationProject:r.queries.moduleProject,d=(yield r.query(a,{id:l._id,buildApplicationOnly:!1,setupGitHubActions:p.setupGitHubActions,setupAgents:p.setupAgents,setupClaudeCode:p.setupClaudeCode,setupGeminiCLI:p.setupGeminiCLI}))[i?"applicationProject":"moduleProject"];if(!d?.files)throw Error("Failed to fetch project files");I("Creating project directory..."),Z.mkdirSync(M,{recursive:!0}),I(`Writing ${d.files.length} files...`),(yield Promise.all(d.files.map((n=c(function*(e){var l=K.join(M,e.name),r=e.input;return e.formatable&&(r=yield ed(r,l)),{...e,filePath:l,content:r}}),function(e){return n.apply(this,arguments)})))).forEach(e=>{var l=K.dirname(e.filePath);Z.existsSync(l)||Z.mkdirSync(l,{recursive:!0}),Z.writeFileSync(e.filePath,e.content)}),m(ei);var u={path:M,files:d.files.length,bunInstalled:!1,gitInitialized:!1};if(p.runBunInstall&&ea("bun")){I("Installing dependencies (bun install)...");try{yield ec("bun",["install"],M),u.bunInstalled=!0}catch{}}if(p.initGit&&ea("git")){I("Initializing git repository...");try{yield ec("git",["init"],M),yield ec("git",["add","."],M),yield ec("git",["-c 'user.name=BRICKS CLI'","-c 'user.email=cli@bricks.tools'","commit","-m 'chore: initialize commit'"],M),u.gitInitialized=!0}catch{}}w(u),m(eo)}catch(e){C(e.message),m(el)}}}),function(e){return a.apply(this,arguments)}),[r,l,e,p,M,o]),U=(0,d.useCallback)(e=>{"exit"===e.value?h():i()},[h,i]);if(g===el){var G=[{label:`${p.setupGitHubActions?"[x]":"[ ]"} GitHub Actions workflow`,value:"setupGitHubActions"},{label:`${p.setupAgents?"[x]":"[ ]"} AGENTS.md`,value:"setupAgents"},{label:`${p.setupClaudeCode?"[x]":"[ ]"} CLAUDE.md`,value:"setupClaudeCode"},{label:`${p.setupGeminiCLI?"[x]":"[ ]"} GEMINI.md`,value:"setupGeminiCLI"},{label:`${p.runBunInstall?"[x]":"[ ]"} Run bun install after generation`,value:"runBunInstall"},{label:`${p.initGit?"[x]":"[ ]"} Initialize git repository`,value:"initGit"},{label:"→ Continue",value:"continue"},{label:"← Back",value:"back"}];return n(u.Box,{flexDirection:"column",children:[n(u.Text,{bold:!0,color:"cyan",children:["Initialize BRICKS Project: ",l?.name||"Untitled"]}),t(u.Text,{color:"gray",marginBottom:1,children:"Select options for project generation (press Enter to toggle)"}),B&&n(u.Text,{color:"red",marginBottom:1,children:["Error: ",B]}),t(S.Ay,{items:G,onSelect:P})]})}return g===er?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Output Directory"}),t(u.Text,{color:"gray",marginBottom:1,children:"Enter the parent directory for the project:"}),B&&t(u.Text,{color:"red",marginBottom:1,children:B}),n(u.Box,{children:[t(u.Text,{children:"Directory: "}),t(X.A,{value:y,onChange:b,onSubmit:R})]}),n(u.Text,{color:"gray",marginTop:1,children:["Project will be created at: ",M]})]}):g===et?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Confirm Project Generation"}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{children:["Name: ",t(u.Text,{color:"green",children:l?.name||"Untitled"})]}),n(u.Text,{children:["Type: ",t(u.Text,{color:"yellow",children:e})]}),n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:M})]}),t(u.Text,{color:"gray",marginTop:1,children:"Options:"}),n(u.Text,{color:"gray",children:[" - GitHub Actions: ",p.setupGitHubActions?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - AGENTS.md: ",p.setupAgents?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - CLAUDE.md: ",p.setupClaudeCode?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - GEMINI.md: ",p.setupGeminiCLI?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Run bun install: ",p.runBunInstall?"Yes":"No"]}),n(u.Text,{color:"gray",children:[" - Initialize git: ",p.initGit?"Yes":"No"]})]}),t(S.Ay,{items:[{label:"Confirm & Generate",value:"confirm"},{label:"← Change Directory",value:"back"},{label:"Cancel",value:"cancel"}],onSelect:N})]}):g===en||g===ei?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"cyan",children:"Generating Project..."}),n(u.Box,{marginY:1,children:[t(u.Text,{color:"green",children:t(f.A,{type:"dots"})}),n(u.Text,{children:[" ",E]})]})]}):g===eo&&L?n(u.Box,{flexDirection:"column",children:[t(u.Text,{bold:!0,color:"green",children:"Project initialized successfully!"}),n(u.Box,{marginY:1,flexDirection:"column",children:[n(u.Text,{children:["Path: ",t(u.Text,{color:"cyan",children:L.path})]}),n(u.Text,{children:["Files: ",t(u.Text,{color:"green",children:L.files})]}),n(u.Text,{children:["Dependencies:"," ",t(u.Text,{color:L.bunInstalled?"green":"yellow",children:L.bunInstalled?"Installed":"Not installed (run bun install manually)"})]}),n(u.Text,{children:["Git:"," ",t(u.Text,{color:L.gitInitialized?"green":"yellow",children:L.gitInitialized?"Initialized":"Not initialized"})]})]}),t(u.Text,{bold:!0,marginY:1,children:"Next steps:"}),n(u.Text,{color:"gray",children:[" cd ",O]}),!L.bunInstalled&&t(u.Text,{color:"gray",children:" bun install"}),t(u.Text,{color:"gray",children:" bun preview"}),n(u.Text,{color:"gray",marginTop:1,children:["For more information, see ",O,"/README.md"]}),t(u.Box,{marginTop:1,children:t(S.Ay,{items:[{label:"← Back to Detail",value:"back"},{label:"Exit CLI",value:"exit"}],onSelect:U})})]}):null};let es=()=>{var e,l,r,i,o,a,T,p,f=(0,u.useApp)().exit,_=s((0,d.useState)(m.MAIN),2),E=_[0],S=_[1],A=s((0,d.useState)(null),2),B=A[0],U=A[1],H=s((0,d.useState)(null),2),Y=H[0],X=H[1],J=s((0,d.useState)(!0),2),W=J[0],K=J[1],Z=s((0,d.useState)(null),2),Q=Z[0],ee=Z[1],el=s((0,d.useState)([]),2),er=el[0],et=el[1],en=s((0,d.useState)(null),2),ei=en[0],eo=en[1],ea=s((0,d.useState)([]),2),ec=ea[0],ed=ea[1],es=s((0,d.useState)(null),2),eh=es[0],ex=es[1],eg=s((0,d.useState)([]),2),em=eg[0],eT=eg[1],ep=s((0,d.useState)(null),2),ef=ep[0],ev=ep[1],e_=s((0,d.useState)([]),2),ey=e_[0],eb=e_[1],eD=s((0,d.useState)(null),2),eE=eD[0],eS=eD[1],eI=s((0,d.useState)([]),2),eA=eI[0],eB=eI[1],eC=s((0,d.useState)(!1),2),ek=eC[0],eL=eC[1],ew=s((0,d.useState)(null),2),eO=ew[0],eM=ew[1],eP=s((0,d.useState)(null),2),eR=eP[0],eN=eP[1],eU=s((0,d.useState)(null),2),eG=eU[0],e$=eU[1],eV=s((0,d.useState)(null),2),eF=eV[0],ej=eV[1],eH=s((0,d.useState)([]),2),eY=eH[0],ez=eH[1],eX=s((0,d.useState)(null),2),eJ=eX[0],eW=eX[1],eq=s((0,d.useState)([]),2),eK=eq[0],eZ=eq[1],eQ=s((0,d.useState)(null),2),e0=eQ[0],e1=eQ[1],e2=E===m.DEVICES,e4=E===m.DEVICE_DETAIL,e6=E===m.GROUPS,e5=E===m.GROUP_DETAIL;(0,d.useEffect)(()=>{var e=(0,x.getCurrentProfile)(),l=(0,x.getToken)(e);if(!l){ee("Not logged in. Run `bricks auth login` first."),K(!1);return}var r=(0,h.createClient)((0,x.getBaseUrl)(),l);U(r),r.workspace().then(e=>{X(e),K(!1)}).catch(e=>{ee(e.message),K(!1)})},[]),(0,u.useInput)((e,l)=>{"q"===e&&f(),l.escape&&(E===m.DEVICE_CONTROL?(S(m.DEVICE_DETAIL),eM(null)):E===m.DEVICE_SCREENSHOT?(S(m.DEVICE_DETAIL),e$(null),ej(null)):E===m.DEVICE_DETAIL?(S(m.DEVICES),eo(null)):E===m.APP_DETAIL?(S(m.APPS),ex(null)):E===m.MODULE_DETAIL?(S(m.MODULES),ev(null)):E===m.GROUP_DETAIL?(S(m.GROUPS),eS(null),eB([])):E===m.MEDIA_FILE_DETAIL?(S(m.MEDIA_FILES),e1(null)):E===m.MEDIA_FILES?(S(m.MEDIA_BOX_DETAIL),e1(null)):E===m.MEDIA_BOX_DETAIL?(S(m.MEDIA_BOXES),eW(null),eZ([])):E===m.MEDIA_BOXES?S(m.MAIN):E!==m.MAIN&&S(m.MAIN))},{isActive:E!==m.APP_SHORT_EDIT&&E!==m.MODULE_SHORT_EDIT&&E!==m.APP_PROJECT_INIT&&E!==m.MODULE_PROJECT_INIT});var e9=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.devices({});et(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),e8=(0,d.useCallback)((e=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.device({id:e});eo(l)}catch(e){eN(e.message)}K(!1)}}),function(l){return e.apply(this,arguments)}),[B]),e3=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.applications({});ed(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),e7=(0,d.useCallback)((l=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.application({id:e});ex(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return l.apply(this,arguments)}),[B]),le=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.modules({});eT(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),ll=(0,d.useCallback)((r=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.module({id:e});ev(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return r.apply(this,arguments)}),[B]),lr=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.deviceGroups({});eb(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),lt=(0,d.useCallback)((i=c(function*(e){if(B){K(!0),eN(null);try{var l=yield Promise.all([B.deviceGroup({id:e}),B.devicesByGroup({id:e})]),r=s(l,2),t=r[0],n=r[1];eS(t),eB(n||[])}catch(e){eN(e.message)}K(!1)}}),function(e){return i.apply(this,arguments)}),[B]),ln=(0,d.useCallback)(c(function*(){if(B){K(!0);try{var e=yield B.mediaBoxes();ez(e||[])}catch(e){ee(e.message)}K(!1)}}),[B]),li=(0,d.useCallback)((o=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.mediaBox({id:e});eW(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return o.apply(this,arguments)}),[B]),lo=(0,d.useCallback)((a=c(function*(e){if(B){K(!0);try{var l=yield B.mediaFiles({boxId:e});eZ(l||[])}catch(e){ee(e.message)}K(!1)}}),function(e){return a.apply(this,arguments)}),[B]),la=(0,d.useCallback)((T=c(function*(e){if(B){K(!0),eN(null);try{var l=yield B.mediaFile({id:e});e1(l)}catch(e){eN(e.message)}K(!1)}}),function(e){return T.apply(this,arguments)}),[B]),lc=(0,d.useCallback)((p=c(function*(e){if(B&&ei){eL(!0),eM(null);try{yield B.controlDevice({id:ei._id,type:e}),eM({success:!0,message:`Command sent: ${e}`})}catch(e){eM({success:!1,message:e.message})}eL(!1)}}),function(e){return p.apply(this,arguments)}),[B,ei]),ld=(0,d.useCallback)(c(function*(e=!1){if(B&&ei&&Y){K(!0),ej(null),e$(null);try{e&&(yield B.controlDevice({id:ei._id,type:"take-screenshot"}),yield new Promise(e=>setTimeout(e,3e3)));var l=yield(0,g.he)(B,Y,ei._id,null,{preferThumbnail:!0});l.error?ej(l.error):e$(l)}catch(e){ej(e.message)}K(!1)}}),[B,ei,Y]),lu=v((0,d.useCallback)(()=>{B&&e9()},[B,e9]),e2),ls=v((0,d.useCallback)(()=>{B&&ei&&e8(ei._id)},[B,ei,e8]),e4),lh=v((0,d.useCallback)(()=>{B&&lr()},[B,lr]),e6),lx=v((0,d.useCallback)(()=>{B&&eE&&lt(eE._id)},[B,eE,lt]),e5);return W&&!Y?n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),t(D,{text:"Connecting to workspace..."})]}):Q&&!Y?n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),n(u.Text,{color:"red",children:["Error: ",Q]}),t(b,{})]}):n(u.Box,{flexDirection:"column",children:[t(y,{workspace:Y,view:E}),E===m.MAIN&&t(I,{onSelect:e=>{"exit"===e.value?f():(S(e.value),e.value===m.DEVICES?e9():e.value===m.APPS?e3():e.value===m.MODULES?le():e.value===m.GROUPS?lr():e.value===m.MEDIA_BOXES&&ln())},mediaEnabled:(0,g.wR)(Y),activityLogEnabled:!!(0,x.getActivityLogBaseUrl)()}),E===m.DEVICES&&t(C,{devices:er,loading:W,onSelect:e=>{if("back"===e.value)return void S(m.MAIN);if("refresh"===e.value){e9(),lu.resetCountdown();return}eo(null),K(!0),S(m.DEVICE_DETAIL),e8(e.value)},countdown:lu.countdown,lastRefreshTime:lu.lastRefreshTime}),E===m.DEVICE_DETAIL&&t(k,{device:ei,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.DEVICES),eo(null);return}if("refresh"===e.value){e8(ei._id),ls.resetCountdown();return}"control"===e.value&&(S(m.DEVICE_CONTROL),eM(null)),"screenshot"===e.value&&(S(m.DEVICE_SCREENSHOT),e$(null),ej(null),ld(!1))},mediaEnabled:(0,g.wR)(Y),countdown:ls.countdown,lastRefreshTime:ls.lastRefreshTime}),E===m.DEVICE_CONTROL&&t(L,{device:ei,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),eM(null);return}lc(e.value)},controlling:ek,controlResult:eO}),E===m.DEVICE_SCREENSHOT&&t(w,{device:ei,screenshot:eG,loading:W,error:eF,onSelect:e=>{if("back"===e.value){S(m.DEVICE_DETAIL),e$(null),ej(null);return}"refresh"===e.value?ld(!1):"take"===e.value&&ld(!0)}}),E===m.APPS&&t(O,{apps:ec,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?e3():(ex(null),K(!0),S(m.APP_DETAIL),e7(e.value))}}),E===m.APP_DETAIL&&t(M,{app:eh,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.APPS),ex(null);return}"refresh"===e.value?e7(eh._id):("short_edit"===e.value&&(S(m.APP_SHORT_EDIT),eN(null)),"project_init"===e.value&&(S(m.APP_PROJECT_INIT),eN(null)))}}),E===m.APP_SHORT_EDIT&&t(q,{instanceType:"application",instance:eh,client:B,onDone:c(function*(){return e7(eh._id)}),onCancel:()=>S(m.APP_DETAIL)}),E===m.APP_PROJECT_INIT&&t(eu,{type:"application",instance:eh,client:B,onDone:()=>S(m.APP_DETAIL),onCancel:()=>S(m.APP_DETAIL)}),E===m.MODULES&&t(P,{modules:em,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?le():(ev(null),K(!0),S(m.MODULE_DETAIL),ll(e.value))}}),E===m.MODULE_DETAIL&&t(R,{module:ef,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MODULES),ev(null);return}"refresh"===e.value?ll(ef._id):("short_edit"===e.value&&(S(m.MODULE_SHORT_EDIT),eN(null)),"project_init"===e.value&&(S(m.MODULE_PROJECT_INIT),eN(null)))}}),E===m.MODULE_SHORT_EDIT&&t(q,{instanceType:"module",instance:ef,client:B,onDone:c(function*(){return ll(ef._id)}),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.MODULE_PROJECT_INIT&&t(eu,{type:"module",instance:ef,client:B,onDone:()=>S(m.MODULE_DETAIL),onCancel:()=>S(m.MODULE_DETAIL)}),E===m.GROUPS&&t(N,{groups:ey,loading:W,onSelect:e=>{if("back"===e.value)return void S(m.MAIN);if("refresh"===e.value){lr(),lh.resetCountdown();return}eS(null),eB([]),K(!0),S(m.GROUP_DETAIL),lt(e.value)},countdown:lh.countdown,lastRefreshTime:lh.lastRefreshTime}),E===m.GROUP_DETAIL&&t(G,{group:eE,groupDevices:eA,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.GROUPS),eS(null),eB([]);return}"refresh"===e.value&&(lt(eE._id),lx.resetCountdown())},countdown:lx.countdown,lastRefreshTime:lx.lastRefreshTime}),E===m.ACTIVITY_LOG&&t(z,{onBack:()=>S(m.MAIN)}),E===m.MEDIA_BOXES&&t($,{boxes:eY,loading:W,onSelect:e=>{"back"===e.value?S(m.MAIN):"refresh"===e.value?ln():(eW(null),eZ([]),K(!0),S(m.MEDIA_BOX_DETAIL),li(e.value))}}),E===m.MEDIA_BOX_DETAIL&&t(V,{box:eJ,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MEDIA_BOXES),eW(null),eZ([]);return}"refresh"===e.value?li(eJ.id):"files"===e.value&&(eZ([]),e1(null),S(m.MEDIA_FILES),lo(eJ.id))}}),E===m.MEDIA_FILES&&t(F,{files:eK,box:eJ,loading:W,onSelect:e=>{if("back"===e.value){S(m.MEDIA_BOX_DETAIL),e1(null);return}"refresh"===e.value?lo(eJ.id):(e1(null),K(!0),S(m.MEDIA_FILE_DETAIL),la(e.value))}}),E===m.MEDIA_FILE_DETAIL&&t(j,{file:e0,loading:W,error:eR,onSelect:e=>{if("back"===e.value){S(m.MEDIA_FILES),e1(null);return}"refresh"===e.value&&la(e0.id)}}),t(b,{})]})};var eh="1"===process.env.BRICKS_CLI_DISTRIBUTION,ex=(a=c(function*(){if(eh)return void(0,u.render)(t(es,{}));var e=(yield i.e(166).then(i.bind(i,29557))).TerminalInfoProvider;(0,u.render)(t(e,{children:t(es,{})}))}),function(){return a.apply(this,arguments)})}};
package/lib/index.js CHANGED
@@ -59,11 +59,11 @@ ${y.Ay.bold("Environment Variables")}`),Object.entries(n.env.variables).forEach(
59
59
  Matching Devices (${o.matches.length})`)),console.log("─".repeat(80)),o.matches.forEach(e=>{console.log(`${y.Ay.cyan(e.name||e.device_name||"Unnamed")} ${y.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){i?i.fail(`Failed to resolve device: ${t.message}`):(0,x.OW)(t.message,{resource:"device",query:e}),process.exit(1)}}),function(e,t){return s.apply(this,arguments)})),O.command("bind <passcode>").description("Bind a new device using passcode").option("-n, --name <name>","Device name").option("--dry-run","Validate inputs and show the device binding plan without creating a device").option("-j, --json","Output as JSON").action((p=v(function*(e,t){var a=(0,_.o)(),i=t.json?null:(0,D.default)("Checking passcode...").start();try{var n=yield a.checkBindDevicePasscode({passcode:e});n||(t.json?(0,x.OW)("Invalid passcode or expired",{action:"device.bind"}):i.fail("Invalid passcode or expired"),process.exit(1));var r={name:t.name||n.payload?.deviceName||"CLI Device",deviceName:n.payload?.deviceName||null};if(t.dryRun){i&&i.stop(),(0,E.S5)({action:"device.bind",target:r,request:{passcodePreview:(0,x.$l)(e),requestedName:t.name||null,inferredName:n.payload?.deviceName||null},checks:[(0,E.Iy)("passcode is valid",!0),(0,E.Iy)("device name resolved",!0,r.name)],json:t.json});return}i&&(i.text="Binding device...");var o=yield a.createDevice({bindPasscode:e,name:r.name,deviceName:n.payload?.deviceName});t.json?(0,E.yd)({action:"device.bind",target:T(o,o._id),result:{inferredName:n.payload?.deviceName||null},json:!0}):(i.succeed(`Device bound successfully: ${y.Ay.green(o.name)}`),console.log(y.Ay.gray(`Device ID: ${o._id}`)))}catch(e){t.json?(0,x.OW)(e.message,{action:"device.bind"}):i.fail(`Failed to bind device: ${e.message}`),process.exit(1)}}),function(e,t){return p.apply(this,arguments)})),O.command("control <id> <type>").description("Control a device").option("-p, --payload <json>","Event payload as JSON").option("--dry-run","Validate inputs and show the control request without sending it").option("-j, --json","Output as JSON").action((l=v(function*(e,t,a){try{var i;a.payload&&(i=JSON.parse(a.payload)),yield S({id:e,type:t,eventPayload:i,options:a,progressMessage:`Sending ${t} to device...`,successMessage:`Control event sent: ${y.Ay.green(t)}`,failureMessage:"Failed to control device"})}catch(i){a.json?(0,x.OW)(i.message,{action:"device.control",target:{id:e},type:t}):console.error(y.Ay.red(`Failed to control device: ${i.message}`)),process.exit(1)}}),function(e,t,a){return l.apply(this,arguments)})),O.command("refresh <id>").description("Refresh device application").option("--dry-run","Validate inputs and show the refresh request without sending it").option("-j, --json","Output as JSON").action((d=v(function*(e,t){yield S({id:e,type:"refresh",options:t,progressMessage:"Refreshing device...",successMessage:"Device refreshed",failureMessage:"Failed to refresh device"})}),function(e,t){return d.apply(this,arguments)})),O.command("clear-cache <id>").description("Clear device cache").option("--dry-run","Validate inputs and show the cache-clear request without sending it").option("-j, --json","Output as JSON").action((u=v(function*(e,t){yield S({id:e,type:"clear-cache",options:t,progressMessage:"Clearing cache...",successMessage:"Cache cleared",failureMessage:"Failed to clear cache"})}),function(e,t){return u.apply(this,arguments)})),O.command("screenshot <id>").description("Take device screenshot and save to file").option("-o, --output <path>","Output file path").option("--no-take","Only fetch existing screenshot without taking a new one").action((c=v(function*(e,t){var a=(0,_.o)(),i=(0,D.default)("Fetching workspace info...").start();try{var n=yield a.workspace();n?.media_resource?.enable_media_workspace||(i.fail("Media workspace is not enabled for this workspace"),process.exit(1)),n.media_resource.system_media_box_id||(i.fail("No media box configured for this workspace"),process.exit(1)),!1!==t.take&&(i.text="Sending screenshot request to device...",yield a.controlDevice({id:e,type:"take-screenshot"}),i.text="Waiting for device to capture screenshot...",yield new Promise(e=>setTimeout(e,3e3))),i.text="Fetching screenshot...";var r=yield(0,b.he)(a,n,e,t.output);if(r.error&&(i.fail(r.error),process.exit(1)),i.succeed("Screenshot saved"),console.log(),console.log(y.Ay.bold("Screenshot saved to:")),console.log(y.Ay.cyan(r.path)),console.log(),r.file?.meta){var o=r.file.meta,s=o.originalWidth,p=o.originalHeight,l=o.originalFileSize;if(s&&p&&console.log(`${y.Ay.gray("Size:")} ${s}x${p}`),l){var d=(l/1024).toFixed(1);console.log(`${y.Ay.gray("File:")} ${d} KB`)}}r.file?.updatedAt&&console.log(`${y.Ay.gray("Updated:")} ${new Date(r.file.updatedAt).toLocaleString()}`)}catch(e){i.fail(`Failed to get screenshot: ${e.message}`),process.exit(1)}}),function(e,t){return c.apply(this,arguments)})),O.command("metrics <id>").description("Show device metrics (uptime, memory, disk)").option("--start-date <date>","Start date/time (ISO 8601 or relative e.g. 1h, 2d, default: today)").option("--end-date <date>","End date/time (ISO 8601 or relative e.g. 1h, 2d, default: now)").option("-j, --json","Output as JSON").action((m=v(function*(e,t){var a=(0,_.o)(),i=(0,D.default)("Fetching device metrics...").start();try{var n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).toISOString(),o=t.startDate?(0,F.p)(t.startDate):r,s=t.endDate?(0,F.p)(t.endDate):n.toISOString(),p=yield a.deviceUsage({deviceId:e,startDate:o,endDate:s});if(i.stop(),!p||0===p.length)return void console.log(y.Ay.yellow("No metrics data found for this device"));if(t.json)return void console.log(JSON.stringify(p,null,2));for(var l of(console.log(y.Ay.bold(`
60
60
  Device Metrics: ${e}`)),console.log("─".repeat(60)),console.log(y.Ay.gray(`${"Date".padEnd(12)} ${"Uptime Events".padEnd(15)} ${"Avg Memory".padEnd(12)} ${"Avg Disk".padEnd(10)}`)),console.log("─".repeat(60)),p)){var d=(l.date||"").padEnd(12),u=String(l.uptime?.length||0).padEnd(15),c="N/A";if(l.memory_usage?.length){var m=0,f=0;for(var v of l.memory_usage){var g=v.values||[],b=h(g,2),x=b[0],w=b[1];null!=x&&null!=w&&w>0&&(m+=x,f+=w)}f>0&&(c=`${(m/f*100).toFixed(1)}%`)}var E="N/A";if(l.disk_usage?.length){var C=0,T=0;for(var A of l.disk_usage){var S=A.values||[],O=h(S,2),N=O[0],k=O[1];null!=N&&null!=k&&k>0&&(C+=N,T+=k)}T>0&&(E=`${(C/T*100).toFixed(1)}%`)}console.log(`${d} ${u} ${c.padEnd(12)} ${E.padEnd(10)}`)}console.log("─".repeat(60))}catch(e){i.fail(`Failed to get device metrics: ${e.message}`),process.exit(1)}}),function(e,t){return m.apply(this,arguments)})),O.command("monitor").description("Monitor device status (polls every 60s)").option("-g, --group <id>","Monitor devices in a group").option("-i, --interval <seconds>","Polling interval in seconds","60").action((f=v(function*(e){var t,a=(0,_.o)(),i=1e3*parseInt(e.interval,10);console.log(y.Ay.bold("\nDevice Monitor")),console.log(y.Ay.gray(`Polling every ${e.interval}s. Press Ctrl+C to stop.
61
61
  `));var n=(t=v(function*(){try{var t;if(t=e.group?yield a.devicesByGroup({id:e.group}):yield a.devices({}),process.stdout.write("\x1b[2J\x1b[0f"),console.log(y.Ay.bold("Device Monitor")+y.Ay.gray(` - ${new Date().toLocaleTimeString()}`)),console.log("─".repeat(80)),!t||0===t.length)return void console.log(y.Ay.yellow("No devices found"));t.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=C(t),i=e.name||e.device_name||e.device_target_name,n=e.entry_detail?.application?.name||y.Ay.gray("No app");console.log(`${a} ${y.Ay.cyan(i.padEnd(25))} ${n}`)}),console.log(`
62
- ${y.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(y.Ay.red(`Error: ${e.message}`))}}),function(){return t.apply(this,arguments)});yield n(),setInterval(n,i)}),function(e){return f.apply(this,arguments)}))},80274(e,t,a){a.d(t,{g:()=>q});var i,n,r,o,s,p,l,d,u,c,m,f,h,v,g,y,D,b,x,_,w,E,F,C,T,A,S=a(68832),O=a(99436),N=a(35679),k=a(73284),I=a(51455),$=a(76760),j=a(75646),B=(i=O(function*(e,t,a=3e3){var i;try{var n=new AbortController;i=setTimeout(()=>n.abort(),a);var r=yield fetch(`http://${e}:${t}/json/list`,{signal:n.signal});if(!r.ok)return null;return yield r.json()}catch{return null}finally{void 0!==i&&clearTimeout(i)}}),function(e,t){return i.apply(this,arguments)}),R=e=>{if(!e)return null;var t=e.match(/\/ws\/(.+)$/);return t?decodeURIComponent(t[1]):null},V=(n=O(function*(e,t=1e3){for(var a=[],i=e,n=0;n<10;n++){var r=$.join(i,".bricks","devtools.json");try{var o=yield I.readFile(r,"utf8"),s=JSON.parse(o),p=yield(0,j.verifyDevToolsServer)(s.address||"localhost",s.port,t);p&&a.push({name:s.name||"BRICKS Preview (CTOR Preview)",address:s.address||"localhost",port:s.port,protocols:["cdp"],hasPasscode:!1,source:"project",projectPath:i,...p})}catch{}var l=$.dirname(i);if(l===i)break;i=l}return a}),function(e){return n.apply(this,arguments)}),P=(r=O(function*({timeout:e=3e3,verify:t=!1,udpOnly:a=!1,project:i=!0,port:n=19851,cwd:r=process.cwd(),onStatus:o}={}){var s,p=(0,j.discoverDevToolsServers)({timeout:e,idleTimeout:800}),l=a?Promise.resolve([]):(o?.("Scanning via UDP + HTTP probe..."),(0,j.httpProbeSubnet)({port:n,timeout:e})),d=i?V(r,1e3):Promise.resolve([]),u=S((yield Promise.all([p,l,d])),3),c=(e=>{var t=new Map;for(var a of e){var i=a.deviceId||`${a.address}:${a.port}`,n=t.get(i);if(!n){t.set(i,{...a,addresses:[a.address],protocols:[...a.protocols||[]]});continue}for(var r of(n.addresses.includes(a.address)||n.addresses.push(a.address),"127.0.0.1"===n.address&&"127.0.0.1"!==a.address&&(n.address=a.address),a.protocols||[]))n.protocols.includes(r)||n.protocols.push(r);for(var o of Object.entries(a)){var s=S(o,2),p=s[0],l=s[1];null!=l&&"address"!==p&&"addresses"!==p&&"protocols"!==p&&(void 0===n[p]||null===n[p])&&(n[p]=l)}}return[...t.values()]})([...u[0],...u[1],...u[2]]);if(0===c.length)return[];if(t){o?.(`Verifying ${c.length} server(s)...`);var m,f=yield Promise.all(c.map((m=O(function*(e){var t=yield(0,j.verifyDevToolsServer)(e.address,e.port);return{...e,verified:!!t,version:t?.version||e.version}}),function(e){return m.apply(this,arguments)})));c.splice(0,c.length,...f)}return o?.("Checking chrome://inspect support..."),yield Promise.all(c.map((s=O(function*(e){var t=yield B(e.address,e.port);if(t){e.chromeInspect=!0;var a=R(t[0]?.webSocketDebuggerUrl);a&&(e.passcode=a)}}),function(e){return s.apply(this,arguments)}))),c}),function(){return r.apply(this,arguments)}),L="2.24",M="19851",U=e=>{if(!e)return!1;for(var t=e.replace(/^v/,"").split(".").map(Number),a=L.split(".").map(Number),i=0;i<a.length&&!((t[i]||0)>a[i]);i++)if((t[i]||0)<a[i])return!1;return!0},q=new N.uB("devtools").description("DevTools server discovery, inspection, and CDP commands").option("-a, --address <address>","DevTools server address for CDP commands").option("-p, --port <port>",`Server port for CDP commands (default: ${M})`).option("--passcode <passcode>","Device passcode for CDP commands"),G=e=>e.option("-a, --address <address>","DevTools server address").option("-p, --port <port>",`Server port (default: ${M})`).option("--passcode <passcode>","Device passcode").option("-j, --json","Output as JSON"),z=(o=O(function*(e,t){var i,n,r=(yield Promise.resolve().then(a.bind(a,30155))).default,o=(yield Promise.resolve().then(a.bind(a,75646))).verifyDevToolsServer,s=(yield a.e(178).then(a.bind(a,28193))).createCdpClient,p=(i=q.opts(),{...e,address:e.address??i.address,port:e.port??i.port??M,passcode:e.passcode??i.passcode});p.address||(console.error(k.Ay.red("Missing required option: --address <address>")),process.exit(1));var l=parseInt(p.port,10),d=r("Connecting to DevTools...").start();try{var u=yield o(p.address,l);u||(d.fail(`Cannot reach DevTools server at ${p.address}:${l}`),process.exit(1)),u.version&&!U(u.version)&&(d.fail(`CDP requires app version >= ${L} (device: ${u.version})`),process.exit(1)),n=s(p.address,l,p.passcode),yield n.connect(),d.stop(),yield t(n)}catch(e){d.isSpinning&&d.stop(),console.error(k.Ay.red(e.message)),process.exit(1)}finally{n?.close()}}),function(e,t){return o.apply(this,arguments)}),Y=e=>{if(!e)return{};for(var t={},a=0;a<e.length;a+=2)t[e[a]]=e[a+1];return t},Q=(e,t="",a=!0,i=!0)=>{var n=[],r=i?"":a?" ":"│ ",o=e.nodeName||"#unknown";if(9===e.nodeType)o="#document";else if(3===e.nodeType){var s=e.nodeValue||"";o=k.Ay.gray(`"${s}"`)}else if(1===e.nodeType){var p=Y(e.attributes),l=p.id||p["short-id"];l&&(o+=k.Ay.gray(`#${l}`)),p.title&&(o+=` ${k.Ay.green(`"${p.title}"`)}`),void 0!==p.w&&void 0!==p.h&&(o+=k.Ay.blue(` ${p.w}\xd7${p.h}`),void 0!==p.x&&void 0!==p.y&&(o+=k.Ay.blue(` @${p.x},${p.y}`)));var d=[];void 0!==p.hide&&d.push(k.Ay.red("hidden")),void 0!==p.pressable&&d.push(k.Ay.yellow("pressable")),void 0!==p.editable&&d.push(k.Ay.yellow("editable")),d.length>0&&(o+=` [${d.join(", ")}]`)}n.push(`${t}${i?"":a?"└─ ":"├─ "}${o}`);var u=e.children||[];return u.forEach((e,a)=>{n.push(...Q(e,t+r,a===u.length-1,!1))}),n};q.command("scan").description("Scan LAN for DevTools servers via UDP + HTTP").option("-t, --timeout <ms>","Scan timeout in milliseconds","3000").option("-j, --json","Output as JSON").option("--verify","Verify each discovered server via HTTP").option("--udp-only","Skip HTTP subnet probe (UDP only)").option("--no-project","Exclude local BRICKS project preview servers").option("-p, --port <port>","Port for HTTP probe","19851").action((s=O(function*(e){var t=(yield Promise.resolve().then(a.bind(a,30155))).default,i=yield Promise.resolve().then(a.bind(a,23258)),n=i.getCurrentProfile,r=i.getTokenInfo,o=parseInt(e.timeout,10),s=t(`Scanning for DevTools servers (${o}ms)...`).start();try{var p=yield P({timeout:o,verify:!!e.verify,udpOnly:!!e.udpOnly,project:!!e.project,port:parseInt(e.port,10),onStatus:e=>{s.text=e}});if(0===p.length){e.json?(s.stop(),console.log(JSON.stringify([],null,2))):s.info("No DevTools servers found on the network."),process.exit(0);return}s.stop(),e.json&&(console.log(JSON.stringify(p,null,2)),process.exit(0));var l=n(),d=r(l),u=d?.workspaceId||null;console.log(k.Ay.bold(`
62
+ ${y.Ay.gray("Press Ctrl+C to stop")}`)}catch(e){console.error(y.Ay.red(`Error: ${e.message}`))}}),function(){return t.apply(this,arguments)});yield n(),setInterval(n,i)}),function(e){return f.apply(this,arguments)}))},80274(e,t,a){a.d(t,{gf:()=>z});var i,n,r,o,s,p,l,d,u,c,m,f,h,v,g,y,D,b,x,_,w,E,F,C,T,A,S=a(68832),O=a(99436),N=a(35679),k=a(73284),I=a(51455),$=a(76760),j=a(75646),B=(i=O(function*(e,t,a=3e3){var i;try{var n=new AbortController;i=setTimeout(()=>n.abort(),a);var r=yield fetch(`http://${e}:${t}/json/list`,{signal:n.signal});if(!r.ok)return null;return yield r.json()}catch{return null}finally{void 0!==i&&clearTimeout(i)}}),function(e,t){return i.apply(this,arguments)}),R=e=>{if(!e)return null;var t=e.match(/\/ws\/(.+)$/);return t?decodeURIComponent(t[1]):null},V=(n=O(function*(e,t=1e3){for(var a=[],i=e,n=0;n<10;n++){var r=$.join(i,".bricks","devtools.json");try{var o=yield I.readFile(r,"utf8"),s=JSON.parse(o),p=yield(0,j.verifyDevToolsServer)(s.address||"localhost",s.port,t);p&&a.push({name:s.name||"BRICKS Preview (CTOR Preview)",address:s.address||"localhost",port:s.port,protocols:["cdp"],hasPasscode:!1,source:"project",projectPath:i,...p})}catch{}var l=$.dirname(i);if(l===i)break;i=l}return a}),function(e){return n.apply(this,arguments)}),P=(r=O(function*({timeout:e=3e3,verify:t=!1,udpOnly:a=!1,project:i=!0,port:n=19851,cwd:r=process.cwd(),onStatus:o}={}){var s,p=(0,j.discoverDevToolsServers)({timeout:e,idleTimeout:800}),l=a?Promise.resolve([]):(o?.("Scanning via UDP + HTTP probe..."),(0,j.httpProbeSubnet)({port:n,timeout:e})),d=i?V(r,1e3):Promise.resolve([]),u=S((yield Promise.all([p,l,d])),3),c=(e=>{var t=new Map;for(var a of e){var i=a.deviceId||`${a.address}:${a.port}`,n=t.get(i);if(!n){t.set(i,{...a,addresses:[a.address],protocols:[...a.protocols||[]]});continue}for(var r of(n.addresses.includes(a.address)||n.addresses.push(a.address),"127.0.0.1"===n.address&&"127.0.0.1"!==a.address&&(n.address=a.address),a.protocols||[]))n.protocols.includes(r)||n.protocols.push(r);for(var o of Object.entries(a)){var s=S(o,2),p=s[0],l=s[1];null!=l&&"address"!==p&&"addresses"!==p&&"protocols"!==p&&(void 0===n[p]||null===n[p])&&(n[p]=l)}}return[...t.values()]})([...u[0],...u[1],...u[2]]);if(0===c.length)return[];if(t){o?.(`Verifying ${c.length} server(s)...`);var m,f=yield Promise.all(c.map((m=O(function*(e){var t=yield(0,j.verifyDevToolsServer)(e.address,e.port);return{...e,verified:!!t,version:t?.version||e.version}}),function(e){return m.apply(this,arguments)})));c.splice(0,c.length,...f)}return o?.("Checking chrome://inspect support..."),yield Promise.all(c.map((s=O(function*(e){var t=yield B(e.address,e.port);if(t){e.chromeInspect=!0;var a=R(t[0]?.webSocketDebuggerUrl);a&&(e.passcode=a)}}),function(e){return s.apply(this,arguments)}))),c}),function(){return r.apply(this,arguments)}),L="2.24",M="19851",U="127.0.0.1",q=e=>{if(!e)return{host:void 0,port:void 0};var t=e.match(/^\[([^\]]+)\](?::(\d+))?$/);if(t)return{host:t[1],port:t[2]};var a=e.lastIndexOf(":");if(a>0&&e.indexOf(":")===a){var i=e.slice(a+1);if(/^\d+$/.test(i))return{host:e.slice(0,a),port:i}}return{host:e,port:void 0}},G=e=>{if(!e)return!1;for(var t=e.replace(/^v/,"").split(".").map(Number),a=L.split(".").map(Number),i=0;i<a.length&&!((t[i]||0)>a[i]);i++)if((t[i]||0)<a[i])return!1;return!0},z=new N.uB("devtools").description("DevTools server discovery, inspection, and CDP commands").option("-a, --address <address>",`DevTools server address, host or host:port (default: ${U})`).option("-p, --port <port>",`Server port for CDP commands (default: ${M})`).option("--passcode <passcode>","Device passcode for CDP commands"),Y=e=>e.option("-a, --address <address>","DevTools server address, host or host:port").option("-p, --port <port>",`Server port (default: ${M})`).option("--passcode <passcode>","Device passcode").option("-j, --json","Output as JSON"),Q=(o=O(function*(e,t){var i,n,r,o=(yield Promise.resolve().then(a.bind(a,30155))).default,s=(yield Promise.resolve().then(a.bind(a,75646))).verifyDevToolsServer,p=(yield a.e(178).then(a.bind(a,28193))).createCdpClient,l=(i=z.opts(),n=q(e.address??i.address),{...e,address:n.host??U,port:e.port??i.port??n.port??M,passcode:e.passcode??i.passcode}),d=parseInt(l.port,10),u=o("Connecting to DevTools...").start();try{var c=yield s(l.address,d);c||(u.fail(`Cannot reach DevTools server at ${l.address}:${d}`),process.exit(1)),c.version&&!G(c.version)&&(u.fail(`CDP requires app version >= ${L} (device: ${c.version})`),process.exit(1)),r=p(l.address,d,l.passcode),yield r.connect(),u.stop(),yield t(r)}catch(e){u.isSpinning&&u.stop(),console.error(k.Ay.red(e.message)),process.exit(1)}finally{r?.close()}}),function(e,t){return o.apply(this,arguments)}),J=e=>{if(!e)return{};for(var t={},a=0;a<e.length;a+=2)t[e[a]]=e[a+1];return t},H=(e,t="",a=!0,i=!0)=>{var n=[],r=i?"":a?" ":"│ ",o=e.nodeName||"#unknown";if(9===e.nodeType)o="#document";else if(3===e.nodeType){var s=e.nodeValue||"";o=k.Ay.gray(`"${s}"`)}else if(1===e.nodeType){var p=J(e.attributes),l=p.id||p["short-id"];l&&(o+=k.Ay.gray(`#${l}`)),p.title&&(o+=` ${k.Ay.green(`"${p.title}"`)}`),void 0!==p.w&&void 0!==p.h&&(o+=k.Ay.blue(` ${p.w}\xd7${p.h}`),void 0!==p.x&&void 0!==p.y&&(o+=k.Ay.blue(` @${p.x},${p.y}`)));var d=[];void 0!==p.hide&&d.push(k.Ay.red("hidden")),void 0!==p.pressable&&d.push(k.Ay.yellow("pressable")),void 0!==p.editable&&d.push(k.Ay.yellow("editable")),d.length>0&&(o+=` [${d.join(", ")}]`)}n.push(`${t}${i?"":a?"└─ ":"├─ "}${o}`);var u=e.children||[];return u.forEach((e,a)=>{n.push(...H(e,t+r,a===u.length-1,!1))}),n};z.command("scan").description("Scan LAN for DevTools servers via UDP + HTTP").option("-t, --timeout <ms>","Scan timeout in milliseconds","3000").option("-j, --json","Output as JSON").option("--verify","Verify each discovered server via HTTP").option("--udp-only","Skip HTTP subnet probe (UDP only)").option("--no-project","Exclude local BRICKS project preview servers").option("-p, --port <port>","Port for HTTP probe","19851").action((s=O(function*(e){var t=(yield Promise.resolve().then(a.bind(a,30155))).default,i=yield Promise.resolve().then(a.bind(a,23258)),n=i.getCurrentProfile,r=i.getTokenInfo,o=parseInt(e.timeout,10),s=t(`Scanning for DevTools servers (${o}ms)...`).start();try{var p=yield P({timeout:o,verify:!!e.verify,udpOnly:!!e.udpOnly,project:!!e.project,port:parseInt(e.port,10),onStatus:e=>{s.text=e}});if(0===p.length){e.json?(s.stop(),console.log(JSON.stringify([],null,2))):s.info("No DevTools servers found on the network."),process.exit(0);return}s.stop(),e.json&&(console.log(JSON.stringify(p,null,2)),process.exit(0));var l=n(),d=r(l),u=d?.workspaceId||null;console.log(k.Ay.bold(`
63
63
  Found ${p.length} DevTools server(s)`)),console.log("─".repeat(80));var c=function*(e){var t=!1===e.verified?k.Ay.red("unverified"):k.Ay.green("online"),a=e.hasPasscode?k.Ay.yellow("passcode"):k.Ay.gray("open"),i=(e.protocols||[]).map(e=>k.Ay.cyan(e)).join(", "),n=e.workspaceId&&u&&e.workspaceId===u,r=e.addresses||[e.address],o=r.filter(t=>t!==e.address),s=o.length>0?`${e.address}:${e.port} +${o.length} more`:`${e.address}:${e.port}`;if(console.log(` ${k.Ay.bold(e.name||"Unknown")} ${k.Ay.gray(`(${s})`)} [${t}]`),o.length>0&&console.log(` Addresses: ${r.map(e=>k.Ay.gray(e)).join(", ")}`),e.version&&console.log(` Version: ${k.Ay.green(e.version)}`),e.chromeInspect){var p=e.passcode?k.Ay.cyan(e.passcode):k.Ay.gray("no passcode");console.log(` Chrome Inspect: ${k.Ay.green("supported")} (passcode: ${p})`)}var l=` Protocols: ${i||k.Ay.gray("none")} Auth: ${a}`;if(e.deviceId&&(l+=` Device: ${k.Ay.gray(e.deviceId)}`),console.log(l),e.workspaceId){var d=n?k.Ay.green(`${e.workspaceId} (current profile)`):k.Ay.gray(e.workspaceId);console.log(` Workspace: ${d}`)}};for(var m of p)yield*c(m);console.log("─".repeat(80));var f=p[0],h=`${f.address}:${f.port||19851}`,v=f.passcode?`/ws/${encodeURIComponent(f.passcode)}`:"/ws/<passcode>";console.log(k.Ay.gray(`
64
- Connect via: http://${h}/devtools-frontend/inspector.html?ws=${h}${v}`)),console.log(k.Ay.gray(`Legacy: devtools://devtools/bundled/inspector.html?ws=${h}${v}`)),process.exit(0)}catch(e){s.fail(`Scan failed: ${e.message}`),process.exit(1)}}),function(e){return s.apply(this,arguments)})),q.command("open <address>").description("Show DevTools server information").option("-p, --port <port>","Server port","19851").option("--info","Show connection URLs").action((p=O(function*(e,t){var i=(yield Promise.resolve().then(a.bind(a,30155))).default,n=(yield Promise.resolve().then(a.bind(a,75646))).verifyDevToolsServer,r=parseInt(t.port,10),o=`${e}:${r}`,s=i(`Fetching server info from ${o}...`).start(),p=yield n(e,r);p||(s.fail(`Could not reach DevTools server at ${o}`),process.exit(1)),s.stop();var l=yield B(e,r),d=l?R(l?.[0]?.webSocketDebuggerUrl):null,u=d?`/ws/${encodeURIComponent(d)}`:"/ws/<passcode>";if(t.info){console.log(k.Ay.bold("Connection URLs")),console.log("─".repeat(60)),console.log(` Web UI: ${k.Ay.cyan(`http://${o}`)}`),console.log(` CDP: ${k.Ay.cyan(`http://${o}/devtools-frontend/inspector.html?ws=${o}${u}`)}`),console.log(` CDP legacy: ${k.Ay.cyan(`devtools://devtools/bundled/inspector.html?ws=${o}${u}`)}`),console.log(` MCP: ${k.Ay.cyan(`http://${o}/mcp`)}`),console.log(` MCP SSE: ${k.Ay.cyan(`http://${o}/sse`)}`),console.log(` Info: ${k.Ay.cyan(`http://${o}/devtools/info`)}`),console.log("─".repeat(60)),console.log(),console.log(k.Ay.bold("Authorization")),d&&console.log(` Passcode: ${k.Ay.cyan(d)}`),console.log(" MCP and MCP SSE require a Bearer token header with the device passcode:"),console.log(` ${k.Ay.gray(`Authorization: Bearer ${d||"<passcode>"}`)}`);return}if(console.log(k.Ay.bold("DevTools Server")),console.log("─".repeat(60)),console.log(` Name: ${k.Ay.cyan(p.name||"Unknown")}`),console.log(` Version: ${p.version?k.Ay.green(p.version):k.Ay.gray("N/A")}`),console.log(` Device ID: ${k.Ay.gray(p.deviceId||"N/A")}`),console.log(` Workspace: ${k.Ay.gray(p.workspaceId||"N/A")}`),console.log(` Protocols: ${(p.protocols||[]).map(e=>k.Ay.cyan(e)).join(", ")||k.Ay.gray("none")}`),console.log(` Auth: ${p.hasPasscode?k.Ay.yellow("passcode required"):k.Ay.gray("open")}`),console.log(` Port: ${p.port}`),l){var c=d?k.Ay.cyan(d):k.Ay.gray("no passcode");console.log(` Inspect: ${k.Ay.green("chrome://inspect supported")} (passcode: ${c})`)}else console.log(` Inspect: ${k.Ay.gray("chrome://inspect not available")}`);console.log("─".repeat(60)),p.version&&!U(p.version)&&console.log(k.Ay.yellow(`
64
+ Connect via: http://${h}/devtools-frontend/inspector.html?ws=${h}${v}`)),console.log(k.Ay.gray(`Legacy: devtools://devtools/bundled/inspector.html?ws=${h}${v}`)),process.exit(0)}catch(e){s.fail(`Scan failed: ${e.message}`),process.exit(1)}}),function(e){return s.apply(this,arguments)})),z.command("open <address>").description("Show DevTools server information").option("-p, --port <port>",`Server port (default: ${M})`).option("--info","Show connection URLs").action((p=O(function*(e,t){var i=(yield Promise.resolve().then(a.bind(a,30155))).default,n=(yield Promise.resolve().then(a.bind(a,75646))).verifyDevToolsServer,r=q(e),o=r.host??U,s=parseInt(t.port??r.port??M,10),p=`${o}:${s}`,l=i(`Fetching server info from ${p}...`).start(),d=yield n(o,s);d||(l.fail(`Could not reach DevTools server at ${p}`),process.exit(1)),l.stop();var u=yield B(o,s),c=u?R(u?.[0]?.webSocketDebuggerUrl):null,m=c?`/ws/${encodeURIComponent(c)}`:"/ws/<passcode>";if(t.info){console.log(k.Ay.bold("Connection URLs")),console.log("─".repeat(60)),console.log(` Web UI: ${k.Ay.cyan(`http://${p}`)}`),console.log(` CDP: ${k.Ay.cyan(`http://${p}/devtools-frontend/inspector.html?ws=${p}${m}`)}`),console.log(` CDP legacy: ${k.Ay.cyan(`devtools://devtools/bundled/inspector.html?ws=${p}${m}`)}`),console.log(` MCP: ${k.Ay.cyan(`http://${p}/mcp`)}`),console.log(` MCP SSE: ${k.Ay.cyan(`http://${p}/sse`)}`),console.log(` Info: ${k.Ay.cyan(`http://${p}/devtools/info`)}`),console.log("─".repeat(60)),console.log(),console.log(k.Ay.bold("Authorization")),c&&console.log(` Passcode: ${k.Ay.cyan(c)}`),console.log(" MCP and MCP SSE require a Bearer token header with the device passcode:"),console.log(` ${k.Ay.gray(`Authorization: Bearer ${c||"<passcode>"}`)}`);return}if(console.log(k.Ay.bold("DevTools Server")),console.log("─".repeat(60)),console.log(` Name: ${k.Ay.cyan(d.name||"Unknown")}`),console.log(` Version: ${d.version?k.Ay.green(d.version):k.Ay.gray("N/A")}`),console.log(` Device ID: ${k.Ay.gray(d.deviceId||"N/A")}`),console.log(` Workspace: ${k.Ay.gray(d.workspaceId||"N/A")}`),console.log(` Protocols: ${(d.protocols||[]).map(e=>k.Ay.cyan(e)).join(", ")||k.Ay.gray("none")}`),console.log(` Auth: ${d.hasPasscode?k.Ay.yellow("passcode required"):k.Ay.gray("open")}`),console.log(` Port: ${d.port}`),u){var f=c?k.Ay.cyan(c):k.Ay.gray("no passcode");console.log(` Inspect: ${k.Ay.green("chrome://inspect supported")} (passcode: ${f})`)}else console.log(` Inspect: ${k.Ay.gray("chrome://inspect not available")}`);console.log("─".repeat(60)),d.version&&!G(d.version)&&console.log(k.Ay.yellow(`
65
65
  CDP commands require version >= ${L}`)),console.log(k.Ay.gray(`
66
- Use --info to see connection URLs`))}),function(e,t){return p.apply(this,arguments)})),G(q.command("screenshot").description("Capture device screenshot").option("-o, --output <path>","Output file path")).action((l=O(function*(e){var t;yield z(e,(t=O(function*(t){var i=yield t.send("Page.captureScreenshot",{format:"png"});i.data||(console.error(k.Ay.red("No screenshot data received")),process.exit(1));var n=yield Promise.resolve().then(a.t.bind(a,73024,19)),r=yield Promise.resolve().then(a.t.bind(a,76760,19)),o=e.output||`screenshot-${Date.now()}.png`,s=r.resolve(o);n.writeFileSync(s,Buffer.from(i.data,"base64")),console.log(k.Ay.green(`Screenshot saved to ${s}`))}),function(e){return t.apply(this,arguments)}))}),function(e){return l.apply(this,arguments)}));var J=q.command("brick").description("Brick component inspection");G(J.command("tree").description("Print brick component tree").option("-d, --depth <depth>","Max depth (-1 for full)","3")).action((d=O(function*(e){var t;yield z(e,(t=O(function*(t){yield t.send("DOM.enable");var a=parseInt(e.depth,10),i=(yield t.send("DOM.getDocument",{depth:a})).root;e.json?console.log(JSON.stringify(i,null,2)):console.log(Q(i).join("\n"))}),function(e){return t.apply(this,arguments)}))}),function(e){return d.apply(this,arguments)})),G(J.command("query <selector>").description("Find brick by CSS selector")).action((u=O(function*(e,t){var a;yield z(t,(a=O(function*(a){yield a.send("DOM.enable");var i=(yield a.send("DOM.getDocument",{depth:0})).root,n=(yield a.send("DOM.querySelector",{nodeId:i.nodeId,selector:e})).nodeId;if(0===n)return void console.log(k.Ay.yellow("No element found"));var r=yield a.send("DOM.describeNode",{nodeId:n}),o=Y((yield a.send("DOM.getAttributes",{nodeId:n})).attributes);if(t.json)return void console.log(JSON.stringify({nodeId:n,...r.node,attributes:o},null,2));if(console.log(k.Ay.bold(`Node ${n}: ${r.node?.nodeName||"unknown"}`)),Object.keys(o).length>0)for(var s of(console.log(k.Ay.bold("Attributes:")),Object.entries(o))){var p=S(s,2),l=p[0],d=p[1];console.log(` ${k.Ay.cyan(l)}: ${d}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return u.apply(this,arguments)})),G(J.command("query-all <selector>").description("Find all bricks matching CSS selector")).action((c=O(function*(e,t){var a;yield z(t,(a=O(function*(a){yield a.send("DOM.enable");var i=(yield a.send("DOM.getDocument",{depth:0})).root,n=(yield a.send("DOM.querySelectorAll",{nodeId:i.nodeId,selector:e})).nodeIds;if(t.json)return void console.log(JSON.stringify({nodeIds:n,count:n.length},null,2));for(var r of(console.log(k.Ay.bold(`Found ${n.length} element(s)`)),n)){var o=yield a.send("DOM.describeNode",{nodeId:r}),s=Y((yield a.send("DOM.getAttributes",{nodeId:r})).attributes),p=s.id||s["short-id"]||"";console.log(` ${r}: ${o.node?.nodeName}${p?k.Ay.gray(`#${p}`):""}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return c.apply(this,arguments)})),G(J.command("attributes <nodeId>").description("Get brick attributes")).action((m=O(function*(e,t){var a;yield z(t,(a=O(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=Y((yield a.send("DOM.getAttributes",{nodeId:i})).attributes);if(t.json)return void console.log(JSON.stringify(n,null,2));if(0===Object.keys(n).length)return void console.log(k.Ay.gray("No attributes"));for(var r of Object.entries(n)){var o=S(r,2),s=o[0],p=o[1];console.log(` ${k.Ay.cyan(s)}: ${p}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return m.apply(this,arguments)})),G(J.command("box-model <nodeId>").description("Get brick dimensions and position")).action((f=O(function*(e,t){var a;yield z(t,(a=O(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=(yield a.send("DOM.getBoxModel",{nodeId:i})).model;t.json?console.log(JSON.stringify(n,null,2)):(console.log(k.Ay.bold(`Box Model for node ${i}`)),console.log(` Width: ${n.width}`),console.log(` Height: ${n.height}`),n.content&&console.log(` Content: [${n.content.join(", ")}]`),n.padding&&console.log(` Padding: [${n.padding.join(", ")}]`),n.border&&console.log(` Border: [${n.border.join(", ")}]`),n.margin&&console.log(` Margin: [${n.margin.join(", ")}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return f.apply(this,arguments)})),G(J.command("resolve <nodeId>").description("Resolve brick to JavaScript object with properties")).action((h=O(function*(e,t){var a;yield z(t,(a=O(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=(yield a.send("DOM.resolveNode",{nodeId:i})).object;if(t.json)return void console.log(JSON.stringify(n,null,2));if(console.log(k.Ay.bold(`Resolved node ${i}`)),console.log(` Type: ${n.type}`),n.className&&console.log(` Class: ${n.className}`),n.description&&console.log(` Description: ${n.description}`),n.objectId&&console.log(` Object ID: ${k.Ay.gray(n.objectId)}`),n.preview?.properties)for(var r of(console.log(k.Ay.bold(" Properties:")),n.preview.properties))console.log(` ${k.Ay.cyan(r.name)}: ${r.value}`)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return h.apply(this,arguments)})),G(J.command("focus <nodeId>").description("Focus a brick element")).action((v=O(function*(e,t){var a;yield z(t,(a=O(function*(t){yield t.send("DOM.enable");var a=parseInt(e,10);yield t.send("DOM.focus",{nodeId:a}),console.log(k.Ay.green(`Focused node ${a}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return v.apply(this,arguments)}));var H=q.command("input").description("Input emulation");G(H.command("tap <x> <y>").description("Tap/click at coordinates")).action((g=O(function*(e,t,a){var i;yield z(a,(i=O(function*(a){var i=parseFloat(e),n=parseFloat(t);yield a.send("Input.dispatchMouseEvent",{type:"mousePressed",x:i,y:n,button:"left",clickCount:1}),yield a.send("Input.dispatchMouseEvent",{type:"mouseReleased",x:i,y:n,button:"left",clickCount:1}),console.log(k.Ay.green(`Tapped at (${i}, ${n})`))}),function(e){return i.apply(this,arguments)}))}),function(e,t,a){return g.apply(this,arguments)})),G(H.command("type <text>").description("Insert text into focused element")).action((y=O(function*(e,t){var a;yield z(t,(a=O(function*(t){yield t.send("Input.insertText",{text:e}),console.log(k.Ay.green(`Typed: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return y.apply(this,arguments)})),G(H.command("key <key>").description("Dispatch key event (e.g., Enter, Escape, Tab)")).action((D=O(function*(e,t){var a;yield z(t,(a=O(function*(t){yield t.send("Input.dispatchKeyEvent",{type:"keyDown",key:e}),yield t.send("Input.dispatchKeyEvent",{type:"keyUp",key:e}),console.log(k.Ay.green(`Key: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return D.apply(this,arguments)}));var W=q.command("network").description("Network inspection");G(W.command("list").description("Capture snapshot of network activity").option("--duration <ms>","Capture duration in milliseconds","2000")).action((b=O(function*(e){var t;yield z(e,(t=O(function*(t){var a=new Map,i=parseInt(e.duration,10);t.on("Network.requestWillBeSent",e=>{a.set(e.requestId,{method:e.request.method,url:e.request.url,requestId:e.requestId,timestamp:e.timestamp})}),t.on("Network.responseReceived",e=>{var t=a.get(e.requestId);t&&(t.status=e.response.status,t.mimeType=e.response.mimeType)}),t.on("Network.loadingFailed",e=>{var t=a.get(e.requestId);t&&(t.error=e.errorText)}),yield t.send("Network.enable"),yield new Promise(e=>setTimeout(e,i)),yield t.send("Network.disable");var n=[...a.values()];if(e.json)return void console.log(JSON.stringify(n,null,2));if(console.log(k.Ay.bold(`Network Activity (captured ${(i/1e3).toFixed(1)}s, ${n.length} requests)`)),0===n.length)return void console.log(k.Ay.gray(" No network activity captured"));for(var r of n){var o=r.error?k.Ay.red("ERR"):r.status?r.status<300?k.Ay.green(r.status):r.status<400?k.Ay.yellow(r.status):k.Ay.red(r.status):k.Ay.gray("..."),s=r.url.length>60?r.url.substring(0,57)+"...":r.url;console.log(` ${o} ${k.Ay.bold(r.method.padEnd(6))} ${s} ${k.Ay.gray(`(${r.requestId})`)}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return b.apply(this,arguments)})),G(W.command("get <requestId>").description("Get response body for a network request")).action((x=O(function*(e,t){var a;yield z(t,(a=O(function*(a){yield a.send("Network.enable");var i=yield a.send("Network.getResponseBody",{requestId:e}),n=i.body,r=i.base64Encoded;t.json?console.log(JSON.stringify({body:n,base64Encoded:r},null,2)):r?console.log(k.Ay.gray(`[base64 encoded, ${n.length} chars]`)):console.log(n)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return x.apply(this,arguments)}));var K=q.command("storage").description("Storage inspection"),X=K.command("system").description("System key-value storage");G(X.command("persist").description("Show persistent system storage entries")).action((_=O(function*(e){var t;yield z(e,(t=O(function*(t){yield t.send("DOMStorage.enable");var a=(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:"bricks://app",isLocalStorage:!0}})).entries;if(e.json)return void console.log(JSON.stringify(a,null,2));for(var i of(console.log(k.Ay.bold(`Persistent Storage (${a.length} items)`)),console.log("─".repeat(60)),a)){var n=S(i,2),r=n[0],o=n[1],s=o.length>80?o.substring(0,80)+"...":o;console.log(` ${k.Ay.cyan(r)}: ${s}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return _.apply(this,arguments)})),G(X.command("memory").description("Show in-memory system storage entries")).action((w=O(function*(e){var t;yield z(e,(t=O(function*(t){yield t.send("DOMStorage.enable");var a=(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:"bricks://app",isLocalStorage:!1}})).entries;if(e.json)return void console.log(JSON.stringify(a,null,2));for(var i of(console.log(k.Ay.bold(`Memory Storage (${a.length} items)`)),console.log("─".repeat(60)),a)){var n=S(i,2),r=n[0],o=n[1],s=o.length>80?o.substring(0,80)+"...":o;console.log(` ${k.Ay.cyan(r)}: ${s}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return w.apply(this,arguments)}));var Z=K.command("data-bank").description("Property Bank data stores");G(Z.command("list").description("List Property Banks")).action((E=O(function*(e){var t;yield z(e,(t=O(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestDatabaseNames",{securityOrigin:"bricks://app"})).databaseNames.filter(e=>e.startsWith("DATA-"));if(e.json)return void console.log(JSON.stringify(a,null,2));for(var i of(console.log(k.Ay.bold(`Property Banks (${a.length})`)),a))console.log(` ${k.Ay.cyan(i)}`)}),function(e){return t.apply(this,arguments)}))}),function(e){return E.apply(this,arguments)})),G(Z.command("get <name> <store>").description("Query Property Bank data").option("-l, --limit <count>","Max items to fetch","25").option("-s, --skip <count>","Items to skip","0")).action((F=O(function*(e,t,a){var i;yield z(a,(i=O(function*(i){yield i.send("IndexedDB.enable");var n=(yield i.send("IndexedDB.requestData",{securityOrigin:"bricks://app",databaseName:e,objectStoreName:t,indexName:"",skipCount:parseInt(a.skip,10),pageSize:parseInt(a.limit,10)})).objectStoreDataEntries;if(a.json)return void console.log(JSON.stringify(n,null,2));for(var r of(console.log(k.Ay.bold(`${e} / ${t} (${n.length} entries)`)),console.log("─".repeat(60)),n)){var o=JSON.stringify(r.key?.value??r.key),s=JSON.stringify(r.value?.value??r.value),p=s.length>100?s.substring(0,100)+"...":s;console.log(` ${k.Ay.cyan(o)}: ${p}`)}}),function(e){return i.apply(this,arguments)}))}),function(e,t,a){return F.apply(this,arguments)})),G(K.command("generator-cache").description("Show generator cache entries")).action((C=O(function*(e){var t;yield z(e,(t=O(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestData",{securityOrigin:"bricks://app",databaseName:"GENERATOR_CACHE",objectStoreName:"entries",indexName:"",skipCount:0,pageSize:100})).objectStoreDataEntries;if(e.json)return void console.log(JSON.stringify(a,null,2));for(var i of(console.log(k.Ay.bold(`Generator Cache (${a.length} entries)`)),console.log("─".repeat(60)),a)){var n=JSON.stringify(i.key?.value??i.key),r=JSON.stringify(i.value?.value??i.value),o=r.length>100?r.substring(0,100)+"...":r;console.log(` ${k.Ay.cyan(n)}: ${o}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return C.apply(this,arguments)}));var ee=q.command("runtime").description("Runtime and evaluation");G(ee.command("eval <expression>").description("Evaluate JavaScript expression").option("--await","Await promise result")).action((T=O(function*(e,t){var a;yield z(t,(a=O(function*(a){yield a.send("Runtime.enable");var i=yield a.send("Runtime.evaluate",{expression:e,objectGroup:"console",returnByValue:!0,awaitPromise:!!t.await,generatePreview:!0});if(t.json)return void console.log(JSON.stringify(i,null,2));i.exceptionDetails&&(console.error(k.Ay.red(`Error: ${i.exceptionDetails.text}`)),i.exceptionDetails.exception?.description&&console.error(k.Ay.red(i.exceptionDetails.exception.description)),process.exit(1));var n=i.result;"undefined"===n.type?console.log(k.Ay.gray("undefined")):void 0!==n.value?console.log("object"==typeof n.value?JSON.stringify(n.value,null,2):String(n.value)):n.description?console.log(n.description):console.log(k.Ay.gray(`[${n.type}${n.subtype?`:${n.subtype}`:""}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return T.apply(this,arguments)})),G(ee.command("properties <objectId>").description("Get properties of a remote object")).action((A=O(function*(e,t){var a;yield z(t,(a=O(function*(a){var i=(yield a.send("Runtime.getProperties",{objectId:e,ownProperties:!0})).result;if(t.json)return void console.log(JSON.stringify(i,null,2));for(var n of(console.log(k.Ay.bold(`Properties of ${e}`)),i))if(n.enumerable){var r=n.value,o=r?.description||r?.value?.toString()||k.Ay.gray(`[${r?.type}]`);console.log(` ${k.Ay.cyan(n.name)}: ${o}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return A.apply(this,arguments)}))},11405(e,t,a){a.d(t,{l:()=>v});var i,n,r,o=a(99436),s=a(35679),p=a(7586),l=a(85382),d=a(8479),u=a(23258),c=(i=o(function*(){try{return yield Promise.all([a.e(587),a.e(647),a.e(10),a.e(117)]).then(a.bind(a,98372)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),m=(e,t,a)=>({severity:e,code:t,message:a}),f=(n=o(function*({version:e="2.25.0-beta.17",mcpCheck:t=c}={}){var a=(0,u.getCurrentProfile)(),i=(0,u.getCurrentProfileSource)(),n=(0,u.getTokenInfo)(a),r=(0,u.getBaseUrl)(),o=(0,u.getActivityLogBaseUrl)(),s=[],f={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:u.CONFIG_PATH,baseUrl:r,activityLogBaseUrl:o},auth:{available:!!n?.token,source:n?.token?"config":"missing",workspaceId:n?.workspaceId||null,workspaceName:n?.workspaceName||null,createdAt:n?.createdAt||null,tokenPreview:(0,p.$l)(n?.token)},connectivity:{workspace:{ok:!1,skipped:!n?.token,error:null}},capabilities:{zeroArgMode:(0,d.z)()?"interactive":"help",mcp:{available:!1,error:null}},issues:s};if(n?.token)try{var h=yield(0,l.createClient)(r,n.token).workspace();f.connectivity.workspace={ok:!0,skipped:!1,error:null,id:h?._id||n.workspaceId||null,name:h?.name||n.workspaceName||null},f.auth.workspaceId=h?._id||f.auth.workspaceId,f.auth.workspaceName=h?.name||f.auth.workspaceName}catch(e){f.connectivity.workspace={ok:!1,skipped:!1,error:e.message},s.push(m("error","workspace_unreachable",`Workspace query failed for ${r}: ${e.message}`))}else s.push(m("warning","auth_missing","No saved token for the current profile."));var v=yield t();return f.capabilities.mcp={available:v.available,error:v.error||null},v.available||s.push(m("warning","mcp_unavailable",`MCP stdio server is unavailable: ${v.error||"Unknown error"}`)),f.ok=0===s.length,f}),function(){return n.apply(this,arguments)}),h=(e,t,a)=>`${e.padEnd(14)} ${t}${a?` ${a}`:""}`,v=new s.uB("doctor").description("Check CLI configuration, auth state, and workspace reachability").option("-j, --json","Output as JSON").action((r=o(function*(e){try{var t=yield f();if(e.json)return void(0,p.GF)(t);console.log((e=>{var t=[];if(t.push("BRICKS CLI Doctor"),t.push("─".repeat(60)),t.push(h("CLI","OK",`bricks v${e.cli.version}`)),t.push(h("Profile","OK",`${e.profile.name} (${e.profile.source})`)),t.push(h("BRICKS API","OK",e.config.baseUrl)),t.push(h("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace";t.push(h("Auth","OK",`${a} (${e.auth.source}, ${e.auth.tokenPreview})`))}else t.push(h("Auth","WARN","No saved token for the current profile"));if(e.connectivity.workspace.skipped)t.push(h("Workspace","WARN","Skipped because no token is available"));else if(e.connectivity.workspace.ok){var i=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";t.push(h("Workspace","OK",i))}else t.push(h("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?t.push(h("MCP","OK","STDIO server import is available")):t.push(h("MCP","WARN",e.capabilities.mcp.error)),t.push(h("Zero-arg mode",((e,t=!1)=>e?"OK":t?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(t.push("─".repeat(60)),t.push("Issues"),e.issues.forEach(e=>{t.push(`- [${e.severity}] ${e.message}`)})),t.join("\n")})(t))}catch(t){e.json?(0,p.OW)(t.message):console.error(`Doctor failed: ${t.message}`),process.exit(1)}}),function(e){return r.apply(this,arguments)}))},28634(e,t,a){a.d(t,{p:()=>_});var i,n,r,o,s,p,l,d=a(68832),u=a(99436),c=a(35679),m=a(73284),f=a(30155),h=a(7586),v=a(56493),g=a(68168),y=a(98593),D=e=>{if(!e)return m.Ay.gray("○");var t=Date.now()-new Date(e).getTime();return t<=3e5?m.Ay.green("●"):60>Math.floor(t/6e4)?m.Ay.yellow("○"):m.Ay.red("○")},b=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",deviceCount:e?.devices?.length||0}),x=["refresh","clear-cache","system-menu-open","system-menu-close","system-info-open","system-info-close","local-sync-panel-open","local-sync-panel-close","debug-panel-open","debug-panel-close","logging-on","logging-off","test-panel-open","test-panel-close"],_=new c.uB("group").description("Device Group management");_.command("list").description("List all device groups").option("-j, --json","Output as JSON").action((i=u(function*(e){var t=(0,v.o)(),a=(0,f.default)("Fetching device groups...").start();try{var i=yield t.deviceGroups({});if(a.stop(),e.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(m.Ay.yellow("No device groups found"));console.log(m.Ay.bold("\nDevice Groups")),console.log("─".repeat(80)),i.forEach(e=>{var t=e.devices?.length||0;console.log(`● ${m.Ay.cyan(e.name)} ${m.Ay.gray(`(${t} devices)`)}`),console.log(` ID: ${m.Ay.gray(e._id)}`),e.description&&console.log(` ${m.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list groups: ${e.message}`),process.exit(1)}}),function(e){return i.apply(this,arguments)})),_.command("get <id>").description("Get device group details").option("-j, --json","Output as JSON").action((n=u(function*(e,t){var a=(0,v.o)(),i=(0,f.default)("Fetching device group...").start();try{var n=yield a.deviceGroup({id:e});if(i.stop(),n||(console.log(m.Ay.red("Device group not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(n,null,2));console.log(m.Ay.bold(`
66
+ Use --info to see connection URLs`))}),function(e,t){return p.apply(this,arguments)})),Y(z.command("screenshot").description("Capture device screenshot").option("-o, --output <path>","Output file path")).action((l=O(function*(e){var t;yield Q(e,(t=O(function*(t){var i=yield t.send("Page.captureScreenshot",{format:"png"});i.data||(console.error(k.Ay.red("No screenshot data received")),process.exit(1));var n=yield Promise.resolve().then(a.t.bind(a,73024,19)),r=yield Promise.resolve().then(a.t.bind(a,76760,19)),o=e.output||`screenshot-${Date.now()}.png`,s=r.resolve(o);n.writeFileSync(s,Buffer.from(i.data,"base64")),console.log(k.Ay.green(`Screenshot saved to ${s}`))}),function(e){return t.apply(this,arguments)}))}),function(e){return l.apply(this,arguments)}));var W=z.command("brick").description("Brick component inspection");Y(W.command("tree").description("Print brick component tree").option("-d, --depth <depth>","Max depth (-1 for full)","3")).action((d=O(function*(e){var t;yield Q(e,(t=O(function*(t){yield t.send("DOM.enable");var a=parseInt(e.depth,10),i=(yield t.send("DOM.getDocument",{depth:a})).root;e.json?console.log(JSON.stringify(i,null,2)):console.log(H(i).join("\n"))}),function(e){return t.apply(this,arguments)}))}),function(e){return d.apply(this,arguments)})),Y(W.command("query <selector>").description("Find brick by CSS selector")).action((u=O(function*(e,t){var a;yield Q(t,(a=O(function*(a){yield a.send("DOM.enable");var i=(yield a.send("DOM.getDocument",{depth:0})).root,n=(yield a.send("DOM.querySelector",{nodeId:i.nodeId,selector:e})).nodeId;if(0===n)return void console.log(k.Ay.yellow("No element found"));var r=yield a.send("DOM.describeNode",{nodeId:n}),o=J((yield a.send("DOM.getAttributes",{nodeId:n})).attributes);if(t.json)return void console.log(JSON.stringify({nodeId:n,...r.node,attributes:o},null,2));if(console.log(k.Ay.bold(`Node ${n}: ${r.node?.nodeName||"unknown"}`)),Object.keys(o).length>0)for(var s of(console.log(k.Ay.bold("Attributes:")),Object.entries(o))){var p=S(s,2),l=p[0],d=p[1];console.log(` ${k.Ay.cyan(l)}: ${d}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return u.apply(this,arguments)})),Y(W.command("query-all <selector>").description("Find all bricks matching CSS selector")).action((c=O(function*(e,t){var a;yield Q(t,(a=O(function*(a){yield a.send("DOM.enable");var i=(yield a.send("DOM.getDocument",{depth:0})).root,n=(yield a.send("DOM.querySelectorAll",{nodeId:i.nodeId,selector:e})).nodeIds;if(t.json)return void console.log(JSON.stringify({nodeIds:n,count:n.length},null,2));for(var r of(console.log(k.Ay.bold(`Found ${n.length} element(s)`)),n)){var o=yield a.send("DOM.describeNode",{nodeId:r}),s=J((yield a.send("DOM.getAttributes",{nodeId:r})).attributes),p=s.id||s["short-id"]||"";console.log(` ${r}: ${o.node?.nodeName}${p?k.Ay.gray(`#${p}`):""}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return c.apply(this,arguments)})),Y(W.command("attributes <nodeId>").description("Get brick attributes")).action((m=O(function*(e,t){var a;yield Q(t,(a=O(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=J((yield a.send("DOM.getAttributes",{nodeId:i})).attributes);if(t.json)return void console.log(JSON.stringify(n,null,2));if(0===Object.keys(n).length)return void console.log(k.Ay.gray("No attributes"));for(var r of Object.entries(n)){var o=S(r,2),s=o[0],p=o[1];console.log(` ${k.Ay.cyan(s)}: ${p}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return m.apply(this,arguments)})),Y(W.command("box-model <nodeId>").description("Get brick dimensions and position")).action((f=O(function*(e,t){var a;yield Q(t,(a=O(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=(yield a.send("DOM.getBoxModel",{nodeId:i})).model;t.json?console.log(JSON.stringify(n,null,2)):(console.log(k.Ay.bold(`Box Model for node ${i}`)),console.log(` Width: ${n.width}`),console.log(` Height: ${n.height}`),n.content&&console.log(` Content: [${n.content.join(", ")}]`),n.padding&&console.log(` Padding: [${n.padding.join(", ")}]`),n.border&&console.log(` Border: [${n.border.join(", ")}]`),n.margin&&console.log(` Margin: [${n.margin.join(", ")}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return f.apply(this,arguments)})),Y(W.command("resolve <nodeId>").description("Resolve brick to JavaScript object with properties")).action((h=O(function*(e,t){var a;yield Q(t,(a=O(function*(a){yield a.send("DOM.enable");var i=parseInt(e,10),n=(yield a.send("DOM.resolveNode",{nodeId:i})).object;if(t.json)return void console.log(JSON.stringify(n,null,2));if(console.log(k.Ay.bold(`Resolved node ${i}`)),console.log(` Type: ${n.type}`),n.className&&console.log(` Class: ${n.className}`),n.description&&console.log(` Description: ${n.description}`),n.objectId&&console.log(` Object ID: ${k.Ay.gray(n.objectId)}`),n.preview?.properties)for(var r of(console.log(k.Ay.bold(" Properties:")),n.preview.properties))console.log(` ${k.Ay.cyan(r.name)}: ${r.value}`)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return h.apply(this,arguments)})),Y(W.command("focus <nodeId>").description("Focus a brick element")).action((v=O(function*(e,t){var a;yield Q(t,(a=O(function*(t){yield t.send("DOM.enable");var a=parseInt(e,10);yield t.send("DOM.focus",{nodeId:a}),console.log(k.Ay.green(`Focused node ${a}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return v.apply(this,arguments)}));var K=z.command("input").description("Input emulation");Y(K.command("tap <x> <y>").description("Tap/click at coordinates")).action((g=O(function*(e,t,a){var i;yield Q(a,(i=O(function*(a){var i=parseFloat(e),n=parseFloat(t);yield a.send("Input.dispatchMouseEvent",{type:"mousePressed",x:i,y:n,button:"left",clickCount:1}),yield a.send("Input.dispatchMouseEvent",{type:"mouseReleased",x:i,y:n,button:"left",clickCount:1}),console.log(k.Ay.green(`Tapped at (${i}, ${n})`))}),function(e){return i.apply(this,arguments)}))}),function(e,t,a){return g.apply(this,arguments)})),Y(K.command("type <text>").description("Insert text into focused element")).action((y=O(function*(e,t){var a;yield Q(t,(a=O(function*(t){yield t.send("Input.insertText",{text:e}),console.log(k.Ay.green(`Typed: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return y.apply(this,arguments)})),Y(K.command("key <key>").description("Dispatch key event (e.g., Enter, Escape, Tab)")).action((D=O(function*(e,t){var a;yield Q(t,(a=O(function*(t){yield t.send("Input.dispatchKeyEvent",{type:"keyDown",key:e}),yield t.send("Input.dispatchKeyEvent",{type:"keyUp",key:e}),console.log(k.Ay.green(`Key: ${e}`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return D.apply(this,arguments)}));var X=z.command("network").description("Network inspection");Y(X.command("list").description("Capture snapshot of network activity").option("--duration <ms>","Capture duration in milliseconds","2000")).action((b=O(function*(e){var t;yield Q(e,(t=O(function*(t){var a=new Map,i=parseInt(e.duration,10);t.on("Network.requestWillBeSent",e=>{a.set(e.requestId,{method:e.request.method,url:e.request.url,requestId:e.requestId,timestamp:e.timestamp})}),t.on("Network.responseReceived",e=>{var t=a.get(e.requestId);t&&(t.status=e.response.status,t.mimeType=e.response.mimeType)}),t.on("Network.loadingFailed",e=>{var t=a.get(e.requestId);t&&(t.error=e.errorText)}),yield t.send("Network.enable"),yield new Promise(e=>setTimeout(e,i)),yield t.send("Network.disable");var n=[...a.values()];if(e.json)return void console.log(JSON.stringify(n,null,2));if(console.log(k.Ay.bold(`Network Activity (captured ${(i/1e3).toFixed(1)}s, ${n.length} requests)`)),0===n.length)return void console.log(k.Ay.gray(" No network activity captured"));for(var r of n){var o=r.error?k.Ay.red("ERR"):r.status?r.status<300?k.Ay.green(r.status):r.status<400?k.Ay.yellow(r.status):k.Ay.red(r.status):k.Ay.gray("..."),s=r.url.length>60?r.url.substring(0,57)+"...":r.url;console.log(` ${o} ${k.Ay.bold(r.method.padEnd(6))} ${s} ${k.Ay.gray(`(${r.requestId})`)}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return b.apply(this,arguments)})),Y(X.command("get <requestId>").description("Get response body for a network request")).action((x=O(function*(e,t){var a;yield Q(t,(a=O(function*(a){yield a.send("Network.enable");var i=yield a.send("Network.getResponseBody",{requestId:e}),n=i.body,r=i.base64Encoded;t.json?console.log(JSON.stringify({body:n,base64Encoded:r},null,2)):r?console.log(k.Ay.gray(`[base64 encoded, ${n.length} chars]`)):console.log(n)}),function(e){return a.apply(this,arguments)}))}),function(e,t){return x.apply(this,arguments)}));var Z=z.command("storage").description("Storage inspection"),ee=Z.command("system").description("System key-value storage");Y(ee.command("persist").description("Show persistent system storage entries")).action((_=O(function*(e){var t;yield Q(e,(t=O(function*(t){yield t.send("DOMStorage.enable");var a=(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:"bricks://app",isLocalStorage:!0}})).entries;if(e.json)return void console.log(JSON.stringify(a,null,2));for(var i of(console.log(k.Ay.bold(`Persistent Storage (${a.length} items)`)),console.log("─".repeat(60)),a)){var n=S(i,2),r=n[0],o=n[1],s=o.length>80?o.substring(0,80)+"...":o;console.log(` ${k.Ay.cyan(r)}: ${s}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return _.apply(this,arguments)})),Y(ee.command("memory").description("Show in-memory system storage entries")).action((w=O(function*(e){var t;yield Q(e,(t=O(function*(t){yield t.send("DOMStorage.enable");var a=(yield t.send("DOMStorage.getDOMStorageItems",{storageId:{securityOrigin:"bricks://app",isLocalStorage:!1}})).entries;if(e.json)return void console.log(JSON.stringify(a,null,2));for(var i of(console.log(k.Ay.bold(`Memory Storage (${a.length} items)`)),console.log("─".repeat(60)),a)){var n=S(i,2),r=n[0],o=n[1],s=o.length>80?o.substring(0,80)+"...":o;console.log(` ${k.Ay.cyan(r)}: ${s}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return w.apply(this,arguments)}));var et=Z.command("data-bank").description("Property Bank data stores");Y(et.command("list").description("List Property Banks")).action((E=O(function*(e){var t;yield Q(e,(t=O(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestDatabaseNames",{securityOrigin:"bricks://app"})).databaseNames.filter(e=>e.startsWith("DATA-"));if(e.json)return void console.log(JSON.stringify(a,null,2));for(var i of(console.log(k.Ay.bold(`Property Banks (${a.length})`)),a))console.log(` ${k.Ay.cyan(i)}`)}),function(e){return t.apply(this,arguments)}))}),function(e){return E.apply(this,arguments)})),Y(et.command("get <name> <store>").description("Query Property Bank data").option("-l, --limit <count>","Max items to fetch","25").option("-s, --skip <count>","Items to skip","0")).action((F=O(function*(e,t,a){var i;yield Q(a,(i=O(function*(i){yield i.send("IndexedDB.enable");var n=(yield i.send("IndexedDB.requestData",{securityOrigin:"bricks://app",databaseName:e,objectStoreName:t,indexName:"",skipCount:parseInt(a.skip,10),pageSize:parseInt(a.limit,10)})).objectStoreDataEntries;if(a.json)return void console.log(JSON.stringify(n,null,2));for(var r of(console.log(k.Ay.bold(`${e} / ${t} (${n.length} entries)`)),console.log("─".repeat(60)),n)){var o=JSON.stringify(r.key?.value??r.key),s=JSON.stringify(r.value?.value??r.value),p=s.length>100?s.substring(0,100)+"...":s;console.log(` ${k.Ay.cyan(o)}: ${p}`)}}),function(e){return i.apply(this,arguments)}))}),function(e,t,a){return F.apply(this,arguments)})),Y(Z.command("generator-cache").description("Show generator cache entries")).action((C=O(function*(e){var t;yield Q(e,(t=O(function*(t){yield t.send("IndexedDB.enable");var a=(yield t.send("IndexedDB.requestData",{securityOrigin:"bricks://app",databaseName:"GENERATOR_CACHE",objectStoreName:"entries",indexName:"",skipCount:0,pageSize:100})).objectStoreDataEntries;if(e.json)return void console.log(JSON.stringify(a,null,2));for(var i of(console.log(k.Ay.bold(`Generator Cache (${a.length} entries)`)),console.log("─".repeat(60)),a)){var n=JSON.stringify(i.key?.value??i.key),r=JSON.stringify(i.value?.value??i.value),o=r.length>100?r.substring(0,100)+"...":r;console.log(` ${k.Ay.cyan(n)}: ${o}`)}}),function(e){return t.apply(this,arguments)}))}),function(e){return C.apply(this,arguments)}));var ea=z.command("runtime").description("Runtime and evaluation");Y(ea.command("eval <expression>").description("Evaluate JavaScript expression").option("--await","Await promise result")).action((T=O(function*(e,t){var a;yield Q(t,(a=O(function*(a){yield a.send("Runtime.enable");var i=yield a.send("Runtime.evaluate",{expression:e,objectGroup:"console",returnByValue:!0,awaitPromise:!!t.await,generatePreview:!0});if(t.json)return void console.log(JSON.stringify(i,null,2));i.exceptionDetails&&(console.error(k.Ay.red(`Error: ${i.exceptionDetails.text}`)),i.exceptionDetails.exception?.description&&console.error(k.Ay.red(i.exceptionDetails.exception.description)),process.exit(1));var n=i.result;"undefined"===n.type?console.log(k.Ay.gray("undefined")):void 0!==n.value?console.log("object"==typeof n.value?JSON.stringify(n.value,null,2):String(n.value)):n.description?console.log(n.description):console.log(k.Ay.gray(`[${n.type}${n.subtype?`:${n.subtype}`:""}]`))}),function(e){return a.apply(this,arguments)}))}),function(e,t){return T.apply(this,arguments)})),Y(ea.command("properties <objectId>").description("Get properties of a remote object")).action((A=O(function*(e,t){var a;yield Q(t,(a=O(function*(a){var i=(yield a.send("Runtime.getProperties",{objectId:e,ownProperties:!0})).result;if(t.json)return void console.log(JSON.stringify(i,null,2));for(var n of(console.log(k.Ay.bold(`Properties of ${e}`)),i))if(n.enumerable){var r=n.value,o=r?.description||r?.value?.toString()||k.Ay.gray(`[${r?.type}]`);console.log(` ${k.Ay.cyan(n.name)}: ${o}`)}}),function(e){return a.apply(this,arguments)}))}),function(e,t){return A.apply(this,arguments)}))},11405(e,t,a){a.d(t,{l:()=>v});var i,n,r,o=a(99436),s=a(35679),p=a(7586),l=a(85382),d=a(8479),u=a(23258),c=(i=o(function*(){try{return yield Promise.all([a.e(587),a.e(647),a.e(10),a.e(117)]).then(a.bind(a,98372)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),m=(e,t,a)=>({severity:e,code:t,message:a}),f=(n=o(function*({version:e="2.25.0-beta.19",mcpCheck:t=c}={}){var a=(0,u.getCurrentProfile)(),i=(0,u.getCurrentProfileSource)(),n=(0,u.getTokenInfo)(a),r=(0,u.getBaseUrl)(),o=(0,u.getActivityLogBaseUrl)(),s=[],f={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:u.CONFIG_PATH,baseUrl:r,activityLogBaseUrl:o},auth:{available:!!n?.token,source:n?.token?"config":"missing",workspaceId:n?.workspaceId||null,workspaceName:n?.workspaceName||null,createdAt:n?.createdAt||null,tokenPreview:(0,p.$l)(n?.token)},connectivity:{workspace:{ok:!1,skipped:!n?.token,error:null}},capabilities:{zeroArgMode:(0,d.z)()?"interactive":"help",mcp:{available:!1,error:null}},issues:s};if(n?.token)try{var h=yield(0,l.createClient)(r,n.token).workspace();f.connectivity.workspace={ok:!0,skipped:!1,error:null,id:h?._id||n.workspaceId||null,name:h?.name||n.workspaceName||null},f.auth.workspaceId=h?._id||f.auth.workspaceId,f.auth.workspaceName=h?.name||f.auth.workspaceName}catch(e){f.connectivity.workspace={ok:!1,skipped:!1,error:e.message},s.push(m("error","workspace_unreachable",`Workspace query failed for ${r}: ${e.message}`))}else s.push(m("warning","auth_missing","No saved token for the current profile."));var v=yield t();return f.capabilities.mcp={available:v.available,error:v.error||null},v.available||s.push(m("warning","mcp_unavailable",`MCP stdio server is unavailable: ${v.error||"Unknown error"}`)),f.ok=0===s.length,f}),function(){return n.apply(this,arguments)}),h=(e,t,a)=>`${e.padEnd(14)} ${t}${a?` ${a}`:""}`,v=new s.uB("doctor").description("Check CLI configuration, auth state, and workspace reachability").option("-j, --json","Output as JSON").action((r=o(function*(e){try{var t=yield f();if(e.json)return void(0,p.GF)(t);console.log((e=>{var t=[];if(t.push("BRICKS CLI Doctor"),t.push("─".repeat(60)),t.push(h("CLI","OK",`bricks v${e.cli.version}`)),t.push(h("Profile","OK",`${e.profile.name} (${e.profile.source})`)),t.push(h("BRICKS API","OK",e.config.baseUrl)),t.push(h("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace";t.push(h("Auth","OK",`${a} (${e.auth.source}, ${e.auth.tokenPreview})`))}else t.push(h("Auth","WARN","No saved token for the current profile"));if(e.connectivity.workspace.skipped)t.push(h("Workspace","WARN","Skipped because no token is available"));else if(e.connectivity.workspace.ok){var i=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";t.push(h("Workspace","OK",i))}else t.push(h("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?t.push(h("MCP","OK","STDIO server import is available")):t.push(h("MCP","WARN",e.capabilities.mcp.error)),t.push(h("Zero-arg mode",((e,t=!1)=>e?"OK":t?"WARN":"FAIL")("interactive"===e.capabilities.zeroArgMode,"help"===e.capabilities.zeroArgMode),"interactive"===e.capabilities.zeroArgMode?"Starts Ink interactive mode on TTY":"Shows help outside TTY contexts")),e.issues.length>0&&(t.push("─".repeat(60)),t.push("Issues"),e.issues.forEach(e=>{t.push(`- [${e.severity}] ${e.message}`)})),t.join("\n")})(t))}catch(t){e.json?(0,p.OW)(t.message):console.error(`Doctor failed: ${t.message}`),process.exit(1)}}),function(e){return r.apply(this,arguments)}))},28634(e,t,a){a.d(t,{p:()=>_});var i,n,r,o,s,p,l,d=a(68832),u=a(99436),c=a(35679),m=a(73284),f=a(30155),h=a(7586),v=a(56493),g=a(68168),y=a(98593),D=e=>{if(!e)return m.Ay.gray("○");var t=Date.now()-new Date(e).getTime();return t<=3e5?m.Ay.green("●"):60>Math.floor(t/6e4)?m.Ay.yellow("○"):m.Ay.red("○")},b=(e,t)=>({id:e?._id||t,name:e?.name||"Unnamed",deviceCount:e?.devices?.length||0}),x=["refresh","clear-cache","system-menu-open","system-menu-close","system-info-open","system-info-close","local-sync-panel-open","local-sync-panel-close","debug-panel-open","debug-panel-close","logging-on","logging-off","test-panel-open","test-panel-close"],_=new c.uB("group").description("Device Group management");_.command("list").description("List all device groups").option("-j, --json","Output as JSON").action((i=u(function*(e){var t=(0,v.o)(),a=(0,f.default)("Fetching device groups...").start();try{var i=yield t.deviceGroups({});if(a.stop(),e.json)return void console.log(JSON.stringify(i,null,2));if(!i||0===i.length)return void console.log(m.Ay.yellow("No device groups found"));console.log(m.Ay.bold("\nDevice Groups")),console.log("─".repeat(80)),i.forEach(e=>{var t=e.devices?.length||0;console.log(`● ${m.Ay.cyan(e.name)} ${m.Ay.gray(`(${t} devices)`)}`),console.log(` ID: ${m.Ay.gray(e._id)}`),e.description&&console.log(` ${m.Ay.gray(e.description)}`),console.log()})}catch(e){a.fail(`Failed to list groups: ${e.message}`),process.exit(1)}}),function(e){return i.apply(this,arguments)})),_.command("get <id>").description("Get device group details").option("-j, --json","Output as JSON").action((n=u(function*(e,t){var a=(0,v.o)(),i=(0,f.default)("Fetching device group...").start();try{var n=yield a.deviceGroup({id:e});if(i.stop(),n||(console.log(m.Ay.red("Device group not found")),process.exit(1)),t.json)return void console.log(JSON.stringify(n,null,2));console.log(m.Ay.bold(`
67
67
  Device Group: ${n.name}`)),console.log("─".repeat(60)),console.log(`ID: ${m.Ay.gray(n._id)}`),console.log(`Description: ${n.description||m.Ay.gray("N/A")}`),console.log(`Tags: ${n.tags?.join(", ")||m.Ay.gray("None")}`),console.log(`Created: ${m.Ay.gray(n.create_datetime)}`),console.log(`Modified: ${m.Ay.gray(n.last_modify_datetime)}`),n.devices?.length>0&&(console.log(`
68
68
  ${m.Ay.bold("Devices")} (${n.devices.length})`),n.devices.forEach(e=>{var t=e.device_target_name||e.device_id;console.log(` - ${t} ${m.Ay.gray(`(${e.device_id})`)}`)})),console.log("─".repeat(60))}catch(e){i.fail(`Failed to get group: ${e.message}`),process.exit(1)}}),function(e,t){return n.apply(this,arguments)})),_.command("resolve <query>").description("Resolve a device group name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action((r=u(function*(e,t){var a=(0,v.o)(),i=t.json?null:(0,f.default)("Resolving device group...").start();try{var n=yield(0,g.Y)(()=>a.deviceGroup({id:e})),r=n?[n]:yield a.deviceGroups({paginate:{limit:t.limit}}),o=n?r:(r||[]).filter(t=>t.name?.toLowerCase().includes(e.trim().toLowerCase())),s=(0,g.K)({resource:"group",query:e,items:o||[],fields:["_id","name"],selectedBy:n?"id":null});if(i&&i.stop(),t.json)return void(0,h.GF)(s);if(s.resolved){var p=s.resolved;console.log(m.Ay.bold("\nResolved Device Group")),console.log("─".repeat(60)),console.log(`Name: ${m.Ay.cyan(p.name||"Unnamed")}`),console.log(`ID: ${m.Ay.gray(p._id)}`),console.log(`Selected By: ${s.selectedBy}`),console.log("─".repeat(60));return}if(0===s.matches.length)return void console.log(m.Ay.yellow(`No device groups matched "${e}"`));console.log(m.Ay.bold(`
69
69
  Matching Device Groups (${s.matches.length})`)),console.log("─".repeat(80)),s.matches.forEach(e=>{console.log(`${m.Ay.cyan(e.name||"Unnamed")} ${m.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){i?i.fail(`Failed to resolve device group: ${t.message}`):(0,h.OW)(t.message,{resource:"group",query:e}),process.exit(1)}}),function(e,t){return r.apply(this,arguments)})),_.command("devices <id>").description("List devices in a group with status").option("-j, --json","Output as JSON").action((o=u(function*(e,t){var a=(0,v.o)(),i=(0,f.default)("Fetching devices...").start();try{var n=yield a.devicesByGroup({id:e});if(i.stop(),t.json)return void console.log(JSON.stringify(n,null,2));if(!n||0===n.length)return void console.log(m.Ay.yellow("No devices in this group"));console.log(m.Ay.bold("\nDevices in Group")),console.log("─".repeat(80)),n.forEach(e=>{var t=e.entry_detail?.watch_dog_timer?.last_alive_time,a=D(t),i=e.name||e.device_name||e.device_target_name,n=e.entry_detail?.application?.name||m.Ay.gray("No app");console.log(`${a} ${m.Ay.cyan(i.padEnd(30))} ${n}`)}),console.log("─".repeat(80))}catch(e){i.fail(`Failed to get devices: ${e.message}`),process.exit(1)}}),function(e,t){return o.apply(this,arguments)})),_.command("dispatch <id> <action>").description("Dispatch action to all devices in group").option("--dry-run","Validate inputs and show the dispatch plan without sending it").option("-j, --json","Output as JSON").action((s=u(function*(e,t,a){var i=(0,v.o)(),n=a.json?null:(0,f.default)(`Dispatching ${t}...`).start();x.includes(t)||(a.json?(0,h.OW)(`Invalid action. Valid actions: ${x.join(", ")}`,{action:"group.dispatch",target:{id:e}}):n.fail(`Invalid action. Valid actions: ${x.join(", ")}`),process.exit(1));try{var r=yield i.deviceGroup({id:e});if(!r)throw Error("Device group not found");if(a.dryRun){n&&n.stop(),(0,y.S5)({action:"group.dispatch",target:b(r,e),request:{action:t},checks:[(0,y.Iy)("group exists",!0,`${r.name} (${r._id})`),(0,y.Iy)("action is valid",!0)],json:a.json});return}var o=yield i.dispatchDeviceGroupAction({id:e,action:t});a.json?(0,y.yd)({action:"group.dispatch",target:b(r,e),result:{action:t,success:o?.success||0,failed:o?.failed||0},json:!0}):(n.succeed(`Action dispatched: ${m.Ay.green(t)}`),o&&(console.log(`Success: ${m.Ay.green(o.success||0)}`),console.log(`Failed: ${m.Ay.red(o.failed||0)}`)))}catch(t){a.json?(0,h.OW)(t.message,{action:"group.dispatch",target:{id:e}}):n.fail(`Failed to dispatch action: ${t.message}`),process.exit(1)}}),function(e,t,a){return s.apply(this,arguments)})),_.command("refresh <id>").description("Refresh all devices in group").option("--dry-run","Validate inputs and show the refresh plan without sending it").option("-j, --json","Output as JSON").action((p=u(function*(e,t){var a=(0,v.o)(),i=t.json?null:(0,f.default)("Refreshing devices...").start();try{var n=yield a.deviceGroup({id:e});if(!n)throw Error("Device group not found");if(t.dryRun){i&&i.stop(),(0,y.S5)({action:"group.refresh",target:b(n,e),request:{action:"refresh"},checks:[(0,y.Iy)("group exists",!0,`${n.name} (${n._id})`)],json:t.json});return}var r=yield a.dispatchDeviceGroupAction({id:e,action:"refresh"});t.json?(0,y.yd)({action:"group.refresh",target:b(n,e),result:{success:r?.success||0,failed:r?.failed||0},json:!0}):(i.succeed("Devices refreshed"),r&&(console.log(`Success: ${m.Ay.green(r.success||0)}`),console.log(`Failed: ${m.Ay.red(r.failed||0)}`)))}catch(a){t.json?(0,h.OW)(a.message,{action:"group.refresh",target:{id:e}}):i.fail(`Failed to refresh: ${a.message}`),process.exit(1)}}),function(e,t){return p.apply(this,arguments)})),_.command("monitor <id>").description("Monitor devices in group (polls every 60s)").option("-i, --interval <seconds>","Polling interval in seconds","60").action((l=u(function*(e,t){var a,i=(0,v.o)(),n=1e3*parseInt(t.interval,10);console.log(m.Ay.bold("\nDevice Group Monitor")),console.log(m.Ay.gray(`Polling every ${t.interval}s. Press Ctrl+C to stop.
@@ -82,7 +82,7 @@ ${v.Ay.bold("Usage")}`),console.log(`Used In: ${n.use_count.total_count} ap
82
82
  ${v.Ay.bold("Exposed Properties")} (${n.expose_properties.length})`),n.expose_properties.forEach(e=>{console.log(` - ${v.Ay.cyan(e)}`)})),console.log("─".repeat(60))}catch(e){i.fail(`Failed to get module: ${e.message}`),process.exit(1)}}),function(e,t){return o.apply(this,arguments)})),A.command("resolve <query>").description("Resolve a module name or ID to stable IDs").option("-l, --limit <limit>","Limit search results",e=>Number.parseInt(e,10),10).option("-j, --json","Output as JSON").action((s=f(function*(e,t){var a=(0,w.o)(),i=t.json?null:(0,g.default)("Resolving module...").start();try{var n=yield(0,E.Y)(()=>a.module({id:e})),r=n?[n]:yield a.modules({keyword:e,paginate:{limit:t.limit}}),o=(0,E.K)({resource:"module",query:e,items:r||[],fields:["_id","name"],selectedBy:n?"id":null});if(i&&i.stop(),t.json)return void(0,_.GF)(o);if(o.resolved){var s=o.resolved;console.log(v.Ay.bold("\nResolved Module")),console.log("─".repeat(60)),console.log(`Name: ${v.Ay.cyan(s.name||"Unnamed")}`),console.log(`ID: ${v.Ay.gray(s._id)}`),console.log(`Selected By: ${o.selectedBy}`),console.log("─".repeat(60));return}if(0===o.matches.length)return void console.log(v.Ay.yellow(`No modules matched "${e}"`));console.log(v.Ay.bold(`
83
83
  Matching Modules (${o.matches.length})`)),console.log("─".repeat(80)),o.matches.forEach(e=>{console.log(`${v.Ay.cyan(e.name||"Unnamed")} ${v.Ay.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){i?i.fail(`Failed to resolve module: ${t.message}`):(0,_.OW)(t.message,{resource:"module",query:e}),process.exit(1)}}),function(e,t){return s.apply(this,arguments)})),A.command("update <id>").description("Update module name, description, and/or configuration").option("-n, --name <name>","Module name").option("-d, --description <description>","Module description").option("-c, --config <json>","Module config as JSON string").option("-f, --file <path>","Module config from file").option("--validate","Validate configuration (default: true when config is set)",!0).option("--no-validate","Skip server-side config validation").option("--last-commit-id <id>","Reject if server config.bricks_project_last_commit_id does not match this value").option("-j, --json","Output as JSON").action((p=f(function*(e,t){var a=(0,w.o)(),i=t.json?null:(0,g.default)("Updating module...").start();try{var n={id:e};t.name&&(n.name=t.name),t.description&&(n.description=t.description),t.config?n.config=t.config:t.file&&(n.config=y.readFileSync(t.file,"utf-8")),void 0!==n.config&&(n.validateConfig=!1!==t.validate),t.lastCommitId&&(n.lastCommitId=t.lastCommitId);var r=yield a.updateModule(n);t.json?(0,C.yd)({action:"module.update",target:T(r,e),result:{lastCommitId:t.lastCommitId||null},json:!0}):(i.succeed(`Module updated: ${v.Ay.green(r.name)}`),r.has_unreleased_changes&&console.log(v.Ay.yellow("Note: Module has unreleased changes")))}catch(a){t.json?(0,_.OW)(a.message,{action:"module.update",target:{id:e}}):i.fail(`Failed to update module: ${a.message}`),process.exit(1)}}),function(e,t){return p.apply(this,arguments)})),A.command("short-edit <id>").description("Short edit module properties").requiredOption("-l, --list <json>","Short edit list as JSON array").action((l=f(function*(e,t){var a=(0,w.o)(),i=(0,g.default)("Applying short edit...").start();try{var n=JSON.parse(t.list);Array.isArray(n)||(i.fail("List must be a JSON array"),process.exit(1));var r=yield a.shortEditModule({id:e,list:n});i.succeed(`Short edit applied to: ${v.Ay.green(r.name)}`)}catch(e){i.fail(`Failed to apply short edit: ${e.message}`),process.exit(1)}}),function(e,t){return l.apply(this,arguments)})),A.command("short-refs <id>").description("List short edit references for a module").option("-k, --keyword <keyword>","Filter by shortId or title").option("-t, --types <types>","Comma-separated shortId prefixes to include (e.g. B,C,S)").option("-j, --json","Output as JSON").action((d=f(function*(e,t){var a=(0,w.o)(),i=(0,g.default)("Fetching short edit references...").start();try{var n=yield a.module({id:e});if(i.stop(),!n?.short_edit?.enabled)return void console.log(v.Ay.yellow("Short Edit is not enabled for this module"));var r=t.types?t.types.split(",").map(e=>e.trim()).filter(Boolean):[],o=(0,x.V)(n.short_edit.ref_map,{keyword:t.keyword,types:r});if(t.json)return void console.log(JSON.stringify(o,null,2));if(0===o.length)return void console.log(v.Ay.yellow("No short edit references found"));console.log(v.Ay.bold(`
84
84
  Short Edit References: ${n.name}`)),o.forEach(e=>{console.log(v.Ay.cyan(`
85
- ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?v.Ay.gray(`- ${t.title}`):"";console.log(` ${v.Ay.green(e)} ${a}`)})}),console.log()}catch(e){i.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,t){return d.apply(this,arguments)})),A.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("-n, --name <name>","Update module name as part of the release").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action((u=f(function*(e,t){var a=(0,w.o)(),i=t.json?null:(0,g.default)("Releasing module...").start();try{var n=(0,F.Ku)(t.config),r=n.config,o=n.source,s=n.sizeBytes,p=yield a.module({id:e});if(!p)throw Error("Module not found");if(p.is_public)throw Error("Public module deployment is temporarily not recommended");var l=t.version||t.name||p.name||"Untitled",d=(0,F.w9)(t.changelogs);if(t.dryRun){i&&i.stop(),(0,C.S5)({action:"module.release",target:T(p,e),request:{name:t.name||null,version:l,changelogs:t.changelogs||null,configSource:o,configSizeBytes:s},checks:[(0,C.Iy)("module exists",!0,`${p.name} (${p._id})`),(0,C.Iy)("module is private",!p.is_public),(0,C.Iy)("release config loaded",!0,`${s} bytes`)],json:t.json});return}var u=yield a.releaseModule({id:e,config:r,...t.name?{name:t.name}:{},releaseCurrentVersion:l,releaseCurrentVersionNote:d});t.json?(0,C.yd)({action:"module.release",target:T(u||p,e),result:{name:t.name||null,version:l,configSource:o,configSizeBytes:s},json:!0}):i.succeed(`Module released: ${v.Ay.green(u?.name||p.name)}`)}catch(a){t.json?(0,_.OW)(a.message,{action:"module.release",target:{id:e}}):i.fail(`Failed to release module: ${a.message}`),process.exit(1)}}),function(e,t){return u.apply(this,arguments)})),A.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((c=f(function*(e,t){var a=(0,w.o)(),i=t.json?null:(0,g.default)("Pulling module project...").start();try{var n=yield a.moduleProject({id:e,buildApplicationOnly:!0});n||(i?i.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(n)):(i.succeed(`Module project fetched: ${v.Ay.green(n.files?.length||0)} files`),console.log(JSON.stringify(n,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):i.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}}),function(e,t){return c.apply(this,arguments)})),A.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((m=f(function*(e,t){var i=(yield a.e(602).then(a.bind(a,6553))).initProject;yield i("module",e,t)}),function(e,t){return m.apply(this,arguments)}))},86141(e,t,a){a.d(t,{D:()=>V});var i,n,r,o,s,p,l,d,u,c=a(99436),m=a(35679),f=a(73284),h=a(30155),v=a(88958),g=a(73024),y=a(76760),D=a(48161),b=e=>{if(!e)return e;try{return g.realpathSync(e)}catch{return e}},x=a(68832),_=a(31421),w=a(51455),E="@fugood/bricks-cli",F="win32"===process.platform,C=(e,t)=>`https://cdn.bricks.tools/bricks-cli/${e}/${t}`,T=e=>"beta"===e?"beta":"latest",A=(i=c(function*(e){var t=yield fetch(e);if(!t.ok)throw Error(`Failed to fetch ${e}: HTTP ${t.status}`);return t}),function(e){return i.apply(this,arguments)}),S=(n=c(function*(e){return(yield A(C(e,"version.json"))).json()}),function(e){return n.apply(this,arguments)}),O=(r=c(function*(e){var t=T(e),a=yield A(`https://registry.npmjs.org/-/package/${E}/dist-tags`),i=(yield a.json())[t];if(!i)throw Error(`No '${t}' dist-tag for ${E}`);return{version:i}}),function(e){return r.apply(this,arguments)}),N=(o=c(function*(e,t){return"npm"===t||"bun"===t?O(e):S(e)}),function(e,t){return o.apply(this,arguments)}),k=(e,t,a={})=>{var i=(0,_.spawnSync)(e,t,{stdio:"inherit",...a});if(i.error){if("ENOENT"===i.error.code)throw Error(`Command not found: ${e}`);throw i.error}if(0!==i.status){var n=Error(`${e} exited with code ${i.status}`);throw n.code=i.status,n}},I=(s=c(function*(e,t){var a=yield A(e),i=Buffer.from((yield a.arrayBuffer())),n=y.join(D.tmpdir(),`bricks-cli-update-${process.pid}-${t}`);return yield w.writeFile(n,i),F||(yield w.chmod(n,493)),n}),function(e,t){return s.apply(this,arguments)}),$=(p=c(function*(e,{installDir:t}={}){var a=F?"install.ps1":"install.sh",i=yield I(C(e,a),a);try{var n=F?["powershell",["-NoProfile","-ExecutionPolicy","Bypass","-File",i,..."beta"===e?["-Beta"]:[],...t?["-InstallDir",t]:[]]]:["sh",[i,..."beta"===e?["--beta"]:[],...t?[`--dir=${t}`]:[]]],r=x(n,2),o=r[0],s=r[1];k(o,s)}finally{yield w.unlink(i).catch(()=>{})}}),function(e){return p.apply(this,arguments)}),j=(l=c(function*(e,t,a={}){if("npm"===e)return void k("npm",["install","-g",`${E}@${T(t)}`]);if("bun"===e)return void k("bun",["install","-g",`${E}@${T(t)}`]);if("binary"===e)return $(t,{installDir:a.installDir});throw Error(`Unsupported update method: ${e}`)}),function(e,t){return l.apply(this,arguments)}),B=a(8479),R=(d=c(function*({message:e,defaultValue:t,autoYes:a}){if(a)return!0;(0,B.z)()||(console.error(f.Ay.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{return yield(0,v.lJ)({message:e,default:t})}catch{return!1}}),function(e){return d.apply(this,arguments)}),V=new m.uB("update-cli").description("Update the BRICKS CLI to the latest version").option("-y, --yes","Skip confirmation prompts").option("--channel <channel>","Override channel (release|beta)").option("--check-update","Only check whether a newer version is available and exit").action((u=c(function*(e){var t,a="2.25.0-beta.17",i=(({execPath:e=process.execPath,scriptPath:t=process.argv[1],homeDir:a=D.homedir(),realpath:i=b}={})=>{let n;var r=(n=e)?y.basename(n).replace(/\.exe$/i,""):"";if("bricks"===r||"bricks-beta"===r)return{method:"binary",execPath:e,installDir:y.dirname(e)};var o=i(t),s=((e,t)=>{if(!e)return null;var a=y.sep,i=`${a}node_modules${a}${t.replace(/\//g,a)}${a}`,n=e.indexOf(i);return -1===n?null:e.slice(0,n)})(o,"@fugood/bricks-cli");if(s){var p=y.sep,l=y.join(a,".bun","install","global");return s===l||s.startsWith(l+p)?{method:"bun",installRoot:s}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(s)?{method:"pnpm",installRoot:s}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(s)?{method:"yarn",installRoot:s}:{method:"npm",installRoot:s.endsWith(`${p}lib`)?s.slice(0,-`${p}lib`.length):s}}return{method:"unknown",execPath:e,scriptPath:o}})(),n=e.channel||(({version:e,execPath:t}={})=>{var a=t||process.execPath;return a&&/[\\/]bricks-beta(?:\.exe)?$/i.test(a)||/-(beta|alpha|rc|next)\b/i.test(e||"2.25.0-beta.17")?"beta":"release"})({version:a,execPath:i.execPath});console.log(f.Ay.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${f.Ay.cyan(a)}`),console.log(`Channel : ${f.Ay.cyan(n)}`),console.log(`Detected method : ${f.Ay.cyan(i.method)}`),i.execPath&&"binary"===i.method&&console.log(`Binary path : ${f.Ay.gray(i.execPath)}`),i.installRoot&&console.log(`Install root : ${f.Ay.gray(i.installRoot)}`);var r="npm"===i.method||"bun"===i.method?"npm":"cdn",o=(0,h.default)(`Fetching latest version info (${r})...`).start(),s=null,p=null;try{s=(yield N(n,i.method)).version,o.succeed(`Latest ${n} (${r}): ${f.Ay.green(s)}`)}catch(e){p=e,o.warn(`Could not fetch version info: ${e.message}`)}var l=s&&s===a;if(e.checkUpdate){if(p&&process.exit(2),l)return void console.log(f.Ay.green("\nUp to date."));s&&(console.log(f.Ay.yellow(`
85
+ ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:t})=>{var a=t?.title?v.Ay.gray(`- ${t.title}`):"";console.log(` ${v.Ay.green(e)} ${a}`)})}),console.log()}catch(e){i.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,t){return d.apply(this,arguments)})),A.command("release <id>").description("Release module to BRICKS platform").requiredOption("-c, --config <path|json>","Module config file path or JSON string").option("-n, --name <name>","Update module name as part of the release").option("--version <version>","Version name").option("--changelogs <text>","Release changelogs").option("--dry-run","Validate inputs and show the release plan without publishing").option("-j, --json","Output as JSON").action((u=f(function*(e,t){var a=(0,w.o)(),i=t.json?null:(0,g.default)("Releasing module...").start();try{var n=(0,F.Ku)(t.config),r=n.config,o=n.source,s=n.sizeBytes,p=yield a.module({id:e});if(!p)throw Error("Module not found");if(p.is_public)throw Error("Public module deployment is temporarily not recommended");var l=t.version||t.name||p.name||"Untitled",d=(0,F.w9)(t.changelogs);if(t.dryRun){i&&i.stop(),(0,C.S5)({action:"module.release",target:T(p,e),request:{name:t.name||null,version:l,changelogs:t.changelogs||null,configSource:o,configSizeBytes:s},checks:[(0,C.Iy)("module exists",!0,`${p.name} (${p._id})`),(0,C.Iy)("module is private",!p.is_public),(0,C.Iy)("release config loaded",!0,`${s} bytes`)],json:t.json});return}var u=yield a.releaseModule({id:e,config:r,...t.name?{name:t.name}:{},releaseCurrentVersion:l,releaseCurrentVersionNote:d});t.json?(0,C.yd)({action:"module.release",target:T(u||p,e),result:{name:t.name||null,version:l,configSource:o,configSizeBytes:s},json:!0}):i.succeed(`Module released: ${v.Ay.green(u?.name||p.name)}`)}catch(a){t.json?(0,_.OW)(a.message,{action:"module.release",target:{id:e}}):i.fail(`Failed to release module: ${a.message}`),process.exit(1)}}),function(e,t){return u.apply(this,arguments)})),A.command("project-pull <id>").description("Pull module source files from BRICKS platform").option("-j, --json","Output as JSON (for programmatic use)").action((c=f(function*(e,t){var a=(0,w.o)(),i=t.json?null:(0,g.default)("Pulling module project...").start();try{var n=yield a.moduleProject({id:e,buildApplicationOnly:!0});n||(i?i.fail("Module project not found"):console.error(JSON.stringify({error:"Module project not found"})),process.exit(1)),t.json?console.log(JSON.stringify(n)):(i.succeed(`Module project fetched: ${v.Ay.green(n.files?.length||0)} files`),console.log(JSON.stringify(n,null,2)))}catch(e){t.json?console.error(JSON.stringify({error:e.message})):i.fail(`Failed to pull module project: ${e.message}`),process.exit(1)}}),function(e,t){return c.apply(this,arguments)})),A.command("ctor-init <id>").alias("project-init").description("Initialize a BRICKS Project from a module").option("-o, --output <dir>","Output directory (default: current directory)").option("--github-actions","Include GitHub Actions workflow (default: true)").option("--no-github-actions","Skip GitHub Actions workflow setup").option("--agents","Include AGENTS.md (default: true)").option("--no-agents","Skip AGENTS.md setup").option("--claude","Include CLAUDE.md (default: true)").option("--no-claude","Skip CLAUDE.md setup").option("--gemini","Include GEMINI.md (default: false)").option("--no-gemini","Skip GEMINI.md setup").option("--install","Run bun install after generation (default: true)").option("--no-install","Skip bun install after generation").option("--git","Initialize git repository (default: true)").option("--no-git","Skip git initialization").option("-y, --yes","Skip prompts and use defaults/flags").option("-j, --json","Output as JSON (for programmatic use)").action((m=f(function*(e,t){var i=(yield a.e(602).then(a.bind(a,6553))).initProject;yield i("module",e,t)}),function(e,t){return m.apply(this,arguments)}))},86141(e,t,a){a.d(t,{D:()=>V});var i,n,r,o,s,p,l,d,u,c=a(99436),m=a(35679),f=a(73284),h=a(30155),v=a(88958),g=a(73024),y=a(76760),D=a(48161),b=e=>{if(!e)return e;try{return g.realpathSync(e)}catch{return e}},x=a(68832),_=a(31421),w=a(51455),E="@fugood/bricks-cli",F="win32"===process.platform,C=(e,t)=>`https://cdn.bricks.tools/bricks-cli/${e}/${t}`,T=e=>"beta"===e?"beta":"latest",A=(i=c(function*(e){var t=yield fetch(e);if(!t.ok)throw Error(`Failed to fetch ${e}: HTTP ${t.status}`);return t}),function(e){return i.apply(this,arguments)}),S=(n=c(function*(e){return(yield A(C(e,"version.json"))).json()}),function(e){return n.apply(this,arguments)}),O=(r=c(function*(e){var t=T(e),a=yield A(`https://registry.npmjs.org/-/package/${E}/dist-tags`),i=(yield a.json())[t];if(!i)throw Error(`No '${t}' dist-tag for ${E}`);return{version:i}}),function(e){return r.apply(this,arguments)}),N=(o=c(function*(e,t){return"npm"===t||"bun"===t?O(e):S(e)}),function(e,t){return o.apply(this,arguments)}),k=(e,t,a={})=>{var i=(0,_.spawnSync)(e,t,{stdio:"inherit",...a});if(i.error){if("ENOENT"===i.error.code)throw Error(`Command not found: ${e}`);throw i.error}if(0!==i.status){var n=Error(`${e} exited with code ${i.status}`);throw n.code=i.status,n}},I=(s=c(function*(e,t){var a=yield A(e),i=Buffer.from((yield a.arrayBuffer())),n=y.join(D.tmpdir(),`bricks-cli-update-${process.pid}-${t}`);return yield w.writeFile(n,i),F||(yield w.chmod(n,493)),n}),function(e,t){return s.apply(this,arguments)}),$=(p=c(function*(e,{installDir:t}={}){var a=F?"install.ps1":"install.sh",i=yield I(C(e,a),a);try{var n=F?["powershell",["-NoProfile","-ExecutionPolicy","Bypass","-File",i,..."beta"===e?["-Beta"]:[],...t?["-InstallDir",t]:[]]]:["sh",[i,..."beta"===e?["--beta"]:[],...t?[`--dir=${t}`]:[]]],r=x(n,2),o=r[0],s=r[1];k(o,s)}finally{yield w.unlink(i).catch(()=>{})}}),function(e){return p.apply(this,arguments)}),j=(l=c(function*(e,t,a={}){if("npm"===e)return void k("npm",["install","-g",`${E}@${T(t)}`]);if("bun"===e)return void k("bun",["install","-g",`${E}@${T(t)}`]);if("binary"===e)return $(t,{installDir:a.installDir});throw Error(`Unsupported update method: ${e}`)}),function(e,t){return l.apply(this,arguments)}),B=a(8479),R=(d=c(function*({message:e,defaultValue:t,autoYes:a}){if(a)return!0;(0,B.z)()||(console.error(f.Ay.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{return yield(0,v.lJ)({message:e,default:t})}catch{return!1}}),function(e){return d.apply(this,arguments)}),V=new m.uB("update-cli").description("Update the BRICKS CLI to the latest version").option("-y, --yes","Skip confirmation prompts").option("--channel <channel>","Override channel (release|beta)").option("--check-update","Only check whether a newer version is available and exit").action((u=c(function*(e){var t,a="2.25.0-beta.19",i=(({execPath:e=process.execPath,scriptPath:t=process.argv[1],homeDir:a=D.homedir(),realpath:i=b}={})=>{let n;var r=(n=e)?y.basename(n).replace(/\.exe$/i,""):"";if("bricks"===r||"bricks-beta"===r)return{method:"binary",execPath:e,installDir:y.dirname(e)};var o=i(t),s=((e,t)=>{if(!e)return null;var a=y.sep,i=`${a}node_modules${a}${t.replace(/\//g,a)}${a}`,n=e.indexOf(i);return -1===n?null:e.slice(0,n)})(o,"@fugood/bricks-cli");if(s){var p=y.sep,l=y.join(a,".bun","install","global");return s===l||s.startsWith(l+p)?{method:"bun",installRoot:s}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(s)?{method:"pnpm",installRoot:s}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(s)?{method:"yarn",installRoot:s}:{method:"npm",installRoot:s.endsWith(`${p}lib`)?s.slice(0,-`${p}lib`.length):s}}return{method:"unknown",execPath:e,scriptPath:o}})(),n=e.channel||(({version:e,execPath:t}={})=>{var a=t||process.execPath;return a&&/[\\/]bricks-beta(?:\.exe)?$/i.test(a)||/-(beta|alpha|rc|next)\b/i.test(e||"2.25.0-beta.19")?"beta":"release"})({version:a,execPath:i.execPath});console.log(f.Ay.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${f.Ay.cyan(a)}`),console.log(`Channel : ${f.Ay.cyan(n)}`),console.log(`Detected method : ${f.Ay.cyan(i.method)}`),i.execPath&&"binary"===i.method&&console.log(`Binary path : ${f.Ay.gray(i.execPath)}`),i.installRoot&&console.log(`Install root : ${f.Ay.gray(i.installRoot)}`);var r="npm"===i.method||"bun"===i.method?"npm":"cdn",o=(0,h.default)(`Fetching latest version info (${r})...`).start(),s=null,p=null;try{s=(yield N(n,i.method)).version,o.succeed(`Latest ${n} (${r}): ${f.Ay.green(s)}`)}catch(e){p=e,o.warn(`Could not fetch version info: ${e.message}`)}var l=s&&s===a;if(e.checkUpdate){if(p&&process.exit(2),l)return void console.log(f.Ay.green("\nUp to date."));s&&(console.log(f.Ay.yellow(`
86
86
  Update available: ${a} → ${s}. Run 'bricks update-cli' to install.`)),process.exit(1)),console.log(f.Ay.yellow("\nCould not determine current version.")),process.exit(2)}if(l&&(console.log(f.Ay.green("\nAlready running the latest version.")),!(yield R({message:"Reinstall anyway?",defaultValue:!1,autoYes:e.yes}))))return void console.log(f.Ay.gray("Skipped."));var d=["npm","bun","binary"].includes(i.method);d||console.log(f.Ay.yellow(`Cannot auto-detect installer (method: ${i.method}); falling back to binary install.`));var u=d?i.method:"binary";if(!(yield R({message:`Update CLI using "${u}" method?`,defaultValue:!0,autoYes:e.yes})))return void console.log(f.Ay.yellow("Cancelled."));var m=(t=c(function*(e){console.log(f.Ay.cyan(`
87
87
  → Running ${e} update...`));try{return yield j(e,n,i),!0}catch(t){return console.error(f.Ay.yellow(`
88
88
  ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,arguments)}),v=yield m(u);!v&&"binary"!==u&&(console.log(f.Ay.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield R({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(v=yield m("binary"))),v||(console.error(f.Ay.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(f.Ay.green("\nUpdate complete."))}),function(e){return u.apply(this,arguments)}))},92642(e,t,a){a.d(t,{W:()=>_});var i,n,r,o=a(99436),s=a(5018),p=a(44668),l=a(4275),d=a(32235),u=a(62192),c=a(79657),m=a(64007);function f(e){var t,a,i,n=2;for("u">typeof Symbol&&(a=Symbol.asyncIterator,i=Symbol.iterator);n--;){if(a&&null!=(t=e[a]))return t.call(e);if(i&&null!=(t=e[i]))return new h(t.call(e));a="@@asyncIterator",i="@@iterator"}throw TypeError("Object is not async iterable")}function h(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return(h=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var a=this.s.return;return void 0===a?Promise.resolve({value:e,done:!0}):t(a.apply(this.s,arguments))},throw:function(e){var a=this.s.return;return void 0===a?Promise.reject(e):t(a.apply(this.s,arguments))}},new h(e)}function v(){return(v=l(function*(e){var t=e.headers.get("content-type")||"";if(t.includes("application/json")){var a=yield d(e.json());if(a.errors?.length)throw Error(a.errors.map(e=>e.message).join("\n"));var i=Object.keys(a.data||{})[0];if(i&&Array.isArray(a.data[i]))for(var n of a.data[i])yield n;return}var r=t.match(/boundary="?([^";]+)"?/),o=r?r[1]:"-",s=`--${o}`,p="",l=!1,c=new TextDecoder,m=function*(){for(var e;-1!==(e=p.indexOf(s));){var t=p.slice(0,e);(p=p.slice(e+s.length)).startsWith("\r\n")?p=p.slice(2):p.startsWith("\n")&&(p=p.slice(1));var a=t.indexOf("\r\n\r\n"),i=-1!==a?t.slice(a+4).trim():t.trim();if(i){var n=void 0;try{n=JSON.parse(i)}catch{continue}if(n.errors?.length)throw Error(n.errors.map(e=>e.message).join("\n"));if(n.data){for(var r of Object.values(n.data))if(Array.isArray(r))for(var o of r)yield o}if(Array.isArray(n.incremental)){for(var d of n.incremental)if(Array.isArray(d.items))for(var u of d.items)yield u}if(!1===n.hasNext){l=!0;return}}}};try{var h=!1,v=!1;try{for(var g,y,D=f(e.body);h=!(y=yield d(D.next())).done;h=!1){var b=y.value;if(p+=c.decode(b,{stream:!0}),yield*u(f(m()),d),l)break}}catch(e){v=!0,g=e}finally{try{h&&null!=D.return&&(yield d(D.return()))}finally{if(v)throw g}}}catch(e){if(!e.message?.includes("Premature close")||!l)throw e}if(!l&&p.trim()){var x,_=p.indexOf("\r\n\r\n"),w=-1!==_?p.slice(_+4).trim():p.trim();if(w&&!w.startsWith("--")){try{x=JSON.parse(w)}catch{}if(x){if(x.errors?.length)throw Error(x.errors.map(e=>e.message).join("\n"));if(x.data){for(var E of Object.values(x.data))if(Array.isArray(E))for(var F of E)yield F}if(Array.isArray(x.incremental)){for(var C of x.incremental)if(Array.isArray(C.items))for(var T of C.items)yield T}!1===x.hasNext&&(l=!0)}}}e.body?.destroy()})).apply(this,arguments)}var g=`
@@ -115,7 +115,7 @@ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,argume
115
115
  workspaceName
116
116
  }
117
117
  }
118
- `,a=yield this.apolloClient.mutate({mutation:t,variables:{passcode:e}}),i=a.data,n=a.errors;if(n?.length>0)throw Error(n.map(({message:e})=>e).join("\n"));return i.exchangeWorkspaceOTP}),function(e){return n.apply(this,arguments)})}]),E=e=>new w(e),F=l(function e(t,a){p(this,e),this.baseUrl=t,this.token=a,this.endpoint="/api/graphql-workspace";var i=new D({uri:`${t}${this.endpoint}`,fetch:_(t)}),n=b((e,{headers:t})=>({headers:{...t,authorization:`Bearer ${a}`}}));this.apolloClient=new g({link:n.concat(i),cache:new y,defaultOptions:{watchQuery:{errorPolicy:"all",fetchPolicy:"no-cache"},query:{errorPolicy:"all",fetchPolicy:"no-cache"}}}),this.queries=h,this.mutations=v,this.generateMethods()},[{key:"generateMethods",value:function(){var e=this,t=t=>([a,i])=>{this[a]||(this[a]=s(function*(n={},r={}){try{var o=e.apolloClient[x[t]].bind(e.apolloClient),s=yield o({[t]:i,variables:n,...r}),p=s.data,l=s.errors;if(l)throw Error(l.map(({message:e})=>e).join("\n"));return p[a]||p[`UNSTABLE_${a}`]}catch(e){if(e.cause?.result?.errors)throw Error(e.cause.result.errors.map(({message:e})=>e).join("\n"));throw e}}))};Object.entries(this.queries).forEach(t("query")),Object.entries(this.mutations).forEach(t("mutation"))}},{key:"query",value:(r=s(function*(e,t={}){var a=yield this.apolloClient.query({query:e,variables:t,fetchPolicy:"no-cache"}),i=a.data,n=a.errors;if(n?.length>0)throw Error(n.map(({message:e})=>e).join("\n"));return i}),function(e){return r.apply(this,arguments)})},{key:"mutate",value:(o=s(function*(e,t={}){var a=yield this.apolloClient.mutate({mutation:e,variables:t}),i=a.data,n=a.errors;if(n?.length>0)throw Error(n.map(({message:e})=>e).join("\n"));return i}),function(e){return o.apply(this,arguments)})}]),C=(e,t)=>new F(e,t)},48596(e,t,a){a.d(t,{$7:()=>l,$V:()=>d,F3:()=>r,J6:()=>u,NJ:()=>o,Yi:()=>n,lI:()=>p,mJ:()=>s});var i=a(94370),n=(0,i.default)`
118
+ `,a=yield this.apolloClient.mutate({mutation:t,variables:{passcode:e}}),i=a.data,n=a.errors;if(n?.length>0)throw Error(n.map(({message:e})=>e).join("\n"));return i.exchangeWorkspaceOTP}),function(e){return n.apply(this,arguments)})}]),E=e=>new w(e),F=l(function e(t,a){p(this,e),this.baseUrl=t,this.token=a,this.endpoint="/api/graphql-workspace";var i=new D({uri:`${t}${this.endpoint}`,fetch:_(t)}),n=b((e,{headers:t})=>({headers:{...t,authorization:`Bearer ${a}`}}));this.apolloClient=new g({link:n.concat(i),cache:new y,defaultOptions:{watchQuery:{errorPolicy:"all",fetchPolicy:"no-cache"},query:{errorPolicy:"all",fetchPolicy:"no-cache"}}}),this.queries=h,this.mutations=v,this.generateMethods()},[{key:"generateMethods",value:function(){var e=this,t=t=>([a,i])=>{this[a]||(this[a]=s(function*(n={},r={}){try{var o=e.apolloClient[x[t]].bind(e.apolloClient),s=yield o({[t]:i,variables:n,...r}),p=s.data,l=s.errors;if(l)throw Error(l.map(({message:e})=>e).join("\n"));return p[a]}catch(e){if(e.cause?.result?.errors)throw Error(e.cause.result.errors.map(({message:e})=>e).join("\n"));throw e}}))};Object.entries(this.queries).forEach(t("query")),Object.entries(this.mutations).forEach(t("mutation"))}},{key:"query",value:(r=s(function*(e,t={}){var a=yield this.apolloClient.query({query:e,variables:t,fetchPolicy:"no-cache"}),i=a.data,n=a.errors;if(n?.length>0)throw Error(n.map(({message:e})=>e).join("\n"));return i}),function(e){return r.apply(this,arguments)})},{key:"mutate",value:(o=s(function*(e,t={}){var a=yield this.apolloClient.mutate({mutation:e,variables:t}),i=a.data,n=a.errors;if(n?.length>0)throw Error(n.map(({message:e})=>e).join("\n"));return i}),function(e){return o.apply(this,arguments)})}]),C=(e,t)=>new F(e,t)},48596(e,t,a){a.d(t,{$7:()=>l,$V:()=>d,F3:()=>r,J6:()=>u,NJ:()=>o,Yi:()=>n,lI:()=>p,mJ:()=>s});var i=a(94370),n=(0,i.default)`
119
119
  fragment cliWorkspaceArguments on Workspace {
120
120
  _id
121
121
  name
@@ -908,7 +908,7 @@ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,argume
908
908
  $setupClaudeCode: Boolean
909
909
  $setupGeminiCLI: Boolean
910
910
  ) {
911
- UNSTABLE_applicationProject(
911
+ applicationProject(
912
912
  id: $id
913
913
  buildApplicationOnly: $buildApplicationOnly
914
914
  setupGitHubActions: $setupGitHubActions
@@ -926,7 +926,7 @@ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,argume
926
926
  $setupClaudeCode: Boolean
927
927
  $setupGeminiCLI: Boolean
928
928
  ) {
929
- UNSTABLE_moduleProject(
929
+ moduleProject(
930
930
  id: $id
931
931
  buildApplicationOnly: $buildApplicationOnly
932
932
  setupGitHubActions: $setupGitHubActions
@@ -944,7 +944,7 @@ ${e} update failed: ${t.message}`)),!1}}),function(e){return t.apply(this,argume
944
944
  lastSeenAt
945
945
  }
946
946
  }
947
- `},1878(e,t,a){a.a(e,async function(e,i){try{a.d(t,{A:()=>C,e:()=>F});var n,r=a(99436),o=a(35679),s=a(73284),p=a(23258),l=a(8479),d=a(55614),u=a(1983),c=a(17422),m=a(32541),f=a(28634),h=a(37818),v=a(71335),g=a(429),y=a(80274),D=a(42400),b=a(98247),x=a(11405),_=a(86141),w=a(59845),E=e([D]);D=(E.then?(await E)():E)[0];var F=(n=r(function*(){var e,t=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==t&&process.argv[t+1]&&((0,p.setProfileOverride)(process.argv[t+1]),process.argv.splice(t,2)),o.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.0-beta.17","-v, --version","output the version number").enablePositionalOptions(),o.DM.addCommand(d.s),o.DM.addCommand(u._),o.DM.addCommand(c.B),o.DM.addCommand(m.A),o.DM.addCommand(f.p),o.DM.addCommand(h.u),o.DM.addCommand(v.oT),o.DM.addCommand(g.K),o.DM.addCommand(y.g),o.DM.addCommand(D.D),o.DM.addCommand(b.v),o.DM.addCommand(x.l),o.DM.addCommand(_.D),o.DM.addCommand(w.Q),o.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(r(function*(){try{var e=(yield Promise.all([a.e(3),a.e(940)]).then(a.bind(a,92319))).runInteractiveMode;yield e()}catch(e){console.error(s.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),o.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=r(function*(e){var t=yield Promise.resolve().then(a.bind(a,23258)),i=t.getToken,n=t.getBaseUrl,r=t.getCurrentProfile,o=(yield Promise.resolve().then(a.bind(a,85382))).createClient,p=(yield Promise.resolve().then(a.bind(a,30155))).default,l=r(),d=i(l);d||(console.error(s.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=p("Fetching workspace info...").start();try{var c=o(n(),d),m=yield c.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(m,null,2));console.log(s.Ay.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${s.Ay.green(m.name)}`),console.log(`ID: ${s.Ay.gray(m._id)}`),console.log(`Description: ${m.description||s.Ay.gray("N/A")}`),console.log(`
947
+ `},1878(e,t,a){a.a(e,async function(e,i){try{a.d(t,{A:()=>C,e:()=>F});var n,r=a(99436),o=a(35679),s=a(73284),p=a(23258),l=a(8479),d=a(55614),u=a(1983),c=a(17422),m=a(32541),f=a(28634),h=a(37818),v=a(71335),g=a(429),y=a(80274),D=a(42400),b=a(98247),x=a(11405),_=a(86141),w=a(59845),E=e([D]);D=(E.then?(await E)():E)[0];var F=(n=r(function*(){var e,t=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==t&&process.argv[t+1]&&((0,p.setProfileOverride)(process.argv[t+1]),process.argv.splice(t,2)),o.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.0-beta.19","-v, --version","output the version number").enablePositionalOptions(),o.DM.addCommand(d.s),o.DM.addCommand(u._),o.DM.addCommand(c.B),o.DM.addCommand(m.A),o.DM.addCommand(f.p),o.DM.addCommand(h.u),o.DM.addCommand(v.oT),o.DM.addCommand(g.K),o.DM.addCommand(y.gf),o.DM.addCommand(D.D),o.DM.addCommand(b.v),o.DM.addCommand(x.l),o.DM.addCommand(_.D),o.DM.addCommand(w.Q),o.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(r(function*(){try{var e=(yield Promise.all([a.e(3),a.e(940)]).then(a.bind(a,92319))).runInteractiveMode;yield e()}catch(e){console.error(s.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),o.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=r(function*(e){var t=yield Promise.resolve().then(a.bind(a,23258)),i=t.getToken,n=t.getBaseUrl,r=t.getCurrentProfile,o=(yield Promise.resolve().then(a.bind(a,85382))).createClient,p=(yield Promise.resolve().then(a.bind(a,30155))).default,l=r(),d=i(l);d||(console.error(s.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=p("Fetching workspace info...").start();try{var c=o(n(),d),m=yield c.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(m,null,2));console.log(s.Ay.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${s.Ay.green(m.name)}`),console.log(`ID: ${s.Ay.gray(m._id)}`),console.log(`Description: ${m.description||s.Ay.gray("N/A")}`),console.log(`
948
948
  ${s.Ay.bold("Data")}`),console.log(`Remote Update: ${m.bank?.enable_remote_update?s.Ay.green("Enabled"):s.Ay.gray("Disabled")}`),console.log(`Spacename: ${m.bank?.spacename||s.Ay.gray("N/A")}`),console.log("─".repeat(60))}catch(e){u.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}}),function(t){return e.apply(this,arguments)})),o.DM.on("--help",()=>{console.log(""),console.log(s.Ay.bold("Examples:")),console.log(""),console.log(s.Ay.gray(" # Login with a one-time passcode (recommended)")),console.log(" $ bricks auth login <passcode>"),console.log(""),console.log(s.Ay.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(s.Ay.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(s.Ay.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(s.Ay.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(s.Ay.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(s.Ay.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(s.Ay.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(s.Ay.gray("Get workspace token from BRICKS Controller:")),console.log(s.Ay.cyan(" https://control.bricks.tools")),console.log(s.Ay.gray(" Go to Workspace Settings > API Token"))});var i=process.argv.slice(2);if(0===i.length){if((0,l.b)(i))try{var n=(yield Promise.all([a.e(3),a.e(940)]).then(a.bind(a,92319))).runInteractiveMode;yield n();return}catch(e){console.error(s.Ay.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}console.error(s.Ay.gray("No command provided. Interactive mode requires a TTY, so showing help instead.\n")),o.DM.outputHelp();return}yield o.DM.parseAsync(process.argv)}),function(){return n.apply(this,arguments)});let C=F;i()}catch(e){i(e)}})},56493(e,t,a){a.d(t,{o:()=>o});var i=a(73284),n=a(23258),r=a(85382),o=()=>{var e=(0,n.getCurrentProfile)(),t=(0,n.getToken)(e);return t||(console.error(i.Ay.red("Not logged in. Use `bricks auth login` first.")),process.exit(1)),(0,r.createClient)((0,n.getBaseUrl)(),t)}},7586(e,t,a){a.d(t,{$l:()=>r,GF:()=>i,OW:()=>n});var i=e=>{console.log(JSON.stringify(e,null,2))},n=(e,t={})=>{console.error(JSON.stringify({ok:!1,error:{message:e,...t}},null,2))},r=(e,t=4)=>e?e.length<=2*t?"*".repeat(e.length):`${e.slice(0,t)}…${e.slice(-t)}`:null},8479(e,t,a){a.d(t,{b:()=>n,z:()=>i});var i=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&"function"==typeof process.stdin.setRawMode),n=(e=[])=>0===e.length&&i()},23258(e,t,i){i.r(t),i.d(t,{setActivityLogBaseUrl:()=>w,listProfiles:()=>x,removeToken:()=>h,setBaseUrl:()=>d,setProfileOverride:()=>g,getBaseUrl:()=>l,CONFIG_PATH:()=>s,CONFIG_DIR:()=>o,getCurrentProfileSource:()=>D,default:()=>F,getToken:()=>c,clearConfig:()=>E,getTokens:()=>u,getActivityLogBaseUrl:()=>_,getTokenInfo:()=>m,setCurrentProfile:()=>b,getCurrentProfile:()=>y,setToken:()=>f});var n=i(16928),r=i(70857),o=n.join(r.homedir(),".bricks-cli"),s=n.join(o,"config.json"),p=new a({projectName:"bricks-cli",cwd:o,schema:{tokens:{type:"object",default:{},additionalProperties:{type:"object",properties:{token:{type:"string"},name:{type:"string"},workspaceId:{type:"string"},workspaceName:{type:"string"},createdAt:{type:"string"},baseUrl:{type:"string"}}}},currentProfile:{type:"string",default:"default"},baseUrl:{type:"string",default:"https://display.bricks.tools"},activityLogBaseUrl:{type:"string",default:"https://activity-log.bricks.tools"}}}),l=()=>{var e=y(),t=p.get("tokens");return t[e]?.baseUrl||p.get("baseUrl")},d=(e,t)=>{if(!t)return void p.set("baseUrl",e);var a=p.get("tokens");a[t]||(a[t]={}),a[t].baseUrl=e,p.set("tokens",a)},u=()=>p.get("tokens"),c=(e="default")=>{var t=p.get("tokens");return t[e]?.token},m=(e="default")=>p.get("tokens")[e],f=(e,t)=>{var a=p.get("tokens"),i=a[e];a[e]={...i?.baseUrl?{baseUrl:i.baseUrl}:{},...i?.activityLogBaseUrl?{activityLogBaseUrl:i.activityLogBaseUrl}:{},...t,createdAt:new Date().toISOString()},p.set("tokens",a)},h=e=>{var t=p.get("tokens");delete t[e],p.set("tokens",t)},v=null,g=e=>{v=e},y=()=>v||process.env.BRICKS_PROFILE||p.get("currentProfile"),D=()=>v?"override":process.env.BRICKS_PROFILE?"env":"config",b=e=>p.set("currentProfile",e),x=()=>{var e=p.get("tokens"),t=p.get("currentProfile");return Object.keys(e).map(a=>({...e[a],name:a,current:a===t}))},_=()=>{var e=y(),t=p.get("tokens");return t[e]?.activityLogBaseUrl||p.get("activityLogBaseUrl")},w=(e,t)=>{if(!t)return void p.set("activityLogBaseUrl",e);var a=p.get("tokens");a[t]||(a[t]={}),a[t].activityLogBaseUrl=e,p.set("tokens",a)},E=()=>{p.clear()};let F=p},75646(e,t,a){a.r(t),a.d(t,{discoverDevToolsServers:()=>d,httpProbeSubnet:()=>u,verifyDevToolsServer:()=>c});var i,n,r=a(99436),o=a(41314),s=a(48161),p="bricks-devtools",l=()=>{var e=[];for(var t of Object.values(s.networkInterfaces()))for(var a of t)if(function(){if("IPv4"!==a.family||a.internal)return 1;var t=a.address.split(".").map(Number),i=a.netmask.split(".").map(Number),n=t.map((e,t)=>(e|255&~i[t]).toString()).join(".");e.push({address:a.address,broadcast:n})}())continue;return e},d=({timeout:e=3e3,idleTimeout:t=0}={})=>new Promise((a,i)=>{var n=new Map,r=o.createSocket("udp4"),s=null,d=null,u=!1,c=()=>{if(!u){u=!0,clearTimeout(s),clearTimeout(d);try{r.close()}catch{}a([...n.values()])}};r.on("error",e=>{if(!u){u=!0,clearTimeout(s),clearTimeout(d);try{r.close()}catch{}i(e)}}),r.on("message",(e,a)=>{try{var i=JSON.parse(e.toString());if(i.s!==p||"ANNOUNCE"!==i.t&&"RESPONSE"!==i.t)return;var r=i.d?.info;if(!r)return;var o=a.address,s=`${o}:${r.port}`;n.has(s)||(n.set(s,{...r,address:o}),t&&!u&&(clearTimeout(d),d=setTimeout(c,t)))}catch{}}),r.bind(()=>{r.setBroadcast(!0);var t=Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:p,d:{id:`cli-${Math.random().toString(36).substring(2,9)}`}})),a=new Set(["255.255.255.255","127.0.0.1"]);for(var i of l())a.add(i.broadcast);for(var n of a)r.send(t,0,t.length,19900,n);s=setTimeout(c,e)})}),u=(i=r(function*({port:e=19851,connectTimeout:t=500,concurrency:a=50,timeout:i=0}={}){var n=l();if(0===n.length)return[];var o=[],s=i>0?Date.now()+i:0,p=[],d=new Set;for(var u of n){var m=u.address.split(".").slice(0,3).join(".");if(!d.has(m)){d.add(m);for(var f=1;f<255;f++)p.push(`${m}.${f}`)}}for(var h=0;h<p.length&&!(s&&Date.now()>=s);h+=a){var v=p.slice(h,h+a);yield Promise.allSettled(v.map(function(){var a=r(function*(a){var i=yield c(a,e,t);i&&o.push({...i,address:a,port:e})});return function(e){return a.apply(this,arguments)}}()))}return o}),function(){return i.apply(this,arguments)}),c=(n=r(function*(e,t,a=3e3){try{var i=new AbortController,n=setTimeout(()=>i.abort(),a),r=yield fetch(`http://${e}:${t}/devtools/info`,{signal:i.signal});if(clearTimeout(n),!r.ok)return null;return yield r.json()}catch{return null}}),function(e,t){return n.apply(this,arguments)})},74049(e,t,a){a.d(t,{Ku:()=>s,w9:()=>o});var i=a(79896),n=a(16928),r=new Set(["CTOR","CTOR Desktop"]),o=e=>{var t,a=`Release by ${(t=process.env.BRICKS_RELEASE_SIGN)&&r.has(t)?t:"BRICKS CLI"}`;return e?`${e}
949
949
 
950
950
  ${a}`:a},s=e=>{if(e.endsWith(".json")||e.includes("/")){if(!i.existsSync(e))throw Error(`Config file not found: ${e}`);var t=i.readFileSync(e,"utf-8");return{config:t,source:{type:"file",path:n.resolve(e)},sizeBytes:Buffer.byteLength(t)}}return{config:e,source:{type:"inline"},sizeBytes:Buffer.byteLength(e)}}},68168(e,t,a){a.d(t,{K:()=>o,Y:()=>s});var i,n=a(99436),r=e=>String(e||"").trim().toLowerCase(),o=({resource:e,query:t,items:a,fields:i,selectedBy:n=null})=>{var o=r(t),s=a.filter(e=>i.some(t=>r(t.split(".").reduce((e,t)=>e?.[t],e)??null)===o)),p=null,l=n;return"id"===n?p=a[0]||null:1===s.length?(p=s[0],l="exact"):1===a.length&&(p=a[0],l="single"),{resource:e,query:t,exactMatchCount:s.length,matchCount:a.length,selectedBy:l,ambiguous:a.length>1&&!p,resolved:p,matches:a}},s=(i=n(function*(e){try{return yield e()}catch(e){if(/not found/i.test(e.message))return null;throw e}}),function(e){return i.apply(this,arguments)})},60450(e,t,a){a.d(t,{Gu:()=>m,he:()=>h,wR:()=>u});var i,n,r,o=a(99436),s=a(79657),p=a(73024),l=a(76760),d=a(48161),u=e=>e?.media_resource?.enable_media_workspace===!0,c=(i=o(function*(e,t,a){var i=yield e.mediaFiles({boxId:t,userTags:[`bricks_screenshot_${a}`],limit:1});return i?.[0]||null}),function(e,t,a){return i.apply(this,arguments)}),m=(e,{preferThumbnail:t=!1}={})=>{if(!e?.meta?.storageEndpoint)return null;var a=e.meta,i=a.storageEndpoint,n=a.originalFileKey,r=(t?(e=>{var t=e?.meta;if(!t)return null;if("Video"===e.fileType&&t.videoThumbOriginalFileKey)return t.videoThumbOriginalFileKey;var a=t.imageVersions||[];if(!Array.isArray(a)||0===a.length)return null;var i=a.filter(e=>e?.strategy==="BOUNDED"&&"number"==typeof e.width).sort((e,t)=>e.width-t.width);return(i[0]||a[0])?.key||null})(e):null)||n;return r?`${i}/${r}`:null},f=(n=o(function*(e,t=null){var a=yield(0,s.Ay)(e);if(!a.ok)throw Error(`Failed to download screenshot: ${a.statusText}`);var i=yield a.buffer(),n=t||l.join(d.tmpdir(),`bricks-screenshot-${Date.now()}.png`),r=l.dirname(n);return p.existsSync(r)||p.mkdirSync(r,{recursive:!0}),p.writeFileSync(n,i),n}),function(e){return n.apply(this,arguments)}),h=(r=o(function*(e,t,a,i=null,n={}){var r=u(t)&&t.media_resource?.system_media_box_id||null;if(!r)return{error:"Media workspace not enabled for this workspace"};var o=yield c(e,r,a);if(!o)return{error:"No screenshot available for this device"};var s=m(o,n);return s?{path:yield f(s,i),file:o,url:s}:{error:"Could not build screenshot URL"}}),function(e,t,a){return r.apply(this,arguments)})},44618(e,t,a){a.d(t,{V:()=>r});var i={S:"Subspace",B:"Brick",C:"Canvas",A:"Animation",G:"Generator",D:"Data",F:"Data Calc",N:"Calc Node",T:"Test",TC:"Test Case",AT:"Automation Map"},n=e=>e?.split("_")?.[0]||"",r=(e,{keyword:t,types:a}={})=>{var r=t?.trim().toLowerCase()||"",o=a?.length>0?new Set(a.flatMap(e=>{var t=String(e).trim().toUpperCase();return t?[t]:[]})):null;return Object.entries(Object.entries(e||{}).filter(([,e])=>e&&!e.hide).filter(([e,t])=>{var a=n(e);if(o&&!o.has(a))return!1;if(!r)return!0;var i=t?.title?String(t.title).toLowerCase():"";return e.toLowerCase().includes(r)||i.includes(r)}).reduce((e,[t,a])=>{var i=n(t);return e[i]||(e[i]=[]),e[i].push({shortId:t,ref:a}),e},{})).map(([e,t])=>({prefix:e,label:i[e]||e,refs:t.sort((e,t)=>{var a=e.ref?.title||e.shortId,i=t.ref?.title||t.shortId;return String(a).localeCompare(String(i))})})).sort((e,t)=>e.label.localeCompare(t.label))}},94979(e,t,a){a.d(t,{p:()=>r});var i=/^(\d+)(s|m|h|d|w)$/,n={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function r(e){var t=e.match(i);if(t){var a=parseInt(t[1],10),r=n[t[2]];return new Date(Date.now()-a*r).toISOString()}var o=new Date(e);if(isNaN(o.getTime()))throw Error(`Invalid time format: "${e}". Use ISO 8601 or relative (e.g. 1h, 30m, 2d)`);return o.toISOString()}},98593(e,t,a){a.d(t,{Iy:()=>r,S5:()=>s,yd:()=>p});var i=a(73284),n=a(7586),r=(e,t,a)=>({label:e,ok:t,detail:a}),o=e=>null==e?i.Ay.gray("N/A"):"object"==typeof e?i.Ay.gray(JSON.stringify(e,null,2)):String(e),s=({action:e,target:t,request:a,checks:r=[],json:s=!1})=>{s?(0,n.GF)({ok:!0,dryRun:!0,action:e,target:t||null,request:a||null,checks:r}):(console.log(i.Ay.bold(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugood/bricks-cli",
3
- "version": "2.25.0-beta.17",
3
+ "version": "2.25.0-beta.19",
4
4
  "description": "BRICKS CLI - Command-line interface for BRICKS Workspace API",
5
5
  "keywords": [
6
6
  "bricks",
@@ -70,5 +70,5 @@
70
70
  "engines": {
71
71
  "node": ">=18.0.0"
72
72
  },
73
- "gitHead": "9163b308db41d22858015eaddf57a77063415ff8"
73
+ "gitHead": "c275ff266863070f0a4d0c2cc6cb7acb8fdce3d4"
74
74
  }