@vanditk2/agentvault-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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vandit Kunapareddi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # @vanditk2/agentvault-sdk
2
+
3
+ TypeScript client for [AgentVault](https://github.com/vandit-kunapareddi/agentvault) — the open-source trust and control layer for AI-agent payments.
4
+
5
+ > **Heads up:** the SDK on its own doesn't move money. It talks to an AgentVault **checkpoint** (the control plane that verifies the credential, enforces budgets, escalates anything unusual, and routes to the right payment protocol). Today AgentVault is self-host — to use this SDK in production you also need to be running your own checkpoint. See the [main repo](https://github.com/vandit-kunapareddi/agentvault) for the self-host quickstart.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @vanditk2/agentvault-sdk
11
+ ```
12
+
13
+ Requires Node 20+.
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { AgentVault } from "@vanditk2/agentvault-sdk";
19
+
20
+ const vault = new AgentVault({
21
+ credential: process.env.AGENT_CREDENTIAL!, // a signed JWT issued by your AgentVault dashboard
22
+ checkpointUrl: "https://your-checkpoint.example.com",
23
+ });
24
+
25
+ const result = await vault.pay({
26
+ endpoint: "https://api.someservice.com/data",
27
+ maxAmount: 0.05,
28
+ });
29
+
30
+ if (result.status === "approved") {
31
+ // result.protocol → "x402" | "mpp" | "acp"
32
+ // result.receipt → vendor, amount, settled, timestamp, receiptId
33
+ // result.trustTier
34
+ }
35
+ ```
36
+
37
+ `pay()` probes the endpoint to detect which agentic payment protocol it speaks (x402 / MPP / ACP), then POSTs to your checkpoint's `/checkpoint` endpoint with the credential + vendor + amount + protocol + endpoint. Your checkpoint runs the full decision pipeline and either approves, escalates (and holds while a human decides), or blocks.
38
+
39
+ ## What the credential carries
40
+
41
+ The signed JWT encodes the spending rules the checkpoint will enforce:
42
+
43
+ ```json
44
+ {
45
+ "agentId": "clx123abc",
46
+ "agentName": "Research Agent",
47
+ "walletAddress": "0x52ce…",
48
+ "authorizedBy": "dev@example.com",
49
+ "dailyCap": 10.0,
50
+ "perTxLimit": 0.5,
51
+ "approvedVendors": ["exa.ai", "hyperbolic.xyz"],
52
+ "vendorLimits": { "exa.ai": 2.0 },
53
+ "supportedProtocols": ["x402", "mpp", "acp"],
54
+ "issuedAt": 1748390400,
55
+ "expiresAt": 1748476800
56
+ }
57
+ ```
58
+
59
+ Generate these from the AgentVault dashboard's "Register agent" form. The checkpoint verifies the signature against the dashboard's `JWT_SECRET` — both must match.
60
+
61
+ ## What status values mean
62
+
63
+ | `status` | Meaning |
64
+ |---|---|
65
+ | `approved` | The payment passed every check and was settled by the matching protocol handler. `receipt` is populated with the on-chain (or mock) settlement details. |
66
+ | `recognized` | The protocol was identified but the handler doesn't execute the payment yet (ACP today). `settled: false`. |
67
+ | `escalated` | The payment was held while a human reviewed it (then resolved as approved or blocked). |
68
+ | `blocked` | A budget, trust, vendor, or settlement check failed. `reason` says which. |
69
+
70
+ ## Direct protocol detection
71
+
72
+ If you just want to know which protocol an endpoint expects without making a payment:
73
+
74
+ ```ts
75
+ import { detectProtocol } from "@vanditk2/agentvault-sdk";
76
+
77
+ const protocol = await detectProtocol("https://api.someservice.com/data");
78
+ // → "x402" | "mpp" | "acp" | "unknown"
79
+ ```
80
+
81
+ ## License
82
+
83
+ [MIT](./LICENSE)
@@ -0,0 +1,30 @@
1
+ import type { PaymentResult, Protocol } from "./types.js";
2
+ export type { Protocol, CheckpointStatus, PaymentReceipt, CheckpointResponse, PaymentResult, } from "./types.js";
3
+ export interface AgentVaultConfig {
4
+ /** The signed JWT spending credential. Rules live inside it, not here. */
5
+ credential: string;
6
+ /** Base URL of the AgentVault checkpoint. Defaults to http://localhost:4000. */
7
+ checkpointUrl?: string;
8
+ }
9
+ export interface PayArgs {
10
+ /** The service endpoint the agent wants to pay. */
11
+ endpoint: string;
12
+ /** Maximum amount (USD) the agent is willing to pay for this call. */
13
+ maxAmount: number;
14
+ }
15
+ /**
16
+ * Detects which agentic payment protocol a service endpoint expects by
17
+ * probing it and reading the X-Payment-Protocol header on a 402 response.
18
+ */
19
+ export declare function detectProtocol(endpoint: string): Promise<Protocol>;
20
+ export declare class AgentVault {
21
+ private readonly config;
22
+ constructor(config: AgentVaultConfig);
23
+ /**
24
+ * Pays for a service. Detects the protocol the endpoint expects, then routes
25
+ * the request through the AgentVault checkpoint, which verifies trust,
26
+ * enforces budget rules, escalates if needed, and routes to the protocol.
27
+ */
28
+ pay(args: PayArgs): Promise<PaymentResult>;
29
+ }
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1D,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,aAAa,GACd,MAAM,YAAY,CAAC;AAIpB,MAAM,WAAW,gBAAgB;IAC/B,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAaxE;AAED,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,gBAAgB;IAErD;;;;OAIG;IACG,GAAG,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;CAuBjD"}
package/dist/index.js ADDED
@@ -0,0 +1,55 @@
1
+ const DEFAULT_CHECKPOINT_URL = "http://localhost:4000";
2
+ /**
3
+ * Detects which agentic payment protocol a service endpoint expects by
4
+ * probing it and reading the X-Payment-Protocol header on a 402 response.
5
+ */
6
+ export async function detectProtocol(endpoint) {
7
+ try {
8
+ const res = await fetch(endpoint, { method: "GET" });
9
+ if (res.status === 402) {
10
+ const header = res.headers.get("x-payment-protocol");
11
+ if (header === "x402" || header === "mpp" || header === "acp") {
12
+ return header;
13
+ }
14
+ }
15
+ return "unknown";
16
+ }
17
+ catch {
18
+ return "unknown";
19
+ }
20
+ }
21
+ export class AgentVault {
22
+ config;
23
+ constructor(config) {
24
+ this.config = config;
25
+ }
26
+ /**
27
+ * Pays for a service. Detects the protocol the endpoint expects, then routes
28
+ * the request through the AgentVault checkpoint, which verifies trust,
29
+ * enforces budget rules, escalates if needed, and routes to the protocol.
30
+ */
31
+ async pay(args) {
32
+ const protocol = await detectProtocol(args.endpoint);
33
+ let vendor;
34
+ try {
35
+ vendor = new URL(args.endpoint).hostname;
36
+ }
37
+ catch {
38
+ vendor = args.endpoint;
39
+ }
40
+ const baseUrl = this.config.checkpointUrl ?? DEFAULT_CHECKPOINT_URL;
41
+ const res = await fetch(`${baseUrl}/checkpoint`, {
42
+ method: "POST",
43
+ headers: { "content-type": "application/json" },
44
+ body: JSON.stringify({
45
+ credential: this.config.credential,
46
+ vendor,
47
+ amount: args.maxAmount,
48
+ protocol,
49
+ endpoint: args.endpoint,
50
+ }),
51
+ });
52
+ return (await res.json());
53
+ }
54
+ }
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAgBvD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAgB;IACnD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACrD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvB,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YACrD,IAAI,MAAM,KAAK,MAAM,IAAI,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;gBAC9D,OAAO,MAAM,CAAC;YAChB,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,OAAO,UAAU;IACQ;IAA7B,YAA6B,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;IAAG,CAAC;IAEzD;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,IAAa;QACrB,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrD,IAAI,MAAc,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC;QAC3C,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;QACzB,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,sBAAsB,CAAC;QACpE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,aAAa,EAAE;YAC/C,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;gBAClC,MAAM;gBACN,MAAM,EAAE,IAAI,CAAC,SAAS;gBACtB,QAAQ;gBACR,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC;SACH,CAAC,CAAC;QACH,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAkB,CAAC;IAC7C,CAAC;CACF"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Public types for the AgentVault SDK. These mirror the shapes used inside
3
+ * the checkpoint and are inlined here so the published SDK has no internal
4
+ * workspace dependencies.
5
+ */
6
+ export type Protocol = "x402" | "mpp" | "acp" | "unknown";
7
+ export type CheckpointStatus = "approved" | "blocked" | "escalated" | "recognized";
8
+ export interface PaymentReceipt {
9
+ protocol: Protocol;
10
+ receiptId: string;
11
+ vendor: string;
12
+ amount: number;
13
+ currency: "USDC";
14
+ settled: boolean;
15
+ timestamp: string;
16
+ }
17
+ export interface CheckpointResponse {
18
+ status: CheckpointStatus;
19
+ reason?: string;
20
+ protocol?: Protocol;
21
+ trustTier?: string;
22
+ receipt?: PaymentReceipt;
23
+ }
24
+ export type PaymentResult = CheckpointResponse;
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GACxB,UAAU,GACV,SAAS,GACT,WAAW,GACX,YAAY,CAAC;AAEjB,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,MAAM,aAAa,GAAG,kBAAkB,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Public types for the AgentVault SDK. These mirror the shapes used inside
3
+ * the checkpoint and are inlined here so the published SDK has no internal
4
+ * workspace dependencies.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@vanditk2/agentvault-sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for AgentVault — the open-source trust and control layer for AI-agent payments.",
5
+ "keywords": [
6
+ "agentvault",
7
+ "agentic-payments",
8
+ "ai-agents",
9
+ "x402",
10
+ "mpp",
11
+ "acp",
12
+ "sdk",
13
+ "payments"
14
+ ],
15
+ "license": "MIT",
16
+ "author": "Vandit Kunapareddi",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/vandit-kunapareddi/agentvault.git",
20
+ "directory": "packages/sdk"
21
+ },
22
+ "homepage": "https://github.com/vandit-kunapareddi/agentvault#readme",
23
+ "bugs": {
24
+ "url": "https://github.com/vandit-kunapareddi/agentvault/issues"
25
+ },
26
+ "type": "module",
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "engines": {
41
+ "node": ">=20"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.build.json",
48
+ "prepublishOnly": "npm run build"
49
+ },
50
+ "devDependencies": {
51
+ "typescript": "^5.6.0"
52
+ }
53
+ }