feat(onebot): report stalled receive health

Separate account login state from receive-path health in get_status. A logged-in account remains online while good becomes false only after the receive path has been confirmed stale.

Apply the same health value to OneBot lifecycle and heartbeat events so API polling and event consumers observe consistent status semantics.

Regenerate the MCP action catalog with the clarified contract and add regression coverage for the online-but-degraded response.

Refs #233.
This commit is contained in:
DrSmoothl committed 2026-07-15 16:48:02 +08:00
1 parent da26d6796f
commit 9c61d991bd
5 files changed
+27 -10

No files matched your search

+2 -2
View File
@@ -5689,7 +5689,7 @@
{
"name": "get_status",
"aliases": [],
"returns": "运行状态。`online`/`good` 均表示账号是否在线。",
"returns": "运行状态。`online` 表示账号在线;`good` 仅在接收链路确认停滞时为 `false`。",
"returnsSchema": {
"type": "object",
"properties": {
@@ -5699,7 +5699,7 @@
},
"good": {
"type": "boolean",
"description": "状态是否正常(与 online 一致)"
"description": "接收链路健康状态;仅在确认停滞时为 false"
}
},
"required": [
+2 -2
View File
@@ -5692,7 +5692,7 @@ export const ACTIONS: CatalogAction[] = [
{
"name": "get_status",
"aliases": [],
"returns": "运行状态。`online`/`good` 均表示账号是否在线。",
"returns": "运行状态。`online` 表示账号在线;`good` 仅在接收链路确认停滞时为 `false`。",
"returnsSchema": {
"type": "object",
"properties": {
@@ -5702,7 +5702,7 @@ export const ACTIONS: CatalogAction[] = [
},
"good": {
"type": "boolean",
"description": "状态是否正常(与 online 一致)"
"description": "接收链路健康状态;仅在确认停滞时为 false"
}
},
"required": [
+3 -4
View File
@@ -27,19 +27,19 @@ export const actions = [
defineAction({
name: 'get_status',
readOnly: true,
returns: '运行状态。`online`/`good` 均表示账号是否在线。',
returns: '运行状态。`online` 表示账号在线;`good` 仅在接收链路确认停滞时为 `false`。',
returnsSchema: {
type: 'object',
properties: {
online: { type: 'boolean', description: '是否在线' },
good: { type: 'boolean', description: '状态是否正常(与 online 一致)' },
good: { type: 'boolean', description: '接收链路健康状态;仅在确认停滞时为 false' },
},
required: ['online', 'good'],
},
params: {},
run: (_p, ctx) => {
const online = ctx.isOnline();
return okResponse({ online, good: online });
return okResponse({ online, good: online && ctx.bridge.receiveHealthy });
},
}),
@@ -96,4 +96,3 @@ export const actions = [
},
}),
];
+2 -2
View File
@@ -465,7 +465,7 @@ export class OneBotInstance {
sub_type: subType,
status: {
online: this.online,
good: this.online,
good: this.online && this.bridge.receiveHealthy,
},
};
}
@@ -484,7 +484,7 @@ export class OneBotInstance {
self_id: selfId,
post_type: 'meta_event',
meta_event_type: 'heartbeat',
status: { online: this.online, good: this.online },
status: { online: this.online, good: this.online && this.bridge.receiveHealthy },
interval: OneBotInstance.HEARTBEAT_INTERVAL,
};
}
@@ -0,0 +1,18 @@
import { describe, expect, it } from 'vitest';
import { ApiHandler, type ApiActionContext } from '../src/api-handler';
describe('get_status receive health (#233)', () => {
it('keeps online true while reporting a stalled receive path as not good', async () => {
const ctx = {
isOnline: () => true,
bridge: { receiveHealthy: false },
} as unknown as ApiActionContext;
const response = await new ApiHandler(ctx).handle('get_status', {});
expect(response).toMatchObject({
status: 'ok',
retcode: 0,
data: { online: true, good: false },
});
});
});