Implement DMN mode support in crew creation and execution

- Added `is_dmn_mode_enabled` utility to check for enterprise non-interactive mode based on the `CREWAI_DMN` environment variable.
- Updated `create` function in `cli.py` to enforce required parameters when DMN mode is active, raising appropriate usage errors.
- Enhanced `create_crew` and `create_json_crew` functions to skip provider prompts and handle folder existence checks in DMN mode.
- Introduced non-interactive defaults for agent and task creation in DMN mode, ensuring seamless project setup without user input.
- Modified `run_crew` to bypass TUI and handle runtime inputs directly when in DMN mode, improving execution flow for JSON-defined crews.
- Added tests to validate DMN mode behavior, ensuring correct handling of required inputs and non-interactive defaults.
This commit is contained in:
Joao Moura
2026-06-16 14:56:47 -07:00
parent 06ada68083
commit 570c7e124f
9 changed files with 270 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ from unittest import mock
import pytest
from click.testing import CliRunner
from crewai_cli.cli import (
create,
deploy_create,
deploy_list,
deploy_logs,
@@ -157,6 +158,28 @@ def test_run_rejects_inputs_without_definition(run_flow_definition, run_crew, ru
run_crew.assert_not_called()
@mock.patch("crewai_cli.create_json_crew.create_json_crew")
def test_create_crew_in_dmn_mode_skips_provider_prompts(create_json_crew, runner):
result = runner.invoke(create, ["crew", "DMN Crew"], env={"CREWAI_DMN": "1"})
assert result.exit_code == 0
create_json_crew.assert_called_once_with("DMN Crew", None, True)
def test_create_requires_type_in_dmn_mode(runner):
result = runner.invoke(create, env={"CREWAI_DMN": "1"})
assert result.exit_code == 2
assert "TYPE is required when CREWAI_DMN is set" in result.output
def test_create_requires_name_in_dmn_mode(runner):
result = runner.invoke(create, ["flow"], env={"CREWAI_DMN": "1"})
assert result.exit_code == 2
assert "NAME is required when CREWAI_DMN is set" in result.output
@mock.patch("crewai_cli.cli.AuthenticationCommand")
def test_login(command, runner):
mock_auth = command.return_value