@t2000/engine 0.36.1 → 0.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +34 -54
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2394,9 +2394,17 @@ var InvoiceSchema = z.object({
|
|
|
2394
2394
|
amount: z.number().positive()
|
|
2395
2395
|
})).optional().describe("Line items. If omitted, a single line item matching the total is implied.")
|
|
2396
2396
|
});
|
|
2397
|
+
function internalHeaders(context) {
|
|
2398
|
+
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2399
|
+
return {
|
|
2400
|
+
"Content-Type": "application/json",
|
|
2401
|
+
"x-sui-address": context.walletAddress ?? "",
|
|
2402
|
+
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2397
2405
|
var createPaymentLinkTool = buildTool({
|
|
2398
2406
|
name: "create_payment_link",
|
|
2399
|
-
description: 'Create a shareable payment link so someone can send USDC to the user. Returns a URL the user can share. Use when the user says "create a payment link", "generate a payment link", "I want to get paid", or similar.',
|
|
2407
|
+
description: 'Create a shareable payment link so someone can send USDC to the user. Returns a URL the user can share. Payers can connect their wallet, scan a QR code, or send manually. Use when the user says "create a payment link", "generate a payment link", "I want to get paid", or similar.',
|
|
2400
2408
|
inputSchema: PaymentLinkSchema,
|
|
2401
2409
|
jsonSchema: {
|
|
2402
2410
|
type: "object",
|
|
@@ -2411,20 +2419,15 @@ var createPaymentLinkTool = buildTool({
|
|
|
2411
2419
|
isReadOnly: true,
|
|
2412
2420
|
async call(input, context) {
|
|
2413
2421
|
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2414
|
-
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2415
2422
|
if (!apiUrl || !context.walletAddress) {
|
|
2416
2423
|
return { data: null, displayText: "Payment link creation is not available." };
|
|
2417
2424
|
}
|
|
2418
2425
|
try {
|
|
2419
|
-
const res = await fetch(`${apiUrl}/api/internal/
|
|
2426
|
+
const res = await fetch(`${apiUrl}/api/internal/payments`, {
|
|
2420
2427
|
method: "POST",
|
|
2421
2428
|
signal: context.signal,
|
|
2422
|
-
headers:
|
|
2423
|
-
|
|
2424
|
-
"x-sui-address": context.walletAddress,
|
|
2425
|
-
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2426
|
-
},
|
|
2427
|
-
body: JSON.stringify(input)
|
|
2429
|
+
headers: internalHeaders(context),
|
|
2430
|
+
body: JSON.stringify({ ...input, type: "link" })
|
|
2428
2431
|
});
|
|
2429
2432
|
if (!res.ok) {
|
|
2430
2433
|
const err = await res.json().catch(() => ({}));
|
|
@@ -2434,7 +2437,7 @@ var createPaymentLinkTool = buildTool({
|
|
|
2434
2437
|
const amountStr = link.amount != null ? `$${link.amount.toFixed(2)} ${link.currency}` : `any amount ${link.currency}`;
|
|
2435
2438
|
return {
|
|
2436
2439
|
data: link,
|
|
2437
|
-
displayText: `Payment link created for ${amountStr}${link.label ? ` \u2014 ${link.label}` : ""}. Share: ${link.url}`
|
|
2440
|
+
displayText: `Payment link created for ${amountStr}${link.label ? ` \u2014 ${link.label}` : ""}. Payers can connect their wallet, scan the QR code, or send manually. Share: ${link.url}`
|
|
2438
2441
|
};
|
|
2439
2442
|
} catch {
|
|
2440
2443
|
return { data: null, displayText: "Failed to create payment link." };
|
|
@@ -2449,33 +2452,29 @@ var listPaymentLinksTool = buildTool({
|
|
|
2449
2452
|
isReadOnly: true,
|
|
2450
2453
|
async call(_input, context) {
|
|
2451
2454
|
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2452
|
-
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2453
2455
|
if (!apiUrl || !context.walletAddress) {
|
|
2454
|
-
return { data: {
|
|
2456
|
+
return { data: { payments: [] }, displayText: "No payment links found." };
|
|
2455
2457
|
}
|
|
2456
2458
|
try {
|
|
2457
|
-
const res = await fetch(`${apiUrl}/api/internal/
|
|
2459
|
+
const res = await fetch(`${apiUrl}/api/internal/payments?type=link`, {
|
|
2458
2460
|
signal: context.signal,
|
|
2459
|
-
headers:
|
|
2460
|
-
"x-sui-address": context.walletAddress,
|
|
2461
|
-
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2462
|
-
}
|
|
2461
|
+
headers: internalHeaders(context)
|
|
2463
2462
|
});
|
|
2464
|
-
if (!res.ok) return { data: {
|
|
2463
|
+
if (!res.ok) return { data: { payments: [] }, displayText: "Could not fetch payment links." };
|
|
2465
2464
|
const data = await res.json();
|
|
2466
|
-
const count = data.
|
|
2465
|
+
const count = data.payments.length;
|
|
2467
2466
|
return {
|
|
2468
2467
|
data,
|
|
2469
2468
|
displayText: count === 0 ? "No payment links yet." : `${count} payment link${count !== 1 ? "s" : ""} found.`
|
|
2470
2469
|
};
|
|
2471
2470
|
} catch {
|
|
2472
|
-
return { data: {
|
|
2471
|
+
return { data: { payments: [] }, displayText: "Could not fetch payment links." };
|
|
2473
2472
|
}
|
|
2474
2473
|
}
|
|
2475
2474
|
});
|
|
2476
2475
|
var createInvoiceTool = buildTool({
|
|
2477
2476
|
name: "create_invoice",
|
|
2478
|
-
description: 'Create a formal invoice that the user can share with a client or customer. Returns a URL for the invoice page. Use when the user says "create an invoice", "generate an invoice", "bill a client", or similar.',
|
|
2477
|
+
description: 'Create a formal invoice that the user can share with a client or customer. Returns a URL for the invoice page. Payers can connect their wallet, scan a QR code, or send manually. Use when the user says "create an invoice", "generate an invoice", "bill a client", or similar.',
|
|
2479
2478
|
inputSchema: InvoiceSchema,
|
|
2480
2479
|
jsonSchema: {
|
|
2481
2480
|
type: "object",
|
|
@@ -2504,20 +2503,15 @@ var createInvoiceTool = buildTool({
|
|
|
2504
2503
|
isReadOnly: true,
|
|
2505
2504
|
async call(input, context) {
|
|
2506
2505
|
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2507
|
-
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2508
2506
|
if (!apiUrl || !context.walletAddress) {
|
|
2509
2507
|
return { data: null, displayText: "Invoice creation is not available." };
|
|
2510
2508
|
}
|
|
2511
2509
|
try {
|
|
2512
|
-
const res = await fetch(`${apiUrl}/api/internal/
|
|
2510
|
+
const res = await fetch(`${apiUrl}/api/internal/payments`, {
|
|
2513
2511
|
method: "POST",
|
|
2514
2512
|
signal: context.signal,
|
|
2515
|
-
headers:
|
|
2516
|
-
|
|
2517
|
-
"x-sui-address": context.walletAddress,
|
|
2518
|
-
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2519
|
-
},
|
|
2520
|
-
body: JSON.stringify(input)
|
|
2513
|
+
headers: internalHeaders(context),
|
|
2514
|
+
body: JSON.stringify({ ...input, type: "invoice" })
|
|
2521
2515
|
});
|
|
2522
2516
|
if (!res.ok) {
|
|
2523
2517
|
const err = await res.json().catch(() => ({}));
|
|
@@ -2527,7 +2521,7 @@ var createInvoiceTool = buildTool({
|
|
|
2527
2521
|
const dueStr = invoice.dueDate ? ` due ${new Date(invoice.dueDate).toLocaleDateString()}` : "";
|
|
2528
2522
|
return {
|
|
2529
2523
|
data: invoice,
|
|
2530
|
-
displayText: `Invoice created for $${invoice.amount.toFixed(2)} ${invoice.currency}${dueStr} \u2014 ${invoice.label}. Share: ${invoice.url}`
|
|
2524
|
+
displayText: `Invoice created for $${invoice.amount.toFixed(2)} ${invoice.currency}${dueStr} \u2014 ${invoice.label}. Payers can connect their wallet, scan the QR code, or send manually. Share: ${invoice.url}`
|
|
2531
2525
|
};
|
|
2532
2526
|
} catch {
|
|
2533
2527
|
return { data: null, displayText: "Failed to create invoice." };
|
|
@@ -2550,19 +2544,14 @@ var cancelPaymentLinkTool = buildTool({
|
|
|
2550
2544
|
isReadOnly: true,
|
|
2551
2545
|
async call(input, context) {
|
|
2552
2546
|
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2553
|
-
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2554
2547
|
if (!apiUrl || !context.walletAddress) {
|
|
2555
2548
|
return { data: null, displayText: "Payment link cancellation is not available." };
|
|
2556
2549
|
}
|
|
2557
2550
|
try {
|
|
2558
|
-
const res = await fetch(`${apiUrl}/api/internal/
|
|
2551
|
+
const res = await fetch(`${apiUrl}/api/internal/payments`, {
|
|
2559
2552
|
method: "PATCH",
|
|
2560
2553
|
signal: context.signal,
|
|
2561
|
-
headers:
|
|
2562
|
-
"Content-Type": "application/json",
|
|
2563
|
-
"x-sui-address": context.walletAddress,
|
|
2564
|
-
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2565
|
-
},
|
|
2554
|
+
headers: internalHeaders(context),
|
|
2566
2555
|
body: JSON.stringify({ slug: input.slug, action: "cancel" })
|
|
2567
2556
|
});
|
|
2568
2557
|
if (!res.ok) {
|
|
@@ -2595,19 +2584,14 @@ var cancelInvoiceTool = buildTool({
|
|
|
2595
2584
|
isReadOnly: true,
|
|
2596
2585
|
async call(input, context) {
|
|
2597
2586
|
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2598
|
-
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2599
2587
|
if (!apiUrl || !context.walletAddress) {
|
|
2600
2588
|
return { data: null, displayText: "Invoice cancellation is not available." };
|
|
2601
2589
|
}
|
|
2602
2590
|
try {
|
|
2603
|
-
const res = await fetch(`${apiUrl}/api/internal/
|
|
2591
|
+
const res = await fetch(`${apiUrl}/api/internal/payments`, {
|
|
2604
2592
|
method: "PATCH",
|
|
2605
2593
|
signal: context.signal,
|
|
2606
|
-
headers:
|
|
2607
|
-
"Content-Type": "application/json",
|
|
2608
|
-
"x-sui-address": context.walletAddress,
|
|
2609
|
-
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2610
|
-
},
|
|
2594
|
+
headers: internalHeaders(context),
|
|
2611
2595
|
body: JSON.stringify({ slug: input.slug, action: "cancel" })
|
|
2612
2596
|
});
|
|
2613
2597
|
if (!res.ok) {
|
|
@@ -2632,27 +2616,23 @@ var listInvoicesTool = buildTool({
|
|
|
2632
2616
|
isReadOnly: true,
|
|
2633
2617
|
async call(_input, context) {
|
|
2634
2618
|
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2635
|
-
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2636
2619
|
if (!apiUrl || !context.walletAddress) {
|
|
2637
|
-
return { data: {
|
|
2620
|
+
return { data: { payments: [] }, displayText: "No invoices found." };
|
|
2638
2621
|
}
|
|
2639
2622
|
try {
|
|
2640
|
-
const res = await fetch(`${apiUrl}/api/internal/
|
|
2623
|
+
const res = await fetch(`${apiUrl}/api/internal/payments?type=invoice`, {
|
|
2641
2624
|
signal: context.signal,
|
|
2642
|
-
headers:
|
|
2643
|
-
"x-sui-address": context.walletAddress,
|
|
2644
|
-
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2645
|
-
}
|
|
2625
|
+
headers: internalHeaders(context)
|
|
2646
2626
|
});
|
|
2647
|
-
if (!res.ok) return { data: {
|
|
2627
|
+
if (!res.ok) return { data: { payments: [] }, displayText: "Could not fetch invoices." };
|
|
2648
2628
|
const data = await res.json();
|
|
2649
|
-
const count = data.
|
|
2629
|
+
const count = data.payments.length;
|
|
2650
2630
|
return {
|
|
2651
2631
|
data,
|
|
2652
2632
|
displayText: count === 0 ? "No invoices yet." : `${count} invoice${count !== 1 ? "s" : ""} found.`
|
|
2653
2633
|
};
|
|
2654
2634
|
} catch {
|
|
2655
|
-
return { data: {
|
|
2635
|
+
return { data: { payments: [] }, displayText: "Could not fetch invoices." };
|
|
2656
2636
|
}
|
|
2657
2637
|
}
|
|
2658
2638
|
});
|