forked from agent0lab/subgraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.graphql
More file actions
279 lines (221 loc) · 6.75 KB
/
Copy pathschema.graphql
File metadata and controls
279 lines (221 loc) · 6.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# Agent0 SDK Subgraph Schema
# Comprehensive indexing for ERC-8004 Agent Discovery and Trust
# =============================================================================
# CORE ENTITIES
# =============================================================================
type Agent @entity(immutable: false) {
# Primary identifiers
id: ID! # Format: "chainId:agentId" (e.g., "11155111:123")
chainId: BigInt!
agentId: BigInt!
# Basic on-chain information
agentURI: String
agentURIType: String # "ipfs", "https", "http", "unknown"
# Ownership and permissions
owner: Bytes! # Address
agentWallet: Bytes # Address (20 bytes). Sourced from on-chain MetadataSet(metadataKey == "agentWallet")
operators: [Bytes!]! # List of approved operators
# Status and metadata
createdAt: BigInt!
updatedAt: BigInt!
# Link to IPFS registration file (source of truth, immutable)
registrationFile: AgentRegistrationFile
# Relationships
feedback: [Feedback!]! @derivedFrom(field: "agent")
validations: [Validation!]! @derivedFrom(field: "agent")
metadata: [AgentMetadata!]! @derivedFrom(field: "agent")
# Computed fields for search
totalFeedback: BigInt!
lastActivity: BigInt!
}
type Feedback @entity(immutable: false) {
# Primary identifier
id: ID! # Format: "chainId:agentId:clientAddress:feedbackIndex"
# Relationships
agent: Agent!
clientAddress: Bytes!
feedbackIndex: BigInt!
# On-chain feedback data
value: BigDecimal!
tag1: String
tag2: String
endpoint: String
feedbackURI: String
feedbackURIType: String
feedbackHash: Bytes
# Status
isRevoked: Boolean!
createdAt: BigInt!
revokedAt: BigInt
# Link to IPFS feedback file (source of truth, immutable)
feedbackFile: FeedbackFile
# Response data
responses: [FeedbackResponse!]! @derivedFrom(field: "feedback")
}
type FeedbackResponse @entity(immutable: false) {
id: ID! # Format: "feedbackId:responseIndex"
feedback: Feedback!
responder: Bytes!
responseUri: String
responseHash: Bytes
createdAt: BigInt!
}
type Validation @entity(immutable: false) {
# Primary identifier
id: ID! # requestHash
# Relationships
agent: Agent!
validatorAddress: Bytes!
# Validation data
requestUri: String
requestHash: Bytes!
response: Int # 0-100, 0 means pending
responseUri: String
responseHash: Bytes
tag: String
# Status
status: ValidationStatus!
createdAt: BigInt!
updatedAt: BigInt!
}
type AgentMetadata @entity(immutable: false) {
id: ID! # Format: "chainId:agentId:key"
agent: Agent!
key: String!
value: Bytes!
updatedAt: BigInt!
}
# =============================================================================
# ENUMS
# =============================================================================
enum ValidationStatus {
PENDING
COMPLETED
EXPIRED
}
# =============================================================================
# AGGREGATION ENTITIES (for analytics and search)
# =============================================================================
type AgentStats @entity(immutable: false) {
id: ID! # "chainId:agentId"
agent: Agent!
# Feedback statistics
totalFeedback: BigInt!
averageFeedbackValue: BigDecimal!
# Validation statistics
totalValidations: BigInt!
completedValidations: BigInt!
averageValidationScore: BigDecimal!
# Activity metrics
lastActivity: BigInt!
updatedAt: BigInt!
}
# =============================================================================
# PROTOCOL ENTITIES
# =============================================================================
type Protocol @entity(immutable: false) {
id: ID! # "chainId"
chainId: BigInt!
name: String!
# Registry addresses
identityRegistry: Bytes!
reputationRegistry: Bytes!
validationRegistry: Bytes!
# Total counts (symmetric with GlobalStats)
totalAgents: BigInt!
totalFeedback: BigInt!
totalValidations: BigInt!
# Search and discovery data (chain-specific)
agents: [Agent!]! # Array of agents on this chain
tags: [String!]! # All unique tags on this chain
# Timestamps
updatedAt: BigInt!
}
# =============================================================================
# GLOBAL STATISTICS
# =============================================================================
type GlobalStats @entity(immutable: false) {
id: ID! # "global"
# Total counts
totalAgents: BigInt!
totalFeedback: BigInt!
totalValidations: BigInt!
totalProtocols: BigInt!
# Search and discovery data
agents: [Agent!]! # Array of all agents
tags: [String!]! # All unique tags
# Timestamps
updatedAt: BigInt!
}
# =============================================================================
# IMMUTABLE FILE-BASED ENTITIES (IPFS Data Sources)
# =============================================================================
type AgentRegistrationFile @entity(immutable: true) {
id: ID! # Format: "transactionHash:cid"
cid: String! # IPFS CID (for querying by content)
# Agent link (passed via context)
agentId: String! # Format: "chainId:agentId"
# IPFS file data
name: String
description: String
image: String
active: Boolean
x402Support: Boolean
supportedTrusts: [String!]!
# Endpoints
endpointsRawJson: String
mcpEndpoint: String
mcpVersion: String
a2aEndpoint: String
a2aVersion: String
webEndpoint: String
oasfEndpoint: String
oasfVersion: String
oasfSkills: [String!]!
oasfDomains: [String!]!
# Derived convenience flag for exact filtering: true if oasfSkills or oasfDomains is non-empty.
hasOASF: Boolean!
emailEndpoint: String
# External identifiers
ens: String
did: String
# Capabilities (not implemented yet)
mcpTools: [String!]!
mcpPrompts: [String!]!
mcpResources: [String!]!
a2aSkills: [String!]!
createdAt: BigInt!
}
type FeedbackFile @entity(immutable: true) {
id: ID! # Format: "transactionHash:cid"
cid: String! # IPFS CID (for querying by content)
# Feedback link (passed via context)
feedbackId: String! # Format: "chainId:agentId:clientAddress:feedbackIndex"
# ERC-8004 off-chain feedback envelope (spec)
agentRegistry: String
agentId: BigInt
clientAddress: String
createdAtIso: String
valueRaw: BigInt
valueDecimals: Int
# IPFS file data (rich/off-chain)
text: String
# ERC-8004 nested objects (spec)
mcpTool: String
mcpPrompt: String
mcpResource: String
a2aSkills: [String!]!
a2aContextId: String
a2aTaskId: String
oasfSkills: [String!]!
oasfDomains: [String!]!
# Proof of payment
proofOfPaymentFromAddress: String
proofOfPaymentToAddress: String
proofOfPaymentChainId: String
proofOfPaymentTxHash: String
# Tags (only if on-chain tags are empty)
tag1: String
tag2: String
createdAt: BigInt!
}