@agent-relay/daemon 0.1.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.
- package/dist/agent-manager.d.ts +134 -0
- package/dist/agent-manager.d.ts.map +1 -0
- package/dist/agent-manager.js +578 -0
- package/dist/agent-manager.js.map +1 -0
- package/dist/agent-registry.d.ts +99 -0
- package/dist/agent-registry.d.ts.map +1 -0
- package/dist/agent-registry.js +213 -0
- package/dist/agent-registry.js.map +1 -0
- package/dist/agent-signing.d.ts +158 -0
- package/dist/agent-signing.d.ts.map +1 -0
- package/dist/agent-signing.js +523 -0
- package/dist/agent-signing.js.map +1 -0
- package/dist/api.d.ts +106 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +876 -0
- package/dist/api.js.map +1 -0
- package/dist/auth.d.ts +94 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +197 -0
- package/dist/auth.js.map +1 -0
- package/dist/channel-membership-store.d.ts +55 -0
- package/dist/channel-membership-store.d.ts.map +1 -0
- package/dist/channel-membership-store.js +176 -0
- package/dist/channel-membership-store.js.map +1 -0
- package/dist/cli-auth.d.ts +89 -0
- package/dist/cli-auth.d.ts.map +1 -0
- package/dist/cli-auth.js +792 -0
- package/dist/cli-auth.js.map +1 -0
- package/dist/cloud-sync.d.ts +150 -0
- package/dist/cloud-sync.d.ts.map +1 -0
- package/dist/cloud-sync.js +446 -0
- package/dist/cloud-sync.js.map +1 -0
- package/dist/connection.d.ts +130 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +438 -0
- package/dist/connection.js.map +1 -0
- package/dist/consensus-integration.d.ts +167 -0
- package/dist/consensus-integration.d.ts.map +1 -0
- package/dist/consensus-integration.js +371 -0
- package/dist/consensus-integration.js.map +1 -0
- package/dist/consensus.d.ts +271 -0
- package/dist/consensus.d.ts.map +1 -0
- package/dist/consensus.js +632 -0
- package/dist/consensus.js.map +1 -0
- package/dist/delivery-tracker.d.ts +34 -0
- package/dist/delivery-tracker.d.ts.map +1 -0
- package/dist/delivery-tracker.js +104 -0
- package/dist/delivery-tracker.js.map +1 -0
- package/dist/enhanced-features.d.ts +118 -0
- package/dist/enhanced-features.d.ts.map +1 -0
- package/dist/enhanced-features.js +176 -0
- package/dist/enhanced-features.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/index.d.ts +73 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +241 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/orchestrator.d.ts +217 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +1143 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/rate-limiter.d.ts +68 -0
- package/dist/rate-limiter.d.ts.map +1 -0
- package/dist/rate-limiter.js +130 -0
- package/dist/rate-limiter.js.map +1 -0
- package/dist/registry.d.ts +9 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +9 -0
- package/dist/registry.js.map +1 -0
- package/dist/relay-ledger.d.ts +261 -0
- package/dist/relay-ledger.d.ts.map +1 -0
- package/dist/relay-ledger.js +532 -0
- package/dist/relay-ledger.js.map +1 -0
- package/dist/relay-watchdog.d.ts +125 -0
- package/dist/relay-watchdog.d.ts.map +1 -0
- package/dist/relay-watchdog.js +611 -0
- package/dist/relay-watchdog.js.map +1 -0
- package/dist/repo-manager.d.ts +116 -0
- package/dist/repo-manager.d.ts.map +1 -0
- package/dist/repo-manager.js +384 -0
- package/dist/repo-manager.js.map +1 -0
- package/dist/router.d.ts +370 -0
- package/dist/router.d.ts.map +1 -0
- package/dist/router.js +1437 -0
- package/dist/router.js.map +1 -0
- package/dist/server.d.ts +174 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1001 -0
- package/dist/server.js.map +1 -0
- package/dist/spawn-manager.d.ts +78 -0
- package/dist/spawn-manager.d.ts.map +1 -0
- package/dist/spawn-manager.js +165 -0
- package/dist/spawn-manager.js.map +1 -0
- package/dist/sync-queue.d.ts +116 -0
- package/dist/sync-queue.d.ts.map +1 -0
- package/dist/sync-queue.js +361 -0
- package/dist/sync-queue.js.map +1 -0
- package/dist/types.d.ts +133 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/dist/workspace-manager.d.ts +80 -0
- package/dist/workspace-manager.d.ts.map +1 -0
- package/dist/workspace-manager.js +314 -0
- package/dist/workspace-manager.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optimized Cloud Sync Queue
|
|
3
|
+
*
|
|
4
|
+
* Handles batched, compressed, resilient message syncing to cloud.
|
|
5
|
+
* Features:
|
|
6
|
+
* - Adaptive batching (size/time/bytes triggers)
|
|
7
|
+
* - Gzip compression for payloads over threshold
|
|
8
|
+
* - Disk spillover for offline resilience
|
|
9
|
+
* - Retry with exponential backoff
|
|
10
|
+
* - Startup reconciliation
|
|
11
|
+
*/
|
|
12
|
+
import * as fs from 'node:fs/promises';
|
|
13
|
+
import * as path from 'node:path';
|
|
14
|
+
import * as os from 'node:os';
|
|
15
|
+
import { gzip } from 'node:zlib';
|
|
16
|
+
import { promisify } from 'node:util';
|
|
17
|
+
import { generateId } from '@agent-relay/wrapper';
|
|
18
|
+
import { createLogger } from '@agent-relay/utils/logger';
|
|
19
|
+
const gzipAsync = promisify(gzip);
|
|
20
|
+
const log = createLogger('sync-queue');
|
|
21
|
+
export const DEFAULT_SYNC_QUEUE_CONFIG = {
|
|
22
|
+
cloudUrl: 'https://agent-relay.com',
|
|
23
|
+
apiKey: '',
|
|
24
|
+
batchSize: 100,
|
|
25
|
+
batchDelayMs: 200,
|
|
26
|
+
maxBatchBytes: 512 * 1024, // 512KB
|
|
27
|
+
compressionThreshold: 1024, // 1KB
|
|
28
|
+
spillDir: path.join(os.tmpdir(), 'agent-relay-sync'),
|
|
29
|
+
maxSpillFiles: 100,
|
|
30
|
+
maxRetries: 3,
|
|
31
|
+
retryDelayMs: 1000,
|
|
32
|
+
verbose: false,
|
|
33
|
+
};
|
|
34
|
+
export class SyncQueue {
|
|
35
|
+
config;
|
|
36
|
+
queue = [];
|
|
37
|
+
queueBytes = 0;
|
|
38
|
+
flushTimer;
|
|
39
|
+
flushing = false;
|
|
40
|
+
flushPromise;
|
|
41
|
+
// Stats
|
|
42
|
+
stats = {
|
|
43
|
+
queuedMessages: 0,
|
|
44
|
+
queuedBytes: 0,
|
|
45
|
+
totalSynced: 0,
|
|
46
|
+
totalFailed: 0,
|
|
47
|
+
totalCompressed: 0,
|
|
48
|
+
totalBytesTransferred: 0,
|
|
49
|
+
spilledFiles: 0,
|
|
50
|
+
};
|
|
51
|
+
constructor(config) {
|
|
52
|
+
this.config = { ...DEFAULT_SYNC_QUEUE_CONFIG, ...config };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Queue a message for sync to cloud.
|
|
56
|
+
* May trigger an immediate flush if thresholds are exceeded.
|
|
57
|
+
*/
|
|
58
|
+
async enqueue(message) {
|
|
59
|
+
// Wait for any in-progress flush
|
|
60
|
+
if (this.flushPromise) {
|
|
61
|
+
await this.flushPromise;
|
|
62
|
+
}
|
|
63
|
+
const msgJson = JSON.stringify(message);
|
|
64
|
+
const sizeBytes = Buffer.byteLength(msgJson, 'utf-8');
|
|
65
|
+
this.queue.push({ message, sizeBytes });
|
|
66
|
+
this.queueBytes += sizeBytes;
|
|
67
|
+
this.stats.queuedMessages = this.queue.length;
|
|
68
|
+
this.stats.queuedBytes = this.queueBytes;
|
|
69
|
+
// Check flush triggers
|
|
70
|
+
const shouldFlush = this.queue.length >= this.config.batchSize ||
|
|
71
|
+
this.queueBytes >= this.config.maxBatchBytes;
|
|
72
|
+
if (shouldFlush) {
|
|
73
|
+
await this.flush();
|
|
74
|
+
}
|
|
75
|
+
else if (!this.flushTimer) {
|
|
76
|
+
this.flushTimer = setTimeout(() => {
|
|
77
|
+
this.flush().catch((err) => {
|
|
78
|
+
log.error('Timer flush failed', { error: String(err) });
|
|
79
|
+
});
|
|
80
|
+
}, this.config.batchDelayMs);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Enqueue multiple messages at once.
|
|
85
|
+
*/
|
|
86
|
+
async enqueueBatch(messages) {
|
|
87
|
+
for (const msg of messages) {
|
|
88
|
+
await this.enqueue(msg);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Flush all queued messages to cloud.
|
|
93
|
+
*/
|
|
94
|
+
async flush() {
|
|
95
|
+
// Clear timer
|
|
96
|
+
if (this.flushTimer) {
|
|
97
|
+
clearTimeout(this.flushTimer);
|
|
98
|
+
this.flushTimer = undefined;
|
|
99
|
+
}
|
|
100
|
+
// Skip if empty or already flushing
|
|
101
|
+
if (this.queue.length === 0 || this.flushing) {
|
|
102
|
+
return { synced: 0, duplicates: 0, failed: 0, compressed: false, bytesTransferred: 0 };
|
|
103
|
+
}
|
|
104
|
+
this.flushing = true;
|
|
105
|
+
// Take current batch
|
|
106
|
+
const batch = this.queue;
|
|
107
|
+
const batchBytes = this.queueBytes;
|
|
108
|
+
this.queue = [];
|
|
109
|
+
this.queueBytes = 0;
|
|
110
|
+
this.stats.queuedMessages = 0;
|
|
111
|
+
this.stats.queuedBytes = 0;
|
|
112
|
+
this.flushPromise = this.syncBatch(batch, batchBytes);
|
|
113
|
+
try {
|
|
114
|
+
const result = await this.flushPromise;
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
this.flushing = false;
|
|
119
|
+
this.flushPromise = undefined;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sync a batch of messages to cloud with retry and spillover.
|
|
124
|
+
*/
|
|
125
|
+
async syncBatch(batch, batchBytes) {
|
|
126
|
+
const messages = batch.map((q) => q.message);
|
|
127
|
+
let lastError = null;
|
|
128
|
+
for (let attempt = 0; attempt < this.config.maxRetries; attempt++) {
|
|
129
|
+
try {
|
|
130
|
+
const result = await this.sendToCloud(messages, batchBytes);
|
|
131
|
+
this.stats.totalSynced += result.synced;
|
|
132
|
+
this.stats.totalBytesTransferred += result.bytesTransferred;
|
|
133
|
+
if (result.compressed) {
|
|
134
|
+
this.stats.totalCompressed++;
|
|
135
|
+
}
|
|
136
|
+
this.stats.lastSyncAt = Date.now();
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
catch (err) {
|
|
140
|
+
lastError = err;
|
|
141
|
+
this.stats.lastError = lastError.message;
|
|
142
|
+
if (attempt < this.config.maxRetries - 1) {
|
|
143
|
+
// Exponential backoff
|
|
144
|
+
const delay = this.config.retryDelayMs * Math.pow(2, attempt);
|
|
145
|
+
if (this.config.verbose) {
|
|
146
|
+
log.warn(`Sync attempt ${attempt + 1} failed, retrying in ${delay}ms`, {
|
|
147
|
+
error: lastError.message,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
await this.sleep(delay);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
// All retries failed - spill to disk
|
|
155
|
+
log.error('Sync failed after retries, spilling to disk', {
|
|
156
|
+
count: messages.length,
|
|
157
|
+
error: lastError?.message,
|
|
158
|
+
});
|
|
159
|
+
await this.spillToDisk(messages);
|
|
160
|
+
this.stats.totalFailed += messages.length;
|
|
161
|
+
return {
|
|
162
|
+
synced: 0,
|
|
163
|
+
duplicates: 0,
|
|
164
|
+
failed: messages.length,
|
|
165
|
+
compressed: false,
|
|
166
|
+
bytesTransferred: 0,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Send messages to cloud API with optional compression.
|
|
171
|
+
*/
|
|
172
|
+
async sendToCloud(messages, _estimatedBytes) {
|
|
173
|
+
// Transform to API format
|
|
174
|
+
const syncPayload = {
|
|
175
|
+
messages: messages.map((msg) => ({
|
|
176
|
+
id: msg.id,
|
|
177
|
+
ts: msg.ts,
|
|
178
|
+
from: msg.from,
|
|
179
|
+
to: msg.to,
|
|
180
|
+
body: msg.body,
|
|
181
|
+
kind: msg.kind,
|
|
182
|
+
topic: msg.topic,
|
|
183
|
+
thread: msg.thread,
|
|
184
|
+
is_broadcast: msg.is_broadcast,
|
|
185
|
+
is_urgent: msg.is_urgent,
|
|
186
|
+
data: msg.data,
|
|
187
|
+
payload_meta: msg.payloadMeta,
|
|
188
|
+
})),
|
|
189
|
+
};
|
|
190
|
+
const payloadJson = JSON.stringify(syncPayload);
|
|
191
|
+
const payloadBytes = Buffer.byteLength(payloadJson, 'utf-8');
|
|
192
|
+
// Determine if we should compress
|
|
193
|
+
const shouldCompress = payloadBytes > this.config.compressionThreshold;
|
|
194
|
+
let body;
|
|
195
|
+
let contentEncoding;
|
|
196
|
+
if (shouldCompress) {
|
|
197
|
+
body = await gzipAsync(Buffer.from(payloadJson));
|
|
198
|
+
contentEncoding = 'gzip';
|
|
199
|
+
if (this.config.verbose) {
|
|
200
|
+
const ratio = ((1 - body.length / payloadBytes) * 100).toFixed(1);
|
|
201
|
+
log.info(`Compressed ${payloadBytes} → ${body.length} bytes (${ratio}% reduction)`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
body = payloadJson;
|
|
206
|
+
}
|
|
207
|
+
const headers = {
|
|
208
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
209
|
+
'Content-Type': 'application/json',
|
|
210
|
+
};
|
|
211
|
+
if (contentEncoding) {
|
|
212
|
+
headers['Content-Encoding'] = contentEncoding;
|
|
213
|
+
}
|
|
214
|
+
const response = await fetch(`${this.config.cloudUrl}/api/daemons/messages/sync`, {
|
|
215
|
+
method: 'POST',
|
|
216
|
+
headers,
|
|
217
|
+
body,
|
|
218
|
+
});
|
|
219
|
+
if (!response.ok) {
|
|
220
|
+
const errorText = await response.text();
|
|
221
|
+
throw new Error(`Sync failed: ${response.status} - ${errorText}`);
|
|
222
|
+
}
|
|
223
|
+
const result = (await response.json());
|
|
224
|
+
return {
|
|
225
|
+
synced: result.synced,
|
|
226
|
+
duplicates: result.duplicates,
|
|
227
|
+
failed: 0,
|
|
228
|
+
compressed: shouldCompress,
|
|
229
|
+
bytesTransferred: typeof body === 'string' ? Buffer.byteLength(body) : body.length,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Spill failed batch to disk for later recovery.
|
|
234
|
+
*/
|
|
235
|
+
async spillToDisk(messages) {
|
|
236
|
+
try {
|
|
237
|
+
await fs.mkdir(this.config.spillDir, { recursive: true });
|
|
238
|
+
const filename = `spill-${Date.now()}-${generateId().replace(/-/g, '')}.json`;
|
|
239
|
+
const filepath = path.join(this.config.spillDir, filename);
|
|
240
|
+
await fs.writeFile(filepath, JSON.stringify(messages));
|
|
241
|
+
this.stats.spilledFiles++;
|
|
242
|
+
if (this.config.verbose) {
|
|
243
|
+
log.info(`Spilled ${messages.length} messages to ${filename}`);
|
|
244
|
+
}
|
|
245
|
+
// Cleanup old spill files
|
|
246
|
+
await this.cleanupSpillFiles();
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
log.error('Failed to spill to disk', { error: String(err) });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Recover and sync messages from spill files.
|
|
254
|
+
* Call this on startup to resume failed syncs.
|
|
255
|
+
*/
|
|
256
|
+
async recoverSpilledMessages() {
|
|
257
|
+
let recovered = 0;
|
|
258
|
+
let failed = 0;
|
|
259
|
+
try {
|
|
260
|
+
const files = await fs.readdir(this.config.spillDir);
|
|
261
|
+
const spillFiles = files.filter((f) => f.startsWith('spill-')).sort();
|
|
262
|
+
for (const file of spillFiles) {
|
|
263
|
+
const filepath = path.join(this.config.spillDir, file);
|
|
264
|
+
try {
|
|
265
|
+
const content = await fs.readFile(filepath, 'utf-8');
|
|
266
|
+
const messages = JSON.parse(content);
|
|
267
|
+
// Try to sync
|
|
268
|
+
const result = await this.sendToCloud(messages, Buffer.byteLength(content, 'utf-8'));
|
|
269
|
+
if (result.synced > 0 || result.duplicates > 0) {
|
|
270
|
+
// Success - remove spill file
|
|
271
|
+
await fs.unlink(filepath);
|
|
272
|
+
recovered += messages.length;
|
|
273
|
+
this.stats.spilledFiles = Math.max(0, this.stats.spilledFiles - 1);
|
|
274
|
+
if (this.config.verbose) {
|
|
275
|
+
log.info(`Recovered ${messages.length} messages from ${file}`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
failed += messages.length;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
catch (err) {
|
|
283
|
+
log.warn(`Failed to recover ${file}`, { error: String(err) });
|
|
284
|
+
failed++;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
catch (err) {
|
|
289
|
+
// Directory doesn't exist or other error
|
|
290
|
+
if (err.code !== 'ENOENT') {
|
|
291
|
+
log.error('Failed to scan spill directory', { error: String(err) });
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (recovered > 0) {
|
|
295
|
+
log.info(`Recovered ${recovered} messages from spill files`);
|
|
296
|
+
}
|
|
297
|
+
return { recovered, failed };
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Cleanup old spill files beyond the limit.
|
|
301
|
+
*/
|
|
302
|
+
async cleanupSpillFiles() {
|
|
303
|
+
try {
|
|
304
|
+
const files = await fs.readdir(this.config.spillDir);
|
|
305
|
+
const spillFiles = files.filter((f) => f.startsWith('spill-')).sort();
|
|
306
|
+
if (spillFiles.length > this.config.maxSpillFiles) {
|
|
307
|
+
const toDelete = spillFiles.slice(0, spillFiles.length - this.config.maxSpillFiles);
|
|
308
|
+
for (const file of toDelete) {
|
|
309
|
+
await fs.unlink(path.join(this.config.spillDir, file)).catch(() => { });
|
|
310
|
+
}
|
|
311
|
+
if (this.config.verbose) {
|
|
312
|
+
log.info(`Cleaned up ${toDelete.length} old spill files`);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
// Ignore cleanup errors
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Get sync queue statistics.
|
|
322
|
+
*/
|
|
323
|
+
getStats() {
|
|
324
|
+
return { ...this.stats };
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Reset statistics (for testing or periodic reporting).
|
|
328
|
+
*/
|
|
329
|
+
resetStats() {
|
|
330
|
+
this.stats = {
|
|
331
|
+
queuedMessages: this.queue.length,
|
|
332
|
+
queuedBytes: this.queueBytes,
|
|
333
|
+
totalSynced: 0,
|
|
334
|
+
totalFailed: 0,
|
|
335
|
+
totalCompressed: 0,
|
|
336
|
+
totalBytesTransferred: 0,
|
|
337
|
+
spilledFiles: this.stats.spilledFiles, // Preserve spill count
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Gracefully close the queue, flushing any pending messages.
|
|
342
|
+
*/
|
|
343
|
+
async close() {
|
|
344
|
+
if (this.flushTimer) {
|
|
345
|
+
clearTimeout(this.flushTimer);
|
|
346
|
+
this.flushTimer = undefined;
|
|
347
|
+
}
|
|
348
|
+
// Wait for any in-progress flush
|
|
349
|
+
if (this.flushPromise) {
|
|
350
|
+
await this.flushPromise;
|
|
351
|
+
}
|
|
352
|
+
// Flush remaining
|
|
353
|
+
if (this.queue.length > 0) {
|
|
354
|
+
await this.flush();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
sleep(ms) {
|
|
358
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=sync-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-queue.js","sourceRoot":"","sources":["../src/sync-queue.ts"],"names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E,IAAI,CAAC,KAAK,CAAC,MAAM;YACjC,WAAW,EAAE,IAAI,CAAC,UAAU;YAC5B,WAAW,EAAE,CAAC;YACd,WAAW,EAAE,CAAC;YACd,eAAe,EAAE,CAAC;YAClB,qBAAqB,EAAE,CAAC;YACxB,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,uBAAuB;SAC/D,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC9B,CAAC;QAED,iCAAiC;QACjC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,YAAY,CAAC;QAC1B,CAAC;QAED,kBAAkB;QAClB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Daemon Types
|
|
3
|
+
* Core types for the agent-relay daemon
|
|
4
|
+
*/
|
|
5
|
+
export type WorkspaceStatus = 'active' | 'inactive' | 'error';
|
|
6
|
+
export type AgentStatus = 'running' | 'idle' | 'crashed' | 'restarting' | 'stopped';
|
|
7
|
+
export type ProviderType = 'claude' | 'codex' | 'gemini' | 'cursor' | 'generic';
|
|
8
|
+
/**
|
|
9
|
+
* Workspace represents a connected repository/project
|
|
10
|
+
*/
|
|
11
|
+
export interface Workspace {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
path: string;
|
|
15
|
+
status: WorkspaceStatus;
|
|
16
|
+
provider: ProviderType;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
lastActiveAt: Date;
|
|
19
|
+
/** Cloud workspace ID if provisioned via cloud */
|
|
20
|
+
cloudId?: string;
|
|
21
|
+
/** Custom domain if configured */
|
|
22
|
+
customDomain?: string;
|
|
23
|
+
/** Git remote URL */
|
|
24
|
+
gitRemote?: string;
|
|
25
|
+
/** Current branch */
|
|
26
|
+
gitBranch?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Agent running within a workspace
|
|
30
|
+
*/
|
|
31
|
+
export interface Agent {
|
|
32
|
+
id: string;
|
|
33
|
+
name: string;
|
|
34
|
+
workspaceId: string;
|
|
35
|
+
provider: ProviderType;
|
|
36
|
+
status: AgentStatus;
|
|
37
|
+
pid?: number;
|
|
38
|
+
task?: string;
|
|
39
|
+
spawnedAt: Date;
|
|
40
|
+
lastHealthCheck?: Date;
|
|
41
|
+
rssBytes?: number;
|
|
42
|
+
cpuPercent?: number;
|
|
43
|
+
restartCount: number;
|
|
44
|
+
logFile?: string;
|
|
45
|
+
/** Unique agent ID for session resume */
|
|
46
|
+
agentId?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Message between agents or from dashboard
|
|
50
|
+
*/
|
|
51
|
+
export interface AgentMessage {
|
|
52
|
+
id: string;
|
|
53
|
+
from: string;
|
|
54
|
+
to: string;
|
|
55
|
+
workspaceId: string;
|
|
56
|
+
body: string;
|
|
57
|
+
timestamp: Date;
|
|
58
|
+
delivered: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Real-time event for WebSocket updates
|
|
62
|
+
*/
|
|
63
|
+
export interface DaemonEvent {
|
|
64
|
+
type: 'workspace:added' | 'workspace:removed' | 'workspace:updated' | 'workspace:switched' | 'agent:spawned' | 'agent:stopped' | 'agent:crashed' | 'agent:restarted' | 'agent:output' | 'agent:summary' | 'agent:session-end' | 'agent:resource-alert' | 'agent:injection-failed' | 'message:received' | 'message:sent';
|
|
65
|
+
workspaceId?: string;
|
|
66
|
+
agentId?: string;
|
|
67
|
+
data: unknown;
|
|
68
|
+
timestamp: Date;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Dashboard user session
|
|
72
|
+
*/
|
|
73
|
+
export interface UserSession {
|
|
74
|
+
userId: string;
|
|
75
|
+
githubUsername: string;
|
|
76
|
+
avatarUrl?: string;
|
|
77
|
+
activeWorkspaceId?: string;
|
|
78
|
+
connectedAt: Date;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* API daemon configuration (for HTTP/WebSocket API)
|
|
82
|
+
*/
|
|
83
|
+
export interface ApiDaemonConfig {
|
|
84
|
+
/** Port for HTTP/WebSocket API */
|
|
85
|
+
port: number;
|
|
86
|
+
/** Host to bind to */
|
|
87
|
+
host: string;
|
|
88
|
+
/** Allowed CORS origins for HTTP API (empty = no cross-origin access) */
|
|
89
|
+
allowedOrigins?: string[];
|
|
90
|
+
/** Data directory for persistence */
|
|
91
|
+
dataDir: string;
|
|
92
|
+
/** Enable auto-restart for crashed agents */
|
|
93
|
+
autoRestart: boolean;
|
|
94
|
+
/** Max restart attempts */
|
|
95
|
+
maxRestarts: number;
|
|
96
|
+
/** Health check interval in ms */
|
|
97
|
+
healthCheckInterval: number;
|
|
98
|
+
/** Cloud API URL (if using cloud features) */
|
|
99
|
+
cloudApiUrl?: string;
|
|
100
|
+
/** User's authentication token for cloud */
|
|
101
|
+
cloudToken?: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* API request to spawn an agent
|
|
105
|
+
*/
|
|
106
|
+
export interface SpawnAgentRequest {
|
|
107
|
+
name: string;
|
|
108
|
+
provider?: ProviderType;
|
|
109
|
+
task?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* API request to add a workspace
|
|
113
|
+
*/
|
|
114
|
+
export interface AddWorkspaceRequest {
|
|
115
|
+
path: string;
|
|
116
|
+
name?: string;
|
|
117
|
+
provider?: ProviderType;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* API response for workspace list
|
|
121
|
+
*/
|
|
122
|
+
export interface WorkspacesResponse {
|
|
123
|
+
workspaces: Workspace[];
|
|
124
|
+
activeWorkspaceId?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* API response for agents in a workspace
|
|
128
|
+
*/
|
|
129
|
+
export interface AgentsResponse {
|
|
130
|
+
agents: Agent[];
|
|
131
|
+
workspaceId: string;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAC9D,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AACpF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,IAAI,CAAC;IACnB,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,SAAS,CAAC,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.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace Manager
|
|
3
|
+
* Manages multiple workspaces (repositories) and handles switching between them.
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import type { Workspace, WorkspaceStatus, AddWorkspaceRequest } from './types.js';
|
|
7
|
+
export declare class WorkspaceManager extends EventEmitter {
|
|
8
|
+
private workspaces;
|
|
9
|
+
private activeWorkspaceId?;
|
|
10
|
+
private dataDir;
|
|
11
|
+
private workspacesFile;
|
|
12
|
+
constructor(dataDir: string);
|
|
13
|
+
/**
|
|
14
|
+
* Add a new workspace
|
|
15
|
+
*/
|
|
16
|
+
add(request: AddWorkspaceRequest): Workspace;
|
|
17
|
+
/**
|
|
18
|
+
* Remove a workspace
|
|
19
|
+
*/
|
|
20
|
+
remove(workspaceId: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Switch to a workspace (set as active)
|
|
23
|
+
*/
|
|
24
|
+
switchTo(workspaceId: string): Workspace;
|
|
25
|
+
/**
|
|
26
|
+
* Get a workspace by ID
|
|
27
|
+
*/
|
|
28
|
+
get(workspaceId: string): Workspace | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Get the active workspace
|
|
31
|
+
*/
|
|
32
|
+
getActive(): Workspace | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Get all workspaces
|
|
35
|
+
*/
|
|
36
|
+
getAll(): Workspace[];
|
|
37
|
+
/**
|
|
38
|
+
* Find workspace by path
|
|
39
|
+
*/
|
|
40
|
+
findByPath(workspacePath: string): Workspace | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Update workspace status
|
|
43
|
+
*/
|
|
44
|
+
updateStatus(workspaceId: string, status: WorkspaceStatus): void;
|
|
45
|
+
/**
|
|
46
|
+
* Update workspace git info
|
|
47
|
+
*/
|
|
48
|
+
refreshGitInfo(workspaceId: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve path (expand ~ and make absolute)
|
|
51
|
+
*/
|
|
52
|
+
private resolvePath;
|
|
53
|
+
/**
|
|
54
|
+
* Detect provider from workspace files
|
|
55
|
+
*/
|
|
56
|
+
private detectProvider;
|
|
57
|
+
/**
|
|
58
|
+
* Get git info for a workspace
|
|
59
|
+
*/
|
|
60
|
+
private getGitInfo;
|
|
61
|
+
/**
|
|
62
|
+
* Load workspaces from disk
|
|
63
|
+
*/
|
|
64
|
+
private loadWorkspaces;
|
|
65
|
+
/**
|
|
66
|
+
* Save workspaces to disk
|
|
67
|
+
*/
|
|
68
|
+
private saveWorkspaces;
|
|
69
|
+
/**
|
|
70
|
+
* Emit a daemon event
|
|
71
|
+
*/
|
|
72
|
+
private emitEvent;
|
|
73
|
+
/**
|
|
74
|
+
* Clean up workspace temp directory
|
|
75
|
+
* Removes /tmp/relay/{workspaceId}/ which contains sockets and outbox
|
|
76
|
+
*/
|
|
77
|
+
private cleanupWorkspaceTempDir;
|
|
78
|
+
}
|
|
79
|
+
export declare function getWorkspaceManager(dataDir?: string): WorkspaceManager;
|
|
80
|
+
//# sourceMappingURL=workspace-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-manager.d.ts","sourceRoot":"","sources":["../src/workspace-manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EAGf,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAQpB,qBAAa,gBAAiB,SAAQ,YAAY;IAChD,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,iBAAiB,CAAC,CAAS;IACnC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAS;gBAEnB,OAAO,EAAE,MAAM;IAc3B;;OAEG;IACH,GAAG,CAAC,OAAO,EAAE,mBAAmB,GAAG,SAAS;IA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