atp-protocol 1.2.0__py3-none-any.whl → 1.3.0__py3-none-any.whl
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.
- atp/__init__.py +9 -1
- atp/client.py +618 -0
- atp/config.py +5 -0
- atp/encryption.py +155 -0
- atp/middleware.py +442 -103
- atp/schemas.py +186 -0
- atp/settlement_client.py +608 -52
- atp_protocol-1.3.0.dist-info/METADATA +590 -0
- atp_protocol-1.3.0.dist-info/RECORD +11 -0
- atp_protocol-1.2.0.dist-info/METADATA +0 -401
- atp_protocol-1.2.0.dist-info/RECORD +0 -9
- {atp_protocol-1.2.0.dist-info → atp_protocol-1.3.0.dist-info}/LICENSE +0 -0
- {atp_protocol-1.2.0.dist-info → atp_protocol-1.3.0.dist-info}/WHEEL +0 -0
atp/schemas.py
CHANGED
|
@@ -107,6 +107,98 @@ class PaymentToken(str, Enum):
|
|
|
107
107
|
USDC = "USDC"
|
|
108
108
|
|
|
109
109
|
|
|
110
|
+
class ATPSettlementMiddlewareConfig(BaseModel):
|
|
111
|
+
"""Configuration schema for ATP Settlement Middleware.
|
|
112
|
+
|
|
113
|
+
This schema defines all configuration parameters for the ATPSettlementMiddleware.
|
|
114
|
+
All parameters match the middleware's __init__ signature, making it easy to
|
|
115
|
+
configure the middleware from a validated configuration object.
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
allowed_endpoints: List[str] = Field(
|
|
119
|
+
...,
|
|
120
|
+
description=(
|
|
121
|
+
"List of endpoint paths to apply settlement to (e.g., ['/v1/chat']). "
|
|
122
|
+
"Supports path patterns - exact matches only."
|
|
123
|
+
),
|
|
124
|
+
)
|
|
125
|
+
input_cost_per_million_usd: float = Field(
|
|
126
|
+
...,
|
|
127
|
+
description="Cost per million input tokens in USD.",
|
|
128
|
+
gt=0.0,
|
|
129
|
+
)
|
|
130
|
+
output_cost_per_million_usd: float = Field(
|
|
131
|
+
...,
|
|
132
|
+
description="Cost per million output tokens in USD.",
|
|
133
|
+
gt=0.0,
|
|
134
|
+
)
|
|
135
|
+
wallet_private_key_header: str = Field(
|
|
136
|
+
default="x-wallet-private-key",
|
|
137
|
+
description=(
|
|
138
|
+
"HTTP header name containing the wallet private key. "
|
|
139
|
+
"The private key should be in JSON array format (e.g., '[1,2,3,...]') "
|
|
140
|
+
"or base58 string format."
|
|
141
|
+
),
|
|
142
|
+
)
|
|
143
|
+
payment_token: PaymentToken = Field(
|
|
144
|
+
default=PaymentToken.SOL,
|
|
145
|
+
description="Token to use for payment (SOL or USDC).",
|
|
146
|
+
)
|
|
147
|
+
recipient_pubkey: Optional[str] = Field(
|
|
148
|
+
default=None,
|
|
149
|
+
description=(
|
|
150
|
+
"Solana public key of the recipient wallet (the endpoint host). "
|
|
151
|
+
"This wallet receives the main payment (after processing fee). "
|
|
152
|
+
"Required when initializing the middleware."
|
|
153
|
+
),
|
|
154
|
+
)
|
|
155
|
+
skip_preflight: bool = Field(
|
|
156
|
+
default=False,
|
|
157
|
+
description="Whether to skip preflight simulation for Solana transactions.",
|
|
158
|
+
)
|
|
159
|
+
commitment: str = Field(
|
|
160
|
+
default="confirmed",
|
|
161
|
+
description="Solana commitment level (processed|confirmed|finalized).",
|
|
162
|
+
)
|
|
163
|
+
require_wallet: bool = Field(
|
|
164
|
+
default=True,
|
|
165
|
+
description=(
|
|
166
|
+
"Whether to require wallet private key. "
|
|
167
|
+
"If False, skips settlement when missing."
|
|
168
|
+
),
|
|
169
|
+
)
|
|
170
|
+
settlement_service_url: Optional[str] = Field(
|
|
171
|
+
default=None,
|
|
172
|
+
description=(
|
|
173
|
+
"Base URL of the settlement service. If not provided, uses "
|
|
174
|
+
"ATP_SETTLEMENT_URL environment variable (default: http://localhost:8001). "
|
|
175
|
+
"The middleware always uses the settlement service for all settlement operations."
|
|
176
|
+
),
|
|
177
|
+
)
|
|
178
|
+
fail_on_settlement_error: bool = Field(
|
|
179
|
+
default=False,
|
|
180
|
+
description=(
|
|
181
|
+
"If True, raises HTTPException when settlement fails (default: False). "
|
|
182
|
+
"If False, returns the response with settlement error info instead of failing the request."
|
|
183
|
+
),
|
|
184
|
+
)
|
|
185
|
+
settlement_timeout: Optional[float] = Field(
|
|
186
|
+
default=None,
|
|
187
|
+
description=(
|
|
188
|
+
"Timeout in seconds for settlement service requests. "
|
|
189
|
+
"Default: from ATP_SETTLEMENT_TIMEOUT env var or 300.0 (5 minutes). "
|
|
190
|
+
"Settlement operations may take longer due to blockchain confirmation times. "
|
|
191
|
+
"Increase this value if you experience timeout errors even when payments are successfully sent."
|
|
192
|
+
),
|
|
193
|
+
gt=0.0,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
class Config:
|
|
197
|
+
"""Pydantic configuration."""
|
|
198
|
+
|
|
199
|
+
use_enum_values = True
|
|
200
|
+
|
|
201
|
+
|
|
110
202
|
class AgentTask(BaseModel):
|
|
111
203
|
"""Complete agent task request requiring full agent specification."""
|
|
112
204
|
|
|
@@ -169,3 +261,97 @@ class SettleTrade(BaseModel):
|
|
|
169
261
|
default="confirmed",
|
|
170
262
|
description="Confirmation level to wait for (processed|confirmed|finalized)",
|
|
171
263
|
)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
class MarketplaceDiscovery(BaseModel):
|
|
268
|
+
name: str = Field(
|
|
269
|
+
...,
|
|
270
|
+
description="The name of the marketplace",
|
|
271
|
+
)
|
|
272
|
+
id: str = Field(
|
|
273
|
+
...,
|
|
274
|
+
description="The id of the marketplace. Generated automatically by the server.",
|
|
275
|
+
)
|
|
276
|
+
url: str = Field(
|
|
277
|
+
...,
|
|
278
|
+
description="The URL of the endpoint",
|
|
279
|
+
)
|
|
280
|
+
description: str = Field(
|
|
281
|
+
...,
|
|
282
|
+
description="The description of the marketplace",
|
|
283
|
+
)
|
|
284
|
+
input_schema: Optional[Union[Dict[Any, Any], List[Dict[str, Any]]]] = Field(
|
|
285
|
+
default=None,
|
|
286
|
+
description="The input schema of the endpoint",
|
|
287
|
+
)
|
|
288
|
+
output_schema: Optional[Union[Dict[Any, Any], List[Dict[str, Any]]]] = Field(
|
|
289
|
+
default=None,
|
|
290
|
+
description="The output schema of the endpoint",
|
|
291
|
+
)
|
|
292
|
+
input_cost_per_million_usd: float = Field(
|
|
293
|
+
...,
|
|
294
|
+
description="The cost per million tokens (USD) for input to this endpoint.",
|
|
295
|
+
)
|
|
296
|
+
output_cost_per_million_usd: float = Field(
|
|
297
|
+
...,
|
|
298
|
+
description="The cost per million tokens (USD) for output from this endpoint.",
|
|
299
|
+
)
|
|
300
|
+
payment_token: PaymentToken = Field(
|
|
301
|
+
default=PaymentToken.SOL,
|
|
302
|
+
description="Payment token to use for settlement (e.g. SOL, USDC)."
|
|
303
|
+
)
|
|
304
|
+
recipient_pubkey: Optional[str] = Field(
|
|
305
|
+
default=None,
|
|
306
|
+
description="Solana recipient public key for settlement."
|
|
307
|
+
)
|
|
308
|
+
tags: Optional[List[str]] = Field(
|
|
309
|
+
default=None,
|
|
310
|
+
description="The tags of the marketplace.",
|
|
311
|
+
)
|
|
312
|
+
business_model: Optional[str] = Field(
|
|
313
|
+
default="usage",
|
|
314
|
+
description="The business model of the marketplace. Usage-based pricing is the default. one-time pricing is also supported.",
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class MarketplaceDiscoveryResponse(BaseModel):
|
|
322
|
+
# Fetch the resources
|
|
323
|
+
resources: List[MarketplaceDiscovery] = Field(
|
|
324
|
+
...,
|
|
325
|
+
description="The resources of the marketplace",
|
|
326
|
+
)
|
|
327
|
+
limit: Optional[int] = Field(
|
|
328
|
+
default=20,
|
|
329
|
+
description="Number of resources to return (default: 20)",
|
|
330
|
+
)
|
|
331
|
+
offset: Optional[int] = Field(
|
|
332
|
+
default=0,
|
|
333
|
+
description="Offset for pagination (default: 0)",
|
|
334
|
+
)
|
|
335
|
+
timestamp: float = Field(
|
|
336
|
+
...,
|
|
337
|
+
description="The timestamp of the response. Generated automatically by the server.",
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
class MarketplaceIndividualDiscoveryQueryRequest(BaseModel):
|
|
343
|
+
id: str = Field(
|
|
344
|
+
...,
|
|
345
|
+
description="The id of the marketplace to query.",
|
|
346
|
+
)
|
|
347
|
+
name: Optional[str] = Field(
|
|
348
|
+
default=None,
|
|
349
|
+
description="The name of the marketplace to query.",
|
|
350
|
+
)
|
|
351
|
+
url: Optional[str] = Field(
|
|
352
|
+
default=None,
|
|
353
|
+
description="The URL of the endpoint to query.",
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|