Implementation:2aronS Duel Agents runDoctor
Appearance
| 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:
- Validates the key format locally via
validateApiKey— exits with code 1 and a dashboard link if invalid - Prints the masked key prefix
duel_<prefix>_…on success - Calls
checkConnectivityfor a live probe - On
ok: prints success, exits 0 - On
unauthorizedorinvalid_key: prints error, exits 1 - 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