Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: add SAS credential issuance and retrieval endpoints with database integration
nirholase2db3d9f5fb2
diff --git a/api/_lib/sas.js b/api/_lib/sas.jsnew file mode 100644index 000000000..658e3da53--- /dev/null+++ b/api/_lib/sas.js@@ -0,0 +1,157 @@+// Solana Attestation Service (SAS) helpers — server-side issuance.+//+// Used to issue *credentialed* attestations: things only three.ws (or our+// authorized validators) can write. Permissionless attestations (general+// feedback, task lifecycle, dispute, revoke) keep using SPL Memos — see+// solana-attestations.js.+//+// The authority secret signs every SAS attestation written by this server.++import fs from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';+import bs58 from 'bs58';+import {+ createSolanaRpc, createSolanaRpcSubscriptions, createKeyPairSignerFromBytes,+ address, generateKeyPair, getAddressFromPublicKey,+ pipe, createTransactionMessage, setTransactionMessageFeePayerSigner,+ setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions,+ signTransactionMessageWithSigners, getSignatureFromTransaction,+ sendAndConfirmTransactionFactory,+} from '@solana/kit';+import {+ deriveAttestationPda, getCreateAttestationInstruction, getCloseAttestationInstruction,+ deriveEventAuthorityAddress,+} from 'sas-lib';+import { BorshSchema } from 'borsher';++const __dirname = path.dirname(fileURLToPath(import.meta.url));+const CONFIG_PATH = path.join(__dirname, '..', '..', 'sdk', 'src', 'sas-config.json');+const CONFIG = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'));++const RPC = {+ mainnet: process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com',+ devnet: process.env.SOLANA_RPC_URL_DEVNET || 'https://api.devnet.solana.com',+};++const TYPE_TO_BORSH = {+ 0: BorshSchema.u8, 10: BorshSchema.bool, 12: BorshSchema.String,+};++function buildBorsh(layout, fieldNames) {+ const fields = {};+ layout.forEach((b, i) => {+ const t = TYPE_TO_BORSH[b];+ if (!t) throw new Error(`unsupported layout byte ${b}`);+ fields[fieldNames[i]] = t;+ });+ return BorshSchema.Struct(fields);+}++function authoritySigner() {+ const secret = process.env.SAS_AUTHORITY_SECRET;+ if (!secret) throw new Error('SAS_AUTHORITY_SECRET not configured');+ return createKeyPairSignerFromBytes(bs58.decode(secret));+}++function pdas(network) {+ const p = CONFIG.pdas?.[network];+ if (!p?.credential) throw new Error(`SAS not bootstrapped for ${network} — run scripts/sas-bootstrap.js ${network}`);+ return p;+}++/**+ * Issue a SAS attestation under one of our schemas.+ *+ * @param {object} opts+ * @param {string} opts.kind — e.g. 'threews.verified-client.v1'+ * @param {string} opts.subject — base58 pubkey the attestation is about (used as nonce)+ * @param {object} opts.data — fields matching the schema's layout+ * @param {bigint|number} [opts.expiry=0] — unix seconds; 0 = no expiry+ * @param {'mainnet'|'devnet'} opts.network+ * @returns {Promise<{signature, attestation_pda, schema_pda, credential_pda}>}+ */+export async function sasIssue({ kind, subject, data, expiry = 0, network }) {+ const def = CONFIG.schemas[kind];+ if (!def) throw new Error(`unknown schema kind ${kind}`);+ const p = pdas(network);+ const schemaPda = p.schemas[kind];+ if (!schemaPda) throw new Error(`schema ${kind} not registered on ${network}`);++ const borsh = buildBorsh(def.layout, def.fieldNames);+ const dataBytes = borsh.serialize(data);++ const authority = await authoritySigner();+ const subjectAddr = address(subject);+ const [attestationPda] = await deriveAttestationPda({+ credential: address(p.credential),+ schema: address(schemaPda),+ nonce: subjectAddr,+ });++ const ix = getCreateAttestationInstruction({+ payer: authority,+ authority,+ credential: address(p.credential),+ schema: address(schemaPda),+ attestation: attestationPda,+ nonce: subjectAddr,+ data: dataBytes,+ expiry: BigInt(expiry),+ });++ const sig = await sendIx(network, authority, ix);+ return {+ signature: sig,+ attestation_pda: attestationPda,+ schema_pda: schemaPda,+ credential_pda: p.credential,+ };+}++/**+ * Close (revoke) a SAS attestation we issued. Only the credential authority+ * can close.+ */+export async function sasClose({ kind, subject, network }) {+ const p = pdas(network);+ const schemaPda = p.schemas[kind];+ const authority = await authoritySigner();+ const [attestationPda] = await deriveAttestationPda({+ credential: address(p.credential),+ schema: address(schemaPda),+ nonce: address(subject),+ });+ const eventAuthority = await deriveEventAuthorityAddress();++ const ix = getCloseAttestationInstruction({+ payer: authority,+ authority,+ credential: address(p.credential),+ attestation: attestationPda,+ eventAuthority,+ attestationProgram: undefined,+ });+ const sig = await sendIx(network, authority, ix);+ return { signature: sig, attestation_pda: attestationPda };+}++async function sendIx(network, payer, ix) {+ const rpcUrl = RPC[network];+ const rpc = createSolanaRpc(rpcUrl);+ const rpcSubs = createSolanaRpcSubscriptions(rpcUrl.replace(/^http/, 'ws'));+ const send = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions: rpcSubs });++ const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();+ const msg = pipe(+ createTransactionMessage({ version: 0 }),+ (m) => setTransactionMessageFeePayerSigner(payer, m),+ (m) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, m),+ (m) => appendTransactionMessageInstructions([ix], m),+ );+ const signed = await signTransactionMessageWithSigners(msg);+ await send(signed, { commitment: 'confirmed' });+ return getSignatureFromTransaction(signed);+}++export const SAS_CONFIG = CONFIG;diff --git a/api/_lib/schema.sql b/api/_lib/schema.sqlindex 1a0bb5c50..690295c06 100644--- a/api/_lib/schema.sql+++ b/api/_lib/schema.sql@@ -442,6 +442,27 @@ create table if not exists solana_attestations_cursor (last_indexed_at timestamptz not null default now());+-- ── SAS credentials (credentialed attestations issued by three.ws authority) ──+-- Permissionless attestations live in solana_attestations (memo-based);+-- this table is the credentialed counterpart for things only we can issue+-- (verified-client, audited-validation, etc.). Used to weight reputation.+create table if not exists solana_credentials (+ attestation_pda text primary key,+ network text not null,+ schema_pda text not null,+ credential_pda text not null,+ kind text not null, -- e.g. threews.verified-client.v1+ subject text not null, -- nonce; wallet or agent asset pubkey+ issuer_signature text not null, -- tx sig of issuance+ data jsonb not null default '{}'::jsonb,+ expiry timestamptz,+ closed boolean not null default false,+ closed_at timestamptz,+ issued_at timestamptz not null default now()+);+create index if not exists solana_creds_subject_kind on solana_credentials(subject, kind) where closed = false;+create index if not exists solana_creds_kind on solana_credentials(kind, issued_at desc);+-- Additive migrations for usage_events.alter table usage_events add column if not exists agent_id uuid references agent_identities(id) on delete set null;create index if not exists usage_events_agent_time on usage_events(agent_id, created_at desc) where agent_id is not null;diff --git a/api/agents/sas-credentials.js b/api/agents/sas-credentials.jsnew file mode 100644index 000000000..c40b7d2ca--- /dev/null+++ b/api/agents/sas-credentials.js@@ -0,0 +1,50 @@+/**+ * GET /api/agents/sas-credentials?subject=<pubkey>&network=devnet|mainnet&kind=...+ *+ * Read SAS credentials issued to a wallet or agent (subject = nonce).+ * Public; backed by solana_credentials cache.+ */++import { sql } from '../_lib/db.js';+import { cors, json, method, wrap, error } from '../_lib/http.js';+import { limits, clientIp } from '../_lib/rate-limit.js';++export default wrap(async (req, res) => {+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: false })) return;+ if (!method(req, res, ['GET'])) return;++ const rl = await limits.authIp(clientIp(req));+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');++ const url = new URL(req.url, `http://${req.headers.host}`);+ const subject = url.searchParams.get('subject');+ const network = url.searchParams.get('network') === 'mainnet' ? 'mainnet' : 'devnet';+ const kind = url.searchParams.get('kind') || null;+ const includeClosed = url.searchParams.get('include_closed') === '1';++ if (!subject) return error(res, 400, 'validation_error', 'subject required');++ const rows = kind+ ? await sql`+ select attestation_pda, schema_pda, credential_pda, kind, subject,+ issuer_signature, data, expiry, closed, issued_at+ from solana_credentials+ where subject = ${subject} and network = ${network} and kind = ${kind}+ and (${includeClosed} or closed = false)+ and (expiry is null or expiry > now())+ order by issued_at desc+ `+ : await sql`+ select attestation_pda, schema_pda, credential_pda, kind, subject,+ issuer_signature, data, expiry, closed, issued_at+ from solana_credentials+ where subject = ${subject} and network = ${network}+ and (${includeClosed} or closed = false)+ and (expiry is null or expiry > now())+ order by issued_at desc+ `;++ return json(res, 200, {+ subject, network, kind, count: rows.length, data: rows,+ });+});diff --git a/api/agents/sas-issue-credential.js b/api/agents/sas-issue-credential.jsnew file mode 100644index 000000000..5715342ec--- /dev/null+++ b/api/agents/sas-issue-credential.js@@ -0,0 +1,97 @@+/**+ * POST /api/agents/sas-issue-credential+ *+ * Admin-only. Issues a credentialed SAS attestation under the three.ws+ * credential authority, then caches it in solana_credentials so the+ * reputation weighting can use it without an RPC roundtrip.+ *+ * Body:+ * { kind: 'threews.verified-client.v1' | 'threews.audited-validation.v1',+ * subject: <base58 pubkey>,+ * data: { ...schema fields },+ * expiry?: <unix seconds>,+ * network?: 'devnet' | 'mainnet' }+ */++import { z } from 'zod';+import { sql } from '../_lib/db.js';+import { cors, json, method, readJson, wrap, error } from '../_lib/http.js';+import { parse } from '../_lib/validate.js';+import { limits, clientIp } from '../_lib/rate-limit.js';+import { requireAdmin } from '../_lib/admin.js';+import { sasIssue, SAS_CONFIG } from '../_lib/sas.js';++const SCHEMAS = Object.keys(SAS_CONFIG.schemas);++const bodySchema = z.object({+ kind: z.enum(SCHEMAS),+ subject: z.string().min(32).max(44),+ data: z.record(z.any()).default({}),+ expiry: z.number().int().nonnegative().default(0),+ network: z.enum(['devnet', 'mainnet']).default('devnet'),+});++export default wrap(async (req, res) => {+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;+ if (!method(req, res, ['POST'])) return;++ const admin = await requireAdmin(req, res);+ if (!admin) return;++ const rl = await limits.authIp(clientIp(req));+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');++ const body = parse(bodySchema, await readJson(req));++ // Validate required fields are present and types are right.+ const def = SAS_CONFIG.schemas[body.kind];+ for (let i = 0; i < def.fieldNames.length; i++) {+ const fname = def.fieldNames[i];+ const v = body.data[fname];+ if (v === undefined) return error(res, 400, 'validation_error', `missing field: ${fname}`);+ const t = def.layout[i];+ if (t === 12 && typeof v !== 'string') return error(res, 400, 'validation_error', `${fname} must be string`);+ if (t === 10 && typeof v !== 'boolean') return error(res, 400, 'validation_error', `${fname} must be bool`);+ if (t === 0 && (!Number.isInteger(v) || v < 0 || v > 255)) return error(res, 400, 'validation_error', `${fname} must be u8`);+ }++ let result;+ try {+ result = await sasIssue({+ kind: body.kind,+ subject: body.subject,+ data: body.data,+ expiry: body.expiry,+ network: body.network,+ });+ } catch (e) {+ return error(res, 500, 'sas_issue_failed', e.message || String(e));+ }++ const expiryDate = body.expiry > 0 ? new Date(body.expiry * 1000) : null;+ await sql`+ insert into solana_credentials+ (attestation_pda, network, schema_pda, credential_pda, kind, subject,+ issuer_signature, data, expiry)+ values (+ ${result.attestation_pda}, ${body.network}, ${result.schema_pda},+ ${result.credential_pda}, ${body.kind}, ${body.subject},+ ${result.signature}, ${JSON.stringify(body.data)}::jsonb, ${expiryDate}+ )+ on conflict (attestation_pda) do update set+ data = excluded.data,+ expiry = excluded.expiry,+ issuer_signature = excluded.issuer_signature,+ closed = false,+ closed_at = null+ `;++ return json(res, 201, {+ signature: result.signature,+ attestation_pda: result.attestation_pda,+ schema_pda: result.schema_pda,+ credential_pda: result.credential_pda,+ kind: body.kind,+ subject: body.subject,+ });+});diff --git a/api/agents/solana-attest-event.js b/api/agents/solana-attest-event.jsnew file mode 100644index 000000000..ee800f0e7--- /dev/null+++ b/api/agents/solana-attest-event.js@@ -0,0 +1,166 @@+// Pumpkit -> attestation bridge.+// Receives a signed webhook from a pumpkit monitor and emits a+// threews.* SPL Memo on Solana, then mirrors it into solana_attestations+// so reputation reflects the event without waiting for the crawler.++import crypto from 'node:crypto';+import {+ Connection,+ Keypair,+ PublicKey,+ Transaction,+ TransactionInstruction,+ sendAndConfirmTransaction,+} from '@solana/web3.js';+import bs58 from 'bs58';+import { z } from 'zod';++import { sql } from '../_lib/db.js';+import { cors, json, method, wrap, error, readJson } from '../_lib/http.js';+import { parse } from '../_lib/validate.js';+import { limits, clientIp } from '../_lib/rate-limit.js';+import { RPC, KIND_MAP } from '../_lib/solana-attestations.js';++const MEMO_PROGRAM_ID = new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');++const bodySchema = z.object({+ event_type: z.enum(['graduation', 'fee_claim', 'whale_trade', 'cto_detected']),+ agent_asset: z.string().min(32).max(44),+ network: z.enum(['mainnet', 'devnet']),+ token_mint: z.string().min(32).max(44),+ task_id: z.string().min(1).max(128),+ detail: z.record(z.unknown()).optional(),+});++// Map a pumpkit event onto a 3ws attestation envelope.+function buildPayload({ event_type, agent_asset, token_mint, task_id, detail }) {+ const base = { v: 1, agent: agent_asset, ts: Math.floor(Date.now() / 1000) };+ switch (event_type) {+ case 'graduation':+ return {+ ...base,+ kind: KIND_MAP.validation,+ task_hash: task_hash(task_id, token_mint),+ passed: true,+ source: 'pumpkit.graduation',+ token: token_mint,+ };+ case 'fee_claim':+ return {+ ...base,+ kind: KIND_MAP.feedback,+ score: 5,+ source: 'pumpkit.fee_claim',+ token: token_mint,+ detail: detail ?? null,+ };+ case 'whale_trade':+ return {+ ...base,+ kind: KIND_MAP.task,+ task_id,+ scope_hash: task_hash(task_id, token_mint),+ source: 'pumpkit.whale',+ };+ case 'cto_detected':+ return {+ ...base,+ kind: KIND_MAP.validation,+ task_hash: task_hash(task_id, token_mint),+ passed: false,+ source: 'pumpkit.cto',+ token: token_mint,+ };+ }+}++function task_hash(task_id, token_mint) {+ return crypto.createHash('sha256').update(`${task_id}:${token_mint}`).digest('hex');+}++function verifyPumpkitSignature(req, raw) {+ const secret = process.env.PUMPKIT_WEBHOOK_SECRET;+ if (!secret) throw Object.assign(new Error('webhook secret not configured'), { status: 500 });+ const got = req.headers['x-pumpkit-signature'];+ if (!got || typeof got !== 'string') return false;+ const expect = crypto.createHmac('sha256', secret).update(raw).digest('hex');+ const a = Buffer.from(got, 'hex');+ const b = Buffer.from(expect, 'hex');+ return a.length === b.length && crypto.timingSafeEqual(a, b);+}++function loadAttesterKeypair() {+ const k = process.env.ATTEST_AGENT_SECRET_KEY;+ if (!k) throw Object.assign(new Error('attester key not configured'), { status: 500 });+ return Keypair.fromSecretKey(bs58.decode(k));+}++export default wrap(async (req, res) => {+ if (cors(req, res, { methods: 'POST,OPTIONS' })) return;+ if (!method(req, res, ['POST'])) return;++ const rl = await limits.authIp(clientIp(req));+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');++ // Read raw body once for HMAC, then parse.+ const raw = await readBuffered(req);+ if (!verifyPumpkitSignature(req, raw)) {+ return error(res, 401, 'unauthorized', 'invalid webhook signature');+ }+ let parsed;+ try { parsed = JSON.parse(raw.toString('utf8')); }+ catch { return error(res, 400, 'validation_error', 'invalid JSON'); }+ const body = parse(bodySchema, parsed);++ const payload = buildPayload(body);+ const memo = JSON.stringify(payload);++ const conn = new Connection(RPC[body.network], 'confirmed');+ const attester = loadAttesterKeypair();+ const agentKey = new PublicKey(body.agent_asset);++ // Memo with the agent asset as a signer-less referenced key, so+ // getSignaturesForAddress(agent) finds the tx during crawl.+ const ix = new TransactionInstruction({+ programId: MEMO_PROGRAM_ID,+ keys: [+ { pubkey: attester.publicKey, isSigner: true, isWritable: false },+ { pubkey: agentKey, isSigner: false, isWritable: false },+ ],+ data: Buffer.from(memo, 'utf8'),+ });++ const tx = new Transaction().add(ix);+ const signature = await sendAndConfirmTransaction(conn, tx, [attester], {+ commitment: 'confirmed',+ });++ // Mirror into the index immediately. The crawler will dedupe via+ // the unique signature constraint.+ await sql`+ insert into solana_attestations (+ signature, network, slot, block_time, agent_asset, attester,+ kind, payload, task_id, target_signature, verified+ )+ values (+ ${signature}, ${body.network}, null, now(),+ ${body.agent_asset}, ${attester.publicKey.toBase58()},+ ${payload.kind}, ${JSON.stringify(payload)}::jsonb,+ ${payload.task_id ?? null}, null, false+ )+ on conflict (signature) do nothing+ `;++ return json(res, 201, { data: { signature, kind: payload.kind } });+});++async function readBuffered(req) {+ const chunks = [];+ let total = 0;+ for await (const c of req) {+ chunks.push(c);+ total += c.length;+ if (total > 64_000) throw Object.assign(new Error('payload too large'), { status: 413 });+ }+ return Buffer.concat(chunks);+}diff --git a/api/agents/solana-reputation.js b/api/agents/solana-reputation.jsindex 8b1edf4bc..ec538bb88 100644--- a/api/agents/solana-reputation.js+++ b/api/agents/solana-reputation.js@@ -32,9 +32,13 @@ export default wrap(async (req, res) => {try { new PublicKey(asset); }catch { return error(res, 400, 'validation_error', 'invalid asset pubkey'); }- // One pass: feedback aggregates split by verified-task-acceptance.- // Sybil-weighting: collapse multiple feedbacks from the same attester to- // their average so one wallet leaving 100 ratings doesn't dominate.+ // One pass: feedback aggregates split by verified-task-acceptance and by+ // SAS credentialing. Three layers of trust:+ // 1. Raw — every memo feedback counts equally.+ // 2. Verified — feedback whose task_id has a matching task.accepted.+ // 3. Credentialed — feedback from attesters who additionally hold a+ // threews.verified-client.v1 SAS credential. This is the strongest+ // Sybil resistance: an outsider can't fabricate a credential.const [fb] = await sql`with feedback as (select@@ -48,7 +52,15 @@ export default wrap(async (req, res) => {and a.payload->>'task_id' = f.payload->>'task_id'and a.verified = trueand f.payload->>'task_id' is not null- ) as task_accepted+ ) as task_accepted,+ exists (+ select 1 from solana_credentials c+ where c.subject = f.attester+ and c.network = f.network+ and c.kind = 'threews.verified-client.v1'+ and c.closed = false+ and (c.expiry is null or c.expiry > now())+ ) as credentialedfrom solana_attestations fwhere f.agent_asset = ${asset}and f.network = ${network}@@ -57,19 +69,24 @@ export default wrap(async (req, res) => {),per_attester as (select attester, avg(score)::float as score_avg,- bool_or(task_accepted) as any_verified+ bool_or(task_accepted) as any_verified,+ bool_or(credentialed) as any_credentialedfrom feedback group by attester)select(select count(*)::int from feedback) as total,(select count(*) filter (where task_accepted)::int from feedback) as verified,+ (select count(*) filter (where credentialed)::int from feedback) as credentialed,(select count(*) filter (where disputed)::int from feedback) as disputed,(select coalesce(avg(score), 0)::float from feedback) as score_avg,(select coalesce(avg(score) filter (where task_accepted), 0)::float from feedback) as score_avg_verified,+ (select coalesce(avg(score) filter (where credentialed), 0)::float from feedback) as score_avg_credentialed,(select count(*)::int from per_attester) as unique_attesters,(select count(*) filter (where any_verified)::int from per_attester) as unique_verified_attesters,+ (select count(*) filter (where any_credentialed)::int from per_attester) as unique_credentialed_attesters,(select coalesce(avg(score_avg), 0)::float from per_attester) as score_avg_weighted,- (select coalesce(avg(score_avg) filter (where any_verified), 0)::float from per_attester) as score_avg_weighted_verified+ (select coalesce(avg(score_avg) filter (where any_verified), 0)::float from per_attester) as score_avg_weighted_verified,+ (select coalesce(avg(score_avg) filter (where any_credentialed), 0)::float from per_attester) as score_avg_weighted_credentialed`;const [val] = await sql`@@ -81,6 +98,17 @@ export default wrap(async (req, res) => {and kind = 'threews.validation.v1' and revoked = false`;+ // Audited validations from authorized validators (SAS-credentialed).+ const [auditedVal] = await sql`+ select+ count(*) filter (where (data->>'passed')::bool)::int as passed,+ count(*) filter (where not (data->>'passed')::bool)::int as failed+ from solana_credentials+ where subject = ${asset} and network = ${network}+ and kind = 'threews.audited-validation.v1'+ and closed = false and (expiry is null or expiry > now())+ `;+const [counts] = await sql`selectcount(*) filter (where kind = 'threews.task.v1')::int as tasks_offered,@@ -99,19 +127,25 @@ export default wrap(async (req, res) => {agent: asset,network,feedback: {- total: fb.total,- verified: fb.verified,- disputed: fb.disputed,- unique_attesters: fb.unique_attesters,- unique_verified_attesters: fb.unique_verified_attesters,- score_avg: Number(fb.score_avg.toFixed(3)),- score_avg_verified: Number(fb.score_avg_verified.toFixed(3)),- score_avg_weighted: Number(fb.score_avg_weighted.toFixed(3)),- score_avg_weighted_verified: Number(fb.score_avg_weighted_verified.toFixed(3)),+ total: fb.total,+ verified: fb.verified,+ credentialed: fb.credentialed,+ disputed: fb.disputed,+ unique_attesters: fb.unique_attesters,+ unique_verified_attesters: fb.unique_verified_attesters,+ unique_credentialed_attesters: fb.unique_credentialed_attesters,+ score_avg: Number(fb.score_avg.toFixed(3)),+ score_avg_verified: Number(fb.score_avg_verified.toFixed(3)),+ score_avg_credentialed: Number(fb.score_avg_credentialed.toFixed(3)),+ score_avg_weighted: Number(fb.score_avg_weighted.toFixed(3)),+ score_avg_weighted_verified: Number(fb.score_avg_weighted_verified.toFixed(3)),+ score_avg_weighted_credentialed: Number(fb.score_avg_weighted_credentialed.toFixed(3)),},validation: {- passed: val.passed,- failed: val.failed,+ self_passed: val.passed,+ self_failed: val.failed,+ audited_passed: auditedVal.passed,+ audited_failed: auditedVal.failed,},tasks: {offered: counts.tasks_offered,