@@ -4,7 +4,7 @@ import { makeWindowDraggable } from './windowDrag.js';
44
55const MODAL_ID = 'diogenes-persephone-workspace-modal' ;
66const TERMINAL = new Set ( [ 'succeeded' , 'failed' , 'cancelled' ] ) ;
7- const VIEWS = [ 'overview' , 'connectors' , 'routes' , 'runtime' , 'queues' , 'schedules' , 'settings' , 'setup' ] ;
7+ const VIEWS = [ 'overview' , 'connectors' , 'routes' , 'runtime' , 'queues' , 'schedules' , 'integrations' , ' settings', 'setup' ] ;
88const ICON = `<svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor"
99 stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
1010 <path d="M12 3a4 4 0 0 0-4 4v2H6a2 2 0 0 0-2 2v8h16v-8a2 2 0 0 0-2-2h-2V7a4 4 0 0 0-4-4z"/>
@@ -24,6 +24,9 @@ let scheduleDraft = null;
2424let dispatchDraft = { channel : 'api' , peerId : 'owner' , message : '' } ;
2525let runtimeLogs = null ;
2626let runtimeLogsLoading = false ;
27+ let integrationInventory = null ;
28+ let integrationLoading = false ;
29+ let integrationError = '' ;
2730let approvalValues = { } ;
2831let busy = '' ;
2932let error = '' ;
@@ -77,7 +80,7 @@ function ensureModal() {
7780 } ) ;
7881 Modals . injectMinimizeButton ( modal , MODAL_ID ) ;
7982 modal . querySelector ( '.close-btn' ) ?. addEventListener ( 'click' , ( ) => Modals . close ( MODAL_ID ) ) ;
80- modal . querySelector ( '[data-pers-refresh]' ) ?. addEventListener ( 'click' , ( ) => loadWorkspace ( true ) ) ;
83+ modal . querySelector ( '[data-pers-refresh]' ) ?. addEventListener ( 'click' , refreshCurrent ) ;
8184 const body = modal . querySelector ( '.dio-persephone-body' ) ;
8285 body ?. addEventListener ( 'click' , onClick ) ;
8386 body ?. addEventListener ( 'input' , onInput ) ;
@@ -109,8 +112,10 @@ function onClick(event) {
109112 if ( tab ) {
110113 view = VIEWS . includes ( tab . dataset . persView ) ? tab . dataset . persView : 'overview' ;
111114 render ( ) ;
115+ if ( view === 'integrations' && ! integrationInventory ) void loadIntegrations ( ) ;
112116 return ;
113117 }
118+ if ( event . target . closest ( '[data-pers-integrations-refresh]' ) ) { loadIntegrations ( true ) ; return ; }
114119 const lifecycle = event . target . closest ( '[data-pers-lifecycle]' ) ;
115120 if ( lifecycle ) { runLifecycle ( lifecycle . dataset . persLifecycle ) ; return ; }
116121 if ( event . target . closest ( '[data-pers-config-save]' ) ) { saveConfiguration ( ) ; return ; }
@@ -217,6 +222,7 @@ function renderView() {
217222 if ( view === 'runtime' ) return renderRuntime ( ) ;
218223 if ( view === 'queues' ) return renderQueues ( ) ;
219224 if ( view === 'schedules' ) return renderSchedules ( ) ;
225+ if ( view === 'integrations' ) return renderIntegrations ( ) ;
220226 if ( view === 'settings' ) return renderSettings ( ) ;
221227 if ( view === 'setup' ) return renderSetup ( ) ;
222228 return renderOverview ( ) ;
@@ -511,6 +517,65 @@ function renderSettings() {
511517 </div>${ configFooter ( ) } ` ;
512518}
513519
520+ function renderIntegrations ( ) {
521+ const inventory = integrationInventory ;
522+ const entries = inventory ?. integrations || [ ] ;
523+ const checks = inventory ?. ompReconciliation || [ ] ;
524+ const profiles = inventory ?. profiles || [ ] ;
525+ const readyOwners = entries . filter ( ( entry ) => entry . configured && entry . ownerContractPresent ) . length ;
526+ const passingChecks = checks . filter ( ( entry ) => entry . ok ) . length ;
527+ return `${ sectionHeading (
528+ 'Integrations' ,
529+ 'Inspect the repositories Persephone maintains and the OMP settings it will restore after upgrades.' ,
530+ integrationLoading ? 'Checking…' : 'Check again' ,
531+ 'data-pers-integrations-refresh' ,
532+ ) }
533+ ${ integrationError ? `<div class="dio-persephone-inline-error">${ esc ( integrationError ) } </div>` : '' }
534+ ${ integrationLoading && ! inventory ? panelMessage ( 'Reading owner inventory…' , 'Persephone is checking its configured repositories and OMP profiles.' ) : '' }
535+ ${ inventory ? `
536+ <section class="dio-persephone-actions">
537+ <button type="button" data-pers-lifecycle="reconcile" ${ busy ? 'disabled' : '' } >${ busy === 'lifecycle:reconcile' ? 'Working…' : 'Review OMP repair' } </button>
538+ <button type="button" data-pers-lifecycle="integrate" ${ busy ? 'disabled' : '' } >${ busy === 'lifecycle:integrate' ? 'Working…' : 'Review full integration' } </button>
539+ </section>
540+ <section class="dio-persephone-metrics integrations">
541+ ${ metric ( 'Owners' , readyOwners , `${ entries . length } configured` ) }
542+ ${ metric ( 'OMP checks' , passingChecks , `${ checks . length - passingChecks } need repair` ) }
543+ ${ metric ( 'Profiles' , profiles . length , 'discovered by owner' ) }
544+ ${ metric ( 'Session repair' , inventory . reconcileOnSessionStart ? 1 : 0 , inventory . reconcileOnSessionStart ? 'enabled' : 'disabled' ) }
545+ </section>
546+ <div class="dio-persephone-integration-grid">
547+ <section class="dio-persephone-integration-list">
548+ ${ entries . length ? entries . map ( renderIntegrationOwner ) . join ( '' ) : panelMessage ( 'No integrations configured' ) }
549+ </section>
550+ <section class="dio-persephone-integration-side">
551+ <article class="dio-persephone-card">
552+ <header><div><small>OMP RECONCILIATION</small><h3>Maintained settings</h3><p>Read from Persephone; no repair runs until you review and confirm it.</p></div>${ badge ( passingChecks === checks . length ? 'ready' : 'incomplete' ) } </header>
553+ <div class="dio-persephone-reconcile-list">${ checks . map ( ( entry ) => `<div class="${ entry . ok ? 'ok' : 'failed' } "><i></i><span><strong>${ esc ( entry . check ) } </strong><small>${ esc ( entry . detail ) } </small></span></div>` ) . join ( '' ) } </div>
554+ </article>
555+ <article class="dio-persephone-card">
556+ <header><div><small>OMP PROFILES</small><h3>Discovered agents</h3></div></header>
557+ <div class="dio-persephone-profile-list">${ profiles . map ( ( profile ) => `<div><strong>${ esc ( profile . profile ) } </strong><code>${ esc ( profile . agentDir ) } </code></div>` ) . join ( '' ) } </div>
558+ </article>
559+ </section>
560+ </div>` : ( ! integrationLoading ? panelMessage ( 'Inventory not loaded' , 'Use Check again to ask Persephone for its current owner inventory.' ) : '' ) } `;
561+ }
562+
563+ function renderIntegrationOwner ( entry ) {
564+ const ready = Boolean ( entry . configured && entry . ownerContractPresent ) ;
565+ return `<article class="dio-persephone-card dio-persephone-integration-owner">
566+ <header><div><small>${ esc ( entry . key ) } </small><h3>${ esc ( entry . label ) } </h3></div>${ badge ( ready ? 'ready' : ( entry . configured ? 'missing' : 'disabled' ) ) } </header>
567+ <dl>
568+ <div><dt>Repository</dt><dd><code>${ esc ( entry . directory ) } </code></dd></div>
569+ <div><dt>Owner contract</dt><dd><code>${ esc ( entry . ownerContract ) } </code></dd></div>
570+ </dl>
571+ <div class="dio-persephone-integration-meta">
572+ <span>MCP ${ esc ( ( entry . mcpNames || [ ] ) . join ( ', ' ) || 'none' ) } </span>
573+ <span>${ ( entry . activeProfiles || [ ] ) . length } active profile${ ( entry . activeProfiles || [ ] ) . length === 1 ? '' : 's' } </span>
574+ </div>
575+ <div class="dio-persephone-profile-chips">${ ( entry . activeProfiles || [ ] ) . map ( ( profile ) => `<span>${ esc ( profile ) } </span>` ) . join ( '' ) } </div>
576+ </article>` ;
577+ }
578+
514579function renderSetup ( ) {
515580 const guides = workspace . setup || { } ;
516581 return `${ sectionHeading ( 'Setup' , 'Provider-side steps and copy-ready values generated by the owner repository.' ) }
@@ -600,6 +665,28 @@ async function loadWorkspace(force = false) {
600665 }
601666}
602667
668+ async function loadIntegrations ( force = false ) {
669+ if ( integrationLoading ) return ;
670+ integrationLoading = true ;
671+ if ( force ) integrationError = '' ;
672+ render ( ) ;
673+ try {
674+ integrationInventory = await request ( '/api/odysseus/persephone/integrations' ) ;
675+ integrationError = '' ;
676+ } catch ( caught ) {
677+ integrationError = caught ?. message || String ( caught ) ;
678+ if ( force ) integrationInventory = null ;
679+ } finally {
680+ integrationLoading = false ;
681+ render ( ) ;
682+ }
683+ }
684+
685+ async function refreshCurrent ( ) {
686+ await loadWorkspace ( true ) ;
687+ if ( view === 'integrations' ) await loadIntegrations ( true ) ;
688+ }
689+
603690async function loadQueue ( kind , id ) {
604691 busy = `queue:${ kind } :${ id } ` ;
605692 error = '' ;
@@ -790,6 +877,7 @@ async function refreshAfterJob() {
790877 } catch ( caught ) {
791878 error = caught ?. message || String ( caught ) ;
792879 }
880+ if ( integrationInventory || view === 'integrations' ) await loadIntegrations ( true ) ;
793881}
794882
795883async function copyText ( value ) {
@@ -824,14 +912,15 @@ function panelMessage(title, detail = '') {
824912}
825913
826914function navLabel ( name ) {
827- return ( { overview : 'Overview' , connectors : 'Connectors' , routes : 'Routes' , runtime : 'Runtime' , queues : 'Queues' , schedules : 'Schedules' , settings : 'Settings' , setup : 'Setup guide' } ) [ name ] || titleCase ( name ) ;
915+ return ( { overview : 'Overview' , connectors : 'Connectors' , routes : 'Routes' , runtime : 'Runtime' , queues : 'Queues' , schedules : 'Schedules' , integrations : 'Integrations' , settings : 'Settings' , setup : 'Setup guide' } ) [ name ] || titleCase ( name ) ;
828916}
829917
830918function navCount ( name ) {
831919 if ( name === 'routes' ) return `<em>${ ( workspace . routes || [ ] ) . length } </em>` ;
832920 if ( name === 'runtime' ) return `<em>${ ( workspace . approvals || [ ] ) . filter ( ( entry ) => entry . status === 'pending' ) . length } </em>` ;
833921 if ( name === 'queues' ) return `<em>${ ( workspace . inbox || [ ] ) . length + ( workspace . outbox || [ ] ) . length } </em>` ;
834922 if ( name === 'schedules' ) return `<em>${ ( workspace . schedules || [ ] ) . length } </em>` ;
923+ if ( name === 'integrations' && integrationInventory ) return `<em>${ ( integrationInventory . integrations || [ ] ) . length } </em>` ;
835924 return '' ;
836925}
837926
0 commit comments