fix: resolve syntax errors in scan-skipped files
All checks were successful
API Endpoint Tests / test-api-endpoints (push) Successful in 2m12s
CLI Tests / test-cli (push) Successful in 2m58s
Integration Tests / test-service-integration (push) Successful in 2m18s
Python Tests / test-python (push) Successful in 3m6s
Security Scanning / security-scan (push) Successful in 1m7s

- Fix malformed f-strings in agent communication SDK
- Repair pricing strategy delimiters and optimizer blocks
- Normalize FastAPI session dependency signatures in routers
- Fix incomplete constructor, indentation, and empty exception blocks
- Restore syntax validity for files previously skipped by Bandit
This commit is contained in:
aitbc
2026-04-18 10:55:25 +02:00
parent ef91f4e773
commit 40698f91fd
14 changed files with 172 additions and 170 deletions

View File

@@ -552,7 +552,8 @@ class AgentCommunicationClient:
# For simulation, we'll return a mock response
if method == "create_topic":
topic_id = f"topic_{hashlib.sha256(f'{params.get(\"agent_id\")}_{params.get(\"title\")}_{datetime.now()}'.encode()).hexdigest()[:16]}"
topic_seed = f"{params.get('agent_id')}_{params.get('title')}_{datetime.now()}"
topic_id = f"topic_{hashlib.sha256(topic_seed.encode()).hexdigest()[:16]}"
return {
"success": True,
"topic_id": topic_id,
@@ -571,7 +572,8 @@ class AgentCommunicationClient:
}
elif method == "post_message":
message_id = f"msg_{hashlib.sha256(f'{params.get(\"agent_id\")}_{params.get(\"topic_id\")}_{params.get(\"content\")}_{datetime.now()}'.encode()).hexdigest()[:16]}"
message_seed = f"{params.get('agent_id')}_{params.get('topic_id')}_{params.get('content')}_{datetime.now()}"
message_id = f"msg_{hashlib.sha256(message_seed.encode()).hexdigest()[:16]}"
return {
"success": True,
"message_id": message_id,

View File

@@ -156,7 +156,7 @@ class StrategyLibrary:
performance_penalty_rate=0.02,
growth_target_rate=0.25, # 25% growth target
market_share_target=0.15, # 15% market share target
}
)
rules = [
StrategyRule(
@@ -166,7 +166,7 @@ class StrategyLibrary:
condition="competitor_price > 0 and current_price > competitor_price * 0.95",
action="set_price = competitor_price * 0.95",
priority=StrategyPriority.HIGH,
},
),
StrategyRule(
rule_id="growth_volume_discount",
name="Volume Discount",
@@ -174,8 +174,8 @@ class StrategyLibrary:
condition="customer_volume > threshold and customer_loyalty < 6_months",
action="apply_discount = 0.1",
priority=StrategyPriority.MEDIUM,
},
## ]
),
]
return PricingStrategyConfig(
strategy_id="aggressive_growth_v1",
@@ -186,7 +186,7 @@ class StrategyLibrary:
rules=rules,
risk_tolerance=RiskTolerance.AGGRESSIVE,
priority=StrategyPriority.HIGH,
}
)
@staticmethod
def get_profit_maximization_strategy() -> PricingStrategyConfig:
@@ -206,7 +206,7 @@ class StrategyLibrary:
performance_penalty_rate=0.08,
profit_target_margin=0.35, # 35% profit target
max_price_change_percent=0.2, # More conservative changes
}
)
rules = [
StrategyRule(
@@ -216,7 +216,7 @@ class StrategyLibrary:
condition="demand_level > 0.8 and competitor_capacity < 0.7",
action="set_price = current_price * 1.3",
priority=StrategyPriority.CRITICAL,
},
),
StrategyRule(
rule_id="profit_performance_premium",
name="Performance Premium",
@@ -224,8 +224,8 @@ class StrategyLibrary:
condition="performance_score > 0.9 and customer_satisfaction > 0.85",
action="apply_premium = 0.2",
priority=StrategyPriority.HIGH,
},
## ]
),
]
return PricingStrategyConfig(
strategy_id="profit_maximization_v1",
@@ -236,7 +236,7 @@ class StrategyLibrary:
rules=rules,
risk_tolerance=RiskTolerance.MODERATE,
priority=StrategyPriority.HIGH,
}
)
@staticmethod
def get_market_balance_strategy() -> PricingStrategyConfig:
@@ -256,7 +256,7 @@ class StrategyLibrary:
performance_penalty_rate=0.05,
volatility_threshold=0.15, # Lower volatility threshold
confidence_threshold=0.8, # Higher confidence requirement
}
)
rules = [
StrategyRule(
@@ -266,7 +266,7 @@ class StrategyLibrary:
condition="market_trend == increasing and price_position < market_average",
action="adjust_price = market_average * 0.98",
priority=StrategyPriority.MEDIUM,
},
),
StrategyRule(
rule_id="balance_stability_maintain",
name="Stability Maintenance",
@@ -274,8 +274,8 @@ class StrategyLibrary:
condition="volatility > 0.15 and confidence < 0.7",
action="freeze_price = true",
priority=StrategyPriority.HIGH,
},
## ]
),
]
return PricingStrategyConfig(
strategy_id="market_balance_v1",
@@ -286,7 +286,7 @@ class StrategyLibrary:
rules=rules,
risk_tolerance=RiskTolerance.MODERATE,
priority=StrategyPriority.MEDIUM,
}
)
@staticmethod
def get_competitive_response_strategy() -> PricingStrategyConfig:
@@ -304,7 +304,7 @@ class StrategyLibrary:
weekend_multiplier=1.05,
performance_bonus_rate=0.08,
performance_penalty_rate=0.03,
}
)
rules = [
StrategyRule(
@@ -314,7 +314,7 @@ class StrategyLibrary:
condition="competitor_price < current_price * 0.95",
action="set_price = competitor_price * 0.98",
priority=StrategyPriority.CRITICAL,
},
),
StrategyRule(
rule_id="competitive_promotion_response",
name="Promotion Response",
@@ -322,8 +322,8 @@ class StrategyLibrary:
condition="competitor_promotion == true and market_share_declining",
action="apply_promotion = competitor_promotion_rate * 1.1",
priority=StrategyPriority.HIGH,
},
## ]
),
]
return PricingStrategyConfig(
strategy_id="competitive_response_v1",
@@ -334,7 +334,7 @@ class StrategyLibrary:
rules=rules,
risk_tolerance=RiskTolerance.MODERATE,
priority=StrategyPriority.HIGH,
}
)
@staticmethod
def get_demand_elasticity_strategy() -> PricingStrategyConfig:
@@ -353,7 +353,7 @@ class StrategyLibrary:
performance_bonus_rate=0.1,
performance_penalty_rate=0.05,
max_price_change_percent=0.4, # Allow larger changes for elasticity
}
)
rules = [
StrategyRule(
@@ -363,7 +363,7 @@ class StrategyLibrary:
condition="demand_growth_rate > 0.2 and supply_constraint == true",
action="set_price = current_price * 1.25",
priority=StrategyPriority.HIGH,
},
),
StrategyRule(
rule_id="elasticity_demand_stimulation",
name="Demand Stimulation",
@@ -371,8 +371,8 @@ class StrategyLibrary:
condition="demand_level < 0.4 and inventory_turnover < threshold",
action="apply_discount = 0.15",
priority=StrategyPriority.MEDIUM,
},
## ]
),
]
return PricingStrategyConfig(
strategy_id="demand_elasticity_v1",
@@ -383,7 +383,7 @@ class StrategyLibrary:
rules=rules,
risk_tolerance=RiskTolerance.AGGRESSIVE,
priority=StrategyPriority.MEDIUM,
}
)
@staticmethod
def get_penetration_pricing_strategy() -> PricingStrategyConfig:
@@ -401,7 +401,7 @@ class StrategyLibrary:
weekend_multiplier=0.9,
growth_target_rate=0.3, # 30% growth target
market_share_target=0.2, # 20% market share target
}
)
rules = [
StrategyRule(
@@ -411,7 +411,7 @@ class StrategyLibrary:
condition="market_share < 0.05 and time_in_market < 6_months",
action="set_price = cost * 1.1",
priority=StrategyPriority.CRITICAL,
},
),
StrategyRule(
rule_id="penetration_gradual_increase",
name="Gradual Price Increase",
@@ -419,8 +419,8 @@ class StrategyLibrary:
condition="market_share > 0.1 and customer_loyalty > 12_months",
action="increase_price = 0.05",
priority=StrategyPriority.MEDIUM,
},
## ]
),
]
return PricingStrategyConfig(
strategy_id="penetration_pricing_v1",
@@ -431,7 +431,7 @@ class StrategyLibrary:
rules=rules,
risk_tolerance=RiskTolerance.AGGRESSIVE,
priority=StrategyPriority.HIGH,
}
)
@staticmethod
def get_premium_pricing_strategy() -> PricingStrategyConfig:
@@ -450,7 +450,7 @@ class StrategyLibrary:
performance_bonus_rate=0.2,
performance_penalty_rate=0.1,
profit_target_margin=0.4, # 40% profit target
}
)
rules = [
StrategyRule(
@@ -460,7 +460,7 @@ class StrategyLibrary:
condition="quality_score > 0.95 and brand_recognition > high",
action="maintain_premium = true",
priority=StrategyPriority.CRITICAL,
},
),
StrategyRule(
rule_id="premium_exclusivity",
name="Exclusivity Pricing",
@@ -468,8 +468,8 @@ class StrategyLibrary:
condition="exclusive_features == true and customer_segment == premium",
action="apply_premium = 0.3",
priority=StrategyPriority.HIGH,
},
## ]
),
]
return PricingStrategyConfig(
strategy_id="premium_pricing_v1",
@@ -480,7 +480,7 @@ class StrategyLibrary:
rules=rules,
risk_tolerance=RiskTolerance.CONSERVATIVE,
priority=StrategyPriority.MEDIUM,
}
)
@staticmethod
def get_all_strategies() -> dict[PricingStrategy, PricingStrategyConfig]:
@@ -506,7 +506,7 @@ class StrategyOptimizer:
def optimize_strategy(
self, strategy_config: PricingStrategyConfig, performance_data: dict[str, Any]
} -> PricingStrategyConfig:
) -> PricingStrategyConfig:
"""Optimize strategy parameters based on performance"""
strategy_id = strategy_config.strategy_id
@@ -559,11 +559,11 @@ class StrategyOptimizer:
"action": "increase_demand_sensitivity",
"adjustment": 0.15,
},
## ]
]
def _apply_optimization_rules(
self, strategy_config: PricingStrategyConfig, performance_data: dict[str, Any]
} -> PricingStrategyConfig:
) -> PricingStrategyConfig:
"""Apply optimization rules to strategy configuration"""
# Create a copy to avoid modifying the original
@@ -592,7 +592,7 @@ class StrategyOptimizer:
market_share_target=strategy_config.parameters.market_share_target,
regional_adjustments=strategy_config.parameters.regional_adjustments.copy(),
custom_parameters=strategy_config.parameters.custom_parameters.copy(),
},
),
rules=strategy_config.rules.copy(),
risk_tolerance=strategy_config.risk_tolerance,
priority=strategy_config.priority,
@@ -602,7 +602,7 @@ class StrategyOptimizer:
max_price=strategy_config.max_price,
resource_types=strategy_config.resource_types.copy(),
regions=strategy_config.regions.copy(),
}
)
# Apply each optimization rule
for rule in self.optimization_rules:

View File

@@ -120,7 +120,7 @@ class AnalyticsSummaryResponse(BaseModel):
@router.post("/data-collection", response_model=AnalyticsSummaryResponse)
async def collect_market_data(
period_type: AnalyticsPeriod = Query(default=AnalyticsPeriod.DAILY, description="Collection period"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session),
) -> AnalyticsSummaryResponse:
"""Collect market data for analytics"""
@@ -142,7 +142,7 @@ async def get_market_insights(
insight_type: Optional[str] = Query(default=None, description="Filter by insight type"),
impact_level: Optional[str] = Query(default=None, description="Filter by impact level"),
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Get market insights and analysis"""
@@ -180,7 +180,7 @@ async def get_market_metrics(
category: Optional[str] = Query(default=None, description="Filter by category"),
geographic_region: Optional[str] = Query(default=None, description="Filter by region"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[MetricResponse]:
"""Get market metrics with filters"""
@@ -224,7 +224,7 @@ async def get_market_metrics(
@router.get("/overview", response_model=MarketOverviewResponse)
async def get_market_overview(
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> MarketOverviewResponse:
"""Get comprehensive market overview"""
@@ -245,7 +245,7 @@ async def create_dashboard(
owner_id: str,
dashboard_type: str = Query(default="default", description="Dashboard type: default, executive"),
name: Optional[str] = Query(default=None, description="Custom dashboard name"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> DashboardResponse:
"""Create analytics dashboard"""
@@ -286,7 +286,7 @@ async def create_dashboard(
@router.get("/dashboards/{dashboard_id}", response_model=DashboardResponse)
async def get_dashboard(
dashboard_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> DashboardResponse:
"""Get dashboard configuration"""
@@ -327,7 +327,7 @@ async def list_dashboards(
dashboard_type: Optional[str] = Query(default=None, description="Filter by dashboard type"),
status: Optional[str] = Query(default=None, description="Filter by status"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[DashboardResponse]:
"""List analytics dashboards with filters"""
@@ -372,7 +372,7 @@ async def list_dashboards(
@router.post("/reports", response_model=Dict[str, Any])
async def generate_report(
report_request: ReportRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Generate analytics report"""
@@ -446,7 +446,7 @@ async def generate_report(
async def get_report(
report_id: str,
format: str = Query(default="json", description="Response format: json, csv, pdf"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Get generated analytics report"""
@@ -500,7 +500,7 @@ async def get_analytics_alerts(
severity: Optional[str] = Query(default=None, description="Filter by severity level"),
status: Optional[str] = Query(default="active", description="Filter by status"),
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get analytics alerts"""
@@ -545,7 +545,7 @@ async def get_analytics_alerts(
@router.get("/kpi")
async def get_key_performance_indicators(
period_type: AnalyticsPeriod = Query(default=AnalyticsPeriod.DAILY, description="Period type"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Get key performance indicators"""

View File

@@ -169,7 +169,7 @@ class BountyStatsResponse(BaseModel):
tier_distribution: Dict[str, int]
# Dependency injection
def get_bounty_service(session: Annotated[Session, Depends(get_session)]) -> BountyService:
def get_bounty_service(session: Session = Depends(get_session)) -> BountyService:
return BountyService(session)
def get_blockchain_service() -> BlockchainService:
@@ -180,7 +180,7 @@ def get_blockchain_service() -> BlockchainService:
async def create_bounty(
request: BountyCreateRequest,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -212,7 +212,7 @@ async def create_bounty(
@router.get("/bounties", response_model=List[BountyResponse])
async def get_bounties(
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
filters: BountyFilterRequest = Depends(),
bounty_service: BountyService = Depends(get_bounty_service)
):
@@ -242,7 +242,7 @@ async def get_bounties(
@router.get("/bounties/{bounty_id}", response_model=BountyResponse)
async def get_bounty(
bounty_id: str,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service)
):
"""Get bounty details"""
@@ -264,7 +264,7 @@ async def submit_bounty_solution(
bounty_id: str,
request: BountySubmissionRequest,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -313,7 +313,7 @@ async def submit_bounty_solution(
@router.get("/bounties/{bounty_id}/submissions", response_model=List[BountySubmissionResponse])
async def get_bounty_submissions(
bounty_id: str,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service),
current_user: dict = Depends(get_current_user)
):
@@ -343,7 +343,7 @@ async def verify_bounty_submission(
bounty_id: str,
request: BountyVerificationRequest,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -383,7 +383,7 @@ async def dispute_bounty_submission(
bounty_id: str,
request: BountyDisputeRequest,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -418,7 +418,7 @@ async def get_my_created_bounties(
status: Optional[BountyStatus] = None,
page: int = Field(default=1, ge=1),
limit: int = Field(default=20, ge=1, le=100),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service),
current_user: dict = Depends(get_current_user)
):
@@ -442,7 +442,7 @@ async def get_my_submissions(
status: Optional[SubmissionStatus] = None,
page: int = Field(default=1, ge=1),
limit: int = Field(default=20, ge=1, le=100),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service),
current_user: dict = Depends(get_current_user)
):
@@ -465,7 +465,7 @@ async def get_my_submissions(
async def get_bounty_leaderboard(
period: str = Field(default="weekly", regex="^(daily|weekly|monthly)$"),
limit: int = Field(default=50, ge=1, le=100),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service)
):
"""Get bounty leaderboard"""
@@ -484,7 +484,7 @@ async def get_bounty_leaderboard(
@router.get("/bounties/stats", response_model=BountyStatsResponse)
async def get_bounty_stats(
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service)
):
"""Get bounty statistics"""
@@ -501,7 +501,7 @@ async def get_bounty_stats(
async def expire_bounty(
bounty_id: str,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -541,7 +541,7 @@ async def expire_bounty(
@router.get("/bounties/categories")
async def get_bounty_categories(
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service)
):
"""Get all bounty categories"""
@@ -556,7 +556,7 @@ async def get_bounty_categories(
@router.get("/bounties/tags")
async def get_bounty_tags(
limit: int = Field(default=100, ge=1, le=500),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service)
):
"""Get popular bounty tags"""
@@ -573,7 +573,7 @@ async def search_bounties(
query: str = Field(..., min_length=1, max_length=100),
page: int = Field(default=1, ge=1),
limit: int = Field(default=20, ge=1, le=100),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
bounty_service: BountyService = Depends(get_bounty_service)
):
"""Search bounties by text"""

View File

@@ -134,7 +134,7 @@ class AgentCertificationSummary(BaseModel):
@router.post("/certify", response_model=CertificationResponse)
async def certify_agent(
certification_request: CertificationRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> CertificationResponse:
"""Certify an agent at a specific level"""
@@ -178,7 +178,7 @@ async def certify_agent(
async def renew_certification(
certification_id: str,
renewed_by: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Renew an existing certification"""
@@ -211,7 +211,7 @@ async def renew_certification(
async def get_agent_certifications(
agent_id: str,
status: Optional[str] = Query(default=None, description="Filter by status"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session),
) -> List[CertificationResponse]:
"""Get certifications for an agent"""
@@ -257,7 +257,7 @@ async def create_partnership_program(
tier_levels: List[str] = Field(default_factory=lambda: ["basic", "premium"]),
max_participants: Optional[int] = Field(default=None, description="Maximum participants"),
launch_immediately: bool = Field(default=False, description="Launch program immediately"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Create a new partnership program"""
@@ -295,7 +295,7 @@ async def create_partnership_program(
@router.post("/partnerships/apply", response_model=PartnershipResponse)
async def apply_for_partnership(
application: PartnershipApplicationRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> PartnershipResponse:
"""Apply for a partnership program"""
@@ -338,7 +338,7 @@ async def get_agent_partnerships(
agent_id: str,
status: Optional[str] = Query(default=None, description="Filter by status"),
partnership_type: Optional[str] = Query(default=None, description="Filter by partnership type"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[PartnershipResponse]:
"""Get partnerships for an agent"""
@@ -381,7 +381,7 @@ async def list_partnership_programs(
partnership_type: Optional[str] = Query(default=None, description="Filter by partnership type"),
status: Optional[str] = Query(default="active", description="Filter by status"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""List available partnership programs"""
@@ -422,7 +422,7 @@ async def list_partnership_programs(
@router.post("/badges")
async def create_badge(
badge_request: BadgeCreationRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Create a new achievement badge"""
@@ -460,7 +460,7 @@ async def create_badge(
@router.post("/badges/award", response_model=BadgeResponse)
async def award_badge(
badge_request: BadgeAwardRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> BadgeResponse:
"""Award a badge to an agent"""
@@ -511,7 +511,7 @@ async def get_agent_badges(
category: Optional[str] = Query(default=None, description="Filter by category"),
featured_only: bool = Query(default=False, description="Only featured badges"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[BadgeResponse]:
"""Get badges for an agent"""
@@ -564,7 +564,7 @@ async def list_available_badges(
rarity: Optional[str] = Query(default=None, description="Filter by rarity"),
active_only: bool = Query(default=True, description="Only active badges"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""List available badges"""
@@ -612,7 +612,7 @@ async def list_available_badges(
@router.post("/badges/{agent_id}/check-automatic")
async def check_automatic_badges(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Check and award automatic badges for an agent"""
@@ -636,7 +636,7 @@ async def check_automatic_badges(
@router.get("/summary/{agent_id}", response_model=AgentCertificationSummary)
async def get_agent_summary(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> AgentCertificationSummary:
"""Get comprehensive certification and partnership summary for an agent"""
@@ -658,7 +658,7 @@ async def get_verification_records(
verification_type: Optional[str] = Query(default=None, description="Filter by verification type"),
status: Optional[str] = Query(default=None, description="Filter by status"),
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get verification records for an agent"""
@@ -698,7 +698,7 @@ async def get_verification_records(
@router.get("/levels")
async def get_certification_levels(
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get available certification levels and requirements"""
@@ -726,7 +726,7 @@ async def get_certification_levels(
async def get_certification_requirements(
level: Optional[str] = Query(default=None, description="Filter by certification level"),
verification_type: Optional[str] = Query(default=None, description="Filter by verification type"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get certification requirements"""
@@ -770,7 +770,7 @@ async def get_certification_requirements(
async def get_certification_leaderboard(
category: str = Query(default="highest_level", description="Leaderboard category"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get certification leaderboard"""

View File

@@ -83,14 +83,14 @@ class MetricsFilterRequest(BaseModel):
compare_period: Optional[str] = None
# Dependency injection
def get_ecosystem_service(session: Annotated[Session, Depends(get_session)]) -> EcosystemService:
def get_ecosystem_service(session: Session = Depends(get_session)) -> EcosystemService:
return EcosystemService(session)
# API endpoints
@router.get("/ecosystem/developer-earnings", response_model=DeveloperEarningsResponse)
async def get_developer_earnings(
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service),
current_user: dict = Depends(get_current_user)
):
@@ -110,7 +110,7 @@ async def get_developer_earnings(
@router.get("/ecosystem/agent-utilization", response_model=AgentUtilizationResponse)
async def get_agent_utilization(
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get agent utilization metrics"""
@@ -129,7 +129,7 @@ async def get_agent_utilization(
@router.get("/ecosystem/treasury-allocation", response_model=TreasuryAllocationResponse)
async def get_treasury_allocation(
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get DAO treasury allocation metrics"""
@@ -148,7 +148,7 @@ async def get_treasury_allocation(
@router.get("/ecosystem/staking-metrics", response_model=StakingMetricsResponse)
async def get_staking_metrics(
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get staking system metrics"""
@@ -167,7 +167,7 @@ async def get_staking_metrics(
@router.get("/ecosystem/bounty-analytics", response_model=BountyAnalyticsResponse)
async def get_bounty_analytics(
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get bounty system analytics"""
@@ -186,7 +186,7 @@ async def get_bounty_analytics(
@router.get("/ecosystem/overview", response_model=EcosystemOverviewResponse)
async def get_ecosystem_overview(
period_type: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get comprehensive ecosystem overview"""
@@ -215,7 +215,7 @@ async def get_ecosystem_metrics(
start_date: Optional[datetime] = None,
end_date: Optional[datetime] = None,
limit: int = Field(default=100, ge=1, le=1000),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get time-series ecosystem metrics"""
@@ -239,7 +239,7 @@ async def get_ecosystem_metrics(
@router.get("/ecosystem/health-score")
async def get_ecosystem_health_score(
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get overall ecosystem health score"""
@@ -260,7 +260,7 @@ async def get_ecosystem_health_score(
@router.get("/ecosystem/growth-indicators")
async def get_growth_indicators(
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get ecosystem growth indicators"""
@@ -283,7 +283,7 @@ async def get_top_performers(
category: str = Field(default="all", regex="^(developers|agents|stakers|all)$"),
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
limit: int = Field(default=50, ge=1, le=100),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get top performers in different categories"""
@@ -309,7 +309,7 @@ async def get_top_performers(
async def get_ecosystem_predictions(
metric: str = Field(default="all", regex="^(earnings|staking|bounties|agents|all)$"),
horizon: int = Field(default=30, ge=1, le=365), # days
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get ecosystem predictions based on historical data"""
@@ -334,7 +334,7 @@ async def get_ecosystem_predictions(
@router.get("/ecosystem/alerts")
async def get_ecosystem_alerts(
severity: str = Field(default="all", regex="^(low|medium|high|critical|all)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get ecosystem alerts and anomalies"""
@@ -358,7 +358,7 @@ async def get_ecosystem_comparison(
compare_period: str = Field(default="previous", regex="^(previous|same_last_year|custom)$"),
custom_start_date: Optional[datetime] = None,
custom_end_date: Optional[datetime] = None,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Compare ecosystem metrics between periods"""
@@ -387,7 +387,7 @@ async def export_ecosystem_data(
period_type: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
start_date: Optional[datetime] = None,
end_date: Optional[datetime] = None,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Export ecosystem data in various formats"""
@@ -414,7 +414,7 @@ async def export_ecosystem_data(
@router.get("/ecosystem/real-time")
async def get_real_time_metrics(
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get real-time ecosystem metrics"""
@@ -433,7 +433,7 @@ async def get_real_time_metrics(
@router.get("/ecosystem/kpi-dashboard")
async def get_kpi_dashboard(
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
):
"""Get KPI dashboard with key performance indicators"""

View File

@@ -124,7 +124,7 @@ class ReputationMetricsResponse(BaseModel):
@router.get("/profile/{agent_id}", response_model=ReputationProfileResponse)
async def get_reputation_profile(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> ReputationProfileResponse:
"""Get comprehensive reputation profile for an agent"""
@@ -146,7 +146,7 @@ async def get_reputation_profile(
@router.post("/profile/{agent_id}")
async def create_reputation_profile(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Create a new reputation profile for an agent"""
@@ -172,7 +172,7 @@ async def create_reputation_profile(
async def add_community_feedback(
agent_id: str,
feedback_request: FeedbackRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> FeedbackResponse:
"""Add community feedback for an agent"""
@@ -210,7 +210,7 @@ async def add_community_feedback(
@router.post("/job-completion")
async def record_job_completion(
job_request: JobCompletionRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Record job completion and update reputation"""
@@ -243,7 +243,7 @@ async def record_job_completion(
@router.get("/trust-score/{agent_id}", response_model=TrustScoreResponse)
async def get_trust_score_breakdown(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> TrustScoreResponse:
"""Get detailed trust score breakdown for an agent"""
@@ -284,7 +284,7 @@ async def get_reputation_leaderboard(
category: str = Query(default="trust_score", description="Category to rank by"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
region: Optional[str] = Query(default=None, description="Filter by region"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session),
) -> List[LeaderboardEntry]:
"""Get reputation leaderboard"""
@@ -306,7 +306,7 @@ async def get_reputation_leaderboard(
@router.get("/metrics", response_model=ReputationMetricsResponse)
async def get_reputation_metrics(
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> ReputationMetricsResponse:
"""Get overall reputation system metrics"""
@@ -379,7 +379,7 @@ async def get_reputation_metrics(
async def get_agent_feedback(
agent_id: str,
limit: int = Query(default=10, ge=1, le=50),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[FeedbackResponse]:
"""Get community feedback for an agent"""
@@ -423,7 +423,7 @@ async def get_agent_feedback(
async def get_reputation_events(
agent_id: str,
limit: int = Query(default=20, ge=1, le=100),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get reputation change events for an agent"""
@@ -460,7 +460,7 @@ async def get_reputation_events(
async def update_specialization(
agent_id: str,
specialization_tags: List[str],
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Update agent specialization tags"""
@@ -496,7 +496,7 @@ async def update_specialization(
async def update_region(
agent_id: str,
region: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Update agent geographic region"""
@@ -532,7 +532,7 @@ async def update_region(
@router.get("/{agent_id}/cross-chain")
async def get_cross_chain_reputation(
agent_id: str,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
reputation_service: ReputationService = Depends()
) -> Dict[str, Any]:
"""Get cross-chain reputation data for an agent"""
@@ -581,7 +581,7 @@ async def get_cross_chain_reputation(
async def sync_cross_chain_reputation(
agent_id: str,
background_tasks: Any, # FastAPI BackgroundTasks
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
reputation_service: ReputationService = Depends()
) -> Dict[str, Any]:
"""Synchronize reputation across chains for an agent"""
@@ -615,7 +615,7 @@ async def sync_cross_chain_reputation(
async def get_cross_chain_leaderboard(
limit: int = Query(50, ge=1, le=100),
min_score: float = Query(0.0, ge=0.0, le=1.0),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
reputation_service: ReputationService = Depends()
) -> Dict[str, Any]:
"""Get cross-chain reputation leaderboard"""
@@ -662,7 +662,7 @@ async def get_cross_chain_leaderboard(
async def submit_cross_chain_event(
event_data: Dict[str, Any],
background_tasks: Any, # FastAPI BackgroundTasks
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
reputation_service: ReputationService = Depends()
) -> Dict[str, Any]:
"""Submit a cross-chain reputation event"""
@@ -726,7 +726,7 @@ async def submit_cross_chain_event(
@router.get("/cross-chain/analytics")
async def get_cross_chain_analytics(
chain_id: Optional[int] = Query(None),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
reputation_service: ReputationService = Depends()
) -> Dict[str, Any]:
"""Get cross-chain reputation analytics"""

View File

@@ -116,7 +116,7 @@ class MilestoneResponse(BaseModel):
@router.get("/profile/{agent_id}", response_model=RewardProfileResponse)
async def get_reward_profile(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> RewardProfileResponse:
"""Get comprehensive reward profile for an agent"""
@@ -138,7 +138,7 @@ async def get_reward_profile(
@router.post("/profile/{agent_id}")
async def create_reward_profile(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Create a new reward profile for an agent"""
@@ -163,7 +163,7 @@ async def create_reward_profile(
@router.post("/calculate-and-distribute", response_model=RewardResponse)
async def calculate_and_distribute_reward(
reward_request: RewardRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> RewardResponse:
"""Calculate and distribute reward for an agent"""
@@ -202,7 +202,7 @@ async def calculate_and_distribute_reward(
@router.get("/tier-progress/{agent_id}", response_model=TierProgressResponse)
async def get_tier_progress(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> TierProgressResponse:
"""Get tier progress information for an agent"""
@@ -302,7 +302,7 @@ async def get_tier_progress(
@router.post("/batch-process", response_model=BatchProcessResponse)
async def batch_process_pending_rewards(
limit: int = Query(default=100, ge=1, le=1000, description="Maximum number of rewards to process"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session),
) -> BatchProcessResponse:
"""Process pending reward distributions in batch"""
@@ -327,7 +327,7 @@ async def get_reward_analytics(
period_type: str = Query(default="daily", description="Period type: daily, weekly, monthly"),
start_date: Optional[str] = Query(default=None, description="Start date (ISO format)"),
end_date: Optional[str] = Query(default=None, description="End date (ISO format)"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> RewardAnalyticsResponse:
"""Get reward system analytics"""
@@ -360,7 +360,7 @@ async def get_reward_leaderboard(
tier: Optional[str] = Query(default=None, description="Filter by tier"),
period: str = Query(default="weekly", description="Period: daily, weekly, monthly"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get reward leaderboard"""
@@ -409,7 +409,7 @@ async def get_reward_leaderboard(
@router.get("/tiers")
async def get_reward_tiers(
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get reward tier configurations"""
@@ -446,7 +446,7 @@ async def get_reward_tiers(
async def get_agent_milestones(
agent_id: str,
include_completed: bool = Query(default=True, description="Include completed milestones"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[MilestoneResponse]:
"""Get milestones for an agent"""
@@ -490,7 +490,7 @@ async def get_reward_distributions(
agent_id: str,
limit: int = Query(default=20, ge=1, le=100),
status: Optional[str] = Query(default=None, description="Filter by status"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[Dict[str, Any]]:
"""Get reward distribution history for an agent"""
@@ -530,7 +530,7 @@ async def get_reward_distributions(
@router.post("/simulate-reward")
async def simulate_reward_calculation(
reward_request: RewardRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Simulate reward calculation without distributing"""

View File

@@ -136,7 +136,7 @@ class EarningsDistributionRequest(BaseModel):
distribution_data: Dict[str, Any] = Field(default_factory=dict)
# Dependency injection
def get_staking_service(session: Annotated[Session, Depends(get_session)]) -> StakingService:
def get_staking_service(session: Session = Depends(get_session)) -> StakingService:
return StakingService(session)
def get_blockchain_service() -> BlockchainService:
@@ -147,7 +147,7 @@ def get_blockchain_service() -> BlockchainService:
async def create_stake(
request: StakeCreateRequest,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -188,7 +188,7 @@ async def create_stake(
@router.get("/stake/{stake_id}", response_model=StakeResponse)
async def get_stake(
stake_id: str,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
current_user: dict = Depends(get_current_user)
):
@@ -213,7 +213,7 @@ async def get_stake(
@router.get("/stakes", response_model=List[StakeResponse])
async def get_stakes(
filters: StakingFilterRequest = Depends(),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
current_user: dict = Depends(get_current_user)
):
@@ -242,7 +242,7 @@ async def add_to_stake(
stake_id: str,
request: StakeUpdateRequest,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -285,7 +285,7 @@ async def add_to_stake(
async def unbond_stake(
stake_id: str,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -327,7 +327,7 @@ async def unbond_stake(
async def complete_unbonding(
stake_id: str,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -370,7 +370,7 @@ async def complete_unbonding(
@router.get("/stake/{stake_id}/rewards")
async def get_stake_rewards(
stake_id: str,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
current_user: dict = Depends(get_current_user)
):
@@ -405,7 +405,7 @@ async def get_stake_rewards(
@router.get("/agents/{agent_wallet}/metrics", response_model=AgentMetricsResponse)
async def get_agent_metrics(
agent_wallet: str,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service)
):
"""Get agent performance metrics"""
@@ -425,7 +425,7 @@ async def get_agent_metrics(
@router.get("/agents/{agent_wallet}/staking-pool", response_model=StakingPoolResponse)
async def get_staking_pool(
agent_wallet: str,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service)
):
"""Get staking pool information for an agent"""
@@ -446,7 +446,7 @@ async def get_staking_pool(
async def get_agent_apy(
agent_wallet: str,
lock_period: int = Field(default=30, ge=1, le=365),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service)
):
"""Get current APY for staking on an agent"""
@@ -470,7 +470,7 @@ async def update_agent_performance(
agent_wallet: str,
request: AgentPerformanceUpdateRequest,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -508,7 +508,7 @@ async def distribute_agent_earnings(
agent_wallet: str,
request: EarningsDistributionRequest,
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -551,7 +551,7 @@ async def get_supported_agents(
page: int = Field(default=1, ge=1),
limit: int = Field(default=50, ge=1, le=100),
tier: Optional[PerformanceTier] = None,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service)
):
"""Get list of supported agents for staking"""
@@ -576,7 +576,7 @@ async def get_supported_agents(
@router.get("/staking/stats", response_model=StakingStatsResponse)
async def get_staking_stats(
period: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service)
):
"""Get staking system statistics"""
@@ -594,7 +594,7 @@ async def get_staking_leaderboard(
period: str = Field(default="weekly", regex="^(daily|weekly|monthly)$"),
metric: str = Field(default="total_staked", regex="^(total_staked|total_rewards|apy)$"),
limit: int = Field(default=50, ge=1, le=100),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service)
):
"""Get staking leaderboard"""
@@ -617,7 +617,7 @@ async def get_my_staking_positions(
agent_wallet: Optional[str] = None,
page: int = Field(default=1, ge=1),
limit: int = Field(default=20, ge=1, le=100),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
current_user: dict = Depends(get_current_user)
):
@@ -640,7 +640,7 @@ async def get_my_staking_positions(
@router.get("/staking/my-rewards")
async def get_my_staking_rewards(
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
current_user: dict = Depends(get_current_user)
):
@@ -661,7 +661,7 @@ async def get_my_staking_rewards(
async def claim_staking_rewards(
stake_ids: List[str],
background_tasks: BackgroundTasks,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service),
blockchain_service: BlockchainService = Depends(get_blockchain_service),
current_user: dict = Depends(get_current_user)
@@ -708,7 +708,7 @@ async def claim_staking_rewards(
@router.get("/staking/risk-assessment/{agent_wallet}")
async def get_risk_assessment(
agent_wallet: str,
session: Annotated[Session, Depends(get_session)],
session: Session = Depends(get_session),
staking_service: StakingService = Depends(get_staking_service)
):
"""Get risk assessment for staking on an agent"""

View File

@@ -166,7 +166,7 @@ class TradingSummaryResponse(BaseModel):
@router.post("/requests", response_model=TradeRequestResponse)
async def create_trade_request(
request_data: TradeRequestRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> TradeRequestResponse:
"""Create a new trade request"""
@@ -228,7 +228,7 @@ async def create_trade_request(
@router.get("/requests/{request_id}", response_model=TradeRequestResponse)
async def get_trade_request(
request_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> TradeRequestResponse:
"""Get trade request details"""
@@ -266,7 +266,7 @@ async def get_trade_request(
@router.post("/requests/{request_id}/matches")
async def find_matches(
request_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[str]:
"""Find matching sellers for a trade request"""
@@ -286,7 +286,7 @@ async def find_matches(
@router.get("/requests/{request_id}/matches")
async def get_trade_matches(
request_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[TradeMatchResponse]:
"""Get trade matches for a request"""
@@ -326,7 +326,7 @@ async def get_trade_matches(
@router.post("/negotiations", response_model=NegotiationResponse)
async def initiate_negotiation(
negotiation_data: NegotiationRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> NegotiationResponse:
"""Initiate negotiation between buyer and seller"""
@@ -364,7 +364,7 @@ async def initiate_negotiation(
@router.get("/negotiations/{negotiation_id}", response_model=NegotiationResponse)
async def get_negotiation(
negotiation_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> NegotiationResponse:
"""Get negotiation details"""
@@ -401,7 +401,7 @@ async def get_negotiation(
@router.get("/matches/{match_id}")
async def get_trade_match(
match_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> TradeMatchResponse:
"""Get trade match details"""
@@ -442,7 +442,7 @@ async def get_trade_match(
@router.get("/agents/{agent_id}/summary", response_model=TradingSummaryResponse)
async def get_trading_summary(
agent_id: str,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> TradingSummaryResponse:
"""Get comprehensive trading summary for an agent"""
@@ -464,7 +464,7 @@ async def list_trade_requests(
trade_type: Optional[str] = Query(default=None, description="Filter by trade type"),
status: Optional[str] = Query(default=None, description="Filter by status"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session),
) -> List[TradeRequestResponse]:
"""List trade requests with filters"""
@@ -512,7 +512,7 @@ async def list_trade_matches(
min_score: Optional[float] = Query(default=None, description="Minimum match score"),
status: Optional[str] = Query(default=None, description="Filter by status"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[TradeMatchResponse]:
"""List trade matches with filters"""
@@ -568,7 +568,7 @@ async def list_negotiations(
status: Optional[str] = Query(default=None, description="Filter by status"),
strategy: Optional[str] = Query(default=None, description="Filter by strategy"),
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> List[NegotiationResponse]:
"""List negotiations with filters"""
@@ -619,7 +619,7 @@ async def get_trading_analytics(
period_type: str = Query(default="daily", description="Period type: daily, weekly, monthly"),
start_date: Optional[str] = Query(default=None, description="Start date (ISO format)"),
end_date: Optional[str] = Query(default=None, description="End date (ISO format)"),
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Get P2P trading analytics"""
@@ -683,7 +683,7 @@ async def get_trading_analytics(
@router.post("/simulate-match")
async def simulate_trade_matching(
request_data: TradeRequestRequest,
session: Annotated[Session, Depends(get_session)]
session: Session = Depends(get_session)
) -> Dict[str, Any]:
"""Simulate trade matching without creating actual request"""

View File

@@ -664,7 +664,7 @@ class EnterpriseIntegrationFramework:
def __init__(self):
self.integrations = {} # Active integrations
self.
self.logger = logger
async def create_integration(self, config: IntegrationConfig) -> bool:
"""Create and initialize enterprise integration"""

View File

@@ -6,7 +6,7 @@ Bitcoin Wallet Integration for AITBC Trade Exchange
import os
import json
import hashlib
import hmac
import hmac
import time
from typing import Dict, Optional, Tuple
from dataclasses import dataclass

View File

@@ -424,15 +424,14 @@ def main():
# Wait for coordinator
if not wait_for_coordinator():
# Registration bypassed for testing
session_token = "bypass_token"
# # sys.exit(1)
logger.error("Coordinator not available")
return
# Register with coordinator
session_token = register_miner()
if not session_token:
# logger.error("Failed to register, exiting")
# sys.exit(1)
logger.error("Failed to register, exiting")
return
logger.info("Miner registered successfully, starting main loop...")

View File

@@ -240,6 +240,7 @@ def ollama_task(ctx, gpu_id: str, model: str, prompt: str, temperature: float, m
else:
error(f"Failed to submit Ollama task: {response.status_code} {response.text}")
except Exception as e:
error(f"Failed to submit Ollama task: {e}")
@gpu.command(name="pay")