@fugood/bricks-cli 2.25.5 → 2.26.0-beta.0

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/1708.js CHANGED
@@ -6,4 +6,4 @@ ${t}
6
6
  ${s.map(({entry:n})=>n).join("\n")}
7
7
  `;yield(0,k.writeFile)(t,`${i}${l}${c}`),console.log(`Added ${s.map(({entry:n})=>n).join(", ")} to .prettierignore`)}}),function(n){return g.apply(this,arguments)}),H=(y=v(function*(n){var e=D.join(n,".claude","settings.local.json"),t={};if(yield P(e)){try{t=JSON.parse((yield(0,k.readFile)(e,"utf-8")))}catch{console.warn(`Skipping auto mode setup; ${e} is not valid JSON`);return}if(t.autoMode)return}t.autoMode={environment:U},yield(0,k.mkdir)(D.dirname(e),{recursive:!0}),yield(0,k.writeFile)(e,`${JSON.stringify(t,null,2)}
8
8
  `),console.log(`Set up auto mode in ${e}`),yield W(n)}),function(n){return y.apply(this,arguments)}),V=(f=v(function*(n,e){var t,a,r={...R(e),default_tools_approval_mode:"approve"};if(yield P(n)){try{a=T.q((yield(0,k.readFile)(n,"utf-8")))}catch{console.warn(`Skipping .codex/config.toml update; ${n} is not valid TOML`);return}(t=a&&"object"==typeof a?a:{mcp_servers:{}}).mcp_servers&&"object"==typeof t.mcp_servers||(t.mcp_servers={}),t.mcp_servers["bricks-ctor"]=r,delete t.mcp_servers["bricks-project"]}else t={mcp_servers:{"bricks-ctor":r}};yield(0,k.writeFile)(n,`${T.A(t)}
9
- `),console.log(`Updated ${n}`)}),function(n,e){return f.apply(this,arguments)});function q(){return j.apply(this,arguments)}function j(){return(j=v(function*(n=process.cwd()){var e,t=(e=v(function*(n,e){var t,a=[],r=[];return yield Promise.all(Object.entries(n).map((t=v(function*([n,t]){try{(yield(0,k.readFile)(D.join(e,n),"utf8")).replace(/\r\n/g,"\n")!==t.replace(/\r\n/g,"\n")&&a.push(n)}catch{r.push(n)}}),function(n){return t.apply(this,arguments)}))),{changed:a.sort(),missing:r.sort()}}),function(n,t){return e.apply(this,arguments)}),a=yield t(w,D.join(n,"ctor")),r=(yield P(D.join(n,"CLAUDE.md")))||(yield P(D.join(n,"AGENTS.md")))?yield t(L,D.join(n,".bricks","skills")):{changed:[],missing:[]};return{upToDate:a.changed.length+a.missing.length+r.changed.length+r.missing.length===0,cliVersion:"2.25.5",lib:a,skills:r}})).apply(this,arguments)}function z(){return Y.apply(this,arguments)}function Y(){return(Y=v(function*(n={}){var e=process.cwd(),t=!!n.skipCopyProject,a=!!n.refreshSkills;yield O(e);var r=D.join(e,"project");(yield P(r))&&(yield(0,k.rm)(r,{recursive:!0,force:!0}),console.log("Removed legacy project/ directory")),t?console.log("Skipping copy of files to ctor/"):yield N(e),yield K(e);var i=yield P(`${e}/CLAUDE.md`),o=yield P(`${e}/AGENTS.md`);(i||o)&&(yield _(`${e}/.mcp.json`,R(e)),yield F(e,{refreshSkills:a})),i&&(yield H(e)),o&&(yield V(`${e}/.codex/config.toml`,e))})).apply(this,arguments)}},53241(n,e,t){t.r(e),t.d(e,{detectChannel:()=>s,detectInstallMethod:()=>l});var a=t(73024),r=t(76760),i=t(48161),o=n=>{if(!n)return n;try{return a.realpathSync(n)}catch{return n}},s=({version:n,execPath:e}={})=>{var t=e||process.execPath;return t&&/[\\/]bricks-beta(?:\.exe)?$/i.test(t)||/-(beta|alpha|rc|next)\b/i.test(n||"2.25.5")?"beta":"release"},l=({execPath:n=process.execPath,scriptPath:e=process.argv[1],homeDir:t=i.homedir(),realpath:a=o}={})=>{let s;var l=(s=n)?r.basename(s).replace(/\.exe$/i,""):"";if("bricks"===l||"bricks-beta"===l)return{method:"binary",execPath:n,installDir:r.dirname(n)};var c=a(e),p=((n,e)=>{if(!n)return null;var t=r.sep,a=`${t}node_modules${t}${e.replace(/\//g,t)}${t}`,i=n.indexOf(a);return -1===i?null:n.slice(0,i)})(c,"@fugood/bricks-cli");if(p){var d=r.sep,u=r.join(t,".bun","install","global");return p===u||p.startsWith(u+d)?{method:"bun",installRoot:p}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(p)?{method:"pnpm",installRoot:p}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(p)?{method:"yarn",installRoot:p}:{method:"npm",installRoot:p.endsWith(`${d}lib`)?p.slice(0,-`${d}lib`.length):p}}return{method:"unknown",execPath:n,scriptPath:c}}}};
9
+ `),console.log(`Updated ${n}`)}),function(n,e){return f.apply(this,arguments)});function q(){return j.apply(this,arguments)}function j(){return(j=v(function*(n=process.cwd()){var e,t=(e=v(function*(n,e){var t,a=[],r=[];return yield Promise.all(Object.entries(n).map((t=v(function*([n,t]){try{(yield(0,k.readFile)(D.join(e,n),"utf8")).replace(/\r\n/g,"\n")!==t.replace(/\r\n/g,"\n")&&a.push(n)}catch{r.push(n)}}),function(n){return t.apply(this,arguments)}))),{changed:a.sort(),missing:r.sort()}}),function(n,t){return e.apply(this,arguments)}),a=yield t(w,D.join(n,"ctor")),r=(yield P(D.join(n,"CLAUDE.md")))||(yield P(D.join(n,"AGENTS.md")))?yield t(L,D.join(n,".bricks","skills")):{changed:[],missing:[]};return{upToDate:a.changed.length+a.missing.length+r.changed.length+r.missing.length===0,cliVersion:"2.26.0-beta.0",lib:a,skills:r}})).apply(this,arguments)}function z(){return Y.apply(this,arguments)}function Y(){return(Y=v(function*(n={}){var e=process.cwd(),t=!!n.skipCopyProject,a=!!n.refreshSkills;yield O(e);var r=D.join(e,"project");(yield P(r))&&(yield(0,k.rm)(r,{recursive:!0,force:!0}),console.log("Removed legacy project/ directory")),t?console.log("Skipping copy of files to ctor/"):yield N(e),yield K(e);var i=yield P(`${e}/CLAUDE.md`),o=yield P(`${e}/AGENTS.md`);(i||o)&&(yield _(`${e}/.mcp.json`,R(e)),yield F(e,{refreshSkills:a})),i&&(yield H(e)),o&&(yield V(`${e}/.codex/config.toml`,e))})).apply(this,arguments)}},53241(n,e,t){t.r(e),t.d(e,{detectChannel:()=>s,detectInstallMethod:()=>l});var a=t(73024),r=t(76760),i=t(48161),o=n=>{if(!n)return n;try{return a.realpathSync(n)}catch{return n}},s=({version:n,execPath:e}={})=>{var t=e||process.execPath;return t&&/[\\/]bricks-beta(?:\.exe)?$/i.test(t)||/-(beta|alpha|rc|next)\b/i.test(n||"2.26.0-beta.0")?"beta":"release"},l=({execPath:n=process.execPath,scriptPath:e=process.argv[1],homeDir:t=i.homedir(),realpath:a=o}={})=>{let s;var l=(s=n)?r.basename(s).replace(/\.exe$/i,""):"";if("bricks"===l||"bricks-beta"===l)return{method:"binary",execPath:n,installDir:r.dirname(n)};var c=a(e),p=((n,e)=>{if(!n)return null;var t=r.sep,a=`${t}node_modules${t}${e.replace(/\//g,t)}${t}`,i=n.indexOf(a);return -1===i?null:n.slice(0,i)})(c,"@fugood/bricks-cli");if(p){var d=r.sep,u=r.join(t,".bun","install","global");return p===u||p.startsWith(u+d)?{method:"bun",installRoot:p}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(p)?{method:"pnpm",installRoot:p}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(p)?{method:"yarn",installRoot:p}:{method:"npm",installRoot:p.endsWith(`${d}lib`)?p.slice(0,-`${d}lib`.length):p}}return{method:"unknown",execPath:n,scriptPath:c}}}};
package/lib/2486.js CHANGED
@@ -1 +1 @@
1
- export const __rspack_esm_id=2486;export const __rspack_esm_ids=[2486];export const __webpack_modules__={421(e,r,a){a.r(r),a.d(r,{buildDoctorReport:()=>h,renderDoctorReport:()=>v});var i,o,t=a(99436),s=a(85382),n=a(31802),c=a(8479),l=a(7586),p=a(47988),u=(i=t(function*(){try{return yield Promise.all([a.e(1826),a.e(6645),a.e(4479),a.e(7648),a.e(6042),a.e(1010),a.e(7233)]).then(a.bind(a,63288)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),k=(e,r,a)=>({severity:e,code:r,message:a}),h=(o=t(function*({version:e="2.25.5",mcpCheck:r=u}={}){var a=(0,p.getCurrentProfile)(),i=(0,p.getCurrentProfileSource)(),o=(0,n.getConnectionContext)(a),t=o.tokenInfo,h=o.auth,d=o.baseUrl,v=o.activityLogBaseUrl,m=[],w={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:p.CONFIG_PATH,baseUrl:d,activityLogBaseUrl:v},auth:{available:!!h,source:h?"config":"missing",kind:h?.kind||null,workspaceId:t?.workspaceId||null,workspaceName:t?.workspaceName||null,createdAt:t?.createdAt||null,tokenPreview:h?.kind==="token"?(0,l.$l)(h.token):null},connectivity:{workspace:{ok:!1,skipped:!h,error:null}},capabilities:{zeroArgMode:(0,c.isInteractiveTerminal)()?"interactive":"help",mcp:{available:!1,error:null}},issues:m};if(h)try{var b=yield(0,s.createClient)(d,h).workspace();w.connectivity.workspace={ok:!0,skipped:!1,error:null,id:b?._id||t.workspaceId||null,name:b?.name||t.workspaceName||null},w.auth.workspaceId=b?._id||w.auth.workspaceId,w.auth.workspaceName=b?.name||w.auth.workspaceName}catch(e){w.connectivity.workspace={ok:!1,skipped:!1,error:e.message},m.push(k("error","workspace_unreachable",`Workspace query failed for ${d}: ${e.message}`))}else m.push(k("warning","auth_missing","No usable credential for the current profile."));var f=yield r();return w.capabilities.mcp={available:f.available,error:f.error||null},f.available||m.push(k("warning","mcp_unavailable",`MCP stdio server is unavailable: ${f.error||"Unknown error"}`)),w.ok=0===m.length,w}),function(){return o.apply(this,arguments)}),d=(e,r,a)=>`${e.padEnd(14)} ${r}${a?` ${a}`:""}`,v=e=>{var r=[];if(r.push("BRICKS CLI Doctor"),r.push("─".repeat(60)),r.push(d("CLI","OK",`bricks v${e.cli.version}`)),r.push(d("Profile","OK",`${e.profile.name} (${e.profile.source})`)),r.push(d("BRICKS API","OK",e.config.baseUrl)),r.push(d("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace",i=[e.auth.source,e.auth.kind,e.auth.tokenPreview].filter(Boolean).join(", ");r.push(d("Auth","OK",i?`${a} (${i})`:a))}else r.push(d("Auth","WARN","No usable credential for the current profile"));if(e.connectivity.workspace.skipped)r.push(d("Workspace","WARN","Skipped because no credential is available"));else if(e.connectivity.workspace.ok){var o=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";r.push(d("Workspace","OK",o))}else r.push(d("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?r.push(d("MCP","OK","STDIO server import is available")):r.push(d("MCP","WARN",e.capabilities.mcp.error)),r.push(d("Zero-arg mode",((e,r=!1)=>e?"OK":r?"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&&(r.push("─".repeat(60)),r.push("Issues"),e.issues.forEach(e=>{r.push(`- [${e.severity}] ${e.message}`)})),r.join("\n")}}};
1
+ export const __rspack_esm_id=2486;export const __rspack_esm_ids=[2486];export const __webpack_modules__={421(e,r,a){a.r(r),a.d(r,{buildDoctorReport:()=>h,renderDoctorReport:()=>v});var i,o,t=a(99436),s=a(85382),n=a(31802),c=a(8479),l=a(7586),p=a(47988),u=(i=t(function*(){try{return yield Promise.all([a.e(1826),a.e(6645),a.e(4479),a.e(7648),a.e(6042),a.e(1010),a.e(7233)]).then(a.bind(a,63288)),{available:!0}}catch(e){return{available:!1,error:e.message}}}),function(){return i.apply(this,arguments)}),k=(e,r,a)=>({severity:e,code:r,message:a}),h=(o=t(function*({version:e="2.26.0-beta.0",mcpCheck:r=u}={}){var a=(0,p.getCurrentProfile)(),i=(0,p.getCurrentProfileSource)(),o=(0,n.getConnectionContext)(a),t=o.tokenInfo,h=o.auth,d=o.baseUrl,v=o.activityLogBaseUrl,m=[],w={ok:!1,timestamp:new Date().toISOString(),cli:{name:"bricks",version:e},profile:{name:a,source:i},config:{path:p.CONFIG_PATH,baseUrl:d,activityLogBaseUrl:v},auth:{available:!!h,source:h?"config":"missing",kind:h?.kind||null,workspaceId:t?.workspaceId||null,workspaceName:t?.workspaceName||null,createdAt:t?.createdAt||null,tokenPreview:h?.kind==="token"?(0,l.$l)(h.token):null},connectivity:{workspace:{ok:!1,skipped:!h,error:null}},capabilities:{zeroArgMode:(0,c.isInteractiveTerminal)()?"interactive":"help",mcp:{available:!1,error:null}},issues:m};if(h)try{var b=yield(0,s.createClient)(d,h).workspace();w.connectivity.workspace={ok:!0,skipped:!1,error:null,id:b?._id||t.workspaceId||null,name:b?.name||t.workspaceName||null},w.auth.workspaceId=b?._id||w.auth.workspaceId,w.auth.workspaceName=b?.name||w.auth.workspaceName}catch(e){w.connectivity.workspace={ok:!1,skipped:!1,error:e.message},m.push(k("error","workspace_unreachable",`Workspace query failed for ${d}: ${e.message}`))}else m.push(k("warning","auth_missing","No usable credential for the current profile."));var f=yield r();return w.capabilities.mcp={available:f.available,error:f.error||null},f.available||m.push(k("warning","mcp_unavailable",`MCP stdio server is unavailable: ${f.error||"Unknown error"}`)),w.ok=0===m.length,w}),function(){return o.apply(this,arguments)}),d=(e,r,a)=>`${e.padEnd(14)} ${r}${a?` ${a}`:""}`,v=e=>{var r=[];if(r.push("BRICKS CLI Doctor"),r.push("─".repeat(60)),r.push(d("CLI","OK",`bricks v${e.cli.version}`)),r.push(d("Profile","OK",`${e.profile.name} (${e.profile.source})`)),r.push(d("BRICKS API","OK",e.config.baseUrl)),r.push(d("Activity Log","OK",e.config.activityLogBaseUrl)),e.auth.available){var a=e.auth.workspaceName||e.auth.workspaceId||"Unknown workspace",i=[e.auth.source,e.auth.kind,e.auth.tokenPreview].filter(Boolean).join(", ");r.push(d("Auth","OK",i?`${a} (${i})`:a))}else r.push(d("Auth","WARN","No usable credential for the current profile"));if(e.connectivity.workspace.skipped)r.push(d("Workspace","WARN","Skipped because no credential is available"));else if(e.connectivity.workspace.ok){var o=e.connectivity.workspace.name||e.connectivity.workspace.id||"Unknown workspace";r.push(d("Workspace","OK",o))}else r.push(d("Workspace","FAIL",e.connectivity.workspace.error));return e.capabilities.mcp.available?r.push(d("MCP","OK","STDIO server import is available")):r.push(d("MCP","WARN",e.capabilities.mcp.error)),r.push(d("Zero-arg mode",((e,r=!1)=>e?"OK":r?"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&&(r.push("─".repeat(60)),r.push("Issues"),e.issues.forEach(e=>{r.push(`- [${e.severity}] ${e.message}`)})),r.join("\n")}}};
package/lib/6818.js CHANGED
@@ -1 +1 @@
1
- export const __rspack_esm_id=6818;export const __rspack_esm_ids=[6818];export const __webpack_modules__={53241(e,t,r){r.r(t),r.d(t,{detectChannel:()=>i,detectInstallMethod:()=>o});var n=r(73024),a=r(76760),s=r(48161),l=e=>{if(!e)return e;try{return n.realpathSync(e)}catch{return e}},i=({version:e,execPath:t}={})=>{var r=t||process.execPath;return r&&/[\\/]bricks-beta(?:\.exe)?$/i.test(r)||/-(beta|alpha|rc|next)\b/i.test(e||"2.25.5")?"beta":"release"},o=({execPath:e=process.execPath,scriptPath:t=process.argv[1],homeDir:r=s.homedir(),realpath:n=l}={})=>{let i;var o=(i=e)?a.basename(i).replace(/\.exe$/i,""):"";if("bricks"===o||"bricks-beta"===o)return{method:"binary",execPath:e,installDir:a.dirname(e)};var c=n(t),p=((e,t)=>{if(!e)return null;var r=a.sep,n=`${r}node_modules${r}${t.replace(/\//g,r)}${r}`,s=e.indexOf(n);return -1===s?null:e.slice(0,s)})(c,"@fugood/bricks-cli");if(p){var d=a.sep,b=a.join(r,".bun","install","global");return p===b||p.startsWith(b+d)?{method:"bun",installRoot:p}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(p)?{method:"pnpm",installRoot:p}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(p)?{method:"yarn",installRoot:p}:{method:"npm",installRoot:p.endsWith(`${d}lib`)?p.slice(0,-`${d}lib`.length):p}}return{method:"unknown",execPath:e,scriptPath:c}}}};
1
+ export const __rspack_esm_id=6818;export const __rspack_esm_ids=[6818];export const __webpack_modules__={53241(e,t,r){r.r(t),r.d(t,{detectChannel:()=>i,detectInstallMethod:()=>o});var a=r(73024),n=r(76760),s=r(48161),l=e=>{if(!e)return e;try{return a.realpathSync(e)}catch{return e}},i=({version:e,execPath:t}={})=>{var r=t||process.execPath;return r&&/[\\/]bricks-beta(?:\.exe)?$/i.test(r)||/-(beta|alpha|rc|next)\b/i.test(e||"2.26.0-beta.0")?"beta":"release"},o=({execPath:e=process.execPath,scriptPath:t=process.argv[1],homeDir:r=s.homedir(),realpath:a=l}={})=>{let i;var o=(i=e)?n.basename(i).replace(/\.exe$/i,""):"";if("bricks"===o||"bricks-beta"===o)return{method:"binary",execPath:e,installDir:n.dirname(e)};var c=a(t),p=((e,t)=>{if(!e)return null;var r=n.sep,a=`${r}node_modules${r}${t.replace(/\//g,r)}${r}`,s=e.indexOf(a);return -1===s?null:e.slice(0,s)})(c,"@fugood/bricks-cli");if(p){var b=n.sep,d=n.join(r,".bun","install","global");return p===d||p.startsWith(d+b)?{method:"bun",installRoot:p}:/[\\/](?:\.pnpm|pnpm[\\/]global)[\\/]/.test(p)?{method:"pnpm",installRoot:p}:/[\\/](?:\.yarn|yarn[\\/]global)[\\/]/.test(p)?{method:"yarn",installRoot:p}:{method:"npm",installRoot:p.endsWith(`${b}lib`)?p.slice(0,-`${b}lib`.length):p}}return{method:"unknown",execPath:e,scriptPath:c}}}};
package/lib/7233.js CHANGED
@@ -1,4 +1,4 @@
1
- export const __rspack_esm_id=7233;export const __rspack_esm_ids=[7233];export const __webpack_modules__={63288(e,i,t){t.r(i),t.d(i,{startStdioServer:()=>t9});var n,a,o,r,s,d,c,l,p={};t.r(p),t.d(p,{applicationFragment:()=>el,applicationShortFragment:()=>ev,deviceFragment:()=>ed,deviceGroupFragment:()=>ec,deviceShortFragment:()=>eh,instanceVersionFragment:()=>e_,mediaBoxFragment:()=>eI,mediaFileFragment:()=>ek,mediaWorkspaceFragment:()=>eb,moduleFragment:()=>eu,moduleShortFragment:()=>em,operationFragment:()=>eg,publicApplicationBasicInfoFragment:()=>ep,userFavoriteFragment:()=>ef,workspaceFragment:()=>ey,workspaceShortFragment:()=>e$});var u={};t.r(u),t.d(u,{application:()=>eY,applicationByDevice:()=>eR,applicationReleaseVersion:()=>eE,applicationReleaseVersions:()=>eB,applicationTestsByDevice:()=>eO,applications:()=>eV,checkBindDevicePasscode:()=>eP,deviceUsage:()=>eG,devices:()=>eK,devicesByGroup:()=>eN,devicesByUniqueId:()=>eF,me:()=>ew,module:()=>eS,moduleReleaseVersion:()=>eM,moduleReleaseVersions:()=>eU,modules:()=>eC,publicModules:()=>eT,publicModulesByIdList:()=>ex,workspace:()=>eW,workspacePricingPlans:()=>eq,workspaces:()=>ej});var m={};t.r(m),t.d(m,{addUserFavorite:()=>iS,assignGroupPermissions:()=>ik,bindApplication:()=>it,bindApplicationWithDeviceGroup:()=>ir,changeWorkspaceAdditionalLimitSpending:()=>ix,changeWorkspaceSubscriptionPlan:()=>iT,controlDevice:()=>e6,createApplication:()=>e7,createApplicationWithShareVersion:()=>ie,createConfigChangeOperation:()=>iv,createDevice:()=>eX,createDeviceGroup:()=>e5,createDeviceGroupWithApp:()=>ic,createModule:()=>im,createVirtualDevice:()=>eQ,createWorkspace:()=>eH,createWorkspaceOTP:()=>iB,dispatchDeviceGroupAction:()=>e9,doOperation:()=>ih,duplicateApplication:()=>ip,duplicateModule:()=>iy,forkApplication:()=>il,moveApplication:()=>id,moveDevice:()=>e0,moveModule:()=>ig,registerFCMNotification:()=>iD,registerRemoteDebug:()=>iA,removeApplication:()=>iu,removeDevice:()=>e4,removeDeviceGroup:()=>e3,removeModule:()=>i$,removeOperation:()=>iI,removeUserFavorite:()=>iC,removeWorkspace:()=>e8,revokeWorkspaceOTP:()=>iE,shareAccessToken:()=>iw,shareApplication:()=>is,toggleShortEditApplication:()=>ia,updateApplication:()=>ii,updateApplicationViewportPreset:()=>io,updateDevice:()=>eZ,updateDeviceGroup:()=>e2,updateModule:()=>i_,updateOperation:()=>ib,updateVirtualDevice:()=>e1,updateWorkspace:()=>ez,updateWorkspaceTokens:()=>eJ});var _={};t.r(_),t.d(_,{application:()=>iP,applicationByDevice:()=>iF,applications:()=>iO,device:()=>ij,deviceUsage:()=>iY,devices:()=>iW,devicesByApplication:()=>iV,mediaBox:()=>iL,mediaBoxes:()=>iG,mediaFile:()=>iz,mediaFiles:()=>iH,mediaWorkspace:()=>iK,module:()=>iq,modules:()=>iN,workspace:()=>iR});var g={};t.r(g),t.d(g,{bindApplication:()=>iQ,copyMediaFiles:()=>i9,createApplication:()=>iJ,createModule:()=>i0,deleteMediaBoxFiles:()=>i8,deleteMediaFiles:()=>i3,requestFileUpload:()=>i4,setMediaFileAsBoxPreview:()=>i2,unbindApplication:()=>iZ,updateApplication:()=>iX,updateMediaFile:()=>i6,updateMediaFiles:()=>i5,updateModule:()=>i1});var f={};t.r(f),t.d(f,{mediaBox:()=>tk,mediaBoxes:()=>tb,mediaFile:()=>tA,mediaFiles:()=>tD,mediaWorkspace:()=>tI,mediaWorkspaces:()=>th});var y={};t.r(y),t.d(y,{assignGroupPermissions:()=>tP,copyMediaFiles:()=>tR,createMediaBox:()=>tC,createMediaWorkspace:()=>tw,deleteMediaFiles:()=>tM,moveMediaBox:()=>tT,requestFileUpload:()=>tB,setMediaFileAsBoxPreview:()=>tO,updateMediaBox:()=>tx,updateMediaFile:()=>tE,updateMediaFiles:()=>tU,updateMediaWorkspace:()=>tS});var $={};t.r($),t.d($,{mediaBox:()=>tN,mediaFile:()=>tW,mediaFiles:()=>tq});var v={};t.r(v),t.d(v,{deleteMediaFiles:()=>tK,requestFileUpload:()=>tj,updateMediaFile:()=>tV,updateMediaFiles:()=>tY});var h=t(99436),b=t(25326),I=t(66029),k={info:"info",manage_signature:"sign",query_application:"qa",query_device:"qd",query_device_group:"qdg",query_module:"qm",query_activity_log:"qal",create_application:"ca",create_device:"cd",create_device_group:"cdg",create_module:"cm",update_application:"ua",bind_application:"ba",short_edit_application:"uas",canvas_control_application:"uacc",update_device:"ud",update_device_group:"udg",update_module:"um",short_edit_module:"ums",remove_application:"ra",remove_device:"rd",remove_device_group:"rdg",remove_module:"rm",control_device:"ctld",control_application_device:"ctlad",control_device_group:"ctldg",query_media_flow:"qmf",write_media_flow:"wmf",access_unstable_feature:"UNSTABLE"},D=Object.entries(k).reduce((e,[i,t])=>(e[t]=i,e),{}),A=["HS256","RS256"],w=["https://auth0.bricks.tools/","https://mybigday.auth0.com/"],S=t(84867);let C='# Getting Started with BRICKS\n\nBRICKS (方塊磚) is a comprehensive platform for creating interactive multimedia display applications specifically designed for digital signage screens. It enables users to design complete applications without programming, using a visual, component-based approach.\n\n**Important**: Users interact through a visual GUI editor, not raw configuration files. Always describe features in user-friendly terms:\n- "text display" not "BRICK_TEXT"\n- "image" not "BRICK_IMAGE"\n- "canvas name" not "CANVAS_xxx"\n- "data storage" not "PROPERTY_BANK"\n- Focus on what users see and do, not technical implementation details\n\n## Core Philosophy\n\nBRICKS operates as a **Launcher system** that reads configuration files from the cloud (or cached locally) and must maintain normal operation even when offline. The system periodically reports health status and supports watchdog timers for automatic restart or maintenance mode activation.\n\n## Fundamental Architecture\n\n### The Three Core Elements\n\n#### 1. Canvas (畫布)\n- **Definition**: The visual container that defines what users see on screen\n- **Behavior**: Screen transitions occur by switching between different canvases\n- **Smart Transitions**: When switching canvases, BRICKS automatically compares shared elements and smoothly animates their position/size changes\n- **Properties**:\n - `Showing Timeout`: Auto-advance to next canvas after specified time\n - `Next Canvas ID`: Target canvas for timeout transitions\n - `Background Color`: Canvas background\n - `Dismiss Keyboard On Press`: Touch behavior for keyboard dismissal\n- **Events**: `CANVAS_FIRST_ENTER`, `CANVAS_ENTER`, `CANVAS_SHOWING_TIMEOUT`, `CANVAS_EXIT`\n\n#### 2. Brick (方塊)\n- **Definition**: Visual components that display content and handle user interactions\n- **Animation System**: All bricks support three animation phases:\n - **Enter Animation**: How the brick appears on screen\n - **Display Animation**: Ongoing animations while visible\n - **Exit Animation**: How the brick disappears\n- **Positioning**: Uses grid-based positioning system for resolution independence\n- **Interaction**: Can respond to touch events and trigger system actions\n\nAvailable template:\n[:BRICK_IDS:]\n\n#### 3. Generator (處理器)\n- **Definition**: Invisible processing units that handle non-visual functionality\n- **Purpose**: Handle hardware interactions (camera, sensors), data processing, network communication\n- **Input**: Receives parameters exclusively through Property Bank\n- **Output**: Returns results exclusively through Property Bank\n- **Triggers**: Activated by Events connected to their Actions\n\nAvailable template:\n[:GENERATOR_IDS:]\n\n### Data (Property Bank, 參數庫)\nThe central data management system that serves as the backbone of BRICKS applications:\n\n#### Key Features\n- **KEY-VALUE Structure**: Simple, accessible data storage\n- **Dual Events**: Each property supports both "Update" and "Value Change" events\n- **Auto-Refresh**: UI elements automatically update when linked data changes\n- **Cross-Subspace Communication**: Properties can be shared between different subspaces\n- **Data Types**: `string`, `number`, `bool`, `object`, `array`, `any`\n- **Special Kinds**: `color`, `datetime`, `id`, `media-resource-*`, `lottie-file-uri`\n- **Units**: `grid`, `px`, `ms` for different measurement types\n\n#### Routing Options\n- **read-only**: Cannot be changed from other subspaces\n- **Default**: Accepts changes from other subspaces\n\nTerminology note: We refer to the central data system as "Data" in docs and UI. Internally, it remains "Property Bank" and uses `PROPERTY_BANK_*` identifiers.\n\n### Event System\nBRICKS uses a comprehensive event-driven architecture:\n\n#### Event Sources\n- **System Events**: Property Bank changes, timer events, canvas transitions\n- **Brick Events**: User interactions (press, focus, value changes)\n- **Generator Events**: Hardware responses, network callbacks, processing completions\n\n#### Event Handling\n- **Sequential Processing**: Events trigger Actions in defined order\n- **Parameter Passing**: All parameters passed through Property Bank\n- **Action Types**: System actions or Generator actions\n\n### Subspace (子空間)\nAdvanced modularity system for complex applications:\n\n#### Concept\n- **Nested Systems**: Complete BRICKS system within a brick\n- **Independent Operation**: Own canvases, bricks, and property banks\n- **Modular Behavior**: Can be positioned, scaled, and animated like regular bricks\n\n#### Communication\n- **Input**: External Property Bank values copied to internal Property Bank\n- **Output**: Internal Property Bank changes trigger external events\n- **Data Flow**: Call-by-value copying maintains isolation while enabling communication\n\n## Grid System\n\n### Resolution Independence\n- **Default Grid**: 96\xd754 units (optimized for HD displays)\n- **Automatic Scaling**: Grid units convert to pixels based on device resolution\n- **Calculation**: `grid_unit_size_px = device_width_px / app_grid_width`\n\n### Examples\n| Device Resolution | App Grid Size | Grid Unit Size |\n|------------------|---------------|----------------|\n| 1920\xd71080 | 96\xd754 | 20px |\n| 3840\xd72160 | 96\xd754 | 40px |\n| 1280\xd7720 | 96\xd754 | 13.33px |\n\n### Positioning Features\n- **Overflow Support**: Elements can extend beyond visible area\n- **Partial Display**: Elements at negative positions show partial content\n- **Performance Optimization**: Completely off-screen elements are automatically ignored\n\n## Configuration Structure\n\n### Hierarchy\n```\nApplication (應用程式)\n├── Root Subspace\n├── Subspace Map\n│ ├── Canvas Map\n│ ├── Brick Map\n│ └── Generator Map\n├── Property Bank\n├── Property Bank Calc\n├── Event Map\n└── Automation Map\n```\n\n### Item property\nProperties can set constant value or link data like this\n\n```js\n{\n "example1": 123,\n "example2": "PROPERTY_BANK#<Data Node ID>", // Link Data\n "example3": {\n "PROPERTY_BANK#<Data Node ID>", // Link Data in object, we recommend direct link without middle object data\n }\n}\n```\n\n### Item outlet\nData output from brick or generator, you can link it to data\n\n```js\n{\n OUTLET_NAME: \'<Data Node ID>\'\n}\n```\n\n### Event actions\nOn handling event can do actions with this schema\n\n```js\n[\n {\n "action": "string",\n "handler": "string",\n "parameter_list": [\n {\n "input_to_receiver": "string", // Argument\n "result_from_sender": "string" // Link data\n }\n ],\n "wait_async": "boolean"\n }\n]\n```\n\n- `handler: SYSTEM`\n[:SYSTEM_ACTIONS:]\n- `handler: GENERATOR_<UUID>`\n- `handler: BRICK_<UUID>`\n\n## Development Workflow\n\n### 1. Design Phase\n- Define grid layout (usually 96\xd754)\n- Plan canvas flow and transitions\n- Identify required data flows\n\n### 2. Implementation\n- Use `create_item` to constuct config\n- Create subspaces for different app sections\n- Add canvases for each screen/state\n- Place and configure bricks for UI elements\n- Add generators for processing logic\n- Connect events to actions\n\n### 3. Data Management\n- Set up Property Bank structure\n- Configure property types and routing\n- Link UI elements to data sources\n- Implement data processing flows\n\n#### Mental Model\n- Reactive architecture: events trigger actions; actions update Data; UI and generators react to Data changes.\n- Calculations: optional graphs transform Data using Data Calculation (command/data nodes or script).\n- Always read/write via Data. Generators receive input from Data and write outputs back to Data.\n\n#### Common Patterns\n- Event → Action → Data update or Outlet → Data update\n- Data change → Triggers downstream calculations → Updates target Data\n- Cross-subspace routing: respect `read-only` vs `default`\n\n### 4. Testing & Deployment\n- Use automation maps for testing\n- Validate configuration schema\n- Deploy to target devices\n- Monitor system health\n\n## Best Practices\n\n### Performance\n- Use 96\xd754 grid for standard content\n- Minimize off-screen elements\n- Optimize property bank access patterns\n- Cache media resources appropriately\n\n### User Experience\n- Always use enter/exit animations (avoid sudden appearances)\n- Maintain consistent transition timing\n- Design for offline operation\n- Implement proper error handling\n\n### Architecture\n- Keep subspaces focused and modular\n- Use generators for all non-visual processing\n- Minimize cross-subspace dependencies\n- Design for reusability through modules\n\n## Network & Offline Behavior\n\n### Online Operation\n- Configuration sync from cloud\n- Media resource loading\n- Real-time data updates\n- Health status reporting\n\n### Offline Requirements\n- **Display Continuity**: All display and reading functions must work offline\n- **Data Caching**: Write operations cached locally and synced when online\n- **Resource Management**: Media and assets preloaded during online periods\n- **Graceful Degradation**: Non-essential features disabled, core functionality maintained\n\nThis comprehensive foundation enables the creation of sophisticated, interactive digital signage applications that are both powerful and maintainable.\n\n## Local Sync\n\nLocal Sync enables near real-time intranet communication between devices for seamless multi-screen display splicing.\n\n- Data Sync: Synchronize selected data (Property Bank/Data nodes) across devices so UI updates remain consistent.\n- Canvas Sync: Optionally synchronize active canvas to orchestrate state transitions across screens.\n- Typical Use: Video walls, tiled displays, or clustered players that must behave as one.\n- Transport: LAN/intranet only; optimized for low latency and reliability inside the local network.\n- Resilience: Designed to tolerate temporary disconnections; devices rejoin and resynchronize state.\n\nConfiguration hints (high level):\n- Subspaces can define local sync behavior (e.g., whether to sync canvas changes).\n- Generators may opt into specific local sync run modes.\n- Keep payloads small and data normalized for best performance.';var T=t(20181),x=(e,i={})=>({content:[T.Buffer.isBuffer(e)?{...i,blob:e.toString("base64"),type:"blob"}:{...i,text:"string"==typeof e?e:JSON.stringify(e,null,2),type:"text"}],isError:!1}),B=t(68832),E=t(79657),U=t(79861),M=t(46123),R=t(80211),O=t(45907),P=t(99548),F=t(96423),N=R.ajv.getSchema("http://display.bricks.tools/root.schema.json5"),q=(0,F.A)(["subspace_map.*.property_bank_calc_map.*.script_config"]),W=e=>e&&"object"==typeof e?e:{};function j(e){var i=[];try{var t=R(e);i.push(...(0,P.L)({errors:t,schema:N,data:e}).map(({path:e,message:i})=>`${e}: ${i}`));try{i.push(...O(e).map(({field:e,message:i})=>`${e}: ${i}`))}catch(e){i.push(`Component reference validation failed: ${e.message}`)}return q(e).forEach(t=>{var n=t.slice(0,-1),a=M(e,n),o=n.join("."),r=W(a?.map),s=W(a?.script_config);if(0===Object.keys(r).length)i.push(`${o}.map is empty`);else{var d=s.inputs,c=s.output,l=s.outputs,p=s.error,u=W(d),m=W(l);d&&Object.keys(u).forEach(e=>{r[e]||i.push(`${o}.map.${e} is missing`)}),c&&!r[c]&&i.push(`${o}.map.${c} is missing`),l&&Object.values(m).flat().forEach(e=>{r[e]||i.push(`${o}.map.${e} is missing`)}),p&&!r[p]&&i.push(`${o}.map.${p} is missing`)}}),{valid:0===i.length,errors:i}}catch(e){return{valid:!1,errors:[`Validation failed: ${e.message}`]}}}var V=t(49741),Y=t(63981),K=(e,i="en-us")=>"object"==typeof e&&null!==e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,"object"!=typeof t||null===t||Array.isArray(t)?t:t[i]??K(t,i)])):e,G=K(V.t),L=Object.entries(V.systemActions).map(([e,{propertyNameType:i,property:t}])=>` - \`${e}\`: ${G[e]}
1
+ export const __rspack_esm_id=7233;export const __rspack_esm_ids=[7233];export const __webpack_modules__={63288(e,i,t){t.r(i),t.d(i,{startStdioServer:()=>t9});var n,a,o,r,s,d,c,l,p={};t.r(p),t.d(p,{applicationFragment:()=>el,applicationShortFragment:()=>ev,deviceFragment:()=>ed,deviceGroupFragment:()=>ec,deviceShortFragment:()=>eh,instanceVersionFragment:()=>e_,mediaBoxFragment:()=>eI,mediaFileFragment:()=>ek,mediaWorkspaceFragment:()=>eb,moduleFragment:()=>eu,moduleShortFragment:()=>em,operationFragment:()=>eg,publicApplicationBasicInfoFragment:()=>ep,userFavoriteFragment:()=>ef,workspaceFragment:()=>ey,workspaceShortFragment:()=>e$});var u={};t.r(u),t.d(u,{application:()=>eY,applicationByDevice:()=>eR,applicationReleaseVersion:()=>eE,applicationReleaseVersions:()=>eB,applicationTestsByDevice:()=>eO,applications:()=>eV,checkBindDevicePasscode:()=>eP,deviceUsage:()=>eG,devices:()=>eK,devicesByGroup:()=>eN,devicesByUniqueId:()=>eF,me:()=>ew,module:()=>eS,moduleReleaseVersion:()=>eM,moduleReleaseVersions:()=>eU,modules:()=>eC,publicModules:()=>eT,publicModulesByIdList:()=>ex,workspace:()=>eW,workspacePricingPlans:()=>eq,workspaces:()=>ej});var m={};t.r(m),t.d(m,{addUserFavorite:()=>iS,assignGroupPermissions:()=>ik,bindApplication:()=>it,bindApplicationWithDeviceGroup:()=>ir,changeWorkspaceAdditionalLimitSpending:()=>ix,changeWorkspaceSubscriptionPlan:()=>iT,controlDevice:()=>e6,createApplication:()=>e7,createApplicationWithShareVersion:()=>ie,createConfigChangeOperation:()=>iv,createDevice:()=>eX,createDeviceGroup:()=>e2,createDeviceGroupWithApp:()=>ic,createModule:()=>im,createVirtualDevice:()=>eQ,createWorkspace:()=>eH,createWorkspaceOTP:()=>iB,dispatchDeviceGroupAction:()=>e9,doOperation:()=>ih,duplicateApplication:()=>ip,duplicateModule:()=>iy,forkApplication:()=>il,moveApplication:()=>id,moveDevice:()=>e0,moveModule:()=>ig,registerFCMNotification:()=>iD,registerRemoteDebug:()=>iA,removeApplication:()=>iu,removeDevice:()=>e4,removeDeviceGroup:()=>e3,removeModule:()=>i$,removeOperation:()=>iI,removeUserFavorite:()=>iC,removeWorkspace:()=>e8,revokeWorkspaceOTP:()=>iE,shareAccessToken:()=>iw,shareApplication:()=>is,toggleShortEditApplication:()=>ia,updateApplication:()=>ii,updateApplicationViewportPreset:()=>io,updateDevice:()=>eZ,updateDeviceGroup:()=>e5,updateModule:()=>i_,updateOperation:()=>ib,updateVirtualDevice:()=>e1,updateWorkspace:()=>ez,updateWorkspaceTokens:()=>eJ});var _={};t.r(_),t.d(_,{application:()=>iP,applicationByDevice:()=>iF,applications:()=>iO,device:()=>ij,deviceUsage:()=>iY,devices:()=>iW,devicesByApplication:()=>iV,mediaBox:()=>iL,mediaBoxes:()=>iG,mediaFile:()=>iz,mediaFiles:()=>iH,mediaWorkspace:()=>iK,module:()=>iq,modules:()=>iN,workspace:()=>iR});var g={};t.r(g),t.d(g,{bindApplication:()=>iQ,copyMediaFiles:()=>i9,createApplication:()=>iJ,createModule:()=>i0,deleteMediaBoxFiles:()=>i8,deleteMediaFiles:()=>i3,requestFileUpload:()=>i4,setMediaFileAsBoxPreview:()=>i5,unbindApplication:()=>iZ,updateApplication:()=>iX,updateMediaFile:()=>i6,updateMediaFiles:()=>i2,updateModule:()=>i1});var f={};t.r(f),t.d(f,{mediaBox:()=>tk,mediaBoxes:()=>tb,mediaFile:()=>tA,mediaFiles:()=>tD,mediaWorkspace:()=>tI,mediaWorkspaces:()=>th});var y={};t.r(y),t.d(y,{assignGroupPermissions:()=>tP,copyMediaFiles:()=>tR,createMediaBox:()=>tC,createMediaWorkspace:()=>tw,deleteMediaFiles:()=>tM,moveMediaBox:()=>tT,requestFileUpload:()=>tB,setMediaFileAsBoxPreview:()=>tO,updateMediaBox:()=>tx,updateMediaFile:()=>tE,updateMediaFiles:()=>tU,updateMediaWorkspace:()=>tS});var $={};t.r($),t.d($,{mediaBox:()=>tN,mediaFile:()=>tW,mediaFiles:()=>tq});var v={};t.r(v),t.d(v,{deleteMediaFiles:()=>tK,requestFileUpload:()=>tj,updateMediaFile:()=>tV,updateMediaFiles:()=>tY});var h=t(99436),b=t(25326),I=t(66029),k={info:"info",manage_signature:"sign",query_application:"qa",query_device:"qd",query_device_group:"qdg",query_module:"qm",query_activity_log:"qal",create_application:"ca",create_device:"cd",create_device_group:"cdg",create_module:"cm",update_application:"ua",bind_application:"ba",short_edit_application:"uas",canvas_control_application:"uacc",update_device:"ud",update_device_group:"udg",update_module:"um",short_edit_module:"ums",remove_application:"ra",remove_device:"rd",remove_device_group:"rdg",remove_module:"rm",control_device:"ctld",control_application_device:"ctlad",control_device_group:"ctldg",query_media_flow:"qmf",write_media_flow:"wmf",access_unstable_feature:"UNSTABLE"},D=Object.entries(k).reduce((e,[i,t])=>(e[t]=i,e),{}),A=["HS256","RS256"],w=["https://auth0.bricks.tools/","https://mybigday.auth0.com/"],S=t(84867);let C='# Getting Started with BRICKS\n\nBRICKS (方塊磚) is a comprehensive platform for creating interactive multimedia display applications specifically designed for digital signage screens. It enables users to design complete applications without programming, using a visual, component-based approach.\n\n**Important**: Users interact through a visual GUI editor, not raw configuration files. Always describe features in user-friendly terms:\n- "text display" not "BRICK_TEXT"\n- "image" not "BRICK_IMAGE"\n- "canvas name" not "CANVAS_xxx"\n- "data storage" not "PROPERTY_BANK"\n- Focus on what users see and do, not technical implementation details\n\n## Core Philosophy\n\nBRICKS operates as a **Launcher system** that reads configuration files from the cloud (or cached locally) and must maintain normal operation even when offline. The system periodically reports health status and supports watchdog timers for automatic restart or maintenance mode activation.\n\n## Fundamental Architecture\n\n### The Three Core Elements\n\n#### 1. Canvas (畫布)\n- **Definition**: The visual container that defines what users see on screen\n- **Behavior**: Screen transitions occur by switching between different canvases\n- **Smart Transitions**: When switching canvases, BRICKS automatically compares shared elements and smoothly animates their position/size changes\n- **Properties**:\n - `Showing Timeout`: Auto-advance to next canvas after specified time\n - `Next Canvas ID`: Target canvas for timeout transitions\n - `Background Color`: Canvas background\n - `Dismiss Keyboard On Press`: Touch behavior for keyboard dismissal\n- **Events**: `CANVAS_FIRST_ENTER`, `CANVAS_ENTER`, `CANVAS_SHOWING_TIMEOUT`, `CANVAS_EXIT`\n\n#### 2. Brick (方塊)\n- **Definition**: Visual components that display content and handle user interactions\n- **Animation System**: All bricks support three animation phases:\n - **Enter Animation**: How the brick appears on screen\n - **Display Animation**: Ongoing animations while visible\n - **Exit Animation**: How the brick disappears\n- **Positioning**: Uses grid-based positioning system for resolution independence\n- **Interaction**: Can respond to touch events and trigger system actions\n\nAvailable template:\n[:BRICK_IDS:]\n\n#### 3. Generator (處理器)\n- **Definition**: Invisible processing units that handle non-visual functionality\n- **Purpose**: Handle hardware interactions (camera, sensors), data processing, network communication\n- **Input**: Receives parameters exclusively through Property Bank\n- **Output**: Returns results exclusively through Property Bank\n- **Triggers**: Activated by Events connected to their Actions\n\nAvailable template:\n[:GENERATOR_IDS:]\n\n### Data (Property Bank, 參數庫)\nThe central data management system that serves as the backbone of BRICKS applications:\n\n#### Key Features\n- **KEY-VALUE Structure**: Simple, accessible data storage\n- **Dual Events**: Each property supports both "Update" and "Value Change" events\n- **Auto-Refresh**: UI elements automatically update when linked data changes\n- **Cross-Subspace Communication**: Properties can be shared between different subspaces\n- **Data Types**: `string`, `number`, `bool`, `object`, `array`, `any`\n- **Special Kinds**: `color`, `datetime`, `id`, `media-resource-*`, `lottie-file-uri`\n- **Units**: `grid`, `px`, `ms` for different measurement types\n\n#### Routing Options\n- **read-only**: Cannot be changed from other subspaces\n- **Default**: Accepts changes from other subspaces\n\nTerminology note: We refer to the central data system as "Data" in docs and UI. Internally, it remains "Property Bank" and uses `PROPERTY_BANK_*` identifiers.\n\n### Event System\nBRICKS uses a comprehensive event-driven architecture:\n\n#### Event Sources\n- **System Events**: Property Bank changes, timer events, canvas transitions\n- **Brick Events**: User interactions (press, focus, value changes)\n- **Generator Events**: Hardware responses, network callbacks, processing completions\n\n#### Event Handling\n- **Sequential Processing**: Events trigger Actions in defined order\n- **Parameter Passing**: All parameters passed through Property Bank\n- **Action Types**: System actions or Generator actions\n\n### Subspace (子空間)\nAdvanced modularity system for complex applications:\n\n#### Concept\n- **Nested Systems**: Complete BRICKS system within a brick\n- **Independent Operation**: Own canvases, bricks, and property banks\n- **Modular Behavior**: Can be positioned, scaled, and animated like regular bricks\n\n#### Communication\n- **Input**: External Property Bank values copied to internal Property Bank\n- **Output**: Internal Property Bank changes trigger external events\n- **Data Flow**: Call-by-value copying maintains isolation while enabling communication\n\n## Grid System\n\n### Resolution Independence\n- **Default Grid**: 96\xd754 units (optimized for HD displays)\n- **Automatic Scaling**: Grid units convert to pixels based on device resolution\n- **Calculation**: `grid_unit_size_px = device_width_px / app_grid_width`\n\n### Examples\n| Device Resolution | App Grid Size | Grid Unit Size |\n|------------------|---------------|----------------|\n| 1920\xd71080 | 96\xd754 | 20px |\n| 3840\xd72160 | 96\xd754 | 40px |\n| 1280\xd7720 | 96\xd754 | 13.33px |\n\n### Positioning Features\n- **Overflow Support**: Elements can extend beyond visible area\n- **Partial Display**: Elements at negative positions show partial content\n- **Performance Optimization**: Completely off-screen elements are automatically ignored\n\n## Configuration Structure\n\n### Hierarchy\n```\nApplication (應用程式)\n├── Root Subspace\n├── Subspace Map\n│ ├── Canvas Map\n│ ├── Brick Map\n│ └── Generator Map\n├── Property Bank\n├── Property Bank Calc\n├── Event Map\n└── Automation Map\n```\n\n### Item property\nProperties can set constant value or link data like this\n\n```js\n{\n "example1": 123,\n "example2": "PROPERTY_BANK#<Data Node ID>", // Link Data\n "example3": {\n "PROPERTY_BANK#<Data Node ID>", // Link Data in object, we recommend direct link without middle object data\n }\n}\n```\n\n### Item outlet\nData output from brick or generator, you can link it to data\n\n```js\n{\n OUTLET_NAME: \'<Data Node ID>\'\n}\n```\n\n### Event actions\nOn handling event can do actions with this schema\n\n```js\n[\n {\n "action": "string",\n "handler": "string",\n "parameter_list": [\n {\n "input_to_receiver": "string", // Argument\n "result_from_sender": "string" // Link data\n }\n ],\n "wait_async": "boolean"\n }\n]\n```\n\n- `handler: SYSTEM`\n[:SYSTEM_ACTIONS:]\n- `handler: GENERATOR_<UUID>`\n- `handler: BRICK_<UUID>`\n\n## Development Workflow\n\n### 1. Design Phase\n- Define grid layout (usually 96\xd754)\n- Plan canvas flow and transitions\n- Identify required data flows\n\n### 2. Implementation\n- Use `create_item` to constuct config\n- Create subspaces for different app sections\n- Add canvases for each screen/state\n- Place and configure bricks for UI elements\n- Add generators for processing logic\n- Connect events to actions\n\n### 3. Data Management\n- Set up Property Bank structure\n- Configure property types and routing\n- Link UI elements to data sources\n- Implement data processing flows\n\n#### Mental Model\n- Reactive architecture: events trigger actions; actions update Data; UI and generators react to Data changes.\n- Calculations: optional graphs transform Data using Data Calculation (command/data nodes or script).\n- Always read/write via Data. Generators receive input from Data and write outputs back to Data.\n\n#### Common Patterns\n- Event → Action → Data update or Outlet → Data update\n- Data change → Triggers downstream calculations → Updates target Data\n- Cross-subspace routing: respect `read-only` vs `default`\n\n### 4. Testing & Deployment\n- Use automation maps for testing\n- Validate configuration schema\n- Deploy to target devices\n- Monitor system health\n\n## Best Practices\n\n### Performance\n- Use 96\xd754 grid for standard content\n- Minimize off-screen elements\n- Optimize property bank access patterns\n- Cache media resources appropriately\n\n### User Experience\n- Always use enter/exit animations (avoid sudden appearances)\n- Maintain consistent transition timing\n- Design for offline operation\n- Implement proper error handling\n\n### Architecture\n- Keep subspaces focused and modular\n- Use generators for all non-visual processing\n- Minimize cross-subspace dependencies\n- Design for reusability through modules\n\n## Network & Offline Behavior\n\n### Online Operation\n- Configuration sync from cloud\n- Media resource loading\n- Real-time data updates\n- Health status reporting\n\n### Offline Requirements\n- **Display Continuity**: All display and reading functions must work offline\n- **Data Caching**: Write operations cached locally and synced when online\n- **Resource Management**: Media and assets preloaded during online periods\n- **Graceful Degradation**: Non-essential features disabled, core functionality maintained\n\nThis comprehensive foundation enables the creation of sophisticated, interactive digital signage applications that are both powerful and maintainable.\n\n## Local Sync\n\nLocal Sync enables near real-time intranet communication between devices for seamless multi-screen display splicing.\n\n- Data Sync: Synchronize selected data (Property Bank/Data nodes) across devices so UI updates remain consistent.\n- Canvas Sync: Optionally synchronize active canvas to orchestrate state transitions across screens.\n- Typical Use: Video walls, tiled displays, or clustered players that must behave as one.\n- Transport: LAN/intranet only; optimized for low latency and reliability inside the local network.\n- Resilience: Designed to tolerate temporary disconnections; devices rejoin and resynchronize state.\n\nConfiguration hints (high level):\n- Subspaces can define local sync behavior (e.g., whether to sync canvas changes).\n- Generators may opt into specific local sync run modes.\n- Keep payloads small and data normalized for best performance.';var T=t(20181),x=(e,i={})=>({content:[T.Buffer.isBuffer(e)?{...i,blob:e.toString("base64"),type:"blob"}:{...i,text:"string"==typeof e?e:JSON.stringify(e,null,2),type:"text"}],isError:!1}),B=t(68832),E=t(79657),U=t(79861),M=t(46123),R=t(80211),O=t(45907),P=t(99548),F=t(96423),N=R.ajv.getSchema("http://display.bricks.tools/root.schema.json5"),q=(0,F.A)(["subspace_map.*.property_bank_calc_map.*.script_config"]),W=e=>e&&"object"==typeof e?e:{};function j(e){var i=[];try{var t=R(e);i.push(...(0,P.L)({errors:t,schema:N,data:e}).map(({path:e,message:i})=>`${e}: ${i}`));try{i.push(...O(e).map(({field:e,message:i})=>`${e}: ${i}`))}catch(e){i.push(`Component reference validation failed: ${e.message}`)}return q(e).forEach(t=>{var n=t.slice(0,-1),a=M(e,n),o=n.join("."),r=W(a?.map),s=W(a?.script_config);if(0===Object.keys(r).length)i.push(`${o}.map is empty`);else{var d=s.inputs,c=s.output,l=s.outputs,p=s.error,u=W(d),m=W(l);d&&Object.keys(u).forEach(e=>{r[e]||i.push(`${o}.map.${e} is missing`)}),c&&!r[c]&&i.push(`${o}.map.${c} is missing`),l&&Object.values(m).flat().forEach(e=>{r[e]||i.push(`${o}.map.${e} is missing`)}),p&&!r[p]&&i.push(`${o}.map.${p} is missing`)}}),{valid:0===i.length,errors:i}}catch(e){return{valid:!1,errors:[`Validation failed: ${e.message}`]}}}var V=t(49741),Y=t(63981),K=(e,i="en-us")=>"object"==typeof e&&null!==e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,"object"!=typeof t||null===t||Array.isArray(t)?t:t[i]??K(t,i)])):e,G=K(V.t),L=Object.entries(V.systemActions).map(([e,{propertyNameType:i,property:t}])=>` - \`${e}\`: ${G[e]}
2
2
  ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i])=>` - \`${e}\`: ${JSON.stringify(i)}`).join("\n");case"property_bank":return" - `PROPERTY_BANK_DATA_NODE_*`: Value";default:return""}})(i,t)}
3
3
  `.trim()).join("\n"),H=Object.keys(Y.brickMapping).map(e=>`- \`${e}\``).join("\n"),z=Object.keys(Y.generatorMapping).map(e=>`- \`${e}\``).join("\n");let J=C.replace("[:SYSTEM_ACTIONS:]",L).replace("[:BRICK_IDS:]",H).replace("[:GENERATOR_IDS:]",z);var X=t(44668),Q=t(5018),Z=t(63315),ee=t(30409),ei=t(40906),et=t(79760),en=t(22268),ea=t(7068),eo=t(26197),er=t(94370);let es=(0,er.default)`
4
4
  fragment workspaceArguments on Workspace {
@@ -1191,7 +1191,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
1191
1191
  }
1192
1192
  }
1193
1193
  ${ed}
1194
- `),e5=eL((0,er.default)`
1194
+ `),e2=eL((0,er.default)`
1195
1195
  mutation ControllerClient_createDeviceGroup(
1196
1196
  $workspaceId: ID!
1197
1197
  $name: String!
@@ -1202,7 +1202,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
1202
1202
  }
1203
1203
  }
1204
1204
  ${ec}
1205
- `),e2=eL((0,er.default)`
1205
+ `),e5=eL((0,er.default)`
1206
1206
  mutation ControllerClient_updateDeviceGroup(
1207
1207
  $id: ID!
1208
1208
  $name: String
@@ -1954,7 +1954,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
1954
1954
  updatedAt
1955
1955
  }
1956
1956
  }
1957
- `,i5=(0,er.default)`
1957
+ `,i2=(0,er.default)`
1958
1958
  mutation Workspace_updateMediaFiles(
1959
1959
  $fileIds: [ID!]!
1960
1960
  $name: String
@@ -1963,7 +1963,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
1963
1963
  ) {
1964
1964
  updateMediaFiles(fileIds: $fileIds, name: $name, description: $description, userTags: $userTags)
1965
1965
  }
1966
- `,i2=(0,er.default)`
1966
+ `,i5=(0,er.default)`
1967
1967
  mutation Workspace_setMediaFileAsBoxPreview($id: ID!) {
1968
1968
  setMediaFileAsBoxPreview(id: $id)
1969
1969
  }
@@ -2472,7 +2472,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
2472
2472
  timestamp
2473
2473
  }
2474
2474
  }
2475
- `,tQ=X(function e(i,t){var n;Q(this,e),this.baseUrl=i,this.auth="string"==typeof t?{token:t,getHeaders:(n=h(function*(){return{authorization:`Bearer ${t}`}}),function(){return n.apply(this,arguments)})}:t,this.token=this.auth?.token,this.graphqlUrl=`${i}/api/graphql`},[{key:"authHeaders",value:(o=h(function*(){var e=yield this.auth.getHeaders();return{Authorization:e.authorization,...tH(e,tz)}}),function(){return o.apply(this,arguments)})},{key:"graphql",value:(r=h(function*(e,i){var t=yield(0,E.Ay)(this.graphqlUrl,{method:"POST",headers:{"Content-Type":"application/json",...yield this.authHeaders(),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 r.apply(this,arguments)})},{key:"events",value:(s=h(function*(e,{limit:i,offset:t}={}){var n={...e};return null!=i&&(n.limit=i),null!=t&&(n.offset=t),(yield this.graphql(tJ,{filter:n})).events}),function(e){return s.apply(this,arguments)})},{key:"screenshots",value:(d=h(function*(e){return(yield this.graphql(tX,{filter:e})).screenshots}),function(e){return d.apply(this,arguments)})},{key:"downloadScreenshot",value:(c=h(function*(e,i,t){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(i)}/screenshot?ts=${encodeURIComponent(t)}`,a=yield(0,E.Ay)(n,{headers:yield this.authHeaders()});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 c.apply(this,arguments)})}]);function tZ(e,i,t){switch(t){case"user":return new iM(e,i);case"workspace":return new te(e,i);default:throw Error(`Invalid token type: ${t}.`)}}process.env.STAGE,process.env.URL_BASE;var t0="bricks-mcp",t1={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 t4=t(1639);let t6=({type:e,title:i,template_key:t})=>{var n,a,o=(0,t4.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=K(Y.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,t4.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=K(Y.dK.Basic),d=K(Y.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:{}};break;case"generator":var l=K(Y.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(Y.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,t4.M4)("property_bank_command"),u=(0,t4.M4)("property_bank_command"),m=(0,t4.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 x({id:o,example:n,extraInfo:a})};var t5=(l=h(function*(e,i){var t=new AbortController,n=setTimeout(()=>t.abort(),15e3);try{var a=yield(0,E.Ay)(e,{agent:i,size:0x6400000,signal:t.signal}),o=Number(a.headers.get("content-length"));if(Number.isFinite(o)&&o>0x6400000)throw Error("source_url response exceeds the 100 MiB download limit");var r=a.headers.get("content-type")||"application/octet-stream";return{data:yield a.blob(),contentType:r}}catch(e){if(e?.name==="AbortError")throw Error("source_url download exceeded the 15s time limit");throw e}finally{clearTimeout(n)}}),function(e,i){return l.apply(this,arguments)}),t2="2.25.5";function t9(){return t3.apply(this,arguments)}function t3(){return(t3=h(function*(e={}){var i,t,n=e.baseUrl||t1.bricks,a=e.activityLogBaseUrl||t1.activityLog,o=!e.token&&!!e.getAuthHeaders,r=e.token||!e.getAuthHeaders&&process.env.BRICKS_API_TOKEN,s=null;if(!r&&e.getAuthHeaders){var d=yield e.getAuthHeaders();r=d.authorization?.replace(/^Bearer /,""),s=d["x-bricks-workspace-id"]||null}if(!r)throw console.error("Error: API token is required"),console.error(o?"OAuth sign-in did not produce credentials. Run `bricks auth login` again.":"Please provide a token via options or set BRICKS_API_TOKEN environment variable"),Error("API token is required");var c=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(!A.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=w.includes(n.iss)?"user":"workspace";if("workspace"===a){var o=Array.isArray(n.t)?n.t:[];n.permissions=o.reduce((e,i)=>{var t=D[i];return t&&e.push(t),e},[])}else n.permissions=Object.keys(k);return{success:!0,token:i,tokenInfo:n,tokenType:a}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}({queryStringParameters:{token:r}});if(!c.success){var l=o?"Invalid OAuth session credentials — run `bricks auth login` again":"Invalid BRICKS_API_TOKEN";throw console.error(`Error: ${l}`),console.error(c.message),Error(l)}var p=new b._({name:t0,version:t2});if(e.getAuthHeaders&&s){var u={token:r,getHeaders:e.getAuthHeaders};t={...c,tokenType:"workspace",tokenInfo:{...c.tokenInfo,w_id:s,permissions:Object.keys(k)},auth:u,client:tZ(n,u,"workspace")}}else t={...c,client:tZ(n,c.token,c.tokenType)};p.prompt("getting-started","Getting started with BRICKS",{},h(function*(){return{messages:[{role:"user",content:{type:"text",text:`Welcome to BRICKS — start here.
2475
+ `,tQ=X(function e(i,t){var n;Q(this,e),this.baseUrl=i,this.auth="string"==typeof t?{token:t,getHeaders:(n=h(function*(){return{authorization:`Bearer ${t}`}}),function(){return n.apply(this,arguments)})}:t,this.token=this.auth?.token,this.graphqlUrl=`${i}/api/graphql`},[{key:"authHeaders",value:(o=h(function*(){var e=yield this.auth.getHeaders();return{Authorization:e.authorization,...tH(e,tz)}}),function(){return o.apply(this,arguments)})},{key:"graphql",value:(r=h(function*(e,i){var t=yield(0,E.Ay)(this.graphqlUrl,{method:"POST",headers:{"Content-Type":"application/json",...yield this.authHeaders(),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 r.apply(this,arguments)})},{key:"events",value:(s=h(function*(e,{limit:i,offset:t}={}){var n={...e};return null!=i&&(n.limit=i),null!=t&&(n.offset=t),(yield this.graphql(tJ,{filter:n})).events}),function(e){return s.apply(this,arguments)})},{key:"screenshots",value:(d=h(function*(e){return(yield this.graphql(tX,{filter:e})).screenshots}),function(e){return d.apply(this,arguments)})},{key:"downloadScreenshot",value:(c=h(function*(e,i,t){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(i)}/screenshot?ts=${encodeURIComponent(t)}`,a=yield(0,E.Ay)(n,{headers:yield this.authHeaders()});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 c.apply(this,arguments)})}]);function tZ(e,i,t){switch(t){case"user":return new iM(e,i);case"workspace":return new te(e,i);default:throw Error(`Invalid token type: ${t}.`)}}process.env.STAGE,process.env.URL_BASE;var t0="bricks-mcp",t1={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 t4=t(1639);let t6=({type:e,title:i,template_key:t})=>{var n,a,o=(0,t4.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=K(Y.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,t4.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=K(Y.dK.Basic),d=K(Y.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:{}};break;case"generator":var l=K(Y.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(Y.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,t4.M4)("property_bank_command"),u=(0,t4.M4)("property_bank_command"),m=(0,t4.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 x({id:o,example:n,extraInfo:a})};var t2=(l=h(function*(e,i){var t=new AbortController,n=setTimeout(()=>t.abort(),15e3);try{var a=yield(0,E.Ay)(e,{agent:i,size:0x6400000,signal:t.signal}),o=Number(a.headers.get("content-length"));if(Number.isFinite(o)&&o>0x6400000)throw Error("source_url response exceeds the 100 MiB download limit");var r=a.headers.get("content-type")||"application/octet-stream";return{data:yield a.blob(),contentType:r}}catch(e){if(e?.name==="AbortError")throw Error("source_url download exceeded the 15s time limit");throw e}finally{clearTimeout(n)}}),function(e,i){return l.apply(this,arguments)}),t5="2.26.0-beta.0";function t9(){return t3.apply(this,arguments)}function t3(){return(t3=h(function*(e={}){var i,t,n=e.baseUrl||t1.bricks,a=e.activityLogBaseUrl||t1.activityLog,o=!e.token&&!!e.getAuthHeaders,r=e.token||!e.getAuthHeaders&&process.env.BRICKS_API_TOKEN,s=null;if(!r&&e.getAuthHeaders){var d=yield e.getAuthHeaders();r=d.authorization?.replace(/^Bearer /,""),s=d["x-bricks-workspace-id"]||null}if(!r)throw console.error("Error: API token is required"),console.error(o?"OAuth sign-in did not produce credentials. Run `bricks auth login` again.":"Please provide a token via options or set BRICKS_API_TOKEN environment variable"),Error("API token is required");var c=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(!A.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=w.includes(n.iss)?"user":"workspace";if("workspace"===a){var o=Array.isArray(n.t)?n.t:[];n.permissions=o.reduce((e,i)=>{var t=D[i];return t&&e.push(t),e},[])}else n.permissions=Object.keys(k);return{success:!0,token:i,tokenInfo:n,tokenType:a}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}({queryStringParameters:{token:r}});if(!c.success){var l=o?"Invalid OAuth session credentials — run `bricks auth login` again":"Invalid BRICKS_API_TOKEN";throw console.error(`Error: ${l}`),console.error(c.message),Error(l)}var p=new b._({name:t0,version:t5});if(e.getAuthHeaders&&s){var u={token:r,getHeaders:e.getAuthHeaders};t={...c,tokenType:"workspace",tokenInfo:{...c.tokenInfo,w_id:s,permissions:Object.keys(k)},auth:u,client:tZ(n,u,"workspace")}}else t={...c,client:tZ(n,c.token,c.tokenType)};p.prompt("getting-started","Getting started with BRICKS",{},h(function*(){return{messages:[{role:"user",content:{type:"text",text:`Welcome to BRICKS — start here.
2476
2476
 
2477
2477
  Before doing any complex work (application design, deployments, etc.),
2478
2478
  always consult the official docs rather than guessing.
@@ -2543,4 +2543,4 @@ What I'll produce first:
2543
2543
  - Short recap of requirements
2544
2544
  - Clarifying questions (only what's necessary)
2545
2545
  - High-level architecture plan
2546
- - Minimal config skeleton that validates against the schema`}}]}}),function(e){return i.apply(this,arguments)})),p.resource("getting-started-docs","file://docs/getting-started.md",{mimeType:"text/markdown",title:"Getting Started with BRICKS",description:"Comprehensive guide to BRICKS architecture, concepts, and development workflow"},h(function*(){return x(C,{uri:"file://docs/getting-started.md",mimeType:"text/markdown"})})),function(e,i,{activityLogBaseUrl:t=t1.activityLog}={}){var n,a="user"===i.tokenType,o=((e,i=null)=>({name:t,description:n,inputSchema:a,permission:o},r)=>{(!o||i.tokenInfo.permissions?.includes(o)||0)&&e.tool(t,n,a,r)})(e,i),r=e=>({...e,...a?{workspace_id:S.Yj().describe("Workspace ID")}:{}}),s=i.client,d=a?function(e){var i=e.endpoint,t=e.accessToken;if(!i)throw Error("Media API endpoint is required");if(!t)throw Error("Access token is required");return((e={})=>{let i=(({endpoint:e="http://localhost:3002",accessToken:i,boxId:t,passcode:n,enableSubscription:a=!0,enableRetry:o=!0,subscriptionOnConnectionOrError:r,onNetworkError:s}={})=>{let d,c,l,p=t&&n,u=`${e}/api/graphql`;return p&&(u=`${e}/api/graphql_with_passcode`),d=function({endpointURL:e,subscriptionEndpointURL:i,accessToken:t,boxId:n,passcode:a,origin:o,enableSubscription:r,enableRetry:s=!0,subscriptionOnConnectionOrError:d,onNetworkError:c=()=>{}}){let l,p,u,m,_={};o&&(_.origin=o),n&&a||(_.authorization=`Bearer ${t}`);let g=new td.z({uri:e,headers:_}),f=()=>{m&&(clearTimeout(m),m=void 0)};r&&(l=(0,tl.UU)({url:i,lazy:!0,connectionParams:_,retryAttempts:1/0,shouldRetry:()=>!0,keepAlive:1e4,on:{error:e=>{f(),d?.(e)},opened:e=>{d?.(),u=e,f()},ping:e=>{e||(f(),m=setTimeout(()=>{u&&u.readyState===WebSocket.OPEN&&u.close(4205,"Client Restart")},5e3))},pong:e=>{e&&f()},closed:()=>{f()}}}),p=new tc.c(l));let y=to.C.from([(0,tp.S)(({networkError:e,operation:i})=>{if(e){let t;c(e,i);let n=e?.message||"";if("Aborted"===(t=e?.message)||e?.name==="AbortError"||"Timeout exceeded"===t||e?.timeout||e?.statusCode===403||e?.status===403||n.includes("Too many requests")||e?.response?.status===429||e?.statusCode===429||e?.status===429)return new tr.c(e=>e.complete())}}),s&&new ts.z({attempts:{max:3,retryIf:e=>(function(e,{nonRetryableResponseStatusCodes:i=tn,nonRetryableStatusCodes:t=ta}={}){if(!e)return!1;let n="string"==typeof e?.message?e.message:"string"==typeof e?e:"";return!(n.includes("Too many requests")||i.includes(e?.response?.status)||t.includes(e?.statusCode)||t.includes(e?.status)||e?.timeout||"Timeout exceeded"===n)&&"Aborted"!==n&&e?.name!=="AbortError"})(e,{nonRetryableStatusCodes:tg})}}),new(tm())(3e4),r?to.C.split(({query:e})=>{let{kind:i,operation:t}=(0,t_.Vn)(e);return"OperationDefinition"===i&&"subscription"===t},p,g):g].filter(Boolean));return y.closeSubscriptionClient=()=>r&&l.dispose(),y}({endpointURL:u,subscriptionEndpointURL:u.replace(/^http/,"ws"),accessToken:i,enableSubscription:!p&&a,enableRetry:o,subscriptionOnConnectionOrError:r,onNetworkError:s}),c=new ea.D,(l=new en.R({link:d,cache:c,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"ignore"},query:{fetchPolicy:"no-cache",errorPolicy:"all"}}})).close=()=>d.closeSubscriptionClient(),l})(e);if(e.boxId&&e.passcode){i.type="passcode",i.queries=$,i.mutations=v;let t={boxId:e.boxId,passcode:e.passcode};Object.entries($).forEach(tt(i,"query",t)),Object.entries(v).forEach(tt(i,"mutation",t)),i.listenBoxChanged=(e,n)=>i.subscribe({query:tG,variables:{...t,...e}}).subscribe({next:tL(n),error(e){n(e)}})}else i.accessToken=e.accessToken,i.type="token",i.queries=f,i.mutations=y,Object.entries(f).forEach(tt(i,"query")),Object.entries(y).forEach(tt(i,"mutation")),i.listenBoxChanged=(e,t)=>i.subscribe({query:tF,variables:e}).subscribe({next:tL(t),error(e){t(e)}});return i})({endpoint:i,accessToken:t,enableSubscription:!1,enableRetry:!0})}({endpoint:t1.media,accessToken:i.token}):s,c=e=>a?{fileId:e}:{id:e},l=e=>a?{list:e}:{fileIds:e};if(a&&e.tool("list_workspaces","List all workspaces",{},h(function*(){return x((yield s.workspaces()))})),o({name:"get_workspace_overview",description:"Get comprehensive overview of the BRICKS workspace including stats and summary",inputSchema:r({}),permission:"info"},(p=h(function*({workspace_id:e}){var i=B((yield Promise.all([s.workspace({id:e}),s.applications({workspaceId:e,paginate:{limit:50,offset:0}}),s.modules({workspaceId:e,paginate:{limit:50,offset:0}}),s.devices({workspaceId:e,paginate:{limit:50,offset:0}}),a?d.mediaWorkspace({workspaceId:e}).catch(()=>null):d.mediaWorkspace().catch(()=>null),a?d.mediaBoxes({workspaceId:e}).catch(()=>[]):d.mediaBoxes().catch(()=>[])])),6),t=i[0],n=i[1],o=i[2],r=i[3],c=i[4],l=i[5];if(!t)throw Error("Authentication failed, please check your token");return x({workspace:t,stats:{applications:n?.length??"No permission",modules:o?.length??"No permission",devices:r?.length??"No permission",running_apps:n?.filter(e=>e.status?.running).length??"No permission",media_boxes:l?.length??"No permission",media_enabled:!!c,notes:"Note: The stats are based on the first 50 applications, modules, and devices in the workspace."},recent_activity:{latest_apps:n?.slice(0,5).map(e=>({id:e._id,name:e.name,status:e.status?.running?"running":"stopped",last_update:e.last_modify_datetime}))||[]},media_info:c?{workspace_id:c.id,name:c.name,size_used:c.size,size_limit:c.sizeLimit,boxes:l?.slice(0,5).map(e=>({id:e.id,name:e.name,size:e.size,description:e.description}))||[]}:{enabled:!1,note:"Media workspace is not enabled for this workspace"}})}),function(e){return p.apply(this,arguments)})),o({name:"get_applications",description:"List all applications in the workspace",inputSchema:r({limit:S.ai().describe("Maximum number of applications to return").optional().default(50),offset:S.ai().describe("Number of applications to skip").optional().default(0)}),permission:"query_application"},(u=h(function*({workspace_id:e,limit:i=50,offset:t=0}){return x((yield s.applications({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return u.apply(this,arguments)})),o({name:"get_application",description:"Get detailed info and config of a specific application",inputSchema:r({id:S.Yj().describe("Application ID")}),permission:"query_application"},(m=h(function*({workspace_id:e,id:i}){return x((yield s.application({workspaceId:e,id:i})))}),function(e){return m.apply(this,arguments)})),o({name:"get_modules",description:"List all modules in the workspace",inputSchema:r({limit:S.ai().describe("Maximum number of modules to return").optional().default(50),offset:S.ai().describe("Number of modules to skip").optional().default(0)}),permission:"query_module"},(_=h(function*({workspace_id:e,limit:i=50,offset:t=0}){return x((yield s.modules({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return _.apply(this,arguments)})),o({name:"get_module",description:"Get detailed info and config of a specific module",inputSchema:r({id:S.Yj().describe("Module ID")}),permission:"query_module"},(g=h(function*({workspace_id:e,id:i}){return x((yield s.module({workspaceId:e,id:i})))}),function(e){return g.apply(this,arguments)})),o({name:"update_module_info",description:"Update a specific module info",inputSchema:r({id:S.Yj().describe("Module ID"),name:S.Yj().describe("Module name"),description:S.Yj().describe("Module description")}),permission:"update_module"},(b=h(function*({workspace_id:e,id:i,name:t,description:n}){return x((yield s.updateModule({workspaceId:e,id:i,name:t,description:n})))}),function(e){return b.apply(this,arguments)})),o({name:"update_module_config",description:"Update a specific module configuration",inputSchema:r({id:S.Yj().describe("Module ID"),config:S.Ik({}).passthrough().describe("New configuration object, see file://docs/config-schema.md for schema reference")}),permission:"update_module"},(I=h(function*({workspace_id:e,id:i,config:t}){var n=yield j(t);if(!n.valid)throw Error(`Config validation failed: ${n.errors.join(", ")}`);return x((yield s.updateModule({workspaceId:e,id:i,config:JSON.stringify(t),validateConfig:!0})))}),function(e){return I.apply(this,arguments)})),o({name:"get_devices",description:"List all devices in the workspace",inputSchema:r({limit:S.ai().describe("Maximum number of devices to return").optional().default(50),offset:S.ai().describe("Number of devices to skip").optional().default(0)}),permission:"query_device"},(k=h(function*({workspace_id:e,limit:i=50,offset:t=0}){return x((yield s.devices({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return k.apply(this,arguments)})),o({name:"create_application",description:"Create a new BRICKS application with default grid layout",inputSchema:r({name:S.Yj().describe("Application name"),description:S.Yj().describe("Application description").optional(),grid_width:S.ai().describe("Grid width in units").optional().default(96),grid_height:S.ai().describe("Grid height in units").optional().default(54)}),permission:"create_application"},(D=h(function*({workspace_id:e,name:i,description:t,grid_width:n,grid_height:a}){return x((yield s.createApplication({workspaceId:e,name:i,description:t,gridWidth:n,gridHeight:a})))}),function(e){return D.apply(this,arguments)})),o({name:"update_application_info",description:"Update application info",inputSchema:{id:S.Yj().describe("Application ID"),name:S.Yj().describe("Application name"),description:S.Yj().describe("Application description")},permission:"update_application"},(A=h(function*({id:e,name:i,description:t}){return x((yield s.updateApplication({id:e,name:i,description:t})))}),function(e){return A.apply(this,arguments)})),o({name:"update_application_config",description:"Update application configuration with validation",inputSchema:{id:S.Yj().describe("Application ID"),config:S.Ik({}).passthrough().describe("New application configuration. Please read `getting-started` for BRICKS concepts before changing")},permission:"update_application"},(w=h(function*({id:e,config:i}){var t=yield j(i);if(!t.valid)throw Error(`Config validation failed: ${t.errors.join(", ")}`);return x((yield s.updateApplication({id:e,config:JSON.stringify(i)})))}),function(e){return w.apply(this,arguments)})),o({name:"bind_application",description:"Bind application to device with viewport configuration",inputSchema:{app_id:S.Yj().describe("Application ID"),viewports:S.YO(S.Ik({device_id:S.Yj().describe("Device ID"),x:S.ai().describe("X coordinate"),y:S.ai().describe("Y coordinate"),width:S.ai().describe("Width"),height:S.ai().describe("Height"),rotate:S.ai().describe("Rotation"),rotateType:S.Yj().describe("Rotation type")})).describe("Viewport configuration")},permission:"bind_application"},(C=h(function*({app_id:e,viewports:i}){return x((yield s.bindApplication({id:e,bindDevices:i.map(e=>e.device_id),deviceFrames:i.reduce((e,i)=>({...e,[i.device_id]:{x:i.x,y:i.y,width:i.width,height:i.height,rotate:i.rotate,rotateType:i.rotateType}}),{})})))}),function(e){return C.apply(this,arguments)})),o({name:"unbind_application",description:"Unbind application from device",inputSchema:{app_id:S.Yj().describe("Application ID"),device_id:S.Yj().describe("Device ID")},permission:"bind_application"},(M=h(function*({app_id:e,device_id:i}){return x((yield s.bindApplication({id:e,unbindDevices:[i]})))}),function(e){return M.apply(this,arguments)})),a&&o({name:"list_media_workspaces",description:"List all media workspaces",inputSchema:{},permission:"query_media_flow"},h(function*(){return x((yield d.mediaWorkspaces()))})),o({name:"get_media_workspace",description:"Get media workspace information and status",inputSchema:r({}),permission:"query_media_flow"},(R=h(function*({workspace_id:e}){return x((yield d.mediaWorkspace({workspaceId:e})))}),function(e){return R.apply(this,arguments)})),o({name:"list_media_boxes",description:"List all media boxes in the workspace",inputSchema:r({}),permission:"query_media_flow"},(O=h(function*({workspace_id:e}){return x((yield d.mediaBoxes({workspaceId:e})))}),function(e){return O.apply(this,arguments)})),o({name:"get_media_box",description:"Get detailed information about a specific media box",inputSchema:{box_id:S.Yj().describe("Media box ID")},permission:"query_media_flow"},(P=h(function*({box_id:e}){return x((yield d.mediaBox({boxId:e})))}),function(e){return P.apply(this,arguments)})),o({name:"list_media_files",description:"List media files in a specific box with filtering options",inputSchema:{box_id:S.Yj().describe("Media box ID"),include_types:S.YO(S.Yj()).optional().describe('Filter by file types (e.g., ["image", "video", "audio"])'),user_tags:S.YO(S.Yj()).optional().describe("Filter by user tags"),limit:S.ai().optional().default(50).describe("Maximum number of files to return"),offset:S.ai().optional().default(0).describe("Number of files to skip")},permission:"query_media_flow"},(F=h(function*({box_id:e,include_types:i,user_tags:t,limit:n,offset:a}){return x((yield d.mediaFiles({boxId:e,includeTypes:i,userTags:t,limit:n,offset:a})))}),function(e){return F.apply(this,arguments)})),o({name:"get_media_file_meta",description:"Get detailed information about a specific media file",inputSchema:{file_id:S.Yj().describe("Media file ID")},permission:"query_media_flow"},(N=h(function*({file_id:e}){return x((yield d.mediaFile(c(e))))}),function(e){return N.apply(this,arguments)})),o({name:"media_box_upload",description:"Upload a file to a media box from URL or base64 data",inputSchema:{box_id:S.Yj().describe("Target media box ID"),name:S.Yj().describe("File name"),description:S.Yj().optional().default("").describe("File description"),file_type:S.k5(["image","video","audio","file"]).describe("File type"),source_url:S.Yj().optional().describe("URL to download the file from (maximum 100 MiB)"),base64_data:S.Yj().optional().describe("Base64 encoded file data"),user_tags:S.YO(S.Yj()).optional().default([]).describe("User-defined tags for the file")},permission:"write_media_flow"},(q=h(function*({box_id:e,name:i,description:t,source_url:n,base64_data:o,file_type:r,user_tags:s}){if(!n&&!o)throw Error("Either source_url or base64_data must be provided");if(n&&o)throw Error("Provide either source_url OR base64_data, not both");var c,l="application/octet-stream";if(n){var p=yield t5(n,(0,U.fJ)(n));c=p.data,l=p.contentType}else c=new Blob([T.Buffer.from(o,"base64")],{type:l});var u=yield d.requestFileUpload({name:i,description:t,boxId:e,fileType:a?r.toUpperCase():r,contentType:l,userTags:s,meta:{}}),m=!1;try{var _=JSON.parse(u?.meta.uploadInfo),g=new FormData;g.append("file",c),g.append("Content-Type",l),g.append("AWSAccessKeyId",_.AWSAccessKeyId),g.append("Signature",_.Signature),g.append("Policy",_.Policy),g.append("acl",_.acl),g.append("key",_.key),m=yield(0,E.Ay)(_.url,{method:"POST",body:g}).then(e=>e.ok).catch(()=>!1)}catch{m=!1}return x({file_id:u.id,upload_success:m,upload_info:{content_type:l,file_type:r,source_type:n?"url":"base64",processing_note:"File will be processed automatically. Use get_media_file to check processing status."}})}),function(e){return q.apply(this,arguments)})),o({name:"update_media_file_meta",description:"Update media file information",inputSchema:{file_id:S.Yj().describe("Media file ID"),name:S.Yj().optional().describe("New file name"),description:S.Yj().optional().describe("New file description"),user_tags:S.YO(S.Yj()).optional().describe("New user tags")},permission:"write_media_flow"},(W=h(function*({file_id:e,name:i,description:t,user_tags:n}){return x((yield d.updateMediaFile({...c(e),name:i,description:t,userTags:n,requestUploadAgain:!1})))}),function(e){return W.apply(this,arguments)})),o({name:"copy_media_files",description:"Copy media files from one box to another",inputSchema:{from_box_id:S.Yj().describe("Source media box ID"),to_box_id:S.Yj().describe("Target media box ID"),file_ids:S.YO(S.Yj()).describe("Array of media file IDs to copy")},permission:"write_media_flow"},(V=h(function*({from_box_id:e,to_box_id:i,file_ids:t}){return x((yield d.copyMediaFiles({fromBoxId:e,toBoxId:i,...l(t)})))}),function(e){return V.apply(this,arguments)})),o({name:"delete_media_files",description:"Delete specific media files from a box",inputSchema:{box_id:S.Yj().describe("Media box ID"),file_ids:S.YO(S.Yj()).describe("Array of media file IDs to delete")},permission:"write_media_flow"},(Y=h(function*({box_id:e,file_ids:i}){return x((yield d.deleteMediaFiles({boxId:e,...l(i)})))}),function(e){return Y.apply(this,arguments)})),o({name:"cleanup_media_box",description:"Delete all files in a media box, optionally filtered by type",inputSchema:{box_id:S.Yj().describe("Media box ID"),include_types:S.YO(S.Yj()).optional().describe('Only delete files of these types (e.g., ["image", "video"])')},permission:"write_media_flow"},(K=h(function*({box_id:e,include_types:i}){if("deleteMediaBoxFiles"in d)return x((yield d.deleteMediaBoxFiles({boxId:e,includeTypes:i})));var t=yield d.mediaFiles({boxId:e,includeTypes:i});return x((yield d.deleteMediaFiles({boxId:e,list:t.map(e=>e.id)})))}),function(e){return K.apply(this,arguments)})),e.tool("calculate_grid_layout","Calculate grid layout and pixel conversions for different device resolutions",{device_width:S.ai().describe("Device width in pixels"),device_height:S.ai().describe("Device height in pixels"),app_grid_width:S.ai().describe("Application grid width").optional().default(96),app_grid_height:S.ai().describe("Application grid height").optional().default(54)},(G=h(function*({device_width:e,device_height:i,app_grid_width:t,app_grid_height:n}){var a,o=(a=e/t,{deviceBrickWidth:e/a,deviceBrickHeight:i/a,deviceBrickUnit:a}),r=function(e,i,t=96){var n=e/t;return i>e&&(n=i/t),{deviceBrickWidth:Math.round(e/n),deviceBrickHeight:Math.round(i/n),deviceBrickUnit:n}}(e,i,t);return x({device_resolution:{width:e,height:i,aspect_ratio:(e/i).toFixed(2)},current_grid:{width:t,height:n,unit_size_px:o.deviceBrickUnit.toFixed(2),total_pixels:{width:o.deviceBrickWidth.toFixed(2),height:o.deviceBrickHeight.toFixed(2)}},recommended_grid:{width:r.deviceBrickWidth,height:r.deviceBrickHeight,unit_size_px:r.deviceBrickUnit.toFixed(2),note:"Optimized for device aspect ratio"}})}),function(e){return G.apply(this,arguments)})),e.tool("create_item","Use this tool to create new item that you can put in application configuration",{type:S.k5(["subspace","canvas","brick","generator","property_bank","property_bank_calc","property_bank_command","animation","state_group","automation_map"]).describe("Item type"),title:S.Yj().describe("Item title"),template_key:S.Yj().optional().describe("Template key for brick or generator")},t6),e.tool("getting_started","Get documentation content for getting started",{},h(function*(){return x(J)})),!a){var p,u,m,_,g,b,I,k,D,A,w,C,M,R,O,P,F,N,q,W,V,Y,K,G,L,H,z,X=()=>new tQ(t,i.auth||i.token);o({name:"activity_log_events",description:"Query activity log events. Returns raw events (general, data, local_sync) with filtering. Max 30-day range.",inputSchema:r({start_time:S.Yj().describe("Start time (ISO 8601)"),end_time:S.Yj().describe("End time (ISO 8601)"),device_id:S.Yj().optional().describe("Filter by device ID"),event_type:S.k5(["general","data","local_sync"]).optional().describe("Filter by event type"),event_name:S.Yj().optional().describe("Filter by event name (e.g. BRICK_xxx_ON_PRESS)"),subspace_id:S.Yj().optional().describe("Filter by subspace ID"),sender:S.Yj().optional().describe("Filter by sender"),limit:S.ai().optional().default(50).describe("Max events to return per page"),offset:S.ai().optional().default(0).describe("Number of events to skip (for pagination)")}),permission:"query_activity_log"},(L=h(function*({start_time:e,end_time:i,device_id:t,event_type:n,event_name:a,subspace_id:o,sender:r,limit:s=50,offset:d=0}){var c=X(),l={start_time:e,end_time:i};return t&&(l.device_id=t),n&&(l.event_type=n),a&&(l.event_name=a),o&&(l.subspace_id=o),r&&(l.sender=r),x((yield c.events(l,{limit:s,offset:d})))}),function(e){return L.apply(this,arguments)})),o({name:"activity_log_screenshots",description:"List available screenshot timestamps for a device in a time range.",inputSchema:r({device_id:S.Yj().describe("Device ID (required)"),start_time:S.Yj().describe("Start time (ISO 8601)"),end_time:S.Yj().describe("End time (ISO 8601)")}),permission:"query_activity_log"},(H=h(function*({device_id:e,start_time:i,end_time:t}){var n=X();return x((yield n.screenshots({device_id:e,start_time:i,end_time:t})))}),function(e){return H.apply(this,arguments)})),o({name:"activity_log_screenshot",description:"Download a device screenshot at a specific timestamp. Returns JPEG image as blob.",inputSchema:r({device_id:S.Yj().describe("Device ID"),ts:S.Yj().describe("Screenshot timestamp (ISO 8601 or epoch ms)")}),permission:"query_activity_log"},(z=h(function*({workspace_id:e,device_id:t,ts:n}){var a=e||i.tokenInfo?.w_id;if(!a)throw Error("Could not determine workspace ID");var o=X(),r=/^\d+$/.test(n)?n:new Date(n).getTime();return x((yield o.downloadScreenshot(a,t,r)),{mimeType:"image/jpeg"})}),function(e){return z.apply(this,arguments)}))}o({name:"get_device_usage",description:"Get device usage metrics (uptime, memory, disk) for a date range. Data from BRICKS main server.",inputSchema:r({device_id:S.Yj().describe("Device ID"),start_date:S.Yj().optional().describe("Start date/time in ISO 8601 format (default: start of today)"),end_date:S.Yj().optional().describe("End date/time in ISO 8601 format (default: now)")}),permission:"query_device"},(n=h(function*({device_id:e,start_date:i,end_date:t}){var n=new Date,a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).toISOString();return x((yield s.deviceUsage({deviceId:e,startDate:i?new Date(i).toISOString():a,endDate:t?new Date(t).toISOString():n.toISOString()})))}),function(e){return n.apply(this,arguments)}))}(p,t,{activityLogBaseUrl:a});var m=new I.S;try{yield p.connect(m),console.error("BRICKS MCP Server running on STDIO"),console.error(`Server: ${t0} v${t2}`),console.error(`Token Type: ${t.tokenType}${s?" (oauth)":""}`),console.error(`Permissions: ${t.tokenInfo.permissions.join(", ")}`),console.error("Ready to accept requests...")}catch(e){throw console.error("Failed to start MCP server:",e),e}})).apply(this,arguments)}}};
2546
+ - Minimal config skeleton that validates against the schema`}}]}}),function(e){return i.apply(this,arguments)})),p.resource("getting-started-docs","file://docs/getting-started.md",{mimeType:"text/markdown",title:"Getting Started with BRICKS",description:"Comprehensive guide to BRICKS architecture, concepts, and development workflow"},h(function*(){return x(C,{uri:"file://docs/getting-started.md",mimeType:"text/markdown"})})),function(e,i,{activityLogBaseUrl:t=t1.activityLog}={}){var n,a="user"===i.tokenType,o=((e,i=null)=>({name:t,description:n,inputSchema:a,permission:o},r)=>{(!o||i.tokenInfo.permissions?.includes(o)||0)&&e.tool(t,n,a,r)})(e,i),r=e=>({...e,...a?{workspace_id:S.Yj().describe("Workspace ID")}:{}}),s=i.client,d=a?function(e){var i=e.endpoint,t=e.accessToken;if(!i)throw Error("Media API endpoint is required");if(!t)throw Error("Access token is required");return((e={})=>{let i=(({endpoint:e="http://localhost:3002",accessToken:i,boxId:t,passcode:n,enableSubscription:a=!0,enableRetry:o=!0,subscriptionOnConnectionOrError:r,onNetworkError:s}={})=>{let d,c,l,p=t&&n,u=`${e}/api/graphql`;return p&&(u=`${e}/api/graphql_with_passcode`),d=function({endpointURL:e,subscriptionEndpointURL:i,accessToken:t,boxId:n,passcode:a,origin:o,enableSubscription:r,enableRetry:s=!0,subscriptionOnConnectionOrError:d,onNetworkError:c=()=>{}}){let l,p,u,m,_={};o&&(_.origin=o),n&&a||(_.authorization=`Bearer ${t}`);let g=new td.z({uri:e,headers:_}),f=()=>{m&&(clearTimeout(m),m=void 0)};r&&(l=(0,tl.UU)({url:i,lazy:!0,connectionParams:_,retryAttempts:1/0,shouldRetry:()=>!0,keepAlive:1e4,on:{error:e=>{f(),d?.(e)},opened:e=>{d?.(),u=e,f()},ping:e=>{e||(f(),m=setTimeout(()=>{u&&u.readyState===WebSocket.OPEN&&u.close(4205,"Client Restart")},5e3))},pong:e=>{e&&f()},closed:()=>{f()}}}),p=new tc.c(l));let y=to.C.from([(0,tp.S)(({networkError:e,operation:i})=>{if(e){let t;c(e,i);let n=e?.message||"";if("Aborted"===(t=e?.message)||e?.name==="AbortError"||"Timeout exceeded"===t||e?.timeout||e?.statusCode===403||e?.status===403||n.includes("Too many requests")||e?.response?.status===429||e?.statusCode===429||e?.status===429)return new tr.c(e=>e.complete())}}),s&&new ts.z({attempts:{max:3,retryIf:e=>(function(e,{nonRetryableResponseStatusCodes:i=tn,nonRetryableStatusCodes:t=ta}={}){if(!e)return!1;let n="string"==typeof e?.message?e.message:"string"==typeof e?e:"";return!(n.includes("Too many requests")||i.includes(e?.response?.status)||t.includes(e?.statusCode)||t.includes(e?.status)||e?.timeout||"Timeout exceeded"===n)&&"Aborted"!==n&&e?.name!=="AbortError"})(e,{nonRetryableStatusCodes:tg})}}),new(tm())(3e4),r?to.C.split(({query:e})=>{let{kind:i,operation:t}=(0,t_.Vn)(e);return"OperationDefinition"===i&&"subscription"===t},p,g):g].filter(Boolean));return y.closeSubscriptionClient=()=>r&&l.dispose(),y}({endpointURL:u,subscriptionEndpointURL:u.replace(/^http/,"ws"),accessToken:i,enableSubscription:!p&&a,enableRetry:o,subscriptionOnConnectionOrError:r,onNetworkError:s}),c=new ea.D,(l=new en.R({link:d,cache:c,defaultOptions:{watchQuery:{fetchPolicy:"no-cache",errorPolicy:"ignore"},query:{fetchPolicy:"no-cache",errorPolicy:"all"}}})).close=()=>d.closeSubscriptionClient(),l})(e);if(e.boxId&&e.passcode){i.type="passcode",i.queries=$,i.mutations=v;let t={boxId:e.boxId,passcode:e.passcode};Object.entries($).forEach(tt(i,"query",t)),Object.entries(v).forEach(tt(i,"mutation",t)),i.listenBoxChanged=(e,n)=>i.subscribe({query:tG,variables:{...t,...e}}).subscribe({next:tL(n),error(e){n(e)}})}else i.accessToken=e.accessToken,i.type="token",i.queries=f,i.mutations=y,Object.entries(f).forEach(tt(i,"query")),Object.entries(y).forEach(tt(i,"mutation")),i.listenBoxChanged=(e,t)=>i.subscribe({query:tF,variables:e}).subscribe({next:tL(t),error(e){t(e)}});return i})({endpoint:i,accessToken:t,enableSubscription:!1,enableRetry:!0})}({endpoint:t1.media,accessToken:i.token}):s,c=e=>a?{fileId:e}:{id:e},l=e=>a?{list:e}:{fileIds:e};if(a&&e.tool("list_workspaces","List all workspaces",{},h(function*(){return x((yield s.workspaces()))})),o({name:"get_workspace_overview",description:"Get comprehensive overview of the BRICKS workspace including stats and summary",inputSchema:r({}),permission:"info"},(p=h(function*({workspace_id:e}){var i=B((yield Promise.all([s.workspace({id:e}),s.applications({workspaceId:e,paginate:{limit:50,offset:0}}),s.modules({workspaceId:e,paginate:{limit:50,offset:0}}),s.devices({workspaceId:e,paginate:{limit:50,offset:0}}),a?d.mediaWorkspace({workspaceId:e}).catch(()=>null):d.mediaWorkspace().catch(()=>null),a?d.mediaBoxes({workspaceId:e}).catch(()=>[]):d.mediaBoxes().catch(()=>[])])),6),t=i[0],n=i[1],o=i[2],r=i[3],c=i[4],l=i[5];if(!t)throw Error("Authentication failed, please check your token");return x({workspace:t,stats:{applications:n?.length??"No permission",modules:o?.length??"No permission",devices:r?.length??"No permission",running_apps:n?.filter(e=>e.status?.running).length??"No permission",media_boxes:l?.length??"No permission",media_enabled:!!c,notes:"Note: The stats are based on the first 50 applications, modules, and devices in the workspace."},recent_activity:{latest_apps:n?.slice(0,5).map(e=>({id:e._id,name:e.name,status:e.status?.running?"running":"stopped",last_update:e.last_modify_datetime}))||[]},media_info:c?{workspace_id:c.id,name:c.name,size_used:c.size,size_limit:c.sizeLimit,boxes:l?.slice(0,5).map(e=>({id:e.id,name:e.name,size:e.size,description:e.description}))||[]}:{enabled:!1,note:"Media workspace is not enabled for this workspace"}})}),function(e){return p.apply(this,arguments)})),o({name:"get_applications",description:"List all applications in the workspace",inputSchema:r({limit:S.ai().describe("Maximum number of applications to return").optional().default(50),offset:S.ai().describe("Number of applications to skip").optional().default(0)}),permission:"query_application"},(u=h(function*({workspace_id:e,limit:i=50,offset:t=0}){return x((yield s.applications({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return u.apply(this,arguments)})),o({name:"get_application",description:"Get detailed info and config of a specific application",inputSchema:r({id:S.Yj().describe("Application ID")}),permission:"query_application"},(m=h(function*({workspace_id:e,id:i}){return x((yield s.application({workspaceId:e,id:i})))}),function(e){return m.apply(this,arguments)})),o({name:"get_modules",description:"List all modules in the workspace",inputSchema:r({limit:S.ai().describe("Maximum number of modules to return").optional().default(50),offset:S.ai().describe("Number of modules to skip").optional().default(0)}),permission:"query_module"},(_=h(function*({workspace_id:e,limit:i=50,offset:t=0}){return x((yield s.modules({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return _.apply(this,arguments)})),o({name:"get_module",description:"Get detailed info and config of a specific module",inputSchema:r({id:S.Yj().describe("Module ID")}),permission:"query_module"},(g=h(function*({workspace_id:e,id:i}){return x((yield s.module({workspaceId:e,id:i})))}),function(e){return g.apply(this,arguments)})),o({name:"update_module_info",description:"Update a specific module info",inputSchema:r({id:S.Yj().describe("Module ID"),name:S.Yj().describe("Module name"),description:S.Yj().describe("Module description")}),permission:"update_module"},(b=h(function*({workspace_id:e,id:i,name:t,description:n}){return x((yield s.updateModule({workspaceId:e,id:i,name:t,description:n})))}),function(e){return b.apply(this,arguments)})),o({name:"update_module_config",description:"Update a specific module configuration",inputSchema:r({id:S.Yj().describe("Module ID"),config:S.Ik({}).passthrough().describe("New configuration object, see file://docs/config-schema.md for schema reference")}),permission:"update_module"},(I=h(function*({workspace_id:e,id:i,config:t}){var n=yield j(t);if(!n.valid)throw Error(`Config validation failed: ${n.errors.join(", ")}`);return x((yield s.updateModule({workspaceId:e,id:i,config:JSON.stringify(t),validateConfig:!0})))}),function(e){return I.apply(this,arguments)})),o({name:"get_devices",description:"List all devices in the workspace",inputSchema:r({limit:S.ai().describe("Maximum number of devices to return").optional().default(50),offset:S.ai().describe("Number of devices to skip").optional().default(0)}),permission:"query_device"},(k=h(function*({workspace_id:e,limit:i=50,offset:t=0}){return x((yield s.devices({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return k.apply(this,arguments)})),o({name:"create_application",description:"Create a new BRICKS application with default grid layout",inputSchema:r({name:S.Yj().describe("Application name"),description:S.Yj().describe("Application description").optional(),grid_width:S.ai().describe("Grid width in units").optional().default(96),grid_height:S.ai().describe("Grid height in units").optional().default(54)}),permission:"create_application"},(D=h(function*({workspace_id:e,name:i,description:t,grid_width:n,grid_height:a}){return x((yield s.createApplication({workspaceId:e,name:i,description:t,gridWidth:n,gridHeight:a})))}),function(e){return D.apply(this,arguments)})),o({name:"update_application_info",description:"Update application info",inputSchema:{id:S.Yj().describe("Application ID"),name:S.Yj().describe("Application name"),description:S.Yj().describe("Application description")},permission:"update_application"},(A=h(function*({id:e,name:i,description:t}){return x((yield s.updateApplication({id:e,name:i,description:t})))}),function(e){return A.apply(this,arguments)})),o({name:"update_application_config",description:"Update application configuration with validation",inputSchema:{id:S.Yj().describe("Application ID"),config:S.Ik({}).passthrough().describe("New application configuration. Please read `getting-started` for BRICKS concepts before changing")},permission:"update_application"},(w=h(function*({id:e,config:i}){var t=yield j(i);if(!t.valid)throw Error(`Config validation failed: ${t.errors.join(", ")}`);return x((yield s.updateApplication({id:e,config:JSON.stringify(i)})))}),function(e){return w.apply(this,arguments)})),o({name:"bind_application",description:"Bind application to device with viewport configuration",inputSchema:{app_id:S.Yj().describe("Application ID"),viewports:S.YO(S.Ik({device_id:S.Yj().describe("Device ID"),x:S.ai().describe("X coordinate"),y:S.ai().describe("Y coordinate"),width:S.ai().describe("Width"),height:S.ai().describe("Height"),rotate:S.ai().describe("Rotation"),rotateType:S.Yj().describe("Rotation type")})).describe("Viewport configuration")},permission:"bind_application"},(C=h(function*({app_id:e,viewports:i}){return x((yield s.bindApplication({id:e,bindDevices:i.map(e=>e.device_id),deviceFrames:i.reduce((e,i)=>({...e,[i.device_id]:{x:i.x,y:i.y,width:i.width,height:i.height,rotate:i.rotate,rotateType:i.rotateType}}),{})})))}),function(e){return C.apply(this,arguments)})),o({name:"unbind_application",description:"Unbind application from device",inputSchema:{app_id:S.Yj().describe("Application ID"),device_id:S.Yj().describe("Device ID")},permission:"bind_application"},(M=h(function*({app_id:e,device_id:i}){return x((yield s.bindApplication({id:e,unbindDevices:[i]})))}),function(e){return M.apply(this,arguments)})),a&&o({name:"list_media_workspaces",description:"List all media workspaces",inputSchema:{},permission:"query_media_flow"},h(function*(){return x((yield d.mediaWorkspaces()))})),o({name:"get_media_workspace",description:"Get media workspace information and status",inputSchema:r({}),permission:"query_media_flow"},(R=h(function*({workspace_id:e}){return x((yield d.mediaWorkspace({workspaceId:e})))}),function(e){return R.apply(this,arguments)})),o({name:"list_media_boxes",description:"List all media boxes in the workspace",inputSchema:r({}),permission:"query_media_flow"},(O=h(function*({workspace_id:e}){return x((yield d.mediaBoxes({workspaceId:e})))}),function(e){return O.apply(this,arguments)})),o({name:"get_media_box",description:"Get detailed information about a specific media box",inputSchema:{box_id:S.Yj().describe("Media box ID")},permission:"query_media_flow"},(P=h(function*({box_id:e}){return x((yield d.mediaBox({boxId:e})))}),function(e){return P.apply(this,arguments)})),o({name:"list_media_files",description:"List media files in a specific box with filtering options",inputSchema:{box_id:S.Yj().describe("Media box ID"),include_types:S.YO(S.Yj()).optional().describe('Filter by file types (e.g., ["image", "video", "audio"])'),user_tags:S.YO(S.Yj()).optional().describe("Filter by user tags"),limit:S.ai().optional().default(50).describe("Maximum number of files to return"),offset:S.ai().optional().default(0).describe("Number of files to skip")},permission:"query_media_flow"},(F=h(function*({box_id:e,include_types:i,user_tags:t,limit:n,offset:a}){return x((yield d.mediaFiles({boxId:e,includeTypes:i,userTags:t,limit:n,offset:a})))}),function(e){return F.apply(this,arguments)})),o({name:"get_media_file_meta",description:"Get detailed information about a specific media file",inputSchema:{file_id:S.Yj().describe("Media file ID")},permission:"query_media_flow"},(N=h(function*({file_id:e}){return x((yield d.mediaFile(c(e))))}),function(e){return N.apply(this,arguments)})),o({name:"media_box_upload",description:"Upload a file to a media box from URL or base64 data",inputSchema:{box_id:S.Yj().describe("Target media box ID"),name:S.Yj().describe("File name"),description:S.Yj().optional().default("").describe("File description"),file_type:S.k5(["image","video","audio","file"]).describe("File type"),source_url:S.Yj().optional().describe("URL to download the file from (maximum 100 MiB)"),base64_data:S.Yj().optional().describe("Base64 encoded file data"),user_tags:S.YO(S.Yj()).optional().default([]).describe("User-defined tags for the file")},permission:"write_media_flow"},(q=h(function*({box_id:e,name:i,description:t,source_url:n,base64_data:o,file_type:r,user_tags:s}){if(!n&&!o)throw Error("Either source_url or base64_data must be provided");if(n&&o)throw Error("Provide either source_url OR base64_data, not both");var c,l="application/octet-stream";if(n){var p=yield t2(n,(0,U.fJ)(n));c=p.data,l=p.contentType}else c=new Blob([T.Buffer.from(o,"base64")],{type:l});var u=yield d.requestFileUpload({name:i,description:t,boxId:e,fileType:a?r.toUpperCase():r,contentType:l,userTags:s,meta:{}}),m=!1;try{var _=JSON.parse(u?.meta.uploadInfo),g=new FormData;g.append("file",c),g.append("Content-Type",l),g.append("AWSAccessKeyId",_.AWSAccessKeyId),g.append("Signature",_.Signature),g.append("Policy",_.Policy),g.append("acl",_.acl),g.append("key",_.key),m=yield(0,E.Ay)(_.url,{method:"POST",body:g}).then(e=>e.ok).catch(()=>!1)}catch{m=!1}return x({file_id:u.id,upload_success:m,upload_info:{content_type:l,file_type:r,source_type:n?"url":"base64",processing_note:"File will be processed automatically. Use get_media_file to check processing status."}})}),function(e){return q.apply(this,arguments)})),o({name:"update_media_file_meta",description:"Update media file information",inputSchema:{file_id:S.Yj().describe("Media file ID"),name:S.Yj().optional().describe("New file name"),description:S.Yj().optional().describe("New file description"),user_tags:S.YO(S.Yj()).optional().describe("New user tags")},permission:"write_media_flow"},(W=h(function*({file_id:e,name:i,description:t,user_tags:n}){return x((yield d.updateMediaFile({...c(e),name:i,description:t,userTags:n,requestUploadAgain:!1})))}),function(e){return W.apply(this,arguments)})),o({name:"copy_media_files",description:"Copy media files from one box to another",inputSchema:{from_box_id:S.Yj().describe("Source media box ID"),to_box_id:S.Yj().describe("Target media box ID"),file_ids:S.YO(S.Yj()).describe("Array of media file IDs to copy")},permission:"write_media_flow"},(V=h(function*({from_box_id:e,to_box_id:i,file_ids:t}){return x((yield d.copyMediaFiles({fromBoxId:e,toBoxId:i,...l(t)})))}),function(e){return V.apply(this,arguments)})),o({name:"delete_media_files",description:"Delete specific media files from a box",inputSchema:{box_id:S.Yj().describe("Media box ID"),file_ids:S.YO(S.Yj()).describe("Array of media file IDs to delete")},permission:"write_media_flow"},(Y=h(function*({box_id:e,file_ids:i}){return x((yield d.deleteMediaFiles({boxId:e,...l(i)})))}),function(e){return Y.apply(this,arguments)})),o({name:"cleanup_media_box",description:"Delete all files in a media box, optionally filtered by type",inputSchema:{box_id:S.Yj().describe("Media box ID"),include_types:S.YO(S.Yj()).optional().describe('Only delete files of these types (e.g., ["image", "video"])')},permission:"write_media_flow"},(K=h(function*({box_id:e,include_types:i}){if("deleteMediaBoxFiles"in d)return x((yield d.deleteMediaBoxFiles({boxId:e,includeTypes:i})));var t=yield d.mediaFiles({boxId:e,includeTypes:i});return x((yield d.deleteMediaFiles({boxId:e,list:t.map(e=>e.id)})))}),function(e){return K.apply(this,arguments)})),e.tool("calculate_grid_layout","Calculate grid layout and pixel conversions for different device resolutions",{device_width:S.ai().describe("Device width in pixels"),device_height:S.ai().describe("Device height in pixels"),app_grid_width:S.ai().describe("Application grid width").optional().default(96),app_grid_height:S.ai().describe("Application grid height").optional().default(54)},(G=h(function*({device_width:e,device_height:i,app_grid_width:t,app_grid_height:n}){var a,o=(a=e/t,{deviceBrickWidth:e/a,deviceBrickHeight:i/a,deviceBrickUnit:a}),r=function(e,i,t=96){var n=e/t;return i>e&&(n=i/t),{deviceBrickWidth:Math.round(e/n),deviceBrickHeight:Math.round(i/n),deviceBrickUnit:n}}(e,i,t);return x({device_resolution:{width:e,height:i,aspect_ratio:(e/i).toFixed(2)},current_grid:{width:t,height:n,unit_size_px:o.deviceBrickUnit.toFixed(2),total_pixels:{width:o.deviceBrickWidth.toFixed(2),height:o.deviceBrickHeight.toFixed(2)}},recommended_grid:{width:r.deviceBrickWidth,height:r.deviceBrickHeight,unit_size_px:r.deviceBrickUnit.toFixed(2),note:"Optimized for device aspect ratio"}})}),function(e){return G.apply(this,arguments)})),e.tool("create_item","Use this tool to create new item that you can put in application configuration",{type:S.k5(["subspace","canvas","brick","generator","property_bank","property_bank_calc","property_bank_command","animation","state_group","automation_map"]).describe("Item type"),title:S.Yj().describe("Item title"),template_key:S.Yj().optional().describe("Template key for brick or generator")},t6),e.tool("getting_started","Get documentation content for getting started",{},h(function*(){return x(J)})),!a){var p,u,m,_,g,b,I,k,D,A,w,C,M,R,O,P,F,N,q,W,V,Y,K,G,L,H,z,X=()=>new tQ(t,i.auth||i.token);o({name:"activity_log_events",description:"Query activity log events. Returns raw events (general, data, local_sync) with filtering. Max 30-day range.",inputSchema:r({start_time:S.Yj().describe("Start time (ISO 8601)"),end_time:S.Yj().describe("End time (ISO 8601)"),device_id:S.Yj().optional().describe("Filter by device ID"),event_type:S.k5(["general","data","local_sync"]).optional().describe("Filter by event type"),event_name:S.Yj().optional().describe("Filter by event name (e.g. BRICK_xxx_ON_PRESS)"),subspace_id:S.Yj().optional().describe("Filter by subspace ID"),sender:S.Yj().optional().describe("Filter by sender"),limit:S.ai().optional().default(50).describe("Max events to return per page"),offset:S.ai().optional().default(0).describe("Number of events to skip (for pagination)")}),permission:"query_activity_log"},(L=h(function*({start_time:e,end_time:i,device_id:t,event_type:n,event_name:a,subspace_id:o,sender:r,limit:s=50,offset:d=0}){var c=X(),l={start_time:e,end_time:i};return t&&(l.device_id=t),n&&(l.event_type=n),a&&(l.event_name=a),o&&(l.subspace_id=o),r&&(l.sender=r),x((yield c.events(l,{limit:s,offset:d})))}),function(e){return L.apply(this,arguments)})),o({name:"activity_log_screenshots",description:"List available screenshot timestamps for a device in a time range.",inputSchema:r({device_id:S.Yj().describe("Device ID (required)"),start_time:S.Yj().describe("Start time (ISO 8601)"),end_time:S.Yj().describe("End time (ISO 8601)")}),permission:"query_activity_log"},(H=h(function*({device_id:e,start_time:i,end_time:t}){var n=X();return x((yield n.screenshots({device_id:e,start_time:i,end_time:t})))}),function(e){return H.apply(this,arguments)})),o({name:"activity_log_screenshot",description:"Download a device screenshot at a specific timestamp. Returns JPEG image as blob.",inputSchema:r({device_id:S.Yj().describe("Device ID"),ts:S.Yj().describe("Screenshot timestamp (ISO 8601 or epoch ms)")}),permission:"query_activity_log"},(z=h(function*({workspace_id:e,device_id:t,ts:n}){var a=e||i.tokenInfo?.w_id;if(!a)throw Error("Could not determine workspace ID");var o=X(),r=/^\d+$/.test(n)?n:new Date(n).getTime();return x((yield o.downloadScreenshot(a,t,r)),{mimeType:"image/jpeg"})}),function(e){return z.apply(this,arguments)}))}o({name:"get_device_usage",description:"Get device usage metrics (uptime, memory, disk) for a date range. Data from BRICKS main server.",inputSchema:r({device_id:S.Yj().describe("Device ID"),start_date:S.Yj().optional().describe("Start date/time in ISO 8601 format (default: start of today)"),end_date:S.Yj().optional().describe("End date/time in ISO 8601 format (default: now)")}),permission:"query_device"},(n=h(function*({device_id:e,start_date:i,end_date:t}){var n=new Date,a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).toISOString();return x((yield s.deviceUsage({deviceId:e,startDate:i?new Date(i).toISOString():a,endDate:t?new Date(t).toISOString():n.toISOString()})))}),function(e){return n.apply(this,arguments)}))}(p,t,{activityLogBaseUrl:a});var m=new I.S;try{yield p.connect(m),console.error("BRICKS MCP Server running on STDIO"),console.error(`Server: ${t0} v${t5}`),console.error(`Token Type: ${t.tokenType}${s?" (oauth)":""}`),console.error(`Permissions: ${t.tokenInfo.permissions.join(", ")}`),console.error("Ready to accept requests...")}catch(e){throw console.error("Failed to start MCP server:",e),e}})).apply(this,arguments)}}};
package/lib/index.js CHANGED
@@ -97,10 +97,10 @@ ${v.default.bold("Exposed Properties")} (${o.expose_properties.length})`),o.expo
97
97
  Resolved ${u}`)),console.log("─".repeat(60)),console.log(`Name: ${o.default.cyan(D.name||"Unnamed")}`),console.log(`ID: ${o.default.gray(D._id)}`),console.log(`Selected By: ${g.selectedBy}`),console.log("─".repeat(60));return}if(0===g.matches.length)return void console.log(o.default.yellow(`No ${m} matched "${e}"`));console.log(o.default.bold(`
98
98
  Matching ${c} (${g.matches.length})`)),console.log("─".repeat(80)),g.matches.forEach(e=>{console.log(`${o.default.cyan(e.name||"Unnamed")} ${o.default.gray(e._id)}`)}),console.log("─".repeat(80))}catch(t){f?f.fail(`Failed to resolve ${a}: ${t.message}`):(0,r.OW)(t.message,{resource:a,query:e}),process.exit(1)}}),function(e,a){return s.apply(this,arguments)}))}},76250(e,a,t){t.d(a,{n:()=>n});var p=t(99436),o=t(73284),i=t(30155),d=t(44618),r=t(56493),n=(e,{description:a,entityName:t,fetchEntity:n})=>{var l;e.command("short-refs <id>").description(a).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((l=p(function*(e,a){var p=(0,r.requireAuth)(),l=(0,i.default)("Fetching short edit references...").start();try{var s=yield n(p,e);if(l.stop(),!s?.short_edit?.enabled)return void console.log(o.default.yellow(`Short Edit is not enabled for this ${t}`));var u=a.types?a.types.split(",").map(e=>e.trim()).filter(Boolean):[],m=(0,d.V)(s.short_edit.ref_map,{keyword:a.keyword,types:u});if(a.json)return void console.log(JSON.stringify(m,null,2));if(0===m.length)return void console.log(o.default.yellow("No short edit references found"));console.log(o.default.bold(`
99
99
  Short Edit References: ${s.name}`)),m.forEach(e=>{console.log(o.default.cyan(`
100
- ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:a})=>{var t=a?.title?o.default.gray(`- ${a.title}`):"";console.log(` ${o.default.green(e)} ${t}`)})}),console.log()}catch(e){l.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,a){return l.apply(this,arguments)}))}},38311(e,a,t){t.d(a,{D:()=>u});var p,o,i,d=t(99436),r=t(35679),n=t(73284),l=(p=d(function*(){var e=(yield Promise.resolve().then(t.bind(t,30155))).default,a=yield t.e(6818).then(t.bind(t,53241)),p=a.detectChannel,o=a.detectInstallMethod,i=yield t.e(9405).then(t.bind(t,21068));return{ora:e,detectChannel:p,detectInstallMethod:o,fetchLatestVersionInfo:i.fetchLatestVersionInfo,runUpdateForMethod:i.runUpdateForMethod}}),function(){return p.apply(this,arguments)}),s=(o=d(function*({message:e,defaultValue:a,autoYes:p}){if(p)return!0;(0,(yield Promise.resolve().then(t.bind(t,8479))).isInteractiveTerminal)()||(console.error(n.default.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{var o=(yield t.e(5658).then(t.bind(t,27521))).confirm;return yield o({message:e,default:a})}catch{return!1}}),function(e){return o.apply(this,arguments)}),u=new r.uB("update-cli").description("Update the BRICKS CLI to the latest version").option("-y, --yes","Skip confirmation prompts").option("--channel <channel>","Override channel (release|beta)").option("--check-update","Only check whether a newer version is available and exit").action((i=d(function*(e){var a,t=yield l(),p=t.ora,o=t.detectChannel,i=t.detectInstallMethod,r=t.fetchLatestVersionInfo,u=t.runUpdateForMethod,m="2.25.5",c=i(),f=e.channel||o({version:m,execPath:c.execPath});console.log(n.default.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${n.default.cyan(m)}`),console.log(`Channel : ${n.default.cyan(f)}`),console.log(`Detected method : ${n.default.cyan(c.method)}`),c.execPath&&"binary"===c.method&&console.log(`Binary path : ${n.default.gray(c.execPath)}`),c.installRoot&&console.log(`Install root : ${n.default.gray(c.installRoot)}`);var h="npm"===c.method||"bun"===c.method?"npm":"cdn",v=p(`Fetching latest version info (${h})...`).start(),g=null,D=null;try{g=(yield r(f,c.method)).version,v.succeed(`Latest ${f} (${h}): ${n.default.green(g)}`)}catch(e){D=e,v.warn(`Could not fetch version info: ${e.message}`)}var y=g&&g===m;if(e.checkUpdate){if(D&&process.exit(2),y)return void console.log(n.default.green("\nUp to date."));g&&(console.log(n.default.yellow(`
100
+ ${e.label} (${e.prefix}_)`)),e.refs.forEach(({shortId:e,ref:a})=>{var t=a?.title?o.default.gray(`- ${a.title}`):"";console.log(` ${o.default.green(e)} ${t}`)})}),console.log()}catch(e){l.fail(`Failed to fetch short edit references: ${e.message}`),process.exit(1)}}),function(e,a){return l.apply(this,arguments)}))}},38311(e,a,t){t.d(a,{D:()=>u});var p,o,i,d=t(99436),r=t(35679),n=t(73284),l=(p=d(function*(){var e=(yield Promise.resolve().then(t.bind(t,30155))).default,a=yield t.e(6818).then(t.bind(t,53241)),p=a.detectChannel,o=a.detectInstallMethod,i=yield t.e(9405).then(t.bind(t,21068));return{ora:e,detectChannel:p,detectInstallMethod:o,fetchLatestVersionInfo:i.fetchLatestVersionInfo,runUpdateForMethod:i.runUpdateForMethod}}),function(){return p.apply(this,arguments)}),s=(o=d(function*({message:e,defaultValue:a,autoYes:p}){if(p)return!0;(0,(yield Promise.resolve().then(t.bind(t,8479))).isInteractiveTerminal)()||(console.error(n.default.red("Refusing to prompt in a non-interactive shell. Pass -y/--yes to confirm.")),process.exit(1));try{var o=(yield t.e(5658).then(t.bind(t,27521))).confirm;return yield o({message:e,default:a})}catch{return!1}}),function(e){return o.apply(this,arguments)}),u=new r.uB("update-cli").description("Update the BRICKS CLI to the latest version").option("-y, --yes","Skip confirmation prompts").option("--channel <channel>","Override channel (release|beta)").option("--check-update","Only check whether a newer version is available and exit").action((i=d(function*(e){var a,t=yield l(),p=t.ora,o=t.detectChannel,i=t.detectInstallMethod,r=t.fetchLatestVersionInfo,u=t.runUpdateForMethod,m="2.26.0-beta.0",c=i(),f=e.channel||o({version:m,execPath:c.execPath});console.log(n.default.bold(e.checkUpdate?"BRICKS CLI Update Check":"BRICKS CLI Update")),console.log("─".repeat(60)),console.log(`Current version : ${n.default.cyan(m)}`),console.log(`Channel : ${n.default.cyan(f)}`),console.log(`Detected method : ${n.default.cyan(c.method)}`),c.execPath&&"binary"===c.method&&console.log(`Binary path : ${n.default.gray(c.execPath)}`),c.installRoot&&console.log(`Install root : ${n.default.gray(c.installRoot)}`);var h="npm"===c.method||"bun"===c.method?"npm":"cdn",v=p(`Fetching latest version info (${h})...`).start(),g=null,D=null;try{g=(yield r(f,c.method)).version,v.succeed(`Latest ${f} (${h}): ${n.default.green(g)}`)}catch(e){D=e,v.warn(`Could not fetch version info: ${e.message}`)}var y=g&&g===m;if(e.checkUpdate){if(D&&process.exit(2),y)return void console.log(n.default.green("\nUp to date."));g&&(console.log(n.default.yellow(`
101
101
  Update available: ${m} → ${g}. Run 'bricks update-cli' to install.`)),process.exit(1)),console.log(n.default.yellow("\nCould not determine current version.")),process.exit(2)}if(y&&(console.log(n.default.green("\nAlready running the latest version.")),!(yield s({message:"Reinstall anyway?",defaultValue:!1,autoYes:e.yes}))))return void console.log(n.default.gray("Skipped."));var w=["npm","bun","binary"].includes(c.method);w||console.log(n.default.yellow(`Cannot auto-detect installer (method: ${c.method}); falling back to binary install.`));var b=w?c.method:"binary";if(!(yield s({message:`Update CLI using "${b}" method?`,defaultValue:!0,autoYes:e.yes})))return void console.log(n.default.yellow("Cancelled."));var _=(a=d(function*(e){console.log(n.default.cyan(`
102
102
  → Running ${e} update...`));try{return yield u(e,f,c),!0}catch(a){return console.error(n.default.yellow(`
103
- ${e} update failed: ${a.message}`)),!1}}),function(e){return a.apply(this,arguments)}),C=yield _(b);!C&&"binary"!==b&&(console.log(n.default.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield s({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(C=yield _("binary"))),C||(console.error(n.default.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(n.default.green("\nUpdate complete."))}),function(e){return i.apply(this,arguments)}))},1878(e,a,t){t.a(e,async function(e,p){try{t.d(a,{A:()=>A,e:()=>E});var o,i=t(99436),d=t(35679),r=t(73284),n=t(47988),l=t(8479),s=t(55614),u=t(51756),m=t(17422),c=t(32541),f=t(28634),h=t(12569),v=t(55609),g=t(71335),D=t(68473),y=t(41623),w=t(42400),b=t(98247),_=t(70970),C=t(38311),F=t(59845),S=t(22175),k=e([w]);w=(k.then?(await k)():k)[0];var E=(o=i(function*(){var e,a=(0,l.getUnsupportedBunRuntimeError)();if(a){var p=process.argv.includes("--json")||process.argv.includes("-j");console.error(p?JSON.stringify({error:a}):r.default.red(a)),process.exit(1)}var o=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==o&&process.argv[o+1]&&((0,n.setProfileOverride)(process.argv[o+1]),process.argv.splice(o,2)),d.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.25.5","-v, --version","output the version number").enablePositionalOptions(),d.DM.addCommand(s.s),d.DM.addCommand(u._),d.DM.addCommand(m.B),d.DM.addCommand(c.A),d.DM.addCommand(f.p),d.DM.addCommand(h.u),d.DM.addCommand(v.E),d.DM.addCommand(g.oT),d.DM.addCommand(D.K),d.DM.addCommand(y.gf),d.DM.addCommand(w.D),d.DM.addCommand(b.v),d.DM.addCommand(_.l),d.DM.addCommand(C.D),d.DM.addCommand(F.Q),d.DM.addCommand(S.g),d.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(i(function*(){try{var e=(yield Promise.all([t.e(3332),t.e(8295),t.e(3690),t.e(907),t.e(7294)]).then(t.bind(t,94685))).runInteractiveMode;yield e()}catch(e){console.error(r.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),d.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=i(function*(e){var a=(yield Promise.resolve().then(t.bind(t,47988))).getCurrentProfile,p=(yield Promise.resolve().then(t.bind(t,31802))).getConnectionContext,o=(yield Promise.all([t.e(3332),t.e(8295),t.e(907)]).then(t.bind(t,85382))).createClient,i=(yield Promise.resolve().then(t.bind(t,30155))).default,d=a(),n=p(d),l=n.auth,s=n.baseUrl;l||(console.error(r.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=i("Fetching workspace info...").start();try{var m=o(s,l),c=yield m.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(c,null,2));console.log(r.default.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${r.default.green(c.name)}`),console.log(`ID: ${r.default.gray(c._id)}`),console.log(`Description: ${c.description||r.default.gray("N/A")}`),console.log(`
103
+ ${e} update failed: ${a.message}`)),!1}}),function(e){return a.apply(this,arguments)}),C=yield _(b);!C&&"binary"!==b&&(console.log(n.default.cyan("\nFalling back to binary install (same method used by the desktop app).")),(yield s({message:"Try the binary installer as a fallback?",defaultValue:!0,autoYes:e.yes}))&&(C=yield _("binary"))),C||(console.error(n.default.red("\nUpdate failed. See messages above.")),process.exit(1)),console.log(n.default.green("\nUpdate complete."))}),function(e){return i.apply(this,arguments)}))},1878(e,a,t){t.a(e,async function(e,p){try{t.d(a,{A:()=>A,e:()=>E});var o,i=t(99436),d=t(35679),r=t(73284),n=t(47988),l=t(8479),s=t(55614),u=t(51756),m=t(17422),c=t(32541),f=t(28634),h=t(12569),v=t(55609),g=t(71335),D=t(68473),y=t(41623),w=t(42400),b=t(98247),_=t(70970),C=t(38311),F=t(59845),S=t(22175),k=e([w]);w=(k.then?(await k)():k)[0];var E=(o=i(function*(){var e,a=(0,l.getUnsupportedBunRuntimeError)();if(a){var p=process.argv.includes("--json")||process.argv.includes("-j");console.error(p?JSON.stringify({error:a}):r.default.red(a)),process.exit(1)}var o=process.argv.findIndex(e=>"--auth-profile"===e||"-ap"===e);-1!==o&&process.argv[o+1]&&((0,n.setProfileOverride)(process.argv[o+1]),process.argv.splice(o,2)),d.DM.name("bricks").description("BRICKS CLI - Command-line interface for BRICKS Workspace API").version("2.26.0-beta.0","-v, --version","output the version number").enablePositionalOptions(),d.DM.addCommand(s.s),d.DM.addCommand(u._),d.DM.addCommand(m.B),d.DM.addCommand(c.A),d.DM.addCommand(f.p),d.DM.addCommand(h.u),d.DM.addCommand(v.E),d.DM.addCommand(g.oT),d.DM.addCommand(D.K),d.DM.addCommand(y.gf),d.DM.addCommand(w.D),d.DM.addCommand(b.v),d.DM.addCommand(_.l),d.DM.addCommand(C.D),d.DM.addCommand(F.Q),d.DM.addCommand(S.g),d.DM.command("interactive").alias("i").description("Start interactive mode with Ink UI").action(i(function*(){try{var e=(yield Promise.all([t.e(3332),t.e(8295),t.e(3690),t.e(907),t.e(7294)]).then(t.bind(t,94685))).runInteractiveMode;yield e()}catch(e){console.error(r.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}})),d.DM.command("workspace").alias("ws").description("Show current workspace information").option("-j, --json","Output as JSON").action((e=i(function*(e){var a=(yield Promise.resolve().then(t.bind(t,47988))).getCurrentProfile,p=(yield Promise.resolve().then(t.bind(t,31802))).getConnectionContext,o=(yield Promise.all([t.e(3332),t.e(8295),t.e(907)]).then(t.bind(t,85382))).createClient,i=(yield Promise.resolve().then(t.bind(t,30155))).default,d=a(),n=p(d),l=n.auth,s=n.baseUrl;l||(console.error(r.default.red("Not logged in. Use `bricks auth login` first.")),process.exit(1));var u=i("Fetching workspace info...").start();try{var m=o(s,l),c=yield m.workspace();if(u.stop(),e.json)return void console.log(JSON.stringify(c,null,2));console.log(r.default.bold("\nWorkspace Information")),console.log("─".repeat(60)),console.log(`Name: ${r.default.green(c.name)}`),console.log(`ID: ${r.default.gray(c._id)}`),console.log(`Description: ${c.description||r.default.gray("N/A")}`),console.log(`
104
104
  ${r.default.bold("Data")}`),console.log(`Remote Update: ${c.bank?.enable_remote_update?r.default.green("Enabled"):r.default.gray("Disabled")}`),console.log(`Spacename: ${c.bank?.spacename||r.default.gray("N/A")}`),console.log("─".repeat(60))}catch(e){u.fail(`Failed to get workspace: ${e.message}`),process.exit(1)}}),function(a){return e.apply(this,arguments)})),d.DM.on("--help",()=>{console.log(""),console.log(r.default.bold("Examples:")),console.log(""),console.log(r.default.gray(" # Sign in with your BRICKS account (opens the browser)")),console.log(" $ bricks auth login"),console.log(""),console.log(r.default.gray(" # Select a workspace as the active profile")),console.log(" $ bricks auth use-workspace"),console.log(""),console.log(r.default.gray(" # Workspace auth (CI/automation): one-time passcode or token")),console.log(" $ bricks auth login-workspace <passcode>"),console.log(""),console.log(r.default.gray(" # List all devices")),console.log(" $ bricks device list"),console.log(""),console.log(r.default.gray(" # Monitor devices in real-time")),console.log(" $ bricks device monitor"),console.log(""),console.log(r.default.gray(" # Control a device")),console.log(" $ bricks device refresh <device-id>"),console.log(" $ bricks device control <device-id> clear-cache"),console.log(""),console.log(r.default.gray(" # Bind a new device")),console.log(' $ bricks device bind <passcode> -n "My Device"'),console.log(""),console.log(r.default.gray(" # List applications")),console.log(" $ bricks app list"),console.log(""),console.log(r.default.gray(" # Start interactive mode")),console.log(" $ bricks interactive"),console.log(""),console.log(r.default.gray(" # Change API endpoint")),console.log(" $ bricks config endpoint beta"),console.log(""),console.log(r.default.gray("Get workspace token from BRICKS Controller:")),console.log(r.default.cyan(" https://control.bricks.tools")),console.log(r.default.gray(" Go to Workspace Settings > API Token"))});var k=process.argv.slice(2);if(0===k.length){if((0,l.shouldStartInteractiveMode)(k))try{var E=(yield Promise.all([t.e(3332),t.e(8295),t.e(3690),t.e(907),t.e(7294)]).then(t.bind(t,94685))).runInteractiveMode;yield E();return}catch(e){console.error(r.default.red(`Failed to start interactive mode: ${e.message}`)),process.exit(1)}console.error(r.default.gray("No command provided. Interactive mode requires a TTY, so showing help instead.\n")),d.DM.outputHelp();return}yield d.DM.parseAsync(process.argv)}),function(){return o.apply(this,arguments)});let A=E;p()}catch(e){p(e)}})},31802(e,a,t){t.r(a),t.d(a,{getAuthContext:()=>n,getConnectionContext:()=>r});var p=t(99436),o=t(47988),i=t(63755),d=(e,a)=>{if(!e)throw Error("Not logged in. Run `bricks auth login` first.");if(e.user?.sub!==a)throw Error("OAuth account changed. Re-select the workspace for the current account.");return e},r=e=>{var a=(0,o.getProfileCredentialSnapshot)(e);return{...a,auth:(({tokenInfo:e,oauth:a})=>{if(!e)return null;if("oauth"===e.type){if(!a?.accessToken||!e.oauthSubject||e.oauthSubject!==a.user?.sub||!e.workspaceId)return null;var t,o,r,n=e.oauthSubject;return{kind:"oauth",workspaceId:e.workspaceId,workspaceName:e.workspaceName,getHeaders:(o=p(function*(){var a=d((yield(0,i.EC)()),n);return{authorization:`Bearer ${a.accessToken}`,"x-bricks-workspace-id":String(e.workspaceId)}}),function(){return o.apply(this,arguments)}),refresh:(r=p(function*(){d((yield(0,i.EC)({forceRefresh:!0})),n)}),function(){return r.apply(this,arguments)})}}return e.token?{kind:"token",token:e.token,workspaceId:e.workspaceId,workspaceName:e.workspaceName,getHeaders:(t=p(function*(){return{authorization:`Bearer ${e.token}`}}),function(){return t.apply(this,arguments)})}:null})(a)}},n=e=>r(e).auth},31596(e,a,t){t.d(a,{GE:()=>o,YC:()=>p,jR:()=>i});var p=["InSubspace","Global"],o="Data Bank is not enabled for this workspace.",i=e=>{if(e&&!p.includes(e))throw Error(`Invalid meta "${e}" (expected ${p.join(" | ")})`)}},56493(e,a,t){t.r(a),t.d(a,{requireAuth:()=>s,requireAuthConnection:()=>l});var p=t(99436),o=t(73284),i=t(47988),d=t(31802),r=t(29988),n=new Set(["$$typeof","asymmetricMatch","catch","constructor","finally","hasOwnProperty","inspect","nodeType","toJSON","toString","valueOf"]),l=(e=(0,i.getCurrentProfile)())=>{var a,t,l,s=(0,d.getConnectionContext)(e),u=s.auth,m=s.baseUrl;return u||(console.error(o.default.red("Not logged in.")),console.error(o.default.gray("Use `bricks auth login` (OAuth) or `bricks auth login-workspace` (workspace token) first.")),process.exit(1)),{...s,client:(a=null,t=p(function*(){return a||=Promise.resolve((0,r.i)()).then(({createClient:e})=>e(m,u))}),l=function(){return t.apply(this,arguments)},new Proxy({},{get:(e,a)=>a===Symbol.toStringTag?"BricksLazyClient":"string"!=typeof a||"then"===a||n.has(a)?void 0:p(function*(...e){var t=yield l(),p=t[a];return"function"==typeof p?p.apply(t,e):p})}))}},s=(e=(0,i.getCurrentProfile)())=>l(e).client},7586(e,a,t){t.d(a,{$l:()=>i,GF:()=>p,OW:()=>o});var p=e=>{console.log(JSON.stringify(e,null,2))},o=(e,a={})=>{console.error(JSON.stringify({ok:!1,error:{message:e,...a}},null,2))},i=(e,a=4)=>e?e.length<=2*a?"*".repeat(e.length):`${e.slice(0,a)}…${e.slice(-a)}`:null},8479(e,a,t){t.r(a),t.d(a,{MINIMUM_BUN_VERSION:()=>p,getUnsupportedBunRuntimeError:()=>i,isInteractiveTerminal:()=>d,shouldStartInteractiveMode:()=>r});var p="1.3.0",o=e=>{var a=String(e).match(/^(\d+)\.(\d+)\.(\d+)/);return a?a.slice(1).map(Number):null},i=(e=process.versions.bun)=>!e||((e,a)=>{var t=o(e),p=o(a);if(!t||!p)return!1;for(var i=0;i<p.length&&!(t[i]>p[i]);i+=1)if(t[i]<p[i])return!1;return!0})(e,p)?null:`Bun ${e} is not supported by BRICKS CLI. Bun ${p} or later is required. Run \`bun upgrade\` and retry.`,d=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&"function"==typeof process.stdin.setRawMode),r=(e=[])=>0===e.length&&d()},47988(e,a,t){t.r(a),t.d(a,{CONFIG_DIR:()=>F,CONFIG_LOCK_PATH:()=>k,CONFIG_PATH:()=>S,OAUTH_REFRESH_LOCK_PATH:()=>E,clearBankCredentials:()=>eU,clearConfig:()=>eq,clearOAuth:()=>eF,clearOAuthIfCurrent:()=>e$,clearOAuthIfCurrentAsync:()=>ex,default:()=>eJ,getActivityLogBaseUrl:()=>eM,getBankCredentials:()=>eP,getBaseUrl:()=>G,getCurrentProfile:()=>eB,getCurrentProfileSource:()=>eI,getOAuth:()=>eb,getProfileAuthKind:()=>ew,getProfileCredentialSnapshot:()=>ee,getProfileCredentialSnapshotAsync:()=>ea,getProfileFingerprint:()=>et,getToken:()=>K,getTokenInfo:()=>z,getTokens:()=>W,initializeConfigAsync:()=>q,installOAuthSessionIfCurrent:()=>eD,installOAuthSessionIfCurrentAsync:()=>ey,invalidateOAuthProfileCredentials:()=>eh,invalidateOAuthProfileCredentialsAsync:()=>ev,listProfiles:()=>eV,removeToken:()=>es,removeTokenIfCurrent:()=>eu,replaceOAuthIfCurrent:()=>eA,replaceOAuthIfCurrentAsync:()=>eN,resolveOAuthProfileTarget:()=>ep,setActivityLogBaseUrl:()=>eL,setBankCredentials:()=>eR,setBaseUrl:()=>H,setCurrentProfile:()=>ej,setDevtoolsTokenIfProfileCurrent:()=>em,setDevtoolsTokenIfProfileCurrentAsync:()=>ec,setOAuth:()=>e_,setOAuthAsync:()=>eC,setProfileOverride:()=>eT,setToken:()=>ed,setTokenIfProfileCurrent:()=>en,setTokenIfProfileCurrentAsync:()=>el,takeOAuthSession:()=>eS,takeOAuthSessionAsync:()=>ek,withOAuthRefreshLock:()=>V});var p,o,i,d,r,n,l,s,u,m,c,f,h,v,g=t(68832),D=t(99436),y=t(83440),w=t(76982),b=t(79896),_=t(16928),C=t(70857),F=_.join(C.homedir(),".bricks-cli"),S=_.join(F,"config.json"),k=`${S}.lock`,E=`${S}.oauth-refresh.lock`,A=new Int32Array(new SharedArrayBuffer(4)),N=e=>new Promise(a=>setTimeout(a,e)),$=e=>{if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"ESRCH"!==e.code}},x=e=>{try{var a=b.readFileSync(e,"utf8"),t=b.statSync(e),p=null;try{var o=JSON.parse(a);Number.isInteger(o?.pid)&&"string"==typeof o?.nonce&&(p=o)}catch{}return{raw:a,stat:t,owner:p}}catch(e){if("ENOENT"===e.code)return null;throw e}},O=e=>{var a,t=x(e);if(!t)return!0;var p=t.owner?!$(t.owner.pid):Date.now()-t.stat.mtimeMs>1e3;if(!p)return!1;var o=`${e}.recovery`;try{a=T(o)}catch(e){if("EEXIST"===e.code)return!1;throw e}try{if(!(t=x(e)))return!0;if(!(p=t.owner?!$(t.owner.pid):Date.now()-t.stat.mtimeMs>1e3))return!1;return b.unlinkSync(e),!0}catch(e){if("ENOENT"===e.code)return!0;throw e}finally{B(o,a)}},T=e=>{var a,t={pid:process.pid,nonce:w.randomUUID()},p=`${e}.${t.pid}.${t.nonce}.candidate`;try{a=b.openSync(p,"wx",384),b.writeFileSync(a,JSON.stringify(t)),b.fsyncSync(a),b.closeSync(a),a=void 0}catch(e){if(void 0!==a)try{b.closeSync(a)}catch{}try{b.unlinkSync(p)}catch{}throw e}try{b.linkSync(p,e)}catch(e){try{b.unlinkSync(p)}catch{}throw e}try{b.unlinkSync(p)}catch(e){"ENOENT"!==e.code&&console.error(`Failed to clean up shared BRICKS lock candidate: ${e.message}`)}return{owner:t}},B=(e,{owner:a})=>{try{var t;(t=x(e))&&t.owner?.nonce===a.nonce&&b.unlinkSync(e)}catch(e){"ENOENT"!==e.code&&console.error(`Failed to release shared BRICKS lock: ${e.message}`)}},I=e=>{b.mkdirSync(F,{recursive:!0});for(var a,t=Date.now()+5e3;!a;)try{a=T(k)}catch(e){if("EEXIST"!==e.code)throw e;if(O(k))continue;if(Date.now()>=t)throw Error(`Timed out waiting for shared BRICKS config lock: ${k}`);Atomics.wait(A,0,0,20)}try{return e()}finally{B(k,a)}},j=(p=D(function*(e){b.mkdirSync(F,{recursive:!0});for(var a,t=Date.now()+5e3;!a;)try{a=T(k)}catch(e){if("EEXIST"!==e.code)throw e;if(O(k))continue;if(Date.now()>=t)throw Error(`Timed out waiting for shared BRICKS config lock: ${k}`);yield N(20)}try{var p=e();if(p&&"function"==typeof p.then)throw Error("Shared BRICKS config lock callbacks must be synchronous");return p}finally{B(k,a)}}),function(e){return p.apply(this,arguments)}),V=(o=D(function*(e,{timeoutMs:a=3e4}={}){b.mkdirSync(F,{recursive:!0});for(var t,p=Date.now()+a;!t;)try{t=T(E)}catch(e){if("EEXIST"!==e.code)throw e;if(O(E))continue;if(Date.now()>=p)throw Error(`Timed out waiting for OAuth refresh lock: ${E}`);yield N(20)}try{return yield e()}finally{B(E,t)}}),function(e){return o.apply(this,arguments)}),P=()=>new y.default({projectName:"bricks-cli",cwd:F,configFileMode:384,schema:{oauth:{type:"object",default:{},properties:{accessToken:{type:"string"},refreshToken:{type:["string","null"]},expiresAt:{type:"string"},user:{type:"object"},audience:{type:"string"}}},tokens:{type:"object",default:{},additionalProperties:{type:"object",properties:{type:{type:"string",enum:["oauth"]},oauthSubject:{type:"string"},token:{type:"string"},name:{type:"string"},workspaceId:{type:"string"},workspaceName:{type:"string"},workspaceBilling:{type:"object"},createdAt:{type:"string"},baseUrl:{type:"string"},activityLogBaseUrl:{type:"string"},bank:{type:"object"}}}},currentProfile:{type:"string",default:"default"},baseUrl:{type:"string",default:"https://display.bricks.tools"},activityLogBaseUrl:{type:"string",default:"https://activity-log.bricks.tools"},devtoolsTokens:{type:"object",default:{},additionalProperties:{type:"object",additionalProperties:{type:"object",properties:{token:{type:"string"},expiresAt:{type:"string"},jti:{type:"string"},workspaceId:{type:"string"}}}}}}}),R=null,U=null,M=()=>R||=P(),L=(i=D(function*(){if(R)return R;U||=j(()=>R||=P());try{return yield U}finally{U=null}}),function(){return i.apply(this,arguments)}),q=(d=D(function*(){yield L()}),function(){return d.apply(this,arguments)}),J={get:e=>M().get(e),set:(e,a)=>{var t=M();return I(()=>t.set(e,a))},clear:()=>{var e=M();return I(()=>e.clear())},setAsync:(r=D(function*(e,a){var t=yield L();return j(()=>t.set(e,a))}),function(e,a){return r.apply(this,arguments)}),update:(e,a)=>{var t=M();return I(()=>{var p=a(t.get(e));return t.set(e,p),p})},updateAsync:(n=D(function*(e,a){var t=yield L();return j(()=>{var p=a(t.get(e));return t.set(e,p),p})}),function(e,a){return n.apply(this,arguments)}),snapshot:e=>{var a=M().store;return Object.fromEntries(e.map(e=>[e,a[e]]))},snapshotAsync:(l=D(function*(e){var a=(yield L()).store;return Object.fromEntries(e.map(e=>[e,a[e]]))}),function(e){return l.apply(this,arguments)}),transaction:(e,a)=>{var t=M();return I(()=>{var p=a(Object.fromEntries(e.map(e=>[e,t.get(e)])))||{};return Object.keys(p).length>0&&t.set(p),p})},transactionAsync:(s=D(function*(e,a){var t=yield L();return j(()=>{var p=a(Object.fromEntries(e.map(e=>[e,t.get(e)])))||{};return Object.keys(p).length>0&&t.set(p),p})}),function(e,a){return s.apply(this,arguments)})},G=(e=eB())=>{var a=J.get("tokens");return a[e]?.baseUrl||J.get("baseUrl")},H=(e,a)=>{a?J.update("tokens",(t={})=>({...t,[a]:{...t[a],baseUrl:e}})):J.set("baseUrl",e)},W=()=>J.get("tokens"),K=(e="default")=>{var a=J.get("tokens");return a[e]?.token},z=(e="default")=>J.get("tokens")[e],Y=(e,a,t,p)=>{if(!e)return null;var o=null==e.workspaceId?null:String(e.workspaceId);return"oauth"===e.type?e.oauthSubject&&e.oauthSubject===a?.user?.sub?{kind:"oauth",workspaceId:o,oauthSubject:e.oauthSubject,baseUrl:t,activityLogBaseUrl:p}:null:e.token?{kind:"token",workspaceId:o,token:e.token,baseUrl:t,activityLogBaseUrl:p}:null},Z=(e,a,t,p,o)=>{if(!e)return!1;var i=Y(a,t,a?.baseUrl||p,a?.activityLogBaseUrl||o);return!!i&&i.kind===e.kind&&i.workspaceId===e.workspaceId&&i.baseUrl===e.baseUrl&&i.activityLogBaseUrl===e.activityLogBaseUrl&&("oauth"===i.kind?i.oauthSubject===e.oauthSubject:i.token===e.token)},Q=(e,a,t)=>({exists:void 0!==e,kind:e?.type==="oauth"?"oauth":e?.token?"token":"incomplete",workspaceId:e?.workspaceId==null?null:String(e.workspaceId),credential:e?.type==="oauth"?e.oauthSubject||null:e?.token||null,baseUrl:a,activityLogBaseUrl:t}),X=(e,{tokens:a={},oauth:t,devtoolsTokens:p={},baseUrl:o,activityLogBaseUrl:i})=>{var d=a[e],r=d?.baseUrl||o,n=d?.activityLogBaseUrl||i,l=Y(d,t,r,n);return{profile:e,tokenInfo:d,oauth:t,fingerprint:l,baseline:Q(d,r,n),bank:l&&d?.bank||null,devtoolsTokens:p[e]||{},baseUrl:r,activityLogBaseUrl:n}},ee=(e="default")=>X(e,J.snapshot(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"])),ea=(u=D(function*(e="default"){return X(e,(yield J.snapshotAsync(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"])))}),function(){return u.apply(this,arguments)}),et=(e="default")=>ee(e).fingerprint,ep=(e,a,t)=>{for(var p=J.snapshot(["tokens","baseUrl","activityLogBaseUrl"]),o=p.tokens||{},i=e,d=2;;){var r=o[i];if(!r||"oauth"===r.type&&r.oauthSubject===t&&String(r.workspaceId)===String(a))break;i=`${e}-${d}`,d+=1}var n=o[i];return{profile:i,baseline:Q(n,n?.baseUrl||p.baseUrl,n?.activityLogBaseUrl||p.activityLogBaseUrl)}},eo=(e,a,t,p)=>{var o=t[e],i=o?.workspaceId&&a?.workspaceId&&String(o.workspaceId)===String(a.workspaceId),d=o?.type==="oauth"&&a?.type==="oauth"&&!!o.oauthSubject&&o.oauthSubject===a.oauthSubject||o?.type!=="oauth"&&a?.type!=="oauth"&&!!o?.token&&o.token===a?.token,r=i&&d,n={tokens:{...t,[e]:{...o?.baseUrl?{baseUrl:o.baseUrl}:{},...o?.activityLogBaseUrl?{activityLogBaseUrl:o.activityLogBaseUrl}:{},...r&&o?.bank?{bank:o.bank}:{},...a,createdAt:new Date().toISOString()}}};if(!r&&p[e]){var l={...p};delete l[e],n.devtoolsTokens=l}return n},ei=(e,a)=>{if(e&&a?.user?.sub!==e)throw Error("OAuth account changed. Re-select the workspace for the current account.")},ed=(e,a,{expectedOAuthSubject:t}={})=>{J.transaction(t?["tokens","devtoolsTokens","oauth"]:["tokens","devtoolsTokens"],({tokens:p={},devtoolsTokens:o={},oauth:i})=>(ei(t,i),eo(e,a,p,o)))},er=(e,a,t,p)=>!!e&&JSON.stringify(e)===JSON.stringify(Q(a,a?.baseUrl||t,a?.activityLogBaseUrl||p)),en=(e,a,t,{expectedOAuthSubject:p,makeCurrent:o=!1}={})=>{var i=!1;return J.transaction(["tokens","devtoolsTokens","oauth","currentProfile","baseUrl","activityLogBaseUrl"],({tokens:d={},devtoolsTokens:r={},oauth:n,baseUrl:l,activityLogBaseUrl:s})=>{if(!er(t,d[e],l,s))return{};ei(p,n),i=!0;var u=eo(e,a,d,r);return o?{...u,currentProfile:e}:u}),i},el=(m=D(function*(e,a,t,{expectedOAuthSubject:p,makeCurrent:o=!1}={}){var i=!1;return yield J.transactionAsync(["tokens","devtoolsTokens","oauth","currentProfile","baseUrl","activityLogBaseUrl"],({tokens:d={},devtoolsTokens:r={},oauth:n,baseUrl:l,activityLogBaseUrl:s})=>{if(!er(t,d[e],l,s))return{};ei(p,n),i=!0;var u=eo(e,a,d,r);return o?{...u,currentProfile:e}:u}),i}),function(e,a,t){return m.apply(this,arguments)}),es=e=>{J.transaction(["tokens","devtoolsTokens"],({tokens:a={},devtoolsTokens:t={}})=>{var p={...a};delete p[e];var o={tokens:p};if(t[e]){var i={...t};delete i[e],o.devtoolsTokens=i}return o})},eu=(e,a)=>{var t=!1;return J.transaction(["tokens","devtoolsTokens"],({tokens:p={},devtoolsTokens:o={}})=>{if(i=p[e],!i||!a||String(i.workspaceId??"")!==String(a.workspaceId??"")||("oauth"===a.type?"oauth"!==i.type||i.oauthSubject!==a.oauthSubject:a.token?"oauth"===i.type||i.token!==a.token:JSON.stringify(i)!==JSON.stringify(a)))return{};t=!0;var i,d={...p};delete d[e];var r={...o};return delete r[e],{tokens:d,devtoolsTokens:r}}),t},em=(e,a,t,p)=>{var o=!1;return J.transaction(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"],({tokens:i={},oauth:d,devtoolsTokens:r={},baseUrl:n,activityLogBaseUrl:l})=>Z(a,i[e],d,n,l)?(o=!0,{devtoolsTokens:{...r,[e]:{...r[e],[t]:p}}}):{}),o},ec=(c=D(function*(e,a,t,p){var o=!1;return yield J.transactionAsync(["tokens","oauth","devtoolsTokens","baseUrl","activityLogBaseUrl"],({tokens:i={},oauth:d,devtoolsTokens:r={},baseUrl:n,activityLogBaseUrl:l})=>Z(a,i[e],d,n,l)?(o=!0,{devtoolsTokens:{...r,[e]:{...r[e],[t]:p}}}):{}),o}),function(e,a,t,p){return c.apply(this,arguments)}),ef=(e,a)=>{if(e)return a(["tokens","devtoolsTokens"],({tokens:a={},devtoolsTokens:t={}})=>{var p={...a},o=[];for(var i of Object.entries(a)){var d=g(i,2),r=d[0],n=d[1];if(n?.type==="oauth"&&(!n.oauthSubject||n.oauthSubject===e)){o.push(r);var l={...n,oauthSubject:n.oauthSubject||e};delete l.bank,p[r]=l}}var s={...t},u=!1;return o.forEach(e=>{s[e]&&(delete s[e],u=!0)}),{tokens:p,...u?{devtoolsTokens:s}:{}}})},eh=e=>ef(e,J.transaction),ev=e=>ef(e,J.transactionAsync),eg=(e,a,t)=>{if(p=t.oauth,e?.accessToken?!eE(e,p):!!p?.accessToken)return{result:{installed:!1,identityChanged:!1,previous:null},updates:{}};var p,o=t.oauth?.accessToken?t.oauth:null,i=o?.user?.sub,d=!!(i&&a?.user?.sub&&i!==a.user.sub),r={installed:!0,identityChanged:d,previous:o};if(!d)return{result:r,updates:{oauth:a}};var n={...t.tokens||{}},l={...t.devtoolsTokens||{}},s=!1;for(var u of Object.entries(t.tokens||{})){var m=g(u,2),c=m[0],f=m[1];if(f?.type==="oauth"&&(!f.oauthSubject||f.oauthSubject===i)){var h={...f,oauthSubject:f.oauthSubject||i};delete h.bank,n[c]=h,l[c]&&(delete l[c],s=!0)}}return{result:r,updates:{oauth:a,tokens:n,...s?{devtoolsTokens:l}:{}}}},eD=(e,a)=>{var t;return J.transaction(["oauth","tokens","devtoolsTokens"],p=>{var o=eg(e,a,p);return t=o.result,o.updates}),t},ey=(f=D(function*(e,a){var t;return yield J.transactionAsync(["oauth","tokens","devtoolsTokens"],p=>{var o=eg(e,a,p);return t=o.result,o.updates}),t}),function(e,a){return f.apply(this,arguments)}),ew=(e="default")=>{var a=z(e);return a?"oauth"===a.type?"oauth":a.token?"token":null:null},eb=()=>{var e=J.get("oauth");return e&&Object.keys(e).length>0?e:null},e_=e=>J.set("oauth",e),eC=e=>J.setAsync("oauth",e),eF=()=>J.set("oauth",{}),eS=()=>{var e=null;return J.update("oauth",a=>(a?.accessToken&&(e=a),{})),e},ek=(h=D(function*(){var e=null;return yield J.updateAsync("oauth",a=>(a?.accessToken&&(e=a),{})),e}),function(){return h.apply(this,arguments)}),eE=(e,a)=>!!e&&!!a&&e.accessToken===a.accessToken&&e.refreshToken===a.refreshToken,eA=(e,a)=>{var t=!1;return J.update("oauth",p=>eE(e,p)?(t=!0,a||{}):p||{}),t},eN=(v=D(function*(e,a){var t=!1;return yield J.updateAsync("oauth",p=>eE(e,p)?(t=!0,a||{}):p||{}),t}),function(e,a){return v.apply(this,arguments)}),e$=e=>eA(e,{}),ex=e=>eN(e,{}),eO=null,eT=e=>{eO=e},eB=()=>eO||process.env.BRICKS_PROFILE||J.get("currentProfile"),eI=()=>eO?"override":process.env.BRICKS_PROFILE?"env":"config",ej=e=>J.set("currentProfile",e),eV=()=>{var e=J.get("tokens"),a=J.get("currentProfile");return Object.keys(e).map(t=>({...e[t],name:t,current:t===a}))},eP=(e="default")=>{var a=J.get("tokens")[e];if(a?.type==="oauth"){var t=eb();if(!a.oauthSubject||a.oauthSubject!==t?.user?.sub)return null}return a?.bank||null},eR=(e,a,{expectedProfile:t}={})=>{var p=!1;return J.transaction(["tokens","oauth","baseUrl","activityLogBaseUrl"],({tokens:o={},oauth:i,baseUrl:d,activityLogBaseUrl:r})=>(!t||Z(t,o[e],i,d,r))&&o[e]?(p=!0,{tokens:{...o,[e]:{...o[e],bank:a}}}):{}),p},eU=(e,{expectedProfile:a,expectedSpacekey:t}={})=>{var p=!1;return J.transaction(["tokens","oauth","baseUrl","activityLogBaseUrl"],({tokens:o={},oauth:i,baseUrl:d,activityLogBaseUrl:r})=>{if(a&&!Z(a,o[e],i,d,r)||!o[e]?.bank||t&&o[e].bank.spacekey!==t)return{};p=!0;var n={...o[e]};return delete n.bank,{tokens:{...o,[e]:n}}}),p},eM=(e=eB())=>{var a=J.get("tokens");return a[e]?.activityLogBaseUrl||J.get("activityLogBaseUrl")},eL=(e,a)=>{a?J.update("tokens",(t={})=>({...t,[a]:{...t[a],activityLogBaseUrl:e}})):J.set("activityLogBaseUrl",e)},eq=()=>{J.clear()};let eJ=J},75646(e,a,t){t.r(a),t.d(a,{discoverDevToolsServers:()=>n,httpProbeSubnet:()=>l,verifyDevToolsServer:()=>s});var p,o,i=t(99436),d=t(19557),r="bricks-devtools",n=({timeout:e=3e3,idleTimeout:a=0}={})=>(0,d.YH)({port:19900,timeout:e,idleTimeout:a,buildQuery:()=>Buffer.from(JSON.stringify({t:"QUERY",v:"1.0",s:r,d:{id:`cli-${(0,d.BW)()}`}})),parseMessage:(e,a)=>{var t=(0,d.nl)(e,e=>e?.s===r);if(!t)return null;var p=a.address;return{key:`${p}:${t.port}`,value:{...t,address:p}}}}),l=(p=i(function*({port:e=19851,connectTimeout:a=500,concurrency:t=50,timeout:p=0}={}){var o=(0,d.r9)();if(0===o.length)return[];var r=[],n=p>0?Date.now()+p:0,l=[],u=new Set;for(var m of o){var c=m.address.split(".").slice(0,3).join(".");if(!u.has(c)){u.add(c);for(var f=1;f<255;f++)l.push(`${c}.${f}`)}}for(var h=0;h<l.length&&!(n&&Date.now()>=n);h+=t){var v=l.slice(h,h+t);yield Promise.allSettled(v.map(function(){var t=i(function*(t){var p=yield s(t,e,a);p&&r.push({...p,address:t,port:e})});return function(e){return t.apply(this,arguments)}}()))}return r}),function(){return p.apply(this,arguments)}),s=(o=i(function*(e,a,t=3e3){return(0,d.uE)(`http://${e}:${a}/devtools/info`,t)}),function(e,a){return o.apply(this,arguments)})},29988(e,a,t){t.d(a,{i:()=>p});var p=()=>"u">typeof module&&"function"==typeof module.require?module.require("../gql/client.js"):Promise.all([t.e(3332),t.e(8295),t.e(907)]).then(t.bind(t,85382))},19557(e,a,t){t.d(a,{BW:()=>r,YH:()=>u,nl:()=>l,r9:()=>s,uE:()=>m});var p,o=t(99436),i=t(41314),d=t(48161),r=()=>Math.random().toString(36).slice(2,9),n=new Set(["ANNOUNCE","RESPONSE"]),l=(e,a)=>{var t=JSON.parse(e.toString());return a(t)&&n.has(t.t)&&t.d?.info||null},s=()=>{var e=[];for(var a of Object.values(d.networkInterfaces()))for(var t of a)if(function(){if("IPv4"!==t.family||t.internal)return 1;var a=t.address.split(".").map(Number),p=t.netmask.split(".").map(Number),o=a.map((e,a)=>(e|255&~p[a]).toString()).join(".");e.push({address:t.address,broadcast:o})}())continue;return e},u=({port:e,timeout:a=3e3,idleTimeout:t=0,buildQuery:p,parseMessage:o})=>new Promise((d,r)=>{var n=new Map,l=i.createSocket("udp4"),u=null,m=null,c=!1,f=()=>{if(!c){c=!0,clearTimeout(u),clearTimeout(m);try{l.close()}catch{}d([...n.values()])}};l.on("error",e=>{if(!c){c=!0,clearTimeout(u),clearTimeout(m);try{l.close()}catch{}r(e)}}),l.on("message",(e,a)=>{try{var p=o(e,a);if(!p||n.has(p.key))return;n.set(p.key,p.value),t&&!c&&(clearTimeout(m),m=setTimeout(f,t))}catch{}}),l.bind(()=>{l.setBroadcast(!0);var t=p();for(var o of(()=>{var e=new Set(["255.255.255.255","127.0.0.1"]);for(var a of s())e.add(a.broadcast);return[...e]})())l.send(t,0,t.length,e,o);u=setTimeout(f,a)})}),m=(p=o(function*(e,a=3e3){var t;try{var p=new AbortController;t=setTimeout(()=>p.abort(),a);var o=yield fetch(e,{signal:p.signal});if(!o.ok)return null;return yield o.json()}catch{return null}finally{void 0!==t&&clearTimeout(t)}}),function(e){return p.apply(this,arguments)})},63755(e,a,t){t.d(a,{EC:()=>U,IC:()=>M,UY:()=>I,X9:()=>J,Zd:()=>V,b2:()=>B,bo:()=>P,iF:()=>L,n_:()=>S,ph:()=>q});var p,o,i,d,r,n,l,s,u=t(68832),m=t(99436),c=t(76982),f=t(58611),h=t(35317),v=t(79657),g=t(64007),D=t(47988),y=process.env.BRICKS_OAUTH_DOMAIN||"auth0.bricks.tools",w=process.env.BRICKS_OAUTH_AUDIENCE||"https://display.bricks.tools",b="openid profile email offline_access",_=process.env.BRICKS_OAUTH_CLIENT_ID||"Atyy2gp0suIWE33rj8LtJ0pJpIGHiGaT",C="/callback",F="127.0.0.1",S=()=>!!_,k=(e,a,{signal:t}={})=>(()=>{var e=process.env.HTTPS_PROXY||process.env.https_proxy;if(!e)return v.Ay;var a=new g(e);return(e,t={})=>(0,v.Ay)(e,{...t,agent:a})})()(`https://${y}${e}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(a).toString(),signal:t}),E=(p=m(function*(e){var a;try{a=yield e.json()}catch(e){if(e?.name==="AbortError")throw e;a={}}if(!e.ok){var t=Error(a.error_description||a.error||`HTTP ${e.status}`);throw t.code=a.error,t}return a}),function(e){return p.apply(this,arguments)}),A=(o=m(function*(e,a){var t=new AbortController,p=setTimeout(()=>t.abort(),15e3);try{return yield E((yield k(e,a,{signal:t.signal})))}finally{clearTimeout(p)}}),function(e,a){return o.apply(this,arguments)}),N=e=>String(e).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#39;"),$=({title:e,heading:a,message:t})=>`<!doctype html>
105
105
  <html lang="en">
106
106
  <head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fugood/bricks-cli",
3
- "version": "2.25.5",
3
+ "version": "2.26.0-beta.0",
4
4
  "description": "BRICKS CLI - Command-line interface for BRICKS Workspace API",
5
5
  "keywords": [
6
6
  "bricks",
@@ -55,11 +55,11 @@
55
55
  "@babel/parser": "7.28.5",
56
56
  "@babel/traverse": "7.28.5",
57
57
  "@babel/types": "7.28.5",
58
- "@fugood/bricks-config-core": "^2.25.5",
59
- "@fugood/bricks-core-generated": "^2.25.5",
58
+ "@fugood/bricks-config-core": "^2.26.0-beta.0",
59
+ "@fugood/bricks-core-generated": "^2.26.0-beta.0",
60
60
  "@fugood/bricks-devtools-core": "^2.25.5",
61
61
  "@fugood/bricks-system-properties-definition": "^2.25.3",
62
- "@fugood/property-bank-calc-generated": "^2.25.5",
62
+ "@fugood/property-bank-calc-generated": "^2.26.0-beta.0",
63
63
  "@huggingface/gguf": "^0.3.2",
64
64
  "@iarna/toml": "^3.0.0",
65
65
  "@inquirer/prompts": "^7.0.0",
@@ -90,5 +90,5 @@
90
90
  "engines": {
91
91
  "node": ">=18.0.0"
92
92
  },
93
- "gitHead": "d58ebf08bbac8100493d91a00cf724f3b313de6b"
93
+ "gitHead": "782515bb3d092465f87e28ee6801a11b0e1f53f2"
94
94
  }