claw-dashboard 2.1.0 → 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 (90) hide show
  1. package/CHANGELOG.md +29 -1
  2. package/docs/API.md +1 -2
  3. package/index.js +32 -42
  4. package/package.json +23 -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/src/widgets/builtin-widgets.js +0 -94
  14. package/src/widgets/index.js +0 -1
  15. package/.c8rc.json +0 -38
  16. package/.dockerignore +0 -68
  17. package/.github/dependabot.yml +0 -45
  18. package/.github/pull_request_template.md +0 -39
  19. package/.github/workflows/ci.yml +0 -147
  20. package/.github/workflows/release.yml +0 -40
  21. package/.github/workflows/security.yml +0 -84
  22. package/.husky/pre-commit +0 -1
  23. package/.planning/codebase/ARCHITECTURE.md +0 -206
  24. package/.planning/codebase/INTEGRATIONS.md +0 -150
  25. package/.planning/codebase/STACK.md +0 -122
  26. package/.planning/codebase/STRUCTURE.md +0 -201
  27. package/CONTRIBUTING.md +0 -378
  28. package/Dockerfile +0 -54
  29. package/FEATURES.md +0 -307
  30. package/TODO.md +0 -28
  31. package/ai.openclaw.dashboard.plist +0 -35
  32. package/build-cjs.js +0 -127
  33. package/cjs-shim.js +0 -13
  34. package/dist/clawdash +0 -1729
  35. package/dist/clawdash.meta.json +0 -2236
  36. package/dist/widgets.cjs +0 -6511
  37. package/docker-compose.yml +0 -67
  38. package/esbuild.config.js +0 -158
  39. package/eslint.config.js +0 -56
  40. package/examples/plugins/README.md +0 -122
  41. package/examples/plugins/api-status/index.js +0 -294
  42. package/examples/plugins/api-status/plugin.json +0 -19
  43. package/examples/plugins/hello-world/index.js +0 -104
  44. package/examples/plugins/hello-world/plugin.json +0 -15
  45. package/examples/plugins/system-metrics-chart/index.js +0 -339
  46. package/examples/plugins/system-metrics-chart/plugin.json +0 -18
  47. package/examples/plugins/weather-widget/index.js +0 -136
  48. package/examples/plugins/weather-widget/plugin.json +0 -19
  49. package/index.cjs +0 -23005
  50. package/jest.config.js +0 -11
  51. package/scripts/release.js +0 -595
  52. package/src/database.js +0 -734
  53. package/tests/alerts.test.js +0 -437
  54. package/tests/auto-save.test.js +0 -529
  55. package/tests/cache.test.js +0 -317
  56. package/tests/cli.test.js +0 -351
  57. package/tests/command-palette.test.js +0 -320
  58. package/tests/config-processor.test.js +0 -452
  59. package/tests/config-validator.test.js +0 -710
  60. package/tests/config-watcher.test.js +0 -594
  61. package/tests/config.test.js +0 -755
  62. package/tests/database.test.js +0 -438
  63. package/tests/errors.test.js +0 -189
  64. package/tests/example-plugins.test.js +0 -624
  65. package/tests/integration.test.js +0 -1321
  66. package/tests/loading-states.test.js +0 -300
  67. package/tests/manifest-validation-on-load.test.js +0 -671
  68. package/tests/performance-monitor.test.js +0 -190
  69. package/tests/plugin-api-rate-limit.test.js +0 -302
  70. package/tests/plugin-errors.test.js +0 -311
  71. package/tests/plugin-lifecycle-e2e.test.js +0 -1036
  72. package/tests/plugin-reload.test.js +0 -764
  73. package/tests/rate-limiter.test.js +0 -539
  74. package/tests/retry.test.js +0 -308
  75. package/tests/security.test.js +0 -411
  76. package/tests/settings-modal.test.js +0 -226
  77. package/tests/theme-selector.test.js +0 -57
  78. package/tests/utils.js +0 -242
  79. package/tests/utils.test.js +0 -317
  80. package/tests/validate-plugin-cli.test.js +0 -359
  81. package/tests/validation.test.js +0 -837
  82. package/tests/web-server.test.js +0 -646
  83. package/tests/widget-arrange-mode.test.js +0 -183
  84. package/tests/widget-config-hot-reload.test.js +0 -465
  85. package/tests/widget-dependency.test.js +0 -591
  86. package/tests/widget-error-boundary.test.js +0 -749
  87. package/tests/widget-error-isolation.test.js +0 -469
  88. package/tests/widget-integration.test.js +0 -1147
  89. package/tests/widget-refresh-intervals.test.js +0 -284
  90. package/tests/worker-pool.test.js +0 -522
@@ -1,308 +0,0 @@
1
- /**
2
- * Integration tests for retry logic with mock failures
3
- */
4
-
5
- import retry from '../src/retry.js';
6
-
7
- // Simple mock helper that properly tracks call counts
8
- function createMockFn(successValue, errorSequence = []) {
9
- let errorIndex = 0;
10
- return async (...args) => {
11
- if (errorIndex < errorSequence.length) {
12
- const err = errorSequence[errorIndex++];
13
- throw err;
14
- }
15
- return successValue;
16
- };
17
- }
18
-
19
- describe('Retry Logic', () => {
20
- describe('withRetry', () => {
21
- test('should succeed on first attempt when function succeeds', async () => {
22
- let callCount = 0;
23
- const fn = async () => {
24
- callCount++;
25
- return 'success';
26
- };
27
-
28
- const wrapped = retry.withRetry(fn);
29
- const result = await wrapped();
30
-
31
- expect(result).toBe('success');
32
- expect(callCount).toBe(1);
33
- });
34
-
35
- test('should retry on failure and eventually succeed', async () => {
36
- const mockFn = createMockFn(
37
- 'success',
38
- [new Error('Network timeout'), new Error('Connection refused')]
39
- );
40
-
41
- const wrapped = retry.withRetry(mockFn);
42
- const result = await wrapped();
43
-
44
- expect(result).toBe('success');
45
- });
46
-
47
- test('should fail after max retries exceeded', async () => {
48
- const error = new Error('Network timeout');
49
- const mockFn = async () => {
50
- throw error;
51
- };
52
-
53
- const wrapped = retry.withRetry(mockFn, { maxRetries: 2 });
54
-
55
- await expect(wrapped()).rejects.toThrow('Network timeout');
56
- });
57
-
58
- test('should not retry on non-retryable errors', async () => {
59
- const error = new Error('Bad Request');
60
- error.status = 400;
61
- let callCount = 0;
62
- const mockFn = async () => {
63
- callCount++;
64
- throw error;
65
- };
66
-
67
- const wrapped = retry.withRetry(mockFn);
68
-
69
- await expect(wrapped()).rejects.toThrow('Bad Request');
70
- expect(callCount).toBe(1);
71
- });
72
-
73
- test('should retry on retryable HTTP status codes', async () => {
74
- const mockFn = createMockFn(
75
- 'success',
76
- [{ message: 'Server Error', status: 500 }]
77
- );
78
-
79
- const wrapped = retry.withRetry(mockFn);
80
- const result = await wrapped();
81
-
82
- expect(result).toBe('success');
83
- });
84
-
85
- test('should retry on retryable error codes', async () => {
86
- const mockFn = createMockFn(
87
- 'success',
88
- [{ message: 'Connection refused', code: 'ECONNREFUSED' }]
89
- );
90
-
91
- const wrapped = retry.withRetry(mockFn);
92
- const result = await wrapped();
93
-
94
- expect(result).toBe('success');
95
- });
96
-
97
- test('should respect custom maxRetries option', async () => {
98
- const error = new Error('Network timeout');
99
- let attempts = 0;
100
- const mockFn = async () => {
101
- attempts++;
102
- throw error;
103
- };
104
-
105
- const wrapped = retry.withRetry(mockFn, { maxRetries: 5, initialDelay: 100 });
106
-
107
- await expect(wrapped()).rejects.toThrow();
108
- expect(attempts).toBe(6);
109
- }, 30000);
110
-
111
- test('should pass arguments to wrapped function', async () => {
112
- let receivedArgs = null;
113
- const mockFn = async (...args) => {
114
- receivedArgs = args;
115
- return 'result';
116
- };
117
-
118
- const wrapped = retry.withRetry(mockFn);
119
- await wrapped('arg1', 'arg2');
120
-
121
- expect(receivedArgs).toEqual(['arg1', 'arg2']);
122
- });
123
-
124
- test('should use custom retryable statuses', async () => {
125
- const mockFn = createMockFn(
126
- 'success',
127
- [{ message: 'Bad Request', status: 400 }]
128
- );
129
-
130
- const wrapped = retry.withRetry(mockFn, {
131
- retryableStatuses: [400, 500]
132
- });
133
-
134
- const result = await wrapped();
135
- expect(result).toBe('success');
136
- });
137
- });
138
-
139
- describe('calculateDelay', () => {
140
- test('should calculate exponential backoff delay', () => {
141
- const options = {
142
- initialDelay: 1000,
143
- maxDelay: 10000,
144
- backoffMultiplier: 2
145
- };
146
-
147
- const delay0 = retry.calculateDelay(0, options);
148
- expect(delay0).toBeGreaterThanOrEqual(900);
149
- expect(delay0).toBeLessThanOrEqual(1100);
150
-
151
- const delay1 = retry.calculateDelay(1, options);
152
- expect(delay1).toBeGreaterThanOrEqual(1800);
153
- expect(delay1).toBeLessThanOrEqual(2200);
154
-
155
- const delay2 = retry.calculateDelay(2, options);
156
- expect(delay2).toBeGreaterThanOrEqual(3600);
157
- expect(delay2).toBeLessThanOrEqual(4400);
158
- });
159
-
160
- test('should not exceed maxDelay', () => {
161
- const options = {
162
- initialDelay: 1000,
163
- maxDelay: 5000,
164
- backoffMultiplier: 2
165
- };
166
-
167
- const delay = retry.calculateDelay(10, options);
168
- expect(delay).toBeLessThanOrEqual(5500);
169
- });
170
- });
171
-
172
- describe('isRetryableError', () => {
173
- test('should return true for retryable error codes', () => {
174
- const options = { retryableErrors: ['ECONNREFUSED', 'ETIMEDOUT'] };
175
-
176
- expect(retry.isRetryableError({ code: 'ECONNREFUSED' }, options)).toBe(true);
177
- expect(retry.isRetryableError({ code: 'ETIMEDOUT' }, options)).toBe(true);
178
- });
179
-
180
- test('should return true for retryable HTTP statuses', () => {
181
- const options = { retryableStatuses: [500, 503] };
182
-
183
- expect(retry.isRetryableError({ status: 500 }, options)).toBe(true);
184
- expect(retry.isRetryableError({ status: 503 }, options)).toBe(true);
185
- });
186
-
187
- test('should return false for non-retryable errors', () => {
188
- const options = {
189
- retryableErrors: ['ECONNREFUSED'],
190
- retryableStatuses: [500]
191
- };
192
-
193
- expect(retry.isRetryableError({ code: 'ENOMEM' }, options)).toBe(false);
194
- expect(retry.isRetryableError({ status: 404 }, options)).toBe(false);
195
- // Use truly non-retryable message
196
- expect(retry.isRetryableError({ message: 'Invalid input provided' }, options)).toBe(false);
197
- });
198
- });
199
-
200
- describe('retryUntil', () => {
201
- test('should succeed when function eventually succeeds', async () => {
202
- let attempts = 0;
203
- const fn = async () => {
204
- attempts++;
205
- if (attempts < 3) {
206
- throw new Error('Not ready yet');
207
- }
208
- return 'ready';
209
- };
210
-
211
- const result = await retry.retryUntil(fn, 5000, 50);
212
-
213
- expect(result).toBe('ready');
214
- expect(attempts).toBe(3);
215
- });
216
-
217
- test('should timeout when function never succeeds', async () => {
218
- const fn = async () => {
219
- throw new Error('Network error');
220
- };
221
-
222
- await expect(
223
- retry.retryUntil(fn, 100, 20)
224
- ).rejects.toThrow('Retry timeout');
225
- });
226
- });
227
-
228
- describe('createRetryableFetch', () => {
229
- test('should retry on 5xx errors', async () => {
230
- let attempts = 0;
231
- const mockFetch = async () => {
232
- attempts++;
233
- if (attempts === 1) {
234
- throw { message: 'Server Error', status: 500 };
235
- }
236
- return { status: 200, data: 'ok' };
237
- };
238
-
239
- const wrappedFetch = retry.createRetryableFetch(mockFetch);
240
- const response = await wrappedFetch('http://test.com');
241
-
242
- expect(response.status).toBe(200);
243
- expect(attempts).toBe(2);
244
- });
245
-
246
- test('should not retry on 4xx errors', async () => {
247
- let attempts = 0;
248
- const mockFetch = async () => {
249
- attempts++;
250
- return { status: 404, statusText: 'Not Found' };
251
- };
252
-
253
- const wrappedFetch = retry.createRetryableFetch(mockFetch);
254
- const response = await wrappedFetch('http://test.com');
255
-
256
- expect(response.status).toBe(404);
257
- expect(attempts).toBe(1);
258
- });
259
- });
260
-
261
- describe('retryBatch', () => {
262
- test('should execute all functions with retries', async () => {
263
- let callCount1 = 0;
264
- let callCount3 = 0;
265
- const fn1 = async () => {
266
- callCount1++;
267
- if (callCount1 === 1) throw new Error('Network timeout');
268
- return 'result1';
269
- };
270
- const fn2 = async () => 'result2';
271
- const fn3 = async () => {
272
- callCount3++;
273
- if (callCount3 < 3) throw new Error('Network timeout');
274
- return 'result3';
275
- };
276
-
277
- const results = await retry.retryBatch([fn1, fn2, fn3], { maxRetries: 2 });
278
-
279
- expect(results[0].status).toBe('fulfilled');
280
- expect(results[0].value).toBe('result1');
281
- expect(results[1].status).toBe('fulfilled');
282
- expect(results[1].value).toBe('result2');
283
- expect(results[2].status).toBe('fulfilled');
284
- expect(results[2].value).toBe('result3');
285
- });
286
-
287
- test('should handle batch with all failures', async () => {
288
- const fn1 = async () => { throw new Error('Network timeout'); };
289
- const fn2 = async () => { throw new Error('Connection refused'); };
290
-
291
- const results = await retry.retryBatch([fn1, fn2], { maxRetries: 1 });
292
-
293
- expect(results[0].status).toBe('rejected');
294
- expect(results[1].status).toBe('rejected');
295
- });
296
- });
297
-
298
- describe('DEFAULT_OPTIONS', () => {
299
- test('should have sensible defaults', () => {
300
- expect(retry.DEFAULT_OPTIONS.maxRetries).toBe(3);
301
- expect(retry.DEFAULT_OPTIONS.initialDelay).toBe(1000);
302
- expect(retry.DEFAULT_OPTIONS.maxDelay).toBe(10000);
303
- expect(retry.DEFAULT_OPTIONS.backoffMultiplier).toBe(2);
304
- expect(retry.DEFAULT_OPTIONS.retryableStatuses).toContain(500);
305
- expect(retry.DEFAULT_OPTIONS.retryableErrors).toContain('ECONNREFUSED');
306
- });
307
- });
308
- });