mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 15:30:39 +00:00
34 lines
1006 B
TypeScript
34 lines
1006 B
TypeScript
import type {
|
|
ChannelAccountSnapshot,
|
|
ChannelGatewayContext,
|
|
OpenClawConfig,
|
|
} from "openclaw/plugin-sdk/test-utils";
|
|
import { vi } from "vitest";
|
|
import { createRuntimeEnv } from "./runtime-env.js";
|
|
|
|
export function createStartAccountContext<TAccount extends { accountId: string }>(params: {
|
|
account: TAccount;
|
|
abortSignal: AbortSignal;
|
|
statusPatchSink?: (next: ChannelAccountSnapshot) => void;
|
|
}): ChannelGatewayContext<TAccount> {
|
|
const snapshot: ChannelAccountSnapshot = {
|
|
accountId: params.account.accountId,
|
|
configured: true,
|
|
enabled: true,
|
|
running: false,
|
|
};
|
|
return {
|
|
accountId: params.account.accountId,
|
|
account: params.account,
|
|
cfg: {} as OpenClawConfig,
|
|
runtime: createRuntimeEnv(),
|
|
abortSignal: params.abortSignal,
|
|
log: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
|
|
getStatus: () => snapshot,
|
|
setStatus: (next) => {
|
|
Object.assign(snapshot, next);
|
|
params.statusPatchSink?.(snapshot);
|
|
},
|
|
};
|
|
}
|