Skip to content

Commit 00ae888

Browse files
committed
merging new tools from feature/mcp-tools into development
2 parents 654b700 + e27fa5d commit 00ae888

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+2852
-262
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { NextResponse } from "next/server"
2+
import { withAuth } from "@lib/api-utils"
3+
4+
const appServerUrl =
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "selfhost"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
8+
9+
// Handler for connecting/disconnecting the WhatsApp MCP number
10+
export const POST = withAuth(async function POST(request, { authHeader }) {
11+
try {
12+
const body = await request.json() // { whatsapp_mcp_number: "..." }
13+
const response = await fetch(
14+
`${appServerUrl}/api/settings/whatsapp-mcp`,
15+
{
16+
method: "POST",
17+
headers: { "Content-Type": "application/json", ...authHeader },
18+
body: JSON.stringify(body)
19+
}
20+
)
21+
22+
const data = await response.json()
23+
if (!response.ok) {
24+
throw new Error(
25+
data.detail || "Failed to update WhatsApp MCP number"
26+
)
27+
}
28+
return NextResponse.json(data)
29+
} catch (error) {
30+
console.error("API Error in /api/settings/whatsapp-mcp (POST):", error)
31+
return NextResponse.json({ error: error.message }, { status: 500 })
32+
}
33+
})
34+
35+
// Handler for getting the current WhatsApp MCP number
36+
export const GET = withAuth(async function GET(request, { authHeader }) {
37+
try {
38+
const response = await fetch(
39+
`${appServerUrl}/api/settings/whatsapp-mcp`,
40+
{
41+
method: "GET",
42+
headers: { "Content-Type": "application/json", ...authHeader }
43+
}
44+
)
45+
const data = await response.json()
46+
if (!response.ok) {
47+
throw new Error(
48+
data.detail || "Failed to fetch WhatsApp MCP settings"
49+
)
50+
}
51+
return NextResponse.json(data)
52+
} catch (error) {
53+
console.error("API Error in /api/settings/whatsapp-mcp (GET):", error)
54+
return NextResponse.json({ error: error.message }, { status: 500 })
55+
}
56+
})
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { NextResponse } from "next/server"
2+
import { withAuth } from "@lib/api-utils"
3+
4+
const appServerUrl =
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "selfhost"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
8+
9+
// Handler for updating or setting the WhatsApp number for notifications
10+
export const POST = withAuth(async function POST(request, { authHeader }) {
11+
try {
12+
const body = await request.json() // { whatsapp_notifications_number: "..." or "" }
13+
// When a number is saved, notifications are implicitly enabled.
14+
// When it's removed, they are disabled.
15+
const isEnabling =
16+
body.whatsapp_notifications_number &&
17+
body.whatsapp_notifications_number.trim() !== ""
18+
19+
const response = await fetch(
20+
`${appServerUrl}/api/settings/whatsapp-notifications`,
21+
{
22+
method: "POST",
23+
headers: { "Content-Type": "application/json", ...authHeader },
24+
body: JSON.stringify({ ...body, enabled: isEnabling })
25+
}
26+
)
27+
28+
const data = await response.json()
29+
if (!response.ok) {
30+
throw new Error(
31+
data.detail || "Failed to update WhatsApp notification number"
32+
)
33+
}
34+
return NextResponse.json(data)
35+
} catch (error) {
36+
console.error(
37+
"API Error in /api/settings/whatsapp-notifications (POST):",
38+
error
39+
)
40+
return NextResponse.json({ error: error.message }, { status: 500 })
41+
}
42+
})
43+
44+
// Handler for getting the current WhatsApp notification settings
45+
export const GET = withAuth(async function GET(request, { authHeader }) {
46+
try {
47+
const response = await fetch(
48+
`${appServerUrl}/api/settings/whatsapp-notifications`,
49+
{
50+
method: "GET",
51+
headers: { "Content-Type": "application/json", ...authHeader }
52+
}
53+
)
54+
const data = await response.json()
55+
if (!response.ok) {
56+
throw new Error(
57+
data.detail || "Failed to fetch WhatsApp notification settings"
58+
)
59+
}
60+
return NextResponse.json(data)
61+
} catch (error) {
62+
console.error(
63+
"API Error in /api/settings/whatsapp-notifications (GET):",
64+
error
65+
)
66+
return NextResponse.json({ error: error.message }, { status: 500 })
67+
}
68+
})
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { NextResponse } from "next/server"
2+
import { withAuth } from "@lib/api-utils"
3+
4+
const appServerUrl =
5+
process.env.NEXT_PUBLIC_ENVIRONMENT === "selfhost"
6+
? process.env.INTERNAL_APP_SERVER_URL
7+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
8+
9+
// Handler for toggling WhatsApp notifications on/off
10+
export const POST = withAuth(async function POST(request, { authHeader }) {
11+
try {
12+
const body = await request.json() // { enabled: true/false }
13+
const response = await fetch(
14+
`${appServerUrl}/api/settings/whatsapp-notifications/toggle`,
15+
{
16+
method: "POST",
17+
headers: { "Content-Type": "application/json", ...authHeader },
18+
body: JSON.stringify(body)
19+
}
20+
)
21+
22+
const data = await response.json()
23+
if (!response.ok) {
24+
throw new Error(
25+
data.detail || "Failed to toggle WhatsApp notifications"
26+
)
27+
}
28+
return NextResponse.json(data)
29+
} catch (error) {
30+
console.error(
31+
"API Error in /api/settings/whatsapp-notifications/toggle (POST):",
32+
error
33+
)
34+
return NextResponse.json({ error: error.message }, { status: 500 })
35+
}
36+
})

src/client/app/api/settings/whatsapp/route.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

src/client/app/chat/[[...chatId]]/page.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,8 @@ export default function ChatPage({ params }) {
695695
<div
696696
className={cn(
697697
"rounded-2xl shadow-2xl shadow-black/40",
698-
!isFocused && "p-0.5 bg-gradient-to-tr from-blue-500 to-cyan-500"
698+
!isFocused &&
699+
"p-0.5 bg-gradient-to-tr from-blue-500 to-cyan-500"
699700
)}
700701
>
701702
<div className="relative bg-neutral-900 rounded-[15px] flex items-end">
@@ -819,7 +820,8 @@ export default function ChatPage({ params }) {
819820
<div
820821
className={cn(
821822
"rounded-2xl shadow-2xl shadow-black/40",
822-
!isFocused && "p-0.5 bg-gradient-to-tr from-blue-500 to-cyan-500"
823+
!isFocused &&
824+
"p-0.5 bg-gradient-to-tr from-blue-500 to-cyan-500"
823825
)}
824826
>
825827
<div className="relative bg-neutral-900 rounded-[15px] flex items-end">
@@ -851,7 +853,9 @@ export default function ChatPage({ params }) {
851853
data-tooltip-id="home-tooltip"
852854
data-tooltip-content="Stop Generation"
853855
>
854-
<IconPlayerStopFilled size={18} />
856+
<IconPlayerStopFilled
857+
size={18}
858+
/>
855859
</button>
856860
) : (
857861
<button

0 commit comments

Comments
 (0)