@aibuildinfra/proofgraph 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/LICENSE +21 -0
- package/PRIVACY.md +8 -0
- package/README.md +193 -0
- package/SECURITY.md +27 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.js +273 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/dashboard/server.d.ts +5 -0
- package/dist/dashboard/server.js +271 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/data/seed.d.ts +6 -0
- package/dist/data/seed.js +325 -0
- package/dist/data/seed.js.map +1 -0
- package/dist/engine/aiDiscoverability.d.ts +11 -0
- package/dist/engine/aiDiscoverability.js +135 -0
- package/dist/engine/aiDiscoverability.js.map +1 -0
- package/dist/engine/claimVerifier.d.ts +26 -0
- package/dist/engine/claimVerifier.js +130 -0
- package/dist/engine/claimVerifier.js.map +1 -0
- package/dist/engine/consistencyAudit.d.ts +11 -0
- package/dist/engine/consistencyAudit.js +172 -0
- package/dist/engine/consistencyAudit.js.map +1 -0
- package/dist/engine/exporter.d.ts +17 -0
- package/dist/engine/exporter.js +83 -0
- package/dist/engine/exporter.js.map +1 -0
- package/dist/engine/graphTraversal.d.ts +25 -0
- package/dist/engine/graphTraversal.js +74 -0
- package/dist/engine/graphTraversal.js.map +1 -0
- package/dist/engine/resolver.d.ts +20 -0
- package/dist/engine/resolver.js +168 -0
- package/dist/engine/resolver.js.map +1 -0
- package/dist/engine/schemaOrg.d.ts +12 -0
- package/dist/engine/schemaOrg.js +105 -0
- package/dist/engine/schemaOrg.js.map +1 -0
- package/dist/engine/tokenOptimizer.d.ts +25 -0
- package/dist/engine/tokenOptimizer.js +166 -0
- package/dist/engine/tokenOptimizer.js.map +1 -0
- package/dist/engine/webPresence.d.ts +32 -0
- package/dist/engine/webPresence.js +63 -0
- package/dist/engine/webPresence.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/prompts.d.ts +25 -0
- package/dist/mcp/prompts.js +136 -0
- package/dist/mcp/prompts.js.map +1 -0
- package/dist/mcp/resources.d.ts +27 -0
- package/dist/mcp/resources.js +118 -0
- package/dist/mcp/resources.js.map +1 -0
- package/dist/mcp/server.d.ts +15 -0
- package/dist/mcp/server.js +88 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +256 -0
- package/dist/mcp/tools.js +391 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/security/robots.d.ts +15 -0
- package/dist/security/robots.js +78 -0
- package/dist/security/robots.js.map +1 -0
- package/dist/security/safeFetch.d.ts +23 -0
- package/dist/security/safeFetch.js +122 -0
- package/dist/security/safeFetch.js.map +1 -0
- package/dist/storage/graphStore.d.ts +70 -0
- package/dist/storage/graphStore.js +275 -0
- package/dist/storage/graphStore.js.map +1 -0
- package/dist/storage/sqliteAdapter.d.ts +14 -0
- package/dist/storage/sqliteAdapter.js +137 -0
- package/dist/storage/sqliteAdapter.js.map +1 -0
- package/dist/tests/proofgraph.test.d.ts +5 -0
- package/dist/tests/proofgraph.test.js +249 -0
- package/dist/tests/proofgraph.test.js.map +1 -0
- package/dist/types/index.d.ts +206 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +65 -0
- package/server.json +24 -0
- package/smithery.yaml +6 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProofGraph MCP Tools Implementation
|
|
3
|
+
* Provides standard Model Context Protocol tool declarations and execution handlers
|
|
4
|
+
*/
|
|
5
|
+
import { GraphStore } from '../storage/graphStore.js';
|
|
6
|
+
export declare const TOOL_DEFINITIONS: ({
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: string;
|
|
11
|
+
properties: {
|
|
12
|
+
query: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
limit: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
entity_id?: undefined;
|
|
21
|
+
claim?: undefined;
|
|
22
|
+
max_tokens?: undefined;
|
|
23
|
+
relationship?: undefined;
|
|
24
|
+
depth?: undefined;
|
|
25
|
+
claims?: undefined;
|
|
26
|
+
question?: undefined;
|
|
27
|
+
domain?: undefined;
|
|
28
|
+
format?: undefined;
|
|
29
|
+
};
|
|
30
|
+
required: string[];
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: string;
|
|
37
|
+
properties: {
|
|
38
|
+
entity_id: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
query?: undefined;
|
|
43
|
+
limit?: undefined;
|
|
44
|
+
claim?: undefined;
|
|
45
|
+
max_tokens?: undefined;
|
|
46
|
+
relationship?: undefined;
|
|
47
|
+
depth?: undefined;
|
|
48
|
+
claims?: undefined;
|
|
49
|
+
question?: undefined;
|
|
50
|
+
domain?: undefined;
|
|
51
|
+
format?: undefined;
|
|
52
|
+
};
|
|
53
|
+
required: string[];
|
|
54
|
+
};
|
|
55
|
+
} | {
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
inputSchema: {
|
|
59
|
+
type: string;
|
|
60
|
+
properties: {
|
|
61
|
+
claim: {
|
|
62
|
+
type: string;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
entity_id: {
|
|
66
|
+
type: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
query?: undefined;
|
|
70
|
+
limit?: undefined;
|
|
71
|
+
max_tokens?: undefined;
|
|
72
|
+
relationship?: undefined;
|
|
73
|
+
depth?: undefined;
|
|
74
|
+
claims?: undefined;
|
|
75
|
+
question?: undefined;
|
|
76
|
+
domain?: undefined;
|
|
77
|
+
format?: undefined;
|
|
78
|
+
};
|
|
79
|
+
required: string[];
|
|
80
|
+
};
|
|
81
|
+
} | {
|
|
82
|
+
name: string;
|
|
83
|
+
description: string;
|
|
84
|
+
inputSchema: {
|
|
85
|
+
type: string;
|
|
86
|
+
properties: {
|
|
87
|
+
claim: {
|
|
88
|
+
type: string;
|
|
89
|
+
description: string;
|
|
90
|
+
};
|
|
91
|
+
max_tokens: {
|
|
92
|
+
type: string;
|
|
93
|
+
description: string;
|
|
94
|
+
};
|
|
95
|
+
query?: undefined;
|
|
96
|
+
limit?: undefined;
|
|
97
|
+
entity_id?: undefined;
|
|
98
|
+
relationship?: undefined;
|
|
99
|
+
depth?: undefined;
|
|
100
|
+
claims?: undefined;
|
|
101
|
+
question?: undefined;
|
|
102
|
+
domain?: undefined;
|
|
103
|
+
format?: undefined;
|
|
104
|
+
};
|
|
105
|
+
required: string[];
|
|
106
|
+
};
|
|
107
|
+
} | {
|
|
108
|
+
name: string;
|
|
109
|
+
description: string;
|
|
110
|
+
inputSchema: {
|
|
111
|
+
type: string;
|
|
112
|
+
properties: {
|
|
113
|
+
entity_id: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
relationship: {
|
|
118
|
+
type: string;
|
|
119
|
+
description: string;
|
|
120
|
+
};
|
|
121
|
+
depth: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
};
|
|
125
|
+
query?: undefined;
|
|
126
|
+
limit?: undefined;
|
|
127
|
+
claim?: undefined;
|
|
128
|
+
max_tokens?: undefined;
|
|
129
|
+
claims?: undefined;
|
|
130
|
+
question?: undefined;
|
|
131
|
+
domain?: undefined;
|
|
132
|
+
format?: undefined;
|
|
133
|
+
};
|
|
134
|
+
required: string[];
|
|
135
|
+
};
|
|
136
|
+
} | {
|
|
137
|
+
name: string;
|
|
138
|
+
description: string;
|
|
139
|
+
inputSchema: {
|
|
140
|
+
type: string;
|
|
141
|
+
properties: {
|
|
142
|
+
claims: {
|
|
143
|
+
type: string;
|
|
144
|
+
items: {
|
|
145
|
+
type: string;
|
|
146
|
+
};
|
|
147
|
+
description: string;
|
|
148
|
+
};
|
|
149
|
+
query?: undefined;
|
|
150
|
+
limit?: undefined;
|
|
151
|
+
entity_id?: undefined;
|
|
152
|
+
claim?: undefined;
|
|
153
|
+
max_tokens?: undefined;
|
|
154
|
+
relationship?: undefined;
|
|
155
|
+
depth?: undefined;
|
|
156
|
+
question?: undefined;
|
|
157
|
+
domain?: undefined;
|
|
158
|
+
format?: undefined;
|
|
159
|
+
};
|
|
160
|
+
required: string[];
|
|
161
|
+
};
|
|
162
|
+
} | {
|
|
163
|
+
name: string;
|
|
164
|
+
description: string;
|
|
165
|
+
inputSchema: {
|
|
166
|
+
type: string;
|
|
167
|
+
properties: {
|
|
168
|
+
question: {
|
|
169
|
+
type: string;
|
|
170
|
+
description: string;
|
|
171
|
+
};
|
|
172
|
+
entity_id: {
|
|
173
|
+
type: string;
|
|
174
|
+
description: string;
|
|
175
|
+
};
|
|
176
|
+
claim: {
|
|
177
|
+
type: string;
|
|
178
|
+
description: string;
|
|
179
|
+
};
|
|
180
|
+
max_tokens: {
|
|
181
|
+
type: string;
|
|
182
|
+
description: string;
|
|
183
|
+
};
|
|
184
|
+
query?: undefined;
|
|
185
|
+
limit?: undefined;
|
|
186
|
+
relationship?: undefined;
|
|
187
|
+
depth?: undefined;
|
|
188
|
+
claims?: undefined;
|
|
189
|
+
domain?: undefined;
|
|
190
|
+
format?: undefined;
|
|
191
|
+
};
|
|
192
|
+
required?: undefined;
|
|
193
|
+
};
|
|
194
|
+
} | {
|
|
195
|
+
name: string;
|
|
196
|
+
description: string;
|
|
197
|
+
inputSchema: {
|
|
198
|
+
type: string;
|
|
199
|
+
properties: {
|
|
200
|
+
entity_id: {
|
|
201
|
+
type: string;
|
|
202
|
+
description: string;
|
|
203
|
+
};
|
|
204
|
+
domain: {
|
|
205
|
+
type: string;
|
|
206
|
+
description: string;
|
|
207
|
+
};
|
|
208
|
+
query?: undefined;
|
|
209
|
+
limit?: undefined;
|
|
210
|
+
claim?: undefined;
|
|
211
|
+
max_tokens?: undefined;
|
|
212
|
+
relationship?: undefined;
|
|
213
|
+
depth?: undefined;
|
|
214
|
+
claims?: undefined;
|
|
215
|
+
question?: undefined;
|
|
216
|
+
format?: undefined;
|
|
217
|
+
};
|
|
218
|
+
required: string[];
|
|
219
|
+
};
|
|
220
|
+
} | {
|
|
221
|
+
name: string;
|
|
222
|
+
description: string;
|
|
223
|
+
inputSchema: {
|
|
224
|
+
type: string;
|
|
225
|
+
properties: {
|
|
226
|
+
format: {
|
|
227
|
+
type: string;
|
|
228
|
+
enum: string[];
|
|
229
|
+
description: string;
|
|
230
|
+
};
|
|
231
|
+
query?: undefined;
|
|
232
|
+
limit?: undefined;
|
|
233
|
+
entity_id?: undefined;
|
|
234
|
+
claim?: undefined;
|
|
235
|
+
max_tokens?: undefined;
|
|
236
|
+
relationship?: undefined;
|
|
237
|
+
depth?: undefined;
|
|
238
|
+
claims?: undefined;
|
|
239
|
+
question?: undefined;
|
|
240
|
+
domain?: undefined;
|
|
241
|
+
};
|
|
242
|
+
required: string[];
|
|
243
|
+
};
|
|
244
|
+
})[];
|
|
245
|
+
export declare class ToolHandler {
|
|
246
|
+
private store;
|
|
247
|
+
private resolver;
|
|
248
|
+
private verifier;
|
|
249
|
+
private traversal;
|
|
250
|
+
private consistency;
|
|
251
|
+
private webPresence;
|
|
252
|
+
private discoverability;
|
|
253
|
+
private exporter;
|
|
254
|
+
constructor(store: GraphStore);
|
|
255
|
+
handleTool(name: string, args: Record<string, any>): Promise<any>;
|
|
256
|
+
}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProofGraph MCP Tools Implementation
|
|
3
|
+
* Provides standard Model Context Protocol tool declarations and execution handlers
|
|
4
|
+
*/
|
|
5
|
+
import { EntityResolver } from '../engine/resolver.js';
|
|
6
|
+
import { ClaimVerifier } from '../engine/claimVerifier.js';
|
|
7
|
+
import { TokenOptimizer } from '../engine/tokenOptimizer.js';
|
|
8
|
+
import { GraphTraversalEngine } from '../engine/graphTraversal.js';
|
|
9
|
+
import { ConsistencyAuditor } from '../engine/consistencyAudit.js';
|
|
10
|
+
import { WebPresenceAnalyzer } from '../engine/webPresence.js';
|
|
11
|
+
import { AIDiscoverabilityEngine } from '../engine/aiDiscoverability.js';
|
|
12
|
+
import { GraphExporter } from '../engine/exporter.js';
|
|
13
|
+
import { SchemaOrgGenerator } from '../engine/schemaOrg.js';
|
|
14
|
+
export const TOOL_DEFINITIONS = [
|
|
15
|
+
{
|
|
16
|
+
name: 'search_entities',
|
|
17
|
+
description: 'Search for candidate entities by name, alias, or keyword using multi-signal matching.',
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object',
|
|
20
|
+
properties: {
|
|
21
|
+
query: { type: 'string', description: 'Entity name, alias, or keyword to search' },
|
|
22
|
+
limit: { type: 'number', description: 'Maximum candidate entities to return (default 10)' },
|
|
23
|
+
},
|
|
24
|
+
required: ['query'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'get_entity',
|
|
29
|
+
description: 'Retrieve canonical information, aliases, metadata, and connected relationships for a specific entity ID.',
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
entity_id: { type: 'string', description: 'Canonical entity ID (e.g. entity:organization:ai-build-infra)' },
|
|
34
|
+
},
|
|
35
|
+
required: ['entity_id'],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'verify_claim',
|
|
40
|
+
description: 'Verify an assertion or claim against cryptographic, timestamped evidence sources.',
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
properties: {
|
|
44
|
+
claim: { type: 'string', description: 'The factual claim to verify' },
|
|
45
|
+
entity_id: { type: 'string', description: 'Optional subject entity ID to scope the verification' },
|
|
46
|
+
},
|
|
47
|
+
required: ['claim'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'find_evidence',
|
|
52
|
+
description: 'Retrieve compact, ranked supporting evidence for a claim under a strict token budget.',
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
claim: { type: 'string', description: 'The claim or subject to find evidence for' },
|
|
57
|
+
max_tokens: { type: 'number', description: 'Maximum token budget (default 1500; allows 500, 1000, 1500, 3000, 5000)' },
|
|
58
|
+
},
|
|
59
|
+
required: ['claim'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'find_relationships',
|
|
64
|
+
description: 'Discover 1-hop, 2-hop, or 3-hop relationships and connecting graph paths starting from an entity.',
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: {
|
|
68
|
+
entity_id: { type: 'string', description: 'Starting entity ID' },
|
|
69
|
+
relationship: { type: 'string', description: 'Optional relationship filter (e.g. DEVELOPS, OWNS, DEPENDS_ON)' },
|
|
70
|
+
depth: { type: 'number', description: 'Graph traversal depth (1, 2, or 3; default 2)' },
|
|
71
|
+
},
|
|
72
|
+
required: ['entity_id'],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'explain_entity',
|
|
77
|
+
description: 'Return a concise, factual entity profile backed by verified sources and structured relationships.',
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
entity_id: { type: 'string', description: 'Canonical entity ID or recognized name' },
|
|
82
|
+
},
|
|
83
|
+
required: ['entity_id'],
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'trace_claim',
|
|
88
|
+
description: 'Trace the complete provenance chain for a claim (Claim -> Evidence -> Source -> URL -> Timestamp -> Hash).',
|
|
89
|
+
inputSchema: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
claim: { type: 'string', description: 'Claim to trace' },
|
|
93
|
+
entity_id: { type: 'string', description: 'Optional entity ID' },
|
|
94
|
+
},
|
|
95
|
+
required: ['claim'],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'compare_claims',
|
|
100
|
+
description: 'Compare multiple potentially conflicting claims and expose discrepancies without arbitrary bias.',
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {
|
|
104
|
+
claims: {
|
|
105
|
+
type: 'array',
|
|
106
|
+
items: { type: 'string' },
|
|
107
|
+
description: 'List of claim statements to compare',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
required: ['claims'],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'get_evidence_packet',
|
|
115
|
+
description: 'Primary AI agent retrieval interface: returns the smallest verified evidence packet sufficient to answer a question.',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {
|
|
119
|
+
question: { type: 'string', description: 'The question or prompt to retrieve evidence for' },
|
|
120
|
+
entity_id: { type: 'string', description: 'Optional specific entity ID' },
|
|
121
|
+
claim: { type: 'string', description: 'Optional specific claim' },
|
|
122
|
+
max_tokens: { type: 'number', description: 'Token budget ceiling (default 1500)' },
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'analyze_web_presence',
|
|
128
|
+
description: 'Analyze an entity digital footprint across official, GitHub, package registry, documentation, and 3rd-party sources.',
|
|
129
|
+
inputSchema: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
properties: {
|
|
132
|
+
entity_id: { type: 'string', description: 'Canonical entity ID or name' },
|
|
133
|
+
domain: { type: 'string', description: 'Optional domain hint (e.g. aibuildinfra.com)' },
|
|
134
|
+
},
|
|
135
|
+
required: ['entity_id'],
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'audit_entity_consistency',
|
|
140
|
+
description: 'Diagnostic audit to detect inconsistencies across company name, domains, GitHub orgs, npm scopes, and Schema.org markup.',
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: 'object',
|
|
143
|
+
properties: {
|
|
144
|
+
entity_id: { type: 'string', description: 'Canonical entity ID or name' },
|
|
145
|
+
},
|
|
146
|
+
required: ['entity_id'],
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'export_graph',
|
|
151
|
+
description: 'Export the verified knowledge graph to standard interoperable formats (JSON, JSON-LD, CSV, GraphML).',
|
|
152
|
+
inputSchema: {
|
|
153
|
+
type: 'object',
|
|
154
|
+
properties: {
|
|
155
|
+
format: {
|
|
156
|
+
type: 'string',
|
|
157
|
+
enum: ['json', 'jsonld', 'csv', 'graphml'],
|
|
158
|
+
description: 'Export format',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
required: ['format'],
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
];
|
|
165
|
+
export class ToolHandler {
|
|
166
|
+
store;
|
|
167
|
+
resolver;
|
|
168
|
+
verifier;
|
|
169
|
+
traversal;
|
|
170
|
+
consistency;
|
|
171
|
+
webPresence;
|
|
172
|
+
discoverability;
|
|
173
|
+
exporter;
|
|
174
|
+
constructor(store) {
|
|
175
|
+
this.store = store;
|
|
176
|
+
this.resolver = new EntityResolver(store);
|
|
177
|
+
this.verifier = new ClaimVerifier(store);
|
|
178
|
+
this.traversal = new GraphTraversalEngine(store);
|
|
179
|
+
this.consistency = new ConsistencyAuditor(store);
|
|
180
|
+
this.webPresence = new WebPresenceAnalyzer(store);
|
|
181
|
+
this.discoverability = new AIDiscoverabilityEngine(store);
|
|
182
|
+
this.exporter = new GraphExporter(store);
|
|
183
|
+
}
|
|
184
|
+
async handleTool(name, args) {
|
|
185
|
+
switch (name) {
|
|
186
|
+
case 'search_entities': {
|
|
187
|
+
const query = String(args.query || '');
|
|
188
|
+
const limit = Number(args.limit) || 10;
|
|
189
|
+
const candidates = this.resolver.resolve({ name: query });
|
|
190
|
+
return {
|
|
191
|
+
query,
|
|
192
|
+
count: Math.min(candidates.length, limit),
|
|
193
|
+
candidates: candidates.slice(0, limit),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
case 'get_entity': {
|
|
197
|
+
const entityId = String(args.entity_id || '');
|
|
198
|
+
const entity = this.store.getEntity(entityId) || this.resolver.findCanonical(entityId);
|
|
199
|
+
if (!entity) {
|
|
200
|
+
return { error: `Entity "${entityId}" not found in graph.` };
|
|
201
|
+
}
|
|
202
|
+
const relationships = this.store.getRelationships(entity.id);
|
|
203
|
+
const claims = this.store.getClaimsForEntity(entity.id);
|
|
204
|
+
return {
|
|
205
|
+
entity,
|
|
206
|
+
relationships,
|
|
207
|
+
claims,
|
|
208
|
+
schema_org: SchemaOrgGenerator.generateForEntity(entity),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
case 'verify_claim': {
|
|
212
|
+
const claim = String(args.claim || '');
|
|
213
|
+
const entityId = args.entity_id ? String(args.entity_id) : undefined;
|
|
214
|
+
return this.verifier.verify(claim, entityId);
|
|
215
|
+
}
|
|
216
|
+
case 'find_evidence': {
|
|
217
|
+
const claim = String(args.claim || '');
|
|
218
|
+
const maxTokens = Number(args.max_tokens) || 1500;
|
|
219
|
+
const verification = this.verifier.verify(claim);
|
|
220
|
+
const sourcesMap = new Map(this.store.getAllSources().map(s => [s.id, s]));
|
|
221
|
+
const packet = TokenOptimizer.buildPacket({
|
|
222
|
+
question: claim,
|
|
223
|
+
entities: verification.entity_id ? [this.store.getEntity(verification.entity_id)].filter(Boolean) : [],
|
|
224
|
+
claims: [
|
|
225
|
+
{
|
|
226
|
+
id: 'claim:queried',
|
|
227
|
+
subject_id: verification.entity_id || 'entity:general',
|
|
228
|
+
predicate: 'VERIFIES',
|
|
229
|
+
statement: claim,
|
|
230
|
+
status: verification.status,
|
|
231
|
+
confidence: verification.confidence,
|
|
232
|
+
evidence_ids: verification.supporting_evidence.map(e => e.id),
|
|
233
|
+
created_at: new Date().toISOString(),
|
|
234
|
+
updated_at: new Date().toISOString(),
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
evidence: [...verification.supporting_evidence, ...verification.contradicting_evidence],
|
|
238
|
+
sources: sourcesMap,
|
|
239
|
+
maxTokens,
|
|
240
|
+
});
|
|
241
|
+
return packet;
|
|
242
|
+
}
|
|
243
|
+
case 'find_relationships': {
|
|
244
|
+
const entityId = String(args.entity_id || '');
|
|
245
|
+
const relType = args.relationship ? String(args.relationship) : undefined;
|
|
246
|
+
const depth = Number(args.depth) || 2;
|
|
247
|
+
return this.traversal.findRelationships(entityId, relType, depth);
|
|
248
|
+
}
|
|
249
|
+
case 'explain_entity': {
|
|
250
|
+
const entityId = String(args.entity_id || '');
|
|
251
|
+
const entity = this.store.getEntity(entityId) || this.resolver.findCanonical(entityId);
|
|
252
|
+
if (!entity) {
|
|
253
|
+
return { error: `Entity "${entityId}" not found.` };
|
|
254
|
+
}
|
|
255
|
+
const relationships = this.store.getRelationships(entity.id);
|
|
256
|
+
const claims = this.store.getClaimsForEntity(entity.id);
|
|
257
|
+
const discoverability = this.discoverability.evaluate(entity.id);
|
|
258
|
+
return {
|
|
259
|
+
entity,
|
|
260
|
+
summary: `${entity.name} is a verified ${entity.type}. ${entity.description}`,
|
|
261
|
+
key_relationships: relationships.map(r => ({
|
|
262
|
+
predicate: r.relationship,
|
|
263
|
+
target: r.target_id === entity.id ? r.source_id : r.target_id,
|
|
264
|
+
confidence: r.confidence,
|
|
265
|
+
})),
|
|
266
|
+
verified_claims: claims.filter(c => c.status === 'supported').map(c => c.statement),
|
|
267
|
+
discoverability_score: discoverability.overall_score,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
case 'trace_claim': {
|
|
271
|
+
const claim = String(args.claim || '');
|
|
272
|
+
const entityId = args.entity_id ? String(args.entity_id) : undefined;
|
|
273
|
+
const verification = this.verifier.verify(claim, entityId);
|
|
274
|
+
const sourcesMap = new Map(this.store.getAllSources().map(s => [s.id, s]));
|
|
275
|
+
const traces = verification.supporting_evidence.map(ev => {
|
|
276
|
+
const source = sourcesMap.get(ev.source_id);
|
|
277
|
+
return {
|
|
278
|
+
claim: claim,
|
|
279
|
+
status: verification.status,
|
|
280
|
+
evidence: {
|
|
281
|
+
id: ev.id,
|
|
282
|
+
excerpt: ev.excerpt,
|
|
283
|
+
directness: ev.directness,
|
|
284
|
+
confidence: ev.confidence,
|
|
285
|
+
},
|
|
286
|
+
source: {
|
|
287
|
+
id: source?.id || ev.source_id,
|
|
288
|
+
title: source?.title,
|
|
289
|
+
url: ev.url,
|
|
290
|
+
publisher: ev.publisher,
|
|
291
|
+
trust_class: ev.source_type,
|
|
292
|
+
last_verified: source?.last_verified || ev.retrieved_at,
|
|
293
|
+
content_hash: ev.content_hash,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
return {
|
|
298
|
+
claim,
|
|
299
|
+
status: verification.status,
|
|
300
|
+
confidence: verification.confidence,
|
|
301
|
+
provenance_chain: traces,
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
case 'compare_claims': {
|
|
305
|
+
const claims = Array.isArray(args.claims) ? args.claims.map(String) : [];
|
|
306
|
+
return this.verifier.compareClaims(claims);
|
|
307
|
+
}
|
|
308
|
+
case 'get_evidence_packet': {
|
|
309
|
+
const question = args.question ? String(args.question) : undefined;
|
|
310
|
+
const entityId = args.entity_id ? String(args.entity_id) : undefined;
|
|
311
|
+
const claimStmt = args.claim ? String(args.claim) : question || '';
|
|
312
|
+
const maxTokens = Number(args.max_tokens) || 1500;
|
|
313
|
+
let entitiesToInclude = entityId ? [this.store.getEntity(entityId)].filter(Boolean) : [];
|
|
314
|
+
if (entitiesToInclude.length === 0 && question) {
|
|
315
|
+
const candidates = this.resolver.resolve({ name: question });
|
|
316
|
+
if (candidates.length > 0) {
|
|
317
|
+
entitiesToInclude = [candidates[0].entity];
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const verification = this.verifier.verify(claimStmt, entitiesToInclude[0]?.id);
|
|
321
|
+
const sourcesMap = new Map(this.store.getAllSources().map(s => [s.id, s]));
|
|
322
|
+
const rels = entitiesToInclude[0] ? this.store.getRelationships(entitiesToInclude[0].id) : [];
|
|
323
|
+
let evidenceToInclude = [...verification.supporting_evidence, ...verification.contradicting_evidence];
|
|
324
|
+
let claimsToInclude = [
|
|
325
|
+
{
|
|
326
|
+
id: 'claim:retrieved',
|
|
327
|
+
subject_id: entitiesToInclude[0]?.id || 'entity:general',
|
|
328
|
+
predicate: 'RETRIEVED',
|
|
329
|
+
statement: claimStmt,
|
|
330
|
+
status: verification.status,
|
|
331
|
+
confidence: verification.confidence,
|
|
332
|
+
evidence_ids: verification.supporting_evidence.map(e => e.id),
|
|
333
|
+
created_at: new Date().toISOString(),
|
|
334
|
+
updated_at: new Date().toISOString(),
|
|
335
|
+
},
|
|
336
|
+
];
|
|
337
|
+
// If evidence is empty for an exploratory question, pull from entity's verified claims
|
|
338
|
+
if (evidenceToInclude.length === 0 && entitiesToInclude.length > 0) {
|
|
339
|
+
const entityClaims = this.store.getClaimsForEntity(entitiesToInclude[0].id);
|
|
340
|
+
if (entityClaims.length > 0) {
|
|
341
|
+
claimsToInclude = entityClaims;
|
|
342
|
+
for (const c of entityClaims) {
|
|
343
|
+
for (const evId of c.evidence_ids) {
|
|
344
|
+
const ev = this.store.getEvidence(evId);
|
|
345
|
+
if (ev && !evidenceToInclude.some(e => e.id === ev.id)) {
|
|
346
|
+
evidenceToInclude.push(ev);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return TokenOptimizer.buildPacket({
|
|
353
|
+
question,
|
|
354
|
+
entities: entitiesToInclude,
|
|
355
|
+
claims: claimsToInclude,
|
|
356
|
+
relationships: rels.map(r => ({
|
|
357
|
+
source_id: r.source_id,
|
|
358
|
+
target_id: r.target_id,
|
|
359
|
+
relationship: r.relationship,
|
|
360
|
+
confidence: r.confidence,
|
|
361
|
+
})),
|
|
362
|
+
evidence: evidenceToInclude,
|
|
363
|
+
sources: sourcesMap,
|
|
364
|
+
maxTokens,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
case 'analyze_web_presence': {
|
|
368
|
+
const entityId = String(args.entity_id || '');
|
|
369
|
+
const domain = args.domain ? String(args.domain) : undefined;
|
|
370
|
+
return this.webPresence.analyze(entityId, domain);
|
|
371
|
+
}
|
|
372
|
+
case 'audit_entity_consistency': {
|
|
373
|
+
const entityId = String(args.entity_id || '');
|
|
374
|
+
return this.consistency.audit(entityId);
|
|
375
|
+
}
|
|
376
|
+
case 'export_graph': {
|
|
377
|
+
const format = String(args.format || 'json').toLowerCase();
|
|
378
|
+
if (format === 'jsonld')
|
|
379
|
+
return { format: 'jsonld', content: this.exporter.toJSONLD() };
|
|
380
|
+
if (format === 'csv')
|
|
381
|
+
return { format: 'csv', content: this.exporter.toCSV() };
|
|
382
|
+
if (format === 'graphml')
|
|
383
|
+
return { format: 'graphml', content: this.exporter.toGraphML() };
|
|
384
|
+
return { format: 'json', content: this.exporter.toJSON() };
|
|
385
|
+
}
|
|
386
|
+
default:
|
|
387
|
+
throw new Error(`Unknown ProofGraph tool: ${name}`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,6BA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|
1
|
+
/**
|
|
2
|
+
* ProofGraph Robots.txt Parser & Compliance Engine
|
|
3
|
+
*/
|
|
4
|
+
export interface RobotsRule {
|
|
5
|
+
userAgent: string;
|
|
6
|
+
disallow: string[];
|
|
7
|
+
allow: string[];
|
|
8
|
+
crawlDelay?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class RobotsParser {
|
|
11
|
+
private rules;
|
|
12
|
+
constructor(robotsTxtContent?: string);
|
|
13
|
+
parse(content: string): void;
|
|
14
|
+
isAllowed(pathname: string, userAgent?: string): boolean;
|
|
15
|
+
}
|