fix(agent): isolate conversation workspaces
This commit is contained in:
@@ -12,6 +12,7 @@ export type SessionBinding = {
|
||||
clientSessionId: string;
|
||||
sessionId: string;
|
||||
startedAt: number;
|
||||
workspaceDirectory?: string;
|
||||
};
|
||||
|
||||
export type SessionContext = {
|
||||
@@ -52,20 +53,26 @@ export class ChatSessionBridge {
|
||||
await this.abortActiveRuntime(requestContext.clientSessionId, existingSessionId);
|
||||
|
||||
let sessionId = existingSessionId;
|
||||
let runtimeSession;
|
||||
let created = false;
|
||||
if (!sessionId) {
|
||||
const session = await this.runtime.createSession();
|
||||
sessionId = session.id;
|
||||
runtimeSession = await this.runtime.createSession(undefined, {
|
||||
conversationWorkspace: true,
|
||||
});
|
||||
sessionId = runtimeSession.id;
|
||||
requestContext = {
|
||||
...requestContext,
|
||||
clientSessionId: sessionId,
|
||||
};
|
||||
created = true;
|
||||
} else {
|
||||
runtimeSession = await this.runtime.getSession(sessionId);
|
||||
}
|
||||
const binding: SessionBinding = {
|
||||
clientSessionId: requestContext.clientSessionId,
|
||||
sessionId,
|
||||
startedAt: Date.now(),
|
||||
workspaceDirectory: runtimeSession.directory,
|
||||
};
|
||||
setRuntimeSessionContext({
|
||||
accessToken: requestContext.accessToken,
|
||||
@@ -79,6 +86,7 @@ export class ChatSessionBridge {
|
||||
sessionId,
|
||||
tokenExpiresAt: requestContext.tokenExpiresAt,
|
||||
traceId: requestContext.traceId,
|
||||
workspaceDirectory: runtimeSession.directory,
|
||||
});
|
||||
|
||||
return { binding, requestContext, created };
|
||||
|
||||
Reference in New Issue
Block a user