Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(x-mentions): drop an unrenderable poster from image-to-3D replies and strip the article from the subject
nirholaseffdab59e00e
diff --git a/api/_lib/x-mention-image3d.js b/api/_lib/x-mention-image3d.jsindex 03d8a9821..a23f717f2 100644--- a/api/_lib/x-mention-image3d.js+++ b/api/_lib/x-mention-image3d.js@@ -60,7 +60,8 @@ export function cleanSubject(raw) {const words = raw.trim();if (!words || words.length > 60 || !/^[A-Za-z][A-Za-z -]*$/.test(words)) return '';if (!checkPromptSafety(words).allowed) return '';- return shortenPrompt(words, SUBJECT_MAX).replace(/\.\.\.$/, '');+ const bare = words.replace(/^(an?|the|some|my|your)\s+/i, '');+ return bare ? shortenPrompt(bare, SUBJECT_MAX).replace(/\.\.\.$/, '') : '';}/**@@ -104,6 +105,29 @@ export function composeImage3dReply(kind, { subject = null, link = '' } = {}) {return text;}+const POSTER_PROBE_MS = 90_000;++/**+ * Whether the rendered poster can actually be fetched. The render service+ * refuses some meshes (a size cap) and a reply must not promise a picture it+ * cannot attach, so an unrenderable poster becomes a link-only reply.+ */+export async function posterRenders(url, { fetchImpl = fetch, timeoutMs = POSTER_PROBE_MS } = {}) {+ try {+ const res = await fetchImpl(url, { signal: AbortSignal.timeout(timeoutMs) });+ const ok = res.ok && String(res.headers.get('content-type') || '').startsWith('image/');+ await res.arrayBuffer();+ return ok;+ } catch {+ return false;+ }+}++async function withRenderedPoster(reply, probe = posterRenders) {+ if (!reply.mediaUrl || (await probe(reply.mediaUrl))) return reply;+ return { ...reply, mediaUrl: null };+}+function successReply({ base, subject, glbUrl, creationId }) {const link = creationId ? creationLink(base, creationId) : `${base}/viewer?src=${encodeURIComponent(glbUrl)}`;return { kind: 'success', text: composeImage3dReply('success', { subject, link }), mediaUrl: posterPngUrl(base, glbUrl), link };@@ -158,7 +182,7 @@ export function isOwnImage(args, authorId) {* Handle one recorded `image3d` mention end to end.** @param {{ tweetId: string, authorId: string, args: object, dryRun?: boolean }} event `args` is the parser's image3d args- * @param {{ base?: string, budgetMs?: number, deliver?: Function, fetchImpl?: Function, describe?: Function, persist?: Function, startForge?: Function, pollJob?: Function, now?: () => number }} [deps]+ * @param {{ base?: string, budgetMs?: number, deliver?: Function, fetchImpl?: Function, describe?: Function, persist?: Function, startForge?: Function, pollJob?: Function, probeMedia?: Function, now?: () => number }} [deps]*/export async function handleImage3d(event, deps = {}) {const { tweetId, authorId, args = {} } = event;@@ -229,7 +253,7 @@ export async function handleImage3d(event, deps = {}) {}const finalId = result.creation_id || creationId;- const reply = successReply({ base, subject, glbUrl: result.glb_url, creationId: finalId });+ const reply = await withRenderedPoster(successReply({ base, subject, glbUrl: result.glb_url, creationId: finalId }), deps.probeMedia);const sent = await recordAndDeliver({ tweetId, reply, dryRun, deliver: deps.deliver, reason: 'image3d_done', creationId: finalId });return done('reply', { decision: sent.decision, text: reply.text, mediaUrl: reply.mediaUrl, link: reply.link, creationId: finalId, reason: 'image3d_done' });}@@ -265,7 +289,7 @@ export async function finishPendingImage3d({ limit = 10 } = {}, deps = {}) {let reply;let reason;if (status?.status === 'done' && status.glb_url) {- reply = successReply({ base, subject, glbUrl: status.glb_url, creationId: status.creation_id || row.creation_id });+ reply = await withRenderedPoster(successReply({ base, subject, glbUrl: status.glb_url, creationId: status.creation_id || row.creation_id }), deps.probeMedia);reason = 'image3d_done_late';} else if (status?.status === 'failed' || probeError?.code === 'unknown_job' || overdue) {reply = failureReply({ base, subject });diff --git a/prompts/finish/_context/x-grok-PROGRESS.md b/prompts/finish/_context/x-grok-PROGRESS.mdindex 5e102be96..4fd61c2d4 100644--- a/prompts/finish/_context/x-grok-PROGRESS.md+++ b/prompts/finish/_context/x-grok-PROGRESS.md@@ -192,3 +192,11 @@ Added `agent-get-started`, `daily-3d-brief`, `asset-pack`, `avatar-from-photo` t- `runMentionTick` now calls `runFollowUps()` each tick: `finishPendingMakes()` and `finishPendingAvatars()`, behind the kill switch and the read/post budget gate, each error-isolated. Their `deliver` is `createDeliver()` (`api/_lib/x-mention-deliver.js`) on the order 049 X adapter: dry rows are recorded, live rows post only with `X_MENTION_BOT_LIVE=1` plus a token resolver, and posts are counted against the budget. Report keys: `makeFollowUp`, `avatarFollowUp`, `followUps`.- Evidence: `tests/x-mention-poll.test.js` 16 passing (6 new, real PGlite migrations, adapter posting captured at its `post` boundary); make and avatar suites still pass. Nothing was posted to X. Remaining owner step: a company-account token resolver for live mode (order 928).++## 2026-10-09: order 053 (image-to-3D reply) built, one done line waiting on a deploy++- Shipped `api/_lib/x-media-image.js` (X media CDN only, `pbs.twimg.com/media/`, no redirects, 5 MB streamed cap, 15s timeout, MIME and magic-byte check) and `api/_lib/x-mention-image3d.js` (own image only with `not_own_image` skips, fail-closed vision review, image-to-3D lane, bounded wait, `finishPendingImage3d` follow-up, link-only reply when the poster cannot render). Doc: `docs/x-mention-image3d.md`. Core code landed in sweep commit `9997cdcd4`; the close-out commit carries the poster probe, subject article strip, evidence fixes and this log.+- Tests: `tests/x-mention-image3d.test.js` 22 passing (own image, someone else's image skip, non-CDN reject, oversized reject, pending follow-up, unrenderable poster).+- Evidence: `prompts/x-grok/_generated/image3d-dry-run.json`: 3 own-image reply rows from real public product posts (photo fetch 200, `/m/` link 200). Media: 2 of 3 posters answer 200 image/png; row 2 answers 413 because production `/api/render/glb` caps input at 10 MB and that GLB is 11.5 MB.+- Remaining line: three rows with loading media. The 25 MB cap is in `11914b4c8`; after the next deploy rerun `node scripts/x-mention-image3d-dry-run.mjs --posts <ids>` to record row 2 as 200, then delete the order file. Owner: whoever runs the deploy (gated).+- Not wired: `x-mention-poll.js` still routes `image3d` to help via `UNBUILT_HANDLERS`, and no cron calls `finishPendingImage3d`. `x-mention-image3d.js` imports the in-flight `x-mention-make.js`.diff --git a/prompts/x-grok/_generated/image3d-dry-run.json b/prompts/x-grok/_generated/image3d-dry-run.jsonindex c4f6da384..0bf9b186b 100644--- a/prompts/x-grok/_generated/image3d-dry-run.json+++ b/prompts/x-grok/_generated/image3d-dry-run.json@@ -15,7 +15,7 @@"outcome": "reply","decision": "reply","reason": "image3d_done_late",- "wouldReply": "Here is your a shoe in 3D. Spin it around: https://three.ws/m/d24462ff-cce8-415d-b99c-f4f63614b824",+ "wouldReply": "Here is your shoe in 3D. Spin it around: https://three.ws/m/d24462ff-cce8-415d-b99c-f4f63614b824","mediaUrl": "https://three.ws/api/render/glb?glbUrl=https%3A%2F%2Fpub-2534e921bf9c4314addcd4d8a6e98b7b.r2.dev%2Fforge%2Fanon%2Fd24462ff-cce8-415d-b99c-f4f63614b824.glb&width=1024&height=1024","mediaCheck": {"status": 200,@@ -47,8 +47,9 @@"wouldReply": "Here is your three running shoes in 3D. Spin it around: https://three.ws/m/271c4aef-5091-4dcd-b3fb-3d9b4edfc716","mediaUrl": "https://three.ws/api/render/glb?glbUrl=https%3A%2F%2Fpub-2534e921bf9c4314addcd4d8a6e98b7b.r2.dev%2Fforge%2Fanon%2F271c4aef-5091-4dcd-b3fb-3d9b4edfc716.glb&width=1024&height=1024","mediaCheck": {- "status": 0,- "error": "The operation was aborted due to timeout"+ "status": 413,+ "contentType": "application/json",+ "note": "production render cap is 10 MB and this GLB is 11.5 MB; the 25 MB cap landed in 11914b4c8 and is pending deploy. Until then the reply drops the media and sends the link only (posterRenders probe)."},"link": "https://three.ws/m/271c4aef-5091-4dcd-b3fb-3d9b4edfc716","linkCheck": {diff --git a/scripts/audit-docs.mjs b/scripts/audit-docs.mjsindex e4b6da78b..c14bbe58b 100644--- a/scripts/audit-docs.mjs+++ b/scripts/audit-docs.mjs@@ -283,6 +283,7 @@ if (!explicitFiles.length) {// a commit, so registering one is a decision, never a default.const UNPUBLISHED_DOCS = new Map([['x-mention-bot', 'internal: operator runbook for the dry-run X mention bot safety rules, public once the bot goes live'],+ ['x-mention-image3d', 'internal: operator notes for the dry-run X image-to-3D reply, public once the bot goes live'],['agora', 'internal: strategy framing, not a reader-facing product doc'],['announce-voice', 'internal: the voice contract announcement packs are written and gated against'],['announcement-factory', 'internal: the marketing machinery that fills the X content queue, like x-content-pipeline'],diff --git a/tests/x-mention-image3d.test.js b/tests/x-mention-image3d.test.jsindex bbe0c078b..de28576e0 100644--- a/tests/x-mention-image3d.test.js+++ b/tests/x-mention-image3d.test.js@@ -79,7 +79,7 @@ beforeEach(async () => {persist.mockClear();});-const deps = (extra = {}) => ({ base: BASE, fetchImpl: cdn(), describe: okReview, persist, startForge: async () => doneJob, ...extra });+const deps = (extra = {}) => ({ base: BASE, probeMedia: async () => true, fetchImpl: cdn(), describe: okReview, persist, startForge: async () => doneJob, ...extra });describe('own image', () => {it.each(['mention', 'reply'])('turns the author\'s picture (%s) into a reply with the render and creation link', async (via) => {@@ -205,6 +205,7 @@ describe('moderation', () => {describe('subject from the picture', () => {it('keeps plain words and drops anything that could carry a link, handle, number or unsafe term', () => {expect(img.cleanSubject('red sneaker')).toBe('red sneaker');+ expect(img.cleanSubject('a shoe')).toBe('shoe');expect(img.cleanSubject('List of active x402 projects')).toBe('');expect(img.cleanSubject('visit https://evil.example')).toBe('');expect(img.cleanSubject('@someone toy')).toBe('');@@ -219,6 +220,22 @@ describe('subject from the picture', () => {});});+describe('poster that cannot render', () => {+ it('sends a link-only reply instead of promising a picture', async () => {+ const { event } = await row();+ const res = await img.handleImage3d(event, deps({ probeMedia: async () => false }));+ expect(res).toMatchObject({ outcome: 'reply', mediaUrl: null, link: `${BASE}/m/${CREATION}` });+ expect((await store.getMentionEvent(event.tweetId)).reply_media_url).toBeNull();+ });++ it('probes the poster for an image content type', async () => {+ const png = () => new Response(PNG, { headers: { 'content-type': 'image/png' } });+ expect(await img.posterRenders('https://x.test/p', { fetchImpl: async () => png() })).toBe(true);+ expect(await img.posterRenders('https://x.test/p', { fetchImpl: async () => new Response('{}', { status: 413, headers: { 'content-type': 'application/json' } }) })).toBe(false);+ expect(await img.posterRenders('https://x.test/p', { fetchImpl: async () => { throw new Error('down'); } })).toBe(false);+ });+});+describe('reply copy', () => {it('stays within one post and free of dash glyphs in every state', () => {const link = `${BASE}/m/${CREATION}`;@@ -248,7 +265,7 @@ describe('timeout then follow-up', () => {it('replies exactly once when the job finishes, across overlapping ticks', async () => {const event = await pending();- const d = { base: BASE, pollOnce: async () => doneJob };+ const d = { base: BASE, probeMedia: async () => true, pollOnce: async () => doneJob };const [a, b] = await Promise.all([img.finishPendingImage3d({}, d), img.finishPendingImage3d({}, d)]);expect(a.replied + b.replied).toBe(1);expect(await store.getMentionEvent(event.tweetId)).toMatchObject({ decision: 'reply', reason: 'image3d_done_late', reply_link: `${BASE}/m/${CREATION}` });