@t2000/engine 0.28.5 → 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 CHANGED
@@ -2238,6 +2238,51 @@ var cancelPaymentLinkTool = buildTool({
2238
2238
  }
2239
2239
  }
2240
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
+ });
2241
2286
  var listInvoicesTool = buildTool({
2242
2287
  name: "list_invoices",
2243
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.`,
@@ -2577,6 +2622,7 @@ var READ_TOOLS = [
2577
2622
  listPaymentLinksTool,
2578
2623
  cancelPaymentLinkTool,
2579
2624
  listInvoicesTool,
2625
+ cancelInvoiceTool,
2580
2626
  createPaymentLinkTool,
2581
2627
  createInvoiceTool
2582
2628
  ];