feat: ContentGuardianAgent, onboarding UX, Team Activity action wiring, docs, agent help modal
ContentGuardianAgent consolidation:
- Merge 3 duplicate classes into single source in specialized/content_guardian.py
- Watchdog audit_committee() with heuristic scoring, coverage gaps, overlaps, alerts
- Remove misleading rejection_rate() helper; use acceptance_rate directly
- Integrate audit + alerts + trend signals into today_workflow_service.py
Team Activity page:
- QualityAuditPanel: health ring, per-agent critiques, coverage gaps, overlaps
- TrendSignalsPanel: opportunity cards with urgency/impact/coverage bars
- AlertBanner: persistent dismiss via POST /alerts/{id}/mark-read
- AgentHelpModal: dialog showing all 8 agents with descriptions, tools, schedule
- QualityAuditPanel action buttons: Fill gap -> /content-planning, Resolve overlap, View CTA on alerts/issues
- TrendSignalsPanel action buttons: Create content from this trend -> /blog-writer with trend context state
Onboarding system:
- Step 4 validation: no auto-pass via basic_ready; requires persona data or explicit progression
- Step 5 validation: logs warning on auto-pass without integration data
- OnboardingCompletionService: single DB session, transactional task creation, upsert pattern
- Business-without-website: nullable website_url on SIFIndexingTask and MarketTrendsTask
- DeepCompetitorAnalysisExecutor: 5-min timeout, 10-competitor cap, asyncio.wait_for
- Persona generation: async with 30s timeout, falls back to scheduler
- OnboardingProgressService.reset_onboarding(): resets session + pauses all DB tasks
- OnboardingControlService.reset_onboarding(): also cancels APScheduler jobs
- FinalStep TaskSchedulingPanel: shows scheduled/failed tasks after completion, 8s auto-redirect
- onboarding_completed agent activity event logged to feed
Documentation:
- docs-site/features/onboarding/: overview, steps, scheduler-tasks, technical-reference (4 pages)
- docs-site/mkdocs.yml: added Onboarding System nav section
- docs-site/features/sif-agents/: overview, agent-directory, committee-system, content-guardian (4 pages)
- docs-site/features/team-activity/: overview, quality-audit, trend-signals, alert-system (4 pages)
- docs-site/features/todays-workflow/: updated overview, technical-architecture, workflow-guide, api-reference
This commit is contained in:
@@ -1,17 +1,33 @@
|
||||
from typing import Any, Dict
|
||||
from typing import Any, Dict, Optional
|
||||
import requests
|
||||
from loguru import logger
|
||||
|
||||
from .retry import wix_api_call_with_retry, WixAPIError
|
||||
|
||||
|
||||
class WixMediaService:
|
||||
"""Service for Wix Media Manager operations with retry logic and error handling."""
|
||||
|
||||
def __init__(self, base_url: str):
|
||||
self.base_url = base_url
|
||||
|
||||
def import_image(self, access_token: str, image_url: str, display_name: str) -> Dict[str, Any]:
|
||||
def import_image(self, access_token: str, image_url: str, display_name: str) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Import external image to Wix Media Manager.
|
||||
|
||||
Official endpoint: https://www.wixapis.com/site-media/v1/files/import
|
||||
Reference: https://dev.wix.com/docs/rest/assets/media/media-manager/files/import-file
|
||||
|
||||
Args:
|
||||
access_token: Valid access token
|
||||
image_url: URL of the image to import
|
||||
display_name: Display name for the image
|
||||
|
||||
Returns:
|
||||
Media result dict with 'file' key, or None on failure
|
||||
|
||||
Raises:
|
||||
WixAPIError: On non-retryable failure or after retries exhausted
|
||||
"""
|
||||
headers = {
|
||||
'Authorization': f'Bearer {access_token}',
|
||||
@@ -22,10 +38,54 @@ class WixMediaService:
|
||||
'mediaType': 'IMAGE',
|
||||
'displayName': display_name,
|
||||
}
|
||||
# Correct endpoint per Wix API documentation
|
||||
endpoint = f"{self.base_url}/site-media/v1/files/import"
|
||||
response = requests.post(endpoint, headers=headers, json=payload)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
|
||||
|
||||
try:
|
||||
result = wix_api_call_with_retry(
|
||||
'POST', endpoint, headers, json_payload=payload, max_attempts=2
|
||||
)
|
||||
if result and 'file' in result and 'id' in result['file']:
|
||||
logger.info(f"Image imported successfully: {result['file']['id'][:16]}...")
|
||||
return result
|
||||
else:
|
||||
logger.warning(f"Image import returned unexpected structure: {list(result.keys()) if isinstance(result, dict) else type(result)}")
|
||||
return None
|
||||
except WixAPIError as e:
|
||||
if e.status_code == 403:
|
||||
logger.error(f"Image import forbidden (403): OAuth app may lack MEDIA.SITE_MEDIA_FILES_IMPORT scope")
|
||||
elif e.status_code == 400:
|
||||
logger.error(f"Image import bad request (400): {e.response_body}")
|
||||
elif e.status_code == 404:
|
||||
logger.error(f"Image import endpoint not found (404) — Wix Media API may not be available for this site")
|
||||
else:
|
||||
logger.error(f"Image import failed after retries: HTTP {e.status_code} - {e.response_body}")
|
||||
raise
|
||||
except Exception as e:
|
||||
logger.error(f"Unexpected error importing image: {e}")
|
||||
raise
|
||||
|
||||
def get_image_url(self, access_token: str, media_id: str) -> Optional[str]:
|
||||
"""
|
||||
Get public URL for a Wix media item.
|
||||
|
||||
Args:
|
||||
access_token: Valid access token
|
||||
media_id: Wix media ID
|
||||
|
||||
Returns:
|
||||
Public URL string, or None
|
||||
"""
|
||||
url = f"{self.base_url}/site-media/v1/files/{media_id}"
|
||||
headers = {
|
||||
'Authorization': f'Bearer {access_token}',
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
try:
|
||||
result = wix_api_call_with_retry('GET', url, headers, max_attempts=2)
|
||||
if result and 'file' in result:
|
||||
return result['file'].get('url')
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to get image URL for {media_id}: {e}")
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user