Skip to content

Commit 4a5b17b

Browse files
author
jony376
committed
fix ci
1 parent dae0500 commit 4a5b17b

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ const {
1313
createOpenClawCodingToolsMock,
1414
getChannelPluginMock,
1515
handleCommandsMock,
16+
resolveSandboxContextMock,
1617
} = vi.hoisted(() => ({
1718
buildStatusReplyMock: vi.fn(),
1819
createOpenClawCodingToolsMock: vi.fn(),
1920
getChannelPluginMock: vi.fn(),
2021
handleCommandsMock: vi.fn(),
22+
resolveSandboxContextMock: vi.fn(),
2123
}));
2224

2325
type HandleInlineActionsInput = Parameters<
@@ -33,6 +35,10 @@ vi.mock("../../agents/pi-tools.js", () => ({
3335
createOpenClawCodingTools: (...args: unknown[]) => createOpenClawCodingToolsMock(...args),
3436
}));
3537

38+
vi.mock("../../agents/sandbox.js", () => ({
39+
resolveSandboxContext: (...args: unknown[]) => resolveSandboxContextMock(...args),
40+
}));
41+
3642
vi.mock("../../channels/plugins/index.js", () => ({
3743
getChannelPlugin: (...args: unknown[]) => getChannelPluginMock(...args),
3844
getLoadedChannelPlugin: (...args: unknown[]) => getChannelPluginMock(...args),
@@ -153,9 +159,11 @@ describe("handleInlineActions", () => {
153159
handleCommandsMock.mockResolvedValue({ shouldContinue: true, reply: undefined });
154160
getChannelPluginMock.mockReset();
155161
createOpenClawCodingToolsMock.mockReset();
162+
resolveSandboxContextMock.mockReset();
156163
buildStatusReplyMock.mockReset();
157164
buildStatusReplyMock.mockResolvedValue({ text: "status" });
158165
createOpenClawCodingToolsMock.mockReturnValue([]);
166+
resolveSandboxContextMock.mockResolvedValue(null);
159167
getChannelPluginMock.mockImplementation((channelId?: string) =>
160168
channelId === "whatsapp"
161169
? { commands: { skipWhenConfigEmpty: true } }
@@ -697,6 +705,13 @@ describe("handleInlineActions", () => {
697705
it("uses the canonical target session policy context for inline tool dispatch", async () => {
698706
const typing = createTypingController();
699707
const toolExecute = vi.fn(async () => ({ content: "spawned" }));
708+
const sandbox = {
709+
enabled: true,
710+
workspaceDir: "/tmp/sandbox",
711+
workspaceAccess: "ro",
712+
tools: { allow: ["read"] },
713+
};
714+
resolveSandboxContextMock.mockResolvedValue(sandbox);
700715
createOpenClawCodingToolsMock.mockReturnValue([
701716
{
702717
name: "sessions_spawn",
@@ -775,9 +790,15 @@ describe("handleInlineActions", () => {
775790
);
776791

777792
expect(result).toEqual({ kind: "reply", reply: { text: "spawned" } });
793+
expect(resolveSandboxContextMock).toHaveBeenCalledWith({
794+
config: { commands: { text: true } },
795+
sessionKey: "agent:target:telegram:direct:target-session",
796+
workspaceDir: "/tmp",
797+
});
778798
expect(createOpenClawCodingToolsMock).toHaveBeenCalledWith(
779799
expect.objectContaining({
780800
sessionKey: "agent:target:telegram:direct:target-session",
801+
sandbox,
781802
groupId: "target-group",
782803
groupChannel: "#target",
783804
groupSpace: "target-space",

‎src/auto-reply/reply/get-reply-inline-actions.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { collectTextContentBlocks } from "../../agents/content-blocks.js";
22
import { createOpenClawCodingTools } from "../../agents/pi-tools.js";
3+
import { resolveSandboxContext } from "../../agents/sandbox.js";
34
import type { BlockReplyChunking } from "../../agents/pi-embedded-block-chunker.js";
45
import type { SkillCommandSpec } from "../../agents/skills.js";
56
import { getChannelPlugin } from "../../channels/plugins/index.js";
@@ -265,12 +266,18 @@ export async function handleInlineActions(params: {
265266
sessionKey,
266267
});
267268
const targetSessionEntry = sessionStore?.[sessionKey] ?? sessionEntry;
269+
const sandbox = await resolveSandboxContext({
270+
config: cfg,
271+
sessionKey: toolPolicySessionKey,
272+
workspaceDir,
273+
});
268274
const tools = createOpenClawCodingTools({
269275
config: cfg,
270276
agentId,
271277
agentDir,
272278
workspaceDir,
273279
sessionKey: toolPolicySessionKey,
280+
sandbox,
274281
allowGatewaySubagentBinding: true,
275282
messageProvider: channel,
276283
agentAccountId: (ctx as { AccountId?: string }).AccountId,

0 commit comments

Comments
 (0)