@weave_protocol/domere 1.0.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/PLANNING.md +231 -0
- package/README.md +50 -0
- package/dist/anchoring/ethereum.d.ts +135 -0
- package/dist/anchoring/ethereum.d.ts.map +1 -0
- package/dist/anchoring/ethereum.js +474 -0
- package/dist/anchoring/ethereum.js.map +1 -0
- package/dist/anchoring/index.d.ts +93 -0
- package/dist/anchoring/index.d.ts.map +1 -0
- package/dist/anchoring/index.js +184 -0
- package/dist/anchoring/index.js.map +1 -0
- package/dist/anchoring/merkle.d.ts +91 -0
- package/dist/anchoring/merkle.d.ts.map +1 -0
- package/dist/anchoring/merkle.js +203 -0
- package/dist/anchoring/merkle.js.map +1 -0
- package/dist/anchoring/solana.d.ts +85 -0
- package/dist/anchoring/solana.d.ts.map +1 -0
- package/dist/anchoring/solana.js +301 -0
- package/dist/anchoring/solana.js.map +1 -0
- package/dist/constants.d.ts +130 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +536 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/language/code-analyzer.d.ts +80 -0
- package/dist/language/code-analyzer.d.ts.map +1 -0
- package/dist/language/code-analyzer.js +489 -0
- package/dist/language/code-analyzer.js.map +1 -0
- package/dist/language/detector.d.ts +53 -0
- package/dist/language/detector.d.ts.map +1 -0
- package/dist/language/detector.js +248 -0
- package/dist/language/detector.js.map +1 -0
- package/dist/language/index.d.ts +61 -0
- package/dist/language/index.d.ts.map +1 -0
- package/dist/language/index.js +109 -0
- package/dist/language/index.js.map +1 -0
- package/dist/language/nl-analyzer.d.ts +59 -0
- package/dist/language/nl-analyzer.d.ts.map +1 -0
- package/dist/language/nl-analyzer.js +350 -0
- package/dist/language/nl-analyzer.js.map +1 -0
- package/dist/language/semantic.d.ts +48 -0
- package/dist/language/semantic.d.ts.map +1 -0
- package/dist/language/semantic.js +329 -0
- package/dist/language/semantic.js.map +1 -0
- package/dist/storage/index.d.ts +6 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +6 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/memory.d.ts +48 -0
- package/dist/storage/memory.d.ts.map +1 -0
- package/dist/storage/memory.js +211 -0
- package/dist/storage/memory.js.map +1 -0
- package/dist/thread/drift.d.ts +43 -0
- package/dist/thread/drift.d.ts.map +1 -0
- package/dist/thread/drift.js +248 -0
- package/dist/thread/drift.js.map +1 -0
- package/dist/thread/index.d.ts +9 -0
- package/dist/thread/index.d.ts.map +1 -0
- package/dist/thread/index.js +9 -0
- package/dist/thread/index.js.map +1 -0
- package/dist/thread/intent.d.ts +68 -0
- package/dist/thread/intent.d.ts.map +1 -0
- package/dist/thread/intent.js +333 -0
- package/dist/thread/intent.js.map +1 -0
- package/dist/thread/manager.d.ts +85 -0
- package/dist/thread/manager.d.ts.map +1 -0
- package/dist/thread/manager.js +305 -0
- package/dist/thread/manager.js.map +1 -0
- package/dist/thread/weave.d.ts +61 -0
- package/dist/thread/weave.d.ts.map +1 -0
- package/dist/thread/weave.js +158 -0
- package/dist/thread/weave.js.map +1 -0
- package/dist/tools/index.d.ts +18 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +102 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types.d.ts +466 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +48 -0
- package/dist/types.js.map +1 -0
- package/package.json +24 -0
- package/src/anchoring/ethereum.ts +568 -0
- package/src/anchoring/index.ts +236 -0
- package/src/anchoring/merkle.ts +256 -0
- package/src/anchoring/solana.ts +370 -0
- package/src/constants.ts +566 -0
- package/src/index.ts +43 -0
- package/src/language/code-analyzer.ts +564 -0
- package/src/language/detector.ts +297 -0
- package/src/language/index.ts +129 -0
- package/src/language/nl-analyzer.ts +411 -0
- package/src/language/semantic.ts +385 -0
- package/src/storage/index.ts +6 -0
- package/src/storage/memory.ts +271 -0
- package/src/thread/drift.ts +319 -0
- package/src/thread/index.ts +9 -0
- package/src/thread/intent.ts +409 -0
- package/src/thread/manager.ts +414 -0
- package/src/thread/weave.ts +205 -0
- package/src/tools/index.ts +107 -0
- package/src/types.ts +736 -0
- package/tsconfig.json +19 -0
package/PLANNING.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Dōmere: The Judge Protocol
|
|
2
|
+
|
|
3
|
+
## Executive Summary
|
|
4
|
+
|
|
5
|
+
**Dōmere** (Old English for "judge, arbiter") is the verification and anchoring layer for AI agent security. While Mund watches and Hord contains, Dōmere verifies the weave of intent through agent chains and anchors proof immutably to blockchain.
|
|
6
|
+
|
|
7
|
+
## Core Philosophy: Weave-First Security
|
|
8
|
+
|
|
9
|
+
Traditional identity systems ask "who is this agent?" - a point-in-time question.
|
|
10
|
+
|
|
11
|
+
Dōmere asks "what is the thread of intent, how does it weave through agents, and does that pattern comply?" - a continuous verification question.
|
|
12
|
+
|
|
13
|
+
**The weave matters more than the identity.**
|
|
14
|
+
|
|
15
|
+
## Core Concepts
|
|
16
|
+
|
|
17
|
+
### Thread Identity
|
|
18
|
+
|
|
19
|
+
A thread represents the complete lifecycle of a human intent as it propagates through multiple AI agents:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Human Intent → Agent A → Agent B → Agent C → Result
|
|
23
|
+
↓ ↓ ↓ ↓ ↓
|
|
24
|
+
[origin] [hop 1] [hop 2] [hop 3] [complete]
|
|
25
|
+
└────────────────────┬────────────────────┘
|
|
26
|
+
Thread Identity
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Each thread has:
|
|
30
|
+
- **Origin**: Where did this start? (human, system, scheduled)
|
|
31
|
+
- **Intent**: What was requested? What constraints apply?
|
|
32
|
+
- **Hops**: Each agent interaction with full context
|
|
33
|
+
- **Weave Signature**: Rolling cryptographic proof of the entire chain
|
|
34
|
+
|
|
35
|
+
### Intent Drift
|
|
36
|
+
|
|
37
|
+
As intent passes through agents, it can "drift" - each agent may reinterpret slightly. Dōmere detects when drift exceeds acceptable bounds:
|
|
38
|
+
|
|
39
|
+
- Semantic similarity (embedding comparison)
|
|
40
|
+
- Action alignment (are actions consistent with original intent)
|
|
41
|
+
- Scope creep (has scope expanded beyond original request)
|
|
42
|
+
- Constraint violations (explicit constraints broken)
|
|
43
|
+
|
|
44
|
+
### Language Analysis
|
|
45
|
+
|
|
46
|
+
Understanding what agents are processing is critical:
|
|
47
|
+
|
|
48
|
+
- **Language Detection**: Is this English? Python? SQL? JSON?
|
|
49
|
+
- **Semantic Analysis**: What does this content mean? What entities are referenced?
|
|
50
|
+
- **Code Analysis**: What does this code do? Is it dangerous?
|
|
51
|
+
- **NL Analysis**: Is there manipulation? Hidden instructions?
|
|
52
|
+
|
|
53
|
+
### Blockchain Anchoring
|
|
54
|
+
|
|
55
|
+
Local proofs are useful but can be modified. Blockchain anchoring provides:
|
|
56
|
+
|
|
57
|
+
- **Immutability**: Cannot be changed by anyone
|
|
58
|
+
- **Third-party Verification**: Anyone can verify
|
|
59
|
+
- **Legal Standing**: Timestamped, cryptographic proof
|
|
60
|
+
- **Audit Trail**: Permanent record
|
|
61
|
+
|
|
62
|
+
## Architecture
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
66
|
+
│ DŌMERE │
|
|
67
|
+
│ │
|
|
68
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
69
|
+
│ │ THREAD MANAGER │ │
|
|
70
|
+
│ │ │ │
|
|
71
|
+
│ │ • Create/manage thread lifecycle │ │
|
|
72
|
+
│ │ • Track hops through agent chain │ │
|
|
73
|
+
│ │ • Compute weave signatures │ │
|
|
74
|
+
│ │ • Detect intent drift │ │
|
|
75
|
+
│ └─────────────────────────────────────────────────────────────────────┘ │
|
|
76
|
+
│ │ │
|
|
77
|
+
│ ┌──────────────────────────┼──────────────────────────┐ │
|
|
78
|
+
│ ▼ ▼ ▼ │
|
|
79
|
+
│ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
|
|
80
|
+
│ │ LANGUAGE │ │ COMPLIANCE │ │ ARBITRATION │ │
|
|
81
|
+
│ │ ANALYZER │ │ ENGINE │ │ ENGINE │ │
|
|
82
|
+
│ │ │ │ │ │ │ │
|
|
83
|
+
│ │ • Detection │ │ • Policy eval │ │ • Case mgmt │ │
|
|
84
|
+
│ │ • Semantics │ │ • ZK proofs │ │ • Resolution │ │
|
|
85
|
+
│ │ • Code analysis │ │ • Violations │ │ • Precedent │ │
|
|
86
|
+
│ │ • NL analysis │ │ │ │ │ │
|
|
87
|
+
│ └─────────────────┘ └─────────────────┘ └─────────────────┘ │
|
|
88
|
+
│ │ │
|
|
89
|
+
│ ▼ │
|
|
90
|
+
│ ┌─────────────────────────────────────────────────────────────────────┐ │
|
|
91
|
+
│ │ ANCHORING CLIENT │ │
|
|
92
|
+
│ │ │ │
|
|
93
|
+
│ │ • Solana (real-time, cheap) │ │
|
|
94
|
+
│ │ • Ethereum (settlement, authoritative) │ │
|
|
95
|
+
│ │ • Merkle tree generation │ │
|
|
96
|
+
│ │ • Verification │ │
|
|
97
|
+
│ └─────────────────────────────────────────────────────────────────────┘ │
|
|
98
|
+
│ │
|
|
99
|
+
└─────────────────────────────────────────────────────────────────────────────┘
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## MCP Tools
|
|
103
|
+
|
|
104
|
+
### Thread Management
|
|
105
|
+
| Tool | Description |
|
|
106
|
+
|------|-------------|
|
|
107
|
+
| `domere_create_thread` | Initialize thread from human intent |
|
|
108
|
+
| `domere_add_hop` | Record agent hop in thread |
|
|
109
|
+
| `domere_verify_thread` | Verify thread integrity |
|
|
110
|
+
| `domere_get_thread` | Retrieve thread details |
|
|
111
|
+
| `domere_close_thread` | Mark thread complete |
|
|
112
|
+
| `domere_list_threads` | List active/recent threads |
|
|
113
|
+
|
|
114
|
+
### Language Analysis
|
|
115
|
+
| Tool | Description |
|
|
116
|
+
|------|-------------|
|
|
117
|
+
| `domere_detect_language` | Detect language/code type |
|
|
118
|
+
| `domere_analyze_content` | Full semantic analysis |
|
|
119
|
+
| `domere_analyze_code` | Code-specific analysis |
|
|
120
|
+
| `domere_check_injection` | Detect prompt injection |
|
|
121
|
+
| `domere_extract_entities` | Extract entities from content |
|
|
122
|
+
|
|
123
|
+
### Intent & Drift
|
|
124
|
+
| Tool | Description |
|
|
125
|
+
|------|-------------|
|
|
126
|
+
| `domere_analyze_intent` | Deep analysis of stated intent |
|
|
127
|
+
| `domere_check_drift` | Check intent drift at current hop |
|
|
128
|
+
| `domere_compare_intents` | Compare two intent statements |
|
|
129
|
+
|
|
130
|
+
### Compliance
|
|
131
|
+
| Tool | Description |
|
|
132
|
+
|------|-------------|
|
|
133
|
+
| `domere_check_policy` | Check thread against policy |
|
|
134
|
+
| `domere_generate_proof` | Generate compliance proof |
|
|
135
|
+
| `domere_list_violations` | List policy violations |
|
|
136
|
+
|
|
137
|
+
### Anchoring
|
|
138
|
+
| Tool | Description |
|
|
139
|
+
|------|-------------|
|
|
140
|
+
| `domere_anchor_solana` | Anchor to Solana |
|
|
141
|
+
| `domere_anchor_ethereum` | Anchor to Ethereum |
|
|
142
|
+
| `domere_verify_anchor` | Verify on-chain anchor |
|
|
143
|
+
| `domere_get_anchor_status` | Check anchoring status |
|
|
144
|
+
|
|
145
|
+
### Arbitration
|
|
146
|
+
| Tool | Description |
|
|
147
|
+
|------|-------------|
|
|
148
|
+
| `domere_open_dispute` | Open arbitration case |
|
|
149
|
+
| `domere_submit_evidence` | Add evidence to case |
|
|
150
|
+
| `domere_resolve_dispute` | Resolve dispute |
|
|
151
|
+
|
|
152
|
+
## Pricing Model
|
|
153
|
+
|
|
154
|
+
### Free (100% Open Source)
|
|
155
|
+
- All language analysis
|
|
156
|
+
- All thread management
|
|
157
|
+
- All compliance checking
|
|
158
|
+
- All proof generation
|
|
159
|
+
- All MCP tools
|
|
160
|
+
- All local operations
|
|
161
|
+
|
|
162
|
+
### Paid (Blockchain Network Fees + Protocol Fee)
|
|
163
|
+
- Solana anchoring: ~$0.001 per anchor
|
|
164
|
+
- Ethereum anchoring: ~$2-10 per anchor
|
|
165
|
+
- Protocol fee: 5% of gas cost
|
|
166
|
+
|
|
167
|
+
## Technology Stack
|
|
168
|
+
|
|
169
|
+
- **Runtime**: Node.js 20+
|
|
170
|
+
- **Language**: TypeScript
|
|
171
|
+
- **Protocol**: MCP (Model Context Protocol)
|
|
172
|
+
- **Blockchain**: Solana (Anchor framework), Ethereum (Solidity)
|
|
173
|
+
- **Crypto**: Native Node.js crypto, ethers.js, @solana/web3.js
|
|
174
|
+
|
|
175
|
+
## Directory Structure
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
domere/
|
|
179
|
+
├── src/
|
|
180
|
+
│ ├── index.ts # MCP server entry
|
|
181
|
+
│ ├── types.ts # Type definitions
|
|
182
|
+
│ ├── constants.ts # Configuration
|
|
183
|
+
│ │
|
|
184
|
+
│ ├── thread/ # Thread identity
|
|
185
|
+
│ │ ├── index.ts
|
|
186
|
+
│ │ ├── manager.ts
|
|
187
|
+
│ │ ├── intent.ts
|
|
188
|
+
│ │ ├── drift.ts
|
|
189
|
+
│ │ └── weave.ts
|
|
190
|
+
│ │
|
|
191
|
+
│ ├── language/ # Language analysis
|
|
192
|
+
│ │ ├── index.ts
|
|
193
|
+
│ │ ├── detector.ts
|
|
194
|
+
│ │ ├── semantic.ts
|
|
195
|
+
│ │ ├── code-analyzer.ts
|
|
196
|
+
│ │ └── nl-analyzer.ts
|
|
197
|
+
│ │
|
|
198
|
+
│ ├── compliance/ # Compliance engine
|
|
199
|
+
│ │ ├── index.ts
|
|
200
|
+
│ │ ├── engine.ts
|
|
201
|
+
│ │ ├── proof.ts
|
|
202
|
+
│ │ └── policies/
|
|
203
|
+
│ │
|
|
204
|
+
│ ├── arbitration/ # Arbitration
|
|
205
|
+
│ │ ├── index.ts
|
|
206
|
+
│ │ ├── case-manager.ts
|
|
207
|
+
│ │ └── resolution.ts
|
|
208
|
+
│ │
|
|
209
|
+
│ ├── anchoring/ # Blockchain
|
|
210
|
+
│ │ ├── index.ts
|
|
211
|
+
│ │ ├── merkle.ts
|
|
212
|
+
│ │ ├── solana.ts
|
|
213
|
+
│ │ └── ethereum.ts
|
|
214
|
+
│ │
|
|
215
|
+
│ ├── tools/ # MCP tools
|
|
216
|
+
│ │ └── index.ts
|
|
217
|
+
│ │
|
|
218
|
+
│ └── storage/ # Persistence
|
|
219
|
+
│ ├── index.ts
|
|
220
|
+
│ └── memory.ts
|
|
221
|
+
│
|
|
222
|
+
├── package.json
|
|
223
|
+
├── tsconfig.json
|
|
224
|
+
└── README.md
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT - Free to use, modify, distribute. Forever.
|
|
230
|
+
|
|
231
|
+
Blockchain anchoring uses deployed contracts with protocol fees that fund development.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Dōmere - The Judge Protocol
|
|
2
|
+
|
|
3
|
+
**Thread Identity, Intent Verification & Blockchain Anchoring for AI Agents**
|
|
4
|
+
|
|
5
|
+
Part of the [Weave Security Suite](../README.md) (Mund + Hord + Dōmere)
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
When AI agents chain together—Agent A calls Agent B calls Agent C—how do you know the final action matches the human's original intent? Protocols like MCP and A2A standardize how agents **communicate**. Dōmere ensures they **execute honestly**.
|
|
10
|
+
|
|
11
|
+
## Core Concepts
|
|
12
|
+
|
|
13
|
+
### Thread Identity
|
|
14
|
+
Track intent from origin through every hop with cryptographic signatures.
|
|
15
|
+
|
|
16
|
+
### Intent Drift Detection
|
|
17
|
+
Detect when agents reinterpret, expand, or violate the original intent.
|
|
18
|
+
|
|
19
|
+
### Blockchain Anchoring
|
|
20
|
+
Immutable proof on Solana (~$0.001) or Ethereum (~$2-10).
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// Create thread
|
|
26
|
+
const thread = await domere.createThread({
|
|
27
|
+
origin: { type: 'human', identity: 'user_jane' },
|
|
28
|
+
intent: 'Get Q3 sales summary',
|
|
29
|
+
constraints: ['read-only']
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Add hop
|
|
33
|
+
const hop = await domere.addHop({
|
|
34
|
+
thread_id: thread.id,
|
|
35
|
+
agent: { id: 'data_agent', type: 'claude' },
|
|
36
|
+
received_intent: 'Query Q3 sales data',
|
|
37
|
+
actions: [{ type: 'query', target: 'sales_db' }]
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Check: hop.intent_drift.verdict === 'aligned'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Business Model
|
|
44
|
+
|
|
45
|
+
**Free:** All analysis, threading, drift detection, MCP tools
|
|
46
|
+
**Paid:** Blockchain anchoring only (you bring your wallet)
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
MIT
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dōmere - The Judge Protocol
|
|
3
|
+
* Ethereum Anchoring Client
|
|
4
|
+
*
|
|
5
|
+
* Note: This is the client interface. The actual Ethereum contract
|
|
6
|
+
* should be deployed separately.
|
|
7
|
+
*/
|
|
8
|
+
import type { AnchorRequest, AnchorResult, AnchorVerification } from '../types.js';
|
|
9
|
+
export interface EthereumConfig {
|
|
10
|
+
rpc_url: string;
|
|
11
|
+
contract_address: string;
|
|
12
|
+
chain_id?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface EthereumAnchorData {
|
|
15
|
+
threadId: string;
|
|
16
|
+
merkleRoot: string;
|
|
17
|
+
hopCount: number;
|
|
18
|
+
intentHash: string;
|
|
19
|
+
compliant: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class EthereumAnchorClient {
|
|
22
|
+
private config;
|
|
23
|
+
private isTestnet;
|
|
24
|
+
constructor(config?: Partial<EthereumConfig>);
|
|
25
|
+
/**
|
|
26
|
+
* Prepare anchor data for Ethereum
|
|
27
|
+
*/
|
|
28
|
+
prepareAnchorData(request: AnchorRequest): EthereumAnchorData;
|
|
29
|
+
/**
|
|
30
|
+
* Estimate gas cost
|
|
31
|
+
*/
|
|
32
|
+
estimateGas(): Promise<{
|
|
33
|
+
gas_limit: number;
|
|
34
|
+
gas_price_gwei: number;
|
|
35
|
+
estimated_eth: string;
|
|
36
|
+
protocol_fee_eth: string;
|
|
37
|
+
total_eth: string;
|
|
38
|
+
usd_estimate?: string;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Create anchor transaction
|
|
42
|
+
*
|
|
43
|
+
* Returns unsigned transaction data for client-side signing.
|
|
44
|
+
*/
|
|
45
|
+
createAnchorTransaction(request: AnchorRequest): Promise<{
|
|
46
|
+
to: string;
|
|
47
|
+
data: string;
|
|
48
|
+
value: string;
|
|
49
|
+
gas_limit: number;
|
|
50
|
+
chain_id: number;
|
|
51
|
+
estimated_cost: any;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Submit signed transaction
|
|
55
|
+
*/
|
|
56
|
+
submitSignedTransaction(signedTransaction: string): Promise<AnchorResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Verify anchor on-chain
|
|
59
|
+
*/
|
|
60
|
+
verifyAnchor(threadId: string, expectedMerkleRoot: string): Promise<AnchorVerification>;
|
|
61
|
+
/**
|
|
62
|
+
* Create batch certification transaction
|
|
63
|
+
*/
|
|
64
|
+
createCertificationTransaction(config: {
|
|
65
|
+
period_id: string;
|
|
66
|
+
merkle_root: string;
|
|
67
|
+
attestation_count: number;
|
|
68
|
+
violation_count: number;
|
|
69
|
+
period_start: Date;
|
|
70
|
+
period_end: Date;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
to: string;
|
|
73
|
+
data: string;
|
|
74
|
+
estimated_cost: any;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Get explorer URL
|
|
78
|
+
*/
|
|
79
|
+
getExplorerUrl(txHash: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Get contract address
|
|
82
|
+
*/
|
|
83
|
+
getContractAddress(): string;
|
|
84
|
+
/**
|
|
85
|
+
* Convert string to bytes32 hex
|
|
86
|
+
*/
|
|
87
|
+
private stringToBytes32;
|
|
88
|
+
/**
|
|
89
|
+
* Ensure value is bytes32 format
|
|
90
|
+
*/
|
|
91
|
+
private ensureBytes32;
|
|
92
|
+
/**
|
|
93
|
+
* Encode bytes32 for ABI
|
|
94
|
+
*/
|
|
95
|
+
private encodeBytes32;
|
|
96
|
+
/**
|
|
97
|
+
* Encode uint256 for ABI
|
|
98
|
+
*/
|
|
99
|
+
private encodeUint256;
|
|
100
|
+
/**
|
|
101
|
+
* Encode bool for ABI
|
|
102
|
+
*/
|
|
103
|
+
private encodeBool;
|
|
104
|
+
/**
|
|
105
|
+
* Simple keccak256 (placeholder - use ethers.js in production)
|
|
106
|
+
*/
|
|
107
|
+
private keccak256;
|
|
108
|
+
}
|
|
109
|
+
export declare const ETHEREUM_CONTRACT_ABI: ({
|
|
110
|
+
inputs: {
|
|
111
|
+
name: string;
|
|
112
|
+
type: string;
|
|
113
|
+
}[];
|
|
114
|
+
name: string;
|
|
115
|
+
outputs: {
|
|
116
|
+
name: string;
|
|
117
|
+
type: string;
|
|
118
|
+
}[];
|
|
119
|
+
stateMutability: string;
|
|
120
|
+
type: string;
|
|
121
|
+
anonymous?: undefined;
|
|
122
|
+
} | {
|
|
123
|
+
anonymous: boolean;
|
|
124
|
+
inputs: {
|
|
125
|
+
indexed: boolean;
|
|
126
|
+
name: string;
|
|
127
|
+
type: string;
|
|
128
|
+
}[];
|
|
129
|
+
name: string;
|
|
130
|
+
type: string;
|
|
131
|
+
outputs?: undefined;
|
|
132
|
+
stateMutability?: undefined;
|
|
133
|
+
})[];
|
|
134
|
+
export declare const ETHEREUM_CONTRACT_SOURCE = "\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\n/**\n * @title DomereProtocol\n * @dev Thread anchoring and compliance certification for AI agent security\n */\ncontract DomereProtocol {\n \n // Protocol fee (5% of gas, calculated off-chain and sent as msg.value)\n uint256 public protocolFeeBps = 500;\n address public treasury;\n address public owner;\n \n struct ThreadAnchor {\n bytes32 merkleRoot;\n uint256 hopCount;\n bytes32 intentHash;\n bool compliant;\n uint256 timestamp;\n address anchorer;\n }\n \n struct CompliancePeriod {\n bytes32 merkleRoot;\n uint256 attestationCount;\n uint256 violationCount;\n uint256 periodStart;\n uint256 periodEnd;\n uint256 timestamp;\n bool certified;\n }\n \n mapping(bytes32 => ThreadAnchor) public anchors;\n mapping(bytes32 => CompliancePeriod) public periods;\n mapping(address => bool) public authorizedAnchors;\n \n event ThreadAnchored(\n bytes32 indexed threadId,\n bytes32 merkleRoot,\n address anchorer,\n uint256 timestamp\n );\n \n event PeriodCertified(\n bytes32 indexed periodId,\n bytes32 merkleRoot,\n uint256 attestationCount,\n uint256 timestamp\n );\n \n modifier onlyOwner() {\n require(msg.sender == owner, \"Not owner\");\n _;\n }\n \n constructor(address _treasury) {\n owner = msg.sender;\n treasury = _treasury;\n authorizedAnchors[msg.sender] = true;\n }\n \n /**\n * @dev Anchor a thread to the blockchain\n */\n function anchorThread(\n bytes32 threadId,\n bytes32 merkleRoot,\n uint256 hopCount,\n bytes32 intentHash,\n bool compliant\n ) external payable {\n require(anchors[threadId].timestamp == 0, \"Thread already anchored\");\n \n // Store anchor\n anchors[threadId] = ThreadAnchor({\n merkleRoot: merkleRoot,\n hopCount: hopCount,\n intentHash: intentHash,\n compliant: compliant,\n timestamp: block.timestamp,\n anchorer: msg.sender\n });\n \n // Transfer protocol fee to treasury\n if (msg.value > 0) {\n payable(treasury).transfer(msg.value);\n }\n \n emit ThreadAnchored(threadId, merkleRoot, msg.sender, block.timestamp);\n }\n \n /**\n * @dev Certify a compliance period\n */\n function certifyPeriod(\n bytes32 periodId,\n bytes32 merkleRoot,\n uint256 attestationCount,\n uint256 violationCount,\n uint256 periodStart,\n uint256 periodEnd\n ) external payable {\n require(authorizedAnchors[msg.sender], \"Not authorized\");\n \n periods[periodId] = CompliancePeriod({\n merkleRoot: merkleRoot,\n attestationCount: attestationCount,\n violationCount: violationCount,\n periodStart: periodStart,\n periodEnd: periodEnd,\n timestamp: block.timestamp,\n certified: true\n });\n \n if (msg.value > 0) {\n payable(treasury).transfer(msg.value);\n }\n \n emit PeriodCertified(periodId, merkleRoot, attestationCount, block.timestamp);\n }\n \n /**\n * @dev Verify a thread anchor\n */\n function verifyAnchor(\n bytes32 threadId,\n bytes32 expectedMerkleRoot\n ) external view returns (bool valid, uint256 timestamp) {\n ThreadAnchor memory anchor = anchors[threadId];\n return (\n anchor.merkleRoot == expectedMerkleRoot && anchor.timestamp > 0,\n anchor.timestamp\n );\n }\n \n /**\n * @dev Verify an attestation using Merkle proof\n */\n function verifyAttestation(\n bytes32 threadId,\n bytes32 attestationHash,\n bytes32[] calldata merkleProof\n ) external view returns (bool) {\n ThreadAnchor memory anchor = anchors[threadId];\n require(anchor.timestamp > 0, \"Thread not anchored\");\n \n bytes32 computedHash = attestationHash;\n for (uint256 i = 0; i < merkleProof.length; i++) {\n bytes32 proofElement = merkleProof[i];\n if (computedHash <= proofElement) {\n computedHash = keccak256(abi.encodePacked(computedHash, proofElement));\n } else {\n computedHash = keccak256(abi.encodePacked(proofElement, computedHash));\n }\n }\n \n return computedHash == anchor.merkleRoot;\n }\n \n /**\n * @dev Authorize an address to certify periods\n */\n function authorizeAnchor(address addr) external onlyOwner {\n authorizedAnchors[addr] = true;\n }\n \n /**\n * @dev Revoke authorization\n */\n function revokeAuthorization(address addr) external onlyOwner {\n authorizedAnchors[addr] = false;\n }\n \n /**\n * @dev Update treasury address\n */\n function setTreasury(address _treasury) external onlyOwner {\n treasury = _treasury;\n }\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