
















@@ -227,7 +227,7 @@ function unwrapRpcPayload(raw) {
227227}
228228229229async function rpcCall(method, params, options) {
230-const { callGateway } = await loadCallGatewayModule();
230+const { callGateway } = await loadCallGatewayModule(options.runner);
231231const payload = await callGateway({
232232config: readJson(options.env.OPENCLAW_CONFIG_PATH),
233233configPath: options.env.OPENCLAW_CONFIG_PATH,
@@ -241,27 +241,35 @@ async function rpcCall(method, params, options) {
241241return unwrapRpcPayload(payload);
242242}
243243244-async function loadCallGatewayModule() {
245-callGatewayModulePromise ??= importCallGatewayModule();
244+async function loadCallGatewayModule(runner) {
245+callGatewayModulePromise ??= importCallGatewayModule(runner);
246246return callGatewayModulePromise;
247247}
248248249-async function importCallGatewayModule() {
249+async function importCallGatewayModule(runner) {
250+if (!usesPackagedOpenClawEntry(runner)) {
251+return import(pathToFileURL(path.join(process.cwd(), "src/gateway/call.ts")).href);
252+}
250253const distDir = path.join(process.cwd(), "dist");
251-if (fs.existsSync(distDir)) {
252-const candidates = fs
253-.readdirSync(distDir)
254-.filter((name) => /^call(?:\.runtime)?-[A-Za-z0-9_-]+\.js$/u.test(name))
255-.toSorted((left, right) => left.localeCompare(right));
256-for (const name of candidates) {
257- const module = await import(pathToFileURL(path.join(distDir, name)).href);
258- if (typeof module.callGateway === "function") {
259- return module;
260-}
254+const candidates = fs.existsSync(distDir)
255+? fs
256+ .readdirSync(distDir)
257+ .filter((name) => /^call(?:\.runtime)?-[A-Za-z0-9_-]+\.js$/u.test(name))
258+ .toSorted((left, right) => left.localeCompare(right))
259+: [];
260+for (const name of candidates) {
261+const module = await import(pathToFileURL(path.join(distDir, name)).href);
262+if (typeof module.callGateway === "function") {
263+return module;
261264}
262-throw new Error(`unable to find callGateway export in dist (${candidates.join(", ")})`);
263265}
264-return import(pathToFileURL(path.join(process.cwd(), "src/gateway/call.ts")).href);
266+throw new Error(`unable to find callGateway export in dist (${candidates.join(", ")})`);
267+}
268+269+function usesPackagedOpenClawEntry(runner) {
270+return Boolean(
271+process.env.OPENCLAW_ENTRY && runner?.baseArgs?.[0] === process.env.OPENCLAW_ENTRY,
272+);
265273}
266274267275async function retryRpcCall(method, params, options) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。