mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 05:41:24 +00:00
refactor: remove bash pty mode
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { readConfigFileSnapshot, writeConfigFile } from "../config/config.js";
|
||||
import {
|
||||
connectOk,
|
||||
installGatewayTestHooks,
|
||||
@@ -64,6 +63,9 @@ describe("gateway server providers", () => {
|
||||
test("telegram.logout clears bot token from config", async () => {
|
||||
const prevToken = process.env.TELEGRAM_BOT_TOKEN;
|
||||
delete process.env.TELEGRAM_BOT_TOKEN;
|
||||
const { readConfigFileSnapshot, writeConfigFile } = await import(
|
||||
"../config/config.js"
|
||||
);
|
||||
await writeConfigFile({
|
||||
telegram: {
|
||||
botToken: "123:abc",
|
||||
|
||||
@@ -86,6 +86,11 @@ import {
|
||||
authorizeGatewayConnect,
|
||||
type ResolvedGatewayAuth,
|
||||
} from "./auth.js";
|
||||
import {
|
||||
type GatewayReloadPlan,
|
||||
type ProviderKind,
|
||||
startGatewayConfigReloader,
|
||||
} from "./config-reload.js";
|
||||
import { normalizeControlUiBasePath } from "./control-ui.js";
|
||||
import { resolveHooksConfig } from "./hooks.js";
|
||||
import {
|
||||
@@ -94,13 +99,12 @@ import {
|
||||
resolveGatewayBindHost,
|
||||
} from "./net.js";
|
||||
import { createBridgeHandlers } from "./server-bridge.js";
|
||||
import { createBridgeSubscriptionManager } from "./server-bridge-subscriptions.js";
|
||||
import { startBrowserControlServerIfEnabled } from "./server-browser.js";
|
||||
import {
|
||||
startGatewayConfigReloader,
|
||||
type GatewayReloadPlan,
|
||||
type ProviderKind,
|
||||
} from "./config-reload.js";
|
||||
type BridgeListConnectedFn,
|
||||
type BridgeSendEventFn,
|
||||
createBridgeSubscriptionManager,
|
||||
} from "./server-bridge-subscriptions.js";
|
||||
import { startBrowserControlServerIfEnabled } from "./server-browser.js";
|
||||
import { createAgentEventHandler, createChatRunState } from "./server-chat.js";
|
||||
import {
|
||||
DEDUPE_MAX,
|
||||
@@ -862,6 +866,11 @@ export async function startGatewayServer(
|
||||
const bridgeSubscribe = bridgeSubscriptions.subscribe;
|
||||
const bridgeUnsubscribe = bridgeSubscriptions.unsubscribe;
|
||||
const bridgeUnsubscribeAll = bridgeSubscriptions.unsubscribeAll;
|
||||
const bridgeSendEvent: BridgeSendEventFn = (opts) => {
|
||||
bridge?.sendEvent(opts);
|
||||
};
|
||||
const bridgeListConnected: BridgeListConnectedFn = () =>
|
||||
bridge?.listConnected() ?? [];
|
||||
const bridgeSendToSession = (
|
||||
sessionKey: string,
|
||||
event: string,
|
||||
@@ -871,20 +880,16 @@ export async function startGatewayServer(
|
||||
sessionKey,
|
||||
event,
|
||||
payload,
|
||||
bridge ? (opts) => bridge.sendEvent(opts) : undefined,
|
||||
bridgeSendEvent,
|
||||
);
|
||||
const bridgeSendToAllSubscribed = (event: string, payload: unknown) =>
|
||||
bridgeSubscriptions.sendToAllSubscribed(
|
||||
event,
|
||||
payload,
|
||||
bridge ? (opts) => bridge.sendEvent(opts) : undefined,
|
||||
);
|
||||
bridgeSubscriptions.sendToAllSubscribed(event, payload, bridgeSendEvent);
|
||||
const bridgeSendToAllConnected = (event: string, payload: unknown) =>
|
||||
bridgeSubscriptions.sendToAllConnected(
|
||||
event,
|
||||
payload,
|
||||
bridge ? () => bridge.listConnected() : undefined,
|
||||
bridge ? (opts) => bridge.sendEvent(opts) : undefined,
|
||||
bridgeListConnected,
|
||||
bridgeSendEvent,
|
||||
);
|
||||
|
||||
const broadcastVoiceWakeChanged = (triggers: string[]) => {
|
||||
@@ -1663,7 +1668,9 @@ export async function startGatewayServer(
|
||||
|
||||
if (plan.restartProviders.size > 0) {
|
||||
if (process.env.CLAWDIS_SKIP_PROVIDERS === "1") {
|
||||
logProviders.info("skipping provider reload (CLAWDIS_SKIP_PROVIDERS=1)");
|
||||
logProviders.info(
|
||||
"skipping provider reload (CLAWDIS_SKIP_PROVIDERS=1)",
|
||||
);
|
||||
} else {
|
||||
const restartProvider = async (
|
||||
name: ProviderKind,
|
||||
@@ -1712,10 +1719,7 @@ export async function startGatewayServer(
|
||||
}
|
||||
}
|
||||
|
||||
setCommandLaneConcurrency(
|
||||
"cron",
|
||||
nextConfig.cron?.maxConcurrentRuns ?? 1,
|
||||
);
|
||||
setCommandLaneConcurrency("cron", nextConfig.cron?.maxConcurrentRuns ?? 1);
|
||||
setCommandLaneConcurrency("main", nextConfig.agent?.maxConcurrent ?? 1);
|
||||
|
||||
if (plan.hotReasons.length > 0) {
|
||||
|
||||
@@ -4,7 +4,6 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, expect, vi } from "vitest";
|
||||
import { WebSocket } from "ws";
|
||||
import { agentCommand } from "../commands/agent.js";
|
||||
import { resetAgentRunContextForTest } from "../infra/agent-events.js";
|
||||
import { drainSystemEvents, peekSystemEvents } from "../infra/system-events.js";
|
||||
import { rawDataToString } from "../infra/ws.js";
|
||||
@@ -64,6 +63,7 @@ const hoisted = vi.hoisted(() => ({
|
||||
}>,
|
||||
},
|
||||
cronIsolatedRun: vi.fn(async () => ({ status: "ok", summary: "ok" })),
|
||||
agentCommand: vi.fn().mockResolvedValue(undefined),
|
||||
testIsNixMode: { value: false },
|
||||
sessionStoreSaveDelayMs: { value: 0 },
|
||||
}));
|
||||
@@ -75,6 +75,7 @@ export const bridgeSendEvent = hoisted.bridgeSendEvent;
|
||||
export const testTailnetIPv4 = hoisted.testTailnetIPv4;
|
||||
export const piSdkMock = hoisted.piSdkMock;
|
||||
export const cronIsolatedRun = hoisted.cronIsolatedRun;
|
||||
export const agentCommand = hoisted.agentCommand;
|
||||
|
||||
export const testState = {
|
||||
sessionStorePath: undefined as string | undefined,
|
||||
@@ -290,7 +291,7 @@ vi.mock("../web/outbound.js", () => ({
|
||||
.mockResolvedValue({ messageId: "msg-1", toJid: "jid-1" }),
|
||||
}));
|
||||
vi.mock("../commands/agent.js", () => ({
|
||||
agentCommand: vi.fn().mockResolvedValue(undefined),
|
||||
agentCommand,
|
||||
}));
|
||||
|
||||
process.env.CLAWDIS_SKIP_PROVIDERS = "1";
|
||||
@@ -509,5 +510,3 @@ export async function waitForSystemEvent(timeoutMs = 2000) {
|
||||
}
|
||||
throw new Error("timeout waiting for system event");
|
||||
}
|
||||
|
||||
export { agentCommand };
|
||||
|
||||
Reference in New Issue
Block a user