Skip to content

Commit 4a05a08

Browse files
authored
refactor(config): retire flat streaming keys from the last six channel schemas via doctor migration (#105709)
* refactor(config): retire flat streaming keys from the last six channel schemas signal, irc, nextcloud-talk, whatsapp, googlechat, and mattermost now accept only the nested streaming.{chunkMode,block.enabled,block.coalesce} shape (mattermost also drops scalar/boolean streaming); flat spellings migrate via each channel's defineChannelAliasMigration doctor contract with root seeding for their wholesale-replace account merges. * feat(channels): warn once per key when the deprecated flat streaming fallback is used Bundled schemas now reject the flat delivery keys, so the streaming.ts fallback only serves external SDK plugin configs; emit a once-per-process per-key subsystem warning and pin the removal plan to the next release train. * chore(config): regenerate bundled channel config metadata for nested-only streaming * docs: describe nested-only channel streaming config and the SDK flat-key deprecation window * fix(whatsapp): seed migrated named-account streaming from the accounts.default layer WhatsApp resolution layers accounts.default shared config between root and named accounts, so doctor-materialized account streaming objects now inherit default-account settings over root ones; mattermost schema test moves to the nested-only shape with explicit rejection coverage; scope flat-key deprecation notes to the pending Matrix/Feishu migrations. * fix(whatsapp): resolve the default account case-insensitively when seeding migrated streaming * chore(plugin-sdk): repin API baseline for nested-only channel streaming types
1 parent 2f25e9c commit 4a05a08

49 files changed

Lines changed: 1012 additions & 247 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
0eb8e2e8ebfe48bbf269d6e0100e38b8c85c387651be7a3bc3d67f549a13768f plugin-sdk-api-baseline.json
2-
f6e5dc7474a7cb54bdcde544f135656ac8e501679e18129607f4f42fec7cd791 plugin-sdk-api-baseline.jsonl
1+
75edbe496d57c19d3ea53e51908c6c7aa37ed8a5c7311234c7ce17eea0775db8 plugin-sdk-api-baseline.json
2+
f21d330f28d93248bd6a7d96780452d6a969f5d1fcca1b9246ceb5a68e589b9f plugin-sdk-api-baseline.jsonl

‎docs/channels/mattermost.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,13 @@ Notes:
294294

295295
Mattermost streams thinking, tool activity, and partial reply text into a **draft preview post** that finalizes in place when the final answer is safe to send. In `partial` mode the preview updates on the same post id instead of spamming the channel with per-chunk messages. In `block` mode the preview rotates between completed text and tool-activity blocks, so earlier blocks stay visible as their own posts instead of being overwritten by the next one. Media/error finals cancel pending preview edits and use normal delivery instead of flushing a throwaway preview post.
296296

297-
Preview streaming is **on by default** in `partial` mode. Configure via `channels.mattermost.streaming` (a mode string, boolean, or an object like `{ mode: "progress" }`):
297+
Preview streaming is **on by default** in `partial` mode. Configure via `channels.mattermost.streaming.mode` (legacy scalar/boolean `streaming` values are migrated by `openclaw doctor --fix`):
298298

299299
```json5
300300
{
301301
channels: {
302302
mattermost: {
303-
streaming: "partial", // off | partial | block | progress
303+
streaming: { mode: "partial" }, // off | partial | block | progress
304304
},
305305
},
306306
}
@@ -311,7 +311,7 @@ Preview streaming is **on by default** in `partial` mode. Configure via `channel
311311
- `partial` (default): one preview post that is edited as the reply grows, then finalized with the complete answer.
312312
- `block` rotates the preview between completed text and tool-activity blocks, so each block stays visible as its own post instead of being overwritten in place. Parallel and consecutive tool updates share the current tool-activity post.
313313
- `progress` shows a status preview while generating and only posts the final answer at completion.
314-
- `off` disables preview streaming. With `blockStreaming: true`, completed assistant blocks are still delivered as normal block replies (separate posts) rather than a single coalesced final post.
314+
- `off` disables preview streaming. With `streaming.block.enabled: true`, completed assistant blocks are still delivered as normal block replies (separate posts) rather than a single coalesced final post.
315315

316316
</Accordion>
317317
<Accordion title="Streaming behavior notes">

‎docs/channels/nextcloud-talk.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ Provider options:
156156
- `channels.nextcloud-talk.dmHistoryLimit`: DM history limit (0 disables).
157157
- `channels.nextcloud-talk.dms`: per-DM overrides keyed by user ID (`historyLimit`).
158158
- `channels.nextcloud-talk.textChunkLimit`: outbound text chunk size in chars (default: 4000).
159-
- `channels.nextcloud-talk.chunkMode`: `length` (default) or `newline` to split on blank lines (paragraph boundaries) before length chunking.
160-
- `channels.nextcloud-talk.blockStreaming`: disable block streaming for this channel.
161-
- `channels.nextcloud-talk.blockStreamingCoalesce`: block streaming coalesce tuning.
159+
- `channels.nextcloud-talk.streaming.chunkMode`: `length` (default) or `newline` to split on blank lines (paragraph boundaries) before length chunking.
160+
- `channels.nextcloud-talk.streaming.block.enabled`: enable or disable block streaming for this channel.
161+
- `channels.nextcloud-talk.streaming.block.coalesce`: block streaming coalesce tuning.
162162
- `channels.nextcloud-talk.responsePrefix`: outbound reply prefix.
163163
- `channels.nextcloud-talk.markdown.tables`: markdown table rendering mode (`off | bullets | code | block`).
164164
- `channels.nextcloud-talk.mediaMaxMb`: inbound media cap (MB).

‎docs/channels/signal.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ Groups:
256256
## Media + limits
257257

258258
- Outbound text is chunked to `channels.signal.textChunkLimit` (default 4000).
259-
- Optional newline chunking: set `channels.signal.chunkMode="newline"` to split on blank lines (paragraph boundaries) before length chunking.
259+
- Optional newline chunking: set `channels.signal.streaming.chunkMode="newline"` to split on blank lines (paragraph boundaries) before length chunking.
260260
- Attachments are supported (base64 fetched from `signal-cli`).
261261
- Voice-note attachments use the `signal-cli` filename as a MIME fallback when `contentType` is missing, so audio transcription can still classify AAC voice memos.
262262
- Default media cap: `channels.signal.mediaMaxMb` (default 8).
@@ -440,12 +440,12 @@ Provider options:
440440
- `channels.signal.historyLimit`: max group messages to include as context (0 disables).
441441
- `channels.signal.dmHistoryLimit`: DM history limit in user turns. Per-user overrides: `channels.signal.dms["<phone_or_uuid>"].historyLimit`.
442442
- `channels.signal.textChunkLimit`: outbound chunk size in characters (default 4000).
443-
- `channels.signal.chunkMode`: `length` (default) or `newline` to split on blank lines (paragraph boundaries) before length chunking.
443+
- `channels.signal.streaming.chunkMode`: `length` (default) or `newline` to split on blank lines (paragraph boundaries) before length chunking.
444444
- `channels.signal.mediaMaxMb`: inbound/outbound media cap in MB (default 8).
445445
- `channels.signal.reactionLevel`: `off | ack | minimal | extensive` (default `minimal`). See [Reactions](#reactions-message-tool).
446446
- `channels.signal.reactionNotifications`: `off | own | all | allowlist` (default `own`) - when the agent is notified of incoming reactions from others.
447447
- `channels.signal.reactionAllowlist`: senders whose reactions notify the agent when `reactionNotifications: "allowlist"`.
448-
- `channels.signal.blockStreaming`, `channels.signal.blockStreamingCoalesce`: block-mode streaming controls shared across channels. See [Streaming](/concepts/streaming).
448+
- `channels.signal.streaming.block.enabled`, `channels.signal.streaming.block.coalesce`: block-mode streaming controls shared across channels. See [Streaming](/concepts/streaming).
449449

450450
Related global options:
451451

‎docs/channels/whatsapp.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ When the linked self number is also present in `allowFrom`, self-chat safeguards
391391
<AccordionGroup>
392392
<Accordion title="Text chunking">
393393
- default chunk limit: `channels.whatsapp.textChunkLimit = 4000`
394-
- `channels.whatsapp.chunkMode = "length" | "newline"`; `newline` prefers paragraph boundaries (blank lines), then falls back to length-safe chunking
394+
- `channels.whatsapp.streaming.chunkMode = "length" | "newline"`; `newline` prefers paragraph boundaries (blank lines), then falls back to length-safe chunking
395395

396396
</Accordion>
397397

@@ -677,7 +677,7 @@ Primary reference: [Configuration reference - WhatsApp](/gateway/config-channels
677677
| Area | Fields |
678678
| ---------------- | -------------------------------------------------------------------------------------------------------------- |
679679
| Access | `dmPolicy`, `allowFrom`, `groupPolicy`, `groupAllowFrom`, `groups` |
680-
| Delivery | `textChunkLimit`, `chunkMode`, `mediaMaxMb`, `sendReadReceipts`, `ackReaction`, `reactionLevel` |
680+
| Delivery | `textChunkLimit`, `streaming.chunkMode`, `mediaMaxMb`, `sendReadReceipts`, `ackReaction`, `reactionLevel` |
681681
| Multi-account | `accounts.<id>.enabled`, `accounts.<id>.authDir`, and other per-account overrides |
682682
| Operations | `configWrites`, `debounceMs`, `web.enabled`, `web.heartbeatSeconds`, `web.reconnect.*`, `web.whatsapp.*` |
683683
| Session behavior | `session.dmScope`, `historyLimit`, `dmHistoryLimit`, `dms.<id>.historyLimit` |

‎docs/concepts/messages.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ Block streaming sends partial replies as the model produces text blocks; chunkin
125125
- `agents.defaults.blockStreamingChunk` (`minChars|maxChars|breakPreference`)
126126
- `agents.defaults.blockStreamingCoalesce` (idle-based batching)
127127
- `agents.defaults.humanDelay` (human-like pause between block replies)
128-
- Channel overrides: `*.streaming.block.enabled` and `*.streaming.block.coalesce` on nested-streaming channels (Telegram, Discord, Slack, iMessage, Microsoft Teams); flat `*.blockStreaming` / `*.blockStreamingCoalesce` on channels without a nested streaming config. Block streaming is off unless explicitly enabled, on every channel including Telegram.
128+
- Channel overrides: `*.streaming.block.enabled` and `*.streaming.block.coalesce` on bundled channels (Matrix and Feishu still use the flat `*.blockStreaming` / `*.blockStreamingCoalesce` spellings); stale flat keys elsewhere are migrated by `openclaw doctor --fix`. Block streaming is off unless explicitly enabled, on every channel including Telegram.
129129

130130
Details: [Streaming + chunking](/concepts/streaming).
131131

‎docs/concepts/streaming.md‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,23 @@ Model output
4141
| `blockStreamingBreak` | `"text_end"` / `"message_end"` | - |
4242
| `blockStreamingChunk` | `{ minChars, maxChars, breakPreference? }` | - |
4343
| `blockStreamingCoalesce` | `{ minChars?, maxChars?, idleMs? }` (merge streamed blocks before send) | - |
44-
| `*.blockStreaming` (channel override) | `true` / `false`, forces block streaming per channel (and per account) | - |
44+
| `*.streaming.block.enabled` (channel override) | `true` / `false`, forces block streaming per channel (and per account) | - |
4545
| `*.textChunkLimit` (e.g. `channels.whatsapp.textChunkLimit`) | number, hard cap | 4000 |
46-
| `*.chunkMode` | `"length"` / `"newline"` | `"length"` |
46+
| `*.streaming.chunkMode` | `"length"` / `"newline"` | `"length"` |
4747
| `channels.discord.maxLinesPerMessage` | number, soft line cap that splits tall replies to avoid UI clipping | 17 |
4848

49-
`chunkMode: "newline"` splits on blank lines (paragraph boundaries), not every
50-
newline, before falling back to length chunking once the text exceeds the
51-
limit.
49+
`streaming.chunkMode: "newline"` splits on blank lines (paragraph boundaries),
50+
not every newline, before falling back to length chunking once the text
51+
exceeds the limit.
5252

53-
Channels with a nested `streaming` config (Telegram, Discord, Slack, iMessage,
54-
Microsoft Teams) spell these overrides as
55-
`channels.<id>.streaming.{chunkMode,block.enabled,block.coalesce}`; the flat
56-
`*.chunkMode` / `*.blockStreaming` / `*.blockStreamingCoalesce` spellings apply
57-
to channels without one (for example Signal, IRC, Google Chat, WhatsApp,
58-
Mattermost). Stale flat keys on nested-streaming channels are migrated by
59-
`openclaw doctor --fix` and are not read at runtime.
53+
Bundled channels spell these overrides as
54+
`channels.<id>.streaming.{chunkMode,block.enabled,block.coalesce}`. The flat
55+
`*.chunkMode` / `*.blockStreaming` / `*.blockStreamingCoalesce` spellings are
56+
legacy everywhere except Matrix and Feishu (their nested migration is still
57+
pending): `openclaw doctor --fix` migrates them into the nested shape, and
58+
migrated channel schemas reject them. External SDK plugin configs that still
59+
use the flat spellings keep working through a deprecated fallback (with a
60+
runtime warning) until the next release train.
6061

6162
**Boundary semantics** for `blockStreamingBreak`:
6263

@@ -104,7 +105,7 @@ progressive output.
104105
(final flush always sends remaining text).
105106
- Joiner is derived from `blockStreamingChunk.breakPreference`: `paragraph` ->
106107
`\n\n`, `newline` -> `\n`, `sentence` -> space.
107-
- Channel overrides are available via `*.blockStreamingCoalesce` (including
108+
- Channel overrides are available via `*.streaming.block.coalesce` (including
108109
per-account configs).
109110
- Discord, Signal, and Slack default coalesce to `{ minChars: 1500, idleMs: 1000 }`
110111
unless overridden.
@@ -126,15 +127,16 @@ replies**, not final replies or tool summaries.
126127
## "Stream chunks or everything"
127128

128129
- **Stream chunks:** `blockStreamingDefault: "on"` + `blockStreamingBreak: "text_end"`
129-
(emit as you go). Non-Telegram channels also need `*.blockStreaming: true`.
130+
(emit as you go). Non-Telegram channels also need
131+
`*.streaming.block.enabled: true`.
130132
- **Stream everything at end:** `blockStreamingBreak: "message_end"` (flush
131133
once, possibly multiple chunks if very long).
132134
- **No block streaming:** `blockStreamingDefault: "off"` (only final reply).
133135

134-
Block streaming is **off unless** `*.blockStreaming` is explicitly set to
135-
`true`. Channels can stream a live preview (`channels.<channel>.streaming`)
136-
without block replies. The `blockStreaming*` defaults live under
137-
`agents.defaults`, not the config root.
136+
Block streaming is **off unless** `*.streaming.block.enabled` is explicitly
137+
set to `true`. Channels can stream a live preview
138+
(`channels.<channel>.streaming.mode`) without block replies. The
139+
`blockStreaming*` defaults live under `agents.defaults`, not the config root.
138140

139141
## Preview streaming modes
140142

‎docs/gateway/config-channels.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ WhatsApp runs through the gateway's web channel (Baileys Web). It starts automat
129129
dmPolicy: "pairing", // pairing | allowlist | open | disabled
130130
allowFrom: ["+15555550123", "+447700900123"],
131131
textChunkLimit: 4000,
132-
chunkMode: "length", // length | newline
132+
streaming: { chunkMode: "length" }, // length | newline
133133
mediaMaxMb: 50,
134134
sendReadReceipts: true, // blue ticks (false in self-chat mode)
135135
groups: {
@@ -202,7 +202,7 @@ WhatsApp runs through the gateway's web channel (Baileys Web). It starts automat
202202
historyLimit: 50,
203203
replyToMode: "first", // off | first | all | batched
204204
linkPreview: true,
205-
streaming: "partial", // off | partial | block | progress (default: partial)
205+
streaming: { mode: "partial" }, // off | partial | block | progress (default: partial)
206206
actions: { reactions: true, sendMessage: true },
207207
reactionNotifications: "own", // off | own | all
208208
mediaMaxMb: 100,
@@ -576,7 +576,7 @@ Check [npmjs.com/package/@openclaw/mattermost](https://www.npmjs.com/package/@op
576576
callbackUrl: "https://gateway.example.com/api/channels/mattermost/command",
577577
},
578578
textChunkLimit: 4000,
579-
chunkMode: "length",
579+
streaming: { chunkMode: "length" },
580580
},
581581
},
582582
}

‎extensions/googlechat/src/doctor-contract.test.ts‎

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Googlechat tests cover doctor contract plugin behavior.
22
import { describe, expect, it } from "vitest";
3-
import { normalizeCompatibilityConfig } from "./doctor-contract.js";
3+
import { legacyConfigRules, normalizeCompatibilityConfig } from "./doctor-contract.js";
44

55
describe("googlechat doctor contract", () => {
66
it("removes legacy streamMode keys", () => {
@@ -73,4 +73,41 @@ describe("googlechat doctor contract", () => {
7373
enabled: true,
7474
});
7575
});
76+
77+
it("matches flat streaming aliases in legacy rules but not the nested shape", () => {
78+
const rootRule = legacyConfigRules.find(
79+
(rule) => rule.path.join(".") === "channels.googlechat" && rule.message.includes("chunkMode"),
80+
);
81+
expect(rootRule?.match?.({ blockStreaming: true }, {})).toBe(true);
82+
expect(rootRule?.match?.({ streaming: { block: { enabled: true } } }, {})).toBe(false);
83+
});
84+
85+
it("moves flat delivery aliases at root and account level with root seeding", () => {
86+
const result = normalizeCompatibilityConfig({
87+
cfg: {
88+
channels: {
89+
googlechat: {
90+
streamMode: "append",
91+
chunkMode: "newline",
92+
accounts: {
93+
work: { blockStreaming: true },
94+
},
95+
},
96+
},
97+
} as never,
98+
});
99+
100+
const googlechat = result.config.channels?.googlechat as unknown as Record<string, unknown>;
101+
expect(googlechat.streamMode).toBeUndefined();
102+
expect(googlechat.streaming).toEqual({ chunkMode: "newline" });
103+
expect(googlechat.chunkMode).toBeUndefined();
104+
const work = (googlechat.accounts as Record<string, Record<string, unknown>>).work;
105+
// Google Chat's account merge replaces root streaming wholesale, so the
106+
// migrated account object carries the inherited root chunk mode.
107+
expect(work?.streaming).toEqual({ chunkMode: "newline", block: { enabled: true } });
108+
expect(work?.blockStreaming).toBeUndefined();
109+
110+
const second = normalizeCompatibilityConfig({ cfg: result.config });
111+
expect(second.changes).toEqual([]);
112+
});
76113
});

‎extensions/googlechat/src/doctor-contract.ts‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,22 @@ import type {
44
ChannelDoctorLegacyConfigRule,
55
} from "openclaw/plugin-sdk/channel-contract";
66
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
7-
import { asObjectRecord } from "openclaw/plugin-sdk/runtime-doctor";
7+
import { asObjectRecord, defineChannelAliasMigration } from "openclaw/plugin-sdk/runtime-doctor";
88

99
type GoogleChatChannelsConfig = NonNullable<OpenClawConfig["channels"]>;
1010

11+
// Google Chat's nested streaming schema is delivery-only ({chunkMode, block});
12+
// it has no preview mode (legacy streamMode is removed outright above), so
13+
// only the delivery flat aliases migrate. Account merge replaces the root
14+
// streaming object wholesale (resolveMergedAccountConfig without a streaming
15+
// deep-merge), so migration seeds materialized account objects with the
16+
// inherited root settings.
17+
const streamingAliasMigration = defineChannelAliasMigration({
18+
channelId: "googlechat",
19+
streaming: { defaultMode: "partial", deliveryOnly: true },
20+
accountStreamingReplacesRoot: true,
21+
});
22+
1123
function hasLegacyGoogleChatStreamMode(value: unknown): boolean {
1224
return asObjectRecord(value)?.streamMode !== undefined;
1325
}
@@ -113,13 +125,10 @@ export const legacyConfigRules: ChannelDoctorLegacyConfigRule[] = [
113125
'channels.googlechat.accounts.<id>.groups.<id>.allow is legacy; use channels.googlechat.accounts.<id>.groups.<id>.enabled instead. Run "openclaw doctor --fix".',
114126
match: (value) => hasLegacyAccountAliases(value, hasLegacyGoogleChatGroupAllowAlias),
115127
},
128+
...streamingAliasMigration.legacyConfigRules,
116129
];
117130

118-
export function normalizeCompatibilityConfig({
119-
cfg,
120-
}: {
121-
cfg: OpenClawConfig;
122-
}): ChannelDoctorConfigMutation {
131+
function normalizeRetiredGoogleChatKeys(cfg: OpenClawConfig): ChannelDoctorConfigMutation {
123132
const rawEntry = asObjectRecord(
124133
(cfg.channels as Record<string, unknown> | undefined)?.googlechat,
125134
);
@@ -179,3 +188,15 @@ export function normalizeCompatibilityConfig({
179188
changes,
180189
};
181190
}
191+
192+
export function normalizeCompatibilityConfig({
193+
cfg,
194+
}: {
195+
cfg: OpenClawConfig;
196+
}): ChannelDoctorConfigMutation {
197+
const retired = normalizeRetiredGoogleChatKeys(cfg);
198+
return streamingAliasMigration.normalizeChannelConfig({
199+
cfg: retired.config,
200+
changes: retired.changes,
201+
});
202+
}

0 commit comments

Comments
 (0)