Skip to content

Commit dd5acf1

Browse files
committed
refactor(channels): keep status contract net-negative
1 parent 49e00ab commit dd5acf1

7 files changed

Lines changed: 31 additions & 150 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
14ff327d9f8d7d823d2391b857441a7b2e7092db4ae07b4c3b93f5972969ee53 plugin-sdk-api-baseline.json
2-
533532f5fc00832ca36e708031923ad0a9ec246e178e0027ab5eb235960ff2a8 plugin-sdk-api-baseline.jsonl
1+
71725394b9addf613ecf74faf08808ae6a68a3b7c7bf82222f9ba24e0ddc6d98 plugin-sdk-api-baseline.json
2+
3eaab17c6854d67dda2235d501687200ac38e106890c33d7e67e0974f3807b01 plugin-sdk-api-baseline.jsonl

docs/plugins/sdk-channel-plugins.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -377,19 +377,8 @@ status adapter, and channel secret target metadata needed for those
377377
summaries. Do not start clients, listeners, or transport runtimes from the
378378
setup entry.
379379

380-
### Status contracts
381-
382-
Use `ChannelAccountStatus` for credential-free snapshots returned by status
383-
commands and Gateway clients. Plugin status hooks, `defaultRuntime`, and
384-
`getStatus`/`setStatus` use `ChannelAccountSnapshotInput` because those values
385-
are contributions that core projects through the public status schema before
386-
delivery.
387-
388-
`ChannelAccountSnapshot` remains as a deprecated alias for contribution input
389-
during the migration window. New plugins should import the explicit type they
390-
need from `openclaw/plugin-sdk/channel-contract` or
391-
`openclaw/plugin-sdk/status-helpers`; do not put raw credential values in
392-
`ChannelAccountStatus`.
380+
Status output uses `ChannelAccountStatus`; contributions use
381+
`ChannelAccountSnapshotInput` (`ChannelAccountSnapshot` is its deprecated alias).
393382

394383
Keep the main channel entry import path narrow too. Discovery can evaluate
395384
the entry and the channel plugin module to register capabilities without

docs/plugins/sdk-migration.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ If a manifest field is still accepted, keep using it until docs and
8888
diagnostics say otherwise. New code should prefer the documented replacement;
8989
existing plugins should not break during ordinary minor releases.
9090

91+
For channel status, use `ChannelAccountStatus` for output and
92+
`ChannelAccountSnapshotInput` for input; its old alias is deprecated.
93+
9194
Audit the current migration queue with `pnpm plugins:boundary-report`:
9295

9396
| Flag | Effect |
@@ -370,21 +373,6 @@ SDK.
370373
</Step>
371374
</Steps>
372375

373-
## Channel status type migration
374-
375-
Channel status output and plugin/runtime contributions now use separate types:
376-
377-
- Use `ChannelAccountStatus` for credential-free snapshots returned by status
378-
commands and Gateway clients.
379-
- Use `ChannelAccountSnapshotInput` for `buildAccountSnapshot`,
380-
`defaultRuntime`, and channel runtime `getStatus`/`setStatus` values.
381-
- `ChannelAccountSnapshot` is a deprecated compatibility alias for
382-
`ChannelAccountSnapshotInput`. Migrate to an explicit type before the next
383-
major-version cleanup.
384-
385-
Both modern types are available from `plugin-sdk/channel-contract`; status
386-
helper consumers can also import them from `plugin-sdk/status-helpers`.
387-
388376
## Import path reference
389377

390378
<Accordion title="Common import path table">

packages/gateway-protocol/src/channels.schema.test.ts

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,58 +38,38 @@ describe("ChannelsStatusResultSchema", () => {
3838
const validate = Compile(ChannelsStatusResultSchema);
3939

4040
it("accepts gateway event-loop diagnostics emitted by channels.status", () => {
41-
expect(
42-
validate.Check({
43-
ts: Date.now(),
44-
channelOrder: ["discord"],
45-
channelLabels: { discord: "Discord" },
46-
channels: { discord: { configured: true } },
47-
channelAccounts: {
48-
discord: [
49-
{
50-
accountId: "default",
51-
enabled: true,
52-
configured: true,
53-
running: true,
54-
connected: false,
55-
healthState: "stale-socket",
56-
},
57-
],
58-
},
59-
channelDefaultAccountId: { discord: "default" },
60-
partial: true,
61-
warnings: ["discord:default probe timed out after 1000ms"],
62-
eventLoop: {
63-
degraded: true,
64-
reasons: ["event_loop_delay", "cpu"],
65-
intervalMs: 62_000,
66-
delayP99Ms: 1_250.5,
67-
delayMaxMs: 62_000,
68-
utilization: 0.98,
69-
cpuCoreRatio: 1.2,
70-
},
71-
}),
72-
).toBe(true);
73-
});
74-
75-
it("rejects credential-shaped and undeclared account status fields", () => {
7641
const result = {
7742
ts: Date.now(),
78-
channelOrder: ["line"],
79-
channelLabels: { line: "LINE" },
80-
channels: { line: { configured: true } },
43+
channelOrder: ["discord"],
44+
channelLabels: { discord: "Discord" },
45+
channels: { discord: { configured: true } },
8146
channelAccounts: {
82-
line: [
47+
discord: [
8348
{
8449
accountId: "default",
50+
enabled: true,
8551
configured: true,
86-
channelAccessToken: "secret-token",
52+
running: true,
53+
connected: false,
54+
healthState: "stale-socket",
8755
},
8856
],
8957
},
90-
channelDefaultAccountId: { line: "default" },
58+
channelDefaultAccountId: { discord: "default" },
59+
partial: true,
60+
warnings: ["discord:default probe timed out after 1000ms"],
61+
eventLoop: {
62+
degraded: true,
63+
reasons: ["event_loop_delay", "cpu"],
64+
intervalMs: 62_000,
65+
delayP99Ms: 1_250.5,
66+
delayMaxMs: 62_000,
67+
utilization: 0.98,
68+
cpuCoreRatio: 1.2,
69+
},
9170
};
92-
71+
expect(validate.Check(result)).toBe(true);
72+
Object.assign(result.channelAccounts.discord[0], { channelAccessToken: "secret-token" });
9373
expect(validate.Check(result)).toBe(false);
9474
});
9575
});

scripts/plugin-sdk-surface-report.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export function readPluginSdkSurfaceBudgets(env = process.env) {
198198
),
199199
publicExports: readPluginSdkSurfaceBudgetEnv(
200200
"OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_EXPORTS",
201-
10471,
201+
10481,
202202
env,
203203
),
204204
publicFunctionExports: readPluginSdkSurfaceBudgetEnv(
@@ -208,7 +208,7 @@ export function readPluginSdkSurfaceBudgets(env = process.env) {
208208
),
209209
publicDeprecatedExports: readPluginSdkSurfaceBudgetEnv(
210210
"OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_DEPRECATED_EXPORTS",
211-
3265,
211+
3269,
212212
env,
213213
),
214214
publicWildcardReexports: readPluginSdkSurfaceBudgetEnv(

src/channels/plugins/status.test.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/plugins/contracts/plugin-sdk-subpaths.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import type {
66
BaseProbeResult as ContractBaseProbeResult,
77
BaseTokenResolution as ContractBaseTokenResolution,
88
ChannelAgentTool as ContractChannelAgentTool,
9-
ChannelAccountStatus as ContractChannelAccountStatus,
109
ChannelAccountSnapshot as ContractChannelAccountSnapshot,
11-
ChannelAccountSnapshotInput as ContractChannelAccountSnapshotInput,
1210
ChannelGroupContext as ContractChannelGroupContext,
1311
ChannelMessageActionAdapter as ContractChannelMessageActionAdapter,
1412
ChannelMessageActionContext as ContractChannelMessageActionContext,
@@ -34,9 +32,7 @@ import type {
3432
BaseProbeResult,
3533
BaseTokenResolution,
3634
ChannelAgentTool,
37-
ChannelAccountStatus,
3835
ChannelAccountSnapshot,
39-
ChannelAccountSnapshotInput,
4036
ChannelGroupContext,
4137
ChannelMessageActionAdapter,
4238
ChannelMessageActionName,
@@ -1329,9 +1325,7 @@ describe("plugin-sdk subpath exports", () => {
13291325
expectTypeOf<ContractBaseProbeResult>().toMatchTypeOf<BaseProbeResult>();
13301326
expectTypeOf<ContractBaseTokenResolution>().toMatchTypeOf<BaseTokenResolution>();
13311327
expectTypeOf<ContractChannelAgentTool>().toMatchTypeOf<ChannelAgentTool>();
1332-
expectTypeOf<ContractChannelAccountStatus>().toMatchTypeOf<ChannelAccountStatus>();
13331328
expectTypeOf<ContractChannelAccountSnapshot>().toMatchTypeOf<ChannelAccountSnapshot>();
1334-
expectTypeOf<ContractChannelAccountSnapshotInput>().toMatchTypeOf<ChannelAccountSnapshotInput>();
13351329
expectTypeOf<ContractChannelGroupContext>().toMatchTypeOf<ChannelGroupContext>();
13361330
expectTypeOf<ContractChannelMessageActionAdapter>().toMatchTypeOf<ChannelMessageActionAdapter>();
13371331
expectTypeOf<ContractChannelMessageActionContext>().toMatchTypeOf<ChannelMessageActionContext>();

0 commit comments

Comments
 (0)