mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-31 05:06:55 +00:00
refactor(core): extract shared dedup helpers
This commit is contained in:
@@ -81,13 +81,44 @@ export function buildBaseAccountStatusSnapshot(params: {
|
||||
name: account.name,
|
||||
enabled: account.enabled,
|
||||
configured: account.configured,
|
||||
...buildRuntimeAccountStatusSnapshot({ runtime, probe }),
|
||||
lastInboundAt: runtime?.lastInboundAt ?? null,
|
||||
lastOutboundAt: runtime?.lastOutboundAt ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildComputedAccountStatusSnapshot(params: {
|
||||
accountId: string;
|
||||
name?: string;
|
||||
enabled?: boolean;
|
||||
configured?: boolean;
|
||||
runtime?: RuntimeLifecycleSnapshot | null;
|
||||
probe?: unknown;
|
||||
}) {
|
||||
const { accountId, name, enabled, configured, runtime, probe } = params;
|
||||
return buildBaseAccountStatusSnapshot({
|
||||
account: {
|
||||
accountId,
|
||||
name,
|
||||
enabled,
|
||||
configured,
|
||||
},
|
||||
runtime,
|
||||
probe,
|
||||
});
|
||||
}
|
||||
|
||||
export function buildRuntimeAccountStatusSnapshot(params: {
|
||||
runtime?: RuntimeLifecycleSnapshot | null;
|
||||
probe?: unknown;
|
||||
}) {
|
||||
const { runtime, probe } = params;
|
||||
return {
|
||||
running: runtime?.running ?? false,
|
||||
lastStartAt: runtime?.lastStartAt ?? null,
|
||||
lastStopAt: runtime?.lastStopAt ?? null,
|
||||
lastError: runtime?.lastError ?? null,
|
||||
probe,
|
||||
lastInboundAt: runtime?.lastInboundAt ?? null,
|
||||
lastOutboundAt: runtime?.lastOutboundAt ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user