mirror of
https://github.com/hanzoai/bot.git
synced 2026-11-02 20:15:14 +00:00
The -X ours merge strategy corrupted ~55 files by mixing our code with upstream structural changes. Restored correct versions from the rebrand bridge branch which has properly-rebranded upstream code. Also includes: lint error fixes for agent.acp.test, cron.ts, channels intent test, Android duplicate declarations, and missing imports.
30 lines
973 B
TypeScript
30 lines
973 B
TypeScript
import type { ChannelAccountSnapshot, ChannelGatewayContext, BotConfig } from "bot/plugin-sdk";
|
|
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 BotConfig,
|
|
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);
|
|
},
|
|
};
|
|
}
|