Skip to content

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.

feat: update favicon conversion script and add new Solana agent handlers

nirholas98299cb79bc9
diff --git a/api/agents/solana-wallet.js b/api/agents/solana-wallet.js
index f5dbe199b..65e2d93f4 100644
--- a/api/agents/solana-wallet.js
+++ b/api/agents/solana-wallet.js
@@ -1,18 +1,5 @@
-// /api/agents/:id/solana
-//
-// GET — return the agent's Solana address + SOL balance (owner only).
-// POST — provision a Solana wallet for this agent.
-// • No body: server generates a fresh random keypair.
-// • Body { secret_key, vanity_prefix? }: imports a user-grinded
-// keypair (e.g. from /vanity-wallet.html). Server verifies the
-// secret derives the claimed pubkey and the prefix matches.
-// Idempotent for "no body" + existing wallet (returns existing).
-// 409 if importing onto an agent that already has a wallet
-// (call DELETE first to replace).
-// DELETE — remove the agent's Solana wallet (clears address + secret).
-//
-// The encrypted secret never leaves the server. Signing is done by the
-// pump.fun action endpoints in api/agents/pumpfun/*.
+// /api/agents/:id/solana — wallet, activity, and airdrop handlers.
+// Dispatched from api/agents/[id].js with the `action` sub-path.
import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';
import { sql } from '../_lib/db.js';
@@ -20,22 +7,21 @@ import { cors, json, method, error, readJson } from '../_lib/http.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
import { generateSolanaAgentWallet } from '../_lib/agent-wallet.js';
import { solanaConnection } from '../_lib/agent-pumpfun.js';
-import { Keypair, PublicKey } from '@solana/web3.js';
+import { Keypair, PublicKey, LAMPORTS_PER_SOL } from '@solana/web3.js';
import { webcrypto } from 'node:crypto';
import { env } from '../_lib/env.js';
+import { recordEvent } from '../_lib/usage.js';
const subtle = globalThis.crypto?.subtle || webcrypto.subtle;
+const BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]+$/;
+const AIRDROP_LAMPORTS = LAMPORTS_PER_SOL;
-// Mirror agent-wallet.js encryption — keep in sync.
async function _deriveKey() {
const raw = new TextEncoder().encode(env.JWT_SECRET);
const base = await subtle.importKey('raw', raw, 'HKDF', false, ['deriveKey']);
return subtle.deriveKey(
{ name: 'HKDF', hash: 'SHA-256', salt: new TextEncoder().encode('agent-wallet-v1'), info: new Uint8Array(0) },
- base,
- { name: 'AES-GCM', length: 256 },
- false,
- ['encrypt', 'decrypt'],
+ base, { name: 'AES-GCM', length: 256 }, false, ['encrypt', 'decrypt'],
);
}
async function _encryptSecret(plaintext) {
@@ -44,13 +30,10 @@ async function _encryptSecret(plaintext) {
(globalThis.crypto || webcrypto).getRandomValues(iv);
const ct = await subtle.encrypt({ name: 'AES-GCM', iv }, key, new TextEncoder().encode(plaintext));
const buf = new Uint8Array(iv.length + ct.byteLength);
- buf.set(iv, 0);
- buf.set(new Uint8Array(ct), iv.length);
+ buf.set(iv, 0); buf.set(new Uint8Array(ct), iv.length);
return Buffer.from(buf).toString('base64');
}
-const BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]+$/;
-
async function resolveAuth(req) {
const session = await getSessionUser(req);
if (session) return { userId: session.id };
@@ -59,7 +42,95 @@ async function resolveAuth(req) {
return null;
}
-export default async function handler(req, res, id) {
+// ── activity ──────────────────────────────────────────────────────────────────
+
+async function handleActivity(req, res, id) {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const auth = await resolveAuth(req);
+ if (!auth) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const [row] = await sql`SELECT id, user_id, meta FROM agent_identities WHERE id = ${id} AND deleted_at IS NULL`;
+ if (!row) return error(res, 404, 'not_found', 'agent not found');
+ if (row.user_id !== auth.userId) return error(res, 403, 'forbidden', 'not your agent');
+
+ const address = row.meta?.solana_address;
+ if (!address) return error(res, 404, 'not_found', 'agent has no solana wallet');
+
+ const url = new URL(req.url, 'http://x');
+ const network = url.searchParams.get('network') === 'devnet' ? 'devnet' : 'mainnet';
+ const limit = Math.min(parseInt(url.searchParams.get('limit') || '20', 10) || 20, 50);
+
+ let signatures = [];
+ try {
+ const conn = solanaConnection(network);
+ const pk = new PublicKey(address);
+ const sigs = await conn.getSignaturesForAddress(pk, { limit });
+ const parsed = await conn.getParsedTransactions(sigs.map((s) => s.signature), { maxSupportedTransactionVersion: 0, commitment: 'confirmed' });
+ signatures = sigs.map((s, i) => {
+ const tx = parsed[i];
+ let lamportDelta = null, summary = null;
+ if (tx?.meta && tx?.transaction) {
+ const keys = tx.transaction.message.accountKeys.map((k) => k.pubkey?.toString());
+ const idx = keys.indexOf(address);
+ if (idx >= 0 && tx.meta.preBalances && tx.meta.postBalances) lamportDelta = tx.meta.postBalances[idx] - tx.meta.preBalances[idx];
+ const ix = tx.transaction.message.instructions?.[0];
+ if (ix?.parsed?.type) summary = ix.parsed.type;
+ else if (ix?.programId) summary = `program ${ix.programId.toString().slice(0, 6)}…`;
+ }
+ return { signature: s.signature, slot: s.slot, block_time: s.blockTime ?? null, success: !s.err && !tx?.meta?.err, error: s.err || tx?.meta?.err || null, lamport_delta: lamportDelta, sol_delta: lamportDelta == null ? null : lamportDelta / 1e9, summary };
+ });
+ } catch (err) {
+ console.error('[agents/solana/activity] RPC fetch failed', err);
+ return error(res, 502, 'rpc_error', 'failed to fetch on-chain activity');
+ }
+
+ return json(res, 200, { data: { address, network, signatures } });
+}
+
+// ── airdrop ───────────────────────────────────────────────────────────────────
+
+async function handleAirdrop(req, res, id) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const auth = await resolveAuth(req);
+ if (!auth) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const [row] = await sql`SELECT id, user_id, meta FROM agent_identities WHERE id = ${id} AND deleted_at IS NULL`;
+ if (!row) return error(res, 404, 'not_found', 'agent not found');
+ if (row.user_id !== auth.userId) return error(res, 403, 'forbidden', 'not your agent');
+
+ const address = row.meta?.solana_address;
+ if (!address) return error(res, 404, 'not_found', 'agent has no solana wallet');
+
+ let signature;
+ try {
+ const conn = solanaConnection('devnet');
+ signature = await conn.requestAirdrop(new PublicKey(address), AIRDROP_LAMPORTS);
+ await conn.confirmTransaction(signature, 'confirmed');
+ } catch (err) {
+ console.error('[agents/solana/airdrop] failed', err);
+ return error(res, 502, 'faucet_unavailable',
+ err?.message?.includes('429') || err?.message?.includes('limit')
+ ? 'Devnet faucet is rate-limited — try again in a minute.'
+ : `Devnet airdrop failed: ${err?.message || 'unknown'}`);
+ }
+
+ recordEvent({ userId: auth.userId, agentId: id, kind: 'solana_airdrop', tool: 'devnet', status: 'ok', meta: { address, signature, lamports: AIRDROP_LAMPORTS } });
+ return json(res, 200, { data: { signature, address, network: 'devnet', lamports: AIRDROP_LAMPORTS, sol: AIRDROP_LAMPORTS / 1e9 } });
+}
+
+// ── wallet ────────────────────────────────────────────────────────────────────
+
+async function handleWallet(req, res, id) {
if (cors(req, res, { methods: 'GET,POST,DELETE,OPTIONS', credentials: true })) return;
if (!method(req, res, ['GET', 'POST', 'DELETE'])) return;
@@ -69,16 +140,12 @@ export default async function handler(req, res, id) {
const rl = await limits.authIp(clientIp(req));
if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
- const [row] = await sql`
- SELECT id, user_id, meta FROM agent_identities
- WHERE id = ${id} AND deleted_at IS NULL
- `;
+ const [row] = await sql`SELECT id, user_id, meta FROM agent_identities WHERE id = ${id} AND deleted_at IS NULL`;
if (!row) return error(res, 404, 'not_found', 'agent not found');
if (row.user_id !== auth.userId) return error(res, 403, 'forbidden', 'not your agent');
let meta = { ...(row.meta || {}) };
- // ── DELETE ─────────────────────────────────────────────────────────────
if (req.method === 'DELETE') {
delete meta.solana_address;
delete meta.encrypted_solana_secret;
@@ -88,65 +155,35 @@ export default async function handler(req, res, id) {
return json(res, 200, { data: { ok: true } });
}
- // ── POST ───────────────────────────────────────────────────────────────
if (req.method === 'POST') {
const body = await readJson(req).catch(() => ({}));
const importing = body && (body.secret_key || body.vanity_prefix);
if (importing) {
- // Validate secret_key shape: 64 numbers (Solana CLI / web3.js format).
const sk = body.secret_key;
if (!Array.isArray(sk) || sk.length !== 64 || !sk.every((n) => Number.isInteger(n) && n >= 0 && n <= 255)) {
return error(res, 400, 'validation_error', 'secret_key must be a 64-byte number array');
}
-
let kp;
- try {
- kp = Keypair.fromSecretKey(Uint8Array.from(sk));
- } catch (e) {
- return error(res, 400, 'validation_error', 'secret_key did not parse as a valid Solana keypair');
- }
+ try { kp = Keypair.fromSecretKey(Uint8Array.from(sk)); }
+ catch { return error(res, 400, 'validation_error', 'secret_key did not parse as a valid Solana keypair'); }
const address = kp.publicKey.toBase58();
-
if (body.vanity_prefix) {
- if (!BASE58_RE.test(body.vanity_prefix) || body.vanity_prefix.length > 6) {
- return error(res, 400, 'validation_error', 'vanity_prefix is not valid base58 (max 6 chars)');
- }
- if (!address.startsWith(body.vanity_prefix)) {
- return error(res, 400, 'validation_error', 'vanity_prefix does not match the keypair address');
- }
+ if (!BASE58_RE.test(body.vanity_prefix) || body.vanity_prefix.length > 6) return error(res, 400, 'validation_error', 'vanity_prefix is not valid base58 (max 6 chars)');
+ if (!address.startsWith(body.vanity_prefix)) return error(res, 400, 'validation_error', 'vanity_prefix does not match the keypair address');
}
-
- if (meta.solana_address) {
- return error(res, 409, 'conflict',
- 'agent already has a Solana wallet — DELETE /api/agents/:id/solana first to replace');
- }
-
+ if (meta.solana_address) return error(res, 409, 'conflict', 'agent already has a Solana wallet — DELETE /api/agents/:id/solana first to replace');
const encrypted_secret = await _encryptSecret(Buffer.from(kp.secretKey).toString('base64'));
- meta = {
- ...meta,
- solana_address: address,
- encrypted_solana_secret: encrypted_secret,
- solana_wallet_source: 'imported_vanity',
- ...(body.vanity_prefix ? { solana_vanity_prefix: body.vanity_prefix } : {}),
- };
+ meta = { ...meta, solana_address: address, encrypted_solana_secret: encrypted_secret, solana_wallet_source: 'imported_vanity', ...(body.vanity_prefix ? { solana_vanity_prefix: body.vanity_prefix } : {}) };
await sql`UPDATE agent_identities SET meta = ${JSON.stringify(meta)}::jsonb WHERE id = ${id}`;
} else if (!meta.solana_address) {
- // No body, no existing wallet → server generates.
const sol = await generateSolanaAgentWallet();
- meta = {
- ...meta,
- solana_address: sol.address,
- encrypted_solana_secret: sol.encrypted_secret,
- solana_wallet_source: 'generated',
- };
+ meta = { ...meta, solana_address: sol.address, encrypted_solana_secret: sol.encrypted_secret, solana_wallet_source: 'generated' };
await sql`UPDATE agent_identities SET meta = ${JSON.stringify(meta)}::jsonb WHERE id = ${id}`;
}
}
- if (!meta.solana_address) {
- return error(res, 404, 'not_found', 'agent has no solana wallet — POST to provision');
- }
+ if (!meta.solana_address) return error(res, 404, 'not_found', 'agent has no solana wallet — POST to provision');
const network = (req.query?.network || new URL(req.url, 'http://x').searchParams.get('network') || 'mainnet').toString();
let lamports = null;
@@ -154,17 +191,18 @@ export default async function handler(req, res, id) {
const conn = solanaConnection(network === 'devnet' ? 'devnet' : 'mainnet');
lamports = await conn.getBalance(new PublicKey(meta.solana_address));
} catch (err) {
- console.error('[agents/solana] balance fetch failed', err);
+ console.error('[agents/solana/wallet] balance fetch failed', err);
}
return json(res, req.method === 'POST' ? 201 : 200, {
- data: {
- address: meta.solana_address,
- network,
- lamports,
- sol: lamports == null ? null : lamports / 1e9,
- vanity_prefix: meta.solana_vanity_prefix || null,
- source: meta.solana_wallet_source || (meta.encrypted_solana_secret ? 'generated' : null),
- },
+ data: { address: meta.solana_address, network, lamports, sol: lamports == null ? null : lamports / 1e9, vanity_prefix: meta.solana_vanity_prefix || null, source: meta.solana_wallet_source || (meta.encrypted_solana_secret ? 'generated' : null) },
});
}
+
+// ── dispatcher ────────────────────────────────────────────────────────────────
+
+export default async function handler(req, res, id, action) {
+ if (action === 'activity') return handleActivity(req, res, id);
+ if (action === 'airdrop') return handleAirdrop(req, res, id);
+ return handleWallet(req, res, id);
+}
diff --git a/api/agents/solana/[action].js b/api/agents/solana/[action].js
new file mode 100644
index 000000000..4b15c698b
--- /dev/null
+++ b/api/agents/solana/[action].js
@@ -0,0 +1,35 @@
+import { wrap, error } from '../../_lib/http.js';
+import {
+ handleAttestations,
+ handleAttestEvent,
+ handleCard,
+ handlePriceHistory,
+ handleRegisterPrep,
+ handleRegisterConfirm,
+ handleReputation,
+ handleReputationHistory,
+} from './_handlers.js';
+
+export {
+ taskHash,
+ buildPayload,
+ verifyPumpkitSignature,
+} from './_handlers.js';
+
+const DISPATCH = {
+ attestations: handleAttestations,
+ 'attest-event': handleAttestEvent,
+ card: handleCard,
+ 'price-history': handlePriceHistory,
+ 'register-prep': handleRegisterPrep,
+ 'register-confirm': handleRegisterConfirm,
+ reputation: handleReputation,
+ 'reputation-history': handleReputationHistory,
+};
+
+export default wrap(async (req, res) => {
+ const action = req.query?.action ?? new URL(req.url, 'http://x').searchParams.get('action');
+ const fn = DISPATCH[action];
+ if (!fn) return error(res, 404, 'not_found', `unknown action: ${action}`);
+ return fn(req, res);
+});
diff --git a/api/agents/solana/_handlers.js b/api/agents/solana/_handlers.js
new file mode 100644
index 000000000..772960631
--- /dev/null
+++ b/api/agents/solana/_handlers.js
@@ -0,0 +1,519 @@
+// Consolidated public Solana agent handlers.
+// Reached via api/agents/solana/[action].js dispatcher.
+// Named exports (taskHash, buildPayload, verifyPumpkitSignature) are kept
+// for backward-compat with the test suite.
+
+import crypto from 'node:crypto';
+import { z } from 'zod';
+import { PublicKey, Connection } from '@solana/web3.js';
+import { sql } from '../../_lib/db.js';
+import { cors, json, method, wrap, error, readJson } from '../../_lib/http.js';
+import { limits, clientIp } from '../../_lib/rate-limit.js';
+import { getSessionUser } from '../../_lib/auth.js';
+import { parse } from '../../_lib/validate.js';
+import { randomToken } from '../../_lib/crypto.js';
+import { env } from '../../_lib/env.js';
+import { KIND_MAP, crawlAgentAttestations } from '../../_lib/solana-attestations.js';
+import {
+ mintAttestation,
+ loadAttesterKeypair,
+ taskHash as _taskHash,
+ buildPayload as _buildPayload,
+} from '../../_lib/attest-event.js';
+
+// ── Named exports preserved for tests ────────────────────────────────────────
+
+export const taskHash = _taskHash;
+export const buildPayload = _buildPayload;
+
+const REPLAY_WINDOW_SECS = 5 * 60;
+const MAX_BODY_BYTES = 64_000;
+
+export function verifyPumpkitSignature({ secret, timestamp, signature, raw, nowSecs = Math.floor(Date.now() / 1000) }) {
+ if (!secret || !timestamp || !signature) return { ok: false, reason: 'missing' };
+ const ts = Number(timestamp);
+ if (!Number.isFinite(ts)) return { ok: false, reason: 'bad_timestamp' };
+ if (Math.abs(nowSecs - ts) > REPLAY_WINDOW_SECS) return { ok: false, reason: 'stale' };
+ const expect = crypto.createHmac('sha256', secret).update(`${ts}.`).update(raw).digest();
+ let got;
+ try { got = Buffer.from(signature, 'hex'); } catch { return { ok: false, reason: 'bad_signature' }; }
+ if (got.length !== expect.length) return { ok: false, reason: 'bad_signature' };
+ return { ok: crypto.timingSafeEqual(got, expect), reason: 'ok' };
+}
+
+// ── solana-attestations ───────────────────────────────────────────────────────
+
+export const handleAttestations = 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 asset = url.searchParams.get('asset');
+ const kindArg = url.searchParams.get('kind') || 'all';
+ const network = url.searchParams.get('network') === 'mainnet' ? 'mainnet' : 'devnet';
+ const limit = Math.min(Number(url.searchParams.get('limit') || 100), 500);
+ const includeRevoked = url.searchParams.get('include_revoked') === '1';
+
+ if (!asset) return error(res, 400, 'validation_error', 'asset query param required');
+ try { new PublicKey(asset); } catch { return error(res, 400, 'validation_error', 'invalid asset pubkey'); }
+
+ const wantKind = kindArg === 'all' ? null : KIND_MAP[kindArg];
+ if (kindArg !== 'all' && !wantKind) {
+ return error(res, 400, 'validation_error', 'kind must be one of: feedback, validation, task, accept, revoke, dispute, all');
+ }
+
+ const [cursor] = await sql`select last_indexed_at from solana_attestations_cursor where agent_asset = ${asset} limit 1`;
+ if (!cursor) {
+ const [agent] = await sql`select wallet_address as owner from agent_identities where meta->>'sol_mint_address' = ${asset} and deleted_at is null limit 1`;
+ try { await crawlAgentAttestations({ agentAsset: asset, network, ownerWallet: agent?.owner || null }); } catch {}
+ }
+
+ const rows = wantKind
+ ? await sql`select signature, slot, block_time, attester, kind, payload, verified, revoked, disputed from solana_attestations where agent_asset = ${asset} and network = ${network} and kind = ${wantKind} and (${includeRevoked} or revoked = false) order by slot desc limit ${limit}`
+ : await sql`select signature, slot, block_time, attester, kind, payload, verified, revoked, disputed from solana_attestations where agent_asset = ${asset} and network = ${network} and (${includeRevoked} or revoked = false) order by slot desc limit ${limit}`;
+
+ return json(res, 200, { data: rows, agent: asset, network, kind: kindArg, count: rows.length, last_indexed_at: cursor?.last_indexed_at || null });
+});
+
+// ── solana-attest-event ───────────────────────────────────────────────────────
+
+async function readBuffered(req) {
+ const chunks = [];
+ let total = 0;
+ for await (const c of req) {
+ chunks.push(c);
+ total += c.length;
+ if (total > MAX_BODY_BYTES) throw Object.assign(new Error('payload too large'), { status: 413 });
+ }
+ return Buffer.concat(chunks);
+}
+
+const attestEventSchema = z.object({
+ event_id: z.string().min(1).max(128),
+ 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(),
+});
+
+export const handleAttestEvent = wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS' })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const startedAt = Date.now();
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const secret = process.env.PUMPKIT_WEBHOOK_SECRET;
+ if (!secret) return error(res, 500, 'internal', 'webhook secret not configured');
+
+ const raw = await readBuffered(req);
+ const verdict = verifyPumpkitSignature({
+ secret,
+ timestamp: req.headers['x-pumpkit-timestamp'],
+ signature: req.headers['x-pumpkit-signature'],
+ raw,
+ });
+ if (!verdict.ok) return error(res, 401, 'unauthorized', `invalid webhook signature (${verdict.reason})`);
+
+ let parsed;
+ try { parsed = JSON.parse(raw.toString('utf8')); } catch { return error(res, 400, 'validation_error', 'invalid JSON'); }
+ const body = parse(attestEventSchema, parsed);
+
+ const [agent] = await sql`select id, user_id from agent_identities where meta->'onchain'->>'sol_asset' = ${body.agent_asset} or meta->>'sol_mint_address' = ${body.agent_asset} limit 1`;
+ if (!agent) return error(res, 404, 'not_found', 'agent_asset not registered');
+
+ const result = await mintAttestation({
+ event_id: body.event_id,
+ event_type: body.event_type,
+ source: `pumpkit.${body.event_type === 'cto_detected' ? 'cto' : body.event_type === 'whale_trade' ? 'whale' : body.event_type}`,
+ agent_asset: body.agent_asset,
+ network: body.network,
+ token_mint: body.token_mint,
+ task_id: body.task_id,
+ detail: body.detail,
+ attester: loadAttesterKeypair(),
+ });
+
+ const baseLog = { userId: agent.user_id, agentId: agent.id, kind: 'attest_event', tool: `pumpkit.${body.event_type}`, latencyMs: Date.now() - startedAt, meta: { network: body.network, event_id: body.event_id, signature: result.signature } };
+ const { recordEvent } = await import('../../_lib/usage.js');
+
+ if (result.status === 'minted') {
+ recordEvent({ ...baseLog, status: 'ok', meta: { ...baseLog.meta, kind: result.kind } });
+ return json(res, 201, { data: { signature: result.signature, kind: result.kind, deduped: false } });
+ }
+ if (result.status === 'deduped') {
+ recordEvent({ ...baseLog, status: 'deduped' });
+ return json(res, 200, { data: { signature: result.signature, deduped: true } });
+ }
+ recordEvent({ ...baseLog, status: 'in_progress' });
+ return json(res, 202, { data: { deduped: true, status: 'in_progress' } });
+});
+
+// ── solana-card ───────────────────────────────────────────────────────────────
+
+export const handleCard = wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const url = new URL(req.url, `http://${req.headers.host}`);
+ const asset = url.searchParams.get('asset');
+ if (!asset) return error(res, 400, 'validation_error', 'asset required');
+ try { new PublicKey(asset); } catch { return error(res, 400, 'validation_error', 'invalid asset pubkey'); }
+
+ const [a] = await sql`select id, name, description, skills, wallet_address as owner, meta, avatar_id from agent_identities where meta->>'sol_mint_address' = ${asset} and deleted_at is null limit 1`;
+ if (!a) return error(res, 404, 'not_found', 'agent not found');
+
+ const network = a.meta?.network || 'mainnet';
+ const origin = env.APP_ORIGIN;
+
+ let pumpfun = null;
+ try {
+ const rows = await sql`select kind, count(*)::int as n, max(seen_at) as last_seen from pumpfun_signals where agent_asset = ${asset} group by kind`;
+ if (rows.length > 0) {
+ const byKind = {};
+ let total = 0, last = null;
+ for (const r of rows) {
+ byKind[r.kind] = { count: r.n, last_seen: r.last_seen };
+ total += r.n;
+ if (!last || (r.last_seen && r.last_seen > last)) last = r.last_seen;
+ }
+ pumpfun = { signal_count: total, by_kind: byKind, last_seen: last, feed_url: `${origin}/api/agents/pumpfun-feed` };
+ }
+ } catch {}
+
+ let token_stats = null;
+ try {
+ const [s] = await sql`select s.graduated, s.bonding_curve, s.amm, s.last_signature, s.last_signature_at, s.recent_tx_count, s.refreshed_at, m.mint, m.network from pump_agent_stats s join pump_agent_mints m on m.id = s.mint_id where m.mint = ${asset} limit 1`;
+ if (s) token_stats = { mint: s.mint, network: s.network, graduated: s.graduated, bonding_curve: s.bonding_curve, amm: s.amm, last_signature: s.last_signature, last_signature_at: s.last_signature_at, recent_tx_count: s.recent_tx_count, refreshed_at: s.refreshed_at };
+ } catch {}
+
+ return json(res, 200, {
+ schema_version: '1.0',
+ name: a.name,
+ description: a.description,
+ identity: {
+ chain: 'solana', network, asset_pubkey: asset, owner: a.owner,
+ passport_url: `${origin}/agent-passport.html?asset=${asset}&network=${network}`,
+ ...(a.meta?.vanity_prefix ? { vanity_prefix: a.meta.vanity_prefix } : {}),
+ ...(a.meta?.solana_address ? { operator_wallet: { address: a.meta.solana_address, ...(a.meta.solana_vanity_prefix ? { vanity_prefix: a.meta.solana_vanity_prefix } : {}), ...(a.meta.solana_wallet_source ? { source: a.meta.solana_wallet_source } : {}) } } : {}),
+ },
+ skills: a.skills || [],
+ endpoints: {
+ chat: `${origin}/api/agents/${a.id}/chat`,
+ attestations: `${origin}/api/agents/solana-attestations?asset=${asset}&network=${network}`,
+ reputation: `${origin}/api/agents/solana-reputation?asset=${asset}&network=${network}`,
+ ...(token_stats ? { quote: `${origin}/api/pump/quote?mint=${asset}&network=${network}`, price_history: `${origin}/api/agents/solana-price-history?asset=${asset}&network=${network}` } : {}),
+ },
+ attestation: {
+ schemas_url: `${origin}/.well-known/agent-attestation-schemas`,
+ transport: 'spl-memo',
+ memo_program: 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr',
+ usage: 'Sign an SPL Memo tx with one of the published schemas as JSON, including this asset_pubkey as a non-signer key.',
+ },
+ ...(pumpfun ? { pumpfun } : {}),
+ ...(token_stats ? { token_stats } : {}),
+ }, { 'cache-control': 'public, max-age=120', 'access-control-allow-origin': '*' });
+});
+
+// ── solana-price-history ──────────────────────────────────────────────────────
+
+export const handlePriceHistory = wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'GET,OPTIONS', origins: '*' })) return;
+ if (!method(req, res, ['GET'])) return;
+
+ const url = new URL(req.url, `http://${req.headers.host}`);
+ const asset = url.searchParams.get('asset');
+ const network = url.searchParams.get('network') === 'devnet' ? 'devnet' : 'mainnet';
+ const hours = Math.max(1, Math.min(720, Number(url.searchParams.get('hours') || 24)));
+ if (!asset) return error(res, 400, 'validation_error', 'asset required');
+
+ const [mintRow] = await sql`select id from pump_agent_mints where mint=${asset} and network=${network} limit 1`;
+ if (!mintRow) return error(res, 404, 'not_found', 'mint not tracked');
+
+ const points = await sql`select ts, sol_per_token, market_cap_lamports, source from pump_agent_price_points where mint_id=${mintRow.id} and ts > now() - (${hours} || ' hours')::interval order by ts asc`;
+
+ return json(res, 200, {
+ mint: asset, network, hours, point_count: points.length,
+ points: points.map((p) => ({ ts: p.ts, sol_per_token: p.sol_per_token, market_cap_lamports: p.market_cap_lamports?.toString?.() ?? p.market_cap_lamports, source: p.source })),
+ }, { 'cache-control': 'public, max-age=60', 'access-control-allow-origin': '*' });
+});
+
+// ── solana-register-prep ──────────────────────────────────────────────────────
+
+import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
+import { mplCore, createV1 } from '@metaplex-foundation/mpl-core';
+import { generateSigner, publicKey as umiPublicKey, signerIdentity, createNoopSigner } from '@metaplex-foundation/umi';
+import { limits as _limits } from '../../_lib/rate-limit.js';
+
+const BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]+$/;
+const VANITY_FREE_THRESHOLD = 5;
+
+const registerPrepSchema = z.object({
+ name: z.string().trim().min(1).max(60),
+ description: z.string().trim().max(280).default(''),
+ avatar_id: z.string().uuid().optional(),
+ wallet_address: z.string().min(32).max(44),
+ metadata_uri: z.string().url().optional(),
+ network: z.enum(['mainnet', 'devnet']).default('mainnet'),
+ asset_pubkey: z.string().min(32).max(44).optional(),
+ vanity_prefix: z.string().min(1).max(6).optional(),
+});
+
+export const handleRegisterPrep = wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const body = parse(registerPrepSchema, await readJson(req));
+ const { name, description, avatar_id, wallet_address, network, asset_pubkey, vanity_prefix } = body;
+
+ const [walletRow] = await sql`select id from user_wallets where user_id = ${user.id} and address = ${wallet_address} and chain_type = 'solana' limit 1`;
+ if (!walletRow) return error(res, 403, 'forbidden', 'wallet not linked to your account');
+
+ if (avatar_id) {
+ const [av] = await sql`select id from avatars where id=${avatar_id} and owner_id=${user.id} and deleted_at is null limit 1`;
+ if (!av) return error(res, 404, 'not_found', 'avatar not found');
+ }
+
+ if (vanity_prefix && !asset_pubkey) return error(res, 400, 'validation_error', 'vanity_prefix requires asset_pubkey');
+ if (asset_pubkey) {
+ if (!BASE58_RE.test(asset_pubkey)) return error(res, 400, 'validation_error', 'asset_pubkey is not valid base58');
+ if (vanity_prefix) {
+ if (!BASE58_RE.test(vanity_prefix)) return error(res, 400, 'validation_error', 'vanity_prefix is not valid base58');
+ if (!asset_pubkey.startsWith(vanity_prefix)) return error(res, 400, 'validation_error', 'asset_pubkey does not start with vanity_prefix');
+ if (vanity_prefix.length >= VANITY_FREE_THRESHOLD && (user.plan ?? 'free') === 'free') {
+ return error(res, 402, 'payment_required', `vanity prefixes of ${VANITY_FREE_THRESHOLD}+ characters require a paid plan`);
+ }
+ }
+ }
+
+ const SOLANA_RPC = process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com';
+ const rpcEndpoint = network === 'devnet' ? (process.env.SOLANA_RPC_URL_DEVNET || 'https://api.devnet.solana.com') : SOLANA_RPC;
+
+ const umi = createUmi(rpcEndpoint).use(mplCore());
+ const ownerPubkey = umiPublicKey(wallet_address);
+ const assetSigner = asset_pubkey ? createNoopSigner(umiPublicKey(asset_pubkey)) : generateSigner(umi);
+ umi.use(signerIdentity(createNoopSigner(ownerPubkey)));
+
+ const appOrigin = env.APP_ORIGIN;
+ const metadataUri = body.metadata_uri || `${appOrigin}/api/agents/solana-metadata?name=${encodeURIComponent(name)}&desc=${encodeURIComponent(description)}`;
+
+ const builder = createV1(umi, { asset: assetSigner, owner: ownerPubkey, name, uri: metadataUri });
+ const tx = await builder.buildAndSign(umi);
+ const txBytes = umi.transactions.serialize(tx);
+ const txBase64 = Buffer.from(txBytes).toString('base64');
+
+ const prepId = await randomToken(24);
+ const expiresAt = new Date(Date.now() + 30 * 60 * 1000);
+
+ await sql`insert into agent_registrations_pending (user_id, cid, metadata_uri, payload, expires_at) values (${user.id}, ${assetSigner.publicKey}, ${metadataUri}, ${JSON.stringify({ name, description, avatar_id, wallet_address, asset_pubkey: assetSigner.publicKey, network, prep_id: prepId, vanity_prefix: vanity_prefix || null })}::jsonb, ${expiresAt})`;
+
+ return json(res, 201, {
+ prep_id: prepId,
+ asset_pubkey: assetSigner.publicKey,
+ tx_base64: txBase64,
+ network,
+ metadata_uri: metadataUri,
+ expires_at: expiresAt.toISOString(),
+ instructions: 'Sign and submit the transaction with your Solana wallet, then call /api/agents/solana-register-confirm with the tx signature.',
+ });
+});
+
+// ── solana-register-confirm ───────────────────────────────────────────────────
+
+const registerConfirmSchema = z.object({
+ tx_signature: z.string().min(80).max(100),
+ asset_pubkey: z.string().min(32).max(44),
+ wallet_address: z.string().min(32).max(44),
+ network: z.enum(['mainnet', 'devnet']).default('mainnet'),
+ name: z.string().trim().min(1).max(60).optional(),
+ description: z.string().trim().max(280).optional(),
+ avatar_id: z.string().uuid().optional(),
+});
+
+export const handleRegisterConfirm = wrap(async (req, res) => {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthorized', 'sign in required');
+
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+
+ const body = parse(registerConfirmSchema, await readJson(req));
+ const { tx_signature, asset_pubkey, wallet_address, network } = body;
+
+ const [walletRow] = await sql`select id from user_wallets where user_id=${user.id} and address=${wallet_address} and chain_type='solana' limit 1`;
+ if (!walletRow) return error(res, 403, 'forbidden', 'wallet not linked to your account');
+
+ const rpcEndpoint = network === 'devnet'
+ ? (process.env.SOLANA_RPC_URL_DEVNET || 'https://api.devnet.solana.com')
+ : (process.env.SOLANA_RPC_URL || 'https://api.mainnet-beta.solana.com');
+
+ const connection = new Connection(rpcEndpoint, 'confirmed');
+ let tx;
+ try { tx = await connection.getParsedTransaction(tx_signature, { maxSupportedTransactionVersion: 0, commitment: 'confirmed' }); }
+ catch { return error(res, 422, 'tx_not_found', 'transaction not found — try again after a few seconds'); }
+ if (!tx) return error(res, 422, 'tx_not_found', 'transaction not found');
+ if (tx.meta?.err) return error(res, 422, 'tx_failed', 'transaction failed on-chain');
+
+ const accountKeys = tx.transaction.message.accountKeys.map((k) => k.pubkey?.toString());
+ if (!accountKeys.includes(asset_pubkey)) return error(res, 422, 'asset_not_in_tx', 'The asset pubkey was not found in the transaction accounts');
+
+ const [existing] = await sql`select id from agent_identities where (meta->>'sol_mint_address') = ${asset_pubkey} and deleted_at is null limit 1`;
+ if (existing) return error(res, 409, 'conflict', 'agent already registered for this mint');
+
+ const [pending] = await sql`select payload from agent_registrations_pending where user_id=${user.id} and payload->>'asset_pubkey'=${asset_pubkey} and expires_at > now() order by created_at desc limit 1`;
+ const payload = pending?.payload || {};
+ const name = body.name || payload.name || `Agent ${asset_pubkey.slice(0, 6)}`;
+ const description = body.description || payload.description || '';
+ const avatar_id = body.avatar_id || payload.avatar_id || null;
+
+ const [agent] = await sql`insert into agent_identities (user_id, name, description, avatar_id, wallet_address, meta) values (${user.id}, ${name}, ${description}, ${avatar_id}, ${wallet_address}, ${JSON.stringify({ chain_type: 'solana', network, sol_mint_address: asset_pubkey, tx_signature, ...(payload.vanity_prefix ? { vanity_prefix: payload.vanity_prefix } : {}) })}::jsonb) returning id, name, description, wallet_address, meta, created_at`;
+
+ await sql`delete from agent_registrations_pending where user_id=${user.id} and payload->>'asset_pubkey'=${asset_pubkey}`;
+
+ return json(res, 201, { ok: true, agent: { ...agent, home_url: `${env.APP_ORIGIN}/agent/${agent.id}` }, sol_mint_address: asset_pubkey, tx_signature, network });
+});
+
+// ── solana-reputation ─────────────────────────────────────────────────────────
+
+export const handleReputation = 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 asset = url.searchParams.get('asset');
+ const network = url.searchParams.get('network') === 'mainnet' ? 'mainnet' : 'devnet';
+
+ if (!asset) return error(res, 400, 'validation_error', 'asset query param required');
+ try { new PublicKey(asset); } catch { return error(res, 400, 'validation_error', 'invalid asset pubkey'); }
+
+ const [fb] = await sql`
+ with feedback as (
+ select f.signature, f.attester, f.disputed, f.revoked,
+ (f.payload->>'score')::int as score, f.payload->>'task_id' as task_id,
+ exists (select 1 from solana_attestations a where a.agent_asset = f.agent_asset and a.kind = 'threews.accept.v1' and a.payload->>'task_id' = f.payload->>'task_id' and a.verified = true and f.payload->>'task_id' is not null) 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 credentialed,
+ (f.payload->>'source' like 'pumpkit.%' or f.payload->>'source' like 'pumpfun.%') as event_attested
+ from solana_attestations f where f.agent_asset = ${asset} and f.network = ${network} and f.kind = 'threews.feedback.v1' and f.revoked = false
+ ),
+ per_attester as (select attester, avg(score)::float as score_avg, bool_or(task_accepted) as any_verified, bool_or(credentialed) as any_credentialed, bool_or(event_attested) as any_event_attested from 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 event_attested)::int from feedback) as event_attested,
+ (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 coalesce(avg(score) filter (where event_attested), 0)::float from feedback) as score_avg_event_attested,
+ (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_credentialed), 0)::float from per_attester) as score_avg_weighted_credentialed
+ `;
+
+ const [val] = await sql`select count(*) filter (where (payload->>'passed')::bool)::int as passed, count(*) filter (where not (payload->>'passed')::bool)::int as failed, count(*) filter (where (payload->>'passed')::bool and (payload->>'source' like 'pumpkit.%' or payload->>'source' like 'pumpfun.%'))::int as event_passed, count(*) filter (where not (payload->>'passed')::bool and (payload->>'source' like 'pumpkit.%' or payload->>'source' like 'pumpfun.%'))::int as event_failed from solana_attestations where agent_asset = ${asset} and network = ${network} and kind = 'threews.validation.v1' and revoked = false`;
+
+ 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`select count(*) filter (where kind = 'threews.task.v1')::int as tasks_offered, count(*) filter (where kind = 'threews.accept.v1' and verified)::int as tasks_accepted, count(*) filter (where kind = 'threews.dispute.v1' and verified)::int as disputes_filed, count(*) filter (where revoked)::int as revoked_count from solana_attestations where agent_asset = ${asset} and network = ${network}`;
+
+ const [cursor] = await sql`select last_indexed_at from solana_attestations_cursor where agent_asset = ${asset} limit 1`;
+
+ const pumpfunRows = await sql`select kind, count(*)::int as n, coalesce(sum(weight), 0)::float as w from pumpfun_signals where agent_asset = ${asset} group by kind`;
+ const pumpfunByKind = {};
+ let pumpfunTotal = 0, pumpfunWeight = 0;
+ for (const r of pumpfunRows) {
+ pumpfunByKind[r.kind] = { count: r.n, weight: Number(r.w.toFixed(3)) };
+ pumpfunTotal += r.n; pumpfunWeight += r.w;
+ }
+
+ const [actRow] = await sql`select s.graduated, s.recent_tx_count, (select count(*)::int from pump_agent_trades t where t.mint_id = m.id) as trade_count from pump_agent_stats s join pump_agent_mints m on m.id = s.mint_id where m.mint = ${asset} and m.network = ${network} limit 1`;
+ const tokenActivity = actRow ? { graduated: !!actRow.graduated, recent_tx_count: actRow.recent_tx_count || 0, trade_count: actRow.trade_count || 0, weight: Number(((actRow.graduated ? 0.3 : 0) + Math.min(0.4, (actRow.recent_tx_count || 0) * 0.005) + Math.min(0.3, (actRow.trade_count || 0) * 0.01)).toFixed(3)) } : { graduated: false, recent_tx_count: 0, trade_count: 0, weight: 0 };
+
+ const [payRow] = await sql`select count(*) filter (where p.status='confirmed')::int as confirmed_count, count(distinct p.payer_wallet) filter (where p.status='confirmed')::int as unique_payers, coalesce(sum(p.amount_atomics) filter (where p.status='confirmed'), 0)::text as total_atomics from pump_agent_payments p join pump_agent_mints m on m.id = p.mint_id join agent_identities a on a.id = m.agent_id where (a.meta->>'sol_mint_address') = ${asset} and m.network = ${network}`;
+
+ return json(res, 200, {
+ agent: asset, network,
+ pump_payments: payRow || { confirmed_count: 0, unique_payers: 0, total_atomics: '0' },
+ pumpfun_signals: { count: pumpfunTotal, weight: Number(pumpfunWeight.toFixed(3)), by_kind: pumpfunByKind },
+ token_activity: tokenActivity,
+ feedback: {
+ total: fb.total, verified: fb.verified, credentialed: fb.credentialed, event_attested: fb.event_attested, 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_event_attested: Number(fb.score_avg_event_attested.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: { self_passed: val.passed, self_failed: val.failed, event_passed: val.event_passed, event_failed: val.event_failed, audited_passed: auditedVal.passed, audited_failed: auditedVal.failed },
+ tasks: { offered: counts.tasks_offered, accepted: counts.tasks_accepted },
+ disputes_filed: counts.disputes_filed, revoked_count: counts.revoked_count,
+ last_indexed_at: cursor?.last_indexed_at || null,
+ });
+});
+
+// ── solana-reputation-history ─────────────────────────────────────────────────
+
+const MAX_DAYS = 90;
+
+export const handleReputationHistory = 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 asset = url.searchParams.get('asset');
+ const network = url.searchParams.get('network') === 'mainnet' ? 'mainnet' : 'devnet';
+ const days = Math.min(Math.max(Number(url.searchParams.get('days') || 30), 1), MAX_DAYS);
+
+ if (!asset) return error(res, 400, 'validation_error', 'asset query param required');
+ try { new PublicKey(asset); } catch { return error(res, 400, 'validation_error', 'invalid asset pubkey'); }
+
+ const rows = await sql`
+ with feedback as (
+ select date_trunc('day', f.block_time) as day, f.attester, (f.payload->>'score')::int as score,
+ exists (select 1 from solana_attestations a where a.agent_asset = f.agent_asset and a.kind = 'threews.accept.v1' and a.payload->>'task_id' = f.payload->>'task_id' and a.verified = true and f.payload->>'task_id' is not null) 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 > f.block_time)) as credentialed,
+ (f.payload->>'source' like 'pumpkit.%') as event_attested
+ from solana_attestations f where f.agent_asset = ${asset} and f.network = ${network} and f.kind = 'threews.feedback.v1' and f.revoked = false and f.block_time >= now() - (${days} || ' days')::interval
+ )
+ select day, count(*)::int as n,
+ coalesce(avg(score) filter (where credentialed), 0)::float as score_credentialed,
+ coalesce(avg(score) filter (where task_accepted), 0)::float as score_verified,
+ coalesce(avg(score) filter (where event_attested), 0)::float as score_event,
+ coalesce(avg(score), 0)::float as score_raw,
+ count(*) filter (where credentialed)::int as n_credentialed,
+ count(*) filter (where task_accepted)::int as n_verified,
+ count(*) filter (where event_attested)::int as n_event
+ from feedback group by day order by day asc
+ `;
+
+ const series = rows.map((r) => {
+ const tier = r.n_credentialed > 0 ? { tier: 'credentialed', score: r.score_credentialed, n: r.n_credentialed } : r.n_verified > 0 ? { tier: 'verified', score: r.score_verified, n: r.n_verified } : r.n_event > 0 ? { tier: 'event', score: r.score_event, n: r.n_event } : { tier: 'community', score: r.score_raw, n: r.n };
+ return { day: r.day instanceof Date ? r.day.toISOString().slice(0, 10) : String(r.day).slice(0, 10), tier: tier.tier, score: Number(tier.score.toFixed(3)), n: tier.n };
+ });
+
+ return json(res, 200, { agent: asset, network, days, series });
+});
diff --git a/api/auth/[action].js b/api/auth/[action].js
new file mode 100644
index 000000000..54c2f5a58
--- /dev/null
+++ b/api/auth/[action].js
@@ -0,0 +1,236 @@
+// Consolidated auth endpoint. Dispatches on URL action segment.
+// Routes: /api/auth/login, /api/auth/logout, /api/auth/register,
+// /api/auth/me, /api/auth/profile, /api/auth/forgot-password,
+// /api/auth/reset-password, /api/auth/verify-email,
+// /api/auth/resend-verification, /api/auth/logout-everywhere
+
+import { sql } from '../_lib/db.js';
+import {
+ verifyPassword, hashPassword, createSession, destroySession, sessionCookie,
+ getSessionUser, revokeRefreshToken,
+} from '../_lib/auth.js';
+import { randomToken, sha256 } from '../_lib/crypto.js';
+import { cors, json, method, readJson, wrap, error } from '../_lib/http.js';
+import { limits, clientIp } from '../_lib/rate-limit.js';
+import { parse, loginBody, registerBody, usernameRegisterBody, username as usernameValidator, displayName, email, password } from '../_lib/validate.js';
+import { sendPasswordResetEmail, sendVerificationEmail } from '../_lib/email.js';
+import { z } from 'zod';
+
+const APP_ORIGIN = process.env.APP_ORIGIN || 'https://three.ws';
+
+// ── login ─────────────────────────────────────────────────────────────────────
+
+async function handleLogin(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ const ip = clientIp(req);
+ const rl = await limits.authIp(ip);
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many attempts; try again later');
+ const body = parse(loginBody, await readJson(req));
+ const isEmail = body.email.includes('@');
+ const rows = isEmail
+ ? await sql`select id, email, password_hash, display_name, plan, avatar_url from users where email = ${body.email} and deleted_at is null limit 1`
+ : await sql`select id, email, password_hash, display_name, plan, avatar_url from users where display_name ilike ${body.email} and deleted_at is null limit 1`;
+ const user = rows[0];
+ const ok = user && (await verifyPassword(body.password, user.password_hash));
+ if (!ok) return error(res, 401, 'invalid_credentials', 'invalid username/email or password');
+ await destroySession(req);
+ const token = await createSession({ userId: user.id, userAgent: req.headers['user-agent'], ip });
+ res.setHeader('set-cookie', sessionCookie(token));
+ const { password_hash: _p, ...safe } = user;
+ return json(res, 200, { user: safe });
+}
+
+// ── logout ────────────────────────────────────────────────────────────────────
+
+async function handleLogout(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ await destroySession(req);
+ res.setHeader('set-cookie', sessionCookie('', { clear: true }));
+ return json(res, 200, { ok: true });
+}
+
+// ── logout-everywhere ─────────────────────────────────────────────────────────
+
+async function handleLogoutEverywhere(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthenticated', 'not signed in');
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+ const sessionResult = await sql`update sessions set revoked_at = now() where user_id = ${user.id} and revoked_at is null`;
+ await sql`update oauth_refresh_tokens set revoked_at = now() where user_id = ${user.id} and revoked_at is null`;
+ const clearCookies = sessionCookie('', { clear: true });
+ const existing = res.getHeader('set-cookie') || [];
+ res.setHeader('set-cookie', [...(Array.isArray(existing) ? existing : [existing]), ...clearCookies]);
+ return json(res, 200, { ok: true, revoked: sessionResult.count });
+}
+
+// ── register ──────────────────────────────────────────────────────────────────
+
+async function handleRegister(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ const ip = clientIp(req);
+ const rl = await limits.registerIp(ip);
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many signups from this IP');
+ const raw = await readJson(req);
+ let email_val, displayName_val, passwordVal;
+ if (raw.username && !raw.email) {
+ const body = parse(usernameRegisterBody, raw);
+ const safe = body.username.toLowerCase().replace(/[^a-z0-9_-]/g, '_');
+ email_val = `${safe}@users.three.ws.local`;
+ displayName_val = body.username;
+ passwordVal = body.password;
+ const existing = await sql`select id from users where display_name ilike ${body.username} and deleted_at is null limit 1`;
+ if (existing[0]) return error(res, 409, 'conflict', 'email or username already in use');
+ } else {
+ const body = parse(registerBody, raw);
+ email_val = body.email; displayName_val = body.display_name ?? null; passwordVal = body.password;
+ const existing = await sql`select id from users where email = ${email_val} and deleted_at is null limit 1`;
+ if (existing[0]) return error(res, 409, 'conflict', 'email or username already in use');
+ }
+ const hash = await hashPassword(passwordVal);
+ const [user] = await sql`insert into users (email, password_hash, display_name) values (${email_val}, ${hash}, ${displayName_val}) returning id, display_name, plan, created_at`;
+ await destroySession(req);
+ const token = await createSession({ userId: user.id, userAgent: req.headers['user-agent'], ip });
+ res.setHeader('set-cookie', sessionCookie(token));
+ return json(res, 201, { user });
+}
+
+// ── me ────────────────────────────────────────────────────────────────────────
+
+async function handleMe(req, res) {
+ if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['GET'])) return;
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthenticated', 'not signed in');
+ return json(res, 200, { user });
+}
+
+// ── profile ───────────────────────────────────────────────────────────────────
+
+const profileSchema = z.object({
+ username: usernameValidator.optional(),
+ display_name: displayName.optional(),
+}).refine((b) => b.username !== undefined || b.display_name !== undefined, { message: 'at least one field required' });
+
+async function handleProfile(req, res) {
+ if (cors(req, res, { methods: 'PATCH,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['PATCH'])) return;
+ const user = await getSessionUser(req);
+ if (!user) return error(res, 401, 'unauthenticated', 'not signed in');
+ const rl = await limits.authIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many requests');
+ const body = parse(profileSchema, await readJson(req));
+ if (body.username) {
+ const taken = await sql`select id from users where lower(username) = ${body.username.toLowerCase()} and id != ${user.id} and deleted_at is null limit 1`;
+ if (taken[0]) return error(res, 409, 'conflict', 'username already taken');
+ }
+ const [updated] = await sql`update users set username = coalesce(${body.username ?? null}, username), display_name = coalesce(${body.display_name ?? null}, display_name), updated_at = now() where id = ${user.id} and deleted_at is null returning id, display_name, username`;
+ return json(res, 200, { user: updated });
+}
+
+// ── forgot-password ───────────────────────────────────────────────────────────
+
+const forgotSchema = z.object({ email });
+
+async function handleForgotPassword(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ const body = parse(forgotSchema, await readJson(req));
+ const rl = await limits.forgotPasswordEmail(body.email);
+ if (!rl.success) return json(res, 200, { success: true });
+ const rows = await sql`select id from users where email = ${body.email} and deleted_at is null limit 1`;
+ if (rows[0]) {
+ const token = randomToken(32);
+ const tokenHash = await sha256(token);
+ const expiresAt = new Date(Date.now() + 60 * 60_000);
+ await sql`insert into password_resets (user_id, token_hash, expires_at) values (${rows[0].id}, ${tokenHash}, ${expiresAt.toISOString()})`;
+ sendPasswordResetEmail({ to: body.email, resetUrl: `${APP_ORIGIN}/reset-password?token=${encodeURIComponent(token)}`, expiresInMinutes: 60 }).catch(() => {});
+ }
+ return json(res, 200, { success: true });
+}
+
+// ── reset-password ────────────────────────────────────────────────────────────
+
+const resetSchema = z.object({ token: z.string().min(16).max(256), password });
+
+async function handleResetPassword(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) 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 attempts; try again later');
+ const body = parse(resetSchema, await readJson(req));
+ const tokenHash = await sha256(body.token);
+ const rows = await sql`select r.id, r.user_id from password_resets r join users u on u.id = r.user_id where r.token_hash = ${tokenHash} and r.consumed_at is null and r.expires_at > now() and u.deleted_at is null limit 1`;
+ if (!rows[0]) return error(res, 400, 'invalid_token', 'reset link is invalid or has expired');
+ const hash = await hashPassword(body.password);
+ await sql`update users set password_hash = ${hash}, updated_at = now() where id = ${rows[0].user_id}`;
+ await sql`update password_resets set consumed_at = now() where id = ${rows[0].id}`;
+ await sql`update sessions set revoked_at = now() where user_id = ${rows[0].user_id} and revoked_at is null`;
+ return json(res, 200, { success: true });
+}
+
+// ── verify-email ──────────────────────────────────────────────────────────────
+
+const verifyEmailSchema = z.object({ code: z.string().trim().regex(/^\d{6}$/, '6-digit code required') });
+
+async function handleVerifyEmail(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ const rl = await limits.verifyEmailIp(clientIp(req));
+ if (!rl.success) return error(res, 429, 'rate_limited', 'too many attempts; try again later');
+ const body = parse(verifyEmailSchema, await readJson(req));
+ const codeHash = await sha256(body.code);
+ const rows = await sql`select v.id, v.user_id from email_verifications v join users u on u.id = v.user_id where v.code_hash = ${codeHash} and v.consumed_at is null and v.expires_at > now() and u.deleted_at is null limit 1`;
+ if (!rows[0]) return error(res, 400, 'invalid_code', 'invalid or expired verification code');
+ await sql`update email_verifications set consumed_at = now() where id = ${rows[0].id}`;
+ await sql`update users set email_verified = true, updated_at = now() where id = ${rows[0].user_id}`;
+ return json(res, 200, { success: true });
+}
+
+// ── resend-verification ───────────────────────────────────────────────────────
+
+async function handleResendVerification(req, res) {
+ if (cors(req, res, { methods: 'POST,OPTIONS', credentials: true })) return;
+ if (!method(req, res, ['POST'])) return;
+ const session = await getSessionUser(req);
+ if (!session) return error(res, 401, 'unauthorized', 'sign in required');
+ const rl = await limits.resendVerifyUser(session.id);
+ if (!rl.success) return error(res, 429, 'rate_limited', 'please wait before requesting again');
+ const rows = await sql`select email, email_verified from users where id = ${session.id} and deleted_at is null limit 1`;
+ if (!rows[0]) return error(res, 401, 'unauthorized', 'sign in required');
+ if (rows[0].email_verified) return json(res, 200, { success: true, already_verified: true });
+ await sql`update email_verifications set consumed_at = now() where user_id = ${session.id} and consumed_at is null`;
+ const code = Math.floor(Math.random() * 1_000_000).toString().padStart(6, '0');
+ const codeHash = await sha256(code);
+ const expiresAt = new Date(Date.now() + 30 * 60_000);
+ await sql`insert into email_verifications (user_id, code_hash, expires_at) values (${session.id}, ${codeHash}, ${expiresAt.toISOString()})`;
+ sendVerificationEmail({ to: rows[0].email, code, expiresInMinutes: 30 }).catch(() => {});
+ return json(res, 200, { success: true });
+}
+
+// ── dispatcher ────────────────────────────────────────────────────────────────
+
+const DISPATCH = {
+ login: handleLogin,
+ logout: handleLogout,
+ 'logout-everywhere': handleLogoutEverywhere,
+ register: handleRegister,
+ me: handleMe,
+ profile: handleProfile,
+ 'forgot-password': handleForgotPassword,
+ 'reset-password': handleResetPassword,
+ 'verify-email': handleVerifyEmail,
+ 'resend-verification': handleResendVerification,
+};
+
+export default wrap(async (req, res) => {
+ const action = req.query?.action ?? new URL(req.url, 'http://x').pathname.split('/').pop();
+ const fn = DISPATCH[action];
+ if (!fn) return error(res, 404, 'not_found', `unknown action: ${action}`);
+ return fn(req, res);
+});
diff --git a/chat/README.md b/chat/README.md
index 370eb25ef..fca817b7d 100644
--- a/chat/README.md
+++ b/chat/README.md
@@ -1,4 +1,4 @@
-# eplus
+# three.ws-chat
### A fast, light, open chat UI
@@ -31,22 +31,22 @@
## How to install?
-If you don't want to use tools, you don't need to install anything. A hosted instance is available at: https://eplus.chat
+If you don't want to use tools, you don't need to install anything. A hosted instance is available at: https://three.ws/chat
If you want to use tools, proceed below.
## Single binary:
-The eplus tool server is available prebuilt as a single binary. [Download prebuilt package from the releases page.](https://github.com/nirholas/eplus/releases)
+The three.ws-chat tool server is available prebuilt as a single binary. [Download prebuilt package from the releases page.](https://github.com/nirholas/three.ws-chat/releases)
Download the binary for your platform, then run it, which will start the tool server:
```
-./eplus-darwin-amd64
+./three.ws-chat-darwin-amd64
Tool server running at http://localhost:8081
```
-Go back to https://eplus.chat, head over to Settings -> Tool calling, and click the "Refresh tools" button. You should be good to go!
+Go back to https://three.ws/chat, head over to Settings -> Tool calling, and click the "Refresh tools" button. You should be good to go!
### Building client and server locally:
diff --git a/chat/package-lock.json b/chat/package-lock.json
index 14c75eebb..c7752b4ac 100644
--- a/chat/package-lock.json
+++ b/chat/package-lock.json
@@ -1,11 +1,11 @@
{
- "name": "eplus",
+ "name": "three.ws-chat",
"version": "0.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
- "name": "eplus",
+ "name": "three.ws-chat",
"version": "0.0.0",
"dependencies": {
"github-slugger": "^2.0.0",
diff --git a/chat/package.json b/chat/package.json
index 909196888..b72a3c6e9 100644
--- a/chat/package.json
+++ b/chat/package.json
@@ -1,5 +1,5 @@
{
- "name": "eplus",
+ "name": "three.ws-chat",
"private": true,
"version": "0.0.0",
"type": "module",
diff --git a/chat/public/convert-favicon-to-mac-icon.sh b/chat/public/convert-favicon-to-mac-icon.sh
index bfd702166..114cf1b2d 100755
--- a/chat/public/convert-favicon-to-mac-icon.sh
+++ b/chat/public/convert-favicon-to-mac-icon.sh
@@ -4,12 +4,12 @@
mkdir -p android ios macos
# Create macOS icon with padding
-padding=50 && convert -background none -density 300 eplus5.svg -resize $((512-2*$padding))x$((512-2*$padding)) -gravity center -extent 512x512 macos/icon.png
+padding=50 && convert -background none -density 300 three.ws-chat5.svg -resize $((512-2*$padding))x$((512-2*$padding)) -gravity center -extent 512x512 macos/icon.png
# Create Android launcher icon (no padding)
-convert -background none -density 300 eplus5.svg -resize 512x512 android/android-launchericon-512-512.png
+convert -background none -density 300 three.ws-chat5.svg -resize 512x512 android/android-launchericon-512-512.png
# Create iOS icon (no padding)
-convert -background none -density 300 eplus5.svg -resize 180x180 ios/180.png
+convert -background none -density 300 three.ws-chat5.svg -resize 180x180 ios/180.png
echo "✅ All icons generated successfully!"
\ No newline at end of file
diff --git a/chat/server/go.mod b/chat/server/go.mod
index d3640a615..60e60a5fc 100644
--- a/chat/server/go.mod
+++ b/chat/server/go.mod
@@ -7,7 +7,7 @@ go 1.23.0
toolchain go1.24.1
require (
- github.com/byte-sat/eplus-tools v0.1.0
+ github.com/byte-sat/three.ws-chat-tools v0.1.0
github.com/go-chi/chi/v5 v5.2.1
github.com/go-chi/cors v1.2.1
github.com/noonien/codoc v0.1.0
diff --git a/chat/server/go.sum b/chat/server/go.sum
index 95a3d82c0..712d448e0 100644
--- a/chat/server/go.sum
+++ b/chat/server/go.sum
@@ -1,7 +1,7 @@
-github.com/byte-sat/eplus-tools v0.0.0-20250311185834-4f80523b4a1d h1:sZM+gosp/548xtzscipEKgYsIZwvuSDsd0KjfOuB3vY=
-github.com/byte-sat/eplus-tools v0.0.0-20250311185834-4f80523b4a1d/go.mod h1:71P8FzmPd/+CptOBnZuHGoFdTH48RFENxRDgAoahD7M=
-github.com/byte-sat/eplus-tools v0.1.0 h1:MpFxy+dHo2hsiYR4TWsogSnmicLWJU8pM0qu5gOZ/Fg=
-github.com/byte-sat/eplus-tools v0.1.0/go.mod h1:71P8FzmPd/+CptOBnZuHGoFdTH48RFENxRDgAoahD7M=
+github.com/byte-sat/three.ws-chat-tools v0.0.0-20250311185834-4f80523b4a1d h1:sZM+gosp/548xtzscipEKgYsIZwvuSDsd0KjfOuB3vY=
+github.com/byte-sat/three.ws-chat-tools v0.0.0-20250311185834-4f80523b4a1d/go.mod h1:71P8FzmPd/+CptOBnZuHGoFdTH48RFENxRDgAoahD7M=
+github.com/byte-sat/three.ws-chat-tools v0.1.0 h1:MpFxy+dHo2hsiYR4TWsogSnmicLWJU8pM0qu5gOZ/Fg=
+github.com/byte-sat/three.ws-chat-tools v0.1.0/go.mod h1:71P8FzmPd/+CptOBnZuHGoFdTH48RFENxRDgAoahD7M=
github.com/go-chi/chi/v5 v5.2.1 h1:KOIHODQj58PmL80G2Eak4WdvUzjSJSm0vG72crDCqb8=
github.com/go-chi/chi/v5 v5.2.1/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops=
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
diff --git a/chat/server/main.go b/chat/server/main.go
index 0b2bd56cd..7cccf83ad 100644
--- a/chat/server/main.go
+++ b/chat/server/main.go
@@ -13,7 +13,7 @@ import (
"strings"
"syscall"
- "github.com/byte-sat/eplus-tools/schema"
+ "github.com/byte-sat/three.ws-chat-tools/schema"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"github.com/go-chi/cors"
diff --git a/chat/server/release.sh b/chat/server/release.sh
index 908d724a9..ced189257 100755
--- a/chat/server/release.sh
+++ b/chat/server/release.sh
@@ -16,7 +16,7 @@ for GOOS in "${GOOS_VALUES[@]}"; do
fi
# Set the output file name
- OUTPUT_FILE="./dist/eplus-${GOOS}-${GOARCH}"
+ OUTPUT_FILE="./dist/three.ws-chat-${GOOS}-${GOARCH}"
# Append .exe for Windows builds
if [ "$GOOS" == "windows" ]; then
diff --git a/chat/server/toolfns/toolfns.go b/chat/server/toolfns/toolfns.go
index 2979c1757..95ef2d6ec 100644
--- a/chat/server/toolfns/toolfns.go
+++ b/chat/server/toolfns/toolfns.go
@@ -2,7 +2,7 @@ package toolfns
import (
"fmt"
- "github.com/byte-sat/eplus-tools/tools"
+ "github.com/byte-sat/three.ws-chat-tools/tools"
"log"
"os"
"os/exec"
diff --git a/chat/src/App.svelte b/chat/src/App.svelte
index ee9aea812..6df9515bc 100644
--- a/chat/src/App.svelte
+++ b/chat/src/App.svelte
@@ -43,7 +43,7 @@
feTerminal,
feMoreHorizontal,
fePaperclip,
- fePlus,
+ fthree.ws-chat,
feRefreshCw,
feSettings,
feShare,
@@ -1176,7 +1176,7 @@
on:click={newConversation}
class="flex rounded-full p-2 transition-colors hover:bg-gray-100"
>
- <Icon icon={fePlus} strokeWidth={3} class="ml-auto h-4 w-4 text-slate-700" />
+ <Icon icon={fthree.ws-chat} strokeWidth={3} class="ml-auto h-4 w-4 text-slate-700" />
</button>
<button
data-trigger="history"
@@ -1232,7 +1232,7 @@
class="flex w-full items-center rounded-[10px] border py-2.5 pl-3 pr-4 text-left text-sm font-medium hover:bg-gray-100"
>
New chat
- <Icon icon={fePlus} strokeWidth={3} class="ml-auto h-3.5 w-3.5 text-slate-700" />
+ <Icon icon={fthree.ws-chat} strokeWidth={3} class="ml-auto h-3.5 w-3.5 text-slate-700" />
</button>
</div>
<ol
diff --git a/chat/src/ClientToolSetting.svelte b/chat/src/ClientToolSetting.svelte
index 69d1df93c..f5b5c385d 100644
--- a/chat/src/ClientToolSetting.svelte
+++ b/chat/src/ClientToolSetting.svelte
@@ -2,7 +2,7 @@
import { createEventDispatcher } from 'svelte';
import Button from './Button.svelte';
import Icon from './Icon.svelte';
- import { feCheck, fePlus, feTrash } from './feather.js';
+ import { feCheck, fthree.ws-chat, feTrash } from './feather.js';
const dispatch = createEventDispatcher();
@@ -168,7 +168,7 @@
];
}}
>
- <Icon icon={fePlus} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />
+ <Icon icon={fthree.ws-chat} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />
Add argument
</Button>
</div>
diff --git a/chat/src/Message.svelte b/chat/src/Message.svelte
index 823ada0e0..72a32e3dc 100644
--- a/chat/src/Message.svelte
+++ b/chat/src/Message.svelte
@@ -13,7 +13,7 @@
feEdit2,
feTerminal,
feMoreHorizontal,
- fePlus,
+ fthree.ws-chat,
feRefreshCw,
feUser,
feX,
@@ -581,7 +581,7 @@
? 'group-hover:opacity-100'
: ''} z-1 absolute bottom-0 left-1/2 flex h-6 w-6 -translate-x-1/2 translate-y-1/2 items-center justify-center rounded-md border border-slate-200 bg-white opacity-0 transition-opacity hover:bg-gray-200"
>
- <Icon icon={fePlus} class="m-auto h-3 w-3 text-slate-600" />
+ <Icon icon={fthree.ws-chat} class="m-auto h-3 w-3 text-slate-600" />
</button>
</li>
{/if}
diff --git a/chat/src/SettingsModal.svelte b/chat/src/SettingsModal.svelte
index 7f556b89a..d87f526d6 100644
--- a/chat/src/SettingsModal.svelte
+++ b/chat/src/SettingsModal.svelte
@@ -22,7 +22,7 @@
feHardDrive,
feKey,
feLayout,
- fePlus,
+ fthree.ws-chat,
feRefreshCw,
feTool,
feUsers,
@@ -473,7 +473,7 @@
});
}}
>
- <Icon icon={fePlus} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />
+ <Icon icon={fthree.ws-chat} strokeWidth={3} class="mr-2 h-3 w-3 text-slate-700" />
Add new tool
</Button>
</div>
diff --git a/chat/src/feather.js b/chat/src/feather.js
index b976727ee..6ca61b7f1 100644
--- a/chat/src/feather.js
+++ b/chat/src/feather.js
@@ -105,7 +105,7 @@ export const feFastForward = `<polygon points="13 19 22 12 13 5 13 19"></polygon
export const feFeather = `<path d="M20.24 12.24a6 6 0 0 0-8.49-8.49L5 10.5V19h8.5z"></path><line x1="16" y1="8" x2="2" y2="22"></line><line x1="17.5" y1="15" x2="9" y2="15"></line>`;
export const feFigma = `<path d="M5 5.5A3.5 3.5 0 0 1 8.5 2H12v7H8.5A3.5 3.5 0 0 1 5 5.5z"></path><path d="M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2z"></path><path d="M12 12.5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 1 1-7 0z"></path><path d="M5 19.5A3.5 3.5 0 0 1 8.5 16H12v3.5a3.5 3.5 0 1 1-7 0z"></path><path d="M5 12.5A3.5 3.5 0 0 1 8.5 9H12v7H8.5A3.5 3.5 0 0 1 5 12.5z"></path>`;
export const feFileMinus = `<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="9" y1="15" x2="15" y2="15"></line>`;
-export const feFilePlus = `<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="12" y1="18" x2="12" y2="12"></line><line x1="9" y1="15" x2="15" y2="15"></line>`;
+export const feFilthree.ws-chat = `<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="12" y1="18" x2="12" y2="12"></line><line x1="9" y1="15" x2="15" y2="15"></line>`;
export const feFileText = `<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline>`;
export const feFile = `<path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline>`;
export const feFilm = `<rect x="2" y="2" width="20" height="20" rx="2.18" ry="2.18"></rect><line x1="7" y1="2" x2="7" y2="22"></line><line x1="17" y1="2" x2="17" y2="22"></line><line x1="2" y1="12" x2="22" y2="12"></line><line x1="2" y1="7" x2="7" y2="7"></line><line x1="2" y1="17" x2="7" y2="17"></line><line x1="17" y1="17" x2="22" y2="17"></line><line x1="17" y1="7" x2="22" y2="7"></line>`;
@@ -191,9 +191,9 @@ export const fePhone = `<path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-
export const fePieChart = `<path d="M21.21 15.89A10 10 0 1 1 8 2.83"></path><path d="M22 12A10 10 0 0 0 12 2v10z"></path>`;
export const fePlayCircle = `<circle cx="12" cy="12" r="10"></circle><polygon points="10 8 16 12 10 16 10 8"></polygon>`;
export const fePlay = `<polygon points="5 3 19 12 5 21 5 3"></polygon>`;
-export const fePlusCircle = `<circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line>`;
-export const fePlusSquare = `<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line>`;
-export const fePlus = `<line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line>`;
+export const fthree.ws-chatCircle = `<circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line>`;
+export const fthree.ws-chatSquare = `<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line>`;
+export const fthree.ws-chat = `<line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line>`;
export const fePocket = `<path d="M4 3h16a2 2 0 0 1 2 2v6a10 10 0 0 1-10 10A10 10 0 0 1 2 11V5a2 2 0 0 1 2-2z"></path><polyline points="8 10 12 14 16 10"></polyline>`;
export const fePower = `<path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path><line x1="12" y1="2" x2="12" y2="12"></line>`;
export const fePrinter = `<polyline points="6 9 6 2 18 2 18 9"></polyline><path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"></path><rect x="6" y="14" width="12" height="8"></rect>`;
diff --git a/chat/src/stores.js b/chat/src/stores.js
index 75840ab3a..bc3faa705 100644
--- a/chat/src/stores.js
+++ b/chat/src/stores.js
@@ -1,7 +1,7 @@
import { writable, get } from 'svelte/store';
import { persisted } from './localstorage.js';
import { v4 as uuidv4 } from 'uuid';
-import { eplusHostedAddress } from './sync.js';
+import { three.ws-chatHostedAddress } from './sync.js';
export const brandConfig = writable({
name: 'three.ws chat',
@@ -53,7 +53,7 @@ export function setAPIKeysFromObject(obj) {
export const remoteServer = persisted('remoteServer', { address: 'http://localhost:8081', password: '' });
export const syncServer = persisted('syncServer', {
- address: eplusHostedAddress,
+ address: three.ws-chatHostedAddress,
token: uuidv4(),
password: '',
});
diff --git a/chat/src/sync.js b/chat/src/sync.js
index c8cc47f4c..b5e6bb90f 100644
--- a/chat/src/sync.js
+++ b/chat/src/sync.js
@@ -1,7 +1,7 @@
import { getAPIKeysAsObject, setAPIKeysFromObject, syncServer } from './stores.js';
import { get } from 'svelte/store';
-export const eplusHostedAddress = 'https://sync.three.ws';
+export const three.ws-chatHostedAddress = 'https://sync.three.ws';
// Encryption state
let encryptionKey = null;
diff --git a/package-lock.json b/package-lock.json
index e2e76888d..ec6e55a3d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -70,7 +70,7 @@
}
},
"chat": {
- "name": "eplus",
+ "name": "three.ws-chat",
"version": "0.0.0",
"dependencies": {
"github-slugger": "^2.0.0",
@@ -13025,7 +13025,7 @@
"node": ">=6"
}
},
- "node_modules/eplus": {
+ "node_modules/three.ws-chat": {
"resolved": "chat",
"link": true
},
diff --git a/public/chat/convert-favicon-to-mac-icon.sh b/public/chat/convert-favicon-to-mac-icon.sh
index bfd702166..114cf1b2d 100755
--- a/public/chat/convert-favicon-to-mac-icon.sh
+++ b/public/chat/convert-favicon-to-mac-icon.sh
@@ -4,12 +4,12 @@
mkdir -p android ios macos
# Create macOS icon with padding
-padding=50 && convert -background none -density 300 eplus5.svg -resize $((512-2*$padding))x$((512-2*$padding)) -gravity center -extent 512x512 macos/icon.png
+padding=50 && convert -background none -density 300 three.ws-chat5.svg -resize $((512-2*$padding))x$((512-2*$padding)) -gravity center -extent 512x512 macos/icon.png
# Create Android launcher icon (no padding)
-convert -background none -density 300 eplus5.svg -resize 512x512 android/android-launchericon-512-512.png
+convert -background none -density 300 three.ws-chat5.svg -resize 512x512 android/android-launchericon-512-512.png
# Create iOS icon (no padding)
-convert -background none -density 300 eplus5.svg -resize 180x180 ios/180.png
+convert -background none -density 300 three.ws-chat5.svg -resize 180x180 ios/180.png
echo "✅ All icons generated successfully!"
\ No newline at end of file