@wzrd_sol/eliza-plugin 0.3.3 → 0.6.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 +123 -49
- package/dist/actions/intel-preflight.js +2 -1
- package/dist/actions/intel-trust.d.ts +1 -1
- package/dist/actions/intel-trust.js +3 -2
- package/dist/actions/verify-receipt.d.ts +2 -2
- package/dist/actions/verify-receipt.js +3 -3
- package/dist/index.d.ts +20 -8
- package/dist/index.js +34 -18
- package/dist/paying-fetch.d.ts +17 -0
- package/dist/paying-fetch.js +19 -0
- package/dist/test/plugin-registration.intel.js +21 -1
- package/package.json +8 -6
package/README.md
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
# @wzrd_sol/eliza-plugin
|
|
2
2
|
|
|
3
|
-
ElizaOS plugin for
|
|
4
|
-
|
|
3
|
+
ElizaOS plugin for **TWZRD Agent Intel** — free preflight before x402 spends, optional paid
|
|
4
|
+
trust receipts, and offline verification. Default path (0.6+):
|
|
5
|
+
|
|
6
|
+
```text
|
|
7
|
+
seller → preflight → merchant_card → policy → optional trust receipt → sign or refuse
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
The default export registers **intel actions only**. Legacy AO/CCM earn actions are opt-in.
|
|
11
|
+
|
|
12
|
+
## Buyer sequence (marketplace default)
|
|
13
|
+
|
|
14
|
+
Before any x402 spend:
|
|
15
|
+
|
|
16
|
+
1. **Free preflight** - `WZRD_INTEL_PREFLIGHT` / `preSpendGate` - ReadinessCard `allow` / `warn` / `block`
|
|
17
|
+
2. **Free merchant_card** - `WZRD_MERCHANT_CARD` (or inside `preSpendGate`) - if `wash_flagged: true`, **do not pay** (default)
|
|
18
|
+
3. **Optional paid trust** - `WZRD_INTEL_TRUST` (~0.05 USDC) - full score + **signed V6 receipt**
|
|
19
|
+
4. **Offline verify** - `WZRD_VERIFY_RECEIPT`
|
|
20
|
+
|
|
21
|
+
This plugin exposes **actions + SDK helpers**. It does **not** auto-intercept every wallet signature.
|
|
22
|
+
Wire `preSpendGate` / actions into your spend path, or compose with standalone `twzrd-x402-gate` on a paying fetch.
|
|
5
23
|
|
|
6
24
|
## 3-line quickstart
|
|
7
25
|
|
|
8
26
|
```typescript
|
|
9
27
|
import wzrdPlugin from '@wzrd_sol/eliza-plugin';
|
|
10
28
|
const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
11
|
-
// "Preflight seller JUP6Lkb... at 0.25 USDC"
|
|
29
|
+
// "Preflight seller JUP6Lkb... at 0.25 USDC" -> allow/warn/block, free, no wallet
|
|
30
|
+
// "Merchant card for GFpLvoc..." -> wash_flagged refuse default
|
|
12
31
|
```
|
|
13
32
|
|
|
14
33
|
## Install
|
|
@@ -17,22 +36,30 @@ const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
|
17
36
|
npm install @wzrd_sol/eliza-plugin
|
|
18
37
|
```
|
|
19
38
|
|
|
39
|
+
## Which package?
|
|
40
|
+
|
|
41
|
+
| Package | Role | Auto-gates every payment? |
|
|
42
|
+
|---------|------|---------------------------|
|
|
43
|
+
| **`@wzrd_sol/eliza-plugin`** (this) | Eliza actions: preflight, merchant_card, paid trust, verify; re-exports SDK `preSpendGate` | No - call-site / LLM actions |
|
|
44
|
+
| **`@wzrd_sol/plugin-trustgate`** | Smaller Eliza provider + `canSpendSafely` (preflight only) | No - opt-in `canSpendSafely` |
|
|
45
|
+
| **`twzrd-x402-gate`** | Framework-agnostic fetch wrapper (preflight + wash refuse on 402) | Only if you wrap fetch |
|
|
46
|
+
|
|
20
47
|
## Configuration
|
|
21
48
|
|
|
22
49
|
| Variable | Required | Default | Description |
|
|
23
50
|
|----------|----------|---------|-------------|
|
|
24
|
-
| `WZRD_INTEL_URL` | No | `https://intel.twzrd.xyz` | Agent Intel API (preflight, trust, verify) |
|
|
25
|
-
| `WZRD_API_URL` |
|
|
26
|
-
| `SOLANA_PRIVATE_KEY` |
|
|
51
|
+
| `WZRD_INTEL_URL` | No | `https://intel.twzrd.xyz` | Agent Intel API (preflight, merchant_card, trust, verify) |
|
|
52
|
+
| `WZRD_API_URL` | Legacy earn only | `https://api.twzrd.xyz` | Earn API when `legacyEarnActions: true` |
|
|
53
|
+
| `SOLANA_PRIVATE_KEY` | Legacy earn only | - | JSON array of secret key bytes for agent Ed25519 auth |
|
|
27
54
|
|
|
28
55
|
## Intel actions (primary)
|
|
29
56
|
|
|
30
57
|
| Action | Auth/Pay | Description |
|
|
31
58
|
|--------|----------|-------------|
|
|
32
59
|
| `WZRD_INTEL_PREFLIGHT` | Free | ReadinessCard: `decision`, `trust_score`, `can_spend`, `caveats`, `preflight_id` |
|
|
33
|
-
| `WZRD_MERCHANT_CARD` | Free | Graph card: `wash_flagged`, tier, catalog join; default refuse if wash |
|
|
34
|
-
| `WZRD_INTEL_TRUST` | x402 (~0.05 USDC) | Paid trust payload + V6 signed receipt + ERC-8004 `reputation_credential` |
|
|
35
|
-
| `WZRD_VERIFY_RECEIPT` | Free (offline) | Recompute leaf + Ed25519 verify;
|
|
60
|
+
| `WZRD_MERCHANT_CARD` | Free | Graph card: `wash_flagged`, tier, catalog join; **default refuse if wash** |
|
|
61
|
+
| `WZRD_INTEL_TRUST` | x402 (~0.05 USDC) | Paid trust payload + **V6** signed receipt + ERC-8004 `reputation_credential` |
|
|
62
|
+
| `WZRD_VERIFY_RECEIPT` | Free (offline) | Recompute leaf + Ed25519 verify; V6 primary (older V5 still accepted) |
|
|
36
63
|
|
|
37
64
|
### Preflight (free, no wallet)
|
|
38
65
|
|
|
@@ -57,60 +84,78 @@ Decision: allow
|
|
|
57
84
|
Trust score: 72
|
|
58
85
|
Can spend: yes
|
|
59
86
|
Preflight ID: pf_abc123
|
|
60
|
-
Paid deep dive available (0.05 USDC)
|
|
87
|
+
Paid deep dive available (0.05 USDC) - use WZRD_INTEL_TRUST
|
|
61
88
|
```
|
|
62
89
|
|
|
63
|
-
###
|
|
64
|
-
|
|
65
|
-
For agents that call x402-gated URLs directly (not via pre-known seller wallet), pair this
|
|
66
|
-
plugin with `twzrd-x402-gate` to intercept 402s before any spend:
|
|
90
|
+
### Merchant card (free wash / demand-quality gate)
|
|
67
91
|
|
|
68
92
|
```typescript
|
|
69
|
-
import
|
|
70
|
-
import { withTwzrdGuard } from 'twzrd-x402-gate';
|
|
71
|
-
import { createAgentcashFetch } from 'agentcash';
|
|
93
|
+
import { merchantCardAction, fetchMerchantCard } from '@wzrd_sol/eliza-plugin';
|
|
72
94
|
|
|
73
|
-
//
|
|
74
|
-
|
|
75
|
-
const safeFetch = withTwzrdGuard(x402Fetch, {
|
|
76
|
-
autoReceipt: true, // auto-buy $0.05 TWZRD receipt on warn/allow
|
|
77
|
-
x402Fetch,
|
|
78
|
-
});
|
|
95
|
+
// Action (LLM-callable):
|
|
96
|
+
// "Merchant card for GFpLvocNdEjnSsLH3VJQL6wGcjGxTbUBrj6fqN3Qe1Gs"
|
|
79
97
|
|
|
80
|
-
//
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
//
|
|
98
|
+
// Programmatic:
|
|
99
|
+
const card = await fetchMerchantCard(sellerPubkey);
|
|
100
|
+
if (card?.wash_flagged) return 'refuse dirty pay_to';
|
|
101
|
+
// card unreachable -> fail-open (do not invent wash); use preflight decision only
|
|
84
102
|
```
|
|
85
103
|
|
|
86
|
-
|
|
87
|
-
1. `safeFetch` hits the resource, gets HTTP 402.
|
|
88
|
-
2. `withTwzrdGuard` reads `accepts[0].payTo` (seller wallet).
|
|
89
|
-
3. Calls `POST /v1/intel/preflight` — free, no auth.
|
|
90
|
-
4. `block` - throws, no payment made.
|
|
91
|
-
5. `warn/allow` - returns the 402 for the x402 client to pay.
|
|
104
|
+
Catalog enrichment is listing metadata only - never overrides wash.
|
|
92
105
|
|
|
93
|
-
### Pre-spend gate (programmatic)
|
|
106
|
+
### Pre-spend gate (programmatic - both free checks)
|
|
94
107
|
|
|
95
108
|
```typescript
|
|
96
109
|
import { preSpendGate, fetchIntelTrust, fetchMerchantCard } from '@wzrd_sol/eliza-plugin';
|
|
97
110
|
|
|
98
|
-
//
|
|
111
|
+
// Free preflight + free merchant_card wash refuse (default on):
|
|
99
112
|
const gate = await preSpendGate({ seller_wallet: sellerPubkey, price_usdc: 0.25 });
|
|
100
113
|
if (!gate.allow) return `Blocked (${gate.decision}): ${gate.reason}`;
|
|
101
114
|
// gate.washFlagged === true was refuse default; null = card gap (fail-open)
|
|
102
115
|
|
|
103
|
-
// Or inspect the card alone:
|
|
104
|
-
const card = await fetchMerchantCard(sellerPubkey);
|
|
105
|
-
if (card?.wash_flagged) return 'refuse dirty pay_to';
|
|
106
|
-
|
|
107
116
|
// Then pay and get the receipt:
|
|
108
117
|
const trust = await fetchIntelTrust(sellerPubkey, { fetchImpl: myX402Fetch });
|
|
109
118
|
```
|
|
110
119
|
|
|
111
|
-
**Default:** `refuseWashFlagged: true`
|
|
120
|
+
**Default:** `refuseWashFlagged: true` - if free `merchant_card.wash_flagged`, do not pay.
|
|
112
121
|
Soft cap: `{ washMaxUsdc: 0.05 }`. Opt out: `{ refuseWashFlagged: false }`.
|
|
113
122
|
|
|
123
|
+
### Guard pattern: fire-before-pay with `installTwzrdAutoGate` (default-on)
|
|
124
|
+
|
|
125
|
+
For agents that call x402-gated URLs directly (not via a pre-known seller wallet), pair this
|
|
126
|
+
plugin with standalone **`twzrd-x402-gate`** (separate package - not bundled here) to intercept
|
|
127
|
+
402s before any spend — and register the result as the plugin's paying fetch in one call:
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import wzrdPlugin, { installTwzrdAutoGate } from '@wzrd_sol/eliza-plugin';
|
|
131
|
+
import { wrapFetchWithPayment } from '@x402/svm';
|
|
132
|
+
|
|
133
|
+
// Guards the raw fetch (free preflight + free merchant_card wash refuse), hands the guarded
|
|
134
|
+
// fetch to your x402 client, registers the result as the module paying fetch — a blocked or
|
|
135
|
+
// wash-flagged seller throws before your client ever signs.
|
|
136
|
+
installTwzrdAutoGate((guarded) => wrapFetchWithPayment(guarded, buyerWallet));
|
|
137
|
+
|
|
138
|
+
const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
139
|
+
// WZRD_INTEL_TRUST and any tool/skill using resolvePayingFetch() now goes through the guard.
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`payWrap` (the function you pass in) receives the **guarded** fetch — the guard has already
|
|
143
|
+
run by the time your client sees a 402. Building the composition the other way round (guarding
|
|
144
|
+
an already-paying client, e.g. one that resolves 402s internally and returns 200) is a no-op;
|
|
145
|
+
see `twzrd-x402-gate`'s Compatibility note. Opt out with `TWZRD_AUTO_GATE=0` (env) or
|
|
146
|
+
`{ disabled: true }`.
|
|
147
|
+
|
|
148
|
+
Guard flow (in `twzrd-x402-gate`, not inside this plugin):
|
|
149
|
+
1. The raw fetch hits the resource, gets HTTP 402.
|
|
150
|
+
2. The guard reads `accepts[0].payTo` (seller wallet).
|
|
151
|
+
3. Free `POST /v1/intel/preflight` — `decision=block` / score floor throws, `payWrap`'s client never signs.
|
|
152
|
+
4. Free `GET /v1/intel/merchant_card/{payTo}` — `wash_flagged:true` refuses by default (only tightens step 3).
|
|
153
|
+
5. Otherwise returns the 402 to `payWrap`'s client, which pays normally.
|
|
154
|
+
|
|
155
|
+
For manual composition (managing the raw/paying split yourself) or `autoReceipt`/`escalateOnWarn`
|
|
156
|
+
options, use `withTwzrdGuard` from `twzrd-x402-gate` directly and pass the result to `setPayingFetch`
|
|
157
|
+
— see that package's README.
|
|
158
|
+
|
|
114
159
|
### Paid trust receipt (agentcash)
|
|
115
160
|
|
|
116
161
|
```typescript
|
|
@@ -121,7 +166,7 @@ setPayingFetch(createAgentcashFetch({ apiKey: process.env.AGENTCASH_API_KEY }));
|
|
|
121
166
|
|
|
122
167
|
const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
123
168
|
// "Get the trust receipt for seller JUP6LkbZ..."
|
|
124
|
-
//
|
|
169
|
+
// -> WZRD_INTEL_TRUST: free preflight + merchant_card, then pays $0.05 USDC, returns VC + V6 receipt
|
|
125
170
|
```
|
|
126
171
|
|
|
127
172
|
### Paid trust receipt (PayAI)
|
|
@@ -136,8 +181,9 @@ setPayingFetch((url, init) => payai.fetch(url, init));
|
|
|
136
181
|
const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
137
182
|
```
|
|
138
183
|
|
|
139
|
-
Without a paying fetch, `WZRD_INTEL_TRUST` returns the HTTP 402 requirements and
|
|
140
|
-
`npx agentcash@latest fetch
|
|
184
|
+
Without a paying fetch, `WZRD_INTEL_TRUST` returns the HTTP 402 requirements and a
|
|
185
|
+
manual pay one-liner. Caveat: `npx agentcash@latest fetch` has been a known-bad path
|
|
186
|
+
for TWZRD paid trust (fee_payer slot); prefer a wired `setPayingFetch` client.
|
|
141
187
|
|
|
142
188
|
**`WZRD_INTEL_TRUST` response fields:**
|
|
143
189
|
|
|
@@ -165,17 +211,43 @@ if (vc.distinctCounterparties < 3) return 'warn'; // thin history
|
|
|
165
211
|
if (vc.washFactor < 0.5) return 'warn'; // suspicious ring
|
|
166
212
|
```
|
|
167
213
|
|
|
168
|
-
`effectiveTrustScore` is the cross-facilitator wash-adjusted score
|
|
214
|
+
`effectiveTrustScore` is the cross-facilitator wash-adjusted score - computed across all known
|
|
169
215
|
x402 facilitators, not just one settlement path.
|
|
170
216
|
|
|
217
|
+
### Facilitator settle attach (optional host pattern - not an Eliza action)
|
|
218
|
+
|
|
219
|
+
If your x402 client uses TWZRD as facilitator (`https://intel.twzrd.xyz`), successful
|
|
220
|
+
`POST /settle` may return `merchant_attach` + `twzrd_receipt` for the requirements `payTo`
|
|
221
|
+
(best-effort; never voids on-chain settle). Discover via `GET /supported` (`twzrd.merchant_attach`).
|
|
222
|
+
This plugin does not register a settle action - wire facilitator URL in the host payer.
|
|
223
|
+
|
|
171
224
|
### Example agent prompts (trust)
|
|
172
225
|
|
|
173
226
|
- `"Preflight Jupiter Quote Preview before I pay 0.25 USDC to 6EF8rrect..."`
|
|
227
|
+
- `"Merchant card for GFpLvocNdEjnSsLH3VJQL6wGcjGxTbUBrj6fqN3Qe1Gs"`
|
|
174
228
|
- `"Get the trust receipt for seller JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"`
|
|
175
229
|
- `"Is it safe to call the paid intel endpoint on this seller?"`
|
|
176
230
|
- `"Verify this receipt: {leaf, preimage, signature...}"`
|
|
177
231
|
|
|
178
|
-
## Legacy earn actions
|
|
232
|
+
## Legacy earn actions (opt-in)
|
|
233
|
+
|
|
234
|
+
**0.6 breaking change:** `import wzrdPlugin from '@wzrd_sol/eliza-plugin'` registers intel
|
|
235
|
+
actions only. To restore the pre-0.6 earn surface:
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
import { createWzrdPlugin, wzrdPluginWithLegacyEarn } from '@wzrd_sol/eliza-plugin';
|
|
239
|
+
|
|
240
|
+
// Either factory:
|
|
241
|
+
const agent = new AgentRuntime({
|
|
242
|
+
plugins: [createWzrdPlugin({ legacyEarnActions: true })],
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Or compatibility export:
|
|
246
|
+
const agent = new AgentRuntime({ plugins: [wzrdPluginWithLegacyEarn] });
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Legacy earn is **not** part of the supported Agent Intel conversion path. New agents should
|
|
250
|
+
use intel actions + `twzrd-x402-gate` for pre-sign policy.
|
|
179
251
|
|
|
180
252
|
| Action | Auth | Description |
|
|
181
253
|
|--------|------|-------------|
|
|
@@ -198,6 +270,7 @@ x402 facilitators, not just one settlement path.
|
|
|
198
270
|
import {
|
|
199
271
|
intelPreflight,
|
|
200
272
|
fetchIntelTrust,
|
|
273
|
+
fetchMerchantCard,
|
|
201
274
|
verifyReceipt,
|
|
202
275
|
preSpendGate,
|
|
203
276
|
IntelPaymentRequiredError,
|
|
@@ -206,6 +279,7 @@ import {
|
|
|
206
279
|
import type {
|
|
207
280
|
ReadinessCard,
|
|
208
281
|
PreflightResponse,
|
|
282
|
+
MerchantCard,
|
|
209
283
|
IntelTrustResponse,
|
|
210
284
|
TwzrdReceipt,
|
|
211
285
|
} from '@wzrd_sol/eliza-plugin';
|
|
@@ -220,8 +294,8 @@ npm run build
|
|
|
220
294
|
npm test
|
|
221
295
|
```
|
|
222
296
|
|
|
223
|
-
`npm test` runs live free preflight against `intel.twzrd.xyz`,
|
|
224
|
-
mocked paid trust path.
|
|
297
|
+
`npm test` runs live free preflight against `intel.twzrd.xyz`, free merchant_card path,
|
|
298
|
+
offline receipt verify, and a mocked paid trust path.
|
|
225
299
|
|
|
226
300
|
Manual earn smoke (requires `SOLANA_PRIVATE_KEY`):
|
|
227
301
|
|
|
@@ -233,9 +307,9 @@ npx tsx test/earn-e2e.ts
|
|
|
233
307
|
|
|
234
308
|
- [Agent Intel API](https://intel.twzrd.xyz)
|
|
235
309
|
- [API docs / llms.txt](https://intel.twzrd.xyz/llms.txt)
|
|
236
|
-
- [x402 gate (standalone firewall)](https://www.npmjs.com/package/twzrd-x402-gate)
|
|
310
|
+
- [x402 gate (standalone fetch firewall)](https://www.npmjs.com/package/twzrd-x402-gate)
|
|
311
|
+
- [plugin-trustgate (smaller Eliza spend guard)](https://www.npmjs.com/package/@wzrd_sol/plugin-trustgate)
|
|
237
312
|
- [GOAT plugin](https://www.npmjs.com/package/@wzrd_sol/goat-plugin)
|
|
238
|
-
- [TWZRD trust quickstart](https://intel.twzrd.xyz/docs/QUICKSTART.md)
|
|
239
313
|
|
|
240
314
|
## License
|
|
241
315
|
|
|
@@ -43,7 +43,8 @@ export const intelPreflightAction = {
|
|
|
43
43
|
similes: ['WZRD_PREFLIGHT', 'INTEL_PREFLIGHT', 'READINESS_CARD'],
|
|
44
44
|
description: 'Free pre-spend ReadinessCard for a seller/resource/price/intent. Returns decision (allow/warn/block), ' +
|
|
45
45
|
'trust_score, can_spend, caveats, paid_deep_dive upsell, and root_provenance when applicable. ' +
|
|
46
|
-
'
|
|
46
|
+
'Step 1 of the buyer sequence before any x402 payment; follow with WZRD_MERCHANT_CARD (wash refuse default) ' +
|
|
47
|
+
'or preSpendGate which runs both free checks.',
|
|
47
48
|
examples: [
|
|
48
49
|
[
|
|
49
50
|
{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* WZRD_INTEL_TRUST — Paid trust payload + signed receipt
|
|
2
|
+
* WZRD_INTEL_TRUST — Paid trust payload + signed V6 receipt via x402-capable
|
|
3
3
|
* fetch. Preflight-gated: free ReadinessCard + free merchant_card wash check run
|
|
4
4
|
* BEFORE payment; decision=block or wash_flagged aborts before any spend.
|
|
5
5
|
*/
|
|
@@ -4,8 +4,9 @@ import { resolvePayingFetch } from '../paying-fetch.js';
|
|
|
4
4
|
export const intelTrustAction = {
|
|
5
5
|
name: 'WZRD_INTEL_TRUST',
|
|
6
6
|
similes: ['WZRD_TRUST_RECEIPT', 'INTEL_TRUST', 'GET_TRUST_RECEIPT'],
|
|
7
|
-
description: 'Paid GET /v1/intel/trust/{pubkey} (~0.05 USDC). Returns trust score + signed
|
|
8
|
-
'Runs free preflight + merchant_card wash check first;
|
|
7
|
+
description: 'Paid GET /v1/intel/trust/{pubkey} (~0.05 USDC on Solana). Returns renormalized trust score + signed V6 ' +
|
|
8
|
+
'twzrd_receipt (portable offline proof). Runs free preflight + merchant_card wash check first; ' +
|
|
9
|
+
'aborts on decision=block or wash_flagged before any spend. ' +
|
|
9
10
|
'Requires an x402-capable fetchImpl (setPayingFetch or host service). ' +
|
|
10
11
|
'Surfaces payment requirements if no payer is configured.',
|
|
11
12
|
examples: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WZRD_VERIFY_RECEIPT — Offline leaf + Ed25519 verification (no network).
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Primary surface is V6 (reputation leaf). Older V5 receipts still verify when
|
|
4
|
+
* presented; the SDK selects the leaf binding from the receipt domain.
|
|
5
5
|
*/
|
|
6
6
|
import type { Action } from '@elizaos/core';
|
|
7
7
|
export declare const verifyReceiptAction: Action;
|
|
@@ -3,11 +3,11 @@ import { getIntelBase, parseReceipt, withTimeout } from '../intel-helpers.js';
|
|
|
3
3
|
export const verifyReceiptAction = {
|
|
4
4
|
name: 'WZRD_VERIFY_RECEIPT',
|
|
5
5
|
similes: ['WZRD_VERIFY', 'VERIFY_TWZRD_RECEIPT', 'CHECK_RECEIPT'],
|
|
6
|
-
description: 'Offline verify a TwzrdReceipt (V5
|
|
7
|
-
'against the published TWZRD key. No network required when trustedPubkey is known.',
|
|
6
|
+
description: 'Offline verify a TwzrdReceipt (V6 primary; older V5 still accepted): recompute keccak leaf from preimage ' +
|
|
7
|
+
'and check Ed25519 signature against the published TWZRD key. No network required when trustedPubkey is known.',
|
|
8
8
|
examples: [
|
|
9
9
|
[
|
|
10
|
-
{ name: '{{user1}}', content: { text: 'Verify this receipt: {"version":"
|
|
10
|
+
{ name: '{{user1}}', content: { text: 'Verify this receipt: {"version":"v6","leaf":"0x...","preimage":{...}}' } },
|
|
11
11
|
{ name: '{{agentName}}', content: { text: 'Receipt valid: leaf OK, signature OK.' } },
|
|
12
12
|
],
|
|
13
13
|
],
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @wzrd_sol/eliza-plugin — WZRD Agent Intel
|
|
2
|
+
* @wzrd_sol/eliza-plugin — WZRD Agent Intel for ElizaOS
|
|
3
3
|
*
|
|
4
4
|
* Intel lane (default https://intel.twzrd.xyz):
|
|
5
5
|
* WZRD_INTEL_PREFLIGHT → WZRD_MERCHANT_CARD → WZRD_INTEL_TRUST → WZRD_VERIFY_RECEIPT
|
|
6
|
-
* Paid intel requires caller-supplied x402 fetch
|
|
6
|
+
* Paid intel requires a caller-supplied x402 fetch — either setPayingFetch(payingFetch)
|
|
7
|
+
* (already-composed, unguarded) or installTwzrdAutoGate(payWrap) (default-on: guards the
|
|
8
|
+
* raw fetch before your client signs, then registers it the same way).
|
|
7
9
|
* Default: preSpendGate refuses wash_flagged pay_to (free merchant_card).
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
* WZRD_INFER → WZRD_REPORT → WZRD_EARN → WZRD_CLAIM / WZRD_REWARDS
|
|
11
|
+
* Legacy earn lane (opt-in via createWzrdPlugin({ legacyEarnActions: true })):
|
|
12
|
+
* WZRD_INFER → WZRD_REPORT → WZRD_EARN → WZRD_CLAIM / WZRD_REWARDS on api.twzrd.xyz
|
|
11
13
|
*
|
|
12
14
|
* Config (runtime.getSetting):
|
|
13
|
-
* SOLANA_PRIVATE_KEY — required for earn tx/auth
|
|
14
|
-
* WZRD_API_URL — optional, defaults to https://api.twzrd.xyz
|
|
15
15
|
* WZRD_INTEL_URL — optional, defaults to https://intel.twzrd.xyz
|
|
16
|
+
* WZRD_API_URL — earn lane only, defaults to https://api.twzrd.xyz
|
|
17
|
+
* SOLANA_PRIVATE_KEY — earn lane only (agent Ed25519 auth)
|
|
16
18
|
*/
|
|
17
|
-
import type { Plugin } from '@elizaos/core';
|
|
19
|
+
import type { Action, Plugin } from '@elizaos/core';
|
|
18
20
|
import { inferAction } from './actions/infer.js';
|
|
19
21
|
import { reportAction } from './actions/report.js';
|
|
20
22
|
import { earnAction } from './actions/earn.js';
|
|
@@ -24,11 +26,21 @@ import { intelPreflightAction } from './actions/intel-preflight.js';
|
|
|
24
26
|
import { merchantCardAction } from './actions/merchant-card.js';
|
|
25
27
|
import { intelTrustAction } from './actions/intel-trust.js';
|
|
26
28
|
import { verifyReceiptAction } from './actions/verify-receipt.js';
|
|
29
|
+
export declare const intelActions: Action[];
|
|
30
|
+
export declare const legacyEarnActions: Action[];
|
|
31
|
+
export interface WzrdPluginOptions {
|
|
32
|
+
/** Register WZRD_INFER / REPORT / EARN / CLAIM / REWARDS (0.5.x default; off in 0.6+). */
|
|
33
|
+
legacyEarnActions?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare function createWzrdPlugin(options?: WzrdPluginOptions): Plugin;
|
|
36
|
+
/** Default plugin: intel actions only (0.6+). */
|
|
27
37
|
export declare const wzrdPlugin: Plugin;
|
|
38
|
+
/** Pre-0.6 compatibility: intel + legacy earn actions. */
|
|
39
|
+
export declare const wzrdPluginWithLegacyEarn: Plugin;
|
|
28
40
|
export default wzrdPlugin;
|
|
29
41
|
export { intelPreflightAction, merchantCardAction, intelTrustAction, verifyReceiptAction, earnAction, inferAction, reportAction, claimAction, rewardsAction, };
|
|
30
42
|
export { getWzrdClient, clearClientCache, getIntelApiBase, getIntelClient } from './client-factory.js';
|
|
31
|
-
export { setPayingFetch, clearPayingFetch, resolvePayingFetch } from './paying-fetch.js';
|
|
43
|
+
export { setPayingFetch, clearPayingFetch, resolvePayingFetch, installTwzrdAutoGate, } from './paying-fetch.js';
|
|
32
44
|
export { WzrdClient } from './client.js';
|
|
33
45
|
export type { InferResult, ReportResult, RewardsBalance, ClaimResult } from './client.js';
|
|
34
46
|
export { IntelPaymentRequiredError, intelPreflight, fetchIntelTrust, fetchMerchantCard, verifyReceipt, preSpendGate, intelTrustUrl, TRUSTED_RECEIPT_PUBKEY, INTEL_TRUST_PRICE_USDC, } from '@wzrd_sol/sdk';
|
package/dist/index.js
CHANGED
|
@@ -7,26 +7,42 @@ import { intelPreflightAction } from './actions/intel-preflight.js';
|
|
|
7
7
|
import { merchantCardAction } from './actions/merchant-card.js';
|
|
8
8
|
import { intelTrustAction } from './actions/intel-trust.js';
|
|
9
9
|
import { verifyReceiptAction } from './actions/verify-receipt.js';
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
export const intelActions = [
|
|
11
|
+
intelPreflightAction,
|
|
12
|
+
merchantCardAction,
|
|
13
|
+
intelTrustAction,
|
|
14
|
+
verifyReceiptAction,
|
|
15
|
+
];
|
|
16
|
+
export const legacyEarnActions = [
|
|
17
|
+
earnAction,
|
|
18
|
+
inferAction,
|
|
19
|
+
reportAction,
|
|
20
|
+
claimAction,
|
|
21
|
+
rewardsAction,
|
|
22
|
+
];
|
|
23
|
+
const INTEL_DESCRIPTION = 'WZRD Agent Intel — free ReadinessCard preflight + free merchant_card wash refuse (default), ' +
|
|
24
|
+
'then optional x402-paid V6 trust receipt (~0.05 USDC) + offline verify on intel.twzrd.xyz. ' +
|
|
25
|
+
'Buyer sequence is call-site / action-driven (not an auto-interceptor of all payments).';
|
|
26
|
+
const LEGACY_EARN_SUFFIX = ' Legacy earn actions (infer/report/claim/rewards) on api.twzrd.xyz are enabled.';
|
|
27
|
+
export function createWzrdPlugin(options = {}) {
|
|
28
|
+
const actions = options.legacyEarnActions
|
|
29
|
+
? [...intelActions, ...legacyEarnActions]
|
|
30
|
+
: [...intelActions];
|
|
31
|
+
return {
|
|
32
|
+
name: 'wzrd',
|
|
33
|
+
description: options.legacyEarnActions
|
|
34
|
+
? INTEL_DESCRIPTION + LEGACY_EARN_SUFFIX
|
|
35
|
+
: INTEL_DESCRIPTION,
|
|
36
|
+
actions,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Default plugin: intel actions only (0.6+). */
|
|
40
|
+
export const wzrdPlugin = createWzrdPlugin();
|
|
41
|
+
/** Pre-0.6 compatibility: intel + legacy earn actions. */
|
|
42
|
+
export const wzrdPluginWithLegacyEarn = createWzrdPlugin({ legacyEarnActions: true });
|
|
27
43
|
export default wzrdPlugin;
|
|
28
44
|
export { intelPreflightAction, merchantCardAction, intelTrustAction, verifyReceiptAction, earnAction, inferAction, reportAction, claimAction, rewardsAction, };
|
|
29
45
|
export { getWzrdClient, clearClientCache, getIntelApiBase, getIntelClient } from './client-factory.js';
|
|
30
|
-
export { setPayingFetch, clearPayingFetch, resolvePayingFetch } from './paying-fetch.js';
|
|
46
|
+
export { setPayingFetch, clearPayingFetch, resolvePayingFetch, installTwzrdAutoGate, } from './paying-fetch.js';
|
|
31
47
|
export { WzrdClient } from './client.js';
|
|
32
48
|
export { IntelPaymentRequiredError, intelPreflight, fetchIntelTrust, fetchMerchantCard, verifyReceipt, preSpendGate, intelTrustUrl, TRUSTED_RECEIPT_PUBKEY, INTEL_TRUST_PRICE_USDC, } from '@wzrd_sol/sdk';
|
package/dist/paying-fetch.d.ts
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
/** x402-capable fetch injection for paid intel actions. No embedded wallet. */
|
|
2
2
|
import type { IAgentRuntime } from '@elizaos/core';
|
|
3
|
+
import { type InstallAutoGateOptions, type PayWrap } from 'twzrd-x402-gate';
|
|
3
4
|
/** Host supplies an x402-capable fetch (agentcash, twzrd-x402-gate, etc.) before runtime creation. */
|
|
4
5
|
export declare function setPayingFetch(f: typeof fetch): void;
|
|
6
|
+
/**
|
|
7
|
+
* Default-on replacement for `setPayingFetch(payWrap(rawFetch))`: guards the raw fetch
|
|
8
|
+
* with the free TWZRD preflight BEFORE handing it to your x402 client's `payWrap`, so a
|
|
9
|
+
* blocked seller is refused before your client ever signs — then registers the result as
|
|
10
|
+
* the module paying fetch (same slot `setPayingFetch` writes to).
|
|
11
|
+
*
|
|
12
|
+
* Opt out with `TWZRD_AUTO_GATE=0` (env) or `{ disabled: true }`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { installTwzrdAutoGate } from '@wzrd_sol/eliza-plugin';
|
|
16
|
+
* import { wrapFetchWithPayment } from '@x402/svm';
|
|
17
|
+
*
|
|
18
|
+
* installTwzrdAutoGate((guarded) => wrapFetchWithPayment(guarded, buyerWallet));
|
|
19
|
+
* const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
20
|
+
*/
|
|
21
|
+
export declare function installTwzrdAutoGate(payWrap: PayWrap, options?: InstallAutoGateOptions): void;
|
|
5
22
|
export declare function clearPayingFetch(): void;
|
|
6
23
|
type FetchLike = typeof fetch;
|
|
7
24
|
/** Resolve paying fetch: module setter > runtime service > runtime.fetch > global fetch. */
|
package/dist/paying-fetch.js
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
import { installTwzrdAutoGate as buildAutoGate, } from 'twzrd-x402-gate';
|
|
1
2
|
let modulePayingFetch = null;
|
|
2
3
|
/** Host supplies an x402-capable fetch (agentcash, twzrd-x402-gate, etc.) before runtime creation. */
|
|
3
4
|
export function setPayingFetch(f) {
|
|
4
5
|
modulePayingFetch = f;
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Default-on replacement for `setPayingFetch(payWrap(rawFetch))`: guards the raw fetch
|
|
9
|
+
* with the free TWZRD preflight BEFORE handing it to your x402 client's `payWrap`, so a
|
|
10
|
+
* blocked seller is refused before your client ever signs — then registers the result as
|
|
11
|
+
* the module paying fetch (same slot `setPayingFetch` writes to).
|
|
12
|
+
*
|
|
13
|
+
* Opt out with `TWZRD_AUTO_GATE=0` (env) or `{ disabled: true }`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* import { installTwzrdAutoGate } from '@wzrd_sol/eliza-plugin';
|
|
17
|
+
* import { wrapFetchWithPayment } from '@x402/svm';
|
|
18
|
+
*
|
|
19
|
+
* installTwzrdAutoGate((guarded) => wrapFetchWithPayment(guarded, buyerWallet));
|
|
20
|
+
* const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
21
|
+
*/
|
|
22
|
+
export function installTwzrdAutoGate(payWrap, options) {
|
|
23
|
+
setPayingFetch(buildAutoGate(payWrap, options));
|
|
24
|
+
}
|
|
6
25
|
export function clearPayingFetch() {
|
|
7
26
|
modulePayingFetch = null;
|
|
8
27
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import assert from 'node:assert/strict';
|
|
11
11
|
import { describe, it, before, after } from 'node:test';
|
|
12
12
|
import { AgentRuntime } from '@elizaos/core';
|
|
13
|
-
import wzrdPlugin, { intelPreflightAction, merchantCardAction, intelTrustAction, verifyReceiptAction, setPayingFetch, clearPayingFetch, getIntelClient, resolvePayingFetch, } from '@wzrd_sol/eliza-plugin';
|
|
13
|
+
import wzrdPlugin, { createWzrdPlugin, wzrdPluginWithLegacyEarn, intelPreflightAction, merchantCardAction, intelTrustAction, verifyReceiptAction, setPayingFetch, clearPayingFetch, getIntelClient, resolvePayingFetch, } from '@wzrd_sol/eliza-plugin';
|
|
14
14
|
function mockMemory(content) {
|
|
15
15
|
return {
|
|
16
16
|
id: '00000000-0000-0000-0000-000000000001',
|
|
@@ -47,6 +47,26 @@ describe('wzrdPlugin intel registration + E2E (real runtime load)', () => {
|
|
|
47
47
|
assert.ok(names.includes('WZRD_INTEL_TRUST'), 'trust must be registered');
|
|
48
48
|
assert.ok(names.includes('WZRD_VERIFY_RECEIPT'), 'verify must be registered');
|
|
49
49
|
});
|
|
50
|
+
it('default plugin (0.6+) does not register legacy earn actions', () => {
|
|
51
|
+
const names = runtime.actions.map((a) => a.name);
|
|
52
|
+
for (const legacy of ['WZRD_INFER', 'WZRD_REPORT', 'WZRD_EARN', 'WZRD_CLAIM', 'WZRD_REWARDS']) {
|
|
53
|
+
assert.equal(names.includes(legacy), false, `${legacy} must be opt-in in 0.6+`);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
it('createWzrdPlugin({ legacyEarnActions: true }) registers earn actions', async () => {
|
|
57
|
+
const rt = new AgentRuntime({
|
|
58
|
+
character: { name: 'wzrd-legacy-earn-test', bio: 'test', plugins: [] },
|
|
59
|
+
settings: {},
|
|
60
|
+
});
|
|
61
|
+
await rt.registerPlugin(createWzrdPlugin({ legacyEarnActions: true }));
|
|
62
|
+
const names = rt.actions.map((a) => a.name);
|
|
63
|
+
for (const legacy of ['WZRD_INFER', 'WZRD_REPORT', 'WZRD_EARN', 'WZRD_CLAIM', 'WZRD_REWARDS']) {
|
|
64
|
+
assert.ok(names.includes(legacy), `${legacy} must register when legacyEarnActions is true`);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
it('wzrdPluginWithLegacyEarn matches createWzrdPlugin legacy opt-in', () => {
|
|
68
|
+
assert.deepEqual(wzrdPluginWithLegacyEarn.actions?.map((a) => a.name), createWzrdPlugin({ legacyEarnActions: true }).actions?.map((a) => a.name));
|
|
69
|
+
});
|
|
50
70
|
it('preflight handler accepts seller_wallet + price + resource_name, returns success + decision/score text (live)', { timeout: 10000 }, async () => {
|
|
51
71
|
const rt = mockRuntime({ WZRD_INTEL_URL: 'https://intel.twzrd.xyz' });
|
|
52
72
|
const callbacks = [];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzrd_sol/eliza-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "WZRD Agent Intel for ElizaOS
|
|
3
|
+
"version": "0.6.0",
|
|
4
|
+
"description": "WZRD Agent Intel for ElizaOS. Default plugin registers intel actions only: free preflight ReadinessCard + merchant_card (wash_flagged refuse default), paid GET /v1/intel/trust (0.05 USDC) V6 receipt, offline verify. Legacy earn loop (infer/report/claim) is opt-in via createWzrdPlugin({ legacyEarnActions: true }).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"@solana/web3.js": "^1.95.0",
|
|
22
22
|
"@wzrd_sol/sdk": "^0.4.7",
|
|
23
23
|
"bs58": "^5.0.0",
|
|
24
|
-
"tweetnacl": "^1.0.3"
|
|
24
|
+
"tweetnacl": "^1.0.3",
|
|
25
|
+
"twzrd-x402-gate": "^0.5.4"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"@elizaos/core": "^1.0.0"
|
|
@@ -47,9 +48,10 @@
|
|
|
47
48
|
"receipt",
|
|
48
49
|
"reputation",
|
|
49
50
|
"preflight",
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
51
|
+
"merchant_card",
|
|
52
|
+
"wash",
|
|
53
|
+
"marketplace",
|
|
54
|
+
"legacy-earn",
|
|
53
55
|
"ai-agent",
|
|
54
56
|
"mcp"
|
|
55
57
|
],
|