-
Notifications
You must be signed in to change notification settings - Fork 10
feat: migrate chat creation to recoup-api #1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
00175ec
74bf97c
6f8afe7
e22ac12
120f283
61cdbb0
ce8e8df
cc20ef4
f93792e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,29 @@ import { updateAgentTemplate } from "@/lib/supabase/agent_templates/updateAgentT | |
| import { deleteAgentTemplate } from "@/lib/supabase/agent_templates/deleteAgentTemplate"; | ||
| import { verifyAgentTemplateOwner } from "@/lib/supabase/agent_templates/verifyAgentTemplateOwner"; | ||
| import { getSharedEmailsForTemplates } from "@/lib/supabase/agent_templates/getSharedEmailsForTemplates"; | ||
| import { NEW_API_BASE_URL } from "@/lib/consts"; | ||
|
|
||
| export const runtime = "edge"; | ||
|
|
||
| const SUNSET_DAYS = 90; | ||
|
|
||
| function getDeprecationHeaders(): Record<string, string> { | ||
| const sunsetDate = new Date(); | ||
| sunsetDate.setDate(sunsetDate.getDate() + SUNSET_DAYS); | ||
|
|
||
| return { | ||
| Deprecation: "true", | ||
| Sunset: sunsetDate.toUTCString(), | ||
| Link: `<${NEW_API_BASE_URL}/api/agent-templates>; rel="deprecation"`, | ||
| }; | ||
|
Comment on lines
+13
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sunset date is recalculated per request (rolling window).
🧭 Suggested fix (use a fixed sunset date)-const SUNSET_DAYS = 90;
+const SUNSET_DATE = new Date("2026-04-16T00:00:00Z"); // set to planned sunset date
function getDeprecationHeaders(): Record<string, string> {
- const sunsetDate = new Date();
- sunsetDate.setDate(sunsetDate.getDate() + SUNSET_DAYS);
-
return {
Deprecation: "true",
- Sunset: sunsetDate.toUTCString(),
+ Sunset: SUNSET_DATE.toUTCString(),
Link: `<${NEW_API_BASE_URL}/api/agent-templates>; rel="deprecation"`,
};
}🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| /** | ||
| * @deprecated This endpoint is deprecated. Use recoup-api directly at recoup-api.vercel.app/api/agent-templates | ||
| */ | ||
| export async function GET(request: Request) { | ||
| const deprecationHeaders = getDeprecationHeaders(); | ||
|
|
||
| try { | ||
| const { searchParams } = new URL(request.url); | ||
| const userId = searchParams.get("userId"); | ||
|
|
@@ -32,10 +51,10 @@ export async function GET(request: Request) { | |
| shared_emails: template.is_private ? (sharedEmails[template.id] || []) : [] | ||
| })); | ||
|
|
||
| return NextResponse.json(templatesWithEmails); | ||
| return NextResponse.json(templatesWithEmails, { headers: deprecationHeaders }); | ||
| } catch (error) { | ||
| console.error('Error fetching agent templates:', error); | ||
| return NextResponse.json({ error: 'Failed to fetch templates' }, { status: 500 }); | ||
| return NextResponse.json({ error: 'Failed to fetch templates' }, { status: 500, headers: deprecationHeaders }); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,44 @@ | ||
| import { NextRequest, NextResponse } from "next/server"; | ||
| import { getArtistAgents } from "@/lib/supabase/getArtistAgents"; | ||
| import { NEW_API_BASE_URL } from "@/lib/consts"; | ||
|
|
||
| const SUNSET_DAYS = 90; | ||
|
|
||
| function getDeprecationHeaders(): Record<string, string> { | ||
| const sunsetDate = new Date(); | ||
| sunsetDate.setDate(sunsetDate.getDate() + SUNSET_DAYS); | ||
|
|
||
| return { | ||
| Deprecation: "true", | ||
| Sunset: sunsetDate.toUTCString(), | ||
| Link: `<${NEW_API_BASE_URL}/api/artist-agents>; rel="deprecation"`, | ||
| }; | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated This endpoint is deprecated. Use recoup-api directly at recoup-api.vercel.app/api/artist-agents | ||
| */ | ||
| export async function GET(request: NextRequest) { | ||
| const deprecationHeaders = getDeprecationHeaders(); | ||
|
|
||
| const { searchParams } = new URL(request.url); | ||
| const socialIds = searchParams.getAll("socialId"); | ||
|
|
||
| if (!socialIds.length) { | ||
| return NextResponse.json( | ||
| { error: "At least one Social ID is required" }, | ||
| { status: 400 }, | ||
| { status: 400, headers: deprecationHeaders }, | ||
| ); | ||
| } | ||
|
|
||
| try { | ||
| const agents = await getArtistAgents(socialIds); | ||
| return NextResponse.json(agents); | ||
| return NextResponse.json(agents, { headers: deprecationHeaders }); | ||
| } catch (error) { | ||
| console.error("Error fetching segments:", error); | ||
| return NextResponse.json( | ||
| { error: "Failed to fetch segments" }, | ||
| { status: 500 }, | ||
| { status: 500, headers: deprecationHeaders }, | ||
|
Comment on lines
+5
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sunset date is recalculated per request (rolling window). Same issue here: computing 🤖 Prompt for AI Agents |
||
| ); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,37 @@ | ||
| import { getAvailableModels } from "@/lib/ai/getAvailableModels"; | ||
| import { NEW_API_BASE_URL } from "@/lib/consts"; | ||
|
|
||
| const SUNSET_DAYS = 90; | ||
|
|
||
| function getDeprecationHeaders(): Record<string, string> { | ||
| const sunsetDate = new Date(); | ||
| sunsetDate.setDate(sunsetDate.getDate() + SUNSET_DAYS); | ||
|
|
||
| return { | ||
| Deprecation: "true", | ||
| Sunset: sunsetDate.toUTCString(), | ||
| Link: `<${NEW_API_BASE_URL}/api/ai/models>; rel="deprecation"`, | ||
| }; | ||
| } | ||
|
Comment on lines
+4
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sunset date is sliding here too—should be fixed. 💡 Proposed fix (example)-const SUNSET_DAYS = 90;
+const SUNSET_DAYS = 90;
+const DEPRECATION_DATE = new Date("2026-01-16T00:00:00Z"); // set to actual deprecation start
+const SUNSET_DATE = new Date(DEPRECATION_DATE);
+SUNSET_DATE.setDate(SUNSET_DATE.getDate() + SUNSET_DAYS);
function getDeprecationHeaders(): Record<string, string> {
- const sunsetDate = new Date();
- sunsetDate.setDate(sunsetDate.getDate() + SUNSET_DAYS);
-
return {
- Deprecation: "true",
- Sunset: sunsetDate.toUTCString(),
+ Deprecation: DEPRECATION_DATE.toUTCString(),
+ Sunset: SUNSET_DATE.toUTCString(),
Link: `<${NEW_API_BASE_URL}/api/ai/models>; rel="deprecation"`,
};
}🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * GET /api/ai/models | ||
| * | ||
| * @deprecated This endpoint is deprecated. Use recoup-api directly at recoup-api.vercel.app/api/ai/models | ||
| * | ||
| * Server-side endpoint that proxies `getAvailableModels()` so that the | ||
| * client can fetch model metadata without requiring server-side imports | ||
| * of `@ai-sdk/gateway`. | ||
| */ | ||
| export async function GET() { | ||
| const deprecationHeaders = getDeprecationHeaders(); | ||
|
|
||
| try { | ||
| const models = await getAvailableModels(); | ||
| return Response.json({ models }); | ||
| return Response.json({ models }, { headers: deprecationHeaders }); | ||
| } catch (error) { | ||
| console.error("/api/ai/models error", error); | ||
| const message = error instanceof Error ? error.message : "failed"; | ||
| return Response.json({ message }, { status: 500 }); | ||
| return Response.json({ message }, { status: 500, headers: deprecationHeaders }); | ||
| } | ||
| } | ||
|
|
||
|
|
||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sunset date should be fixed, not recomputed per request.
As written, every request pushes the Sunset date out by 90 days, so the window never truly closes and clients get inconsistent timelines. Use a fixed date (env or constant) computed once.
💡 Proposed fix (example)
🤖 Prompt for AI Agents