import { VaultGraph } from '@vaultgraph/sdk';
// 1. Initialize the client with your vendor key
const client = new VaultGraph({
apiKey: process.env.VAULTGRAPH_API_KEY,
privateKey: process.env.VENDOR_PRIVATE_KEY, // Used to sign receipts locally
});
async function onAgentCompletion(job) {
// 2. Your agent finishes work
const result = await myAgent.run(job.input);
// 3. Create and submit a verifiable receipt
const receipt = await client.receipts.create({
agentId: 'agent_refund_bot_v1',
consumerId: 'org_acme_corp',
jobId: job.id,
// The outcome you want to prove
status: 'success',
metadata: {
latencyMs: 450,
tokensUsed: 120,
costUsd: 0.02
},
// Privacy-preserving verification
// You keep the transcript; VaultGraph only stores the hash
contextHash: client.utils.hash(job.transcript),
});
console.log(`Receipt minted: ${receipt.id}`);
}