@rovn-ai/mcp-server 0.1.0 → 0.3.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/server.d.ts +148 -12
- package/dist/server.js +146 -35
- package/package.json +1 -1
package/dist/server.d.ts
CHANGED
|
@@ -27,9 +27,13 @@ export interface ServerConfig {
|
|
|
27
27
|
ownerEmail: string;
|
|
28
28
|
apiKey: string;
|
|
29
29
|
agentId: string;
|
|
30
|
+
sessionId: string;
|
|
30
31
|
}
|
|
31
32
|
export declare function getArg(args: string[], flag: string): string | undefined;
|
|
32
33
|
export declare function createConfig(args: string[]): ServerConfig;
|
|
34
|
+
export declare const config: ServerConfig;
|
|
35
|
+
/** Reset config for testing. */
|
|
36
|
+
export declare function resetConfig(overrides?: Partial<ServerConfig>): void;
|
|
33
37
|
export declare function requireAgent(cfg: ServerConfig): string | null;
|
|
34
38
|
export declare function rovnPost(path: string, body: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
35
39
|
export declare function rovnGet(path: string): Promise<Record<string, unknown>>;
|
|
@@ -61,13 +65,14 @@ export declare const TOOLS: ({
|
|
|
61
65
|
};
|
|
62
66
|
title?: undefined;
|
|
63
67
|
metadata?: undefined;
|
|
68
|
+
task_id?: undefined;
|
|
64
69
|
action?: undefined;
|
|
65
70
|
context?: undefined;
|
|
66
71
|
urgency?: undefined;
|
|
67
72
|
cost?: undefined;
|
|
68
73
|
status?: undefined;
|
|
69
|
-
task_id?: undefined;
|
|
70
74
|
days?: undefined;
|
|
75
|
+
summary?: undefined;
|
|
71
76
|
};
|
|
72
77
|
required: string[];
|
|
73
78
|
};
|
|
@@ -93,6 +98,10 @@ export declare const TOOLS: ({
|
|
|
93
98
|
type: string;
|
|
94
99
|
description: string;
|
|
95
100
|
};
|
|
101
|
+
task_id: {
|
|
102
|
+
type: string;
|
|
103
|
+
description: string;
|
|
104
|
+
};
|
|
96
105
|
name?: undefined;
|
|
97
106
|
capabilities?: undefined;
|
|
98
107
|
action?: undefined;
|
|
@@ -100,8 +109,8 @@ export declare const TOOLS: ({
|
|
|
100
109
|
urgency?: undefined;
|
|
101
110
|
cost?: undefined;
|
|
102
111
|
status?: undefined;
|
|
103
|
-
task_id?: undefined;
|
|
104
112
|
days?: undefined;
|
|
113
|
+
summary?: undefined;
|
|
105
114
|
};
|
|
106
115
|
required: string[];
|
|
107
116
|
};
|
|
@@ -134,9 +143,10 @@ export declare const TOOLS: ({
|
|
|
134
143
|
capabilities?: undefined;
|
|
135
144
|
title?: undefined;
|
|
136
145
|
metadata?: undefined;
|
|
137
|
-
status?: undefined;
|
|
138
146
|
task_id?: undefined;
|
|
147
|
+
status?: undefined;
|
|
139
148
|
days?: undefined;
|
|
149
|
+
summary?: undefined;
|
|
140
150
|
};
|
|
141
151
|
required: string[];
|
|
142
152
|
};
|
|
@@ -166,12 +176,13 @@ export declare const TOOLS: ({
|
|
|
166
176
|
name?: undefined;
|
|
167
177
|
capabilities?: undefined;
|
|
168
178
|
metadata?: undefined;
|
|
179
|
+
task_id?: undefined;
|
|
169
180
|
action?: undefined;
|
|
170
181
|
context?: undefined;
|
|
171
182
|
cost?: undefined;
|
|
172
183
|
status?: undefined;
|
|
173
|
-
task_id?: undefined;
|
|
174
184
|
days?: undefined;
|
|
185
|
+
summary?: undefined;
|
|
175
186
|
};
|
|
176
187
|
required: string[];
|
|
177
188
|
};
|
|
@@ -192,12 +203,13 @@ export declare const TOOLS: ({
|
|
|
192
203
|
capabilities?: undefined;
|
|
193
204
|
title?: undefined;
|
|
194
205
|
metadata?: undefined;
|
|
206
|
+
task_id?: undefined;
|
|
195
207
|
action?: undefined;
|
|
196
208
|
context?: undefined;
|
|
197
209
|
urgency?: undefined;
|
|
198
210
|
cost?: undefined;
|
|
199
|
-
task_id?: undefined;
|
|
200
211
|
days?: undefined;
|
|
212
|
+
summary?: undefined;
|
|
201
213
|
};
|
|
202
214
|
required?: undefined;
|
|
203
215
|
};
|
|
@@ -227,6 +239,7 @@ export declare const TOOLS: ({
|
|
|
227
239
|
urgency?: undefined;
|
|
228
240
|
cost?: undefined;
|
|
229
241
|
days?: undefined;
|
|
242
|
+
summary?: undefined;
|
|
230
243
|
};
|
|
231
244
|
required: string[];
|
|
232
245
|
};
|
|
@@ -246,12 +259,13 @@ export declare const TOOLS: ({
|
|
|
246
259
|
capabilities?: undefined;
|
|
247
260
|
title?: undefined;
|
|
248
261
|
metadata?: undefined;
|
|
262
|
+
task_id?: undefined;
|
|
249
263
|
action?: undefined;
|
|
250
264
|
context?: undefined;
|
|
251
265
|
urgency?: undefined;
|
|
252
266
|
cost?: undefined;
|
|
253
267
|
status?: undefined;
|
|
254
|
-
|
|
268
|
+
summary?: undefined;
|
|
255
269
|
};
|
|
256
270
|
required?: undefined;
|
|
257
271
|
};
|
|
@@ -267,12 +281,68 @@ export declare const TOOLS: ({
|
|
|
267
281
|
capabilities?: undefined;
|
|
268
282
|
title?: undefined;
|
|
269
283
|
metadata?: undefined;
|
|
284
|
+
task_id?: undefined;
|
|
285
|
+
action?: undefined;
|
|
286
|
+
context?: undefined;
|
|
287
|
+
urgency?: undefined;
|
|
288
|
+
cost?: undefined;
|
|
289
|
+
status?: undefined;
|
|
290
|
+
days?: undefined;
|
|
291
|
+
summary?: undefined;
|
|
292
|
+
};
|
|
293
|
+
required?: undefined;
|
|
294
|
+
};
|
|
295
|
+
} | {
|
|
296
|
+
name: string;
|
|
297
|
+
description: string;
|
|
298
|
+
inputSchema: {
|
|
299
|
+
type: "object";
|
|
300
|
+
properties: {
|
|
301
|
+
name: {
|
|
302
|
+
type: string;
|
|
303
|
+
description: string;
|
|
304
|
+
};
|
|
305
|
+
metadata: {
|
|
306
|
+
type: string;
|
|
307
|
+
description: string;
|
|
308
|
+
};
|
|
309
|
+
description?: undefined;
|
|
310
|
+
type?: undefined;
|
|
311
|
+
capabilities?: undefined;
|
|
312
|
+
title?: undefined;
|
|
313
|
+
task_id?: undefined;
|
|
270
314
|
action?: undefined;
|
|
271
315
|
context?: undefined;
|
|
272
316
|
urgency?: undefined;
|
|
273
317
|
cost?: undefined;
|
|
274
318
|
status?: undefined;
|
|
319
|
+
days?: undefined;
|
|
320
|
+
summary?: undefined;
|
|
321
|
+
};
|
|
322
|
+
required?: undefined;
|
|
323
|
+
};
|
|
324
|
+
} | {
|
|
325
|
+
name: string;
|
|
326
|
+
description: string;
|
|
327
|
+
inputSchema: {
|
|
328
|
+
type: "object";
|
|
329
|
+
properties: {
|
|
330
|
+
summary: {
|
|
331
|
+
type: string;
|
|
332
|
+
description: string;
|
|
333
|
+
};
|
|
334
|
+
name?: undefined;
|
|
335
|
+
description?: undefined;
|
|
336
|
+
type?: undefined;
|
|
337
|
+
capabilities?: undefined;
|
|
338
|
+
title?: undefined;
|
|
339
|
+
metadata?: undefined;
|
|
275
340
|
task_id?: undefined;
|
|
341
|
+
action?: undefined;
|
|
342
|
+
context?: undefined;
|
|
343
|
+
urgency?: undefined;
|
|
344
|
+
cost?: undefined;
|
|
345
|
+
status?: undefined;
|
|
276
346
|
days?: undefined;
|
|
277
347
|
};
|
|
278
348
|
required?: undefined;
|
|
@@ -327,13 +397,14 @@ export declare function handleRequest(request: {
|
|
|
327
397
|
};
|
|
328
398
|
title?: undefined;
|
|
329
399
|
metadata?: undefined;
|
|
400
|
+
task_id?: undefined;
|
|
330
401
|
action?: undefined;
|
|
331
402
|
context?: undefined;
|
|
332
403
|
urgency?: undefined;
|
|
333
404
|
cost?: undefined;
|
|
334
405
|
status?: undefined;
|
|
335
|
-
task_id?: undefined;
|
|
336
406
|
days?: undefined;
|
|
407
|
+
summary?: undefined;
|
|
337
408
|
};
|
|
338
409
|
required: string[];
|
|
339
410
|
};
|
|
@@ -359,6 +430,10 @@ export declare function handleRequest(request: {
|
|
|
359
430
|
type: string;
|
|
360
431
|
description: string;
|
|
361
432
|
};
|
|
433
|
+
task_id: {
|
|
434
|
+
type: string;
|
|
435
|
+
description: string;
|
|
436
|
+
};
|
|
362
437
|
name?: undefined;
|
|
363
438
|
capabilities?: undefined;
|
|
364
439
|
action?: undefined;
|
|
@@ -366,8 +441,8 @@ export declare function handleRequest(request: {
|
|
|
366
441
|
urgency?: undefined;
|
|
367
442
|
cost?: undefined;
|
|
368
443
|
status?: undefined;
|
|
369
|
-
task_id?: undefined;
|
|
370
444
|
days?: undefined;
|
|
445
|
+
summary?: undefined;
|
|
371
446
|
};
|
|
372
447
|
required: string[];
|
|
373
448
|
};
|
|
@@ -400,9 +475,10 @@ export declare function handleRequest(request: {
|
|
|
400
475
|
capabilities?: undefined;
|
|
401
476
|
title?: undefined;
|
|
402
477
|
metadata?: undefined;
|
|
403
|
-
status?: undefined;
|
|
404
478
|
task_id?: undefined;
|
|
479
|
+
status?: undefined;
|
|
405
480
|
days?: undefined;
|
|
481
|
+
summary?: undefined;
|
|
406
482
|
};
|
|
407
483
|
required: string[];
|
|
408
484
|
};
|
|
@@ -432,12 +508,13 @@ export declare function handleRequest(request: {
|
|
|
432
508
|
name?: undefined;
|
|
433
509
|
capabilities?: undefined;
|
|
434
510
|
metadata?: undefined;
|
|
511
|
+
task_id?: undefined;
|
|
435
512
|
action?: undefined;
|
|
436
513
|
context?: undefined;
|
|
437
514
|
cost?: undefined;
|
|
438
515
|
status?: undefined;
|
|
439
|
-
task_id?: undefined;
|
|
440
516
|
days?: undefined;
|
|
517
|
+
summary?: undefined;
|
|
441
518
|
};
|
|
442
519
|
required: string[];
|
|
443
520
|
};
|
|
@@ -458,12 +535,13 @@ export declare function handleRequest(request: {
|
|
|
458
535
|
capabilities?: undefined;
|
|
459
536
|
title?: undefined;
|
|
460
537
|
metadata?: undefined;
|
|
538
|
+
task_id?: undefined;
|
|
461
539
|
action?: undefined;
|
|
462
540
|
context?: undefined;
|
|
463
541
|
urgency?: undefined;
|
|
464
542
|
cost?: undefined;
|
|
465
|
-
task_id?: undefined;
|
|
466
543
|
days?: undefined;
|
|
544
|
+
summary?: undefined;
|
|
467
545
|
};
|
|
468
546
|
required?: undefined;
|
|
469
547
|
};
|
|
@@ -493,6 +571,7 @@ export declare function handleRequest(request: {
|
|
|
493
571
|
urgency?: undefined;
|
|
494
572
|
cost?: undefined;
|
|
495
573
|
days?: undefined;
|
|
574
|
+
summary?: undefined;
|
|
496
575
|
};
|
|
497
576
|
required: string[];
|
|
498
577
|
};
|
|
@@ -512,12 +591,13 @@ export declare function handleRequest(request: {
|
|
|
512
591
|
capabilities?: undefined;
|
|
513
592
|
title?: undefined;
|
|
514
593
|
metadata?: undefined;
|
|
594
|
+
task_id?: undefined;
|
|
515
595
|
action?: undefined;
|
|
516
596
|
context?: undefined;
|
|
517
597
|
urgency?: undefined;
|
|
518
598
|
cost?: undefined;
|
|
519
599
|
status?: undefined;
|
|
520
|
-
|
|
600
|
+
summary?: undefined;
|
|
521
601
|
};
|
|
522
602
|
required?: undefined;
|
|
523
603
|
};
|
|
@@ -533,12 +613,68 @@ export declare function handleRequest(request: {
|
|
|
533
613
|
capabilities?: undefined;
|
|
534
614
|
title?: undefined;
|
|
535
615
|
metadata?: undefined;
|
|
616
|
+
task_id?: undefined;
|
|
617
|
+
action?: undefined;
|
|
618
|
+
context?: undefined;
|
|
619
|
+
urgency?: undefined;
|
|
620
|
+
cost?: undefined;
|
|
621
|
+
status?: undefined;
|
|
622
|
+
days?: undefined;
|
|
623
|
+
summary?: undefined;
|
|
624
|
+
};
|
|
625
|
+
required?: undefined;
|
|
626
|
+
};
|
|
627
|
+
} | {
|
|
628
|
+
name: string;
|
|
629
|
+
description: string;
|
|
630
|
+
inputSchema: {
|
|
631
|
+
type: "object";
|
|
632
|
+
properties: {
|
|
633
|
+
name: {
|
|
634
|
+
type: string;
|
|
635
|
+
description: string;
|
|
636
|
+
};
|
|
637
|
+
metadata: {
|
|
638
|
+
type: string;
|
|
639
|
+
description: string;
|
|
640
|
+
};
|
|
641
|
+
description?: undefined;
|
|
642
|
+
type?: undefined;
|
|
643
|
+
capabilities?: undefined;
|
|
644
|
+
title?: undefined;
|
|
645
|
+
task_id?: undefined;
|
|
536
646
|
action?: undefined;
|
|
537
647
|
context?: undefined;
|
|
538
648
|
urgency?: undefined;
|
|
539
649
|
cost?: undefined;
|
|
540
650
|
status?: undefined;
|
|
651
|
+
days?: undefined;
|
|
652
|
+
summary?: undefined;
|
|
653
|
+
};
|
|
654
|
+
required?: undefined;
|
|
655
|
+
};
|
|
656
|
+
} | {
|
|
657
|
+
name: string;
|
|
658
|
+
description: string;
|
|
659
|
+
inputSchema: {
|
|
660
|
+
type: "object";
|
|
661
|
+
properties: {
|
|
662
|
+
summary: {
|
|
663
|
+
type: string;
|
|
664
|
+
description: string;
|
|
665
|
+
};
|
|
666
|
+
name?: undefined;
|
|
667
|
+
description?: undefined;
|
|
668
|
+
type?: undefined;
|
|
669
|
+
capabilities?: undefined;
|
|
670
|
+
title?: undefined;
|
|
671
|
+
metadata?: undefined;
|
|
541
672
|
task_id?: undefined;
|
|
673
|
+
action?: undefined;
|
|
674
|
+
context?: undefined;
|
|
675
|
+
urgency?: undefined;
|
|
676
|
+
cost?: undefined;
|
|
677
|
+
status?: undefined;
|
|
542
678
|
days?: undefined;
|
|
543
679
|
};
|
|
544
680
|
required?: undefined;
|
package/dist/server.js
CHANGED
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
* }
|
|
25
25
|
*/
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.TOOLS = void 0;
|
|
27
|
+
exports.TOOLS = exports.config = void 0;
|
|
28
28
|
exports.getArg = getArg;
|
|
29
29
|
exports.createConfig = createConfig;
|
|
30
|
+
exports.resetConfig = resetConfig;
|
|
30
31
|
exports.requireAgent = requireAgent;
|
|
31
32
|
exports.rovnPost = rovnPost;
|
|
32
33
|
exports.rovnGet = rovnGet;
|
|
@@ -45,9 +46,18 @@ function createConfig(args) {
|
|
|
45
46
|
ownerEmail: getArg(args, '--email') ?? process.env.ROVN_OWNER_EMAIL ?? '',
|
|
46
47
|
apiKey: getArg(args, '--api-key') ?? process.env.ROVN_API_KEY ?? '',
|
|
47
48
|
agentId: getArg(args, '--agent-id') ?? process.env.ROVN_AGENT_ID ?? '',
|
|
49
|
+
sessionId: '',
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
exports.config = createConfig(process.argv.slice(2));
|
|
53
|
+
/** Reset config for testing. */
|
|
54
|
+
function resetConfig(overrides = {}) {
|
|
55
|
+
exports.config.rovnUrl = overrides.rovnUrl ?? 'https://rovn.io';
|
|
56
|
+
exports.config.ownerEmail = overrides.ownerEmail ?? '';
|
|
57
|
+
exports.config.apiKey = overrides.apiKey ?? '';
|
|
58
|
+
exports.config.agentId = overrides.agentId ?? '';
|
|
59
|
+
exports.config.sessionId = overrides.sessionId ?? '';
|
|
60
|
+
}
|
|
51
61
|
function requireAgent(cfg) {
|
|
52
62
|
if (!cfg.agentId || !cfg.apiKey) {
|
|
53
63
|
return 'Not registered. Call rovn_register first.';
|
|
@@ -97,9 +107,9 @@ async function safeFetch(url, init) {
|
|
|
97
107
|
}
|
|
98
108
|
async function rovnPost(path, body) {
|
|
99
109
|
const headers = { 'Content-Type': 'application/json' };
|
|
100
|
-
if (config.apiKey)
|
|
101
|
-
headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
102
|
-
return safeFetch(`${config.rovnUrl}${path}`, {
|
|
110
|
+
if (exports.config.apiKey)
|
|
111
|
+
headers['Authorization'] = `Bearer ${exports.config.apiKey}`;
|
|
112
|
+
return safeFetch(`${exports.config.rovnUrl}${path}`, {
|
|
103
113
|
method: 'POST',
|
|
104
114
|
headers,
|
|
105
115
|
body: JSON.stringify(body),
|
|
@@ -107,15 +117,15 @@ async function rovnPost(path, body) {
|
|
|
107
117
|
}
|
|
108
118
|
async function rovnGet(path) {
|
|
109
119
|
const headers = {};
|
|
110
|
-
if (config.apiKey)
|
|
111
|
-
headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
112
|
-
return safeFetch(`${config.rovnUrl}${path}`, { headers });
|
|
120
|
+
if (exports.config.apiKey)
|
|
121
|
+
headers['Authorization'] = `Bearer ${exports.config.apiKey}`;
|
|
122
|
+
return safeFetch(`${exports.config.rovnUrl}${path}`, { headers });
|
|
113
123
|
}
|
|
114
124
|
async function rovnPatch(path, body) {
|
|
115
125
|
const headers = { 'Content-Type': 'application/json' };
|
|
116
|
-
if (config.apiKey)
|
|
117
|
-
headers['Authorization'] = `Bearer ${config.apiKey}`;
|
|
118
|
-
return safeFetch(`${config.rovnUrl}${path}`, {
|
|
126
|
+
if (exports.config.apiKey)
|
|
127
|
+
headers['Authorization'] = `Bearer ${exports.config.apiKey}`;
|
|
128
|
+
return safeFetch(`${exports.config.rovnUrl}${path}`, {
|
|
119
129
|
method: 'PATCH',
|
|
120
130
|
headers,
|
|
121
131
|
body: JSON.stringify(body),
|
|
@@ -123,15 +133,32 @@ async function rovnPatch(path, body) {
|
|
|
123
133
|
}
|
|
124
134
|
// ─── Auto-Logging (fire-and-forget) ─────────────────────────
|
|
125
135
|
function autoLog(title, type = 'governance') {
|
|
126
|
-
if (!config.agentId || !config.apiKey)
|
|
136
|
+
if (!exports.config.agentId || !exports.config.apiKey)
|
|
127
137
|
return;
|
|
128
138
|
// Fire-and-forget — don't await, don't block the tool response
|
|
129
|
-
rovnPost(`/api/agents/${config.agentId}/activities`, {
|
|
139
|
+
rovnPost(`/api/agents/${exports.config.agentId}/activities`, {
|
|
130
140
|
type,
|
|
131
141
|
title,
|
|
132
142
|
metadata: { source: 'mcp-auto' },
|
|
143
|
+
session_id: exports.config.sessionId || undefined,
|
|
133
144
|
}).catch(() => { });
|
|
134
145
|
}
|
|
146
|
+
// ─── Session Helpers ─────────────────────────────────────────
|
|
147
|
+
async function startSession() {
|
|
148
|
+
if (!exports.config.agentId || !exports.config.apiKey)
|
|
149
|
+
return null;
|
|
150
|
+
try {
|
|
151
|
+
const res = await rovnPost(`/api/agents/${exports.config.agentId}/sessions`, {});
|
|
152
|
+
if (res.success) {
|
|
153
|
+
const data = res.data;
|
|
154
|
+
const sessionId = data.id;
|
|
155
|
+
exports.config.sessionId = sessionId;
|
|
156
|
+
return sessionId;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch { /* ignore session start failures */ }
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
135
162
|
// ─── MCP Tools Definition ───────────────────────────────────
|
|
136
163
|
exports.TOOLS = [
|
|
137
164
|
{
|
|
@@ -162,6 +189,7 @@ exports.TOOLS = [
|
|
|
162
189
|
type: { type: 'string', description: 'Activity type (e.g., code_generation, testing, deployment, review)' },
|
|
163
190
|
description: { type: 'string', description: 'Detailed description of what was done' },
|
|
164
191
|
metadata: { type: 'object', description: 'Additional structured data (e.g., { files_changed: 3 })' },
|
|
192
|
+
task_id: { type: 'string', description: 'Optional task ID to link this activity to a specific task' },
|
|
165
193
|
},
|
|
166
194
|
required: ['title'],
|
|
167
195
|
},
|
|
@@ -234,6 +262,27 @@ exports.TOOLS = [
|
|
|
234
262
|
properties: {},
|
|
235
263
|
},
|
|
236
264
|
},
|
|
265
|
+
{
|
|
266
|
+
name: 'rovn_start_session',
|
|
267
|
+
description: 'Start a new session. Activities logged after this will be automatically grouped under this session.',
|
|
268
|
+
inputSchema: {
|
|
269
|
+
type: 'object',
|
|
270
|
+
properties: {
|
|
271
|
+
name: { type: 'string', description: 'Optional session name' },
|
|
272
|
+
metadata: { type: 'object', description: 'Optional metadata for the session' },
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
name: 'rovn_end_session',
|
|
278
|
+
description: 'End the current session. Optionally provide a summary.',
|
|
279
|
+
inputSchema: {
|
|
280
|
+
type: 'object',
|
|
281
|
+
properties: {
|
|
282
|
+
summary: { type: 'string', description: 'Optional summary of what was accomplished in this session' },
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
},
|
|
237
286
|
];
|
|
238
287
|
// ─── MCP Protocol Handler ───────────────────────────────────
|
|
239
288
|
async function handleRequest(request) {
|
|
@@ -260,42 +309,66 @@ async function handleToolCall(params) {
|
|
|
260
309
|
switch (name) {
|
|
261
310
|
case 'rovn_register': {
|
|
262
311
|
// Reuse existing agent if already registered (api-key + agent-id set)
|
|
263
|
-
if (config.apiKey && config.agentId) {
|
|
312
|
+
if (exports.config.apiKey && exports.config.agentId) {
|
|
264
313
|
// Validate existing credentials by fetching trust score
|
|
265
|
-
const check = await rovnGet(`/api/agents/${config.agentId}/trust-score`);
|
|
314
|
+
const check = await rovnGet(`/api/agents/${exports.config.agentId}/trust-score`);
|
|
266
315
|
if (check.success) {
|
|
316
|
+
const data = (check.data ?? check);
|
|
317
|
+
// Auto-start session on reuse
|
|
318
|
+
if (!exports.config.sessionId)
|
|
319
|
+
await startSession();
|
|
267
320
|
return toolResult({
|
|
268
321
|
success: true,
|
|
269
322
|
data: {
|
|
270
|
-
id: config.agentId,
|
|
323
|
+
id: exports.config.agentId,
|
|
324
|
+
name: data.agent_name ?? toolArgs.name,
|
|
325
|
+
session_id: exports.config.sessionId || undefined,
|
|
271
326
|
message: 'Already registered. Using existing agent credentials.',
|
|
272
327
|
},
|
|
273
328
|
});
|
|
274
329
|
}
|
|
275
|
-
//
|
|
276
|
-
|
|
277
|
-
|
|
330
|
+
// Pre-configured credentials (from CLI args) — keep using them even if validation fails
|
|
331
|
+
// This prevents creating duplicate agents when the server is temporarily unavailable
|
|
332
|
+
if (getArg(process.argv.slice(2), '--api-key') || process.env.ROVN_API_KEY) {
|
|
333
|
+
// Auto-start session on reuse
|
|
334
|
+
if (!exports.config.sessionId)
|
|
335
|
+
await startSession();
|
|
336
|
+
return toolResult({
|
|
337
|
+
success: true,
|
|
338
|
+
data: {
|
|
339
|
+
id: exports.config.agentId,
|
|
340
|
+
session_id: exports.config.sessionId || undefined,
|
|
341
|
+
message: 'Using pre-configured credentials (server validation skipped).',
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
// Only clear credentials if they were from a previous dynamic registration
|
|
346
|
+
exports.config.apiKey = '';
|
|
347
|
+
exports.config.agentId = '';
|
|
278
348
|
}
|
|
279
349
|
const body = {
|
|
280
350
|
name: toolArgs.name,
|
|
281
351
|
description: toolArgs.description,
|
|
282
352
|
type: toolArgs.type ?? 'mcp-agent',
|
|
283
353
|
capabilities: toolArgs.capabilities,
|
|
284
|
-
owner_email: config.ownerEmail || undefined,
|
|
354
|
+
owner_email: exports.config.ownerEmail || undefined,
|
|
285
355
|
metadata: { platform: 'mcp', registered_at: new Date().toISOString() },
|
|
286
356
|
};
|
|
287
357
|
const res = await rovnPost('/api/agents/register', body);
|
|
288
358
|
const data = res.data;
|
|
289
359
|
if (res.success && data) {
|
|
290
|
-
config.apiKey = data.api_key;
|
|
291
|
-
config.agentId = data.id;
|
|
360
|
+
exports.config.apiKey = data.api_key;
|
|
361
|
+
exports.config.agentId = data.id;
|
|
292
362
|
autoLog(`Registered as ${data.name}`, 'registration');
|
|
363
|
+
// Auto-start session on new registration
|
|
364
|
+
await startSession();
|
|
293
365
|
return toolResult({
|
|
294
366
|
success: true,
|
|
295
367
|
data: {
|
|
296
368
|
id: data.id,
|
|
297
369
|
name: data.name,
|
|
298
370
|
claim_url: data.claim_url,
|
|
371
|
+
session_id: exports.config.sessionId || undefined,
|
|
299
372
|
message: 'Agent registered! Share the claim_url with the owner. API key saved for this session.',
|
|
300
373
|
},
|
|
301
374
|
});
|
|
@@ -303,18 +376,20 @@ async function handleToolCall(params) {
|
|
|
303
376
|
return toolResult(res);
|
|
304
377
|
}
|
|
305
378
|
case 'rovn_log_activity': {
|
|
306
|
-
const err = requireAgent(config);
|
|
379
|
+
const err = requireAgent(exports.config);
|
|
307
380
|
if (err)
|
|
308
381
|
return toolResult({ success: false, error: err });
|
|
309
|
-
return toolResult(await rovnPost(`/api/agents/${config.agentId}/activities`, {
|
|
382
|
+
return toolResult(await rovnPost(`/api/agents/${exports.config.agentId}/activities`, {
|
|
310
383
|
type: toolArgs.type ?? 'action',
|
|
311
384
|
title: toolArgs.title,
|
|
312
385
|
description: toolArgs.description,
|
|
313
386
|
metadata: toolArgs.metadata,
|
|
387
|
+
session_id: exports.config.sessionId || undefined,
|
|
388
|
+
task_id: toolArgs.task_id || undefined,
|
|
314
389
|
}));
|
|
315
390
|
}
|
|
316
391
|
case 'rovn_check_action': {
|
|
317
|
-
const err = requireAgent(config);
|
|
392
|
+
const err = requireAgent(exports.config);
|
|
318
393
|
if (err)
|
|
319
394
|
return toolResult({ success: false, error: err });
|
|
320
395
|
// Use GET with query params (matches the API endpoint)
|
|
@@ -326,16 +401,16 @@ async function handleToolCall(params) {
|
|
|
326
401
|
params.set('cost', String(toolArgs.cost));
|
|
327
402
|
if (toolArgs.context)
|
|
328
403
|
params.set('context', toolArgs.context);
|
|
329
|
-
const checkRes = await rovnGet(`/api/agents/${config.agentId}/check?${params}`);
|
|
404
|
+
const checkRes = await rovnGet(`/api/agents/${exports.config.agentId}/check?${params}`);
|
|
330
405
|
const decision = (checkRes.data?.decision ?? '');
|
|
331
406
|
autoLog(`Checked: ${toolArgs.action} → ${decision}`, 'governance');
|
|
332
407
|
return toolResult(checkRes);
|
|
333
408
|
}
|
|
334
409
|
case 'rovn_request_approval': {
|
|
335
|
-
const err = requireAgent(config);
|
|
410
|
+
const err = requireAgent(exports.config);
|
|
336
411
|
if (err)
|
|
337
412
|
return toolResult({ success: false, error: err });
|
|
338
|
-
const approvalRes = await rovnPost(`/api/agents/${config.agentId}/approvals`, {
|
|
413
|
+
const approvalRes = await rovnPost(`/api/agents/${exports.config.agentId}/approvals`, {
|
|
339
414
|
type: toolArgs.type ?? 'action',
|
|
340
415
|
title: toolArgs.title,
|
|
341
416
|
description: toolArgs.description,
|
|
@@ -346,14 +421,14 @@ async function handleToolCall(params) {
|
|
|
346
421
|
return toolResult(approvalRes);
|
|
347
422
|
}
|
|
348
423
|
case 'rovn_get_tasks': {
|
|
349
|
-
const err = requireAgent(config);
|
|
424
|
+
const err = requireAgent(exports.config);
|
|
350
425
|
if (err)
|
|
351
426
|
return toolResult({ success: false, error: err });
|
|
352
427
|
const query = toolArgs.status ? `?status=${toolArgs.status}` : '';
|
|
353
|
-
return toolResult(await rovnGet(`/api/agents/${config.agentId}/tasks${query}`));
|
|
428
|
+
return toolResult(await rovnGet(`/api/agents/${exports.config.agentId}/tasks${query}`));
|
|
354
429
|
}
|
|
355
430
|
case 'rovn_update_task': {
|
|
356
|
-
const err = requireAgent(config);
|
|
431
|
+
const err = requireAgent(exports.config);
|
|
357
432
|
if (err)
|
|
358
433
|
return toolResult({ success: false, error: err });
|
|
359
434
|
const taskRes = await rovnPatch(`/api/tasks/${toolArgs.task_id}`, {
|
|
@@ -364,17 +439,53 @@ async function handleToolCall(params) {
|
|
|
364
439
|
return toolResult(taskRes);
|
|
365
440
|
}
|
|
366
441
|
case 'rovn_get_report_card': {
|
|
367
|
-
const err = requireAgent(config);
|
|
442
|
+
const err = requireAgent(exports.config);
|
|
368
443
|
if (err)
|
|
369
444
|
return toolResult({ success: false, error: err });
|
|
370
445
|
const days = toolArgs.days ? `?days=${toolArgs.days}` : '';
|
|
371
|
-
return toolResult(await rovnGet(`/api/agents/${config.agentId}/report-card${days}`));
|
|
446
|
+
return toolResult(await rovnGet(`/api/agents/${exports.config.agentId}/report-card${days}`));
|
|
372
447
|
}
|
|
373
448
|
case 'rovn_get_trust_score': {
|
|
374
|
-
const err = requireAgent(config);
|
|
449
|
+
const err = requireAgent(exports.config);
|
|
450
|
+
if (err)
|
|
451
|
+
return toolResult({ success: false, error: err });
|
|
452
|
+
return toolResult(await rovnGet(`/api/agents/${exports.config.agentId}/trust-score`));
|
|
453
|
+
}
|
|
454
|
+
case 'rovn_start_session': {
|
|
455
|
+
const err = requireAgent(exports.config);
|
|
456
|
+
if (err)
|
|
457
|
+
return toolResult({ success: false, error: err });
|
|
458
|
+
// End existing session if any
|
|
459
|
+
if (exports.config.sessionId) {
|
|
460
|
+
await rovnPatch(`/api/sessions/${exports.config.sessionId}`, {});
|
|
461
|
+
exports.config.sessionId = '';
|
|
462
|
+
}
|
|
463
|
+
const sessionRes = await rovnPost(`/api/agents/${exports.config.agentId}/sessions`, {
|
|
464
|
+
name: toolArgs.name,
|
|
465
|
+
metadata: toolArgs.metadata,
|
|
466
|
+
});
|
|
467
|
+
if (sessionRes.success) {
|
|
468
|
+
const data = sessionRes.data;
|
|
469
|
+
exports.config.sessionId = data.id;
|
|
470
|
+
autoLog(`Session started: ${toolArgs.name ?? data.id}`, 'session');
|
|
471
|
+
}
|
|
472
|
+
return toolResult(sessionRes);
|
|
473
|
+
}
|
|
474
|
+
case 'rovn_end_session': {
|
|
475
|
+
const err = requireAgent(exports.config);
|
|
375
476
|
if (err)
|
|
376
477
|
return toolResult({ success: false, error: err });
|
|
377
|
-
|
|
478
|
+
if (!exports.config.sessionId) {
|
|
479
|
+
return toolResult({ success: false, error: 'No active session to end' });
|
|
480
|
+
}
|
|
481
|
+
const endRes = await rovnPatch(`/api/sessions/${exports.config.sessionId}`, {
|
|
482
|
+
summary: toolArgs.summary,
|
|
483
|
+
});
|
|
484
|
+
if (endRes.success) {
|
|
485
|
+
autoLog(`Session ended: ${exports.config.sessionId}`, 'session');
|
|
486
|
+
exports.config.sessionId = '';
|
|
487
|
+
}
|
|
488
|
+
return toolResult(endRes);
|
|
378
489
|
}
|
|
379
490
|
default:
|
|
380
491
|
return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
|