@t2000/engine 0.36.0 → 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/README.md +43 -3
- package/dist/index.js +34 -54
- 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 (38 — parallel, auto-approved)
|
|
91
91
|
|
|
92
92
|
| Tool | Description |
|
|
93
93
|
|------|-------------|
|
|
@@ -120,8 +120,17 @@ QueryEngine.submitMessage()
|
|
|
120
120
|
| `toggle_allowance` | Pause or resume agent autonomous spending |
|
|
121
121
|
| `update_daily_limit` | Change the daily USDC spending cap |
|
|
122
122
|
| `update_permissions` | Update which service categories the agent can act on |
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
| `spending_analytics` | Spending breakdown by service/category over time period |
|
|
124
|
+
| `yield_summary` | Yield earned + projections with sparkline data |
|
|
125
|
+
| `activity_summary` | Activity breakdown by action type |
|
|
126
|
+
| `create_schedule` | Create a recurring scheduled action (DCA) |
|
|
127
|
+
| `list_schedules` | List scheduled actions with trust stage |
|
|
128
|
+
| `cancel_schedule` | Cancel a scheduled action |
|
|
129
|
+
| `render_canvas` | Generate interactive HTML canvas visualizations |
|
|
130
|
+
| `pattern_status` | View behavioral pattern proposals and trust stage |
|
|
131
|
+
| `record_advice` | Record financial advice given for outcome tracking |
|
|
132
|
+
|
|
133
|
+
### Write Tools (12 — serial, confirmation required)
|
|
125
134
|
|
|
126
135
|
| Tool | Description |
|
|
127
136
|
|------|-------------|
|
|
@@ -136,6 +145,34 @@ QueryEngine.submitMessage()
|
|
|
136
145
|
| `volo_stake` | Stake SUI for vSUI (VOLO liquid staking) |
|
|
137
146
|
| `volo_unstake` | Unstake vSUI back to SUI |
|
|
138
147
|
| `save_contact` | Save a contact name + address for quick sends |
|
|
148
|
+
| `pause_pattern` | Pause an autonomous behavioral pattern |
|
|
149
|
+
|
|
150
|
+
## Audric 2.0 Engine Features
|
|
151
|
+
|
|
152
|
+
### Streaming Tool Execution (Early Dispatch)
|
|
153
|
+
|
|
154
|
+
`EarlyToolDispatcher` dispatches read-only tools mid-stream before `message_stop`. Tools with `isReadOnly && isConcurrencySafe` fire as soon as their `tool_use` block completes. Write tools still go through the permission gate.
|
|
155
|
+
|
|
156
|
+
### Tool Result Budgeting
|
|
157
|
+
|
|
158
|
+
Tools can set `maxResultSizeChars` to cap output size. Results exceeding the limit are truncated with a hint to narrow parameters. Custom `summarizeOnTruncate` callbacks supported.
|
|
159
|
+
|
|
160
|
+
### Microcompact
|
|
161
|
+
|
|
162
|
+
`microcompact(messages)` deduplicates identical tool calls (same name + input) in conversation history, replacing repeated results with `[Same result as turn N]`.
|
|
163
|
+
|
|
164
|
+
### Granular Permissions (USD-aware)
|
|
165
|
+
|
|
166
|
+
Write tool permission resolved dynamically via `resolvePermissionTier(operation, amountUsd, config)`. Small amounts auto-execute; large amounts require confirmation. Three presets: `conservative`, `balanced`, `aggressive`.
|
|
167
|
+
|
|
168
|
+
### Reasoning Engine
|
|
169
|
+
|
|
170
|
+
- **Adaptive thinking** — routes queries to `low`/`medium`/`high` effort based on financial complexity
|
|
171
|
+
- **Guard runner** — 9 guards across 3 priority tiers (Safety > Financial > UX)
|
|
172
|
+
- **Skill recipes** — YAML recipe files with longest-trigger-match-wins
|
|
173
|
+
- **Context compaction** — 200k limit, 85% compact trigger, LLM summarizer fallback
|
|
174
|
+
- **Tool flags** — `mutating`, `requiresBalance`, `affectsHealth`, `irreversible` etc.
|
|
175
|
+
- **Preflight validation** — input validation on `send_transfer`, `swap_execute`, `pay_api`, `borrow`, `save_deposit`
|
|
139
176
|
|
|
140
177
|
## Configuration
|
|
141
178
|
|
|
@@ -165,9 +202,12 @@ The `submitMessage()` async generator yields `EngineEvent`:
|
|
|
165
202
|
| Event | Fields | When |
|
|
166
203
|
|-------|--------|------|
|
|
167
204
|
| `text_delta` | `text` | LLM streams a text chunk |
|
|
205
|
+
| `thinking_delta` | `text` | Extended thinking chunk (reasoning accordion) |
|
|
206
|
+
| `thinking_done` | — | Extended thinking complete |
|
|
168
207
|
| `tool_start` | `toolName`, `toolUseId`, `input` | Tool execution begins |
|
|
169
208
|
| `tool_result` | `toolName`, `toolUseId`, `result`, `isError` | Tool execution completes |
|
|
170
209
|
| `pending_action` | `action` (PendingAction) | Write tool awaiting client-side execution |
|
|
210
|
+
| `canvas` | `html` | Interactive HTML visualization from `render_canvas` |
|
|
171
211
|
| `turn_complete` | `stopReason` | Conversation turn finished |
|
|
172
212
|
| `usage` | `inputTokens`, `outputTokens`, `cacheReadTokens?`, `cacheWriteTokens?` | Token usage report |
|
|
173
213
|
| `error` | `error` | Unrecoverable error |
|
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
|
});
|