maiat-sdk 0.1.0

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 ADDED
@@ -0,0 +1,64 @@
1
+ # maiat-sdk
2
+
3
+ Trust scores, token safety & swap verification for AI agents.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install maiat-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Maiat } from "maiat-sdk";
15
+
16
+ const maiat = new Maiat();
17
+
18
+ // Check if an agent is trustworthy
19
+ const trusted = await maiat.isTrusted("0x...");
20
+
21
+ // Token safety check
22
+ const safe = await maiat.isTokenSafe("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913");
23
+
24
+ // Full trust score
25
+ const score = await maiat.agentTrust("0xAf1aE6F344c60c7Fe56CB53d1809f2c0B997a2b9");
26
+ console.log(score.trustScore, score.verdict); // 69, "caution"
27
+
28
+ // Trust-verified swap quote
29
+ const swap = await maiat.trustSwap({
30
+ swapper: "0x...",
31
+ tokenIn: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // ETH
32
+ tokenOut: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
33
+ amount: "10000000000000000", // 0.01 ETH in wei
34
+ });
35
+ console.log(swap.trust.tokenOut?.score); // 100
36
+ console.log(swap.calldata); // ready-to-sign tx calldata
37
+ ```
38
+
39
+ ## API
40
+
41
+ ### `new Maiat(config?)`
42
+
43
+ | Option | Default | Description |
44
+ |--------|---------|-------------|
45
+ | `baseUrl` | `https://maiat-protocol.vercel.app` | API base URL |
46
+ | `apiKey` | — | Optional API key for higher rate limits |
47
+ | `timeout` | `15000` | Request timeout (ms) |
48
+
49
+ ### Methods
50
+
51
+ | Method | Returns | Description |
52
+ |--------|---------|-------------|
53
+ | `agentTrust(address)` | `AgentTrustResult` | Full trust score + breakdown |
54
+ | `tokenCheck(address)` | `TokenCheckResult` | Token safety analysis |
55
+ | `trustSwap(params)` | `TrustSwapResult` | Swap quote with trust verification |
56
+ | `listAgents(limit?)` | `{ agents, total }` | Browse indexed agents |
57
+ | `isTrusted(address, threshold?)` | `boolean` | Quick trust check (default ≥60) |
58
+ | `isTokenSafe(address)` | `boolean` | Quick token safety check |
59
+
60
+ ## Links
61
+
62
+ - Protocol: [maiat-protocol.vercel.app](https://maiat-protocol.vercel.app)
63
+ - GitHub: [JhiNResH/maiat-protocol](https://github.com/JhiNResH/maiat-protocol)
64
+ - ACP: [Agent #3723 on Virtuals](https://app.virtuals.io/acp)
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Maiat SDK — Trust scores, token safety & swap verification for AI agents
3
+ *
4
+ * Usage:
5
+ * import { Maiat } from "maiat-sdk";
6
+ * const maiat = new Maiat();
7
+ * const score = await maiat.agentTrust("0x...");
8
+ * const token = await maiat.tokenCheck("0x...");
9
+ * const swap = await maiat.trustSwap({ ... });
10
+ */
11
+ export interface MaiatConfig {
12
+ /** Base URL for Maiat Protocol API. Default: https://maiat-protocol.vercel.app */
13
+ baseUrl?: string;
14
+ /** Optional API key for higher rate limits */
15
+ apiKey?: string;
16
+ /** Request timeout in ms. Default: 15000 */
17
+ timeout?: number;
18
+ }
19
+ export interface AgentTrustResult {
20
+ address: string;
21
+ trustScore: number;
22
+ dataSource: string;
23
+ breakdown: {
24
+ completionRate: number;
25
+ paymentRate: number;
26
+ expireRate: number;
27
+ totalJobs: number;
28
+ ageWeeks: number | null;
29
+ };
30
+ verdict: "proceed" | "caution" | "avoid";
31
+ lastUpdated: string;
32
+ }
33
+ export interface TokenCheckResult {
34
+ address: string;
35
+ tokenType: string;
36
+ trustScore: number;
37
+ verdict: "proceed" | "caution" | "avoid";
38
+ riskFlags: string[];
39
+ riskSummary: string;
40
+ dataSource: string;
41
+ }
42
+ export interface TrustSwapParams {
43
+ swapper: string;
44
+ tokenIn: string;
45
+ tokenOut: string;
46
+ amount: string;
47
+ chainId?: number;
48
+ slippage?: number;
49
+ }
50
+ export interface TrustSwapResult {
51
+ quote: Record<string, unknown>;
52
+ calldata: string | null;
53
+ to: string | null;
54
+ value: string | null;
55
+ trust: {
56
+ tokenIn: {
57
+ score: number;
58
+ risk: string;
59
+ } | null;
60
+ tokenOut: {
61
+ score: number;
62
+ risk: string;
63
+ } | null;
64
+ };
65
+ timestamp: string;
66
+ }
67
+ export declare class Maiat {
68
+ private baseUrl;
69
+ private apiKey?;
70
+ private timeout;
71
+ constructor(config?: MaiatConfig);
72
+ private request;
73
+ /** Get trust score for an ACP agent by wallet address */
74
+ agentTrust(address: string): Promise<AgentTrustResult>;
75
+ /** Check if a token is safe (honeypot, rug, liquidity) */
76
+ tokenCheck(address: string): Promise<TokenCheckResult>;
77
+ /** Get a trust-verified swap quote with calldata */
78
+ trustSwap(params: TrustSwapParams): Promise<TrustSwapResult>;
79
+ /** List indexed agents with trust scores */
80
+ listAgents(limit?: number): Promise<{
81
+ agents: AgentTrustResult[];
82
+ total: number;
83
+ }>;
84
+ /** Quick check: is this agent trustworthy? Returns true if score >= threshold */
85
+ isTrusted(address: string, threshold?: number): Promise<boolean>;
86
+ /** Quick check: is this token safe to swap? */
87
+ isTokenSafe(address: string): Promise<boolean>;
88
+ }
89
+ export declare class MaiatError extends Error {
90
+ status: number;
91
+ constructor(message: string, status: number);
92
+ }
93
+ export default Maiat;
package/dist/index.js ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Maiat SDK — Trust scores, token safety & swap verification for AI agents
3
+ *
4
+ * Usage:
5
+ * import { Maiat } from "maiat-sdk";
6
+ * const maiat = new Maiat();
7
+ * const score = await maiat.agentTrust("0x...");
8
+ * const token = await maiat.tokenCheck("0x...");
9
+ * const swap = await maiat.trustSwap({ ... });
10
+ */
11
+ // ─── Client ───────────────────────────────────────────────────────────────────
12
+ export class Maiat {
13
+ baseUrl;
14
+ apiKey;
15
+ timeout;
16
+ constructor(config = {}) {
17
+ this.baseUrl = (config.baseUrl ?? "https://maiat-protocol.vercel.app").replace(/\/$/, "");
18
+ this.apiKey = config.apiKey;
19
+ this.timeout = config.timeout ?? 15_000;
20
+ }
21
+ async request(path, options) {
22
+ const headers = {
23
+ "Content-Type": "application/json",
24
+ ...(this.apiKey ? { "X-Maiat-Key": this.apiKey } : {}),
25
+ };
26
+ const res = await fetch(`${this.baseUrl}${path}`, {
27
+ ...options,
28
+ headers: { ...headers, ...options?.headers },
29
+ signal: AbortSignal.timeout(this.timeout),
30
+ });
31
+ if (!res.ok) {
32
+ const body = await res.text().catch(() => "");
33
+ throw new MaiatError(`HTTP ${res.status}: ${body}`, res.status);
34
+ }
35
+ return res.json();
36
+ }
37
+ // ─── Core Methods ─────────────────────────────────────────────────────────
38
+ /** Get trust score for an ACP agent by wallet address */
39
+ async agentTrust(address) {
40
+ return this.request(`/api/v1/agent/${address}`);
41
+ }
42
+ /** Check if a token is safe (honeypot, rug, liquidity) */
43
+ async tokenCheck(address) {
44
+ return this.request(`/api/v1/token/${address}`);
45
+ }
46
+ /** Get a trust-verified swap quote with calldata */
47
+ async trustSwap(params) {
48
+ return this.request("/api/v1/swap/quote", {
49
+ method: "POST",
50
+ body: JSON.stringify(params),
51
+ });
52
+ }
53
+ /** List indexed agents with trust scores */
54
+ async listAgents(limit = 50) {
55
+ return this.request(`/api/v1/agents?limit=${limit}`);
56
+ }
57
+ // ─── Convenience ──────────────────────────────────────────────────────────
58
+ /** Quick check: is this agent trustworthy? Returns true if score >= threshold */
59
+ async isTrusted(address, threshold = 60) {
60
+ try {
61
+ const result = await this.agentTrust(address);
62
+ return result.trustScore >= threshold;
63
+ }
64
+ catch {
65
+ return false; // fail-closed: unknown = untrusted
66
+ }
67
+ }
68
+ /** Quick check: is this token safe to swap? */
69
+ async isTokenSafe(address) {
70
+ try {
71
+ const result = await this.tokenCheck(address);
72
+ return result.verdict === "proceed";
73
+ }
74
+ catch {
75
+ return false;
76
+ }
77
+ }
78
+ }
79
+ // ─── Error ────────────────────────────────────────────────────────────────────
80
+ export class MaiatError extends Error {
81
+ status;
82
+ constructor(message, status) {
83
+ super(message);
84
+ this.status = status;
85
+ this.name = "MaiatError";
86
+ }
87
+ }
88
+ // ─── Default export ───────────────────────────────────────────────────────────
89
+ export default Maiat;
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "maiat-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Maiat Protocol SDK — trust scores, token safety, and swap verification for AI agents",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": ["dist"],
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "keywords": ["maiat", "trust", "agent", "acp", "virtuals", "uniswap", "safety"],
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/JhiNResH/maiat-protocol",
24
+ "directory": "packages/sdk"
25
+ },
26
+ "devDependencies": {
27
+ "typescript": "^5.0.0"
28
+ }
29
+ }