Entry point for console script.
()
| 2481 | |
| 2482 | |
| 2483 | def 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>` |
searching dependent graphs…