Skip to content

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

require a song id in the Suno URL, use the landed page's id, and test prepare()

[._.]/ Adam Eivy9ae73d36805a
diff --git a/server/lib/README.md b/server/lib/README.md
index b0bd2c6d40..38ec7f066a 100644
--- a/server/lib/README.md
+++ b/server/lib/README.md
@@ -673,6 +673,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub
| `concurrencyGate.js` | `createConcurrencyGate(limit)` → `run(fn)` — cap on simultaneous async work for ONE module-scoped budget, released FIFO. Sibling to `mapWithConcurrency.js`, which caps in-flight work *within one array map*; a gate is shared state, so several call sites fanning out at the same remote respect one budget instead of each respecting its own while the host sees the sum. `createMutex` (`asyncMutex.js`) is this with `limit` fixed at 1 — prefer it for mutual exclusion. Note the budget is per-MODULE, not per-host: two modules calling one host each get their own gate. Used by `huggingFaceMetadata.js` (4) and `ollamaRegistryCatalog.js` (16), whose cold catalog-enrichment bursts otherwise arrive at a free public API as a thundering herd — which the Hub answers with an HTTP/2 GOAWAY that surfaces as a bare `fetch failed`. |
| `dispatchLabels.js` | slashdo dispatch-hint contract: the `model:` capability and `effort:` reasoning-budget label vocabulary (the tiers themselves live in this module and are deliberately not re-enumerated here — a catalog copy of them is what drifted a tier behind), prescribed forge colors, validation (`normalizeDispatchModel` / `normalizeDispatchEffort`), the read-side inverse (`dispatchHintFromLabels` — recovers `{model, effort}` from a raw label-name list, used by branch-reconcile's per-branch routing hint), the per-forge label separator (`labelSeparator` / `forgeLabelName` — GitLab spells every prefixed label with its native scoped `::`, GitHub keeps `:`, and the read side accepts both; applied once at the `forgeIssueLabels` / `dispatchLabelSpec` boundary so the axis builders stay canonical; Jira keeps the hyphen form), optional contributor labels (`good first issue` / `help wanted`, never implied by `model:light`, and released at claim time by `formatContributorLabelReleaseCommands` — one best-effort command per label, since a forge fails the whole edit when a named label is absent), the one shared volunteer-claim policy (`volunteerClaimLabels` / `formatVolunteerClaimCommands` — a human comment claiming an unassigned issue is resolved by BOTH issueWatcher.js's deterministic pass and the claim prompt's Phase 1 handoff, so both stamp `in-progress` and retire the invitations rather than writing opposite state), the open-ended planner-attribution axis (`planner:<model>`, `normalizePlannerId` / `resolvePlannerId` / `formatPlannerLabelGuidance` — records WHICH model wrote the plan, prefix-matched by `dispatchLabelSpec` so it lazily creates like the fixed labels; a filing agent takes the value from its prompt, never from self-identification), the workflow-state markers (`EPIC_LABEL`/`EPIC_DECOMPOSED_LABEL` and `IN_PROGRESS_LABEL` — state, not hints: shared with perpetualWork.js#isActionableIssue, issueReconcile.js's zombie scan, issueWatcher.js's volunteer assignment, and the claim prompts), lazy-create command text, the optional `--label` slots a rendered `issue create` example offers (`OPTIONAL_ISSUE_LABEL_FLAG_SLOTS` / `formatOptionalIssueLabelFlags` — one list so a new axis reaches every prompt template's copy-pasteable command, not just its prose), and shared dispatch plus issue-quality guidance (`ISSUE_QUALITY_GUIDANCE`, `DISPATCH_HINT_GUIDANCE`, `MANDATORY_DISPATCH_HINT_GUIDANCE`, `JIRA_DISPATCH_HINT_GUIDANCE`, `MANDATORY_JIRA_DISPATCH_HINT_GUIDANCE`, `REFERENCE_WATCH_LABEL_CONTRACT`, plus the consumer-side pair `DISPATCH_HINT_READING_GUIDANCE` / `DISPATCH_HINT_FANOUT_GUIDANCE` — what the labels mean to an agent that RECEIVES them (the preloaded `open-issues` task data input) and, for an orchestrator only, how to route each sub-agent by its own issue (the swarm block); the fan-out form is the reading form plus one line, never a second copy of the vocabulary). All forge filing callers require both dispatch axes and verify labels after creation; help wanted requires specific hardware validation or valuable input from real users; never invent `medium`; reject future-only/speculative work while keeping useful current refactors claimable. Consumed by work-tracker instructions, quota-burn audits, Layered Intelligence filing, and claim follow-up prompts. |
| `distrokidForm.js` | The in-page steps of the DistroKid upload recipe (#10337): `fillDistrokidFields` (genre, language, store profiles, credits, preview start, the track's normal answers), `discloseDistrokidAi` (inline AI checkboxes, gate then parts) and `untickDistrokidExtras` (paid extras). Self-contained so `page.evaluate` can ship them, and tested against a fixture form in the client's DOM tests. |
+| `sunoPage.js` | The in-page step of the Suno publish recipe: `markSunoSongMenu(songId)` tags the song page's OWN "More options" button with `data-portos-song-menu` (false when there is none), skipping the menus of other songs the page shows: the "Cover of" card of the song a cover was made from, the Similar / By-artist lists, the playbar. Runs inside the page via `page.evaluate`, so it reads only `document`; fixture tests live in `client/src/lib/sunoPage.test.js`. |
| `distrokidGenres.js` | DistroKid's store genre list (`DISTROKID_GENRES`) and `suggestDistrokidGenres(project)`, a first primary/secondary genre guess from the song's own style words. Shared by the DistroKid publish payload and the publish panel's genre pickers. |
| `domainAutonomy.js` | Per-domain autonomy guardrails (pure). `AUTONOMY_DOMAINS`/`DOMAIN_IDS`/`DOMAIN_MODES` (`off`/`dry-run`/`execute`), `getDomainMode(config, id)`, and `normalizeDomainAutonomy(raw)` to coerce a hand-edited/partial map. Default per domain is `execute` (reproduces pre-#711 behavior, so no migration needed). Also `CREATIVE_DOMAIN`/`getCreativeAutonomyMode(config)` (#2183) — the Creative Director orchestrator domain, kept out of `DOMAIN_IDS` and defaulting to mirror the `cos` mode. |
| `domainBudgets.js` | Per-domain daily autonomy budgets (pure). `BUDGET_LIMIT_FIELDS` (`maxActionsPerDay`/`maxMinutesPerDay`), `getDomainBudget(config, id)`, `normalizeDomainBudgets(raw)`, `hasBudget(budget)`, and `evaluateBudget(budget, usage)` → `{ withinBudget, exceeded }`. A `null`/non-positive cap means unlimited (default per domain, so no migration needed). Token/$ caps are intentionally absent — CLI subscription providers expose no per-run metering. Usage ledger + gate wiring live in `services/domainUsage.js`. |
diff --git a/server/lib/index.js b/server/lib/index.js
index 18a5eb9b53..a033ad2a1b 100644
--- a/server/lib/index.js
+++ b/server/lib/index.js
@@ -647,6 +647,7 @@ export * from './concurrencyGate.js';
export * from './dispatchLabels.js';
export * from './distrokidForm.js';
export * from './distrokidGenres.js';
+export * from './sunoPage.js';
export * from './domainAutonomy.js';
export * from './domainBudgets.js';
export * from './eidoverseCreativeToolkit.js';
diff --git a/server/services/musicVideo/publish/payloads.js b/server/services/musicVideo/publish/payloads.js
index 805722cb6b..a88921eea4 100644
--- a/server/services/musicVideo/publish/payloads.js
+++ b/server/services/musicVideo/publish/payloads.js
@@ -168,7 +168,8 @@ const BUILDERS = {
},
suno: (project, kit, options = {}) => {
const song = songUrl(kit, options);
- if (!/^https:\/\/(www\.)?suno\.com\/song\/[\w-]+/.test(song)) throw missing('Give the Suno song URL to publish (suno.com/song/…)');
+ // The adapter finds the song's own menu by its id, so the URL must carry it.
+ if (!/^https:\/\/(www\.)?suno\.com\/song\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i.test(song)) throw missing('Give the Suno song URL to publish (suno.com/song/…)');
const video = fullVideoUrl(kit);
const lead = text(kit.copy?.youtube?.description).split(/\n\s*\n/)[0] || '';
const caption = [lead, video ? `Music video: ${video}` : ''].filter(Boolean).join(' ').slice(0, 500);
diff --git a/server/services/musicVideo/publish/payloads.test.js b/server/services/musicVideo/publish/payloads.test.js
index 907e0a976e..7058e40f7c 100644
--- a/server/services/musicVideo/publish/payloads.test.js
+++ b/server/services/musicVideo/publish/payloads.test.js
@@ -12,7 +12,7 @@ const kit = (over = {}) => ({
thumbnail: 'thumb-1.jpg',
captionsFilename: 'captions.srt',
chapters: [{ startSec: 0, label: 'Intro' }, { startSec: 30, label: 'Chorus' }, { startSec: 75, label: 'Outro' }],
- links: { youtube: 'https://youtu.be/abc', song: 'https://suno.com/song/1234-abcd' },
+ links: { youtube: 'https://youtu.be/abc', song: 'https://suno.com/song/12345678-abcd-4abc-8abc-123456789abc' },
copy: {
youtube: { title: 'Song — Music Video', description: 'The story.\n\nMore.', tags: ['ai music', ' '] },
shorts: { title: 'Song #Shorts', description: 'Hook' },
@@ -91,7 +91,7 @@ describe('buildPublishPayload (#9282)', () => {
it('threads X: hook with the 1080p encode, story, prompt, then links with the full video last', () => {
const { posts } = buildPublishPayload('x', project(), { prompt: 'the prompt', storyImage: 'still.png' });
- expect(posts.map((p) => p.text)).toEqual(['Watch this', 'How it was made', 'the prompt', 'The song: https://suno.com/song/1234-abcd\nFull video: https://youtu.be/abc']);
+ expect(posts.map((p) => p.text)).toEqual(['Watch this', 'How it was made', 'the prompt', 'The song: https://suno.com/song/12345678-abcd-4abc-8abc-123456789abc\nFull video: https://youtu.be/abc']);
expect(posts[0].media).toEqual({ dir: 'videos', name: 'x.mp4' });
expect(posts[1].media).toEqual({ dir: 'videoThumbnails', name: 'still.png' });
expect(() => buildPublishPayload('x', project({ exports: [] }))).toThrow(/1080p/);
@@ -115,9 +115,11 @@ describe('buildPublishPayload (#9282)', () => {
it('needs a suno.com song URL and captions it with the full video', () => {
const p = buildPublishPayload('suno', project());
- expect(p).toMatchObject({ songUrl: 'https://suno.com/song/1234-abcd', pin: true, cover: { name: 'thumb-1.jpg' } });
+ expect(p).toMatchObject({ songUrl: 'https://suno.com/song/12345678-abcd-4abc-8abc-123456789abc', pin: true, cover: { name: 'thumb-1.jpg' } });
expect(p.caption).toBe('The story. Music video: https://youtu.be/abc');
expect(() => buildPublishPayload('suno', project({ links: {} }))).toThrow(/Suno song URL/);
+ // The adapter needs the song's id to find its menu, so an id-less song URL is refused up front.
+ expect(() => buildPublishPayload('suno', project({ links: {} }), { songUrl: 'https://suno.com/song/example' })).toThrow(/Suno song URL/);
});
it('rejects an unknown target', () => {
@@ -149,6 +151,6 @@ describe('buildPublishPayload (#9282)', () => {
const withCover = song({ publishKit: kit({ coverArt: { filename: 'cover-1.jpg' } }) });
expect(buildPublishPayload('distrokid', withCover, who).cover).toEqual({ dir: 'videoThumbnails', name: 'cover-1.jpg', square: true });
expect(buildPublishPayload('distrokid', { ...withCover, publishKit: kit({ thumbnail: null, coverArt: { filename: 'cover-1.jpg' } }) }, who).cover.name).toBe('cover-1.jpg');
- expect(buildPublishPayload('suno', withCover, { songUrl: 'https://suno.com/song/example' }).cover.name).toBe('cover-1.jpg');
+ expect(buildPublishPayload('suno', withCover, { songUrl: 'https://suno.com/song/87654321-dcba-4cba-8cba-cba987654321' }).cover.name).toBe('cover-1.jpg');
});
});
diff --git a/server/services/musicVideo/publish/suno.js b/server/services/musicVideo/publish/suno.js
index a7bcc063c7..dd8ff27389 100644
--- a/server/services/musicVideo/publish/suno.js
+++ b/server/services/musicVideo/publish/suno.js
@@ -20,8 +20,10 @@ export const sunoAdapter = {
await step(label, 'open the Publish dialog', async () => {
// A cover's page lists the song it covers first, with its own menu, so the
// page song's menu is picked by which song card it sits in.
- const songId = songIdOf(payload.songUrl);
- if (!songId || !(await page.evaluate(markSunoSongMenu, songId))) throw new Error("no menu for this page's own song");
+ // A share link or redirect can land on the song under another URL; the page's own wins.
+ const songId = songIdOf(page.url()) || songIdOf(payload.songUrl);
+ if (!songId) throw new Error(`no song id in ${payload.songUrl}`);
+ if (!(await page.evaluate(markSunoSongMenu, songId))) throw new Error("no menu for this page's own song (only other songs' menus were found)");
await page.locator('[data-portos-song-menu]').click({ timeout: T });
await page.locator('[role=menuitem]').filter({ hasText: /^Publish$/ }).first().click({ timeout: T });
await page.locator('[role=dialog]').first().waitFor({ timeout: T });
diff --git a/server/services/musicVideo/publish/suno.test.js b/server/services/musicVideo/publish/suno.test.js
new file mode 100644
index 0000000000..578e99ac42
--- /dev/null
+++ b/server/services/musicVideo/publish/suno.test.js
@@ -0,0 +1,59 @@
+import { describe, it, expect } from 'vitest';
+import { sunoAdapter } from './suno.js';
+import { markSunoSongMenu } from '../../../lib/sunoPage.js';
+
+const SONG = '12345678-abcd-4abc-8abc-123456789abc';
+const LANDED = '87654321-dcba-4cba-8cba-cba987654321';
+
+// A song page: `marks` is what markSunoSongMenu finds; the Publish dialog
+// opens on the marked button's click and the run stops there.
+const fakePage = ({ url = `https://suno.com/song/${SONG}`, marks = true } = {}) => {
+ const calls = { marked: [], clicked: [] };
+ return {
+ calls,
+ goto: async () => {},
+ url: () => url,
+ waitForTimeout: async () => {},
+ evaluate: async (fn, arg) => {
+ if (fn === markSunoSongMenu) { calls.marked.push(arg); return marks; }
+ return true;
+ },
+ locator: (sel) => {
+ const node = {
+ count: async () => 1,
+ click: async () => { calls.clicked.push(sel); },
+ waitFor: async () => { throw new Error('stop here'); },
+ filter: () => node,
+ first: () => node,
+ };
+ return node;
+ },
+ };
+};
+
+describe('Suno prepare', () => {
+ it("opens the menu marked as the page song's own", async () => {
+ const page = fakePage();
+ await expect(sunoAdapter.prepare(page, { songUrl: `https://suno.com/song/${SONG}` })).rejects.toThrow(/stop here/);
+ expect(page.calls.marked).toEqual([SONG]);
+ expect(page.calls.clicked[0]).toBe('[data-portos-song-menu]');
+ });
+
+ it('uses the song the page landed on when the link redirected', async () => {
+ const page = fakePage({ url: `https://suno.com/song/${LANDED}?sh=abc` });
+ await expect(sunoAdapter.prepare(page, { songUrl: `https://suno.com/song/${SONG}` })).rejects.toThrow(/stop here/);
+ expect(page.calls.marked).toEqual([LANDED]);
+ });
+
+ it("fails before clicking anything when only other songs' menus are on the page", async () => {
+ const page = fakePage({ marks: false });
+ await expect(sunoAdapter.prepare(page, { songUrl: `https://suno.com/song/${SONG}` })).rejects.toThrow(/no menu for this page's own song/);
+ expect(page.calls.clicked).toEqual([]);
+ });
+
+ it('names the URL when neither it nor the page carries a song id', async () => {
+ const page = fakePage({ url: 'https://suno.com/s/abc' });
+ await expect(sunoAdapter.prepare(page, { songUrl: 'https://suno.com/s/abc' })).rejects.toThrow(/no song id in https:\/\/suno\.com\/s\/abc/);
+ expect(page.calls.clicked).toEqual([]);
+ });
+});