Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:2aronS Duel Agents runDoctor

From Leeroopedia
Knowledge Sources
Domains Configuration, Developer_Tools
Last Updated 2026-10-27 14:00 GMT

Overview

Concrete tool for running the Duel Agents "doctor" diagnostic command that verifies key format and live connectivity, returning a process exit code, provided by @duel-agents/install.

Description

The runDoctor function is the CLI diagnostic entry point. It:

  1. Validates the key format locally via validateApiKey — exits with code 1 and a dashboard link if invalid
  2. Prints the masked key prefix duel_<prefix>_… on success
  3. Calls checkConnectivity for a live probe
  4. On ok: prints success, exits 0
  5. On unauthorized or invalid_key: prints error, exits 1
  6. On unreachable: prints a warning (not a failure), exits 0 — transient network issues are not treated as failures

The function is invoked directly by runInstall when the target is "doctor" or "all"/undefined (the doctor runs after a full install).

Usage

Import this function when you need to:

  • Run the diagnostic check programmatically
  • Build a custom install flow that ends with a connectivity check
  • Understand the exit-code semantics for CI/CD integration

Code Reference

Source Location

  • Repository: Duel-Agents
  • File: packages/cli/src/install.ts (lines 66-96)

Signature

export async function runDoctor(apiKey: string): Promise<number>;

Import

import { runDoctor } from "@duel-agents/install";  // re-exported from cli/install.ts

I/O Contract

Inputs

Name Type Required Description
apiKey string Yes Duel key to verify

Outputs

Name Type Description
returns Promise<number> Process exit code: 0 (ok or transient), 1 (invalid/rejected key)

Usage Examples

Run Doctor Standalone

import { runDoctor } from "@duel-agents/install";
import { resolveApiKeyFromEnv } from "@duel-agents/install";

const key = resolveApiKeyFromEnv();
if (!key) {
  console.error("Set DUEL_API_KEY");
  process.exit(1);
}
const code = await runDoctor(key);
process.exit(code);

Doctor After Full Install

// runInstall calls runDoctor automatically after installing all targets
import { runInstall } from "@duel-agents/install";
const code = await runInstall(undefined, apiKey);  // undefined = install all + doctor
process.exit(code);

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment