mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 08:18:10 +01:00
feat(loki): "Ask Loki" joins the personal cross-surface session
When LOKI_PERSONAL_SESSION_KEY is set (George's box: agent:main:direct:george), the app's "Ask Loki" modal uses the SAME OpenClaw session as Telegram/WhatsApp — one continuous conversation across surfaces (shared running transcript, not just shared durable memory). Unset → per-user web thread (multi-tenant safe). The Loki page keeps its own per-conversation threads. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
908fca24e9
commit
f573cd89a9
1 file changed
+8
-5
@@ -14,10 +14,13 @@ export async function POST(req: NextRequest) {
|
||||
const dataOrResp = await readJsonBody(req, AskLokiBody);
|
||||
if (dataOrResp instanceof NextResponse) return dataOrResp;
|
||||
|
||||
// Stable per-user session for the global "Ask Loki" modal (own thread, same
|
||||
// agent + memory). Distinct from per-conversation Loki-page threads.
|
||||
const { status, body } = await askLoki(dataOrResp.message, {
|
||||
sessionKey: `agent:main:web:ask:${userId}`,
|
||||
});
|
||||
// "Ask Loki" = the user's PERSONAL Loki conversation. When LOKI_PERSONAL_SESSION_KEY
|
||||
// is set (single-tenant box: George's `agent:main:direct:george`), the modal joins
|
||||
// the SAME session as Telegram/WhatsApp → one continuous conversation across surfaces.
|
||||
// Unset (multi-tenant default) → a stable per-user web thread. The Loki *page* keeps
|
||||
// its own per-conversation threads regardless (same agent + memory).
|
||||
const personalSessionKey =
|
||||
process.env.LOKI_PERSONAL_SESSION_KEY?.trim() || `agent:main:web:ask:${userId}`;
|
||||
const { status, body } = await askLoki(dataOrResp.message, { sessionKey: personalSessionKey });
|
||||
return NextResponse.json(body, { status });
|
||||
}
|
||||
Reference in new issue
Block a user