mirror of https://github.com/openclaw/openclaw.git
refactor: route telegram env helpers through runtime-env
This commit is contained in:
parent
d027b442af
commit
6b4d097b25
|
|
@ -10,13 +10,12 @@ import {
|
|||
resolveAccountWithDefaultFallback,
|
||||
type OpenClawConfig,
|
||||
} from "openclaw/plugin-sdk/account-resolution";
|
||||
import { isTruthyEnvValue } from "openclaw/plugin-sdk/infra-runtime";
|
||||
import {
|
||||
listBoundAccountIds,
|
||||
resolveDefaultAgentBoundAccountId,
|
||||
} from "openclaw/plugin-sdk/routing";
|
||||
import { formatSetExplicitDefaultInstruction } from "openclaw/plugin-sdk/routing";
|
||||
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
|
||||
import { createSubsystemLogger, isTruthyEnvValue } from "openclaw/plugin-sdk/runtime-env";
|
||||
import type { TelegramAccountConfig, TelegramActionConfig } from "../runtime-api.js";
|
||||
import { resolveTelegramToken } from "./token.js";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,22 @@
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { TelegramNetworkConfig } from "../../../src/config/types.telegram.js";
|
||||
|
||||
vi.mock("openclaw/plugin-sdk/infra-runtime", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/infra-runtime")>();
|
||||
vi.mock("openclaw/plugin-sdk/runtime-env", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/runtime-env")>();
|
||||
return {
|
||||
...actual,
|
||||
isWSL2Sync: vi.fn(() => false),
|
||||
};
|
||||
});
|
||||
|
||||
let isWSL2Sync: typeof import("openclaw/plugin-sdk/infra-runtime").isWSL2Sync;
|
||||
let isWSL2Sync: typeof import("openclaw/plugin-sdk/runtime-env").isWSL2Sync;
|
||||
let resetTelegramNetworkConfigStateForTests: typeof import("./network-config.js").resetTelegramNetworkConfigStateForTests;
|
||||
let resolveTelegramAutoSelectFamilyDecision: typeof import("./network-config.js").resolveTelegramAutoSelectFamilyDecision;
|
||||
let resolveTelegramDnsResultOrderDecision: typeof import("./network-config.js").resolveTelegramDnsResultOrderDecision;
|
||||
|
||||
async function loadModule() {
|
||||
vi.resetModules();
|
||||
({ isWSL2Sync } = await import("openclaw/plugin-sdk/infra-runtime"));
|
||||
({ isWSL2Sync } = await import("openclaw/plugin-sdk/runtime-env"));
|
||||
({
|
||||
resetTelegramNetworkConfigStateForTests,
|
||||
resolveTelegramAutoSelectFamilyDecision,
|
||||
|
|
@ -132,7 +132,7 @@ describe("resolveTelegramAutoSelectFamilyDecision", () => {
|
|||
},
|
||||
])("$name", ({ env, network, expected, wsl2 = true }) => {
|
||||
if (!isWSL2Sync) {
|
||||
throw new Error("infra-runtime mock not loaded");
|
||||
throw new Error("runtime-env mock not loaded");
|
||||
}
|
||||
vi.mocked(isWSL2Sync).mockReturnValue(wsl2);
|
||||
const decision = resolveTelegramAutoSelectFamilyDecision({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import process from "node:process";
|
||||
import type { TelegramNetworkConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import { isTruthyEnvValue } from "openclaw/plugin-sdk/infra-runtime";
|
||||
import { isWSL2Sync } from "openclaw/plugin-sdk/infra-runtime";
|
||||
import { isTruthyEnvValue, isWSL2Sync } from "openclaw/plugin-sdk/runtime-env";
|
||||
|
||||
export const TELEGRAM_DISABLE_AUTO_SELECT_FAMILY_ENV =
|
||||
"OPENCLAW_TELEGRAM_DISABLE_AUTO_SELECT_FAMILY";
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ export {
|
|||
success,
|
||||
warn,
|
||||
} from "../globals.js";
|
||||
export { isTruthyEnvValue } from "../infra/env.js";
|
||||
export * from "../logging.js";
|
||||
export { waitForAbortSignal } from "../infra/abort-signal.js";
|
||||
export { retryAsync } from "../infra/retry.js";
|
||||
|
|
|
|||
Loading…
Reference in New Issue