Skip to content

Commit c89298f

Browse files
committed
fix: preserve channel runResolved mock compatibility
1 parent 329dad2 commit c89298f

7 files changed

Lines changed: 97 additions & 5 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
ad0244c9ea86a2c2b3f43f285b066c1ec8e0969dbcce87dd848a33442712db13 plugin-sdk-api-baseline.json
2-
b21846ef642b66f7af8439724424abbced35bd0b51b6ecdab90db75c44bbc516 plugin-sdk-api-baseline.jsonl
1+
83399e00723ea5cc4e7d3a4db0baaef73ad681a42baf72d18b088c649c1c7772 plugin-sdk-api-baseline.json
2+
89fd85479942e9cc3bf30692a0a94a0a0ebfed72ebe9eaf36cec650103cddb11 plugin-sdk-api-baseline.jsonl

docs/plugins/sdk-channel-inbound.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ prefer message adapters and durable message helpers.
5959

6060
- `runtime.channel.turn.run(...)` -> `runtime.channel.inbound.run(...)`
6161
- `runtime.channel.turn.runPrepared(...)` ->
62-
`runtime.channel.inbound.dispatchReply(...)`
62+
`runtime.channel.inbound.runPreparedReply(...)`
6363
- `runtime.channel.turn.runAssembled(...)` ->
6464
`runtime.channel.inbound.dispatchReply(...)`
6565
- `runtime.channel.turn.buildContext(...)` ->
@@ -68,3 +68,7 @@ prefer message adapters and durable message helpers.
6868
New plugin code should not introduce `turn`-named channel APIs. Keep model or
6969
agent turn vocabulary inside agent/provider code; channel plugins use inbound,
7070
message, delivery, and reply terms.
71+
72+
The `runtime.channel.turn.*` aliases remain only as deprecated compatibility
73+
for already published plugins. They can be removed in the next major SDK cleanup
74+
after external plugins have had a migration window.

docs/plugins/sdk-channel-message.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ This page moved to [Channel outbound API](/plugins/sdk-channel-outbound).
1010
subpaths for older plugins. New channel plugins should use
1111
`openclaw/plugin-sdk/channel-outbound` for message lifecycle, receipt, durable
1212
send, and live preview helpers.
13+
14+
Removal plan: keep these aliases through the external plugin migration window,
15+
then remove them in the next major SDK cleanup after callers have moved to
16+
`channel-outbound`.

docs/plugins/sdk-channel-turn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ title: "Channel turn"
44
---
55

66
This page moved to [Channel inbound API](/plugins/sdk-channel-inbound).
7+
8+
The old channel-turn runtime names remain deprecated compatibility only. New
9+
plugin code should use `runtime.channel.inbound.*`, `channel-inbound`, and
10+
`channel-outbound`; the aliases can be removed in the next major SDK cleanup
11+
after external plugin migration.

docs/plugins/sdk-subpaths.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ by package contract guardrails.
126126
| `plugin-sdk/channel-secret-runtime` | Narrow secret-contract helpers such as `collectSimpleChannelFieldAssignments`, `getChannelSurface`, `pushAssignment`, and secret target types |
127127
</Accordion>
128128

129+
Deprecated channel helper families stay available only for published-plugin
130+
compatibility. The removal plan is: keep them through the external plugin
131+
migration window, keep repo/bundled plugins on `channel-inbound` and
132+
`channel-outbound`, then remove the compatibility subpaths in the next major
133+
SDK cleanup. This applies to the old channel message/runtime, channel
134+
streaming, direct-DM access, inbound helper splinter, reply-options,
135+
pairing-path, and runtime `channel.turn.*` families.
136+
129137
<Accordion title="Provider subpaths">
130138
| Subpath | Key exports |
131139
| --- | --- |

src/plugin-sdk/test-helpers/plugin-runtime-mock.test.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,65 @@ describe("createPluginRuntimeMock", () => {
1414
expect(vi.isMockFunction(debouncer.cancelKey)).toBe(true);
1515
});
1616

17+
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+
1776
it("routes untrusted group prompt facts into untrusted structured context", () => {
1877
const runtime = createPluginRuntimeMock();
1978

src/plugin-sdk/test-helpers/plugin-runtime-mock.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,20 @@ export function createPluginRuntimeMock(overrides: DeepPartial<PluginRuntime> =
731731
run: runChannelTurnMock,
732732
runAssembled:
733733
dispatchAssembledChannelTurnMock as unknown as PluginRuntime["channel"]["turn"]["runAssembled"],
734-
runResolved:
735-
runChannelTurnMock as unknown as PluginRuntime["channel"]["turn"]["runResolved"],
734+
runResolved: vi.fn(
735+
async (params: Parameters<PluginRuntime["channel"]["turn"]["runResolved"]>[0]) =>
736+
await runChannelTurnMock({
737+
channel: params.channel,
738+
accountId: params.accountId,
739+
raw: params.raw,
740+
log: params.log,
741+
adapter: {
742+
ingest: (raw) =>
743+
typeof params.input === "function" ? params.input(raw) : params.input,
744+
resolveTurn: params.resolveTurn,
745+
},
746+
}),
747+
) as unknown as PluginRuntime["channel"]["turn"]["runResolved"],
736748
buildContext: buildChannelInboundEventContextMock,
737749
runPrepared: runPreparedChannelTurnMock,
738750
dispatchAssembled:

0 commit comments

Comments
 (0)