MCPcopy
hub / github.com/langchain-ai/deepagents / cli_main

Function cli_main

libs/code/deepagents_code/main.py:2483–3650  ·  view source on GitHub ↗

Entry point for console script.

()

Source from the content-addressed store, hash-verified

2481
2482
2483def cli_main() -> None:
2484 """Entry point for console script."""
2485 # Fix for gRPC fork issue on macOS
2486 # https://github.com/grpc/grpc/issues/37642
2487 if sys.platform == "darwin":
2488 os.environ["GRPC_ENABLE_FORK_SUPPORT"] = "0"
2489
2490 # Note: LANGSMITH_PROJECT override is handled lazily by config.py's
2491 # _ensure_bootstrap() (triggered on first access of `settings`).
2492 # This ensures agent traces use DEEPAGENTS_CODE_LANGSMITH_PROJECT while
2493 # shell commands use the user's original LANGSMITH_PROJECT.
2494
2495 # Fast path: print version without loading heavy dependencies
2496 if len(sys.argv) == 2 and sys.argv[1] in {"-v", "--version"}: # noqa: PLR2004 # argv length check for fast-path
2497 print(build_version_text()) # noqa: T201 # Version output
2498 sys.exit(0)
2499
2500 # ACP mode does not require Textual, so skip UI dependency checks when
2501 # the flag is present in raw argv.
2502 if "--acp" not in sys.argv[1:]:
2503 check_cli_dependencies()
2504
2505 try:
2506 args = parse_args()
2507
2508 if _show_bare_command_group_help(args):
2509 return
2510
2511 # Keep self-contained commands that do not need global settings here, before
2512 # state migration and settings bootstrap. If a future command only reads
2513 # local files or delegates bootstrap to specific subcommands, dispatch it here
2514 # so lightweight diagnostic paths stay fast.
2515 # Use `getattr` because this fast-path block is for optional top-level
2516 # subcommands only. ACP/root-mode invocations may not define `command`,
2517 # and should fall through to the later handlers instead of raising here.
2518 command = getattr(args, "command", None)
2519 if command == "config":
2520 from deepagents_code.config_commands import run_config_command
2521
2522 sys.exit(run_config_command(args))
2523
2524 if command == "auth" and getattr(args, "auth_command", None) == "path":
2525 from deepagents_code.auth_commands import run_auth_command
2526
2527 sys.exit(run_auth_command(args))
2528
2529 if command == "doctor":
2530 from deepagents_code.doctor import run_doctor_command
2531
2532 sys.exit(run_doctor_command(args))
2533
2534 if command == "tools":
2535 from deepagents_code.tools_commands import run_tools_command
2536
2537 sys.exit(run_tools_command(args))
2538
2539 # Best-effort, idempotent migration. Placed after parse_args and the
2540 # bare-help fast path so --help / --version / `deepagents <group>`

Calls 15

run_config_commandFunction · 0.90
run_auth_commandFunction · 0.90
run_doctor_commandFunction · 0.90
run_tools_commandFunction · 0.90
migrate_legacy_stateFunction · 0.90
parse_shell_allow_listFunction · 0.90
_is_editable_installFunction · 0.90
format_age_suffixFunction · 0.90
is_update_availableFunction · 0.90

Used in the wild real call sites across dependent graphs

searching dependent graphs…