agirails 2.0.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.
- agirails-2.0.0/.env.example +55 -0
- agirails-2.0.0/.github/workflows/test.yml +388 -0
- agirails-2.0.0/.gitignore +89 -0
- agirails-2.0.0/CHANGELOG.md +110 -0
- agirails-2.0.0/LICENSE +190 -0
- agirails-2.0.0/MIGRATION.md +301 -0
- agirails-2.0.0/PKG-INFO +546 -0
- agirails-2.0.0/README.md +491 -0
- agirails-2.0.0/pyproject.toml +174 -0
- agirails-2.0.0/src/agirails/__init__.py +547 -0
- agirails-2.0.0/src/agirails/abi/ACTPKernel.json +1340 -0
- agirails-2.0.0/src/agirails/abi/ERC20.json +40 -0
- agirails-2.0.0/src/agirails/abi/EscrowVault.json +134 -0
- agirails-2.0.0/src/agirails/abis/actp_kernel.json +1617 -0
- agirails-2.0.0/src/agirails/abis/agent_registry.json +782 -0
- agirails-2.0.0/src/agirails/abis/eas.json +110 -0
- agirails-2.0.0/src/agirails/abis/escrow_vault.json +337 -0
- agirails-2.0.0/src/agirails/abis/usdc.json +185 -0
- agirails-2.0.0/src/agirails/adapters/__init__.py +59 -0
- agirails-2.0.0/src/agirails/adapters/base.py +285 -0
- agirails-2.0.0/src/agirails/adapters/basic.py +288 -0
- agirails-2.0.0/src/agirails/adapters/standard.py +378 -0
- agirails-2.0.0/src/agirails/builders/__init__.py +50 -0
- agirails-2.0.0/src/agirails/builders/delivery_proof.py +655 -0
- agirails-2.0.0/src/agirails/builders/quote.py +357 -0
- agirails-2.0.0/src/agirails/cli/__init__.py +15 -0
- agirails-2.0.0/src/agirails/cli/commands/__init__.py +19 -0
- agirails-2.0.0/src/agirails/cli/commands/balance.py +93 -0
- agirails-2.0.0/src/agirails/cli/commands/batch.py +378 -0
- agirails-2.0.0/src/agirails/cli/commands/config.py +174 -0
- agirails-2.0.0/src/agirails/cli/commands/init.py +104 -0
- agirails-2.0.0/src/agirails/cli/commands/mint.py +100 -0
- agirails-2.0.0/src/agirails/cli/commands/pay.py +115 -0
- agirails-2.0.0/src/agirails/cli/commands/simulate.py +348 -0
- agirails-2.0.0/src/agirails/cli/commands/time.py +233 -0
- agirails-2.0.0/src/agirails/cli/commands/tx.py +263 -0
- agirails-2.0.0/src/agirails/cli/commands/watch.py +264 -0
- agirails-2.0.0/src/agirails/cli/main.py +138 -0
- agirails-2.0.0/src/agirails/cli/utils/__init__.py +39 -0
- agirails-2.0.0/src/agirails/cli/utils/client.py +283 -0
- agirails-2.0.0/src/agirails/cli/utils/output.py +252 -0
- agirails-2.0.0/src/agirails/cli/utils/validation.py +297 -0
- agirails-2.0.0/src/agirails/client.py +431 -0
- agirails-2.0.0/src/agirails/config/__init__.py +27 -0
- agirails-2.0.0/src/agirails/config/abis/AgentRegistry.json +782 -0
- agirails-2.0.0/src/agirails/config/networks.py +239 -0
- agirails-2.0.0/src/agirails/errors/__init__.py +116 -0
- agirails-2.0.0/src/agirails/errors/agent.py +282 -0
- agirails-2.0.0/src/agirails/errors/base.py +161 -0
- agirails-2.0.0/src/agirails/errors/mock.py +106 -0
- agirails-2.0.0/src/agirails/errors/network.py +139 -0
- agirails-2.0.0/src/agirails/errors/storage.py +243 -0
- agirails-2.0.0/src/agirails/errors/transaction.py +271 -0
- agirails-2.0.0/src/agirails/errors/validation.py +129 -0
- agirails-2.0.0/src/agirails/level0/__init__.py +68 -0
- agirails-2.0.0/src/agirails/level0/directory.py +410 -0
- agirails-2.0.0/src/agirails/level0/provide.py +237 -0
- agirails-2.0.0/src/agirails/level0/provider.py +815 -0
- agirails-2.0.0/src/agirails/level0/request.py +964 -0
- agirails-2.0.0/src/agirails/level1/__init__.py +70 -0
- agirails-2.0.0/src/agirails/level1/agent.py +917 -0
- agirails-2.0.0/src/agirails/level1/config.py +210 -0
- agirails-2.0.0/src/agirails/level1/job.py +258 -0
- agirails-2.0.0/src/agirails/level1/pricing.py +230 -0
- agirails-2.0.0/src/agirails/protocol/__init__.py +148 -0
- agirails-2.0.0/src/agirails/protocol/agent_registry.py +820 -0
- agirails-2.0.0/src/agirails/protocol/did.py +611 -0
- agirails-2.0.0/src/agirails/protocol/eas.py +739 -0
- agirails-2.0.0/src/agirails/protocol/escrow.py +753 -0
- agirails-2.0.0/src/agirails/protocol/events.py +785 -0
- agirails-2.0.0/src/agirails/protocol/kernel.py +728 -0
- agirails-2.0.0/src/agirails/protocol/messages.py +686 -0
- agirails-2.0.0/src/agirails/protocol/nonce.py +354 -0
- agirails-2.0.0/src/agirails/protocol/proofs.py +468 -0
- agirails-2.0.0/src/agirails/py.typed +0 -0
- agirails-2.0.0/src/agirails/runtime/__init__.py +72 -0
- agirails-2.0.0/src/agirails/runtime/base.py +329 -0
- agirails-2.0.0/src/agirails/runtime/blockchain_runtime.py +673 -0
- agirails-2.0.0/src/agirails/runtime/mock_runtime.py +645 -0
- agirails-2.0.0/src/agirails/runtime/mock_state_manager.py +340 -0
- agirails-2.0.0/src/agirails/runtime/types.py +427 -0
- agirails-2.0.0/src/agirails/types/__init__.py +69 -0
- agirails-2.0.0/src/agirails/types/did.py +278 -0
- agirails-2.0.0/src/agirails/types/message.py +717 -0
- agirails-2.0.0/src/agirails/types/transaction.py +391 -0
- agirails-2.0.0/src/agirails/utils/__init__.py +86 -0
- agirails-2.0.0/src/agirails/utils/canonical_json.py +334 -0
- agirails-2.0.0/src/agirails/utils/helpers.py +927 -0
- agirails-2.0.0/src/agirails/utils/logger.py +185 -0
- agirails-2.0.0/src/agirails/utils/logging.py +200 -0
- agirails-2.0.0/src/agirails/utils/nonce_tracker.py +542 -0
- agirails-2.0.0/src/agirails/utils/received_nonce_tracker.py +472 -0
- agirails-2.0.0/src/agirails/utils/secure_nonce.py +96 -0
- agirails-2.0.0/src/agirails/utils/security.py +1156 -0
- agirails-2.0.0/src/agirails/utils/semaphore.py +233 -0
- agirails-2.0.0/src/agirails/utils/used_attestation_tracker.py +325 -0
- agirails-2.0.0/src/agirails/utils/validation.py +657 -0
- agirails-2.0.0/src/agirails/version.py +4 -0
- agirails-2.0.0/tests/__init__.py +0 -0
- agirails-2.0.0/tests/benchmarks/__init__.py +1 -0
- agirails-2.0.0/tests/benchmarks/test_performance.py +523 -0
- agirails-2.0.0/tests/conftest.py +83 -0
- agirails-2.0.0/tests/fixtures/parity/canonical_json.json +84 -0
- agirails-2.0.0/tests/fixtures/parity/delivery_proof.json +98 -0
- agirails-2.0.0/tests/fixtures/parity/eip712.json +139 -0
- agirails-2.0.0/tests/fixtures/parity/service_hash.json +100 -0
- agirails-2.0.0/tests/integration/__init__.py +0 -0
- agirails-2.0.0/tests/integration/test_blockchain_runtime.py +617 -0
- agirails-2.0.0/tests/integration/test_eas.py +635 -0
- agirails-2.0.0/tests/test_adapters/__init__.py +0 -0
- agirails-2.0.0/tests/test_adapters/test_basic.py +211 -0
- agirails-2.0.0/tests/test_adapters/test_standard.py +354 -0
- agirails-2.0.0/tests/test_builders/__init__.py +1 -0
- agirails-2.0.0/tests/test_builders/test_delivery_proof.py +438 -0
- agirails-2.0.0/tests/test_builders/test_quote.py +291 -0
- agirails-2.0.0/tests/test_cli.py +471 -0
- agirails-2.0.0/tests/test_client.py +266 -0
- agirails-2.0.0/tests/test_errors/__init__.py +1 -0
- agirails-2.0.0/tests/test_errors/test_agent.py +234 -0
- agirails-2.0.0/tests/test_errors/test_base.py +125 -0
- agirails-2.0.0/tests/test_errors/test_network.py +126 -0
- agirails-2.0.0/tests/test_errors/test_transaction.py +196 -0
- agirails-2.0.0/tests/test_errors/test_validation.py +138 -0
- agirails-2.0.0/tests/test_level0/__init__.py +1 -0
- agirails-2.0.0/tests/test_level0/test_directory.py +323 -0
- agirails-2.0.0/tests/test_level0/test_provider.py +1274 -0
- agirails-2.0.0/tests/test_level0/test_request.py +1060 -0
- agirails-2.0.0/tests/test_level1/__init__.py +1 -0
- agirails-2.0.0/tests/test_level1/test_agent_lifecycle.py +732 -0
- agirails-2.0.0/tests/test_level1/test_config.py +277 -0
- agirails-2.0.0/tests/test_level1/test_pricing.py +215 -0
- agirails-2.0.0/tests/test_packaging/__init__.py +1 -0
- agirails-2.0.0/tests/test_packaging/test_smoke.py +542 -0
- agirails-2.0.0/tests/test_parity.py +695 -0
- agirails-2.0.0/tests/test_properties/__init__.py +1 -0
- agirails-2.0.0/tests/test_properties/test_state_machine.py +328 -0
- agirails-2.0.0/tests/test_protocol/__init__.py +1 -0
- agirails-2.0.0/tests/test_protocol/test_did.py +345 -0
- agirails-2.0.0/tests/test_protocol/test_networks.py +240 -0
- agirails-2.0.0/tests/test_protocol/test_proofs.py +254 -0
- agirails-2.0.0/tests/test_runtime/__init__.py +0 -0
- agirails-2.0.0/tests/test_runtime/test_concurrent_file_locking.py +590 -0
- agirails-2.0.0/tests/test_runtime/test_mock_runtime.py +952 -0
- agirails-2.0.0/tests/test_runtime/test_mock_state_manager.py +464 -0
- agirails-2.0.0/tests/test_security/__init__.py +1 -0
- agirails-2.0.0/tests/test_security/test_security_audit.py +640 -0
- agirails-2.0.0/tests/test_types/__init__.py +1 -0
- agirails-2.0.0/tests/test_types/test_message.py +510 -0
- agirails-2.0.0/tests/test_types/test_transaction.py +297 -0
- agirails-2.0.0/tests/test_utils/__init__.py +0 -0
- agirails-2.0.0/tests/test_utils/test_attestation_replay.py +486 -0
- agirails-2.0.0/tests/test_utils/test_helpers.py +395 -0
- agirails-2.0.0/tests/test_utils/test_helpers_extended.py +363 -0
- agirails-2.0.0/tests/test_utils/test_nonce_tracker.py +398 -0
- agirails-2.0.0/tests/test_utils/test_nonce_tracker_extended.py +389 -0
- agirails-2.0.0/tests/test_utils/test_received_nonce_tracker_extended.py +507 -0
- agirails-2.0.0/tests/test_utils/test_secure_nonce_concurrency.py +432 -0
- agirails-2.0.0/tests/test_utils/test_security.py +473 -0
- agirails-2.0.0/tests/test_utils/test_security_extended.py +935 -0
- agirails-2.0.0/tests/test_utils/test_validation.py +653 -0
- agirails-2.0.0/tests/test_utils/test_validation_extended.py +487 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# AGIRAILS Python SDK - Environment Variables
|
|
2
|
+
# Copy this file to .env and fill in your values
|
|
3
|
+
#
|
|
4
|
+
# IMPORTANT: Never commit .env to version control!
|
|
5
|
+
|
|
6
|
+
# =============================================================================
|
|
7
|
+
# Wallet Configuration (Required for testnet/mainnet)
|
|
8
|
+
# =============================================================================
|
|
9
|
+
|
|
10
|
+
# Client wallet (requester) - Your private key for sending transactions
|
|
11
|
+
# Generate a new wallet for testing: https://vanity-eth.tk/
|
|
12
|
+
CLIENT_PRIVATE_KEY=0x_your_client_private_key_here
|
|
13
|
+
|
|
14
|
+
# Provider wallet - Private key for receiving payments (optional)
|
|
15
|
+
PROVIDER_PRIVATE_KEY=0x_your_provider_private_key_here
|
|
16
|
+
|
|
17
|
+
# =============================================================================
|
|
18
|
+
# Network Configuration
|
|
19
|
+
# =============================================================================
|
|
20
|
+
|
|
21
|
+
# Base Sepolia Testnet (default)
|
|
22
|
+
RPC_URL=https://sepolia.base.org
|
|
23
|
+
CHAIN_ID=84532
|
|
24
|
+
|
|
25
|
+
# Base Mainnet (for production)
|
|
26
|
+
# RPC_URL=https://mainnet.base.org
|
|
27
|
+
# CHAIN_ID=8453
|
|
28
|
+
|
|
29
|
+
# =============================================================================
|
|
30
|
+
# Contract Addresses (Base Sepolia)
|
|
31
|
+
# =============================================================================
|
|
32
|
+
|
|
33
|
+
# MockUSDC contract for testnet
|
|
34
|
+
MOCK_USDC_ADDRESS=0x444b4e1A65949AB2ac75979D5d0166Eb7A248Ccb
|
|
35
|
+
|
|
36
|
+
# ACTP Kernel contract
|
|
37
|
+
# ACTP_KERNEL_ADDRESS=0xD199070F8e9FB9a127F6Fe730Bc13300B4b3d962
|
|
38
|
+
|
|
39
|
+
# Escrow Vault contract
|
|
40
|
+
# ESCROW_VAULT_ADDRESS=0x948b9Ea081C4Cec1E112Af2e539224c531d4d585
|
|
41
|
+
|
|
42
|
+
# =============================================================================
|
|
43
|
+
# EAS (Ethereum Attestation Service)
|
|
44
|
+
# =============================================================================
|
|
45
|
+
|
|
46
|
+
# Delivery proof schema UID on Base Sepolia
|
|
47
|
+
EAS_DELIVERY_SCHEMA_UID=0x1525e033c59c1c34aa5ab5f38fc0524641835476bca08b2e5c5e076b9ba7ed84
|
|
48
|
+
|
|
49
|
+
# =============================================================================
|
|
50
|
+
# Local Development (Optional)
|
|
51
|
+
# =============================================================================
|
|
52
|
+
|
|
53
|
+
# Anvil fork URL for local blockchain testing
|
|
54
|
+
# Run: anvil --fork-url https://sepolia.base.org
|
|
55
|
+
# ANVIL_RPC_URL=http://localhost:8545
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
name: Python SDK Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, develop]
|
|
6
|
+
paths:
|
|
7
|
+
- 'src/**'
|
|
8
|
+
- 'tests/**'
|
|
9
|
+
- 'pyproject.toml'
|
|
10
|
+
- '.github/workflows/test.yml'
|
|
11
|
+
pull_request:
|
|
12
|
+
branches: [main, develop]
|
|
13
|
+
paths:
|
|
14
|
+
- 'src/**'
|
|
15
|
+
- 'tests/**'
|
|
16
|
+
- 'pyproject.toml'
|
|
17
|
+
- '.github/workflows/test.yml'
|
|
18
|
+
workflow_dispatch: # Allow manual trigger
|
|
19
|
+
|
|
20
|
+
env:
|
|
21
|
+
PYTHON_VERSION: '3.11'
|
|
22
|
+
COVERAGE_THRESHOLD: 85
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
# =============================================================================
|
|
26
|
+
# Fast Unit Tests (< 5 minutes)
|
|
27
|
+
# =============================================================================
|
|
28
|
+
test-fast:
|
|
29
|
+
name: Unit Tests
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
timeout-minutes: 10
|
|
32
|
+
|
|
33
|
+
strategy:
|
|
34
|
+
matrix:
|
|
35
|
+
python-version: ['3.9', '3.10', '3.11', '3.12']
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v4
|
|
39
|
+
|
|
40
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
41
|
+
uses: actions/setup-python@v5
|
|
42
|
+
with:
|
|
43
|
+
python-version: ${{ matrix.python-version }}
|
|
44
|
+
cache: 'pip'
|
|
45
|
+
|
|
46
|
+
- name: Install dependencies
|
|
47
|
+
run: |
|
|
48
|
+
python -m pip install --upgrade pip
|
|
49
|
+
pip install -e ".[dev]"
|
|
50
|
+
|
|
51
|
+
- name: Run unit tests
|
|
52
|
+
run: |
|
|
53
|
+
pytest tests/ \
|
|
54
|
+
--ignore=tests/integration/ \
|
|
55
|
+
--ignore=tests/benchmarks/ \
|
|
56
|
+
-v \
|
|
57
|
+
--tb=short \
|
|
58
|
+
-x # Stop on first failure
|
|
59
|
+
|
|
60
|
+
- name: Upload test results
|
|
61
|
+
uses: actions/upload-artifact@v4
|
|
62
|
+
if: failure()
|
|
63
|
+
with:
|
|
64
|
+
name: test-results-${{ matrix.python-version }}
|
|
65
|
+
path: |
|
|
66
|
+
pytest.log
|
|
67
|
+
.pytest_cache/
|
|
68
|
+
|
|
69
|
+
# =============================================================================
|
|
70
|
+
# Coverage Report
|
|
71
|
+
# =============================================================================
|
|
72
|
+
test-coverage:
|
|
73
|
+
name: Coverage Report
|
|
74
|
+
runs-on: ubuntu-latest
|
|
75
|
+
timeout-minutes: 15
|
|
76
|
+
needs: test-fast
|
|
77
|
+
|
|
78
|
+
steps:
|
|
79
|
+
- uses: actions/checkout@v4
|
|
80
|
+
|
|
81
|
+
- name: Set up Python
|
|
82
|
+
uses: actions/setup-python@v5
|
|
83
|
+
with:
|
|
84
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
85
|
+
cache: 'pip'
|
|
86
|
+
|
|
87
|
+
- name: Install dependencies
|
|
88
|
+
run: |
|
|
89
|
+
python -m pip install --upgrade pip
|
|
90
|
+
pip install -e ".[dev]"
|
|
91
|
+
pip install pytest-cov
|
|
92
|
+
|
|
93
|
+
- name: Run tests with coverage
|
|
94
|
+
run: |
|
|
95
|
+
pytest tests/ \
|
|
96
|
+
--ignore=tests/integration/ \
|
|
97
|
+
--ignore=tests/benchmarks/ \
|
|
98
|
+
--cov=src/agirails \
|
|
99
|
+
--cov-report=xml \
|
|
100
|
+
--cov-report=html \
|
|
101
|
+
--cov-report=term-missing \
|
|
102
|
+
--cov-fail-under=${{ env.COVERAGE_THRESHOLD }}
|
|
103
|
+
|
|
104
|
+
- name: Upload coverage to Codecov
|
|
105
|
+
uses: codecov/codecov-action@v4
|
|
106
|
+
with:
|
|
107
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
108
|
+
files: ./coverage.xml
|
|
109
|
+
flags: unittests
|
|
110
|
+
name: python-sdk-coverage
|
|
111
|
+
fail_ci_if_error: false
|
|
112
|
+
|
|
113
|
+
- name: Upload coverage HTML report
|
|
114
|
+
uses: actions/upload-artifact@v4
|
|
115
|
+
with:
|
|
116
|
+
name: coverage-report
|
|
117
|
+
path: htmlcov/
|
|
118
|
+
|
|
119
|
+
# =============================================================================
|
|
120
|
+
# Security Tests
|
|
121
|
+
# =============================================================================
|
|
122
|
+
test-security:
|
|
123
|
+
name: Security Tests
|
|
124
|
+
runs-on: ubuntu-latest
|
|
125
|
+
timeout-minutes: 10
|
|
126
|
+
needs: test-fast
|
|
127
|
+
|
|
128
|
+
steps:
|
|
129
|
+
- uses: actions/checkout@v4
|
|
130
|
+
|
|
131
|
+
- name: Set up Python
|
|
132
|
+
uses: actions/setup-python@v5
|
|
133
|
+
with:
|
|
134
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
135
|
+
cache: 'pip'
|
|
136
|
+
|
|
137
|
+
- name: Install dependencies
|
|
138
|
+
run: |
|
|
139
|
+
python -m pip install --upgrade pip
|
|
140
|
+
pip install -e ".[dev]"
|
|
141
|
+
pip install bandit pip-audit safety
|
|
142
|
+
|
|
143
|
+
- name: Run security tests
|
|
144
|
+
run: |
|
|
145
|
+
pytest tests/test_security/ -v --tb=short
|
|
146
|
+
|
|
147
|
+
- name: Run bandit security linter
|
|
148
|
+
run: |
|
|
149
|
+
bandit -r src/agirails -ll -ii --format json -o bandit-report.json || true
|
|
150
|
+
bandit -r src/agirails -ll -ii
|
|
151
|
+
|
|
152
|
+
- name: Run pip-audit for dependency vulnerabilities
|
|
153
|
+
run: |
|
|
154
|
+
pip-audit --format json --output pip-audit-report.json || true
|
|
155
|
+
pip-audit
|
|
156
|
+
|
|
157
|
+
- name: Upload security reports
|
|
158
|
+
uses: actions/upload-artifact@v4
|
|
159
|
+
if: always()
|
|
160
|
+
with:
|
|
161
|
+
name: security-reports
|
|
162
|
+
path: |
|
|
163
|
+
bandit-report.json
|
|
164
|
+
pip-audit-report.json
|
|
165
|
+
|
|
166
|
+
# =============================================================================
|
|
167
|
+
# Property-Based Tests (Hypothesis)
|
|
168
|
+
# =============================================================================
|
|
169
|
+
test-properties:
|
|
170
|
+
name: Property-Based Tests
|
|
171
|
+
runs-on: ubuntu-latest
|
|
172
|
+
timeout-minutes: 15
|
|
173
|
+
needs: test-fast
|
|
174
|
+
|
|
175
|
+
steps:
|
|
176
|
+
- uses: actions/checkout@v4
|
|
177
|
+
|
|
178
|
+
- name: Set up Python
|
|
179
|
+
uses: actions/setup-python@v5
|
|
180
|
+
with:
|
|
181
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
182
|
+
cache: 'pip'
|
|
183
|
+
|
|
184
|
+
- name: Install dependencies
|
|
185
|
+
run: |
|
|
186
|
+
python -m pip install --upgrade pip
|
|
187
|
+
pip install -e ".[dev]"
|
|
188
|
+
|
|
189
|
+
- name: Run property-based tests
|
|
190
|
+
run: |
|
|
191
|
+
pytest tests/test_properties/ \
|
|
192
|
+
-v \
|
|
193
|
+
--tb=short \
|
|
194
|
+
--hypothesis-show-statistics \
|
|
195
|
+
--hypothesis-seed=0 # Reproducible
|
|
196
|
+
|
|
197
|
+
# =============================================================================
|
|
198
|
+
# Parity Tests (Python <-> TypeScript SDK)
|
|
199
|
+
# =============================================================================
|
|
200
|
+
test-parity:
|
|
201
|
+
name: SDK Parity Tests
|
|
202
|
+
runs-on: ubuntu-latest
|
|
203
|
+
timeout-minutes: 10
|
|
204
|
+
needs: test-fast
|
|
205
|
+
|
|
206
|
+
steps:
|
|
207
|
+
- uses: actions/checkout@v4
|
|
208
|
+
|
|
209
|
+
- name: Set up Python
|
|
210
|
+
uses: actions/setup-python@v5
|
|
211
|
+
with:
|
|
212
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
213
|
+
cache: 'pip'
|
|
214
|
+
|
|
215
|
+
- name: Install dependencies
|
|
216
|
+
run: |
|
|
217
|
+
python -m pip install --upgrade pip
|
|
218
|
+
pip install -e ".[dev]"
|
|
219
|
+
|
|
220
|
+
- name: Run parity tests
|
|
221
|
+
run: |
|
|
222
|
+
pytest tests/test_parity.py -v --tb=short
|
|
223
|
+
|
|
224
|
+
- name: Run fixture-based parity tests
|
|
225
|
+
run: |
|
|
226
|
+
pytest tests/fixtures/ -v --tb=short || true
|
|
227
|
+
|
|
228
|
+
# =============================================================================
|
|
229
|
+
# Integration Tests (Requires Anvil - Push only)
|
|
230
|
+
# =============================================================================
|
|
231
|
+
test-integration:
|
|
232
|
+
name: Integration Tests
|
|
233
|
+
runs-on: ubuntu-latest
|
|
234
|
+
timeout-minutes: 20
|
|
235
|
+
if: github.event_name == 'push'
|
|
236
|
+
needs: [test-fast, test-security]
|
|
237
|
+
|
|
238
|
+
steps:
|
|
239
|
+
- uses: actions/checkout@v4
|
|
240
|
+
|
|
241
|
+
- name: Set up Python
|
|
242
|
+
uses: actions/setup-python@v5
|
|
243
|
+
with:
|
|
244
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
245
|
+
cache: 'pip'
|
|
246
|
+
|
|
247
|
+
- name: Install Foundry (Anvil)
|
|
248
|
+
uses: foundry-rs/foundry-toolchain@v1
|
|
249
|
+
with:
|
|
250
|
+
version: nightly
|
|
251
|
+
|
|
252
|
+
- name: Install dependencies
|
|
253
|
+
run: |
|
|
254
|
+
python -m pip install --upgrade pip
|
|
255
|
+
pip install -e ".[dev]"
|
|
256
|
+
|
|
257
|
+
- name: Start Anvil in background
|
|
258
|
+
run: |
|
|
259
|
+
anvil --fork-url ${{ secrets.BASE_SEPOLIA_RPC_URL || 'https://sepolia.base.org' }} &
|
|
260
|
+
sleep 5 # Wait for Anvil to start
|
|
261
|
+
|
|
262
|
+
- name: Run integration tests
|
|
263
|
+
env:
|
|
264
|
+
ANVIL_RPC_URL: http://localhost:8545
|
|
265
|
+
run: |
|
|
266
|
+
pytest tests/integration/ -v --tb=short || echo "Integration tests completed (some may be skipped)"
|
|
267
|
+
|
|
268
|
+
- name: Stop Anvil
|
|
269
|
+
if: always()
|
|
270
|
+
run: pkill anvil || true
|
|
271
|
+
|
|
272
|
+
# =============================================================================
|
|
273
|
+
# Benchmarks (Main only)
|
|
274
|
+
# =============================================================================
|
|
275
|
+
test-benchmarks:
|
|
276
|
+
name: Performance Benchmarks
|
|
277
|
+
runs-on: ubuntu-latest
|
|
278
|
+
timeout-minutes: 15
|
|
279
|
+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
280
|
+
needs: test-fast
|
|
281
|
+
|
|
282
|
+
steps:
|
|
283
|
+
- uses: actions/checkout@v4
|
|
284
|
+
|
|
285
|
+
- name: Set up Python
|
|
286
|
+
uses: actions/setup-python@v5
|
|
287
|
+
with:
|
|
288
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
289
|
+
cache: 'pip'
|
|
290
|
+
|
|
291
|
+
- name: Install dependencies
|
|
292
|
+
run: |
|
|
293
|
+
python -m pip install --upgrade pip
|
|
294
|
+
pip install -e ".[dev]"
|
|
295
|
+
pip install pytest-benchmark
|
|
296
|
+
|
|
297
|
+
- name: Run benchmarks
|
|
298
|
+
run: |
|
|
299
|
+
pytest tests/benchmarks/ \
|
|
300
|
+
-v \
|
|
301
|
+
--benchmark-only \
|
|
302
|
+
--benchmark-json=benchmark-results.json \
|
|
303
|
+
--benchmark-min-rounds=10 \
|
|
304
|
+
--benchmark-warmup=on
|
|
305
|
+
|
|
306
|
+
- name: Upload benchmark results
|
|
307
|
+
uses: actions/upload-artifact@v4
|
|
308
|
+
with:
|
|
309
|
+
name: benchmark-results
|
|
310
|
+
path: benchmark-results.json
|
|
311
|
+
|
|
312
|
+
- name: Store benchmark result
|
|
313
|
+
uses: benchmark-action/github-action-benchmark@v1
|
|
314
|
+
if: github.event_name == 'push'
|
|
315
|
+
with:
|
|
316
|
+
tool: 'pytest'
|
|
317
|
+
output-file-path: benchmark-results.json
|
|
318
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
319
|
+
auto-push: true
|
|
320
|
+
alert-threshold: '150%'
|
|
321
|
+
comment-on-alert: true
|
|
322
|
+
fail-on-alert: false
|
|
323
|
+
|
|
324
|
+
# =============================================================================
|
|
325
|
+
# Linting & Type Checking
|
|
326
|
+
# =============================================================================
|
|
327
|
+
lint:
|
|
328
|
+
name: Lint & Type Check
|
|
329
|
+
runs-on: ubuntu-latest
|
|
330
|
+
timeout-minutes: 5
|
|
331
|
+
|
|
332
|
+
steps:
|
|
333
|
+
- uses: actions/checkout@v4
|
|
334
|
+
|
|
335
|
+
- name: Set up Python
|
|
336
|
+
uses: actions/setup-python@v5
|
|
337
|
+
with:
|
|
338
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
|
339
|
+
cache: 'pip'
|
|
340
|
+
|
|
341
|
+
- name: Install dependencies
|
|
342
|
+
run: |
|
|
343
|
+
python -m pip install --upgrade pip
|
|
344
|
+
pip install ruff mypy
|
|
345
|
+
pip install -e ".[dev]"
|
|
346
|
+
|
|
347
|
+
- name: Run Ruff linter
|
|
348
|
+
run: |
|
|
349
|
+
ruff check src/agirails --output-format github
|
|
350
|
+
|
|
351
|
+
- name: Run Ruff formatter check
|
|
352
|
+
run: |
|
|
353
|
+
ruff format --check src/agirails
|
|
354
|
+
|
|
355
|
+
- name: Run mypy type checker
|
|
356
|
+
run: |
|
|
357
|
+
mypy src/agirails --ignore-missing-imports --no-error-summary || true
|
|
358
|
+
|
|
359
|
+
# =============================================================================
|
|
360
|
+
# Summary Job
|
|
361
|
+
# =============================================================================
|
|
362
|
+
test-summary:
|
|
363
|
+
name: Test Summary
|
|
364
|
+
runs-on: ubuntu-latest
|
|
365
|
+
needs: [test-fast, test-coverage, test-security, test-properties, test-parity, lint]
|
|
366
|
+
if: always()
|
|
367
|
+
|
|
368
|
+
steps:
|
|
369
|
+
- name: Check test results
|
|
370
|
+
run: |
|
|
371
|
+
echo "## Test Results Summary" >> $GITHUB_STEP_SUMMARY
|
|
372
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
373
|
+
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
|
|
374
|
+
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
|
|
375
|
+
echo "| Unit Tests | ${{ needs.test-fast.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
376
|
+
echo "| Coverage | ${{ needs.test-coverage.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
377
|
+
echo "| Security | ${{ needs.test-security.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
378
|
+
echo "| Properties | ${{ needs.test-properties.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
379
|
+
echo "| Parity | ${{ needs.test-parity.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
380
|
+
echo "| Lint | ${{ needs.lint.result }} |" >> $GITHUB_STEP_SUMMARY
|
|
381
|
+
|
|
382
|
+
- name: Fail if any required job failed
|
|
383
|
+
if: |
|
|
384
|
+
needs.test-fast.result == 'failure' ||
|
|
385
|
+
needs.test-coverage.result == 'failure' ||
|
|
386
|
+
needs.test-security.result == 'failure' ||
|
|
387
|
+
needs.lint.result == 'failure'
|
|
388
|
+
run: exit 1
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
*.egg-info/
|
|
24
|
+
.installed.cfg
|
|
25
|
+
*.egg
|
|
26
|
+
|
|
27
|
+
# PyInstaller
|
|
28
|
+
*.manifest
|
|
29
|
+
*.spec
|
|
30
|
+
|
|
31
|
+
# Installer logs
|
|
32
|
+
pip-log.txt
|
|
33
|
+
pip-delete-this-directory.txt
|
|
34
|
+
|
|
35
|
+
# Unit test / coverage reports
|
|
36
|
+
htmlcov/
|
|
37
|
+
.tox/
|
|
38
|
+
.nox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*.cover
|
|
45
|
+
*.py,cover
|
|
46
|
+
.hypothesis/
|
|
47
|
+
.pytest_cache/
|
|
48
|
+
|
|
49
|
+
# Translations
|
|
50
|
+
*.mo
|
|
51
|
+
*.pot
|
|
52
|
+
|
|
53
|
+
# Environments
|
|
54
|
+
.env
|
|
55
|
+
.venv
|
|
56
|
+
env/
|
|
57
|
+
venv/
|
|
58
|
+
ENV/
|
|
59
|
+
env.bak/
|
|
60
|
+
venv.bak/
|
|
61
|
+
|
|
62
|
+
# IDE
|
|
63
|
+
.idea/
|
|
64
|
+
.vscode/
|
|
65
|
+
*.swp
|
|
66
|
+
*.swo
|
|
67
|
+
*~
|
|
68
|
+
|
|
69
|
+
# mypy
|
|
70
|
+
.mypy_cache/
|
|
71
|
+
.dmypy.json
|
|
72
|
+
dmypy.json
|
|
73
|
+
|
|
74
|
+
# ruff
|
|
75
|
+
.ruff_cache/
|
|
76
|
+
|
|
77
|
+
# ACTP mock state (created by MockRuntime)
|
|
78
|
+
.actp/
|
|
79
|
+
|
|
80
|
+
# OS
|
|
81
|
+
.DS_Store
|
|
82
|
+
Thumbs.db
|
|
83
|
+
|
|
84
|
+
# Secrets - never commit
|
|
85
|
+
*.pem
|
|
86
|
+
*.key
|
|
87
|
+
.env.local
|
|
88
|
+
.env.*.local
|
|
89
|
+
secrets.json
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to AGIRAILS Python SDK will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2024-12-25
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
#### Core SDK
|
|
13
|
+
- `ACTPClient` - Main client with factory pattern and three-tier API access
|
|
14
|
+
- `ACTPClientConfig` - Configuration dataclass for client initialization
|
|
15
|
+
- `ACTPClientMode` - Enum for mock/blockchain modes
|
|
16
|
+
|
|
17
|
+
#### Adapters
|
|
18
|
+
- `BasicAdapter` - Simple `pay()` method for quick payments
|
|
19
|
+
- `StandardAdapter` - Full lifecycle control with explicit steps
|
|
20
|
+
- `BaseAdapter` - Shared utilities for amount/deadline parsing
|
|
21
|
+
|
|
22
|
+
#### Runtime Layer
|
|
23
|
+
- `MockRuntime` - Complete mock implementation for local testing
|
|
24
|
+
- `MockStateManager` - File-based state persistence with atomic locking
|
|
25
|
+
- `IACTPRuntime` - Abstract interface for runtime implementations
|
|
26
|
+
- 8-state transaction lifecycle (INITIATED, QUOTED, COMMITTED, IN_PROGRESS, DELIVERED, SETTLED, DISPUTED, CANCELLED)
|
|
27
|
+
|
|
28
|
+
#### Error Hierarchy (24 exception types)
|
|
29
|
+
- `ACTPError` - Base exception with structured error codes
|
|
30
|
+
- Transaction errors: `TransactionNotFoundError`, `InvalidStateTransitionError`, `EscrowNotFoundError`
|
|
31
|
+
- Validation errors: `ValidationError`, `InvalidAddressError`, `InvalidAmountError`
|
|
32
|
+
- Network errors: `NetworkError`, `TransactionRevertedError`, `SignatureVerificationError`
|
|
33
|
+
- Storage errors: `StorageError`, `InvalidCIDError`, `UploadTimeoutError`, `DownloadTimeoutError`
|
|
34
|
+
- Agent errors: `NoProviderFoundError`, `ProviderRejectedError`, `DeliveryFailedError`
|
|
35
|
+
- Mock errors: `MockStateCorruptedError`, `MockStateVersionError`, `MockStateLockError`
|
|
36
|
+
|
|
37
|
+
#### Utilities
|
|
38
|
+
- `NonceTracker` - Thread-safe nonce management for Ethereum transactions
|
|
39
|
+
- `Logger` - Structured logging with JSON output support
|
|
40
|
+
- `LRUCache` - Generic LRU cache with size limits
|
|
41
|
+
- `Semaphore` / `RateLimiter` - Concurrency control primitives
|
|
42
|
+
- Security utilities: `timing_safe_equal()`, `validate_path()`, `safe_json_parse()`
|
|
43
|
+
- Helpers: `USDC`, `Deadline`, `Address`, `Bytes32`, `StateHelper`, `DisputeWindow`
|
|
44
|
+
|
|
45
|
+
#### Level 0 API (Low-level Primitives)
|
|
46
|
+
- `ServiceDirectory` - Service registration and discovery
|
|
47
|
+
- `ServiceEntry` / `ServiceQuery` - Service metadata and filtering
|
|
48
|
+
- `Provider` / `ProviderConfig` - Provider management
|
|
49
|
+
- `request()` / `provide()` - Core request/provide functions
|
|
50
|
+
|
|
51
|
+
#### Level 1 API (Agent Framework)
|
|
52
|
+
- `Agent` / `AgentConfig` - Agent abstraction with lifecycle management
|
|
53
|
+
- `Job` / `JobContext` / `JobHandler` - Job handling framework
|
|
54
|
+
- `PricingStrategy` / `CostModel` - Flexible pricing calculations
|
|
55
|
+
- `ServiceConfig` / `ServiceFilter` - Service configuration
|
|
56
|
+
|
|
57
|
+
#### Types
|
|
58
|
+
- `AgentDID` / `DIDDocument` - Decentralized identity types
|
|
59
|
+
- `Transaction` / `TransactionState` / `TransactionReceipt` - Transaction types
|
|
60
|
+
- `EIP712Domain` / `SignedMessage` / `TypedData` - EIP-712 signing types
|
|
61
|
+
- `ServiceRequest` / `ServiceResponse` / `DeliveryProof` - Message types
|
|
62
|
+
|
|
63
|
+
#### Testing
|
|
64
|
+
- 337 unit tests covering all modules
|
|
65
|
+
- Async test support with pytest-asyncio
|
|
66
|
+
- Mock runtime enables testing without blockchain
|
|
67
|
+
|
|
68
|
+
### Changed
|
|
69
|
+
- Full Python 3.9 compatibility (previously required 3.10+)
|
|
70
|
+
- All type annotations now use `Optional[]`, `Union[]`, `List[]`, `Dict[]` from typing module
|
|
71
|
+
- Added `from __future__ import annotations` for deferred evaluation
|
|
72
|
+
|
|
73
|
+
### Security
|
|
74
|
+
- Added `timing_safe_equal()` for constant-time signature verification
|
|
75
|
+
- Added `safe_json_parse()` to prevent prototype pollution attacks
|
|
76
|
+
- Added `validate_path()` to prevent directory traversal attacks
|
|
77
|
+
- Added query cap limits (`QueryCapExceededError`) for DoS prevention
|
|
78
|
+
- File locking in `MockStateManager` for atomic state operations
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
- Signature verification now emits warning instead of silently passing on missing crypto
|
|
82
|
+
|
|
83
|
+
### Developer Experience
|
|
84
|
+
- Comprehensive docstrings with usage examples
|
|
85
|
+
- Type hints throughout codebase
|
|
86
|
+
- Structured error codes for programmatic error handling
|
|
87
|
+
- Three-tier API for different experience levels
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## [Unreleased]
|
|
92
|
+
|
|
93
|
+
### Planned for 2.1.0
|
|
94
|
+
- `BlockchainRuntime` - Real blockchain integration
|
|
95
|
+
- CLI tool implementation (`actp` command)
|
|
96
|
+
- EAS attestation integration
|
|
97
|
+
- Gas estimation and optimization
|
|
98
|
+
|
|
99
|
+
### Planned for 2.2.0
|
|
100
|
+
- WebSocket event streaming
|
|
101
|
+
- Transaction batching
|
|
102
|
+
- Multi-chain support
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Version History
|
|
107
|
+
|
|
108
|
+
| Version | Date | Highlights |
|
|
109
|
+
|---------|------|------------|
|
|
110
|
+
| 2.0.0 | 2024-12-25 | Initial v2 release with Python 3.9 support |
|