@@ -38,78 +38,6 @@ import {
3838- ` dispatchChannelInboundReply(...) ` : records and dispatches an already
3939 assembled inbound reply with a delivery adapter.
4040
41- ## Prepared inbound envelope
42-
43- Channels that finish transport admission and normalization before entering the
44- shared runner can use ` PreparedChannelInbound ` as the boundary:
45-
46- ``` ts
47- import {
48- projectPreparedChannelInbound ,
49- resolveChannelInboundReplyPolicy ,
50- runChannelInboundEvent ,
51- type PreparedChannelInbound ,
52- } from " openclaw/plugin-sdk/channel-inbound" ;
53-
54- const inbound = {
55- channel: " demo" ,
56- event: { id: nativeEvent .id , timestamp: nativeEvent .timestamp },
57- from: conversation .id ,
58- sender: { id: sender .id , name: sender .name },
59- conversation: { kind: " group" , id: conversation .id },
60- route: { agentId , accountId , routeSessionKey },
61- reply: { to: conversation .id , replyToId: quote ?.id },
62- message: {
63- rawBody ,
64- body: formattedBody ,
65- bodyForAgent ,
66- commandBody ,
67- },
68- command: {
69- kind: " text-slash" ,
70- body: commandBody ,
71- authorization: { kind: " authorized" },
72- },
73- media ,
74- } satisfies PreparedChannelInbound ;
75-
76- const prepared = projectPreparedChannelInbound ({
77- inbound ,
78- control: { messageReceivedHooks: " core" },
79- });
80- const replyPolicy = resolveChannelInboundReplyPolicy ({
81- cfg ,
82- ctx: prepared .context ,
83- blockStreamingEnabled ,
84- });
85-
86- await runChannelInboundEvent ({
87- channel: inbound .channel ,
88- accountId ,
89- raw: inbound ,
90- adapter: {
91- ingest : () => prepared .input ,
92- resolveTurn : () => buildTurnPlan (prepared .context , replyPolicy ),
93- },
94- });
95- ```
96-
97- The envelope contains prepared product facts only. Keep native callbacks,
98- socket objects, provider message records, and transport lifecycle symbols in a
99- channel-private context beside it. Represent command authorization explicitly
100- as ` not_checked ` , ` authorized ` , or ` denied ` ; do not make core infer it from a
101- transport payload.
102-
103- Use ` resolveChannelInboundReplyPolicy(...) ` after building the portable inbound
104- context. Core resolves product policy for source reply delivery, block
105- streaming, and typing suppression. The channel supplies prepared context facts,
106- including mention state, plus native capabilities such as whether block
107- streaming is enabled.
108-
109- Keep quote encoding, reply callbacks, native target lookup, and other
110- transport mechanics in the channel. Do not duplicate visible-reply policy in a
111- channel adapter.
112-
11341For media-only inbound events, keep the message body and command text empty and
11442pass one ` ChannelInboundMediaInput ` fact per native attachment. When an ambient
11543history line or another text-only carrier must describe those facts, use
0 commit comments