Skip to content

Commit 9899ec8

Browse files
committed
Adding memory + voice + unichat + proactivity changes to development branch (merging feature/memory into development)
2 parents 4b361db + 642ebcc commit 9899ec8

132 files changed

Lines changed: 7300 additions & 2005 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,6 @@ settings.local.json
265265
settings.json
266266
src/server/celerybeat-schedule-shm
267267
src/server/celerybeat-schedule-wal
268+
waha.sqlite3
269+
waha.sqlite3-shm
270+
waha.sqlite3-wal

src/client/app/api/chat/[chatId]/route.js

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

src/client/app/api/chat/history/route.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ const appServerUrl =
88
: process.env.NEXT_PUBLIC_APP_SERVER_URL
99

1010
export const GET = withAuth(async function GET(request, { authHeader }) {
11+
const { searchParams } = new URL(request.url)
12+
const limit = searchParams.get("limit")
13+
const before_timestamp = searchParams.get("before_timestamp")
14+
15+
const backendUrl = new URL(`${appServerUrl}/chat/history`)
16+
if (limit) backendUrl.searchParams.append("limit", limit)
17+
if (before_timestamp)
18+
backendUrl.searchParams.append("before_timestamp", before_timestamp)
19+
1120
try {
12-
const response = await fetch(`${appServerUrl}/chat/history`, {
21+
const response = await fetch(backendUrl.toString(), {
1322
method: "GET",
1423
headers: { "Content-Type": "application/json", ...authHeader }
1524
})

src/client/app/api/chat/message/route.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const appServerUrl =
88

99
export const POST = withAuth(async function POST(request, { authHeader }) {
1010
try {
11-
const { messages, chatId } = await request.json()
11+
const { messages } = await request.json()
1212

1313
// Fetch user pricing/credits to pass to the backend
1414
const pricingResponse = await fetch(
@@ -28,7 +28,6 @@ export const POST = withAuth(async function POST(request, { authHeader }) {
2828
body: JSON.stringify({
2929
// Pass `messages` array instead of `input`
3030
messages,
31-
chatId,
3231
pricing, // Note: pricing and credits are still sent for backend logic
3332
credits
3433
}),
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// src/client/app/api/chat/history/[chatId]/route.js
21
import { NextResponse } from "next/server"
32
import { withAuth } from "@lib/api-utils"
43

@@ -7,27 +6,22 @@ const appServerUrl =
76
? process.env.INTERNAL_APP_SERVER_URL
87
: process.env.NEXT_PUBLIC_APP_SERVER_URL
98

10-
export const GET = withAuth(async function GET(
11-
request,
12-
{ params, authHeader }
13-
) {
14-
const { chatId } = params
15-
if (!chatId) {
16-
return NextResponse.json(
17-
{ error: "Chat ID parameter is required" },
18-
{ status: 400 }
19-
)
20-
}
9+
export const GET = withAuth(async function GET(request, { authHeader }) {
10+
const backendUrl = new URL(`${appServerUrl}/api/memories/`)
2111

2212
try {
23-
const response = await fetch(`${appServerUrl}/chat/history/${chatId}`, {
13+
const response = await fetch(backendUrl.toString(), {
14+
method: "GET",
2415
headers: { "Content-Type": "application/json", ...authHeader }
2516
})
17+
2618
const data = await response.json()
27-
if (!response.ok)
28-
throw new Error(data.detail || "Failed to fetch chat messages")
19+
if (!response.ok) {
20+
throw new Error(data.detail || "Failed to fetch memories")
21+
}
2922
return NextResponse.json(data)
3023
} catch (error) {
24+
console.error("API Error in /api/memories:", error)
3125
return NextResponse.json({ error: error.message }, { status: 500 })
3226
}
3327
})
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// src/client/app/api/proactivity/action/route.js
2+
import { NextResponse } from "next/server"
3+
import { withAuth } from "@lib/api-utils"
4+
5+
const appServerUrl =
6+
process.env.NEXT_PUBLIC_ENVIRONMENT === "selfhost"
7+
? process.env.INTERNAL_APP_SERVER_URL
8+
: process.env.NEXT_PUBLIC_APP_SERVER_URL
9+
10+
export const POST = withAuth(async function POST(request, { authHeader }) {
11+
try {
12+
const { notification_id, user_action } = await request.json()
13+
if (!notification_id || !user_action) {
14+
return NextResponse.json(
15+
{ error: "Notification ID and user action are required" },
16+
{ status: 400 }
17+
)
18+
}
19+
20+
const response = await fetch(`${appServerUrl}/api/proactivity/action`, {
21+
method: "POST",
22+
headers: { "Content-Type": "application/json", ...authHeader },
23+
body: JSON.stringify({ notification_id, user_action })
24+
})
25+
26+
const data = await response.json()
27+
if (!response.ok) {
28+
throw new Error(
29+
data.detail || "Failed to process suggestion action"
30+
)
31+
}
32+
return NextResponse.json(data)
33+
} catch (error) {
34+
console.error("API Error in /proactivity/action:", error)
35+
return NextResponse.json({ error: error.message }, { status: 500 })
36+
}
37+
})

src/client/app/api/settings/mcp/route.js renamed to src/client/app/api/settings/memory/route.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,22 @@ import { withAuth } from "@lib/api-utils"
33

44
const appServerUrl =
55
process.env.NEXT_PUBLIC_ENVIRONMENT === "selfhost"
6-
? process.env.INTERNAL_APP_SERVER_URL
6+
? "http://localhost:8000"
77
: process.env.NEXT_PUBLIC_APP_SERVER_URL
88

9-
// GET handler to fetch the current Supermemory MCP URL
9+
// GET handler to fetch the current Memory MCP URL
1010
export const GET = withAuth(async function GET(request, { authHeader }) {
1111
try {
12-
const response = await fetch(
13-
`${appServerUrl}/api/settings/supermemory`,
14-
{
15-
// Ensure GET is used for fetching data
16-
method: "GET",
17-
headers: { "Content-Type": "application/json", ...authHeader }
18-
}
19-
)
12+
const response = await fetch(`${appServerUrl}/api/settings/memory`, {
13+
// Ensure GET is used for fetching data
14+
method: "GET",
15+
headers: { "Content-Type": "application/json", ...authHeader }
16+
})
2017

2118
const data = await response.json()
2219
if (!response.ok) {
2320
throw new Error(
24-
data.detail ||
25-
data.error ||
26-
"Failed to fetch Supermemory settings"
21+
data.detail || data.error || "Failed to fetch Memory settings"
2722
)
2823
}
2924
return NextResponse.json(data)
@@ -33,13 +28,13 @@ export const GET = withAuth(async function GET(request, { authHeader }) {
3328
}
3429
})
3530

36-
// POST handler to save the Supermemory MCP URL
31+
// POST handler to save the Memory MCP URL
3732
export const POST = withAuth(async function POST(request, { authHeader }) {
3833
try {
3934
const body = await request.json() // { mcp_url: "..." }
4035
const backendResponse = await fetch(
4136
// Renamed to avoid conflict with API response
42-
`${appServerUrl}/api/settings/supermemory`,
37+
`${appServerUrl}/api/settings/memory`,
4338
{
4439
method: "POST",
4540
headers: { "Content-Type": "application/json", ...authHeader },
@@ -50,9 +45,7 @@ export const POST = withAuth(async function POST(request, { authHeader }) {
5045
const data = await backendResponse.json()
5146
if (!backendResponse.ok) {
5247
throw new Error(
53-
data.detail ||
54-
data.error ||
55-
"Failed to save Supermemory settings"
48+
data.detail || data.error || "Failed to save Memory settings"
5649
)
5750
}
5851
return NextResponse.json(data) // Return the backend's response directly

0 commit comments

Comments
 (0)