Skip to main content

nyx_agent_api/
lib.rs

1//! Loopback HTTP + WebSocket surface for the nyx-agent daemon.
2//!
3//! This crate is published so the `nyx-agent` binary can be installed
4//! from crates.io with versioned internal dependencies. It is an
5//! implementation detail of Nyx Agent, not a stable public API.
6//!
7//! The `nyx-agent` binary owns the long-lived daemon process and
8//! wires three things into [`ServerState`]:
9//!
10//! - a connected [`nyx_agent_core::Store`] for read-only queries,
11//! - a tokio broadcast sink ([`nyx_agent_types::event::EventSink`])
12//!   that the run dispatcher publishes lifecycle events through,
13//! - a [`ScanTrigger`] handle the API uses to kick off a manual scan.
14//!
15//! Subscribers attach to the broadcast sink through the
16//! `/api/v1/events?run_id=<id>` WebSocket endpoint without the
17//! dispatcher knowing about them.
18
19pub mod integrations;
20pub mod router;
21pub mod state;
22pub mod webhook;
23
24pub use integrations::spawn_integration_delivery_task;
25pub use router::build_router;
26pub use state::{
27    ApiError, AuthConfig, AuthSetupAgent, AuthSetupAgentError, AuthSetupAgentFuture,
28    AuthSetupAgentOutput, AuthSetupAgentRequest, AuthSetupJobStore, EventReplay, ProjectSetupAgent,
29    ProjectSetupAgentError, ProjectSetupAgentFuture, ProjectSetupAgentOutput,
30    ProjectSetupAgentRequest, ProjectSetupJobStore, RemediationAgent, RemediationAgentError,
31    RemediationAgentFuture, RemediationAgentOutput, RemediationAgentRequest,
32    RemediationChangedFile, RemediationJobError, RemediationJobRecord, RemediationJobStore,
33    ScanRunOverrides, ScanTrigger, ScanTriggerError, ScanTriggerSource, SeedSetupAgent,
34    SeedSetupAgentError, SeedSetupAgentFuture, SeedSetupAgentOutput, SeedSetupAgentRequest,
35    ServerState, SetupContext,
36};
37pub use webhook::{
38    sign as sign_webhook, verify_signature as verify_webhook_signature, EnvSecretResolver,
39    StaticSecretResolver, WebhookConcurrencyLimit, WebhookConfig, WebhookRateLimiter,
40    WebhookResponse, WebhookSecretResolver, DEFAULT_WEBHOOK_MAX_CONCURRENT,
41    DEFAULT_WEBHOOK_RATE_LIMIT_BURST, DEFAULT_WEBHOOK_RATE_LIMIT_MAX_IPS,
42    DEFAULT_WEBHOOK_RATE_LIMIT_PER_MINUTE, MAX_WEBHOOK_BODY_BYTES,
43};