@wzrd_sol/eliza-plugin 0.3.2 → 0.3.3
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 +12 -3
- package/dist/actions/intel-trust.d.ts +2 -2
- package/dist/actions/intel-trust.js +16 -8
- package/dist/actions/merchant-card.d.ts +6 -0
- package/dist/actions/merchant-card.js +85 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +7 -5
- package/dist/test/plugin-registration.intel.js +94 -13
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ npm install @wzrd_sol/eliza-plugin
|
|
|
30
30
|
| Action | Auth/Pay | Description |
|
|
31
31
|
|--------|----------|-------------|
|
|
32
32
|
| `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 |
|
|
33
34
|
| `WZRD_INTEL_TRUST` | x402 (~0.05 USDC) | Paid trust payload + V6 signed receipt + ERC-8004 `reputation_credential` |
|
|
34
35
|
| `WZRD_VERIFY_RECEIPT` | Free (offline) | Recompute leaf + Ed25519 verify; no network when pubkey is known |
|
|
35
36
|
|
|
@@ -92,16 +93,24 @@ Guard flow:
|
|
|
92
93
|
### Pre-spend gate (programmatic)
|
|
93
94
|
|
|
94
95
|
```typescript
|
|
95
|
-
import { preSpendGate, fetchIntelTrust } from '@wzrd_sol/eliza-plugin';
|
|
96
|
+
import { preSpendGate, fetchIntelTrust, fetchMerchantCard } from '@wzrd_sol/eliza-plugin';
|
|
96
97
|
|
|
97
|
-
// Gate before paying:
|
|
98
|
-
const gate = await preSpendGate({ seller_wallet: sellerPubkey });
|
|
98
|
+
// Gate before paying (free preflight + free merchant_card wash refuse, default on):
|
|
99
|
+
const gate = await preSpendGate({ seller_wallet: sellerPubkey, price_usdc: 0.25 });
|
|
99
100
|
if (!gate.allow) return `Blocked (${gate.decision}): ${gate.reason}`;
|
|
101
|
+
// gate.washFlagged === true was refuse default; null = card gap (fail-open)
|
|
102
|
+
|
|
103
|
+
// Or inspect the card alone:
|
|
104
|
+
const card = await fetchMerchantCard(sellerPubkey);
|
|
105
|
+
if (card?.wash_flagged) return 'refuse dirty pay_to';
|
|
100
106
|
|
|
101
107
|
// Then pay and get the receipt:
|
|
102
108
|
const trust = await fetchIntelTrust(sellerPubkey, { fetchImpl: myX402Fetch });
|
|
103
109
|
```
|
|
104
110
|
|
|
111
|
+
**Default:** `refuseWashFlagged: true` — if free `merchant_card.wash_flagged`, do not pay.
|
|
112
|
+
Soft cap: `{ washMaxUsdc: 0.05 }`. Opt out: `{ refuseWashFlagged: false }`.
|
|
113
|
+
|
|
105
114
|
### Paid trust receipt (agentcash)
|
|
106
115
|
|
|
107
116
|
```typescript
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WZRD_INTEL_TRUST — Paid trust payload + signed receipt (V5/V6) via x402-capable
|
|
3
|
-
* fetch. Preflight-gated:
|
|
4
|
-
* decision=block aborts before any spend
|
|
3
|
+
* fetch. Preflight-gated: free ReadinessCard + free merchant_card wash check run
|
|
4
|
+
* BEFORE payment; decision=block or wash_flagged aborts before any spend.
|
|
5
5
|
*/
|
|
6
6
|
import type { Action } from '@elizaos/core';
|
|
7
7
|
export declare const intelTrustAction: Action;
|
|
@@ -5,7 +5,7 @@ export const intelTrustAction = {
|
|
|
5
5
|
name: 'WZRD_INTEL_TRUST',
|
|
6
6
|
similes: ['WZRD_TRUST_RECEIPT', 'INTEL_TRUST', 'GET_TRUST_RECEIPT'],
|
|
7
7
|
description: 'Paid GET /v1/intel/trust/{pubkey} (~0.05 USDC). Returns trust score + signed twzrd_receipt (V5/V6). ' +
|
|
8
|
-
'Runs
|
|
8
|
+
'Runs free preflight + merchant_card wash check first; aborts on decision=block or wash_flagged. ' +
|
|
9
9
|
'Requires an x402-capable fetchImpl (setPayingFetch or host service). ' +
|
|
10
10
|
'Surfaces payment requirements if no payer is configured.',
|
|
11
11
|
examples: [
|
|
@@ -24,24 +24,32 @@ export const intelTrustAction = {
|
|
|
24
24
|
}
|
|
25
25
|
const apiBase = getIntelBase(runtime);
|
|
26
26
|
const baseFetchImpl = resolvePayingFetch(runtime);
|
|
27
|
-
// preflight-before-pay
|
|
28
|
-
//
|
|
27
|
+
// preflight-before-pay + wash refuse: FREE ReadinessCard + free merchant_card.
|
|
28
|
+
// Abort on decision=block or wash_flagged before any payment. failOpen=false so
|
|
29
29
|
// the block-on-block guarantee holds even if the gate errors — a reference
|
|
30
|
-
// plugin must demonstrate the safe posture, not bypass it.
|
|
31
|
-
// is free (the gate only ever reads), so this adds no spend.
|
|
30
|
+
// plugin must demonstrate the safe posture, not bypass it. Free reads only.
|
|
32
31
|
try {
|
|
33
|
-
const gate = await preSpendGate({ seller_wallet: pubkey }, { apiBase, failOpen: false, fetchImpl: baseFetchImpl });
|
|
32
|
+
const gate = await preSpendGate({ seller_wallet: pubkey }, { apiBase, failOpen: false, refuseWashFlagged: true, fetchImpl: baseFetchImpl });
|
|
34
33
|
if (!gate.allow) {
|
|
34
|
+
const washLine = gate.washFlagged === true
|
|
35
|
+
? `Wash flagged: yes (merchant_card refuse default)\n`
|
|
36
|
+
: '';
|
|
35
37
|
await callback?.({
|
|
36
38
|
text: `Preflight blocked the trust purchase for ${pubkey}.\n` +
|
|
37
39
|
`Decision: ${gate.decision}${gate.trustScore != null ? `, trust_score=${gate.trustScore}` : ''}\n` +
|
|
40
|
+
washLine +
|
|
38
41
|
`Reason: ${gate.reason}\n` +
|
|
39
42
|
`No payment was sent.`,
|
|
40
43
|
});
|
|
41
44
|
return {
|
|
42
45
|
success: false,
|
|
43
|
-
error: 'preflight_block',
|
|
44
|
-
data: {
|
|
46
|
+
error: gate.washFlagged === true ? 'wash_flagged' : 'preflight_block',
|
|
47
|
+
data: {
|
|
48
|
+
decision: gate.decision,
|
|
49
|
+
trustScore: gate.trustScore,
|
|
50
|
+
reason: gate.reason,
|
|
51
|
+
washFlagged: gate.washFlagged ?? null,
|
|
52
|
+
},
|
|
45
53
|
};
|
|
46
54
|
}
|
|
47
55
|
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { fetchMerchantCard } from '@wzrd_sol/sdk';
|
|
2
|
+
import { extractPubkey, getIntelBase, withTimeout } from '../intel-helpers.js';
|
|
3
|
+
function formatMerchantCard(card) {
|
|
4
|
+
const lines = [
|
|
5
|
+
`Merchant card for ${card.merchant ?? 'unknown'}`,
|
|
6
|
+
`In corpus: ${card.in_corpus ? 'yes' : 'no'}`,
|
|
7
|
+
`Wash flagged: ${card.wash_flagged === true ? 'YES — default refuse pay' : card.wash_flagged === false ? 'no' : 'unknown'}`,
|
|
8
|
+
];
|
|
9
|
+
if (card.wash_label)
|
|
10
|
+
lines.push(`Wash label: ${card.wash_label}`);
|
|
11
|
+
if (card.provider_reputation_tier)
|
|
12
|
+
lines.push(`Tier: ${card.provider_reputation_tier}`);
|
|
13
|
+
if (card.unique_payers_90d != null)
|
|
14
|
+
lines.push(`Unique payers (90d): ${card.unique_payers_90d}`);
|
|
15
|
+
if (card.offering_status)
|
|
16
|
+
lines.push(`Offering: ${card.offering_status}`);
|
|
17
|
+
if (card.catalog_enriched) {
|
|
18
|
+
const name = card.catalog && typeof card.catalog === 'object' && 'name' in card.catalog
|
|
19
|
+
? String(card.catalog.name ?? '')
|
|
20
|
+
: '';
|
|
21
|
+
lines.push(`Catalog enriched: yes${name ? ` (${name})` : ''} — listing only, not quality proof`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
lines.push('Catalog enriched: no (graph only)');
|
|
25
|
+
}
|
|
26
|
+
if (card.wash_flagged === true) {
|
|
27
|
+
lines.push('Policy: do not pay this pay_to (trustless default). Cap only if operator set washMaxUsdc.');
|
|
28
|
+
}
|
|
29
|
+
return lines.join('\n');
|
|
30
|
+
}
|
|
31
|
+
export const merchantCardAction = {
|
|
32
|
+
name: 'WZRD_MERCHANT_CARD',
|
|
33
|
+
similes: ['WZRD_MERCHANT', 'MERCHANT_CARD', 'INTEL_MERCHANT_CARD', 'CHECK_WASH'],
|
|
34
|
+
description: 'Free GET merchant demand-quality card for a Solana receive wallet (no auth). ' +
|
|
35
|
+
'Returns wash_flagged, tier, unique payers, catalog join when listed. ' +
|
|
36
|
+
'Default: if wash_flagged is true, do not pay that pay_to.',
|
|
37
|
+
examples: [
|
|
38
|
+
[
|
|
39
|
+
{
|
|
40
|
+
name: '{{user1}}',
|
|
41
|
+
content: { text: 'Merchant card for 7G73dUxj8Qn4yH4x9zXkKqZ8oKqZ8oKqZ8o' },
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: '{{agentName}}',
|
|
45
|
+
content: { text: 'Merchant card: wash_flagged YES — default refuse pay' },
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
],
|
|
49
|
+
validate: async () => true,
|
|
50
|
+
handler: async (runtime, message, _state, _opt, callback) => {
|
|
51
|
+
const content = (message.content ?? {});
|
|
52
|
+
const pubkey = extractPubkey(content);
|
|
53
|
+
if (!pubkey) {
|
|
54
|
+
await callback?.({
|
|
55
|
+
text: 'Provide a merchant/seller wallet (32-44 char base58) for merchant_card.',
|
|
56
|
+
});
|
|
57
|
+
return { success: false, error: 'Missing pubkey' };
|
|
58
|
+
}
|
|
59
|
+
const apiBase = getIntelBase(runtime);
|
|
60
|
+
try {
|
|
61
|
+
const card = await withTimeout(() => fetchMerchantCard(pubkey, { apiBase }));
|
|
62
|
+
if (!card) {
|
|
63
|
+
await callback?.({
|
|
64
|
+
text: `Merchant card unavailable for ${pubkey} (network or invalid). ` +
|
|
65
|
+
`Fail-open: do not invent wash_flagged; use WZRD_INTEL_PREFLIGHT decision only.`,
|
|
66
|
+
});
|
|
67
|
+
return { success: false, error: 'merchant_card_unavailable' };
|
|
68
|
+
}
|
|
69
|
+
const text = formatMerchantCard(card);
|
|
70
|
+
await callback?.({ text });
|
|
71
|
+
return {
|
|
72
|
+
success: true,
|
|
73
|
+
data: {
|
|
74
|
+
...card,
|
|
75
|
+
refuse_pay: card.wash_flagged === true,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
81
|
+
await callback?.({ text: `Merchant card failed: ${msg}` });
|
|
82
|
+
return { success: false, error: msg };
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @wzrd_sol/eliza-plugin — WZRD Agent Intel + Earn Loop for ElizaOS
|
|
3
3
|
*
|
|
4
4
|
* Intel lane (default https://intel.twzrd.xyz):
|
|
5
|
-
* WZRD_INTEL_PREFLIGHT → WZRD_INTEL_TRUST → WZRD_VERIFY_RECEIPT
|
|
5
|
+
* WZRD_INTEL_PREFLIGHT → WZRD_MERCHANT_CARD → WZRD_INTEL_TRUST → WZRD_VERIFY_RECEIPT
|
|
6
6
|
* Paid intel requires caller-supplied x402 fetch via setPayingFetch().
|
|
7
|
+
* Default: preSpendGate refuses wash_flagged pay_to (free merchant_card).
|
|
7
8
|
*
|
|
8
9
|
* Earn lane (default https://api.twzrd.xyz):
|
|
9
10
|
* WZRD_INFER → WZRD_REPORT → WZRD_EARN → WZRD_CLAIM / WZRD_REWARDS
|
|
@@ -20,14 +21,15 @@ import { earnAction } from './actions/earn.js';
|
|
|
20
21
|
import { claimAction } from './actions/claim.js';
|
|
21
22
|
import { rewardsAction } from './actions/rewards.js';
|
|
22
23
|
import { intelPreflightAction } from './actions/intel-preflight.js';
|
|
24
|
+
import { merchantCardAction } from './actions/merchant-card.js';
|
|
23
25
|
import { intelTrustAction } from './actions/intel-trust.js';
|
|
24
26
|
import { verifyReceiptAction } from './actions/verify-receipt.js';
|
|
25
27
|
export declare const wzrdPlugin: Plugin;
|
|
26
28
|
export default wzrdPlugin;
|
|
27
|
-
export { intelPreflightAction, intelTrustAction, verifyReceiptAction, earnAction, inferAction, reportAction, claimAction, rewardsAction, };
|
|
29
|
+
export { intelPreflightAction, merchantCardAction, intelTrustAction, verifyReceiptAction, earnAction, inferAction, reportAction, claimAction, rewardsAction, };
|
|
28
30
|
export { getWzrdClient, clearClientCache, getIntelApiBase, getIntelClient } from './client-factory.js';
|
|
29
31
|
export { setPayingFetch, clearPayingFetch, resolvePayingFetch } from './paying-fetch.js';
|
|
30
32
|
export { WzrdClient } from './client.js';
|
|
31
33
|
export type { InferResult, ReportResult, RewardsBalance, ClaimResult } from './client.js';
|
|
32
|
-
export { IntelPaymentRequiredError, intelPreflight, fetchIntelTrust, verifyReceipt, preSpendGate, intelTrustUrl, TRUSTED_RECEIPT_PUBKEY, INTEL_TRUST_PRICE_USDC, } from '@wzrd_sol/sdk';
|
|
33
|
-
export type { ReadinessCard, PreflightInput, PreflightResponse, TwzrdReceipt, IntelTrustResponse, VerifyReceiptResult, X402PaymentRequired, } from '@wzrd_sol/sdk';
|
|
34
|
+
export { IntelPaymentRequiredError, intelPreflight, fetchIntelTrust, fetchMerchantCard, verifyReceipt, preSpendGate, intelTrustUrl, TRUSTED_RECEIPT_PUBKEY, INTEL_TRUST_PRICE_USDC, } from '@wzrd_sol/sdk';
|
|
35
|
+
export type { ReadinessCard, PreflightInput, PreflightResponse, MerchantCard, TwzrdReceipt, IntelTrustResponse, VerifyReceiptResult, X402PaymentRequired, } from '@wzrd_sol/sdk';
|
package/dist/index.js
CHANGED
|
@@ -4,15 +4,17 @@ import { earnAction } from './actions/earn.js';
|
|
|
4
4
|
import { claimAction } from './actions/claim.js';
|
|
5
5
|
import { rewardsAction } from './actions/rewards.js';
|
|
6
6
|
import { intelPreflightAction } from './actions/intel-preflight.js';
|
|
7
|
+
import { merchantCardAction } from './actions/merchant-card.js';
|
|
7
8
|
import { intelTrustAction } from './actions/intel-trust.js';
|
|
8
9
|
import { verifyReceiptAction } from './actions/verify-receipt.js';
|
|
9
10
|
export const wzrdPlugin = {
|
|
10
11
|
name: 'wzrd',
|
|
11
|
-
description: 'WZRD Agent Intel — free ReadinessCard preflight
|
|
12
|
-
'(V5/V6), offline verification on intel.twzrd.xyz.
|
|
13
|
-
'on api.twzrd.xyz.',
|
|
12
|
+
description: 'WZRD Agent Intel — free ReadinessCard preflight + merchant_card wash refuse (default), ' +
|
|
13
|
+
'x402-paid trust receipts (V5/V6), offline verification on intel.twzrd.xyz. ' +
|
|
14
|
+
'Also ships the legacy earn loop (infer/report/claim) on api.twzrd.xyz.',
|
|
14
15
|
actions: [
|
|
15
16
|
intelPreflightAction,
|
|
17
|
+
merchantCardAction,
|
|
16
18
|
intelTrustAction,
|
|
17
19
|
verifyReceiptAction,
|
|
18
20
|
earnAction,
|
|
@@ -23,8 +25,8 @@ export const wzrdPlugin = {
|
|
|
23
25
|
],
|
|
24
26
|
};
|
|
25
27
|
export default wzrdPlugin;
|
|
26
|
-
export { intelPreflightAction, intelTrustAction, verifyReceiptAction, earnAction, inferAction, reportAction, claimAction, rewardsAction, };
|
|
28
|
+
export { intelPreflightAction, merchantCardAction, intelTrustAction, verifyReceiptAction, earnAction, inferAction, reportAction, claimAction, rewardsAction, };
|
|
27
29
|
export { getWzrdClient, clearClientCache, getIntelApiBase, getIntelClient } from './client-factory.js';
|
|
28
30
|
export { setPayingFetch, clearPayingFetch, resolvePayingFetch } from './paying-fetch.js';
|
|
29
31
|
export { WzrdClient } from './client.js';
|
|
30
|
-
export { IntelPaymentRequiredError, intelPreflight, fetchIntelTrust, verifyReceipt, preSpendGate, intelTrustUrl, TRUSTED_RECEIPT_PUBKEY, INTEL_TRUST_PRICE_USDC, } from '@wzrd_sol/sdk';
|
|
32
|
+
export { IntelPaymentRequiredError, intelPreflight, fetchIntelTrust, fetchMerchantCard, verifyReceipt, preSpendGate, intelTrustUrl, TRUSTED_RECEIPT_PUBKEY, INTEL_TRUST_PRICE_USDC, } from '@wzrd_sol/sdk';
|
|
@@ -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, intelTrustAction, verifyReceiptAction, setPayingFetch, clearPayingFetch, getIntelClient, resolvePayingFetch, } from '@wzrd_sol/eliza-plugin';
|
|
13
|
+
import wzrdPlugin, { 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',
|
|
@@ -43,6 +43,7 @@ describe('wzrdPlugin intel registration + E2E (real runtime load)', () => {
|
|
|
43
43
|
it('constructs runtime with plugins and registers intel actions', () => {
|
|
44
44
|
const names = runtime.actions.map((a) => a.name);
|
|
45
45
|
assert.ok(names.includes('WZRD_INTEL_PREFLIGHT'), 'preflight must be registered');
|
|
46
|
+
assert.ok(names.includes('WZRD_MERCHANT_CARD'), 'merchant card must be registered');
|
|
46
47
|
assert.ok(names.includes('WZRD_INTEL_TRUST'), 'trust must be registered');
|
|
47
48
|
assert.ok(names.includes('WZRD_VERIFY_RECEIPT'), 'verify must be registered');
|
|
48
49
|
});
|
|
@@ -121,35 +122,115 @@ describe('wzrdPlugin intel registration + E2E (real runtime load)', () => {
|
|
|
121
122
|
assert.ok(result.data);
|
|
122
123
|
});
|
|
123
124
|
it('PREFLIGHT-BEFORE-PAY: decision=block aborts the trust purchase before any payment', async () => {
|
|
124
|
-
// preSpendGate runs
|
|
125
|
-
//
|
|
126
|
-
// paid leg). So we stub global fetch to return a block ReadinessCard, and put a
|
|
127
|
-
// tripwire on the injected paying fetch: if the pay leg runs after a block, the
|
|
128
|
-
// tripwire fires and the test fails.
|
|
125
|
+
// preSpendGate runs FREE preflight + merchant_card via global fetch (not the
|
|
126
|
+
// injected paying fetch). Stub both; tripwire on pay leg.
|
|
129
127
|
const realFetch = globalThis.fetch;
|
|
130
128
|
let payAttempted = false;
|
|
131
129
|
setPayingFetch(async () => {
|
|
132
130
|
payAttempted = true;
|
|
133
131
|
return { ok: true, status: 200, json: async () => ({}) };
|
|
134
132
|
});
|
|
133
|
+
globalThis.fetch = (async (input) => {
|
|
134
|
+
const url = String(input);
|
|
135
|
+
if (url.includes('/merchant_card/')) {
|
|
136
|
+
return {
|
|
137
|
+
ok: true,
|
|
138
|
+
status: 200,
|
|
139
|
+
json: async () => ({ wash_flagged: false }),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
ok: true,
|
|
144
|
+
status: 200,
|
|
145
|
+
json: async () => ({
|
|
146
|
+
readiness_card: { decision: 'block', trust_score: 5, can_spend: false },
|
|
147
|
+
reason: 'seller flagged by corpus',
|
|
148
|
+
}),
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
try {
|
|
152
|
+
const callbacks = [];
|
|
153
|
+
const result = await intelTrustAction.handler(mockRuntime(), mockMemory({ pubkey: '4LkEFjJdXARkKx8FBx4LBFa2SvJNmjQpgGDLoJcypZUE' }), undefined, undefined, async (r) => {
|
|
154
|
+
callbacks.push(r.text ?? '');
|
|
155
|
+
return [];
|
|
156
|
+
});
|
|
157
|
+
assert.equal(result?.success, false);
|
|
158
|
+
assert.equal(result?.error, 'preflight_block');
|
|
159
|
+
assert.equal(payAttempted, false, 'payment must NOT be attempted after a block decision');
|
|
160
|
+
assert.match(callbacks.join('\n'), /blocked|No payment was sent/i);
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
globalThis.fetch = realFetch;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
it('WASH REFUSE: wash_flagged aborts trust purchase even when preflight allows', async () => {
|
|
167
|
+
const realFetch = globalThis.fetch;
|
|
168
|
+
let payAttempted = false;
|
|
169
|
+
setPayingFetch(async () => {
|
|
170
|
+
payAttempted = true;
|
|
171
|
+
return { ok: true, status: 200, json: async () => ({}) };
|
|
172
|
+
});
|
|
173
|
+
globalThis.fetch = (async (input) => {
|
|
174
|
+
const url = String(input);
|
|
175
|
+
if (url.includes('/merchant_card/')) {
|
|
176
|
+
return {
|
|
177
|
+
ok: true,
|
|
178
|
+
status: 200,
|
|
179
|
+
json: async () => ({
|
|
180
|
+
merchant: '4LkEFjJdXARkKx8FBx4LBFa2SvJNmjQpgGDLoJcypZUE',
|
|
181
|
+
wash_flagged: true,
|
|
182
|
+
wash_label: 'fleet_dominated',
|
|
183
|
+
}),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
ok: true,
|
|
188
|
+
status: 200,
|
|
189
|
+
json: async () => ({
|
|
190
|
+
readiness_card: { decision: 'allow', trust_score: 80, can_spend: true },
|
|
191
|
+
reason: 'preflight decision=allow',
|
|
192
|
+
}),
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
try {
|
|
196
|
+
const callbacks = [];
|
|
197
|
+
const result = await intelTrustAction.handler(mockRuntime(), mockMemory({ pubkey: '4LkEFjJdXARkKx8FBx4LBFa2SvJNmjQpgGDLoJcypZUE' }), undefined, undefined, async (r) => {
|
|
198
|
+
callbacks.push(r.text ?? '');
|
|
199
|
+
return [];
|
|
200
|
+
});
|
|
201
|
+
assert.equal(result?.success, false);
|
|
202
|
+
assert.equal(result?.error, 'wash_flagged');
|
|
203
|
+
assert.equal(payAttempted, false, 'payment must NOT run after wash refuse');
|
|
204
|
+
assert.match(callbacks.join('\n'), /wash|No payment was sent/i);
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
globalThis.fetch = realFetch;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
it('merchant card handler returns wash / catalog fields (mocked)', async () => {
|
|
211
|
+
const realFetch = globalThis.fetch;
|
|
135
212
|
globalThis.fetch = (async () => ({
|
|
136
213
|
ok: true,
|
|
137
214
|
status: 200,
|
|
138
215
|
json: async () => ({
|
|
139
|
-
|
|
140
|
-
|
|
216
|
+
merchant: '4LkEFjJdXARkKx8FBx4LBFa2SvJNmjQpgGDLoJcypZUE',
|
|
217
|
+
in_corpus: true,
|
|
218
|
+
wash_flagged: false,
|
|
219
|
+
wash_label: 'provider_organic_broad',
|
|
220
|
+
catalog_enriched: false,
|
|
221
|
+
offering_status: 'Offering unknown — graph only',
|
|
222
|
+
unique_payers_90d: 12,
|
|
141
223
|
}),
|
|
142
224
|
}));
|
|
143
225
|
try {
|
|
144
226
|
const callbacks = [];
|
|
145
|
-
const result = await
|
|
227
|
+
const result = await merchantCardAction.handler(mockRuntime(), mockMemory({ pubkey: '4LkEFjJdXARkKx8FBx4LBFa2SvJNmjQpgGDLoJcypZUE' }), undefined, undefined, async (r) => {
|
|
146
228
|
callbacks.push(r.text ?? '');
|
|
147
229
|
return [];
|
|
148
230
|
});
|
|
149
|
-
assert.equal(result?.success,
|
|
150
|
-
assert.
|
|
151
|
-
assert.
|
|
152
|
-
assert.match(callbacks.join('\n'), /blocked|No payment was sent/i);
|
|
231
|
+
assert.equal(result?.success, true);
|
|
232
|
+
assert.match(callbacks.join('\n'), /Wash flagged: no/i);
|
|
233
|
+
assert.match(callbacks.join('\n'), /graph only/i);
|
|
153
234
|
}
|
|
154
235
|
finally {
|
|
155
236
|
globalThis.fetch = realFetch;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wzrd_sol/eliza-plugin",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "WZRD Agent Intel for ElizaOS — preflight ReadinessCards, x402-paid signed trust receipts (V6 reputation leaf), offline verification on intel.twzrd.xyz. Also ships the legacy earn loop.",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "WZRD Agent Intel for ElizaOS — preflight ReadinessCards, free merchant_card wash refuse default, x402-paid signed trust receipts (V6 reputation leaf), offline verification on intel.twzrd.xyz. Also ships the legacy earn loop.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@solana/web3.js": "^1.95.0",
|
|
22
|
-
"@wzrd_sol/sdk": "^0.4.
|
|
22
|
+
"@wzrd_sol/sdk": "^0.4.7",
|
|
23
23
|
"bs58": "^5.0.0",
|
|
24
24
|
"tweetnacl": "^1.0.3"
|
|
25
25
|
},
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
},
|
|
60
60
|
"repository": {
|
|
61
61
|
"type": "git",
|
|
62
|
-
"url": "git+https://github.com/twzrd-sol/
|
|
63
|
-
"directory": "
|
|
62
|
+
"url": "git+https://github.com/twzrd-sol/twzrd-trust.git",
|
|
63
|
+
"directory": "eliza-plugin"
|
|
64
64
|
},
|
|
65
65
|
"bugs": {
|
|
66
66
|
"url": "https://github.com/twzrd-sol/twzrd-trust/issues"
|