agentloop-profiler 0.2.7__tar.gz → 0.2.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/PKG-INFO +4 -4
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/README.md +3 -3
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/cli.py +119 -13
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/client.py +12 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/doctor.py +104 -5
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/migrations.py +19 -0
- agentloop_profiler-0.2.8/agentloop/request_limits.py +102 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/server.py +32 -5
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/store.py +215 -26
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/version.py +1 -1
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop_profiler.egg-info/PKG-INFO +4 -4
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop_profiler.egg-info/SOURCES.txt +3 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/dashboard/app.py +69 -6
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/pyproject.toml +1 -1
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_ci_evidence.py +23 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_cli_store_commands.py +30 -0
- agentloop_profiler-0.2.8/tests/test_cli_upload.py +96 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_client.py +26 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dashboard_project_access.py +47 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_doctor_autoinstrument.py +58 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_finding_identity.py +2 -1
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_migrations.py +2 -2
- agentloop_profiler-0.2.8/tests/test_request_limits.py +91 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_server.py +46 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_store_contract.py +85 -1
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/LICENSE +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/THIRD_PARTY_LICENSES.md +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/__init__.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/ablation_protocol.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/ablations.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/aggregate_cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/aggregate_stats.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/aggregates.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/audit.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/autoinstrument.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/batch_experiments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/batching.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/budget_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/budgets.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/calibration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/checkpoint_state.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/checkpoint_store.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/ci.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/cli_paths.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/completion.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/completion_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/config.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/context_controls.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/context_experiments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/context_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/costs.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/cursor_validation.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/decorators.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/demo.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/drift.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/drift_cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/drift_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/drift_windows.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/entrypoint.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/estimates.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/events.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/experiment_artifacts.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/experiment_observations.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/experiment_reports.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/experiment_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/experiments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/exporters.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/finding_benchmark_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/finding_benchmarks.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/findings.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/graph.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/harness.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/harness_bench/__init__.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/harness_bench/cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/harness_bench/drivers.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/harness_bench/offline.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/harness_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/harness_usage.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/html_report.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/improvement.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/improvement_cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/improvement_init.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/improvement_report.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/improvement_verifier.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/__init__.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/crewai.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/harbor/__init__.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/harbor/atif.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/harbor/atif_validation.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/harbor/cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/harbor/manifest.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/harbor/trial_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/harbor/trials.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/harbor/verifier.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/hermes.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/hermes_cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/hermes_recorder.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/langgraph.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/langgraph_harness.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/langgraph_recovery.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/omnigent/__init__.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/omnigent/cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/omnigent/evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/omnigent/telemetry.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/openai.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/openai_agents.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/sdk.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/integrations/vercel_ai.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/__init__.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/artifacts.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/cohort_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/cohorts.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/contracts.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/coordination.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/otlp_jsonl.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/otlp_validation.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/registry.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interoperability/validation.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/intervention_service.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/intervention_store.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/interventions.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/issues.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/judgment_adapters.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/judgment_benchmark_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/judgment_benchmarks.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/judgment_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/judgment_views.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/judgments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/loop_guards.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/loop_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/markdown.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/metrics.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/model_routing.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/onboarding.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/operations.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/optimizer.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/otel.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/otel_ids.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/otel_semantics.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/parallelism.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/patches.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/plan_export.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/policy_promotion.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/promotion_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/promotion_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/quality.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/ranking.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/recovery_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/repetitions.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/replay.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/retention.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/retention_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/reuse_experiments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/routing_checks.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/routing_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/rules.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/runners/__init__.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/runners/_common.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/runners/claude_code.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/runners/codex.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/runtime.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/savings.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/scheduling_plan.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/scheduling_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/schema.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/semantic_rules.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/semantic_waste.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/semantic_waste_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/structural_experiments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/structural_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/structured_quality.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/studies.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/study_statistics.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/substitution_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/substitution_export.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/substitution_reports.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/substitution_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/substitutions.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/timing.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/tokens.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/tool_scheduling.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/trace_sources.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/tracer.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/value.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/workflow_types.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop/workflows.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop_profiler.egg-info/dependency_links.txt +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop_profiler.egg-info/entry_points.txt +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop_profiler.egg-info/requires.txt +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/agentloop_profiler.egg-info/top_level.txt +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/dashboard/__init__.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/dashboard/access.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/dashboard/streamlit_compat.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/dashboard/trace_upload.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/dashboard/value_view.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/setup.cfg +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_ablations.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_aggregates.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_api_versioning.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_batch_data_pipeline.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_budgets.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_bump_version.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_calibration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_capability_registry.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_checkpoint_recovery.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_ci_command.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_claude_code_runner.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_cli_output_paths.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_cli_trace_inputs.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_client_transport.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_codex_exec_runner.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_completion.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_context_controls.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_context_reuse_experiments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_context_study.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_costs.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_crewai_integration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_cursor_server.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_cursor_shape_validation.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dashboard_input_validation.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dashboard_quality.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dashboard_semantic_waste.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dashboard_structured_quality.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dashboard_trace_upload.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dashboard_value_view.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dashboard_workflows.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_decorators.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_demo_cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_dependabot_config.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_diagnosis_api.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_distribution_metadata.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_docs_site.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_drift.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_email_workflow.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_empirical_calibration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_enforcement_conformance.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_estimates.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_evidence_workflow.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_experiments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_exporters.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_external_cohorts.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_finding_benchmarks.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_finding_rules.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_first_use_cli.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_graph.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_guided_validation.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_guided_verifier.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_harbor_atif.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_harbor_trials.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_harness.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_harness_bench.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_harness_error_usage.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_harness_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_hermes_integration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_hermes_replay_capture.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_hermes_repository_example.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_hermes_runtime_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_html_report.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_improvement.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_improvement_init.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_incident_triage.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_instrumentation_measurement.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_integration_conformance.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_interoperability_contracts.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_interventions.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_issues.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_judgment_adapters.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_judgment_benchmarks.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_judgment_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_judgment_provider_optional.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_judgments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_langgraph_conformance.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_langgraph_harness.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_langgraph_integration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_langgraph_recovery.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_loop_guards.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_markdown.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_markdown_exporters.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_marketplace_workflow.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_metrics.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_model_batching.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_model_routing.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_multiagent_coordination.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_non_agent_study.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_omnigent_telemetry.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_onboarding.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_openai_agents_integration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_openai_integration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_operations.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_optimizer.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_otel_ids.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_otel_interop.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_otlp_jsonl.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_parallelization_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_patch_plan.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_patch_source_scope.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_payment_review.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_policy_promotion.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_published_readme.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_python_support.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_quality.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_ranking.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_real_agent_study.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_real_calibration_study.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_real_harness_study.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_release_workflows.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_remote_cli_credentials.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_repetitions.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_replay.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_repository_policy_traversal.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_research_example.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_retention.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_retry_recommendations.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_routing_study.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_rule_error_privacy.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_runtime.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_savings_aggregation.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_scheduling_study.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_semantic_findings.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_semantic_waste.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_standalone_notices.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_store.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_streaming_inventory.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_streamlit_compat.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_structural_experiments.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_structured_quality.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_structured_quality_evidence.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_studies.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_substitutions.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_telemetry_conformance.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_timing.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_token_provenance.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_tool_scheduling.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_trace_context.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_trace_failure_recording.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_trace_schema.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_usefulness_benchmark.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_value.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_vercel_ai_integration.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_workflow_storage.py +0 -0
- {agentloop_profiler-0.2.7 → agentloop_profiler-0.2.8}/tests/test_workflows.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentloop-profiler
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
4
4
|
Summary: Profiler and optimization layer for AI agent execution graphs
|
|
5
5
|
Author: Dipesh Tharu Mahato
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -533,13 +533,13 @@ where the examples show `agentloop`.
|
|
|
533
533
|
<summary>Download and verify a standalone executable</summary>
|
|
534
534
|
|
|
535
535
|
Download the executable and `SHA256SUMS` from the same release. These examples use
|
|
536
|
-
version 0.2.
|
|
536
|
+
version 0.2.8. Change the version when choosing another release.
|
|
537
537
|
|
|
538
538
|
Linux (Bash):
|
|
539
539
|
|
|
540
540
|
```bash
|
|
541
541
|
set -euo pipefail
|
|
542
|
-
version=0.2.
|
|
542
|
+
version=0.2.8
|
|
543
543
|
asset="agentloop-v${version}-linux-x86_64"
|
|
544
544
|
curl --fail --location --remote-name "https://github.com/dipeshbabu/agentloop/releases/download/v${version}/${asset}"
|
|
545
545
|
curl --fail --location --remote-name "https://github.com/dipeshbabu/agentloop/releases/download/v${version}/SHA256SUMS"
|
|
@@ -556,7 +556,7 @@ chmod +x "$asset"
|
|
|
556
556
|
Windows PowerShell:
|
|
557
557
|
|
|
558
558
|
```powershell
|
|
559
|
-
$Version = "0.2.
|
|
559
|
+
$Version = "0.2.8"
|
|
560
560
|
$Asset = "agentloop-v$Version-windows-x86_64.exe"
|
|
561
561
|
Invoke-WebRequest "https://github.com/dipeshbabu/agentloop/releases/download/v$Version/$Asset" -OutFile agentloop.exe
|
|
562
562
|
Invoke-WebRequest "https://github.com/dipeshbabu/agentloop/releases/download/v$Version/SHA256SUMS" -OutFile SHA256SUMS
|
|
@@ -475,13 +475,13 @@ where the examples show `agentloop`.
|
|
|
475
475
|
<summary>Download and verify a standalone executable</summary>
|
|
476
476
|
|
|
477
477
|
Download the executable and `SHA256SUMS` from the same release. These examples use
|
|
478
|
-
version 0.2.
|
|
478
|
+
version 0.2.8. Change the version when choosing another release.
|
|
479
479
|
|
|
480
480
|
Linux (Bash):
|
|
481
481
|
|
|
482
482
|
```bash
|
|
483
483
|
set -euo pipefail
|
|
484
|
-
version=0.2.
|
|
484
|
+
version=0.2.8
|
|
485
485
|
asset="agentloop-v${version}-linux-x86_64"
|
|
486
486
|
curl --fail --location --remote-name "https://github.com/dipeshbabu/agentloop/releases/download/v${version}/${asset}"
|
|
487
487
|
curl --fail --location --remote-name "https://github.com/dipeshbabu/agentloop/releases/download/v${version}/SHA256SUMS"
|
|
@@ -498,7 +498,7 @@ chmod +x "$asset"
|
|
|
498
498
|
Windows PowerShell:
|
|
499
499
|
|
|
500
500
|
```powershell
|
|
501
|
-
$Version = "0.2.
|
|
501
|
+
$Version = "0.2.8"
|
|
502
502
|
$Asset = "agentloop-v$Version-windows-x86_64.exe"
|
|
503
503
|
Invoke-WebRequest "https://github.com/dipeshbabu/agentloop/releases/download/v$Version/$Asset" -OutFile agentloop.exe
|
|
504
504
|
Invoke-WebRequest "https://github.com/dipeshbabu/agentloop/releases/download/v$Version/SHA256SUMS" -OutFile SHA256SUMS
|
|
@@ -56,9 +56,12 @@ from agentloop.ranking import RankingSort, sort_ranked
|
|
|
56
56
|
from agentloop.replay import ReplayGates, build_replay_report, replay_report_to_markdown
|
|
57
57
|
from agentloop.store import (
|
|
58
58
|
DEFAULT_PAGE_SIZE,
|
|
59
|
+
LABEL_KEY_PATTERN,
|
|
60
|
+
MAX_LABEL_VALUE_LENGTH,
|
|
59
61
|
FindingNotFoundError,
|
|
60
62
|
FindingTransitionError,
|
|
61
63
|
get_store,
|
|
64
|
+
parse_label_filter,
|
|
62
65
|
)
|
|
63
66
|
from agentloop.studies import StudyValidationError, study_to_markdown, summarize_study
|
|
64
67
|
from agentloop.timing import format_duration_ms
|
|
@@ -983,7 +986,7 @@ def init_store() -> None:
|
|
|
983
986
|
@app.command("create-api-key")
|
|
984
987
|
def create_api_key(project_id: str = "default", name: str = "default") -> None:
|
|
985
988
|
db = get_store()
|
|
986
|
-
key = db.create_api_key(project_id=project_id, name=name)
|
|
989
|
+
key = db.create_api_key(project_id=project_id, name=name, actor="cli")
|
|
987
990
|
console.print("Created API key. Save it now; it will not be shown again.")
|
|
988
991
|
console.print(key["api_key"])
|
|
989
992
|
|
|
@@ -1003,7 +1006,7 @@ def revoke_api_key(
|
|
|
1003
1006
|
) -> None:
|
|
1004
1007
|
"""Revoke a project's API key; it stops working immediately."""
|
|
1005
1008
|
try:
|
|
1006
|
-
revoked = get_store().revoke_api_key(project_id, prefix)
|
|
1009
|
+
revoked = get_store().revoke_api_key(project_id, prefix, actor="cli")
|
|
1007
1010
|
except ValueError as exc:
|
|
1008
1011
|
raise typer.BadParameter(str(exc)) from exc
|
|
1009
1012
|
if not revoked:
|
|
@@ -1020,7 +1023,7 @@ def delete_trace(
|
|
|
1020
1023
|
project_id: str = "default",
|
|
1021
1024
|
) -> None:
|
|
1022
1025
|
"""Delete a stored trace with its findings, usage and interventions."""
|
|
1023
|
-
deleted = get_store().delete_trace(run_id, project_id)
|
|
1026
|
+
deleted = get_store().delete_trace(run_id, project_id, actor="cli")
|
|
1024
1027
|
if deleted is None:
|
|
1025
1028
|
console.print(f"No trace {run_id} in project {project_id}.", markup=False)
|
|
1026
1029
|
raise typer.Exit(1)
|
|
@@ -1038,6 +1041,7 @@ def purge_traces(
|
|
|
1038
1041
|
project_id: str | None = typer.Option(None, help="Only purge this project."),
|
|
1039
1042
|
) -> None:
|
|
1040
1043
|
"""Apply a retention period: delete traces stored longer ago than allowed."""
|
|
1044
|
+
actor = "cli" if older_than_days is not None else "retention:AGENTLOOP_RETENTION_DAYS"
|
|
1041
1045
|
if older_than_days is None:
|
|
1042
1046
|
configured = os.getenv("AGENTLOOP_RETENTION_DAYS", "").strip()
|
|
1043
1047
|
if not configured:
|
|
@@ -1054,7 +1058,7 @@ def purge_traces(
|
|
|
1054
1058
|
param_hint="AGENTLOOP_RETENTION_DAYS",
|
|
1055
1059
|
) from None
|
|
1056
1060
|
try:
|
|
1057
|
-
deleted = get_store().purge_traces(older_than_days, project_id=project_id)
|
|
1061
|
+
deleted = get_store().purge_traces(older_than_days, project_id=project_id, actor=actor)
|
|
1058
1062
|
except ValueError as exc:
|
|
1059
1063
|
raise typer.BadParameter(str(exc)) from exc
|
|
1060
1064
|
scope = f"project {project_id}" if project_id else "all projects"
|
|
@@ -1067,6 +1071,20 @@ def purge_traces(
|
|
|
1067
1071
|
)
|
|
1068
1072
|
|
|
1069
1073
|
|
|
1074
|
+
@app.command("audit-log")
|
|
1075
|
+
def audit_log(
|
|
1076
|
+
project_id: str | None = typer.Option(None, help="Only this project's events."),
|
|
1077
|
+
limit: int = typer.Option(50, min=1, max=1000, help="Newest events to show."),
|
|
1078
|
+
) -> None:
|
|
1079
|
+
"""Show recent key, deletion and retention events from the store's audit log."""
|
|
1080
|
+
console.print_json(
|
|
1081
|
+
data={
|
|
1082
|
+
"project_id": project_id,
|
|
1083
|
+
"events": get_store().list_audit_events(project_id, limit=limit),
|
|
1084
|
+
}
|
|
1085
|
+
)
|
|
1086
|
+
|
|
1087
|
+
|
|
1070
1088
|
@app.command("store-trace")
|
|
1071
1089
|
def store_trace(
|
|
1072
1090
|
path: Path = Path("runs/research_agent_baseline.json"),
|
|
@@ -1085,14 +1103,24 @@ def list_stored_traces(
|
|
|
1085
1103
|
cursor: str | None = typer.Option(
|
|
1086
1104
|
None, help="Continuation cursor from a previous --limit call's printed next-cursor."
|
|
1087
1105
|
),
|
|
1106
|
+
label: str | None = typer.Option(
|
|
1107
|
+
None, help="Only traces with this KEY=VALUE label, such as commit=abc123."
|
|
1108
|
+
),
|
|
1088
1109
|
) -> None:
|
|
1089
1110
|
db = get_store()
|
|
1090
|
-
|
|
1111
|
+
try:
|
|
1112
|
+
label_filter = parse_label_filter(label) if label is not None else None
|
|
1113
|
+
except ValueError as exc:
|
|
1114
|
+
raise typer.BadParameter(str(exc), param_hint="--label") from exc
|
|
1115
|
+
if limit is None and cursor is None and label_filter is None:
|
|
1091
1116
|
traces = db.list_traces(project_id=project_id)
|
|
1092
1117
|
next_cursor = None
|
|
1093
1118
|
else:
|
|
1094
1119
|
page = db.list_traces_page(
|
|
1095
|
-
project_id=project_id,
|
|
1120
|
+
project_id=project_id,
|
|
1121
|
+
limit=limit or DEFAULT_PAGE_SIZE,
|
|
1122
|
+
cursor=cursor,
|
|
1123
|
+
label=label_filter,
|
|
1096
1124
|
)
|
|
1097
1125
|
traces = page["items"]
|
|
1098
1126
|
next_cursor = page["next_cursor"]
|
|
@@ -1102,8 +1130,11 @@ def list_stored_traces(
|
|
|
1102
1130
|
table.add_column("Name")
|
|
1103
1131
|
table.add_column("Runtime ms")
|
|
1104
1132
|
table.add_column("Cost")
|
|
1133
|
+
show_labels = any(item.get("labels") for item in traces)
|
|
1134
|
+
if show_labels:
|
|
1135
|
+
table.add_column("Labels")
|
|
1105
1136
|
for item in traces:
|
|
1106
|
-
|
|
1137
|
+
row = [
|
|
1107
1138
|
str(item.get("project_id", "")),
|
|
1108
1139
|
str(item.get("run_id", "")),
|
|
1109
1140
|
str(item.get("name", "")),
|
|
@@ -1111,7 +1142,11 @@ def list_stored_traces(
|
|
|
1111
1142
|
if item.get("total_runtime_ms") is None
|
|
1112
1143
|
else f"{float(item.get('total_runtime_ms', 0)):.2f}",
|
|
1113
1144
|
format_cost_usd(item.get("estimated_cost_usd"), item.get("cost_status", "complete")),
|
|
1114
|
-
|
|
1145
|
+
]
|
|
1146
|
+
if show_labels:
|
|
1147
|
+
labels = item.get("labels") or {}
|
|
1148
|
+
row.append(", ".join(f"{key}={value}" for key, value in sorted(labels.items())))
|
|
1149
|
+
table.add_row(*row, end_section=False)
|
|
1115
1150
|
console.print(table)
|
|
1116
1151
|
if next_cursor:
|
|
1117
1152
|
console.print(f"More results available. Next cursor: {next_cursor}")
|
|
@@ -1270,19 +1305,76 @@ def usage_summary(project_id: str | None = None) -> None:
|
|
|
1270
1305
|
console.print(table)
|
|
1271
1306
|
|
|
1272
1307
|
|
|
1308
|
+
def _parse_labels(values: list[str] | None) -> dict[str, str]:
|
|
1309
|
+
labels: dict[str, str] = {}
|
|
1310
|
+
for value in values or []:
|
|
1311
|
+
key, separator, text = value.partition("=")
|
|
1312
|
+
if not separator or not LABEL_KEY_PATTERN.match(key):
|
|
1313
|
+
raise typer.BadParameter(
|
|
1314
|
+
"Use KEY=VALUE with a key of letters, digits, '.', '_' or '-'",
|
|
1315
|
+
param_hint="--label",
|
|
1316
|
+
)
|
|
1317
|
+
if len(text) > MAX_LABEL_VALUE_LENGTH:
|
|
1318
|
+
raise typer.BadParameter(
|
|
1319
|
+
f"Label values are limited to {MAX_LABEL_VALUE_LENGTH} characters",
|
|
1320
|
+
param_hint="--label",
|
|
1321
|
+
)
|
|
1322
|
+
labels[key] = text
|
|
1323
|
+
return labels
|
|
1324
|
+
|
|
1325
|
+
|
|
1326
|
+
def _upload_files(paths: list[Path]) -> list[Path]:
|
|
1327
|
+
files: list[Path] = []
|
|
1328
|
+
for path in paths:
|
|
1329
|
+
if path.is_dir():
|
|
1330
|
+
found = sorted(item for item in path.glob("*.json") if item.is_file())
|
|
1331
|
+
if not found:
|
|
1332
|
+
raise typer.BadParameter(
|
|
1333
|
+
f"No .json trace files in directory {path}", param_hint="--path"
|
|
1334
|
+
)
|
|
1335
|
+
files.extend(found)
|
|
1336
|
+
else:
|
|
1337
|
+
files.append(path)
|
|
1338
|
+
return files
|
|
1339
|
+
|
|
1340
|
+
|
|
1273
1341
|
@app.command()
|
|
1274
1342
|
def upload(
|
|
1275
|
-
path: Path =
|
|
1343
|
+
path: list[Path] = typer.Option(
|
|
1344
|
+
[Path("runs/research_agent_baseline.json")],
|
|
1345
|
+
"--path",
|
|
1346
|
+
help="Trace JSON file, or a directory of them; repeat for several.",
|
|
1347
|
+
),
|
|
1348
|
+
label: list[str] | None = typer.Option(
|
|
1349
|
+
None,
|
|
1350
|
+
"--label",
|
|
1351
|
+
help="KEY=VALUE stored under metadata.labels of each uploaded trace, "
|
|
1352
|
+
"such as commit=abc123; repeat for several.",
|
|
1353
|
+
),
|
|
1276
1354
|
api_url: str = typer.Option("http://127.0.0.1:8000", help="AgentLoop API base URL."),
|
|
1277
1355
|
api_key: str | None = typer.Option(
|
|
1278
1356
|
None, help="Optional API key. Defaults to AGENTLOOP_API_KEY."
|
|
1279
1357
|
),
|
|
1280
1358
|
) -> None:
|
|
1281
|
-
|
|
1359
|
+
"""Upload traces to an AgentLoop API, optionally labelled with CI context."""
|
|
1360
|
+
labels = _parse_labels(label)
|
|
1361
|
+
files = _upload_files(path)
|
|
1362
|
+
traces = [_load_trace(file, param_hint="--path") for file in files]
|
|
1282
1363
|
client = _remote_client(api_url, api_key)
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1364
|
+
project = None
|
|
1365
|
+
for trace in traces:
|
|
1366
|
+
if labels:
|
|
1367
|
+
existing = trace.metadata.get("labels")
|
|
1368
|
+
trace.metadata["labels"] = {
|
|
1369
|
+
**(existing if isinstance(existing, dict) else {}),
|
|
1370
|
+
**labels,
|
|
1371
|
+
}
|
|
1372
|
+
response = client.upload_trace(trace)
|
|
1373
|
+
project = response.get("project_id", "default")
|
|
1374
|
+
console.print(f"Uploaded trace {response['run_id']} to {api_url}", markup=False)
|
|
1375
|
+
if len(traces) > 1:
|
|
1376
|
+
console.print(f"Uploaded {len(traces)} traces.", markup=False)
|
|
1377
|
+
console.print(f"Project: {project}", markup=False)
|
|
1286
1378
|
|
|
1287
1379
|
|
|
1288
1380
|
@app.command("remote-delete-trace")
|
|
@@ -1438,6 +1530,20 @@ def remote_list_api_keys(
|
|
|
1438
1530
|
console.print_json(data=client.list_api_keys(project_id))
|
|
1439
1531
|
|
|
1440
1532
|
|
|
1533
|
+
@app.command("remote-audit-log")
|
|
1534
|
+
def remote_audit_log(
|
|
1535
|
+
project_id: str | None = typer.Option(None, help="Only this project's events."),
|
|
1536
|
+
limit: int = typer.Option(50, min=1, max=1000, help="Newest events to show."),
|
|
1537
|
+
api_url: str = typer.Option("http://127.0.0.1:8000", help="AgentLoop API base URL."),
|
|
1538
|
+
admin_api_key: str | None = typer.Option(
|
|
1539
|
+
None, help="Admin API key. Defaults to AGENTLOOP_ADMIN_API_KEY."
|
|
1540
|
+
),
|
|
1541
|
+
) -> None:
|
|
1542
|
+
"""Show a remote server's audit log (admin key required)."""
|
|
1543
|
+
client = _remote_admin_client(api_url, admin_api_key)
|
|
1544
|
+
console.print_json(data=client.list_audit_events(project_id=project_id, limit=limit))
|
|
1545
|
+
|
|
1546
|
+
|
|
1441
1547
|
@app.command("remote-revoke-api-key")
|
|
1442
1548
|
def remote_revoke_api_key(
|
|
1443
1549
|
prefix: str = typer.Option(..., help="First 10 characters of the key, as listed."),
|
|
@@ -59,6 +59,15 @@ class AgentLoopClient:
|
|
|
59
59
|
credential_scope="admin",
|
|
60
60
|
)
|
|
61
61
|
|
|
62
|
+
def list_audit_events(self, project_id: str | None = None, limit: int = 100) -> dict[str, Any]:
|
|
63
|
+
"""Newest audit events first, optionally for one project (admin key required)."""
|
|
64
|
+
params: dict[str, Any] = {"limit": limit}
|
|
65
|
+
if project_id:
|
|
66
|
+
params["project_id"] = project_id
|
|
67
|
+
return self._request(
|
|
68
|
+
"GET", "/audit-events?" + urllib.parse.urlencode(params), credential_scope="admin"
|
|
69
|
+
)
|
|
70
|
+
|
|
62
71
|
def list_api_keys(self, project_id: str) -> dict[str, Any]:
|
|
63
72
|
"""List a project's key prefixes, names and usage times (admin key required)."""
|
|
64
73
|
return self._request(
|
|
@@ -93,6 +102,7 @@ class AgentLoopClient:
|
|
|
93
102
|
*,
|
|
94
103
|
page_size: int | None = None,
|
|
95
104
|
cursor: str | None = None,
|
|
105
|
+
label: str | None = None,
|
|
96
106
|
) -> dict[str, Any]:
|
|
97
107
|
params: dict[str, Any] = {}
|
|
98
108
|
if project_id:
|
|
@@ -101,6 +111,8 @@ class AgentLoopClient:
|
|
|
101
111
|
params["page_size"] = page_size
|
|
102
112
|
if cursor:
|
|
103
113
|
params["cursor"] = cursor
|
|
114
|
+
if label is not None:
|
|
115
|
+
params["label"] = label
|
|
104
116
|
route = "/traces"
|
|
105
117
|
if params:
|
|
106
118
|
route += "?" + urllib.parse.urlencode(params)
|
|
@@ -105,6 +105,70 @@ def _ready_check(api_url: str, timeout: float = 2.0) -> DoctorCheck:
|
|
|
105
105
|
return _fail("api_ready", f"Could not reach {url}: {exc}")
|
|
106
106
|
|
|
107
107
|
|
|
108
|
+
def _is_local_origin(origin: str) -> bool:
|
|
109
|
+
host = urlsplit(origin).hostname or ""
|
|
110
|
+
return host in {"localhost", "127.0.0.1", "::1"} or host.endswith(".localhost")
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _hosting_policy_checks() -> list[DoctorCheck]:
|
|
114
|
+
"""Checks for settings added for shared deployments (0.2.7 and newer)."""
|
|
115
|
+
from agentloop.request_limits import ENVIRONMENT_VARIABLE, max_request_bytes
|
|
116
|
+
|
|
117
|
+
checks: list[DoctorCheck] = []
|
|
118
|
+
try:
|
|
119
|
+
limit = max_request_bytes()
|
|
120
|
+
except ValueError as exc:
|
|
121
|
+
checks.append(_fail("request_size_limit", str(exc), f"Fix {ENVIRONMENT_VARIABLE}."))
|
|
122
|
+
else:
|
|
123
|
+
if limit is None:
|
|
124
|
+
checks.append(
|
|
125
|
+
_warn(
|
|
126
|
+
"request_size_limit",
|
|
127
|
+
"disabled; request bodies of any size are read into memory",
|
|
128
|
+
f"Unset {ENVIRONMENT_VARIABLE} for the 16 MiB default or set a size.",
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
else:
|
|
132
|
+
checks.append(_ok("request_size_limit", f"{limit} bytes"))
|
|
133
|
+
|
|
134
|
+
if _env_enabled("AGENTLOOP_DASHBOARD_REQUIRE_KEY"):
|
|
135
|
+
checks.append(_ok("dashboard_access", "project API key sign-in required"))
|
|
136
|
+
else:
|
|
137
|
+
checks.append(
|
|
138
|
+
_warn(
|
|
139
|
+
"dashboard_access",
|
|
140
|
+
"the dashboard shows any project to anyone who can reach it",
|
|
141
|
+
"Set AGENTLOOP_DASHBOARD_REQUIRE_KEY=true on the dashboard service.",
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
retention = os.getenv("AGENTLOOP_RETENTION_DAYS", "").strip()
|
|
146
|
+
if not retention:
|
|
147
|
+
checks.append(
|
|
148
|
+
_warn(
|
|
149
|
+
"retention",
|
|
150
|
+
"not configured; traces are kept until deleted by hand",
|
|
151
|
+
"Set AGENTLOOP_RETENTION_DAYS and run agentloop purge-traces on a schedule.",
|
|
152
|
+
)
|
|
153
|
+
)
|
|
154
|
+
else:
|
|
155
|
+
try:
|
|
156
|
+
days = float(retention)
|
|
157
|
+
except ValueError:
|
|
158
|
+
days = -1.0
|
|
159
|
+
if days > 0 and days == days and days != float("inf"):
|
|
160
|
+
checks.append(_ok("retention", f"{days:g} days"))
|
|
161
|
+
else:
|
|
162
|
+
checks.append(
|
|
163
|
+
_fail(
|
|
164
|
+
"retention",
|
|
165
|
+
f"AGENTLOOP_RETENTION_DAYS={retention!r} is not a positive number of days",
|
|
166
|
+
"Set it to a positive number of days, or unset it.",
|
|
167
|
+
)
|
|
168
|
+
)
|
|
169
|
+
return checks
|
|
170
|
+
|
|
171
|
+
|
|
108
172
|
def _env_enabled(name: str) -> bool:
|
|
109
173
|
return os.getenv(name, "").lower() in {"1", "true", "yes", "on"}
|
|
110
174
|
|
|
@@ -115,14 +179,14 @@ def run_doctor(*, check_api: bool = True, runs_dir: Path | str = "runs") -> dict
|
|
|
115
179
|
checks: list[DoctorCheck] = []
|
|
116
180
|
|
|
117
181
|
py_version = sys.version_info
|
|
118
|
-
if py_version >= (3,
|
|
182
|
+
if py_version >= (3, 11):
|
|
119
183
|
checks.append(_ok("python", f"Python {platform.python_version()}"))
|
|
120
184
|
else:
|
|
121
185
|
checks.append(
|
|
122
186
|
_fail(
|
|
123
187
|
"python",
|
|
124
188
|
f"Python {platform.python_version()} is too old",
|
|
125
|
-
"Use Python 3.
|
|
189
|
+
"Use Python 3.11 or newer.",
|
|
126
190
|
)
|
|
127
191
|
)
|
|
128
192
|
|
|
@@ -220,14 +284,14 @@ def run_production_check(
|
|
|
220
284
|
checks: list[DoctorCheck] = []
|
|
221
285
|
|
|
222
286
|
py_version = sys.version_info
|
|
223
|
-
if py_version >= (3,
|
|
287
|
+
if py_version >= (3, 11):
|
|
224
288
|
checks.append(_ok("python", f"Python {platform.python_version()}"))
|
|
225
289
|
else:
|
|
226
290
|
checks.append(
|
|
227
291
|
_fail(
|
|
228
292
|
"python",
|
|
229
293
|
f"Python {platform.python_version()} is too old",
|
|
230
|
-
"Use Python 3.
|
|
294
|
+
"Use Python 3.11 or newer.",
|
|
231
295
|
)
|
|
232
296
|
)
|
|
233
297
|
|
|
@@ -313,7 +377,42 @@ def run_production_check(
|
|
|
313
377
|
)
|
|
314
378
|
)
|
|
315
379
|
else:
|
|
316
|
-
|
|
380
|
+
insecure = [
|
|
381
|
+
origin
|
|
382
|
+
for origin in cors_origins
|
|
383
|
+
if not origin.startswith("https://") and not _is_local_origin(origin)
|
|
384
|
+
]
|
|
385
|
+
if insecure and not allow_http:
|
|
386
|
+
checks.append(
|
|
387
|
+
_fail(
|
|
388
|
+
"cors_origins",
|
|
389
|
+
f"non-HTTPS origins: {', '.join(insecure)}",
|
|
390
|
+
"Serve the dashboard over HTTPS and list its https:// origin.",
|
|
391
|
+
)
|
|
392
|
+
)
|
|
393
|
+
elif insecure:
|
|
394
|
+
checks.append(
|
|
395
|
+
_warn(
|
|
396
|
+
"cors_origins",
|
|
397
|
+
f"non-HTTPS origins: {', '.join(insecure)}",
|
|
398
|
+
"Use HTTPS origins for production traffic.",
|
|
399
|
+
)
|
|
400
|
+
)
|
|
401
|
+
else:
|
|
402
|
+
checks.append(_ok("cors_origins", ", ".join(cors_origins)))
|
|
403
|
+
|
|
404
|
+
if os.getenv("AGENTLOOP_API_KEY"):
|
|
405
|
+
checks.append(
|
|
406
|
+
_warn(
|
|
407
|
+
"shared_api_key",
|
|
408
|
+
"AGENTLOOP_API_KEY grants access to project 'default'; it cannot be revoked, "
|
|
409
|
+
"listed or attributed in the audit log",
|
|
410
|
+
"Unset AGENTLOOP_API_KEY on the server and give each team a project key "
|
|
411
|
+
"created with the admin key.",
|
|
412
|
+
)
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
checks.extend(_hosting_policy_checks())
|
|
317
416
|
|
|
318
417
|
api_url = os.getenv("AGENTLOOP_API_URL", "")
|
|
319
418
|
if not api_url:
|
|
@@ -219,6 +219,25 @@ MIGRATIONS: tuple[Migration, ...] = (
|
|
|
219
219
|
"PRIMARY KEY(project_id, intervention_id))",
|
|
220
220
|
),
|
|
221
221
|
),
|
|
222
|
+
Migration(
|
|
223
|
+
version=6,
|
|
224
|
+
name="audit_log",
|
|
225
|
+
sqlite_statements=(
|
|
226
|
+
"CREATE TABLE IF NOT EXISTS audit_events ("
|
|
227
|
+
"id INTEGER PRIMARY KEY AUTOINCREMENT, "
|
|
228
|
+
"occurred_at TEXT DEFAULT CURRENT_TIMESTAMP, project_id TEXT, "
|
|
229
|
+
"action TEXT NOT NULL, actor TEXT NOT NULL, target TEXT, "
|
|
230
|
+
"details_json TEXT NOT NULL DEFAULT '{}')",
|
|
231
|
+
"CREATE INDEX IF NOT EXISTS audit_events_project_id ON audit_events(project_id, id)",
|
|
232
|
+
),
|
|
233
|
+
postgres_statements=(
|
|
234
|
+
"CREATE TABLE IF NOT EXISTS audit_events ("
|
|
235
|
+
"id BIGSERIAL PRIMARY KEY, occurred_at TIMESTAMPTZ DEFAULT now(), project_id TEXT, "
|
|
236
|
+
"action TEXT NOT NULL, actor TEXT NOT NULL, target TEXT, "
|
|
237
|
+
"details_json TEXT NOT NULL DEFAULT '{}')",
|
|
238
|
+
"CREATE INDEX IF NOT EXISTS audit_events_project_id ON audit_events(project_id, id)",
|
|
239
|
+
),
|
|
240
|
+
),
|
|
222
241
|
)
|
|
223
242
|
|
|
224
243
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""Reject oversized API requests before they are buffered.
|
|
2
|
+
|
|
3
|
+
Deployments without a reverse proxy (managed container platforms, a direct
|
|
4
|
+
``agentloop server``) would otherwise read request bodies of any size into
|
|
5
|
+
memory. The limit applies to the declared ``Content-Length`` and, for
|
|
6
|
+
streamed or chunked bodies, to the bytes actually received.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
|
|
14
|
+
DEFAULT_MAX_REQUEST_BYTES = 16 * 1024 * 1024
|
|
15
|
+
ENVIRONMENT_VARIABLE = "AGENTLOOP_MAX_REQUEST_BYTES"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def max_request_bytes(value: str | None = None) -> int | None:
|
|
19
|
+
"""Parse the limit; ``0`` disables it. Invalid values fail at startup."""
|
|
20
|
+
text = os.getenv(ENVIRONMENT_VARIABLE) if value is None else value
|
|
21
|
+
if text is None or not text.strip():
|
|
22
|
+
return DEFAULT_MAX_REQUEST_BYTES
|
|
23
|
+
try:
|
|
24
|
+
limit = int(text.strip())
|
|
25
|
+
except ValueError:
|
|
26
|
+
raise ValueError(f"{ENVIRONMENT_VARIABLE} must be a whole number of bytes") from None
|
|
27
|
+
if limit < 0:
|
|
28
|
+
raise ValueError(f"{ENVIRONMENT_VARIABLE} must be 0 (no limit) or a positive size")
|
|
29
|
+
return limit or None
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class RequestSizeLimitMiddleware:
|
|
33
|
+
"""ASGI middleware answering 413 for request bodies over ``limit`` bytes."""
|
|
34
|
+
|
|
35
|
+
def __init__(self, app, limit: int | None) -> None:
|
|
36
|
+
self.app = app
|
|
37
|
+
self.limit = limit
|
|
38
|
+
|
|
39
|
+
async def __call__(self, scope, receive, send):
|
|
40
|
+
if scope["type"] != "http" or self.limit is None:
|
|
41
|
+
await self.app(scope, receive, send)
|
|
42
|
+
return
|
|
43
|
+
limit = self.limit
|
|
44
|
+
declared = None
|
|
45
|
+
for name, value in scope.get("headers", []):
|
|
46
|
+
if name == b"content-length":
|
|
47
|
+
try:
|
|
48
|
+
declared = int(value)
|
|
49
|
+
except ValueError:
|
|
50
|
+
declared = None
|
|
51
|
+
if declared is not None:
|
|
52
|
+
# The HTTP server already refuses bodies longer than their declared length.
|
|
53
|
+
if declared > limit:
|
|
54
|
+
await _reject(send, limit)
|
|
55
|
+
return
|
|
56
|
+
await self.app(scope, receive, send)
|
|
57
|
+
return
|
|
58
|
+
|
|
59
|
+
# No declared length (for example chunked uploads): read up to the limit
|
|
60
|
+
# here, so the application never buffers more, then replay the body.
|
|
61
|
+
chunks: list[bytes] = []
|
|
62
|
+
received = 0
|
|
63
|
+
while True:
|
|
64
|
+
message = await receive()
|
|
65
|
+
if message["type"] != "http.request":
|
|
66
|
+
# The client disconnected; let the application see that.
|
|
67
|
+
replay = [message]
|
|
68
|
+
break
|
|
69
|
+
body = message.get("body", b"")
|
|
70
|
+
received += len(body)
|
|
71
|
+
if received > limit:
|
|
72
|
+
await _reject(send, limit)
|
|
73
|
+
return
|
|
74
|
+
chunks.append(body)
|
|
75
|
+
if not message.get("more_body", False):
|
|
76
|
+
replay = [{"type": "http.request", "body": b"".join(chunks), "more_body": False}]
|
|
77
|
+
break
|
|
78
|
+
|
|
79
|
+
async def replay_receive():
|
|
80
|
+
if replay:
|
|
81
|
+
return replay.pop(0)
|
|
82
|
+
return await receive()
|
|
83
|
+
|
|
84
|
+
await self.app(scope, replay_receive, send)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
async def _reject(send, limit: int) -> None:
|
|
88
|
+
body = json.dumps(
|
|
89
|
+
{"detail": f"request body exceeds the {limit}-byte limit ({ENVIRONMENT_VARIABLE})"}
|
|
90
|
+
).encode("utf-8")
|
|
91
|
+
await send(
|
|
92
|
+
{
|
|
93
|
+
"type": "http.response.start",
|
|
94
|
+
"status": 413,
|
|
95
|
+
"headers": [
|
|
96
|
+
(b"content-type", b"application/json"),
|
|
97
|
+
(b"content-length", str(len(body)).encode("ascii")),
|
|
98
|
+
(b"connection", b"close"),
|
|
99
|
+
],
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
await send({"type": "http.response.body", "body": body})
|