fix: update agent and wallet API endpoints, improve RPC error handling, and mark additional CLI commands as working
- Update agent execute endpoint to use /v1/agents/workflows/{id}/execute path
- Add workflow_id and inputs fields to agent creation and execution payloads
- Accept both 200 and 201 status codes for agent create, network create, and contribution submit
- Update wallet balance and send RPC endpoints to use rstrip('/') instead of replace('/api', '')
- Add chain_id parameter to wallet R
This commit is contained in:
@@ -35,6 +35,8 @@ def create(ctx, name: str, description: str, workflow_file, verification: str,
|
||||
"name": name,
|
||||
"description": description,
|
||||
"verification_level": verification,
|
||||
"workflow_id": agent_id,
|
||||
"inputs": {},
|
||||
"max_execution_time": max_execution_time,
|
||||
"max_cost_budget": max_cost_budget
|
||||
}
|
||||
@@ -55,7 +57,7 @@ def create(ctx, name: str, description: str, workflow_file, verification: str,
|
||||
json=workflow_data
|
||||
)
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code in (200, 201):
|
||||
workflow = response.json()
|
||||
success(f"Agent workflow created: {workflow['id']}")
|
||||
output(workflow, ctx.obj['output_format'])
|
||||
@@ -126,6 +128,8 @@ def execute(ctx, agent_id: str, inputs, verification: str, priority: str, timeou
|
||||
# Prepare execution data
|
||||
execution_data = {
|
||||
"verification_level": verification,
|
||||
"workflow_id": agent_id,
|
||||
"inputs": {},
|
||||
"priority": priority,
|
||||
"timeout_seconds": timeout
|
||||
}
|
||||
@@ -141,7 +145,7 @@ def execute(ctx, agent_id: str, inputs, verification: str, priority: str, timeou
|
||||
try:
|
||||
with httpx.Client() as client:
|
||||
response = client.post(
|
||||
f"{config.coordinator_url}/agents/{agent_id}/execute",
|
||||
f"{config.coordinator_url}/v1/agents/workflows/{agent_id}/execute",
|
||||
headers={"X-Api-Key": config.api_key or ""},
|
||||
json=execution_data
|
||||
)
|
||||
@@ -297,7 +301,7 @@ def create(ctx, name: str, agents: str, description: str, coordination: str):
|
||||
json=network_data
|
||||
)
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code in (200, 201):
|
||||
network = response.json()
|
||||
success(f"Agent network created: {network['id']}")
|
||||
output(network, ctx.obj['output_format'])
|
||||
@@ -610,7 +614,7 @@ def submit_contribution(ctx, type: str, description: str, github_repo: str, bran
|
||||
json=contribution_data
|
||||
)
|
||||
|
||||
if response.status_code == 201:
|
||||
if response.status_code in (200, 201):
|
||||
result = response.json()
|
||||
success(f"Contribution submitted: {result['id']}")
|
||||
output(result, ctx.obj['output_format'])
|
||||
|
||||
@@ -488,7 +488,7 @@ def balance(ctx):
|
||||
try:
|
||||
with httpx.Client() as client:
|
||||
response = client.get(
|
||||
f"{config.coordinator_url.replace('/api', '')}/rpc/balance/{wallet_data['address']}",
|
||||
f"{config.coordinator_url.rstrip('/')}/rpc/balance/{wallet_data['address']}?chain_id=ait-devnet",
|
||||
timeout=5,
|
||||
)
|
||||
|
||||
@@ -515,7 +515,7 @@ def balance(ctx):
|
||||
"wallet": wallet_name,
|
||||
"address": wallet_data["address"],
|
||||
"balance": wallet_data.get("balance", 0),
|
||||
"note": "Local balance only (blockchain not accessible)",
|
||||
"note": "Local balance (blockchain RPC not available)",
|
||||
},
|
||||
ctx.obj.get("output_format", "table"),
|
||||
)
|
||||
@@ -702,12 +702,13 @@ def send(ctx, to_address: str, amount: float, description: Optional[str]):
|
||||
try:
|
||||
with httpx.Client() as client:
|
||||
response = client.post(
|
||||
f"{config.coordinator_url.replace('/api', '')}/rpc/transactions",
|
||||
f"{config.coordinator_url.rstrip('/')}/rpc/transactions",
|
||||
json={
|
||||
"from": wallet_data["address"],
|
||||
"to": to_address,
|
||||
"amount": amount,
|
||||
"description": description or "",
|
||||
"chain_id": "ait-devnet",
|
||||
},
|
||||
headers={"X-Api-Key": getattr(config, "api_key", "") or ""},
|
||||
)
|
||||
@@ -774,7 +775,7 @@ def send(ctx, to_address: str, amount: float, description: Optional[str]):
|
||||
"amount": amount,
|
||||
"to": to_address,
|
||||
"new_balance": wallet_data["balance"],
|
||||
"note": "Transaction recorded locally (pending blockchain confirmation)",
|
||||
"note": "Transaction recorded locally (blockchain RPC not available)",
|
||||
},
|
||||
ctx.obj.get("output_format", "table"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user