@aifinpay/mcp 2.2.2 → 2.2.4
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 +34 -13
- package/bin/aifinpay-mcp.js +25 -3
- package/dist/directory.d.ts +55 -0
- package/dist/directory.d.ts.map +1 -0
- package/dist/directory.js +56 -0
- package/dist/directory.js.map +1 -0
- package/dist/native-price.d.ts +34 -0
- package/dist/native-price.d.ts.map +1 -0
- package/dist/native-price.js +127 -0
- package/dist/native-price.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +6 -0
- package/dist/server.js.map +1 -1
- package/dist/tools/agent-address.d.ts +4 -0
- package/dist/tools/agent-address.d.ts.map +1 -1
- package/dist/tools/agent-address.js +7 -1
- package/dist/tools/agent-address.js.map +1 -1
- package/dist/tools/agent-call.d.ts +68 -0
- package/dist/tools/agent-call.d.ts.map +1 -0
- package/dist/tools/agent-call.js +129 -0
- package/dist/tools/agent-call.js.map +1 -0
- package/dist/tools/agent-claim-self.d.ts +66 -0
- package/dist/tools/agent-claim-self.d.ts.map +1 -0
- package/dist/tools/agent-claim-self.js +300 -0
- package/dist/tools/agent-claim-self.js.map +1 -0
- package/dist/tools/agent-quote.d.ts +41 -0
- package/dist/tools/agent-quote.d.ts.map +1 -0
- package/dist/tools/agent-quote.js +81 -0
- package/dist/tools/agent-quote.js.map +1 -0
- package/dist/tools/pay-with-split.d.ts +93 -0
- package/dist/tools/pay-with-split.d.ts.map +1 -0
- package/dist/tools/pay-with-split.js +138 -0
- package/dist/tools/pay-with-split.js.map +1 -0
- package/dist/tools/payable-fetch.d.ts.map +1 -1
- package/dist/tools/payable-fetch.js +8 -14
- package/dist/tools/payable-fetch.js.map +1 -1
- package/package.json +2 -2
- package/skills/SKILL.md +74 -37
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ToolContext } from "../server.js";
|
|
2
|
+
/**
|
|
3
|
+
* `agent_call` — unified registry-resolved paid HTTP call.
|
|
4
|
+
*
|
|
5
|
+
* The agent picks a provider by name ("exa", "io-net", "venice", …),
|
|
6
|
+
* the SDK looks up the bridge URL + price from the public AiFinPay
|
|
7
|
+
* registry, negotiates the 402 challenge, settles on Polygon via
|
|
8
|
+
* B2BSplitter.payMatic, retries with proof, and returns the upstream
|
|
9
|
+
* response body.
|
|
10
|
+
*
|
|
11
|
+
* Use this in preference to `payable_fetch` when you have a registered
|
|
12
|
+
* provider name — it auto-routes price, chain, and bridge URL.
|
|
13
|
+
*
|
|
14
|
+
* Requires the EVM address (from `agent_address`) to be funded with POL
|
|
15
|
+
* on Polygon mainnet (gas + payment), or USDC if the provider quotes in
|
|
16
|
+
* stablecoin.
|
|
17
|
+
*/
|
|
18
|
+
export declare function agentCallTool(): {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: string;
|
|
23
|
+
properties: {
|
|
24
|
+
provider: {
|
|
25
|
+
type: string;
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
body: {
|
|
29
|
+
type: string;
|
|
30
|
+
description: string;
|
|
31
|
+
additionalProperties: boolean;
|
|
32
|
+
};
|
|
33
|
+
method: {
|
|
34
|
+
type: string;
|
|
35
|
+
enum: string[];
|
|
36
|
+
default: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
cost: {
|
|
40
|
+
type: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
required: string[];
|
|
45
|
+
};
|
|
46
|
+
annotations: {
|
|
47
|
+
readOnlyHint: boolean;
|
|
48
|
+
openWorldHint: boolean;
|
|
49
|
+
destructiveHint: boolean;
|
|
50
|
+
};
|
|
51
|
+
outputSchema: {
|
|
52
|
+
type: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export declare function runAgentCall(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
56
|
+
isError: boolean;
|
|
57
|
+
content: {
|
|
58
|
+
type: string;
|
|
59
|
+
text: string;
|
|
60
|
+
}[];
|
|
61
|
+
} | {
|
|
62
|
+
content: {
|
|
63
|
+
type: string;
|
|
64
|
+
text: string;
|
|
65
|
+
}[];
|
|
66
|
+
isError?: undefined;
|
|
67
|
+
}>;
|
|
68
|
+
//# sourceMappingURL=agent-call.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-call.d.ts","sourceRoot":"","sources":["../../src/tools/agent-call.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgD5B;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GAkE9B"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent_call` — unified registry-resolved paid HTTP call.
|
|
3
|
+
*
|
|
4
|
+
* The agent picks a provider by name ("exa", "io-net", "venice", …),
|
|
5
|
+
* the SDK looks up the bridge URL + price from the public AiFinPay
|
|
6
|
+
* registry, negotiates the 402 challenge, settles on Polygon via
|
|
7
|
+
* B2BSplitter.payMatic, retries with proof, and returns the upstream
|
|
8
|
+
* response body.
|
|
9
|
+
*
|
|
10
|
+
* Use this in preference to `payable_fetch` when you have a registered
|
|
11
|
+
* provider name — it auto-routes price, chain, and bridge URL.
|
|
12
|
+
*
|
|
13
|
+
* Requires the EVM address (from `agent_address`) to be funded with POL
|
|
14
|
+
* on Polygon mainnet (gas + payment), or USDC if the provider quotes in
|
|
15
|
+
* stablecoin.
|
|
16
|
+
*/
|
|
17
|
+
export function agentCallTool() {
|
|
18
|
+
return {
|
|
19
|
+
name: "agent_call",
|
|
20
|
+
description: "USE THIS TOOL whenever the user asks to call, pay, query, search via, " +
|
|
21
|
+
"or use any of these AiFinPay-registered paid providers: 'exa' (neural " +
|
|
22
|
+
"web search), 'io-net' (LLM inference, Llama-3.3-70B), 'venice' (image " +
|
|
23
|
+
"generation), or any other provider listed at " +
|
|
24
|
+
"https://aifinpay.io/api/providers. " +
|
|
25
|
+
"DO NOT use WebSearch or WebFetch for these providers — they are paid " +
|
|
26
|
+
"APIs accessible only through this MCP, and a plain web search will " +
|
|
27
|
+
"return public marketing pages instead of the actual API. " +
|
|
28
|
+
"Natural-language triggers that should invoke this tool: 'call exa for X', " +
|
|
29
|
+
"'search exa', 'pay venice to generate Y', 'use io-net to run inference', " +
|
|
30
|
+
"'query exa', 'ask io-net'. Provider name maps to the `provider` argument. " +
|
|
31
|
+
"Body is the provider-specific request shape (e.g. {messages:[...]} for " +
|
|
32
|
+
"io-net inference, {query:'...'} for exa search). Returns the upstream " +
|
|
33
|
+
"response with the Polygon tx hash + Polygonscan link prepended. " +
|
|
34
|
+
"Settlement is automatic — Polygon mainnet, atomic 99/1 split via B2BSplitter.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
provider: {
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Registered provider name. Example: 'io-net', 'exa', 'venice'.",
|
|
41
|
+
},
|
|
42
|
+
body: {
|
|
43
|
+
type: "object",
|
|
44
|
+
description: "Provider-specific request body. Forwarded to the bridge after payment.",
|
|
45
|
+
additionalProperties: true,
|
|
46
|
+
},
|
|
47
|
+
method: {
|
|
48
|
+
type: "string",
|
|
49
|
+
enum: ["GET", "POST"],
|
|
50
|
+
default: "POST",
|
|
51
|
+
description: "HTTP method. Defaults to POST (matches all current providers).",
|
|
52
|
+
},
|
|
53
|
+
cost: {
|
|
54
|
+
type: "number",
|
|
55
|
+
description: "Optional override of the registry-quoted price (USD). Use to enforce a stricter budget cap.",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
required: ["provider"],
|
|
59
|
+
},
|
|
60
|
+
// Settles a real on-chain payment to an arbitrary registered provider.
|
|
61
|
+
annotations: { readOnlyHint: false, openWorldHint: true, destructiveHint: true },
|
|
62
|
+
outputSchema: { type: "object" },
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export async function runAgentCall(ctx, args) {
|
|
66
|
+
const provider = args.provider;
|
|
67
|
+
const body = args.body;
|
|
68
|
+
const method = args.method ?? "POST";
|
|
69
|
+
const cost = args.cost;
|
|
70
|
+
if (!provider) {
|
|
71
|
+
return {
|
|
72
|
+
isError: true,
|
|
73
|
+
content: [{ type: "text", text: "`provider` is required (e.g. 'exa', 'io-net')" }],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const resp = await ctx.agent.call({
|
|
78
|
+
provider,
|
|
79
|
+
body,
|
|
80
|
+
method,
|
|
81
|
+
cost,
|
|
82
|
+
});
|
|
83
|
+
if (resp === null) {
|
|
84
|
+
return {
|
|
85
|
+
isError: true,
|
|
86
|
+
content: [{ type: "text", text: "Call skipped — budget cap exceeded (on_limit_exceeded='skip')." }],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const text = await resp.text();
|
|
90
|
+
let parsed = text;
|
|
91
|
+
try {
|
|
92
|
+
parsed = JSON.parse(text);
|
|
93
|
+
}
|
|
94
|
+
catch { /* keep as text */ }
|
|
95
|
+
// Pull the @internal settlement metadata attached by AiFinPayAgent.call
|
|
96
|
+
// (see unifiedAgent.ts). Surfacing the tx hash here lets the agent show
|
|
97
|
+
// a clickable explorer link in chat without re-querying the chain.
|
|
98
|
+
const meta = resp;
|
|
99
|
+
const txHash = meta.aifinpayTx;
|
|
100
|
+
const txChain = meta.aifinpayChain;
|
|
101
|
+
const txLine = txHash
|
|
102
|
+
? `Paid on ${txChain ?? "polygon"}. Tx: ${txHash} → https://${txChain === "solana" ? "solscan.io/tx" : "polygonscan.com/tx"}/${txHash}\n\n`
|
|
103
|
+
: "";
|
|
104
|
+
const bodyText = typeof parsed === "string"
|
|
105
|
+
? parsed
|
|
106
|
+
: JSON.stringify({ status: resp.status, body: parsed }, null, 2);
|
|
107
|
+
return {
|
|
108
|
+
content: [
|
|
109
|
+
{
|
|
110
|
+
type: "text",
|
|
111
|
+
text: txLine + bodyText,
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
118
|
+
const hint = message.toLowerCase().includes("budget")
|
|
119
|
+
? "Tip: increase the per-call cost cap or use `agent_quote` to preview before paying."
|
|
120
|
+
: message.toLowerCase().includes("revert") || message.toLowerCase().includes("insufficient")
|
|
121
|
+
? `Tip: ensure the EVM address ${ctx.agent.evmAddress} holds enough POL on Polygon for gas + payment.`
|
|
122
|
+
: `Provider may be misconfigured. Check https://aifinpay.io/api/providers.`;
|
|
123
|
+
return {
|
|
124
|
+
isError: true,
|
|
125
|
+
content: [{ type: "text", text: `agent_call failed: ${message}\n\n${hint}` }],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=agent-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-call.js","sourceRoot":"","sources":["../../src/tools/agent-call.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,WAAW,EACT,wEAAwE;YACxE,wEAAwE;YACxE,wEAAwE;YACxE,+CAA+C;YAC/C,qCAAqC;YACrC,uEAAuE;YACvE,qEAAqE;YACrE,2DAA2D;YAC3D,4EAA4E;YAC5E,2EAA2E;YAC3E,4EAA4E;YAC5E,yEAAyE;YACzE,wEAAwE;YACxE,kEAAkE;YAClE,+EAA+E;QACjF,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBAC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AY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,MAAM,IAAI,GACR,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACtC,CAAC,CAAC,oFAAoF;YACtF,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;gBAC1F,CAAC,CAAC,+BAA+B,GAAG,CAAC,KAAK,CAAC,UAAU,iDAAiD;gBACtG,CAAC,CAAC,yEAAyE,CAAC;QAClF,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB,OAAO,OAAO,IAAI,EAAE,EAAE,CAAC;SAC9E,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ToolContext } from "../server.js";
|
|
2
|
+
/**
|
|
3
|
+
* `agent_claim_self` — agent attaches itself to a user's AiFinPay account
|
|
4
|
+
* autonomously by signing a claim challenge with its own key.
|
|
5
|
+
*
|
|
6
|
+
* Flow (executed inside the tool, no copy-paste between UIs):
|
|
7
|
+
* 1. User signs in to /login on aifinpay.io → gets a magic-link
|
|
8
|
+
* email with URL like `https://aifinpay.io/api/auth/verify?token=…`
|
|
9
|
+
* 2. User pastes that URL to the agent: "claim yourself on my account
|
|
10
|
+
* using this magic link"
|
|
11
|
+
* 3. Agent calls this tool with the magic_link_url
|
|
12
|
+
* 4. Tool hits the magic link → server issues session cookie
|
|
13
|
+
* 5. Tool POSTs to /api/me/agents/challenge with the agent's EVM address
|
|
14
|
+
* 6. Tool signs the returned message with the agent's EVM key (EIP-191)
|
|
15
|
+
* 7. Tool POSTs to /api/me/agents/claim → server verifies signature →
|
|
16
|
+
* agent attached to user's watchlist
|
|
17
|
+
*
|
|
18
|
+
* Optional `label` field gives the agent a friendly name in the user's UI.
|
|
19
|
+
*
|
|
20
|
+
* Security model:
|
|
21
|
+
* - Magic-link URL is one-shot, 15-min TTL, identifies the user
|
|
22
|
+
* - Signature proves the agent holds the EVM private key
|
|
23
|
+
* - Combination: "this user OWNS this agent". Either alone is
|
|
24
|
+
* insufficient (signature alone can't pick an account; magic link
|
|
25
|
+
* alone can't prove key control).
|
|
26
|
+
*/
|
|
27
|
+
export declare function agentClaimSelfTool(): {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: string;
|
|
32
|
+
properties: {
|
|
33
|
+
magic_link_url: {
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
};
|
|
37
|
+
label: {
|
|
38
|
+
type: string;
|
|
39
|
+
description: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
required: string[];
|
|
43
|
+
};
|
|
44
|
+
annotations: {
|
|
45
|
+
readOnlyHint: boolean;
|
|
46
|
+
openWorldHint: boolean;
|
|
47
|
+
destructiveHint: boolean;
|
|
48
|
+
};
|
|
49
|
+
outputSchema: {
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export declare function runAgentClaimSelf(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
54
|
+
isError: boolean;
|
|
55
|
+
content: {
|
|
56
|
+
type: string;
|
|
57
|
+
text: string;
|
|
58
|
+
}[];
|
|
59
|
+
} | {
|
|
60
|
+
content: {
|
|
61
|
+
type: string;
|
|
62
|
+
text: string;
|
|
63
|
+
}[];
|
|
64
|
+
isError?: undefined;
|
|
65
|
+
}>;
|
|
66
|
+
//# sourceMappingURL=agent-claim-self.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-claim-self.d.ts","sourceRoot":"","sources":["../../src/tools/agent-claim-self.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;EA8BjC;AAqED,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;;GAmMtF"}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent_claim_self` — agent attaches itself to a user's AiFinPay account
|
|
3
|
+
* autonomously by signing a claim challenge with its own key.
|
|
4
|
+
*
|
|
5
|
+
* Flow (executed inside the tool, no copy-paste between UIs):
|
|
6
|
+
* 1. User signs in to /login on aifinpay.io → gets a magic-link
|
|
7
|
+
* email with URL like `https://aifinpay.io/api/auth/verify?token=…`
|
|
8
|
+
* 2. User pastes that URL to the agent: "claim yourself on my account
|
|
9
|
+
* using this magic link"
|
|
10
|
+
* 3. Agent calls this tool with the magic_link_url
|
|
11
|
+
* 4. Tool hits the magic link → server issues session cookie
|
|
12
|
+
* 5. Tool POSTs to /api/me/agents/challenge with the agent's EVM address
|
|
13
|
+
* 6. Tool signs the returned message with the agent's EVM key (EIP-191)
|
|
14
|
+
* 7. Tool POSTs to /api/me/agents/claim → server verifies signature →
|
|
15
|
+
* agent attached to user's watchlist
|
|
16
|
+
*
|
|
17
|
+
* Optional `label` field gives the agent a friendly name in the user's UI.
|
|
18
|
+
*
|
|
19
|
+
* Security model:
|
|
20
|
+
* - Magic-link URL is one-shot, 15-min TTL, identifies the user
|
|
21
|
+
* - Signature proves the agent holds the EVM private key
|
|
22
|
+
* - Combination: "this user OWNS this agent". Either alone is
|
|
23
|
+
* insufficient (signature alone can't pick an account; magic link
|
|
24
|
+
* alone can't prove key control).
|
|
25
|
+
*/
|
|
26
|
+
export function agentClaimSelfTool() {
|
|
27
|
+
return {
|
|
28
|
+
name: "agent_claim_self",
|
|
29
|
+
description: "Link this agent to its owner's AiFinPay dashboard, so the owner sees the agent's " +
|
|
30
|
+
"balance, payments and receipts. Offer this after creating a wallet. The owner " +
|
|
31
|
+
"generates a one-time URL at https://dash.aifinpay.io → My Agents → Claim via MCP " +
|
|
32
|
+
"and pastes it here; the tool signs only an AiFinPay claim challenge for this " +
|
|
33
|
+
"agent's own address and moves no funds.",
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
magic_link_url: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "The one-time URL from My Agents → Claim via MCP. Looks like " +
|
|
40
|
+
"https://dash.aifinpay.io/api/auth/verify?token=… — single use, " +
|
|
41
|
+
"expires 15 minutes after it was generated.",
|
|
42
|
+
},
|
|
43
|
+
label: {
|
|
44
|
+
type: "string",
|
|
45
|
+
description: "Optional human-friendly label (e.g. 'claude-research-bot').",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ["magic_link_url"],
|
|
49
|
+
},
|
|
50
|
+
// Binds the agent to a user account (bounded to AiFinPay; not fund-moving).
|
|
51
|
+
annotations: { readOnlyHint: false, openWorldHint: false, destructiveHint: false },
|
|
52
|
+
outputSchema: { type: "object" },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// ── Who this tool may talk to, and what it may sign ─────────────────────────
|
|
56
|
+
//
|
|
57
|
+
// This tool took the API host out of the URL it was handed, checked only that
|
|
58
|
+
// the string contained "/api/auth/verify?token=", fetched a challenge from that
|
|
59
|
+
// host, and signed whatever came back with the agent's EVM key AND its Solana
|
|
60
|
+
// secret — then posted both signatures back to the same host.
|
|
61
|
+
//
|
|
62
|
+
// That is a signing oracle with an SSRF in front of it. Anyone who can put a
|
|
63
|
+
// URL in front of the agent, prompt injection included, could name their own
|
|
64
|
+
// server, choose the text to be signed, and collect the signatures. Naming
|
|
65
|
+
// 127.0.0.1 or 169.254.169.254 instead reached whatever the host could reach.
|
|
66
|
+
//
|
|
67
|
+
// Two independent barriers below, because either alone is one mistake away
|
|
68
|
+
// from failing.
|
|
69
|
+
const DEFAULT_CLAIM_ORIGINS = [
|
|
70
|
+
"https://aifinpay.io",
|
|
71
|
+
"https://www.aifinpay.io",
|
|
72
|
+
"https://dash.aifinpay.io",
|
|
73
|
+
"https://api.aifinpay.io",
|
|
74
|
+
];
|
|
75
|
+
/** Origins this tool will contact. Override deliberately, for staging. */
|
|
76
|
+
function allowedOrigins() {
|
|
77
|
+
const raw = process.env.AIFINPAY_CLAIM_ORIGINS;
|
|
78
|
+
if (!raw)
|
|
79
|
+
return DEFAULT_CLAIM_ORIGINS;
|
|
80
|
+
return raw
|
|
81
|
+
.split(",")
|
|
82
|
+
.map((o) => o.trim().replace(/\/+$/, ""))
|
|
83
|
+
.filter(Boolean);
|
|
84
|
+
}
|
|
85
|
+
/** null when the URL may be used; otherwise the reason it may not. */
|
|
86
|
+
function originRefusal(url) {
|
|
87
|
+
const origin = `${url.protocol}//${url.host}`;
|
|
88
|
+
const allowed = allowedOrigins();
|
|
89
|
+
if (!allowed.includes(origin)) {
|
|
90
|
+
return (`refusing to use ${origin}: not an allowed AiFinPay origin. ` +
|
|
91
|
+
`Allowed: ${allowed.join(", ")}. Set AIFINPAY_CLAIM_ORIGINS to add one deliberately.`);
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The only shape this agent will sign here.
|
|
97
|
+
*
|
|
98
|
+
* The server builds `AiFinPay-claim:<chain>:<address>:<nonce>` and nothing
|
|
99
|
+
* else. Checking that locally means even an allowed origin — compromised, or
|
|
100
|
+
* simply the wrong one — cannot choose the bytes. The address must be this
|
|
101
|
+
* agent's own, so a signature obtained here says only "I am this agent", which
|
|
102
|
+
* is the whole purpose of the exchange.
|
|
103
|
+
*
|
|
104
|
+
* EVM addresses compare case-insensitively because the server lowercases them.
|
|
105
|
+
* base58 is case-significant and compares exactly.
|
|
106
|
+
*/
|
|
107
|
+
function challengeIsWellFormed(message, address) {
|
|
108
|
+
if (typeof message !== "string")
|
|
109
|
+
return false;
|
|
110
|
+
const chain = address.startsWith("0x") ? "polygon" : "solana";
|
|
111
|
+
const prefix = `AiFinPay-claim:${chain}:${address}:`;
|
|
112
|
+
const matches = chain === "polygon" ? message.toLowerCase().startsWith(prefix.toLowerCase()) : message.startsWith(prefix);
|
|
113
|
+
if (!matches)
|
|
114
|
+
return false;
|
|
115
|
+
return /^[0-9a-f]{32}$/.test(message.slice(prefix.length));
|
|
116
|
+
}
|
|
117
|
+
export async function runAgentClaimSelf(ctx, args) {
|
|
118
|
+
const magicLinkUrl = typeof args.magic_link_url === "string" ? args.magic_link_url : "";
|
|
119
|
+
const label = typeof args.label === "string" ? args.label : null;
|
|
120
|
+
if (!magicLinkUrl || !magicLinkUrl.includes("/api/auth/verify?token=")) {
|
|
121
|
+
return {
|
|
122
|
+
isError: true,
|
|
123
|
+
content: [
|
|
124
|
+
{
|
|
125
|
+
type: "text",
|
|
126
|
+
text: "magic_link_url required — should look like https://aifinpay.io/api/auth/verify?token=…",
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// Derive API base from the magic link itself so demo can run against
|
|
132
|
+
// staging / localhost without extra config.
|
|
133
|
+
let apiBase;
|
|
134
|
+
try {
|
|
135
|
+
const u = new URL(magicLinkUrl);
|
|
136
|
+
const refusal = originRefusal(u);
|
|
137
|
+
if (refusal) {
|
|
138
|
+
return { isError: true, content: [{ type: "text", text: refusal }] };
|
|
139
|
+
}
|
|
140
|
+
apiBase = `${u.protocol}//${u.host}`;
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return {
|
|
144
|
+
isError: true,
|
|
145
|
+
content: [{ type: "text", text: "magic_link_url is not a valid URL" }],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
// ── 1. Establish session by hitting the magic link ─────────────────
|
|
149
|
+
let setCookie = null;
|
|
150
|
+
try {
|
|
151
|
+
const res = await fetch(magicLinkUrl, { redirect: "manual" });
|
|
152
|
+
setCookie = res.headers.get("set-cookie");
|
|
153
|
+
if (!setCookie) {
|
|
154
|
+
return {
|
|
155
|
+
isError: true,
|
|
156
|
+
content: [
|
|
157
|
+
{
|
|
158
|
+
type: "text",
|
|
159
|
+
text: `Magic link did not return a session cookie (HTTP ${res.status}). Link may be expired or already used.`,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch (e) {
|
|
166
|
+
return {
|
|
167
|
+
isError: true,
|
|
168
|
+
content: [{ type: "text", text: `Failed to fetch magic link: ${e.message}` }],
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
// Some setups split multiple cookies; grab the session one we care about.
|
|
172
|
+
const cookieHeader = setCookie
|
|
173
|
+
.split(",")
|
|
174
|
+
.map((c) => c.trim().split(";")[0])
|
|
175
|
+
.join("; ");
|
|
176
|
+
// Claim both chains (EVM + Solana). Each is its own challenge + sig.
|
|
177
|
+
// We try Polygon first because that's where live bridges settle today;
|
|
178
|
+
// Solana side is best-effort — if anything fails we still consider the
|
|
179
|
+
// overall claim successful as long as Polygon went through.
|
|
180
|
+
const evmAddr = ctx.agent.evmAddress;
|
|
181
|
+
const solAddr = ctx.agent.solanaAddress;
|
|
182
|
+
const innerAny = ctx.agent.inner;
|
|
183
|
+
const solSecret = innerAny.secretKey; // tweetnacl 64-byte secretKey
|
|
184
|
+
async function claimOne(address, sigFn) {
|
|
185
|
+
// 1) challenge
|
|
186
|
+
const cr = await fetch(`${apiBase}/api/me/agents/challenge`, {
|
|
187
|
+
method: "POST",
|
|
188
|
+
redirect: "error", // a redirect would leave the origin we vetted
|
|
189
|
+
headers: { "content-type": "application/json", cookie: cookieHeader },
|
|
190
|
+
body: JSON.stringify({ address }),
|
|
191
|
+
});
|
|
192
|
+
const cj = (await cr.json());
|
|
193
|
+
if (!cr.ok || !cj.challenge_id || !cj.message) {
|
|
194
|
+
return { ok: false, reason: cj.error || `challenge HTTP ${cr.status}` };
|
|
195
|
+
}
|
|
196
|
+
// 2) sign — but only the one shape this exchange is defined to produce.
|
|
197
|
+
if (!challengeIsWellFormed(cj.message, address)) {
|
|
198
|
+
return {
|
|
199
|
+
ok: false,
|
|
200
|
+
reason: "challenge is not a well-formed AiFinPay claim for this agent — refusing to sign it",
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
let sigPayload;
|
|
204
|
+
try {
|
|
205
|
+
sigPayload = await sigFn(cj.message);
|
|
206
|
+
}
|
|
207
|
+
catch (e) {
|
|
208
|
+
return { ok: false, reason: `sign: ${e.message}` };
|
|
209
|
+
}
|
|
210
|
+
// 3) submit
|
|
211
|
+
const sr = await fetch(`${apiBase}/api/me/agents/claim`, {
|
|
212
|
+
method: "POST",
|
|
213
|
+
redirect: "error", // a redirect would leave the origin we vetted
|
|
214
|
+
headers: { "content-type": "application/json", cookie: cookieHeader },
|
|
215
|
+
body: JSON.stringify({ challenge_id: cj.challenge_id, label, ...sigPayload }),
|
|
216
|
+
});
|
|
217
|
+
const sj = (await sr.json());
|
|
218
|
+
if (!sr.ok) {
|
|
219
|
+
return { ok: false, reason: sj.error + (sj.reason ? ` (${sj.reason})` : "") };
|
|
220
|
+
}
|
|
221
|
+
return { ok: true };
|
|
222
|
+
}
|
|
223
|
+
// ── 2. Claim Polygon EVM ───────────────────────────────────────────
|
|
224
|
+
const polRes = await claimOne(evmAddr, async (msg) => ({
|
|
225
|
+
signature: await ctx.agent.evmAccount.signMessage({ message: msg }),
|
|
226
|
+
}));
|
|
227
|
+
if (!polRes.ok) {
|
|
228
|
+
return {
|
|
229
|
+
isError: true,
|
|
230
|
+
content: [{ type: "text", text: `Polygon claim failed: ${polRes.reason}` }],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
// ── 3. Claim Solana (best-effort) ──────────────────────────────────
|
|
234
|
+
let solRes;
|
|
235
|
+
try {
|
|
236
|
+
const nacl = (await import("tweetnacl")).default;
|
|
237
|
+
const bs58 = (await import("bs58")).default;
|
|
238
|
+
solRes = await claimOne(solAddr, async (msg) => {
|
|
239
|
+
const sig = nacl.sign.detached(Buffer.from(msg, "utf8"), solSecret);
|
|
240
|
+
return { signature_base58: bs58.encode(sig) };
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
catch (e) {
|
|
244
|
+
solRes = { ok: false, reason: `solana_signer_unavailable: ${e.message}` };
|
|
245
|
+
}
|
|
246
|
+
// ── 4. Balance check (best-effort) — drives funded-vs-unfunded copy ─
|
|
247
|
+
// Never block the claim flow on a balance check; if the RPC is down or
|
|
248
|
+
// balance() throws, fall back to the standard funding recommendation.
|
|
249
|
+
// payable_fetch settles AIFP-1 v1.4 in native POL, so POL is what counts.
|
|
250
|
+
let polygonPol = 0;
|
|
251
|
+
let polUsd = null;
|
|
252
|
+
try {
|
|
253
|
+
const bal = await ctx.agent.balance();
|
|
254
|
+
polygonPol = bal.chains.polygon.matic ?? 0;
|
|
255
|
+
polUsd = Number.isFinite(bal.prices?.pol?.usd) ? bal.prices.pol.usd : null;
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
/* swallow — keep funding_recommendation as-is */
|
|
259
|
+
}
|
|
260
|
+
// ── 5. Report ──────────────────────────────────────────────────────
|
|
261
|
+
try {
|
|
262
|
+
// The dashboard is dash.aifinpay.io; /me redirects to My Agents.
|
|
263
|
+
// (dashboard.aifinpay.io only 301s here.)
|
|
264
|
+
const DASHBOARD_BASE = "https://dash.aifinpay.io";
|
|
265
|
+
// Funded threshold: $0.20 of POL — the smallest batch ($0.10) plus gas.
|
|
266
|
+
// At or above it we say so, so the agent does not ask for money it has.
|
|
267
|
+
const FUNDED_USD_THRESHOLD = 0.2;
|
|
268
|
+
const polValueUsd = polUsd === null ? null : polygonPol * polUsd;
|
|
269
|
+
const fundingFields = polValueUsd !== null && polValueUsd >= FUNDED_USD_THRESHOLD
|
|
270
|
+
? { funding_status: `Funded — ${polygonPol.toFixed(4)} POL (≈ $${polValueUsd.toFixed(2)}) on Polygon` }
|
|
271
|
+
: {
|
|
272
|
+
// AIFP-1 v1.4 settles in native POL on Polygon, and gas is POL too.
|
|
273
|
+
funding_recommendation: `Send POL on Polygon to ${evmAddr}. The smallest batch is $0.10 plus gas; 2–3 POL covers many batches.`,
|
|
274
|
+
};
|
|
275
|
+
return {
|
|
276
|
+
content: [
|
|
277
|
+
{
|
|
278
|
+
type: "text",
|
|
279
|
+
text: JSON.stringify({
|
|
280
|
+
ok: true,
|
|
281
|
+
polygon_address: evmAddr,
|
|
282
|
+
polygon_claim: "ok",
|
|
283
|
+
solana_address: solAddr,
|
|
284
|
+
solana_claim: solRes.ok ? "ok" : `skipped (${solRes.reason})`,
|
|
285
|
+
label: label || null,
|
|
286
|
+
...fundingFields,
|
|
287
|
+
next: `Open ${DASHBOARD_BASE}/me (My Agents) to see this agent's balance, payments and receipts. Public page: ${DASHBOARD_BASE}/agents/${evmAddr}.`,
|
|
288
|
+
}, null, 2),
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
catch (e) {
|
|
294
|
+
return {
|
|
295
|
+
isError: true,
|
|
296
|
+
content: [{ type: "text", text: `Claim POST failed: ${e.message}` }],
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
//# sourceMappingURL=agent-claim-self.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-claim-self.js","sourceRoot":"","sources":["../../src/tools/agent-claim-self.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACT,mFAAmF;YACnF,gFAAgF;YAChF,mFAAmF;YACnF,+EAA+E;YAC/E,yCAAyC;QAC3C,WAAW,EAAE;Y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,EAAE,0BAA0B,OAAO,sEAAsE;aAChI,CAAC;QAER,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;wBACE,EAAE,EAAE,IAAI;wBACR,eAAe,EAAE,OAAO;wBACxB,aAAa,EAAE,IAAI;wBACnB,cAAc,EAAE,OAAO;wBACvB,YAAY,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,MAAM,CAAC,MAAM,GAAG;wBAC7D,KAAK,EAAE,KAAK,IAAI,IAAI;wBACpB,GAAG,aAAa;wBAChB,IAAI,EAAE,QAAQ,cAAc,oFAAoF,cAAc,WAAW,OAAO,GAAG;qBACpJ,EACD,IAAI,EACJ,CAAC,CACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAuB,CAAW,CAAC,OAAO,EAAE,EAAE,CAAC;SAChF,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ToolContext } from "../server.js";
|
|
2
|
+
export declare function agentQuoteTool(): {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: string;
|
|
7
|
+
properties: {
|
|
8
|
+
url: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
method: {
|
|
13
|
+
type: string;
|
|
14
|
+
enum: string[];
|
|
15
|
+
default: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
required: string[];
|
|
19
|
+
};
|
|
20
|
+
annotations: {
|
|
21
|
+
readOnlyHint: boolean;
|
|
22
|
+
openWorldHint: boolean;
|
|
23
|
+
destructiveHint: boolean;
|
|
24
|
+
};
|
|
25
|
+
outputSchema: {
|
|
26
|
+
type: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare function runAgentQuote(ctx: ToolContext, args: Record<string, unknown>): Promise<{
|
|
30
|
+
isError: boolean;
|
|
31
|
+
content: {
|
|
32
|
+
type: string;
|
|
33
|
+
text: string;
|
|
34
|
+
}[];
|
|
35
|
+
} | {
|
|
36
|
+
content: {
|
|
37
|
+
type: string;
|
|
38
|
+
text: string;
|
|
39
|
+
}[];
|
|
40
|
+
}>;
|
|
41
|
+
//# sourceMappingURL=agent-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-quote.d.ts","sourceRoot":"","sources":["../../src/tools/agent-quote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;EAuB7B;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;GA2D9B"}
|