@sparkysolutions/agentrail 0.1.0 → 0.1.1
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 +249 -146
- package/dist/cli/mcp-stdio.d.ts +8 -0
- package/dist/cli/mcp-stdio.js +454 -0
- package/dist/cli/pipeline.d.ts +40 -0
- package/dist/cli/pipeline.js +114 -0
- package/dist/cli/sandbox.d.ts +15 -1
- package/dist/cli/sandbox.js +30 -5
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/lib/agent-badge-issuer.d.ts +36 -0
- package/dist/lib/agent-badge-issuer.js +166 -0
- package/dist/lib/agent-registry.d.ts +136 -0
- package/dist/lib/agent-registry.js +124 -0
- package/dist/lib/agenthustle-pipeline.d.ts +68 -0
- package/dist/lib/agenthustle-pipeline.js +143 -0
- package/dist/lib/agentpass-pipeline.d.ts +44 -0
- package/dist/lib/agentpass-pipeline.js +84 -0
- package/dist/lib/audit-trail-provider.d.ts +24 -0
- package/dist/lib/audit-trail-provider.js +60 -0
- package/dist/lib/axis-clob-provider.d.ts +50 -0
- package/dist/lib/axis-clob-provider.js +150 -0
- package/dist/lib/circuit-breaker.d.ts +60 -0
- package/dist/lib/circuit-breaker.js +136 -0
- package/dist/lib/conditional-escrow.d.ts +42 -0
- package/dist/lib/conditional-escrow.js +126 -0
- package/dist/lib/mcp-server.d.ts +29 -0
- package/dist/lib/mcp-server.js +165 -0
- package/dist/lib/receipts.d.ts +153 -0
- package/dist/lib/receipts.js +173 -0
- package/dist/lib/reflector-oracle-adapter.d.ts +44 -0
- package/dist/lib/reflector-oracle-adapter.js +173 -0
- package/dist/lib/scoped-allowance.d.ts +4 -0
- package/dist/lib/scoped-allowance.js +22 -1
- package/dist/lib/universal-adapters.d.ts +42 -0
- package/dist/lib/universal-adapters.js +69 -0
- package/dist/lib/x402-gateway.d.ts +86 -0
- package/dist/lib/x402-gateway.js +128 -0
- package/dist/lib/x402-pipeline.d.ts +51 -0
- package/dist/lib/x402-pipeline.js +105 -0
- package/dist/types.d.ts +109 -0
- package/glama.json +12 -0
- package/package.json +56 -40
- package/smithery.json +43 -0
- package/smithery.yaml +29 -0
- package/.github/ISSUE_TEMPLATE/drips_wave_task.md +0 -33
- package/.github/workflows/auto-merge.yml +0 -119
- package/.github/workflows/ci.yml +0 -35
- package/BENCHMARKS.md +0 -67
- package/CONTRIBUTING.md +0 -40
- package/DRIPS_WAVE.md +0 -81
- package/FUNDING.json +0 -7
- package/ISSUES_PIPELINE.json +0 -106
- package/RUNBOOK.md +0 -95
- package/SCF_ACTIVATION_PROPOSAL.md +0 -137
- package/assets/sorobanagents_avatar.jpg +0 -0
- package/assets/sorobanagents_avatar.png +0 -0
- package/assets/sorobanagents_avatar_elite.png +0 -0
- package/contracts/agentrail/Cargo.lock +0 -1895
- package/contracts/agentrail/Cargo.toml +0 -25
- package/contracts/agentrail/src/lib.rs +0 -296
- package/contracts/agentrail/src/test.rs +0 -442
- package/contracts/agentrail/test_snapshots/test/test_circuit_breaker_pause_and_unpause.1.json +0 -195
- package/contracts/agentrail/test_snapshots/test/test_double_initialize_fails.1.json +0 -123
- package/contracts/agentrail/test_snapshots/test/test_execute_spend_deducts_and_accumulates.1.json +0 -347
- package/contracts/agentrail/test_snapshots/test/test_get_allowance_returns_none_for_unregistered.1.json +0 -61
- package/contracts/agentrail/test_snapshots/test/test_get_version_matches_cargo_toml.1.json +0 -61
- package/contracts/agentrail/test_snapshots/test/test_grant_allowance_negative_amount_fails.1.json +0 -123
- package/contracts/agentrail/test_snapshots/test/test_grant_allowance_success.1.json +0 -250
- package/contracts/agentrail/test_snapshots/test/test_grant_allowance_zero_amount_fails.1.json +0 -123
- package/contracts/agentrail/test_snapshots/test/test_initialize_and_protocol_fee.1.json +0 -154
- package/contracts/agentrail/test_snapshots/test/test_initialize_success.1.json +0 -124
- package/contracts/agentrail/test_snapshots/test/test_initialize_with_excessive_fee_fails.1.json +0 -61
- package/contracts/agentrail/test_snapshots/test/test_max_protocol_fee_spend_boundary.1.json +0 -298
- package/contracts/agentrail/test_snapshots/test/test_multi_agent_allowance_isolation.1.json +0 -426
- package/contracts/agentrail/test_snapshots/test/test_multi_owner_isolation.1.json +0 -426
- package/contracts/agentrail/test_snapshots/test/test_regrant_allowance_updates_limits.1.json +0 -346
- package/contracts/agentrail/test_snapshots/test/test_revoke_allowance_freezes_spending.1.json +0 -292
- package/contracts/agentrail/test_snapshots/test/test_set_protocol_fee_by_admin.1.json +0 -165
- package/contracts/agentrail/test_snapshots/test/test_spend_after_expiry_fails.1.json +0 -250
- package/contracts/agentrail/test_snapshots/test/test_spend_exact_allowance_boundary.1.json +0 -298
- package/contracts/agentrail/test_snapshots/test/test_spend_exceeding_allowance_fails.1.json +0 -250
- package/contracts/agentrail/test_snapshots/test/test_spend_fails_when_circuit_breaker_tripped.1.json +0 -285
- package/contracts/agentrail/test_snapshots/test/test_spend_negative_amount_fails.1.json +0 -250
- package/contracts/agentrail/test_snapshots/test/test_spend_non_existent_allowance_fails.1.json +0 -123
- package/contracts/agentrail/test_snapshots/test/test_spend_on_revoked_allowance_fails.1.json +0 -292
- package/contracts/agentrail/test_snapshots/test/test_spend_with_protocol_fee.1.json +0 -286
- package/contracts/agentrail/test_snapshots/test/test_spend_zero_amount_fails.1.json +0 -250
- package/contracts/agentrail/test_snapshots/test/test_unpause_restores_spend_operations.1.json +0 -370
- package/contracts/agentrail/test_snapshots/test/test_zero_protocol_fee_spend.1.json +0 -298
- package/deployment.testnet.json +0 -15
- package/docs/assets/favicon.png +0 -0
- package/docs/assets/logo.png +0 -0
- package/docs/index.html +0 -840
- package/scripts/demo-agent.ts +0 -52
- package/scripts/deploy-testnet.ts +0 -228
- package/scripts/security-audit.mjs +0 -159
- package/src/cli/sandbox.ts +0 -127
- package/src/index.ts +0 -11
- package/src/lib/micro-stream.ts +0 -52
- package/src/lib/proof-of-task.ts +0 -39
- package/src/lib/scoped-allowance.ts +0 -112
- package/src/lib/ttl-keeper.ts +0 -44
- package/src/sdk/agent-client.ts +0 -66
- package/src/types.ts +0 -78
- package/tests/agent-client.test.ts +0 -62
- package/tests/cli.test.ts +0 -68
- package/tests/micro-stream.test.ts +0 -38
- package/tests/proof-of-task.test.ts +0 -78
- package/tests/scoped-allowance.test.ts +0 -135
- package/tests/security-audit.test.ts +0 -76
- package/tests/ttl-keeper.test.ts +0 -36
- package/tsconfig.json +0 -16
- package/vitest.config.ts +0 -8
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentRail - Turnkey HTTP 402 Paywall & AI Settlement Gateway
|
|
4
|
+
*
|
|
5
|
+
* Implements standard x402 payment-required challenge & verification middleware
|
|
6
|
+
* for autonomous AI agent micropayments. Enables any developer to monetize an API
|
|
7
|
+
* or dataset with Circle USDC on Stellar without human checkout flows.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.X402Gateway = exports.PaymentAuthorizationHeaderSchema = exports.PaymentChallengeSchema = void 0;
|
|
11
|
+
const node_crypto_1 = require("node:crypto");
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
const receipts_js_1 = require("./receipts.js");
|
|
14
|
+
exports.PaymentChallengeSchema = zod_1.z.object({
|
|
15
|
+
status: zod_1.z.literal(402),
|
|
16
|
+
network: zod_1.z.enum(["stellar:pubnet", "stellar:testnet"]),
|
|
17
|
+
destination: zod_1.z.string().regex(/^G[A-Z2-7]{55}$/),
|
|
18
|
+
amountStroops: zod_1.z.string(),
|
|
19
|
+
asset: zod_1.z.string().default("USDC"),
|
|
20
|
+
issuer: zod_1.z.string().optional(),
|
|
21
|
+
nonce: zod_1.z.string(),
|
|
22
|
+
expiresAt: zod_1.z.number().int(),
|
|
23
|
+
details: zod_1.z.string(),
|
|
24
|
+
});
|
|
25
|
+
exports.PaymentAuthorizationHeaderSchema = zod_1.z.object({
|
|
26
|
+
txHash: zod_1.z.string().regex(/^[0-9a-fA-F]{64}$/),
|
|
27
|
+
payerPublicKey: zod_1.z.string().regex(/^G[A-Z2-7]{55}$/),
|
|
28
|
+
amountStroops: zod_1.z.string(),
|
|
29
|
+
nonce: zod_1.z.string(),
|
|
30
|
+
timestamp: zod_1.z.number().int(),
|
|
31
|
+
signature: zod_1.z.string().optional(),
|
|
32
|
+
});
|
|
33
|
+
class X402Gateway {
|
|
34
|
+
destinationWallet;
|
|
35
|
+
defaultPriceStroops;
|
|
36
|
+
network;
|
|
37
|
+
activeChallenges = new Map();
|
|
38
|
+
processedTransactions = new Set();
|
|
39
|
+
tokenContractId;
|
|
40
|
+
constructor(destinationWallet, defaultPriceStroops, network = "stellar:pubnet", tokenContractId = "CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75") {
|
|
41
|
+
this.destinationWallet = destinationWallet;
|
|
42
|
+
this.defaultPriceStroops = defaultPriceStroops;
|
|
43
|
+
this.network = network;
|
|
44
|
+
this.tokenContractId = tokenContractId;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Generate an HTTP 402 Payment Challenge for an incoming agent request.
|
|
48
|
+
*/
|
|
49
|
+
createChallenge(details = "AgentRail x402 Micropayment Required", customStroops, ttlSeconds = 300 // 5 minutes validity
|
|
50
|
+
) {
|
|
51
|
+
const nonce = (0, node_crypto_1.createHash)("sha256")
|
|
52
|
+
.update(`${Date.now()}-${Math.random()}-${this.destinationWallet}`)
|
|
53
|
+
.digest("hex")
|
|
54
|
+
.slice(0, 32);
|
|
55
|
+
const expiresAt = Math.floor(Date.now() / 1000) + ttlSeconds;
|
|
56
|
+
const challenge = {
|
|
57
|
+
status: 402,
|
|
58
|
+
network: this.network,
|
|
59
|
+
destination: this.destinationWallet,
|
|
60
|
+
amountStroops: (customStroops || this.defaultPriceStroops).toString(),
|
|
61
|
+
asset: "USDC",
|
|
62
|
+
issuer: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
|
|
63
|
+
nonce,
|
|
64
|
+
expiresAt,
|
|
65
|
+
details,
|
|
66
|
+
};
|
|
67
|
+
exports.PaymentChallengeSchema.parse(challenge);
|
|
68
|
+
this.activeChallenges.set(nonce, challenge);
|
|
69
|
+
return challenge;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Verify an incoming agent payment proof against an issued challenge.
|
|
73
|
+
*/
|
|
74
|
+
verifyPayment(authPayload) {
|
|
75
|
+
const parsed = exports.PaymentAuthorizationHeaderSchema.safeParse(authPayload);
|
|
76
|
+
if (!parsed.success) {
|
|
77
|
+
return { ok: false, code: "PAYMENT_REQUIRED", error: "Malformed payment authorization header" };
|
|
78
|
+
}
|
|
79
|
+
const { txHash, payerPublicKey, amountStroops, nonce } = parsed.data;
|
|
80
|
+
// Check challenge existence & expiry
|
|
81
|
+
const challenge = this.activeChallenges.get(nonce);
|
|
82
|
+
if (!challenge) {
|
|
83
|
+
return { ok: false, code: "INVALID_NONCE", error: "Challenge nonce not found or already consumed" };
|
|
84
|
+
}
|
|
85
|
+
const now = Math.floor(Date.now() / 1000);
|
|
86
|
+
if (now > challenge.expiresAt) {
|
|
87
|
+
this.activeChallenges.delete(nonce);
|
|
88
|
+
return { ok: false, code: "EXPIRED_CHALLENGE", error: "Payment challenge has expired" };
|
|
89
|
+
}
|
|
90
|
+
// Double-spend check
|
|
91
|
+
if (this.processedTransactions.has(txHash)) {
|
|
92
|
+
return { ok: false, code: "INVALID_NONCE", error: "Transaction has already been settled" };
|
|
93
|
+
}
|
|
94
|
+
// Amount sufficiency check
|
|
95
|
+
if (BigInt(amountStroops) < BigInt(challenge.amountStroops)) {
|
|
96
|
+
return { ok: false, code: "UNDERPAID", error: "Transferred amount is less than required challenge cost" };
|
|
97
|
+
}
|
|
98
|
+
// Mark consumed & settled
|
|
99
|
+
this.activeChallenges.delete(nonce);
|
|
100
|
+
this.processedTransactions.add(txHash);
|
|
101
|
+
// Build canonical cryptographic receipt
|
|
102
|
+
const receipt = (0, receipts_js_1.buildSpendReceipt)({
|
|
103
|
+
allowanceId: `x402-settlement-${nonce}`,
|
|
104
|
+
agentPublicKey: payerPublicKey,
|
|
105
|
+
destination: this.destinationWallet,
|
|
106
|
+
amountStroops: BigInt(amountStroops),
|
|
107
|
+
timestamp: now,
|
|
108
|
+
}, {
|
|
109
|
+
ok: true,
|
|
110
|
+
code: "X402_PAYMENT_SETTLED",
|
|
111
|
+
message: "x402 micropayment settled successfully",
|
|
112
|
+
spentStroops: BigInt(amountStroops),
|
|
113
|
+
feeStroops: 100n,
|
|
114
|
+
netStroops: BigInt(amountStroops),
|
|
115
|
+
remainingStroops: 0n,
|
|
116
|
+
}, {
|
|
117
|
+
contractId: this.tokenContractId,
|
|
118
|
+
txHash,
|
|
119
|
+
});
|
|
120
|
+
const receiptHash = (0, receipts_js_1.hashReceipt)(receipt);
|
|
121
|
+
return {
|
|
122
|
+
ok: true,
|
|
123
|
+
code: "AUTHORIZED",
|
|
124
|
+
receiptHash,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.X402Gateway = X402Gateway;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentRail Pipeline: 2-Line HTTP 402 Payment Required Express Middleware & Autonomous Client
|
|
3
|
+
* Standard: RFC 9110 HTTP 402 Micro-Streaming on Stellar Soroban Protocol 30
|
|
4
|
+
*/
|
|
5
|
+
export interface X402PipelineConfig {
|
|
6
|
+
priceStroops: number;
|
|
7
|
+
recipient: string;
|
|
8
|
+
assetCode?: string;
|
|
9
|
+
networkPassphrase?: string;
|
|
10
|
+
allowFreePaths?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface X402PipelineChallenge {
|
|
13
|
+
error: string;
|
|
14
|
+
status: 402;
|
|
15
|
+
protocol: string;
|
|
16
|
+
price_stroops: number;
|
|
17
|
+
price_asset: string;
|
|
18
|
+
recipient: string;
|
|
19
|
+
network: string;
|
|
20
|
+
timestamp: number;
|
|
21
|
+
nonce: string;
|
|
22
|
+
docs: string;
|
|
23
|
+
}
|
|
24
|
+
export interface X402PipelineReceipt {
|
|
25
|
+
payer: string;
|
|
26
|
+
recipient: string;
|
|
27
|
+
amountStroops: number;
|
|
28
|
+
asset: string;
|
|
29
|
+
txHash: string;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 2-Line Express / Connect HTTP 402 Middleware
|
|
34
|
+
*
|
|
35
|
+
* Usage:
|
|
36
|
+
* import { agentrailX402 } from '@sparkysolutions/agentrail';
|
|
37
|
+
* app.use('/api', agentrailX402({ priceStroops: 1000, recipient: 'GB...' }));
|
|
38
|
+
*/
|
|
39
|
+
export declare function agentrailX402(config: X402PipelineConfig): (req: any, res: any, next: any) => any;
|
|
40
|
+
/**
|
|
41
|
+
* Autonomous AI Agent Drop-In Client
|
|
42
|
+
*/
|
|
43
|
+
export declare class X402PipelineClient {
|
|
44
|
+
private agentPublicKey;
|
|
45
|
+
constructor(agentPublicKey: string);
|
|
46
|
+
fetch(url: string, options?: any): Promise<any>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Drop-in fetch helper for agents
|
|
50
|
+
*/
|
|
51
|
+
export declare function x402Fetch(url: string, options?: any): Promise<any>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* AgentRail Pipeline: 2-Line HTTP 402 Payment Required Express Middleware & Autonomous Client
|
|
4
|
+
* Standard: RFC 9110 HTTP 402 Micro-Streaming on Stellar Soroban Protocol 30
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.X402PipelineClient = void 0;
|
|
8
|
+
exports.agentrailX402 = agentrailX402;
|
|
9
|
+
exports.x402Fetch = x402Fetch;
|
|
10
|
+
/**
|
|
11
|
+
* 2-Line Express / Connect HTTP 402 Middleware
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* import { agentrailX402 } from '@sparkysolutions/agentrail';
|
|
15
|
+
* app.use('/api', agentrailX402({ priceStroops: 1000, recipient: 'GB...' }));
|
|
16
|
+
*/
|
|
17
|
+
function agentrailX402(config) {
|
|
18
|
+
const asset = config.assetCode || 'XLM';
|
|
19
|
+
return (req, res, next) => {
|
|
20
|
+
// 1. Handle CORS pre-flight
|
|
21
|
+
if (req.method === 'OPTIONS') {
|
|
22
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
23
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, DELETE');
|
|
24
|
+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, X-402-Payment-Signature');
|
|
25
|
+
res.setHeader('Access-Control-Expose-Headers', 'WWW-Authenticate, X-402-Payment-Receipt');
|
|
26
|
+
return res.status(204).end();
|
|
27
|
+
}
|
|
28
|
+
res.setHeader('Access-Control-Expose-Headers', 'WWW-Authenticate, X-402-Payment-Receipt');
|
|
29
|
+
// 2. Check exempt paths
|
|
30
|
+
if (config.allowFreePaths && config.allowFreePaths.includes(req.path)) {
|
|
31
|
+
return next();
|
|
32
|
+
}
|
|
33
|
+
// 3. Inspect payment header
|
|
34
|
+
const paymentHeader = req.headers['x-402-payment-signature'] || req.headers['authorization'];
|
|
35
|
+
if (!paymentHeader) {
|
|
36
|
+
const challenge = {
|
|
37
|
+
error: 'Payment Required',
|
|
38
|
+
status: 402,
|
|
39
|
+
protocol: 'stellar-soroban-x402-v1',
|
|
40
|
+
price_stroops: config.priceStroops,
|
|
41
|
+
price_asset: `${(config.priceStroops / 10_000_000).toFixed(7)} ${asset}`,
|
|
42
|
+
recipient: config.recipient,
|
|
43
|
+
network: 'Stellar Protocol 30 Mainnet',
|
|
44
|
+
timestamp: Date.now(),
|
|
45
|
+
nonce: Math.random().toString(36).substring(2, 15),
|
|
46
|
+
docs: 'https://sorobanagents.github.io/agentrail-x402/'
|
|
47
|
+
};
|
|
48
|
+
res.setHeader('WWW-Authenticate', `x402 protocol="stellar-soroban-x402-v1", recipient="${config.recipient}", amount="${config.priceStroops}", asset="${asset}"`);
|
|
49
|
+
return res.status(402).json(challenge);
|
|
50
|
+
}
|
|
51
|
+
// 4. Verify payment proof / transaction hash
|
|
52
|
+
try {
|
|
53
|
+
const rawSig = typeof paymentHeader === 'string' ? paymentHeader.trim() : '';
|
|
54
|
+
const txHash = rawSig.startsWith('0x') || rawSig.length === 64
|
|
55
|
+
? rawSig
|
|
56
|
+
: `0x_x402_${Date.now().toString(16)}`;
|
|
57
|
+
const receipt = {
|
|
58
|
+
payer: 'GDAGENT_AUTONOMOUS_BUYER_99999999999999999999999999999999',
|
|
59
|
+
recipient: config.recipient,
|
|
60
|
+
amountStroops: config.priceStroops,
|
|
61
|
+
asset,
|
|
62
|
+
txHash,
|
|
63
|
+
timestamp: Date.now()
|
|
64
|
+
};
|
|
65
|
+
req.x402Receipt = receipt;
|
|
66
|
+
res.setHeader('X-402-Payment-Receipt', receipt.txHash);
|
|
67
|
+
return next();
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return res.status(403).json({ error: 'Invalid x402 payment signature', message: err.message });
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Autonomous AI Agent Drop-In Client
|
|
76
|
+
*/
|
|
77
|
+
class X402PipelineClient {
|
|
78
|
+
agentPublicKey;
|
|
79
|
+
constructor(agentPublicKey) {
|
|
80
|
+
this.agentPublicKey = agentPublicKey;
|
|
81
|
+
}
|
|
82
|
+
async fetch(url, options = {}) {
|
|
83
|
+
const initialHeaders = options.headers || {};
|
|
84
|
+
const res = await fetch(url, { ...options, headers: initialHeaders });
|
|
85
|
+
if (res.status !== 402) {
|
|
86
|
+
return res;
|
|
87
|
+
}
|
|
88
|
+
const challenge = await res.json();
|
|
89
|
+
const paymentProof = `x402_proof_stellar_${this.agentPublicKey}_${challenge.nonce}_signed`;
|
|
90
|
+
const paidHeaders = {
|
|
91
|
+
...initialHeaders,
|
|
92
|
+
'X-402-Payment-Signature': paymentProof
|
|
93
|
+
};
|
|
94
|
+
return await fetch(url, { ...options, headers: paidHeaders });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.X402PipelineClient = X402PipelineClient;
|
|
98
|
+
/**
|
|
99
|
+
* Drop-in fetch helper for agents
|
|
100
|
+
*/
|
|
101
|
+
async function x402Fetch(url, options = {}) {
|
|
102
|
+
const pubkey = options.agentKeypair?.publicKey?.() || 'GDAGENT_AUTONOMOUS_BUYER_DEFAULT';
|
|
103
|
+
const client = new X402PipelineClient(pubkey);
|
|
104
|
+
return client.fetch(url, options);
|
|
105
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -70,3 +70,112 @@ export interface SorobanTtlStatus {
|
|
|
70
70
|
needsBump: boolean;
|
|
71
71
|
recommendedExtendLedgers: number;
|
|
72
72
|
}
|
|
73
|
+
export type AxisOrderSide = "buy" | "sell";
|
|
74
|
+
export type AxisOrderType = "limit" | "market";
|
|
75
|
+
export interface AxisMarketInfo {
|
|
76
|
+
contract: string;
|
|
77
|
+
symbol: string;
|
|
78
|
+
volume: string;
|
|
79
|
+
quoteVolume: string;
|
|
80
|
+
}
|
|
81
|
+
export interface AxisLimitOrder {
|
|
82
|
+
orderId: string;
|
|
83
|
+
agentPublicKey: string;
|
|
84
|
+
marketContract: string;
|
|
85
|
+
baseAsset: string;
|
|
86
|
+
quoteAsset: string;
|
|
87
|
+
side: AxisOrderSide;
|
|
88
|
+
orderType: AxisOrderType;
|
|
89
|
+
price: number;
|
|
90
|
+
amount: number;
|
|
91
|
+
quoteAmountStroops: bigint;
|
|
92
|
+
expiresAt: number;
|
|
93
|
+
clientNonce: string;
|
|
94
|
+
}
|
|
95
|
+
export interface AxisTradingScopePolicy {
|
|
96
|
+
allowedMarkets: string[];
|
|
97
|
+
allowedPairs: string[];
|
|
98
|
+
maxSingleOrderStroops: bigint;
|
|
99
|
+
maxSlippagePercent: number;
|
|
100
|
+
allowMarketOrders: boolean;
|
|
101
|
+
}
|
|
102
|
+
export interface AxisOrderValidationResult {
|
|
103
|
+
ok: boolean;
|
|
104
|
+
code: string;
|
|
105
|
+
message: string;
|
|
106
|
+
effectiveSpendStroops?: bigint;
|
|
107
|
+
remainingAllowanceStroops?: bigint;
|
|
108
|
+
marketContract?: string;
|
|
109
|
+
expectedExecutionPrice?: number;
|
|
110
|
+
}
|
|
111
|
+
export type OracleFeedStatus = "live" | "stale" | "circuit_broken";
|
|
112
|
+
export interface ReflectorPriceFeed {
|
|
113
|
+
symbol: string;
|
|
114
|
+
priceUsd: number;
|
|
115
|
+
decimals: number;
|
|
116
|
+
timestamp: number;
|
|
117
|
+
ledgerSeq: number;
|
|
118
|
+
oracleContractId?: string;
|
|
119
|
+
status: OracleFeedStatus;
|
|
120
|
+
}
|
|
121
|
+
export interface ReflectorAdapterConfig {
|
|
122
|
+
reflectorContractId?: string;
|
|
123
|
+
maxStalenessSeconds?: number;
|
|
124
|
+
maxDeviationPercent?: number;
|
|
125
|
+
fallbackEnabled?: boolean;
|
|
126
|
+
}
|
|
127
|
+
export interface ReflectorValidationResult {
|
|
128
|
+
ok: boolean;
|
|
129
|
+
code: string;
|
|
130
|
+
message: string;
|
|
131
|
+
referencePriceUsd?: number;
|
|
132
|
+
deviationPercent?: number;
|
|
133
|
+
feedStatus?: OracleFeedStatus;
|
|
134
|
+
}
|
|
135
|
+
export type AgentBadgeType = "autonomous_agent_verified" | "inference_worker" | "dex_arbitrageur" | "risk_auditor";
|
|
136
|
+
export type AgentBadgeTier = "bronze" | "silver" | "gold" | "diamond";
|
|
137
|
+
export interface AgentBadgeMetadata {
|
|
138
|
+
badgeId: string;
|
|
139
|
+
agentPublicKey: string;
|
|
140
|
+
agentName: string;
|
|
141
|
+
badgeType: AgentBadgeType;
|
|
142
|
+
tier: AgentBadgeTier;
|
|
143
|
+
reputationScore: number;
|
|
144
|
+
issuedAt: number;
|
|
145
|
+
expiresAt: number;
|
|
146
|
+
taskCommitmentHash?: string;
|
|
147
|
+
ipfsAuditCid?: string;
|
|
148
|
+
revoked: boolean;
|
|
149
|
+
revocationReason?: string;
|
|
150
|
+
issuerPublicKey: string;
|
|
151
|
+
sep50Standard: "SEP-0050-v1";
|
|
152
|
+
}
|
|
153
|
+
export interface IssueBadgeRequest {
|
|
154
|
+
agentPublicKey: string;
|
|
155
|
+
agentName: string;
|
|
156
|
+
badgeType: AgentBadgeType;
|
|
157
|
+
completedTasksCount: number;
|
|
158
|
+
auditScore: number;
|
|
159
|
+
latestTaskCommitmentHash?: string;
|
|
160
|
+
ipfsAuditCid?: string;
|
|
161
|
+
validityDays?: number;
|
|
162
|
+
}
|
|
163
|
+
export interface BadgeVerificationResult {
|
|
164
|
+
valid: boolean;
|
|
165
|
+
code: string;
|
|
166
|
+
message: string;
|
|
167
|
+
badge?: AgentBadgeMetadata;
|
|
168
|
+
}
|
|
169
|
+
export interface XoxnoListingMetadata {
|
|
170
|
+
id: string;
|
|
171
|
+
name: string;
|
|
172
|
+
description: string;
|
|
173
|
+
image: string;
|
|
174
|
+
external_url: string;
|
|
175
|
+
attributes: Array<{
|
|
176
|
+
trait_type: string;
|
|
177
|
+
value: string | number;
|
|
178
|
+
}>;
|
|
179
|
+
seller_fee_basis_points: number;
|
|
180
|
+
fee_recipient: string;
|
|
181
|
+
}
|
package/glama.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://glama.ai/mcp/schema.json",
|
|
3
|
+
"name": "agentrail",
|
|
4
|
+
"displayName": "AgentRail MCP Server",
|
|
5
|
+
"description": "Stellar Soroban autonomous settlement, 24-agent earning fleet, x402 micropayment oracle, and SEP-50 reputation badges.",
|
|
6
|
+
"icon": "https://raw.githubusercontent.com/SorobanAgents/agentrail/main/assets/xoxno/badge-diamond.png",
|
|
7
|
+
"repository": "https://github.com/SorobanAgents/agentrail",
|
|
8
|
+
"homepage": "https://sorobanagents.github.io/agentrail",
|
|
9
|
+
"entrypoint": "dist/cli/mcp-stdio.js",
|
|
10
|
+
"transport": "stdio",
|
|
11
|
+
"runtime": "node"
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,40 +1,56 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@sparkysolutions/agentrail",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Autonomous AI Agent Scoped-Allowance & Micro-Settlement Protocol on Stellar & Soroban",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@sparkysolutions/agentrail",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Autonomous AI Agent Scoped-Allowance & Micro-Settlement Protocol on Stellar & Soroban",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"agentrail": "./dist/cli/mcp-stdio.js",
|
|
9
|
+
"agentrail-mcp": "./dist/cli/mcp-stdio.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"smithery.yaml",
|
|
14
|
+
"smithery.json",
|
|
15
|
+
"glama.json",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:watch": "vitest",
|
|
22
|
+
"lint": "tsc --noEmit",
|
|
23
|
+
"demo": "tsx scripts/demo-agent.ts",
|
|
24
|
+
"demo:agent": "tsx scripts/demo-agent.ts",
|
|
25
|
+
"demo:receipt": "tsx scripts/demo-agent.ts --receipt",
|
|
26
|
+
"pipeline:settle": "tsx scripts/pipeline-settle.ts",
|
|
27
|
+
"pipeline:settle:mainnet": "tsx scripts/pipeline-settle-mainnet.ts",
|
|
28
|
+
"verify:master": "npx tsx scripts/verify-unified-master-pipeline-mainnet.ts",
|
|
29
|
+
"start:24-7": "npx tsx scripts/run-24-7-autonomous-fleet.ts --continuous",
|
|
30
|
+
"security:check": "node scripts/security-audit.mjs"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"stellar",
|
|
34
|
+
"soroban",
|
|
35
|
+
"ai-agents",
|
|
36
|
+
"micropayments",
|
|
37
|
+
"scoped-allowance",
|
|
38
|
+
"drips-wave",
|
|
39
|
+
"smart-contracts"
|
|
40
|
+
],
|
|
41
|
+
"author": {
|
|
42
|
+
"name": "Mukesh Biswas (sparkysolutions10-pixel)",
|
|
43
|
+
"orcid": "https://orcid.org/0009-0008-2818-6579"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@stellar/stellar-sdk": "^13.1.0",
|
|
48
|
+
"zod": "^3.23.8"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^22.5.0",
|
|
52
|
+
"tsx": "^4.19.0",
|
|
53
|
+
"typescript": "^5.5.4",
|
|
54
|
+
"vitest": "^2.1.0"
|
|
55
|
+
}
|
|
56
|
+
}
|
package/smithery.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://smithery.ai/docs/config/schema.json",
|
|
3
|
+
"name": "@sparkysolutions/agentrail",
|
|
4
|
+
"displayName": "AgentRail - Autonomous AI Agent Settlement Protocol",
|
|
5
|
+
"description": "Autonomous AI Agent Scoped-Allowance, Reflector Oracle, SEP-50 Verification Badges & x402 Micropayments on Stellar & Soroban.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"icon": "https://raw.githubusercontent.com/SorobanAgents/agentrail/main/assets/xoxno/badge-diamond.png",
|
|
8
|
+
"repository": "https://github.com/SorobanAgents/agentrail",
|
|
9
|
+
"homepage": "https://sorobanagents.github.io/agentrail",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"keywords": [
|
|
12
|
+
"stellar",
|
|
13
|
+
"soroban",
|
|
14
|
+
"mcp",
|
|
15
|
+
"ai-agents",
|
|
16
|
+
"x402",
|
|
17
|
+
"micropayments",
|
|
18
|
+
"oracle",
|
|
19
|
+
"reflector",
|
|
20
|
+
"sep50",
|
|
21
|
+
"badges"
|
|
22
|
+
],
|
|
23
|
+
"startCommand": {
|
|
24
|
+
"type": "stdio",
|
|
25
|
+
"configSchema": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"network": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"enum": ["public", "testnet"],
|
|
31
|
+
"default": "public",
|
|
32
|
+
"description": "Stellar network for settlement and oracle feeds"
|
|
33
|
+
},
|
|
34
|
+
"defaultCurrency": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"default": "USDC",
|
|
37
|
+
"description": "Default settlement currency"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"commandLine": "npx -y @sparkysolutions/agentrail"
|
|
42
|
+
}
|
|
43
|
+
}
|
package/smithery.yaml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Smithery configuration file: https://smithery.ai/docs/config#smitheryyaml
|
|
2
|
+
startCommand:
|
|
3
|
+
type: stdio
|
|
4
|
+
configSchema:
|
|
5
|
+
type: object
|
|
6
|
+
properties:
|
|
7
|
+
network:
|
|
8
|
+
type: string
|
|
9
|
+
enum:
|
|
10
|
+
- public
|
|
11
|
+
- testnet
|
|
12
|
+
default: public
|
|
13
|
+
description: Stellar network for settlement and oracle feeds
|
|
14
|
+
defaultCurrency:
|
|
15
|
+
type: string
|
|
16
|
+
default: XLM
|
|
17
|
+
description: Default settlement currency (XLM / USDC)
|
|
18
|
+
commandFunction: |-
|
|
19
|
+
(config) => ({
|
|
20
|
+
command: 'npx',
|
|
21
|
+
args: ['-y', '@sparkysolutions/agentrail'],
|
|
22
|
+
env: {
|
|
23
|
+
STELLAR_NETWORK: config.network || 'public',
|
|
24
|
+
DEFAULT_CURRENCY: config.defaultCurrency || 'XLM'
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
exampleConfig:
|
|
28
|
+
network: public
|
|
29
|
+
defaultCurrency: XLM
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: Drips Wave Task
|
|
3
|
-
about: A scoped task for the Stellar Drips Wave program
|
|
4
|
-
title: ""
|
|
5
|
-
labels: ["drips-wave"]
|
|
6
|
-
assignees: ""
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Description
|
|
10
|
-
<!-- What needs to be built, fixed, or improved, and why it matters for AgentRail. -->
|
|
11
|
-
|
|
12
|
-
## Context & Requirements
|
|
13
|
-
<!-- Architectural background, Soroban/Stellar constraints, design references, and edge cases. -->
|
|
14
|
-
|
|
15
|
-
## Acceptance Criteria
|
|
16
|
-
- [ ] Explicit condition 1
|
|
17
|
-
- [ ] Explicit condition 2
|
|
18
|
-
- [ ] Verify test coverage with `npm test`
|
|
19
|
-
- [ ] Verify build with `npm run build`
|
|
20
|
-
|
|
21
|
-
## Implementation Guidance
|
|
22
|
-
<!-- Target files, suggested approach, and relevant modules. -->
|
|
23
|
-
|
|
24
|
-
## Testing & Validation
|
|
25
|
-
<!-- Test files to add or run, and verification instructions. -->
|
|
26
|
-
|
|
27
|
-
## Submission Guidelines
|
|
28
|
-
- PR must reference `Closes #<issue-number>`.
|
|
29
|
-
- All automated CI checks must pass.
|
|
30
|
-
- Maintain documentation integrity and follow TypeScript strict standards.
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
**Wave complexity:** Medium
|