@thoughtproof/goat-plugin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +213 -0
- package/dist/actions/attest.d.ts +13 -0
- package/dist/actions/attest.d.ts.map +1 -0
- package/dist/actions/attest.js +32 -0
- package/dist/actions/attest.js.map +1 -0
- package/dist/actions/sentinel.d.ts +12 -0
- package/dist/actions/sentinel.d.ts.map +1 -0
- package/dist/actions/sentinel.js +31 -0
- package/dist/actions/sentinel.js.map +1 -0
- package/dist/actions/status.d.ts +8 -0
- package/dist/actions/status.d.ts.map +1 -0
- package/dist/actions/status.js +19 -0
- package/dist/actions/status.js.map +1 -0
- package/dist/actions/verify.d.ts +18 -0
- package/dist/actions/verify.d.ts.map +1 -0
- package/dist/actions/verify.js +39 -0
- package/dist/actions/verify.js.map +1 -0
- package/dist/adapters/http-thoughtproof.d.ts +39 -0
- package/dist/adapters/http-thoughtproof.d.ts.map +1 -0
- package/dist/adapters/http-thoughtproof.js +235 -0
- package/dist/adapters/http-thoughtproof.js.map +1 -0
- package/dist/adapters/types.d.ts +132 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +9 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/hooks/reputation.d.ts +26 -0
- package/dist/hooks/reputation.d.ts.map +1 -0
- package/dist/hooks/reputation.js +67 -0
- package/dist/hooks/reputation.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ThoughtProof
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# ThoughtProof Plugin
|
|
2
|
+
|
|
3
|
+
Epistemic verification for AI agents — catch bad reasoning before it costs money.
|
|
4
|
+
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
Autonomous agents hallucinate, drift from instructions, and make unsupported logical leaps. When agents control wallets, one bad output costs more than thousands of verification checks. ThoughtProof adds a verification layer between "agent decided" and "transaction sent."
|
|
8
|
+
|
|
9
|
+
**Two products, one flow:**
|
|
10
|
+
- **Sentinel** — fast pre-execution triage (~$0.003, ~2s). Call on every decision.
|
|
11
|
+
- **RV** — adversarial deep verification (~$0.02–0.08, 5–45s). Call when Sentinel is uncertain or stakes are high.
|
|
12
|
+
|
|
13
|
+
## Actions
|
|
14
|
+
|
|
15
|
+
| Action | Purpose | Risk | Cost | Latency |
|
|
16
|
+
|--------|---------|------|------|---------|
|
|
17
|
+
| `thoughtproof.sentinel` | Pre-execution check (ALLOW / BLOCK / UNCERTAIN) | read | ~$0.003 | ~2s |
|
|
18
|
+
| `thoughtproof.verify` | Adversarial reality verification (evaluate → critique → synthesize) | read | $0.02–0.08 | 5–45s |
|
|
19
|
+
| `thoughtproof.attest` | On-chain attestation (EAS for Sentinel, TP-VC for RV) | medium | gas | ~10s |
|
|
20
|
+
| `thoughtproof.status` | Health check both APIs | read | free | <1s |
|
|
21
|
+
|
|
22
|
+
## Agent Decision Flow
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Agent decides action
|
|
26
|
+
│
|
|
27
|
+
├─► thoughtproof.sentinel (every decision, ~$0.003)
|
|
28
|
+
│ ├── ALLOW → Execute
|
|
29
|
+
│ ├── BLOCK → Stop
|
|
30
|
+
│ └── UNCERTAIN → Escalate ─┐
|
|
31
|
+
│ │
|
|
32
|
+
└───────────────────────────────►│
|
|
33
|
+
│
|
|
34
|
+
thoughtproof.verify (tier: standard|deep)
|
|
35
|
+
├── ALLOW → Execute
|
|
36
|
+
└── BLOCK → Stop
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @thoughtproof/goat-plugin
|
|
43
|
+
# peer dependency
|
|
44
|
+
npm install @goatnetwork/agentkit
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Setup
|
|
48
|
+
|
|
49
|
+
Two auth modes — choose one:
|
|
50
|
+
|
|
51
|
+
### Option A: API Key (simple)
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { HttpThoughtProofAdapter } from '@thoughtproof/goat-plugin';
|
|
55
|
+
|
|
56
|
+
const adapter = new HttpThoughtProofAdapter({
|
|
57
|
+
apiKey: process.env.THOUGHTPROOF_API_KEY,
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Option B: x402 Pay-per-call (no API key, agent wallet pays)
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
65
|
+
import { HttpThoughtProofAdapter } from '@thoughtproof/goat-plugin';
|
|
66
|
+
|
|
67
|
+
const adapter = new HttpThoughtProofAdapter({
|
|
68
|
+
x402Signer: privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`),
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The server dictates the price via the `PAYMENT-REQUIRED` header. The adapter signs and pays automatically. No hardcoded prices, no subscription — pure pay-per-use.
|
|
73
|
+
|
|
74
|
+
### Option C: Pre-configured x402 fetch (advanced)
|
|
75
|
+
|
|
76
|
+
If you've already wired up `@x402/fetch`:
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { wrapFetchWithPayment } from '@x402/fetch';
|
|
80
|
+
import { x402Client } from '@x402/core/client';
|
|
81
|
+
import { ExactEvmScheme } from '@x402/evm/exact/client';
|
|
82
|
+
|
|
83
|
+
const client = new x402Client();
|
|
84
|
+
client.register('eip155:*', new ExactEvmScheme(signer));
|
|
85
|
+
|
|
86
|
+
const adapter = new HttpThoughtProofAdapter({
|
|
87
|
+
x402Fetch: wrapFetchWithPayment(fetch, client),
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Register Actions
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { ActionProvider } from '@goatnetwork/agentkit/providers';
|
|
95
|
+
import {
|
|
96
|
+
thoughtproofSentinelAction,
|
|
97
|
+
thoughtproofVerifyAction,
|
|
98
|
+
thoughtproofAttestAction,
|
|
99
|
+
thoughtproofStatusAction,
|
|
100
|
+
} from '@thoughtproof/goat-plugin';
|
|
101
|
+
|
|
102
|
+
const provider = new ActionProvider();
|
|
103
|
+
provider.register(thoughtproofSentinelAction(adapter));
|
|
104
|
+
provider.register(thoughtproofVerifyAction(adapter));
|
|
105
|
+
provider.register(thoughtproofAttestAction(adapter));
|
|
106
|
+
provider.register(thoughtproofStatusAction(adapter));
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Demo
|
|
110
|
+
|
|
111
|
+
Run the included demo agent that tests three scenarios (safe trade, risky trade, ambiguous signal):
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npx tsx examples/thoughtproof-verification/index.ts
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Expected output:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
🐐 ThoughtProof × GOAT AgentKit — Verification Demo
|
|
121
|
+
Sentinel (triage) → RV (deep verification) escalation flow
|
|
122
|
+
|
|
123
|
+
═══════════════════════════════════════════════════════════════
|
|
124
|
+
Health Check
|
|
125
|
+
═══════════════════════════════════════════════════════════════
|
|
126
|
+
Sentinel: ✅ healthy (142ms)
|
|
127
|
+
RV: ✅ healthy (305ms)
|
|
128
|
+
|
|
129
|
+
═══════════════════════════════════════════════════════════════
|
|
130
|
+
Scenario 1: Safe trade — clear signal
|
|
131
|
+
═══════════════════════════════════════════════════════════════
|
|
132
|
+
Expected: Should ALLOW — clear reasoning, within risk parameters
|
|
133
|
+
|
|
134
|
+
→ Running Sentinel pre-check...
|
|
135
|
+
✅ [Sentinel] ALLOW (confidence: 0.94, 1847ms)
|
|
136
|
+
└─ Reasoning is sound and within stated parameters
|
|
137
|
+
|
|
138
|
+
📋 Final Decision:
|
|
139
|
+
Verdict: ALLOW
|
|
140
|
+
Decided by: sentinel
|
|
141
|
+
→ Agent would EXECUTE the trade
|
|
142
|
+
|
|
143
|
+
═══════════════════════════════════════════════════════════════
|
|
144
|
+
Scenario 2: Risky trade — reasoning gaps
|
|
145
|
+
═══════════════════════════════════════════════════════════════
|
|
146
|
+
Expected: Should BLOCK — violates position limits, speculative
|
|
147
|
+
|
|
148
|
+
→ Running Sentinel pre-check...
|
|
149
|
+
🛑 [Sentinel] BLOCK (confidence: 0.97, 1203ms)
|
|
150
|
+
└─ Violates position size limit (50 ETH > 1 ETH max)
|
|
151
|
+
└─ No technical analysis provided
|
|
152
|
+
|
|
153
|
+
📋 Final Decision:
|
|
154
|
+
Verdict: BLOCK
|
|
155
|
+
Decided by: sentinel
|
|
156
|
+
→ Agent would SKIP the trade
|
|
157
|
+
|
|
158
|
+
═══════════════════════════════════════════════════════════════
|
|
159
|
+
Scenario 3: Ambiguous — needs deeper analysis
|
|
160
|
+
═══════════════════════════════════════════════════════════════
|
|
161
|
+
Expected: May trigger UNCERTAIN → RV escalation
|
|
162
|
+
|
|
163
|
+
→ Running Sentinel pre-check...
|
|
164
|
+
⚠️ [Sentinel] UNCERTAIN (confidence: 0.52, 1654ms)
|
|
165
|
+
└─ Correlation analysis methodology unclear
|
|
166
|
+
|
|
167
|
+
→ Sentinel UNCERTAIN — escalating to RV deep verification...
|
|
168
|
+
✅ [RV] ALLOW (confidence: 0.71, 9234ms)
|
|
169
|
+
└─ Synthesis: Correlation is plausible but weak. Position size conservative...
|
|
170
|
+
|
|
171
|
+
📋 Final Decision:
|
|
172
|
+
Verdict: ALLOW
|
|
173
|
+
Decided by: rv
|
|
174
|
+
→ Agent would EXECUTE the trade
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## ERC-8004 Reputation
|
|
178
|
+
|
|
179
|
+
Verification results are submitted as ERC-8004 reputation feedback **automatically** via an internal hook — not as an agent-callable action. This prevents agents from self-scoring.
|
|
180
|
+
|
|
181
|
+
Score mapping: ALLOW → 100, UNCERTAIN → 50, BLOCK → 0.
|
|
182
|
+
|
|
183
|
+
## Tests
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
npx vitest run tests/unit/thoughtproof.test.ts
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
30+ tests covering all 4 actions, x402 payment flow, and reputation hook (metadata, execute, signal propagation, error handling, verdict mapping).
|
|
190
|
+
|
|
191
|
+
## Architecture
|
|
192
|
+
|
|
193
|
+
```
|
|
194
|
+
plugins/thoughtproof/
|
|
195
|
+
├── actions/
|
|
196
|
+
│ ├── sentinel.ts # Pre-execution triage
|
|
197
|
+
│ ├── verify.ts # Adversarial RV verification (tier: standard|deep)
|
|
198
|
+
│ ├── attest.ts # On-chain attestation (source: sentinel|rv)
|
|
199
|
+
│ └── status.ts # Health check
|
|
200
|
+
├── adapters/
|
|
201
|
+
│ ├── types.ts # Shared types + adapter interface
|
|
202
|
+
│ └── http-thoughtproof.ts # HTTP client for Sentinel + RV APIs
|
|
203
|
+
├── hooks/
|
|
204
|
+
│ └── reputation.ts # Internal ERC-8004 reputation hook
|
|
205
|
+
└── index.ts # Plugin exports
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Links
|
|
209
|
+
|
|
210
|
+
- [ThoughtProof](https://thoughtproof.ai)
|
|
211
|
+
- [Sentinel API](https://sentinel.thoughtproof.ai)
|
|
212
|
+
- [ERC-8004](https://eips.ethereum.org/EIPS/eip-8004)
|
|
213
|
+
- [x402](https://docs.x402.org)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@goatnetwork/agentkit/core';
|
|
2
|
+
import type { ThoughtProofAdapter, AttestInput, AttestOutput } from '../adapters/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* On-chain attestation of a ThoughtProof verification result.
|
|
5
|
+
*
|
|
6
|
+
* Creates a permanent, verifiable record of the verification:
|
|
7
|
+
* - source="sentinel" → EAS attestation on Base mainnet
|
|
8
|
+
* - source="rv" → ThoughtProof Verifiable Credential (TP-VC)
|
|
9
|
+
*
|
|
10
|
+
* Requires the requestId from a prior sentinel or verify call.
|
|
11
|
+
*/
|
|
12
|
+
export declare function thoughtproofAttestAction(adapter: ThoughtProofAdapter): ActionDefinition<AttestInput, AttestOutput>;
|
|
13
|
+
//# sourceMappingURL=attest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attest.d.ts","sourceRoot":"","sources":["../../src/actions/attest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAU3F;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,mBAAmB,GAC3B,gBAAgB,CAAC,WAAW,EAAE,YAAY,CAAC,CAgB7C"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const inputSchema = z.object({
|
|
3
|
+
source: z.enum(['sentinel', 'rv']).describe('Which verification result to attest: "sentinel" → EAS on-chain attestation, "rv" → TP-VC attestation'),
|
|
4
|
+
requestId: z.string().min(1, 'requestId from the verification response is required'),
|
|
5
|
+
recipient: z.string().regex(/^0x[0-9a-fA-F]{40}$/, 'recipient must be a valid EVM address'),
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* On-chain attestation of a ThoughtProof verification result.
|
|
9
|
+
*
|
|
10
|
+
* Creates a permanent, verifiable record of the verification:
|
|
11
|
+
* - source="sentinel" → EAS attestation on Base mainnet
|
|
12
|
+
* - source="rv" → ThoughtProof Verifiable Credential (TP-VC)
|
|
13
|
+
*
|
|
14
|
+
* Requires the requestId from a prior sentinel or verify call.
|
|
15
|
+
*/
|
|
16
|
+
export function thoughtproofAttestAction(adapter) {
|
|
17
|
+
return {
|
|
18
|
+
name: 'thoughtproof.attest',
|
|
19
|
+
description: 'Create an on-chain attestation of a verification result. ' +
|
|
20
|
+
'Pass source="sentinel" for EAS attestation or source="rv" for TP-VC. ' +
|
|
21
|
+
'Requires the requestId from a prior thoughtproof.sentinel or thoughtproof.verify call. ' +
|
|
22
|
+
'The recipient address receives the attestation.',
|
|
23
|
+
riskLevel: 'medium',
|
|
24
|
+
requiresConfirmation: true,
|
|
25
|
+
networks: ['goat-mainnet', 'goat-testnet'],
|
|
26
|
+
zodInputSchema: inputSchema,
|
|
27
|
+
async execute(ctx, input) {
|
|
28
|
+
return adapter.attest(input, ctx.signal);
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=attest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attest.js","sourceRoot":"","sources":["../../src/actions/attest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CACzC,sGAAsG,CACvG;IACD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,sDAAsD,CAAC;IACpF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qBAAqB,EAAE,uCAAuC,CAAC;CAC5F,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA4B;IAE5B,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,2DAA2D;YAC3D,uEAAuE;YACvE,yFAAyF;YACzF,iDAAiD;QACnD,SAAS,EAAE,QAAQ;QACnB,oBAAoB,EAAE,IAAI;QAC1B,QAAQ,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;QAC1C,cAAc,EAAE,WAAW;QAC3B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK;YACtB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@goatnetwork/agentkit/core';
|
|
2
|
+
import type { ThoughtProofAdapter, SentinelVerifyInput, SentinelVerifyOutput } from '../adapters/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Pre-execution verification via ThoughtProof Sentinel.
|
|
5
|
+
*
|
|
6
|
+
* Checks agent reasoning and planned actions BEFORE execution.
|
|
7
|
+
* Returns ALLOW (safe to proceed), BLOCK (stop), or UNCERTAIN (escalate to RV).
|
|
8
|
+
*
|
|
9
|
+
* Cost: ~$0.003 per call. Designed for every agent decision cycle.
|
|
10
|
+
*/
|
|
11
|
+
export declare function thoughtproofSentinelAction(adapter: ThoughtProofAdapter): ActionDefinition<SentinelVerifyInput, SentinelVerifyOutput>;
|
|
12
|
+
//# sourceMappingURL=sentinel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentinel.d.ts","sourceRoot":"","sources":["../../src/actions/sentinel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAQ3G;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,mBAAmB,GAC3B,gBAAgB,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,CAgB7D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const inputSchema = z.object({
|
|
3
|
+
claim: z.string().min(1, 'claim must not be empty — the agent reasoning or planned action to verify'),
|
|
4
|
+
context: z.string().optional().describe('Context or instructions the agent was given'),
|
|
5
|
+
task: z.string().optional().describe('The agent task or goal'),
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* Pre-execution verification via ThoughtProof Sentinel.
|
|
9
|
+
*
|
|
10
|
+
* Checks agent reasoning and planned actions BEFORE execution.
|
|
11
|
+
* Returns ALLOW (safe to proceed), BLOCK (stop), or UNCERTAIN (escalate to RV).
|
|
12
|
+
*
|
|
13
|
+
* Cost: ~$0.003 per call. Designed for every agent decision cycle.
|
|
14
|
+
*/
|
|
15
|
+
export function thoughtproofSentinelAction(adapter) {
|
|
16
|
+
return {
|
|
17
|
+
name: 'thoughtproof.sentinel',
|
|
18
|
+
description: 'Pre-execution verification: check agent reasoning before executing an action. ' +
|
|
19
|
+
'Send the agent\'s planned action and reasoning as "claim", get back ALLOW, BLOCK, or UNCERTAIN. ' +
|
|
20
|
+
'Use before every economic decision. Fast (~2s) and cheap (~$0.003). ' +
|
|
21
|
+
'If UNCERTAIN, escalate to thoughtproof.verify for deeper analysis.',
|
|
22
|
+
riskLevel: 'read',
|
|
23
|
+
requiresConfirmation: false,
|
|
24
|
+
networks: ['goat-mainnet', 'goat-testnet'],
|
|
25
|
+
zodInputSchema: inputSchema,
|
|
26
|
+
async execute(ctx, input) {
|
|
27
|
+
return adapter.sentinelVerify(input, ctx.signal);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=sentinel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sentinel.js","sourceRoot":"","sources":["../../src/actions/sentinel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,2EAA2E,CAAC;IACrG,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;IACtF,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;CAC/D,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACxC,OAA4B;IAE5B,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EACT,gFAAgF;YAChF,kGAAkG;YAClG,sEAAsE;YACtE,oEAAoE;QACtE,SAAS,EAAE,MAAM;QACjB,oBAAoB,EAAE,KAAK;QAC3B,QAAQ,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;QAC1C,cAAc,EAAE,WAAW;QAC3B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK;YACtB,OAAO,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@goatnetwork/agentkit/core';
|
|
2
|
+
import type { ThoughtProofAdapter, StatusOutput } from '../adapters/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Health check for both ThoughtProof APIs (Sentinel + RV).
|
|
5
|
+
* No input required. Returns health status and latency for each backend.
|
|
6
|
+
*/
|
|
7
|
+
export declare function thoughtproofStatusAction(adapter: ThoughtProofAdapter): ActionDefinition<Record<string, never>, StatusOutput>;
|
|
8
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/actions/status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,mBAAmB,GAC3B,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,YAAY,CAAC,CAcvD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Health check for both ThoughtProof APIs (Sentinel + RV).
|
|
3
|
+
* No input required. Returns health status and latency for each backend.
|
|
4
|
+
*/
|
|
5
|
+
export function thoughtproofStatusAction(adapter) {
|
|
6
|
+
return {
|
|
7
|
+
name: 'thoughtproof.status',
|
|
8
|
+
description: 'Check health of ThoughtProof verification APIs. ' +
|
|
9
|
+
'Returns availability and latency for both Sentinel and RV backends. ' +
|
|
10
|
+
'Call before critical verification flows to ensure services are reachable.',
|
|
11
|
+
riskLevel: 'read',
|
|
12
|
+
requiresConfirmation: false,
|
|
13
|
+
networks: ['goat-mainnet', 'goat-testnet'],
|
|
14
|
+
async execute(ctx) {
|
|
15
|
+
return adapter.status(ctx.signal);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/actions/status.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA4B;IAE5B,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,kDAAkD;YAClD,sEAAsE;YACtE,2EAA2E;QAC7E,SAAS,EAAE,MAAM;QACjB,oBAAoB,EAAE,KAAK;QAC3B,QAAQ,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;QAC1C,KAAK,CAAC,OAAO,CAAC,GAAG;YACf,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActionDefinition } from '@goatnetwork/agentkit/core';
|
|
2
|
+
import type { ThoughtProofAdapter, RVVerifyInput, RVVerifyOutput } from '../adapters/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Adversarial reality verification via ThoughtProof RV.
|
|
5
|
+
*
|
|
6
|
+
* Three-stage pipeline: evaluate → critique (red-team) → synthesize.
|
|
7
|
+
* Checks whether an agent's output is substantively correct — not just
|
|
8
|
+
* process compliance, but actual factual/logical correctness.
|
|
9
|
+
*
|
|
10
|
+
* Use when:
|
|
11
|
+
* - Sentinel returns UNCERTAIN and you need deeper analysis
|
|
12
|
+
* - High-stakes decisions where correctness matters (trading, compliance)
|
|
13
|
+
* - Post-execution audit of agent reasoning quality
|
|
14
|
+
*
|
|
15
|
+
* Cost: ~$0.02 (standard) or ~$0.08 (deep) per call.
|
|
16
|
+
*/
|
|
17
|
+
export declare function thoughtproofVerifyAction(adapter: ThoughtProofAdapter): ActionDefinition<RVVerifyInput, RVVerifyOutput>;
|
|
18
|
+
//# sourceMappingURL=verify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/actions/verify.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAa/F;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,mBAAmB,GAC3B,gBAAgB,CAAC,aAAa,EAAE,cAAc,CAAC,CAiBjD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const inputSchema = z.object({
|
|
3
|
+
claim: z.string().min(1, 'claim must not be empty — the agent output or decision to verify'),
|
|
4
|
+
context: z.string().optional().describe('Supporting context, evidence, or source material'),
|
|
5
|
+
tier: z.enum(['standard', 'deep']).default('standard').describe('Verification depth: "standard" (~$0.02, 5-15s) for most decisions, "deep" (~$0.08, 15-45s) for high-stakes'),
|
|
6
|
+
domain: z.string().optional().describe('Domain hint for domain-specific verification profiles (e.g., "finance", "medical", "legal")'),
|
|
7
|
+
});
|
|
8
|
+
/**
|
|
9
|
+
* Adversarial reality verification via ThoughtProof RV.
|
|
10
|
+
*
|
|
11
|
+
* Three-stage pipeline: evaluate → critique (red-team) → synthesize.
|
|
12
|
+
* Checks whether an agent's output is substantively correct — not just
|
|
13
|
+
* process compliance, but actual factual/logical correctness.
|
|
14
|
+
*
|
|
15
|
+
* Use when:
|
|
16
|
+
* - Sentinel returns UNCERTAIN and you need deeper analysis
|
|
17
|
+
* - High-stakes decisions where correctness matters (trading, compliance)
|
|
18
|
+
* - Post-execution audit of agent reasoning quality
|
|
19
|
+
*
|
|
20
|
+
* Cost: ~$0.02 (standard) or ~$0.08 (deep) per call.
|
|
21
|
+
*/
|
|
22
|
+
export function thoughtproofVerifyAction(adapter) {
|
|
23
|
+
return {
|
|
24
|
+
name: 'thoughtproof.verify',
|
|
25
|
+
description: 'Adversarial reality verification: check whether an agent output is substantively correct. ' +
|
|
26
|
+
'Uses a multi-model evaluate → red-team critique → synthesize pipeline. ' +
|
|
27
|
+
'Set tier="standard" for most checks (~$0.02, 5-15s), tier="deep" for high-stakes (~$0.08, 15-45s). ' +
|
|
28
|
+
'Use after Sentinel returns UNCERTAIN, or directly for critical decisions. ' +
|
|
29
|
+
'Returns verdict (ALLOW/BLOCK/UNCERTAIN), confidence score, and full reasoning chain.',
|
|
30
|
+
riskLevel: 'read',
|
|
31
|
+
requiresConfirmation: false,
|
|
32
|
+
networks: ['goat-mainnet', 'goat-testnet'],
|
|
33
|
+
zodInputSchema: inputSchema,
|
|
34
|
+
async execute(ctx, input) {
|
|
35
|
+
return adapter.rvVerify(input, ctx.signal);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/actions/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,kEAAkE,CAAC;IAC5F,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kDAAkD,CAAC;IAC3F,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,CAC7D,4GAA4G,CAC7G;IACD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CACpC,6FAA6F,CAC9F;CACF,CAAC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAA4B;IAE5B,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EACT,4FAA4F;YAC5F,yEAAyE;YACzE,qGAAqG;YACrG,4EAA4E;YAC5E,sFAAsF;QACxF,SAAS,EAAE,MAAM;QACjB,oBAAoB,EAAE,KAAK;QAC3B,QAAQ,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;QAC1C,cAAc,EAAE,WAAW;QAC3B,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK;YACtB,OAAO,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;QAC7C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ThoughtProofAdapter, ThoughtProofConfig, SentinelVerifyInput, SentinelVerifyOutput, RVVerifyInput, RVVerifyOutput, AttestInput, AttestOutput, StatusOutput } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* HTTP adapter for ThoughtProof Sentinel + RV APIs.
|
|
4
|
+
*
|
|
5
|
+
* Supports two auth modes:
|
|
6
|
+
* 1. **API Key** (default): Bearer token auth. Simple, no wallet needed.
|
|
7
|
+
* 2. **x402 Pay-per-call**: Agent wallet pays per verification via HTTP 402.
|
|
8
|
+
* Server dictates price. No API key needed. Zero subscription.
|
|
9
|
+
*
|
|
10
|
+
* Priority: x402Fetch > x402Signer > apiKey
|
|
11
|
+
*/
|
|
12
|
+
export declare class HttpThoughtProofAdapter implements ThoughtProofAdapter {
|
|
13
|
+
private readonly sentinelBase;
|
|
14
|
+
private readonly rvBase;
|
|
15
|
+
private readonly apiKey?;
|
|
16
|
+
private readonly x402Signer?;
|
|
17
|
+
private readonly maxPaymentAmount?;
|
|
18
|
+
private readonly fetchFn;
|
|
19
|
+
private readonly sentinelTimeout;
|
|
20
|
+
private readonly rvTimeout;
|
|
21
|
+
constructor(config?: ThoughtProofConfig);
|
|
22
|
+
/** Whether this adapter uses x402 pay-per-call */
|
|
23
|
+
get isX402Enabled(): boolean;
|
|
24
|
+
private headers;
|
|
25
|
+
/**
|
|
26
|
+
* Handle x402 payment flow:
|
|
27
|
+
* 1. Server responds 402 + PAYMENT-REQUIRED header
|
|
28
|
+
* 2. Parse payment requirements (amount, asset, network, scheme)
|
|
29
|
+
* 3. Sign payment authorization with wallet
|
|
30
|
+
* 4. Retry original request with PAYMENT-SIGNATURE header
|
|
31
|
+
*/
|
|
32
|
+
private handleX402;
|
|
33
|
+
private fetchWithTimeout;
|
|
34
|
+
sentinelVerify(input: SentinelVerifyInput, signal?: AbortSignal): Promise<SentinelVerifyOutput>;
|
|
35
|
+
rvVerify(input: RVVerifyInput, signal?: AbortSignal): Promise<RVVerifyOutput>;
|
|
36
|
+
attest(input: AttestInput, signal?: AbortSignal): Promise<AttestOutput>;
|
|
37
|
+
status(signal?: AbortSignal): Promise<StatusOutput>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=http-thoughtproof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-thoughtproof.d.ts","sourceRoot":"","sources":["../../src/adapters/http-thoughtproof.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,Y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
6
|
+
* Parse the base64-encoded PAYMENT-REQUIRED header from a 402 response.
|
|
7
|
+
* Returns the decoded payment requirements object.
|
|
8
|
+
*/
|
|
9
|
+
function parsePaymentRequired(headerValue) {
|
|
10
|
+
// Use Buffer for Node compatibility (atob is Browser + Node 16+ only)
|
|
11
|
+
const json = typeof Buffer !== 'undefined'
|
|
12
|
+
? Buffer.from(headerValue, 'base64').toString('utf-8')
|
|
13
|
+
: atob(headerValue);
|
|
14
|
+
return JSON.parse(json);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Build a PAYMENT-SIGNATURE header value from a signed payment payload.
|
|
18
|
+
*/
|
|
19
|
+
function encodePaymentSignature(payload) {
|
|
20
|
+
const json = JSON.stringify(payload);
|
|
21
|
+
return typeof Buffer !== 'undefined'
|
|
22
|
+
? Buffer.from(json, 'utf-8').toString('base64')
|
|
23
|
+
: btoa(json);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* HTTP adapter for ThoughtProof Sentinel + RV APIs.
|
|
27
|
+
*
|
|
28
|
+
* Supports two auth modes:
|
|
29
|
+
* 1. **API Key** (default): Bearer token auth. Simple, no wallet needed.
|
|
30
|
+
* 2. **x402 Pay-per-call**: Agent wallet pays per verification via HTTP 402.
|
|
31
|
+
* Server dictates price. No API key needed. Zero subscription.
|
|
32
|
+
*
|
|
33
|
+
* Priority: x402Fetch > x402Signer > apiKey
|
|
34
|
+
*/
|
|
35
|
+
export class HttpThoughtProofAdapter {
|
|
36
|
+
sentinelBase;
|
|
37
|
+
rvBase;
|
|
38
|
+
apiKey;
|
|
39
|
+
x402Signer;
|
|
40
|
+
maxPaymentAmount;
|
|
41
|
+
fetchFn;
|
|
42
|
+
sentinelTimeout;
|
|
43
|
+
rvTimeout;
|
|
44
|
+
constructor(config = {}) {
|
|
45
|
+
this.sentinelBase = (config.sentinelBaseUrl ?? DEFAULT_SENTINEL_URL).replace(/\/$/, '');
|
|
46
|
+
this.rvBase = (config.rvBaseUrl ?? DEFAULT_RV_URL).replace(/\/$/, '');
|
|
47
|
+
this.apiKey = config.apiKey;
|
|
48
|
+
this.x402Signer = config.x402Signer;
|
|
49
|
+
this.maxPaymentAmount = config.maxPaymentAmount ? BigInt(config.maxPaymentAmount) : undefined;
|
|
50
|
+
this.sentinelTimeout = config.sentinelTimeoutMs ?? DEFAULT_SENTINEL_TIMEOUT;
|
|
51
|
+
this.rvTimeout = config.rvTimeoutMs ?? DEFAULT_RV_TIMEOUT;
|
|
52
|
+
// Priority: x402Fetch (user-managed) > native fetch (we handle 402 ourselves)
|
|
53
|
+
this.fetchFn = config.x402Fetch ?? fetch;
|
|
54
|
+
}
|
|
55
|
+
/** Whether this adapter uses x402 pay-per-call */
|
|
56
|
+
get isX402Enabled() {
|
|
57
|
+
return !!this.x402Signer || this.fetchFn !== fetch;
|
|
58
|
+
}
|
|
59
|
+
headers() {
|
|
60
|
+
const h = { 'Content-Type': 'application/json' };
|
|
61
|
+
// API key auth only when NOT using x402
|
|
62
|
+
if (this.apiKey && !this.x402Signer) {
|
|
63
|
+
h['Authorization'] = `Bearer ${this.apiKey}`;
|
|
64
|
+
}
|
|
65
|
+
return h;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Handle x402 payment flow:
|
|
69
|
+
* 1. Server responds 402 + PAYMENT-REQUIRED header
|
|
70
|
+
* 2. Parse payment requirements (amount, asset, network, scheme)
|
|
71
|
+
* 3. Sign payment authorization with wallet
|
|
72
|
+
* 4. Retry original request with PAYMENT-SIGNATURE header
|
|
73
|
+
*/
|
|
74
|
+
async handleX402(res, url, init, signal) {
|
|
75
|
+
if (!this.x402Signer?.signTypedData) {
|
|
76
|
+
throw new Error('ThoughtProof API requires payment (HTTP 402) but no x402Signer is configured. ' +
|
|
77
|
+
'Provide an x402Signer in ThoughtProofConfig or use an apiKey instead.');
|
|
78
|
+
}
|
|
79
|
+
const paymentRequiredHeader = res.headers.get('payment-required');
|
|
80
|
+
if (!paymentRequiredHeader) {
|
|
81
|
+
throw new Error('ThoughtProof API returned 402 but no PAYMENT-REQUIRED header. ' +
|
|
82
|
+
'The server may not support x402 yet.');
|
|
83
|
+
}
|
|
84
|
+
const requirements = parsePaymentRequired(paymentRequiredHeader);
|
|
85
|
+
// Safety cap: reject if server requests more than configured max
|
|
86
|
+
if (this.maxPaymentAmount) {
|
|
87
|
+
const requestedAmount = requirements.amount ?? requirements.maxAmountRequired;
|
|
88
|
+
if (requestedAmount && BigInt(String(requestedAmount)) > this.maxPaymentAmount) {
|
|
89
|
+
throw new Error(`ThoughtProof x402 payment amount ${requestedAmount} exceeds configured maxPaymentAmount ${this.maxPaymentAmount}. ` +
|
|
90
|
+
'Refusing to sign. Increase maxPaymentAmount in config if this is expected.');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Extract typed data for signing from the payment requirements.
|
|
94
|
+
// x402 v2 embeds the EIP-712 signing payload in the requirements.
|
|
95
|
+
const typedData = requirements.typedData;
|
|
96
|
+
if (!typedData) {
|
|
97
|
+
// Fallback: construct minimal payment authorization
|
|
98
|
+
// This handles servers that use a simpler payment-required format
|
|
99
|
+
const signature = await this.x402Signer.signTypedData({
|
|
100
|
+
domain: requirements.domain ?? {},
|
|
101
|
+
types: requirements.types ?? {},
|
|
102
|
+
primaryType: requirements.primaryType ?? 'Payment',
|
|
103
|
+
message: requirements.message ?? requirements,
|
|
104
|
+
});
|
|
105
|
+
const paymentPayload = {
|
|
106
|
+
signature,
|
|
107
|
+
signer: this.x402Signer.address,
|
|
108
|
+
scheme: requirements.scheme ?? 'exact',
|
|
109
|
+
};
|
|
110
|
+
return this.fetchFn(url, {
|
|
111
|
+
...init,
|
|
112
|
+
headers: {
|
|
113
|
+
...init.headers,
|
|
114
|
+
'payment-signature': encodePaymentSignature(paymentPayload),
|
|
115
|
+
},
|
|
116
|
+
signal,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
// Standard x402 v2 path: sign the embedded typed data
|
|
120
|
+
const signature = await this.x402Signer.signTypedData(typedData);
|
|
121
|
+
const paymentPayload = {
|
|
122
|
+
signature,
|
|
123
|
+
signer: this.x402Signer.address,
|
|
124
|
+
scheme: requirements.scheme ?? 'exact',
|
|
125
|
+
};
|
|
126
|
+
return this.fetchFn(url, {
|
|
127
|
+
...init,
|
|
128
|
+
headers: {
|
|
129
|
+
...init.headers,
|
|
130
|
+
'payment-signature': encodePaymentSignature(paymentPayload),
|
|
131
|
+
},
|
|
132
|
+
signal,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
async fetchWithTimeout(url, body, timeoutMs, signal) {
|
|
136
|
+
const start = Date.now();
|
|
137
|
+
const makeSignal = () => {
|
|
138
|
+
const elapsed = Date.now() - start;
|
|
139
|
+
const remaining = Math.max(timeoutMs - elapsed, 1_000);
|
|
140
|
+
const timeoutSignal = AbortSignal.timeout(remaining);
|
|
141
|
+
return signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
|
|
142
|
+
};
|
|
143
|
+
const init = {
|
|
144
|
+
method: 'POST',
|
|
145
|
+
headers: this.headers(),
|
|
146
|
+
body: JSON.stringify(body),
|
|
147
|
+
signal: makeSignal(),
|
|
148
|
+
};
|
|
149
|
+
let res = await this.fetchFn(url, init);
|
|
150
|
+
// x402: server requires payment — retry with fresh timeout
|
|
151
|
+
if (res.status === 402 && this.x402Signer) {
|
|
152
|
+
const retryInit = {
|
|
153
|
+
...init,
|
|
154
|
+
signal: makeSignal(), // fresh timeout for the payment retry
|
|
155
|
+
};
|
|
156
|
+
res = await this.handleX402(res, url, retryInit, makeSignal());
|
|
157
|
+
}
|
|
158
|
+
if (!res.ok) {
|
|
159
|
+
const text = await res.text().catch(() => '');
|
|
160
|
+
throw new Error(`ThoughtProof API error ${res.status}: ${text}`);
|
|
161
|
+
}
|
|
162
|
+
const data = await res.json();
|
|
163
|
+
return { ...data, _latencyMs: Date.now() - start };
|
|
164
|
+
}
|
|
165
|
+
async sentinelVerify(input, signal) {
|
|
166
|
+
const body = {
|
|
167
|
+
claim: input.claim,
|
|
168
|
+
...(input.context && { context: input.context }),
|
|
169
|
+
...(input.task && { task: input.task }),
|
|
170
|
+
};
|
|
171
|
+
const raw = await this.fetchWithTimeout(`${this.sentinelBase}/sentinel/verify`, body, this.sentinelTimeout, signal);
|
|
172
|
+
return {
|
|
173
|
+
verdict: raw.verdict,
|
|
174
|
+
confidence: raw.confidence ?? 0,
|
|
175
|
+
reasons: raw.reasons ?? [],
|
|
176
|
+
requestId: raw.request_id ?? raw.requestId ?? '',
|
|
177
|
+
latencyMs: raw._latencyMs,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
async rvVerify(input, signal) {
|
|
181
|
+
const body = {
|
|
182
|
+
claim: input.claim,
|
|
183
|
+
...(input.context && { context: input.context }),
|
|
184
|
+
tier: input.tier,
|
|
185
|
+
...(input.domain && { domain: input.domain }),
|
|
186
|
+
};
|
|
187
|
+
const raw = await this.fetchWithTimeout(`${this.rvBase}/v1/verify`, body, this.rvTimeout, signal);
|
|
188
|
+
return {
|
|
189
|
+
verdict: raw.verdict,
|
|
190
|
+
confidence: raw.confidence ?? 0,
|
|
191
|
+
evaluation: raw.evaluation ?? '',
|
|
192
|
+
critique: raw.critique ?? '',
|
|
193
|
+
synthesis: raw.synthesis ?? '',
|
|
194
|
+
requestId: raw.request_id ?? raw.requestId ?? '',
|
|
195
|
+
latencyMs: raw._latencyMs,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
async attest(input, signal) {
|
|
199
|
+
const baseUrl = input.source === 'sentinel' ? this.sentinelBase : this.rvBase;
|
|
200
|
+
const path = input.source === 'sentinel'
|
|
201
|
+
? '/sentinel/attest'
|
|
202
|
+
: '/v1/attest';
|
|
203
|
+
const timeout = input.source === 'sentinel' ? this.sentinelTimeout : this.rvTimeout;
|
|
204
|
+
const body = {
|
|
205
|
+
request_id: input.requestId,
|
|
206
|
+
recipient: input.recipient,
|
|
207
|
+
};
|
|
208
|
+
const raw = await this.fetchWithTimeout(`${baseUrl}${path}`, body, timeout, signal);
|
|
209
|
+
return {
|
|
210
|
+
attestationId: raw.attestation_id ?? raw.attestationId ?? '',
|
|
211
|
+
txHash: raw.tx_hash ?? raw.txHash,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
async status(signal) {
|
|
215
|
+
const check = async (url, timeout) => {
|
|
216
|
+
const start = Date.now();
|
|
217
|
+
try {
|
|
218
|
+
const res = await this.fetchFn(url, {
|
|
219
|
+
method: 'GET',
|
|
220
|
+
signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(timeout)]) : AbortSignal.timeout(timeout),
|
|
221
|
+
});
|
|
222
|
+
return { healthy: res.ok, latencyMs: Date.now() - start };
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return { healthy: false, latencyMs: Date.now() - start };
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
const [sentinel, rv] = await Promise.all([
|
|
229
|
+
check(`${this.sentinelBase}/sentinel/health`, 10_000),
|
|
230
|
+
check(`${this.rvBase}/v1/health`, 10_000),
|
|
231
|
+
]);
|
|
232
|
+
return { sentinel, rv };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=http-thoughtproof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-thoughtproof.js","sourceRoot":"","sources":["../../src/adapters/http-thoughtproof.ts"],"names":[],"mappings":"AAaA,MAAM,oBAAoB,GAAG,kCAAkC,CAAC;AAChE,MAAM,cAAc,GAAG,6BAA6B,CAAC;AACrD,MAAM,wBAAwB,GAAG,MAAM,CAAC;AACxC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC;;;GAGG;AACH,SAAS,oBAAoB,CAAC,WAAmB;IAC/C,sEAAsE;IACtE,MAAM,IAAI,GAAG,OAAO,MAAM,KAAK,WAAW;QACxC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,QAAQ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;YAC3D,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACvC,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,kBAAkB,EAAE,MAAM,CAAC;YACrD,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC;SAC1C,CAAC,CAAC;QAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ThoughtProof API adapter types.
|
|
3
|
+
*
|
|
4
|
+
* Two backend APIs:
|
|
5
|
+
* - Sentinel: sentinel.thoughtproof.ai/sentinel/verify
|
|
6
|
+
* - RV: api.thoughtproof.ai/v1/verify
|
|
7
|
+
*/
|
|
8
|
+
export type Verdict = 'ALLOW' | 'BLOCK' | 'UNCERTAIN';
|
|
9
|
+
/**
|
|
10
|
+
* x402 signer interface — any object that can sign EIP-712 typed data.
|
|
11
|
+
* Compatible with viem's `privateKeyToAccount()` and ethers' `Wallet`.
|
|
12
|
+
*/
|
|
13
|
+
export interface X402Signer {
|
|
14
|
+
/** Sign EIP-712 typed data. Compatible with viem Account or ethers Signer. */
|
|
15
|
+
signTypedData?(args: {
|
|
16
|
+
domain: Record<string, unknown>;
|
|
17
|
+
types: Record<string, Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
type: string;
|
|
20
|
+
}>>;
|
|
21
|
+
primaryType: string;
|
|
22
|
+
message: Record<string, unknown>;
|
|
23
|
+
}): Promise<string>;
|
|
24
|
+
/** EVM address of the signer */
|
|
25
|
+
address?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ThoughtProofConfig {
|
|
28
|
+
/** Sentinel API base URL (default: https://sentinel.thoughtproof.ai) */
|
|
29
|
+
sentinelBaseUrl?: string;
|
|
30
|
+
/** RV API base URL (default: https://api.thoughtproof.ai) */
|
|
31
|
+
rvBaseUrl?: string;
|
|
32
|
+
/** API key for authenticated requests. Ignored when x402Signer is provided. */
|
|
33
|
+
apiKey?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Maximum payment amount (in smallest unit, e.g. USDC micro-units) the adapter
|
|
36
|
+
* will sign per request. Prevents a compromised server from draining the wallet.
|
|
37
|
+
* Default: no limit. Recommended: set to 10x your expected max per-call cost.
|
|
38
|
+
*/
|
|
39
|
+
maxPaymentAmount?: string;
|
|
40
|
+
/**
|
|
41
|
+
* x402 wallet signer for pay-per-call verification.
|
|
42
|
+
* When provided, the adapter pays via x402 (HTTP 402) instead of using an API key.
|
|
43
|
+
* The server dictates the price — the adapter just signs and pays.
|
|
44
|
+
*
|
|
45
|
+
* Pass a viem account: `privateKeyToAccount('0x...')`
|
|
46
|
+
* Or any object implementing X402Signer.
|
|
47
|
+
*/
|
|
48
|
+
x402Signer?: X402Signer;
|
|
49
|
+
/**
|
|
50
|
+
* Custom fetch function with x402 payment handling already wired in.
|
|
51
|
+
* Use this if you've already set up `@x402/fetch` `wrapFetchWithPayment()`.
|
|
52
|
+
* When provided, x402Signer is ignored (you handle payment externally).
|
|
53
|
+
*/
|
|
54
|
+
x402Fetch?: typeof fetch;
|
|
55
|
+
/** Timeout in ms for API calls (default: 30_000 for Sentinel, 120_000 for RV) */
|
|
56
|
+
sentinelTimeoutMs?: number;
|
|
57
|
+
rvTimeoutMs?: number;
|
|
58
|
+
}
|
|
59
|
+
export interface SentinelVerifyInput {
|
|
60
|
+
/** The agent's reasoning or planned action to verify */
|
|
61
|
+
claim: string;
|
|
62
|
+
/** Context / instructions the agent was given */
|
|
63
|
+
context?: string;
|
|
64
|
+
/** The agent's task or goal */
|
|
65
|
+
task?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface SentinelVerifyOutput {
|
|
68
|
+
verdict: Verdict;
|
|
69
|
+
confidence: number;
|
|
70
|
+
reasons: string[];
|
|
71
|
+
/** Request ID for tracing */
|
|
72
|
+
requestId: string;
|
|
73
|
+
/** Latency in ms */
|
|
74
|
+
latencyMs: number;
|
|
75
|
+
}
|
|
76
|
+
export type RVTier = 'standard' | 'deep';
|
|
77
|
+
export interface RVVerifyInput {
|
|
78
|
+
/** The claim or agent output to verify */
|
|
79
|
+
claim: string;
|
|
80
|
+
/** Supporting context or evidence */
|
|
81
|
+
context?: string;
|
|
82
|
+
/** Verification depth */
|
|
83
|
+
tier: RVTier;
|
|
84
|
+
/** Domain hint for domain-specific verification profiles */
|
|
85
|
+
domain?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface RVVerifyOutput {
|
|
88
|
+
verdict: Verdict;
|
|
89
|
+
confidence: number;
|
|
90
|
+
/** Adversarial evaluation result */
|
|
91
|
+
evaluation: string;
|
|
92
|
+
/** Red-team critique */
|
|
93
|
+
critique: string;
|
|
94
|
+
/** Final synthesized reasoning */
|
|
95
|
+
synthesis: string;
|
|
96
|
+
/** Request ID for tracing */
|
|
97
|
+
requestId: string;
|
|
98
|
+
/** Latency in ms */
|
|
99
|
+
latencyMs: number;
|
|
100
|
+
}
|
|
101
|
+
export type AttestationSource = 'sentinel' | 'rv';
|
|
102
|
+
export interface AttestInput {
|
|
103
|
+
/** Which verification result to attest */
|
|
104
|
+
source: AttestationSource;
|
|
105
|
+
/** The request ID from the verification response */
|
|
106
|
+
requestId: string;
|
|
107
|
+
/** Recipient address for the attestation */
|
|
108
|
+
recipient: string;
|
|
109
|
+
}
|
|
110
|
+
export interface AttestOutput {
|
|
111
|
+
/** EAS attestation UID (for Sentinel) or TP-VC ID (for RV) */
|
|
112
|
+
attestationId: string;
|
|
113
|
+
/** Transaction hash if on-chain */
|
|
114
|
+
txHash?: string;
|
|
115
|
+
}
|
|
116
|
+
export interface StatusOutput {
|
|
117
|
+
sentinel: {
|
|
118
|
+
healthy: boolean;
|
|
119
|
+
latencyMs: number;
|
|
120
|
+
};
|
|
121
|
+
rv: {
|
|
122
|
+
healthy: boolean;
|
|
123
|
+
latencyMs: number;
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export interface ThoughtProofAdapter {
|
|
127
|
+
sentinelVerify(input: SentinelVerifyInput, signal?: AbortSignal): Promise<SentinelVerifyOutput>;
|
|
128
|
+
rvVerify(input: RVVerifyInput, signal?: AbortSignal): Promise<RVVerifyOutput>;
|
|
129
|
+
attest(input: AttestInput, signal?: AbortSignal): Promise<AttestOutput>;
|
|
130
|
+
status(signal?: AbortSignal): Promise<StatusOutput>;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,aAAa,CAAC,CAAC,IAAI,EAAE;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC,CAAC;QAC7D,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACpB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,M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AG,UAAU,GAAG,IAAI,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,MAAM,EAAE,iBAAiB,CAAC;IAC1B,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAID,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,EAAE,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAID,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAChG,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAC9E,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IACxE,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { WalletProvider } from '@goatnetwork/agentkit/core';
|
|
2
|
+
import type { SentinelVerifyOutput, RVVerifyOutput } from '../adapters/types.js';
|
|
3
|
+
export interface ReputationHookConfig {
|
|
4
|
+
/** ERC-8004 agent ID to submit feedback for */
|
|
5
|
+
agentId: string;
|
|
6
|
+
/** Whether to submit reputation feedback (default: true) */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
/** Override reputation registry addresses per network */
|
|
9
|
+
registryAddresses?: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Submit verification result as ERC-8004 reputation feedback.
|
|
13
|
+
*
|
|
14
|
+
* Tags:
|
|
15
|
+
* - tag1: "thoughtproof" (verifier identity)
|
|
16
|
+
* - tag2: "sentinel" | "rv" (verification type)
|
|
17
|
+
*
|
|
18
|
+
* Score mapping:
|
|
19
|
+
* - ALLOW → 100 (decimals=0)
|
|
20
|
+
* - UNCERTAIN → 50
|
|
21
|
+
* - BLOCK → 0
|
|
22
|
+
*/
|
|
23
|
+
export declare function submitReputationFeedback(wallet: WalletProvider, network: string, config: ReputationHookConfig, source: 'sentinel' | 'rv', result: SentinelVerifyOutput | RVVerifyOutput): Promise<{
|
|
24
|
+
txHash: string;
|
|
25
|
+
} | null>;
|
|
26
|
+
//# sourceMappingURL=reputation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reputation.d.ts","sourceRoot":"","sources":["../../src/hooks/reputation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAW,MAAM,sBAAsB,CAAC;AA8B1F,MAAM,WAAW,oBAAoB;IACnC,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yDAAyD;IACzD,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,UAAU,GAAG,IAAI,EACzB,MAAM,EAAE,oBAAoB,GAAG,cAAc,GAC5C,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAmCpC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal post-verification hook that submits ERC-8004 reputation
|
|
3
|
+
* feedback based on verification results.
|
|
4
|
+
*
|
|
5
|
+
* NOT exposed as an agent action — this runs automatically after
|
|
6
|
+
* verification to prevent agents from gaming their own reputation.
|
|
7
|
+
*
|
|
8
|
+
* Called by the plugin internally after sentinel/verify actions complete.
|
|
9
|
+
*/
|
|
10
|
+
const REPUTATION_REGISTRY_ABI = [
|
|
11
|
+
'function giveFeedback(uint256 agentId, int128 value, uint8 valueDecimals, string tag1, string tag2, string endpoint, string feedbackURI, bytes32 feedbackHash)',
|
|
12
|
+
];
|
|
13
|
+
// Default addresses — override via ReputationHookConfig.registryAddresses
|
|
14
|
+
const DEFAULT_REPUTATION_ADDRESSES = {
|
|
15
|
+
'goat-mainnet': '0x8004BAa1000000000000000000000000000000a1',
|
|
16
|
+
'goat-testnet': '0xd914000000000000000000000000000000a964',
|
|
17
|
+
};
|
|
18
|
+
function verdictToScore(verdict) {
|
|
19
|
+
switch (verdict) {
|
|
20
|
+
case 'ALLOW': return 100;
|
|
21
|
+
case 'UNCERTAIN': return 50;
|
|
22
|
+
case 'BLOCK': return 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Submit verification result as ERC-8004 reputation feedback.
|
|
27
|
+
*
|
|
28
|
+
* Tags:
|
|
29
|
+
* - tag1: "thoughtproof" (verifier identity)
|
|
30
|
+
* - tag2: "sentinel" | "rv" (verification type)
|
|
31
|
+
*
|
|
32
|
+
* Score mapping:
|
|
33
|
+
* - ALLOW → 100 (decimals=0)
|
|
34
|
+
* - UNCERTAIN → 50
|
|
35
|
+
* - BLOCK → 0
|
|
36
|
+
*/
|
|
37
|
+
export async function submitReputationFeedback(wallet, network, config, source, result) {
|
|
38
|
+
if (config.enabled === false)
|
|
39
|
+
return null;
|
|
40
|
+
const registryAddress = config.registryAddresses?.[network] ?? DEFAULT_REPUTATION_ADDRESSES[network];
|
|
41
|
+
if (!registryAddress)
|
|
42
|
+
return null;
|
|
43
|
+
const score = verdictToScore(result.verdict);
|
|
44
|
+
// Build a deterministic feedback hash from requestId
|
|
45
|
+
const encoder = new TextEncoder();
|
|
46
|
+
const data = encoder.encode(`thoughtproof:${source}:${result.requestId}`);
|
|
47
|
+
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
|
|
48
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
49
|
+
const feedbackHash = '0x' + hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
|
50
|
+
try {
|
|
51
|
+
return await wallet.writeContract(registryAddress, REPUTATION_REGISTRY_ABI, 'giveFeedback', [
|
|
52
|
+
BigInt(config.agentId),
|
|
53
|
+
score,
|
|
54
|
+
0, // decimals
|
|
55
|
+
'thoughtproof',
|
|
56
|
+
source,
|
|
57
|
+
`thoughtproof.${source}`,
|
|
58
|
+
`thoughtproof://${result.requestId}`,
|
|
59
|
+
feedbackHash,
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// Reputation submission is best-effort — don't block verification
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=reputation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reputation.js","sourceRoot":"","sources":["../../src/hooks/reputation.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,MAAM,uBAAuB,GAAG;IAC9B,gKAAgK;CACjK,CAAC;AAEF,0EAA0E;AAC1E,MAAM,4BAA4B,GAA2B;IAC3D,cAAc,EAA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C,IAAI,CAAC,EAAE,CAAC,CAAC;IAEzF,IAAI,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,aAAa,CAC/B,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd;YACE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YACtB,KAAK;YACL,CAAC,EAAE,WAAW;YACd,cAAc;YACd,MAAM;YACN,gBAAgB,MAAM,EAAE;YACxB,kBAAkB,MAAM,CAAC,SAAS,EAAE;YACpC,YAAY;SACb,CACF,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,kEAAkE;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { thoughtproofSentinelAction } from './actions/sentinel.js';
|
|
2
|
+
export { thoughtproofVerifyAction } from './actions/verify.js';
|
|
3
|
+
export { thoughtproofAttestAction } from './actions/attest.js';
|
|
4
|
+
export { thoughtproofStatusAction } from './actions/status.js';
|
|
5
|
+
export { HttpThoughtProofAdapter } from './adapters/http-thoughtproof.js';
|
|
6
|
+
export type { ThoughtProofAdapter, ThoughtProofConfig, X402Signer, Verdict, SentinelVerifyInput, SentinelVerifyOutput, RVTier, RVVerifyInput, RVVerifyOutput, AttestationSource, AttestInput, AttestOutput, StatusOutput, } from './adapters/types.js';
|
|
7
|
+
export type { ReputationHookConfig } from './hooks/reputation.js';
|
|
8
|
+
export { submitReputationFeedback } from './hooks/reputation.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,OAAO,EACP,mBAAmB,EACnB,oBAAoB,EACpB,MAAM,EACN,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// ThoughtProof Plugin for GOAT AgentKit
|
|
2
|
+
// Epistemic verification layer: Sentinel (triage) + RV (deep verification)
|
|
3
|
+
export { thoughtproofSentinelAction } from './actions/sentinel.js';
|
|
4
|
+
export { thoughtproofVerifyAction } from './actions/verify.js';
|
|
5
|
+
export { thoughtproofAttestAction } from './actions/attest.js';
|
|
6
|
+
export { thoughtproofStatusAction } from './actions/status.js';
|
|
7
|
+
export { HttpThoughtProofAdapter } from './adapters/http-thoughtproof.js';
|
|
8
|
+
export { submitReputationFeedback } from './hooks/reputation.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,2EAA2E;AAE3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAmB1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thoughtproof/goat-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "ThoughtProof verification plugin for GOAT AgentKit - epistemic verification for AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"lint": "tsc --noEmit",
|
|
25
|
+
"clean": "rm -rf dist",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@goatnetwork/agentkit": "^0.2.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@goatnetwork/agentkit": "^0.2.0",
|
|
33
|
+
"typescript": "^5.9.2",
|
|
34
|
+
"vitest": "^3.2.4",
|
|
35
|
+
"zod": "^3.24.2"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"zod": "^3.24.2"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"goat",
|
|
42
|
+
"agentkit",
|
|
43
|
+
"thoughtproof",
|
|
44
|
+
"verification",
|
|
45
|
+
"ai-agents",
|
|
46
|
+
"epistemic",
|
|
47
|
+
"reasoning"
|
|
48
|
+
],
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/thoughtproof/goat-plugin"
|
|
52
|
+
},
|
|
53
|
+
"license": "MIT"
|
|
54
|
+
}
|