@sanctuary-framework/mcp-server 1.2.10 → 1.2.11

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/index.d.cts CHANGED
@@ -7525,26 +7525,143 @@ declare class SentinelDispatcher {
7525
7525
  }
7526
7526
 
7527
7527
  /**
7528
- * Sanctuary MCP Server Principal Dashboard
7528
+ * Sanctuary v1.3 WP-V1.3-3 Omega-1 Coordination Handoff Log.
7529
+ *
7530
+ * OPENS WP-V1.3-3 Coordination Handoff Visualization. Read-only
7531
+ * server-side data API: queries the existing audit log for the
7532
+ * handoff-shape event classes, normalizes them into a uniform
7533
+ * HandoffEntry, and exposes query + per-entry detail.
7534
+ *
7535
+ * Why this matters: operators running multiple wrapped agents need
7536
+ * to SEE what their agents are doing together. Handoffs between
7537
+ * agents are the most important state transitions: who passed work
7538
+ * to whom, what got transferred, what got withheld. Without
7539
+ * visibility, operators can't audit the multi-agent workflow OR
7540
+ * diagnose where work stalled.
7541
+ *
7542
+ * Audit event sources unioned by this module:
7543
+ * - `v1.1_local_handoff` (Tau-3 in-process coordination): canonical
7544
+ * explicit-pair signal. Details carry sender_agent_id +
7545
+ * recipient_agent_id.
7546
+ * - `cross_harness_approval_aggregated` (Upsilon-1 cross-harness
7547
+ * aggregator): wrapped-agent -> operator handoff. Details carry
7548
+ * source_harness; recipient is the synthetic `operator` node.
7549
+ *
7550
+ * NOT included at v1.3 Omega-1 (deviation, documented in PR body):
7551
+ * - `composition_completed` events do not exist as audit-log
7552
+ * operations in current source; composition events are mesh-only
7553
+ * signed envelopes (`composition_receipt_*` / `composition_*` are
7554
+ * in COMPOSITION_EVENT_TYPES but never flow through
7555
+ * auditLog.append). When composition wires audit emissions, the
7556
+ * union extends here. Same posture as Phi-3 cross-agent-chatter
7557
+ * watcher.
7529
7558
  *
7530
- * HTTP-based approval channel that serves a real-time web dashboard
7531
- * for human principals to approve/deny agent operations.
7559
+ * Castle-walking discipline:
7560
+ * - No outbound surface. Reads server-local audit log only.
7561
+ * - No LLM call (purely operator-eyes view; no inference).
7562
+ * - No new operator attack surface (read-only against existing audit
7563
+ * log; new audit events are operator-action observability only).
7532
7564
  *
7533
- * Architecture:
7534
- * - Node.js built-in `http`/`https` modules (no Express or external deps)
7535
- * - SSE (Server-Sent Events) for real-time push to browser
7536
- * - Pending approval requests block the MCP tool call via Promise
7537
- * - Human clicks approve/deny in browser → POST /api/approve/:id → Promise resolves
7538
- * - Timeout fallback: auto-deny (or auto-approve) if no response
7565
+ * Multi-fortress isolation: HandoffLog is scoped to ONE AuditLog
7566
+ * instance per fortress; the audit log itself enforces fortress
7567
+ * boundary at the encryption layer.
7568
+ */
7569
+
7570
+ /** Operator-facing per-handoff record. */
7571
+ interface HandoffEntry {
7572
+ /** Stable per-fortress entry id (32 hex chars; SHA-256 of audit_event_id). */
7573
+ entry_id: string;
7574
+ /** Pointer back to the source audit-event. */
7575
+ audit_event_id: string;
7576
+ source_agent_id: string;
7577
+ /** `operator` for cross-harness flows; `unknown` when the entry shape lacks a recipient. */
7578
+ target_agent_id: string;
7579
+ /** ISO 8601 timestamp from the underlying audit entry. */
7580
+ observed_at: string;
7581
+ /** The original audit operation (`v1.1_local_handoff`, `cross_harness_approval_aggregated`). */
7582
+ event_class: string;
7583
+ /** Operator-friendly one-liner. */
7584
+ context_transfer_summary: string;
7585
+ /** Multi-step workflow grouping key (Omega-3); v1.3 Omega-1 returns null. */
7586
+ workflow_link: string | null;
7587
+ }
7588
+ interface HandoffEntryDetail {
7589
+ entry: HandoffEntry;
7590
+ /** Source audit entry, decrypted under operator auth. */
7591
+ source_audit_entry: AuditEntry;
7592
+ }
7593
+ interface HandoffLogQueryOptions {
7594
+ /** Filter to entries with observed_at >= ISO 8601. */
7595
+ since?: string;
7596
+ /** Filter to entries with observed_at <= ISO 8601. */
7597
+ until?: string;
7598
+ /** Filter to entries where the agent participates as sender or recipient. */
7599
+ agent_id?: string;
7600
+ /** Result cap. Default 50; max 500. */
7601
+ limit?: number;
7602
+ }
7603
+ interface HandoffLogOptions {
7604
+ auditLog: AuditLog;
7605
+ fortressId: string;
7606
+ }
7607
+ declare class HandoffLog {
7608
+ private readonly auditLog;
7609
+ private readonly fortressId;
7610
+ constructor(opts: HandoffLogOptions);
7611
+ /** Stable fortress id this HandoffLog reads. */
7612
+ getFortressId(): string;
7613
+ /**
7614
+ * Query handoffs in chronological-newest-first order. Filters
7615
+ * applied after normalization so the per-event-class shape
7616
+ * differences (sender field name, recipient inference) are handled
7617
+ * once.
7618
+ */
7619
+ query(opts: HandoffLogQueryOptions): Promise<HandoffEntry[]>;
7620
+ /**
7621
+ * Look up a single entry by id. Returns the normalized entry +
7622
+ * the source audit payload for operator-facing detail rendering.
7623
+ * Returns null when no audit entry maps to the given id.
7624
+ */
7625
+ getEntry(entryId: string): Promise<HandoffEntryDetail | null>;
7626
+ private normalize;
7627
+ }
7628
+
7629
+ /**
7630
+ * Sanctuary v1.3 WP-V1.3-3 Omega-1 Coordination handoff HTTP routes.
7539
7631
  *
7540
- * Security invariants:
7541
- * - Binds to 127.0.0.1 by default (localhost only)
7542
- * - Optional bearer token authentication for non-localhost deployments
7543
- * - Optional TLS (HTTPS) via cert/key paths
7544
- * - All decisions are audit-logged
7545
- * - Agent cannot access the dashboard (it runs outside MCP stdin/stdout)
7632
+ * Mounted under `/api/coordination/*`. Mirrors the Phi-1 sentinel
7633
+ * route module shape (Standing CTO call: follow Phi-1 sibling-view
7634
+ * pattern; spawn-prompt's `dashboard-handoff-view.ts` filename did
7635
+ * not exist on main, so the routes live under the
7636
+ * `coordination/` subsystem with the rest of the handoff machinery).
7637
+ *
7638
+ * Routes:
7639
+ * GET /api/coordination/handoffs (chronological list, filtered)
7640
+ * GET /api/coordination/handoffs/stream (SSE stream of new entries)
7641
+ * GET /api/coordination/handoffs/:entry_id (full detail incl. source audit entry)
7642
+ *
7643
+ * Auth-gated via existing operator middleware. Multi-fortress
7644
+ * isolation enforced at the audit-log encryption boundary the
7645
+ * underlying HandoffLog reads through.
7646
+ *
7647
+ * Two new operator-action audit events fire on these routes:
7648
+ * - `operator_coordination_view_opened` on the list route.
7649
+ * - `operator_handoff_entry_drilled` on the detail route.
7546
7650
  */
7547
7651
 
7652
+ /**
7653
+ * In-process bridge that lets the dispatcher (or any other in-process
7654
+ * source) push handoff events to live SSE subscribers without
7655
+ * coupling the HandoffLog to a transport. The list route reads
7656
+ * historical state via HandoffLog.query(); the stream route subscribes
7657
+ * here for new entries.
7658
+ */
7659
+ declare class HandoffEventBridge {
7660
+ private readonly listeners;
7661
+ subscribe(listener: (entry: HandoffEntry) => void): () => void;
7662
+ emit(entry: HandoffEntry): void;
7663
+ }
7664
+
7548
7665
  interface DashboardConfig {
7549
7666
  port: number;
7550
7667
  host: string;
@@ -7628,6 +7745,17 @@ declare class DashboardApprovalChannel implements ApprovalChannel {
7628
7745
  * dispatcher's audited paths.
7629
7746
  */
7630
7747
  private sentinelDispatcher;
7748
+ /**
7749
+ * v1.3 WP-V1.3-3 Omega-1 Coordination Handoff Visualization.
7750
+ * Mounted additively at `/api/coordination/*` when set. Read-only
7751
+ * against the audit log; the only writes are operator-action audit
7752
+ * events (operator_coordination_view_opened,
7753
+ * operator_handoff_entry_drilled).
7754
+ */
7755
+ private handoffLog;
7756
+ private handoffEventBridge;
7757
+ private handoffAuditLog;
7758
+ private handoffOperatorId;
7631
7759
  constructor(config: DashboardConfig);
7632
7760
  /**
7633
7761
  * Inject dependencies after construction.
@@ -7671,6 +7799,18 @@ declare class DashboardApprovalChannel implements ApprovalChannel {
7671
7799
  * Pass `null` to detach (used by tests + during shutdown).
7672
7800
  */
7673
7801
  setSentinelDispatcher(dispatcher: SentinelDispatcher | null): void;
7802
+ /**
7803
+ * v1.3 WP-V1.3-3 Omega-1: bind the Coordination handoff log +
7804
+ * event bridge + audit log + operator id. Once set, requests to
7805
+ * `/api/coordination/*` route through `handleCoordinationRoute`.
7806
+ * Pass `null` for any field to detach.
7807
+ */
7808
+ setHandoffLog(opts: {
7809
+ handoffLog: HandoffLog | null;
7810
+ eventBridge?: HandoffEventBridge | null;
7811
+ auditLog?: AuditLog | null;
7812
+ operatorId?: string | null;
7813
+ }): void;
7674
7814
  /**
7675
7815
  * v1.3 WP-V1.3-10 dispatch entry point. Called from `handleRequest`
7676
7816
  * before the legacy approval route table. Returns true when served.
@@ -7682,6 +7822,12 @@ declare class DashboardApprovalChannel implements ApprovalChannel {
7682
7822
  * bound. Returns true when served.
7683
7823
  */
7684
7824
  private dispatchSentinel;
7825
+ /**
7826
+ * v1.3 WP-V1.3-3 Omega-1 dispatch entry point. Routes
7827
+ * `/api/coordination/*` requests through the coordination router
7828
+ * when a HandoffLog has been bound. Returns true when served.
7829
+ */
7830
+ private dispatchCoordination;
7685
7831
  /**
7686
7832
  * v1.1 dispatch entry point. Called from `handleRequest` before the
7687
7833
  * legacy route table. Returns true when the request was served by v1.1
package/dist/index.d.ts CHANGED
@@ -7525,26 +7525,143 @@ declare class SentinelDispatcher {
7525
7525
  }
7526
7526
 
7527
7527
  /**
7528
- * Sanctuary MCP Server Principal Dashboard
7528
+ * Sanctuary v1.3 WP-V1.3-3 Omega-1 Coordination Handoff Log.
7529
+ *
7530
+ * OPENS WP-V1.3-3 Coordination Handoff Visualization. Read-only
7531
+ * server-side data API: queries the existing audit log for the
7532
+ * handoff-shape event classes, normalizes them into a uniform
7533
+ * HandoffEntry, and exposes query + per-entry detail.
7534
+ *
7535
+ * Why this matters: operators running multiple wrapped agents need
7536
+ * to SEE what their agents are doing together. Handoffs between
7537
+ * agents are the most important state transitions: who passed work
7538
+ * to whom, what got transferred, what got withheld. Without
7539
+ * visibility, operators can't audit the multi-agent workflow OR
7540
+ * diagnose where work stalled.
7541
+ *
7542
+ * Audit event sources unioned by this module:
7543
+ * - `v1.1_local_handoff` (Tau-3 in-process coordination): canonical
7544
+ * explicit-pair signal. Details carry sender_agent_id +
7545
+ * recipient_agent_id.
7546
+ * - `cross_harness_approval_aggregated` (Upsilon-1 cross-harness
7547
+ * aggregator): wrapped-agent -> operator handoff. Details carry
7548
+ * source_harness; recipient is the synthetic `operator` node.
7549
+ *
7550
+ * NOT included at v1.3 Omega-1 (deviation, documented in PR body):
7551
+ * - `composition_completed` events do not exist as audit-log
7552
+ * operations in current source; composition events are mesh-only
7553
+ * signed envelopes (`composition_receipt_*` / `composition_*` are
7554
+ * in COMPOSITION_EVENT_TYPES but never flow through
7555
+ * auditLog.append). When composition wires audit emissions, the
7556
+ * union extends here. Same posture as Phi-3 cross-agent-chatter
7557
+ * watcher.
7529
7558
  *
7530
- * HTTP-based approval channel that serves a real-time web dashboard
7531
- * for human principals to approve/deny agent operations.
7559
+ * Castle-walking discipline:
7560
+ * - No outbound surface. Reads server-local audit log only.
7561
+ * - No LLM call (purely operator-eyes view; no inference).
7562
+ * - No new operator attack surface (read-only against existing audit
7563
+ * log; new audit events are operator-action observability only).
7532
7564
  *
7533
- * Architecture:
7534
- * - Node.js built-in `http`/`https` modules (no Express or external deps)
7535
- * - SSE (Server-Sent Events) for real-time push to browser
7536
- * - Pending approval requests block the MCP tool call via Promise
7537
- * - Human clicks approve/deny in browser → POST /api/approve/:id → Promise resolves
7538
- * - Timeout fallback: auto-deny (or auto-approve) if no response
7565
+ * Multi-fortress isolation: HandoffLog is scoped to ONE AuditLog
7566
+ * instance per fortress; the audit log itself enforces fortress
7567
+ * boundary at the encryption layer.
7568
+ */
7569
+
7570
+ /** Operator-facing per-handoff record. */
7571
+ interface HandoffEntry {
7572
+ /** Stable per-fortress entry id (32 hex chars; SHA-256 of audit_event_id). */
7573
+ entry_id: string;
7574
+ /** Pointer back to the source audit-event. */
7575
+ audit_event_id: string;
7576
+ source_agent_id: string;
7577
+ /** `operator` for cross-harness flows; `unknown` when the entry shape lacks a recipient. */
7578
+ target_agent_id: string;
7579
+ /** ISO 8601 timestamp from the underlying audit entry. */
7580
+ observed_at: string;
7581
+ /** The original audit operation (`v1.1_local_handoff`, `cross_harness_approval_aggregated`). */
7582
+ event_class: string;
7583
+ /** Operator-friendly one-liner. */
7584
+ context_transfer_summary: string;
7585
+ /** Multi-step workflow grouping key (Omega-3); v1.3 Omega-1 returns null. */
7586
+ workflow_link: string | null;
7587
+ }
7588
+ interface HandoffEntryDetail {
7589
+ entry: HandoffEntry;
7590
+ /** Source audit entry, decrypted under operator auth. */
7591
+ source_audit_entry: AuditEntry;
7592
+ }
7593
+ interface HandoffLogQueryOptions {
7594
+ /** Filter to entries with observed_at >= ISO 8601. */
7595
+ since?: string;
7596
+ /** Filter to entries with observed_at <= ISO 8601. */
7597
+ until?: string;
7598
+ /** Filter to entries where the agent participates as sender or recipient. */
7599
+ agent_id?: string;
7600
+ /** Result cap. Default 50; max 500. */
7601
+ limit?: number;
7602
+ }
7603
+ interface HandoffLogOptions {
7604
+ auditLog: AuditLog;
7605
+ fortressId: string;
7606
+ }
7607
+ declare class HandoffLog {
7608
+ private readonly auditLog;
7609
+ private readonly fortressId;
7610
+ constructor(opts: HandoffLogOptions);
7611
+ /** Stable fortress id this HandoffLog reads. */
7612
+ getFortressId(): string;
7613
+ /**
7614
+ * Query handoffs in chronological-newest-first order. Filters
7615
+ * applied after normalization so the per-event-class shape
7616
+ * differences (sender field name, recipient inference) are handled
7617
+ * once.
7618
+ */
7619
+ query(opts: HandoffLogQueryOptions): Promise<HandoffEntry[]>;
7620
+ /**
7621
+ * Look up a single entry by id. Returns the normalized entry +
7622
+ * the source audit payload for operator-facing detail rendering.
7623
+ * Returns null when no audit entry maps to the given id.
7624
+ */
7625
+ getEntry(entryId: string): Promise<HandoffEntryDetail | null>;
7626
+ private normalize;
7627
+ }
7628
+
7629
+ /**
7630
+ * Sanctuary v1.3 WP-V1.3-3 Omega-1 Coordination handoff HTTP routes.
7539
7631
  *
7540
- * Security invariants:
7541
- * - Binds to 127.0.0.1 by default (localhost only)
7542
- * - Optional bearer token authentication for non-localhost deployments
7543
- * - Optional TLS (HTTPS) via cert/key paths
7544
- * - All decisions are audit-logged
7545
- * - Agent cannot access the dashboard (it runs outside MCP stdin/stdout)
7632
+ * Mounted under `/api/coordination/*`. Mirrors the Phi-1 sentinel
7633
+ * route module shape (Standing CTO call: follow Phi-1 sibling-view
7634
+ * pattern; spawn-prompt's `dashboard-handoff-view.ts` filename did
7635
+ * not exist on main, so the routes live under the
7636
+ * `coordination/` subsystem with the rest of the handoff machinery).
7637
+ *
7638
+ * Routes:
7639
+ * GET /api/coordination/handoffs (chronological list, filtered)
7640
+ * GET /api/coordination/handoffs/stream (SSE stream of new entries)
7641
+ * GET /api/coordination/handoffs/:entry_id (full detail incl. source audit entry)
7642
+ *
7643
+ * Auth-gated via existing operator middleware. Multi-fortress
7644
+ * isolation enforced at the audit-log encryption boundary the
7645
+ * underlying HandoffLog reads through.
7646
+ *
7647
+ * Two new operator-action audit events fire on these routes:
7648
+ * - `operator_coordination_view_opened` on the list route.
7649
+ * - `operator_handoff_entry_drilled` on the detail route.
7546
7650
  */
7547
7651
 
7652
+ /**
7653
+ * In-process bridge that lets the dispatcher (or any other in-process
7654
+ * source) push handoff events to live SSE subscribers without
7655
+ * coupling the HandoffLog to a transport. The list route reads
7656
+ * historical state via HandoffLog.query(); the stream route subscribes
7657
+ * here for new entries.
7658
+ */
7659
+ declare class HandoffEventBridge {
7660
+ private readonly listeners;
7661
+ subscribe(listener: (entry: HandoffEntry) => void): () => void;
7662
+ emit(entry: HandoffEntry): void;
7663
+ }
7664
+
7548
7665
  interface DashboardConfig {
7549
7666
  port: number;
7550
7667
  host: string;
@@ -7628,6 +7745,17 @@ declare class DashboardApprovalChannel implements ApprovalChannel {
7628
7745
  * dispatcher's audited paths.
7629
7746
  */
7630
7747
  private sentinelDispatcher;
7748
+ /**
7749
+ * v1.3 WP-V1.3-3 Omega-1 Coordination Handoff Visualization.
7750
+ * Mounted additively at `/api/coordination/*` when set. Read-only
7751
+ * against the audit log; the only writes are operator-action audit
7752
+ * events (operator_coordination_view_opened,
7753
+ * operator_handoff_entry_drilled).
7754
+ */
7755
+ private handoffLog;
7756
+ private handoffEventBridge;
7757
+ private handoffAuditLog;
7758
+ private handoffOperatorId;
7631
7759
  constructor(config: DashboardConfig);
7632
7760
  /**
7633
7761
  * Inject dependencies after construction.
@@ -7671,6 +7799,18 @@ declare class DashboardApprovalChannel implements ApprovalChannel {
7671
7799
  * Pass `null` to detach (used by tests + during shutdown).
7672
7800
  */
7673
7801
  setSentinelDispatcher(dispatcher: SentinelDispatcher | null): void;
7802
+ /**
7803
+ * v1.3 WP-V1.3-3 Omega-1: bind the Coordination handoff log +
7804
+ * event bridge + audit log + operator id. Once set, requests to
7805
+ * `/api/coordination/*` route through `handleCoordinationRoute`.
7806
+ * Pass `null` for any field to detach.
7807
+ */
7808
+ setHandoffLog(opts: {
7809
+ handoffLog: HandoffLog | null;
7810
+ eventBridge?: HandoffEventBridge | null;
7811
+ auditLog?: AuditLog | null;
7812
+ operatorId?: string | null;
7813
+ }): void;
7674
7814
  /**
7675
7815
  * v1.3 WP-V1.3-10 dispatch entry point. Called from `handleRequest`
7676
7816
  * before the legacy approval route table. Returns true when served.
@@ -7682,6 +7822,12 @@ declare class DashboardApprovalChannel implements ApprovalChannel {
7682
7822
  * bound. Returns true when served.
7683
7823
  */
7684
7824
  private dispatchSentinel;
7825
+ /**
7826
+ * v1.3 WP-V1.3-3 Omega-1 dispatch entry point. Routes
7827
+ * `/api/coordination/*` requests through the coordination router
7828
+ * when a HandoffLog has been bound. Returns true when served.
7829
+ */
7830
+ private dispatchCoordination;
7685
7831
  /**
7686
7832
  * v1.1 dispatch entry point. Called from `handleRequest` before the
7687
7833
  * legacy route table. Returns true when the request was served by v1.1