claw-dashboard 1.9.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/.c8rc.json +38 -0
  2. package/.dockerignore +68 -0
  3. package/.github/dependabot.yml +45 -0
  4. package/.github/pull_request_template.md +39 -0
  5. package/.github/workflows/ci.yml +147 -0
  6. package/.github/workflows/release.yml +40 -0
  7. package/.github/workflows/security.yml +84 -0
  8. package/.husky/pre-commit +1 -0
  9. package/.planning/codebase/ARCHITECTURE.md +206 -0
  10. package/.planning/codebase/INTEGRATIONS.md +150 -0
  11. package/.planning/codebase/STACK.md +122 -0
  12. package/.planning/codebase/STRUCTURE.md +201 -0
  13. package/CHANGELOG.md +293 -0
  14. package/CONTRIBUTING.md +378 -0
  15. package/Dockerfile +54 -0
  16. package/FEATURES.md +195 -21
  17. package/README.md +83 -6
  18. package/TODO.md +28 -0
  19. package/build-cjs.js +127 -0
  20. package/cjs-shim.js +13 -0
  21. package/dist/clawdash +1729 -0
  22. package/dist/clawdash.meta.json +2236 -0
  23. package/dist/widgets.cjs +6511 -0
  24. package/docker-compose.yml +67 -0
  25. package/docs/API.md +1050 -0
  26. package/docs/PLUGINS.md +1504 -0
  27. package/esbuild.config.js +158 -0
  28. package/eslint.config.js +56 -0
  29. package/examples/plugins/README.md +122 -0
  30. package/examples/plugins/api-status/index.js +294 -0
  31. package/examples/plugins/api-status/plugin.json +19 -0
  32. package/examples/plugins/hello-world/index.js +104 -0
  33. package/examples/plugins/hello-world/plugin.json +15 -0
  34. package/examples/plugins/system-metrics-chart/index.js +339 -0
  35. package/examples/plugins/system-metrics-chart/plugin.json +18 -0
  36. package/examples/plugins/weather-widget/index.js +136 -0
  37. package/examples/plugins/weather-widget/plugin.json +19 -0
  38. package/index.cjs +23005 -0
  39. package/index.js +5236 -566
  40. package/jest.config.js +11 -0
  41. package/man/clawdash.1 +276 -0
  42. package/package.json +54 -5
  43. package/schemas/plugin-manifest.json +128 -0
  44. package/scripts/release.js +595 -0
  45. package/src/alerts.js +693 -0
  46. package/src/auto-save.js +584 -0
  47. package/src/cache.js +390 -0
  48. package/src/checksum.js +146 -0
  49. package/src/cli/args.js +110 -0
  50. package/src/cli/export-schedule.js +423 -0
  51. package/src/cli/export-snapshot.js +138 -0
  52. package/src/cli/help.js +69 -0
  53. package/src/cli/import-snapshot.js +230 -0
  54. package/src/cli/index.js +14 -0
  55. package/src/cli/list-templates.js +69 -0
  56. package/src/cli/validate-config.js +76 -0
  57. package/src/cli/validate-plugin.js +187 -0
  58. package/src/cli/version.js +15 -0
  59. package/src/config-validator.js +586 -0
  60. package/src/config-watcher.js +401 -0
  61. package/src/config.js +684 -0
  62. package/src/container-detector.js +499 -0
  63. package/src/database.js +734 -0
  64. package/src/differential-render.js +327 -0
  65. package/src/errors.js +169 -0
  66. package/src/export-scheduler.js +581 -0
  67. package/src/gateway-manager.js +685 -0
  68. package/src/hints.js +371 -0
  69. package/src/loading-states.js +509 -0
  70. package/src/logger.js +185 -0
  71. package/src/memory-pressure.js +467 -0
  72. package/src/performance-monitor.js +374 -0
  73. package/src/plugin-errors.js +586 -0
  74. package/src/plugin-manifest-validator.js +219 -0
  75. package/src/plugin-reload.js +481 -0
  76. package/src/plugin-scaffold.js +1941 -0
  77. package/src/plugin-validator.js +284 -0
  78. package/src/retry.js +218 -0
  79. package/src/security.js +860 -0
  80. package/src/snapshot.js +372 -0
  81. package/src/splash.js +115 -0
  82. package/src/theme-selector.js +411 -0
  83. package/src/themes.js +874 -0
  84. package/src/transitions.js +534 -0
  85. package/src/types.d.ts +174 -0
  86. package/src/validation.js +926 -0
  87. package/src/web-server.js +885 -0
  88. package/src/widgets/builtin-widgets.js +1057 -0
  89. package/src/widgets/config-processor.js +401 -0
  90. package/src/widgets/dependency-resolver.js +596 -0
  91. package/src/widgets/index.js +79 -0
  92. package/src/widgets/plugin-api.js +845 -0
  93. package/src/widgets/widget-error-boundary.js +773 -0
  94. package/src/widgets/widget-error-isolation.js +551 -0
  95. package/src/widgets/widget-loader.js +1437 -0
  96. package/src/workers/system-worker.js +130 -0
  97. package/src/workers/worker-pool.js +633 -0
  98. package/tests/alerts.test.js +437 -0
  99. package/tests/auto-save.test.js +529 -0
  100. package/tests/cache.test.js +317 -0
  101. package/tests/cli.test.js +351 -0
  102. package/tests/command-palette.test.js +320 -0
  103. package/tests/config-processor.test.js +452 -0
  104. package/tests/config-validator.test.js +710 -0
  105. package/tests/config-watcher.test.js +594 -0
  106. package/tests/config.test.js +755 -0
  107. package/tests/database.test.js +438 -0
  108. package/tests/errors.test.js +189 -0
  109. package/tests/example-plugins.test.js +624 -0
  110. package/tests/integration.test.js +1321 -0
  111. package/tests/loading-states.test.js +300 -0
  112. package/tests/manifest-validation-on-load.test.js +671 -0
  113. package/tests/performance-monitor.test.js +190 -0
  114. package/tests/plugin-api-rate-limit.test.js +302 -0
  115. package/tests/plugin-errors.test.js +311 -0
  116. package/tests/plugin-lifecycle-e2e.test.js +1036 -0
  117. package/tests/plugin-reload.test.js +764 -0
  118. package/tests/rate-limiter.test.js +539 -0
  119. package/tests/retry.test.js +308 -0
  120. package/tests/security.test.js +411 -0
  121. package/tests/settings-modal.test.js +226 -0
  122. package/tests/theme-selector.test.js +57 -0
  123. package/tests/utils.js +242 -0
  124. package/tests/utils.test.js +317 -0
  125. package/tests/validate-plugin-cli.test.js +359 -0
  126. package/tests/validation.test.js +837 -0
  127. package/tests/web-server.test.js +646 -0
  128. package/tests/widget-arrange-mode.test.js +183 -0
  129. package/tests/widget-config-hot-reload.test.js +465 -0
  130. package/tests/widget-dependency.test.js +591 -0
  131. package/tests/widget-error-boundary.test.js +749 -0
  132. package/tests/widget-error-isolation.test.js +469 -0
  133. package/tests/widget-integration.test.js +1147 -0
  134. package/tests/widget-refresh-intervals.test.js +284 -0
  135. package/tests/worker-pool.test.js +522 -0
package/.c8rc.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "all": true,
3
+ "include": [
4
+ "index.js",
5
+ "src/**/*.js"
6
+ ],
7
+ "exclude": [
8
+ "node_modules/**",
9
+ "coverage/**",
10
+ "tests/**",
11
+ "dist/**",
12
+ "scripts/**",
13
+ "examples/**",
14
+ "src/workers/**",
15
+ "**/*.test.js",
16
+ "**/*.config.js"
17
+ ],
18
+ "reporter": [
19
+ "text",
20
+ "text-summary",
21
+ "lcov",
22
+ "html",
23
+ "json-summary"
24
+ ],
25
+ "check-coverage": true,
26
+ "statements": 35,
27
+ "branches": 30,
28
+ "functions": 20,
29
+ "lines": 35,
30
+ "watermarks": {
31
+ "statements": [70, 90],
32
+ "branches": [65, 85],
33
+ "functions": [70, 90],
34
+ "lines": [70, 90]
35
+ },
36
+ "report-dir": "./coverage",
37
+ "temp-dir": "./coverage/.tmp"
38
+ }
package/.dockerignore ADDED
@@ -0,0 +1,68 @@
1
+ # Dependencies
2
+ node_modules
3
+ npm-debug.log*
4
+ yarn-debug.log*
5
+ yarn-error.log*
6
+
7
+ # Testing
8
+ tests/
9
+ coverage/
10
+ *.test.js
11
+ *.spec.js
12
+ jest.config.js
13
+
14
+ # Documentation
15
+ docs/
16
+ *.md
17
+ CONTRIBUTING.md
18
+ CHANGELOG.md
19
+ README.md
20
+ TODO.md
21
+
22
+ # Git
23
+ .git
24
+ .gitignore
25
+ .gitattributes
26
+
27
+ # CI/CD
28
+ .github/
29
+ .travis.yml
30
+ .gitlab-ci.yml
31
+
32
+ # IDE
33
+ .vscode/
34
+ .idea/
35
+ *.swp
36
+ *.swo
37
+ *~
38
+
39
+ # OS
40
+ .DS_Store
41
+ Thumbs.db
42
+
43
+ # Logs
44
+ logs/
45
+ *.log
46
+
47
+ # Runtime data
48
+ pids/
49
+ *.pid
50
+ *.seed
51
+ *.pid.lock
52
+
53
+ # Optional npm cache directory
54
+ .npm
55
+
56
+ # Optional eslint cache
57
+ .eslintcache
58
+
59
+ # Build outputs
60
+ dist/
61
+ build/
62
+
63
+ # Worktrees
64
+ .worktrees/
65
+
66
+ # Installation scripts (not needed in container)
67
+ install.sh
68
+ start.sh
@@ -0,0 +1,45 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'npm'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
7
+ day: 'monday'
8
+ time: '09:00'
9
+ open-pull-requests-limit: 10
10
+ reviewers:
11
+ - 'spleck'
12
+ assignees:
13
+ - 'spleck'
14
+ commit-message:
15
+ prefix: 'chore(deps)'
16
+ include: 'scope'
17
+ labels:
18
+ - 'dependencies'
19
+ groups:
20
+ dev-dependencies:
21
+ patterns:
22
+ - '*'
23
+ exclude-patterns:
24
+ - 'blessed*'
25
+ - 'systeminformation'
26
+ production-dependencies:
27
+ patterns:
28
+ - 'blessed*'
29
+ - 'systeminformation'
30
+
31
+ - package-ecosystem: 'github-actions'
32
+ directory: '/'
33
+ schedule:
34
+ interval: 'weekly'
35
+ day: 'monday'
36
+ time: '09:00'
37
+ open-pull-requests-limit: 5
38
+ reviewers:
39
+ - 'spleck'
40
+ commit-message:
41
+ prefix: 'chore(actions)'
42
+ include: 'scope'
43
+ labels:
44
+ - 'dependencies'
45
+ - 'github-actions'
@@ -0,0 +1,39 @@
1
+ ## Description
2
+
3
+ Brief description of the changes in this PR.
4
+
5
+ ## Type of Change
6
+
7
+ - [ ] Bug fix (non-breaking change that fixes an issue)
8
+ - [ ] New feature (non-breaking change that adds functionality)
9
+ - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
10
+ - [ ] Documentation update
11
+ - [ ] Refactoring (no functional changes)
12
+ - [ ] Performance improvement
13
+ - [ ] Test addition or improvement
14
+
15
+ ## Checklist
16
+
17
+ - [ ] I have run `npm test` and all tests pass
18
+ - [ ] I have run `npm run build` and the build succeeds
19
+ - [ ] My code follows the project's style guidelines
20
+ - [ ] I have performed a self-review of my code
21
+ - [ ] I have commented my code, particularly in hard-to-understand areas
22
+ - [ ] I have made corresponding changes to the documentation
23
+ - [ ] My changes generate no new warnings
24
+ - [ ] I have added tests that prove my fix is effective or that my feature works
25
+ - [ ] New and existing unit tests pass locally with my changes
26
+
27
+ ## Testing
28
+
29
+ Describe the tests you ran and how to reproduce them:
30
+
31
+ ## Screenshots (if applicable)
32
+
33
+ ## Related Issues
34
+
35
+ Fixes #(issue number)
36
+
37
+ ## Additional Notes
38
+
39
+ Any other information that would be helpful for reviewers.
@@ -0,0 +1,147 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ paths-ignore:
7
+ - '**.md'
8
+ - 'docs/**'
9
+ - '.github/*.md'
10
+ pull_request:
11
+ branches: [main]
12
+ paths-ignore:
13
+ - '**.md'
14
+ - 'docs/**'
15
+ - '.github/*.md'
16
+
17
+ jobs:
18
+ test:
19
+ name: Test (Node ${{ matrix.node-version }})
20
+ runs-on: ubuntu-latest
21
+ strategy:
22
+ matrix:
23
+ node-version: [18, 20, 22]
24
+ fail-fast: false
25
+
26
+ steps:
27
+ - name: Checkout code
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Setup Node.js ${{ matrix.node-version }}
31
+ uses: actions/setup-node@v4
32
+ with:
33
+ node-version: ${{ matrix.node-version }}
34
+ cache: 'npm'
35
+
36
+ - name: Install dependencies
37
+ run: npm ci
38
+
39
+ - name: Run linter (ESLint checks)
40
+ run: npm run lint
41
+
42
+ - name: Run tests
43
+ run: npm test
44
+
45
+ - name: Run tests with coverage
46
+ if: matrix.node-version == 20
47
+ run: npm run test:coverage
48
+
49
+ - name: Upload coverage to Codecov
50
+ if: matrix.node-version == 20 && github.event_name != 'pull_request'
51
+ uses: codecov/codecov-action@v4
52
+ with:
53
+ files: ./coverage/lcov.info
54
+ fail_ci_if_error: false
55
+ verbose: true
56
+ env:
57
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
58
+
59
+ build:
60
+ name: Build
61
+ runs-on: ubuntu-latest
62
+ needs: test
63
+
64
+ steps:
65
+ - name: Checkout code
66
+ uses: actions/checkout@v4
67
+
68
+ - name: Setup Node.js
69
+ uses: actions/setup-node@v4
70
+ with:
71
+ node-version: 20
72
+ cache: 'npm'
73
+
74
+ - name: Install dependencies
75
+ run: npm ci
76
+
77
+ - name: Build distribution
78
+ run: npm run build
79
+
80
+ - name: Upload build artifacts
81
+ uses: actions/upload-artifact@v4
82
+ with:
83
+ name: dist
84
+ path: dist/
85
+ retention-days: 7
86
+
87
+ docker:
88
+ name: Docker Build
89
+ runs-on: ubuntu-latest
90
+ needs: test
91
+ if: github.event_name == 'pull_request'
92
+
93
+ steps:
94
+ - name: Checkout code
95
+ uses: actions/checkout@v4
96
+
97
+ - name: Set up Docker Buildx
98
+ uses: docker/setup-buildx-action@v3
99
+
100
+ - name: Build Docker image
101
+ uses: docker/build-push-action@v5
102
+ with:
103
+ context: .
104
+ push: false
105
+ tags: claw-dashboard:test
106
+ cache-from: type=gha
107
+ cache-to: type=gha,mode=max
108
+
109
+ security-audit:
110
+ name: Security Audit
111
+ runs-on: ubuntu-latest
112
+ needs: test
113
+ permissions:
114
+ actions: read
115
+ contents: read
116
+ security-events: write
117
+
118
+ steps:
119
+ - name: Checkout code
120
+ uses: actions/checkout@v4
121
+
122
+ - name: Setup Node.js
123
+ uses: actions/setup-node@v4
124
+ with:
125
+ node-version: 20
126
+ cache: 'npm'
127
+
128
+ - name: Install dependencies
129
+ run: npm ci
130
+
131
+ - name: Run npm audit
132
+ run: npm audit --audit-level=moderate
133
+ continue-on-error: true
134
+
135
+ - name: Run Trivy vulnerability scanner
136
+ uses: aquasecurity/trivy-action@master
137
+ with:
138
+ scan-type: 'fs'
139
+ scan-ref: '.'
140
+ format: 'sarif'
141
+ output: 'trivy-results.sarif'
142
+
143
+ - name: Upload Trivy scan results
144
+ uses: github/codeql-action/upload-sarif@v3
145
+ if: always()
146
+ with:
147
+ sarif_file: 'trivy-results.sarif'
@@ -0,0 +1,40 @@
1
+ name: Release
2
+
3
+ on:
4
+ release:
5
+ types: [created, published]
6
+
7
+ jobs:
8
+ build-and-publish:
9
+ name: Build and Publish
10
+ runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ id-token: write
14
+
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v4
18
+
19
+ - name: Setup Node.js
20
+ uses: actions/setup-node@v4
21
+ with:
22
+ node-version: 20
23
+ cache: 'npm'
24
+ registry-url: 'https://registry.npmjs.org'
25
+
26
+ - name: Install dependencies
27
+ run: npm ci
28
+
29
+ - name: Run tests
30
+ run: npm test
31
+
32
+ - name: Build all bundles
33
+ run: |
34
+ npm run build
35
+ npm run build:cjs
36
+
37
+ - name: Publish to npm
38
+ run: npm publish --provenance --access public
39
+ env:
40
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,84 @@
1
+ name: Security Audit
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ pull_request:
7
+ branches: [main]
8
+ schedule:
9
+ # Run daily at 2:00 AM UTC
10
+ - cron: '0 2 * * *'
11
+ workflow_dispatch:
12
+
13
+ jobs:
14
+ npm-audit:
15
+ name: NPM Audit
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - name: Checkout code
20
+ uses: actions/checkout@v4
21
+
22
+ - name: Setup Node.js
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: 20
26
+ cache: 'npm'
27
+
28
+ - name: Install dependencies
29
+ run: npm ci
30
+
31
+ - name: Run npm audit
32
+ run: |
33
+ npm audit --audit-level=moderate || exit_code=$?
34
+ if [ "${exit_code:-0}" -eq 0 ]; then
35
+ echo "No vulnerabilities found"
36
+ elif [ "${exit_code:-0}" -eq 1 ]; then
37
+ echo "Vulnerabilities found! See above for details."
38
+ exit 1
39
+ fi
40
+
41
+ dependency-review:
42
+ name: Dependency Review
43
+ runs-on: ubuntu-latest
44
+ if: github.event_name == 'pull_request'
45
+
46
+ steps:
47
+ - name: Checkout code
48
+ uses: actions/checkout@v4
49
+
50
+ - name: Dependency Review
51
+ uses: actions/dependency-review-action@v4
52
+ with:
53
+ fail-on-severity: moderate
54
+ comment-summary-in-pr: true
55
+
56
+ codeql-analysis:
57
+ name: CodeQL Analysis
58
+ runs-on: ubuntu-latest
59
+ permissions:
60
+ actions: read
61
+ contents: read
62
+ security-events: write
63
+
64
+ strategy:
65
+ fail-fast: false
66
+ matrix:
67
+ language: ['javascript']
68
+
69
+ steps:
70
+ - name: Checkout code
71
+ uses: actions/checkout@v4
72
+
73
+ - name: Initialize CodeQL
74
+ uses: github/codeql-action/init@v3
75
+ with:
76
+ languages: ${{ matrix.language }}
77
+
78
+ - name: Autobuild
79
+ uses: github/codeql-action/autobuild@v3
80
+
81
+ - name: Perform CodeQL Analysis
82
+ uses: github/codeql-action/analyze@v3
83
+ with:
84
+ category: "/language:${{matrix.language}}"
@@ -0,0 +1 @@
1
+ npx lint-staged
@@ -0,0 +1,206 @@
1
+ # Architecture
2
+
3
+ **Analysis Date:** 2026-02-28
4
+
5
+ ## Pattern Overview
6
+
7
+ **Overall:** Modular widget-based terminal dashboard with plugin architecture
8
+
9
+ **Key Characteristics:**
10
+ - Widget-based UI components using blessed framework
11
+ - Plugin system with lazy loading and hot-reload
12
+ - Event-driven architecture (EventEmitter pattern)
13
+ - Worker thread pool for heavy system operations
14
+ - Rate limiting throughout API access
15
+ - Comprehensive error boundaries
16
+
17
+ ## Layers
18
+
19
+ **Application Layer:**
20
+ - Purpose: Entry point, CLI parsing, main dashboard orchestration
21
+ - Location: `index.js`
22
+ - Contains: Main screen setup, keyboard handlers, initialization sequence
23
+ - Depends on: All other layers
24
+ - Used by: CLI binary
25
+
26
+ **Widget Layer:**
27
+ - Purpose: UI components and plugin system
28
+ - Location: `src/widgets/`
29
+ - Contains: BaseWidget class, PluginAPI, WidgetLoader, built-in widgets
30
+ - Depends on: blessed, blessed-contrib
31
+ - Used by: Application layer
32
+
33
+ **Service Layer:**
34
+ - Purpose: Business logic, data fetching, caching
35
+ - Location: `src/*.js` (non-widget files)
36
+ - Contains: gateway-manager, database, cache, themes, alerts, validation
37
+ - Depends on: systeminformation, sql.js
38
+ - Used by: Widgets and Application
39
+
40
+ **Worker Layer:**
41
+ - Purpose: Offload heavy system calls to threads
42
+ - Location: `src/workers/`
43
+ - Contains: WorkerPool, system-worker
44
+ - Depends on: Node.js worker_threads
45
+ - Used by: Application layer for system metrics
46
+
47
+ **Data Layer:**
48
+ - Purpose: Persistence and caching
49
+ - Location: `src/database.js`, `src/cache.js`
50
+ - Contains: SQLite persistence, in-memory caching
51
+ - Depends on: sql.js, fs
52
+ - Used by: Service layer
53
+
54
+ ## Data Flow
55
+
56
+ **System Metrics Flow:**
57
+
58
+ 1. Widget requests data via PluginAPI
59
+ 2. PluginAPI checks rate limiter
60
+ 3. Widget calls getData() which may use:
61
+ - Worker pool for systeminformation calls
62
+ - Cache for recent data
63
+ - Direct fetch for real-time data
64
+ 4. Data returns to widget
65
+ 5. Widget renders to blessed elements
66
+
67
+ **Gateway Data Flow:**
68
+
69
+ 1. GatewayManager initialized with endpoints
70
+ 2. Periodic fetch from `/api/sessions`, `/api/agents`
71
+ 3. Checksum verification (optional)
72
+ 4. Data aggregated from multiple endpoints
73
+ 5. Stored in SQLite database
74
+ 6. Widgets query database for display
75
+
76
+ **Widget Plugin Flow:**
77
+
78
+ 1. WidgetLoader discovers plugins from `~/.openclaw/plugins/`
79
+ 2. Manifest validated (`src/plugin-manifest-validator.js`)
80
+ 3. Dependencies resolved (`src/widgets/dependency-resolver.js`)
81
+ 4. Widget class loaded dynamically
82
+ 5. BaseWidget lifecycle: init -> create -> getData -> render -> destroy
83
+ 6. Config watcher enables hot-reload
84
+
85
+ ## Key Abstractions
86
+
87
+ **BaseWidget:**
88
+ - Purpose: Base class for all widgets
89
+ - Location: `src/widgets/plugin-api.js` (class BaseWidget)
90
+ - Pattern: Template method pattern with lifecycle hooks
91
+ - Methods: init(), create(screen, theme), getData(), render(data), destroy()
92
+
93
+ **PluginAPI:**
94
+ - Purpose: Stable API for widget development
95
+ - Location: `src/widgets/plugin-api.js`
96
+ - Pattern: Facade pattern with rate limiting
97
+ - Extension points: registerExtensionPoint(), extend(), registerProvider()
98
+
99
+ **WidgetLoader:**
100
+ - Purpose: Lazy loading and plugin management
101
+ - Location: `src/widgets/widget-loader.js`
102
+ - Pattern: Registry + Factory pattern
103
+ - Features: Priority-based loading, dependency resolution, hot-reload
104
+
105
+ **GatewayManager:**
106
+ - Purpose: Multi-endpoint gateway aggregation
107
+ - Location: `src/gateway-manager.js`
108
+ - Pattern: Manager pattern with aggregation
109
+ - Features: Checksum verification, retry logic, endpoint health tracking
110
+
111
+ **Error Boundaries:**
112
+ - Purpose: Isolate widget failures
113
+ - Location: `src/widgets/widget-error-boundary.js`
114
+ - Pattern: Decorator pattern
115
+ - Features: Per-widget error isolation, automatic retry
116
+
117
+ ## Entry Points
118
+
119
+ **Main Entry:**
120
+ - Location: `index.js`
121
+ - Triggers: CLI execution (`clawdash` or `node index.js`)
122
+ - Responsibilities:
123
+ - Parse CLI args (`src/cli/index.js`)
124
+ - Initialize database
125
+ - Setup blessed screen
126
+ - Load widgets via WidgetLoader
127
+ - Setup keyboard handlers
128
+ - Start refresh loop
129
+
130
+ **CLI Commands:**
131
+ - Location: `src/cli/`
132
+ - Files: args.js, help.js, version.js, validate-plugin.js, validate-config.js
133
+ - Exports centralized in: `src/cli/index.js`
134
+
135
+ **Worker Entry:**
136
+ - Location: `src/workers/system-worker.js`
137
+ - Triggers: WorkerPool initialization
138
+ - Responsibilities: Execute systeminformation calls in separate threads
139
+
140
+ ## State Management
141
+
142
+ **Theme State:**
143
+ - File: `src/themes.js`
144
+ - Pattern: Singleton with observer pattern
145
+ - Detection: Auto-detects system dark/light mode
146
+ - Persistence: Settings file
147
+
148
+ **Settings State:**
149
+ - File: `src/config.js` (constants), `src/validation.js` (validation)
150
+ - Pattern: Immutable constants with validation
151
+ - Storage: JSON file at `~/.openclaw/dashboard-settings.json`
152
+
153
+ **Widget State:**
154
+ - File: `src/widgets/widget-loader.js`
155
+ - Pattern: Registry with metadata
156
+ - Storage: In-memory Map instances
157
+
158
+ **Performance State:**
159
+ - File: `src/performance-monitor.js`
160
+ - Pattern: Observer with periodic sampling
161
+ - Metrics: Memory usage, worker pool stats
162
+
163
+ ## Error Handling
164
+
165
+ **Strategy:** Hierarchical error classes with boundary isolation
166
+
167
+ **Patterns:**
168
+ - Custom error hierarchy: `DashboardError` -> specific errors
169
+ - Widget error boundaries isolate failures
170
+ - Plugin error analyzer for debugging
171
+ - Rate-limited error reporting
172
+
173
+ **Error Classes:**
174
+ - `src/errors.js`: DashboardError, ConfigError, SettingsError, GatewayError, etc.
175
+ - `src/plugin-errors.js`: PluginError, PluginErrorAnalyzer
176
+
177
+ ## Cross-Cutting Concerns
178
+
179
+ **Logging:**
180
+ - Location: `src/logger.js`
181
+ - Pattern: Centralized with level filtering
182
+ - Output: Console + file (`~/.openclaw/claw-dashboard.log`)
183
+
184
+ **Validation:**
185
+ - Location: `src/validation.js`
186
+ - Pattern: Schema-based with detailed error messages
187
+ - Scope: Settings, file paths, refresh intervals
188
+
189
+ **Security:**
190
+ - Location: `src/security.js`
191
+ - Pattern: Input sanitization + path validation
192
+ - Features: Path traversal prevention, file permission management
193
+
194
+ **Rate Limiting:**
195
+ - Location: `src/alerts.js` (RateLimiter class)
196
+ - Pattern: Token bucket per category
197
+ - Integration: PluginAPI uses for API calls
198
+
199
+ **Caching:**
200
+ - Location: `src/cache.js`
201
+ - Pattern: TTL-based with category-specific timeouts
202
+ - Features: Debounce, throttle, memoization
203
+
204
+ ---
205
+
206
+ *Architecture analysis: 2026-02-28*