tlc-claude-code 1.4.4 → 1.4.6

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 (72) hide show
  1. package/dashboard/dist/App.js +28 -2
  2. package/dashboard/dist/api/health-diagnostics.d.ts +26 -0
  3. package/dashboard/dist/api/health-diagnostics.js +85 -0
  4. package/dashboard/dist/api/health-diagnostics.test.d.ts +1 -0
  5. package/dashboard/dist/api/health-diagnostics.test.js +126 -0
  6. package/dashboard/dist/api/index.d.ts +5 -0
  7. package/dashboard/dist/api/index.js +5 -0
  8. package/dashboard/dist/api/notes-api.d.ts +18 -0
  9. package/dashboard/dist/api/notes-api.js +68 -0
  10. package/dashboard/dist/api/notes-api.test.d.ts +1 -0
  11. package/dashboard/dist/api/notes-api.test.js +113 -0
  12. package/dashboard/dist/api/safeFetch.d.ts +50 -0
  13. package/dashboard/dist/api/safeFetch.js +135 -0
  14. package/dashboard/dist/api/safeFetch.test.d.ts +1 -0
  15. package/dashboard/dist/api/safeFetch.test.js +215 -0
  16. package/dashboard/dist/api/tasks-api.d.ts +32 -0
  17. package/dashboard/dist/api/tasks-api.js +98 -0
  18. package/dashboard/dist/api/tasks-api.test.d.ts +1 -0
  19. package/dashboard/dist/api/tasks-api.test.js +383 -0
  20. package/dashboard/dist/components/BugsPane.d.ts +20 -0
  21. package/dashboard/dist/components/BugsPane.js +210 -0
  22. package/dashboard/dist/components/BugsPane.test.d.ts +1 -0
  23. package/dashboard/dist/components/BugsPane.test.js +256 -0
  24. package/dashboard/dist/components/HealthPane.d.ts +3 -1
  25. package/dashboard/dist/components/HealthPane.js +44 -6
  26. package/dashboard/dist/components/HealthPane.test.js +105 -2
  27. package/dashboard/dist/components/RouterPane.d.ts +4 -3
  28. package/dashboard/dist/components/RouterPane.js +60 -57
  29. package/dashboard/dist/components/RouterPane.test.js +150 -96
  30. package/dashboard/dist/components/UpdateBanner.d.ts +26 -0
  31. package/dashboard/dist/components/UpdateBanner.js +30 -0
  32. package/dashboard/dist/components/UpdateBanner.test.d.ts +1 -0
  33. package/dashboard/dist/components/UpdateBanner.test.js +96 -0
  34. package/dashboard/dist/components/ui/EmptyState.d.ts +14 -0
  35. package/dashboard/dist/components/ui/EmptyState.js +58 -0
  36. package/dashboard/dist/components/ui/EmptyState.test.d.ts +1 -0
  37. package/dashboard/dist/components/ui/EmptyState.test.js +97 -0
  38. package/dashboard/dist/components/ui/ErrorState.d.ts +17 -0
  39. package/dashboard/dist/components/ui/ErrorState.js +80 -0
  40. package/dashboard/dist/components/ui/ErrorState.test.d.ts +1 -0
  41. package/dashboard/dist/components/ui/ErrorState.test.js +166 -0
  42. package/dashboard/package.json +3 -0
  43. package/package.json +4 -1
  44. package/server/dashboard/index.html +284 -13
  45. package/server/dashboard/login.html +262 -0
  46. package/server/index.js +304 -0
  47. package/server/lib/api-provider.js +104 -186
  48. package/server/lib/api-provider.test.js +238 -336
  49. package/server/lib/cli-detector.js +90 -166
  50. package/server/lib/cli-detector.test.js +114 -269
  51. package/server/lib/cli-provider.js +142 -212
  52. package/server/lib/cli-provider.test.js +196 -349
  53. package/server/lib/debug.test.js +3 -3
  54. package/server/lib/devserver-router-api.js +54 -249
  55. package/server/lib/devserver-router-api.test.js +126 -426
  56. package/server/lib/introspect.js +309 -0
  57. package/server/lib/introspect.test.js +286 -0
  58. package/server/lib/model-router.js +107 -245
  59. package/server/lib/model-router.test.js +122 -313
  60. package/server/lib/output-schemas.js +146 -269
  61. package/server/lib/output-schemas.test.js +106 -307
  62. package/server/lib/plan-parser.js +59 -16
  63. package/server/lib/provider-interface.js +99 -153
  64. package/server/lib/provider-interface.test.js +228 -394
  65. package/server/lib/provider-queue.js +164 -158
  66. package/server/lib/provider-queue.test.js +186 -315
  67. package/server/lib/router-config.js +99 -221
  68. package/server/lib/router-config.test.js +83 -237
  69. package/server/lib/router-setup-command.js +94 -419
  70. package/server/lib/router-setup-command.test.js +96 -375
  71. package/server/lib/router-status-api.js +93 -0
  72. package/server/lib/router-status-api.test.js +270 -0
@@ -1,158 +1,164 @@
1
- /**
2
- * Provider Queue - Queue concurrent provider tasks
3
- *
4
- * Features:
5
- * - Configurable max concurrent executions
6
- * - FIFO ordering with priority support
7
- * - Task timeout handling
8
- * - Queue status reporting
9
- */
10
-
11
- /**
12
- * Priority levels
13
- */
14
- export const PRIORITY = {
15
- URGENT: 10,
16
- NORMAL: 5,
17
- LOW: 1,
18
- };
19
-
20
- /**
21
- * Create a new task queue
22
- * @param {Object} [options] - Queue options
23
- * @param {number} [options.maxConcurrent=3] - Maximum concurrent tasks
24
- * @param {number} [options.timeout=120000] - Task timeout in ms
25
- * @returns {Object} Queue instance
26
- */
27
- export function createQueue(options = {}) {
28
- const maxConcurrent = options.maxConcurrent ?? 3;
29
- const timeout = options.timeout ?? 120000;
30
-
31
- return {
32
- maxConcurrent,
33
- timeout,
34
- pending: [],
35
- running: new Set(),
36
- completed: 0,
37
- failed: 0,
38
- _processing: false,
39
- };
40
- }
41
-
42
- /**
43
- * Process the next tasks in the queue
44
- * @param {Object} queue - Queue instance
45
- */
46
- function processQueue(queue) {
47
- if (queue._processing) return;
48
- queue._processing = true;
49
-
50
- while (queue.running.size < queue.maxConcurrent && queue.pending.length > 0) {
51
- // Sort by priority (highest first)
52
- queue.pending.sort((a, b) => (b.priority || PRIORITY.NORMAL) - (a.priority || PRIORITY.NORMAL));
53
-
54
- const task = queue.pending.shift();
55
- if (!task) continue;
56
-
57
- queue.running.add(task.id);
58
-
59
- // Execute with timeout
60
- const timeoutPromise = new Promise((_, reject) => {
61
- task.timeoutId = setTimeout(() => {
62
- reject(new Error(`Task ${task.id} timeout after ${queue.timeout}ms`));
63
- }, queue.timeout);
64
- });
65
-
66
- Promise.race([task.execute(), timeoutPromise])
67
- .then((result) => {
68
- clearTimeout(task.timeoutId);
69
- queue.running.delete(task.id);
70
- queue.completed++;
71
- task.resolve(result);
72
- processQueue(queue);
73
- })
74
- .catch((error) => {
75
- clearTimeout(task.timeoutId);
76
- queue.running.delete(task.id);
77
- queue.failed++;
78
- task.reject(error);
79
- processQueue(queue);
80
- });
81
- }
82
-
83
- queue._processing = false;
84
- }
85
-
86
- /**
87
- * Add a task to the queue
88
- * @param {Object} queue - Queue instance
89
- * @param {Object} task - Task to add
90
- * @param {string} task.id - Unique task ID
91
- * @param {Function} task.execute - Async function to execute
92
- * @param {number} [task.priority] - Task priority (default: PRIORITY.NORMAL)
93
- * @returns {Promise<any>} Promise that resolves with task result
94
- */
95
- export function enqueue(queue, task) {
96
- return new Promise((resolve, reject) => {
97
- const queuedTask = {
98
- ...task,
99
- priority: task.priority ?? PRIORITY.NORMAL,
100
- resolve,
101
- reject,
102
- enqueuedAt: Date.now(),
103
- };
104
-
105
- queue.pending.push(queuedTask);
106
- processQueue(queue);
107
- });
108
- }
109
-
110
- /**
111
- * Get queue status
112
- * @param {Object} queue - Queue instance
113
- * @returns {Object} Queue status
114
- */
115
- export function getStatus(queue) {
116
- return {
117
- pending: queue.pending.length,
118
- running: queue.running.size,
119
- completed: queue.completed,
120
- failed: queue.failed,
121
- maxConcurrent: queue.maxConcurrent,
122
- };
123
- }
124
-
125
- /**
126
- * Clear all pending tasks from the queue
127
- * @param {Object} queue - Queue instance
128
- */
129
- export function clearQueue(queue) {
130
- // Reject all pending tasks
131
- for (const task of queue.pending) {
132
- task.reject(new Error('Queue cleared'));
133
- if (task.timeoutId) {
134
- clearTimeout(task.timeoutId);
135
- }
136
- }
137
-
138
- queue.pending = [];
139
- }
140
-
141
- /**
142
- * Wait for all tasks to complete
143
- * @param {Object} queue - Queue instance
144
- * @returns {Promise<void>} Resolves when queue is drained
145
- */
146
- export function drainQueue(queue) {
147
- return new Promise((resolve) => {
148
- const checkDrained = () => {
149
- if (queue.pending.length === 0 && queue.running.size === 0) {
150
- resolve();
151
- } else {
152
- setTimeout(checkDrained, 10);
153
- }
154
- };
155
-
156
- checkDrained();
157
- });
158
- }
1
+ /**
2
+ * Provider Queue - Queue concurrent provider tasks
3
+ * Phase 33, Task 8
4
+ */
5
+
6
+ export const Priority = {
7
+ URGENT: 'urgent',
8
+ NORMAL: 'normal',
9
+ LOW: 'low',
10
+ };
11
+
12
+ const PRIORITY_ORDER = {
13
+ [Priority.URGENT]: 0,
14
+ [Priority.NORMAL]: 1,
15
+ [Priority.LOW]: 2,
16
+ };
17
+
18
+ let taskIdCounter = 0;
19
+
20
+ export class ProviderQueue {
21
+ constructor(options = {}) {
22
+ this.maxConcurrent = options.maxConcurrent || 3;
23
+ this.timeout = options.timeout || 30000;
24
+ this.pending = [];
25
+ this.running = new Map();
26
+ this.completed = new Map();
27
+ this.processing = false;
28
+ }
29
+
30
+ enqueue(task) {
31
+ const id = task.id || `task-${++taskIdCounter}`;
32
+ const queuedTask = {
33
+ id,
34
+ priority: task.priority || Priority.NORMAL,
35
+ execute: task.execute || (() => Promise.resolve()),
36
+ prompt: task.prompt,
37
+ status: 'pending',
38
+ enqueuedAt: Date.now(),
39
+ };
40
+
41
+ this.pending.push(queuedTask);
42
+ this._sortPending();
43
+
44
+ if (this.processing) {
45
+ this._processNext();
46
+ }
47
+
48
+ return id;
49
+ }
50
+
51
+ _sortPending() {
52
+ this.pending.sort((a, b) => {
53
+ const priorityDiff = PRIORITY_ORDER[a.priority] - PRIORITY_ORDER[b.priority];
54
+ if (priorityDiff !== 0) return priorityDiff;
55
+ return a.enqueuedAt - b.enqueuedAt;
56
+ });
57
+ }
58
+
59
+ process() {
60
+ this.processing = true;
61
+ this._processNext();
62
+ }
63
+
64
+ async _processNext() {
65
+ while (
66
+ this.processing &&
67
+ this.pending.length > 0 &&
68
+ this.running.size < this.maxConcurrent
69
+ ) {
70
+ const task = this.pending.shift();
71
+ if (!task) break;
72
+
73
+ task.status = 'running';
74
+ task.startedAt = Date.now();
75
+ this.running.set(task.id, task);
76
+
77
+ this._executeTask(task);
78
+ }
79
+ }
80
+
81
+ async _executeTask(task) {
82
+ const timeoutId = setTimeout(() => {
83
+ if (this.running.has(task.id)) {
84
+ task.status = 'cancelled';
85
+ task.error = 'Timeout';
86
+ this.running.delete(task.id);
87
+ this.completed.set(task.id, task);
88
+ this._processNext();
89
+ }
90
+ }, this.timeout);
91
+
92
+ try {
93
+ const result = await task.execute();
94
+ clearTimeout(timeoutId);
95
+
96
+ if (this.running.has(task.id)) {
97
+ task.status = 'completed';
98
+ task.result = result;
99
+ task.completedAt = Date.now();
100
+ this.running.delete(task.id);
101
+ this.completed.set(task.id, task);
102
+ }
103
+ } catch (error) {
104
+ clearTimeout(timeoutId);
105
+
106
+ if (this.running.has(task.id)) {
107
+ task.status = 'failed';
108
+ task.error = error.message;
109
+ task.completedAt = Date.now();
110
+ this.running.delete(task.id);
111
+ this.completed.set(task.id, task);
112
+ }
113
+ }
114
+
115
+ this._processNext();
116
+ }
117
+
118
+ getStatus() {
119
+ return {
120
+ pending: this.pending.length,
121
+ running: this.running.size,
122
+ completed: this.completed.size,
123
+ };
124
+ }
125
+
126
+ getTaskStatus(taskId) {
127
+ if (this.running.has(taskId)) {
128
+ return this.running.get(taskId).status;
129
+ }
130
+ if (this.completed.has(taskId)) {
131
+ return this.completed.get(taskId).status;
132
+ }
133
+ const pending = this.pending.find(t => t.id === taskId);
134
+ if (pending) {
135
+ return pending.status;
136
+ }
137
+ return null;
138
+ }
139
+
140
+ clearQueue() {
141
+ this.pending = [];
142
+ }
143
+
144
+ async drainQueue() {
145
+ this.process();
146
+
147
+ return new Promise((resolve) => {
148
+ const check = () => {
149
+ if (this.pending.length === 0 && this.running.size === 0) {
150
+ resolve();
151
+ } else {
152
+ setTimeout(check, 10);
153
+ }
154
+ };
155
+ check();
156
+ });
157
+ }
158
+
159
+ stop() {
160
+ this.processing = false;
161
+ }
162
+ }
163
+
164
+ export default { ProviderQueue, Priority };