




















@@ -14,6 +14,65 @@ describe("createPluginRuntimeMock", () => {
1414expect(vi.isMockFunction(debouncer.cancelKey)).toBe(true);
1515});
161617+it("keeps deprecated turn runtime aliases aligned with inbound mocks", async () => {
18+const runtime = createPluginRuntimeMock();
19+const channel = "test";
20+21+expect(runtime.channel.turn.run).toBe(runtime.channel.inbound.run);
22+expect(runtime.channel.turn.runAssembled).toBe(runtime.channel.inbound.dispatchReply);
23+expect(runtime.channel.turn.buildContext).toBe(runtime.channel.inbound.buildContext);
24+expect(runtime.channel.turn.runPrepared).toBe(runtime.channel.inbound.runPreparedReply);
25+expect(runtime.channel.turn.dispatchAssembled).toBe(runtime.channel.inbound.dispatchReply);
26+27+const input = vi.fn((raw: { id: string }) => ({
28+id: raw.id,
29+rawText: "hello",
30+}));
31+const recordInboundSession = vi.fn();
32+const runDispatch = vi.fn(async () => ({
33+visibleReplySent: true,
34+}));
35+const resolveTurn = vi.fn(async () => ({
36+ channel,
37+storePath: "/tmp/openclaw-test",
38+routeSessionKey: "agent:main:test:direct:u1",
39+ctxPayload: {
40+Body: "hello",
41+CommandAuthorized: false,
42+SessionKey: "agent:main:test:direct:u1",
43+},
44+ recordInboundSession,
45+ runDispatch,
46+}));
47+48+const result = await runtime.channel.turn.runResolved({
49+ channel,
50+raw: { id: "m1" },
51+ input,
52+ resolveTurn,
53+});
54+55+expect(input).toHaveBeenCalledWith({ id: "m1" });
56+expect(resolveTurn).toHaveBeenCalledWith(
57+{ id: "m1", rawText: "hello" },
58+{ kind: "message", canStartAgentTurn: true },
59+{},
60+);
61+expect(recordInboundSession).toHaveBeenCalledWith(
62+expect.objectContaining({
63+storePath: "/tmp/openclaw-test",
64+sessionKey: "agent:main:test:direct:u1",
65+}),
66+);
67+expect(runDispatch).toHaveBeenCalled();
68+expect(result).toEqual(
69+expect.objectContaining({
70+admission: { kind: "dispatch" },
71+dispatched: true,
72+}),
73+);
74+});
75+1776it("routes untrusted group prompt facts into untrusted structured context", () => {
1877const runtime = createPluginRuntimeMock();
1978此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。