agent-orchestrator-mcp-server 0.2.3 → 0.2.5
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/README.md +125 -30
- package/build/index.js +4 -4
- package/package.json +1 -1
- package/shared/orchestrator-client/orchestrator-client.d.ts +123 -1
- package/shared/orchestrator-client/orchestrator-client.integration-mock.js +313 -0
- package/shared/orchestrator-client/orchestrator-client.js +139 -0
- package/shared/resources.js +9 -4
- package/shared/tools/action-health.d.ts +58 -0
- package/shared/tools/action-health.js +101 -0
- package/shared/tools/action-notification.d.ts +46 -0
- package/shared/tools/action-notification.js +99 -0
- package/shared/tools/action-session.d.ts +33 -9
- package/shared/tools/action-session.js +177 -15
- package/shared/tools/action-trigger.d.ts +114 -0
- package/shared/tools/action-trigger.js +177 -0
- package/shared/tools/get-notifications.d.ts +70 -0
- package/shared/tools/get-notifications.js +113 -0
- package/shared/tools/get-session.d.ts +8 -0
- package/shared/tools/get-session.js +21 -2
- package/shared/tools/get-system-health.d.ts +38 -0
- package/shared/tools/get-system-health.js +69 -0
- package/shared/tools/get-transcript-archive.d.ts +27 -0
- package/shared/tools/get-transcript-archive.js +64 -0
- package/shared/tools/manage-enqueued-messages.d.ts +94 -0
- package/shared/tools/manage-enqueued-messages.js +259 -0
- package/shared/tools/search-triggers.d.ts +78 -0
- package/shared/tools/search-triggers.js +145 -0
- package/shared/tools/start-session.d.ts +1 -1
- package/shared/tools/start-session.js +5 -1
- package/shared/tools.d.ts +7 -9
- package/shared/tools.js +104 -31
- package/shared/types.d.ts +162 -0
|
@@ -443,5 +443,318 @@ export function createIntegrationMockOrchestratorClient(initialMockData) {
|
|
|
443
443
|
session_id: session.id,
|
|
444
444
|
};
|
|
445
445
|
},
|
|
446
|
+
// Session Extensions
|
|
447
|
+
async forkSession(id, _messageIndex) {
|
|
448
|
+
const session = mockData.sessions?.find((s) => s.id === Number(id) || s.slug === String(id));
|
|
449
|
+
if (!session)
|
|
450
|
+
throw new Error(`API Error (404): Session not found`);
|
|
451
|
+
sessionIdCounter++;
|
|
452
|
+
const forked = {
|
|
453
|
+
...session,
|
|
454
|
+
id: sessionIdCounter,
|
|
455
|
+
title: `Forked: ${session.title}`,
|
|
456
|
+
status: 'waiting',
|
|
457
|
+
created_at: new Date().toISOString(),
|
|
458
|
+
updated_at: new Date().toISOString(),
|
|
459
|
+
};
|
|
460
|
+
mockData.sessions?.push(forked);
|
|
461
|
+
return { session: forked, message: 'Session forked successfully' };
|
|
462
|
+
},
|
|
463
|
+
async refreshSession(id) {
|
|
464
|
+
const session = mockData.sessions?.find((s) => s.id === Number(id) || s.slug === String(id));
|
|
465
|
+
if (!session)
|
|
466
|
+
throw new Error(`API Error (404): Session not found`);
|
|
467
|
+
return { session, message: 'Session refreshed' };
|
|
468
|
+
},
|
|
469
|
+
async refreshAllSessions() {
|
|
470
|
+
return {
|
|
471
|
+
message: 'All sessions refreshed',
|
|
472
|
+
refreshed: mockData.sessions?.length || 0,
|
|
473
|
+
restarted: 0,
|
|
474
|
+
continued: 0,
|
|
475
|
+
errors: 0,
|
|
476
|
+
};
|
|
477
|
+
},
|
|
478
|
+
async updateSessionNotes(id, _notes) {
|
|
479
|
+
const session = mockData.sessions?.find((s) => s.id === Number(id) || s.slug === String(id));
|
|
480
|
+
if (!session)
|
|
481
|
+
throw new Error(`API Error (404): Session not found`);
|
|
482
|
+
session.updated_at = new Date().toISOString();
|
|
483
|
+
return session;
|
|
484
|
+
},
|
|
485
|
+
async toggleFavorite(id) {
|
|
486
|
+
const session = mockData.sessions?.find((s) => s.id === Number(id) || s.slug === String(id));
|
|
487
|
+
if (!session)
|
|
488
|
+
throw new Error(`API Error (404): Session not found`);
|
|
489
|
+
return { ...session, favorited: true };
|
|
490
|
+
},
|
|
491
|
+
async bulkArchiveSessions(sessionIds) {
|
|
492
|
+
let archived = 0;
|
|
493
|
+
for (const sid of sessionIds) {
|
|
494
|
+
const session = mockData.sessions?.find((s) => s.id === sid);
|
|
495
|
+
if (session) {
|
|
496
|
+
session.status = 'archived';
|
|
497
|
+
session.archived_at = new Date().toISOString();
|
|
498
|
+
archived++;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return { archived_count: archived, errors: [] };
|
|
502
|
+
},
|
|
503
|
+
async getTranscript(_id, _format) {
|
|
504
|
+
return { transcript_text: 'User: Hello\nAssistant: Hi there!' };
|
|
505
|
+
},
|
|
506
|
+
// Enqueued Messages
|
|
507
|
+
async listEnqueuedMessages(_sessionId, options) {
|
|
508
|
+
const page = options?.page || 1;
|
|
509
|
+
const perPage = options?.per_page || 25;
|
|
510
|
+
return {
|
|
511
|
+
enqueued_messages: [],
|
|
512
|
+
pagination: { page, per_page: perPage, total_count: 0, total_pages: 0 },
|
|
513
|
+
};
|
|
514
|
+
},
|
|
515
|
+
async getEnqueuedMessage(_sessionId, messageId) {
|
|
516
|
+
return {
|
|
517
|
+
id: messageId,
|
|
518
|
+
session_id: 1,
|
|
519
|
+
content: 'Test message',
|
|
520
|
+
stop_condition: null,
|
|
521
|
+
position: 1,
|
|
522
|
+
status: 'pending',
|
|
523
|
+
created_at: new Date().toISOString(),
|
|
524
|
+
updated_at: new Date().toISOString(),
|
|
525
|
+
};
|
|
526
|
+
},
|
|
527
|
+
async createEnqueuedMessage(sessionId, data) {
|
|
528
|
+
return {
|
|
529
|
+
id: 1,
|
|
530
|
+
session_id: Number(sessionId),
|
|
531
|
+
content: data.content,
|
|
532
|
+
stop_condition: data.stop_condition || null,
|
|
533
|
+
position: 1,
|
|
534
|
+
status: 'pending',
|
|
535
|
+
created_at: new Date().toISOString(),
|
|
536
|
+
updated_at: new Date().toISOString(),
|
|
537
|
+
};
|
|
538
|
+
},
|
|
539
|
+
async updateEnqueuedMessage(_sessionId, messageId, data) {
|
|
540
|
+
return {
|
|
541
|
+
id: messageId,
|
|
542
|
+
session_id: 1,
|
|
543
|
+
content: data.content || 'Updated message',
|
|
544
|
+
stop_condition: data.stop_condition || null,
|
|
545
|
+
position: 1,
|
|
546
|
+
status: 'pending',
|
|
547
|
+
created_at: new Date().toISOString(),
|
|
548
|
+
updated_at: new Date().toISOString(),
|
|
549
|
+
};
|
|
550
|
+
},
|
|
551
|
+
async deleteEnqueuedMessage(_sessionId, _messageId) {
|
|
552
|
+
// No-op
|
|
553
|
+
},
|
|
554
|
+
async reorderEnqueuedMessage(_sessionId, messageId, position) {
|
|
555
|
+
return {
|
|
556
|
+
id: messageId,
|
|
557
|
+
session_id: 1,
|
|
558
|
+
content: 'Test message',
|
|
559
|
+
stop_condition: null,
|
|
560
|
+
position,
|
|
561
|
+
status: 'pending',
|
|
562
|
+
created_at: new Date().toISOString(),
|
|
563
|
+
updated_at: new Date().toISOString(),
|
|
564
|
+
};
|
|
565
|
+
},
|
|
566
|
+
async interruptEnqueuedMessage(sessionId, _messageId) {
|
|
567
|
+
const session = mockData.sessions?.find((s) => s.id === Number(sessionId) || s.slug === String(sessionId));
|
|
568
|
+
if (!session)
|
|
569
|
+
throw new Error(`API Error (404): Session not found`);
|
|
570
|
+
return { session, message: 'Message sent as interrupt' };
|
|
571
|
+
},
|
|
572
|
+
// Triggers
|
|
573
|
+
async listTriggers(options) {
|
|
574
|
+
const page = options?.page || 1;
|
|
575
|
+
const perPage = options?.per_page || 25;
|
|
576
|
+
return {
|
|
577
|
+
triggers: [],
|
|
578
|
+
pagination: { page, per_page: perPage, total_count: 0, total_pages: 0 },
|
|
579
|
+
};
|
|
580
|
+
},
|
|
581
|
+
async getTrigger(id) {
|
|
582
|
+
const trigger = {
|
|
583
|
+
id,
|
|
584
|
+
name: 'Test Trigger',
|
|
585
|
+
trigger_type: 'schedule',
|
|
586
|
+
status: 'enabled',
|
|
587
|
+
agent_root_name: 'mcp-servers',
|
|
588
|
+
prompt_template: 'Test prompt',
|
|
589
|
+
stop_condition: null,
|
|
590
|
+
reuse_session: false,
|
|
591
|
+
mcp_servers: [],
|
|
592
|
+
configuration: {},
|
|
593
|
+
schedule_description: 'Every day',
|
|
594
|
+
last_session_id: null,
|
|
595
|
+
last_triggered_at: null,
|
|
596
|
+
last_polled_at: null,
|
|
597
|
+
sessions_created_count: 0,
|
|
598
|
+
created_at: new Date().toISOString(),
|
|
599
|
+
updated_at: new Date().toISOString(),
|
|
600
|
+
};
|
|
601
|
+
return { trigger, recent_sessions: [] };
|
|
602
|
+
},
|
|
603
|
+
async createTrigger(data) {
|
|
604
|
+
return {
|
|
605
|
+
id: 1,
|
|
606
|
+
name: data.name,
|
|
607
|
+
trigger_type: data.trigger_type,
|
|
608
|
+
status: data.status || 'enabled',
|
|
609
|
+
agent_root_name: data.agent_root_name,
|
|
610
|
+
prompt_template: data.prompt_template,
|
|
611
|
+
stop_condition: data.stop_condition || null,
|
|
612
|
+
reuse_session: data.reuse_session || false,
|
|
613
|
+
mcp_servers: data.mcp_servers || [],
|
|
614
|
+
configuration: data.configuration || {},
|
|
615
|
+
schedule_description: null,
|
|
616
|
+
last_session_id: null,
|
|
617
|
+
last_triggered_at: null,
|
|
618
|
+
last_polled_at: null,
|
|
619
|
+
sessions_created_count: 0,
|
|
620
|
+
created_at: new Date().toISOString(),
|
|
621
|
+
updated_at: new Date().toISOString(),
|
|
622
|
+
};
|
|
623
|
+
},
|
|
624
|
+
async updateTrigger(id, data) {
|
|
625
|
+
return {
|
|
626
|
+
id,
|
|
627
|
+
name: data.name || 'Updated Trigger',
|
|
628
|
+
trigger_type: data.trigger_type || 'schedule',
|
|
629
|
+
status: data.status || 'enabled',
|
|
630
|
+
agent_root_name: data.agent_root_name || 'mcp-servers',
|
|
631
|
+
prompt_template: data.prompt_template || 'Test prompt',
|
|
632
|
+
stop_condition: data.stop_condition || null,
|
|
633
|
+
reuse_session: data.reuse_session || false,
|
|
634
|
+
mcp_servers: data.mcp_servers || [],
|
|
635
|
+
configuration: data.configuration || {},
|
|
636
|
+
schedule_description: null,
|
|
637
|
+
last_session_id: null,
|
|
638
|
+
last_triggered_at: null,
|
|
639
|
+
last_polled_at: null,
|
|
640
|
+
sessions_created_count: 0,
|
|
641
|
+
created_at: new Date().toISOString(),
|
|
642
|
+
updated_at: new Date().toISOString(),
|
|
643
|
+
};
|
|
644
|
+
},
|
|
645
|
+
async deleteTrigger(_id) {
|
|
646
|
+
// No-op
|
|
647
|
+
},
|
|
648
|
+
async toggleTrigger(id) {
|
|
649
|
+
return {
|
|
650
|
+
id,
|
|
651
|
+
name: 'Toggled Trigger',
|
|
652
|
+
trigger_type: 'schedule',
|
|
653
|
+
status: 'disabled',
|
|
654
|
+
agent_root_name: 'mcp-servers',
|
|
655
|
+
prompt_template: 'Test prompt',
|
|
656
|
+
stop_condition: null,
|
|
657
|
+
reuse_session: false,
|
|
658
|
+
mcp_servers: [],
|
|
659
|
+
configuration: {},
|
|
660
|
+
schedule_description: null,
|
|
661
|
+
last_session_id: null,
|
|
662
|
+
last_triggered_at: null,
|
|
663
|
+
last_polled_at: null,
|
|
664
|
+
sessions_created_count: 0,
|
|
665
|
+
created_at: new Date().toISOString(),
|
|
666
|
+
updated_at: new Date().toISOString(),
|
|
667
|
+
};
|
|
668
|
+
},
|
|
669
|
+
async getTriggerChannels() {
|
|
670
|
+
return {
|
|
671
|
+
channels: [{ id: 'C123', name: 'general', is_private: false, num_members: 50 }],
|
|
672
|
+
};
|
|
673
|
+
},
|
|
674
|
+
// Notification Management
|
|
675
|
+
async listNotifications(options) {
|
|
676
|
+
const page = options?.page || 1;
|
|
677
|
+
const perPage = options?.per_page || 25;
|
|
678
|
+
return {
|
|
679
|
+
notifications: [],
|
|
680
|
+
pagination: { page, per_page: perPage, total_count: 0, total_pages: 0 },
|
|
681
|
+
};
|
|
682
|
+
},
|
|
683
|
+
async getNotification(id) {
|
|
684
|
+
return {
|
|
685
|
+
id,
|
|
686
|
+
session_id: 1,
|
|
687
|
+
notification_type: 'session_needs_input',
|
|
688
|
+
read: false,
|
|
689
|
+
stale: false,
|
|
690
|
+
created_at: new Date().toISOString(),
|
|
691
|
+
updated_at: new Date().toISOString(),
|
|
692
|
+
};
|
|
693
|
+
},
|
|
694
|
+
async getNotificationBadge() {
|
|
695
|
+
return { pending_count: 0 };
|
|
696
|
+
},
|
|
697
|
+
async markNotificationRead(id) {
|
|
698
|
+
return {
|
|
699
|
+
id,
|
|
700
|
+
session_id: 1,
|
|
701
|
+
notification_type: 'session_needs_input',
|
|
702
|
+
read: true,
|
|
703
|
+
stale: false,
|
|
704
|
+
created_at: new Date().toISOString(),
|
|
705
|
+
updated_at: new Date().toISOString(),
|
|
706
|
+
};
|
|
707
|
+
},
|
|
708
|
+
async markAllNotificationsRead() {
|
|
709
|
+
return { marked_count: 0, pending_count: 0 };
|
|
710
|
+
},
|
|
711
|
+
async dismissNotification(_id) {
|
|
712
|
+
// No-op
|
|
713
|
+
},
|
|
714
|
+
async dismissAllReadNotifications() {
|
|
715
|
+
return { dismissed_count: 0, pending_count: 0 };
|
|
716
|
+
},
|
|
717
|
+
// Health
|
|
718
|
+
async getHealth() {
|
|
719
|
+
return {
|
|
720
|
+
health_report: { sessions: { running: 1 } },
|
|
721
|
+
timestamp: new Date().toISOString(),
|
|
722
|
+
rails_env: 'test',
|
|
723
|
+
ruby_version: '3.3.0',
|
|
724
|
+
};
|
|
725
|
+
},
|
|
726
|
+
async cleanupProcesses() {
|
|
727
|
+
return { cleaned: 0, message: 'No orphaned processes' };
|
|
728
|
+
},
|
|
729
|
+
async retrySessions(_sessionIds) {
|
|
730
|
+
return { retried: 0, message: 'No sessions to retry' };
|
|
731
|
+
},
|
|
732
|
+
async archiveOldSessions(_days) {
|
|
733
|
+
return { archived: 0, message: 'No old sessions' };
|
|
734
|
+
},
|
|
735
|
+
// CLIs
|
|
736
|
+
async getCliStatus() {
|
|
737
|
+
return { cli_status: {}, unauthenticated_count: 0 };
|
|
738
|
+
},
|
|
739
|
+
async refreshCli() {
|
|
740
|
+
return { queued: true, message: 'CLI refresh queued' };
|
|
741
|
+
},
|
|
742
|
+
async clearCliCache() {
|
|
743
|
+
return { queued: true, message: 'CLI cache clear queued' };
|
|
744
|
+
},
|
|
745
|
+
// Transcript Archive
|
|
746
|
+
async getTranscriptArchiveStatus() {
|
|
747
|
+
return {
|
|
748
|
+
generated_at: '2025-01-15T15:00:00Z',
|
|
749
|
+
session_count: 10,
|
|
750
|
+
file_size_bytes: 524288,
|
|
751
|
+
};
|
|
752
|
+
},
|
|
753
|
+
getTranscriptArchiveDownloadUrl() {
|
|
754
|
+
return {
|
|
755
|
+
url: 'http://localhost:3000/api/v1/transcript_archive/download',
|
|
756
|
+
apiKey: 'test-api-key',
|
|
757
|
+
};
|
|
758
|
+
},
|
|
446
759
|
};
|
|
447
760
|
}
|
|
@@ -207,4 +207,143 @@ export class AgentOrchestratorClient {
|
|
|
207
207
|
message,
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
|
+
// Session Extensions
|
|
211
|
+
async forkSession(id, messageIndex) {
|
|
212
|
+
return this.request('POST', `/sessions/${id}/fork`, {
|
|
213
|
+
message_index: messageIndex,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
async refreshSession(id) {
|
|
217
|
+
return this.request('POST', `/sessions/${id}/refresh`);
|
|
218
|
+
}
|
|
219
|
+
async refreshAllSessions() {
|
|
220
|
+
return this.request('POST', '/sessions/refresh_all');
|
|
221
|
+
}
|
|
222
|
+
async updateSessionNotes(id, notes) {
|
|
223
|
+
const response = await this.request('PATCH', `/sessions/${id}/notes`, {
|
|
224
|
+
session_notes: notes,
|
|
225
|
+
});
|
|
226
|
+
return response.session;
|
|
227
|
+
}
|
|
228
|
+
async toggleFavorite(id) {
|
|
229
|
+
return this.request('POST', `/sessions/${id}/toggle_favorite`);
|
|
230
|
+
}
|
|
231
|
+
async bulkArchiveSessions(sessionIds) {
|
|
232
|
+
return this.request('POST', '/sessions/bulk_archive', {
|
|
233
|
+
session_ids: sessionIds,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
async getTranscript(id, format = 'json') {
|
|
237
|
+
return this.request('GET', `/sessions/${id}/transcript`, undefined, {
|
|
238
|
+
format,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
// Enqueued Messages
|
|
242
|
+
async listEnqueuedMessages(sessionId, options) {
|
|
243
|
+
return this.request('GET', `/sessions/${sessionId}/enqueued_messages`, undefined, options);
|
|
244
|
+
}
|
|
245
|
+
async getEnqueuedMessage(sessionId, messageId) {
|
|
246
|
+
const response = await this.request('GET', `/sessions/${sessionId}/enqueued_messages/${messageId}`);
|
|
247
|
+
return response.enqueued_message;
|
|
248
|
+
}
|
|
249
|
+
async createEnqueuedMessage(sessionId, data) {
|
|
250
|
+
const response = await this.request('POST', `/sessions/${sessionId}/enqueued_messages`, data);
|
|
251
|
+
return response.enqueued_message;
|
|
252
|
+
}
|
|
253
|
+
async updateEnqueuedMessage(sessionId, messageId, data) {
|
|
254
|
+
const response = await this.request('PATCH', `/sessions/${sessionId}/enqueued_messages/${messageId}`, data);
|
|
255
|
+
return response.enqueued_message;
|
|
256
|
+
}
|
|
257
|
+
async deleteEnqueuedMessage(sessionId, messageId) {
|
|
258
|
+
await this.request('DELETE', `/sessions/${sessionId}/enqueued_messages/${messageId}`);
|
|
259
|
+
}
|
|
260
|
+
async reorderEnqueuedMessage(sessionId, messageId, position) {
|
|
261
|
+
const response = await this.request('PATCH', `/sessions/${sessionId}/enqueued_messages/${messageId}/reorder`, { position });
|
|
262
|
+
return response.enqueued_message;
|
|
263
|
+
}
|
|
264
|
+
async interruptEnqueuedMessage(sessionId, messageId) {
|
|
265
|
+
return this.request('POST', `/sessions/${sessionId}/enqueued_messages/${messageId}/interrupt`);
|
|
266
|
+
}
|
|
267
|
+
// Triggers
|
|
268
|
+
async listTriggers(options) {
|
|
269
|
+
return this.request('GET', '/triggers', undefined, options);
|
|
270
|
+
}
|
|
271
|
+
async getTrigger(id) {
|
|
272
|
+
return this.request('GET', `/triggers/${id}`);
|
|
273
|
+
}
|
|
274
|
+
async createTrigger(data) {
|
|
275
|
+
const response = await this.request('POST', '/triggers', data);
|
|
276
|
+
return response.trigger;
|
|
277
|
+
}
|
|
278
|
+
async updateTrigger(id, data) {
|
|
279
|
+
const response = await this.request('PATCH', `/triggers/${id}`, data);
|
|
280
|
+
return response.trigger;
|
|
281
|
+
}
|
|
282
|
+
async deleteTrigger(id) {
|
|
283
|
+
await this.request('DELETE', `/triggers/${id}`);
|
|
284
|
+
}
|
|
285
|
+
async toggleTrigger(id) {
|
|
286
|
+
const response = await this.request('POST', `/triggers/${id}/toggle`);
|
|
287
|
+
return response.trigger;
|
|
288
|
+
}
|
|
289
|
+
async getTriggerChannels() {
|
|
290
|
+
return this.request('GET', '/triggers/channels');
|
|
291
|
+
}
|
|
292
|
+
// Notification Management
|
|
293
|
+
async listNotifications(options) {
|
|
294
|
+
return this.request('GET', '/notifications', undefined, options);
|
|
295
|
+
}
|
|
296
|
+
async getNotification(id) {
|
|
297
|
+
const response = await this.request('GET', `/notifications/${id}`);
|
|
298
|
+
return response.notification;
|
|
299
|
+
}
|
|
300
|
+
async getNotificationBadge() {
|
|
301
|
+
return this.request('GET', '/notifications/badge');
|
|
302
|
+
}
|
|
303
|
+
async markNotificationRead(id) {
|
|
304
|
+
const response = await this.request('PATCH', `/notifications/${id}/mark_read`);
|
|
305
|
+
return response.notification;
|
|
306
|
+
}
|
|
307
|
+
async markAllNotificationsRead() {
|
|
308
|
+
return this.request('PATCH', '/notifications/mark_all_read');
|
|
309
|
+
}
|
|
310
|
+
async dismissNotification(id) {
|
|
311
|
+
await this.request('DELETE', `/notifications/${id}`);
|
|
312
|
+
}
|
|
313
|
+
async dismissAllReadNotifications() {
|
|
314
|
+
return this.request('DELETE', '/notifications/dismiss_all_read');
|
|
315
|
+
}
|
|
316
|
+
// Health
|
|
317
|
+
async getHealth() {
|
|
318
|
+
return this.request('GET', '/health');
|
|
319
|
+
}
|
|
320
|
+
async cleanupProcesses() {
|
|
321
|
+
return this.request('POST', '/health/cleanup_processes');
|
|
322
|
+
}
|
|
323
|
+
async retrySessions(sessionIds) {
|
|
324
|
+
return this.request('POST', '/health/retry_sessions', sessionIds ? { session_ids: sessionIds } : undefined);
|
|
325
|
+
}
|
|
326
|
+
async archiveOldSessions(days) {
|
|
327
|
+
return this.request('POST', '/health/archive_old', days ? { days } : undefined);
|
|
328
|
+
}
|
|
329
|
+
// CLIs
|
|
330
|
+
async getCliStatus() {
|
|
331
|
+
return this.request('GET', '/clis/status');
|
|
332
|
+
}
|
|
333
|
+
async refreshCli() {
|
|
334
|
+
return this.request('POST', '/clis/refresh');
|
|
335
|
+
}
|
|
336
|
+
async clearCliCache() {
|
|
337
|
+
return this.request('POST', '/clis/clear_cache');
|
|
338
|
+
}
|
|
339
|
+
// Transcript Archive
|
|
340
|
+
async getTranscriptArchiveStatus() {
|
|
341
|
+
return this.request('GET', '/transcript_archive/status');
|
|
342
|
+
}
|
|
343
|
+
getTranscriptArchiveDownloadUrl() {
|
|
344
|
+
return {
|
|
345
|
+
url: `${this.baseUrl}/api/v1/transcript_archive/download`,
|
|
346
|
+
apiKey: this.apiKey,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
210
349
|
}
|
package/shared/resources.js
CHANGED
|
@@ -58,7 +58,7 @@ export function createRegisterResources(clientFactory) {
|
|
|
58
58
|
AGENT_ORCHESTRATOR_API_KEY: process.env.AGENT_ORCHESTRATOR_API_KEY
|
|
59
59
|
? '***configured***'
|
|
60
60
|
: 'not set',
|
|
61
|
-
|
|
61
|
+
TOOL_GROUPS: process.env.TOOL_GROUPS || 'all (default)',
|
|
62
62
|
SKIP_HEALTH_CHECKS: process.env.SKIP_HEALTH_CHECKS || 'false',
|
|
63
63
|
},
|
|
64
64
|
capabilities: {
|
|
@@ -66,9 +66,14 @@ export function createRegisterResources(clientFactory) {
|
|
|
66
66
|
resources: true,
|
|
67
67
|
},
|
|
68
68
|
toolGroups: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
sessions: 'All session tools (read + write): search, get, configs, start, action, enqueued messages',
|
|
70
|
+
sessions_readonly: 'Session tools (read only): search_sessions, get_session, get_configs',
|
|
71
|
+
notifications: 'All notification tools (read + write): get, send, mark read, dismiss',
|
|
72
|
+
notifications_readonly: 'Notification tools (read only): get_notifications',
|
|
73
|
+
triggers: 'All trigger tools (read + write): search, create, update, delete, toggle',
|
|
74
|
+
triggers_readonly: 'Trigger tools (read only): search_triggers',
|
|
75
|
+
health: 'All health tools (read + write): health report, CLI status, maintenance actions',
|
|
76
|
+
health_readonly: 'Health tools (read only): get_system_health',
|
|
72
77
|
},
|
|
73
78
|
};
|
|
74
79
|
return {
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { IAgentOrchestratorClient } from '../orchestrator-client/orchestrator-client.js';
|
|
4
|
+
export declare const ActionHealthSchema: z.ZodObject<{
|
|
5
|
+
action: z.ZodEnum<["cleanup_processes", "retry_sessions", "archive_old", "cli_refresh", "cli_clear_cache"]>;
|
|
6
|
+
session_ids: z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>;
|
|
7
|
+
days: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
action: "cleanup_processes" | "retry_sessions" | "archive_old" | "cli_refresh" | "cli_clear_cache";
|
|
10
|
+
session_ids?: number[] | undefined;
|
|
11
|
+
days?: number | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
action: "cleanup_processes" | "retry_sessions" | "archive_old" | "cli_refresh" | "cli_clear_cache";
|
|
14
|
+
session_ids?: number[] | undefined;
|
|
15
|
+
days?: number | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
export declare function actionHealthTool(_server: Server, clientFactory: () => IAgentOrchestratorClient): {
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
inputSchema: {
|
|
21
|
+
type: "object";
|
|
22
|
+
properties: {
|
|
23
|
+
action: {
|
|
24
|
+
type: string;
|
|
25
|
+
enum: readonly ["cleanup_processes", "retry_sessions", "archive_old", "cli_refresh", "cli_clear_cache"];
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
session_ids: {
|
|
29
|
+
type: string;
|
|
30
|
+
items: {
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
days: {
|
|
36
|
+
type: string;
|
|
37
|
+
minimum: number;
|
|
38
|
+
maximum: number;
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
required: string[];
|
|
43
|
+
};
|
|
44
|
+
handler: (args: unknown) => Promise<{
|
|
45
|
+
content: {
|
|
46
|
+
type: string;
|
|
47
|
+
text: string;
|
|
48
|
+
}[];
|
|
49
|
+
isError: boolean;
|
|
50
|
+
} | {
|
|
51
|
+
content: {
|
|
52
|
+
type: string;
|
|
53
|
+
text: string;
|
|
54
|
+
}[];
|
|
55
|
+
isError?: undefined;
|
|
56
|
+
}>;
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=action-health.d.ts.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const ACTION_ENUM = [
|
|
3
|
+
'cleanup_processes',
|
|
4
|
+
'retry_sessions',
|
|
5
|
+
'archive_old',
|
|
6
|
+
'cli_refresh',
|
|
7
|
+
'cli_clear_cache',
|
|
8
|
+
];
|
|
9
|
+
export const ActionHealthSchema = z.object({
|
|
10
|
+
action: z.enum(ACTION_ENUM),
|
|
11
|
+
session_ids: z.array(z.number()).optional(),
|
|
12
|
+
days: z.number().min(1).max(365).optional(),
|
|
13
|
+
});
|
|
14
|
+
const TOOL_DESCRIPTION = `Perform system health and maintenance actions.
|
|
15
|
+
|
|
16
|
+
**Actions:**
|
|
17
|
+
- **cleanup_processes**: Terminate orphaned agent processes
|
|
18
|
+
- **retry_sessions**: Retry failed sessions (optionally specify session_ids)
|
|
19
|
+
- **archive_old**: Archive sessions older than N days (requires "days", default 7)
|
|
20
|
+
- **cli_refresh**: Trigger a background refresh of CLI tool installations
|
|
21
|
+
- **cli_clear_cache**: Clear npm/pip caches and reinstall MCP packages
|
|
22
|
+
|
|
23
|
+
Note: Health actions are rate-limited (30s cooldown between calls).`;
|
|
24
|
+
export function actionHealthTool(_server, clientFactory) {
|
|
25
|
+
return {
|
|
26
|
+
name: 'action_health',
|
|
27
|
+
description: TOOL_DESCRIPTION,
|
|
28
|
+
inputSchema: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: {
|
|
31
|
+
action: { type: 'string', enum: ACTION_ENUM, description: 'Health action to perform.' },
|
|
32
|
+
session_ids: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: { type: 'number' },
|
|
35
|
+
description: 'Session IDs to retry. For retry_sessions action.',
|
|
36
|
+
},
|
|
37
|
+
days: {
|
|
38
|
+
type: 'number',
|
|
39
|
+
minimum: 1,
|
|
40
|
+
maximum: 365,
|
|
41
|
+
description: 'Archive sessions older than this many days. For archive_old action. Default: 7',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: ['action'],
|
|
45
|
+
},
|
|
46
|
+
handler: async (args) => {
|
|
47
|
+
try {
|
|
48
|
+
const validated = ActionHealthSchema.parse(args);
|
|
49
|
+
const client = clientFactory();
|
|
50
|
+
const { action } = validated;
|
|
51
|
+
let result;
|
|
52
|
+
switch (action) {
|
|
53
|
+
case 'cleanup_processes': {
|
|
54
|
+
const response = await client.cleanupProcesses();
|
|
55
|
+
result = `## Processes Cleaned Up\n\n\`\`\`json\n${JSON.stringify(response, null, 2)}\n\`\`\``;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case 'retry_sessions': {
|
|
59
|
+
const response = await client.retrySessions(validated.session_ids);
|
|
60
|
+
result = `## Sessions Retried\n\n\`\`\`json\n${JSON.stringify(response, null, 2)}\n\`\`\``;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
case 'archive_old': {
|
|
64
|
+
const response = await client.archiveOldSessions(validated.days);
|
|
65
|
+
result = `## Old Sessions Archived\n\n\`\`\`json\n${JSON.stringify(response, null, 2)}\n\`\`\``;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case 'cli_refresh': {
|
|
69
|
+
const response = await client.refreshCli();
|
|
70
|
+
result = `## CLI Refresh Queued\n\n- **Message:** ${response.message}`;
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'cli_clear_cache': {
|
|
74
|
+
const response = await client.clearCliCache();
|
|
75
|
+
result = `## CLI Cache Clear Queued\n\n- **Message:** ${response.message}`;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
default: {
|
|
79
|
+
const _exhaustiveCheck = action;
|
|
80
|
+
return {
|
|
81
|
+
content: [{ type: 'text', text: `Error: Unknown action "${_exhaustiveCheck}"` }],
|
|
82
|
+
isError: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return { content: [{ type: 'text', text: result }] };
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return {
|
|
90
|
+
content: [
|
|
91
|
+
{
|
|
92
|
+
type: 'text',
|
|
93
|
+
text: `Error performing health action: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
isError: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|