opticparse-agentkit-action 1.0.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 +46 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +68 -0
- package/package.json +24 -0
- package/src/index.ts +87 -0
- package/tsconfig.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# opticparse-agentkit-action
|
|
2
|
+
|
|
3
|
+
Official **Coinbase AgentKit** action provider for **OpticParse** multimodal web scraping and **PhishVision** zero-day threat intelligence on **Base**.
|
|
4
|
+
|
|
5
|
+
Enables autonomous crypto agents equipped with Base wallets to:
|
|
6
|
+
1. **Visually Scrape The Web:** Extract clean structured JSON schemas without breaking on dynamic CSS or anti-bot protections.:2. **Inspect Zero-Day Threats:** Scan unknown dApps and contracts for crypto-drainers before interacting.
|
|
7
|
+
3. **HTTP 402 Machine Settlement:** Autonomously settle micropayments ($0.05 USDC) on Base.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
gbash
|
|
14
|
+
npm install opticparse-agentkit-action
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Usage with Coinbase AgentKit
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { OpticParseActionProvider } from "opticparse-agentkit-action";
|
|
23
|
+
|
|
24
|
+
// 1. Initialize Action Provider
|
|
25
|
+
const opticParseProvider = new OpticParseActionProvider({
|
|
26
|
+
apiKey: process.env.OPTICPARSE_API_KEY // or settles autonomously via Base USDC
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// 2. Perform Visual Web Extraction
|
|
30
|
+
const result = await opticParseProvider.scrapeWebpage({
|
|
31
|
+
url: "https://news.ycombinator.com",
|
|
32
|
+
query: "Extract top stories with points and author"
|
|
33
|
+
});
|
|
34
|
+
console.log("Scraped Data:", result);
|
|
35
|
+
|
|
36
|
+
// 3. Scan Suspicious URL for Crypto Drainers
|
|
37
|
+
const securityReport = await opticParseProvider.scanThreat({
|
|
38
|
+
url: "https://suspicious-airdrop-claim.xyz"
|
|
39
|
+
});
|
|
40
|
+
const.log("Security Verdict:", securityReport);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## License
|
|
46
|
+
MIT © OpticParse Enterprise
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coinbase AgentKit Action Provider for OpticParse
|
|
3
|
+
* Enables autonomous on-chain agents on Base to perform visual web scraping
|
|
4
|
+
* and zero-day threat detection via HTTP 402 / USDC settlement.
|
|
5
|
+
*/
|
|
6
|
+
export interface OpticParseScrapeParams {
|
|
7
|
+
url: string;
|
|
8
|
+
query?: string;
|
|
9
|
+
paymentTxHash?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PhishVisionScanParams {
|
|
12
|
+
url: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class OpticParseActionProvider {
|
|
15
|
+
private endpoint;
|
|
16
|
+
private apiKey;
|
|
17
|
+
private treasuryEvm;
|
|
18
|
+
constructor(options?: {
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
apiKey?: string;
|
|
21
|
+
treasuryEvm?: string;
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Scrapes structured JSON from any URL without breaking on CSS changes or anti-bot checks.
|
|
25
|
+
*/
|
|
26
|
+
scrapeWebpage(args: OpticParseScrapeParams): Promise<any>;
|
|
27
|
+
/**
|
|
28
|
+
* Inspects a URL for malicious crypto drainers, zero-day phishing kits, or brand impersonations.
|
|
29
|
+
*/
|
|
30
|
+
scanThreat(args: PhishVisionScanParams): Promise<any>;
|
|
31
|
+
}
|
|
32
|
+
export default OpticParseActionProvider;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Coinbase AgentKit Action Provider for OpticParse
|
|
4
|
+
* Enables autonomous on-chain agents on Base to perform visual web scraping
|
|
5
|
+
* and zero-day threat detection via HTTP 402 / USDC settlement.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.OpticParseActionProvider = void 0;
|
|
9
|
+
class OpticParseActionProvider {
|
|
10
|
+
endpoint;
|
|
11
|
+
apiKey;
|
|
12
|
+
treasuryEvm;
|
|
13
|
+
constructor(options) {
|
|
14
|
+
const env = typeof process !== 'undefined' && process.env ? process.env : {};
|
|
15
|
+
this.endpoint = options?.endpoint || env.OPTICPARSE_ENDPOINT || 'https://opticparse-mcp-portal.parastejpal987.workers.dev';
|
|
16
|
+
this.apiKey = options?.apiKey || env.OPTICPARSE_API_KEY || 'op_live_agentkit';
|
|
17
|
+
this.treasuryEvm = options?.treasuryEvm || '0xd458E709e7d54fd3659EF66624A621Cde74EDD27';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Scrapes structured JSON from any URL without breaking on CSS changes or anti-bot checks.
|
|
21
|
+
*/
|
|
22
|
+
async scrapeWebpage(args) {
|
|
23
|
+
const targetUrl = args.url;
|
|
24
|
+
const query = args.query || 'Extract structured data, pricing, and main content';
|
|
25
|
+
const headers = {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
28
|
+
'User-Agent': 'Coinbase-AgentKit-OpticParse/1.0'
|
|
29
|
+
};
|
|
30
|
+
if (args.paymentTxHash) {
|
|
31
|
+
headers['X-Payment-TxHash'] = args.paymentTxHash;
|
|
32
|
+
}
|
|
33
|
+
const targetEndpoint = this.endpoint + '/mcp/tools/opticparse_extract';
|
|
34
|
+
const response = await fetch(targetEndpoint, {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers,
|
|
37
|
+
body: JSON.stringify({ url: targetUrl, query })
|
|
38
|
+
});
|
|
39
|
+
if (response.status === 402) {
|
|
40
|
+
return {
|
|
41
|
+
status: 'payment_required',
|
|
42
|
+
code: 402,
|
|
43
|
+
required_amount_usdc: 0.05,
|
|
44
|
+
recipient_treasury: this.treasuryEvm,
|
|
45
|
+
accepted_chain: 'base',
|
|
46
|
+
instructions: 'Transfer 0.05 USDC on Base to recipient_treasury and pass paymentTxHash in parameters.'
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return await response.json();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Inspects a URL for malicious crypto drainers, zero-day phishing kits, or brand impersonations.
|
|
53
|
+
*/
|
|
54
|
+
async scanThreat(args) {
|
|
55
|
+
const scanEndpoint = this.endpoint + '/phishvision/scan';
|
|
56
|
+
const response = await fetch(scanEndpoint, {
|
|
57
|
+
method: 'POST',
|
|
58
|
+
headers: {
|
|
59
|
+
'Content-Type': 'application/json',
|
|
60
|
+
'Authorization': `Bearer ${this.apiKey}`
|
|
61
|
+
},
|
|
62
|
+
body: JSON.stringify({ url: args.url })
|
|
63
|
+
});
|
|
64
|
+
return await response.json();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.OpticParseActionProvider = OpticParseActionProvider;
|
|
68
|
+
exports.default = OpticParseActionProvider;
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opticparse-agentkit-action",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Coinbase AgentKit Action Provider for OpticParse Vision Web Scraping on Base",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"agentkit",
|
|
12
|
+
"coinbase",
|
|
13
|
+
"base",
|
|
14
|
+
"opticparse",
|
|
15
|
+
"web-scraping",
|
|
16
|
+
"x402"
|
|
17
|
+
],
|
|
18
|
+
"author": "OpticParse Enterprise",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^20.0.0",
|
|
22
|
+
"typescript": "^5.9.3"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coinbase AgentKit Action Provider for OpticParse
|
|
3
|
+
* Enables autonomous on-chain agents on Base to perform visual web scraping
|
|
4
|
+
* and zero-day threat detection via HTTP 402 / USDC settlement.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare var process: any;
|
|
8
|
+
|
|
9
|
+
export interface OpticParseScrapeParams {
|
|
10
|
+
url: string;
|
|
11
|
+
query?: string;
|
|
12
|
+
paymentTxHash?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface PhishVisionScanParams {
|
|
16
|
+
url: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export class OpticParseActionProvider {
|
|
20
|
+
private endpoint: string;
|
|
21
|
+
private apiKey: string;
|
|
22
|
+
private treasuryEvm: string;
|
|
23
|
+
|
|
24
|
+
constructor(options?: { endpoint?: string; apiKey?: string; treasuryEvm?: string }) {
|
|
25
|
+
const env = typeof process !== 'undefined' && process.env ? process.env : {};
|
|
26
|
+
this.endpoint = options?.endpoint || env.OPTICPARSE_ENDPOINT || 'https://opticparse-mcp-portal.parastejpal987.workers.dev';
|
|
27
|
+
this.apiKey = options?.apiKey || env.OPTICPARSE_API_KEY || 'op_live_agentkit';
|
|
28
|
+
this.treasuryEvm = options?.treasuryEvm || '0xd458E709e7d54fd3659EF66624A621Cde74EDD27';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Scrapes structured JSON from any URL without breaking on CSS changes or anti-bot checks.
|
|
33
|
+
*/
|
|
34
|
+
async scrapeWebpage(args: OpticParseScrapeParams): Promise<any> {
|
|
35
|
+
const targetUrl = args.url;
|
|
36
|
+
const query = args.query || 'Extract structured data, pricing, and main content';
|
|
37
|
+
|
|
38
|
+
const headers: Record<string, string> = {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
41
|
+
'User-Agent': 'Coinbase-AgentKit-OpticParse/1.0'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (args.paymentTxHash) {
|
|
45
|
+
headers['X-Payment-TxHash'] = args.paymentTxHash;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const targetEndpoint = this.endpoint + '/mcp/tools/opticparse_extract';
|
|
49
|
+
const response = await fetch(targetEndpoint, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers,
|
|
52
|
+
body: JSON.stringify({ url: targetUrl, query })
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (response.status === 402) {
|
|
56
|
+
return {
|
|
57
|
+
status: 'payment_required',
|
|
58
|
+
code: 402,
|
|
59
|
+
required_amount_usdc: 0.05,
|
|
60
|
+
recipient_treasury: this.treasuryEvm,
|
|
61
|
+
accepted_chain: 'base',
|
|
62
|
+
instructions: 'Transfer 0.05 USDC on Base to recipient_treasury and pass paymentTxHash in parameters.'
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return await response.json();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Inspects a URL for malicious crypto drainers, zero-day phishing kits, or brand impersonations.
|
|
71
|
+
*/
|
|
72
|
+
async scanThreat(args: PhishVisionScanParams): Promise<any> {
|
|
73
|
+
const scanEndpoint = this.endpoint + '/phishvision/scan';
|
|
74
|
+
const response = await fetch(scanEndpoint, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers: {
|
|
77
|
+
'Content-Type': 'application/json',
|
|
78
|
+
'Authorization': `Bearer ${this.apiKey}`
|
|
79
|
+
},
|
|
80
|
+
body: JSON.stringify({ url: args.url })
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
return await response.json();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default OpticParseActionProvider;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true
|
|
11
|
+
},
|
|
12
|
+
"include": [
|
|
13
|
+
"src/**/*"
|
|
14
|
+
]
|
|
15
|
+
}
|