Skip to content

Commit 9aa5a93

Browse files
committed
Merge branch 'staging'
2 parents bb4e7b8 + 6e83f81 commit 9aa5a93

File tree

280 files changed

+19990
-11184
lines changed

Some content is hidden

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

280 files changed

+19990
-11184
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,5 @@ waha.sqlite3
269269
waha.sqlite3-shm
270270
waha.sqlite3-wal
271271
sentient_files/
272-
linkedin_cookies.json
272+
linkedin_cookies.json
273+
audio_debug_logs/

src/.env.selfhost.template

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
11
# Root environment variables for docker-compose.selfhost.yaml
22
# Copy this file to .env in the same directory (src/.env) and fill in the values.
33

4-
# --- Client (Frontend) Variables ---
5-
# The public-facing URL of your client application.
6-
# [BUILD-TIME & RUNTIME] Crucial for OAuth redirects and server-side requests.
4+
# --- Public URLs ---
5+
# These are the URLs that users will use in their browser to access the application.
6+
# For a standard local setup, these defaults are correct.
7+
# If you expose this on the internet, change localhost to your domain.
78
APP_BASE_URL=http://localhost:3000
89
NEXT_PUBLIC_APP_BASE_URL=http://localhost:3000
9-
10-
# The URL where the backend server will be accessible from the user's browser
11-
# [BUILD-TIME & RUNTIME] Used by the client to make API calls.
1210
NEXT_PUBLIC_APP_SERVER_URL=http://localhost:5000
1311

14-
# The internal URL for the backend server, used for server-to-server communication inside Docker.
15-
# [BUILD-TIME & RUNTIME] Used by the client's Next.js server to talk to the backend server.
12+
# --- Internal Docker URLs ---
13+
# These are for container-to-container communication and should not be changed.
1614
INTERNAL_APP_SERVER_URL=http://server:80
17-
18-
# The internal URL for the client container, used for server-side self-requests
19-
# [BUILD-TIME & RUNTIME] Used for OAuth callbacks within the Docker network.
2015
INTERNAL_CLIENT_URL=http://client:3000
2116

22-
# The mode to run the application in
23-
# [BUILD-TIME & RUNTIME] Switches between Auth0 and self-host auth mode.
17+
# --- Authentication ---
18+
# Sets the application to run in self-hosted mode. Do not change.
2419
NEXT_PUBLIC_ENVIRONMENT=selfhost
25-
26-
# [BUILD-TIME & RUNTIME] A long, random, secret string. It must match SELF_HOST_AUTH_SECRET in server/.env.selfhost.template
20+
# A long, random, secret string that acts as your master password for the app.
21+
# It must be the same in all three .env files where it appears.
22+
# Generate a strong secret here (e.g., using a password manager or `openssl rand -hex 32`).
2723
SELF_HOST_AUTH_TOKEN=<generate_a_strong_secret_here>
2824

2925
# --- Server (Backend) Build-Time Variables ---
3026
# [BUILD-TIME] Set OPENAI_API_KEY to "ollama" to install Ollama in the server container.
31-
# Otherwise, provide your key for a remote service.
27+
# This allows you to run a local LLM without needing an external API key for chat.
28+
# To use a remote service (like OpenAI or another provider via LiteLLM), provide your key here.
3229
OPENAI_API_KEY=ollama
33-
# [BUILD-TIME] The model to pull if Ollama is being installed. This should match the model in the server's Modelfile.
30+
# [BUILD-TIME] The model to pull if Ollama is being installed. This should match the model
31+
# in the server's Modelfile and the OPENAI_MODEL_NAME in server/.env.selfhost.
3432
OPENAI_MODEL_NAME=qwen3:4b
3533

36-
# --- Gemini API Key (for Server - Memory MCP & optional LiteLLM) ---
37-
# [RUNTIME] Required for memory embeddings and can be used for chat via LiteLLM.
34+
# --- Gemini API Key (for Server - Memory & optional LiteLLM) ---
35+
# [RUNTIME] Required for memory embeddings and can be used for chat via the LiteLLM proxy.
36+
# Get this from Google AI Studio.
3837
GEMINI_API_KEY=<your-gemini-api-key>
3938

4039
# --- MongoDB Credentials (for Server) ---
41-
MONGO_USER=test
40+
MONGO_USER=sentient
4241
MONGO_PASS=<generate_a_strong_password_for_mongo>
4342

4443
# --- PostgreSQL Credentials (for Server - Memory MCP) ---
@@ -51,6 +50,7 @@ REDIS_PASSWORD=<generate_a_strong_password_for_redis>
5150

5251
# --- WhatsApp (WAHA) Credentials (for WAHA Service) ---
5352
# These are used by the WAHA container for WhatsApp integration.
53+
# You can leave these as default for a local setup.
5454
WAHA_API_KEY=admin
5555
WAHA_DASHBOARD_USERNAME=admin
5656
WAHA_DASHBOARD_PASSWORD=admin

src/client/.env.selfhost.template

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,28 @@ NEXT_PUBLIC_APP_SERVER_URL=http://localhost:5000
99

1010
# The internal URL for the backend server, used for server-to-server communication inside Docker.
1111
# This is passed at build time and used by the Next.js server part of the client.
12-
INTERNAL_APP_SERVER_URL=http://server:80 # Must match the root .env
12+
# It MUST match INTERNAL_APP_SERVER_URL in the root src/.env file.
13+
INTERNAL_APP_SERVER_URL=http://server:80
1314

1415
# The public-facing base URL of the client application.
16+
# These MUST match the corresponding variables in the root src/.env file.
1517
APP_BASE_URL=http://localhost:3000
1618
NEXT_PUBLIC_APP_BASE_URL=http://localhost:3000
1719

1820
# The static token for authenticating with the backend.
19-
# This MUST match the `SELF_HOST_AUTH_SECRET` in the server's .env.selfhost file.
21+
# This MUST match the `SELF_HOST_AUTH_TOKEN` in the root src/.env file.
2022
SELF_HOST_AUTH_TOKEN=<use_the_same_strong_secret_as_in_src/.env>
2123

2224
# --- Database (for Server Actions) ---
2325
# This is the internal URI for the MongoDB service within Docker.
2426
# It MUST include the credentials defined in the root .env file.
25-
MONGO_URI=mongodb://test:<pass_from_src/.env>@mongodb:27017/
26-
MONGO_DB_NAME=development
27+
MONGO_URI=mongodb://sentient:<pass_from_src/.env>@mongodb:27017/
28+
MONGO_DB_NAME=sentient_selfhost_db
2729

2830
# Auth0 variables are not used in selfhost mode, but are kept here
2931
# to avoid breaking any code that might reference them before a check.
3032
# The build process requires them to be present in some form.
3133
AUTH0_SECRET=""
32-
APP_BASE_URL="http://localhost:3000"
3334
AUTH0_ISSUER_BASE_URL=""
3435
AUTH0_CLIENT_ID=""
3536
AUTH0_CLIENT_SECRET=""

src/client/app/actions.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export async function subscribeUser(subscription) {
6868
{ upsert: true }
6969
)
7070

71-
console.log(`[Actions] Subscription saved for user: ${userId}`)
7271
return { success: true }
7372
} catch (error) {
7473
console.error("[Actions] Error saving subscription:", error)
@@ -95,9 +94,6 @@ export async function unsubscribeUser(endpoint) {
9594
{ $pull: { "userData.pwa_subscriptions": { endpoint: endpoint } } }
9695
)
9796

98-
console.log(
99-
`[Actions] Subscription with endpoint ${endpoint} removed for user: ${userId}`
100-
)
10197
return { success: true }
10298
} catch (error) {
10399
console.error("[Actions] Error removing subscription:", error)
@@ -144,9 +140,6 @@ export async function sendNotificationToCurrentUser(payload) {
144140
!Array.isArray(subscriptions) ||
145141
subscriptions.length === 0
146142
) {
147-
console.log(
148-
`[Actions] No push subscription found for user ${userId}.`
149-
)
150143
return { success: false, error: "No subscription found for user." }
151144
}
152145

@@ -156,9 +149,6 @@ export async function sendNotificationToCurrentUser(payload) {
156149
.sendNotification(subscription, JSON.stringify(payload))
157150
.then(() => {
158151
successCount++
159-
console.log(
160-
`[Actions] Push notification sent successfully to endpoint for user ${userId}.`
161-
)
162152
})
163153
.catch(async (error) => {
164154
console.error(

src/client/app/api/auth/refresh-session/route.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import { auth0 } from "@lib/auth0"
44
// This route is only for Auth0 environments
55
export async function GET(request) {
66
if (process.env.NEXT_PUBLIC_ENVIRONMENT === "selfhost") {
7-
return NextResponse.json({
8-
status: "ok",
9-
message: "Self-host mode, no refresh needed."
10-
})
7+
return NextResponse.json(
8+
{
9+
status: "ok",
10+
message: "Self-host mode, no refresh needed."
11+
},
12+
{
13+
headers: { "Cache-Control": "no-store, max-age=0" }
14+
}
15+
)
1116
}
1217

1318
const res = new NextResponse()
@@ -26,11 +31,13 @@ export async function GET(request) {
2631
refresh: true
2732
})
2833

34+
const newHeaders = new Headers(res.headers)
35+
newHeaders.set("Cache-Control", "no-store, max-age=0")
2936
// The new session cookie is now on the `res` object.
3037
// Return a success response with the new headers.
3138
return NextResponse.json(
3239
{ status: "ok" },
33-
{ status: 200, headers: res.headers }
40+
{ status: 200, headers: newHeaders }
3441
)
3542
} catch (error) {
3643
console.error("Error refreshing session in main app:", error.message)

src/client/app/api/auth/token/route.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ export async function GET() {
1515
{ status: 500 }
1616
)
1717
}
18-
return NextResponse.json({ accessToken: token })
18+
return NextResponse.json(
19+
{ accessToken: token },
20+
{
21+
headers: { "Cache-Control": "no-store, max-age=0" }
22+
}
23+
)
1924
}
2025
try {
2126
const tokenResult = await auth0.getAccessToken()
@@ -27,9 +32,23 @@ export async function GET() {
2732
{ status: 401 }
2833
)
2934
}
30-
return NextResponse.json({ accessToken: token })
35+
return NextResponse.json(
36+
{ accessToken: token },
37+
{
38+
headers: { "Cache-Control": "no-store, max-age=0" }
39+
}
40+
)
3141
} catch (error) {
3242
console.error("Error in /api/auth/token:", error)
43+
// If the error is specifically because of a missing session,
44+
// return a 401 Unauthorized status, which is more appropriate
45+
// and allows the client to handle it by redirecting to login.
46+
if (error.code === "missing_session") {
47+
return NextResponse.json(
48+
{ message: error.message },
49+
{ status: 401 }
50+
)
51+
}
3352
return NextResponse.json(
3453
{ message: "Internal Server Error", error: error.message },
3554
{ status: 500 }

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ const appServerUrl =
66
? process.env.INTERNAL_APP_SERVER_URL
77
: process.env.NEXT_PUBLIC_APP_SERVER_URL
88

9+
// Increase the body size limit for this specific route to handle large chat histories.
10+
// The default is 4MB, which can be exceeded if the context window includes large messages.
11+
export const config = {
12+
api: {
13+
bodyParser: {
14+
sizeLimit: "10mb" // Set to match the Nginx limit
15+
}
16+
}
17+
}
18+
919
export const POST = withAuth(async function POST(request, { authHeader }) {
1020
try {
1121
const { messages } = await request.json()

src/client/app/api/files/download/[...filename]/route.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export const GET = withAuth(async function GET(
5353
status: 200,
5454
headers: {
5555
"Content-Type": "application/octet-stream",
56-
"Content-Disposition": `attachment; filename="${filename}"`
56+
"Content-Disposition": `attachment; filename="${filename}"`,
57+
"Cache-Control": "no-store, max-age=0"
5758
}
5859
})
5960
} catch (error) {

src/client/app/api/files/list/route.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export const GET = withAuth(async function GET(request, { authHeader }) {
1717
if (!response.ok) {
1818
throw new Error(data.detail || "Failed to list files")
1919
}
20-
return NextResponse.json(data)
20+
return NextResponse.json(data, {
21+
headers: { "Cache-Control": "no-store, max-age=0" }
22+
})
2123
} catch (error) {
2224
console.error("API Error in /files/list:", error)
2325
return NextResponse.json({ error: error.message }, { status: 500 })

src/client/app/api/integrations/connected/route.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export const GET = withAuth(async function GET(request, { authHeader }) {
2020
if (!response.ok) {
2121
throw new Error(data.detail || "Failed to fetch integrations")
2222
}
23-
return NextResponse.json(data)
23+
return NextResponse.json(data, {
24+
headers: { "Cache-Control": "no-store, max-age=0" }
25+
})
2426
} catch (error) {
2527
console.error("API Error in /integrations/connected:", error)
2628
return NextResponse.json({ error: error.message }, { status: 500 })

0 commit comments

Comments
 (0)