fix(agent): isolate conversation workspaces
This commit is contained in:
+22
-10
@@ -71,6 +71,7 @@ type StreamPromptOptions = {
|
||||
traceId?: string;
|
||||
projectId?: string;
|
||||
signal?: AbortSignal;
|
||||
workspaceRoot?: string;
|
||||
write: (event: string, data: Record<string, unknown>) => void;
|
||||
};
|
||||
|
||||
@@ -157,6 +158,7 @@ export const streamPromptResponse = async ({
|
||||
traceId,
|
||||
projectId,
|
||||
signal,
|
||||
workspaceRoot,
|
||||
write,
|
||||
}: StreamPromptOptions): Promise<{
|
||||
aborted: boolean;
|
||||
@@ -397,7 +399,7 @@ export const streamPromptResponse = async ({
|
||||
{
|
||||
metadata: event.properties.metadata,
|
||||
patterns: event.properties.patterns,
|
||||
workspaceRoot: process.cwd(),
|
||||
workspaceRoot: workspaceRoot ?? process.cwd(),
|
||||
},
|
||||
);
|
||||
logDevelopmentDebug("permission request received", {
|
||||
@@ -410,20 +412,25 @@ export const streamPromptResponse = async ({
|
||||
emitProgress({
|
||||
id: `permission-${event.properties.id}`,
|
||||
phase: "permission",
|
||||
status: permissionApproval.autoApprove ? "completed" : "running",
|
||||
status: permissionApproval.autoReject
|
||||
? "error"
|
||||
: permissionApproval.autoApprove
|
||||
? "completed"
|
||||
: "running",
|
||||
title: permissionApproval.title,
|
||||
detail: permissionApproval.detail ?? buildPermissionDetail(event),
|
||||
});
|
||||
if (permissionApproval.autoApprove) {
|
||||
if (permissionApproval.autoApprove || permissionApproval.autoReject) {
|
||||
const reply = permissionApproval.autoReject ? "reject" : "once";
|
||||
await runtime.replyPermission({
|
||||
requestId: event.properties.id,
|
||||
sessionId,
|
||||
reply: "once",
|
||||
reply,
|
||||
});
|
||||
write("permission_response", {
|
||||
session_id: clientSessionId,
|
||||
request_id: event.properties.id,
|
||||
reply: "once" satisfies PermissionReply,
|
||||
reply: reply satisfies PermissionReply,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@@ -448,7 +455,7 @@ export const streamPromptResponse = async ({
|
||||
{
|
||||
metadata: event.properties.metadata,
|
||||
patterns: event.properties.resources,
|
||||
workspaceRoot: process.cwd(),
|
||||
workspaceRoot: workspaceRoot ?? process.cwd(),
|
||||
},
|
||||
);
|
||||
logDevelopmentDebug("permission v2 request received", {
|
||||
@@ -461,20 +468,25 @@ export const streamPromptResponse = async ({
|
||||
emitProgress({
|
||||
id: `permission-${event.properties.id}`,
|
||||
phase: "permission",
|
||||
status: permissionApproval.autoApprove ? "completed" : "running",
|
||||
status: permissionApproval.autoReject
|
||||
? "error"
|
||||
: permissionApproval.autoApprove
|
||||
? "completed"
|
||||
: "running",
|
||||
title: permissionApproval.title,
|
||||
detail: permissionApproval.detail ?? buildPermissionV2Detail(event),
|
||||
});
|
||||
if (permissionApproval.autoApprove) {
|
||||
if (permissionApproval.autoApprove || permissionApproval.autoReject) {
|
||||
const reply = permissionApproval.autoReject ? "reject" : "once";
|
||||
await runtime.replyPermission({
|
||||
requestId: event.properties.id,
|
||||
sessionId,
|
||||
reply: "once",
|
||||
reply,
|
||||
});
|
||||
write("permission_response", {
|
||||
session_id: clientSessionId,
|
||||
request_id: event.properties.id,
|
||||
reply: "once" satisfies PermissionReply,
|
||||
reply: reply satisfies PermissionReply,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user