mirror of https://github.com/openclaw/openclaw.git
refactor: share extension monitor runtime setup
This commit is contained in:
parent
6decaebcf2
commit
1ac4bac8b1
|
|
@ -1,4 +1,5 @@
|
|||
import { createLoggerBackedRuntime, type RuntimeEnv } from "openclaw/plugin-sdk/irc";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk/irc";
|
||||
import { resolveLoggerBackedRuntime } from "../../shared/runtime.js";
|
||||
import { resolveIrcAccount } from "./accounts.js";
|
||||
import { connectIrcClient, type IrcClient } from "./client.js";
|
||||
import { buildIrcConnectOptions } from "./connect-options.js";
|
||||
|
|
@ -39,12 +40,10 @@ export async function monitorIrcProvider(opts: IrcMonitorOptions): Promise<{ sto
|
|||
accountId: opts.accountId,
|
||||
});
|
||||
|
||||
const runtime: RuntimeEnv =
|
||||
opts.runtime ??
|
||||
createLoggerBackedRuntime({
|
||||
logger: core.logging.getChildLogger(),
|
||||
exitError: () => new Error("Runtime exit not available"),
|
||||
});
|
||||
const runtime: RuntimeEnv = resolveLoggerBackedRuntime(
|
||||
opts.runtime,
|
||||
core.logging.getChildLogger(),
|
||||
);
|
||||
|
||||
if (!account.configured) {
|
||||
throw new Error(
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import { createServer, type IncomingMessage, type Server, type ServerResponse } from "node:http";
|
||||
import os from "node:os";
|
||||
import {
|
||||
createLoggerBackedRuntime,
|
||||
type RuntimeEnv,
|
||||
isRequestBodyLimitError,
|
||||
readRequestBodyWithLimit,
|
||||
requestBodyErrorToText,
|
||||
} from "openclaw/plugin-sdk/nextcloud-talk";
|
||||
import { resolveLoggerBackedRuntime } from "../../shared/runtime.js";
|
||||
import { resolveNextcloudTalkAccount } from "./accounts.js";
|
||||
import { handleNextcloudTalkInbound } from "./inbound.js";
|
||||
import { createNextcloudTalkReplayGuard } from "./replay-guard.js";
|
||||
|
|
@ -318,12 +318,10 @@ export async function monitorNextcloudTalkProvider(
|
|||
cfg,
|
||||
accountId: opts.accountId,
|
||||
});
|
||||
const runtime: RuntimeEnv =
|
||||
opts.runtime ??
|
||||
createLoggerBackedRuntime({
|
||||
logger: core.logging.getChildLogger(),
|
||||
exitError: () => new Error("Runtime exit not available"),
|
||||
});
|
||||
const runtime: RuntimeEnv = resolveLoggerBackedRuntime(
|
||||
opts.runtime,
|
||||
core.logging.getChildLogger(),
|
||||
);
|
||||
|
||||
if (!account.secret) {
|
||||
throw new Error(`Nextcloud Talk bot secret not configured for account "${account.accountId}"`);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import { createLoggerBackedRuntime } from "openclaw/plugin-sdk";
|
||||
|
||||
export function resolveLoggerBackedRuntime<TRuntime>(
|
||||
runtime: TRuntime | undefined,
|
||||
logger: Parameters<typeof createLoggerBackedRuntime>[0]["logger"],
|
||||
): TRuntime {
|
||||
return (
|
||||
runtime ??
|
||||
(createLoggerBackedRuntime({
|
||||
logger,
|
||||
exitError: () => new Error("Runtime exit not available"),
|
||||
}) as TRuntime)
|
||||
);
|
||||
}
|
||||
Loading…
Reference in New Issue