wired in project isolation
This commit is contained in:
@@ -105,21 +105,16 @@ async function chat(externalId, userMessage, options = {}) {
|
||||
let projectSessionIds = null;
|
||||
if (session.project_id) {
|
||||
try {
|
||||
console.log('[orchestration] Resolving isolation for project:', session.project_id);
|
||||
const project = await memory.getProject(session.project_id);
|
||||
console.log('[orchestration] Project resolved:', project);
|
||||
if (project?.isolated === 1) {
|
||||
const projectSessions = await memory.getProjectSessions(
|
||||
session.project_id,
|
||||
);
|
||||
projectSessionIds = projectSessions.map((s) => s.id);
|
||||
console.log(
|
||||
`[orchestration] Isolated project ${session.project_id} — restricting search to ${projectSessionIds.length} sessions`,
|
||||
);
|
||||
const projectSessions = await memory.getProjectSessions(session.project_id);
|
||||
console.log('[orchestration] Project sessions:', projectSessions);
|
||||
projectSessionIds = projectSessions.map(s => s.id);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
"[orchestration] Failed to resolve isolation context:",
|
||||
err.message,
|
||||
);
|
||||
console.warn('[orchestration] Failed to resolve isolation context:', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,6 +167,10 @@ async function chat(externalId, userMessage, options = {}) {
|
||||
}
|
||||
|
||||
async function chatStream(externalId, userMessage, onChunk, options = {}) {
|
||||
|
||||
console.log('[orchestration] chatStream entry');
|
||||
try {
|
||||
|
||||
console.log("[orchestration] chatStream called:", {
|
||||
externalId,
|
||||
userMessage: userMessage.slice(0, 50),
|
||||
@@ -182,21 +181,16 @@ async function chatStream(externalId, userMessage, onChunk, options = {}) {
|
||||
let projectSessionIds = null;
|
||||
if (session.project_id) {
|
||||
try {
|
||||
console.log('[orchestration] Resolving isolation for project:', session.project_id);
|
||||
const project = await memory.getProject(session.project_id);
|
||||
console.log('[orchestration] Project resolved:', project);
|
||||
if (project?.isolated === 1) {
|
||||
const projectSessions = await memory.getProjectSessions(
|
||||
session.project_id,
|
||||
);
|
||||
projectSessionIds = projectSessions.map((s) => s.id);
|
||||
console.log(
|
||||
`[orchestration] Isolated project ${session.project_id} — restricting search to ${projectSessionIds.length} sessions`,
|
||||
);
|
||||
const projectSessions = await memory.getProjectSessions(session.project_id);
|
||||
console.log('[orchestration] Project sessions:', projectSessions);
|
||||
projectSessionIds = projectSessions.map(s => s.id);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(
|
||||
"[orchestration] Failed to resolve isolation context:",
|
||||
err.message,
|
||||
);
|
||||
console.warn('[orchestration] Failed to resolve isolation context:', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,5 +273,10 @@ async function chatStream(externalId, userMessage, onChunk, options = {}) {
|
||||
}
|
||||
|
||||
return { model, tokenCount };
|
||||
} catch (err) {
|
||||
console.error('[orchestration] chatStream fatal error:', err.message, err.stack);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { chat, chatStream };
|
||||
|
||||
Reference in New Issue
Block a user