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(wallet): expose the per-counterparty cap in the wallet hub and register reconstructions in the forge

nirholas83d301b7bfd3
diff --git a/api/_lib/forge-store.js b/api/_lib/forge-store.js
index 36b5cb4a9..f3baa9454 100644
--- a/api/_lib/forge-store.js
+++ b/api/_lib/forge-store.js
@@ -158,6 +158,64 @@ export async function createCreation({
}
}
+// Register a finished selfie/prompt reconstruction (api/_lib/reconstruct-
+// finalize.js) as a first-class creation, so the Forge surfaces — showcase,
+// recent feed, share/embed pages, leaderboards — see reconstructions the same
+// way they see /forge generations. The row lands already 'done': the GLB is
+// durably stored by the avatar pipeline before this is called, so there is no
+// generating phase to track here.
+//
+// Privacy contract: `visibility` mirrors the avatar's setting. Public feeds
+// only serve null/'public' rows (see the visibility predicates on the list
+// readers below); 'unlisted' additionally resolves on the direct share read
+// (getPublicCreation); 'private' rows exist for provenance and the owner's own
+// stores only. The client_key is derived from the owner's user id — it never
+// matches a browser's anonymous key, which keeps these rows out of every
+// anonymous client gallery.
+//
+// Idempotent per job: keyed on replicate_job_id (the regen job id), so the
+// poll/cron race that can double-drive finalize registers one row, not two.
+export async function registerReconstructionCreation({
+ userId,
+ avatarId,
+ jobId,
+ provider,
+ prompt,
+ glbKey,
+ glbUrl,
+ sizeBytes,
+ visibility,
+ previewImageUrl = null,
+}) {
+ if (!forgeStoreEnabled() || !userId || !avatarId || !jobId || !glbUrl) return null;
+ const vis = ['public', 'unlisted', 'private'].includes(visibility) ? visibility : 'private';
+ const promptLine = String(prompt || 'Selfie avatar').slice(0, 500);
+ try {
+ const existing = await sql`
+ select id from forge_creations where replicate_job_id = ${jobId} limit 1
+ `;
+ if (existing[0]) return existing[0].id;
+ const id = randomUUID();
+ await sql`
+ insert into forge_creations
+ (id, client_key, prompt, preview_image_url, replicate_job_id,
+ glb_key, glb_url, size_bytes, backend, path, status, outcome,
+ model_category, user_id, visibility, avatar_id)
+ values
+ (${id}, ${hashClient(`user:${userId}`)}, ${promptLine}, ${previewImageUrl},
+ ${jobId}, ${glbKey ?? null}, ${glbUrl}, ${Number.isFinite(sizeBytes) ? sizeBytes : null},
+ ${provider ?? null}, 'reconstruct', 'done', 'generated', 'avatar',
+ ${userId}, ${vis}, ${avatarId})
+ `;
+ await recordGenerationEvent({ phase: 'done', backend: provider ?? 'unknown', path: 'reconstruct', source: 'reconstruct' });
+ return id;
+ } catch (err) {
+ if (isDbUnavailableError(err)) console.warn('[forge-store] registerReconstructionCreation skipped (db unavailable):', err?.message);
+ else console.error('[forge-store] registerReconstructionCreation failed:', err?.message);
+ return null;
+ }
+}
+
// Look up an in-flight creation by its TRELLIS prediction id, scoped to the
// requesting client so one browser can't poll another's job into existence.
export async function findByJob({ replicateJobId, clientKey }) {
@@ -574,6 +632,7 @@ export async function getPublicCreation({ id, voterKey = null }) {
from forge_creations fc
left join users u on u.id = fc.user_id and u.deleted_at is null
where fc.id = ${id} and fc.status = 'done' and fc.glb_url is not null
+ and (fc.visibility is null or fc.visibility in ('public', 'unlisted'))
limit 1
`;
const r = rows[0];
@@ -644,6 +703,7 @@ export async function listRelated({ id, category, limit = 6 }) {
(model_category = ${cat ?? ''}) as same_category
from forge_creations
where status = 'done' and glb_url is not null and id != ${id}
+ and (visibility is null or visibility = 'public')
order by (model_category = ${cat ?? ''}) desc, created_at desc
limit ${capped}
`;
@@ -797,6 +857,7 @@ export async function listCreationsByUser({ userId, limit = 24, before } = {}) {
parent_creation_id, remixable, created_at
from forge_creations
where user_id = ${userId} and status = 'done' and glb_url is not null
+ and (visibility is null or visibility = 'public')
and created_at < ${before}
order by created_at desc
limit ${capped}
@@ -806,6 +867,7 @@ export async function listCreationsByUser({ userId, limit = 24, before } = {}) {
parent_creation_id, remixable, created_at
from forge_creations
where user_id = ${userId} and status = 'done' and glb_url is not null
+ and (visibility is null or visibility = 'public')
order by created_at desc
limit ${capped}
`;
@@ -836,6 +898,7 @@ export async function countCreationsByUser({ userId } = {}) {
select count(*)::int as n
from forge_creations
where user_id = ${userId} and status = 'done' and glb_url is not null
+ and (visibility is null or visibility = 'public')
`;
return row?.n ?? 0;
} catch (err) {
@@ -883,6 +946,7 @@ export async function listShowcase({ limit = 12, voterKey = null, sort = 'fresh'
left join forge_votes v on v.creation_id = fc.id and v.voter_key = ${vk}
where fc.status = 'done' and fc.glb_url is not null
and (fc.outcome is null or fc.outcome != 'rejected')
+ and (fc.visibility is null or fc.visibility = 'public')
and (${weekStart}::timestamptz is null or fc.created_at >= ${weekStart}::timestamptz)
order by fc.vote_count desc, fc.created_at desc
limit ${capped}
@@ -897,6 +961,7 @@ export async function listShowcase({ limit = 12, voterKey = null, sort = 'fresh'
left join forge_votes v on v.creation_id = fc.id and v.voter_key = ${vk}
where fc.status = 'done' and fc.glb_url is not null
and (fc.outcome is null or fc.outcome != 'rejected')
+ and (fc.visibility is null or fc.visibility = 'public')
order by (fc.preview_image_url is not null) desc, fc.created_at desc
limit ${capped}
`;
@@ -934,6 +999,7 @@ export async function countShowcase() {
from forge_creations
where status = 'done' and glb_url is not null
and (outcome is null or outcome != 'rejected')
+ and (visibility is null or visibility = 'public')
`;
return row?.n ?? 0;
} catch (err) {
@@ -1041,6 +1107,7 @@ export async function listRecentCreations({ limit = 24, before } = {}) {
left join users u on u.id = fc.user_id and u.deleted_at is null and u.username is not null
where fc.status = 'done' and fc.glb_url is not null
and (fc.outcome is null or fc.outcome != 'rejected')
+ and (fc.visibility is null or fc.visibility = 'public')
and fc.created_at < ${before}
order by fc.created_at desc
limit ${capped}`
@@ -1053,6 +1120,7 @@ export async function listRecentCreations({ limit = 24, before } = {}) {
left join users u on u.id = fc.user_id and u.deleted_at is null and u.username is not null
where fc.status = 'done' and fc.glb_url is not null
and (fc.outcome is null or fc.outcome != 'rejected')
+ and (fc.visibility is null or fc.visibility = 'public')
order by fc.created_at desc
limit ${capped}`;
return rows.map((r) => ({
diff --git a/api/_lib/migrations/20260811130000_reconstruct_forge_registration.sql b/api/_lib/migrations/20260811130000_reconstruct_forge_registration.sql
new file mode 100644
index 000000000..d422de568
--- /dev/null
+++ b/api/_lib/migrations/20260811130000_reconstruct_forge_registration.sql
@@ -0,0 +1,46 @@
+-- Reconstruction results join the Forge store, without leaking private captures.
+--
+-- Selfie/prompt reconstructions (avatar_regen_jobs mode='reconstruct') used to
+-- finish as an avatars row only: the Forge surfaces keyed off forge_creations
+-- (showcase, recent feed, share/embed pages, remix bazaar, leaderboards) never
+-- saw them. Registering them there requires a visibility notion the table never
+-- needed while every row was a public anonymous /forge generation.
+--
+-- visibility null = legacy row, treated as 'public' (exactly today's
+-- behavior); otherwise 'public' | 'unlisted' | 'private',
+-- mirrored from the avatar the reconstruction produced.
+-- Public feeds serve null/'public'; the share/embed read also
+-- serves 'unlisted'; 'private' rows are owner-only.
+-- avatar_id the avatars row the reconstruction materialized, so provenance
+-- resolves in both directions (avatars.source_meta.jobId already
+-- points back at the job).
+--
+-- avatar_regen_jobs.error_kind mirrors the reconstruction worker's error
+-- taxonomy ('input' = the photos were unusable and `error` is caller-facing
+-- copy; 'internal' = service fault, `error` is an opaque correlation id), so
+-- the status endpoint can relay actionable capture errors instead of masking
+-- every failure into the generic retry message.
+
+alter table forge_creations
+ add column if not exists visibility text,
+ add column if not exists avatar_id uuid references avatars(id) on delete set null;
+
+alter table forge_creations
+ drop constraint if exists forge_creations_visibility_check;
+alter table forge_creations
+ add constraint forge_creations_visibility_check
+ check (visibility is null or visibility in ('public', 'unlisted', 'private'));
+
+-- Provenance lookup: which creation row a given avatar registered as.
+create index if not exists idx_forge_creations_avatar
+ on forge_creations (avatar_id)
+ where avatar_id is not null;
+
+alter table avatar_regen_jobs
+ add column if not exists error_kind text;
+
+alter table avatar_regen_jobs
+ drop constraint if exists avatar_regen_jobs_error_kind_check;
+alter table avatar_regen_jobs
+ add constraint avatar_regen_jobs_error_kind_check
+ check (error_kind is null or error_kind in ('input', 'internal'));
diff --git a/api/_lib/reconstruct-finalize.js b/api/_lib/reconstruct-finalize.js
index 53702e428..8d78dfd56 100644
--- a/api/_lib/reconstruct-finalize.js
+++ b/api/_lib/reconstruct-finalize.js
@@ -26,6 +26,7 @@ import { getRegenProviderForMode } from './regen-provider.js';
// shared guard: host allowlist + IP-pinned SSRF connect + 64 MB ceiling. No bare
// fetch() of a provider URL remains in this file.
import { fetchProviderGlbBuffer } from './provider-result-url.js';
+import { registerReconstructionCreation } from './forge-store.js';
function glbMetaFrom(info) {
return info
@@ -123,6 +124,31 @@ async function materializeReconstructAvatar({
data: { id: avatar.id, name: avatar.name, slug: avatar.slug, source: 'reconstruct' },
}).catch(() => {});
+ // Register the result in the Forge store so galleries, share/embed pages,
+ // and leaderboards see reconstructions like any other creation. Visibility
+ // rides along so private captures never surface publicly. Best-effort: the
+ // avatar is already delivered, a store hiccup must not fail the job.
+ try {
+ const referenceUrl =
+ typeof promptMeta.referenceImageUrl === 'string' && /^https:\/\//i.test(promptMeta.referenceImageUrl)
+ ? promptMeta.referenceImageUrl
+ : null;
+ await registerReconstructionCreation({
+ userId,
+ avatarId: avatar.id,
+ jobId,
+ provider: job.provider,
+ prompt: fromPrompt && params.prompt ? String(params.prompt) : name,
+ glbKey: storageKey,
+ glbUrl: publicUrl(storageKey),
+ sizeBytes: glbBuf.length,
+ visibility,
+ previewImageUrl: referenceUrl,
+ });
+ } catch (err) {
+ console.warn('[reconstruct] forge registration skipped:', err?.message);
+ }
+
return avatar;
}
diff --git a/api/agents/[id]/memory-seed-farcaster.js b/api/agents/[id]/memory-seed-farcaster.js
index 7d2a45f5b..8f3768d39 100644
--- a/api/agents/[id]/memory-seed-farcaster.js
+++ b/api/agents/[id]/memory-seed-farcaster.js
@@ -69,6 +69,10 @@ const challengeSchema = z.object({
intent: z.literal('challenge'),
fid: z.number().int().positive().optional(),
fname: z.string().trim().min(1).max(64).optional(),
+ // Which verified wallet to sign with. Omitted on the first call, when the
+ // server picks Solana first; sent when the user chooses another of their
+ // verified wallets, which needs a fresh message naming that address.
+ address: z.string().trim().min(8).max(128).optional(),
});
const grantSchema = z.object({
@@ -173,9 +177,27 @@ async function handleChallenge(req, res, agentId, userId, body) {
);
}
- // Solana first: it is the home chain and the wallet UX we lead with.
- const chain = solana.length > 0 ? 'solana' : 'ethereum';
- const address = chain === 'solana' ? solana[0] : ethereum[0];
+ // Solana first: it is the home chain and the wallet UX we lead with. A caller
+ // may name another of the fid's verified wallets instead.
+ let chain = solana.length > 0 ? 'solana' : 'ethereum';
+ let address = chain === 'solana' ? solana[0] : ethereum[0];
+ if (body.address) {
+ if (addressMatches(body.address, solana, 'solana')) {
+ chain = 'solana';
+ address = normalizeAddress(body.address, 'solana');
+ } else if (addressMatches(body.address, ethereum, 'ethereum')) {
+ chain = 'ethereum';
+ address = normalizeAddress(body.address, 'ethereum');
+ } else {
+ return error(
+ res,
+ 403,
+ 'address_not_verified',
+ 'that wallet is not one of the addresses this Farcaster account has verified',
+ { wallets: { solana, ethereum } },
+ );
+ }
+ }
// 24 alphanumeric chars from the CSPRNG, same shape as the SIWS nonce.
let nonce = '';
diff --git a/api/chat.js b/api/chat.js
index dd0a56e92..2db8f9f5a 100644
--- a/api/chat.js
+++ b/api/chat.js
@@ -29,6 +29,7 @@ import { getSessionUser, authenticateBearer, extractBearer } from './_lib/auth.j
import { cors, json, method, readJson, wrap, error, rateLimited } from './_lib/http.js';
import { parse } from './_lib/validate.js';
import { recordEvent } from './_lib/usage.js';
+import { trackAgentOwnerVisit } from './_lib/retention.js';
import { costMicroUsd } from './_lib/llm-pricing.js';
import { captureException } from './_lib/sentry.js';
import { sql } from './_lib/db.js';
@@ -1002,6 +1003,10 @@ export default wrap(async (req, res) => {
userId: auth?.userId ?? null,
apiKeyId: auth?.apiKeyId,
clientId: auth?.clientId,
+ // Agent attribution on the chat path. Without it a conversation with an
+ // agent was indistinguishable from a bare /api/chat call in usage_events,
+ // so per-agent chat volume and the retention rollup had nothing to key on.
+ agentId: body.agentId ?? null,
kind: 'chat',
tool: route.model,
latencyMs,
@@ -1034,6 +1039,14 @@ export default wrap(async (req, res) => {
anonymous,
},
});
+
+ // Week-2 retention signal: an owner conversing with their OWN agent is the
+ // exact behaviour the phase-2 roadmap metric measures. One coarse row per
+ // owner/agent/UTC day, nothing per-request and nothing identifying beyond the
+ // ids already on this request. Detached — telemetry never delays a reply.
+ if (isOwner) {
+ trackAgentOwnerVisit({ userId: auth.userId, agentId: body.agentId, conversed: true });
+ }
});
// Govern autonomous value-transfer actions with IBM Granite Guardian before the
diff --git a/api/tts/eleven/voices.js b/api/tts/eleven/voices.js
index 4ec97c77e..54f2dcb82 100644
--- a/api/tts/eleven/voices.js
+++ b/api/tts/eleven/voices.js
@@ -4,14 +4,16 @@
* Returns the ElevenLabs voice list (filtered to safe public fields), served
* from the shared per-instance cache in _lib/elevenlabs.js. A request carrying
* its own `x-eleven-key` header (BYOK) lists that account's voices instead,
- * uncached. Returns { enabled: false, voices: [] } when ELEVENLABS_API_KEY is
- * not set and no user key was sent, so the client can gate the UI without a
- * separate config check.
+ * uncached, and so does a caller who saved an ElevenLabs key at
+ * /api/user/provider-keys. Returns { enabled: false, voices: [] } when no
+ * credential resolves at all, so the client can gate the UI without a separate
+ * config check. `key_source` names the lane that answered.
*/
import { getSessionUser, authenticateBearer, extractBearer } from '../../_lib/auth.js';
import { cors, json, method, wrap, error } from '../../_lib/http.js';
-import { resolveElevenKey, listVoices, TTS_MODELS } from '../../_lib/elevenlabs.js';
+import { listVoices, TTS_MODELS } from '../../_lib/elevenlabs.js';
+import { resolveAgentElevenKey } from '../../_lib/agent-voice-key.js';
export default wrap(async (req, res) => {
if (cors(req, res, { methods: 'GET,OPTIONS', credentials: true })) return;
@@ -21,15 +23,25 @@ export default wrap(async (req, res) => {
const bearer = session ? null : await authenticateBearer(extractBearer(req));
if (!session && !bearer) return error(res, 401, 'unauthorized', 'sign in required');
- // A user-supplied x-eleven-key (BYOK) lists THAT account's voices; otherwise
- // the platform account's. Unconfigured with no user key stays a soft-off so
- // the client can gate the UI without a separate config check.
- const { apiKey, byok } = resolveElevenKey(req);
- if (!apiKey) return json(res, 200, { enabled: false, voices: [], models: TTS_MODELS });
+ // A user-supplied x-eleven-key (BYOK) lists THAT account's voices, then the
+ // caller's saved key, then the platform account's. No credential at all stays
+ // a soft-off so the client can gate the UI without a separate config check.
+ const { apiKey, source } = await resolveAgentElevenKey({
+ req,
+ ownerId: session?.id ?? bearer?.userId ?? null,
+ });
+ if (!apiKey)
+ return json(res, 200, {
+ enabled: false,
+ voices: [],
+ models: TTS_MODELS,
+ key_source: null,
+ byok_url: '/dashboard/account',
+ });
let result;
try {
- result = await listVoices(byok ? { apiKey } : {});
+ result = await listVoices(source === 'platform' ? {} : { apiKey });
} catch (e) {
console.error('[tts/eleven/voices] listVoices failed', e);
return error(
@@ -43,7 +55,7 @@ export default wrap(async (req, res) => {
return json(
res,
200,
- { enabled: true, voices: result.voices, models: TTS_MODELS },
+ { enabled: true, voices: result.voices, models: TTS_MODELS, key_source: source },
{
'cache-control': 'private, max-age=300',
'x-voices-cache': result.cached ? 'hit' : 'miss',
diff --git a/src/agent-wallet-hub/tabs/policy.js b/src/agent-wallet-hub/tabs/policy.js
index 4a5035f49..7fe321142 100644
--- a/src/agent-wallet-hub/tabs/policy.js
+++ b/src/agent-wallet-hub/tabs/policy.js
@@ -199,6 +199,7 @@ registerWalletTab({
<div class="awp-caps" style="margin-top:10px;">
<span class="awp-cap">Daily cap: ${caps.daily_usd != null ? esc(formatUsd(caps.daily_usd)) : 'none'}</span>
<span class="awp-cap">Per-tx cap: ${caps.per_tx_usd != null ? esc(formatUsd(caps.per_tx_usd)) : 'none'}</span>
+ <span class="awp-cap">Per-counterparty cap: ${caps.per_counterparty_daily_usd != null ? esc(formatUsd(caps.per_counterparty_daily_usd)) : 'none'}</span>
<span class="awp-cap">${caps.frozen ? '🔒 frozen' : 'active'}</span>
</div>
<p class="awp-hint" style="margin:8px 0 0;">Numeric caps and the freeze switch are always enforced — edit them under Withdraw → Limits & Safety.</p>`;
diff --git a/src/agent-wallet-hub/tabs/withdraw.js b/src/agent-wallet-hub/tabs/withdraw.js
index 5551f2234..7a708e16e 100644
--- a/src/agent-wallet-hub/tabs/withdraw.js
+++ b/src/agent-wallet-hub/tabs/withdraw.js
@@ -571,8 +571,9 @@ registerWalletTab({
<span class="awh-chip${overDaily ? ' alert' : ''}">Spent today: ${esc(formatUsd(spent) || '$0.00')}</span>
<span class="awh-chip">Daily cap: ${lim.daily_usd != null ? esc(formatUsd(lim.daily_usd)) : 'none'}</span>
<span class="awh-chip">Per-tx cap: ${lim.per_tx_usd != null ? esc(formatUsd(lim.per_tx_usd)) : 'none'}</span>
+ <span class="awh-chip">Per-counterparty cap: ${lim.per_counterparty_daily_usd != null ? esc(formatUsd(lim.per_counterparty_daily_usd)) : 'none'}</span>
</div>
- <p class="awh-empty" style="margin-top:0;">These ceilings apply to every outbound path — trades, snipes, x402 payments and withdrawals. Leave a field blank for no limit.</p>
+ <p class="awh-empty" style="margin-top:0;">These ceilings apply to every outbound path — trades, snipes, x402 and agent-to-agent payments, and withdrawals. Leave a field blank for no limit.</p>
<div class="awh-fld">
<label for="awh-daily">Daily spend cap (USD)</label>
<input class="awh-in" id="awh-daily" type="text" inputmode="decimal" placeholder="No limit" value="${lim.daily_usd != null ? esc(lim.daily_usd) : ''}">
@@ -581,6 +582,10 @@ registerWalletTab({
<label for="awh-pertx">Per-transaction cap (USD)</label>
<input class="awh-in" id="awh-pertx" type="text" inputmode="decimal" placeholder="No limit" value="${lim.per_tx_usd != null ? esc(lim.per_tx_usd) : ''}">
</div>
+ <div class="awh-fld">
+ <label for="awh-percp">Per-counterparty daily cap (USD) <span style="opacity:.6">(optional — how much may go to any single payee in 24h)</span></label>
+ <input class="awh-in" id="awh-percp" type="text" inputmode="decimal" placeholder="No limit" value="${lim.per_counterparty_daily_usd != null ? esc(lim.per_counterparty_daily_usd) : ''}">
+ </div>
<div class="awh-fld">
<label>Withdraw allowlist <span style="opacity:.6">(optional — restrict where funds can be swept)</span></label>
<ul class="awh-allow" id="awh-allow">
@@ -656,11 +661,13 @@ registerWalletTab({
const parse = (v) => (v.trim() === '' ? null : Number(v));
const daily = parse(panel.querySelector('#awh-daily').value);
const perTx = parse(panel.querySelector('#awh-pertx').value);
+ const perCp = parse(panel.querySelector('#awh-percp').value);
if (daily != null && (!Number.isFinite(daily) || daily < 0)) { errEl.hidden = false; errEl.textContent = 'Daily cap must be a non-negative number.'; return; }
if (perTx != null && (!Number.isFinite(perTx) || perTx < 0)) { errEl.hidden = false; errEl.textContent = 'Per-tx cap must be a non-negative number.'; return; }
+ if (perCp != null && (!Number.isFinite(perCp) || perCp < 0)) { errEl.hidden = false; errEl.textContent = 'Per-counterparty cap must be a non-negative number.'; return; }
saveBtn.disabled = true;
saveBtn.innerHTML = '<span class="awh-spin"></span>Saving…';
- const res = await call(`${base('limits')}?network=${ctx.getNetwork()}`, { method: 'PUT', body: { daily_usd: daily, per_tx_usd: perTx, withdraw_allowlist: allowState } });
+ const res = await call(`${base('limits')}?network=${ctx.getNetwork()}`, { method: 'PUT', body: { daily_usd: daily, per_tx_usd: perTx, per_counterparty_daily_usd: perCp, withdraw_allowlist: allowState } });
if (destroyed) return;
if (!res.ok) {
saveBtn.disabled = false; saveBtn.textContent = 'Save limits';
diff --git a/src/dashboard-next/pages/agents.js b/src/dashboard-next/pages/agents.js
index 085122a67..e568fd625 100644
--- a/src/dashboard-next/pages/agents.js
+++ b/src/dashboard-next/pages/agents.js
@@ -22,6 +22,7 @@ import { walletChipHTML, wireWalletChips } from '../../shared/agent-wallet-chip.
import { skeletonHTML, emptyStateHTML, errorStateHTML, attachRetry, ensureStateKitStyles } from '../../shared/state-kit.js';
import { rigBadgeHTML, matchesRigFilter, RIG_FILTERS } from '../../shared/rig-status.js';
import { toast } from '../../shared/toast.js';
+import { mountFarcasterSeed } from '../farcaster-seed.js';
ensureStateKitStyles();
const MONO = `'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace`;
@@ -1051,11 +1052,9 @@ function openPersonaModal(host, agent, allAgents, avatars) {
<div style="flex:1;min-width:0;font-size:12.5px;color:var(--nxt-ink-dim)">Distil your repos and commits. Uses your connected <strong style="color:var(--nxt-ink)">GitHub</strong> account.</div>
<button class="dn-btn" data-action="seed-github" type="button" style="flex-shrink:0">Seed from GitHub</button>
</div>
- <div style="display:grid;grid-template-columns:1fr auto;gap:8px;margin-bottom:0">
- <input data-slot="seed-farcaster" type="text" maxlength="50" placeholder="Farcaster username or FID" aria-label="Farcaster username or FID"
- style="padding:8px 11px;border-radius:8px;border:1px solid var(--nxt-stroke);
- background:rgba(255,255,255,0.04);color:var(--nxt-ink);font:inherit;font-size:13px" />
- <button class="dn-btn" data-action="seed-farcaster" type="button" style="flex-shrink:0">Seed from Farcaster</button>
+ <div style="border-top:1px solid var(--nxt-stroke);padding-top:12px;margin-top:12px">
+ <div style="font-size:12.5px;font-weight:600;color:var(--nxt-ink);margin-bottom:2px">Farcaster</div>
+ <div data-slot="seed-farcaster"></div>
</div>
<div data-slot="seed-status" style="font-size:12.5px;color:var(--nxt-ink-dim);margin-top:10px;min-height:18px"></div>
</div>
@@ -1118,38 +1117,23 @@ function openPersonaModal(host, agent, allAgents, avatars) {
const SEED_LABELS = {
'seed-twitter': 'Seed from X',
'seed-github': 'Seed from GitHub',
- 'seed-farcaster': 'Seed from Farcaster',
};
const SOURCE_NAMES = {
'seed-twitter': 'X',
'seed-github': 'GitHub',
- 'seed-farcaster': 'Farcaster',
};
const seedAction = async (action) => {
seedStatus.innerHTML = '';
- // X and GitHub seed from the user's connected OAuth account (no handle).
- // Farcaster is public, so it takes a username or FID.
- let endpoint;
- let body;
- if (action === 'seed-twitter') {
- endpoint = `/api/agents/${aid}/memory-seed-x`;
- } else if (action === 'seed-github') {
- endpoint = `/api/agents/${aid}/memory-seed`;
- } else {
- const handle = overlay
- .querySelector('[data-slot="seed-farcaster"]')
- .value.trim()
- .replace(/^@/, '');
- if (!handle) {
- seedStatus.style.color = 'var(--nxt-danger)';
- seedStatus.textContent = 'Enter a Farcaster username or FID first.';
- return;
- }
- endpoint = `/api/agents/${aid}/memory/seed/farcaster`;
- body = /^\d+$/.test(handle) ? { fid: Number(handle) } : { fname: handle };
- }
+ // X and GitHub seed from the user's connected OAuth account. Farcaster has
+ // no OAuth, so it runs its own consent panel below (wallet-signature proof
+ // of the fid) instead of a one-click button here.
+ const endpoint =
+ action === 'seed-twitter'
+ ? `/api/agents/${aid}/memory/seed/x`
+ : `/api/agents/${aid}/memory-seed`;
+ const body = undefined;
const btn = overlay.querySelector(`[data-action="${action}"]`);
btn.disabled = true;
@@ -1167,8 +1151,17 @@ function openPersonaModal(host, agent, allAgents, avatars) {
: `No new facts found from ${SOURCE_NAMES[action]}.`;
} catch (err) {
seedStatus.style.color = 'var(--nxt-danger)';
- // The X/GitHub endpoints require a connected account; guide the user there.
- if (err?.code === 'not_connected' || err?.status === 412) {
+ // X seeding is consent-gated. Consent can only be given on the screen
+ // that shows the full disclosure of what gets read and stored, so send
+ // the user there rather than granting it from a button labelled "Seed".
+ if (err?.code === 'consent_required' || err?.body?.error === 'consent_required') {
+ seedStatus.innerHTML = 'Seeding from X needs your consent first. ';
+ const link = document.createElement('a');
+ link.href = '/settings#connected-accounts';
+ link.textContent = 'Review what gets read and stored';
+ link.style.color = 'var(--nxt-accent, #6ea8fe)';
+ seedStatus.appendChild(link);
+ } else if (err?.code === 'not_connected' || err?.status === 412) {
seedStatus.innerHTML = `Connect ${esc(SOURCE_NAMES[action])} to seed from it. `;
const link = document.createElement('a');
link.href = '/settings#connected-accounts';
@@ -1193,9 +1186,8 @@ function openPersonaModal(host, agent, allAgents, avatars) {
overlay
.querySelector('[data-action="seed-github"]')
.addEventListener('click', () => seedAction('seed-github'));
- overlay
- .querySelector('[data-action="seed-farcaster"]')
- .addEventListener('click', () => seedAction('seed-farcaster'));
+
+ mountFarcasterSeed(overlay.querySelector('[data-slot="seed-farcaster"]'), { agentId: agent.id });
}
// ── Screen Caster setup modal ──────────────────────────────────────────────
diff --git a/src/voice/talk-controller.js b/src/voice/talk-controller.js
index 293bc240d..a01a14403 100644
--- a/src/voice/talk-controller.js
+++ b/src/voice/talk-controller.js
@@ -614,6 +614,10 @@ export class TalkController {
body: JSON.stringify({
voiceId: voiceId || ELEVEN_DEFAULT_VOICE,
text: text.slice(0, 500),
+ // Names the agent whose voice this is, so the proxy can serve the
+ // clip on its owner's own ElevenLabs key (BYOK) rather than the
+ // platform key. Without it, an owner-cloned voice is unreachable.
+ ...(this.avatar?.agent_id ? { agentId: this.avatar.agent_id } : {}),
}),
});
if (!r.ok) {