@agent-shield/mcp 0.3.1 → 0.4.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 +69 -37
- package/dist/config.d.ts +55 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +99 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +148 -76
- package/dist/index.js.map +1 -1
- package/dist/tools/configure-from-file.d.ts +47 -0
- package/dist/tools/configure-from-file.d.ts.map +1 -0
- package/dist/tools/configure-from-file.js +239 -0
- package/dist/tools/configure-from-file.js.map +1 -0
- package/dist/tools/configure.d.ts +65 -0
- package/dist/tools/configure.d.ts.map +1 -0
- package/dist/tools/configure.js +286 -0
- package/dist/tools/configure.js.map +1 -0
- package/dist/tools/fund-wallet.d.ts +33 -0
- package/dist/tools/fund-wallet.d.ts.map +1 -0
- package/dist/tools/fund-wallet.js +89 -0
- package/dist/tools/fund-wallet.js.map +1 -0
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +17 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/provision.d.ts +4 -4
- package/dist/tools/setup-status.d.ts +18 -0
- package/dist/tools/setup-status.d.ts.map +1 -0
- package/dist/tools/setup-status.js +107 -0
- package/dist/tools/setup-status.js.map +1 -0
- package/dist/tools/upgrade-tier.d.ts +27 -0
- package/dist/tools/upgrade-tier.d.ts.map +1 -0
- package/dist/tools/upgrade-tier.js +115 -0
- package/dist/tools/upgrade-tier.js.map +1 -0
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -10,15 +10,34 @@ npm install -g @agent-shield/mcp
|
|
|
10
10
|
npx @agent-shield/mcp
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
+
## Security Tiers
|
|
14
|
+
|
|
15
|
+
AgentShield uses a three-tier security model. The MCP server supports all three and guides you through setup.
|
|
16
|
+
|
|
17
|
+
| Tier | Name | Enforcement | Use Case |
|
|
18
|
+
| ---- | -------------------- | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| 1 | Shield | Client-side only | Development and testing only — not suitable for real funds |
|
|
20
|
+
| 2 | Shield + TEE | Client-side + hardware enclave key custody | Improved key security, but policies still enforced off-chain |
|
|
21
|
+
| 3 | Shield + TEE + Vault | On-chain PDA vault with cryptographic policy enforcement | **Recommended for production** — owner kill-switch, immutable audit trail, policies enforced at the blockchain level |
|
|
22
|
+
|
|
23
|
+
Only Tier 3 enforces spending limits and protocol allowlists on-chain where they cannot be bypassed by a compromised agent. For any deployment handling real funds, use Tier 3.
|
|
24
|
+
|
|
25
|
+
## Quickstart
|
|
26
|
+
|
|
27
|
+
1. Install and add to your MCP client (see Configuration below)
|
|
28
|
+
2. Ask your AI assistant: _"What's my AgentShield setup status?"_ — it will call `shield_setup_status`
|
|
29
|
+
3. Follow the guided flow: _"Set up AgentShield"_ — the assistant walks you through tier selection, wallet creation, and policy configuration
|
|
30
|
+
4. For programmatic/CI deployments, use `shield_configure_from_file` with a pre-written JSON config
|
|
31
|
+
|
|
13
32
|
## Configuration
|
|
14
33
|
|
|
15
34
|
### Environment Variables
|
|
16
35
|
|
|
17
|
-
| Variable
|
|
18
|
-
|
|
19
|
-
| `AGENTSHIELD_WALLET_PATH`
|
|
20
|
-
| `AGENTSHIELD_RPC_URL`
|
|
21
|
-
| `AGENTSHIELD_AGENT_KEYPAIR_PATH` | No
|
|
36
|
+
| Variable | Required | Default | Description |
|
|
37
|
+
| -------------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `AGENTSHIELD_WALLET_PATH` | No | — | Path to Solana keypair JSON (vault owner). Not required — server starts in setup mode without it. |
|
|
39
|
+
| `AGENTSHIELD_RPC_URL` | No | devnet | Solana RPC endpoint URL |
|
|
40
|
+
| `AGENTSHIELD_AGENT_KEYPAIR_PATH` | No | — | Path to agent keypair JSON (needed for swap/position tools) |
|
|
22
41
|
|
|
23
42
|
### Claude Desktop
|
|
24
43
|
|
|
@@ -57,50 +76,60 @@ Add to `.cursor/mcp.json` in your project:
|
|
|
57
76
|
}
|
|
58
77
|
```
|
|
59
78
|
|
|
60
|
-
## Tools (
|
|
79
|
+
## Tools (23)
|
|
80
|
+
|
|
81
|
+
### Setup & Onboarding (always available — no wallet required)
|
|
82
|
+
|
|
83
|
+
| Tool | Description |
|
|
84
|
+
| ---------------------------- | ----------------------------------------------------------------------------- |
|
|
85
|
+
| `shield_setup_status` | Check current setup status — which security tiers are active |
|
|
86
|
+
| `shield_configure` | Set up AgentShield with any tier (1=Shield, 2=TEE, 3=Vault) |
|
|
87
|
+
| `shield_configure_from_file` | Apply a pre-written JSON config file (for CI/CD and programmatic deployments) |
|
|
88
|
+
| `shield_fund_wallet` | Generate funding links (Blink URL, Solana Pay, raw address) |
|
|
89
|
+
| `shield_upgrade_tier` | Upgrade from current tier to a higher one |
|
|
61
90
|
|
|
62
91
|
### Read-Only
|
|
63
92
|
|
|
64
|
-
| Tool
|
|
65
|
-
|
|
66
|
-
| `shield_check_vault`
|
|
67
|
-
| `shield_check_spending`
|
|
68
|
-
| `shield_check_pending_policy` | Check pending timelocked policy update status
|
|
93
|
+
| Tool | Description |
|
|
94
|
+
| ----------------------------- | ---------------------------------------------------------- |
|
|
95
|
+
| `shield_check_vault` | Check vault status, owner, agent, and policy configuration |
|
|
96
|
+
| `shield_check_spending` | Check rolling 24h spending and recent transaction history |
|
|
97
|
+
| `shield_check_pending_policy` | Check pending timelocked policy update status |
|
|
69
98
|
|
|
70
99
|
### Owner-Signed (Write)
|
|
71
100
|
|
|
72
|
-
| Tool
|
|
73
|
-
|
|
74
|
-
| `shield_create_vault`
|
|
75
|
-
| `shield_deposit`
|
|
76
|
-
| `shield_withdraw`
|
|
77
|
-
| `shield_register_agent`
|
|
78
|
-
| `shield_update_policy`
|
|
79
|
-
| `shield_queue_policy_update`
|
|
80
|
-
| `shield_apply_pending_policy`
|
|
81
|
-
| `shield_cancel_pending_policy` | Cancel a queued policy change
|
|
82
|
-
| `shield_revoke_agent`
|
|
83
|
-
| `shield_reactivate_vault`
|
|
84
|
-
| `shield_provision`
|
|
101
|
+
| Tool | Description |
|
|
102
|
+
| ------------------------------ | ---------------------------------------------------------------- |
|
|
103
|
+
| `shield_create_vault` | Create a new vault with policy configuration |
|
|
104
|
+
| `shield_deposit` | Deposit tokens into a vault |
|
|
105
|
+
| `shield_withdraw` | Withdraw tokens from a vault |
|
|
106
|
+
| `shield_register_agent` | Register an agent signing key |
|
|
107
|
+
| `shield_update_policy` | Update spending caps, token/protocol allowlists, leverage limits |
|
|
108
|
+
| `shield_queue_policy_update` | Queue a timelocked policy change |
|
|
109
|
+
| `shield_apply_pending_policy` | Apply a queued policy change after timelock expires |
|
|
110
|
+
| `shield_cancel_pending_policy` | Cancel a queued policy change |
|
|
111
|
+
| `shield_revoke_agent` | Emergency kill switch — freezes vault immediately |
|
|
112
|
+
| `shield_reactivate_vault` | Unfreeze a vault, optionally with a new agent |
|
|
113
|
+
| `shield_provision` | Provision a vault via Solana Actions |
|
|
85
114
|
|
|
86
115
|
### Agent-Signed (Requires `AGENTSHIELD_AGENT_KEYPAIR_PATH`)
|
|
87
116
|
|
|
88
|
-
| Tool
|
|
89
|
-
|
|
90
|
-
| `shield_execute_swap`
|
|
91
|
-
| `shield_open_position`
|
|
92
|
-
| `shield_close_position` | Close a Flash Trade perpetual position
|
|
93
|
-
| `shield_agent_transfer` | Transfer tokens to an allowlisted destination
|
|
117
|
+
| Tool | Description |
|
|
118
|
+
| ----------------------- | ----------------------------------------------- |
|
|
119
|
+
| `shield_execute_swap` | Execute a Jupiter token swap through the vault |
|
|
120
|
+
| `shield_open_position` | Open a Flash Trade leveraged perpetual position |
|
|
121
|
+
| `shield_close_position` | Close a Flash Trade perpetual position |
|
|
122
|
+
| `shield_agent_transfer` | Transfer tokens to an allowlisted destination |
|
|
94
123
|
|
|
95
124
|
## Resources (3)
|
|
96
125
|
|
|
97
126
|
Dynamic resources using vault address as URI parameter:
|
|
98
127
|
|
|
99
|
-
| URI Template
|
|
100
|
-
|
|
101
|
-
| `shield://vault/{address}/policy`
|
|
102
|
-
| `shield://vault/{address}/spending` | Rolling 24h spending state (JSON)
|
|
103
|
-
| `shield://vault/{address}/activity` | Recent transaction history (JSON)
|
|
128
|
+
| URI Template | Description |
|
|
129
|
+
| ----------------------------------- | ----------------------------------- |
|
|
130
|
+
| `shield://vault/{address}/policy` | Current policy configuration (JSON) |
|
|
131
|
+
| `shield://vault/{address}/spending` | Rolling 24h spending state (JSON) |
|
|
132
|
+
| `shield://vault/{address}/activity` | Recent transaction history (JSON) |
|
|
104
133
|
|
|
105
134
|
## Development
|
|
106
135
|
|
|
@@ -111,7 +140,7 @@ pnpm install
|
|
|
111
140
|
# Build
|
|
112
141
|
pnpm build
|
|
113
142
|
|
|
114
|
-
# Run tests (
|
|
143
|
+
# Run tests (124 tests)
|
|
115
144
|
pnpm test
|
|
116
145
|
|
|
117
146
|
# Smoke test
|
|
@@ -123,7 +152,10 @@ AGENTSHIELD_WALLET_PATH=~/.config/solana/id.json node dist/index.js
|
|
|
123
152
|
- **Transport**: stdio only (local subprocess of the AI tool)
|
|
124
153
|
- **Credentials**: Environment variables (keypair file paths)
|
|
125
154
|
- **SDK**: Wraps `AgentShieldClient` from `@agent-shield/sdk` — every tool delegates to a client method
|
|
126
|
-
- **
|
|
155
|
+
- **Setup mode**: Starts without a wallet — only setup/onboarding tools available until configured
|
|
156
|
+
- **Programmatic config**: `shield_configure_from_file` reads a JSON config matching the `ShieldLocalConfig` schema — for CI/CD pipelines and orchestrator platforms where interactive setup is not practical
|
|
157
|
+
- **Local config**: `~/.agentshield/config.json` stores tier, wallet, and policy state across sessions
|
|
158
|
+
- **Error handling**: All 40 Anchor error codes (6000–6039) mapped to human-readable messages with actionable suggestions
|
|
127
159
|
|
|
128
160
|
## Support
|
|
129
161
|
|
package/dist/config.d.ts
CHANGED
|
@@ -2,6 +2,61 @@ import { Keypair } from "@solana/web3.js";
|
|
|
2
2
|
import { AgentShieldClient } from "@agent-shield/sdk";
|
|
3
3
|
/** Supported custody providers for MCP server. */
|
|
4
4
|
export type McpCustodyProvider = "crossmint" | "turnkey" | "privy";
|
|
5
|
+
export interface ShieldLayerConfig {
|
|
6
|
+
shield: {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
dailyCapUsd: number;
|
|
9
|
+
allowedProtocols: string[];
|
|
10
|
+
maxLeverageBps: number;
|
|
11
|
+
rateLimit: number;
|
|
12
|
+
};
|
|
13
|
+
tee: {
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
locator: string | null;
|
|
16
|
+
publicKey: string | null;
|
|
17
|
+
};
|
|
18
|
+
vault: {
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
address: string | null;
|
|
21
|
+
owner: string | null;
|
|
22
|
+
vaultId: string | null;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface ShieldLocalConfig {
|
|
26
|
+
version: 1;
|
|
27
|
+
layers: ShieldLayerConfig;
|
|
28
|
+
wallet: {
|
|
29
|
+
type: "keypair" | "crossmint";
|
|
30
|
+
path: string | null;
|
|
31
|
+
publicKey: string;
|
|
32
|
+
};
|
|
33
|
+
network: "devnet" | "mainnet-beta";
|
|
34
|
+
template: "conservative" | "moderate" | "aggressive";
|
|
35
|
+
configuredAt: string;
|
|
36
|
+
}
|
|
37
|
+
/** Canonical config directory. */
|
|
38
|
+
export declare function getConfigDir(): string;
|
|
39
|
+
/** Canonical config file path. */
|
|
40
|
+
export declare function getConfigPath(): string;
|
|
41
|
+
/**
|
|
42
|
+
* Load local shield config from ~/.agentshield/config.json.
|
|
43
|
+
* Falls back to env vars for backwards compatibility with existing MCP installs.
|
|
44
|
+
* Returns null if neither config file nor env vars exist.
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadShieldConfig(): ShieldLocalConfig | null;
|
|
47
|
+
/**
|
|
48
|
+
* Save local shield config to ~/.agentshield/config.json.
|
|
49
|
+
* Creates the directory if needed. Sets file permissions to 0600.
|
|
50
|
+
*/
|
|
51
|
+
export declare function saveShieldConfig(config: ShieldLocalConfig): void;
|
|
52
|
+
/**
|
|
53
|
+
* Returns true if AgentShield is configured (config file exists or env vars set).
|
|
54
|
+
*/
|
|
55
|
+
export declare function isConfigured(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the current tier number based on enabled layers.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getCurrentTier(config: ShieldLocalConfig): 1 | 2 | 3;
|
|
5
60
|
export interface McpConfig {
|
|
6
61
|
/** Path to owner wallet keypair JSON. Not needed when using custody. */
|
|
7
62
|
walletPath?: string;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAiB,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAiB,MAAM,iBAAiB,CAAC;AAErE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAKtD,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;AAInE,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE;QACN,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,GAAG,EAAE;QACH,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,SAAS,EAAE,MAAM,GAAG,IAAI,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2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,UAAU,IAAI,SAAS,CAgCtC;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAOjD;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,iBAAiB,CAWjE;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IACpE,SAAS,EAAE,OAAO,iBAAiB,EAAE,SAAS,CAAC;IAC/C,eAAe,EAAE,QAAQ,CAAC;CAC3B,CAAC,CAuCD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAQ3D"}
|
package/dist/config.js
CHANGED
|
@@ -33,6 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getConfigDir = getConfigDir;
|
|
37
|
+
exports.getConfigPath = getConfigPath;
|
|
38
|
+
exports.loadShieldConfig = loadShieldConfig;
|
|
39
|
+
exports.saveShieldConfig = saveShieldConfig;
|
|
40
|
+
exports.isConfigured = isConfigured;
|
|
41
|
+
exports.getCurrentTier = getCurrentTier;
|
|
36
42
|
exports.loadConfig = loadConfig;
|
|
37
43
|
exports.loadKeypair = loadKeypair;
|
|
38
44
|
exports.createClient = createClient;
|
|
@@ -42,6 +48,99 @@ const web3_js_1 = require("@solana/web3.js");
|
|
|
42
48
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
43
49
|
const sdk_1 = require("@agent-shield/sdk");
|
|
44
50
|
const fs = __importStar(require("fs"));
|
|
51
|
+
const path = __importStar(require("path"));
|
|
52
|
+
const os = __importStar(require("os"));
|
|
53
|
+
/** Canonical config directory. */
|
|
54
|
+
function getConfigDir() {
|
|
55
|
+
return path.join(os.homedir(), ".agentshield");
|
|
56
|
+
}
|
|
57
|
+
/** Canonical config file path. */
|
|
58
|
+
function getConfigPath() {
|
|
59
|
+
return path.join(getConfigDir(), "config.json");
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Load local shield config from ~/.agentshield/config.json.
|
|
63
|
+
* Falls back to env vars for backwards compatibility with existing MCP installs.
|
|
64
|
+
* Returns null if neither config file nor env vars exist.
|
|
65
|
+
*/
|
|
66
|
+
function loadShieldConfig() {
|
|
67
|
+
const configPath = getConfigPath();
|
|
68
|
+
// Config file takes precedence
|
|
69
|
+
if (fs.existsSync(configPath)) {
|
|
70
|
+
try {
|
|
71
|
+
const raw = fs.readFileSync(configPath, "utf-8");
|
|
72
|
+
return JSON.parse(raw);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Fall back to env vars (backwards compatible with existing installs)
|
|
79
|
+
const walletPath = process.env.AGENTSHIELD_WALLET_PATH;
|
|
80
|
+
if (walletPath) {
|
|
81
|
+
try {
|
|
82
|
+
const kp = loadKeypair(walletPath);
|
|
83
|
+
return {
|
|
84
|
+
version: 1,
|
|
85
|
+
layers: {
|
|
86
|
+
shield: {
|
|
87
|
+
enabled: true,
|
|
88
|
+
dailyCapUsd: 500,
|
|
89
|
+
allowedProtocols: [],
|
|
90
|
+
maxLeverageBps: 0,
|
|
91
|
+
rateLimit: 60,
|
|
92
|
+
},
|
|
93
|
+
tee: { enabled: false, locator: null, publicKey: null },
|
|
94
|
+
vault: { enabled: false, address: null, owner: null, vaultId: null },
|
|
95
|
+
},
|
|
96
|
+
wallet: {
|
|
97
|
+
type: "keypair",
|
|
98
|
+
path: walletPath,
|
|
99
|
+
publicKey: kp.publicKey.toBase58(),
|
|
100
|
+
},
|
|
101
|
+
network: (process.env.AGENTSHIELD_RPC_URL?.includes("mainnet")
|
|
102
|
+
? "mainnet-beta"
|
|
103
|
+
: "devnet"),
|
|
104
|
+
template: "conservative",
|
|
105
|
+
configuredAt: new Date().toISOString(),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Save local shield config to ~/.agentshield/config.json.
|
|
116
|
+
* Creates the directory if needed. Sets file permissions to 0600.
|
|
117
|
+
*/
|
|
118
|
+
function saveShieldConfig(config) {
|
|
119
|
+
const dir = getConfigDir();
|
|
120
|
+
if (!fs.existsSync(dir)) {
|
|
121
|
+
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
122
|
+
}
|
|
123
|
+
const configPath = getConfigPath();
|
|
124
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), {
|
|
125
|
+
mode: 0o600,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Returns true if AgentShield is configured (config file exists or env vars set).
|
|
130
|
+
*/
|
|
131
|
+
function isConfigured() {
|
|
132
|
+
return loadShieldConfig() !== null;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Returns the current tier number based on enabled layers.
|
|
136
|
+
*/
|
|
137
|
+
function getCurrentTier(config) {
|
|
138
|
+
if (config.layers.vault.enabled)
|
|
139
|
+
return 3;
|
|
140
|
+
if (config.layers.tee.enabled)
|
|
141
|
+
return 2;
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
45
144
|
function loadConfig() {
|
|
46
145
|
const rpcUrl = process.env.AGENTSHIELD_RPC_URL || (0, web3_js_1.clusterApiUrl)("devnet");
|
|
47
146
|
const agentKeypairPath = process.env.AGENTSHIELD_AGENT_KEYPAIR_PATH || undefined;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|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