@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.
Files changed (104) hide show
  1. package/PLANNING.md +231 -0
  2. package/README.md +50 -0
  3. package/dist/anchoring/ethereum.d.ts +135 -0
  4. package/dist/anchoring/ethereum.d.ts.map +1 -0
  5. package/dist/anchoring/ethereum.js +474 -0
  6. package/dist/anchoring/ethereum.js.map +1 -0
  7. package/dist/anchoring/index.d.ts +93 -0
  8. package/dist/anchoring/index.d.ts.map +1 -0
  9. package/dist/anchoring/index.js +184 -0
  10. package/dist/anchoring/index.js.map +1 -0
  11. package/dist/anchoring/merkle.d.ts +91 -0
  12. package/dist/anchoring/merkle.d.ts.map +1 -0
  13. package/dist/anchoring/merkle.js +203 -0
  14. package/dist/anchoring/merkle.js.map +1 -0
  15. package/dist/anchoring/solana.d.ts +85 -0
  16. package/dist/anchoring/solana.d.ts.map +1 -0
  17. package/dist/anchoring/solana.js +301 -0
  18. package/dist/anchoring/solana.js.map +1 -0
  19. package/dist/constants.d.ts +130 -0
  20. package/dist/constants.d.ts.map +1 -0
  21. package/dist/constants.js +536 -0
  22. package/dist/constants.js.map +1 -0
  23. package/dist/index.d.ts +13 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +37 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/language/code-analyzer.d.ts +80 -0
  28. package/dist/language/code-analyzer.d.ts.map +1 -0
  29. package/dist/language/code-analyzer.js +489 -0
  30. package/dist/language/code-analyzer.js.map +1 -0
  31. package/dist/language/detector.d.ts +53 -0
  32. package/dist/language/detector.d.ts.map +1 -0
  33. package/dist/language/detector.js +248 -0
  34. package/dist/language/detector.js.map +1 -0
  35. package/dist/language/index.d.ts +61 -0
  36. package/dist/language/index.d.ts.map +1 -0
  37. package/dist/language/index.js +109 -0
  38. package/dist/language/index.js.map +1 -0
  39. package/dist/language/nl-analyzer.d.ts +59 -0
  40. package/dist/language/nl-analyzer.d.ts.map +1 -0
  41. package/dist/language/nl-analyzer.js +350 -0
  42. package/dist/language/nl-analyzer.js.map +1 -0
  43. package/dist/language/semantic.d.ts +48 -0
  44. package/dist/language/semantic.d.ts.map +1 -0
  45. package/dist/language/semantic.js +329 -0
  46. package/dist/language/semantic.js.map +1 -0
  47. package/dist/storage/index.d.ts +6 -0
  48. package/dist/storage/index.d.ts.map +1 -0
  49. package/dist/storage/index.js +6 -0
  50. package/dist/storage/index.js.map +1 -0
  51. package/dist/storage/memory.d.ts +48 -0
  52. package/dist/storage/memory.d.ts.map +1 -0
  53. package/dist/storage/memory.js +211 -0
  54. package/dist/storage/memory.js.map +1 -0
  55. package/dist/thread/drift.d.ts +43 -0
  56. package/dist/thread/drift.d.ts.map +1 -0
  57. package/dist/thread/drift.js +248 -0
  58. package/dist/thread/drift.js.map +1 -0
  59. package/dist/thread/index.d.ts +9 -0
  60. package/dist/thread/index.d.ts.map +1 -0
  61. package/dist/thread/index.js +9 -0
  62. package/dist/thread/index.js.map +1 -0
  63. package/dist/thread/intent.d.ts +68 -0
  64. package/dist/thread/intent.d.ts.map +1 -0
  65. package/dist/thread/intent.js +333 -0
  66. package/dist/thread/intent.js.map +1 -0
  67. package/dist/thread/manager.d.ts +85 -0
  68. package/dist/thread/manager.d.ts.map +1 -0
  69. package/dist/thread/manager.js +305 -0
  70. package/dist/thread/manager.js.map +1 -0
  71. package/dist/thread/weave.d.ts +61 -0
  72. package/dist/thread/weave.d.ts.map +1 -0
  73. package/dist/thread/weave.js +158 -0
  74. package/dist/thread/weave.js.map +1 -0
  75. package/dist/tools/index.d.ts +18 -0
  76. package/dist/tools/index.d.ts.map +1 -0
  77. package/dist/tools/index.js +102 -0
  78. package/dist/tools/index.js.map +1 -0
  79. package/dist/types.d.ts +466 -0
  80. package/dist/types.d.ts.map +1 -0
  81. package/dist/types.js +48 -0
  82. package/dist/types.js.map +1 -0
  83. package/package.json +24 -0
  84. package/src/anchoring/ethereum.ts +568 -0
  85. package/src/anchoring/index.ts +236 -0
  86. package/src/anchoring/merkle.ts +256 -0
  87. package/src/anchoring/solana.ts +370 -0
  88. package/src/constants.ts +566 -0
  89. package/src/index.ts +43 -0
  90. package/src/language/code-analyzer.ts +564 -0
  91. package/src/language/detector.ts +297 -0
  92. package/src/language/index.ts +129 -0
  93. package/src/language/nl-analyzer.ts +411 -0
  94. package/src/language/semantic.ts +385 -0
  95. package/src/storage/index.ts +6 -0
  96. package/src/storage/memory.ts +271 -0
  97. package/src/thread/drift.ts +319 -0
  98. package/src/thread/index.ts +9 -0
  99. package/src/thread/intent.ts +409 -0
  100. package/src/thread/manager.ts +414 -0
  101. package/src/thread/weave.ts +205 -0
  102. package/src/tools/index.ts +107 -0
  103. package/src/types.ts +736 -0
  104. package/tsconfig.json +19 -0
package/src/types.ts ADDED
@@ -0,0 +1,736 @@
1
+ /**
2
+ * Dōmere - The Judge Protocol
3
+ * Type Definitions
4
+ */
5
+
6
+ // ============================================================================
7
+ // Thread Identity Types
8
+ // ============================================================================
9
+
10
+ export interface Thread {
11
+ id: string;
12
+
13
+ origin: ThreadOrigin;
14
+ intent: ThreadIntent;
15
+ hops: ThreadHop[];
16
+
17
+ weave_signature: string; // Rolling signature of entire thread
18
+ merkle_root?: string; // Merkle root of all hops
19
+
20
+ status: ThreadStatus;
21
+ created_at: Date;
22
+ updated_at: Date;
23
+ closed_at?: Date;
24
+
25
+ metadata: Record<string, unknown>;
26
+ }
27
+
28
+ export type ThreadStatus =
29
+ | 'active' // Thread is in progress
30
+ | 'complete' // Successfully completed
31
+ | 'violated' // Policy violation detected
32
+ | 'disputed' // Under arbitration
33
+ | 'abandoned'; // Timed out or abandoned
34
+
35
+ export interface ThreadOrigin {
36
+ type: 'human' | 'system' | 'scheduled' | 'delegated';
37
+ identity: string; // User ID, system ID, cron reference, or parent thread
38
+ verification?: VerificationInfo;
39
+ timestamp: Date;
40
+ context?: Record<string, unknown>;
41
+ }
42
+
43
+ export interface VerificationInfo {
44
+ method: 'sso' | 'oauth' | 'api_key' | 'certificate' | 'spiffe' | 'none';
45
+ provider?: string;
46
+ verified: boolean;
47
+ verified_at?: Date;
48
+ claims?: Record<string, unknown>;
49
+ }
50
+
51
+ export interface ThreadIntent {
52
+ raw: string; // Original request text
53
+ hash: string; // Cryptographic hash of intent
54
+ normalized?: string; // Normalized/cleaned version
55
+
56
+ classification: IntentClassification;
57
+ constraints: string[]; // What it should NOT do
58
+
59
+ entities: ExtractedEntity[]; // Entities mentioned
60
+ actions_implied: string[]; // What the intent implies will happen
61
+
62
+ language_analysis?: LanguageAnalysis;
63
+ }
64
+
65
+ export type IntentClassification =
66
+ | 'query' // Read/fetch data
67
+ | 'mutation' // Create/update data
68
+ | 'deletion' // Delete data
69
+ | 'execution' // Run code/command
70
+ | 'communication' // Send message/email
71
+ | 'analysis' // Analyze/summarize
72
+ | 'generation' // Create content
73
+ | 'unknown';
74
+
75
+ export interface ThreadHop {
76
+ sequence: number;
77
+ hop_id: string;
78
+
79
+ agent: AgentInfo;
80
+
81
+ // Intent verification
82
+ received_intent: string;
83
+ received_intent_hash: string;
84
+ intent_preserved: boolean;
85
+ intent_drift: DriftAnalysis;
86
+
87
+ // Actions
88
+ actions: HopAction[];
89
+
90
+ // Security checks
91
+ language_analysis: LanguageAnalysis;
92
+ security_scan?: SecurityScanResult;
93
+ sandbox_result?: SandboxReference;
94
+
95
+ // Cryptographic proof
96
+ hop_signature: string;
97
+ cumulative_hash: string; // Hash including all previous hops
98
+
99
+ // Timing
100
+ started_at: Date;
101
+ completed_at: Date;
102
+ duration_ms: number;
103
+
104
+ // Outcome
105
+ status: 'success' | 'failure' | 'blocked' | 'timeout';
106
+ error?: string;
107
+ }
108
+
109
+ export interface AgentInfo {
110
+ id: string;
111
+ type: string; // 'claude', 'gpt', 'custom', etc.
112
+ version?: string;
113
+ capabilities?: string[];
114
+ metadata?: Record<string, unknown>;
115
+ }
116
+
117
+ export interface HopAction {
118
+ type: ActionType;
119
+ target?: string;
120
+ description: string;
121
+ input_hash?: string;
122
+ output_hash?: string;
123
+ timestamp: Date;
124
+ metadata?: Record<string, unknown>;
125
+ }
126
+
127
+ export type ActionType =
128
+ | 'route' // Route to another agent
129
+ | 'query' // Query data
130
+ | 'mutate' // Modify data
131
+ | 'execute' // Execute code
132
+ | 'generate' // Generate content
133
+ | 'send' // Send communication
134
+ | 'analyze' // Analyze content
135
+ | 'transform' // Transform data
136
+ | 'validate' // Validate something
137
+ | 'other';
138
+
139
+ // ============================================================================
140
+ // Language Analysis Types
141
+ // ============================================================================
142
+
143
+ export interface LanguageAnalysis {
144
+ detected_languages: DetectedLanguage[];
145
+ primary_language: string;
146
+ confidence: number;
147
+
148
+ semantic?: SemanticAnalysis;
149
+ code_analysis?: CodeAnalysis;
150
+ nl_analysis?: NLAnalysis;
151
+ }
152
+
153
+ export interface DetectedLanguage {
154
+ language: LanguageType;
155
+ confidence: number;
156
+ segments: LanguageSegment[];
157
+ }
158
+
159
+ export type LanguageType =
160
+ // Natural languages
161
+ | 'english' | 'spanish' | 'french' | 'german' | 'chinese' | 'japanese'
162
+ // Programming languages
163
+ | 'javascript' | 'typescript' | 'python' | 'java' | 'csharp' | 'go' | 'rust'
164
+ | 'ruby' | 'php' | 'swift' | 'kotlin' | 'scala' | 'r'
165
+ // Data/Config languages
166
+ | 'sql' | 'json' | 'yaml' | 'xml' | 'html' | 'css' | 'markdown'
167
+ | 'toml' | 'ini' | 'csv'
168
+ // Shell/Script
169
+ | 'bash' | 'powershell' | 'shell'
170
+ // Other
171
+ | 'regex' | 'graphql' | 'protobuf'
172
+ | 'unknown' | 'mixed';
173
+
174
+ export interface LanguageSegment {
175
+ start: number;
176
+ end: number;
177
+ language: LanguageType;
178
+ content: string;
179
+ confidence: number;
180
+ }
181
+
182
+ export interface SemanticAnalysis {
183
+ intent_classification: IntentClassification;
184
+ entities: ExtractedEntity[];
185
+ actions_implied: string[];
186
+ topics: string[];
187
+ sentiment?: number; // -1 to 1
188
+ formality?: number; // 0 to 1
189
+ urgency?: number; // 0 to 1
190
+ }
191
+
192
+ export interface ExtractedEntity {
193
+ type: EntityType;
194
+ value: string;
195
+ normalized?: string;
196
+ confidence: number;
197
+ position: { start: number; end: number };
198
+ metadata?: Record<string, unknown>;
199
+ }
200
+
201
+ export type EntityType =
202
+ | 'person' | 'organization' | 'location' | 'datetime'
203
+ | 'money' | 'percent' | 'quantity'
204
+ | 'email' | 'phone' | 'url' | 'ip_address'
205
+ | 'file_path' | 'database' | 'table' | 'api_endpoint'
206
+ | 'credential' | 'pii'
207
+ | 'custom';
208
+
209
+ export interface CodeAnalysis {
210
+ language: LanguageType;
211
+
212
+ // Structure
213
+ functions: string[];
214
+ classes: string[];
215
+ imports: string[];
216
+ exports: string[];
217
+
218
+ // Security
219
+ dangerous_patterns: DangerousPattern[];
220
+ data_flows: DataFlow[];
221
+ external_calls: ExternalCall[];
222
+
223
+ // Quality
224
+ complexity_score?: number;
225
+
226
+ // Recommendations
227
+ sandbox_required: boolean;
228
+ risk_level: 'low' | 'medium' | 'high' | 'critical';
229
+ recommendations: string[];
230
+ }
231
+
232
+ export interface DangerousPattern {
233
+ pattern: string;
234
+ description: string;
235
+ severity: 'low' | 'medium' | 'high' | 'critical' | 'critical';
236
+ line?: number;
237
+ column?: number;
238
+ recommendation: string;
239
+ }
240
+
241
+ export interface DataFlow {
242
+ source: string;
243
+ destination: string;
244
+ data_type?: string;
245
+ sensitive: boolean;
246
+ }
247
+
248
+ export interface ExternalCall {
249
+ type: 'http' | 'database' | 'file' | 'process' | 'network' | 'other';
250
+ target: string;
251
+ method?: string;
252
+ risk_level: 'low' | 'medium' | 'high';
253
+ }
254
+
255
+ export interface NLAnalysis {
256
+ // Manipulation detection
257
+ manipulation_score: number; // 0-1
258
+ manipulation_indicators: ManipulationIndicator[];
259
+
260
+ // Authority/instruction analysis
261
+ authority_claims: string[];
262
+ instruction_overrides: string[];
263
+ hidden_instructions: HiddenInstruction[];
264
+
265
+ // Jailbreak detection
266
+ jailbreak_score: number; // 0-1
267
+ jailbreak_patterns: string[];
268
+
269
+ // Overall assessment
270
+ risk_level: 'low' | 'medium' | 'high' | 'critical';
271
+ }
272
+
273
+ export interface ManipulationIndicator {
274
+ type: string;
275
+ description: string;
276
+ evidence: string;
277
+ severity: 'low' | 'medium' | 'high' | 'critical';
278
+ }
279
+
280
+ export interface HiddenInstruction {
281
+ instruction: string;
282
+ encoding?: string; // 'base64', 'unicode', 'steganographic', etc.
283
+ position: { start: number; end: number };
284
+ confidence: number;
285
+ }
286
+
287
+ // ============================================================================
288
+ // Intent Drift Types
289
+ // ============================================================================
290
+
291
+ export interface DriftAnalysis {
292
+ original_intent: string;
293
+ current_interpretation: string;
294
+
295
+ metrics: DriftMetrics;
296
+ cumulative_drift: number; // 0-1, total drift so far
297
+ hop_drift: number; // 0-1, drift at this hop specifically
298
+
299
+ max_acceptable_drift: number; // Policy-defined threshold
300
+
301
+ verdict: 'aligned' | 'minor_drift' | 'significant_drift' | 'violated';
302
+ explanation: string;
303
+
304
+ constraint_violations: string[];
305
+ }
306
+
307
+ export interface DriftMetrics {
308
+ semantic_similarity: number; // 0-1
309
+ action_alignment: number; // 0-1
310
+ scope_creep: number; // 0-1, negative means scope narrowed
311
+ entity_preservation: number; // 0-1, are same entities referenced
312
+ constraint_adherence: number; // 0-1
313
+ }
314
+
315
+ // ============================================================================
316
+ // Security Types
317
+ // ============================================================================
318
+
319
+ export interface SecurityScanResult {
320
+ scanner: 'mund' | 'custom';
321
+ timestamp: Date;
322
+
323
+ clean: boolean;
324
+ risk_level: 'low' | 'medium' | 'high' | 'critical';
325
+
326
+ findings: SecurityFinding[];
327
+
328
+ scan_duration_ms: number;
329
+ }
330
+
331
+ export interface SecurityFinding {
332
+ type: string;
333
+ severity: 'info' | 'low' | 'medium' | 'high' | 'critical';
334
+ description: string;
335
+ evidence?: string;
336
+ recommendation?: string;
337
+ false_positive_likelihood?: number;
338
+ }
339
+
340
+ export interface SandboxReference {
341
+ sandbox_id: string;
342
+ result_id: string;
343
+ status: 'safe' | 'review' | 'blocked';
344
+ summary: string;
345
+ }
346
+
347
+ // ============================================================================
348
+ // Compliance Types
349
+ // ============================================================================
350
+
351
+ export interface CompliancePolicy {
352
+ id: string;
353
+ name: string;
354
+ version: string;
355
+ description: string;
356
+
357
+ rules: ComplianceRule[];
358
+
359
+ jurisdiction?: string;
360
+ effective_date: Date;
361
+
362
+ metadata?: Record<string, unknown>;
363
+ }
364
+
365
+ export interface ComplianceRule {
366
+ id: string;
367
+ description: string;
368
+
369
+ // What to check
370
+ condition: RuleCondition;
371
+
372
+ // Outcome
373
+ severity: 'info' | 'warning' | 'violation' | 'critical';
374
+ remediation?: string;
375
+
376
+ // Evidence
377
+ evidence_required: string[];
378
+ }
379
+
380
+ export interface RuleCondition {
381
+ type: 'intent' | 'action' | 'data' | 'agent' | 'drift' | 'custom';
382
+ operator: 'equals' | 'contains' | 'matches' | 'exceeds' | 'custom';
383
+ value: unknown;
384
+ custom_fn?: string; // For custom conditions
385
+ }
386
+
387
+ export interface ComplianceResult {
388
+ thread_id: string;
389
+ policy_id: string;
390
+ policy_version: string;
391
+
392
+ compliant: boolean;
393
+ violations: ComplianceViolation[];
394
+ warnings: ComplianceWarning[];
395
+
396
+ checked_at: Date;
397
+
398
+ proof?: ComplianceProof;
399
+ }
400
+
401
+ export interface ComplianceViolation {
402
+ rule_id: string;
403
+ rule_description: string;
404
+ severity: 'violation' | 'critical';
405
+
406
+ evidence: string;
407
+ hop_id?: string;
408
+
409
+ remediation?: string;
410
+ }
411
+
412
+ export interface ComplianceWarning {
413
+ rule_id: string;
414
+ rule_description: string;
415
+
416
+ evidence: string;
417
+ hop_id?: string;
418
+ }
419
+
420
+ export interface ComplianceProof {
421
+ id: string;
422
+ thread_id: string;
423
+ policy_id: string;
424
+
425
+ claims: ProofClaim[];
426
+
427
+ proof_type: 'hash' | 'merkle' | 'zk';
428
+ proof_data: string;
429
+
430
+ generated_at: Date;
431
+
432
+ anchor?: AnchorReference;
433
+ }
434
+
435
+ export interface ProofClaim {
436
+ claim: string;
437
+ evidence_hash: string;
438
+ verified: boolean;
439
+ }
440
+
441
+ // ============================================================================
442
+ // Anchoring Types
443
+ // ============================================================================
444
+
445
+ export type BlockchainNetwork = 'solana' | 'ethereum' | 'solana-devnet' | 'ethereum-sepolia';
446
+
447
+ export interface AnchorRequest {
448
+ thread_id: string;
449
+ merkle_root: string;
450
+ hop_count: number;
451
+ intent_hash: string;
452
+ compliant: boolean;
453
+
454
+ network: BlockchainNetwork;
455
+ wallet?: WalletInfo; // User provides their wallet
456
+ }
457
+
458
+ export interface WalletInfo {
459
+ type: 'solana' | 'ethereum';
460
+ public_key: string;
461
+ // Private key is NEVER stored - signing happens client-side
462
+ }
463
+
464
+ export interface AnchorResult {
465
+ success: boolean;
466
+
467
+ network: BlockchainNetwork;
468
+ transaction_id: string;
469
+ block?: number;
470
+ slot?: number; // Solana
471
+ timestamp: Date;
472
+
473
+ // Costs
474
+ network_fee: string;
475
+ protocol_fee: string;
476
+ total_cost: string;
477
+
478
+ // Verification
479
+ verification_url: string;
480
+
481
+ error?: string;
482
+ }
483
+
484
+ export interface AnchorReference {
485
+ network: BlockchainNetwork;
486
+ transaction_id: string;
487
+ block?: number;
488
+ slot?: number;
489
+ timestamp: Date;
490
+ verified: boolean;
491
+ }
492
+
493
+ export interface AnchorVerification {
494
+ valid: boolean;
495
+
496
+ thread_id: string;
497
+ merkle_root: string;
498
+
499
+ anchor: AnchorReference;
500
+
501
+ on_chain_data?: {
502
+ merkle_root: string;
503
+ hop_count: number;
504
+ intent_hash: string;
505
+ compliant: boolean;
506
+ timestamp: number;
507
+ anchorer: string;
508
+ };
509
+
510
+ verified_at: Date;
511
+ error?: string;
512
+ }
513
+
514
+ // ============================================================================
515
+ // Arbitration Types
516
+ // ============================================================================
517
+
518
+ export interface ArbitrationCase {
519
+ id: string;
520
+ thread_id: string;
521
+
522
+ dispute: Dispute;
523
+
524
+ status: 'open' | 'evidence' | 'review' | 'resolved' | 'appealed';
525
+
526
+ evidence: ArbitrationEvidence[];
527
+
528
+ resolution?: Resolution;
529
+
530
+ created_at: Date;
531
+ updated_at: Date;
532
+ resolved_at?: Date;
533
+
534
+ anchor?: AnchorReference;
535
+ }
536
+
537
+ export interface Dispute {
538
+ type: DisputeType;
539
+ description: string;
540
+ agents_involved: string[];
541
+
542
+ claimed_by: string;
543
+ claimed_at: Date;
544
+ }
545
+
546
+ export type DisputeType =
547
+ | 'intent_conflict' // Agents disagree on intent
548
+ | 'resource_conflict' // Competing for same resource
549
+ | 'result_conflict' // Different results from same input
550
+ | 'policy_violation' // Alleged policy violation
551
+ | 'drift_dispute' // Dispute over intent drift
552
+ | 'other';
553
+
554
+ export interface ArbitrationEvidence {
555
+ id: string;
556
+ case_id: string;
557
+
558
+ type: 'thread' | 'hop' | 'scan' | 'attestation' | 'document' | 'other';
559
+ description: string;
560
+
561
+ data_hash: string;
562
+ data?: unknown; // Actual evidence data
563
+
564
+ submitted_by: string;
565
+ submitted_at: Date;
566
+ }
567
+
568
+ export interface Resolution {
569
+ method: 'automatic' | 'human' | 'committee';
570
+
571
+ decision: string;
572
+ reasoning: string;
573
+
574
+ outcome: 'upheld' | 'rejected' | 'partial' | 'withdrawn';
575
+
576
+ actions_required: ResolutionAction[];
577
+ policy_updates?: string[];
578
+
579
+ resolved_by: string;
580
+ resolved_at: Date;
581
+
582
+ dissenting_opinions?: string[];
583
+ }
584
+
585
+ export interface ResolutionAction {
586
+ action: string;
587
+ target: string;
588
+ deadline?: Date;
589
+ completed?: boolean;
590
+ }
591
+
592
+ // ============================================================================
593
+ // Storage Types
594
+ // ============================================================================
595
+
596
+ export interface IDomereStorage {
597
+ // Threads
598
+ saveThread(thread: Thread): Promise<void>;
599
+ getThread(id: string): Promise<Thread | null>;
600
+ updateThread(thread: Thread): Promise<void>;
601
+ listThreads(filters?: ThreadFilters): Promise<Thread[]>;
602
+
603
+ // Hops
604
+ addHop(threadId: string, hop: ThreadHop): Promise<void>;
605
+ getHops(threadId: string): Promise<ThreadHop[]>;
606
+
607
+ // Compliance
608
+ saveComplianceResult(result: ComplianceResult): Promise<void>;
609
+ getComplianceResults(threadId: string): Promise<ComplianceResult[]>;
610
+
611
+ // Policies
612
+ savePolicy(policy: CompliancePolicy): Promise<void>;
613
+ getPolicy(id: string): Promise<CompliancePolicy | null>;
614
+ listPolicies(): Promise<CompliancePolicy[]>;
615
+
616
+ // Anchors
617
+ saveAnchor(threadId: string, anchor: AnchorReference): Promise<void>;
618
+ getAnchors(threadId: string): Promise<AnchorReference[]>;
619
+
620
+ // Arbitration
621
+ saveCase(case_: ArbitrationCase): Promise<void>;
622
+ getCase(id: string): Promise<ArbitrationCase | null>;
623
+ listCases(filters?: CaseFilters): Promise<ArbitrationCase[]>;
624
+
625
+ // Evidence
626
+ saveEvidence(evidence: ArbitrationEvidence): Promise<void>;
627
+ getEvidence(caseId: string): Promise<ArbitrationEvidence[]>;
628
+ }
629
+
630
+ export interface ThreadFilters {
631
+ status?: ThreadStatus;
632
+ origin_type?: ThreadOrigin['type'];
633
+ origin_identity?: string;
634
+ since?: Date;
635
+ until?: Date;
636
+ limit?: number;
637
+ offset?: number;
638
+ }
639
+
640
+ export interface CaseFilters {
641
+ status?: ArbitrationCase['status'];
642
+ dispute_type?: DisputeType;
643
+ thread_id?: string;
644
+ limit?: number;
645
+ offset?: number;
646
+ }
647
+
648
+ // ============================================================================
649
+ // Configuration Types
650
+ // ============================================================================
651
+
652
+ export interface DomereConfig {
653
+ port: number;
654
+ host: string;
655
+ transport: 'stdio' | 'http';
656
+ log_level: 'debug' | 'info' | 'warn' | 'error';
657
+ storage: 'memory' | 'sqlite';
658
+
659
+ // Language analysis
660
+ language: {
661
+ enable_semantic: boolean;
662
+ enable_code_analysis: boolean;
663
+ enable_nl_analysis: boolean;
664
+ };
665
+
666
+ // Drift detection
667
+ drift: {
668
+ max_acceptable_drift: number; // 0-1, default 0.3
669
+ warn_threshold: number; // 0-1, default 0.2
670
+ };
671
+
672
+ // Anchoring
673
+ anchoring: {
674
+ solana_rpc: string;
675
+ solana_program_id: string;
676
+ ethereum_rpc: string;
677
+ ethereum_contract: string;
678
+ protocol_fee_bps: number; // Basis points, 500 = 5%
679
+ };
680
+
681
+ // Integration
682
+ integration: {
683
+ mund_url?: string;
684
+ hord_url?: string;
685
+ };
686
+ }
687
+
688
+ // ============================================================================
689
+ // Error Types
690
+ // ============================================================================
691
+
692
+ export class DomereError extends Error {
693
+ constructor(
694
+ message: string,
695
+ public code: string,
696
+ public details?: Record<string, unknown>
697
+ ) {
698
+ super(message);
699
+ this.name = 'DomereError';
700
+ }
701
+ }
702
+
703
+ export class ThreadError extends DomereError {
704
+ constructor(message: string, details?: Record<string, unknown>) {
705
+ super(message, 'THREAD_ERROR', details);
706
+ this.name = 'ThreadError';
707
+ }
708
+ }
709
+
710
+ export class LanguageAnalysisError extends DomereError {
711
+ constructor(message: string, details?: Record<string, unknown>) {
712
+ super(message, 'LANGUAGE_ERROR', details);
713
+ this.name = 'LanguageAnalysisError';
714
+ }
715
+ }
716
+
717
+ export class ComplianceError extends DomereError {
718
+ constructor(message: string, details?: Record<string, unknown>) {
719
+ super(message, 'COMPLIANCE_ERROR', details);
720
+ this.name = 'ComplianceError';
721
+ }
722
+ }
723
+
724
+ export class AnchoringError extends DomereError {
725
+ constructor(message: string, details?: Record<string, unknown>) {
726
+ super(message, 'ANCHORING_ERROR', details);
727
+ this.name = 'AnchoringError';
728
+ }
729
+ }
730
+
731
+ export class ArbitrationError extends DomereError {
732
+ constructor(message: string, details?: Record<string, unknown>) {
733
+ super(message, 'ARBITRATION_ERROR', details);
734
+ this.name = 'ArbitrationError';
735
+ }
736
+ }