const commandModule = (await (async () => {
    const workerCommandsSpecifier = '@zintrust/core/worker-commands';
    try {
        return (await import(workerCommandsSpecifier));
    }
    catch {
        return (await import('../../../src/cli.js'));
    }
})());
const getWorkerProviders = () => {
    const { WorkerCommands } = commandModule;
    return [
        ['worker:list', WorkerCommands.createWorkerListCommand()],
        ['worker:status', WorkerCommands.createWorkerStatusCommand()],
        ['worker:start', WorkerCommands.createWorkerStartCommand()],
        ['worker:start-all', WorkerCommands.createWorkerStartAllCommand()],
        ['worker:stop', WorkerCommands.createWorkerStopCommand()],
        ['worker:restart', WorkerCommands.createWorkerRestartCommand()],
        ['worker:summary', WorkerCommands.createWorkerSummaryCommand()],
    ];
};
export function registerWorkerCliCommands(registry) {
    for (const [id, provider] of getWorkerProviders()) {
        registry.register(id, provider);
    }
}
const globalWithRegistry = globalThis;
const globalRegistry = globalWithRegistry.__zintrust_cli_command_registry__ ??
    (globalWithRegistry.__zintrust_cli_command_registry__ = new Map());
registerWorkerCliCommands({
    register: (id, provider) => {
        globalRegistry.set(id, provider);
    },
});
try {
    const coreCli = (await import('../../../src/cli.js'));
    if (coreCli.OptionalCliCommandRegistry !== undefined) {
        registerWorkerCliCommands(coreCli.OptionalCliCommandRegistry);
    }
}
catch {
    // no-op
}
