agentcredia 0.0.1a1__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.
Potentially problematic release.
This version of agentcredia might be problematic. Click here for more details.
- agentcredia-0.0.1a1/.github/workflows/publish.yml +74 -0
- agentcredia-0.0.1a1/.gitignore +28 -0
- agentcredia-0.0.1a1/CHANGELOG.md +10 -0
- agentcredia-0.0.1a1/LICENSE +201 -0
- agentcredia-0.0.1a1/PKG-INFO +188 -0
- agentcredia-0.0.1a1/README.md +156 -0
- agentcredia-0.0.1a1/RELEASING.md +119 -0
- agentcredia-0.0.1a1/codegen/README.md +73 -0
- agentcredia-0.0.1a1/pyproject.toml +67 -0
- agentcredia-0.0.1a1/src/agentcredia/__init__.py +57 -0
- agentcredia-0.0.1a1/src/agentcredia/_client.py +216 -0
- agentcredia-0.0.1a1/src/agentcredia/_errors.py +97 -0
- agentcredia-0.0.1a1/src/agentcredia/_version.py +8 -0
- agentcredia-0.0.1a1/src/agentcredia/resources/__init__.py +1 -0
- agentcredia-0.0.1a1/src/agentcredia/resources/agents.py +65 -0
- agentcredia-0.0.1a1/src/agentcredia/resources/api_keys.py +131 -0
- agentcredia-0.0.1a1/src/agentcredia/resources/payment_requests.py +86 -0
- agentcredia-0.0.1a1/src/agentcredia/resources/payments.py +91 -0
- agentcredia-0.0.1a1/src/agentcredia/resources/transactions.py +35 -0
- agentcredia-0.0.1a1/src/agentcredia/webhooks.py +229 -0
- agentcredia-0.0.1a1/tests/__init__.py +0 -0
- agentcredia-0.0.1a1/tests/test_client.py +669 -0
- agentcredia-0.0.1a1/tests/test_version.py +23 -0
- agentcredia-0.0.1a1/tests/test_webhooks_verify.py +188 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Publish `agentcredia` to PyPI via Trusted Publisher OIDC.
|
|
2
|
+
# Manual dispatch only.
|
|
3
|
+
#
|
|
4
|
+
# Requires PyPI Trusted Publisher binding on
|
|
5
|
+
# https://pypi.org/manage/project/agentcredia/settings/publishing/:
|
|
6
|
+
# Publisher: GitHub
|
|
7
|
+
# Owner: agentcredia
|
|
8
|
+
# Repository name: agentcredia-python
|
|
9
|
+
# Workflow filename: publish.yml
|
|
10
|
+
# Environment: pypi
|
|
11
|
+
#
|
|
12
|
+
# This file is mirrored from the private monorepo
|
|
13
|
+
# `packages/sdk-python/.public-templates/.github/workflows/publish.yml` in the private AgentCredia monorepo
|
|
14
|
+
# by the `mirror-sdk-python` workflow there. Do not edit it directly in
|
|
15
|
+
# the public repo - changes will be overwritten on the next mirror.
|
|
16
|
+
|
|
17
|
+
name: publish
|
|
18
|
+
|
|
19
|
+
on:
|
|
20
|
+
workflow_dispatch:
|
|
21
|
+
inputs:
|
|
22
|
+
tag:
|
|
23
|
+
description: 'PyPI release classifier (informational only; pypi tracks pre-release vs final from the version string itself, e.g. 0.0.1a0 = alpha).'
|
|
24
|
+
required: true
|
|
25
|
+
default: 'alpha'
|
|
26
|
+
type: choice
|
|
27
|
+
options:
|
|
28
|
+
- alpha
|
|
29
|
+
- beta
|
|
30
|
+
- latest
|
|
31
|
+
|
|
32
|
+
permissions:
|
|
33
|
+
contents: read
|
|
34
|
+
id-token: write
|
|
35
|
+
|
|
36
|
+
jobs:
|
|
37
|
+
publish:
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
environment: pypi
|
|
40
|
+
timeout-minutes: 10
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
|
|
44
|
+
- uses: actions/setup-python@v5
|
|
45
|
+
with:
|
|
46
|
+
python-version: '3.11'
|
|
47
|
+
|
|
48
|
+
- name: install build tooling
|
|
49
|
+
run: |
|
|
50
|
+
python -m pip install --upgrade pip
|
|
51
|
+
python -m pip install build twine
|
|
52
|
+
|
|
53
|
+
- name: build sdist + wheel
|
|
54
|
+
run: |
|
|
55
|
+
python -m build
|
|
56
|
+
ls -la dist/
|
|
57
|
+
|
|
58
|
+
- name: validate distribution metadata
|
|
59
|
+
# twine check catches README markup errors, missing classifiers,
|
|
60
|
+
# and other PyPI-rejecting issues before the upload itself.
|
|
61
|
+
run: python -m twine check dist/*
|
|
62
|
+
|
|
63
|
+
- name: publish to PyPI (Trusted Publisher OIDC)
|
|
64
|
+
# No PYPI_TOKEN involved - the action exchanges the GitHub OIDC
|
|
65
|
+
# token for a short-lived PyPI publish token via the Trusted
|
|
66
|
+
# Publisher binding configured on pypi.org. The binding is the
|
|
67
|
+
# source of trust; this workflow file's PATH on the public repo
|
|
68
|
+
# is part of that binding.
|
|
69
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
70
|
+
with:
|
|
71
|
+
# No `password:` field - OIDC is used when omitted.
|
|
72
|
+
# `print-hash: true` records the sha256 of every uploaded
|
|
73
|
+
# artefact in the run log for provenance auditing.
|
|
74
|
+
print-hash: true
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Python byte-code + caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
*.egg-info/
|
|
10
|
+
*.egg
|
|
11
|
+
.eggs/
|
|
12
|
+
|
|
13
|
+
# Virtual envs
|
|
14
|
+
.venv/
|
|
15
|
+
venv/
|
|
16
|
+
env/
|
|
17
|
+
|
|
18
|
+
# Test + coverage caches
|
|
19
|
+
.pytest_cache/
|
|
20
|
+
.tox/
|
|
21
|
+
.coverage
|
|
22
|
+
.coverage.*
|
|
23
|
+
htmlcov/
|
|
24
|
+
.mypy_cache/
|
|
25
|
+
.ruff_cache/
|
|
26
|
+
|
|
27
|
+
# Generated DTO models (from codegen/regenerate.sh)
|
|
28
|
+
src/agentcredia/_models/_generated_*.py
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the `agentcredia` Python SDK are documented here.
|
|
4
|
+
|
|
5
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
6
|
+
this project adheres to [PEP 440](https://peps.python.org/pep-0440/) versioning.
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
- Initial release.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Recordskeeper Inc
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing
|
|
201
|
+
permissions and limitations under the License.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agentcredia
|
|
3
|
+
Version: 0.0.1a1
|
|
4
|
+
Summary: Official Python SDK for the AgentCredia non-custodial AI-agent wallet platform
|
|
5
|
+
Project-URL: Homepage, https://agentcredia.com
|
|
6
|
+
Project-URL: Documentation, https://docs.agentcredia.com
|
|
7
|
+
Project-URL: Repository, https://github.com/agentcredia/agentcredia-python
|
|
8
|
+
Project-URL: Source, https://github.com/agentcredia/agentcredia-python
|
|
9
|
+
Project-URL: Changelog, https://github.com/agentcredia/agentcredia-python/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Issue Tracker, https://github.com/agentcredia/agentcredia-python/issues
|
|
11
|
+
Author-email: AgentCredia <support@agentcredia.com>
|
|
12
|
+
License: Apache-2.0
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Keywords: agent,agentcredia,stablecoin,usdc,wallet,x402
|
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Requires-Dist: httpx>=0.27.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.4; extra == 'dev'
|
|
30
|
+
Requires-Dist: respx>=0.20; extra == 'dev'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# agentcredia (Python SDK)
|
|
34
|
+
|
|
35
|
+
**Official Python SDK for [AgentCredia](https://agentcredia.com)** -
|
|
36
|
+
the non-custodial AI-agent wallet platform on Base.
|
|
37
|
+
|
|
38
|
+
> Pre-release: `0.0.1a0` ships the operational essentials - HTTP
|
|
39
|
+
> transport, `apiKeys` resource, and `webhooks.verify`. The full
|
|
40
|
+
> surface (every resource + x402 client + async client) lands in the
|
|
41
|
+
> 21.3 Phase C follow-up rows.
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install agentcredia
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Requires Python 3.9 or newer.
|
|
50
|
+
|
|
51
|
+
## Quick start
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from agentcredia import Client
|
|
55
|
+
|
|
56
|
+
client = Client(api_key="sk_test_...")
|
|
57
|
+
for key in client.api_keys.list()["data"]:
|
|
58
|
+
print(key["id"], key["prefix"])
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The client pins the network from the api-key prefix
|
|
62
|
+
(`sk_test_*` → testnet, `sk_live_*` → mainnet). Override with
|
|
63
|
+
`Client(api_key=..., network="mainnet")` when you need both modes in
|
|
64
|
+
one process (mixed-mode tests).
|
|
65
|
+
|
|
66
|
+
## Verify webhook signatures
|
|
67
|
+
|
|
68
|
+
This is the single most important utility this SDK ships - drop it
|
|
69
|
+
into the top of your webhook handler BEFORE touching the body.
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from agentcredia import webhooks
|
|
73
|
+
|
|
74
|
+
# In your Flask / FastAPI / Django handler:
|
|
75
|
+
def receive_webhook(req, raw_body, secret):
|
|
76
|
+
result = webhooks.verify(headers=req.headers, raw_body=raw_body, secret=secret)
|
|
77
|
+
if not result.ok:
|
|
78
|
+
return {"code": result.code}, 400
|
|
79
|
+
# result.event_type / result.event_id / result.delivery_id populated
|
|
80
|
+
process_event(raw_body, result.event_type)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The verifier:
|
|
84
|
+
|
|
85
|
+
- Reads `X-AgentCredia-Signature` in either `t=<ts>,v1=<hex>` or
|
|
86
|
+
bare-hex form (some load balancers strip commas).
|
|
87
|
+
- Falls back to `X-AgentCredia-Timestamp` when the signature is bare.
|
|
88
|
+
- Rejects with `webhook.timestamp_outside_window` when drift exceeds
|
|
89
|
+
300s (5-minute replay window; matches the worker).
|
|
90
|
+
- Constant-time compares via `hmac.compare_digest`.
|
|
91
|
+
|
|
92
|
+
For exception-based flows pass `raise_on_fail=True`:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
try:
|
|
96
|
+
webhooks.verify(headers=req.headers, raw_body=raw_body, secret=secret, raise_on_fail=True)
|
|
97
|
+
except WebhookSignatureError as e:
|
|
98
|
+
return {"code": e.code}, 400
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Errors
|
|
102
|
+
|
|
103
|
+
Two classes:
|
|
104
|
+
|
|
105
|
+
- `AgentCrediaError` - base class; every SDK error inherits.
|
|
106
|
+
- `ApiKeyError` - subclass for HTTP 401 / 403 envelopes whose
|
|
107
|
+
`error.code` starts with `apikey.` (e.g. `apikey.scope_insufficient`,
|
|
108
|
+
`apikey.wallet_not_assigned`).
|
|
109
|
+
|
|
110
|
+
Always branch on `.code`, never regex-match `.message`:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from agentcredia import ApiKeyError
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
client.api_keys.list()
|
|
117
|
+
except ApiKeyError as e:
|
|
118
|
+
if e.code == "apikey.scope_insufficient":
|
|
119
|
+
# mint a fresh key with more scope
|
|
120
|
+
...
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Workspace keys (sub-plan 21.3)
|
|
124
|
+
|
|
125
|
+
Two key shapes exist (see [the Authentication guide](https://docs.agentcredia.com/docs/authentication) for the full decision tree):
|
|
126
|
+
|
|
127
|
+
- **Wallet-only**: bound to ONE agent via `agent_id`. The right shape for an autonomous AI agent that IS one wallet.
|
|
128
|
+
- **Workspace**: for human operators that can carry workspace-level scopes AND assignments to N specific wallets.
|
|
129
|
+
|
|
130
|
+
The Python SDK forwards both shapes through the same `client.api_keys` resource; the body shape decides the flavor on the server. Once the create surface lands beyond the C-2 scaffold:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
key = client.api_keys.create(
|
|
134
|
+
label="Treasury daily reconciliation",
|
|
135
|
+
workspace_scopes=["read_workspace"],
|
|
136
|
+
wallet_assignments=[
|
|
137
|
+
{"agentId": "agt_trading", "scopes": ["read_wallet_metadata"]},
|
|
138
|
+
{"agentId": "agt_settlement", "scopes": ["read_wallet_metadata"]},
|
|
139
|
+
],
|
|
140
|
+
expires_in_days=30,
|
|
141
|
+
)
|
|
142
|
+
print(key["secret"]) # shown ONCE
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Server-side RBAC: the minter cannot grant a scope they do not have themselves. Over-grants reject with `apikey.role_insufficient_for_grants` - catch `ApiKeyError` and branch on `e.code`.
|
|
146
|
+
|
|
147
|
+
Cascade behaviour: when an assigned wallet is soft-deleted, the assignment row is removed. If the key has zero workspace scopes AND no remaining assignments, it auto-revokes with `apikey.no_grants_remaining`. Mint a fresh key.
|
|
148
|
+
|
|
149
|
+
## x402 (Phase C-7)
|
|
150
|
+
|
|
151
|
+
The sibling package `agentcredia-x402` (Python port of [`@agentcredia/x402`](https://www.npmjs.com/package/@agentcredia/x402)) will ship the x402 client + FastAPI / Starlette / Flask adapters in sub-plan 21.3 row C-7. The wire format is identical across languages so a Python service can accept payments from a Node client and vice-versa.
|
|
152
|
+
|
|
153
|
+
## Retry behaviour
|
|
154
|
+
|
|
155
|
+
The transport retries on `429` and `5xx` with exponential backoff
|
|
156
|
+
(0.5s → 1s → 2s → ... → 30s cap). `Retry-After` is honoured when the
|
|
157
|
+
server sends it. Network errors (timeout, connection drop) get the
|
|
158
|
+
same retry budget.
|
|
159
|
+
|
|
160
|
+
`POST` / `PATCH` / `DELETE` requests carry an `Idempotency-Key` header
|
|
161
|
+
|
|
162
|
+
- the SDK mints a uuid4 if you do not supply one. Pass
|
|
163
|
+
`idempotency_key="..."` to thread a stable key across SDK retries OR
|
|
164
|
+
across processes (e.g. cron jobs that hash their input deterministically).
|
|
165
|
+
|
|
166
|
+
## Codegen
|
|
167
|
+
|
|
168
|
+
Type-only DTOs are generated from `apps/backend/openapi/openapi.yaml`
|
|
169
|
+
via [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator).
|
|
170
|
+
Transport, retry, error mapping, and the webhook verifier stay
|
|
171
|
+
handwritten - see [codegen/README.md](./codegen/README.md) for the
|
|
172
|
+
decision rationale.
|
|
173
|
+
|
|
174
|
+
## Source-of-truth + distribution
|
|
175
|
+
|
|
176
|
+
Source-of-truth: this directory in
|
|
177
|
+
the private AgentCredia monorepo
|
|
178
|
+
under `packages/sdk-python/`.
|
|
179
|
+
|
|
180
|
+
Public mirror: [agentcredia/agentcredia-python](https://github.com/agentcredia/agentcredia-python)
|
|
181
|
+
(receives merges from this directory on each push to `dev`).
|
|
182
|
+
|
|
183
|
+
Distribution: [pypi](https://pypi.org/project/agentcredia/) via
|
|
184
|
+
Trusted Publisher OIDC.
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
Apache-2.0.
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# agentcredia (Python SDK)
|
|
2
|
+
|
|
3
|
+
**Official Python SDK for [AgentCredia](https://agentcredia.com)** -
|
|
4
|
+
the non-custodial AI-agent wallet platform on Base.
|
|
5
|
+
|
|
6
|
+
> Pre-release: `0.0.1a0` ships the operational essentials - HTTP
|
|
7
|
+
> transport, `apiKeys` resource, and `webhooks.verify`. The full
|
|
8
|
+
> surface (every resource + x402 client + async client) lands in the
|
|
9
|
+
> 21.3 Phase C follow-up rows.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install agentcredia
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Python 3.9 or newer.
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from agentcredia import Client
|
|
23
|
+
|
|
24
|
+
client = Client(api_key="sk_test_...")
|
|
25
|
+
for key in client.api_keys.list()["data"]:
|
|
26
|
+
print(key["id"], key["prefix"])
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The client pins the network from the api-key prefix
|
|
30
|
+
(`sk_test_*` → testnet, `sk_live_*` → mainnet). Override with
|
|
31
|
+
`Client(api_key=..., network="mainnet")` when you need both modes in
|
|
32
|
+
one process (mixed-mode tests).
|
|
33
|
+
|
|
34
|
+
## Verify webhook signatures
|
|
35
|
+
|
|
36
|
+
This is the single most important utility this SDK ships - drop it
|
|
37
|
+
into the top of your webhook handler BEFORE touching the body.
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from agentcredia import webhooks
|
|
41
|
+
|
|
42
|
+
# In your Flask / FastAPI / Django handler:
|
|
43
|
+
def receive_webhook(req, raw_body, secret):
|
|
44
|
+
result = webhooks.verify(headers=req.headers, raw_body=raw_body, secret=secret)
|
|
45
|
+
if not result.ok:
|
|
46
|
+
return {"code": result.code}, 400
|
|
47
|
+
# result.event_type / result.event_id / result.delivery_id populated
|
|
48
|
+
process_event(raw_body, result.event_type)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The verifier:
|
|
52
|
+
|
|
53
|
+
- Reads `X-AgentCredia-Signature` in either `t=<ts>,v1=<hex>` or
|
|
54
|
+
bare-hex form (some load balancers strip commas).
|
|
55
|
+
- Falls back to `X-AgentCredia-Timestamp` when the signature is bare.
|
|
56
|
+
- Rejects with `webhook.timestamp_outside_window` when drift exceeds
|
|
57
|
+
300s (5-minute replay window; matches the worker).
|
|
58
|
+
- Constant-time compares via `hmac.compare_digest`.
|
|
59
|
+
|
|
60
|
+
For exception-based flows pass `raise_on_fail=True`:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
try:
|
|
64
|
+
webhooks.verify(headers=req.headers, raw_body=raw_body, secret=secret, raise_on_fail=True)
|
|
65
|
+
except WebhookSignatureError as e:
|
|
66
|
+
return {"code": e.code}, 400
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Errors
|
|
70
|
+
|
|
71
|
+
Two classes:
|
|
72
|
+
|
|
73
|
+
- `AgentCrediaError` - base class; every SDK error inherits.
|
|
74
|
+
- `ApiKeyError` - subclass for HTTP 401 / 403 envelopes whose
|
|
75
|
+
`error.code` starts with `apikey.` (e.g. `apikey.scope_insufficient`,
|
|
76
|
+
`apikey.wallet_not_assigned`).
|
|
77
|
+
|
|
78
|
+
Always branch on `.code`, never regex-match `.message`:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from agentcredia import ApiKeyError
|
|
82
|
+
|
|
83
|
+
try:
|
|
84
|
+
client.api_keys.list()
|
|
85
|
+
except ApiKeyError as e:
|
|
86
|
+
if e.code == "apikey.scope_insufficient":
|
|
87
|
+
# mint a fresh key with more scope
|
|
88
|
+
...
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Workspace keys (sub-plan 21.3)
|
|
92
|
+
|
|
93
|
+
Two key shapes exist (see [the Authentication guide](https://docs.agentcredia.com/docs/authentication) for the full decision tree):
|
|
94
|
+
|
|
95
|
+
- **Wallet-only**: bound to ONE agent via `agent_id`. The right shape for an autonomous AI agent that IS one wallet.
|
|
96
|
+
- **Workspace**: for human operators that can carry workspace-level scopes AND assignments to N specific wallets.
|
|
97
|
+
|
|
98
|
+
The Python SDK forwards both shapes through the same `client.api_keys` resource; the body shape decides the flavor on the server. Once the create surface lands beyond the C-2 scaffold:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
key = client.api_keys.create(
|
|
102
|
+
label="Treasury daily reconciliation",
|
|
103
|
+
workspace_scopes=["read_workspace"],
|
|
104
|
+
wallet_assignments=[
|
|
105
|
+
{"agentId": "agt_trading", "scopes": ["read_wallet_metadata"]},
|
|
106
|
+
{"agentId": "agt_settlement", "scopes": ["read_wallet_metadata"]},
|
|
107
|
+
],
|
|
108
|
+
expires_in_days=30,
|
|
109
|
+
)
|
|
110
|
+
print(key["secret"]) # shown ONCE
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Server-side RBAC: the minter cannot grant a scope they do not have themselves. Over-grants reject with `apikey.role_insufficient_for_grants` - catch `ApiKeyError` and branch on `e.code`.
|
|
114
|
+
|
|
115
|
+
Cascade behaviour: when an assigned wallet is soft-deleted, the assignment row is removed. If the key has zero workspace scopes AND no remaining assignments, it auto-revokes with `apikey.no_grants_remaining`. Mint a fresh key.
|
|
116
|
+
|
|
117
|
+
## x402 (Phase C-7)
|
|
118
|
+
|
|
119
|
+
The sibling package `agentcredia-x402` (Python port of [`@agentcredia/x402`](https://www.npmjs.com/package/@agentcredia/x402)) will ship the x402 client + FastAPI / Starlette / Flask adapters in sub-plan 21.3 row C-7. The wire format is identical across languages so a Python service can accept payments from a Node client and vice-versa.
|
|
120
|
+
|
|
121
|
+
## Retry behaviour
|
|
122
|
+
|
|
123
|
+
The transport retries on `429` and `5xx` with exponential backoff
|
|
124
|
+
(0.5s → 1s → 2s → ... → 30s cap). `Retry-After` is honoured when the
|
|
125
|
+
server sends it. Network errors (timeout, connection drop) get the
|
|
126
|
+
same retry budget.
|
|
127
|
+
|
|
128
|
+
`POST` / `PATCH` / `DELETE` requests carry an `Idempotency-Key` header
|
|
129
|
+
|
|
130
|
+
- the SDK mints a uuid4 if you do not supply one. Pass
|
|
131
|
+
`idempotency_key="..."` to thread a stable key across SDK retries OR
|
|
132
|
+
across processes (e.g. cron jobs that hash their input deterministically).
|
|
133
|
+
|
|
134
|
+
## Codegen
|
|
135
|
+
|
|
136
|
+
Type-only DTOs are generated from `apps/backend/openapi/openapi.yaml`
|
|
137
|
+
via [datamodel-code-generator](https://github.com/koxudaxi/datamodel-code-generator).
|
|
138
|
+
Transport, retry, error mapping, and the webhook verifier stay
|
|
139
|
+
handwritten - see [codegen/README.md](./codegen/README.md) for the
|
|
140
|
+
decision rationale.
|
|
141
|
+
|
|
142
|
+
## Source-of-truth + distribution
|
|
143
|
+
|
|
144
|
+
Source-of-truth: this directory in
|
|
145
|
+
the private AgentCredia monorepo
|
|
146
|
+
under `packages/sdk-python/`.
|
|
147
|
+
|
|
148
|
+
Public mirror: [agentcredia/agentcredia-python](https://github.com/agentcredia/agentcredia-python)
|
|
149
|
+
(receives merges from this directory on each push to `dev`).
|
|
150
|
+
|
|
151
|
+
Distribution: [pypi](https://pypi.org/project/agentcredia/) via
|
|
152
|
+
Trusted Publisher OIDC.
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
Apache-2.0.
|