Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.trigger
.env
.DS_Store
node_modules
tsconfig.tsbuildinfo.env.local
.env
tsconfig.tsbuildinfo
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"test": "vitest run"
},
"dependencies": {
"@fal-ai/client": "^1.9.4",
"@trigger.dev/sdk": "4.3.3",
"@vercel/sandbox": "^1.8.0",
"ai": "^5.0.87",
Expand All @@ -17,7 +16,6 @@
"devDependencies": {
"@trigger.dev/build": "4.3.3",
"@types/ms": "^2.1.0",
"dotenv": "^17.3.1",
"typescript": "^5.9.3",
"vitest": "^4.0.18"
}
Expand Down
39 changes: 0 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions src/artists/getBatchArtistSocials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ import { getArtistSocials } from "../recoup/getArtistSocials";
/**
* Fetches socials for all artists in parallel.
* Returns a Map of artistId -> socials array.
*
* @param artistIds
*/
export async function getBatchArtistSocials(
artistIds: string[]
artistIds: string[],
): Promise<Map<string, Awaited<ReturnType<typeof getArtistSocials>>>> {
logger.log("Fetching socials for all artists", {
totalArtists: artistIds.length,
});

const socialsResponses = await Promise.all(
artistIds.map((artistId) => getArtistSocials(artistId))
);
const socialsResponses = await Promise.all(artistIds.map(artistId => getArtistSocials(artistId)));

// Store socials in map
const artistSocialsMap = new Map<
string,
Awaited<ReturnType<typeof getArtistSocials>>
>();
const artistSocialsMap = new Map<string, Awaited<ReturnType<typeof getArtistSocials>>>();

for (let i = 0; i < artistIds.length; i++) {
artistSocialsMap.set(artistIds[i], socialsResponses[i]);
Expand Down
4 changes: 3 additions & 1 deletion src/artists/isScrapableSocial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import type { ArtistSocialProfile } from "../recoup/getArtistSocials";
*
* Non-scrapable platforms:
* - open.spotify.com
*
* @param social
*/
export function isScrapableSocial(social: ArtistSocialProfile): boolean {
const profileUrl = social.profile_url.toLowerCase();
Expand Down Expand Up @@ -39,5 +41,5 @@ export function isScrapableSocial(social: ArtistSocialProfile): boolean {
"youtube.com",
];

return scrapableDomains.some((domain) => profileUrl.includes(domain));
return scrapableDomains.some(domain => profileUrl.includes(domain));
}
4 changes: 1 addition & 3 deletions src/chats/getTaskRoomId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ type GetTaskRoomIdParams = {
* @param params - Parameters containing optional roomId and artistId
* @returns The room ID, or undefined if creation fails
*/
export async function getTaskRoomId(
params: GetTaskRoomIdParams
): Promise<string | undefined> {
export async function getTaskRoomId(params: GetTaskRoomIdParams): Promise<string | undefined> {
if (params.roomId) {
logger.log("Using existing roomId", { roomId: params.roomId });
return params.roomId;
Expand Down
2 changes: 1 addition & 1 deletion src/consts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const NEW_API_BASE_URL = "https://recoup-api.vercel.app";
export const RECOUP_API_KEY = process.env.RECOUP_API_KEY;
export const CODING_AGENT_ACCOUNT_ID = "04e3aba9-c130-4fb8-8b92-34e95d43e66b";
export const OPENCLAW_DEFAULT_MODEL = "vercel-ai-gateway/anthropic/claude-sonnet-4.6";
export const OPENCLAW_DEFAULT_MODEL = "vercel-ai-gateway/anthropic/claude-sonnet-4.6";
11 changes: 3 additions & 8 deletions src/github/__tests__/createOrgGithubRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ describe("createOrgGithubRepo", () => {

const result = await createOrgGithubRepo("Test Org", "uuid-123");

expect(result).toBe(
"https://github.com/Recoupable-Com/org-test-org-uuid-123"
);
expect(result).toBe("https://github.com/Recoupable-Com/org-test-org-uuid-123");
expect(mockFetch).toHaveBeenCalledOnce();

// Verify the request body has the right repo name and auto_init
Expand Down Expand Up @@ -57,9 +55,7 @@ describe("createOrgGithubRepo", () => {

const result = await createOrgGithubRepo("My Org", "uuid-456");

expect(result).toBe(
"https://github.com/Recoupable-Com/org-my-org-uuid-456"
);
expect(result).toBe("https://github.com/Recoupable-Com/org-my-org-uuid-456");
expect(mockFetch).toHaveBeenCalledTimes(2);
});

Expand Down Expand Up @@ -104,8 +100,7 @@ describe("createOrgGithubRepo", () => {
mockFetch.mockResolvedValueOnce({
ok: true,
json: async () => ({
html_url:
"https://github.com/Recoupable-Com/org-my-cool-org-uuid-111",
html_url: "https://github.com/Recoupable-Com/org-my-cool-org-uuid-111",
}),
});

Expand Down
29 changes: 13 additions & 16 deletions src/github/createGithubRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const GITHUB_ORG = "recoupable";
*/
export async function createGithubRepo(
accountName: string,
accountId: string
accountId: string,
): Promise<string | undefined> {
const token = process.env.GITHUB_TOKEN;

Expand All @@ -32,21 +32,18 @@ export async function createGithubRepo(
});

try {
const response = await fetch(
`https://api.github.com/orgs/${GITHUB_ORG}/repos`,
{
method: "POST",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${token}`,
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({
name: repoName,
private: true,
}),
}
);
const response = await fetch(`https://api.github.com/orgs/${GITHUB_ORG}/repos`, {
method: "POST",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${token}`,
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({
name: repoName,
private: true,
}),
});

if (!response.ok) {
// 422 means repo already exists — fetch existing URL
Expand Down
31 changes: 14 additions & 17 deletions src/github/createOrgGithubRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const GITHUB_ORG = "recoupable";
*/
export async function createOrgGithubRepo(
orgName: string,
orgId: string
orgId: string,
): Promise<string | undefined> {
const token = process.env.GITHUB_TOKEN;

Expand All @@ -35,22 +35,19 @@ export async function createOrgGithubRepo(
});

try {
const response = await fetch(
`https://api.github.com/orgs/${GITHUB_ORG}/repos`,
{
method: "POST",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${token}`,
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({
name: repoName,
private: true,
auto_init: true,
}),
}
);
const response = await fetch(`https://api.github.com/orgs/${GITHUB_ORG}/repos`, {
method: "POST",
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${token}`,
"X-GitHub-Api-Version": "2022-11-28",
},
body: JSON.stringify({
name: repoName,
private: true,
auto_init: true,
}),
});

if (!response.ok) {
// 422 means repo already exists — fetch existing URL
Expand Down
21 changes: 8 additions & 13 deletions src/github/getExistingGithubRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ const GITHUB_ORG = "recoupable";
* @param repoName - The full repository name (e.g. "account-name-uuid")
* @returns The repository HTML URL, or undefined if not found or on error
*/
export async function getExistingGithubRepo(
repoName: string
): Promise<string | undefined> {
export async function getExistingGithubRepo(repoName: string): Promise<string | undefined> {
const token = process.env.GITHUB_TOKEN;

if (!token) {
Expand All @@ -24,16 +22,13 @@ export async function getExistingGithubRepo(
});

try {
const response = await fetch(
`https://api.github.com/repos/${GITHUB_ORG}/${repoName}`,
{
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${token}`,
"X-GitHub-Api-Version": "2022-11-28",
},
}
);
const response = await fetch(`https://api.github.com/repos/${GITHUB_ORG}/${repoName}`, {
headers: {
Accept: "application/vnd.github+json",
Authorization: `Bearer ${token}`,
"X-GitHub-Api-Version": "2022-11-28",
},
});

if (!response.ok) {
logger.error("Failed to fetch existing GitHub repo", {
Expand Down
12 changes: 5 additions & 7 deletions src/polling/pollScraperResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ export type PollResult = ScrapeRun & {
/**
* Polls each scraper run in parallel until all are completed (SUCCEEDED or FAILED).
* Returns an array of results for each run.
*
* @param runs
*/
export async function pollScraperResults(
runs: ScrapeRun[]
): Promise<PollResult[]> {
export async function pollScraperResults(runs: ScrapeRun[]): Promise<PollResult[]> {
const results: PollResult[] = [];
const pendingRuns = new Map<string, ScrapeRun>(
runs.map((run) => [run.runId, run])
);
const pendingRuns = new Map<string, ScrapeRun>(runs.map(run => [run.runId, run]));

while (pendingRuns.size > 0) {
// Poll all pending runs in parallel
const pollPromises = Array.from(pendingRuns.values()).map(async (run) => {
const pollPromises = Array.from(pendingRuns.values()).map(async run => {
const result = await getScraperResults(run.runId);

if (!result) {
Expand Down
Loading
Loading