Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
323
scripts/zai-fallback-repro.ts
Normal file
323
scripts/zai-fallback-repro.ts
Normal file
@@ -0,0 +1,323 @@
|
||||
// Zai Fallback Repro script supports OpenClaw repository automation.
|
||||
import { spawn } from "node:child_process";
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { createReadStream } from "node:fs";
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { resolvePnpmRunner } from "./pnpm-runner.mjs";
|
||||
|
||||
type RunResult = {
|
||||
code: number | null;
|
||||
signal: string | null;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
};
|
||||
|
||||
type OutputCapture = {
|
||||
text: string;
|
||||
truncatedChars: number;
|
||||
};
|
||||
|
||||
type PnpmCommand = {
|
||||
args: string[];
|
||||
command: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
shell: boolean;
|
||||
windowsVerbatimArguments?: boolean;
|
||||
};
|
||||
|
||||
type ResolvePnpmCommandOptions = {
|
||||
comSpec?: string;
|
||||
env?: NodeJS.ProcessEnv;
|
||||
execPath?: string;
|
||||
npmExecPath?: string;
|
||||
platform?: NodeJS.Platform;
|
||||
};
|
||||
|
||||
const COMMAND_OUTPUT_MAX_CHARS = 512 * 1024;
|
||||
const SESSION_TRANSCRIPT_SCAN_BYTES = 16 * 1024 * 1024;
|
||||
type ReproLog = (message: string) => void;
|
||||
type RunCommand = typeof runCommand;
|
||||
|
||||
type RunZaiFallbackReproDeps = {
|
||||
env?: NodeJS.ProcessEnv;
|
||||
error?: ReproLog;
|
||||
log?: ReproLog;
|
||||
mkdtemp?: typeof fs.mkdtemp;
|
||||
mkdir?: typeof fs.mkdir;
|
||||
randomUUID?: typeof randomUUID;
|
||||
rm?: typeof fs.rm;
|
||||
runCommand?: RunCommand;
|
||||
writeFile?: typeof fs.writeFile;
|
||||
};
|
||||
|
||||
export function appendBoundedReproOutput(
|
||||
capture: OutputCapture,
|
||||
chunk: unknown,
|
||||
maxChars = COMMAND_OUTPUT_MAX_CHARS,
|
||||
): OutputCapture {
|
||||
const nextText = capture.text + String(chunk);
|
||||
if (nextText.length <= maxChars) {
|
||||
return { text: nextText, truncatedChars: capture.truncatedChars };
|
||||
}
|
||||
const truncatedChars = capture.truncatedChars + nextText.length - maxChars;
|
||||
return { text: nextText.slice(-maxChars), truncatedChars };
|
||||
}
|
||||
|
||||
function formatBoundedReproOutput(capture: OutputCapture): string {
|
||||
if (capture.truncatedChars === 0) {
|
||||
return capture.text;
|
||||
}
|
||||
return `[output truncated ${capture.truncatedChars} chars; showing tail]\n${capture.text}`;
|
||||
}
|
||||
|
||||
export async function sessionTranscriptHasToolResult(
|
||||
sessionFile: string,
|
||||
maxBytes = SESSION_TRANSCRIPT_SCAN_BYTES,
|
||||
): Promise<boolean> {
|
||||
let scannedBytes = 0;
|
||||
let carry = "";
|
||||
try {
|
||||
for await (const rawChunk of createReadStream(sessionFile, { highWaterMark: 64 * 1024 })) {
|
||||
const chunk = Buffer.isBuffer(rawChunk) ? rawChunk : Buffer.from(String(rawChunk));
|
||||
const remaining = maxBytes - scannedBytes;
|
||||
if (remaining <= 0) {
|
||||
break;
|
||||
}
|
||||
const readableChunk = chunk.length > remaining ? chunk.subarray(0, remaining) : chunk;
|
||||
scannedBytes += readableChunk.length;
|
||||
const text = `${carry}${readableChunk.toString("utf8")}`;
|
||||
if (text.includes('"toolResult"') || text.includes('"tool_result"')) {
|
||||
return true;
|
||||
}
|
||||
carry = text.slice(-64);
|
||||
if (readableChunk.length < chunk.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if ((error as { code?: unknown }).code === "ENOENT") {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function outputContainsStandaloneToolOk(output: string): boolean {
|
||||
return output
|
||||
.split(/\r?\n/u)
|
||||
.map((line) => line.trim())
|
||||
.some((line) => line === "tool-ok");
|
||||
}
|
||||
|
||||
export function resolveZaiFallbackPnpmCommand(
|
||||
args: string[],
|
||||
options: ResolvePnpmCommandOptions = {},
|
||||
): PnpmCommand {
|
||||
const env = options.env ?? process.env;
|
||||
const command = resolvePnpmRunner({
|
||||
comSpec: options.comSpec,
|
||||
env,
|
||||
npmExecPath: options.npmExecPath ?? env.npm_execpath,
|
||||
nodeExecPath: options.execPath ?? process.execPath,
|
||||
platform: options.platform,
|
||||
pnpmArgs: args,
|
||||
});
|
||||
if (command.env === undefined) {
|
||||
const invocation = { ...command };
|
||||
delete invocation.env;
|
||||
return invocation;
|
||||
}
|
||||
return command;
|
||||
}
|
||||
|
||||
function pickAnthropicEnv(env: NodeJS.ProcessEnv): { type: "oauth" | "api"; value: string } | null {
|
||||
const oauth = env.ANTHROPIC_OAUTH_TOKEN?.trim();
|
||||
if (oauth) {
|
||||
return { type: "oauth", value: oauth };
|
||||
}
|
||||
const api = env.ANTHROPIC_API_KEY?.trim();
|
||||
if (api) {
|
||||
return { type: "api", value: api };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function pickZaiKey(env: NodeJS.ProcessEnv): string | null {
|
||||
return env.ZAI_API_KEY?.trim() ?? env.Z_AI_API_KEY?.trim() ?? null;
|
||||
}
|
||||
|
||||
async function runCommand(
|
||||
label: string,
|
||||
args: string[],
|
||||
env: NodeJS.ProcessEnv,
|
||||
): Promise<RunResult> {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const command = resolveZaiFallbackPnpmCommand(args, { env });
|
||||
const child = spawn(command.command, command.args, {
|
||||
env: command.env ?? env,
|
||||
shell: command.shell,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
windowsVerbatimArguments: command.windowsVerbatimArguments,
|
||||
});
|
||||
let stdout: OutputCapture = { text: "", truncatedChars: 0 };
|
||||
let stderr: OutputCapture = { text: "", truncatedChars: 0 };
|
||||
child.stdout.on("data", (chunk) => {
|
||||
const text = String(chunk);
|
||||
stdout = appendBoundedReproOutput(stdout, text);
|
||||
process.stdout.write(text);
|
||||
});
|
||||
child.stderr.on("data", (chunk) => {
|
||||
const text = String(chunk);
|
||||
stderr = appendBoundedReproOutput(stderr, text);
|
||||
process.stderr.write(text);
|
||||
});
|
||||
child.on("error", (err) => reject(err));
|
||||
child.on("close", (code, signal) => {
|
||||
const result = {
|
||||
code,
|
||||
signal,
|
||||
stdout: formatBoundedReproOutput(stdout),
|
||||
stderr: formatBoundedReproOutput(stderr),
|
||||
};
|
||||
if (code === 0) {
|
||||
resolve(result);
|
||||
return;
|
||||
}
|
||||
resolve(result);
|
||||
const summary = signal
|
||||
? `${label} exited with signal ${signal}`
|
||||
: `${label} exited with code ${code}`;
|
||||
console.error(summary);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function runZaiFallbackRepro(deps: RunZaiFallbackReproDeps = {}): Promise<number> {
|
||||
const env = deps.env ?? process.env;
|
||||
const log = deps.log ?? console.log;
|
||||
const error = deps.error ?? console.error;
|
||||
const mkdtemp = deps.mkdtemp ?? fs.mkdtemp;
|
||||
const mkdir = deps.mkdir ?? fs.mkdir;
|
||||
const rm = deps.rm ?? fs.rm;
|
||||
const writeFile = deps.writeFile ?? fs.writeFile;
|
||||
const run = deps.runCommand ?? runCommand;
|
||||
const createUuid = deps.randomUUID ?? randomUUID;
|
||||
const anthropic = pickAnthropicEnv(env);
|
||||
const zaiKey = pickZaiKey(env);
|
||||
if (!anthropic) {
|
||||
error("Missing ANTHROPIC_OAUTH_TOKEN or ANTHROPIC_API_KEY.");
|
||||
return 1;
|
||||
}
|
||||
if (!zaiKey) {
|
||||
error("Missing ZAI_API_KEY or Z_AI_API_KEY.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const baseDir = await mkdtemp(path.join(os.tmpdir(), "openclaw-zai-fallback-"));
|
||||
const stateDir = path.join(baseDir, "state");
|
||||
const configPath = path.join(baseDir, "openclaw.json");
|
||||
try {
|
||||
await mkdir(stateDir, { recursive: true });
|
||||
|
||||
const config = {
|
||||
agents: {
|
||||
defaults: {
|
||||
model: {
|
||||
primary: "anthropic/claude-opus-4-6",
|
||||
fallbacks: ["zai/glm-4.7"],
|
||||
},
|
||||
models: {
|
||||
"anthropic/claude-opus-4-6": {},
|
||||
"anthropic/claude-opus-4-5": {},
|
||||
"zai/glm-4.7": {},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
await writeFile(configPath, JSON.stringify(config, null, 2), "utf8");
|
||||
|
||||
const sessionId = env.OPENCLAW_ZAI_FALLBACK_SESSION_ID ?? createUuid();
|
||||
|
||||
const baseEnv: NodeJS.ProcessEnv = {
|
||||
...env,
|
||||
OPENCLAW_CONFIG_PATH: configPath,
|
||||
OPENCLAW_STATE_DIR: stateDir,
|
||||
ZAI_API_KEY: zaiKey,
|
||||
Z_AI_API_KEY: "",
|
||||
};
|
||||
|
||||
const envValidAnthropic: NodeJS.ProcessEnv = {
|
||||
...baseEnv,
|
||||
ANTHROPIC_OAUTH_TOKEN: anthropic.type === "oauth" ? anthropic.value : "",
|
||||
ANTHROPIC_API_KEY: anthropic.type === "api" ? anthropic.value : "",
|
||||
};
|
||||
|
||||
const envInvalidAnthropic: NodeJS.ProcessEnv = {
|
||||
...baseEnv,
|
||||
ANTHROPIC_OAUTH_TOKEN: anthropic.type === "oauth" ? "invalid" : "",
|
||||
ANTHROPIC_API_KEY: anthropic.type === "api" ? "invalid" : "",
|
||||
};
|
||||
|
||||
log("== Run 1: create tool history (primary only)");
|
||||
const toolPrompt =
|
||||
"Use the exec tool to create a file named zai-fallback-tool.txt with the content tool-ok. " +
|
||||
"Then use the read tool to display the file contents. Reply with just the file contents.";
|
||||
const run1 = await run(
|
||||
"run1",
|
||||
["openclaw", "agent", "--local", "--session-id", sessionId, "--message", toolPrompt],
|
||||
envValidAnthropic,
|
||||
);
|
||||
if (run1.code !== 0) {
|
||||
return run1.code ?? 1;
|
||||
}
|
||||
|
||||
const sessionFile = path.join(stateDir, "agents", "main", "sessions", `${sessionId}.jsonl`);
|
||||
if (!(await sessionTranscriptHasToolResult(sessionFile))) {
|
||||
error("FAIL: no toolResult entries detected in session history.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
log("== Run 2: force auth failover to Z.AI");
|
||||
const followupPrompt =
|
||||
"What is the content of zai-fallback-tool.txt? Reply with just the contents.";
|
||||
const run2 = await run(
|
||||
"run2",
|
||||
["openclaw", "agent", "--local", "--session-id", sessionId, "--message", followupPrompt],
|
||||
envInvalidAnthropic,
|
||||
);
|
||||
|
||||
if (run2.code === 0) {
|
||||
if (outputContainsStandaloneToolOk(`${run2.stdout}\n${run2.stderr}`)) {
|
||||
log("PASS: fallback succeeded.");
|
||||
return 0;
|
||||
}
|
||||
error("FAIL: fallback run did not return standalone tool-ok.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
error("FAIL: fallback failed.");
|
||||
return run2.code ?? 1;
|
||||
} finally {
|
||||
await rm(baseDir, { force: true, recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
process.exitCode = await runZaiFallbackRepro();
|
||||
}
|
||||
|
||||
function isCliEntrypoint() {
|
||||
const entrypoint = process.argv[1];
|
||||
return Boolean(entrypoint && import.meta.url === pathToFileURL(path.resolve(entrypoint)).href);
|
||||
}
|
||||
|
||||
if (isCliEntrypoint()) {
|
||||
await main().catch((err: unknown) => {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user