Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: diagnose unaccepted Suno creation requests (#9474)
[._.]/ Adam Eivy0782488ab46e
diff --git a/server/services/musicVideo/autonomousSuno.js b/server/services/musicVideo/autonomousSuno.jsindex f8c675ac21..1a7ae9af08 100644--- a/server/services/musicVideo/autonomousSuno.js+++ b/server/services/musicVideo/autonomousSuno.js@@ -44,6 +44,64 @@ const songLinks = (page, title = null) => page.evaluate((wantedTitle) => [...doc.filter((a) => wantedTitle === null || a.textContent.trim() === wantedTitle).map((a) => a.getAttribute('href')), title);+// Observe only this click's bounded network metadata. A Suno POST may be+// analytics rather than generation: neither its presence nor a 2xx proves+// acceptance. Never export URLs, headers, bodies, request errors or account data.+function observeSunoPosts(page) {+ const posts = new Map();+ let truncated = false;+ const request = (req) => {+ if (req.method() !== 'POST' || !['xhr', 'fetch'].includes(req.resourceType())) return;+ const host = new URL(req.url()).hostname;+ if (!['suno.com', 'suno.ai'].some((domain) => host === domain || host.endsWith(`.${domain}`))) return;+ if (posts.size >= 16) { truncated = true; return; }+ posts.set(req, { status: null, failed: false });+ };+ const response = (res) => {+ const post = posts.get(res.request());+ if (post) post.status = res.status();+ };+ const failed = (req) => {+ const post = posts.get(req);+ if (post) post.failed = true;+ };+ page.on('request', request);+ page.on('response', response);+ page.on('requestfailed', failed);+ return {+ snapshot: () => ({+ scope: 'suno-fetch-posts',+ observedPosts: posts.size,+ httpStatuses: [...new Set([...posts.values()].map((post) => post.status).filter((status) => status !== null))].sort((a, b) => a - b),+ failedPosts: [...posts.values()].filter((post) => post.failed).length,+ pendingPosts: [...posts.values()].filter((post) => post.status === null && !post.failed).length,+ truncated,+ }),+ stop: () => {+ page.off('request', request);+ page.off('response', response);+ page.off('requestfailed', failed);+ posts.clear();+ },+ };+}++async function sunoRefusalSignals(page) {+ return page.evaluate(() => {+ const visible = (el) => el.getClientRects().length > 0 && getComputedStyle(el).visibility !== 'hidden';+ const text = [...document.querySelectorAll('[role="dialog"],[role="alert"]')]+ .filter(visible).map((el) => el.textContent.toLowerCase()).join(' ');+ // Return fixed signal names only, never the page's private text.+ return {+ inspected: true,+ captcha: [...document.querySelectorAll('iframe[src*="captcha"],iframe[src*="challenge"]')].some(visible),+ credits: /not enough credits|insufficient credits|out of credits/.test(text),+ signIn: /sign in|log in/.test(text),+ contentPolicy: /content policy|moderation|copyright/.test(text),+ };+ }).catch(() => ({ inspected: false }));+}+/*** Fill Suno's custom-song form and press Create. Returns the ids of the songs* that appeared (Suno makes two takes per request) — the links present before@@ -92,20 +150,32 @@ async function submitSunoSong(page, fields, { sleep = defaultSleep, now = Date.n}const before = new Set(sunoSongIdsFromHrefs(await songLinks(page)));- await step(LABEL, 'press Create', async () => {- await page.getByRole('button', { name: /^create( song)?$/i }).last().click({ timeout: T });- });+ const observer = observeSunoPosts(page);+ try {+ await step(LABEL, 'press Create', async () => {+ await page.getByRole('button', { name: /^create( song)?$/i }).last().click({ timeout: T });+ });- // New rows land at the top of the workspace list once Suno accepts the request.- const deadline = now() + 90_000;- while (now() < deadline) {- await sleep(3000);- const fresh = sunoSongIdsFromHrefs(await songLinks(page, fields.title)).filter((id) => !before.has(id));- if (fresh.length) return fresh;+ // New rows land at the top of the workspace list once Suno accepts the request.+ const deadline = now() + 90_000;+ while (now() < deadline) {+ await sleep(3000);+ const fresh = sunoSongIdsFromHrefs(await songLinks(page, fields.title)).filter((id) => !before.has(id));+ if (fresh.length) return fresh;+ }+ const network = observer.snapshot();+ const refusalSignals = await sunoRefusalSignals(page);+ const observed = network.observedPosts+ ? `${network.observedPosts} Suno POST request(s) observed; HTTP statuses: ${network.httpStatuses.join(', ') || 'none'}`+ : 'no Suno POST request observed';+ const signals = ['captcha', 'credits', 'signIn', 'contentPolicy'].filter((key) => refusalSignals[key]);+ const ui = refusalSignals.inspected ? `visible refusal signals: ${signals.join(', ') || 'none'}` : 'refusal inspection unavailable';+ throw new ServerError(`Suno: no matching song appeared after pressing Create (${observed}; failed: ${network.failedPosts}; pending: ${network.pendingPosts}${network.truncated ? '; sample capped' : ''}; ${ui}). Request metadata does not prove generation acceptance.`, {+ status: 502, code: 'SUNO_NO_SONG', context: { platform: LABEL, network, refusalSignals },+ });+ } finally {+ observer.stop();}- throw new ServerError('Suno: no matching song appeared after pressing Create — check the PortOS Browser for a credits, captcha or content-policy prompt', {- status: 502, code: 'SUNO_NO_SONG', context: { platform: LABEL },- });}/**diff --git a/server/services/musicVideo/autonomousSuno.test.js b/server/services/musicVideo/autonomousSuno.test.jsindex b9c7c469e8..84c931a599 100644--- a/server/services/musicVideo/autonomousSuno.test.js+++ b/server/services/musicVideo/autonomousSuno.test.js@@ -5,6 +5,7 @@* is accepted only once it stops growing, and a retry reuses submitted songs.*/+import { EventEmitter } from 'node:events';import { describe, it, expect, vi } from 'vitest';import { __testing, generateSunoSong } from './autonomousSuno.js';@@ -16,8 +17,9 @@ const NEW_B = '33333333-3333-3333-3333-333333333333';const noSleep = async () => {};/** A just-enough Playwright page: tracks fills/clicks and exposes song links that appear after Create. */-function fakePage({ url = 'https://suno.com/create', hasForm = true, modern = true, newTitleMatches = true, afterCreate = [NEW_A, NEW_B] } = {}) {+function fakePage({ url = 'https://suno.com/create', hasForm = true, modern = true, newTitleMatches = true, afterCreate = [NEW_A, NEW_B], onCreate, refusalSignals = { inspected: true, captcha: false, credits: false, signIn: false, contentPolicy: false } } = {}) {const fills = {};+ const events = new EventEmitter();let created = false;const locator = (selector) => {const handle = {@@ -31,15 +33,18 @@ function fakePage({ url = 'https://suno.com/create', hasForm = true, modern = trconst button = (role, options) => ({count: async () => role === 'textbox' || role === 'tab' ? (modern ? 1 : 0) : /instrumental|custom/.test(String(options.name)) ? (modern ? 0 : 1) : 1,first: () => ({ click: async () => {}, fill: async v => { fills[options.name] = v; } }),- last: () => ({ click: async () => { created = true; } }),+ last: () => ({ click: async () => { created = true; onCreate?.(events); } }),});return {fills,+ on: events.on.bind(events),+ off: events.off.bind(events),+ listenerCount: events.listenerCount.bind(events),goto: vi.fn(async () => {}),url: () => url,locator,getByRole: button,- evaluate: async (_fn, title) => [+ evaluate: async (_fn, title) => title === undefined ? refusalSignals : [...(title === null ? [`/song/${OLD}`] : []),...(created && (title === null || newTitleMatches) ? afterCreate.map((id) => `/song/${id}`) : []),],@@ -54,6 +59,7 @@ describe('submitSunoSong', () => {const page = fakePage();const ids = await submitSunoSong(page, fields, { sleep: noSleep });expect(ids).toEqual([NEW_A, NEW_B]);+ expect(page.listenerCount('request')).toBe(0);expect(page.fills['[role="textbox"][aria-label="Lyrics editor"],textarea[placeholder*="lyrics" i]']).toBe('[verse]\nrain');expect(page.fills['textarea:not([aria-label]):not([placeholder="Describe the sound you want"])']).toBe('synthwave');expect(page.fills['input[placeholder*="title" i]:visible']).toBe('Neon Rain');@@ -72,6 +78,41 @@ describe('submitSunoSong', () => {})).rejects.toMatchObject({ code: 'SUNO_NO_SONG' });});+ it('distinguishes a click with no observed POST without inventing a refusal', async () => {+ let time = 0;+ const page = fakePage({ afterCreate: [] });+ await expect(submitSunoSong(page, fields, { sleep: noSleep, now: () => (time += 30_000) }))+ .rejects.toMatchObject({ code: 'SUNO_NO_SONG', context: {+ network: { observedPosts: 0, httpStatuses: [], failedPosts: 0, pendingPosts: 0, truncated: false },+ refusalSignals: { inspected: true, captcha: false, credits: false, signIn: false, contentPolicy: false },+ } });+ expect(page.listenerCount('request')).toBe(0);+ expect(page.listenerCount('response')).toBe(0);+ expect(page.listenerCount('requestfailed')).toBe(0);+ });++ it('reports bounded HTTP/failure evidence without private URLs or response bodies', async () => {+ let time = 0;+ const request = (url) => ({ method: () => 'POST', resourceType: () => 'fetch', url: () => url });+ const page = fakePage({ afterCreate: [], refusalSignals: { inspected: true, credits: true }, onCreate: (events) => {+ events.emit('request', request('https://suno.com.attacker.example/api?token=private-token'));+ const rejected = request('https://studio-api.prod.suno.com/api/generate/?token=private-token');+ events.emit('request', rejected);+ events.emit('response', { request: () => rejected, status: () => 403, text: () => 'private-body' });+ const failed = request('https://studio-api.prod.suno.com/private-account');+ events.emit('request', failed);+ events.emit('requestfailed', failed);+ for (let i = 0; i < 20; i += 1) events.emit('request', request('https://suno.com/api'));+ } });+ const error = await submitSunoSong(page, fields, { sleep: noSleep, now: () => (time += 30_000) }).catch((err) => err);+ expect(error).toMatchObject({ code: 'SUNO_NO_SONG', context: {+ network: { observedPosts: 16, httpStatuses: [403], failedPosts: 1, pendingPosts: 14, truncated: true },+ refusalSignals: { inspected: true, credits: true },+ } });+ expect(JSON.stringify({ message: error.message, context: error.context })).not.toMatch(/private-|studio-api|attacker/);+ expect(page.listenerCount('request')).toBe(0);+ });+it('keeps the older Custom form compatible', async () => {const page = fakePage({ modern: false });await submitSunoSong(page, fields, { sleep: noSleep });