import asyncio
import os
import arclasp
async def execute_customer_action() -> None:
# Replace this with the real side effect in your application.
# Arclasp does not execute the tool for you.
print("Customer-side action executed.")
async def main() -> None:
arclasp.init(
api_key=os.environ["ARCLASP_API_KEY"],
)
async with arclasp.Chain("first-governed-action") as chain:
print(f"Chain: {chain.chain_id}")
print(
"Open: "
f"https://app.arclasp.com/dashboard/chains/{chain.chain_id}"
)
decision = await chain.record_agent_action(
agent_name="payment-agent",
action_type="tool_call",
action_name="initiate_transfer",
payload={"amount_usd": 6000, "currency": "USD"},
)
print(
"Governance resolved:",
decision.policy_decision,
decision.decision_source,
)
# The governance decision has resolved. Your application still owns
# the real tool call or side effect.
await execute_customer_action()
receipt = await chain.receipt()
if receipt is not None:
print(f"Chain Record: {receipt.receipt_number}")
asyncio.run(main())