@t2000/engine 0.28.4 → 0.28.6
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 +92 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2193,6 +2193,96 @@ var createInvoiceTool = buildTool({
|
|
|
2193
2193
|
}
|
|
2194
2194
|
}
|
|
2195
2195
|
});
|
|
2196
|
+
var cancelPaymentLinkTool = buildTool({
|
|
2197
|
+
name: "cancel_payment_link",
|
|
2198
|
+
description: 'Cancel an active payment link so it can no longer be used. Use when the user says "cancel my payment link", "delete my payment link", or "remove the link [slug/label]". Ask for the slug if ambiguous \u2014 use list_payment_links first to find it.',
|
|
2199
|
+
inputSchema: z.object({
|
|
2200
|
+
slug: z.string().describe('The slug of the payment link to cancel (e.g. "LzLawhY7")')
|
|
2201
|
+
}),
|
|
2202
|
+
jsonSchema: {
|
|
2203
|
+
type: "object",
|
|
2204
|
+
properties: {
|
|
2205
|
+
slug: { type: "string", description: "The slug of the payment link to cancel" }
|
|
2206
|
+
},
|
|
2207
|
+
required: ["slug"]
|
|
2208
|
+
},
|
|
2209
|
+
isReadOnly: true,
|
|
2210
|
+
async call(input, context) {
|
|
2211
|
+
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2212
|
+
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2213
|
+
if (!apiUrl || !context.walletAddress) {
|
|
2214
|
+
return { data: null, displayText: "Payment link cancellation is not available." };
|
|
2215
|
+
}
|
|
2216
|
+
try {
|
|
2217
|
+
const res = await fetch(`${apiUrl}/api/internal/payment-links`, {
|
|
2218
|
+
method: "PATCH",
|
|
2219
|
+
signal: context.signal,
|
|
2220
|
+
headers: {
|
|
2221
|
+
"Content-Type": "application/json",
|
|
2222
|
+
"x-sui-address": context.walletAddress,
|
|
2223
|
+
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2224
|
+
},
|
|
2225
|
+
body: JSON.stringify({ slug: input.slug, action: "cancel" })
|
|
2226
|
+
});
|
|
2227
|
+
if (!res.ok) {
|
|
2228
|
+
const err = await res.json().catch(() => ({}));
|
|
2229
|
+
return { data: null, displayText: err.error ?? "Failed to cancel payment link." };
|
|
2230
|
+
}
|
|
2231
|
+
const result = await res.json();
|
|
2232
|
+
return {
|
|
2233
|
+
data: result,
|
|
2234
|
+
displayText: `Payment link ${result.slug} cancelled.`
|
|
2235
|
+
};
|
|
2236
|
+
} catch {
|
|
2237
|
+
return { data: null, displayText: "Failed to cancel payment link." };
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
});
|
|
2241
|
+
var cancelInvoiceTool = buildTool({
|
|
2242
|
+
name: "cancel_invoice",
|
|
2243
|
+
description: 'Cancel an invoice that has not yet been paid. Use when the user says "cancel my invoice", "delete invoice", or refers to a specific invoice slug or label. Use list_invoices first if the slug is not known.',
|
|
2244
|
+
inputSchema: z.object({
|
|
2245
|
+
slug: z.string().describe('The slug of the invoice to cancel (e.g. "xFYKBWy5")')
|
|
2246
|
+
}),
|
|
2247
|
+
jsonSchema: {
|
|
2248
|
+
type: "object",
|
|
2249
|
+
properties: {
|
|
2250
|
+
slug: { type: "string", description: "The slug of the invoice to cancel" }
|
|
2251
|
+
},
|
|
2252
|
+
required: ["slug"]
|
|
2253
|
+
},
|
|
2254
|
+
isReadOnly: true,
|
|
2255
|
+
async call(input, context) {
|
|
2256
|
+
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2257
|
+
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2258
|
+
if (!apiUrl || !context.walletAddress) {
|
|
2259
|
+
return { data: null, displayText: "Invoice cancellation is not available." };
|
|
2260
|
+
}
|
|
2261
|
+
try {
|
|
2262
|
+
const res = await fetch(`${apiUrl}/api/internal/invoices`, {
|
|
2263
|
+
method: "PATCH",
|
|
2264
|
+
signal: context.signal,
|
|
2265
|
+
headers: {
|
|
2266
|
+
"Content-Type": "application/json",
|
|
2267
|
+
"x-sui-address": context.walletAddress,
|
|
2268
|
+
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2269
|
+
},
|
|
2270
|
+
body: JSON.stringify({ slug: input.slug, action: "cancel" })
|
|
2271
|
+
});
|
|
2272
|
+
if (!res.ok) {
|
|
2273
|
+
const err = await res.json().catch(() => ({}));
|
|
2274
|
+
return { data: null, displayText: err.error ?? "Failed to cancel invoice." };
|
|
2275
|
+
}
|
|
2276
|
+
const result = await res.json();
|
|
2277
|
+
return {
|
|
2278
|
+
data: result,
|
|
2279
|
+
displayText: `Invoice ${result.slug} cancelled.`
|
|
2280
|
+
};
|
|
2281
|
+
} catch {
|
|
2282
|
+
return { data: null, displayText: "Failed to cancel invoice." };
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
});
|
|
2196
2286
|
var listInvoicesTool = buildTool({
|
|
2197
2287
|
name: "list_invoices",
|
|
2198
2288
|
description: `List the user's invoices \u2014 pending, overdue, paid, and cancelled. Use when the user asks "show my invoices", "what invoices do I have", or wants to check invoice status.`,
|
|
@@ -2530,7 +2620,9 @@ var READ_TOOLS = [
|
|
|
2530
2620
|
defillamaSuiProtocolsTool,
|
|
2531
2621
|
allowanceStatusTool,
|
|
2532
2622
|
listPaymentLinksTool,
|
|
2623
|
+
cancelPaymentLinkTool,
|
|
2533
2624
|
listInvoicesTool,
|
|
2625
|
+
cancelInvoiceTool,
|
|
2534
2626
|
createPaymentLinkTool,
|
|
2535
2627
|
createInvoiceTool
|
|
2536
2628
|
];
|