@fugood/bricks-cli 2.26.1 → 2.26.2-beta.1
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/1010.js +1 -1
- package/lib/1374.js +1 -1
- package/lib/1708.js +4 -4
- package/lib/2486.js +1 -1
- package/lib/2517.js +7 -7
- package/lib/2678.js +7 -0
- package/lib/3223.js +4 -4
- package/lib/3774.js +3 -3
- package/lib/4456.js +2 -2
- package/lib/6194.js +3 -2
- package/lib/6818.js +1 -1
- package/lib/7294.js +2 -2
- package/lib/7511.js +1 -1
- package/lib/8310.js +3 -0
- package/lib/8412.js +1 -0
- package/lib/907.js +60 -40
- package/lib/9439.js +53 -33
- package/lib/index.js +57 -52
- package/lib/lib.js +101 -81
- package/package.json +5 -5
- package/lib/4642.js +0 -9
package/lib/9439.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const __rspack_esm_id=9439;export const __rspack_esm_ids=[9439];export const __webpack_modules__={4376(e,i){i.k=(e,i,t)=>{let n=i/e;return{deviceBrickWidth:i/n,deviceBrickHeight:t/n,deviceBrickUnit:n}};let t=96;i.Y=(e,i,n=t)=>{let a=e/n;return i>e&&(a=i/n),{deviceBrickWidth:Math.round(e/a),deviceBrickHeight:Math.round(i/a),deviceBrickUnit:a}}},70114(e,i,t){t.r(i),t.d(i,{startStdioServer:()=>np});var n,a,o,r,s,d,c,l,p,u={};t.r(u),t.d(u,{applicationFragment:()=>ef,applicationShortFragment:()=>eD,deviceApplicationStatusFragment:()=>eu,deviceDetailFragment:()=>e_,deviceFragment:()=>em,deviceGroupFragment:()=>eg,deviceShortFragment:()=>ew,instanceVersionFragment:()=>eh,mediaBoxFragment:()=>eC,mediaFileFragment:()=>eT,mediaWorkspaceFragment:()=>eS,moduleFragment:()=>e$,moduleShortFragment:()=>ev,operationFragment:()=>eb,publicApplicationBasicInfoFragment:()=>ey,userFavoriteFragment:()=>eI,workspaceFragment:()=>ek,workspaceShortFragment:()=>eA});var m={};t.r(m),t.d(m,{application:()=>ez,applicationByDevice:()=>eq,applicationReleaseVersion:()=>eP,applicationReleaseVersions:()=>eR,applicationTestsByDevice:()=>ej,applications:()=>eL,checkBindDevicePasscode:()=>eW,deviceUsage:()=>eQ,devices:()=>eX,devicesByGroup:()=>eH,devicesByUniqueId:()=>eV,me:()=>eE,module:()=>eJ,moduleReleaseVersion:()=>eN,moduleReleaseVersions:()=>eF,modules:()=>eU,publicModules:()=>eO,publicModulesByIdList:()=>eM,workspace:()=>eK,workspacePricingPlans:()=>eY,workspaces:()=>eG});var _={};t.r(_),t.d(_,{addUserFavorite:()=>iB,assignGroupPermissions:()=>iS,bindApplication:()=>id,bindApplicationWithDeviceGroup:()=>ip,changeWorkspaceAdditionalLimitSpending:()=>iO,changeWorkspaceSubscriptionPlan:()=>iU,controlDevice:()=>e7,createApplication:()=>ir,createApplicationWithShareVersion:()=>is,createConfigChangeOperation:()=>ik,createDevice:()=>e6,createDeviceGroup:()=>ie,createDeviceGroupWithApp:()=>i_,createModule:()=>i$,createVirtualDevice:()=>e5,createWorkspace:()=>e0,createWorkspaceOTP:()=>iM,dispatchDeviceGroupAction:()=>it,doOperation:()=>iA,duplicateApplication:()=>ig,duplicateModule:()=>ib,forkApplication:()=>iF,moveApplication:()=>im,moveDevice:()=>e9,moveModule:()=>ih,registerFCMNotification:()=>iC,registerRemoteDebug:()=>iT,removeApplication:()=>iy,removeDevice:()=>e8,removeDeviceGroup:()=>ia,removeModule:()=>iI,removeOperation:()=>iw,removeUserFavorite:()=>iE,removeWorkspace:()=>io,revokeWorkspaceOTP:()=>iR,shareAccessToken:()=>ix,shareApplication:()=>iu,toggleShortEditApplication:()=>ic,updateApplication:()=>iP,updateApplicationViewportPreset:()=>il,updateDevice:()=>e2,updateDeviceGroup:()=>ii,updateModule:()=>iv,updateOperation:()=>iD,updateVirtualDevice:()=>e3,updateWorkspace:()=>e1,updateWorkspaceTokens:()=>e4});var g={};t.r(g),t.d(g,{application:()=>iH,applicationByDevice:()=>iY,applications:()=>iV,device:()=>iz,deviceUsage:()=>iX,devices:()=>iL,devicesByApplication:()=>iJ,mediaBox:()=>i0,mediaBoxes:()=>iZ,mediaFile:()=>i4,mediaFiles:()=>i1,mediaWorkspace:()=>iQ,module:()=>iG,modules:()=>iK,workspace:()=>iW});var f={};t.r(f),t.d(f,{bindApplication:()=>i9,copyMediaFiles:()=>ta,createApplication:()=>i6,createModule:()=>i8,deleteMediaBoxFiles:()=>tr,deleteMediaFiles:()=>to,forkApplication:()=>i2,requestFileUpload:()=>te,setMediaFileAsBoxPreview:()=>tn,unbindApplication:()=>i3,updateApplication:()=>i5,updateMediaFile:()=>ti,updateMediaFiles:()=>tt,updateModule:()=>i7});var y={};t.r(y),t.d(y,{mediaBox:()=>tM,mediaBoxes:()=>tU,mediaFile:()=>tP,mediaFiles:()=>tR,mediaWorkspace:()=>tO,mediaWorkspaces:()=>tE});var $={};t.r($),t.d($,{assignGroupPermissions:()=>tz,copyMediaFiles:()=>tG,createMediaBox:()=>tq,createMediaWorkspace:()=>tF,deleteMediaFiles:()=>tK,moveMediaBox:()=>tj,requestFileUpload:()=>tV,setMediaFileAsBoxPreview:()=>tL,updateMediaBox:()=>tW,updateMediaFile:()=>tH,updateMediaFiles:()=>tY,updateMediaWorkspace:()=>tN});var v={};t.r(v),t.d(v,{mediaBox:()=>tX,mediaFile:()=>tZ,mediaFiles:()=>tQ});var h={};t.r(h),t.d(h,{deleteMediaFiles:()=>t6,requestFileUpload:()=>t0,updateMediaFile:()=>t1,updateMediaFiles:()=>t4});var b=t(99436),I=t(42820),k=t(66029),A={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_blueprint:"qbp",write_blueprint:"wbp",query_media_flow:"qmf",write_media_flow:"wmf",access_unstable_feature:"UNSTABLE"},D=Object.entries(A).reduce((e,[i,t])=>(e[t]=i,e),{}),w=["HS256","RS256"],S=["https://auth0.bricks.tools/","https://mybigday.auth0.com/"],C=e=>S.includes(e?.iss),T=t(84867);let x='# 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 B=t(68832),E=t(20181),U=t(79657),O=t(79861),M=t(4376),R=t(46123),P=t(80211),F=t(45907),N=t(99548),q=t(96423),j=P.ajv.getSchema("http://display.bricks.tools/root.schema.json5"),W=(0,q.A)(["subspace_map.*.property_bank_calc_map.*.script_config"]),V=e=>e&&"object"==typeof e?e:{};function H(e){var i=[];try{var t=P(e);i.push(...(0,N.L)({errors:t,schema:j,data:e}).map(({path:e,message:i})=>`${e}: ${i}`));try{i.push(...F(e).map(({field:e,message:i})=>`${e}: ${i}`))}catch(e){i.push(`Component reference validation failed: ${e.message}`)}return W(e).forEach(t=>{var n=t.slice(0,-1),a=R(e,n),o=n.join("."),r=V(a?.map),s=V(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=V(d),m=V(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 Y=t(49741),K=t(63981),G=(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]??G(t,i)])):e,L=G(Y.t),z=Object.entries(Y.systemActions).map(([e,{propertyNameType:i,property:t}])=>` - \`${e}\`: ${L[e]}
|
|
1
|
+
export const __rspack_esm_id=9439;export const __rspack_esm_ids=[9439];export const __webpack_modules__={4376(e,i){i.k=(e,i,t)=>{let n=i/e;return{deviceBrickWidth:i/n,deviceBrickHeight:t/n,deviceBrickUnit:n}};let t=96;i.Y=(e,i,n=t)=>{let a=e/n;return i>e&&(a=i/n),{deviceBrickWidth:Math.round(e/a),deviceBrickHeight:Math.round(i/a),deviceBrickUnit:a}}},70114(e,i,t){t.r(i),t.d(i,{startStdioServer:()=>np});var n,a,o,r,s,d,c,l,p,u={};t.r(u),t.d(u,{applicationFragment:()=>ef,applicationShortFragment:()=>eD,deviceApplicationStatusFragment:()=>eu,deviceDetailFragment:()=>e_,deviceFragment:()=>em,deviceGroupFragment:()=>eg,deviceShortFragment:()=>ew,instanceVersionFragment:()=>eh,mediaBoxFragment:()=>eC,mediaFileFragment:()=>eT,mediaWorkspaceFragment:()=>eS,moduleFragment:()=>e$,moduleShortFragment:()=>ev,operationFragment:()=>eb,publicApplicationBasicInfoFragment:()=>ey,userFavoriteFragment:()=>eI,workspaceFragment:()=>ek,workspaceShortFragment:()=>eA});var m={};t.r(m),t.d(m,{application:()=>ez,applicationByDevice:()=>eN,applicationReleaseVersion:()=>eR,applicationReleaseVersions:()=>eM,applicationTestsByDevice:()=>eq,applications:()=>eG,checkBindDevicePasscode:()=>ej,deviceUsage:()=>eQ,devices:()=>eX,devicesByGroup:()=>eV,devicesByUniqueId:()=>eW,me:()=>eE,module:()=>eJ,moduleReleaseVersion:()=>eF,moduleReleaseVersions:()=>eP,modules:()=>eL,publicModules:()=>eU,publicModulesByIdList:()=>eO,workspace:()=>eY,workspacePricingPlans:()=>eH,workspaces:()=>eK});var _={};t.r(_),t.d(_,{addUserFavorite:()=>iB,assignGroupPermissions:()=>iS,bindApplication:()=>id,bindApplicationWithDeviceGroup:()=>ip,changeWorkspaceAdditionalLimitSpending:()=>iO,changeWorkspaceSubscriptionPlan:()=>iU,controlDevice:()=>e7,createApplication:()=>ir,createApplicationWithShareVersion:()=>is,createConfigChangeOperation:()=>ik,createDevice:()=>e6,createDeviceGroup:()=>ie,createDeviceGroupWithApp:()=>i_,createModule:()=>i$,createVirtualDevice:()=>e2,createWorkspace:()=>e0,createWorkspaceOTP:()=>iM,dispatchDeviceGroupAction:()=>it,doOperation:()=>iA,duplicateApplication:()=>ig,duplicateModule:()=>ib,forkApplication:()=>iF,moveApplication:()=>im,moveDevice:()=>e9,moveModule:()=>ih,registerFCMNotification:()=>iC,registerRemoteDebug:()=>iT,removeApplication:()=>iy,removeDevice:()=>e8,removeDeviceGroup:()=>ia,removeModule:()=>iI,removeOperation:()=>iw,removeUserFavorite:()=>iE,removeWorkspace:()=>io,revokeWorkspaceOTP:()=>iR,shareAccessToken:()=>ix,shareApplication:()=>iu,toggleShortEditApplication:()=>ic,updateApplication:()=>iP,updateApplicationViewportPreset:()=>il,updateDevice:()=>e5,updateDeviceGroup:()=>ii,updateModule:()=>iv,updateOperation:()=>iD,updateVirtualDevice:()=>e3,updateWorkspace:()=>e1,updateWorkspaceTokens:()=>e4});var g={};t.r(g),t.d(g,{application:()=>iH,applicationByDevice:()=>iY,applications:()=>iV,device:()=>iz,deviceUsage:()=>iX,devices:()=>iL,devicesByApplication:()=>iJ,mediaBox:()=>i0,mediaBoxes:()=>iZ,mediaFile:()=>i4,mediaFiles:()=>i1,mediaWorkspace:()=>iQ,module:()=>iG,modules:()=>iK,workspace:()=>iW});var f={};t.r(f),t.d(f,{bindApplication:()=>i9,copyMediaFiles:()=>ta,createApplication:()=>i6,createModule:()=>i8,deleteMediaBoxFiles:()=>tr,deleteMediaFiles:()=>to,forkApplication:()=>i5,requestFileUpload:()=>te,setMediaFileAsBoxPreview:()=>tn,unbindApplication:()=>i3,updateApplication:()=>i2,updateMediaFile:()=>ti,updateMediaFiles:()=>tt,updateModule:()=>i7});var y={};t.r(y),t.d(y,{mediaBox:()=>tM,mediaBoxes:()=>tU,mediaFile:()=>tP,mediaFiles:()=>tR,mediaWorkspace:()=>tO,mediaWorkspaces:()=>tE});var $={};t.r($),t.d($,{assignGroupPermissions:()=>tz,copyMediaFiles:()=>tG,createMediaBox:()=>tq,createMediaWorkspace:()=>tF,deleteMediaFiles:()=>tK,moveMediaBox:()=>tj,requestFileUpload:()=>tV,setMediaFileAsBoxPreview:()=>tL,updateMediaBox:()=>tW,updateMediaFile:()=>tH,updateMediaFiles:()=>tY,updateMediaWorkspace:()=>tN});var v={};t.r(v),t.d(v,{mediaBox:()=>tX,mediaFile:()=>tZ,mediaFiles:()=>tQ});var h={};t.r(h),t.d(h,{deleteMediaFiles:()=>t6,requestFileUpload:()=>t0,updateMediaFile:()=>t1,updateMediaFiles:()=>t4});var b=t(99436),I=t(42820),k=t(66029),A={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_blueprint:"qbp",write_blueprint:"wbp",query_media_flow:"qmf",write_media_flow:"wmf",access_unstable_feature:"UNSTABLE"},D=Object.entries(A).reduce((e,[i,t])=>(e[t]=i,e),{}),w=["HS256","RS256"],S=["https://auth0.bricks.tools/","https://mybigday.auth0.com/"],C=e=>S.includes(e?.iss),T=t(84867);let x='# 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 B=t(68832),E=t(20181),U=t(79657),O=t(79861),M=t(4376),R=t(46123),P=t(80211),F=t(45907),N=t(99548),q=t(96423),j=P.ajv.getSchema("http://display.bricks.tools/root.schema.json5"),W=(0,q.A)(["subspace_map.*.property_bank_calc_map.*.script_config"]),V=e=>e&&"object"==typeof e?e:{};function H(e){var i=[];try{var t=P(e);i.push(...(0,N.L)({errors:t,schema:j,data:e}).map(({path:e,message:i})=>`${e}: ${i}`));try{i.push(...F(e).map(({field:e,message:i})=>`${e}: ${i}`))}catch(e){i.push(`Component reference validation failed: ${e.message}`)}return W(e).forEach(t=>{var n=t.slice(0,-1),a=R(e,n),o=n.join("."),r=V(a?.map),s=V(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=V(d),m=V(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 Y=t(49741),K=t(63981),G=(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]??G(t,i)])):e,L=G(Y.t),z=Object.entries(Y.systemActions).map(([e,{propertyNameType:i,property:t}])=>` - \`${e}\`: ${L[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"),J=Object.keys(K.brickMapping).map(e=>`- \`${e}\``).join("\n"),X=Object.keys(K.generatorMapping).map(e=>`- \`${e}\``).join("\n");let Q=x.replace("[:SYSTEM_ACTIONS:]",z).replace("[:BRICK_IDS:]",J).replace("[:GENERATOR_IDS:]",X);var Z=(e,i={})=>({content:[E.Buffer.isBuffer(e)?{...i,data:e.toString("base64"),type:"image"}:{...i,text:"string"==typeof e?e:JSON.stringify(e,null,2),type:"text"}],isError:!1}),ee=e=>e?.tokenType==="user"||C(e?.tokenInfo),ei=t(44668),et=t(5018),en=t(63315),ea=t(30409),eo=t(40906),er=t(79760),es=t(22268),ed=t(7068),ec=t(26197),el=t(94370);let ep=(0,el.default)`
|
|
4
4
|
fragment workspaceArguments on Workspace {
|
|
@@ -851,59 +851,72 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
851
851
|
query ControllerClient_module($id: ID!) {
|
|
852
852
|
module(id: $id) {
|
|
853
853
|
...moduleArguments
|
|
854
|
+
import_info {
|
|
855
|
+
root_subspace_id
|
|
856
|
+
title
|
|
857
|
+
layout
|
|
858
|
+
exposed_properties
|
|
859
|
+
action_map
|
|
860
|
+
requirements
|
|
861
|
+
requirement_routings
|
|
862
|
+
module
|
|
863
|
+
uses_popup
|
|
864
|
+
}
|
|
854
865
|
}
|
|
855
866
|
}
|
|
856
867
|
${e$}
|
|
857
|
-
|
|
868
|
+
`,(0,el.default)`
|
|
858
869
|
query ControllerClient_modules($workspaceId: ID, $limit: Int) {
|
|
859
870
|
modules(workspaceId: $workspaceId, paginate: { limit: $limit }) {
|
|
860
871
|
...moduleShortArguments
|
|
861
872
|
}
|
|
862
873
|
}
|
|
863
874
|
${ev}
|
|
864
|
-
|
|
875
|
+
`;let eU=(0,el.default)`
|
|
865
876
|
query ControllerClient_publicModules($keyword: String!, $limit: Int) {
|
|
866
877
|
publicModules(keyword: $keyword, paginate: { limit: $limit }) {
|
|
867
878
|
...moduleShortArguments
|
|
868
879
|
}
|
|
869
880
|
}
|
|
870
881
|
${ev}
|
|
871
|
-
`,
|
|
882
|
+
`,eO=(0,el.default)`
|
|
872
883
|
query ControllerClient_publicModulesByIdList($idList: [ID]) {
|
|
873
884
|
publicModulesByIdList(idList: $idList) {
|
|
874
885
|
...moduleShortArguments
|
|
875
886
|
}
|
|
876
887
|
}
|
|
877
888
|
${ev}
|
|
878
|
-
`,
|
|
889
|
+
`,eM=(0,el.default)`
|
|
879
890
|
query ControllerClient_applicationReleaseVersions($id: ID!) {
|
|
880
891
|
applicationReleaseVersions(id: $id) {
|
|
881
892
|
...instanceVersionArguments
|
|
882
893
|
}
|
|
883
894
|
}
|
|
884
895
|
${eh}
|
|
885
|
-
`,
|
|
896
|
+
`,eR=(0,el.default)`
|
|
886
897
|
query ControllerClient_applicationReleaseVersion($id: ID!, $versionId: ID!) {
|
|
887
898
|
applicationReleaseVersion(id: $id, versionId: $versionId) {
|
|
888
899
|
...applicationReleaseVersionArguments
|
|
889
900
|
}
|
|
890
901
|
}
|
|
891
902
|
${eh}
|
|
892
|
-
`,
|
|
903
|
+
`,eP=(0,el.default)`
|
|
893
904
|
query ControllerClient_moduleReleaseVersions($id: ID!) {
|
|
894
905
|
moduleReleaseVersions(id: $id) {
|
|
895
906
|
...instanceVersionArguments
|
|
907
|
+
uses_popup
|
|
896
908
|
}
|
|
897
909
|
}
|
|
898
910
|
${eh}
|
|
899
|
-
`,
|
|
911
|
+
`,eF=(0,el.default)`
|
|
900
912
|
query ControllerClient_moduleReleaseVersion($id: ID!, $versionId: ID!) {
|
|
901
913
|
moduleReleaseVersion(id: $id, versionId: $versionId) {
|
|
902
914
|
...instanceVersionArguments
|
|
915
|
+
uses_popup
|
|
903
916
|
}
|
|
904
917
|
}
|
|
905
918
|
${eh}
|
|
906
|
-
`,
|
|
919
|
+
`,eN=(0,el.default)`
|
|
907
920
|
query ControllerClient_applicationByDevice(
|
|
908
921
|
$deviceId: ID!
|
|
909
922
|
$debug: Boolean
|
|
@@ -921,7 +934,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
921
934
|
}
|
|
922
935
|
}
|
|
923
936
|
${ef}
|
|
924
|
-
`,
|
|
937
|
+
`,eq=(0,el.default)`
|
|
925
938
|
query ControllerClient_applicationTestsByDevice($deviceId: ID!) {
|
|
926
939
|
applicationTestsByDevice: applicationByDevice(
|
|
927
940
|
deviceId: $deviceId
|
|
@@ -934,18 +947,18 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
934
947
|
config_tests
|
|
935
948
|
}
|
|
936
949
|
}
|
|
937
|
-
`,
|
|
950
|
+
`,ej=(0,el.default)`
|
|
938
951
|
query ControllerClient_checkBindDevicePasscode($passcode: String!) {
|
|
939
952
|
checkBindDevicePasscode(passcode: $passcode)
|
|
940
953
|
}
|
|
941
|
-
`,
|
|
954
|
+
`,eW=(0,el.default)`
|
|
942
955
|
query ControllerClient_devicesByUniqueId($uniqueID: String!, $unbindApplication: Boolean) {
|
|
943
956
|
devicesByUniqueId(uniqueID: $uniqueID, unbindApplication: $unbindApplication) {
|
|
944
957
|
...deviceArguments
|
|
945
958
|
}
|
|
946
959
|
}
|
|
947
960
|
${em}
|
|
948
|
-
`,
|
|
961
|
+
`,eV=(0,el.default)`
|
|
949
962
|
query ControllerClient_devicesByGroup($id: ID!) {
|
|
950
963
|
devicesByGroup(id: $id) {
|
|
951
964
|
device {
|
|
@@ -996,31 +1009,38 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
996
1009
|
target_name
|
|
997
1010
|
}
|
|
998
1011
|
}
|
|
999
|
-
`,
|
|
1012
|
+
`,eH=(0,el.default)`
|
|
1000
1013
|
query ControllerClient_workspacePricingPlans {
|
|
1001
1014
|
workspacePricingPlans
|
|
1002
1015
|
}
|
|
1003
|
-
`;var
|
|
1016
|
+
`;var eY=(0,el.default)`
|
|
1004
1017
|
query User_workspace($id: ID!) {
|
|
1005
1018
|
workspace(id: $id) {
|
|
1006
1019
|
...mcpWorkspaceArguments
|
|
1007
1020
|
}
|
|
1008
1021
|
}
|
|
1009
1022
|
${ek}
|
|
1010
|
-
`,
|
|
1023
|
+
`,eK=(0,el.default)`
|
|
1011
1024
|
query User_workspaces($paginate: Paginate) {
|
|
1012
1025
|
workspaces(paginate: $paginate) {
|
|
1013
1026
|
...mcpWorkspaceShortArguments
|
|
1014
1027
|
}
|
|
1015
1028
|
}
|
|
1016
1029
|
${eA}
|
|
1017
|
-
`,
|
|
1018
|
-
query User_applications {
|
|
1019
|
-
applications {
|
|
1030
|
+
`,eG=(0,el.default)`
|
|
1031
|
+
query User_applications($workspaceId: ID, $paginate: Paginate) {
|
|
1032
|
+
applications(workspaceId: $workspaceId, paginate: $paginate) {
|
|
1020
1033
|
...mcpApplicationShortArguments
|
|
1021
1034
|
}
|
|
1022
1035
|
}
|
|
1023
1036
|
${eD}
|
|
1037
|
+
`,eL=(0,el.default)`
|
|
1038
|
+
query User_modules($workspaceId: ID, $paginate: Paginate) {
|
|
1039
|
+
modules(workspaceId: $workspaceId, paginate: $paginate) {
|
|
1040
|
+
...moduleShortArguments
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
${ev}
|
|
1024
1044
|
`,ez=(0,el.default)`
|
|
1025
1045
|
query User_application($id: ID!) {
|
|
1026
1046
|
application(id: $id) {
|
|
@@ -1038,8 +1058,8 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
1038
1058
|
}
|
|
1039
1059
|
${e$}
|
|
1040
1060
|
`,eX=(0,el.default)`
|
|
1041
|
-
query User_devices {
|
|
1042
|
-
devices {
|
|
1061
|
+
query User_devices($workspaceId: ID, $paginate: Paginate) {
|
|
1062
|
+
devices(workspaceId: $workspaceId, paginate: $paginate) {
|
|
1043
1063
|
...mcpDeviceShortArguments
|
|
1044
1064
|
}
|
|
1045
1065
|
}
|
|
@@ -1139,7 +1159,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
1139
1159
|
}
|
|
1140
1160
|
}
|
|
1141
1161
|
${em}
|
|
1142
|
-
`),
|
|
1162
|
+
`),e2=eZ((0,el.default)`
|
|
1143
1163
|
mutation ControllerClient_createVirtualDevice(
|
|
1144
1164
|
$workspaceId: ID
|
|
1145
1165
|
$name: String
|
|
@@ -1156,7 +1176,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
1156
1176
|
}
|
|
1157
1177
|
}
|
|
1158
1178
|
${em}
|
|
1159
|
-
`),
|
|
1179
|
+
`),e5=eZ((0,el.default)`
|
|
1160
1180
|
mutation ControllerClient_updateDevice(
|
|
1161
1181
|
$id: ID!
|
|
1162
1182
|
$name: String
|
|
@@ -1913,7 +1933,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
1913
1933
|
}
|
|
1914
1934
|
}
|
|
1915
1935
|
${eD}
|
|
1916
|
-
`,
|
|
1936
|
+
`,i2=(0,el.default)`
|
|
1917
1937
|
mutation Workspace_updateApplication(
|
|
1918
1938
|
$id: ID!
|
|
1919
1939
|
$config: String
|
|
@@ -1937,7 +1957,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
1937
1957
|
}
|
|
1938
1958
|
}
|
|
1939
1959
|
${eD}
|
|
1940
|
-
`,
|
|
1960
|
+
`,i5=(0,el.default)`
|
|
1941
1961
|
mutation Workspace_forkApplication($id: ID!) {
|
|
1942
1962
|
forkApplication(id: $id) {
|
|
1943
1963
|
...mcpApplicationShortArguments
|
|
@@ -1972,7 +1992,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
1972
1992
|
}
|
|
1973
1993
|
`,i3=(0,el.default)`
|
|
1974
1994
|
mutation Workspace_unbindApplication($id: ID!, $unbindDevices: [ID]) {
|
|
1975
|
-
bindApplication(id: $id, unbindDevices: $unbindDevices) {
|
|
1995
|
+
unbindApplication: bindApplication(id: $id, unbindDevices: $unbindDevices) {
|
|
1976
1996
|
_id
|
|
1977
1997
|
devices {
|
|
1978
1998
|
device_id
|
|
@@ -2036,7 +2056,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
2036
2056
|
$userTags: [String]
|
|
2037
2057
|
$meta: RequestUploadMetaInput!
|
|
2038
2058
|
) {
|
|
2039
|
-
createMediaFileUploadRequest(
|
|
2059
|
+
requestFileUpload: createMediaFileUploadRequest(
|
|
2040
2060
|
name: $name
|
|
2041
2061
|
description: $description
|
|
2042
2062
|
boxId: $boxId
|
|
@@ -2388,8 +2408,8 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
2388
2408
|
`,tH=(0,el.default)`
|
|
2389
2409
|
mutation MediaClient_updateMediaFile(
|
|
2390
2410
|
$fileId: UUID!
|
|
2391
|
-
$name: String
|
|
2392
|
-
$description: String
|
|
2411
|
+
$name: String
|
|
2412
|
+
$description: String
|
|
2393
2413
|
$userTags: [String!]
|
|
2394
2414
|
$requestUploadAgain: Boolean!
|
|
2395
2415
|
) {
|
|
@@ -2559,7 +2579,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
2559
2579
|
mutation MediaClient_deleteMediaFiles($boxId: UUID!, $passcode: String!, $list: [UUID!]!) {
|
|
2560
2580
|
deleteMediaFiles(boxId: $boxId, passcode: $passcode, list: $list)
|
|
2561
2581
|
}
|
|
2562
|
-
`,
|
|
2582
|
+
`,t2=(0,el.default)`
|
|
2563
2583
|
subscription MediaClient_listenBoxChanged(
|
|
2564
2584
|
$boxId: UUID!
|
|
2565
2585
|
$passcode: String!
|
|
@@ -2578,7 +2598,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
2578
2598
|
}
|
|
2579
2599
|
}
|
|
2580
2600
|
${tx}
|
|
2581
|
-
`,
|
|
2601
|
+
`,t5=e=>({data:i,errors:t})=>{var n;let a=(n=!i?.mediaBoxChanged&&"Missing mediaBoxChanged payload",t?.length?Error(t.map(e=>e.message).join("\n")):n?Error(n):null);return a?e(a):e(null,i.mediaBoxChanged)};var t9=t(67996),t3=["authorization"],t8=`
|
|
2582
2602
|
query AL_events($filter: EventsFilter!) {
|
|
2583
2603
|
events(filter: $filter) {
|
|
2584
2604
|
device_id
|
|
@@ -2596,7 +2616,7 @@ ${((e,i)=>{switch(e){case"defined_properties":return Object.entries(i).map(([e,i
|
|
|
2596
2616
|
timestamp
|
|
2597
2617
|
}
|
|
2598
2618
|
}
|
|
2599
|
-
`,ne=ei(function e(i,t){var n;et(this,e),this.baseUrl=i,this.auth="string"==typeof t?{token:t,getHeaders:(n=b(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=b(function*(){var e=yield this.auth.getHeaders();return{Authorization:e.authorization,...t9(e,t3)}}),function(){return o.apply(this,arguments)})},{key:"graphql",value:(r=b(function*(e,i){var t=yield(0,U.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=b(function*(e,{limit:i,offset:t}={}){var n={...e};return null!=i&&(n.limit=i),null!=t&&(n.offset=t),(yield this.graphql(t8,{filter:n})).events}),function(e){return s.apply(this,arguments)})},{key:"screenshots",value:(d=b(function*(e){return(yield this.graphql(t7,{filter:e})).screenshots}),function(e){return d.apply(this,arguments)})},{key:"downloadScreenshot",value:(c=b(function*(e,i,t){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(i)}/screenshot?ts=${encodeURIComponent(t)}`,a=yield(0,U.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 ni(e,i,t){switch(t){case"user":return new iq(e,i);case"workspace":return new tu(e,i);default:throw Error(`Invalid token type: ${t}.`)}}process.env.STAGE,process.env.URL_BASE;var nt="bricks-mcp",nn={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 na=t(1639);let no=({type:e,title:i,template_key:t})=>{var n,a,o=(0,na.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=G(K.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,na.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=G(K.dK.Basic),d=G(K.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=G(K.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(K.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,na.M4)("property_bank_command"),u=(0,na.M4)("property_bank_command"),m=(0,na.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 Z({id:o,example:n,extraInfo:a})};var nr={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},ns=(l=b(function*(e,i){var t=new AbortController,n=setTimeout(()=>t.abort(),15e3);try{var a=yield(0,U.Ay)(e,{agent:i,size:0x6400000,signal:t.signal});if(!a.ok)throw Error(`source_url responded with HTTP ${a.status}`);var 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),t.abort()}}),function(e,i){return l.apply(this,arguments)}),nd="The `bricks_project_last_commit_id` returned when you read it. The server refuses the write if someone saved in between, instead of overwriting their change.",nc=(p=b(function*(e,i){try{return yield i()}catch(i){if(!/config conflict: lastCommitId mismatch/.test(i?.message))throw i;throw Error(`${i.message} Someone else saved after you read it. Call ${e} again, apply your change to the config it returns, and retry with its bricks_project_last_commit_id as last_commit_id.`)}}),function(e,i){return p.apply(this,arguments)}),nl="2.26.1";function np(){return nu.apply(this,arguments)}function nu(){return(nu=b(function*(e={}){var i,t,n=e.baseUrl||nn.bricks,a=e.activityLogBaseUrl||nn.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,t,n=new Headers(e.headers||{}).get("authorization");if(null!==n?(i=n.match(/^(?:Bearer +)?([^\s]+)$/i)?.[1])&&!/^Bearer +/i.test(n)&&(t="raw_header"):(i=e.queryStringParameters?.token)&&(t="query"),t&&console.warn(JSON.stringify({event:"legacy_token_transport",transport:t})),!i)return{success:!1,message:"Authentication failed: No bearer token provided",...null!==n?{error:"invalid_token"}:{}};var a=function(e){try{var i=e.split(".");if(i.length<3)return null;var t=JSON.parse(Buffer.from(i[0],"base64url").toString());if(!w.includes(t?.alg))return null;var n=JSON.parse(Buffer.from(i[1],"base64url").toString());return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch{return null}}(i);if(!a)return{success:!1,message:"Authentication failed: Invalid token",error:"invalid_token"};if(void 0!==a.exp&&(!Number.isFinite(a.exp)||Date.now()/1e3>=a.exp+30))return{success:!1,message:"Authentication failed: Expired or invalid token expiry",error:"invalid_token"};var o=C(a)?"user":"workspace";if("workspace"===o){var r=Array.isArray(a.t)?a.t:[];a.permissions=r.reduce((e,i)=>{var t=D[i];return t&&e.push(t),e},[])}else a.permissions=Object.keys(A);return{success:!0,token:i,tokenInfo:a,tokenType:o}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}({headers:{Authorization:`Bearer ${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 I._({name:nt,version:nl});if(e.getAuthHeaders&&s){var u={token:r,getHeaders:e.getAuthHeaders};t={...c,tokenType:"workspace",tokenInfo:{...c.tokenInfo,w_id:s,permissions:Object.keys(A)},auth:u,client:ni(n,u,"workspace")}}else t={...c,client:ni(n,c.token,c.tokenType)};p.prompt("getting-started","Getting started with BRICKS",{},b(function*(){return{messages:[{role:"user",content:{type:"text",text:`Welcome to BRICKS — start here.
|
|
2619
|
+
`,ne=ei(function e(i,t){var n;et(this,e),this.baseUrl=i,this.auth="string"==typeof t?{token:t,getHeaders:(n=b(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=b(function*(){var e=yield this.auth.getHeaders();return{Authorization:e.authorization,...t9(e,t3)}}),function(){return o.apply(this,arguments)})},{key:"graphql",value:(r=b(function*(e,i){var t=yield(0,U.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=b(function*(e,{limit:i,offset:t}={}){var n={...e};return null!=i&&(n.limit=i),null!=t&&(n.offset=t),(yield this.graphql(t8,{filter:n})).events}),function(e){return s.apply(this,arguments)})},{key:"screenshots",value:(d=b(function*(e){return(yield this.graphql(t7,{filter:e})).screenshots}),function(e){return d.apply(this,arguments)})},{key:"downloadScreenshot",value:(c=b(function*(e,i,t){var n=`${this.baseUrl}/api/v1/${encodeURIComponent(e)}/${encodeURIComponent(i)}/screenshot?ts=${encodeURIComponent(t)}`,a=yield(0,U.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 ni(e,i,t){switch(t){case"user":return new iq(e,i);case"workspace":return new tu(e,i);default:throw Error(`Invalid token type: ${t}.`)}}process.env.STAGE,process.env.URL_BASE;var nt="bricks-mcp",nn={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 na=t(1639);let no=({type:e,title:i,template_key:t})=>{var n,a,o=(0,na.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=G(K.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,na.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=G(K.dK.Basic),d=G(K.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=G(K.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(K.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,na.M4)("property_bank_command"),u=(0,na.M4)("property_bank_command"),m=(0,na.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 Z({id:o,example:n,extraInfo:a})};var nr={readOnlyHint:!0,destructiveHint:!1,idempotentHint:!0,openWorldHint:!1},ns=(l=b(function*(e,i){var t=new AbortController,n=setTimeout(()=>t.abort(),15e3);try{var a=yield(0,U.Ay)(e,{agent:i,size:0x6400000,signal:t.signal});if(!a.ok)throw Error(`source_url responded with HTTP ${a.status}`);var 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),t.abort()}}),function(e,i){return l.apply(this,arguments)}),nd="The `bricks_project_last_commit_id` returned when you read it. The server refuses the write if someone saved in between, instead of overwriting their change.",nc=(p=b(function*(e,i){try{return yield i()}catch(i){if(!/config conflict: lastCommitId mismatch/.test(i?.message))throw i;throw Error(`${i.message} Someone else saved after you read it. Call ${e} again, apply your change to the config it returns, and retry with its bricks_project_last_commit_id as last_commit_id.`)}}),function(e,i){return p.apply(this,arguments)}),nl="2.26.2-beta.1";function np(){return nu.apply(this,arguments)}function nu(){return(nu=b(function*(e={}){var i,t,n=e.baseUrl||nn.bricks,a=e.activityLogBaseUrl||nn.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,t,n=new Headers(e.headers||{}).get("authorization");if(null!==n?(i=n.match(/^(?:Bearer +)?([^\s]+)$/i)?.[1])&&!/^Bearer +/i.test(n)&&(t="raw_header"):(i=e.queryStringParameters?.token)&&(t="query"),t&&console.warn(JSON.stringify({event:"legacy_token_transport",transport:t})),!i)return{success:!1,message:"Authentication failed: No bearer token provided",...null!==n?{error:"invalid_token"}:{}};var a=function(e){try{var i=e.split(".");if(i.length<3)return null;var t=JSON.parse(Buffer.from(i[0],"base64url").toString());if(!w.includes(t?.alg))return null;var n=JSON.parse(Buffer.from(i[1],"base64url").toString());return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch{return null}}(i);if(!a)return{success:!1,message:"Authentication failed: Invalid token",error:"invalid_token"};if(void 0!==a.exp&&(!Number.isFinite(a.exp)||Date.now()/1e3>=a.exp+30))return{success:!1,message:"Authentication failed: Expired or invalid token expiry",error:"invalid_token"};var o=C(a)?"user":"workspace";if("workspace"===o){var r=Array.isArray(a.t)?a.t:[];a.permissions=r.reduce((e,i)=>{var t=D[i];return t&&e.push(t),e},[])}else a.permissions=Object.keys(A);return{success:!0,token:i,tokenInfo:a,tokenType:o}}catch(e){return{success:!1,message:`Authentication failed: ${e.message}`}}}({headers:{Authorization:`Bearer ${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 I._({name:nt,version:nl});if(e.getAuthHeaders&&s){var u={token:r,getHeaders:e.getAuthHeaders};t={...c,tokenType:"workspace",tokenInfo:{...c.tokenInfo,w_id:s,permissions:Object.keys(A)},auth:u,client:ni(n,u,"workspace")}}else t={...c,client:ni(n,c.token,c.tokenType)};p.prompt("getting-started","Getting started with BRICKS",{},b(function*(){return{messages:[{role:"user",content:{type:"text",text:`Welcome to BRICKS — start here.
|
|
2600
2620
|
|
|
2601
2621
|
Before doing any complex work (application design, deployments, etc.),
|
|
2602
2622
|
always consult the official docs rather than guessing.
|
|
@@ -2667,4 +2687,4 @@ What I'll produce first:
|
|
|
2667
2687
|
- Short recap of requirements
|
|
2668
2688
|
- Clarifying questions (only what's necessary)
|
|
2669
2689
|
- High-level architecture plan
|
|
2670
|
-
- 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"},b(function*(){return{contents:[{uri:"file://docs/getting-started.md",mimeType:"text/markdown",text:x}]}})),function(e,i,{activityLogBaseUrl:t=nn.activityLog}={}){var n,a="user"===i.tokenType,o=ee(i),r=((e,i=null)=>({name:t,description:n,inputSchema:a,annotations:o,permission:r,workspaceTokenOnly:s=!1},d)=>{!(s&&ee(i))&&(!r||i.tokenInfo.permissions?.includes(r)||0)&&e.tool(t,n,a,o,d)})(e,i),s=e=>({...e,...a?{workspace_id:T.Yj().describe("Workspace ID")}:{}}),d=i.client,c=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={};o&&(u.origin=o),n&&a||(u.authorization=`Bearer ${t}`);let m=new th.z({uri:e,headers:u});if(r){let e,t,n;l=(0,tI.UU)({url:i,lazy:!0,connectionParams:u,retryAttempts:1/0,shouldRetry:()=>!0,keepAlive:1e4,on:{error:e=>{n(),d?.(e)},opened:i=>{d?.(),e=i,n()},ping:i=>{i||(n(),t=setTimeout(()=>{e&&e.readyState===WebSocket.OPEN&&e.close(4205,"Client Restart")},5e3))},pong:e=>{e&&n()},closed:n=()=>{t&&(clearTimeout(t),t=void 0)}}}),p=new tb.c(l)}let _=ty.C.from([(0,tk.S)(({networkError:e,operation:i})=>{if(e){let t;if(c(e,i),!1===i.getContext().suppressExpectedErrors)return;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 t$.c(e=>e.complete())}}),s&&new tv.z({attempts:{max:3,retryIf:e=>(function(e,{nonRetryableResponseStatusCodes:i=tg,nonRetryableStatusCodes:t=tf}={}){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:tS})}}),new(tD())(3e4),r?ty.C.split(({query:e})=>{let{kind:i,operation:t}=(0,tw.Vn)(e);return"OperationDefinition"===i&&"subscription"===t},p,m):m].filter(Boolean));return _.closeSubscriptionClient=()=>r&&l.dispose().catch(e=>{if(1e3!==e.code)throw e}),_}({endpointURL:u,subscriptionEndpointURL:u.replace(/^http/,"ws"),accessToken:i,enableSubscription:!p&&a,enableRetry:o,subscriptionOnConnectionOrError:r,onNetworkError:s}),c=new ed.D,(l=new es.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=v,i.mutations=h;let t={boxId:e.boxId,passcode:e.passcode};Object.entries(v).forEach(t_(i,"query",t)),Object.entries(h).forEach(t_(i,"mutation",t)),i.listenBoxChanged=(e,n)=>i.subscribe({query:t5,variables:{...t,...e}}).subscribe({next:t2(n),error(e){n(e)}})}else i.accessToken=e.accessToken,i.type="token",i.queries=y,i.mutations=$,Object.entries(y).forEach(t_(i,"query")),Object.entries($).forEach(t_(i,"mutation")),i.listenBoxChanged=(e,t)=>i.subscribe({query:tJ,variables:e}).subscribe({next:t2(t),error(e){t(e)}});return i})({endpoint:i,accessToken:t,enableSubscription:!1,enableRetry:!0})}({endpoint:nn.media,accessToken:i.token}):d,l=e=>a?{fileId:e}:{id:e},p=e=>a?{list:e}:{fileIds:e},u=e=>e.toUpperCase(),m=e=>e?.map(u);if(a&&e.tool("list_workspaces","List all workspaces",{},nr,b(function*(){return Z((yield d.workspaces()))})),r({name:"get_workspace_overview",annotations:nr,description:"Get comprehensive overview of the BRICKS workspace including stats and summary",inputSchema:s({}),permission:"info"},(_=b(function*({workspace_id:e}){var i=B((yield Promise.all([d.workspace({id:e}),d.applications({workspaceId:e,paginate:{limit:50,offset:0}}),d.modules({workspaceId:e,paginate:{limit:50,offset:0}}),d.devices({workspaceId:e,paginate:{limit:50,offset:0}}),a?c.mediaWorkspace({workspaceId:e}).catch(()=>null):c.mediaWorkspace().catch(()=>null),a?c.mediaBoxes({workspaceId:e}).catch(()=>[]):c.mediaBoxes().catch(()=>[])])),6),t=i[0],n=i[1],o=i[2],r=i[3],s=i[4],l=i[5];if(!t)throw Error("Authentication failed, please check your token");return Z({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:!!s,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:s?{workspace_id:s.id,name:s.name,size_used:s.size,size_limit:s.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 _.apply(this,arguments)})),r({name:"get_applications",annotations:nr,description:"List all applications in the workspace",inputSchema:s({limit:T.ai().describe("Maximum number of applications to return").optional().default(50),offset:T.ai().describe("Number of applications to skip").optional().default(0)}),permission:"query_application"},(g=b(function*({workspace_id:e,limit:i=50,offset:t=0}){return Z((yield d.applications({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return g.apply(this,arguments)})),r({name:"get_application",annotations:nr,description:"Get detailed info and config of a specific application. `bricks_project_last_commit_id` is the config revision to pass to update_application_config, and `dev_ref.is_dev` tells whether the application is a dev fork.",inputSchema:s({id:T.Yj().describe("Application ID")}),permission:"query_application"},(f=b(function*({workspace_id:e,id:i}){return Z((yield d.application({workspaceId:e,id:i})))}),function(e){return f.apply(this,arguments)})),r({name:"get_modules",annotations:nr,description:"List all modules in the workspace",inputSchema:s({limit:T.ai().describe("Maximum number of modules to return").optional().default(50),offset:T.ai().describe("Number of modules to skip").optional().default(0)}),permission:"query_module"},(I=b(function*({workspace_id:e,limit:i=50,offset:t=0}){return Z((yield d.modules({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return I.apply(this,arguments)})),r({name:"get_module",annotations:nr,description:"Get detailed info and config of a specific module. `bricks_project_last_commit_id` is the config revision to pass to update_module_config.",inputSchema:s({id:T.Yj().describe("Module ID")}),permission:"query_module"},(k=b(function*({workspace_id:e,id:i}){return Z((yield d.module({workspaceId:e,id:i})))}),function(e){return k.apply(this,arguments)})),r({name:"update_module_info",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Update a specific module info",inputSchema:s({id:T.Yj().describe("Module ID"),name:T.Yj().describe("Module name"),description:T.Yj().describe("Module description")}),permission:"update_module"},(A=b(function*({workspace_id:e,id:i,name:t,description:n}){return Z((yield d.updateModule({workspaceId:e,id:i,name:t,description:n})))}),function(e){return A.apply(this,arguments)})),r({name:"update_module_config",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},description:"Update a specific module configuration. Applications that use the module get the change at once.",inputSchema:s({id:T.Yj().describe("Module ID"),config:T.Ik({}).passthrough().describe("New configuration object, see file://docs/config-schema.md for schema reference"),last_commit_id:T.Yj().optional().describe(nd)}),permission:"update_module",workspaceTokenOnly:!0},(D=b(function*({workspace_id:e,id:i,config:t,last_commit_id:n}){var a=yield H(t);if(!a.valid)throw Error(`Config validation failed: ${a.errors.join(", ")}`);return Z((yield nc("get_module",()=>d.updateModule({workspaceId:e,id:i,config:JSON.stringify(t),validateConfig:!0,lastCommitId:n}))))}),function(e){return D.apply(this,arguments)})),r({name:"get_devices",annotations:nr,description:"List all devices in the workspace",inputSchema:s({limit:T.ai().describe("Maximum number of devices to return").optional().default(50),offset:T.ai().describe("Number of devices to skip").optional().default(0)}),permission:"query_device"},(w=b(function*({workspace_id:e,limit:i=50,offset:t=0}){return Z((yield d.devices({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return w.apply(this,arguments)})),r({name:"create_application",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Create a new BRICKS application with default grid layout",inputSchema:s({name:T.Yj().describe("Application name"),description:T.Yj().describe("Application description").optional(),grid_width:T.ai().describe("Grid width in units").optional().default(96),grid_height:T.ai().describe("Grid height in units").optional().default(54)}),permission:"create_application"},(S=b(function*({workspace_id:e,name:i,description:t,grid_width:n,grid_height:a}){return Z((yield d.createApplication({workspaceId:e,name:i,description:t,gridWidth:n,gridHeight:a})))}),function(e){return S.apply(this,arguments)})),r({name:"update_application_info",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Update application info",inputSchema:{id:T.Yj().describe("Application ID"),name:T.Yj().describe("Application name"),description:T.Yj().describe("Application description")},permission:"update_application"},(C=b(function*({id:e,name:i,description:t}){return Z((yield d.updateApplication({id:e,name:i,description:t})))}),function(e){return C.apply(this,arguments)})),r({name:"fork_application",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Create a dev fork of an application: a copy with no bound devices. Changes to the fork do not reach the devices of the original application.",inputSchema:{id:T.Yj().describe("ID of the application to fork (not a dev fork itself)")},permission:"create_application"},(x=b(function*({id:e}){return Z((yield d.forkApplication({id:e})))}),function(e){return x.apply(this,arguments)})),r({name:"update_application_config",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},description:o?"Update the configuration of a dev fork application with validation. Only a dev fork (see fork_application) can be written in an OAuth session; publishing the fork to the original application is done by a person in BRICKS Controller.":"Update application configuration with validation. Devices bound to the application get the change at once.",inputSchema:{id:T.Yj().describe("Application ID"),config:T.Ik({}).passthrough().describe("New application configuration. Please read `getting-started` for BRICKS concepts before changing"),last_commit_id:T.Yj().optional().describe(nd)},permission:"update_application"},(R=b(function*({id:e,config:i,last_commit_id:t}){if(o){var n=yield d.application({id:e});if(!n?.dev_ref?.is_dev)throw Error(`Application ${e} is not a dev fork. An OAuth session cannot change an application that may run on devices. Call fork_application, then update the fork.`)}var a=yield H(i);if(!a.valid)throw Error(`Config validation failed: ${a.errors.join(", ")}`);return Z((yield nc("get_application",()=>d.updateApplication({id:e,config:JSON.stringify(i),validateConfig:!0,lastCommitId:t}))))}),function(e){return R.apply(this,arguments)})),r({name:"bind_application",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},description:"Bind application to device with viewport configuration",inputSchema:{app_id:T.Yj().describe("Application ID"),viewports:T.YO(T.Ik({device_id:T.Yj().describe("Device ID"),x:T.ai().describe("X coordinate"),y:T.ai().describe("Y coordinate"),width:T.ai().describe("Width"),height:T.ai().describe("Height"),rotate:T.ai().describe("Rotation"),rotateType:T.Yj().describe("Rotation type")})).describe("Viewport configuration")},permission:"bind_application",workspaceTokenOnly:!0},(P=b(function*({app_id:e,viewports:i}){return Z((yield d.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 P.apply(this,arguments)})),r({name:"unbind_application",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},description:"Unbind application from device",inputSchema:{app_id:T.Yj().describe("Application ID"),device_id:T.Yj().describe("Device ID")},permission:"bind_application",workspaceTokenOnly:!0},(F=b(function*({app_id:e,device_id:i}){return Z((yield d.bindApplication({id:e,unbindDevices:[i]})))}),function(e){return F.apply(this,arguments)})),a&&r({name:"list_media_workspaces",annotations:nr,description:"List all media workspaces",inputSchema:{},permission:"query_media_flow"},b(function*(){return Z((yield c.mediaWorkspaces()))})),r({name:"get_media_workspace",annotations:nr,description:"Get media workspace information and status",inputSchema:s({}),permission:"query_media_flow"},(N=b(function*({workspace_id:e}){return Z((yield c.mediaWorkspace({workspaceId:e})))}),function(e){return N.apply(this,arguments)})),r({name:"list_media_boxes",annotations:nr,description:"List all media boxes in the workspace",inputSchema:s({}),permission:"query_media_flow"},(q=b(function*({workspace_id:e}){return Z((yield c.mediaBoxes({workspaceId:e})))}),function(e){return q.apply(this,arguments)})),r({name:"get_media_box",annotations:nr,description:"Get detailed information about a specific media box",inputSchema:{box_id:T.Yj().describe("Media box ID")},permission:"query_media_flow"},(j=b(function*({box_id:e}){return Z((yield c.mediaBox({boxId:e})))}),function(e){return j.apply(this,arguments)})),r({name:"list_media_files",annotations:nr,description:"List media files in a specific box with filtering options",inputSchema:{box_id:T.Yj().describe("Media box ID"),include_types:T.YO(T.Yj()).optional().describe('Filter by file types (e.g., ["image", "video", "audio"])'),user_tags:T.YO(T.Yj()).optional().describe("Filter by user tags"),limit:T.ai().optional().default(50).describe("Maximum number of files to return"),offset:T.ai().optional().default(0).describe("Number of files to skip")},permission:"query_media_flow"},(W=b(function*({box_id:e,include_types:i,user_tags:t,limit:n,offset:a}){return Z((yield c.mediaFiles({boxId:e,includeTypes:m(i),userTags:t,limit:n,offset:a})))}),function(e){return W.apply(this,arguments)})),r({name:"get_media_file_meta",annotations:nr,description:"Get detailed information about a specific media file",inputSchema:{file_id:T.Yj().describe("Media file ID")},permission:"query_media_flow"},(V=b(function*({file_id:e}){return Z((yield c.mediaFile(l(e))))}),function(e){return V.apply(this,arguments)})),r({name:"media_box_upload",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},description:"Upload a file to a media box from URL or base64 data",inputSchema:{box_id:T.Yj().describe("Target media box ID"),name:T.Yj().describe("File name"),description:T.Yj().optional().default("").describe("File description"),file_type:T.k5(["image","video","audio","file"]).describe("File type"),source_url:T.Yj().optional().describe("URL to download the file from (maximum 100 MiB)"),base64_data:T.Yj().optional().describe("Base64 encoded file data"),user_tags:T.YO(T.Yj()).optional().default([]).describe("User-defined tags for the file")},permission:"write_media_flow"},(Y=b(function*({box_id:e,name:i,description:t,source_url:n,base64_data:a,file_type:o,user_tags:r}){if(!n&&!a)throw Error("Either source_url or base64_data must be provided");if(n&&a)throw Error("Provide either source_url OR base64_data, not both");var s,d="application/octet-stream";if(n){var l=yield ns(n,(0,O.fJ)(n));s=l.data,d=l.contentType}else s=new Blob([E.Buffer.from(a,"base64")],{type:d});var p=yield c.requestFileUpload({name:i,description:t,boxId:e,fileType:u(o),contentType:d,userTags:r,meta:{}}),m=!1;try{var _=JSON.parse(p?.meta.uploadInfo),g=new FormData;g.append("file",s),g.append("Content-Type",d),g.append("AWSAccessKeyId",_.AWSAccessKeyId),g.append("Signature",_.Signature),g.append("Policy",_.Policy),g.append("acl",_.acl),g.append("key",_.key),m=yield(0,U.Ay)(_.url,{method:"POST",body:g}).then(e=>e.ok).catch(()=>!1)}catch{m=!1}return Z({file_id:p.id,upload_success:m,upload_info:{content_type:d,file_type:o,source_type:n?"url":"base64",processing_note:"File will be processed automatically. Use get_media_file to check processing status."}})}),function(e){return Y.apply(this,arguments)})),r({name:"update_media_file_meta",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Update media file information",inputSchema:{file_id:T.Yj().describe("Media file ID"),name:T.Yj().optional().describe("New file name"),description:T.Yj().optional().describe("New file description"),user_tags:T.YO(T.Yj()).optional().describe("New user tags")},permission:"write_media_flow"},(K=b(function*({file_id:e,name:i,description:t,user_tags:n}){return Z((yield c.updateMediaFile({...l(e),name:i,description:t,userTags:n,requestUploadAgain:!1})))}),function(e){return K.apply(this,arguments)})),r({name:"copy_media_files",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Copy media files from one box to another",inputSchema:{from_box_id:T.Yj().describe("Source media box ID"),to_box_id:T.Yj().describe("Target media box ID"),file_ids:T.YO(T.Yj()).describe("Array of media file IDs to copy")},permission:"write_media_flow"},(G=b(function*({from_box_id:e,to_box_id:i,file_ids:t}){return Z((yield c.copyMediaFiles({fromBoxId:e,toBoxId:i,...p(t)})))}),function(e){return G.apply(this,arguments)})),r({name:"delete_media_files",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Delete specific media files from a box",inputSchema:{box_id:T.Yj().describe("Media box ID"),file_ids:T.YO(T.Yj()).describe("Array of media file IDs to delete")},permission:"write_media_flow"},(L=b(function*({box_id:e,file_ids:i}){return Z((yield c.deleteMediaFiles({boxId:e,...p(i)})))}),function(e){return L.apply(this,arguments)})),r({name:"cleanup_media_box",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Delete all files in a media box, optionally filtered by type",inputSchema:{box_id:T.Yj().describe("Media box ID"),include_types:T.YO(T.Yj()).optional().describe('Only delete files of these types (e.g., ["image", "video"])')},permission:"write_media_flow"},(z=b(function*({box_id:e,include_types:i}){var t=m(i);if("deleteMediaBoxFiles"in c)return Z((yield c.deleteMediaBoxFiles({boxId:e,includeTypes:t})));var n=yield c.mediaFiles({boxId:e,includeTypes:t});return Z((yield c.deleteMediaFiles({boxId:e,list:n.map(e=>e.id)})))}),function(e){return z.apply(this,arguments)})),e.tool("calculate_grid_layout","Calculate grid layout and pixel conversions for different device resolutions",{device_width:T.ai().describe("Device width in pixels"),device_height:T.ai().describe("Device height in pixels"),app_grid_width:T.ai().describe("Application grid width").optional().default(96),app_grid_height:T.ai().describe("Application grid height").optional().default(54)},nr,(J=b(function*({device_width:e,device_height:i,app_grid_width:t,app_grid_height:n}){var a=(0,M.k)(t,e,i),o=(0,M.Y)(e,i,t);return Z({device_resolution:{width:e,height:i,aspect_ratio:(e/i).toFixed(2)},current_grid:{width:t,height:n,unit_size_px:a.deviceBrickUnit.toFixed(2),total_pixels:{width:a.deviceBrickWidth.toFixed(2),height:a.deviceBrickHeight.toFixed(2)}},recommended_grid:{width:o.deviceBrickWidth,height:o.deviceBrickHeight,unit_size_px:o.deviceBrickUnit.toFixed(2),note:"Optimized for device aspect ratio"}})}),function(e){return J.apply(this,arguments)})),e.tool("create_item","Use this tool to create new item that you can put in application configuration",{type:T.k5(["subspace","canvas","brick","generator","property_bank","property_bank_calc","property_bank_command","animation","state_group","automation_map"]).describe("Item type"),title:T.Yj().describe("Item title"),template_key:T.Yj().optional().describe("Template key for brick or generator")},nr,no),e.tool("getting_started","Get documentation content for getting started",{},nr,b(function*(){return Z(Q)})),!a){var _,g,f,I,k,A,D,w,S,C,x,R,P,F,N,q,j,W,V,Y,K,G,L,z,J,X,ei,et,en=()=>new ne(t,i.auth||i.token);r({name:"activity_log_events",annotations:nr,description:"Query activity log events. Returns raw events (general, data, local_sync) with filtering. Max 30-day range.",inputSchema:s({start_time:T.Yj().describe("Start time (ISO 8601)"),end_time:T.Yj().describe("End time (ISO 8601)"),device_id:T.Yj().optional().describe("Filter by device ID"),event_type:T.k5(["general","data","local_sync"]).optional().describe("Filter by event type"),event_name:T.Yj().optional().describe("Filter by event name (e.g. BRICK_xxx_ON_PRESS)"),subspace_id:T.Yj().optional().describe("Filter by subspace ID"),sender:T.Yj().optional().describe("Filter by sender"),limit:T.ai().optional().default(50).describe("Max events to return per page"),offset:T.ai().optional().default(0).describe("Number of events to skip (for pagination)")}),permission:"query_activity_log"},(X=b(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=en(),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),Z((yield c.events(l,{limit:s,offset:d})))}),function(e){return X.apply(this,arguments)})),r({name:"activity_log_screenshots",annotations:nr,description:"List available screenshot timestamps for a device in a time range.",inputSchema:s({device_id:T.Yj().describe("Device ID (required)"),start_time:T.Yj().describe("Start time (ISO 8601)"),end_time:T.Yj().describe("End time (ISO 8601)")}),permission:"query_activity_log"},(ei=b(function*({device_id:e,start_time:i,end_time:t}){var n=en();return Z((yield n.screenshots({device_id:e,start_time:i,end_time:t})))}),function(e){return ei.apply(this,arguments)})),r({name:"activity_log_screenshot",annotations:nr,description:"Download a device screenshot at a specific timestamp. Returns a base64-encoded JPEG image.",inputSchema:s({device_id:T.Yj().describe("Device ID"),ts:T.Yj().describe("Screenshot timestamp (ISO 8601 or epoch ms)")}),permission:"query_activity_log"},(et=b(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=en(),r=/^\d+$/.test(n)?n:new Date(n).getTime();return Z((yield o.downloadScreenshot(a,t,r)),{mimeType:"image/jpeg"})}),function(e){return et.apply(this,arguments)}))}r({name:"get_device_usage",annotations:nr,description:"Get device usage metrics (uptime, memory, disk) for a date range. Data from BRICKS main server.",inputSchema:s({device_id:T.Yj().describe("Device ID"),start_date:T.Yj().optional().describe("Start date/time in ISO 8601 format (default: start of today)"),end_date:T.Yj().optional().describe("End date/time in ISO 8601 format (default: now)")}),permission:"query_device"},(n=b(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 Z((yield d.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 k.S;try{yield p.connect(m),console.error("BRICKS MCP Server running on STDIO"),console.error(`Server: ${nt} v${nl}`),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)}}};
|
|
2690
|
+
- 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"},b(function*(){return{contents:[{uri:"file://docs/getting-started.md",mimeType:"text/markdown",text:x}]}})),function(e,i,{activityLogBaseUrl:t=nn.activityLog}={}){var n,a="user"===i.tokenType,o=ee(i),r=((e,i=null)=>({name:t,description:n,inputSchema:a,annotations:o,permission:r,workspaceTokenOnly:s=!1},d)=>{!(s&&ee(i))&&(!r||i.tokenInfo.permissions?.includes(r)||0)&&e.tool(t,n,a,o,d)})(e,i),s=e=>({...e,...a?{workspace_id:T.Yj().describe("Workspace ID")}:{}}),d=i.client,c=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={};o&&(u.origin=o),n&&a||(u.authorization=`Bearer ${t}`);let m=new th.z({uri:e,headers:u});if(r){let e,t,n;l=(0,tI.UU)({url:i,lazy:!0,connectionParams:u,retryAttempts:1/0,shouldRetry:()=>!0,keepAlive:1e4,on:{error:e=>{n(),d?.(e)},opened:i=>{d?.(),e=i,n()},ping:i=>{i||(n(),t=setTimeout(()=>{e&&e.readyState===WebSocket.OPEN&&e.close(4205,"Client Restart")},5e3))},pong:e=>{e&&n()},closed:n=()=>{t&&(clearTimeout(t),t=void 0)}}}),p=new tb.c(l)}let _=ty.C.from([(0,tk.S)(({networkError:e,operation:i})=>{if(e){let t;if(c(e,i),!1===i.getContext().suppressExpectedErrors)return;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 t$.c(e=>e.complete())}}),s&&new tv.z({attempts:{max:3,retryIf:e=>(function(e,{nonRetryableResponseStatusCodes:i=tg,nonRetryableStatusCodes:t=tf}={}){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:tS})}}),new(tD())(3e4),r?ty.C.split(({query:e})=>{let{kind:i,operation:t}=(0,tw.Vn)(e);return"OperationDefinition"===i&&"subscription"===t},p,m):m].filter(Boolean));return _.closeSubscriptionClient=()=>r&&l.dispose().catch(e=>{if(1e3!==e.code)throw e}),_}({endpointURL:u,subscriptionEndpointURL:u.replace(/^http/,"ws"),accessToken:i,enableSubscription:!p&&a,enableRetry:o,subscriptionOnConnectionOrError:r,onNetworkError:s}),c=new ed.D,(l=new es.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=v,i.mutations=h;let t={boxId:e.boxId,passcode:e.passcode};Object.entries(v).forEach(t_(i,"query",t)),Object.entries(h).forEach(t_(i,"mutation",t)),i.listenBoxChanged=(e,n)=>i.subscribe({query:t2,variables:{...t,...e}}).subscribe({next:t5(n),error(e){n(e)}})}else i.accessToken=e.accessToken,i.type="token",i.queries=y,i.mutations=$,Object.entries(y).forEach(t_(i,"query")),Object.entries($).forEach(t_(i,"mutation")),i.listenBoxChanged=(e,t)=>i.subscribe({query:tJ,variables:e}).subscribe({next:t5(t),error(e){t(e)}});return i})({endpoint:i,accessToken:t,enableSubscription:!1,enableRetry:!0})}({endpoint:nn.media,accessToken:i.token}):d,l=e=>a?{fileId:e}:{id:e},p=e=>a?{list:e}:{fileIds:e},u=e=>e.toUpperCase(),m=e=>e?.map(u);if(a&&e.tool("list_workspaces","List all workspaces",{},nr,b(function*(){return Z((yield d.workspaces()))})),r({name:"get_workspace_overview",annotations:nr,description:"Get comprehensive overview of the BRICKS workspace including stats and summary",inputSchema:s({}),permission:"info"},(_=b(function*({workspace_id:e}){var i=B((yield Promise.all([d.workspace({id:e}),d.applications({workspaceId:e,paginate:{limit:50,offset:0}}),d.modules({workspaceId:e,paginate:{limit:50,offset:0}}),d.devices({workspaceId:e,paginate:{limit:50,offset:0}}),a?c.mediaWorkspace({workspaceId:e}).catch(()=>null):c.mediaWorkspace().catch(()=>null),a?c.mediaBoxes({workspaceId:e}).catch(()=>[]):c.mediaBoxes().catch(()=>[])])),6),t=i[0],n=i[1],o=i[2],r=i[3],s=i[4],l=i[5];if(!t)throw Error("Authentication failed, please check your token");return Z({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:!!s,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:s?{workspace_id:s.id,name:s.name,size_used:s.size,size_limit:s.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 _.apply(this,arguments)})),r({name:"get_applications",annotations:nr,description:"List all applications in the workspace",inputSchema:s({limit:T.ai().describe("Maximum number of applications to return").optional().default(50),offset:T.ai().describe("Number of applications to skip").optional().default(0)}),permission:"query_application"},(g=b(function*({workspace_id:e,limit:i=50,offset:t=0}){return Z((yield d.applications({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return g.apply(this,arguments)})),r({name:"get_application",annotations:nr,description:"Get detailed info and config of a specific application. `bricks_project_last_commit_id` is the config revision to pass to update_application_config, and `dev_ref.is_dev` tells whether the application is a dev fork.",inputSchema:s({id:T.Yj().describe("Application ID")}),permission:"query_application"},(f=b(function*({workspace_id:e,id:i}){return Z((yield d.application({workspaceId:e,id:i})))}),function(e){return f.apply(this,arguments)})),r({name:"get_modules",annotations:nr,description:"List all modules in the workspace",inputSchema:s({limit:T.ai().describe("Maximum number of modules to return").optional().default(50),offset:T.ai().describe("Number of modules to skip").optional().default(0)}),permission:"query_module"},(I=b(function*({workspace_id:e,limit:i=50,offset:t=0}){return Z((yield d.modules({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return I.apply(this,arguments)})),r({name:"get_module",annotations:nr,description:"Get detailed info and config of a specific module. `bricks_project_last_commit_id` is the config revision to pass to update_module_config.",inputSchema:s({id:T.Yj().describe("Module ID")}),permission:"query_module"},(k=b(function*({workspace_id:e,id:i}){return Z((yield d.module({workspaceId:e,id:i})))}),function(e){return k.apply(this,arguments)})),r({name:"update_module_info",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Update a specific module info",inputSchema:s({id:T.Yj().describe("Module ID"),name:T.Yj().describe("Module name"),description:T.Yj().describe("Module description")}),permission:"update_module"},(A=b(function*({workspace_id:e,id:i,name:t,description:n}){return Z((yield d.updateModule({workspaceId:e,id:i,name:t,description:n})))}),function(e){return A.apply(this,arguments)})),r({name:"update_module_config",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},description:"Update a specific module configuration. Applications that use the module get the change at once.",inputSchema:s({id:T.Yj().describe("Module ID"),config:T.Ik({}).passthrough().describe("New configuration object, see file://docs/config-schema.md for schema reference"),last_commit_id:T.Yj().optional().describe(nd)}),permission:"update_module",workspaceTokenOnly:!0},(D=b(function*({workspace_id:e,id:i,config:t,last_commit_id:n}){var a=yield H(t);if(!a.valid)throw Error(`Config validation failed: ${a.errors.join(", ")}`);return Z((yield nc("get_module",()=>d.updateModule({workspaceId:e,id:i,config:JSON.stringify(t),validateConfig:!0,lastCommitId:n}))))}),function(e){return D.apply(this,arguments)})),r({name:"get_devices",annotations:nr,description:"List all devices in the workspace",inputSchema:s({limit:T.ai().describe("Maximum number of devices to return").optional().default(50),offset:T.ai().describe("Number of devices to skip").optional().default(0)}),permission:"query_device"},(w=b(function*({workspace_id:e,limit:i=50,offset:t=0}){return Z((yield d.devices({workspaceId:e,paginate:{limit:i,offset:t}})))}),function(e){return w.apply(this,arguments)})),r({name:"create_application",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Create a new BRICKS application with default grid layout",inputSchema:s({name:T.Yj().describe("Application name"),description:T.Yj().describe("Application description").optional(),grid_width:T.ai().describe("Grid width in units").optional().default(96),grid_height:T.ai().describe("Grid height in units").optional().default(54)}),permission:"create_application"},(S=b(function*({workspace_id:e,name:i,description:t,grid_width:n,grid_height:a}){return Z((yield d.createApplication({workspaceId:e,name:i,description:t,gridWidth:n,gridHeight:a})))}),function(e){return S.apply(this,arguments)})),r({name:"update_application_info",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Update application info",inputSchema:{id:T.Yj().describe("Application ID"),name:T.Yj().describe("Application name"),description:T.Yj().describe("Application description")},permission:"update_application"},(C=b(function*({id:e,name:i,description:t}){return Z((yield d.updateApplication({id:e,name:i,description:t})))}),function(e){return C.apply(this,arguments)})),r({name:"fork_application",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Create a dev fork of an application: a copy with no bound devices. Changes to the fork do not reach the devices of the original application.",inputSchema:{id:T.Yj().describe("ID of the application to fork (not a dev fork itself)")},permission:"create_application"},(x=b(function*({id:e}){return Z((yield d.forkApplication({id:e})))}),function(e){return x.apply(this,arguments)})),r({name:"update_application_config",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},description:o?"Update the configuration of a dev fork application with validation. Only a dev fork (see fork_application) can be written in an OAuth session; publishing the fork to the original application is done by a person in BRICKS Controller.":"Update application configuration with validation. Devices bound to the application get the change at once.",inputSchema:{id:T.Yj().describe("Application ID"),config:T.Ik({}).passthrough().describe("New application configuration. Please read `getting-started` for BRICKS concepts before changing"),last_commit_id:T.Yj().optional().describe(nd)},permission:"update_application"},(R=b(function*({id:e,config:i,last_commit_id:t}){if(o){var n=yield d.application({id:e});if(!n?.dev_ref?.is_dev)throw Error(`Application ${e} is not a dev fork. An OAuth session cannot change an application that may run on devices. Call fork_application, then update the fork.`)}var a=yield H(i);if(!a.valid)throw Error(`Config validation failed: ${a.errors.join(", ")}`);return Z((yield nc("get_application",()=>d.updateApplication({id:e,config:JSON.stringify(i),validateConfig:!0,lastCommitId:t}))))}),function(e){return R.apply(this,arguments)})),r({name:"bind_application",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},description:"Bind application to device with viewport configuration",inputSchema:{app_id:T.Yj().describe("Application ID"),viewports:T.YO(T.Ik({device_id:T.Yj().describe("Device ID"),x:T.ai().describe("X coordinate"),y:T.ai().describe("Y coordinate"),width:T.ai().describe("Width"),height:T.ai().describe("Height"),rotate:T.ai().describe("Rotation"),rotateType:T.Yj().describe("Rotation type")})).describe("Viewport configuration")},permission:"bind_application",workspaceTokenOnly:!0},(P=b(function*({app_id:e,viewports:i}){return Z((yield d.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 P.apply(this,arguments)})),r({name:"unbind_application",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!1,openWorldHint:!0},description:"Unbind application from device",inputSchema:{app_id:T.Yj().describe("Application ID"),device_id:T.Yj().describe("Device ID")},permission:"bind_application",workspaceTokenOnly:!0},(F=b(function*({app_id:e,device_id:i}){return Z((yield d.bindApplication({id:e,unbindDevices:[i]})))}),function(e){return F.apply(this,arguments)})),a&&r({name:"list_media_workspaces",annotations:nr,description:"List all media workspaces",inputSchema:{},permission:"query_media_flow"},b(function*(){return Z((yield c.mediaWorkspaces()))})),r({name:"get_media_workspace",annotations:nr,description:"Get media workspace information and status",inputSchema:s({}),permission:"query_media_flow"},(N=b(function*({workspace_id:e}){return Z((yield c.mediaWorkspace({workspaceId:e})))}),function(e){return N.apply(this,arguments)})),r({name:"list_media_boxes",annotations:nr,description:"List all media boxes in the workspace",inputSchema:s({}),permission:"query_media_flow"},(q=b(function*({workspace_id:e}){return Z((yield c.mediaBoxes({workspaceId:e})))}),function(e){return q.apply(this,arguments)})),r({name:"get_media_box",annotations:nr,description:"Get detailed information about a specific media box",inputSchema:{box_id:T.Yj().describe("Media box ID")},permission:"query_media_flow"},(j=b(function*({box_id:e}){return Z((yield c.mediaBox({boxId:e})))}),function(e){return j.apply(this,arguments)})),r({name:"list_media_files",annotations:nr,description:"List media files in a specific box with filtering options",inputSchema:{box_id:T.Yj().describe("Media box ID"),include_types:T.YO(T.Yj()).optional().describe('Filter by file types (e.g., ["image", "video", "audio"])'),user_tags:T.YO(T.Yj()).optional().describe("Filter by user tags"),limit:T.ai().optional().default(50).describe("Maximum number of files to return"),offset:T.ai().optional().default(0).describe("Number of files to skip")},permission:"query_media_flow"},(W=b(function*({box_id:e,include_types:i,user_tags:t,limit:n,offset:a}){return Z((yield c.mediaFiles({boxId:e,includeTypes:m(i),userTags:t,limit:n,offset:a})))}),function(e){return W.apply(this,arguments)})),r({name:"get_media_file_meta",annotations:nr,description:"Get detailed information about a specific media file",inputSchema:{file_id:T.Yj().describe("Media file ID")},permission:"query_media_flow"},(V=b(function*({file_id:e}){return Z((yield c.mediaFile(l(e))))}),function(e){return V.apply(this,arguments)})),r({name:"media_box_upload",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!0},description:"Upload a file to a media box from URL or base64 data",inputSchema:{box_id:T.Yj().describe("Target media box ID"),name:T.Yj().describe("File name"),description:T.Yj().optional().default("").describe("File description"),file_type:T.k5(["image","video","audio","file"]).describe("File type"),source_url:T.Yj().optional().describe("URL to download the file from (maximum 100 MiB)"),base64_data:T.Yj().optional().describe("Base64 encoded file data"),user_tags:T.YO(T.Yj()).optional().default([]).describe("User-defined tags for the file")},permission:"write_media_flow"},(Y=b(function*({box_id:e,name:i,description:t,source_url:n,base64_data:a,file_type:o,user_tags:r}){if(!n&&!a)throw Error("Either source_url or base64_data must be provided");if(n&&a)throw Error("Provide either source_url OR base64_data, not both");var s,d="application/octet-stream";if(n){var l=yield ns(n,(0,O.fJ)(n));s=l.data,d=l.contentType}else s=new Blob([E.Buffer.from(a,"base64")],{type:d});var p=yield c.requestFileUpload({name:i,description:t,boxId:e,fileType:u(o),contentType:d,userTags:r,meta:{}}),m=!1;try{var _=JSON.parse(p?.meta.uploadInfo),g=new FormData;g.append("file",s),g.append("Content-Type",d),g.append("AWSAccessKeyId",_.AWSAccessKeyId),g.append("Signature",_.Signature),g.append("Policy",_.Policy),g.append("acl",_.acl),g.append("key",_.key),m=yield(0,U.Ay)(_.url,{method:"POST",body:g}).then(e=>e.ok).catch(()=>!1)}catch{m=!1}return Z({file_id:p.id,upload_success:m,upload_info:{content_type:d,file_type:o,source_type:n?"url":"base64",processing_note:"File will be processed automatically. Use get_media_file to check processing status."}})}),function(e){return Y.apply(this,arguments)})),r({name:"update_media_file_meta",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Update media file information",inputSchema:{file_id:T.Yj().describe("Media file ID"),name:T.Yj().optional().describe("New file name"),description:T.Yj().optional().describe("New file description"),user_tags:T.YO(T.Yj()).optional().describe("New user tags")},permission:"write_media_flow"},(K=b(function*({file_id:e,name:i,description:t,user_tags:n}){return Z((yield c.updateMediaFile({...l(e),name:i,description:t,userTags:n,requestUploadAgain:!1})))}),function(e){return K.apply(this,arguments)})),r({name:"copy_media_files",annotations:{readOnlyHint:!1,destructiveHint:!1,idempotentHint:!1,openWorldHint:!1},description:"Copy media files from one box to another",inputSchema:{from_box_id:T.Yj().describe("Source media box ID"),to_box_id:T.Yj().describe("Target media box ID"),file_ids:T.YO(T.Yj()).describe("Array of media file IDs to copy")},permission:"write_media_flow"},(G=b(function*({from_box_id:e,to_box_id:i,file_ids:t}){return Z((yield c.copyMediaFiles({fromBoxId:e,toBoxId:i,...p(t)})))}),function(e){return G.apply(this,arguments)})),r({name:"delete_media_files",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Delete specific media files from a box",inputSchema:{box_id:T.Yj().describe("Media box ID"),file_ids:T.YO(T.Yj()).describe("Array of media file IDs to delete")},permission:"write_media_flow"},(L=b(function*({box_id:e,file_ids:i}){return Z((yield c.deleteMediaFiles({boxId:e,...p(i)})))}),function(e){return L.apply(this,arguments)})),r({name:"cleanup_media_box",annotations:{readOnlyHint:!1,destructiveHint:!0,idempotentHint:!0,openWorldHint:!1},description:"Delete all files in a media box, optionally filtered by type",inputSchema:{box_id:T.Yj().describe("Media box ID"),include_types:T.YO(T.Yj()).optional().describe('Only delete files of these types (e.g., ["image", "video"])')},permission:"write_media_flow"},(z=b(function*({box_id:e,include_types:i}){var t=m(i);if("deleteMediaBoxFiles"in c)return Z((yield c.deleteMediaBoxFiles({boxId:e,includeTypes:t})));var n=yield c.mediaFiles({boxId:e,includeTypes:t});return Z((yield c.deleteMediaFiles({boxId:e,list:n.map(e=>e.id)})))}),function(e){return z.apply(this,arguments)})),e.tool("calculate_grid_layout","Calculate grid layout and pixel conversions for different device resolutions",{device_width:T.ai().describe("Device width in pixels"),device_height:T.ai().describe("Device height in pixels"),app_grid_width:T.ai().describe("Application grid width").optional().default(96),app_grid_height:T.ai().describe("Application grid height").optional().default(54)},nr,(J=b(function*({device_width:e,device_height:i,app_grid_width:t,app_grid_height:n}){var a=(0,M.k)(t,e,i),o=(0,M.Y)(e,i,t);return Z({device_resolution:{width:e,height:i,aspect_ratio:(e/i).toFixed(2)},current_grid:{width:t,height:n,unit_size_px:a.deviceBrickUnit.toFixed(2),total_pixels:{width:a.deviceBrickWidth.toFixed(2),height:a.deviceBrickHeight.toFixed(2)}},recommended_grid:{width:o.deviceBrickWidth,height:o.deviceBrickHeight,unit_size_px:o.deviceBrickUnit.toFixed(2),note:"Optimized for device aspect ratio"}})}),function(e){return J.apply(this,arguments)})),e.tool("create_item","Use this tool to create new item that you can put in application configuration",{type:T.k5(["subspace","canvas","brick","generator","property_bank","property_bank_calc","property_bank_command","animation","state_group","automation_map"]).describe("Item type"),title:T.Yj().describe("Item title"),template_key:T.Yj().optional().describe("Template key for brick or generator")},nr,no),e.tool("getting_started","Get documentation content for getting started",{},nr,b(function*(){return Z(Q)})),!a){var _,g,f,I,k,A,D,w,S,C,x,R,P,F,N,q,j,W,V,Y,K,G,L,z,J,X,ei,et,en=()=>new ne(t,i.auth||i.token);r({name:"activity_log_events",annotations:nr,description:"Query activity log events. Returns raw events (general, data, local_sync) with filtering. Max 30-day range.",inputSchema:s({start_time:T.Yj().describe("Start time (ISO 8601)"),end_time:T.Yj().describe("End time (ISO 8601)"),device_id:T.Yj().optional().describe("Filter by device ID"),event_type:T.k5(["general","data","local_sync"]).optional().describe("Filter by event type"),event_name:T.Yj().optional().describe("Filter by event name (e.g. BRICK_xxx_ON_PRESS)"),subspace_id:T.Yj().optional().describe("Filter by subspace ID"),sender:T.Yj().optional().describe("Filter by sender"),limit:T.ai().optional().default(50).describe("Max events to return per page"),offset:T.ai().optional().default(0).describe("Number of events to skip (for pagination)")}),permission:"query_activity_log"},(X=b(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=en(),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),Z((yield c.events(l,{limit:s,offset:d})))}),function(e){return X.apply(this,arguments)})),r({name:"activity_log_screenshots",annotations:nr,description:"List available screenshot timestamps for a device in a time range.",inputSchema:s({device_id:T.Yj().describe("Device ID (required)"),start_time:T.Yj().describe("Start time (ISO 8601)"),end_time:T.Yj().describe("End time (ISO 8601)")}),permission:"query_activity_log"},(ei=b(function*({device_id:e,start_time:i,end_time:t}){var n=en();return Z((yield n.screenshots({device_id:e,start_time:i,end_time:t})))}),function(e){return ei.apply(this,arguments)})),r({name:"activity_log_screenshot",annotations:nr,description:"Download a device screenshot at a specific timestamp. Returns a base64-encoded JPEG image.",inputSchema:s({device_id:T.Yj().describe("Device ID"),ts:T.Yj().describe("Screenshot timestamp (ISO 8601 or epoch ms)")}),permission:"query_activity_log"},(et=b(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=en(),r=/^\d+$/.test(n)?n:new Date(n).getTime();return Z((yield o.downloadScreenshot(a,t,r)),{mimeType:"image/jpeg"})}),function(e){return et.apply(this,arguments)}))}r({name:"get_device_usage",annotations:nr,description:"Get device usage metrics (uptime, memory, disk) for a date range. Data from BRICKS main server.",inputSchema:s({device_id:T.Yj().describe("Device ID"),start_date:T.Yj().optional().describe("Start date/time in ISO 8601 format (default: start of today)"),end_date:T.Yj().optional().describe("End date/time in ISO 8601 format (default: now)")}),permission:"query_device"},(n=b(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 Z((yield d.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 k.S;try{yield p.connect(m),console.error("BRICKS MCP Server running on STDIO"),console.error(`Server: ${nt} v${nl}`),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)}}};
|