feat(settings): agent.sessionDir setting shown on settings page
null keeps the deployment default (AGENT_SESSION_DIR / DATA_DIR/agent-sessions). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f9c20c67dc
commit
f6457a29db
3 files changed
+26
-3
No files matched your search
@@ -81,9 +81,16 @@ export function scopeFor(mode: "execute" | "plan_only", allowlist?: readonly str
|
|||||||
return { capabilities: allowlist?.length ? [...allowlist] : all.map((d) => d.id), allowedKinds: null };
|
return { capabilities: allowlist?.length ? [...allowlist] : all.map((d) => d.id), allowedKinds: null };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sessionDirOf(env: AgentEnv): string {
|
/**
|
||||||
|
* 会话目录优先级:模块装配参数(测试)> settings.agent.sessionDir > AGENT_SESSION_DIR(main 按 DATA_DIR 算好注入)
|
||||||
|
* > ./data/agent-sessions
|
||||||
|
*/
|
||||||
|
export function sessionDirOf(env: AgentEnv, configured?: string | null): string {
|
||||||
return resolve(
|
return resolve(
|
||||||
env.opts.sessionDir ?? Deno.env.get("AGENT_SESSION_DIR") ?? join(Deno.cwd(), "data", "agent-sessions"),
|
env.opts.sessionDir ??
|
||||||
|
configured ??
|
||||||
|
Deno.env.get("AGENT_SESSION_DIR") ??
|
||||||
|
join(Deno.cwd(), "data", "agent-sessions"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,7 +356,7 @@ export async function drive(
|
|||||||
systemPrompt: systemPromptFor(run, scope),
|
systemPrompt: systemPromptFor(run, scope),
|
||||||
capabilities: scope.capabilities?.length ? scope.capabilities : Object.keys(CAPABILITY_CATALOG),
|
capabilities: scope.capabilities?.length ? scope.capabilities : Object.keys(CAPABILITY_CATALOG),
|
||||||
settings,
|
settings,
|
||||||
sessionDir: sessionDirOf(env),
|
sessionDir: sessionDirOf(env, s.agent.sessionDir),
|
||||||
actor,
|
actor,
|
||||||
firstSeq: maxSeq?.m === null || maxSeq?.m === undefined ? 0 : Number(maxSeq.m) + 1,
|
firstSeq: maxSeq?.m === null || maxSeq?.m === undefined ? 0 : Number(maxSeq.m) + 1,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -247,6 +247,14 @@ const AGENT_RUNTIME_CARD: CardSpec = {
|
|||||||
kind: "textarea",
|
kind: "textarea",
|
||||||
hint: '{"match":"收进来","steps":[{"toolCalls":[{"capability":"inventory.query","input":{"query":"沙丘2"}}]}],"finalText":"…"},格式见 docs/runbook/agent.md',
|
hint: '{"match":"收进来","steps":[{"toolCalls":[{"capability":"inventory.query","input":{"query":"沙丘2"}}]}],"finalText":"…"},格式见 docs/runbook/agent.md',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "agent.sessionDir",
|
||||||
|
label: "会话目录",
|
||||||
|
kind: "text",
|
||||||
|
wide: true,
|
||||||
|
placeholder: "留空用部署默认:DATA_DIR/agent-sessions(容器内 /data/agent-sessions)",
|
||||||
|
hint: "绝对路径,api 与 worker 进程都要可读写;有运行中的会话时不要改(续跑会找不到旧会话文件)",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
fromSettings: (s) => ({
|
fromSettings: (s) => ({
|
||||||
"agent.maxToolCalls": n(s.agent.maxToolCalls),
|
"agent.maxToolCalls": n(s.agent.maxToolCalls),
|
||||||
@@ -256,6 +264,7 @@ const AGENT_RUNTIME_CARD: CardSpec = {
|
|||||||
"agent.goalPollSec": n(s.agent.goalPollSec),
|
"agent.goalPollSec": n(s.agent.goalPollSec),
|
||||||
"agent.goalWaitHours": n(s.agent.goalWaitHours),
|
"agent.goalWaitHours": n(s.agent.goalWaitHours),
|
||||||
"agent.fakeScript": s.agent.fakeScript ?? "",
|
"agent.fakeScript": s.agent.fakeScript ?? "",
|
||||||
|
"agent.sessionDir": s.agent.sessionDir ?? "",
|
||||||
}),
|
}),
|
||||||
toPatch: (v) => ({
|
toPatch: (v) => ({
|
||||||
agent: {
|
agent: {
|
||||||
@@ -266,6 +275,7 @@ const AGENT_RUNTIME_CARD: CardSpec = {
|
|||||||
goalPollSec: num(v["agent.goalPollSec"]),
|
goalPollSec: num(v["agent.goalPollSec"]),
|
||||||
goalWaitHours: num(v["agent.goalWaitHours"]),
|
goalWaitHours: num(v["agent.goalWaitHours"]),
|
||||||
fakeScript: str(v["agent.fakeScript"]).trim() || null,
|
fakeScript: str(v["agent.fakeScript"]).trim() || null,
|
||||||
|
sessionDir: str(v["agent.sessionDir"]).trim() || null,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ export const AgentRuntimeSettings = z.object({
|
|||||||
.max(24 * 30),
|
.max(24 * 30),
|
||||||
/** fake 模式脚本(JSON,FakeScript 的可序列化子集);null 用内置演示脚本 */
|
/** fake 模式脚本(JSON,FakeScript 的可序列化子集);null 用内置演示脚本 */
|
||||||
fakeScript: z.string().max(100_000).nullable(),
|
fakeScript: z.string().max(100_000).nullable(),
|
||||||
|
/**
|
||||||
|
* Agent JSONL 会话目录(绝对路径,api 与 worker 进程都要能读写);
|
||||||
|
* null = 部署默认(环境变量 AGENT_SESSION_DIR,缺省 DATA_DIR/agent-sessions)
|
||||||
|
*/
|
||||||
|
sessionDir: z.string().max(1024).regex(/^\//, "必须是绝对路径").nullable(),
|
||||||
});
|
});
|
||||||
export type AgentRuntimeSettings = z.infer<typeof AgentRuntimeSettings>;
|
export type AgentRuntimeSettings = z.infer<typeof AgentRuntimeSettings>;
|
||||||
|
|
||||||
@@ -168,6 +173,7 @@ export const DEFAULT_SETTINGS: GlobalSettings = {
|
|||||||
goalPollSec: 60,
|
goalPollSec: 60,
|
||||||
goalWaitHours: 72,
|
goalWaitHours: 72,
|
||||||
fakeScript: null,
|
fakeScript: null,
|
||||||
|
sessionDir: null,
|
||||||
},
|
},
|
||||||
metadata: { tmdbApiKeySecretRef: null, tmdbBaseUrl: null },
|
metadata: { tmdbApiKeySecretRef: null, tmdbBaseUrl: null },
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user