@agentwonderland/mcp 0.1.24 → 0.1.25
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/core/__tests__/amount-utils.test.d.ts +1 -0
- package/dist/core/__tests__/amount-utils.test.js +11 -0
- package/dist/core/__tests__/payments.test.js +55 -6
- package/dist/core/__tests__/spend-policy.test.d.ts +1 -0
- package/dist/core/__tests__/spend-policy.test.js +40 -0
- package/dist/core/amount-utils.d.ts +1 -0
- package/dist/core/amount-utils.js +4 -0
- package/dist/core/base-charge.js +3 -2
- package/dist/core/config.d.ts +19 -0
- package/dist/core/config.js +22 -0
- package/dist/core/formatters.d.ts +2 -3
- package/dist/core/formatters.js +5 -7
- package/dist/core/payments.js +14 -4
- package/dist/core/solana-charge.js +2 -1
- package/dist/core/spend-policy.d.ts +12 -0
- package/dist/core/spend-policy.js +53 -0
- package/dist/core/types.d.ts +1 -2
- package/dist/index.js +5 -2
- package/dist/prompts/index.js +4 -2
- package/dist/resources/agents.js +1 -1
- package/dist/tools/agent-info.js +2 -2
- package/dist/tools/favorites.js +1 -1
- package/dist/tools/observability.d.ts +2 -0
- package/dist/tools/observability.js +20 -0
- package/dist/tools/run.js +40 -28
- package/dist/tools/solve.js +45 -39
- package/dist/tools/wallet.js +26 -10
- package/package.json +1 -1
- package/src/core/__tests__/amount-utils.test.ts +13 -0
- package/src/core/__tests__/payments.test.ts +68 -6
- package/src/core/__tests__/spend-policy.test.ts +58 -0
- package/src/core/amount-utils.ts +5 -0
- package/src/core/base-charge.ts +3 -2
- package/src/core/config.ts +45 -0
- package/src/core/formatters.ts +6 -8
- package/src/core/payments.ts +17 -4
- package/src/core/solana-charge.ts +2 -1
- package/src/core/spend-policy.ts +69 -0
- package/src/core/types.ts +1 -2
- package/src/index.ts +5 -2
- package/src/prompts/index.ts +4 -2
- package/src/resources/agents.ts +1 -1
- package/src/tools/agent-info.ts +2 -2
- package/src/tools/favorites.ts +1 -4
- package/src/tools/observability.ts +43 -0
- package/src/tools/passes.ts +1 -7
- package/src/tools/run.ts +44 -43
- package/src/tools/solve.ts +50 -55
- package/src/tools/wallet.ts +30 -10
package/src/tools/wallet.ts
CHANGED
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
setCardConfig,
|
|
7
7
|
addWallet,
|
|
8
8
|
getPendingCardSetupToken,
|
|
9
|
+
getSpendPolicy,
|
|
10
|
+
setSpendPolicy,
|
|
9
11
|
} from "../core/config.js";
|
|
10
12
|
import { getWalletAddress } from "../core/payments.js";
|
|
11
13
|
import {
|
|
@@ -352,8 +354,13 @@ export function registerWalletTools(server: McpServer): void {
|
|
|
352
354
|
.positive()
|
|
353
355
|
.optional()
|
|
354
356
|
.describe("Maximum USD per day across all transactions"),
|
|
357
|
+
require_confirmation_above: z
|
|
358
|
+
.number()
|
|
359
|
+
.positive()
|
|
360
|
+
.optional()
|
|
361
|
+
.describe("Require manual confirmation above this USD amount even when auto-spend is enabled"),
|
|
355
362
|
},
|
|
356
|
-
async ({ wallet_id, max_per_tx, max_per_day }) => {
|
|
363
|
+
async ({ wallet_id, max_per_tx, max_per_day, require_confirmation_above }) => {
|
|
357
364
|
const wallets = getWallets();
|
|
358
365
|
const wallet = wallets.find((w) => w.id === wallet_id);
|
|
359
366
|
|
|
@@ -364,23 +371,36 @@ export function registerWalletTools(server: McpServer): void {
|
|
|
364
371
|
);
|
|
365
372
|
}
|
|
366
373
|
|
|
367
|
-
if (
|
|
374
|
+
if (
|
|
375
|
+
max_per_tx == null &&
|
|
376
|
+
max_per_day == null &&
|
|
377
|
+
require_confirmation_above == null
|
|
378
|
+
) {
|
|
368
379
|
return text(
|
|
369
|
-
"No policy changes specified. Provide
|
|
380
|
+
"No policy changes specified. Provide at least one policy field.",
|
|
370
381
|
);
|
|
371
382
|
}
|
|
372
383
|
|
|
384
|
+
const existing = getSpendPolicy(wallet_id) ?? {};
|
|
385
|
+
const nextPolicy = {
|
|
386
|
+
...existing,
|
|
387
|
+
...(max_per_tx != null ? { maxPerTxUsd: max_per_tx } : {}),
|
|
388
|
+
...(max_per_day != null ? { maxPerDayUsd: max_per_day } : {}),
|
|
389
|
+
...(require_confirmation_above != null ? { requireConfirmationAboveUsd: require_confirmation_above } : {}),
|
|
390
|
+
};
|
|
391
|
+
setSpendPolicy(wallet_id, nextPolicy);
|
|
392
|
+
|
|
373
393
|
// Build policy summary
|
|
374
394
|
const policies: string[] = [];
|
|
375
|
-
if (
|
|
376
|
-
policies.push(`Max per transaction: $${
|
|
395
|
+
if (nextPolicy.maxPerTxUsd != null) {
|
|
396
|
+
policies.push(`Max per transaction: $${nextPolicy.maxPerTxUsd.toFixed(2)}`);
|
|
377
397
|
}
|
|
378
|
-
if (
|
|
379
|
-
policies.push(`Max per day: $${
|
|
398
|
+
if (nextPolicy.maxPerDayUsd != null) {
|
|
399
|
+
policies.push(`Max per day: $${nextPolicy.maxPerDayUsd.toFixed(2)}`);
|
|
400
|
+
}
|
|
401
|
+
if (nextPolicy.requireConfirmationAboveUsd != null) {
|
|
402
|
+
policies.push(`Require confirmation above: $${nextPolicy.requireConfirmationAboveUsd.toFixed(2)}`);
|
|
380
403
|
}
|
|
381
|
-
|
|
382
|
-
// Note: actual persistence depends on the config module supporting policy fields.
|
|
383
|
-
// For now, we report what would be set. The core/config module will handle storage.
|
|
384
404
|
return text(
|
|
385
405
|
[
|
|
386
406
|
`Spending policy set for wallet "${wallet_id}":`,
|