Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore(ai): config.rs + doppler_config in mcp_service and agent-schedule-service (#4306)
Eric Hayes9089afd295f7
diff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.jsonindex d9414bd3cf..ceb184ce23 100644--- a/.github/workspace-dep-closures.json+++ b/.github/workspace-dep-closures.json@@ -2638,10 +2638,13 @@"lexical_client","macro_auth","macro_aws_config",+ "macro_config",+ "macro_config_derive","macro_db_client","macro_entrypoint","macro_env","macro_env_var",+ "macro_env_vars/database_env_vars","macro_middleware","macro_service_urls","macro_user_id",@@ -3509,11 +3512,14 @@"lexical_client","macro_auth","macro_aws_config",+ "macro_config",+ "macro_config_derive","macro_cors","macro_db_client","macro_entrypoint","macro_env","macro_env_var",+ "macro_env_vars/database_env_vars","macro_middleware","macro_service_urls","macro_user_id",diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex 60116fff22..a92319d96a 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -7376,7 +7376,9 @@ dependencies = ["channels","chat","crm",+ "database_env_vars","documents",+ "doppler-config","email","email_service_client","entity_access",@@ -7388,6 +7390,7 @@ dependencies = ["lexical_client","macro_auth","macro_aws_config",+ "macro_config","macro_db_client","macro_entrypoint","macro_env",@@ -10706,9 +10709,12 @@ dependencies = ["chrono-tz","connection_gateway_client","cron",+ "database_env_vars",+ "doppler-config","futures","macro_auth","macro_aws_config",+ "macro_config","macro_cors","macro_db_client","macro_entrypoint",diff --git a/rust/cloud-storage/mcp_service/Cargo.toml b/rust/cloud-storage/mcp_service/Cargo.tomlindex a63f73022a..4fe77b5f42 100644--- a/rust/cloud-storage/mcp_service/Cargo.toml+++ b/rust/cloud-storage/mcp_service/Cargo.toml@@ -5,6 +5,14 @@ name = "mcp_service"publish = falseversion = "0.1.0"+[[bin]]+name = "mcp_service"+path = "src/main.rs"++[[bin]]+name = "mcp_service_doppler_config"+path = "src/doppler_config.rs"+[dependencies]ai_usage = { path = "../ai_usage" }ai_tools = { path = "../ai_tools" }@@ -32,8 +40,11 @@ macro_auth = { path = "../macro_auth" }macro_db_client = { path = "../macro_db_client" }macro_aws_config = { path = "../macro_aws_config", features = ["s3"] }macro_entrypoint = { path = "../macro_entrypoint" }+macro_config = { path = "../macro_config" }macro_env = { path = "../macro_env" }macro_env_var = { path = "../macro_env_var" }+database_env_vars = { path = "../macro_env_vars/database_env_vars" }+doppler-config = { workspace = true }macro_middleware = { path = "../macro_middleware", default-features = false, features = ["auth","cloud_storage",diff --git a/rust/cloud-storage/mcp_service/src/config.rs b/rust/cloud-storage/mcp_service/src/config.rsnew file mode 100644index 0000000000..dddbdebf62--- /dev/null+++ b/rust/cloud-storage/mcp_service/src/config.rs@@ -0,0 +1,96 @@+//! Configuration for the MCP server, loaded via the standard `macro_config`+//! pattern so it gets a `doppler_config` validation binary.+//!+//! All required env vars are declared here as typed fields. The+//! `doppler_config` binary loads this `Config` from Doppler for both the dev+//! and prod environments, surfacing any missing or mistyped values at CI time.++use anyhow::Context;+use database_env_vars::DatabaseUrl;+pub use macro_env::Environment;+use macro_env_var::env_vars;+pub use macro_middleware::auth::internal_access::InternalApiSecretKey;++env_vars! {+ /// SQS URL for the email scheduled queue, consumed by the AI tools.+ pub struct EmailScheduledQueue;+ /// Auth key used by the document storage / search / lexical clients.+ pub struct DocumentStorageServiceAuthKey;+ /// Secrets Manager secret name for the sync service auth key.+ pub struct SyncServiceAuthKey;+ /// S3 bucket for document storage.+ pub struct DocumentStorageBucket;+ /// S3 bucket for docx document uploads.+ pub struct DocxDocumentUploadBucket;+ /// CloudFront distribution URL for document storage.+ pub struct DocumentStorageServiceCloudfrontDistributionUrl;+ /// CloudFront signer public key id for document storage.+ pub struct DocumentStorageServiceCloudfrontSignerPublicKeyId;+ /// Secrets Manager secret name for the CloudFront signer private key.+ pub struct DocumentStorageServiceCloudfrontSignerPrivateKeySecretName;+ /// Public URL this MCP server is served from (used for OAuth callbacks and+ /// the allowed-hosts list).+ pub struct McpPublicUrl;+ /// FusionAuth base URL.+ pub struct FusionauthBaseUrl;+ /// FusionAuth client id.+ pub struct FusionauthClientId;+ /// FusionAuth tenant id.+ pub struct FusionauthTenantId;+ /// Secrets Manager secret name for the FusionAuth API key.+ pub struct FusionauthApiKeySecretKey;+ /// Secrets Manager secret name for the FusionAuth client secret.+ pub struct FusionauthClientSecretKey;+ /// Google OAuth client id.+ pub struct GoogleClientId;+ /// Secrets Manager secret name for the Google OAuth client secret.+ pub struct GoogleClientSecretKey;+ /// Redis URL used by the MCP auth proxy for in-flight OAuth state.+ pub struct RedisUrl;+ /// Base URL of the Macro web app (e.g. `https://macro.com`), used to build+ /// links to Macro items in MCP responses.+ pub struct AppBaseUrl;+}++/// The configuration parameters for the MCP server.+#[derive(macro_config::MacroConfig)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub struct Config {+ /// The environment we are in.+ #[macro_config_default(Environment::new_or_prod())]+ pub environment: Environment,+ /// Port to listen on. Defaults to `8090` when unset.+ #[macro_config_default(8090)]+ pub port: usize,+ /// The connection URL for the Postgres database this application uses.+ pub database_url: DatabaseUrl,+ pub email_scheduled_queue: EmailScheduledQueue,+ pub document_storage_service_auth_key: DocumentStorageServiceAuthKey,+ pub sync_service_auth_key: SyncServiceAuthKey,+ pub document_storage_bucket: DocumentStorageBucket,+ pub docx_document_upload_bucket: DocxDocumentUploadBucket,+ pub document_storage_service_cloudfront_distribution_url:+ DocumentStorageServiceCloudfrontDistributionUrl,+ pub document_storage_service_cloudfront_signer_public_key_id:+ DocumentStorageServiceCloudfrontSignerPublicKeyId,+ pub document_storage_service_cloudfront_signer_private_key_secret_name:+ DocumentStorageServiceCloudfrontSignerPrivateKeySecretName,+ pub mcp_public_url: McpPublicUrl,+ pub fusionauth_base_url: FusionauthBaseUrl,+ pub fusionauth_client_id: FusionauthClientId,+ pub fusionauth_tenant_id: FusionauthTenantId,+ pub fusionauth_api_key_secret_key: FusionauthApiKeySecretKey,+ pub fusionauth_client_secret_key: FusionauthClientSecretKey,+ pub google_client_id: GoogleClientId,+ pub google_client_secret_key: GoogleClientSecretKey,+ pub redis_url: RedisUrl,+ pub app_base_url: AppBaseUrl,+ /// Shared secret for authenticating internal service-to-service calls.+ pub internal_api_secret_key: InternalApiSecretKey,+}++impl Config {+ pub fn from_env() -> anyhow::Result<Self> {+ macro_config::ConfigLoader::load::<Config>().context("failed to load mcp server config")+ }+}diff --git a/rust/cloud-storage/mcp_service/src/context.rs b/rust/cloud-storage/mcp_service/src/context.rsindex a6e2c35258..f2bf9e3738 100644--- a/rust/cloud-storage/mcp_service/src/context.rs+++ b/rust/cloud-storage/mcp_service/src/context.rs@@ -25,8 +25,6 @@ use foreign_entity::{use frecency::domain::services::FrecencyQueryServiceImpl;use frecency::outbound::postgres::FrecencyPgStorage;use macro_auth::middleware::decode_jwt::JwtValidationArgs;-use macro_env_var::env_var;-use macro_middleware::auth::internal_access::InternalApiSecretKey;use macro_service_urls::{DocumentStorageServiceUrl, EmailServiceUrl, LexicalServiceUrl, SyncServiceUrl,};@@ -43,28 +41,7 @@ use soup::outbound::pg_soup_repo::PgSoupRepo;use sqlx::{PgPool, postgres::PgPoolOptions};use sync_service_client::SyncServiceClient;-env_var!(- pub struct McpEnvVars {- DatabaseUrl,- EmailScheduledQueue,- DocumentStorageServiceAuthKey,- SyncServiceAuthKey,- DocumentStorageBucket,- DocxDocumentUploadBucket,- DocumentStorageServiceCloudfrontDistributionUrl,- DocumentStorageServiceCloudfrontSignerPublicKeyId,- DocumentStorageServiceCloudfrontSignerPrivateKeySecretName,- McpPublicUrl,- FusionauthBaseUrl,- FusionauthClientId,- FusionauthTenantId,- FusionauthApiKeySecretKey,- FusionauthClientSecretKey,- GoogleClientId,- GoogleClientSecretKey,- RedisUrl,- }-);+use crate::config::Config;#[derive(Clone)]pub struct McpContext {@@ -75,23 +52,21 @@ pub struct McpContext {pub db: PgPool,}-pub async fn build_context() -> anyhow::Result<McpContext> {- let env_vars = McpEnvVars::new().context("failed to load environment variables")?;-+pub async fn build_context(config: &Config) -> anyhow::Result<McpContext> {let db = PgPoolOptions::new().min_connections(3).max_connections(10)- .connect(&env_vars.database_url)+ .connect(&config.database_url).await.context("failed to connect to macrodb")?;tracing::info!("initialized db connection");- let macro_env = macro_env::Environment::new_or_prod();+ let macro_env = config.environment;let aws_config = macro_aws_config::get_macro_aws_config().await;let queue_aws_client = aws_sdk_sqs::Client::new(&aws_config);let sqs_client = sqs_client::SQS::new(queue_aws_client)- .email_scheduled_queue(env_vars.email_scheduled_queue.as_ref());+ .email_scheduled_queue(config.email_scheduled_queue.as_ref());let secretsmanager_client = secretsmanager_client::SecretsManager::new(aws_sdk_secretsmanager::Client::new(&aws_config),@@ -101,34 +76,30 @@ pub async fn build_context() -> anyhow::Result<McpContext> {.await.context("failed to initialize JWT validation args")?;- let internal_auth_key = secretsmanager_client::LocalOrRemoteSecret::Local(- InternalApiSecretKey::new().context("failed to create internal auth key")?,- );+ let internal_auth_key =+ secretsmanager_client::LocalOrRemoteSecret::Local(config.internal_api_secret_key.clone());let sync_service_auth_key = LocalOrRemoteSecret::new_from_secret_manager(- env_vars.sync_service_auth_key.as_ref().to_owned(),+ config.sync_service_auth_key.as_ref().to_owned(),&secretsmanager_client,).await.context("failed to load sync service auth key")?;let tool_context = build_tool_context(- &env_vars,+ config,&db,&secretsmanager_client,sqs_client,internal_auth_key.as_ref().to_string(),- env_vars- .document_storage_service_auth_key- .as_ref()- .to_owned(),+ config.document_storage_service_auth_key.as_ref().to_owned(),sync_service_auth_key.as_ref().to_owned(),).await?;- let auth_proxy = build_auth_proxy(&env_vars, &secretsmanager_client).await?;+ let auth_proxy = build_auth_proxy(config, &secretsmanager_client).await?;- let mcp_public_host = http::Uri::try_from(env_vars.mcp_public_url.as_ref())+ let mcp_public_host = http::Uri::try_from(config.mcp_public_url.as_ref()).context("MCP_PUBLIC_URL is not a valid URI")?.host().context("MCP_PUBLIC_URL has no host")?@@ -144,7 +115,7 @@ pub async fn build_context() -> anyhow::Result<McpContext> {}async fn build_tool_context(- env_vars: &McpEnvVars,+ config: &Config,db: &PgPool,secretsmanager_client: &secretsmanager_client::SecretsManager,sqs_client: sqs_client::SQS,@@ -204,12 +175,12 @@ async fn build_tool_context(let s3_client = macro_aws_config::s3_client().await;let s3_upload_adapter = S3UploadUrlAdapter::new(s3_client,- env_vars.document_storage_bucket.as_ref(),- env_vars.docx_document_upload_bucket.as_ref(),+ config.document_storage_bucket.as_ref(),+ config.docx_document_upload_bucket.as_ref(),);let document_repo = PgDocumentRepo::new(db.clone());let cloudfront_private_key = LocalOrRemoteSecret::new_from_secret_manager(- env_vars+ config.document_storage_service_cloudfront_signer_private_key_secret_name.as_ref().to_owned(),@@ -218,11 +189,11 @@ async fn build_tool_context(.await.context("failed to load CloudFront signer private key")?;let cloudfront_config = CloudFrontConfig {- distribution_url: env_vars+ distribution_url: config.document_storage_service_cloudfront_distribution_url.as_ref().to_owned(),- signer_public_key_id: env_vars+ signer_public_key_id: config.document_storage_service_cloudfront_signer_public_key_id.as_ref().to_owned(),@@ -347,48 +318,48 @@ async fn build_tool_context(}async fn build_auth_proxy(- env_vars: &McpEnvVars,+ config: &Config,secretsmanager_client: &secretsmanager_client::SecretsManager,) -> anyhow::Result<McpAuthProxyServiceImpl<RedisInflightAuth>> {- let mcp_public_url: String = env_vars.mcp_public_url.as_ref().to_owned();+ let mcp_public_url: String = config.mcp_public_url.as_ref().to_owned();let mcp_oauth_redirect_uri = format!("{mcp_public_url}/oauth/callback");let fusionauth_api_key = LocalOrRemoteSecret::new_from_secret_manager(- env_vars.fusionauth_api_key_secret_key.as_ref().to_owned(),+ config.fusionauth_api_key_secret_key.as_ref().to_owned(),secretsmanager_client,).await.context("failed to load FusionAuth API key")?;let fusionauth_client_secret = LocalOrRemoteSecret::new_from_secret_manager(- env_vars.fusionauth_client_secret_key.as_ref().to_owned(),+ config.fusionauth_client_secret_key.as_ref().to_owned(),secretsmanager_client,).await.context("failed to load FusionAuth client secret")?;let google_client_secret = LocalOrRemoteSecret::new_from_secret_manager(- env_vars.google_client_secret_key.as_ref().to_owned(),+ config.google_client_secret_key.as_ref().to_owned(),secretsmanager_client,).await.context("failed to load Google client secret")?;let fusionauth_client = fusionauth::FusionAuthClient::new(- env_vars.fusionauth_tenant_id.as_ref().to_owned(),+ config.fusionauth_tenant_id.as_ref().to_owned(),fusionauth_api_key.as_ref().to_owned(),- env_vars.fusionauth_client_id.as_ref().to_owned(),+ config.fusionauth_client_id.as_ref().to_owned(),fusionauth_client_secret.as_ref().to_owned(),- env_vars.fusionauth_base_url.as_ref().to_owned(),+ config.fusionauth_base_url.as_ref().to_owned(),mcp_oauth_redirect_uri,- env_vars.google_client_id.as_ref().to_owned(),+ config.google_client_id.as_ref().to_owned(),google_client_secret.as_ref().to_owned(),);let auth_provider = FusionAuthOAuthProvider::new(fusionauth_client).await.context("failed to initialize MCP auth provider")?;- let redis_client = redis::Client::open(env_vars.redis_url.as_ref().to_owned())+ let redis_client = redis::Client::open(config.redis_url.as_ref().to_owned()).context("failed to initialize redis client for MCP auth proxy")?;Ok(McpAuthProxyServiceImpl::new(diff --git a/rust/cloud-storage/mcp_service/src/doppler_config.rs b/rust/cloud-storage/mcp_service/src/doppler_config.rsnew file mode 100644index 0000000000..2a2aeb9269--- /dev/null+++ b/rust/cloud-storage/mcp_service/src/doppler_config.rs@@ -0,0 +1,31 @@+#![allow(unused)]+#![recursion_limit = "256"]++use macro_env::Environment;++mod config;++const DOPPLER_PROJECT: &str = "mcp-server";++#[tokio::main]+async fn main() -> anyhow::Result<()> {+ let dev = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Develop.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ dev.load::<config::Config>().await?;++ let prd = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Production.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ prd.load::<config::Config>().await?;++ Ok(())+}diff --git a/rust/cloud-storage/mcp_service/src/main.rs b/rust/cloud-storage/mcp_service/src/main.rsindex 7b68465552..8d988433ca 100644--- a/rust/cloud-storage/mcp_service/src/main.rs+++ b/rust/cloud-storage/mcp_service/src/main.rs@@ -4,12 +4,13 @@//! tools that are available in the DCS chat/stream API, with OAuth 2.1//! authentication backed by FusionAuth.+mod config;mod context;mod tool_service;use anyhow::Context;+use config::Config;use context::build_context;use macro_entrypoint::MacroEntrypoint;-use macro_env_var::maybe_env_vars;use mcp_auth_proxy::domain::service::McpAuthProxyService;use mcp_auth_proxy::inbound::axum_router::mcp_router;use rmcp::transport::streamable_http_server::{@@ -21,29 +22,18 @@ use tool_service::AuthenticatedToolService;const AUTH_PROXY_CLEANUP_INTERVAL: Duration = Duration::from_secs(60);-maybe_env_vars! {- struct Port;-}--macro_env_var::env_var! {- /// Base URL of the Macro web app (e.g. `https://macro.com`), used to build- /// links to Macro items in MCP responses. Read from `APP_BASE_URL`.- pub struct AppBaseUrl;-}-#[tokio::main]#[tracing::instrument(err)]async fn main() -> anyhow::Result<()> {MacroEntrypoint::default().init();- let context = build_context().await?;+ let config = Config::from_env()?;// Base URL of the Macro web app, used to build links to Macro items in MCP- // responses. Loaded from the `APP_BASE_URL` environment variable via the- // macro_env_var infra.- let item_base_url = AppBaseUrl::new()- .context("failed to read APP_BASE_URL")?- .to_string();+ // responses.+ let item_base_url = config.app_base_url.as_ref().to_string();++ let context = build_context(&config).await?;// Create the MCP service with authenticated tool handlerlet mcp_service = StreamableHttpService::new(@@ -83,9 +73,7 @@ async fn main() -> anyhow::Result<()> {let app = mcp_router(context.auth_proxy, context.jwt_args, mcp_service);- let port = Port::new()- .map(|port| port.to_string())- .unwrap_or_else(|| "8090".to_string());+ let port = config.port;let addr = format!("0.0.0.0:{port}");let listener = tokio::net::TcpListener::bind(&addr).awaitdiff --git a/rust/cloud-storage/scheduled_action/Cargo.toml b/rust/cloud-storage/scheduled_action/Cargo.tomlindex 574b5aaba6..f206041760 100644--- a/rust/cloud-storage/scheduled_action/Cargo.toml+++ b/rust/cloud-storage/scheduled_action/Cargo.toml@@ -12,6 +12,10 @@ path = "src/bins/service.rs"name = "scheduled_action_openapi"path = "src/bins/openapi.rs"+[[bin]]+name = "scheduled_action_doppler_config"+path = "src/doppler_config.rs"+[features]default = []local_auth = ["macro_middleware/local_auth"]@@ -20,6 +24,9 @@ local_auth = ["macro_middleware/local_auth"]serde = { workspace = true }serde_json = { workspace = true }macro_env_var = { path = "../macro_env_var" }+macro_config = { path = "../macro_config" }+database_env_vars = { path = "../macro_env_vars/database_env_vars" }+doppler-config = { workspace = true }sqlx = { workspace = true }macro_user_id = { path = "../macro_user_id"}cron = { version = "0.16.0" }diff --git a/rust/cloud-storage/scheduled_action/src/bins/service.rs b/rust/cloud-storage/scheduled_action/src/bins/service.rsindex 24b1b6de49..4f6d60a129 100644--- a/rust/cloud-storage/scheduled_action/src/bins/service.rs+++ b/rust/cloud-storage/scheduled_action/src/bins/service.rs@@ -7,12 +7,10 @@ use axum::Router;use connection_gateway_client::client::ConnectionGatewayClient;use macro_auth::middleware::decode_jwt::JwtValidationArgs;use macro_entrypoint::MacroEntrypoint;-use macro_env::Environment;-use macro_env_var::env_var;-use macro_middleware::auth::internal_access::InternalApiSecretKey;use macro_service_urls::ConnectionGatewayUrl;use notification::domain::service::SqsNotificationIngress;use notification::outbound::queue::SqsQueue;+use scheduled_action::config::Config;use scheduled_action::domain::ports::ScheduledActionDispatcher;use scheduled_action::domain::service::ScheduledActionServiceImpl;use scheduled_action::inbound::axum_router::{@@ -27,31 +25,21 @@ use sqlx::postgres::PgPoolOptions;use utoipa::OpenApi;use utoipa_swagger_ui::SwaggerUi;-env_var! {- pub struct EnvVars {- Port,- DatabaseUrl,- NotificationQueue,- }-}-#[tokio::main]#[tracing::instrument(err)]async fn main() -> Result<()> {MacroEntrypoint::default().init();- let env = EnvVars::new().context("failed to read environment")?;- let environment = Environment::new_or_prod();+ let config = Config::from_env()?;+ let environment = config.environment;let db = PgPoolOptions::new().min_connections(3).max_connections(10)- .connect(&env.database_url)+ .connect(&config.database_url).await.context("failed to connect to macrodb")?;- // TODO: This shoud be a config and use `macro_config` so we can- // have doppler tests for it.let tool_context = build_tool_service_context_from_env(db.clone()).await.context("failed to build tool service context")?;@@ -60,17 +48,15 @@ async fn main() -> Result<()> {let notification_ingress = Arc::new(SqsNotificationIngress {queue: SqsQueue::new(aws_sdk_sqs::Client::new(&aws_config),- env.notification_queue.to_string(),+ config.notification_queue.to_string(),),});let secretsmanager_client = secretsmanager_client::SecretsManager::new(aws_sdk_secretsmanager::Client::new(¯o_aws_config::get_macro_aws_config().await),);- let internal_api_secret = InternalApiSecretKey::new()?;-let conn_gateway_client = Arc::new(ConnectionGatewayClient::new(- internal_api_secret.as_ref().to_string(),+ config.internal_api_secret_key.as_ref().to_string(),ConnectionGatewayUrl::new()?.to_string(),));let live_updates = Arc::new(ConnGatewayLiveUpdates::new(Arc::clone(@@ -121,7 +107,8 @@ async fn main() -> Result<()> {.merge(authed_routes).layer(macro_cors::cors_layer());- let addr = format!("0.0.0.0:{}", &*env.port);+ let port = config.port;+ let addr = format!("0.0.0.0:{port}");let listener = tokio::net::TcpListener::bind(&addr).await.with_context(|| format!("failed to bind {addr}"))?;diff --git a/rust/cloud-storage/scheduled_action/src/config.rs b/rust/cloud-storage/scheduled_action/src/config.rsnew file mode 100644index 0000000000..d3b764e75f--- /dev/null+++ b/rust/cloud-storage/scheduled_action/src/config.rs@@ -0,0 +1,73 @@+//! Configuration for the agent schedule service, loaded via the standard+//! `macro_config` pattern so it gets a `doppler_config` validation binary.+//!+//! All required env vars are declared here as typed fields. The+//! `doppler_config` binary loads this `Config` from Doppler for both the dev+//! and prod environments, surfacing any missing or mistyped values at CI time.+//!+//! The AI tool service context built by+//! [`ai_tools::build_tool_service_context_from_env`] reads several env vars of+//! its own; those are mirrored here so the Doppler validation binary covers+//! them as well.++use anyhow::Context;+use database_env_vars::DatabaseUrl;+pub use macro_env::Environment;+use macro_env_var::env_vars;+pub use macro_middleware::auth::internal_access::InternalApiSecretKey;++env_vars! {+ /// SQS URL for the notification ingress queue.+ pub struct NotificationQueue;+ /// Auth key used by the document storage / search / lexical clients.+ pub struct DocumentStorageServiceAuthKey;+ /// Secrets Manager secret name for the sync service auth key.+ pub struct SyncServiceAuthKey;+ /// S3 bucket for document storage.+ pub struct DocumentStorageBucket;+ /// S3 bucket for docx document uploads.+ pub struct DocxDocumentUploadBucket;+ /// SQS URL for the email scheduled queue, consumed by the AI tools.+ pub struct EmailScheduledQueue;+ /// CloudFront distribution URL for document storage.+ pub struct DocumentStorageServiceCloudfrontDistributionUrl;+ /// CloudFront signer public key id for document storage.+ pub struct DocumentStorageServiceCloudfrontSignerPublicKeyId;+ /// Secrets Manager secret name for the CloudFront signer private key.+ pub struct DocumentStorageServiceCloudfrontSignerPrivateKeySecretName;+}++/// The configuration parameters for the agent schedule service.+#[derive(macro_config::MacroConfig)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]+pub struct Config {+ /// The environment we are in.+ #[macro_config_default(Environment::new_or_prod())]+ pub environment: Environment,+ /// Port to listen on. Defaults to `8080` when unset.+ #[macro_config_default(8080)]+ pub port: usize,+ /// The connection URL for the Postgres database this application uses.+ pub database_url: DatabaseUrl,+ pub notification_queue: NotificationQueue,+ pub document_storage_service_auth_key: DocumentStorageServiceAuthKey,+ pub sync_service_auth_key: SyncServiceAuthKey,+ pub document_storage_bucket: DocumentStorageBucket,+ pub docx_document_upload_bucket: DocxDocumentUploadBucket,+ pub email_scheduled_queue: EmailScheduledQueue,+ pub document_storage_service_cloudfront_distribution_url:+ DocumentStorageServiceCloudfrontDistributionUrl,+ pub document_storage_service_cloudfront_signer_public_key_id:+ DocumentStorageServiceCloudfrontSignerPublicKeyId,+ pub document_storage_service_cloudfront_signer_private_key_secret_name:+ DocumentStorageServiceCloudfrontSignerPrivateKeySecretName,+ /// Shared secret for authenticating internal service-to-service calls.+ pub internal_api_secret_key: InternalApiSecretKey,+}++impl Config {+ pub fn from_env() -> anyhow::Result<Self> {+ macro_config::ConfigLoader::load::<Config>()+ .context("failed to load agent schedule service config")+ }+}diff --git a/rust/cloud-storage/scheduled_action/src/doppler_config.rs b/rust/cloud-storage/scheduled_action/src/doppler_config.rsnew file mode 100644index 0000000000..07e86b01f6--- /dev/null+++ b/rust/cloud-storage/scheduled_action/src/doppler_config.rs@@ -0,0 +1,30 @@+#![allow(unused)]+#![recursion_limit = "256"]++use macro_env::Environment;+use scheduled_action::config::Config;++const DOPPLER_PROJECT: &str = "agent-schedule-service";++#[tokio::main]+async fn main() -> anyhow::Result<()> {+ let dev = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Develop.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ dev.load::<Config>().await?;++ let prd = doppler_config::DopplerConfig::builder()+ .token_from_env("DOPPLER_TOKEN")+ .config(Environment::Production.to_doppler_slug())+ .project(DOPPLER_PROJECT)+ .build()+ .expect("able to grab doppler project");++ prd.load::<Config>().await?;++ Ok(())+}diff --git a/rust/cloud-storage/scheduled_action/src/lib.rs b/rust/cloud-storage/scheduled_action/src/lib.rsindex c411d162c7..69d1600ee9 100644--- a/rust/cloud-storage/scheduled_action/src/lib.rs+++ b/rust/cloud-storage/scheduled_action/src/lib.rs@@ -1,3 +1,4 @@+pub mod config;pub mod domain;pub mod inbound;pub mod outbound;