-
-
Notifications
You must be signed in to change notification settings - Fork 76.2k
Expand file tree
/
Copy pathrun-main.ts
More file actions
688 lines (643 loc) · 22 KB
/
run-main.ts
File metadata and controls
688 lines (643 loc) · 22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
import { existsSync } from "node:fs";
import path from "node:path";
import process from "node:process";
import { fileURLToPath } from "node:url";
import { resolveStateDir } from "../config/paths.js";
import type { OpenClawConfig } from "../config/types.openclaw.js";
import { isTruthyEnvValue, normalizeEnv } from "../infra/env.js";
import { isMainModule } from "../infra/is-main.js";
import type { ProxyHandle } from "../infra/net/proxy/proxy-lifecycle.js";
import { ensureOpenClawCliOnPath } from "../infra/path-env.js";
import { assertSupportedRuntime } from "../infra/runtime-guard.js";
import type { PluginManifestCommandAliasRegistry } from "../plugins/manifest-command-aliases.js";
import { normalizeOptionalString } from "../shared/string-coerce.js";
import { resolveCliArgvInvocation } from "./argv-invocation.js";
import {
isReservedNonPluginCommandRoot,
shouldRegisterPrimaryCommandOnly,
shouldSkipPluginCommandRegistration,
} from "./command-registration-policy.js";
import { maybeRunCliInContainer, parseCliContainerArgs } from "./container-target.js";
import {
consumeGatewayFastPathRootOptionToken,
consumeGatewayRunOptionToken,
} from "./gateway-run-argv.js";
import { applyCliProfileEnv, parseCliProfileArgs } from "./profile.js";
import { getCoreCliCommandNames } from "./program/core-command-descriptors.js";
import { getSubCliEntries } from "./program/subcli-descriptors.js";
import {
resolveMissingPluginCommandMessage as resolveMissingPluginCommandMessageFromPolicy,
rewriteUpdateFlagArgv,
shouldEnsureCliPath,
shouldStartCrestodianForBareRoot,
shouldStartCrestodianForModernOnboard,
shouldStartProxyForCli,
shouldUseBrowserHelpFastPath,
shouldUseRootHelpFastPath,
} from "./run-main-policy.js";
import { normalizeWindowsArgv } from "./windows-argv.js";
export {
rewriteUpdateFlagArgv,
shouldEnsureCliPath,
shouldStartCrestodianForBareRoot,
shouldStartCrestodianForModernOnboard,
shouldStartProxyForCli,
shouldUseBrowserHelpFastPath,
shouldUseRootHelpFastPath,
} from "./run-main-policy.js";
type Awaitable<T> = T | Promise<T>;
const CLI_PROXY_ENV_KEYS = [
"HTTP_PROXY",
"HTTPS_PROXY",
"ALL_PROXY",
"http_proxy",
"https_proxy",
"all_proxy",
] as const;
function createGatewayCliMainStartupTrace(argv: string[]) {
const enabled =
isTruthyEnvValue(process.env.OPENCLAW_GATEWAY_STARTUP_TRACE) &&
argv.slice(2).includes("gateway");
const started = performance.now();
let last = started;
const emit = (name: string, durationMs: number, totalMs: number) => {
if (!enabled) {
return;
}
process.stderr.write(
`[gateway] startup trace: cli.main.${name} ${durationMs.toFixed(1)}ms total=${totalMs.toFixed(1)}ms\n`,
);
};
return {
mark(name: string) {
const now = performance.now();
emit(name, now - last, now - started);
last = now;
},
async measure<T>(name: string, run: () => Awaitable<T>): Promise<T> {
const before = performance.now();
try {
return await run();
} finally {
const now = performance.now();
emit(name, now - before, now - started);
last = now;
}
},
};
}
export function isGatewayRunFastPathArgv(argv: string[]): boolean {
const invocation = resolveCliArgvInvocation(argv);
if (invocation.hasHelpOrVersion) {
return false;
}
const args = argv.slice(2);
let sawGateway = false;
let sawRun = false;
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
if (!arg || arg === "--") {
return false;
}
if (!sawGateway) {
const consumed = consumeGatewayFastPathRootOptionToken(args, index);
if (consumed > 0) {
index += consumed - 1;
continue;
}
if (arg !== "gateway") {
return false;
}
sawGateway = true;
continue;
}
const consumed = consumeGatewayRunOptionToken(args, index);
if (consumed > 0) {
index += consumed - 1;
continue;
}
if (!sawRun && arg === "run") {
sawRun = true;
continue;
}
return false;
}
return sawGateway;
}
function hasJsonOutputFlag(argv: string[]): boolean {
return argv.some((arg) => arg === "--json" || arg.startsWith("--json="));
}
async function tryRunGatewayRunFastPath(
argv: string[],
startupTrace: ReturnType<typeof createGatewayCliMainStartupTrace>,
): Promise<boolean> {
if (!isGatewayRunFastPathArgv(argv)) {
return false;
}
const [
{ Command },
{ addGatewayRunCommand },
{ VERSION },
{ emitCliBanner },
{ resolveCliStartupPolicy },
] = await startupTrace.measure("gateway-run-imports", () =>
Promise.all([
import("commander"),
import("./gateway-cli/run.js"),
import("../version.js"),
import("./banner.js"),
import("./command-startup-policy.js"),
]),
);
const invocation = resolveCliArgvInvocation(argv);
const startupPolicy = resolveCliStartupPolicy({
commandPath: invocation.commandPath,
jsonOutputMode: hasJsonOutputFlag(argv),
routeMode: true,
});
if (!startupPolicy.hideBanner) {
emitCliBanner(VERSION, { argv });
}
const program = new Command();
program.name("openclaw");
program.enablePositionalOptions();
program.option("--no-color", "Disable ANSI colors", false);
program.exitOverride((err) => {
process.exitCode = typeof err.exitCode === "number" ? err.exitCode : 1;
throw err;
});
const gateway = addGatewayRunCommand(
program.command("gateway").description("Run, inspect, and query the WebSocket Gateway"),
);
addGatewayRunCommand(
gateway.command("run").description("Run the WebSocket Gateway (foreground)"),
);
try {
await startupTrace.measure("gateway-run-parse", () => program.parseAsync(argv));
} catch (error) {
if (!isCommanderParseExit(error)) {
throw error;
}
process.exitCode = error.exitCode;
}
return true;
}
async function closeCliMemoryManagers(): Promise<void> {
try {
const { hasMemoryRuntime } = await import("../plugins/memory-state.js");
if (!hasMemoryRuntime()) {
return;
}
const { closeActiveMemorySearchManagers } = await import("../plugins/memory-runtime.js");
await closeActiveMemorySearchManagers();
} catch {
// Best-effort teardown for short-lived CLI processes. Package updates can
// replace hashed chunks before this finalizer runs.
}
}
export function resolveMissingPluginCommandMessage(
pluginId: string,
config?: OpenClawConfig,
options?: { registry?: PluginManifestCommandAliasRegistry },
): string | null {
return resolveMissingPluginCommandMessageFromPolicy(
pluginId,
config,
options?.registry ? { registry: options.registry } : undefined,
);
}
function shouldLoadCliDotEnv(env: NodeJS.ProcessEnv = process.env): boolean {
if (existsSync(path.join(process.cwd(), ".env"))) {
return true;
}
return existsSync(path.join(resolveStateDir(env), ".env"));
}
function isCommanderParseExit(error: unknown): error is { exitCode: number } {
if (!error || typeof error !== "object") {
return false;
}
const candidate = error as { code?: unknown; exitCode?: unknown };
return (
typeof candidate.exitCode === "number" &&
Number.isInteger(candidate.exitCode) &&
typeof candidate.code === "string" &&
candidate.code.startsWith("commander.")
);
}
async function ensureCliEnvProxyDispatcher(): Promise<void> {
try {
const { hasEnvHttpProxyAgentConfigured } = await import("../infra/net/proxy-env.js");
if (!hasEnvHttpProxyAgentConfigured()) {
return;
}
const { ensureGlobalUndiciEnvProxyDispatcher } =
await import("../infra/net/undici-global-dispatcher.js");
ensureGlobalUndiciEnvProxyDispatcher();
} catch {
// Best-effort proxy bootstrap; CLI startup should continue without it.
}
}
function shouldBootstrapCliProxyBeforeFastPath(env: NodeJS.ProcessEnv = process.env): boolean {
if (
isTruthyEnvValue(env.OPENCLAW_DEBUG_PROXY_ENABLED) ||
isTruthyEnvValue(env.OPENCLAW_DEBUG_PROXY_REQUIRE)
) {
return true;
}
return CLI_PROXY_ENV_KEYS.some((key) => {
const value = env[key];
return typeof value === "string" && value.trim().length > 0;
});
}
function isKnownBuiltInCommandRoot(primary: string): boolean {
return (
getCoreCliCommandNames().includes(primary) ||
getSubCliEntries().some((entry) => entry.name === primary)
);
}
async function isPluginCliRoot(params: {
primary: string;
config: OpenClawConfig;
}): Promise<boolean | null> {
try {
const { resolvePluginCliRootOwnerIds } = await import("../plugins/cli-registry-loader.js");
const ownerIds = await resolvePluginCliRootOwnerIds({
cfg: params.config,
env: process.env,
primaryCommand: params.primary,
});
return ownerIds === null ? null : ownerIds.length > 0;
} catch {
return null;
}
}
async function resolveUnownedCliPrimary(params: {
argv: string[];
config: OpenClawConfig;
}): Promise<string | null> {
const invocation = resolveCliArgvInvocation(rewriteUpdateFlagArgv(params.argv));
const { primary } = invocation;
if (
invocation.hasHelpOrVersion ||
!primary ||
primary === "help" ||
isReservedNonPluginCommandRoot(primary) ||
isKnownBuiltInCommandRoot(primary)
) {
return null;
}
const pluginRoot = await isPluginCliRoot({ primary, config: params.config });
if (pluginRoot !== false) {
return null;
}
return primary;
}
async function bootstrapCliProxyCaptureAndDispatcher(
startupTrace: ReturnType<typeof createGatewayCliMainStartupTrace>,
options: { ensureDispatcher?: boolean } = {},
): Promise<void> {
const [
{ initializeDebugProxyCapture, finalizeDebugProxyCapture },
{ maybeWarnAboutDebugProxyCoverage },
] = await startupTrace.measure("proxy-imports", () =>
Promise.all([import("../proxy-capture/runtime.js"), import("../proxy-capture/coverage.js")]),
);
initializeDebugProxyCapture("cli");
process.once("exit", () => {
finalizeDebugProxyCapture();
});
if (options.ensureDispatcher !== false) {
await startupTrace.measure("proxy-dispatcher", () => ensureCliEnvProxyDispatcher());
}
maybeWarnAboutDebugProxyCoverage();
}
export async function runCli(argv: string[] = process.argv) {
const originalArgv = normalizeWindowsArgv(argv);
const startupTrace = createGatewayCliMainStartupTrace(originalArgv);
const parsedContainer = parseCliContainerArgs(originalArgv);
if (!parsedContainer.ok) {
throw new Error(parsedContainer.error);
}
const parsedProfile = parseCliProfileArgs(parsedContainer.argv);
if (!parsedProfile.ok) {
throw new Error(parsedProfile.error);
}
if (parsedProfile.profile) {
applyCliProfileEnv({ profile: parsedProfile.profile });
}
const containerTargetName =
parsedContainer.container ?? normalizeOptionalString(process.env.OPENCLAW_CONTAINER) ?? null;
if (containerTargetName && parsedProfile.profile) {
throw new Error("--container cannot be combined with --profile/--dev");
}
const containerTarget = maybeRunCliInContainer(originalArgv);
if (containerTarget.handled) {
if (containerTarget.exitCode !== 0) {
process.exitCode = containerTarget.exitCode;
}
return;
}
let normalizedArgv = parsedProfile.argv;
startupTrace.mark("argv");
if (shouldLoadCliDotEnv()) {
await startupTrace.measure("dotenv", async () => {
const { loadCliDotEnv } = await import("./dotenv.js");
loadCliDotEnv({ quiet: true });
});
}
normalizeEnv();
if (shouldEnsureCliPath(normalizedArgv)) {
ensureOpenClawCliOnPath();
}
// Enforce the minimum supported runtime before doing any work.
assertSupportedRuntime();
// Activate operator-managed proxy routing for network-capable commands.
// Local Gateway/control-plane commands keep direct loopback access while
// runtime, provider, plugin, update, and manifest/metadata-owned plugin commands route egress.
let proxyHandle: ProxyHandle | null = null;
let bestEffortConfigPromise: Promise<OpenClawConfig> | null = null;
const readBestEffortCliConfig = async (): Promise<OpenClawConfig> => {
if (!bestEffortConfigPromise) {
bestEffortConfigPromise = import("../config/io.js").then(({ readBestEffortConfig }) =>
readBestEffortConfig(),
);
}
return await bestEffortConfigPromise;
};
const stopStartedProxy = async () => {
const handle = proxyHandle;
proxyHandle = null;
if (handle) {
const { stopProxy } = await import("../infra/net/proxy/proxy-lifecycle.js");
await stopProxy(handle);
}
};
const killStartedProxy = () => {
const handle = proxyHandle;
proxyHandle = null;
handle?.kill("SIGTERM");
};
if (shouldStartProxyForCli(normalizedArgv)) {
const config = await readBestEffortCliConfig();
const unownedPrimary = await resolveUnownedCliPrimary({ argv: normalizedArgv, config });
if (unownedPrimary) {
throw new Error(
`Unknown command: openclaw ${unownedPrimary}. No built-in command or plugin CLI metadata owns "${unownedPrimary}".`,
);
}
const { startProxy } = await import("../infra/net/proxy/proxy-lifecycle.js");
proxyHandle = await startProxy(config?.proxy ?? undefined);
}
let onSigterm: (() => void) | null = null;
let onSigint: (() => void) | null = null;
let onExit: (() => void) | null = null;
if (proxyHandle) {
const shutdown = (exitCode: number) => {
if (onSigterm) {
process.off("SIGTERM", onSigterm);
}
if (onSigint) {
process.off("SIGINT", onSigint);
}
void stopStartedProxy().finally(() => {
process.exit(exitCode);
});
};
onSigterm = () => shutdown(143);
onSigint = () => shutdown(130);
onExit = () => killStartedProxy();
process.once("SIGTERM", onSigterm);
process.once("SIGINT", onSigint);
process.once("exit", onExit);
}
try {
if (shouldUseRootHelpFastPath(normalizedArgv)) {
const { outputPrecomputedRootHelpText } = await import("./root-help-metadata.js");
if (!outputPrecomputedRootHelpText()) {
const { outputRootHelp } = await import("./program/root-help.js");
await outputRootHelp();
}
return;
}
if (shouldUseBrowserHelpFastPath(normalizedArgv)) {
const { outputPrecomputedBrowserHelpText } = await import("./root-help-metadata.js");
if (outputPrecomputedBrowserHelpText()) {
return;
}
}
const shouldRunBareRootCrestodian = shouldStartCrestodianForBareRoot(normalizedArgv);
const shouldRunModernOnboardCrestodian = shouldStartCrestodianForModernOnboard(normalizedArgv);
if (shouldRunBareRootCrestodian || shouldRunModernOnboardCrestodian) {
await ensureCliEnvProxyDispatcher();
}
if (shouldRunBareRootCrestodian) {
if (!process.stdin.isTTY || !process.stdout.isTTY) {
console.error(
'Crestodian needs an interactive TTY. Use `openclaw crestodian --message "status"` for one command.',
);
process.exitCode = 1;
return;
}
const { runCrestodian } = await import("../crestodian/crestodian.js");
const { createCliProgress } = await import("./progress.js");
const progress = createCliProgress({
label: "Starting Crestodian…",
indeterminate: true,
delayMs: 0,
fallback: "none",
});
let progressStopped = false;
const stopProgress = () => {
if (progressStopped) {
return;
}
progressStopped = true;
progress.done();
};
try {
await runCrestodian({ onReady: stopProgress });
} finally {
stopProgress();
}
return;
}
if (shouldRunModernOnboardCrestodian) {
const { runCrestodian } = await import("../crestodian/crestodian.js");
const nonInteractive = normalizedArgv.includes("--non-interactive");
await runCrestodian({
message: nonInteractive ? "overview" : undefined,
yes: false,
json: normalizedArgv.includes("--json"),
interactive: !nonInteractive,
});
return;
}
const shouldUseCliEnvProxy = shouldStartProxyForCli(normalizedArgv);
const bootstrapProxyBeforeFastPath =
shouldUseCliEnvProxy && shouldBootstrapCliProxyBeforeFastPath();
if (
!bootstrapProxyBeforeFastPath &&
(await tryRunGatewayRunFastPath(normalizedArgv, startupTrace))
) {
return;
}
await bootstrapCliProxyCaptureAndDispatcher(startupTrace, {
ensureDispatcher: shouldUseCliEnvProxy,
});
if (
bootstrapProxyBeforeFastPath &&
(await tryRunGatewayRunFastPath(normalizedArgv, startupTrace))
) {
return;
}
const { tryRouteCli } = await startupTrace.measure("route-import", () => import("./route.js"));
if (await startupTrace.measure("route", () => tryRouteCli(normalizedArgv))) {
return;
}
const { createCliProgress } = await import("./progress.js");
const startupProgress = createCliProgress({
label: "Loading OpenClaw CLI…",
indeterminate: true,
delayMs: 0,
fallback: "none",
});
let startupProgressStopped = false;
const stopStartupProgress = () => {
if (startupProgressStopped) {
return;
}
startupProgressStopped = true;
startupProgress.done();
};
try {
// Capture all console output into structured logs while keeping stdout/stderr behavior.
const { enableConsoleCapture } = await import("../logging.js");
enableConsoleCapture();
const [
{ buildProgram },
{ formatUncaughtError },
{ runFatalErrorHooks },
{
installUnhandledRejectionHandler,
isBenignUncaughtExceptionError,
isUncaughtExceptionHandled,
},
{ restoreTerminalState },
] = await startupTrace.measure("core-imports", () =>
Promise.all([
import("./program.js"),
import("../infra/errors.js"),
import("../infra/fatal-error-hooks.js"),
import("../infra/unhandled-rejections.js"),
import("../terminal/restore.js"),
]),
);
const program = await startupTrace.measure("build-program", () => buildProgram());
// Global error handlers to prevent silent crashes from unhandled rejections/exceptions.
// These log the error and exit gracefully instead of crashing without trace.
installUnhandledRejectionHandler();
process.on("uncaughtException", (error) => {
if (isUncaughtExceptionHandled(error)) {
return;
}
if (isBenignUncaughtExceptionError(error)) {
console.warn(
"[openclaw] Non-fatal uncaught exception (continuing):",
formatUncaughtError(error),
);
return;
}
console.error("[openclaw] Uncaught exception:", formatUncaughtError(error));
for (const message of runFatalErrorHooks({ reason: "uncaught_exception", error })) {
console.error("[openclaw]", message);
}
restoreTerminalState("uncaught exception", { resumeStdinIfPaused: false });
process.exit(1);
});
const parseArgv = rewriteUpdateFlagArgv(normalizedArgv);
const invocation = resolveCliArgvInvocation(parseArgv);
// Register the primary command (builtin or subcli) so help and command parsing
// are correct even with lazy command registration.
const { primary } = invocation;
if (primary && shouldRegisterPrimaryCommandOnly(parseArgv)) {
await startupTrace.measure("register-primary", async () => {
const { getProgramContext } = await import("./program/program-context.js");
const ctx = getProgramContext(program);
if (ctx) {
const { registerCoreCliByName } = await import("./program/command-registry.js");
await registerCoreCliByName(program, ctx, primary, parseArgv);
}
const { registerSubCliByName } = await import("./program/register.subclis.js");
await registerSubCliByName(program, primary, parseArgv);
});
}
const hasBuiltinPrimary =
primary !== null &&
program.commands.some(
(command) => command.name() === primary || command.aliases().includes(primary),
);
const shouldSkipPluginRegistration = shouldSkipPluginCommandRegistration({
argv: parseArgv,
primary,
hasBuiltinPrimary,
});
if (!shouldSkipPluginRegistration) {
const config = await startupTrace.measure("register-plugin-commands", async () => {
const { registerPluginCliCommandsFromValidatedConfig } =
await import("../plugins/cli.js");
return await registerPluginCliCommandsFromValidatedConfig(program, undefined, undefined, {
mode: "lazy",
primary,
});
});
if (config) {
if (
primary &&
!program.commands.some(
(command) => command.name() === primary || command.aliases().includes(primary),
)
) {
const { resolveManifestCommandAliasOwner } =
await import("../plugins/manifest-command-aliases.runtime.js");
const missingPluginCommandMessage = resolveMissingPluginCommandMessageFromPolicy(
primary,
config,
{
resolveCommandAliasOwner: resolveManifestCommandAliasOwner,
},
);
if (missingPluginCommandMessage) {
throw new Error(missingPluginCommandMessage);
}
}
}
}
stopStartupProgress();
try {
await startupTrace.measure("parse", () => program.parseAsync(parseArgv));
} catch (error) {
if (!isCommanderParseExit(error)) {
throw error;
}
process.exitCode = error.exitCode;
}
} finally {
stopStartupProgress();
}
} finally {
if (onSigterm) {
process.off("SIGTERM", onSigterm);
}
if (onSigint) {
process.off("SIGINT", onSigint);
}
if (onExit) {
process.off("exit", onExit);
}
await stopStartedProxy();
await closeCliMemoryManagers();
}
}
export function isCliMainModule(): boolean {
return isMainModule({ currentFile: fileURLToPath(import.meta.url) });
}