Delegate to the headless entrypoint.
(args)
| 447 | |
| 448 | |
| 449 | def _run_print_mode(args) -> int: |
| 450 | """Delegate to the headless entrypoint.""" |
| 451 | |
| 452 | from src.cli_core.exit import cli_error |
| 453 | from src.entrypoints.headless import HeadlessOptions, run_headless |
| 454 | |
| 455 | # Some combinations are invalid; report early with a helpful message. |
| 456 | if args.input_format == 'stream-json' and args.output_format != 'stream-json': |
| 457 | cli_error( |
| 458 | "error: --input-format stream-json requires --output-format stream-json", |
| 459 | 2, |
| 460 | ) |
| 461 | if args.include_partial_messages and args.output_format != 'stream-json': |
| 462 | cli_error( |
| 463 | "error: --include-partial-messages requires --output-format stream-json", |
| 464 | 2, |
| 465 | ) |
| 466 | |
| 467 | allowed = _split_csv(args.allowed_tools) |
| 468 | disallowed = _split_csv(args.disallowed_tools) |
| 469 | |
| 470 | options = HeadlessOptions( |
| 471 | prompt=args.prompt, |
| 472 | output_format=args.output_format, |
| 473 | input_format=args.input_format, |
| 474 | provider_name=args.provider, |
| 475 | model=args.model, |
| 476 | max_turns=args.max_turns, |
| 477 | skip_permissions=bool(args.dangerously_skip_permissions), |
| 478 | permission_mode=args._resolved_permission_mode, |
| 479 | is_bypass_permissions_mode_available=args._resolved_is_bypass_available, |
| 480 | allowed_tools=tuple(allowed), |
| 481 | disallowed_tools=tuple(disallowed), |
| 482 | include_partial_messages=bool(args.include_partial_messages), |
| 483 | verbose=bool(args.verbose), |
| 484 | ) |
| 485 | return run_headless(options) |
| 486 | |
| 487 | |
| 488 | def _split_csv(value: str | None) -> list[str]: |
no test coverage detected