adcp 2.0.0__tar.gz → 2.2.0__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.
- {adcp-2.0.0/src/adcp.egg-info → adcp-2.2.0}/PKG-INFO +40 -3
- {adcp-2.0.0 → adcp-2.2.0}/README.md +39 -2
- {adcp-2.0.0 → adcp-2.2.0}/pyproject.toml +4 -1
- adcp-2.2.0/src/adcp/__init__.py +255 -0
- adcp-2.2.0/src/adcp/py.typed +0 -0
- adcp-2.2.0/src/adcp/types/__init__.py +48 -0
- adcp-2.2.0/src/adcp/types/aliases.py +249 -0
- {adcp-2.0.0 → adcp-2.2.0/src/adcp.egg-info}/PKG-INFO +40 -3
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp.egg-info/SOURCES.txt +4 -1
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_discriminated_unions.py +290 -24
- adcp-2.2.0/tests/test_type_aliases.py +284 -0
- adcp-2.0.0/src/adcp/__init__.py +0 -120
- adcp-2.0.0/src/adcp/types/__init__.py +0 -27
- {adcp-2.0.0 → adcp-2.2.0}/LICENSE +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/setup.cfg +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/__main__.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/adagents.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/client.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/config.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/exceptions.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/protocols/__init__.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/protocols/a2a.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/protocols/base.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/protocols/mcp.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/simple.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/testing/__init__.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/testing/test_helpers.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/base.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/core.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/__init__.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/activate_signal_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/activate_signal_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/activation_key.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/adagents.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/asset_type.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/audio_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/brand_manifest.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/brand_manifest_ref.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/build_creative_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/build_creative_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/channels.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/cpc_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/cpcv_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/cpm_auction_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/cpm_fixed_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/cpp_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/cpv_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/create_media_buy_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/create_media_buy_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/creative_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/creative_assignment.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/creative_manifest.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/creative_policy.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/creative_status.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/css_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/daast_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/delivery_metrics.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/delivery_type.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/deployment.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/destination.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/error.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/flat_rate_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/format.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/format_id.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/frequency_cap.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/frequency_cap_scope.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/get_media_buy_delivery_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/get_media_buy_delivery_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/get_products_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/get_products_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/get_signals_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/get_signals_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/html_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/identifier_types.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/image_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/index.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/javascript_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/list_authorized_properties_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/list_authorized_properties_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/list_creative_formats_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/list_creative_formats_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/list_creatives_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/list_creatives_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/markdown_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/measurement.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/media_buy.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/media_buy_status.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/pacing.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/package.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/package_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/package_status.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/performance_feedback.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/placement.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/preview_creative_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/preview_creative_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/preview_render.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/pricing_model.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/pricing_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/product.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/promoted_offerings.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/promoted_products.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/property.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/protocol_envelope.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/provide_performance_feedback_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/provide_performance_feedback_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/publisher_identifier_types.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/push_notification_config.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/reporting_capabilities.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/standard_format_ids.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/start_timing.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/sub_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/sync_creatives_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/sync_creatives_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/targeting.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/task_status.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/task_type.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/tasks_get_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/tasks_get_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/tasks_list_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/tasks_list_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/text_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/update_media_buy_request.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/update_media_buy_response.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/url_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/vast_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/vcpm_auction_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/vcpm_fixed_option.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/video_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/webhook_asset.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/types/generated_poc/webhook_payload.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/utils/__init__.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/utils/operation_id.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/utils/preview_cache.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/utils/response_parser.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp/validation.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp.egg-info/dependency_links.txt +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp.egg-info/entry_points.txt +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp.egg-info/requires.txt +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/src/adcp.egg-info/top_level.txt +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_adagents.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_cli.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_client.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_code_generation.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_format_id_validation.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_helpers.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_preview_html.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_protocols.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_response_parser.py +0 -0
- {adcp-2.0.0 → adcp-2.2.0}/tests/test_simple_api.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: adcp
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Official Python client for the Ad Context Protocol (AdCP)
|
|
5
5
|
Author-email: AdCP Community <maintainers@adcontextprotocol.org>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -94,7 +94,7 @@ print(products.products[0].name)
|
|
|
94
94
|
**Standard API** (`client.*`) - Recommended for production:
|
|
95
95
|
```python
|
|
96
96
|
from adcp.testing import test_agent
|
|
97
|
-
from adcp
|
|
97
|
+
from adcp import GetProductsRequest
|
|
98
98
|
|
|
99
99
|
# Explicit request objects and TaskResult wrapper
|
|
100
100
|
request = GetProductsRequest(brief='Coffee brands')
|
|
@@ -124,6 +124,8 @@ Pre-configured agents (all include `.simple` accessor):
|
|
|
124
124
|
|
|
125
125
|
See [examples/simple_api_demo.py](examples/simple_api_demo.py) for a complete comparison.
|
|
126
126
|
|
|
127
|
+
> **Tip**: Import types from the main `adcp` package (e.g., `from adcp import GetProductsRequest`) rather than `adcp.types.generated` for better API stability.
|
|
128
|
+
|
|
127
129
|
## Quick Start: Distributed Operations
|
|
128
130
|
|
|
129
131
|
For production use, configure your own agents:
|
|
@@ -187,7 +189,7 @@ from adcp.testing import (
|
|
|
187
189
|
test_agent_no_auth, test_agent_a2a_no_auth,
|
|
188
190
|
creative_agent, test_agent_client, create_test_agent
|
|
189
191
|
)
|
|
190
|
-
from adcp
|
|
192
|
+
from adcp import GetProductsRequest, PreviewCreativeRequest
|
|
191
193
|
|
|
192
194
|
# 1. Single agent with authentication (MCP)
|
|
193
195
|
result = await test_agent.get_products(
|
|
@@ -243,6 +245,7 @@ client = ADCPClient(config)
|
|
|
243
245
|
- **Auto-detection**: Automatically detect which protocol an agent uses
|
|
244
246
|
|
|
245
247
|
### Type Safety
|
|
248
|
+
|
|
246
249
|
Full type hints with Pydantic validation and auto-generated types from the AdCP spec:
|
|
247
250
|
|
|
248
251
|
```python
|
|
@@ -258,6 +261,40 @@ if result.success:
|
|
|
258
261
|
print(product.name, product.pricing_options) # Full IDE autocomplete!
|
|
259
262
|
```
|
|
260
263
|
|
|
264
|
+
#### Semantic Type Aliases
|
|
265
|
+
|
|
266
|
+
For discriminated union types (success/error responses), use semantic aliases for clearer code:
|
|
267
|
+
|
|
268
|
+
```python
|
|
269
|
+
from adcp import (
|
|
270
|
+
CreateMediaBuySuccessResponse, # Clear: this is the success case
|
|
271
|
+
CreateMediaBuyErrorResponse, # Clear: this is the error case
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
def handle_response(
|
|
275
|
+
response: CreateMediaBuySuccessResponse | CreateMediaBuyErrorResponse
|
|
276
|
+
) -> None:
|
|
277
|
+
if isinstance(response, CreateMediaBuySuccessResponse):
|
|
278
|
+
print(f"✅ Media buy created: {response.media_buy_id}")
|
|
279
|
+
else:
|
|
280
|
+
print(f"❌ Errors: {response.errors}")
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Available semantic aliases:**
|
|
284
|
+
- Response types: `*SuccessResponse` / `*ErrorResponse` (e.g., `CreateMediaBuySuccessResponse`)
|
|
285
|
+
- Request variants: `*FormatRequest` / `*ManifestRequest` (e.g., `PreviewCreativeFormatRequest`)
|
|
286
|
+
- Preview renders: `PreviewRenderImage` / `PreviewRenderHtml` / `PreviewRenderIframe`
|
|
287
|
+
- Activation keys: `PropertyIdActivationKey` / `PropertyTagActivationKey`
|
|
288
|
+
|
|
289
|
+
See `examples/type_aliases_demo.py` for more examples.
|
|
290
|
+
|
|
291
|
+
**Import guidelines:**
|
|
292
|
+
- ✅ **DO**: Import from main package: `from adcp import GetProductsRequest`
|
|
293
|
+
- ✅ **DO**: Use semantic aliases: `from adcp import CreateMediaBuySuccessResponse`
|
|
294
|
+
- ⚠️ **AVOID**: Import from internal modules: `from adcp.types.generated import CreateMediaBuyResponse1`
|
|
295
|
+
|
|
296
|
+
The main package exports provide a stable API while internal generated types may change.
|
|
297
|
+
|
|
261
298
|
### Multi-Agent Operations
|
|
262
299
|
Execute across multiple agents simultaneously:
|
|
263
300
|
|
|
@@ -55,7 +55,7 @@ print(products.products[0].name)
|
|
|
55
55
|
**Standard API** (`client.*`) - Recommended for production:
|
|
56
56
|
```python
|
|
57
57
|
from adcp.testing import test_agent
|
|
58
|
-
from adcp
|
|
58
|
+
from adcp import GetProductsRequest
|
|
59
59
|
|
|
60
60
|
# Explicit request objects and TaskResult wrapper
|
|
61
61
|
request = GetProductsRequest(brief='Coffee brands')
|
|
@@ -85,6 +85,8 @@ Pre-configured agents (all include `.simple` accessor):
|
|
|
85
85
|
|
|
86
86
|
See [examples/simple_api_demo.py](examples/simple_api_demo.py) for a complete comparison.
|
|
87
87
|
|
|
88
|
+
> **Tip**: Import types from the main `adcp` package (e.g., `from adcp import GetProductsRequest`) rather than `adcp.types.generated` for better API stability.
|
|
89
|
+
|
|
88
90
|
## Quick Start: Distributed Operations
|
|
89
91
|
|
|
90
92
|
For production use, configure your own agents:
|
|
@@ -148,7 +150,7 @@ from adcp.testing import (
|
|
|
148
150
|
test_agent_no_auth, test_agent_a2a_no_auth,
|
|
149
151
|
creative_agent, test_agent_client, create_test_agent
|
|
150
152
|
)
|
|
151
|
-
from adcp
|
|
153
|
+
from adcp import GetProductsRequest, PreviewCreativeRequest
|
|
152
154
|
|
|
153
155
|
# 1. Single agent with authentication (MCP)
|
|
154
156
|
result = await test_agent.get_products(
|
|
@@ -204,6 +206,7 @@ client = ADCPClient(config)
|
|
|
204
206
|
- **Auto-detection**: Automatically detect which protocol an agent uses
|
|
205
207
|
|
|
206
208
|
### Type Safety
|
|
209
|
+
|
|
207
210
|
Full type hints with Pydantic validation and auto-generated types from the AdCP spec:
|
|
208
211
|
|
|
209
212
|
```python
|
|
@@ -219,6 +222,40 @@ if result.success:
|
|
|
219
222
|
print(product.name, product.pricing_options) # Full IDE autocomplete!
|
|
220
223
|
```
|
|
221
224
|
|
|
225
|
+
#### Semantic Type Aliases
|
|
226
|
+
|
|
227
|
+
For discriminated union types (success/error responses), use semantic aliases for clearer code:
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
from adcp import (
|
|
231
|
+
CreateMediaBuySuccessResponse, # Clear: this is the success case
|
|
232
|
+
CreateMediaBuyErrorResponse, # Clear: this is the error case
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
def handle_response(
|
|
236
|
+
response: CreateMediaBuySuccessResponse | CreateMediaBuyErrorResponse
|
|
237
|
+
) -> None:
|
|
238
|
+
if isinstance(response, CreateMediaBuySuccessResponse):
|
|
239
|
+
print(f"✅ Media buy created: {response.media_buy_id}")
|
|
240
|
+
else:
|
|
241
|
+
print(f"❌ Errors: {response.errors}")
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Available semantic aliases:**
|
|
245
|
+
- Response types: `*SuccessResponse` / `*ErrorResponse` (e.g., `CreateMediaBuySuccessResponse`)
|
|
246
|
+
- Request variants: `*FormatRequest` / `*ManifestRequest` (e.g., `PreviewCreativeFormatRequest`)
|
|
247
|
+
- Preview renders: `PreviewRenderImage` / `PreviewRenderHtml` / `PreviewRenderIframe`
|
|
248
|
+
- Activation keys: `PropertyIdActivationKey` / `PropertyTagActivationKey`
|
|
249
|
+
|
|
250
|
+
See `examples/type_aliases_demo.py` for more examples.
|
|
251
|
+
|
|
252
|
+
**Import guidelines:**
|
|
253
|
+
- ✅ **DO**: Import from main package: `from adcp import GetProductsRequest`
|
|
254
|
+
- ✅ **DO**: Use semantic aliases: `from adcp import CreateMediaBuySuccessResponse`
|
|
255
|
+
- ⚠️ **AVOID**: Import from internal modules: `from adcp.types.generated import CreateMediaBuyResponse1`
|
|
256
|
+
|
|
257
|
+
The main package exports provide a stable API while internal generated types may change.
|
|
258
|
+
|
|
222
259
|
### Multi-Agent Operations
|
|
223
260
|
Execute across multiple agents simultaneously:
|
|
224
261
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "adcp"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.2.0"
|
|
8
8
|
description = "Official Python client for the Ad Context Protocol (AdCP)"
|
|
9
9
|
authors = [
|
|
10
10
|
{name = "AdCP Community", email = "maintainers@adcontextprotocol.org"}
|
|
@@ -57,6 +57,9 @@ Issues = "https://github.com/adcontextprotocol/adcp-client-python/issues"
|
|
|
57
57
|
[tool.setuptools.packages.find]
|
|
58
58
|
where = ["src"]
|
|
59
59
|
|
|
60
|
+
[tool.setuptools.package-data]
|
|
61
|
+
adcp = ["py.typed"]
|
|
62
|
+
|
|
60
63
|
[tool.black]
|
|
61
64
|
line-length = 100
|
|
62
65
|
target-version = ["py310", "py311", "py312"]
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
AdCP Python Client Library
|
|
5
|
+
|
|
6
|
+
Official Python client for the Ad Context Protocol (AdCP).
|
|
7
|
+
Supports both A2A and MCP protocols with full type safety.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from adcp.adagents import (
|
|
11
|
+
domain_matches,
|
|
12
|
+
fetch_adagents,
|
|
13
|
+
get_all_properties,
|
|
14
|
+
get_all_tags,
|
|
15
|
+
get_properties_by_agent,
|
|
16
|
+
identifiers_match,
|
|
17
|
+
verify_agent_authorization,
|
|
18
|
+
verify_agent_for_property,
|
|
19
|
+
)
|
|
20
|
+
from adcp.client import ADCPClient, ADCPMultiAgentClient
|
|
21
|
+
from adcp.exceptions import (
|
|
22
|
+
AdagentsNotFoundError,
|
|
23
|
+
AdagentsTimeoutError,
|
|
24
|
+
AdagentsValidationError,
|
|
25
|
+
ADCPAuthenticationError,
|
|
26
|
+
ADCPConnectionError,
|
|
27
|
+
ADCPError,
|
|
28
|
+
ADCPProtocolError,
|
|
29
|
+
ADCPTimeoutError,
|
|
30
|
+
ADCPToolNotFoundError,
|
|
31
|
+
ADCPWebhookError,
|
|
32
|
+
ADCPWebhookSignatureError,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# Test helpers
|
|
36
|
+
from adcp.testing import (
|
|
37
|
+
CREATIVE_AGENT_CONFIG,
|
|
38
|
+
TEST_AGENT_A2A_CONFIG,
|
|
39
|
+
TEST_AGENT_A2A_NO_AUTH_CONFIG,
|
|
40
|
+
TEST_AGENT_MCP_CONFIG,
|
|
41
|
+
TEST_AGENT_MCP_NO_AUTH_CONFIG,
|
|
42
|
+
TEST_AGENT_TOKEN,
|
|
43
|
+
create_test_agent,
|
|
44
|
+
creative_agent,
|
|
45
|
+
test_agent,
|
|
46
|
+
test_agent_a2a,
|
|
47
|
+
test_agent_a2a_no_auth,
|
|
48
|
+
test_agent_client,
|
|
49
|
+
test_agent_no_auth,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
# Import all generated types - users can import what they need from adcp.types.generated
|
|
53
|
+
from adcp.types import aliases, generated
|
|
54
|
+
|
|
55
|
+
# Re-export semantic type aliases for better ergonomics
|
|
56
|
+
from adcp.types.aliases import (
|
|
57
|
+
ActivateSignalErrorResponse,
|
|
58
|
+
ActivateSignalSuccessResponse,
|
|
59
|
+
BothPreviewRender,
|
|
60
|
+
BuildCreativeErrorResponse,
|
|
61
|
+
BuildCreativeSuccessResponse,
|
|
62
|
+
CreateMediaBuyErrorResponse,
|
|
63
|
+
CreateMediaBuySuccessResponse,
|
|
64
|
+
HtmlPreviewRender,
|
|
65
|
+
InlineDaastAsset,
|
|
66
|
+
InlineVastAsset,
|
|
67
|
+
MediaSubAsset,
|
|
68
|
+
PreviewCreativeFormatRequest,
|
|
69
|
+
PreviewCreativeInteractiveResponse,
|
|
70
|
+
PreviewCreativeManifestRequest,
|
|
71
|
+
PreviewCreativeStaticResponse,
|
|
72
|
+
PropertyIdActivationKey,
|
|
73
|
+
PropertyTagActivationKey,
|
|
74
|
+
ProvidePerformanceFeedbackErrorResponse,
|
|
75
|
+
ProvidePerformanceFeedbackSuccessResponse,
|
|
76
|
+
SyncCreativesErrorResponse,
|
|
77
|
+
SyncCreativesSuccessResponse,
|
|
78
|
+
TextSubAsset,
|
|
79
|
+
UpdateMediaBuyErrorResponse,
|
|
80
|
+
UpdateMediaBuyPackagesRequest,
|
|
81
|
+
UpdateMediaBuyPropertiesRequest,
|
|
82
|
+
UpdateMediaBuySuccessResponse,
|
|
83
|
+
UrlDaastAsset,
|
|
84
|
+
UrlPreviewRender,
|
|
85
|
+
UrlVastAsset,
|
|
86
|
+
)
|
|
87
|
+
from adcp.types.core import AgentConfig, Protocol, TaskResult, TaskStatus, WebhookMetadata
|
|
88
|
+
|
|
89
|
+
# Re-export commonly-used request/response types for convenience
|
|
90
|
+
# Users should import from main package (e.g., `from adcp import GetProductsRequest`)
|
|
91
|
+
# rather than internal modules for better API stability
|
|
92
|
+
from adcp.types.generated import (
|
|
93
|
+
# Audience & Targeting
|
|
94
|
+
ActivateSignalRequest,
|
|
95
|
+
ActivateSignalResponse,
|
|
96
|
+
# Creative Operations
|
|
97
|
+
BuildCreativeRequest,
|
|
98
|
+
BuildCreativeResponse,
|
|
99
|
+
# Media Buy Operations
|
|
100
|
+
CreateMediaBuyRequest,
|
|
101
|
+
CreateMediaBuyResponse,
|
|
102
|
+
# Common data types
|
|
103
|
+
Error,
|
|
104
|
+
Format,
|
|
105
|
+
GetMediaBuyDeliveryRequest,
|
|
106
|
+
GetMediaBuyDeliveryResponse,
|
|
107
|
+
GetProductsRequest,
|
|
108
|
+
GetProductsResponse,
|
|
109
|
+
GetSignalsRequest,
|
|
110
|
+
GetSignalsResponse,
|
|
111
|
+
ListAuthorizedPropertiesRequest,
|
|
112
|
+
ListAuthorizedPropertiesResponse,
|
|
113
|
+
ListCreativeFormatsRequest,
|
|
114
|
+
ListCreativeFormatsResponse,
|
|
115
|
+
ListCreativesRequest,
|
|
116
|
+
ListCreativesResponse,
|
|
117
|
+
PreviewCreativeRequest,
|
|
118
|
+
PreviewCreativeResponse,
|
|
119
|
+
Product,
|
|
120
|
+
Property,
|
|
121
|
+
ProvidePerformanceFeedbackRequest,
|
|
122
|
+
ProvidePerformanceFeedbackResponse,
|
|
123
|
+
SyncCreativesRequest,
|
|
124
|
+
SyncCreativesResponse,
|
|
125
|
+
UpdateMediaBuyRequest,
|
|
126
|
+
UpdateMediaBuyResponse,
|
|
127
|
+
)
|
|
128
|
+
from adcp.types.generated import TaskStatus as GeneratedTaskStatus
|
|
129
|
+
from adcp.validation import (
|
|
130
|
+
ValidationError,
|
|
131
|
+
validate_adagents,
|
|
132
|
+
validate_agent_authorization,
|
|
133
|
+
validate_product,
|
|
134
|
+
validate_publisher_properties_item,
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
__version__ = "2.2.0"
|
|
138
|
+
|
|
139
|
+
__all__ = [
|
|
140
|
+
# Client classes
|
|
141
|
+
"ADCPClient",
|
|
142
|
+
"ADCPMultiAgentClient",
|
|
143
|
+
# Core types
|
|
144
|
+
"AgentConfig",
|
|
145
|
+
"Protocol",
|
|
146
|
+
"TaskResult",
|
|
147
|
+
"TaskStatus",
|
|
148
|
+
"WebhookMetadata",
|
|
149
|
+
# Common request/response types (re-exported for convenience)
|
|
150
|
+
"CreateMediaBuyRequest",
|
|
151
|
+
"CreateMediaBuyResponse",
|
|
152
|
+
"GetMediaBuyDeliveryRequest",
|
|
153
|
+
"GetMediaBuyDeliveryResponse",
|
|
154
|
+
"GetProductsRequest",
|
|
155
|
+
"GetProductsResponse",
|
|
156
|
+
"UpdateMediaBuyRequest",
|
|
157
|
+
"UpdateMediaBuyResponse",
|
|
158
|
+
"BuildCreativeRequest",
|
|
159
|
+
"BuildCreativeResponse",
|
|
160
|
+
"ListCreativeFormatsRequest",
|
|
161
|
+
"ListCreativeFormatsResponse",
|
|
162
|
+
"ListCreativesRequest",
|
|
163
|
+
"ListCreativesResponse",
|
|
164
|
+
"PreviewCreativeRequest",
|
|
165
|
+
"PreviewCreativeResponse",
|
|
166
|
+
"SyncCreativesRequest",
|
|
167
|
+
"SyncCreativesResponse",
|
|
168
|
+
"ActivateSignalRequest",
|
|
169
|
+
"ActivateSignalResponse",
|
|
170
|
+
"GetSignalsRequest",
|
|
171
|
+
"GetSignalsResponse",
|
|
172
|
+
"ListAuthorizedPropertiesRequest",
|
|
173
|
+
"ListAuthorizedPropertiesResponse",
|
|
174
|
+
"ProvidePerformanceFeedbackRequest",
|
|
175
|
+
"ProvidePerformanceFeedbackResponse",
|
|
176
|
+
"Error",
|
|
177
|
+
"Format",
|
|
178
|
+
"Product",
|
|
179
|
+
"Property",
|
|
180
|
+
# Adagents validation
|
|
181
|
+
"fetch_adagents",
|
|
182
|
+
"verify_agent_authorization",
|
|
183
|
+
"verify_agent_for_property",
|
|
184
|
+
"domain_matches",
|
|
185
|
+
"identifiers_match",
|
|
186
|
+
"get_all_properties",
|
|
187
|
+
"get_all_tags",
|
|
188
|
+
"get_properties_by_agent",
|
|
189
|
+
# Test helpers
|
|
190
|
+
"test_agent",
|
|
191
|
+
"test_agent_a2a",
|
|
192
|
+
"test_agent_no_auth",
|
|
193
|
+
"test_agent_a2a_no_auth",
|
|
194
|
+
"creative_agent",
|
|
195
|
+
"test_agent_client",
|
|
196
|
+
"create_test_agent",
|
|
197
|
+
"TEST_AGENT_TOKEN",
|
|
198
|
+
"TEST_AGENT_MCP_CONFIG",
|
|
199
|
+
"TEST_AGENT_A2A_CONFIG",
|
|
200
|
+
"TEST_AGENT_MCP_NO_AUTH_CONFIG",
|
|
201
|
+
"TEST_AGENT_A2A_NO_AUTH_CONFIG",
|
|
202
|
+
"CREATIVE_AGENT_CONFIG",
|
|
203
|
+
# Exceptions
|
|
204
|
+
"ADCPError",
|
|
205
|
+
"ADCPConnectionError",
|
|
206
|
+
"ADCPAuthenticationError",
|
|
207
|
+
"ADCPTimeoutError",
|
|
208
|
+
"ADCPProtocolError",
|
|
209
|
+
"ADCPToolNotFoundError",
|
|
210
|
+
"ADCPWebhookError",
|
|
211
|
+
"ADCPWebhookSignatureError",
|
|
212
|
+
"AdagentsValidationError",
|
|
213
|
+
"AdagentsNotFoundError",
|
|
214
|
+
"AdagentsTimeoutError",
|
|
215
|
+
# Validation utilities
|
|
216
|
+
"ValidationError",
|
|
217
|
+
"validate_adagents",
|
|
218
|
+
"validate_agent_authorization",
|
|
219
|
+
"validate_product",
|
|
220
|
+
"validate_publisher_properties_item",
|
|
221
|
+
# Generated types modules
|
|
222
|
+
"generated",
|
|
223
|
+
"aliases",
|
|
224
|
+
"GeneratedTaskStatus",
|
|
225
|
+
# Semantic type aliases (for better API ergonomics)
|
|
226
|
+
"ActivateSignalSuccessResponse",
|
|
227
|
+
"ActivateSignalErrorResponse",
|
|
228
|
+
"BothPreviewRender",
|
|
229
|
+
"BuildCreativeSuccessResponse",
|
|
230
|
+
"BuildCreativeErrorResponse",
|
|
231
|
+
"CreateMediaBuySuccessResponse",
|
|
232
|
+
"CreateMediaBuyErrorResponse",
|
|
233
|
+
"HtmlPreviewRender",
|
|
234
|
+
"InlineDaastAsset",
|
|
235
|
+
"InlineVastAsset",
|
|
236
|
+
"MediaSubAsset",
|
|
237
|
+
"PreviewCreativeFormatRequest",
|
|
238
|
+
"PreviewCreativeManifestRequest",
|
|
239
|
+
"PreviewCreativeStaticResponse",
|
|
240
|
+
"PreviewCreativeInteractiveResponse",
|
|
241
|
+
"PropertyIdActivationKey",
|
|
242
|
+
"PropertyTagActivationKey",
|
|
243
|
+
"ProvidePerformanceFeedbackSuccessResponse",
|
|
244
|
+
"ProvidePerformanceFeedbackErrorResponse",
|
|
245
|
+
"SyncCreativesSuccessResponse",
|
|
246
|
+
"SyncCreativesErrorResponse",
|
|
247
|
+
"TextSubAsset",
|
|
248
|
+
"UpdateMediaBuySuccessResponse",
|
|
249
|
+
"UpdateMediaBuyErrorResponse",
|
|
250
|
+
"UpdateMediaBuyPackagesRequest",
|
|
251
|
+
"UpdateMediaBuyPropertiesRequest",
|
|
252
|
+
"UrlDaastAsset",
|
|
253
|
+
"UrlPreviewRender",
|
|
254
|
+
"UrlVastAsset",
|
|
255
|
+
]
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
"""Type definitions for AdCP client."""
|
|
4
|
+
|
|
5
|
+
from adcp.types.aliases import (
|
|
6
|
+
BothPreviewRender,
|
|
7
|
+
HtmlPreviewRender,
|
|
8
|
+
InlineDaastAsset,
|
|
9
|
+
InlineVastAsset,
|
|
10
|
+
MediaSubAsset,
|
|
11
|
+
TextSubAsset,
|
|
12
|
+
UrlDaastAsset,
|
|
13
|
+
UrlPreviewRender,
|
|
14
|
+
UrlVastAsset,
|
|
15
|
+
)
|
|
16
|
+
from adcp.types.base import AdCPBaseModel
|
|
17
|
+
from adcp.types.core import (
|
|
18
|
+
Activity,
|
|
19
|
+
ActivityType,
|
|
20
|
+
AgentConfig,
|
|
21
|
+
DebugInfo,
|
|
22
|
+
Protocol,
|
|
23
|
+
TaskResult,
|
|
24
|
+
TaskStatus,
|
|
25
|
+
WebhookMetadata,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"AdCPBaseModel",
|
|
30
|
+
"AgentConfig",
|
|
31
|
+
"Protocol",
|
|
32
|
+
"TaskResult",
|
|
33
|
+
"TaskStatus",
|
|
34
|
+
"WebhookMetadata",
|
|
35
|
+
"Activity",
|
|
36
|
+
"ActivityType",
|
|
37
|
+
"DebugInfo",
|
|
38
|
+
# Semantic aliases for discriminated unions
|
|
39
|
+
"BothPreviewRender",
|
|
40
|
+
"HtmlPreviewRender",
|
|
41
|
+
"InlineDaastAsset",
|
|
42
|
+
"InlineVastAsset",
|
|
43
|
+
"MediaSubAsset",
|
|
44
|
+
"TextSubAsset",
|
|
45
|
+
"UrlDaastAsset",
|
|
46
|
+
"UrlPreviewRender",
|
|
47
|
+
"UrlVastAsset",
|
|
48
|
+
]
|