openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
86 lines (85 loc) • 3.58 kB
JavaScript
import { r as normalizeEnv } from "./env-HehwidXj.mjs";
import { n as parseCliProfileArgs, t as applyCliProfileEnv } from "./profile-TAKKDhQt.mjs";
import { t as isMainModule } from "./is-main-DHs8alyJ.mjs";
import { i as ensureOpenClawExecMarkerOnProcess } from "./openclaw-exec-env-BPYcT7Dr.mjs";
import { t as installProcessWarningFilter } from "./warning-filter-DRoUNq4c.mjs";
import { r as defaultRuntime } from "./runtime-B-SLYP-m.mjs";
import { t as enableConsoleCapture } from "./console-BkI11Tqj.mjs";
import { o as withCliProcessScope } from "./runtime-cleanup-scope-DuOL68nJ.mjs";
import "./logging-FPYEZPak.mjs";
import { a as withConsoleLogsRoutedToStderrForJson } from "./json-output-mode-DSme4Xvd.mjs";
import { t as closeCliResources } from "./runtime-cleanup-BKu6ZJ6-.mjs";
import { i as runCliWithExitFinalization } from "./one-shot-exit-DkbGSQD5.mjs";
import { t as assertSupportedRuntime } from "./runtime-guard-BiEisZ4L.mjs";
import { t as resolveCliStartupPolicy } from "./command-startup-policy-z6i1gNVg.mjs";
import { t as withCliPluginInvocation } from "./run-main-plugin-cache-BBtqqzcy.mjs";
import { n as ensureCliExecutionBootstrap } from "./command-execution-startup-CNYA-PPs.mjs";
import { t as loadCliDotEnv } from "./dotenv-RXCNDj1p.mjs";
import { n as createNodeWorkerCommand } from "./command-options-pF05i-p6.mjs";
import { t as runNodeHostWorker } from "./worker-74Xw50hr.mjs";
import process from "node:process";
import { fileURLToPath } from "node:url";
//#region src/node-host/mac-worker-entry.ts
const COMMAND_PATH = ["node", "worker"];
function resolveMacNodeWorkerArgv(e) {
const t = parseCliProfileArgs(e);
if (!t.ok) throw new Error(t.error);
const n = t.argv.slice(2);
const r = createNodeWorkerCommand();
const i = r.parseOptions(n.slice(COMMAND_PATH.length));
if (!COMMAND_PATH.every((e, t) => n[t] === e) || i.operands.length || i.unknown.length) throw new Error("Private macOS worker accepts only: node worker");
return {
argv: t.argv,
profile: t.profile,
desktopSharingEnabled: r.opts().desktopSharing
};
}
async function runMacNodeWorkerEntry(e = process.argv) {
const t = resolveMacNodeWorkerArgv(e);
process.title = "openclaw-node-worker";
ensureOpenClawExecMarkerOnProcess();
installProcessWarningFilter();
normalizeEnv();
if (t.profile) applyCliProfileEnv({ profile: t.profile });
loadCliDotEnv();
enableConsoleCapture();
await assertSupportedRuntime(void 0, void 0, t.argv, true, { ...process.env });
const n = resolveCliStartupPolicy({
argv: t.argv,
commandPath: [...COMMAND_PATH],
jsonOutputMode: false,
machineOutputMode: true
});
await withConsoleLogsRoutedToStderrForJson(t.argv, async () => {
await ensureCliExecutionBootstrap({
runtime: defaultRuntime,
commandPath: [...COMMAND_PATH],
startupPolicy: n
});
await runNodeHostWorker({ desktopSharingEnabled: t.desktopSharingEnabled });
}, {
machineOutput: true,
retainRoutingUntilProcessExit: true
});
}
if (isMainModule({ currentFile: fileURLToPath(import.meta.url) })) await runCliWithExitFinalization({
run: () => withCliProcessScope(() => withCliPluginInvocation(false, async (e) => {
const t = e?.pluginResources;
try {
await (t ? t.run(() => runMacNodeWorkerEntry()) : runMacNodeWorkerEntry());
} finally {
try {
await closeCliResources(e);
} finally {
await t?.release();
}
}
})),
onError: (e) => {
process.stderr.write(`${e instanceof Error ? e.message : String(e)}\n`);
process.exitCode = 1;
}
});
//#endregion
export { resolveMacNodeWorkerArgv };