@wzrd_sol/eliza-plugin 0.6.0 → 0.7.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 +37 -167
- package/dist/actions/intel-preflight.js +2 -2
- package/dist/actions/intel-trust.d.ts +4 -1
- package/dist/actions/intel-trust.js +33 -20
- package/dist/actions/merchant-card.d.ts +2 -1
- package/dist/actions/verify-receipt.d.ts +4 -3
- package/dist/actions/verify-receipt.js +24 -13
- package/dist/client-factory.d.ts +3 -2
- package/dist/client-factory.js +3 -2
- package/dist/client.d.ts +3 -2
- package/dist/client.js +9 -6
- package/dist/index.d.ts +7 -11
- package/dist/index.js +6 -5
- package/dist/intel-helpers.d.ts +3 -11
- package/dist/intel-helpers.js +2 -13
- package/dist/paying-fetch.d.ts +1 -12
- package/dist/paying-fetch.js +1 -12
- package/dist/receipt-verify.d.ts +68 -0
- package/dist/receipt-verify.js +152 -0
- package/package.json +10 -19
- package/dist/test/plugin-registration.intel.d.ts +0 -1
- package/dist/test/plugin-registration.intel.js +0 -354
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @wzrd_sol/eliza-plugin
|
|
2
2
|
|
|
3
3
|
ElizaOS plugin for **TWZRD Agent Intel** — free preflight before x402 spends, optional paid
|
|
4
|
-
trust receipts, and offline verification. Default path (0.
|
|
4
|
+
trust receipts, and offline verification. Default path (0.7+):
|
|
5
5
|
|
|
6
6
|
```text
|
|
7
|
-
seller → preflight → merchant_card → policy → optional trust receipt → sign or refuse
|
|
7
|
+
seller → preflight → merchant_card → policy → optional V7 trust receipt → sign or refuse
|
|
8
8
|
```
|
|
9
9
|
|
|
10
10
|
The default export registers **intel actions only**. Legacy AO/CCM earn actions are opt-in.
|
|
@@ -15,8 +15,8 @@ Before any x402 spend:
|
|
|
15
15
|
|
|
16
16
|
1. **Free preflight** - `WZRD_INTEL_PREFLIGHT` / `preSpendGate` - ReadinessCard `allow` / `warn` / `block`
|
|
17
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
|
|
19
|
-
4. **Offline verify** - `WZRD_VERIFY_RECEIPT`
|
|
18
|
+
3. **Optional paid trust** - `WZRD_INTEL_TRUST` (~0.05 USDC) - full score + **signed V7 receipt**
|
|
19
|
+
4. **Offline verify** - `WZRD_VERIFY_RECEIPT` via `twzrd-receipt-verifier`
|
|
20
20
|
|
|
21
21
|
This plugin exposes **actions + SDK helpers**. It does **not** auto-intercept every wallet signature.
|
|
22
22
|
Wire `preSpendGate` / actions into your spend path, or compose with standalone `twzrd-x402-gate` on a paying fetch.
|
|
@@ -58,15 +58,26 @@ npm install @wzrd_sol/eliza-plugin
|
|
|
58
58
|
|--------|----------|-------------|
|
|
59
59
|
| `WZRD_INTEL_PREFLIGHT` | Free | ReadinessCard: `decision`, `trust_score`, `can_spend`, `caveats`, `preflight_id` |
|
|
60
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 + **
|
|
62
|
-
| `WZRD_VERIFY_RECEIPT` | Free (offline) |
|
|
61
|
+
| `WZRD_INTEL_TRUST` | x402 (~0.05 USDC) | Paid trust payload + **V7** signed receipt + ERC-8004 `reputation_credential` |
|
|
62
|
+
| `WZRD_VERIFY_RECEIPT` | Free (offline) | Leaf + Ed25519 verify via `twzrd-receipt-verifier`; V7 current, V6 labeled legacy |
|
|
63
|
+
|
|
64
|
+
### Receipt versions
|
|
65
|
+
|
|
66
|
+
| Version | Freshness | Notes |
|
|
67
|
+
|---------|-----------|-------|
|
|
68
|
+
| **V7** (current) | `signed` | `recheck_after_unix`, `staleness_days`, `score_decay_model` are leaf-bound. Claimed only after offline verify returns `valid` on a V7 domain with `freshness_unauthenticated === false`. |
|
|
69
|
+
| **V6** (legacy) | `derived_from_timestamp` | Those three fields are advisory. Enforce `max_age_seconds` against signed `timestamp_unix`. |
|
|
70
|
+
| **V5** (legacy) | `unauthenticated` | Provenance and freshness are unsigned. |
|
|
71
|
+
|
|
72
|
+
Classification uses the verifier domain allowlist only. Envelope `version` / `kind` cannot promote a V6 body to V7.
|
|
73
|
+
|
|
74
|
+
`verifyReceipt` and `getIntelClient().verify` are **synchronous**. They do not accept `fetchPubkey` / `apiBase` (0.6.1 SDK path) and return `receiptVersion` + `freshness` instead of SDK `leafVersion`. Default signing key is `CURRENT_RECEIPT_PUBKEY` (v2). Do not pass SDK `TRUSTED_RECEIPT_PUBKEY` (v1) or live V7 receipts fail closed.
|
|
63
75
|
|
|
64
76
|
### Preflight (free, no wallet)
|
|
65
77
|
|
|
66
78
|
```typescript
|
|
67
79
|
import { intelPreflightAction } from '@wzrd_sol/eliza-plugin';
|
|
68
80
|
|
|
69
|
-
// Reads seller_wallet / price_usdc / agent_intent from message content.
|
|
70
81
|
await intelPreflightAction.handler(runtime, {
|
|
71
82
|
content: {
|
|
72
83
|
seller_wallet: 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4',
|
|
@@ -76,194 +87,68 @@ await intelPreflightAction.handler(runtime, {
|
|
|
76
87
|
}, state, opts, callback);
|
|
77
88
|
```
|
|
78
89
|
|
|
79
|
-
Response (formatted text returned to agent):
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
ReadinessCard v1
|
|
83
|
-
Decision: allow
|
|
84
|
-
Trust score: 72
|
|
85
|
-
Can spend: yes
|
|
86
|
-
Preflight ID: pf_abc123
|
|
87
|
-
Paid deep dive available (0.05 USDC) - use WZRD_INTEL_TRUST
|
|
88
|
-
```
|
|
89
|
-
|
|
90
90
|
### Merchant card (free wash / demand-quality gate)
|
|
91
91
|
|
|
92
92
|
```typescript
|
|
93
93
|
import { merchantCardAction, fetchMerchantCard } from '@wzrd_sol/eliza-plugin';
|
|
94
94
|
|
|
95
|
-
// Action (LLM-callable):
|
|
96
|
-
// "Merchant card for GFpLvocNdEjnSsLH3VJQL6wGcjGxTbUBrj6fqN3Qe1Gs"
|
|
97
|
-
|
|
98
|
-
// Programmatic:
|
|
99
95
|
const card = await fetchMerchantCard(sellerPubkey);
|
|
100
96
|
if (card?.wash_flagged) return 'refuse dirty pay_to';
|
|
101
|
-
// card unreachable -> fail-open (do not invent wash); use preflight decision only
|
|
102
97
|
```
|
|
103
98
|
|
|
104
|
-
Catalog enrichment is listing metadata only
|
|
99
|
+
Catalog enrichment is listing metadata only — never overrides wash.
|
|
105
100
|
|
|
106
|
-
### Pre-spend gate (programmatic
|
|
101
|
+
### Pre-spend gate (programmatic — both free checks)
|
|
107
102
|
|
|
108
103
|
```typescript
|
|
109
104
|
import { preSpendGate, fetchIntelTrust, fetchMerchantCard } from '@wzrd_sol/eliza-plugin';
|
|
110
105
|
|
|
111
|
-
// Free preflight + free merchant_card wash refuse (default on):
|
|
112
106
|
const gate = await preSpendGate({ seller_wallet: sellerPubkey, price_usdc: 0.25 });
|
|
113
107
|
if (!gate.allow) return `Blocked (${gate.decision}): ${gate.reason}`;
|
|
114
|
-
// gate.washFlagged === true was refuse default; null = card gap (fail-open)
|
|
115
108
|
|
|
116
|
-
// Then pay and get the receipt:
|
|
117
109
|
const trust = await fetchIntelTrust(sellerPubkey, { fetchImpl: myX402Fetch });
|
|
118
110
|
```
|
|
119
111
|
|
|
120
|
-
**Default:** `refuseWashFlagged: true`
|
|
121
|
-
Soft cap: `{ washMaxUsdc: 0.05 }`. Opt out: `{ refuseWashFlagged: false }`.
|
|
112
|
+
**Default:** `refuseWashFlagged: true`. Soft cap: `{ washMaxUsdc: 0.05 }`. Opt out: `{ refuseWashFlagged: false }`.
|
|
122
113
|
|
|
123
|
-
### Guard pattern:
|
|
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:
|
|
114
|
+
### Guard pattern: `installTwzrdAutoGate`
|
|
128
115
|
|
|
129
116
|
```typescript
|
|
130
117
|
import wzrdPlugin, { installTwzrdAutoGate } from '@wzrd_sol/eliza-plugin';
|
|
131
118
|
import { wrapFetchWithPayment } from '@x402/svm';
|
|
132
119
|
|
|
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
120
|
installTwzrdAutoGate((guarded) => wrapFetchWithPayment(guarded, buyerWallet));
|
|
137
|
-
|
|
138
121
|
const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
139
|
-
// WZRD_INTEL_TRUST and any tool/skill using resolvePayingFetch() now goes through the guard.
|
|
140
122
|
```
|
|
141
123
|
|
|
142
|
-
`payWrap`
|
|
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.
|
|
124
|
+
`payWrap` receives the **guarded** fetch. Opt out with `TWZRD_AUTO_GATE=0` or `{ disabled: true }`.
|
|
154
125
|
|
|
155
|
-
|
|
156
|
-
options, use `withTwzrdGuard` from `twzrd-x402-gate` directly and pass the result to `setPayingFetch`
|
|
157
|
-
— see that package's README.
|
|
158
|
-
|
|
159
|
-
### Paid trust receipt (agentcash)
|
|
126
|
+
### Paid trust receipt
|
|
160
127
|
|
|
161
128
|
```typescript
|
|
162
129
|
import wzrdPlugin, { setPayingFetch } from '@wzrd_sol/eliza-plugin';
|
|
163
130
|
import { createAgentcashFetch } from 'agentcash';
|
|
164
131
|
|
|
165
132
|
setPayingFetch(createAgentcashFetch({ apiKey: process.env.AGENTCASH_API_KEY }));
|
|
166
|
-
|
|
167
|
-
const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
168
|
-
// "Get the trust receipt for seller JUP6LkbZ..."
|
|
169
|
-
// -> WZRD_INTEL_TRUST: free preflight + merchant_card, then pays $0.05 USDC, returns VC + V6 receipt
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### Paid trust receipt (PayAI)
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
import wzrdPlugin, { setPayingFetch } from '@wzrd_sol/eliza-plugin';
|
|
176
|
-
import { PayAIClient } from '@payai/client';
|
|
177
|
-
|
|
178
|
-
const payai = new PayAIClient({ keypairPath: '~/.config/solana/id.json' });
|
|
179
|
-
setPayingFetch((url, init) => payai.fetch(url, init));
|
|
180
|
-
|
|
181
133
|
const agent = new AgentRuntime({ plugins: [wzrdPlugin] });
|
|
134
|
+
// WZRD_INTEL_TRUST: free preflight + merchant_card, then pays ~$0.05 USDC,
|
|
135
|
+
// returns VC + V7 receipt, then offline-verifies before labeling freshness=signed
|
|
182
136
|
```
|
|
183
137
|
|
|
184
|
-
Without a paying fetch, `WZRD_INTEL_TRUST` returns the HTTP 402 requirements
|
|
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.
|
|
187
|
-
|
|
188
|
-
**`WZRD_INTEL_TRUST` response fields:**
|
|
189
|
-
|
|
190
|
-
```
|
|
191
|
-
Trust payload for JUP6Lkb...
|
|
192
|
-
Score: 61.8 Paid: yes
|
|
193
|
-
Settlement tx: 4xK3n...
|
|
194
|
-
Reputation credential (ERC-8004 AgentReputationCredential):
|
|
195
|
-
effectiveTrustScore: 62 <- route on this (wash-adjusted)
|
|
196
|
-
trustScore: 72 washFactor: 0.86
|
|
197
|
-
distinctCounterparties: 14 <- cross-facilitator breadth
|
|
198
|
-
corpusScope: cross-facilitator
|
|
199
|
-
version: intel_renorm_v1
|
|
200
|
-
Routing gate: effectiveTrustScore < 30 -> block, 30-60 -> warn, > 60 -> allow
|
|
201
|
-
Receipt v6, leaf: 0x3a4f...
|
|
202
|
-
Use WZRD_VERIFY_RECEIPT to verify offline.
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
**Routing logic:**
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
const vc = trust.reputation_credential.credentialSubject;
|
|
209
|
-
if (vc.effectiveTrustScore < 30) return 'block';
|
|
210
|
-
if (vc.distinctCounterparties < 3) return 'warn'; // thin history
|
|
211
|
-
if (vc.washFactor < 0.5) return 'warn'; // suspicious ring
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
`effectiveTrustScore` is the cross-facilitator wash-adjusted score - computed across all known
|
|
215
|
-
x402 facilitators, not just one settlement path.
|
|
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
|
-
|
|
224
|
-
### Example agent prompts (trust)
|
|
225
|
-
|
|
226
|
-
- `"Preflight Jupiter Quote Preview before I pay 0.25 USDC to 6EF8rrect..."`
|
|
227
|
-
- `"Merchant card for GFpLvocNdEjnSsLH3VJQL6wGcjGxTbUBrj6fqN3Qe1Gs"`
|
|
228
|
-
- `"Get the trust receipt for seller JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"`
|
|
229
|
-
- `"Is it safe to call the paid intel endpoint on this seller?"`
|
|
230
|
-
- `"Verify this receipt: {leaf, preimage, signature...}"`
|
|
138
|
+
Without a paying fetch, `WZRD_INTEL_TRUST` returns the HTTP 402 requirements.
|
|
231
139
|
|
|
232
140
|
## Legacy earn actions (opt-in)
|
|
233
141
|
|
|
234
|
-
**0.6 breaking change:** `
|
|
235
|
-
actions only. To restore the pre-0.6 earn surface:
|
|
142
|
+
**0.6 breaking change:** default `wzrdPlugin` registers intel actions only.
|
|
236
143
|
|
|
237
144
|
```typescript
|
|
238
145
|
import { createWzrdPlugin, wzrdPluginWithLegacyEarn } from '@wzrd_sol/eliza-plugin';
|
|
239
146
|
|
|
240
|
-
// Either factory:
|
|
241
147
|
const agent = new AgentRuntime({
|
|
242
148
|
plugins: [createWzrdPlugin({ legacyEarnActions: true })],
|
|
243
149
|
});
|
|
244
|
-
|
|
245
|
-
// Or compatibility export:
|
|
246
|
-
const agent = new AgentRuntime({ plugins: [wzrdPluginWithLegacyEarn] });
|
|
247
150
|
```
|
|
248
151
|
|
|
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.
|
|
251
|
-
|
|
252
|
-
| Action | Auth | Description |
|
|
253
|
-
|--------|------|-------------|
|
|
254
|
-
| `WZRD_INFER` | Agent Ed25519 | Server-witnessed inference; returns `execution_id` |
|
|
255
|
-
| `WZRD_REPORT` | Agent Ed25519 | Report outcome with `execution_id` for verified rewards |
|
|
256
|
-
| `WZRD_EARN` | Agent Ed25519 | Full infer -> report -> rewards check in one action |
|
|
257
|
-
| `WZRD_CLAIM` | Agent Ed25519 | Gasless CCM claim via relay |
|
|
258
|
-
| `WZRD_REWARDS` | Agent Ed25519 | Pending and lifetime CCM balance |
|
|
259
|
-
|
|
260
|
-
### Example prompts (earn)
|
|
261
|
-
|
|
262
|
-
- `"Run inference through WZRD: explain quicksort in Python"`
|
|
263
|
-
- `"Earn some CCM on WZRD"`
|
|
264
|
-
- `"Check my WZRD rewards"`
|
|
265
|
-
- `"Claim my CCM"`
|
|
266
|
-
|
|
267
152
|
## Programmatic SDK usage
|
|
268
153
|
|
|
269
154
|
```typescript
|
|
@@ -273,43 +158,28 @@ import {
|
|
|
273
158
|
fetchMerchantCard,
|
|
274
159
|
verifyReceipt,
|
|
275
160
|
preSpendGate,
|
|
161
|
+
CURRENT_RECEIPT_PUBKEY,
|
|
276
162
|
IntelPaymentRequiredError,
|
|
277
163
|
} from '@wzrd_sol/eliza-plugin';
|
|
278
|
-
|
|
279
|
-
import type {
|
|
280
|
-
ReadinessCard,
|
|
281
|
-
PreflightResponse,
|
|
282
|
-
MerchantCard,
|
|
283
|
-
IntelTrustResponse,
|
|
284
|
-
TwzrdReceipt,
|
|
285
|
-
} from '@wzrd_sol/eliza-plugin';
|
|
286
164
|
```
|
|
287
165
|
|
|
288
|
-
## Test
|
|
166
|
+
## Test (source, not this tarball)
|
|
289
167
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
npm ci
|
|
293
|
-
npm run build
|
|
294
|
-
npm test
|
|
295
|
-
```
|
|
296
|
-
|
|
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.
|
|
299
|
-
|
|
300
|
-
Manual earn smoke (requires `SOLANA_PRIVATE_KEY`):
|
|
168
|
+
This npm package is a `dist/` artifact. Source and tests live in the
|
|
169
|
+
`twzrd-trust` monorepo as `eliza-plugin-source/`:
|
|
301
170
|
|
|
302
171
|
```bash
|
|
303
|
-
|
|
172
|
+
cd eliza-plugin-source
|
|
173
|
+
npm test
|
|
174
|
+
npm run typecheck
|
|
304
175
|
```
|
|
305
176
|
|
|
306
177
|
## Links
|
|
307
178
|
|
|
308
179
|
- [Agent Intel API](https://intel.twzrd.xyz)
|
|
309
180
|
- [API docs / llms.txt](https://intel.twzrd.xyz/llms.txt)
|
|
310
|
-
- [x402 gate
|
|
311
|
-
- [plugin-trustgate
|
|
312
|
-
- [GOAT plugin](https://www.npmjs.com/package/@wzrd_sol/goat-plugin)
|
|
181
|
+
- [x402 gate](https://www.npmjs.com/package/twzrd-x402-gate)
|
|
182
|
+
- [plugin-trustgate](https://www.npmjs.com/package/@wzrd_sol/plugin-trustgate)
|
|
313
183
|
|
|
314
184
|
## License
|
|
315
185
|
|
|
@@ -44,7 +44,7 @@ export const intelPreflightAction = {
|
|
|
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
|
+
'or preSpendGate which runs both free checks. Paid deep dive is a V7 receipt via WZRD_INTEL_TRUST.',
|
|
48
48
|
examples: [
|
|
49
49
|
[
|
|
50
50
|
{
|
|
@@ -65,7 +65,7 @@ export const intelPreflightAction = {
|
|
|
65
65
|
const input = parsePreflightInput(content);
|
|
66
66
|
if (!input.seller_wallet && !input.resource_name && !input.resource_url) {
|
|
67
67
|
await callback?.({
|
|
68
|
-
text: 'Provide seller_wallet, resource_name, or
|
|
68
|
+
text: 'Provide seller_wallet, resource_name, resource_url, or agent_intent for preflight. ' +
|
|
69
69
|
'Example: "Preflight seller JUP6Lkb... at 0.25 USDC"',
|
|
70
70
|
});
|
|
71
71
|
return { success: false, error: 'Missing preflight input' };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* WZRD_INTEL_TRUST — Paid trust payload + signed
|
|
2
|
+
* WZRD_INTEL_TRUST — Paid trust payload + signed V7 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
|
+
*
|
|
6
|
+
* Current service surface is V7. Legacy V6/V5 payloads are labeled, not treated
|
|
7
|
+
* as the current receipt policy.
|
|
5
8
|
*/
|
|
6
9
|
import type { Action } from '@elizaos/core';
|
|
7
10
|
export declare const intelTrustAction: Action;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { fetchIntelTrust, preSpendGate, IntelPaymentRequiredError } from '@wzrd_sol/sdk';
|
|
2
2
|
import { extractPubkey, formatPaymentRequired, getIntelBase, withTimeout } from '../intel-helpers.js';
|
|
3
3
|
import { resolvePayingFetch } from '../paying-fetch.js';
|
|
4
|
+
import { classifyReceipt, describeReceiptSurface, freshnessFromVerify, verifyReceipt, } from '../receipt-verify.js';
|
|
4
5
|
export const intelTrustAction = {
|
|
5
6
|
name: 'WZRD_INTEL_TRUST',
|
|
6
7
|
similes: ['WZRD_TRUST_RECEIPT', 'INTEL_TRUST', 'GET_TRUST_RECEIPT'],
|
|
7
|
-
description: 'Paid GET /v1/intel/trust/{pubkey} (~0.05 USDC on Solana). Returns renormalized trust score + signed
|
|
8
|
-
'twzrd_receipt (portable offline proof). Runs free preflight + merchant_card
|
|
9
|
-
'aborts on decision=block or wash_flagged before any spend. ' +
|
|
10
|
-
'
|
|
11
|
-
'
|
|
8
|
+
description: 'Paid GET /v1/intel/trust/{pubkey} (~0.05 USDC on Solana). Returns renormalized trust score + signed V7 ' +
|
|
9
|
+
'twzrd_receipt (portable offline proof; freshness fields are leaf-bound). Runs free preflight + merchant_card ' +
|
|
10
|
+
'wash check first; aborts on decision=block or wash_flagged before any spend. ' +
|
|
11
|
+
'Legacy V6 receipts, if still returned, are labeled freshness=derived_from_timestamp. ' +
|
|
12
|
+
'Requires an x402-capable fetchImpl (setPayingFetch or host service).',
|
|
12
13
|
examples: [
|
|
13
14
|
[
|
|
14
15
|
{ name: '{{user1}}', content: { text: 'Get the trust receipt for seller JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4' } },
|
|
15
|
-
{ name: '{{agentName}}', content: { text: 'Trust receipt received. score=42,
|
|
16
|
+
{ name: '{{agentName}}', content: { text: 'Trust receipt received. score=42, Receipt v7 (current surface), leaf=0x...' } },
|
|
16
17
|
],
|
|
17
18
|
],
|
|
18
19
|
validate: async () => true,
|
|
@@ -25,16 +26,10 @@ export const intelTrustAction = {
|
|
|
25
26
|
}
|
|
26
27
|
const apiBase = getIntelBase(runtime);
|
|
27
28
|
const baseFetchImpl = resolvePayingFetch(runtime);
|
|
28
|
-
// preflight-before-pay + wash refuse: FREE ReadinessCard + free merchant_card.
|
|
29
|
-
// Abort on decision=block or wash_flagged before any payment. failOpen=false so
|
|
30
|
-
// the block-on-block guarantee holds even if the gate errors — a reference
|
|
31
|
-
// plugin must demonstrate the safe posture, not bypass it. Free reads only.
|
|
32
29
|
try {
|
|
33
30
|
const gate = await preSpendGate({ seller_wallet: pubkey }, { apiBase, failOpen: false, refuseWashFlagged: true, fetchImpl: baseFetchImpl });
|
|
34
31
|
if (!gate.allow) {
|
|
35
|
-
const washLine = gate.washFlagged === true
|
|
36
|
-
? `Wash flagged: yes (merchant_card refuse default)\n`
|
|
37
|
-
: '';
|
|
32
|
+
const washLine = gate.washFlagged === true ? `Wash flagged: yes (merchant_card refuse default)\n` : '';
|
|
38
33
|
await callback?.({
|
|
39
34
|
text: `Preflight blocked the trust purchase for ${pubkey}.\n` +
|
|
40
35
|
`Decision: ${gate.decision}${gate.trustScore != null ? `, trust_score=${gate.trustScore}` : ''}\n` +
|
|
@@ -55,7 +50,6 @@ export const intelTrustAction = {
|
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
52
|
catch (gateErr) {
|
|
58
|
-
// failOpen=false means a gate error should NOT silently pay. Surface it and stop.
|
|
59
53
|
const msg = gateErr instanceof Error ? gateErr.message : String(gateErr);
|
|
60
54
|
await callback?.({ text: `Preflight gate unavailable (${msg}); not spending. Try again shortly.` });
|
|
61
55
|
return { success: false, error: 'preflight_unavailable', data: { detail: msg } };
|
|
@@ -65,8 +59,14 @@ export const intelTrustAction = {
|
|
|
65
59
|
const abortingFetch = ((input, init) => baseFetchImpl(input, { ...(init || {}), signal }));
|
|
66
60
|
return fetchIntelTrust(pubkey, { apiBase, fetchImpl: abortingFetch });
|
|
67
61
|
});
|
|
68
|
-
const
|
|
69
|
-
const
|
|
62
|
+
const paid = res;
|
|
63
|
+
const receipt = paid.twzrd_receipt;
|
|
64
|
+
const verified = receipt ? verifyReceipt(receipt) : null;
|
|
65
|
+
const surface = describeReceiptSurface(receipt);
|
|
66
|
+
const freshness = verified
|
|
67
|
+
? freshnessFromVerify(verified)
|
|
68
|
+
: surface.freshness;
|
|
69
|
+
const vc = paid.reputation_credential?.credentialSubject;
|
|
70
70
|
const lines = [
|
|
71
71
|
`Trust payload for ${pubkey}`,
|
|
72
72
|
`Score: ${res.trust?.score ?? 'n/a'} Paid: ${res.paid ? 'yes' : 'no'}`,
|
|
@@ -77,12 +77,25 @@ export const intelTrustAction = {
|
|
|
77
77
|
if (vc) {
|
|
78
78
|
lines.push(`Reputation credential (ERC-8004 AgentReputationCredential):`, ` effectiveTrustScore: ${vc.effectiveTrustScore ?? 'n/a'}`, ` trustScore: ${vc.trustScore ?? 'n/a'} washFactor: ${vc.washFactor ?? 'n/a'}`, ` distinctCounterparties: ${vc.distinctCounterparties ?? 'n/a'}`, ` corpusScope: ${vc.corpusScope ?? 'n/a'}`, ` version: ${vc.trustScoreVersion ?? 'n/a'}`, `Routing gate: effectiveTrustScore < 30 → block, 30-60 → warn, > 60 → allow`);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
if (receipt) {
|
|
81
|
+
lines.push(`${surface.label}, leaf: ${receipt.leaf}`, `Offline verify: ${verified?.valid ? 'VALID' : 'INVALID'} (freshness=${freshness})`, verified?.valid
|
|
82
|
+
? surface.detail
|
|
83
|
+
: 'Do not treat freshness as signed unless offline verify is VALID on a V7 domain.', 'Use WZRD_VERIFY_RECEIPT (twzrd-receipt-verifier) to re-check offline.');
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
lines.push('No twzrd_receipt in response.');
|
|
87
|
+
}
|
|
83
88
|
const text = lines.join('\n');
|
|
84
89
|
await callback?.({ text });
|
|
85
|
-
return {
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
data: {
|
|
93
|
+
...res,
|
|
94
|
+
receipt_surface: classifyReceipt(receipt),
|
|
95
|
+
freshness,
|
|
96
|
+
receipt_valid: verified?.valid ?? false,
|
|
97
|
+
},
|
|
98
|
+
};
|
|
86
99
|
}
|
|
87
100
|
catch (err) {
|
|
88
101
|
if (err instanceof IntelPaymentRequiredError) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WZRD_MERCHANT_CARD — Free demand-quality graph card for a receive wallet.
|
|
3
|
-
*
|
|
3
|
+
* Forward-ported from the 0.6.1 artifact (dist/actions/merchant-card.js); this
|
|
4
|
+
* file did not exist in the 98e4b78 historical source baseline.
|
|
4
5
|
*/
|
|
5
6
|
import type { Action } from '@elizaos/core';
|
|
6
7
|
export declare const merchantCardAction: Action;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* WZRD_VERIFY_RECEIPT — Offline leaf + Ed25519 verification
|
|
3
|
-
* Primary surface is
|
|
4
|
-
*
|
|
2
|
+
* WZRD_VERIFY_RECEIPT — Offline leaf + Ed25519 verification.
|
|
3
|
+
* Primary surface is V7 (freshness signed into the leaf). Legacy V6 still
|
|
4
|
+
* verifies with freshness=derived_from_timestamp. Older V5 remains accepted
|
|
5
|
+
* with unauthenticated provenance/freshness.
|
|
5
6
|
*/
|
|
6
7
|
import type { Action } from '@elizaos/core';
|
|
7
8
|
export declare const verifyReceiptAction: Action;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { parseReceipt } from '../intel-helpers.js';
|
|
2
|
+
import { formatVerifyResult, verifyReceipt } from '../receipt-verify.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
|
|
7
|
-
'
|
|
6
|
+
description: 'Offline verify a TwzrdReceipt with twzrd-receipt-verifier@^1.4.0. ' +
|
|
7
|
+
'V7 is the current surface (freshness signed). V6 is accepted as legacy with ' +
|
|
8
|
+
'freshness=derived_from_timestamp. V5 still verifies but provenance is unsigned. ' +
|
|
9
|
+
'Optional content.max_age_seconds enforces signed timestamp_unix.',
|
|
8
10
|
examples: [
|
|
9
11
|
[
|
|
10
|
-
{ name: '{{user1}}', content: { text: 'Verify this receipt: {"version":"
|
|
11
|
-
{ name: '{{agentName}}', content: { text: 'Receipt
|
|
12
|
+
{ name: '{{user1}}', content: { text: 'Verify this receipt: {"version":"v7","kind":"twzrd_reputation_receipt_v7","leaf":"0x...","preimage":{...}}' } },
|
|
13
|
+
{ name: '{{agentName}}', content: { text: 'Receipt VALID (v7, freshness=signed, leaf=true, sig=true).' } },
|
|
12
14
|
],
|
|
13
15
|
],
|
|
14
16
|
validate: async () => true,
|
|
15
|
-
handler: async (
|
|
17
|
+
handler: async (_runtime, message, _state, _opt, callback) => {
|
|
16
18
|
const content = (message.content ?? {});
|
|
17
19
|
const receipt = parseReceipt(content);
|
|
18
20
|
if (!receipt) {
|
|
@@ -21,13 +23,12 @@ export const verifyReceiptAction = {
|
|
|
21
23
|
});
|
|
22
24
|
return { success: false, error: 'Missing receipt' };
|
|
23
25
|
}
|
|
24
|
-
const
|
|
25
|
-
const fetchPubkey = content.fetch_pubkey === true || content.fetchPubkey === true;
|
|
26
|
+
const maxAgeSeconds = num(content.max_age_seconds ?? content.maxAgeSeconds);
|
|
26
27
|
try {
|
|
27
|
-
const result =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const result = verifyReceipt(receipt, {
|
|
29
|
+
maxAgeSeconds: maxAgeSeconds && maxAgeSeconds > 0 ? maxAgeSeconds : undefined,
|
|
30
|
+
});
|
|
31
|
+
const text = formatVerifyResult(result);
|
|
31
32
|
await callback?.({ text });
|
|
32
33
|
return {
|
|
33
34
|
success: result.valid,
|
|
@@ -42,3 +43,13 @@ export const verifyReceiptAction = {
|
|
|
42
43
|
}
|
|
43
44
|
},
|
|
44
45
|
};
|
|
46
|
+
function num(v) {
|
|
47
|
+
if (typeof v === 'number' && Number.isFinite(v))
|
|
48
|
+
return v;
|
|
49
|
+
if (typeof v === 'string' && v.trim()) {
|
|
50
|
+
const n = Number(v);
|
|
51
|
+
if (Number.isFinite(n))
|
|
52
|
+
return n;
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
package/dist/client-factory.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WzrdClient } from './client.js';
|
|
2
2
|
import type { IAgentRuntime } from '@elizaos/core';
|
|
3
|
-
import { intelPreflight
|
|
3
|
+
import { intelPreflight } from '@wzrd_sol/sdk';
|
|
4
|
+
import { verifyReceipt } from './receipt-verify.js';
|
|
4
5
|
/** Intel API base URL from runtime settings (default https://intel.twzrd.xyz). */
|
|
5
6
|
export declare function getIntelApiBase(runtime: IAgentRuntime): string;
|
|
6
7
|
export declare function getWzrdClient(runtime: IAgentRuntime): WzrdClient;
|
|
@@ -10,5 +11,5 @@ export declare function clearClientCache(): void;
|
|
|
10
11
|
export declare function getIntelClient(runtime: IAgentRuntime): {
|
|
11
12
|
preflight: (input: Parameters<typeof intelPreflight>[0]) => Promise<import("@wzrd_sol/sdk").PreflightResponse>;
|
|
12
13
|
trust: (pubkey: string) => Promise<import("@wzrd_sol/sdk").IntelTrustResponse>;
|
|
13
|
-
verify: (receipt: Parameters<typeof verifyReceipt>[0], opts?: Parameters<typeof verifyReceipt>[1]) =>
|
|
14
|
+
verify: (receipt: Parameters<typeof verifyReceipt>[0], opts?: Parameters<typeof verifyReceipt>[1]) => import("./receipt-verify.js").VerifyReceiptResult;
|
|
14
15
|
};
|
package/dist/client-factory.js
CHANGED
|
@@ -3,7 +3,8 @@ import { Keypair } from '@solana/web3.js';
|
|
|
3
3
|
import { WzrdClient } from './client.js';
|
|
4
4
|
import { getIntelBase, withTimeout } from './intel-helpers.js';
|
|
5
5
|
import { resolvePayingFetch } from './paying-fetch.js';
|
|
6
|
-
import { intelPreflight, fetchIntelTrust
|
|
6
|
+
import { intelPreflight, fetchIntelTrust } from '@wzrd_sol/sdk';
|
|
7
|
+
import { verifyReceipt } from './receipt-verify.js';
|
|
7
8
|
const cache = new Map();
|
|
8
9
|
/** Intel API base URL from runtime settings (default https://intel.twzrd.xyz). */
|
|
9
10
|
export function getIntelApiBase(runtime) {
|
|
@@ -35,6 +36,6 @@ export function getIntelClient(runtime) {
|
|
|
35
36
|
const abortingFetch = ((input, init) => f(input, { ...(init || {}), signal }));
|
|
36
37
|
return fetchIntelTrust(pubkey, { apiBase, fetchImpl: abortingFetch });
|
|
37
38
|
}),
|
|
38
|
-
verify: (receipt, opts) =>
|
|
39
|
+
verify: (receipt, opts) => verifyReceipt(receipt, opts),
|
|
39
40
|
};
|
|
40
41
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -75,7 +75,7 @@ export declare class WzrdClient {
|
|
|
75
75
|
quality_score?: number;
|
|
76
76
|
latency_ms?: number;
|
|
77
77
|
}): Promise<ReportResult>;
|
|
78
|
-
/** Check pending + total rewards (
|
|
78
|
+
/** Check pending + total rewards (flattens nested /v1/agent/earned response) */
|
|
79
79
|
getRewards(): Promise<RewardsBalance>;
|
|
80
80
|
/** Gasless CCM claim via server relay */
|
|
81
81
|
claimRelay(): Promise<ClaimResult>;
|
|
@@ -88,4 +88,5 @@ export declare class WzrdClient {
|
|
|
88
88
|
claimable: number;
|
|
89
89
|
}>;
|
|
90
90
|
}
|
|
91
|
-
export { intelPreflight as intelPreflightClient, fetchIntelTrust as fetchIntelTrustClient,
|
|
91
|
+
export { intelPreflight as intelPreflightClient, fetchIntelTrust as fetchIntelTrustClient, } from '@wzrd_sol/sdk';
|
|
92
|
+
export { verifyReceipt as verifyReceiptClient } from './receipt-verify.js';
|
package/dist/client.js
CHANGED
|
@@ -87,17 +87,19 @@ export class WzrdClient {
|
|
|
87
87
|
}
|
|
88
88
|
return res.json();
|
|
89
89
|
}
|
|
90
|
-
/** Check pending + total rewards (
|
|
90
|
+
/** Check pending + total rewards (flattens nested /v1/agent/earned response) */
|
|
91
91
|
async getRewards() {
|
|
92
92
|
const res = await this.authedFetch('/v1/agent/earned');
|
|
93
93
|
if (!res.ok)
|
|
94
94
|
throw new Error(`Rewards check failed: ${res.status}`);
|
|
95
95
|
const data = await res.json();
|
|
96
|
+
const economy = data.economy;
|
|
97
|
+
const routing = data.routing;
|
|
96
98
|
return {
|
|
97
|
-
pending_ccm: Number(
|
|
98
|
-
total_rewarded_ccm: Number(
|
|
99
|
-
rank:
|
|
100
|
-
contribution_count: Number(
|
|
99
|
+
pending_ccm: Number(economy?.pending_ccm ?? 0),
|
|
100
|
+
total_rewarded_ccm: Number(economy?.earned_ccm ?? 0),
|
|
101
|
+
rank: null, // rank not in this endpoint
|
|
102
|
+
contribution_count: Number(routing?.lifetime_contributions ?? 0),
|
|
101
103
|
};
|
|
102
104
|
}
|
|
103
105
|
/** Gasless CCM claim via server relay */
|
|
@@ -132,4 +134,5 @@ export class WzrdClient {
|
|
|
132
134
|
}
|
|
133
135
|
// Thin wrappers delegating to @wzrd_sol/sdk intel surface (preflight/trust/verify) per plan.
|
|
134
136
|
// Kept in client.ts alongside earn WzrdClient. Actual runtime client for intel is via getIntelClient() in factory.
|
|
135
|
-
export { intelPreflight as intelPreflightClient, fetchIntelTrust as fetchIntelTrustClient,
|
|
137
|
+
export { intelPreflight as intelPreflightClient, fetchIntelTrust as fetchIntelTrustClient, } from '@wzrd_sol/sdk';
|
|
138
|
+
export { verifyReceipt as verifyReceiptClient } from './receipt-verify.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @wzrd_sol/eliza-plugin — WZRD Agent Intel for ElizaOS
|
|
2
|
+
* @wzrd_sol/eliza-plugin-source — V7-migrated 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
6
|
* Paid intel requires a caller-supplied x402 fetch — either setPayingFetch(payingFetch)
|
|
7
|
-
*
|
|
8
|
-
* raw fetch before your client signs, then registers it the same way).
|
|
9
|
-
* Default: preSpendGate refuses wash_flagged pay_to (free merchant_card).
|
|
7
|
+
* or installTwzrdAutoGate(payWrap). Current paid receipt surface is V7.
|
|
10
8
|
*
|
|
11
9
|
* Legacy earn lane (opt-in via createWzrdPlugin({ legacyEarnActions: true })):
|
|
12
10
|
* WZRD_INFER → WZRD_REPORT → WZRD_EARN → WZRD_CLAIM / WZRD_REWARDS on api.twzrd.xyz
|
|
13
|
-
*
|
|
14
|
-
* Config (runtime.getSetting):
|
|
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)
|
|
18
11
|
*/
|
|
19
12
|
import type { Action, Plugin } from '@elizaos/core';
|
|
20
13
|
import { inferAction } from './actions/infer.js';
|
|
@@ -43,5 +36,8 @@ export { getWzrdClient, clearClientCache, getIntelApiBase, getIntelClient } from
|
|
|
43
36
|
export { setPayingFetch, clearPayingFetch, resolvePayingFetch, installTwzrdAutoGate, } from './paying-fetch.js';
|
|
44
37
|
export { WzrdClient } from './client.js';
|
|
45
38
|
export type { InferResult, ReportResult, RewardsBalance, ClaimResult } from './client.js';
|
|
46
|
-
|
|
47
|
-
export
|
|
39
|
+
/** SDK intel helpers. TRUSTED_RECEIPT_PUBKEY is the v1 key — use CURRENT_RECEIPT_PUBKEY for V7 verify. */
|
|
40
|
+
export { IntelPaymentRequiredError, intelPreflight, fetchIntelTrust, fetchMerchantCard, preSpendGate, intelTrustUrl, TRUSTED_RECEIPT_PUBKEY, INTEL_TRUST_PRICE_USDC, } from '@wzrd_sol/sdk';
|
|
41
|
+
export { verifyReceipt, classifyReceipt, describeReceiptSurface, freshnessStatusFor, freshnessFromVerify, formatVerifyResult, CURRENT_RECEIPT_PUBKEY, CURRENT_RECEIPT_KEY_ID, REPUTATION_V5_DOMAIN, REPUTATION_V6_DOMAIN, REPUTATION_V7_DOMAIN, } from './receipt-verify.js';
|
|
42
|
+
export type { VerifyReceiptResult, VerifyReceiptOptions, TwzrdReceiptLike, ReceiptVersion, FreshnessStatus, } from './receipt-verify.js';
|
|
43
|
+
export type { ReadinessCard, PreflightInput, PreflightResponse, MerchantCard, TwzrdReceipt, IntelTrustResponse, X402PaymentRequired, } from '@wzrd_sol/sdk';
|