@t2000/engine 0.36.2 → 0.36.4
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 +19 -17
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2377,7 +2377,7 @@ var updatePermissionsTool = buildTool({
|
|
|
2377
2377
|
}
|
|
2378
2378
|
});
|
|
2379
2379
|
var PaymentLinkSchema = z.object({
|
|
2380
|
-
amount: z.number().positive().
|
|
2380
|
+
amount: z.number().positive().describe("Amount in USDC (required). Ask the user if not specified."),
|
|
2381
2381
|
label: z.string().optional().describe('Human-readable label e.g. "Consulting fee March"'),
|
|
2382
2382
|
memo: z.string().optional().describe("Optional note shown to the payer"),
|
|
2383
2383
|
expiresInHours: z.number().positive().optional().describe("Hours until the link expires. Omit for permanent links.")
|
|
@@ -2404,17 +2404,17 @@ function internalHeaders(context) {
|
|
|
2404
2404
|
}
|
|
2405
2405
|
var createPaymentLinkTool = buildTool({
|
|
2406
2406
|
name: "create_payment_link",
|
|
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.',
|
|
2407
|
+
description: 'Create a shareable payment link so someone can send USDC to the user. Amount is required \u2014 ask the user for the amount if not specified. 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.',
|
|
2408
2408
|
inputSchema: PaymentLinkSchema,
|
|
2409
2409
|
jsonSchema: {
|
|
2410
2410
|
type: "object",
|
|
2411
2411
|
properties: {
|
|
2412
|
-
amount: { type: "number", description: "Amount in USDC.
|
|
2412
|
+
amount: { type: "number", description: "Amount in USDC (required). Ask the user if not specified." },
|
|
2413
2413
|
label: { type: "string", description: 'Human-readable label e.g. "Consulting fee March"' },
|
|
2414
2414
|
memo: { type: "string", description: "Optional note shown to the payer" },
|
|
2415
2415
|
expiresInHours: { type: "number", description: "Hours until the link expires. Omit for permanent links." }
|
|
2416
2416
|
},
|
|
2417
|
-
required: []
|
|
2417
|
+
required: ["amount"]
|
|
2418
2418
|
},
|
|
2419
2419
|
isReadOnly: true,
|
|
2420
2420
|
async call(input, context) {
|
|
@@ -2434,7 +2434,7 @@ var createPaymentLinkTool = buildTool({
|
|
|
2434
2434
|
return { data: null, displayText: err.error ?? "Failed to create payment link." };
|
|
2435
2435
|
}
|
|
2436
2436
|
const link = await res.json();
|
|
2437
|
-
const amountStr =
|
|
2437
|
+
const amountStr = `$${link.amount.toFixed(2)} ${link.currency}`;
|
|
2438
2438
|
return {
|
|
2439
2439
|
data: link,
|
|
2440
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}`
|
|
@@ -2453,22 +2453,23 @@ var listPaymentLinksTool = buildTool({
|
|
|
2453
2453
|
async call(_input, context) {
|
|
2454
2454
|
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2455
2455
|
if (!apiUrl || !context.walletAddress) {
|
|
2456
|
-
return { data: {
|
|
2456
|
+
return { data: { links: [] }, displayText: "No payment links found." };
|
|
2457
2457
|
}
|
|
2458
2458
|
try {
|
|
2459
2459
|
const res = await fetch(`${apiUrl}/api/internal/payments?type=link`, {
|
|
2460
2460
|
signal: context.signal,
|
|
2461
2461
|
headers: internalHeaders(context)
|
|
2462
2462
|
});
|
|
2463
|
-
if (!res.ok) return { data: {
|
|
2464
|
-
const
|
|
2465
|
-
const
|
|
2463
|
+
if (!res.ok) return { data: { links: [] }, displayText: "Could not fetch payment links." };
|
|
2464
|
+
const raw = await res.json();
|
|
2465
|
+
const links = raw.payments;
|
|
2466
|
+
const count = links.length;
|
|
2466
2467
|
return {
|
|
2467
|
-
data,
|
|
2468
|
+
data: { links },
|
|
2468
2469
|
displayText: count === 0 ? "No payment links yet." : `${count} payment link${count !== 1 ? "s" : ""} found.`
|
|
2469
2470
|
};
|
|
2470
2471
|
} catch {
|
|
2471
|
-
return { data: {
|
|
2472
|
+
return { data: { links: [] }, displayText: "Could not fetch payment links." };
|
|
2472
2473
|
}
|
|
2473
2474
|
}
|
|
2474
2475
|
});
|
|
@@ -2617,22 +2618,23 @@ var listInvoicesTool = buildTool({
|
|
|
2617
2618
|
async call(_input, context) {
|
|
2618
2619
|
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2619
2620
|
if (!apiUrl || !context.walletAddress) {
|
|
2620
|
-
return { data: {
|
|
2621
|
+
return { data: { invoices: [] }, displayText: "No invoices found." };
|
|
2621
2622
|
}
|
|
2622
2623
|
try {
|
|
2623
2624
|
const res = await fetch(`${apiUrl}/api/internal/payments?type=invoice`, {
|
|
2624
2625
|
signal: context.signal,
|
|
2625
2626
|
headers: internalHeaders(context)
|
|
2626
2627
|
});
|
|
2627
|
-
if (!res.ok) return { data: {
|
|
2628
|
-
const
|
|
2629
|
-
const
|
|
2628
|
+
if (!res.ok) return { data: { invoices: [] }, displayText: "Could not fetch invoices." };
|
|
2629
|
+
const raw = await res.json();
|
|
2630
|
+
const invoices = raw.payments;
|
|
2631
|
+
const count = invoices.length;
|
|
2630
2632
|
return {
|
|
2631
|
-
data,
|
|
2633
|
+
data: { invoices },
|
|
2632
2634
|
displayText: count === 0 ? "No invoices yet." : `${count} invoice${count !== 1 ? "s" : ""} found.`
|
|
2633
2635
|
};
|
|
2634
2636
|
} catch {
|
|
2635
|
-
return { data: {
|
|
2637
|
+
return { data: { invoices: [] }, displayText: "Could not fetch invoices." };
|
|
2636
2638
|
}
|
|
2637
2639
|
}
|
|
2638
2640
|
});
|