@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.
Files changed (38) hide show
  1. package/LICENSE +158 -0
  2. package/README.md +365 -0
  3. package/dist/action-production-proof-evidence.js +553 -0
  4. package/dist/adapter-catalog.d.ts +29 -0
  5. package/dist/adapter-catalog.js +146 -0
  6. package/dist/adapter-core.d.ts +48 -0
  7. package/dist/adapter-core.js +249 -0
  8. package/dist/approval-signature.js +197 -0
  9. package/dist/base58.js +69 -0
  10. package/dist/bot-auth.js +50 -0
  11. package/dist/bot-certification-evidence.js +342 -0
  12. package/dist/bot-first-action-runbook.js +299 -0
  13. package/dist/bot-integration-contract.js +41 -0
  14. package/dist/certified-submit-status.js +176 -0
  15. package/dist/common.d.ts +1135 -0
  16. package/dist/elizaos.d.ts +43 -0
  17. package/dist/elizaos.js +227 -0
  18. package/dist/goat.d.ts +47 -0
  19. package/dist/goat.js +261 -0
  20. package/dist/index.d.ts +330 -0
  21. package/dist/index.js +128 -0
  22. package/dist/protocol.d.ts +205 -0
  23. package/dist/protocol.js +900 -0
  24. package/dist/receipt.js +51 -0
  25. package/dist/signed-proof-read-protection.js +495 -0
  26. package/dist/solana-agent-kit.d.ts +35 -0
  27. package/dist/solana-agent-kit.js +151 -0
  28. package/dist/svs-client.js +1232 -0
  29. package/dist/vercel-ai.d.ts +47 -0
  30. package/dist/vercel-ai.js +266 -0
  31. package/dist/verified-agent-adoption-kit.js +471 -0
  32. package/dist/verified-agent-profile.js +329 -0
  33. package/dist/verified-agent-registry-consumer.js +421 -0
  34. package/dist/verified-agent-registry.d.ts +36 -0
  35. package/dist/verified-agent-registry.js +826 -0
  36. package/dist/verified-agent-trust-score.js +335 -0
  37. package/dist/webhooks.js +834 -0
  38. package/package.json +72 -0
@@ -0,0 +1,421 @@
1
+ import {
2
+ VERIFIED_AGENT_REGISTRY_TRUST_MANIFEST_VERSION,
3
+ hashVerifiedAgentRegistry,
4
+ hashVerifiedAgentRegistryTrustManifest
5
+ } from "./verified-agent-registry.js";
6
+ import { verifyVerifiedAgentProfile } from "./verified-agent-profile.js";
7
+ import {
8
+ VERIFIED_AGENT_TRUST_SCORE_POLICY,
9
+ hashVerifiedAgentTrustScore
10
+ } from "./verified-agent-trust-score.js";
11
+
12
+ export const VERIFIED_AGENT_REGISTRY_CONSUMER_VERIFICATION_VERSION = "svs.verified-agent-registry-consumer-verification.v1";
13
+
14
+ export async function verifyVerifiedAgentRegistryUrl({
15
+ registryUrl,
16
+ trustManifestUrl = null,
17
+ expectedRegistryHash,
18
+ requireVerified = true,
19
+ staleAfterMs = null,
20
+ now = new Date(),
21
+ fetchImpl = globalThis.fetch
22
+ } = {}) {
23
+ if (!registryUrl) {
24
+ throw new Error("registryUrl is required.");
25
+ }
26
+
27
+ if (!expectedRegistryHash) {
28
+ throw new Error("expectedRegistryHash is required.");
29
+ }
30
+
31
+ if (typeof fetchImpl !== "function") {
32
+ throw new Error("fetch implementation is required.");
33
+ }
34
+
35
+ const checkedAt = now instanceof Date ? now.toISOString() : new Date(now).toISOString();
36
+ const registry = await fetchJson({ url: registryUrl, fetchImpl });
37
+ const computedRegistryHash = hashVerifiedAgentRegistry(registry);
38
+ const trustManifestStatus = await fetchAndVerifyTrustManifest({
39
+ registryUrl,
40
+ trustManifestUrl,
41
+ expectedRegistryHash,
42
+ registry,
43
+ fetchImpl
44
+ });
45
+ const checks = [
46
+ check(
47
+ "Registry hash matches pinned expected hash",
48
+ registry?.registryHash === expectedRegistryHash && computedRegistryHash === expectedRegistryHash,
49
+ `expected=${expectedRegistryHash} declared=${registry?.registryHash ?? "missing"} computed=${computedRegistryHash ?? "missing"}`
50
+ ),
51
+ check(
52
+ "Registry profile count matches entries",
53
+ registry?.profileCount === registry?.agents?.length,
54
+ `declared=${registry?.profileCount ?? "missing"} actual=${registry?.agents?.length ?? "missing"}`
55
+ ),
56
+ check(
57
+ "Registry has at least one agent",
58
+ Array.isArray(registry?.agents) && registry.agents.length > 0,
59
+ `count=${registry?.agents?.length ?? "missing"}`
60
+ ),
61
+ ...trustManifestStatus.checks
62
+ ];
63
+ const agents = [];
64
+
65
+ if (Array.isArray(registry?.agents)) {
66
+ for (const [index, agent] of registry.agents.entries()) {
67
+ const agentChecks = [];
68
+ let profile = null;
69
+ let profileUrl = null;
70
+ let verification = null;
71
+ const computedTrustScoreHash = hashVerifiedAgentTrustScore(agent.trustScore);
72
+ const manifestAgent = Array.isArray(trustManifestStatus.manifest?.agents)
73
+ ? trustManifestStatus.manifest.agents.find((item) => item.botId === agent.botId)
74
+ : null;
75
+
76
+ try {
77
+ profileUrl = resolveRegistryUrl(registryUrl, agent.profilePath);
78
+ profile = await fetchJson({ url: profileUrl, fetchImpl });
79
+ verification = verifyVerifiedAgentProfile(profile, {
80
+ requireVerified,
81
+ expectedBotId: agent.botId,
82
+ staleAfterMs,
83
+ now
84
+ });
85
+ } catch (error) {
86
+ agentChecks.push(check(
87
+ "Linked profile can be fetched",
88
+ false,
89
+ error.message
90
+ ));
91
+ }
92
+
93
+ if (profile) {
94
+ agentChecks.push(
95
+ check(
96
+ "Linked profile verifies",
97
+ verification?.ok === true,
98
+ `status=${verification?.status ?? "missing"} failed=${verification?.failedCheckCount ?? "missing"}`
99
+ ),
100
+ check(
101
+ "Registry bot id matches linked profile",
102
+ agent.botId === profile.agent?.botId,
103
+ `registry=${agent.botId ?? "missing"} profile=${profile.agent?.botId ?? "missing"}`
104
+ ),
105
+ check(
106
+ "Registry profile hash matches linked profile",
107
+ agent.profileHash === profile.profileHash,
108
+ `registry=${agent.profileHash ?? "missing"} profile=${profile.profileHash ?? "missing"}`
109
+ ),
110
+ check(
111
+ "Registry status matches linked profile",
112
+ agent.status === profile.status?.value,
113
+ `registry=${agent.status ?? "missing"} profile=${profile.status?.value ?? "missing"}`
114
+ ),
115
+ check(
116
+ "Registry certification hash matches linked profile",
117
+ agent.certificationHash === profile.certification?.certificationHash,
118
+ `registry=${agent.certificationHash ?? "missing"} profile=${profile.certification?.certificationHash ?? "missing"}`
119
+ ),
120
+ check(
121
+ "Registry agent trust score hash is valid",
122
+ !agent.trustScore ||
123
+ agent.trustScore.trustScoreHash === computedTrustScoreHash,
124
+ agent.trustScore
125
+ ? `declared=${agent.trustScore.trustScoreHash ?? "missing"} computed=${computedTrustScoreHash ?? "missing"}`
126
+ : "not present"
127
+ ),
128
+ check(
129
+ "Hosted registry trust manifest agent trust score matches registry",
130
+ !manifestAgent?.trustScore ||
131
+ agentTrustScoreSummaryMatchesRegistry(manifestAgent.trustScore, agent.trustScore),
132
+ manifestAgent?.trustScore
133
+ ? `manifest=${manifestAgent.trustScore.trustScoreHash ?? "missing"} registry=${agent.trustScore?.trustScoreHash ?? "missing"}`
134
+ : "not present"
135
+ )
136
+ );
137
+
138
+ if (verification?.failedChecks?.length) {
139
+ agentChecks.push(...verification.failedChecks.map((item) => ({
140
+ name: `Profile check: ${item.name}`,
141
+ ok: false,
142
+ detail: item.detail
143
+ })));
144
+ }
145
+ }
146
+
147
+ agents.push({
148
+ index,
149
+ botId: agent?.botId ?? null,
150
+ profilePath: agent?.profilePath ?? null,
151
+ profileUrl,
152
+ ok: agentChecks.every((item) => item.ok),
153
+ failedCheckCount: agentChecks.filter((item) => !item.ok).length,
154
+ failedChecks: agentChecks.filter((item) => !item.ok),
155
+ checks: agentChecks,
156
+ profileHash: profile?.profileHash ?? null,
157
+ trustScore: summarizeTrustScore(agent.trustScore, computedTrustScoreHash)
158
+ });
159
+ }
160
+ }
161
+
162
+ checks.push(check(
163
+ "Linked profiles verify",
164
+ agents.every((agent) => agent.ok),
165
+ `failed=${agents.filter((agent) => !agent.ok).length}`
166
+ ));
167
+
168
+ const failedChecks = [
169
+ ...checks.filter((item) => !item.ok),
170
+ ...agents.flatMap((agent) => agent.failedChecks.map((item) => ({
171
+ ...item,
172
+ agentIndex: agent.index,
173
+ botId: agent.botId
174
+ })))
175
+ ];
176
+
177
+ return {
178
+ version: VERIFIED_AGENT_REGISTRY_CONSUMER_VERIFICATION_VERSION,
179
+ ok: failedChecks.length === 0,
180
+ status: failedChecks.length === 0 ? "verified" : "failed",
181
+ checkedAt,
182
+ registryUrl,
183
+ trustManifestUrl: trustManifestStatus.url,
184
+ expectedRegistryHash,
185
+ registryHash: registry?.registryHash ?? null,
186
+ computedRegistryHash,
187
+ trustManifest: trustManifestStatus.summary,
188
+ profileCount: registry?.profileCount ?? null,
189
+ verifiedAgentCount: agents.filter((agent) => agent.ok).length,
190
+ failedCheckCount: failedChecks.length,
191
+ failedChecks,
192
+ checks,
193
+ agents
194
+ };
195
+ }
196
+
197
+ async function fetchAndVerifyTrustManifest({
198
+ registryUrl,
199
+ trustManifestUrl,
200
+ expectedRegistryHash,
201
+ registry,
202
+ fetchImpl
203
+ }) {
204
+ const resolvedTrustManifestUrl = trustManifestUrl ?? resolveRegistryUrl(registryUrl, "trust-manifest.json");
205
+ const checks = [];
206
+ let manifest = null;
207
+
208
+ try {
209
+ manifest = await fetchJson({ url: resolvedTrustManifestUrl, fetchImpl });
210
+ checks.push(check(
211
+ "Hosted registry trust manifest can be fetched",
212
+ true,
213
+ resolvedTrustManifestUrl
214
+ ));
215
+ } catch (error) {
216
+ checks.push(check(
217
+ "Hosted registry trust manifest can be fetched",
218
+ false,
219
+ error.message
220
+ ));
221
+
222
+ return {
223
+ url: resolvedTrustManifestUrl,
224
+ summary: {
225
+ found: false,
226
+ url: resolvedTrustManifestUrl,
227
+ trustManifestHash: null,
228
+ computedTrustManifestHash: null,
229
+ registryHash: null
230
+ },
231
+ checks
232
+ };
233
+ }
234
+
235
+ const computedTrustManifestHash = hashVerifiedAgentRegistryTrustManifest(manifest);
236
+ const manifestAgentsMatchRegistry = trustManifestAgentsMatchRegistry({ manifest, registry });
237
+
238
+ checks.push(
239
+ check(
240
+ "Hosted registry trust manifest version is supported",
241
+ manifest.version === VERIFIED_AGENT_REGISTRY_TRUST_MANIFEST_VERSION,
242
+ manifest.version ?? "missing"
243
+ ),
244
+ check(
245
+ "Hosted registry trust manifest hash is valid",
246
+ manifest.trustManifestHash === computedTrustManifestHash,
247
+ `declared=${manifest.trustManifestHash ?? "missing"} computed=${computedTrustManifestHash ?? "missing"}`
248
+ ),
249
+ check(
250
+ "Hosted registry trust manifest pins expected registry hash",
251
+ manifest.registry?.registryHash === expectedRegistryHash &&
252
+ manifest.registry?.registryHash === registry?.registryHash,
253
+ `expected=${expectedRegistryHash ?? "missing"} manifest=${manifest.registry?.registryHash ?? "missing"} registry=${registry?.registryHash ?? "missing"}`
254
+ ),
255
+ check(
256
+ "Hosted registry trust manifest agent count matches registry",
257
+ manifest.registry?.profileCount === registry?.profileCount &&
258
+ Array.isArray(manifest.agents) &&
259
+ manifest.agents.length === registry?.agents?.length,
260
+ `manifest=${manifest.registry?.profileCount ?? "missing"}/${manifest.agents?.length ?? "missing"} registry=${registry?.profileCount ?? "missing"}/${registry?.agents?.length ?? "missing"}`
261
+ ),
262
+ check(
263
+ "Hosted registry trust manifest agents match registry",
264
+ manifestAgentsMatchRegistry.ok,
265
+ manifestAgentsMatchRegistry.detail
266
+ ),
267
+ check(
268
+ "Hosted registry trust manifest has verifier instructions",
269
+ typeof manifest.verifierInstructions?.cli === "string" &&
270
+ manifest.verifierInstructions.cli.includes("verify:verified-agent-registry-url") &&
271
+ typeof manifest.verifierInstructions?.sdkCall === "string" &&
272
+ manifest.verifierInstructions.sdkCall.includes("verifyVerifiedAgentRegistryUrl"),
273
+ `cli=${manifest.verifierInstructions?.cli ?? "missing"}`
274
+ ),
275
+ check(
276
+ "Hosted registry trust manifest excludes secrets",
277
+ manifest.reportSafety?.secretsIncluded === false && !containsSecretMaterial(manifest),
278
+ `secretsIncluded=${manifest.reportSafety?.secretsIncluded ?? "missing"}`
279
+ )
280
+ );
281
+
282
+ return {
283
+ url: resolvedTrustManifestUrl,
284
+ summary: {
285
+ found: true,
286
+ url: resolvedTrustManifestUrl,
287
+ trustManifestHash: manifest.trustManifestHash ?? null,
288
+ computedTrustManifestHash,
289
+ registryHash: manifest.registry?.registryHash ?? null,
290
+ agentCount: Array.isArray(manifest.agents) ? manifest.agents.length : null,
291
+ trustScorePolicy: summarizeTrustScorePolicy(manifest.trustScorePolicy)
292
+ },
293
+ manifest,
294
+ checks
295
+ };
296
+ }
297
+
298
+ function trustManifestAgentsMatchRegistry({ manifest, registry }) {
299
+ if (!Array.isArray(manifest?.agents) || !Array.isArray(registry?.agents)) {
300
+ return {
301
+ ok: false,
302
+ detail: `manifest=${manifest?.agents?.length ?? "missing"} registry=${registry?.agents?.length ?? "missing"}`
303
+ };
304
+ }
305
+
306
+ const manifestByBotId = new Map(manifest.agents.map((agent) => [agent.botId, agent]));
307
+ const mismatches = [];
308
+
309
+ for (const registryAgent of registry.agents) {
310
+ const manifestAgent = manifestByBotId.get(registryAgent.botId);
311
+
312
+ if (!manifestAgent) {
313
+ mismatches.push(`${registryAgent.botId}: missing`);
314
+ continue;
315
+ }
316
+
317
+ for (const key of ["name", "status", "profileHash", "certificationHash", "recordId", "profilePath", "badgePath", "pagePath"]) {
318
+ if ((manifestAgent[key] ?? null) !== (registryAgent[key] ?? null)) {
319
+ mismatches.push(`${registryAgent.botId}: ${key}`);
320
+ }
321
+ }
322
+
323
+ if (!agentTrustScoreSummaryMatchesRegistry(manifestAgent.trustScore, registryAgent.trustScore)) {
324
+ mismatches.push(`${registryAgent.botId}: trustScore`);
325
+ }
326
+ }
327
+
328
+ return {
329
+ ok: mismatches.length === 0,
330
+ detail: mismatches.length === 0 ? "matched" : `mismatches=${mismatches.slice(0, 5).join(", ")}`
331
+ };
332
+ }
333
+
334
+ async function fetchJson({ url, fetchImpl }) {
335
+ const response = await fetchImpl(url);
336
+
337
+ if (!response?.ok) {
338
+ throw new Error(`HTTP ${response?.status ?? "unknown"} while fetching ${url}`);
339
+ }
340
+
341
+ return response.json();
342
+ }
343
+
344
+ function resolveRegistryUrl(registryUrl, relativePath) {
345
+ if (!relativePath || typeof relativePath !== "string") {
346
+ throw new Error("registry agent profilePath is required.");
347
+ }
348
+
349
+ if (/^[a-z][a-z0-9+.-]*:/i.test(relativePath)) {
350
+ throw new Error("registry agent profilePath must be relative.");
351
+ }
352
+
353
+ return new URL(relativePath, registryUrl).toString();
354
+ }
355
+
356
+ function check(name, ok, detail = "") {
357
+ return { name, ok: Boolean(ok), detail };
358
+ }
359
+
360
+ function summarizeTrustScore(trustScore, computedTrustScoreHash = hashVerifiedAgentTrustScore(trustScore)) {
361
+ if (!trustScore) {
362
+ return null;
363
+ }
364
+
365
+ return {
366
+ version: trustScore.version ?? null,
367
+ status: trustScore.status ?? null,
368
+ score: Number.isFinite(trustScore.score) ? trustScore.score : null,
369
+ maxScore: Number.isFinite(trustScore.maxScore) ? trustScore.maxScore : null,
370
+ evidenceComplete: trustScore.evidenceComplete === true,
371
+ blockingSignalCount: Number.isFinite(trustScore.blockingSignalCount) ? trustScore.blockingSignalCount : null,
372
+ passedSignalCount: Number.isFinite(trustScore.passedSignalCount) ? trustScore.passedSignalCount : null,
373
+ failedSignalCount: Number.isFinite(trustScore.failedSignalCount) ? trustScore.failedSignalCount : null,
374
+ trustScoreHash: trustScore.trustScoreHash ?? null,
375
+ computedTrustScoreHash,
376
+ hashValid: Boolean(trustScore.trustScoreHash) && trustScore.trustScoreHash === computedTrustScoreHash,
377
+ highTrustMinimumScore: VERIFIED_AGENT_TRUST_SCORE_POLICY.highTrustMinimumScore,
378
+ nextAction: trustScore.nextAction ?? null
379
+ };
380
+ }
381
+
382
+ function summarizeTrustScorePolicy(policy) {
383
+ if (!policy) {
384
+ return null;
385
+ }
386
+
387
+ return {
388
+ version: policy.version ?? null,
389
+ scoreVersion: policy.scoreVersion ?? null,
390
+ highTrustMinimumScore: policy.highTrustMinimumScore ?? null,
391
+ maxScore: policy.maxScore ?? null,
392
+ highTrustRequiresEvidenceComplete: policy.highTrustRequiresEvidenceComplete === true,
393
+ requiredSignalIds: Array.isArray(policy.requiredSignalIds) ? policy.requiredSignalIds : [],
394
+ optionalSignalIds: Array.isArray(policy.optionalSignalIds) ? policy.optionalSignalIds : []
395
+ };
396
+ }
397
+
398
+ function agentTrustScoreSummaryMatchesRegistry(manifestTrustScore, registryTrustScore) {
399
+ if (!manifestTrustScore && !registryTrustScore) {
400
+ return true;
401
+ }
402
+
403
+ if (!manifestTrustScore || !registryTrustScore) {
404
+ return false;
405
+ }
406
+
407
+ return [
408
+ "status",
409
+ "score",
410
+ "maxScore",
411
+ "evidenceComplete",
412
+ "blockingSignalCount",
413
+ "trustScoreHash"
414
+ ].every((key) => (manifestTrustScore[key] ?? null) === (registryTrustScore[key] ?? null));
415
+ }
416
+
417
+ function containsSecretMaterial(value) {
418
+ const text = JSON.stringify(value ?? {});
419
+
420
+ return /(svs_live|svs_req_live|BEGIN PRIVATE KEY|secret-value)/i.test(text);
421
+ }
@@ -0,0 +1,36 @@
1
+ import type {
2
+ JsonObject,
3
+ SvsVerifiedAgentRegistry,
4
+ SvsVerifiedAgentRegistryBuildOptions,
5
+ SvsVerifiedAgentRegistryTrustManifest,
6
+ SvsVerifiedAgentRegistryVerificationOptions,
7
+ SvsVerifiedAgentRegistryVerification
8
+ } from "./common.js";
9
+
10
+ export type {
11
+ SvsVerifiedAgentRegistry,
12
+ SvsVerifiedAgentRegistryBuildOptions,
13
+ SvsVerifiedAgentRegistryTrustManifest,
14
+ SvsVerifiedAgentRegistryVerificationOptions,
15
+ SvsVerifiedAgentRegistryVerification
16
+ } from "./common.js";
17
+
18
+ export const DEFAULT_VERIFIED_AGENT_REGISTRY_DIR: string;
19
+ export const VERIFIED_AGENT_REGISTRY_BUILD_VERSION: "svs.verified-agent-registry-build.v1";
20
+ export const VERIFIED_AGENT_REGISTRY_TRUST_MANIFEST_VERSION: "svs.verified-agent-registry-trust-manifest.v1";
21
+ export const VERIFIED_AGENT_REGISTRY_VERIFICATION_VERSION: "svs.verified-agent-registry-verification.v1";
22
+ export const VERIFIED_AGENT_REGISTRY_VERSION: "svs.verified-agent-registry.v1";
23
+
24
+ export function buildVerifiedAgentRegistry(options: SvsVerifiedAgentRegistryBuildOptions): Promise<JsonObject>;
25
+
26
+ export function createVerifiedAgentRegistryTrustManifest(options?: {
27
+ title?: string;
28
+ generatedAt?: Date | string;
29
+ registry: SvsVerifiedAgentRegistry;
30
+ }): SvsVerifiedAgentRegistryTrustManifest;
31
+
32
+ export function hashVerifiedAgentRegistry(registry: unknown): string | null;
33
+
34
+ export function hashVerifiedAgentRegistryTrustManifest(manifest: unknown): string | null;
35
+
36
+ export function verifyVerifiedAgentRegistry(options?: SvsVerifiedAgentRegistryVerificationOptions): Promise<SvsVerifiedAgentRegistryVerification>;