mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 17:31:10 +00:00
feat(agents): add sessions_spawn sandbox require mode
This commit is contained in:
@@ -53,6 +53,7 @@ describe("sessions_spawn tool", () => {
|
||||
thread: true,
|
||||
mode: "session",
|
||||
cleanup: "keep",
|
||||
sandbox: "require",
|
||||
});
|
||||
|
||||
expect(result.details).toMatchObject({
|
||||
@@ -70,6 +71,7 @@ describe("sessions_spawn tool", () => {
|
||||
thread: true,
|
||||
mode: "session",
|
||||
cleanup: "keep",
|
||||
sandbox: "require",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
agentSessionKey: "agent:main:main",
|
||||
@@ -78,6 +80,25 @@ describe("sessions_spawn tool", () => {
|
||||
expect(hoisted.spawnAcpDirectMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('defaults sandbox to "inherit" for subagent runtime', async () => {
|
||||
const tool = createSessionsSpawnTool({
|
||||
agentSessionKey: "agent:main:main",
|
||||
agentChannel: "discord",
|
||||
});
|
||||
|
||||
await tool.execute("call-sandbox-default", {
|
||||
task: "summarize logs",
|
||||
agentId: "main",
|
||||
});
|
||||
|
||||
expect(hoisted.spawnSubagentDirectMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
sandbox: "inherit",
|
||||
}),
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
|
||||
it("routes to ACP runtime when runtime=acp", async () => {
|
||||
const tool = createSessionsSpawnTool({
|
||||
agentSessionKey: "agent:main:main",
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { AnyAgentTool } from "./common.js";
|
||||
import { jsonResult, readStringParam } from "./common.js";
|
||||
|
||||
const SESSIONS_SPAWN_RUNTIMES = ["subagent", "acp"] as const;
|
||||
const SESSIONS_SPAWN_SANDBOX_MODES = ["inherit", "require"] as const;
|
||||
|
||||
const SessionsSpawnToolSchema = Type.Object({
|
||||
task: Type.String(),
|
||||
@@ -22,6 +23,7 @@ const SessionsSpawnToolSchema = Type.Object({
|
||||
thread: Type.Optional(Type.Boolean()),
|
||||
mode: optionalStringEnum(SUBAGENT_SPAWN_MODES),
|
||||
cleanup: optionalStringEnum(["delete", "keep"] as const),
|
||||
sandbox: optionalStringEnum(SESSIONS_SPAWN_SANDBOX_MODES),
|
||||
});
|
||||
|
||||
export function createSessionsSpawnTool(opts?: {
|
||||
@@ -55,6 +57,7 @@ export function createSessionsSpawnTool(opts?: {
|
||||
const mode = params.mode === "run" || params.mode === "session" ? params.mode : undefined;
|
||||
const cleanup =
|
||||
params.cleanup === "keep" || params.cleanup === "delete" ? params.cleanup : "keep";
|
||||
const sandbox = params.sandbox === "require" ? "require" : "inherit";
|
||||
// Back-compat: older callers used timeoutSeconds for this tool.
|
||||
const timeoutSecondsCandidate =
|
||||
typeof params.runTimeoutSeconds === "number"
|
||||
@@ -98,6 +101,7 @@ export function createSessionsSpawnTool(opts?: {
|
||||
thread,
|
||||
mode,
|
||||
cleanup,
|
||||
sandbox,
|
||||
expectsCompletionMessage: true,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user