agentkit-cleanweb 0.0.0-stage → 1.0.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.
@@ -0,0 +1,99 @@
1
+ import { CleanWebContentSchema, CleanPdfSchema, CleanYoutubeSchema, OracleGroundingSchema, ManageVaultSchema, } from "./types.js";
2
+ import { cleanWebContent, cleanPdfResearch, cleanYoutubeTranscript, oracleGrounding, manageX402Vault, } from "./actions.js";
3
+ import { BASE_CHAIN_ID, BASE_SEPOLIA_CHAIN_ID } from "./constants.js";
4
+ /**
5
+ * Coinbase AgentKit CleanWeb Action Provider
6
+ * Drop-in Action Provider supplying 87% token-compressed web scraping,
7
+ * research PDF analysis, YouTube Gemini Flash intelligence, and Base EIP-712 oracle attestations.
8
+ */
9
+ export class CleanWebActionProvider {
10
+ name = "cleanweb";
11
+ description = "87% token noise reduction web scraper, academic PDF analyzer, YouTube Gemini video intelligence, and Base Mainnet EIP-712 signed oracle grounding.";
12
+ config;
13
+ constructor(config = {}) {
14
+ this.config = config;
15
+ }
16
+ /**
17
+ * Verifies if the provider supports the given network.
18
+ * Native support for Base (8453), Base Sepolia (84532), and all EVM chains.
19
+ */
20
+ supportsNetwork(network) {
21
+ if (!network || !network.chainId)
22
+ return true;
23
+ const cid = Number(network.chainId);
24
+ return cid === BASE_CHAIN_ID || cid === BASE_SEPOLIA_CHAIN_ID || cid === 137 || cid === 42161;
25
+ }
26
+ /**
27
+ * Returns all 5 Action instances for Coinbase AgentKit runtime registration.
28
+ */
29
+ getActions(walletProvider) {
30
+ const opts = {
31
+ gatewayUrl: this.config.gatewayUrl,
32
+ vaultKey: this.config.vaultKey,
33
+ agentNonce: this.config.agentNonce,
34
+ timeoutMs: this.config.timeoutMs,
35
+ };
36
+ return [
37
+ {
38
+ name: "cleanweb_clean_web_content",
39
+ description: "Scrapes any target webpage URL and compresses noise/ads into 87% token-reduced clean Markdown for LLMs.",
40
+ schema: CleanWebContentSchema,
41
+ invoke: async (args) => {
42
+ const parsed = CleanWebContentSchema.parse(args);
43
+ return await cleanWebContent(parsed, opts);
44
+ },
45
+ },
46
+ {
47
+ name: "cleanweb_clean_pdf_research",
48
+ description: "Extracts structured academic text, executive findings, and sections from online PDF whitepapers and reports.",
49
+ schema: CleanPdfSchema,
50
+ invoke: async (args) => {
51
+ const parsed = CleanPdfSchema.parse(args);
52
+ return await cleanPdfResearch(parsed, opts);
53
+ },
54
+ },
55
+ {
56
+ name: "cleanweb_clean_youtube_transcript",
57
+ description: "Extracts high-precision subtitles and Google Gemini 3.8 Flash summary from YouTube videos without downloading media.",
58
+ schema: CleanYoutubeSchema,
59
+ invoke: async (args) => {
60
+ const parsed = CleanYoutubeSchema.parse(args);
61
+ return await cleanYoutubeTranscript(parsed, opts);
62
+ },
63
+ },
64
+ {
65
+ name: "cleanweb_oracle_grounding",
66
+ description: "Discovers factual ground truth from the web and cryptographically signs an on-chain verifiable EIP-712 attestation for Base (8453).",
67
+ schema: OracleGroundingSchema,
68
+ invoke: async (args) => {
69
+ const parsed = OracleGroundingSchema.parse(args);
70
+ return await oracleGrounding(parsed, opts);
71
+ },
72
+ },
73
+ {
74
+ name: "cleanweb_manage_x402_vault",
75
+ description: "Checks prefunded agent USDC vault balance, retrieves Base USDC deposit address, or inspects VIP pass entitlements.",
76
+ schema: ManageVaultSchema,
77
+ invoke: async (args) => {
78
+ const parsed = ManageVaultSchema.parse(args);
79
+ let addr = parsed.agentAddress;
80
+ if (!addr && walletProvider && typeof walletProvider.getAddress === "function") {
81
+ try {
82
+ addr = await walletProvider.getAddress();
83
+ }
84
+ catch {
85
+ // fallback
86
+ }
87
+ }
88
+ return await manageX402Vault({ ...parsed, agentAddress: addr }, opts);
89
+ },
90
+ },
91
+ ];
92
+ }
93
+ }
94
+ /**
95
+ * Factory helper for clean instantiations
96
+ */
97
+ export function cleanWebActionProvider(config = {}) {
98
+ return new CleanWebActionProvider(config);
99
+ }
@@ -0,0 +1,137 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * 1. Clean Web Content Schema
4
+ */
5
+ export declare const CleanWebContentSchema: z.ZodObject<{
6
+ url: z.ZodString;
7
+ maxLength: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
8
+ includeLinks: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ url: string;
11
+ maxLength: number;
12
+ includeLinks: boolean;
13
+ }, {
14
+ url: string;
15
+ maxLength?: number | undefined;
16
+ includeLinks?: boolean | undefined;
17
+ }>;
18
+ export type CleanWebContentParams = z.infer<typeof CleanWebContentSchema>;
19
+ /**
20
+ * 2. Clean Research PDF Schema
21
+ */
22
+ export declare const CleanPdfSchema: z.ZodObject<{
23
+ pdfUrl: z.ZodString;
24
+ maxPages: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ pdfUrl: string;
27
+ maxPages: number;
28
+ }, {
29
+ pdfUrl: string;
30
+ maxPages?: number | undefined;
31
+ }>;
32
+ export type CleanPdfParams = z.infer<typeof CleanPdfSchema>;
33
+ /**
34
+ * 3. Clean YouTube Transcript Schema
35
+ */
36
+ export declare const CleanYoutubeSchema: z.ZodObject<{
37
+ videoUrl: z.ZodString;
38
+ includeSummary: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ videoUrl: string;
41
+ includeSummary: boolean;
42
+ }, {
43
+ videoUrl: string;
44
+ includeSummary?: boolean | undefined;
45
+ }>;
46
+ export type CleanYoutubeParams = z.infer<typeof CleanYoutubeSchema>;
47
+ /**
48
+ * 4. Oracle Grounding & EIP-712 Attestation Schema
49
+ */
50
+ export declare const OracleGroundingSchema: z.ZodObject<{
51
+ query: z.ZodString;
52
+ targetUrl: z.ZodOptional<z.ZodString>;
53
+ chainId: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
54
+ }, "strip", z.ZodTypeAny, {
55
+ query: string;
56
+ chainId: number;
57
+ targetUrl?: string | undefined;
58
+ }, {
59
+ query: string;
60
+ targetUrl?: string | undefined;
61
+ chainId?: number | undefined;
62
+ }>;
63
+ export type OracleGroundingParams = z.infer<typeof OracleGroundingSchema>;
64
+ /**
65
+ * 5. Manage x402 Agent Vault Schema
66
+ */
67
+ export declare const ManageVaultSchema: z.ZodObject<{
68
+ action: z.ZodEnum<["balance", "deposit_info", "pass_status"]>;
69
+ agentAddress: z.ZodOptional<z.ZodString>;
70
+ }, "strip", z.ZodTypeAny, {
71
+ action: "balance" | "deposit_info" | "pass_status";
72
+ agentAddress?: string | undefined;
73
+ }, {
74
+ action: "balance" | "deposit_info" | "pass_status";
75
+ agentAddress?: string | undefined;
76
+ }>;
77
+ export type ManageVaultParams = z.infer<typeof ManageVaultSchema>;
78
+ /**
79
+ * CleanWeb Universal Action Result Interfaces
80
+ */
81
+ export interface CleanWebContentResult {
82
+ success: boolean;
83
+ url: string;
84
+ title: string;
85
+ cleanMarkdown: string;
86
+ tokenReductionRate: string;
87
+ sourceTokensEstimate: number;
88
+ compressedTokensEstimate: number;
89
+ latencyMs: number;
90
+ }
91
+ export interface CleanPdfResult {
92
+ success: boolean;
93
+ pdfUrl: string;
94
+ title: string;
95
+ pageCount: number;
96
+ wordCount: number;
97
+ text: string;
98
+ latencyMs: number;
99
+ }
100
+ export interface CleanYoutubeResult {
101
+ success: boolean;
102
+ videoId: string;
103
+ title: string;
104
+ channel: string;
105
+ summary?: string;
106
+ transcriptSample: string;
107
+ fullTranscriptLength: number;
108
+ latencyMs: number;
109
+ }
110
+ export interface OracleGroundingResult {
111
+ success: boolean;
112
+ query: string;
113
+ groundedFacts: string[];
114
+ summary: string;
115
+ verdict: "VERIFIED" | "CONTRADICTED" | "UNVERIFIED";
116
+ confidence: number;
117
+ attestation?: {
118
+ chainId: number;
119
+ signerAddress: string;
120
+ merkleRoot: string;
121
+ signature: string;
122
+ eip712Domain: Record<string, unknown>;
123
+ };
124
+ latencyMs: number;
125
+ }
126
+ export interface ManageVaultResult {
127
+ success: boolean;
128
+ action: string;
129
+ agentAddress?: string;
130
+ balanceUsdc?: number;
131
+ totalConsumedUsdc?: number;
132
+ depositAddress?: string;
133
+ supportedChains?: string[];
134
+ passTier?: string;
135
+ passActive?: boolean;
136
+ }
137
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAiB4C,CAAC;AAE/E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;EAa2E,CAAC;AAEvG,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;EAUoE,CAAC;AAEpG,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAgBiF,CAAC;AAEpH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;EAYsE,CAAC;AAErG,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,kBA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C,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
package/dist/types.js ADDED
@@ -0,0 +1,89 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * 1. Clean Web Content Schema
4
+ */
5
+ export const CleanWebContentSchema = z
6
+ .object({
7
+ url: z.string().url().describe("The HTTP/HTTPS webpage URL to scrape and compress into clean Markdown"),
8
+ maxLength: z
9
+ .number()
10
+ .int()
11
+ .positive()
12
+ .optional()
13
+ .default(50000)
14
+ .describe("Maximum character length for the returned markdown body (default 50,000)"),
15
+ includeLinks: z
16
+ .boolean()
17
+ .optional()
18
+ .default(true)
19
+ .describe("Whether to preserve relevant markdown links in the cleaned text"),
20
+ })
21
+ .strip()
22
+ .describe("Parameters for scraping and reducing webpage token noise by 87%");
23
+ /**
24
+ * 2. Clean Research PDF Schema
25
+ */
26
+ export const CleanPdfSchema = z
27
+ .object({
28
+ pdfUrl: z.string().url().describe("The direct URL of the PDF whitepaper, financial filing, or arXiv research report"),
29
+ maxPages: z
30
+ .number()
31
+ .int()
32
+ .min(1)
33
+ .max(100)
34
+ .optional()
35
+ .default(50)
36
+ .describe("Maximum number of pages to parse (1-100, default 50)"),
37
+ })
38
+ .strip()
39
+ .describe("Parameters for extracting clean academic and financial text from online PDF whitepapers");
40
+ /**
41
+ * 3. Clean YouTube Transcript Schema
42
+ */
43
+ export const CleanYoutubeSchema = z
44
+ .object({
45
+ videoUrl: z.string().describe("YouTube video URL or 11-character video ID"),
46
+ includeSummary: z
47
+ .boolean()
48
+ .optional()
49
+ .default(true)
50
+ .describe("Whether to generate Gemini 3.8 Flash bullet-point executive summary"),
51
+ })
52
+ .strip()
53
+ .describe("Parameters for extracting timestamped subtitles and AI summaries from YouTube videos");
54
+ /**
55
+ * 4. Oracle Grounding & EIP-712 Attestation Schema
56
+ */
57
+ export const OracleGroundingSchema = z
58
+ .object({
59
+ query: z.string().min(3).describe("The factual proposition or topic to verify (e.g. 'Base TVL surpasses 4B' or 'CRMA compliance')"),
60
+ targetUrl: z
61
+ .string()
62
+ .url()
63
+ .optional()
64
+ .describe("Optional target webpage URL to ground the facts against"),
65
+ chainId: z
66
+ .number()
67
+ .int()
68
+ .optional()
69
+ .default(8453)
70
+ .describe("Target blockchain network ID for EIP-712 signature (Base Mainnet: 8453, Base Sepolia: 84532)"),
71
+ })
72
+ .strip()
73
+ .describe("Parameters for web ground-truth discovery with on-chain verifiable EIP-712 cryptographic attestation");
74
+ /**
75
+ * 5. Manage x402 Agent Vault Schema
76
+ */
77
+ export const ManageVaultSchema = z
78
+ .object({
79
+ action: z
80
+ .enum(["balance", "deposit_info", "pass_status"])
81
+ .describe("Action to perform: 'balance' (check prefunded USDC balance), 'deposit_info' (get deposit address & chain parameters), or 'pass_status' (check agent VIP pass)"),
82
+ agentAddress: z
83
+ .string()
84
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Must be a valid EVM address (0x...)")
85
+ .optional()
86
+ .describe("The agent's EVM wallet address on Base Mainnet"),
87
+ })
88
+ .strip()
89
+ .describe("Parameters for managing gasless sub-millisecond x402 USDC micropayment session vaults");
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "agentkit-cleanweb",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "Official Coinbase AgentKit Action Provider for CleanWeb 87% Token Reduction, Research PDF Parser, YouTube Gemini Intelligence, and Base Mainnet EIP-712 Oracle Grounding",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/nohosa001-pixel/x402-cleanweb-agent.git",
12
+ "directory": "packages/agentkit-cleanweb"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "test": "node --test tests/test_action_provider.test.mjs"
20
+ },
21
+ "keywords": [
22
+ "coinbase",
23
+ "agentkit",
24
+ "base",
25
+ "x402",
26
+ "ai-agent",
27
+ "web-scraping",
28
+ "token-reduction",
29
+ "ground-truth",
30
+ "eip712",
31
+ "oracle",
32
+ "gemini"
33
+ ],
34
+ "author": "CleanWeb & A.GRID Team",
35
+ "license": "MIT",
36
+ "peerDependencies": {
37
+ "@coinbase/agentkit": ">=0.1.0"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "@coinbase/agentkit": {
41
+ "optional": true
42
+ }
43
+ },
44
+ "dependencies": {
45
+ "zod": "^3.23.8"
46
+ },
47
+ "devDependencies": {
48
+ "@types/node": "^22.13.0",
49
+ "typescript": "^5.8.2",
50
+ "zod": "^3.23.8"
51
+ },
52
+ "files": [
53
+ "dist",
54
+ "src",
55
+ "README.md"
56
+ ]
57
+ }