@t2000/engine 0.28.5 → 0.28.7
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/README.md +10 -1
- package/dist/index.js +174 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -87,7 +87,7 @@ QueryEngine.submitMessage()
|
|
|
87
87
|
|
|
88
88
|
## Built-in Tools
|
|
89
89
|
|
|
90
|
-
### Read Tools (
|
|
90
|
+
### Read Tools (29 — parallel, auto-approved)
|
|
91
91
|
|
|
92
92
|
| Tool | Description |
|
|
93
93
|
|------|-------------|
|
|
@@ -111,6 +111,15 @@ QueryEngine.submitMessage()
|
|
|
111
111
|
| `defillama_chain_tvl` | Chain TVL rankings |
|
|
112
112
|
| `defillama_protocol_fees` | Protocol fees/revenue rankings |
|
|
113
113
|
| `defillama_sui_protocols` | Sui ecosystem protocols — TVL, category, changes |
|
|
114
|
+
| `create_payment_link` | Create a shareable USDC payment link |
|
|
115
|
+
| `list_payment_links` | List payment links with statuses |
|
|
116
|
+
| `cancel_payment_link` | Cancel an active payment link |
|
|
117
|
+
| `create_invoice` | Create a formal invoice with due date and line items |
|
|
118
|
+
| `list_invoices` | List invoices with statuses |
|
|
119
|
+
| `cancel_invoice` | Cancel an unpaid invoice |
|
|
120
|
+
| `toggle_allowance` | Pause or resume agent autonomous spending |
|
|
121
|
+
| `update_daily_limit` | Change the daily USDC spending cap |
|
|
122
|
+
| `update_permissions` | Update which service categories the agent can act on |
|
|
114
123
|
|
|
115
124
|
### Write Tools (11 — serial, confirmation required)
|
|
116
125
|
|
package/dist/index.js
CHANGED
|
@@ -1985,6 +1985,20 @@ Risks: ${riskFactors.join("; ")}`
|
|
|
1985
1985
|
};
|
|
1986
1986
|
}
|
|
1987
1987
|
});
|
|
1988
|
+
async function patchAllowance(apiUrl, walletAddress, internalKey, body, signal) {
|
|
1989
|
+
const res = await fetch(`${apiUrl}/api/allowance/${walletAddress}`, {
|
|
1990
|
+
method: "PATCH",
|
|
1991
|
+
headers: {
|
|
1992
|
+
"Content-Type": "application/json",
|
|
1993
|
+
"x-internal-key": internalKey ?? "",
|
|
1994
|
+
"x-sui-address": walletAddress
|
|
1995
|
+
},
|
|
1996
|
+
body: JSON.stringify(body),
|
|
1997
|
+
signal
|
|
1998
|
+
});
|
|
1999
|
+
if (!res.ok) return null;
|
|
2000
|
+
return res.json();
|
|
2001
|
+
}
|
|
1988
2002
|
var allowanceStatusTool = buildTool({
|
|
1989
2003
|
name: "allowance_status",
|
|
1990
2004
|
description: "Check the agent spending allowance status: whether it is enabled, the daily USDC limit, amount spent today, remaining budget, which service categories are permitted, and when the budget resets. Use this when the user asks about their agent budget, spending limits, or autonomous transaction permissions.",
|
|
@@ -2035,6 +2049,117 @@ var allowanceStatusTool = buildTool({
|
|
|
2035
2049
|
};
|
|
2036
2050
|
}
|
|
2037
2051
|
});
|
|
2052
|
+
var toggleAllowanceTool = buildTool({
|
|
2053
|
+
name: "toggle_allowance",
|
|
2054
|
+
description: 'Pause or resume the agent spending allowance. Use when the user says "pause my agent", "disable autonomous spending", "resume my agent", or similar. ALWAYS confirm with the user before calling \u2014 e.g. "Pause agent spending? Your daily limit will be suspended." Only call after explicit confirmation.',
|
|
2055
|
+
inputSchema: z.object({
|
|
2056
|
+
enabled: z.boolean().describe("true to enable agent spending, false to pause it")
|
|
2057
|
+
}),
|
|
2058
|
+
jsonSchema: {
|
|
2059
|
+
type: "object",
|
|
2060
|
+
properties: {
|
|
2061
|
+
enabled: { type: "boolean", description: "true to enable, false to pause" }
|
|
2062
|
+
},
|
|
2063
|
+
required: ["enabled"]
|
|
2064
|
+
},
|
|
2065
|
+
isReadOnly: true,
|
|
2066
|
+
async call(input, context) {
|
|
2067
|
+
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2068
|
+
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2069
|
+
if (!apiUrl || !context.walletAddress) {
|
|
2070
|
+
return { data: null, displayText: "Allowance management is not available." };
|
|
2071
|
+
}
|
|
2072
|
+
try {
|
|
2073
|
+
const result = await patchAllowance(apiUrl, context.walletAddress, internalKey, {
|
|
2074
|
+
action: "toggle",
|
|
2075
|
+
enabled: input.enabled
|
|
2076
|
+
}, context.signal);
|
|
2077
|
+
if (!result) return { data: null, displayText: "Failed to update allowance." };
|
|
2078
|
+
const action = input.enabled ? "enabled" : "paused";
|
|
2079
|
+
return {
|
|
2080
|
+
data: result,
|
|
2081
|
+
displayText: `Agent spending ${action}.`
|
|
2082
|
+
};
|
|
2083
|
+
} catch {
|
|
2084
|
+
return { data: null, displayText: "Failed to update allowance." };
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
var updateDailyLimitTool = buildTool({
|
|
2089
|
+
name: "update_daily_limit",
|
|
2090
|
+
description: `Update the agent's daily spending limit in USDC. Use when the user says "set my daily limit to $X", "change my spending cap", or similar. ALWAYS confirm with the user before calling \u2014 show the current limit and the new limit. Only call after explicit confirmation.`,
|
|
2091
|
+
inputSchema: z.object({
|
|
2092
|
+
dailyLimitUsdc: z.number().min(0).max(1e4).describe("New daily limit in USDC (0\u201310000)")
|
|
2093
|
+
}),
|
|
2094
|
+
jsonSchema: {
|
|
2095
|
+
type: "object",
|
|
2096
|
+
properties: {
|
|
2097
|
+
dailyLimitUsdc: { type: "number", description: "New daily spending limit in USDC (0\u201310000)" }
|
|
2098
|
+
},
|
|
2099
|
+
required: ["dailyLimitUsdc"]
|
|
2100
|
+
},
|
|
2101
|
+
isReadOnly: true,
|
|
2102
|
+
async call(input, context) {
|
|
2103
|
+
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2104
|
+
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2105
|
+
if (!apiUrl || !context.walletAddress) {
|
|
2106
|
+
return { data: null, displayText: "Allowance management is not available." };
|
|
2107
|
+
}
|
|
2108
|
+
try {
|
|
2109
|
+
const result = await patchAllowance(apiUrl, context.walletAddress, internalKey, {
|
|
2110
|
+
action: "setLimit",
|
|
2111
|
+
dailyLimitUsdc: input.dailyLimitUsdc
|
|
2112
|
+
}, context.signal);
|
|
2113
|
+
if (!result) return { data: null, displayText: "Failed to update daily limit." };
|
|
2114
|
+
return {
|
|
2115
|
+
data: result,
|
|
2116
|
+
displayText: `Daily limit updated to $${input.dailyLimitUsdc.toFixed(2)} USDC.`
|
|
2117
|
+
};
|
|
2118
|
+
} catch {
|
|
2119
|
+
return { data: null, displayText: "Failed to update daily limit." };
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
});
|
|
2123
|
+
var updatePermissionsTool = buildTool({
|
|
2124
|
+
name: "update_permissions",
|
|
2125
|
+
description: 'Update which service categories the agent is allowed to act on autonomously. Valid permissions: savings, send, pay, credit, swap, stake. Use when the user says "disable sends", "only allow savings", "enable all services", or similar. ALWAYS show the current permissions and the new permissions before calling. Only call after explicit confirmation.',
|
|
2126
|
+
inputSchema: z.object({
|
|
2127
|
+
permissions: z.array(z.enum(["savings", "send", "pay", "credit", "swap", "stake"])).describe("Full list of enabled permission categories")
|
|
2128
|
+
}),
|
|
2129
|
+
jsonSchema: {
|
|
2130
|
+
type: "object",
|
|
2131
|
+
properties: {
|
|
2132
|
+
permissions: {
|
|
2133
|
+
type: "array",
|
|
2134
|
+
items: { type: "string", enum: ["savings", "send", "pay", "credit", "swap", "stake"] },
|
|
2135
|
+
description: "Full list of enabled permission categories"
|
|
2136
|
+
}
|
|
2137
|
+
},
|
|
2138
|
+
required: ["permissions"]
|
|
2139
|
+
},
|
|
2140
|
+
isReadOnly: true,
|
|
2141
|
+
async call(input, context) {
|
|
2142
|
+
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2143
|
+
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2144
|
+
if (!apiUrl || !context.walletAddress) {
|
|
2145
|
+
return { data: null, displayText: "Allowance management is not available." };
|
|
2146
|
+
}
|
|
2147
|
+
try {
|
|
2148
|
+
const result = await patchAllowance(apiUrl, context.walletAddress, internalKey, {
|
|
2149
|
+
action: "setPermissions",
|
|
2150
|
+
permissions: input.permissions
|
|
2151
|
+
}, context.signal);
|
|
2152
|
+
if (!result) return { data: null, displayText: "Failed to update permissions." };
|
|
2153
|
+
const list = input.permissions.length > 0 ? input.permissions.join(", ") : "none";
|
|
2154
|
+
return {
|
|
2155
|
+
data: result,
|
|
2156
|
+
displayText: `Permissions updated: ${list}.`
|
|
2157
|
+
};
|
|
2158
|
+
} catch {
|
|
2159
|
+
return { data: null, displayText: "Failed to update permissions." };
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
});
|
|
2038
2163
|
var PaymentLinkSchema = z.object({
|
|
2039
2164
|
amount: z.number().positive().optional().describe("Amount in USDC. Omit for open-amount links."),
|
|
2040
2165
|
label: z.string().optional().describe('Human-readable label e.g. "Consulting fee March"'),
|
|
@@ -2238,6 +2363,51 @@ var cancelPaymentLinkTool = buildTool({
|
|
|
2238
2363
|
}
|
|
2239
2364
|
}
|
|
2240
2365
|
});
|
|
2366
|
+
var cancelInvoiceTool = buildTool({
|
|
2367
|
+
name: "cancel_invoice",
|
|
2368
|
+
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.',
|
|
2369
|
+
inputSchema: z.object({
|
|
2370
|
+
slug: z.string().describe('The slug of the invoice to cancel (e.g. "xFYKBWy5")')
|
|
2371
|
+
}),
|
|
2372
|
+
jsonSchema: {
|
|
2373
|
+
type: "object",
|
|
2374
|
+
properties: {
|
|
2375
|
+
slug: { type: "string", description: "The slug of the invoice to cancel" }
|
|
2376
|
+
},
|
|
2377
|
+
required: ["slug"]
|
|
2378
|
+
},
|
|
2379
|
+
isReadOnly: true,
|
|
2380
|
+
async call(input, context) {
|
|
2381
|
+
const apiUrl = context.env?.ALLOWANCE_API_URL;
|
|
2382
|
+
const internalKey = context.env?.AUDRIC_INTERNAL_KEY;
|
|
2383
|
+
if (!apiUrl || !context.walletAddress) {
|
|
2384
|
+
return { data: null, displayText: "Invoice cancellation is not available." };
|
|
2385
|
+
}
|
|
2386
|
+
try {
|
|
2387
|
+
const res = await fetch(`${apiUrl}/api/internal/invoices`, {
|
|
2388
|
+
method: "PATCH",
|
|
2389
|
+
signal: context.signal,
|
|
2390
|
+
headers: {
|
|
2391
|
+
"Content-Type": "application/json",
|
|
2392
|
+
"x-sui-address": context.walletAddress,
|
|
2393
|
+
...internalKey ? { "x-internal-key": internalKey } : {}
|
|
2394
|
+
},
|
|
2395
|
+
body: JSON.stringify({ slug: input.slug, action: "cancel" })
|
|
2396
|
+
});
|
|
2397
|
+
if (!res.ok) {
|
|
2398
|
+
const err = await res.json().catch(() => ({}));
|
|
2399
|
+
return { data: null, displayText: err.error ?? "Failed to cancel invoice." };
|
|
2400
|
+
}
|
|
2401
|
+
const result = await res.json();
|
|
2402
|
+
return {
|
|
2403
|
+
data: result,
|
|
2404
|
+
displayText: `Invoice ${result.slug} cancelled.`
|
|
2405
|
+
};
|
|
2406
|
+
} catch {
|
|
2407
|
+
return { data: null, displayText: "Failed to cancel invoice." };
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2241
2411
|
var listInvoicesTool = buildTool({
|
|
2242
2412
|
name: "list_invoices",
|
|
2243
2413
|
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.`,
|
|
@@ -2574,9 +2744,13 @@ var READ_TOOLS = [
|
|
|
2574
2744
|
defillamaProtocolFeesTool,
|
|
2575
2745
|
defillamaSuiProtocolsTool,
|
|
2576
2746
|
allowanceStatusTool,
|
|
2747
|
+
toggleAllowanceTool,
|
|
2748
|
+
updateDailyLimitTool,
|
|
2749
|
+
updatePermissionsTool,
|
|
2577
2750
|
listPaymentLinksTool,
|
|
2578
2751
|
cancelPaymentLinkTool,
|
|
2579
2752
|
listInvoicesTool,
|
|
2753
|
+
cancelInvoiceTool,
|
|
2580
2754
|
createPaymentLinkTool,
|
|
2581
2755
|
createInvoiceTool
|
|
2582
2756
|
];
|