Files
RSSuper/check-identity.js

65 lines
1.6 KiB
JavaScript

const http = require('http');
const agentId = process.env.PAPERCLIP_AGENT_ID;
const apiKey = process.env.PAPERCLIP_API_KEY;
const apiUrl = process.env.PAPERCLIP_API_URL;
const runId = process.env.PAPERCLIP_RUN_ID;
console.log('Agent ID:', agentId);
console.log('API URL:', apiUrl);
console.log('Run ID:', runId);
if (!apiKey || !apiUrl) {
console.error('Missing environment variables');
process.exit(1);
}
function fetch(url, options = {}) {
return new Promise((resolve, reject) => {
const request = http.request({
hostname: new URL(url).hostname,
port: new URL(url).port,
path: new URL(url).pathname,
method: options.method || 'GET',
headers: {
'Authorization': `Bearer ${apiKey}`,
'X-Paperclip-Run-Id': runId,
...options.headers
}
}, (response) => {
let data = '';
response.on('data', chunk => data += chunk);
response.on('end', () => {
try {
resolve(JSON.parse(data));
} catch {
resolve(data);
}
});
});
request.on('error', reject);
request.end();
});
}
async function main() {
console.log('\n=== FETCHING AGENT IDENTITY ===\n');
try {
const identity = await fetch(`${apiUrl}/api/agents/me`);
console.log(JSON.stringify(identity, null, 2));
} catch (err) {
console.error('Error fetching identity:', err.message);
}
console.log('\n=== FETCHING INBOX-LITE ===\n');
try {
const inbox = await fetch(`${apiUrl}/api/agents/${agentId}/inbox-lite`);
console.log(JSON.stringify(inbox, null, 2));
} catch (err) {
console.error('Error fetching inbox:', err.message);
}
}
main();