Add AI agent capabilities and integrate with Anthropic and LNbits

Integrate Anthropic AI for agent capabilities, introduce database schemas for jobs and invoices, and set up LNbits for payment processing.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 418bf6f8-212b-4bb0-a7a5-8231a061da4e
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: cce28acc-aeac-46ff-80ec-af4ade39e30f
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
alexpaynex
2026-03-18 14:59:02 +00:00
parent 90354c5034
commit b095efcfd3
20 changed files with 719 additions and 20 deletions

View File

@@ -0,0 +1,87 @@
const LNBITS_URL = process.env.LNBITS_URL;
const LNBITS_API_KEY = process.env.LNBITS_API_KEY;
function getBaseUrl(): string {
if (!LNBITS_URL) {
throw new Error("LNBITS_URL environment variable is not set");
}
return LNBITS_URL.replace(/\/$/, "");
}
function getHeaders(): Record<string, string> {
if (!LNBITS_API_KEY) {
throw new Error("LNBITS_API_KEY environment variable is not set");
}
return {
"Content-Type": "application/json",
"X-Api-Key": LNBITS_API_KEY,
};
}
export interface LNbitsInvoice {
paymentHash: string;
paymentRequest: string;
}
export interface LNbitsInvoiceStatus {
paid: boolean;
paidAt?: Date;
}
export async function createInvoice(
amountSats: number,
memo: string,
): Promise<LNbitsInvoice> {
const baseUrl = getBaseUrl();
const response = await fetch(`${baseUrl}/api/v1/payments`, {
method: "POST",
headers: getHeaders(),
body: JSON.stringify({
out: false,
amount: amountSats,
memo,
}),
});
if (!response.ok) {
const body = await response.text();
throw new Error(`LNbits createInvoice failed (${response.status}): ${body}`);
}
const data = (await response.json()) as {
payment_hash: string;
payment_request: string;
};
return {
paymentHash: data.payment_hash,
paymentRequest: data.payment_request,
};
}
export async function checkInvoicePaid(
paymentHash: string,
): Promise<LNbitsInvoiceStatus> {
const baseUrl = getBaseUrl();
const response = await fetch(`${baseUrl}/api/v1/payments/${paymentHash}`, {
method: "GET",
headers: getHeaders(),
});
if (!response.ok) {
const body = await response.text();
throw new Error(`LNbits checkInvoice failed (${response.status}): ${body}`);
}
const data = (await response.json()) as {
paid: boolean;
details?: { time?: number };
};
return {
paid: data.paid,
paidAt: data.paid && data.details?.time
? new Date(data.details.time * 1000)
: undefined,
};
}