claw-dashboard 2.1.1 → 2.2.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 (89) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/docs/API.md +1 -2
  3. package/index.js +31 -41
  4. package/package.json +22 -12
  5. package/src/auto-save.js +11 -5
  6. package/src/cli/export-snapshot.js +3 -1
  7. package/src/cli/import-snapshot.js +3 -1
  8. package/src/config.js +9 -15
  9. package/src/errors.js +0 -9
  10. package/src/security.js +6 -2
  11. package/src/snapshot.js +73 -26
  12. package/src/web-server.js +7 -10
  13. package/.c8rc.json +0 -38
  14. package/.dockerignore +0 -68
  15. package/.github/dependabot.yml +0 -45
  16. package/.github/pull_request_template.md +0 -39
  17. package/.github/workflows/ci.yml +0 -147
  18. package/.github/workflows/release.yml +0 -40
  19. package/.github/workflows/security.yml +0 -84
  20. package/.husky/pre-commit +0 -1
  21. package/.planning/codebase/ARCHITECTURE.md +0 -206
  22. package/.planning/codebase/INTEGRATIONS.md +0 -150
  23. package/.planning/codebase/STACK.md +0 -122
  24. package/.planning/codebase/STRUCTURE.md +0 -201
  25. package/CONTRIBUTING.md +0 -378
  26. package/Dockerfile +0 -54
  27. package/FEATURES.md +0 -307
  28. package/TODO.md +0 -28
  29. package/ai.openclaw.dashboard.plist +0 -35
  30. package/build-cjs.js +0 -127
  31. package/cjs-shim.js +0 -13
  32. package/dist/clawdash +0 -1729
  33. package/dist/clawdash.meta.json +0 -2236
  34. package/dist/widgets.cjs +0 -6511
  35. package/docker-compose.yml +0 -67
  36. package/esbuild.config.js +0 -158
  37. package/eslint.config.js +0 -56
  38. package/examples/plugins/README.md +0 -122
  39. package/examples/plugins/api-status/index.js +0 -294
  40. package/examples/plugins/api-status/plugin.json +0 -19
  41. package/examples/plugins/hello-world/index.js +0 -104
  42. package/examples/plugins/hello-world/plugin.json +0 -15
  43. package/examples/plugins/system-metrics-chart/index.js +0 -339
  44. package/examples/plugins/system-metrics-chart/plugin.json +0 -18
  45. package/examples/plugins/weather-widget/index.js +0 -136
  46. package/examples/plugins/weather-widget/plugin.json +0 -19
  47. package/index.cjs +0 -23005
  48. package/jest.config.js +0 -11
  49. package/scripts/release.js +0 -595
  50. package/src/database.js +0 -734
  51. package/tests/alerts.test.js +0 -437
  52. package/tests/auto-save.test.js +0 -529
  53. package/tests/cache.test.js +0 -317
  54. package/tests/cli.test.js +0 -351
  55. package/tests/command-palette.test.js +0 -320
  56. package/tests/config-processor.test.js +0 -452
  57. package/tests/config-validator.test.js +0 -710
  58. package/tests/config-watcher.test.js +0 -594
  59. package/tests/config.test.js +0 -755
  60. package/tests/database.test.js +0 -438
  61. package/tests/errors.test.js +0 -189
  62. package/tests/example-plugins.test.js +0 -624
  63. package/tests/integration.test.js +0 -1321
  64. package/tests/loading-states.test.js +0 -300
  65. package/tests/manifest-validation-on-load.test.js +0 -671
  66. package/tests/performance-monitor.test.js +0 -190
  67. package/tests/plugin-api-rate-limit.test.js +0 -302
  68. package/tests/plugin-errors.test.js +0 -311
  69. package/tests/plugin-lifecycle-e2e.test.js +0 -1036
  70. package/tests/plugin-reload.test.js +0 -764
  71. package/tests/rate-limiter.test.js +0 -539
  72. package/tests/removed-dependencies.test.js +0 -74
  73. package/tests/retry.test.js +0 -308
  74. package/tests/security.test.js +0 -411
  75. package/tests/settings-modal.test.js +0 -226
  76. package/tests/theme-selector.test.js +0 -57
  77. package/tests/utils.js +0 -242
  78. package/tests/utils.test.js +0 -317
  79. package/tests/validate-plugin-cli.test.js +0 -359
  80. package/tests/validation.test.js +0 -837
  81. package/tests/web-server.test.js +0 -646
  82. package/tests/widget-arrange-mode.test.js +0 -183
  83. package/tests/widget-config-hot-reload.test.js +0 -465
  84. package/tests/widget-dependency.test.js +0 -591
  85. package/tests/widget-error-boundary.test.js +0 -749
  86. package/tests/widget-error-isolation.test.js +0 -469
  87. package/tests/widget-integration.test.js +0 -1147
  88. package/tests/widget-refresh-intervals.test.js +0 -284
  89. package/tests/worker-pool.test.js +0 -522
@@ -1,311 +0,0 @@
1
- /**
2
- * Plugin Errors Tests
3
- * Tests for enhanced plugin error messages and diagnostics
4
- */
5
-
6
- import {
7
- PluginError,
8
- PluginErrorAnalyzer,
9
- PLUGIN_ERROR_CODES,
10
- formatPluginError,
11
- extractErrorInfo,
12
- } from '../src/plugin-errors.js';
13
-
14
- describe('PluginError', () => {
15
- test('creates PluginError with code and message', () => {
16
- const error = new PluginError(
17
- PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND,
18
- 'Plugin manifest not found',
19
- { pluginId: 'test-plugin' }
20
- );
21
-
22
- expect(error.message).toBe('Plugin manifest not found');
23
- expect(error.code).toBe(PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND);
24
- expect(error.pluginId).toBe('test-plugin');
25
- expect(error.name).toBe('PluginError');
26
- });
27
-
28
- test('provides suggestion based on error code', () => {
29
- const error = new PluginError(
30
- PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND,
31
- 'Manifest not found',
32
- { pluginId: 'test-plugin' }
33
- );
34
-
35
- expect(error.suggestion).toContain('Create a plugin.json');
36
- expect(error.getHint()).toContain('Create a plugin.json file');
37
- });
38
-
39
- test('provides documentation link when available', () => {
40
- const error = new PluginError(
41
- PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND,
42
- 'Manifest not found',
43
- { pluginId: 'test-plugin' }
44
- );
45
-
46
- expect(error.docs).toContain('github.com');
47
- });
48
-
49
- test('getFormattedMessage includes all helpful information', () => {
50
- const error = new PluginError(
51
- PLUGIN_ERROR_CODES.MANIFEST_MISSING_FIELD,
52
- 'Missing required field',
53
- { pluginId: 'test-plugin' }
54
- );
55
-
56
- const formatted = error.getFormattedMessage();
57
- expect(formatted).toContain('Plugin Error');
58
- expect(formatted).toContain(PLUGIN_ERROR_CODES.MANIFEST_MISSING_FIELD);
59
- expect(formatted).toContain('test-plugin');
60
- expect(formatted).toContain('💡 Suggestion');
61
- expect(formatted).toContain('📚 Documentation');
62
- });
63
-
64
- test('toJSON includes all properties', () => {
65
- const error = new PluginError(
66
- PLUGIN_ERROR_CODES.ENTRY_NOT_FOUND,
67
- 'Entry point not found',
68
- { pluginId: 'test-plugin', extra: 'detail' }
69
- );
70
-
71
- const json = error.toJSON();
72
- expect(json.code).toBe(PLUGIN_ERROR_CODES.ENTRY_NOT_FOUND);
73
- expect(json.pluginId).toBe('test-plugin');
74
- expect(json.suggestion).toBeDefined();
75
- expect(json.docs).toBeDefined();
76
- });
77
-
78
- test('handles error codes without full suggestions', () => {
79
- const error = new PluginError(
80
- 'UNKNOWN_CODE',
81
- 'Unknown error',
82
- { pluginId: 'test-plugin' }
83
- );
84
-
85
- expect(error.suggestion).toBe('Check the plugin documentation for more information');
86
- expect(error.docs).toBeNull();
87
- });
88
-
89
- test('extracts pluginId from details', () => {
90
- const error1 = new PluginError(
91
- PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND,
92
- 'Error',
93
- { pluginId: 'explicit-id' }
94
- );
95
- expect(error1.pluginId).toBe('explicit-id');
96
-
97
- const error2 = new PluginError(
98
- PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND,
99
- 'Error',
100
- { id: 'id-from-details' }
101
- );
102
- expect(error2.pluginId).toBe('id-from-details');
103
- });
104
- });
105
-
106
- describe('PluginErrorAnalyzer', () => {
107
- describe('analyze', () => {
108
- test('analyzes manifest JSON parse error', () => {
109
- const originalError = new Error('Unexpected token } in JSON');
110
- const error = PluginErrorAnalyzer.analyze(originalError, 'test-plugin', {
111
- phase: 'manifest',
112
- });
113
-
114
- expect(error.code).toBe(PLUGIN_ERROR_CODES.MANIFEST_INVALID_JSON);
115
- expect(error.message).toContain('test-plugin');
116
- expect(error.suggestion).toContain('JSON');
117
- });
118
-
119
- test('analyzes manifest not found error', () => {
120
- const originalError = new Error('ENOENT: file not found');
121
- const error = PluginErrorAnalyzer.analyze(originalError, 'test-plugin', {
122
- phase: 'manifest',
123
- });
124
-
125
- expect(error.code).toBe(PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND);
126
- });
127
-
128
- test('analyzes entry point export error', () => {
129
- const originalError = new Error('does not provide an export');
130
- const error = PluginErrorAnalyzer.analyze(originalError, 'test-plugin', {
131
- phase: 'entry',
132
- });
133
-
134
- expect(error.code).toBe(PLUGIN_ERROR_CODES.ENTRY_NO_EXPORT);
135
- });
136
-
137
- test('analyzes widget method missing error', () => {
138
- const originalError = new Error('missing required methods: render, getData');
139
- const error = PluginErrorAnalyzer.analyze(originalError, 'test-plugin', {
140
- phase: 'widget',
141
- });
142
-
143
- expect(error.code).toBe(PLUGIN_ERROR_CODES.WIDGET_MISSING_METHODS);
144
- });
145
-
146
- test('analyzes path validation error', () => {
147
- const originalError = new Error('invalid path: traversal detected');
148
- const error = PluginErrorAnalyzer.analyze(originalError, 'test-plugin', {});
149
-
150
- expect(error.code).toBe(PLUGIN_ERROR_CODES.PATH_INVALID);
151
- });
152
-
153
- test('analyzes dependency missing error', () => {
154
- const originalError = new Error('dependency not found: other-plugin');
155
- const error = PluginErrorAnalyzer.analyze(originalError, 'test-plugin', {});
156
-
157
- expect(error.code).toBe(PLUGIN_ERROR_CODES.DEPENDENCY_MISSING);
158
- });
159
-
160
- test('analyzes circular dependency error', () => {
161
- const originalError = new Error('circular dependency detected');
162
- const error = PluginErrorAnalyzer.analyze(originalError, 'test-plugin', {});
163
-
164
- expect(error.code).toBe(PLUGIN_ERROR_CODES.DEPENDENCY_CIRCULAR);
165
- });
166
-
167
- test('falls back to generic error code for unknown errors', () => {
168
- const originalError = new Error('some random error');
169
- const error = PluginErrorAnalyzer.analyze(originalError, 'test-plugin', {});
170
-
171
- expect(error.code).toBe(PLUGIN_ERROR_CODES.PLUGIN_LOAD_ERROR);
172
- });
173
- });
174
-
175
- describe('checkCommonMistakes', () => {
176
- test('detects missing super() call', () => {
177
- const error = new Error('Error in constructor');
178
- error.stack = 'Error\n at new MyWidget (file.js:5:5)\n at super call';
179
-
180
- const result = PluginErrorAnalyzer.checkCommonMistakes(error);
181
- // Note: the actual detection depends on stack trace content
182
- expect(result).toBeNull(); // Since our mock stack doesn't contain actual 'super' keyword
183
- });
184
-
185
- test('detects missing module', () => {
186
- const error = new Error("Cannot find module 'some-package'");
187
- const result = PluginErrorAnalyzer.checkCommonMistakes(error);
188
-
189
- expect(result).toBeTruthy();
190
- expect(result.mistake).toBe('Missing import/module');
191
- expect(result.fix).toContain('npm install');
192
- });
193
-
194
- test('detects calling non-function', () => {
195
- const error = new Error('foo is not a function');
196
- const result = PluginErrorAnalyzer.checkCommonMistakes(error);
197
-
198
- expect(result).toBeTruthy();
199
- expect(result.mistake).toBe('Calling a non-function');
200
- });
201
-
202
- test('detects undefined property access', () => {
203
- const error = new Error("Cannot read property 'foo' of undefined");
204
- const result = PluginErrorAnalyzer.checkCommonMistakes(error);
205
-
206
- expect(result).toBeTruthy();
207
- expect(result.mistake).toContain('undefined');
208
- expect(result.fix).toContain('?.');
209
- });
210
-
211
- test('detects trailing comma in JSON', () => {
212
- const error = new Error('Unexpected token } in JSON');
213
- const result = PluginErrorAnalyzer.checkCommonMistakes(error);
214
-
215
- expect(result).toBeTruthy();
216
- expect(result.mistake).toContain('Trailing comma');
217
- });
218
-
219
- test('detects invalid JSON syntax', () => {
220
- const error = new Error('Unexpected token in JSON at position 42');
221
- const result = PluginErrorAnalyzer.checkCommonMistakes(error);
222
-
223
- expect(result).toBeTruthy();
224
- expect(result.mistake).toContain('JSON');
225
- });
226
-
227
- test('returns null for unrecognized errors', () => {
228
- const error = new Error('completely unexpected error');
229
- const result = PluginErrorAnalyzer.checkCommonMistakes(error);
230
-
231
- expect(result).toBeNull();
232
- });
233
- });
234
- });
235
-
236
- describe('formatPluginError', () => {
237
- test('returns formatted message by default', () => {
238
- const error = new PluginError(
239
- PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND,
240
- 'Test error',
241
- { pluginId: 'test' }
242
- );
243
-
244
- const formatted = formatPluginError(error);
245
- expect(formatted).toContain('Plugin Error');
246
- expect(formatted).toContain('💡 Suggestion');
247
- });
248
-
249
- test('returns compact message when requested', () => {
250
- const error = new PluginError(
251
- PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND,
252
- 'Test error',
253
- { pluginId: 'test' }
254
- );
255
-
256
- const formatted = formatPluginError(error, { compact: true });
257
- expect(formatted).toContain(PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND);
258
- expect(formatted).not.toContain('💡 Suggestion'); // Compact doesn't include full format
259
- });
260
- });
261
-
262
- describe('extractErrorInfo', () => {
263
- test('extracts info from PluginError', () => {
264
- const error = new PluginError(
265
- PLUGIN_ERROR_CODES.MANIFEST_INVALID_JSON,
266
- 'Test error',
267
- { pluginId: 'test' }
268
- );
269
-
270
- const info = extractErrorInfo(error);
271
- expect(info.isPluginError).toBe(true);
272
- expect(info.code).toBe(PLUGIN_ERROR_CODES.MANIFEST_INVALID_JSON);
273
- expect(info.pluginId).toBe('test');
274
- expect(info.suggestion).toBeDefined();
275
- expect(info.docs).toBeDefined();
276
- expect(info.hasFix).toBe(true);
277
- expect(info.formatted).toBeDefined();
278
- });
279
-
280
- test('extracts info from regular Error', () => {
281
- const error = new Error('regular error');
282
-
283
- const info = extractErrorInfo(error);
284
- expect(info.isPluginError).toBe(false);
285
- expect(info.message).toBe('regular error');
286
- expect(info.commonMistake).toBeNull();
287
- });
288
-
289
- test('analyzes common mistakes for regular errors', () => {
290
- const error = new Error('Cannot find module');
291
-
292
- const info = extractErrorInfo(error);
293
- expect(info.isPluginError).toBe(false);
294
- expect(info.commonMistake).toBeTruthy();
295
- expect(info.commonMistake.mistake).toBe('Missing import/module');
296
- });
297
- });
298
-
299
- describe('PLUGIN_ERROR_CODES', () => {
300
- test('contains all expected error codes', () => {
301
- expect(PLUGIN_ERROR_CODES.MANIFEST_NOT_FOUND).toBe('PLUGIN_MANIFEST_NOT_FOUND');
302
- expect(PLUGIN_ERROR_CODES.MANIFEST_INVALID_JSON).toBe('PLUGIN_MANIFEST_INVALID_JSON');
303
- expect(PLUGIN_ERROR_CODES.MANIFEST_MISSING_FIELD).toBe('PLUGIN_MANIFEST_MISSING_FIELD');
304
- expect(PLUGIN_ERROR_CODES.ENTRY_NOT_FOUND).toBe('PLUGIN_ENTRY_NOT_FOUND');
305
- expect(PLUGIN_ERROR_CODES.ENTRY_NO_EXPORT).toBe('PLUGIN_ENTRY_NO_EXPORT');
306
- expect(PLUGIN_ERROR_CODES.WIDGET_MISSING_METHODS).toBe('PLUGIN_WIDGET_MISSING_METHODS');
307
- expect(PLUGIN_ERROR_CODES.PATH_INVALID).toBe('PLUGIN_PATH_INVALID');
308
- expect(PLUGIN_ERROR_CODES.DEPENDENCY_MISSING).toBe('PLUGIN_DEPENDENCY_MISSING');
309
- expect(PLUGIN_ERROR_CODES.PLUGIN_LOAD_ERROR).toBe('PLUGIN_LOAD_ERROR');
310
- });
311
- });