Enforce session workspace boundaries
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
import {
|
||||
accountSessionInputRoot,
|
||||
accountSessionOutputRoot,
|
||||
accountSessionRoot,
|
||||
accountSessionScratchpadRoot,
|
||||
getCurrentAccount,
|
||||
} from "@/lib/claw-auth";
|
||||
|
||||
@@ -274,17 +276,26 @@ async function getLastUserText(
|
||||
|
||||
async function ensureSessionDirectories(accountId: string, sessionId: string) {
|
||||
await Promise.all([
|
||||
mkdir(accountSessionRoot(accountId, sessionId), { recursive: true }),
|
||||
mkdir(accountSessionInputRoot(accountId, sessionId), { recursive: true }),
|
||||
mkdir(accountSessionOutputRoot(accountId, sessionId), { recursive: true }),
|
||||
mkdir(accountSessionScratchpadRoot(accountId, sessionId), {
|
||||
recursive: true,
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
function renderSessionRuntimeContext(accountId: string, sessionId: string) {
|
||||
return [
|
||||
"[当前会话目录]",
|
||||
"[当前 session 工作区]",
|
||||
`- session_root: ${accountSessionRoot(accountId, sessionId)}`,
|
||||
`- 输入目录: ${accountSessionInputRoot(accountId, sessionId)}`,
|
||||
`- 输出目录: ${accountSessionOutputRoot(accountId, sessionId)}`,
|
||||
"如需保存本轮任务产物,请优先写入输出目录。",
|
||||
`- 临时目录: ${accountSessionScratchpadRoot(accountId, sessionId)}`,
|
||||
"当前 session 目录是默认可写工作区。",
|
||||
"交付产物必须优先写入输出目录。",
|
||||
"临时脚本、缓存和中间结果必须写入临时目录。",
|
||||
"可以读取完成任务所需的外部资料,但不要修改平台服务代码目录。",
|
||||
].join("\n\n");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user