@agent-shield/platform 0.1.1 → 0.1.3
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 +158 -0
- package/package.json +7 -1
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# @agent-shield/platform
|
|
2
|
+
|
|
3
|
+
Platform client for AgentShield — request TEE wallet provisioning via Solana Actions endpoints. Zero runtime dependencies.
|
|
4
|
+
|
|
5
|
+
`@agent-shield/platform` is a lightweight HTTP client that lets AI agents request protected wallet provisioning through AgentShield's Solana Actions (Blinks) API. It generates Action URLs, Blink URLs, submits provision requests, and polls for results.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @agent-shield/platform
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Zero runtime dependencies. Uses the native `fetch` API (Node.js 18+).
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { AgentShieldPlatform } from "@agent-shield/platform";
|
|
19
|
+
|
|
20
|
+
// 1. Create a platform client
|
|
21
|
+
const platform = new AgentShieldPlatform("https://agent-middleware.vercel.app");
|
|
22
|
+
|
|
23
|
+
// 2. Generate an Action URL for the user to sign
|
|
24
|
+
const actionUrl = platform.getProvisionActionUrl({ dailyCap: 500 });
|
|
25
|
+
|
|
26
|
+
// 3. Or generate a Blink URL for in-chat rendering
|
|
27
|
+
const blinkUrl = platform.getBlinkUrl({ dailyCap: 500 });
|
|
28
|
+
|
|
29
|
+
// 4. Request a provision transaction for a specific account
|
|
30
|
+
const { transaction } = await platform.requestProvision(
|
|
31
|
+
"UserPublicKeyBase58...",
|
|
32
|
+
{ dailyCap: 500, template: "conservative" }
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// 5. After the user signs, poll for the result
|
|
36
|
+
const result = await platform.waitForProvision(txSignature);
|
|
37
|
+
console.log(result.vaultAddress); // On-chain vault PDA
|
|
38
|
+
console.log(result.agentPubkey); // Agent signing key
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API Reference
|
|
42
|
+
|
|
43
|
+
### `new AgentShieldPlatform(baseUrl)`
|
|
44
|
+
|
|
45
|
+
Create a platform client pointing to an AgentShield Actions server.
|
|
46
|
+
|
|
47
|
+
| Parameter | Type | Description |
|
|
48
|
+
|-----------|------|-------------|
|
|
49
|
+
| `baseUrl` | `string` | Base URL of the Actions server (e.g. `https://agent-middleware.vercel.app`) |
|
|
50
|
+
|
|
51
|
+
### `getProvisionActionUrl(options?): string`
|
|
52
|
+
|
|
53
|
+
Generate a Solana Action URL for vault provisioning.
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const url = platform.getProvisionActionUrl({ dailyCap: 500, template: "moderate" });
|
|
57
|
+
// → "https://agent-middleware.vercel.app/api/actions/provision?template=moderate&dailyCap=500"
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### `getBlinkUrl(options?): string`
|
|
61
|
+
|
|
62
|
+
Generate a Dialect Blink URL that renders the Action in-chat.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
const url = platform.getBlinkUrl({ dailyCap: 500 });
|
|
66
|
+
// → "https://dial.to/?action=solana-action:https%3A%2F%2F..."
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### `getActionMetadata(): Promise<ActionMetadata>`
|
|
70
|
+
|
|
71
|
+
Fetch the Action metadata (GET endpoint). Returns the action's title, description, icon, and available parameters.
|
|
72
|
+
|
|
73
|
+
### `requestProvision(account, options?): Promise<{ transaction, message? }>`
|
|
74
|
+
|
|
75
|
+
Request a provision transaction for a specific Solana account. Returns a base64-encoded unsigned `VersionedTransaction`.
|
|
76
|
+
|
|
77
|
+
| Parameter | Type | Description |
|
|
78
|
+
|-----------|------|-------------|
|
|
79
|
+
| `account` | `string` | User's Solana public key (base58) |
|
|
80
|
+
| `options` | `ProvisionOptions` | Optional daily cap and template |
|
|
81
|
+
|
|
82
|
+
### `checkStatus(txSignature): Promise<ProvisionResult>`
|
|
83
|
+
|
|
84
|
+
Poll the status endpoint for a provision result.
|
|
85
|
+
|
|
86
|
+
| Parameter | Type | Description |
|
|
87
|
+
|-----------|------|-------------|
|
|
88
|
+
| `txSignature` | `string` | Transaction signature from the user's wallet |
|
|
89
|
+
|
|
90
|
+
### `waitForProvision(txSignature, timeoutMs?, intervalMs?): Promise<ProvisionResult>`
|
|
91
|
+
|
|
92
|
+
Poll until the provision is confirmed or times out. Default timeout: 60s, default interval: 2s.
|
|
93
|
+
|
|
94
|
+
### `formatProvisionMessage(options?): string`
|
|
95
|
+
|
|
96
|
+
Generate a human-readable message with both Action URL and Blink URL for presenting to users.
|
|
97
|
+
|
|
98
|
+
## Types
|
|
99
|
+
|
|
100
|
+
### `ProvisionOptions`
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
interface ProvisionOptions {
|
|
104
|
+
dailyCap?: number; // Daily spending cap in USDC (e.g. 500)
|
|
105
|
+
template?: string; // Policy template: "conservative" | "moderate" | "aggressive"
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### `ProvisionResult`
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
interface ProvisionResult {
|
|
113
|
+
status: "pending" | "confirmed" | "not_found";
|
|
114
|
+
vaultAddress?: string;
|
|
115
|
+
agentPubkey?: string;
|
|
116
|
+
agentLocator?: string;
|
|
117
|
+
template?: string;
|
|
118
|
+
error?: string;
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `ActionMetadata`
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
interface ActionMetadata {
|
|
126
|
+
type: string;
|
|
127
|
+
icon: string;
|
|
128
|
+
title: string;
|
|
129
|
+
description: string;
|
|
130
|
+
label: string;
|
|
131
|
+
links: {
|
|
132
|
+
actions: Array<{
|
|
133
|
+
label: string;
|
|
134
|
+
href: string;
|
|
135
|
+
parameters?: Array<{ name: string; label: string; required?: boolean }>;
|
|
136
|
+
}>;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Related Packages
|
|
142
|
+
|
|
143
|
+
| Package | Description |
|
|
144
|
+
|---------|-------------|
|
|
145
|
+
| [`@agent-shield/sdk`](https://www.npmjs.com/package/@agent-shield/sdk) | On-chain vault SDK (Level 3 enforcement) |
|
|
146
|
+
| [`@agent-shield/solana`](https://www.npmjs.com/package/@agent-shield/solana) | Client-side wallet wrapper (Level 1) |
|
|
147
|
+
| [`@agent-shield/core`](https://www.npmjs.com/package/@agent-shield/core) | Pure TypeScript policy engine |
|
|
148
|
+
| [`@agent-shield/mcp`](https://www.npmjs.com/package/@agent-shield/mcp) | MCP server for AI tools |
|
|
149
|
+
|
|
150
|
+
## Support
|
|
151
|
+
|
|
152
|
+
- X/Twitter: [@MightieMags](https://x.com/MightieMags)
|
|
153
|
+
- Telegram: [MightyMags](https://t.me/MightyMags)
|
|
154
|
+
- Issues: [GitHub Issues](https://github.com/Kaleb-Rupe/agentshield/issues)
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-shield/platform",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"author": "Kaleb Rupe (https://x.com/MightieMags)",
|
|
5
|
+
"homepage": "https://github.com/Kaleb-Rupe/agentshield#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/Kaleb-Rupe/agentshield/issues",
|
|
8
|
+
"email": "https://t.me/MightyMags"
|
|
9
|
+
},
|
|
4
10
|
"description": "Platform client for AgentShield — request TEE wallet provisioning via Solana Actions",
|
|
5
11
|
"main": "dist/index.js",
|
|
6
12
|
"types": "dist/index.d.ts",
|