@konstantinbozukov/plugin-edge-signals 0.0.0-stage → 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 Konstantin Bozukov
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 CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # @konstantinbozukov/plugin-edge-signals
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ElizaOS plugin: **`TOKEN_VERDICT_BEFORE_SWAP`** action (paid Edge Signals) and **`EDGE_SIGNALS_TOKEN_VERDICT`** provider.
4
+
5
+ Configure `X402_PAYER_PRIVATE_KEY` via `agentConfig` (sensitive) — never commit keys.
6
+
7
+ ```typescript
8
+ import edgeSignalsPlugin from "@konstantinbozukov/plugin-edge-signals";
9
+
10
+ export default {
11
+ plugins: [edgeSignalsPlugin],
12
+ };
13
+ ```
@@ -0,0 +1,24 @@
1
+ import { Action, Provider, Plugin } from '@elizaos/core';
2
+
3
+ type TokenVerdictBand = "SAFE" | "CAUTION" | "AVOID";
4
+ type TokenVerdictGrade = "A" | "B" | "C" | "D" | "F";
5
+ interface TokenVerdictResponse {
6
+ grade: TokenVerdictGrade;
7
+ band: TokenVerdictBand;
8
+ score: number;
9
+ reasons: string[];
10
+ disclaimer: string;
11
+ summary?: string;
12
+ }
13
+ type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
14
+
15
+ declare function setEdgeSignalsFetch(fn: FetchLike): void;
16
+ declare function fetchTokenVerdict(token: string, chain?: string): Promise<TokenVerdictResponse>;
17
+
18
+ declare const tokenVerdictBeforeSwapAction: Action;
19
+
20
+ declare const tokenVerdictProvider: Provider;
21
+
22
+ declare const edgeSignalsPlugin: Plugin;
23
+
24
+ export { edgeSignalsPlugin as default, edgeSignalsPlugin, fetchTokenVerdict, setEdgeSignalsFetch, tokenVerdictBeforeSwapAction, tokenVerdictProvider };
package/dist/index.js ADDED
@@ -0,0 +1,155 @@
1
+ // src/client.ts
2
+ var BASE = "https://signals.edge.report";
3
+ var fetchFn = null;
4
+ function setEdgeSignalsFetch(fn) {
5
+ fetchFn = fn;
6
+ }
7
+ function getEdgeSignalsFetch() {
8
+ if (!fetchFn) {
9
+ throw new Error(
10
+ "Edge Signals fetch not configured. Set X402_PAYER_PRIVATE_KEY in plugin init or call setEdgeSignalsFetch in tests."
11
+ );
12
+ }
13
+ return fetchFn;
14
+ }
15
+ function buildTokenVerdictUrl(token, chain = "base") {
16
+ const url = new URL("/v1/token-verdict", BASE);
17
+ url.searchParams.set("token", token);
18
+ url.searchParams.set("chain", chain);
19
+ return url.toString();
20
+ }
21
+ async function fetchTokenVerdict(token, chain = "base") {
22
+ const res = await getEdgeSignalsFetch()(buildTokenVerdictUrl(token, chain));
23
+ if (!res.ok) throw new Error(`Token Verdict HTTP ${res.status}`);
24
+ return await res.json();
25
+ }
26
+ function extractErc20Address(text) {
27
+ const match = text.match(/0x[a-fA-F0-9]{40}/);
28
+ return match?.[0] ?? null;
29
+ }
30
+
31
+ // src/types.ts
32
+ var LAST_VERDICT_KEY = "edgeSignals:lastTokenVerdict";
33
+
34
+ // src/actions/tokenVerdictBeforeSwap.ts
35
+ var tokenVerdictBeforeSwapAction = {
36
+ name: "TOKEN_VERDICT_BEFORE_SWAP",
37
+ similes: [
38
+ "CHECK_TOKEN_BEFORE_SWAP",
39
+ "EDGE_SIGNALS_VERDICT",
40
+ "SCREEN_TOKEN_BEFORE_TRADE"
41
+ ],
42
+ description: "Pay $0.01 for Edge Signals Token Verdict on an ERC-20 before approving or swapping.",
43
+ validate: async (_runtime, message) => {
44
+ const text = message.content?.text ?? "";
45
+ return /swap|buy|trade|verdict|risk/i.test(text) && !!extractErc20Address(text);
46
+ },
47
+ handler: async (runtime, message, _state, _options, callback) => {
48
+ const text = message.content?.text ?? "";
49
+ const token = extractErc20Address(text);
50
+ if (!token) {
51
+ return { success: false, text: "No ERC-20 address found in message.", error: "NO_TOKEN" };
52
+ }
53
+ const chain = runtime.getSetting("EDGE_SIGNALS_CHAIN") ?? "base";
54
+ let verdict;
55
+ try {
56
+ verdict = await fetchTokenVerdict(token, chain);
57
+ } catch (err) {
58
+ const msg = err instanceof Error ? err.message : String(err);
59
+ return { success: false, text: `Token Verdict failed: ${msg}`, error: msg };
60
+ }
61
+ runtime.setSetting(LAST_VERDICT_KEY, JSON.stringify({ token, chain, verdict }));
62
+ const allowSwap = verdict.band !== "AVOID";
63
+ const summary = verdict.summary ?? `${verdict.band} \u2014 grade ${verdict.grade} (score ${verdict.score}/100)`;
64
+ const responseText = allowSwap ? `Token Verdict OK to proceed with caution: ${summary}. Reasons: ${verdict.reasons.join("; ")}` : `Swap blocked \u2014 ${summary}. Reasons: ${verdict.reasons.join("; ")}`;
65
+ await callback?.({ text: responseText, action: "TOKEN_VERDICT_BEFORE_SWAP" });
66
+ return {
67
+ success: true,
68
+ text: responseText,
69
+ data: { token, chain, verdict, allowSwap },
70
+ values: { allowSwap, tokenVerdictBand: verdict.band }
71
+ };
72
+ },
73
+ examples: [
74
+ [
75
+ {
76
+ name: "{{user}}",
77
+ content: {
78
+ text: "Run token verdict before I swap 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 on Base"
79
+ }
80
+ },
81
+ {
82
+ name: "{{agent}}",
83
+ content: {
84
+ text: "I'll call Edge Signals Token Verdict before the swap.",
85
+ action: "TOKEN_VERDICT_BEFORE_SWAP"
86
+ }
87
+ }
88
+ ]
89
+ ]
90
+ };
91
+
92
+ // src/providers/tokenVerdictProvider.ts
93
+ var tokenVerdictProvider = {
94
+ name: "EDGE_SIGNALS_TOKEN_VERDICT",
95
+ description: "Latest Edge Signals Token Verdict cached from the pre-swap action",
96
+ get: async (runtime, _message, _state) => {
97
+ const raw = runtime.getSetting(LAST_VERDICT_KEY);
98
+ if (!raw) {
99
+ return {
100
+ text: "No Token Verdict cached yet. Run TOKEN_VERDICT_BEFORE_SWAP first.",
101
+ values: {},
102
+ data: {}
103
+ };
104
+ }
105
+ let stored;
106
+ try {
107
+ stored = JSON.parse(raw);
108
+ } catch {
109
+ return { text: "Token Verdict cache corrupted.", values: {}, data: {} };
110
+ }
111
+ const { verdict, token, chain } = stored;
112
+ const line = `${verdict.band} (${verdict.grade}, ${verdict.score}/100) for ${token} on ${chain}`;
113
+ return {
114
+ text: `Latest Token Verdict: ${line}. ${verdict.disclaimer}`,
115
+ values: {
116
+ tokenVerdictBand: verdict.band,
117
+ tokenVerdictGrade: verdict.grade,
118
+ tokenVerdictToken: token
119
+ },
120
+ data: {
121
+ token,
122
+ chain,
123
+ grade: verdict.grade,
124
+ band: verdict.band,
125
+ score: verdict.score,
126
+ reasons: verdict.reasons,
127
+ disclaimer: verdict.disclaimer
128
+ }
129
+ };
130
+ }
131
+ };
132
+
133
+ // src/index.ts
134
+ var edgeSignalsPlugin = {
135
+ name: "edge-signals",
136
+ description: "Edge Signals Token Verdict via x402 USDC on Base \u2014 screen tokens before swaps.",
137
+ actions: [tokenVerdictBeforeSwapAction],
138
+ providers: [tokenVerdictProvider],
139
+ init: async (_config, runtime) => {
140
+ const pk = runtime.getSetting("X402_PAYER_PRIVATE_KEY") ?? process.env.X402_PAYER_PRIVATE_KEY ?? process.env.EDGE_SIGNALS_PAYER_PRIVATE_KEY;
141
+ if (pk) {
142
+ const { loadX402Fetch } = await import("./loadX402Fetch-OGOTSAUV.js");
143
+ setEdgeSignalsFetch(await loadX402Fetch(pk));
144
+ }
145
+ }
146
+ };
147
+ var index_default = edgeSignalsPlugin;
148
+ export {
149
+ index_default as default,
150
+ edgeSignalsPlugin,
151
+ fetchTokenVerdict,
152
+ setEdgeSignalsFetch,
153
+ tokenVerdictBeforeSwapAction,
154
+ tokenVerdictProvider
155
+ };
@@ -0,0 +1,13 @@
1
+ // src/loadX402Fetch.ts
2
+ async function loadX402Fetch(privateKey) {
3
+ const { privateKeyToAccount } = await import("viem/accounts");
4
+ const { x402Client, wrapFetchWithPayment } = await import("@x402/fetch");
5
+ const { registerExactEvmScheme } = await import("@x402/evm/exact/client/register");
6
+ const client = registerExactEvmScheme(new x402Client(), {
7
+ signer: privateKeyToAccount(privateKey)
8
+ });
9
+ return wrapFetchWithPayment(fetch, client);
10
+ }
11
+ export {
12
+ loadX402Fetch
13
+ };
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@konstantinbozukov/plugin-edge-signals",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "ElizaOS plugin: Token Verdict before swaps (Edge Signals x402)",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsup",
13
+ "test": "vitest run",
14
+ "lint": "tsc --noEmit"
15
+ },
16
+ "peerDependencies": {
17
+ "@elizaos/core": ">=2.0.0"
18
+ },
19
+ "optionalDependencies": {
20
+ "@x402/evm": "^2.31.0",
21
+ "@x402/fetch": "^2.31.0",
22
+ "viem": "^2.31.0"
23
+ },
24
+ "devDependencies": {
25
+ "@elizaos/core": "^2.0.5",
26
+ "@types/node": "^22.10.0",
27
+ "tsup": "^8.3.5",
28
+ "typescript": "^5.7.2",
29
+ "vitest": "^3.0.5"
30
+ },
31
+ "agentConfig": {
32
+ "pluginType": "elizaos:plugin:1.0.0",
33
+ "pluginParameters": {
34
+ "X402_PAYER_PRIVATE_KEY": {
35
+ "type": "string",
36
+ "description": "Base wallet private key for x402 USDC payments to Edge Signals. Never commit.",
37
+ "sensitive": true
38
+ },
39
+ "EDGE_SIGNALS_CHAIN": {
40
+ "type": "string",
41
+ "description": "Default EVM chain for Token Verdict",
42
+ "defaultValue": "base"
43
+ }
44
+ }
45
+ },
46
+ "license": "MIT",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/konstantinbozukov/edge-signals-kits.git",
50
+ "directory": "elizaos"
51
+ },
52
+ "homepage": "https://github.com/konstantinbozukov/edge-signals-kits/tree/main/elizaos",
53
+ "bugs": {
54
+ "url": "https://github.com/konstantinbozukov/edge-signals-kits/issues"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ }
59
+ }