@svsprotocol/solana 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 +158 -0
- package/README.md +365 -0
- package/dist/action-production-proof-evidence.js +553 -0
- package/dist/adapter-catalog.d.ts +29 -0
- package/dist/adapter-catalog.js +146 -0
- package/dist/adapter-core.d.ts +48 -0
- package/dist/adapter-core.js +249 -0
- package/dist/approval-signature.js +197 -0
- package/dist/base58.js +69 -0
- package/dist/bot-auth.js +50 -0
- package/dist/bot-certification-evidence.js +342 -0
- package/dist/bot-first-action-runbook.js +299 -0
- package/dist/bot-integration-contract.js +41 -0
- package/dist/certified-submit-status.js +176 -0
- package/dist/common.d.ts +1135 -0
- package/dist/elizaos.d.ts +43 -0
- package/dist/elizaos.js +227 -0
- package/dist/goat.d.ts +47 -0
- package/dist/goat.js +261 -0
- package/dist/index.d.ts +330 -0
- package/dist/index.js +128 -0
- package/dist/protocol.d.ts +205 -0
- package/dist/protocol.js +900 -0
- package/dist/receipt.js +51 -0
- package/dist/signed-proof-read-protection.js +495 -0
- package/dist/solana-agent-kit.d.ts +35 -0
- package/dist/solana-agent-kit.js +151 -0
- package/dist/svs-client.js +1232 -0
- package/dist/vercel-ai.d.ts +47 -0
- package/dist/vercel-ai.js +266 -0
- package/dist/verified-agent-adoption-kit.js +471 -0
- package/dist/verified-agent-profile.js +329 -0
- package/dist/verified-agent-registry-consumer.js +421 -0
- package/dist/verified-agent-registry.d.ts +36 -0
- package/dist/verified-agent-registry.js +826 -0
- package/dist/verified-agent-trust-score.js +335 -0
- package/dist/webhooks.js +834 -0
- package/package.json +72 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { hashObject } from "./receipt.js";
|
|
2
|
+
|
|
3
|
+
export const VERIFIED_AGENT_TRUST_SCORE_VERSION = "svs.verified-agent-trust-score.v1";
|
|
4
|
+
export const VERIFIED_AGENT_TRUST_SCORE_MAX = 100;
|
|
5
|
+
export const VERIFIED_AGENT_TRUST_SCORE_HIGH_TRUST_MIN = 90;
|
|
6
|
+
|
|
7
|
+
export const VERIFIED_AGENT_TRUST_SCORE_SIGNAL_DEFINITIONS = Object.freeze([
|
|
8
|
+
{
|
|
9
|
+
id: "profile_verification",
|
|
10
|
+
label: "Verified-agent profile",
|
|
11
|
+
weight: 15,
|
|
12
|
+
required: true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "registry_membership",
|
|
16
|
+
label: "Registry membership",
|
|
17
|
+
weight: 15,
|
|
18
|
+
required: true
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "production_certification",
|
|
22
|
+
label: "Current production certification",
|
|
23
|
+
weight: 15,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "action_production_proof",
|
|
28
|
+
label: "Fresh action production proof",
|
|
29
|
+
weight: 15,
|
|
30
|
+
required: true
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "custom_registry_proof",
|
|
34
|
+
label: "Custom receipt registry proof",
|
|
35
|
+
weight: 10,
|
|
36
|
+
required: true
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "credential_lifecycle",
|
|
40
|
+
label: "Credential lifecycle health",
|
|
41
|
+
weight: 10,
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: "host_framework_validation",
|
|
46
|
+
label: "Host-framework validation",
|
|
47
|
+
weight: 10,
|
|
48
|
+
required: false
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "secret_safety",
|
|
52
|
+
label: "Secret-safe public evidence",
|
|
53
|
+
weight: 5,
|
|
54
|
+
required: true
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "portable_or_webhook_proof",
|
|
58
|
+
label: "Portable export or webhook proof",
|
|
59
|
+
weight: 5,
|
|
60
|
+
required: false
|
|
61
|
+
}
|
|
62
|
+
].map((signal) => Object.freeze({ ...signal })));
|
|
63
|
+
|
|
64
|
+
export const VERIFIED_AGENT_TRUST_SCORE_POLICY = Object.freeze({
|
|
65
|
+
version: "svs.verified-agent-trust-score-policy.v1",
|
|
66
|
+
scoreVersion: VERIFIED_AGENT_TRUST_SCORE_VERSION,
|
|
67
|
+
maxScore: VERIFIED_AGENT_TRUST_SCORE_MAX,
|
|
68
|
+
highTrustMinimumScore: VERIFIED_AGENT_TRUST_SCORE_HIGH_TRUST_MIN,
|
|
69
|
+
highTrustRequiresEvidenceComplete: true,
|
|
70
|
+
requiredSignalIds: Object.freeze(
|
|
71
|
+
VERIFIED_AGENT_TRUST_SCORE_SIGNAL_DEFINITIONS
|
|
72
|
+
.filter((signal) => signal.required)
|
|
73
|
+
.map((signal) => signal.id)
|
|
74
|
+
),
|
|
75
|
+
optionalSignalIds: Object.freeze(
|
|
76
|
+
VERIFIED_AGENT_TRUST_SCORE_SIGNAL_DEFINITIONS
|
|
77
|
+
.filter((signal) => !signal.required)
|
|
78
|
+
.map((signal) => signal.id)
|
|
79
|
+
),
|
|
80
|
+
signals: VERIFIED_AGENT_TRUST_SCORE_SIGNAL_DEFINITIONS
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export function createVerifiedAgentTrustScore({
|
|
84
|
+
profile = null,
|
|
85
|
+
profileVerification = null,
|
|
86
|
+
registryVerification = null,
|
|
87
|
+
actionProductionProofEvidence = null,
|
|
88
|
+
actionProductionProofVerification = null,
|
|
89
|
+
credentialReadiness = null,
|
|
90
|
+
hostValidation = null,
|
|
91
|
+
generatedAt = new Date()
|
|
92
|
+
} = {}) {
|
|
93
|
+
const generatedAtIso = toIsoString(generatedAt);
|
|
94
|
+
const profileOk = profileVerification?.ok === true ||
|
|
95
|
+
profile?.status?.ok === true && profile?.status?.value === "verified";
|
|
96
|
+
const registryOk = registryVerification?.ok === true ||
|
|
97
|
+
registryVerification?.status === "verified";
|
|
98
|
+
const productionCertificationOk = profile?.status?.ok === true &&
|
|
99
|
+
profile?.certification?.stale !== true &&
|
|
100
|
+
Boolean(profile?.certification?.certificationHash);
|
|
101
|
+
const actionProductionProofOk = actionProductionProofVerification?.ok === true ||
|
|
102
|
+
actionProductionProofEvidence?.productionProof?.ready === true &&
|
|
103
|
+
actionProductionProofEvidence?.request?.requestSignatureVerified === true &&
|
|
104
|
+
actionProductionProofEvidence?.humanApproval?.verified === true &&
|
|
105
|
+
actionProductionProofEvidence?.broadcast?.confirmed === true;
|
|
106
|
+
const customRegistryOk = profile?.proofs?.actionRecordVerificationOk === true &&
|
|
107
|
+
profile?.proofs?.receiptRegistrySubmissionVerificationOk === true ||
|
|
108
|
+
actionProductionProofEvidence?.receiptRegistry?.confirmed === true &&
|
|
109
|
+
actionProductionProofEvidence?.actionRecordVerification?.ok === true;
|
|
110
|
+
const credentialCleanupRequiredCount = Number(credentialReadiness?.summary?.cleanupRequiredCount ??
|
|
111
|
+
credentialReadiness?.credentialCleanup?.expiredPreviousSecretCount ??
|
|
112
|
+
credentialReadiness?.summary?.expiredPreviousGraceCount ??
|
|
113
|
+
0);
|
|
114
|
+
const credentialActiveBotCount = Number(credentialReadiness?.summary?.activeBotCount ??
|
|
115
|
+
credentialReadiness?.summary?.botCount ??
|
|
116
|
+
credentialReadiness?.activeBotCount ??
|
|
117
|
+
0);
|
|
118
|
+
const credentialProductionReadyCount = Number(credentialReadiness?.summary?.productionReadyCount ??
|
|
119
|
+
credentialReadiness?.summary?.productionReadyActionObservedCount ??
|
|
120
|
+
0);
|
|
121
|
+
const credentialLifecycleReady = credentialReadiness?.productionReady === true ||
|
|
122
|
+
credentialReadiness?.status === "production_ready" ||
|
|
123
|
+
credentialReadiness?.summary?.notReadyCount === 0 && credentialActiveBotCount > 0 ||
|
|
124
|
+
credentialProductionReadyCount > 0;
|
|
125
|
+
const credentialLifecycleOk = credentialLifecycleReady &&
|
|
126
|
+
credentialCleanupRequiredCount === 0 &&
|
|
127
|
+
credentialReadiness?.credentialCleanup?.status !== "cleanup_required";
|
|
128
|
+
const hostValidationOk = hostValidation?.ok === true ||
|
|
129
|
+
["ready", "verified"].includes(hostValidation?.status) && (hostValidation?.failedCheckCount ?? 0) === 0;
|
|
130
|
+
const secretSafetyOk = profile?.reportSafety?.secretsIncluded === false &&
|
|
131
|
+
profile?.reportSafety?.sourceEvidenceSecretsIncluded !== true &&
|
|
132
|
+
actionProductionProofEvidence?.reportSafety?.secretsIncluded !== true;
|
|
133
|
+
const portableOrWebhookOk = profile?.proofs?.portableSetVerified === true ||
|
|
134
|
+
actionProductionProofEvidence?.productionProofWebhook?.delivery?.ok === true;
|
|
135
|
+
|
|
136
|
+
const signals = [
|
|
137
|
+
createTrustSignal("profile_verification", profileOk, {
|
|
138
|
+
detail: profileOk
|
|
139
|
+
? `status=${profile?.status?.value ?? profileVerification?.status ?? "verified"}`
|
|
140
|
+
: "Missing a verified profile or successful profile verification.",
|
|
141
|
+
evidence: {
|
|
142
|
+
profileHash: profile?.profileHash ?? profileVerification?.profileHash ?? null,
|
|
143
|
+
status: profile?.status?.value ?? profileVerification?.status ?? null
|
|
144
|
+
}
|
|
145
|
+
}),
|
|
146
|
+
createTrustSignal("registry_membership", registryOk, {
|
|
147
|
+
detail: registryOk
|
|
148
|
+
? `status=${registryVerification?.status ?? "verified"}`
|
|
149
|
+
: "Missing a successful registry verification for this agent.",
|
|
150
|
+
evidence: {
|
|
151
|
+
registryHash: registryVerification?.registryHash ?? null,
|
|
152
|
+
botId: registryVerification?.botId ?? profile?.agent?.botId ?? null
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
createTrustSignal("production_certification", productionCertificationOk, {
|
|
156
|
+
detail: productionCertificationOk
|
|
157
|
+
? `certificationHash=${profile?.certification?.certificationHash}`
|
|
158
|
+
: "Missing a current production certification hash on the verified-agent profile.",
|
|
159
|
+
evidence: {
|
|
160
|
+
certificationHash: profile?.certification?.certificationHash ?? null,
|
|
161
|
+
stale: profile?.certification?.stale ?? null,
|
|
162
|
+
qualityTargetReady: profile?.qualityTarget?.ready ?? null
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
createTrustSignal("action_production_proof", actionProductionProofOk, {
|
|
166
|
+
detail: actionProductionProofOk
|
|
167
|
+
? `recordId=${actionProductionProofEvidence?.productionProof?.recordId ?? actionProductionProofVerification?.recordId ?? "verified"}`
|
|
168
|
+
: "Missing a fresh signed action production proof with bot request, human approval, and broadcast evidence.",
|
|
169
|
+
evidence: {
|
|
170
|
+
recordId: actionProductionProofEvidence?.productionProof?.recordId ?? actionProductionProofVerification?.recordId ?? null,
|
|
171
|
+
evidenceHash: actionProductionProofEvidence?.evidenceHash ?? actionProductionProofVerification?.evidenceHash ?? null
|
|
172
|
+
}
|
|
173
|
+
}),
|
|
174
|
+
createTrustSignal("custom_registry_proof", customRegistryOk, {
|
|
175
|
+
detail: customRegistryOk
|
|
176
|
+
? `receiptAccount=${actionProductionProofEvidence?.receiptRegistry?.receiptAccount ?? "profile-pinned"}`
|
|
177
|
+
: "Missing custom receipt-registry and action-record verification proof.",
|
|
178
|
+
evidence: {
|
|
179
|
+
receiptAccount: actionProductionProofEvidence?.receiptRegistry?.receiptAccount ?? null,
|
|
180
|
+
registrySignature: actionProductionProofEvidence?.receiptRegistry?.signature ?? null
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
createTrustSignal("credential_lifecycle", credentialLifecycleOk, {
|
|
184
|
+
detail: credentialLifecycleOk
|
|
185
|
+
? "Credential readiness is production-ready with no cleanup debt."
|
|
186
|
+
: "Credential readiness is missing, not production-ready, or has cleanup debt.",
|
|
187
|
+
evidence: {
|
|
188
|
+
readinessHash: credentialReadiness?.readinessHash ?? null,
|
|
189
|
+
activeBotCount: Number.isFinite(credentialActiveBotCount) ? credentialActiveBotCount : null,
|
|
190
|
+
productionReadyCount: Number.isFinite(credentialProductionReadyCount) ? credentialProductionReadyCount : null,
|
|
191
|
+
cleanupRequiredCount: Number.isFinite(credentialCleanupRequiredCount) ? credentialCleanupRequiredCount : null,
|
|
192
|
+
cleanupStatus: credentialReadiness?.credentialCleanup?.status ?? null
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
createTrustSignal("host_framework_validation", hostValidationOk, {
|
|
196
|
+
detail: hostValidationOk
|
|
197
|
+
? `status=${hostValidation?.status ?? "verified"}`
|
|
198
|
+
: "Host-framework validation evidence is missing or failed.",
|
|
199
|
+
evidence: {
|
|
200
|
+
status: hostValidation?.status ?? null,
|
|
201
|
+
failedCheckCount: hostValidation?.failedCheckCount ?? null,
|
|
202
|
+
targetCount: hostValidation?.summary?.targetCount ?? hostValidation?.targetCount ?? null
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
createTrustSignal("secret_safety", secretSafetyOk, {
|
|
206
|
+
detail: secretSafetyOk
|
|
207
|
+
? "Public evidence is marked secret-safe."
|
|
208
|
+
: "Public evidence is missing secret-safety flags or reports source secrets.",
|
|
209
|
+
evidence: {
|
|
210
|
+
profileSecretsIncluded: profile?.reportSafety?.secretsIncluded ?? null,
|
|
211
|
+
sourceEvidenceSecretsIncluded: profile?.reportSafety?.sourceEvidenceSecretsIncluded ?? null,
|
|
212
|
+
proofSecretsIncluded: actionProductionProofEvidence?.reportSafety?.secretsIncluded ?? null
|
|
213
|
+
}
|
|
214
|
+
}),
|
|
215
|
+
createTrustSignal("portable_or_webhook_proof", portableOrWebhookOk, {
|
|
216
|
+
detail: portableOrWebhookOk
|
|
217
|
+
? "Portable verification set or signed webhook delivery is present."
|
|
218
|
+
: "Missing portable-set or signed production-proof webhook delivery evidence.",
|
|
219
|
+
evidence: {
|
|
220
|
+
portableSetVerified: profile?.proofs?.portableSetVerified ?? null,
|
|
221
|
+
webhookDeliveryOk: actionProductionProofEvidence?.productionProofWebhook?.delivery?.ok ?? null
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
];
|
|
225
|
+
const score = signals.reduce((sum, signal) => sum + signal.earned, 0);
|
|
226
|
+
const failedSignals = signals.filter((signal) => !signal.ok);
|
|
227
|
+
const blockingSignals = failedSignals.filter((signal) => signal.required);
|
|
228
|
+
const evidenceComplete = blockingSignals.length === 0;
|
|
229
|
+
const status = evidenceComplete && score >= VERIFIED_AGENT_TRUST_SCORE_HIGH_TRUST_MIN
|
|
230
|
+
? "high_trust"
|
|
231
|
+
: score >= 70
|
|
232
|
+
? "needs_review"
|
|
233
|
+
: "low_trust";
|
|
234
|
+
const unsigned = {
|
|
235
|
+
version: VERIFIED_AGENT_TRUST_SCORE_VERSION,
|
|
236
|
+
generatedAt: generatedAtIso,
|
|
237
|
+
status,
|
|
238
|
+
score,
|
|
239
|
+
maxScore: VERIFIED_AGENT_TRUST_SCORE_MAX,
|
|
240
|
+
evidenceComplete,
|
|
241
|
+
botId: profile?.agent?.botId ?? registryVerification?.botId ?? actionProductionProofEvidence?.productionProof?.botId ?? null,
|
|
242
|
+
recordId: actionProductionProofEvidence?.productionProof?.recordId ?? actionProductionProofVerification?.recordId ?? profile?.certification?.recordId ?? null,
|
|
243
|
+
profileHash: profile?.profileHash ?? profileVerification?.profileHash ?? null,
|
|
244
|
+
registryHash: registryVerification?.registryHash ?? null,
|
|
245
|
+
signalCount: signals.length,
|
|
246
|
+
passedSignalCount: signals.length - failedSignals.length,
|
|
247
|
+
failedSignalCount: failedSignals.length,
|
|
248
|
+
blockingSignalCount: blockingSignals.length,
|
|
249
|
+
signals,
|
|
250
|
+
nextAction: createTrustScoreNextAction({ status, failedSignals, blockingSignals })
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
...unsigned,
|
|
255
|
+
trustScoreHash: hashVerifiedAgentTrustScore(unsigned)
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function hashVerifiedAgentTrustScore(score) {
|
|
260
|
+
if (!score || typeof score !== "object") {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const {
|
|
265
|
+
trustScoreHash: _trustScoreHash,
|
|
266
|
+
computedTrustScoreHash: _computedTrustScoreHash,
|
|
267
|
+
...unsigned
|
|
268
|
+
} = score;
|
|
269
|
+
|
|
270
|
+
return hashObject(unsigned);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function createTrustSignal(id, ok, {
|
|
274
|
+
detail,
|
|
275
|
+
evidence
|
|
276
|
+
} = {}) {
|
|
277
|
+
const definition = VERIFIED_AGENT_TRUST_SCORE_SIGNAL_DEFINITIONS.find((item) => item.id === id);
|
|
278
|
+
if (!definition) {
|
|
279
|
+
throw new Error(`Unknown SVS trust score signal: ${id}`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return {
|
|
283
|
+
id,
|
|
284
|
+
label: definition.label,
|
|
285
|
+
weight: definition.weight,
|
|
286
|
+
earned: ok ? definition.weight : 0,
|
|
287
|
+
required: definition.required,
|
|
288
|
+
ok: Boolean(ok),
|
|
289
|
+
detail,
|
|
290
|
+
evidence: pruneNullish(evidence)
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function createTrustScoreNextAction({
|
|
295
|
+
status,
|
|
296
|
+
failedSignals,
|
|
297
|
+
blockingSignals
|
|
298
|
+
}) {
|
|
299
|
+
const firstBlocking = blockingSignals[0];
|
|
300
|
+
const firstFailed = failedSignals[0];
|
|
301
|
+
const target = firstBlocking ?? firstFailed;
|
|
302
|
+
|
|
303
|
+
if (!target) {
|
|
304
|
+
return {
|
|
305
|
+
code: "none",
|
|
306
|
+
message: "Verified-agent trust score has all evidence signals present."
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return {
|
|
311
|
+
code: firstBlocking ? "fix_required_trust_signal" : "improve_optional_trust_signal",
|
|
312
|
+
message: `${status === "needs_review" ? "Improve" : "Fix"} ${target.label}: ${target.detail}`,
|
|
313
|
+
signalId: target.id
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function toIsoString(value) {
|
|
318
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
319
|
+
|
|
320
|
+
if (Number.isNaN(date.getTime())) {
|
|
321
|
+
return new Date().toISOString();
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return date.toISOString();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function pruneNullish(value) {
|
|
328
|
+
if (!value || typeof value !== "object") {
|
|
329
|
+
return {};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
return Object.fromEntries(
|
|
333
|
+
Object.entries(value).filter((entry) => entry[1] !== null && entry[1] !== undefined)
|
|
334
|
+
);
|
|
335
|
+
}
|