refactor: reuse account status helpers in bundled channels

This commit is contained in:
Peter Steinberger
2026-03-22 20:54:11 +00:00
parent 87722d6327
commit 2a1acec6a7
5 changed files with 39 additions and 30 deletions

View File

@@ -1,6 +1,7 @@
export {
DEFAULT_ACCOUNT_ID,
PAIRING_APPROVED_MESSAGE,
buildComputedAccountStatusSnapshot,
buildChannelConfigSchema,
collectStatusIssuesFromLastError,
formatTrimmedAllowFromEntries,

View File

@@ -5,6 +5,7 @@ import { createLazyRuntimeModule } from "openclaw/plugin-sdk/lazy-runtime";
import { resolveOutboundSendDep } from "openclaw/plugin-sdk/outbound-runtime";
import { buildOutboundBaseSessionKey, type RoutePeer } from "openclaw/plugin-sdk/routing";
import {
buildComputedAccountStatusSnapshot,
collectStatusIssuesFromLastError,
DEFAULT_ACCOUNT_ID,
formatTrimmedAllowFromEntries,
@@ -206,21 +207,21 @@ export const imessagePlugin: ChannelPlugin<ResolvedIMessageAccount> = {
}),
probeAccount: async ({ timeoutMs }) =>
await (await loadIMessageChannelRuntime()).probeIMessageAccount(timeoutMs),
buildAccountSnapshot: ({ account, runtime, probe }) => ({
accountId: account.accountId,
name: account.name,
enabled: account.enabled,
configured: account.configured,
running: runtime?.running ?? false,
lastStartAt: runtime?.lastStartAt ?? null,
lastStopAt: runtime?.lastStopAt ?? null,
lastError: runtime?.lastError ?? null,
cliPath: runtime?.cliPath ?? account.config.cliPath ?? null,
dbPath: runtime?.dbPath ?? account.config.dbPath ?? null,
probe,
lastInboundAt: runtime?.lastInboundAt ?? null,
lastOutboundAt: runtime?.lastOutboundAt ?? null,
}),
buildAccountSnapshot: ({ account, runtime, probe }) =>
buildComputedAccountStatusSnapshot(
{
accountId: account.accountId,
name: account.name,
enabled: account.enabled,
configured: account.configured,
runtime,
probe,
},
{
cliPath: runtime?.cliPath ?? account.config.cliPath ?? null,
dbPath: runtime?.dbPath ?? account.config.dbPath ?? null,
},
),
resolveAccountState: ({ enabled }) => (enabled ? "enabled" : "disabled"),
},
gateway: {

View File

@@ -41,6 +41,7 @@ import {
resolveMatrixTargetIdentity,
} from "./matrix/target-ids.js";
import {
buildComputedAccountStatusSnapshot,
buildChannelConfigSchema,
buildProbeChannelStatusSummary,
collectStatusIssuesFromLastError,
@@ -412,20 +413,22 @@ export const matrixPlugin: ChannelPlugin<ResolvedMatrixAccount> = {
};
}
},
buildAccountSnapshot: ({ account, runtime, probe }) => ({
accountId: account.accountId,
name: account.name,
enabled: account.enabled,
configured: account.configured,
baseUrl: account.homeserver,
running: runtime?.running ?? false,
lastStartAt: runtime?.lastStartAt ?? null,
lastStopAt: runtime?.lastStopAt ?? null,
lastError: runtime?.lastError ?? null,
probe,
lastProbeAt: runtime?.lastProbeAt ?? null,
...buildTrafficStatusSummary(runtime),
}),
buildAccountSnapshot: ({ account, runtime, probe }) =>
buildComputedAccountStatusSnapshot(
{
accountId: account.accountId,
name: account.name,
enabled: account.enabled,
configured: account.configured,
runtime,
probe,
},
{
baseUrl: account.homeserver,
lastProbeAt: runtime?.lastProbeAt ?? null,
...buildTrafficStatusSummary(runtime),
},
),
},
gateway: {
startAccount: async (ctx) => {

View File

@@ -42,7 +42,10 @@ export {
export { IMessageConfigSchema } from "../config/zod-schema.providers-core.js";
export { resolveChannelMediaMaxBytes } from "../channels/plugins/media-limits.js";
export { collectStatusIssuesFromLastError } from "./status-helpers.js";
export {
buildComputedAccountStatusSnapshot,
collectStatusIssuesFromLastError,
} from "./status-helpers.js";
export {
monitorIMessageProvider,
probeIMessage,

View File

@@ -148,6 +148,7 @@ export { formatResolvedUnresolvedNote } from "./resolution-notes.js";
export { runPluginCommandWithTimeout } from "./run-command.js";
export { createLoggerBackedRuntime, resolveRuntimeEnv } from "./runtime.js";
export {
buildComputedAccountStatusSnapshot,
buildProbeChannelStatusSummary,
collectStatusIssuesFromLastError,
} from "./status-helpers.js";