Skip to content

Commit cd4239e

Browse files
committed
feat(monke): clean up monke and make ready for use
1 parent 1e74d58 commit cd4239e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1398
-1252
lines changed

backend/airweave/billing/service.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
is_paid_plan,
2525
)
2626
from airweave.billing.transactions import billing_transactions
27-
from airweave.core.config import settings
2827
from airweave.core.exceptions import InvalidStateError, NotFoundException
2928
from airweave.core.logging import ContextualLogger, logger
3029
from airweave.db.unit_of_work import UnitOfWork
@@ -898,4 +897,4 @@ async def get_subscription_info(
898897

899898

900899
# Singleton instance
901-
billing_service = BillingService() if settings.STRIPE_ENABLED else None
900+
billing_service = BillingService()

backend/airweave/platform/sources/onedrive.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ def _build_file_entity(
330330
)
331331

332332
# Add additional properties for file processing
333-
entity.total_size = item.get("size", 0)
333+
if entity.airweave_system_metadata:
334+
entity.airweave_system_metadata.total_size = item.get("size", 0)
334335

335336
return entity
336337

monke/auth/broker.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,14 @@ def __init__(
4949
account_id: Optional[str] = None,
5050
) -> None:
5151
self.logger = get_logger("composio_broker")
52-
self.api_key = api_key or os.getenv("DM_AUTH_PROVIDER_API_KEY")
53-
self.auth_config_id = auth_config_id or os.getenv(
54-
"DM_AUTH_PROVIDER_AUTH_CONFIG_ID"
55-
)
56-
self.account_id = account_id or os.getenv("DM_AUTH_PROVIDER_ACCOUNT_ID")
52+
self.api_key = api_key or os.getenv("COMPOSIO_API_KEY")
53+
self.auth_config_id = auth_config_id
54+
self.account_id = account_id
5755

5856
if not self.api_key:
59-
raise ValueError("Missing Composio api key (DM_AUTH_PROVIDER_API_KEY)")
57+
raise ValueError("Missing Composio API key (COMPOSIO_API_KEY)")
6058

61-
async def _get(
62-
self, path: str, params: Optional[Dict[str, Any]] = None
63-
) -> Dict[str, Any]:
59+
async def _get(self, path: str, params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
6460
async with httpx.AsyncClient() as client:
6561
r = await client.get(
6662
f"{self.BASE_URL}{path}",
@@ -112,10 +108,7 @@ async def get_credentials(
112108
sensitive_fields = [
113109
k
114110
for k in creds.keys()
115-
if any(
116-
sensitive in k.lower()
117-
for sensitive in ["token", "key", "secret", "password"]
118-
)
111+
if any(sensitive in k.lower() for sensitive in ["token", "key", "secret", "password"])
119112
]
120113
non_sensitive_fields = [k for k in creds.keys() if k not in sensitive_fields]
121114

monke/auth/credentials_resolver.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Centralized credential resolution for connectors.
22
33
Priority:
4-
1) Explicit auth_fields provided in test config
5-
2) Auth broker (e.g., Composio) if configured
4+
1) Explicit auth_fields provided in test config (direct auth)
5+
2) Composio auth broker if API key is configured
66
"""
77

88
from __future__ import annotations
@@ -13,22 +13,15 @@
1313
from monke.auth.broker import BaseAuthBroker, ComposioBroker
1414

1515

16-
def _make_broker(source_short_name: str) -> Optional[BaseAuthBroker]:
17-
provider = os.getenv("DM_AUTH_PROVIDER") # e.g., "composio"
18-
if not provider:
16+
def _make_broker() -> Optional[BaseAuthBroker]:
17+
"""Create a Composio broker if API key is available."""
18+
# Check if Composio API key exists
19+
if not os.getenv("COMPOSIO_API_KEY"):
1920
return None
20-
if provider == "composio":
21-
# Check for source-specific account/config IDs
22-
source_upper = source_short_name.upper()
23-
account_id = os.getenv(f"{source_upper}_AUTH_PROVIDER_ACCOUNT_ID")
24-
auth_config_id = os.getenv(f"{source_upper}_AUTH_PROVIDER_AUTH_CONFIG_ID")
2521

26-
# If source-specific IDs exist, use them
27-
if account_id and auth_config_id:
28-
return ComposioBroker(account_id=account_id, auth_config_id=auth_config_id)
29-
# Otherwise use default broker
30-
return ComposioBroker()
31-
raise ValueError(f"Unsupported auth provider: {provider}")
22+
# Return a broker without specific account/auth config
23+
# These will be provided from the YAML config when needed
24+
return ComposioBroker()
3225

3326

3427
async def resolve_credentials(
@@ -46,11 +39,11 @@ async def resolve_credentials(
4639
if provided_auth_fields:
4740
return provided_auth_fields
4841

49-
broker = _make_broker(connector_short_name)
42+
broker = _make_broker()
5043

5144
if broker:
5245
return await broker.get_credentials(connector_short_name)
5346

5447
raise ValueError(
55-
f"No credentials provided and no DM_AUTH_PROVIDER configured for {connector_short_name}"
48+
f"No credentials provided and no Composio API key configured for {connector_short_name}"
5649
)

monke/auth/keyvault_adapter.py

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)