36 lines
1.0 KiB
Python
36 lines
1.0 KiB
Python
import urllib.request
|
|
import json
|
|
import os
|
|
|
|
agentId = os.environ.get('PAPERCLIP_AGENT_ID', 'unknown')
|
|
apiKey = os.environ.get('PAPERCLIP_API_KEY', '')
|
|
apiUrl = os.environ.get('PAPERCLIP_API_URL', '')
|
|
runId = os.environ.get('PAPERCLIP_RUN_ID', '')
|
|
|
|
print(f'Agent ID: {agentId}')
|
|
print(f'API URL: {apiUrl}')
|
|
print(f'Run ID: {runId}')
|
|
|
|
if not apiKey or not apiUrl:
|
|
print('Missing environment variables')
|
|
exit(1)
|
|
|
|
def fetch(url, method='GET', headers=None):
|
|
req = urllib.request.Request(url, method=method)
|
|
if headers:
|
|
for k, v in headers.items():
|
|
req.add_header(k, str(v))
|
|
try:
|
|
with urllib.request.urlopen(req) as resp:
|
|
return json.loads(resp.read().decode())
|
|
except Exception as e:
|
|
print(f'Error: {e}')
|
|
return None
|
|
|
|
print('\n=== FETCHING AGENT IDENTITY ===\n')
|
|
identity = fetch(f'{apiUrl}/api/agents/me')
|
|
print(json.dumps(identity or {}, indent=2))
|
|
|
|
print('\n=== FETCHING INBOX-LITE ===\n')
|
|
inbox = fetch(f'{apiUrl}/api/agents/{agentId}/inbox-lite')
|
|
print(json.dumps(inbox or {}, indent=2)) |