|
17 | 17 | from dreadnode.agents.tools import tool |
18 | 18 | from dreadnode.app.env import resolve_python_executable |
19 | 19 |
|
20 | | -# Support flexible workspace organization |
21 | | -_base_workspace = Path(os.environ.get("DREADNODE_WORKSPACE_ROOT", str(Path.home() / "workspace"))) |
22 | | -_org_key = os.environ.get("DREADNODE_ORG_KEY", "default") |
23 | | -_project_key = os.environ.get("DREADNODE_PROJECT_KEY", "airt") |
24 | | - |
25 | | -# Organized structure: ~/workspace/[org]/[project]/workflows |
26 | | -# Falls back to original structure if new env vars not set |
27 | | -WORKFLOWS_DIR = Path( |
28 | | - os.environ.get( |
29 | | - "AIRT_WORKFLOWS_DIR", |
30 | | - str(_base_workspace / _org_key / _project_key / "workflows") |
31 | | - if any([os.environ.get(var) for var in ["DREADNODE_WORKSPACE_ROOT", "DREADNODE_ORG_KEY", "DREADNODE_PROJECT_KEY"]]) |
32 | | - else str(Path.home() / "workspace" / "airt" / "workflows"), |
33 | | - ) |
34 | | -) |
| 20 | +# Get org/workspace from active profile, with fallbacks |
| 21 | +def _get_workspace_path() -> Path: |
| 22 | + try: |
| 23 | + from dreadnode.app.config import UserConfig |
| 24 | + config = UserConfig.read() |
| 25 | + profile_data = config.active_profile |
| 26 | + if profile_data: |
| 27 | + _, profile = profile_data |
| 28 | + org_key = profile.organization or "default" |
| 29 | + workspace_key = profile.workspace or "main" |
| 30 | + else: |
| 31 | + org_key = "default" |
| 32 | + workspace_key = "main" |
| 33 | + except Exception: |
| 34 | + # Fallback if config system unavailable |
| 35 | + org_key = "default" |
| 36 | + workspace_key = "main" |
| 37 | + |
| 38 | + return Path.home() / ".dreadnode" / "airt" / org_key / workspace_key / "workflows" |
| 39 | + |
| 40 | +WORKFLOWS_DIR = Path(os.environ.get("AIRT_WORKFLOWS_DIR")) if os.environ.get("AIRT_WORKFLOWS_DIR") else _get_workspace_path() |
35 | 41 | METADATA_FILE = WORKFLOWS_DIR / ".workflow_metadata.json" |
36 | 42 |
|
37 | 43 |
|
|
0 commit comments