hexaqueue-cli 0.5.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/PKG-INFO +6 -6
  2. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/pyproject.toml +7 -7
  3. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/pyproject.toml.orig +7 -7
  4. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/adapters/local.py +23 -4
  5. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/adapters/presenter.py +69 -10
  6. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/commands/__init__.py +2 -0
  7. hexaqueue_cli-0.6.0/src/hexaqueue_cli/commands/admin.py +172 -0
  8. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/commands/collateral.py +3 -0
  9. hexaqueue_cli-0.6.0/src/hexaqueue_cli/commands/mcp.py +117 -0
  10. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/commands/run.py +16 -1
  11. hexaqueue_cli-0.6.0/src/hexaqueue_cli/commands/scanner.py +198 -0
  12. hexaqueue_cli-0.6.0/src/hexaqueue_cli/commands/server.py +181 -0
  13. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/commands/workflow.py +5 -1
  14. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/domain/session.py +23 -16
  15. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/main.py +19 -0
  16. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/ports/client.py +20 -0
  17. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/README.md +0 -0
  18. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/__init__.py +0 -0
  19. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/adapters/__init__.py +0 -0
  20. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/commands/node.py +0 -0
  21. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/commands/suite.py +0 -0
  22. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/domain/__init__.py +0 -0
  23. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/domain/models.py +0 -0
  24. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/domain/options.py +0 -0
  25. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/domain/parser.py +0 -0
  26. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/infra/__init__.py +0 -0
  27. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/infra/bootstrap.py +0 -0
  28. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/infra/options.py +0 -0
  29. {hexaqueue_cli-0.5.0 → hexaqueue_cli-0.6.0}/src/hexaqueue_cli/ports/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hexaqueue-cli
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Hexaqueue CLI - Modern developer and operator terminal interface
5
5
  Author: Richard West
6
6
  Author-email: Richard West <dopplereffect.us@gmail.com>
@@ -9,14 +9,14 @@ Requires-Dist: hexaqueue-core
9
9
  Requires-Dist: hexaqueue-server
10
10
  Requires-Dist: hexaqueue-worker
11
11
  Requires-Dist: hexaqueue-workflow
12
- Requires-Dist: hexastack-cli>=0.8.0
13
- Requires-Dist: hexastack-core>=0.8.0
14
- Requires-Dist: hexastack-cqrs>=0.8.0
15
- Requires-Dist: hexastack-grpc>=0.8.0
12
+ Requires-Dist: hexastack-cli>=0.11.0
13
+ Requires-Dist: hexastack-core>=0.11.0
14
+ Requires-Dist: hexastack-cqrs>=0.11.0
15
+ Requires-Dist: hexastack-grpc>=0.11.0
16
16
  Requires-Dist: pyyaml>=6.0.2
17
17
  Requires-Dist: rich>=13.8.0
18
18
  Requires-Dist: typer>=0.15.0
19
- Requires-Python: >=3.13
19
+ Requires-Python: >=3.12
20
20
  Description-Content-Type: text/markdown
21
21
 
22
22
  # 💻 `hexaqueue-cli`
@@ -1,19 +1,19 @@
1
1
  [project]
2
2
  name = "hexaqueue-cli"
3
- version = "0.5.0"
3
+ version = "0.6.0"
4
4
  description = "Hexaqueue CLI - Modern developer and operator terminal interface"
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
7
- requires-python = ">=3.13"
7
+ requires-python = ">=3.12"
8
8
  dependencies = [
9
9
  "hexaqueue-core",
10
10
  "hexaqueue-server",
11
11
  "hexaqueue-worker",
12
12
  "hexaqueue-workflow",
13
- "hexastack-cli>=0.8.0",
14
- "hexastack-core>=0.8.0",
15
- "hexastack-cqrs>=0.8.0",
16
- "hexastack-grpc>=0.8.0",
13
+ "hexastack-cli>=0.11.0",
14
+ "hexastack-core>=0.11.0",
15
+ "hexastack-cqrs>=0.11.0",
16
+ "hexastack-grpc>=0.11.0",
17
17
  "pyyaml>=6.0.2",
18
18
  "rich>=13.8.0",
19
19
  "typer>=0.15.0",
@@ -27,7 +27,7 @@ email = "dopplereffect.us@gmail.com"
27
27
  hq = "hexaqueue_cli.main:app"
28
28
 
29
29
  [build-system]
30
- requires = ["uv_build>=0.12.3,<0.13.0"]
30
+ requires = ["uv_build>=0.12.3,<0.14.0"]
31
31
  build-backend = "uv_build"
32
32
 
33
33
  [tool.uv.sources.hexaqueue-core]
@@ -1,22 +1,22 @@
1
1
  [project]
2
2
  name = "hexaqueue-cli"
3
- version = "0.5.0"
3
+ version = "0.6.0"
4
4
  description = "Hexaqueue CLI - Modern developer and operator terminal interface"
5
5
  readme = "README.md"
6
6
  license = "Apache-2.0"
7
7
  authors = [
8
8
  { name = "Richard West", email = "dopplereffect.us@gmail.com" }
9
9
  ]
10
- requires-python = ">=3.13"
10
+ requires-python = ">=3.12"
11
11
  dependencies = [
12
12
  "hexaqueue-core",
13
13
  "hexaqueue-server",
14
14
  "hexaqueue-worker",
15
15
  "hexaqueue-workflow",
16
- "hexastack-cli>=0.8.0",
17
- "hexastack-core>=0.8.0",
18
- "hexastack-cqrs>=0.8.0",
19
- "hexastack-grpc>=0.8.0",
16
+ "hexastack-cli>=0.11.0",
17
+ "hexastack-core>=0.11.0",
18
+ "hexastack-cqrs>=0.11.0",
19
+ "hexastack-grpc>=0.11.0",
20
20
  "pyyaml>=6.0.2",
21
21
  "rich>=13.8.0",
22
22
  "typer>=0.15.0",
@@ -26,7 +26,7 @@ dependencies = [
26
26
  hq = "hexaqueue_cli.main:app"
27
27
 
28
28
  [build-system]
29
- requires = ["uv_build>=0.12.3,<0.13.0"]
29
+ requires = ["uv_build>=0.12.3,<0.14.0"]
30
30
  build-backend = "uv_build"
31
31
 
32
32
  [tool.uv.sources]
@@ -8,6 +8,7 @@ Notes/Architectural Intent:
8
8
  from __future__ import annotations
9
9
 
10
10
  from collections.abc import AsyncIterator
11
+ from datetime import UTC, datetime
11
12
  from pathlib import Path
12
13
  from uuid import uuid4
13
14
 
@@ -143,6 +144,28 @@ class LocalClientAdapter(ClientPort):
143
144
  c async for c in self._session.log_stream.stream_logs(job_id, follow=False)
144
145
  ]
145
146
 
147
+ async def get_log_download_url(
148
+ self,
149
+ job_id: str,
150
+ expires_in_seconds: int = 900,
151
+ user_id: str = "default",
152
+ elevate: bool = False,
153
+ ) -> str:
154
+ """Retrieve presigned direct download URL for job execution logs."""
155
+ from hexaqueue_core.domain.cqrs import (
156
+ GetJobLogDownloadUrlQuery,
157
+ PresignedDownloadUrl,
158
+ )
159
+
160
+ qry = GetJobLogDownloadUrlQuery(
161
+ job_id=job_id,
162
+ expires_in_seconds=expires_in_seconds,
163
+ user_id=user_id,
164
+ elevate=elevate,
165
+ )
166
+ res: PresignedDownloadUrl = self._session.pipeline.execute(qry)
167
+ return res.download_url
168
+
146
169
  async def stream_logs(
147
170
  self, job_id: str, follow: bool = False, tail: int | None = None
148
171
  ) -> AsyncIterator[LogChunk]:
@@ -208,8 +231,6 @@ class LocalClientAdapter(ClientPort):
208
231
  is_admin: bool = False,
209
232
  ) -> SchedulingDecisionReport:
210
233
  """Generate explainability report for a job in the local session."""
211
- from datetime import UTC, datetime
212
-
213
234
  from hexaqueue_core.domain.explainability import SchedulerExplainabilityEngine
214
235
  from hexaqueue_core.domain.redaction import MultiTenantRedactionFilter
215
236
  from hexaqueue_core.domain.scheduling import ResourceSlotPool
@@ -234,8 +255,6 @@ class LocalClientAdapter(ClientPort):
234
255
  is_admin: bool = False,
235
256
  ) -> FairShareTreeReport:
236
257
  """Generate fair-share tree report for the local session."""
237
- from datetime import UTC, datetime
238
-
239
258
  from hexaqueue_core.domain.explainability import (
240
259
  SchedulerExplainabilityEngine,
241
260
  )
@@ -21,6 +21,7 @@ from rich.tree import Tree
21
21
 
22
22
  from hexaqueue_cli.domain.models import ClusterStatsReport
23
23
  from hexaqueue_cli.domain.options import OutputFormat
24
+ from hexaqueue_core.domain.bastion import BastionSession
24
25
  from hexaqueue_core.domain.explainability import (
25
26
  FairShareNodeReport,
26
27
  FairShareTreeReport,
@@ -86,11 +87,7 @@ class CliPresenter:
86
87
  if hasattr(report.state, "value")
87
88
  else str(report.state)
88
89
  ),
89
- "outcome": (
90
- report.outcome.value
91
- if hasattr(report.outcome, "value")
92
- else (str(report.outcome) if report.outcome else None)
93
- ),
90
+ "outcome": (report.outcome.value if report.outcome is not None else None),
94
91
  "total_jobs": report.total_jobs,
95
92
  "completed_jobs": report.completed_jobs,
96
93
  "failed_jobs": report.failed_jobs,
@@ -236,11 +233,7 @@ class CliPresenter:
236
233
  )
237
234
 
238
235
  state_val = job.state.value if hasattr(job.state, "value") else str(job.state)
239
- outcome_val = (
240
- job.outcome.value
241
- if hasattr(job.outcome, "value")
242
- else (str(job.outcome) if job.outcome else None)
243
- )
236
+ outcome_val = job.outcome.value if job.outcome is not None else None
244
237
 
245
238
  data = {
246
239
  "id": job.id,
@@ -724,6 +717,72 @@ class CliPresenter:
724
717
  )
725
718
  self._console.print(table)
726
719
 
720
+ def render_bastion_sessions_table(
721
+ self,
722
+ sessions: list[BastionSession],
723
+ format_type: str | OutputFormat = OutputFormat.TABLE,
724
+ ) -> None:
725
+ """Render active administrative bastion sessions in requested format.
726
+
727
+ Args:
728
+ sessions: List of BastionSession records.
729
+ format_type: Output format (table, json, markdown, plain).
730
+ """
731
+ fmt = (
732
+ format_type.value
733
+ if isinstance(format_type, OutputFormat)
734
+ else str(format_type).lower().strip()
735
+ )
736
+ if fmt == OutputFormat.JSON.value:
737
+ dumped = [s.model_dump(mode="json") for s in sessions]
738
+ self._console.print(json.dumps(dumped, indent=2))
739
+ return
740
+
741
+ if fmt == OutputFormat.MARKDOWN.value:
742
+ lines = [
743
+ "| Session ID | Node ID | Operator | Protocol | Created (UTC) | Expires (UTC) | Active |",
744
+ "|---|---|---|---|---|---|---|",
745
+ ]
746
+ for s in sessions:
747
+ created_str = s.created_at.strftime("%Y-%m-%d %H:%M:%S")
748
+ expires_str = s.expires_at.strftime("%Y-%m-%d %H:%M:%S")
749
+ lines.append(
750
+ f"| {s.session_id} | {s.node_id} | {s.operator_id} | {s.protocol.value} | {created_str} | {expires_str} | {s.is_active} |"
751
+ )
752
+ self._console.print("\n".join(lines))
753
+ return
754
+
755
+ if fmt == OutputFormat.PLAIN.value:
756
+ for s in sessions:
757
+ self._console.print(
758
+ f"SESSION={s.session_id} NODE={s.node_id} OPERATOR={s.operator_id} PROTOCOL={s.protocol.value} ACTIVE={s.is_active}"
759
+ )
760
+ return
761
+
762
+ table = Table(title="Active Bastion Sessions", border_style="cyan")
763
+ table.add_column("Session ID", style="bold cyan")
764
+ table.add_column("Node ID", style="green")
765
+ table.add_column("Operator", style="yellow")
766
+ table.add_column("Protocol", style="magenta")
767
+ table.add_column("Created (UTC)", justify="center")
768
+ table.add_column("Expires (UTC)", justify="center")
769
+ table.add_column("Active", justify="center")
770
+
771
+ for s in sessions:
772
+ created_str = s.created_at.strftime("%Y-%m-%d %H:%M:%S")
773
+ expires_str = s.expires_at.strftime("%Y-%m-%d %H:%M:%S")
774
+ active_str = "[bold green]YES[/]" if s.is_active else "[bold red]NO[/]"
775
+ table.add_row(
776
+ s.session_id,
777
+ s.node_id,
778
+ s.operator_id,
779
+ s.protocol.value,
780
+ created_str,
781
+ expires_str,
782
+ active_str,
783
+ )
784
+ self._console.print(table)
785
+
727
786
  def build_top_dashboard(
728
787
  self,
729
788
  stats: ClusterStatsReport,
@@ -4,6 +4,7 @@ Notes/Architectural Intent:
4
4
  Exposes Typer subcommand modules for batch run pipelines and distributed workflow execution.
5
5
  """
6
6
 
7
+ from hexaqueue_cli.commands.admin import app as admin_app
7
8
  from hexaqueue_cli.commands.collateral import app as collateral_app
8
9
  from hexaqueue_cli.commands.node import app as node_app
9
10
  from hexaqueue_cli.commands.run import app as run_app
@@ -11,6 +12,7 @@ from hexaqueue_cli.commands.suite import app as suite_app
11
12
  from hexaqueue_cli.commands.workflow import app as workflow_app
12
13
 
13
14
  __all__ = [
15
+ "admin_app",
14
16
  "collateral_app",
15
17
  "node_app",
16
18
  "run_app",
@@ -0,0 +1,172 @@
1
+ """CLI subcommand group for administrative operations and bastion session governance.
2
+
3
+ Notes/Architectural Intent:
4
+ Provides `hq admin session` commands to mint zero-trust bastion sessions,
5
+ generate cloud-specific tunnel connection commands, audit active sessions,
6
+ and terminate maintenance leases across AWS SSM, GCP IAP, Azure Bastion,
7
+ Tailscale/Teleport, and Native Break-Glass setups.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import asyncio
13
+
14
+ import typer
15
+ from rich.console import Console
16
+ from rich.panel import Panel
17
+
18
+ from hexaqueue_cli.adapters.presenter import CliPresenter
19
+ from hexaqueue_cli.infra.options import format_option, resolve_format
20
+ from hexaqueue_core.adapters.bastion import (
21
+ AWSSSMAdapter,
22
+ AzureBastionAdapter,
23
+ GCPIAPAdapter,
24
+ NativeBreakGlassAdapter,
25
+ TailscaleTeleportAdapter,
26
+ )
27
+ from hexaqueue_core.domain.bastion import BastionProtocolType
28
+ from hexaqueue_core.ports.bastion import BastionAccessPort
29
+
30
+ app = typer.Typer(
31
+ name="admin",
32
+ help="Administrative operations and zero-trust session governance",
33
+ no_args_is_help=True,
34
+ )
35
+ session_app = typer.Typer(
36
+ name="session",
37
+ help="Manage and audit zero-trust bastion operator access sessions",
38
+ no_args_is_help=True,
39
+ )
40
+ app.add_typer(session_app, name="session")
41
+ console = Console()
42
+
43
+
44
+ def get_bastion_adapter(protocol: BastionProtocolType) -> BastionAccessPort:
45
+ """Resolve the appropriate bastion adapter for a given protocol."""
46
+ if protocol == BastionProtocolType.AWS_SSM:
47
+ return AWSSSMAdapter()
48
+ if protocol == BastionProtocolType.GCP_IAP:
49
+ return GCPIAPAdapter()
50
+ if protocol == BastionProtocolType.AZURE_BASTION:
51
+ return AzureBastionAdapter()
52
+ if protocol == BastionProtocolType.TAILSCALE_TELEPORT:
53
+ return TailscaleTeleportAdapter()
54
+ return NativeBreakGlassAdapter()
55
+
56
+
57
+ @session_app.command("create")
58
+ def create_session_cmd(
59
+ node_id: str = typer.Argument(..., help="Target compute node ID"),
60
+ operator: str = typer.Option(
61
+ "default", "--operator", "-o", help="Requesting operator identity"
62
+ ),
63
+ protocol: BastionProtocolType = typer.Option(
64
+ BastionProtocolType.NATIVE_BREAK_GLASS,
65
+ "--protocol",
66
+ "-p",
67
+ help="Bastion access protocol",
68
+ ),
69
+ duration: int = typer.Option(
70
+ 3600, "--duration", "-d", help="Lease duration in seconds"
71
+ ),
72
+ admin: bool = typer.Option(
73
+ False,
74
+ "--admin",
75
+ help="Assert explicit administrative elevation for bastion shell access",
76
+ ),
77
+ ) -> None:
78
+ """Mint an ephemeral zero-trust bastion session and generate connection command."""
79
+ if not admin:
80
+ console.print(
81
+ f"[bold red]Permission denied:[/] Minting bastion session on node '{node_id}' "
82
+ "requires explicit administrative elevation (--admin)."
83
+ )
84
+ raise typer.Exit(code=1)
85
+
86
+ adapter = get_bastion_adapter(protocol)
87
+
88
+ async def _create() -> None:
89
+ try:
90
+ session = await adapter.generate_session_token(
91
+ node_id=node_id,
92
+ operator_id=operator,
93
+ duration_seconds=duration,
94
+ )
95
+ cmd = await adapter.get_connection_command(node_id, session)
96
+
97
+ console.print(
98
+ f"[bold green]✓[/] Bastion session '[bold cyan]{session.session_id}[/]' "
99
+ f"minted for operator '[bold yellow]{operator}[/]'.\n"
100
+ f" Protocol: [magenta]{session.protocol.value}[/]\n"
101
+ f" Expires: [dim]{session.expires_at.strftime('%Y-%m-%d %H:%M:%S UTC')}[/]"
102
+ )
103
+ console.print(
104
+ Panel(
105
+ cmd.as_shell_string(),
106
+ title="[bold green]Connection Command[/]",
107
+ border_style="green",
108
+ )
109
+ )
110
+ except Exception as exc:
111
+ console.print(f"[bold red]Error creating bastion session:[/] {exc}")
112
+ raise typer.Exit(code=1) from exc
113
+
114
+ asyncio.run(_create())
115
+
116
+
117
+ @session_app.command("list")
118
+ def list_sessions_cmd(
119
+ protocol: BastionProtocolType = typer.Option(
120
+ BastionProtocolType.NATIVE_BREAK_GLASS,
121
+ "--protocol",
122
+ "-p",
123
+ help="Target bastion access protocol to audit",
124
+ ),
125
+ format_type: str = format_option(),
126
+ ) -> None:
127
+ """Audit and list active unexpired bastion sessions."""
128
+ resolved_fmt = resolve_format(format_type)
129
+ presenter = CliPresenter(console=console)
130
+ adapter = get_bastion_adapter(protocol)
131
+
132
+ async def _list() -> None:
133
+ try:
134
+ sessions = await adapter.audit_active_sessions()
135
+ presenter.render_bastion_sessions_table(sessions, resolved_fmt)
136
+ except Exception as exc:
137
+ console.print(f"[bold red]Error auditing bastion sessions:[/] {exc}")
138
+ raise typer.Exit(code=1) from exc
139
+
140
+ asyncio.run(_list())
141
+
142
+
143
+ @session_app.command("terminate")
144
+ def terminate_session_cmd(
145
+ session_id: str = typer.Argument(..., help="Target session ID to terminate"),
146
+ protocol: BastionProtocolType = typer.Option(
147
+ BastionProtocolType.NATIVE_BREAK_GLASS,
148
+ "--protocol",
149
+ "-p",
150
+ help="Bastion access protocol governing the session",
151
+ ),
152
+ ) -> None:
153
+ """Revoke an active bastion session immediately."""
154
+ adapter = get_bastion_adapter(protocol)
155
+
156
+ async def _terminate() -> None:
157
+ try:
158
+ await adapter.terminate_session(session_id)
159
+ console.print(
160
+ f"[bold green]✓[/] Bastion session '[bold cyan]{session_id}[/]' successfully terminated."
161
+ )
162
+ except Exception as exc:
163
+ console.print(f"[bold red]Error terminating bastion session:[/] {exc}")
164
+ raise typer.Exit(code=1) from exc
165
+
166
+ asyncio.run(_terminate())
167
+
168
+
169
+ __all__ = [
170
+ "app",
171
+ "get_bastion_adapter",
172
+ ]
@@ -119,6 +119,9 @@ def push_collateral_cmd(
119
119
  asyncio.run(_push())
120
120
 
121
121
 
122
+ # Register stage command alias
123
+ app.command("stage")(push_collateral_cmd)
124
+
122
125
  __all__ = [
123
126
  "app",
124
127
  ]
@@ -0,0 +1,117 @@
1
+ """Model Context Protocol (MCP) server stdio runner command.
2
+
3
+ Notes/Architectural Intent:
4
+ Invokes run_mcp_stdio to run Hexaqueue's central CQRS command and query bus
5
+ over the Model Context Protocol stdio transport for direct orchestration
6
+ by local AI coding assistants (Antigravity, Cursor, Claude Desktop).
7
+ """
8
+
9
+ import typer
10
+ from rich.console import Console
11
+
12
+ from hexaqueue_core.adapters.queue.in_memory import InMemoryJobQueueAdapter
13
+ from hexaqueue_server.adapters.local import LocalSchedulerControllerAdapter
14
+ from hexaqueue_server.adapters.mcp import run_mcp_stdio
15
+ from hexaqueue_server.domain.config import (
16
+ McpConfig,
17
+ McpToolConfig,
18
+ ServerConfig,
19
+ )
20
+ from hexaqueue_server.infra.cqrs import create_hexaqueue_execution_pipeline
21
+
22
+ app = typer.Typer(
23
+ name="mcp",
24
+ help="Manage and run Hexaqueue Model Context Protocol (MCP) server",
25
+ )
26
+ console = Console()
27
+
28
+
29
+ def _build_mcp_config(
30
+ config_file: str | None,
31
+ read_only: bool,
32
+ tools: str | None,
33
+ ) -> McpConfig:
34
+ """Build McpConfig combining configuration file, flags, and tool filters.
35
+
36
+ Args:
37
+ config_file: Optional path to TOML configuration file.
38
+ read_only: Restrict tools to read-only queries.
39
+ tools: Comma-separated list of enabled tool names.
40
+
41
+ Returns:
42
+ Configured McpConfig instance.
43
+ """
44
+ if config_file:
45
+ server_cfg = ServerConfig.load_from_toml(config_file, apply_env=False)
46
+ mcp_cfg = server_cfg.mcp
47
+ else:
48
+ mcp_cfg = McpConfig()
49
+
50
+ if read_only:
51
+ mcp_cfg = mcp_cfg.model_copy(
52
+ update={
53
+ "read_only": True,
54
+ "tools": mcp_cfg.tools.model_copy(
55
+ update={"lease_task": False, "submit_run": False}
56
+ ),
57
+ }
58
+ )
59
+
60
+ if tools:
61
+ tool_list = [t.strip().lower() for t in tools.split(",") if t.strip()]
62
+ tool_cfg = McpToolConfig(
63
+ get_cluster_nodes="get_cluster_nodes" in tool_list,
64
+ get_run_status="get_run_status" in tool_list,
65
+ lease_task="lease_task" in tool_list,
66
+ list_jobs="list_jobs" in tool_list,
67
+ stream_logs="stream_logs" in tool_list,
68
+ submit_run="submit_run" in tool_list,
69
+ )
70
+ mcp_cfg = mcp_cfg.model_copy(update={"tools": tool_cfg})
71
+
72
+ return mcp_cfg.apply_feature_flags()
73
+
74
+
75
+ @app.command("run")
76
+ def run_mcp_cmd(
77
+ name: str = typer.Option("hexaqueue-mcp", "--name", "-n", help="MCP server name"),
78
+ config_file: str | None = typer.Option(
79
+ None,
80
+ "--config",
81
+ "-c",
82
+ help="Path to TOML configuration file",
83
+ ),
84
+ read_only: bool = typer.Option(
85
+ False,
86
+ "--read-only",
87
+ help="Restrict MCP tools to read-only queries (disables mutations)",
88
+ ),
89
+ tools: str | None = typer.Option(
90
+ None,
91
+ "--tools",
92
+ help="Comma-separated list of enabled tools (e.g. 'list_jobs,get_run_status')",
93
+ ),
94
+ ) -> None:
95
+ """Run Hexaqueue MCP driving adapter over stdio transport.
96
+
97
+ Notes/Architectural Intent:
98
+ Standard entrypoint for AI coding assistants configured with local
99
+ subprocesses ('hq mcp run'). Supports read-only sandboxing and granular
100
+ tool filters via command options or TOML configuration.
101
+
102
+ Args:
103
+ name: Name of the MCP server instance.
104
+ config_file: Optional path to TOML configuration file.
105
+ read_only: Restrict MCP tools to read-only queries.
106
+ tools: Comma-separated list of enabled tools.
107
+ """
108
+ try:
109
+ mcp_cfg = _build_mcp_config(config_file, read_only, tools)
110
+ except Exception as exc:
111
+ console.print(f"[bold red]Configuration error:[/] {exc}")
112
+ raise typer.Exit(code=1) from exc
113
+
114
+ queue = InMemoryJobQueueAdapter()
115
+ controller = LocalSchedulerControllerAdapter(queue=queue)
116
+ pipeline = create_hexaqueue_execution_pipeline(controller)
117
+ run_mcp_stdio(pipeline, name=name, config=mcp_cfg)
@@ -22,12 +22,24 @@ from hexaqueue_core.domain.notification import (
22
22
  NotificationPolicy,
23
23
  NotificationTrigger,
24
24
  )
25
+ from hexaqueue_core.infra.notification import NotificationDispatcher
25
26
  from hexaqueue_server.domain.models import RunSubmission
26
27
 
27
28
  app = typer.Typer(help="Pipeline run management commands.")
28
29
  console = Console()
29
30
 
30
31
 
32
+ def _create_apprise_dispatcher() -> NotificationDispatcher | None:
33
+ try:
34
+ from hexastack_events.adapters.notifications.apprise import (
35
+ AppriseNotificationAdapter,
36
+ )
37
+
38
+ return NotificationDispatcher(notification_port=AppriseNotificationAdapter())
39
+ except Exception:
40
+ return None
41
+
42
+
31
43
  def _attach_notifications(
32
44
  submission: RunSubmission, notify: list[str], notify_on: str
33
45
  ) -> None:
@@ -50,10 +62,12 @@ async def _execute_submit_and_watch(
50
62
  free_tier: bool,
51
63
  resolved_fmt: str,
52
64
  presenter: CliPresenter,
65
+ has_notifications: bool = False,
53
66
  ) -> None:
54
67
  """Execute submission and optional status polling."""
55
68
  session_mode = ExecutionMode.FREE_TIER if free_tier else None
56
- session = get_default_session(mode=session_mode)
69
+ dispatcher = _create_apprise_dispatcher() if has_notifications else None
70
+ session = get_default_session(mode=session_mode, notification_dispatcher=dispatcher)
57
71
  await session.start()
58
72
  client = LocalClientAdapter(session=session)
59
73
 
@@ -132,6 +146,7 @@ def submit_cmd(
132
146
  free_tier=free_tier,
133
147
  resolved_fmt=resolved_fmt,
134
148
  presenter=presenter,
149
+ has_notifications=bool(notify),
135
150
  )
136
151
  )
137
152
 
@@ -0,0 +1,198 @@
1
+ """CLI subcommand group for malware scanning, quarantine, and security verification.
2
+
3
+ Notes/Architectural Intent:
4
+ Provides `hq scanner file`, `hq scanner daemon`, and `hq scanner ping` commands
5
+ to manually inspect files or operate the background security worker daemon.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import asyncio
11
+ import logging
12
+ from pathlib import Path
13
+
14
+ import typer
15
+ from rich.console import Console
16
+ from rich.table import Table
17
+
18
+ from hexaqueue_scanner.adapters.clamav import ClamAvDaemonAdapter
19
+ from hexaqueue_scanner.adapters.yara import YaraRuleScannerAdapter
20
+ from hexaqueue_scanner.domain.config import ScannerConfig
21
+ from hexaqueue_scanner.infra.bootstrap import create_scanner_daemon
22
+ from hexaqueue_scanner.ports.engine import MalwareScannerEnginePort
23
+
24
+ app = typer.Typer(
25
+ name="scanner",
26
+ help="Malware inspection, antivirus verification, and quarantine daemon",
27
+ no_args_is_help=True,
28
+ )
29
+ console = Console()
30
+ logger = logging.getLogger(__name__)
31
+
32
+
33
+ @app.command("file")
34
+ def scan_file_cmd(
35
+ file_path: Path = typer.Argument(
36
+ ...,
37
+ help="Path to local file or artifact to scan",
38
+ exists=True,
39
+ readable=True,
40
+ ),
41
+ clamav_socket: str = typer.Option(
42
+ "/var/run/clamav/clamd.ctl",
43
+ "--clamav-socket",
44
+ help="Path to ClamAV UNIX domain socket",
45
+ ),
46
+ yara_rule: list[str] | None = typer.Option(
47
+ None,
48
+ "--rule",
49
+ "-r",
50
+ help="Path to YARA rule file (.yar)",
51
+ ),
52
+ ) -> None:
53
+ """Inspect a local file for virus signatures and YARA heuristic matches.
54
+
55
+ Args:
56
+ file_path: Path to target file on disk.
57
+ clamav_socket: ClamAV socket path.
58
+ yara_rule: Optional list of YARA rule paths.
59
+
60
+ Notes/Architectural Intent:
61
+ Executes immediate multi-engine scan on local target file without requiring
62
+ a running server or collateral registration.
63
+ """
64
+
65
+ async def _run_scan() -> None:
66
+ engines: list[MalwareScannerEnginePort] = []
67
+ if Path(clamav_socket).exists():
68
+ engines.append(
69
+ ClamAvDaemonAdapter(
70
+ config=ScannerConfig().clamav.model_copy(
71
+ update={"socket_path": clamav_socket}
72
+ )
73
+ )
74
+ )
75
+
76
+ if yara_rule:
77
+ engines.append(
78
+ YaraRuleScannerAdapter(
79
+ config=ScannerConfig().yara.model_copy(
80
+ update={"rule_paths": yara_rule}
81
+ )
82
+ )
83
+ )
84
+
85
+ if not engines:
86
+ # Fallback to local heuristic scanner if no daemons available
87
+ console.print(
88
+ "[yellow]Notice:[/] No active ClamAV socket or YARA rules specified. Using default rule evaluation."
89
+ )
90
+ engines.append(YaraRuleScannerAdapter(config=ScannerConfig().yara))
91
+
92
+ console.print(
93
+ f"[bold blue]Scanning[/] {file_path.name} ({file_path.stat().st_size} bytes)..."
94
+ )
95
+ all_clean = True
96
+ table = Table(title=f"Scan Findings: {file_path.name}")
97
+ table.add_column("Scanner Engine", style="cyan")
98
+ table.add_column("Clean?", style="bold")
99
+ table.add_column("Threat / Rule Match", style="red")
100
+
101
+ for engine in engines:
102
+ res = await engine.scan_file(file_path)
103
+ status_str = "[green]CLEAN[/]" if res.is_clean else "[red]INFECTED[/]"
104
+ table.add_row(res.scanner_engine, status_str, res.threat_name or "None")
105
+ if not res.is_clean:
106
+ all_clean = False
107
+
108
+ console.print(table)
109
+ if all_clean:
110
+ console.print("[bold green]✓ Artifact is verified clean.[/]")
111
+ else:
112
+ console.print("[bold red]✗ Threat detected! Artifact flagged.[/]")
113
+ raise typer.Exit(code=2)
114
+
115
+ asyncio.run(_run_scan())
116
+
117
+
118
+ @app.command("daemon")
119
+ def run_daemon_cmd(
120
+ poll_interval: float = typer.Option(
121
+ 1.0,
122
+ "--poll-interval",
123
+ "-i",
124
+ help="Polling interval in seconds for scan task queue",
125
+ ),
126
+ quarantine_on_threat: bool = typer.Option(
127
+ True,
128
+ "--quarantine/--reject",
129
+ help="Whether to isolate threats in quarantine vault or reject outright",
130
+ ),
131
+ ) -> None:
132
+ """Run the background security scanner worker daemon.
133
+
134
+ Args:
135
+ poll_interval: Loop sleep interval in seconds.
136
+ quarantine_on_threat: Flag to quarantine or reject threats.
137
+
138
+ Notes/Architectural Intent:
139
+ Continuously polls for staged collateral bundles, verifies them against
140
+ configured antivirus engines, and promotes or quarantines them.
141
+ """
142
+ config = ScannerConfig(quarantine_on_threat=quarantine_on_threat)
143
+ daemon = create_scanner_daemon(config=config, poll_interval_seconds=poll_interval)
144
+
145
+ async def _run() -> None:
146
+ console.print("[bold green]Starting Hexaqueue Security Scanner Daemon...[/]")
147
+ console.print(f" Poll Interval: {poll_interval}s")
148
+ console.print(f" Quarantine On Threat: {quarantine_on_threat}")
149
+ await daemon.start()
150
+ try:
151
+ while daemon.is_running():
152
+ await asyncio.sleep(1.0)
153
+ except (KeyboardInterrupt, asyncio.CancelledError):
154
+ console.print("\n[yellow]Stopping scanner daemon gracefully...[/]")
155
+ finally:
156
+ await daemon.stop()
157
+ metrics = daemon.get_metrics()
158
+ console.print(
159
+ f"[bold cyan]Scanner Daemon Stopped.[/] Processed: {metrics.total_scans} (Clean: {metrics.approved_scans}, Quarantined: {metrics.quarantined_scans}, Rejected: {metrics.rejected_scans})"
160
+ )
161
+
162
+ asyncio.run(_run())
163
+
164
+
165
+ @app.command("ping")
166
+ def ping_cmd(
167
+ clamav_socket: str = typer.Option(
168
+ "/var/run/clamav/clamd.ctl",
169
+ "--clamav-socket",
170
+ help="Path to ClamAV UNIX domain socket",
171
+ ),
172
+ ) -> None:
173
+ """Check connectivity and responsiveness of security inspection engines.
174
+
175
+ Args:
176
+ clamav_socket: UNIX domain socket path for clamd.
177
+ """
178
+
179
+ async def _ping() -> None:
180
+ clamav = ClamAvDaemonAdapter(
181
+ config=ScannerConfig().clamav.model_copy(
182
+ update={"socket_path": clamav_socket}
183
+ )
184
+ )
185
+ is_healthy = await clamav.ping()
186
+ if is_healthy:
187
+ console.print("[bold green]✓ ClamAV daemon is healthy and reachable.[/]")
188
+ else:
189
+ console.print(
190
+ f"[yellow]! ClamAV daemon is unreachable on {clamav_socket} (daemon may be offline).[/]"
191
+ )
192
+
193
+ asyncio.run(_ping())
194
+
195
+
196
+ __all__ = [
197
+ "app",
198
+ ]
@@ -0,0 +1,181 @@
1
+ """Server daemon start command.
2
+
3
+ Notes/Architectural Intent:
4
+ Invokes run_hexaqueue_server to boot the central scheduler controller
5
+ and API server using the configured ASGI engine (uvicorn or granian)
6
+ and operational role (all, gateway, worker-api, analytics, custom).
7
+ """
8
+
9
+ import typer
10
+ from rich.console import Console
11
+
12
+ from hexaqueue_server.adapters.runner import run_hexaqueue_server
13
+ from hexaqueue_server.domain.config import (
14
+ ServerConfig,
15
+ ServerInterfaceConfig,
16
+ ServerRole,
17
+ )
18
+
19
+ app = typer.Typer(
20
+ name="server",
21
+ help="Manage Hexaqueue central scheduler and HTTP/ASGI API server",
22
+ )
23
+ console = Console()
24
+
25
+
26
+ def _build_server_config(
27
+ config_file: str | None,
28
+ host: str,
29
+ port: int,
30
+ engine: str,
31
+ role: str,
32
+ interfaces: str | None,
33
+ mcp: bool | None,
34
+ workers: int | None,
35
+ reload: bool,
36
+ ) -> ServerConfig:
37
+ """Resolve and build validated ServerConfig combining file, role, CLI, and env settings.
38
+
39
+ Args:
40
+ config_file: Path to TOML configuration file if provided.
41
+ host: Listen host string.
42
+ port: Listen port number.
43
+ engine: ASGI server engine name.
44
+ role: Operational role preset string.
45
+ interfaces: Comma-separated list of active interfaces.
46
+ mcp: Explicit boolean toggle for MCP driving adapter.
47
+ workers: Worker concurrency count.
48
+ reload: Auto-reload boolean.
49
+
50
+ Returns:
51
+ Configured and validated ServerConfig instance.
52
+ """
53
+ if config_file:
54
+ base_cfg = ServerConfig.load_from_toml(config_file, apply_env=False)
55
+ else:
56
+ base_cfg = ServerConfig()
57
+
58
+ resolved_role = (
59
+ ServerRole(role.lower().strip())
60
+ if (role != "all" or not config_file)
61
+ else base_cfg.role
62
+ )
63
+
64
+ if interfaces:
65
+ enabled_list = [i.strip().lower() for i in interfaces.split(",") if i.strip()]
66
+ iface_cfg = ServerInterfaceConfig(
67
+ budget="budget" in enabled_list,
68
+ cluster="cluster" in enabled_list,
69
+ collateral="collateral" in enabled_list,
70
+ jobs="jobs" in enabled_list,
71
+ logs="logs" in enabled_list,
72
+ mcp="mcp" in enabled_list,
73
+ nodes="nodes" in enabled_list,
74
+ runs="runs" in enabled_list,
75
+ webhooks="webhooks" in enabled_list,
76
+ )
77
+ resolved_role = ServerRole.CUSTOM
78
+ elif config_file and role == "all":
79
+ iface_cfg = base_cfg.interfaces
80
+ else:
81
+ iface_cfg = ServerInterfaceConfig.for_role(resolved_role)
82
+
83
+ if mcp is not None:
84
+ iface_cfg = iface_cfg.model_copy(update={"mcp": mcp})
85
+ mcp_cfg = base_cfg.mcp.model_copy(update={"enabled": mcp})
86
+ else:
87
+ mcp_cfg = base_cfg.mcp
88
+
89
+ iface_cfg = iface_cfg.apply_feature_flags()
90
+ mcp_cfg = mcp_cfg.apply_feature_flags()
91
+
92
+ eff_host = host if (host != "0.0.0.0" or not config_file) else base_cfg.host
93
+ eff_port = port if (port != 8000 or not config_file) else base_cfg.port
94
+ eff_engine = engine if (engine != "uvicorn" or not config_file) else base_cfg.engine
95
+
96
+ return ServerConfig(
97
+ host=eff_host,
98
+ port=eff_port,
99
+ engine=eff_engine,
100
+ role=resolved_role,
101
+ interfaces=iface_cfg,
102
+ mcp=mcp_cfg,
103
+ workers=workers if workers is not None else base_cfg.workers,
104
+ reload=reload or base_cfg.reload,
105
+ )
106
+
107
+
108
+ @app.command("start")
109
+ def start_server_cmd(
110
+ config_file: str | None = typer.Option(
111
+ None,
112
+ "--config",
113
+ "-c",
114
+ help="Path to TOML configuration file (e.g. hexaqueue.toml)",
115
+ ),
116
+ host: str = typer.Option("0.0.0.0", "--host", "-h", help="Bind host address"),
117
+ port: int = typer.Option(8000, "--port", "-p", help="Bind port number"),
118
+ engine: str = typer.Option(
119
+ "uvicorn",
120
+ "--engine",
121
+ "-e",
122
+ help="ASGI engine: 'uvicorn' or 'granian'",
123
+ ),
124
+ role: str = typer.Option(
125
+ "all",
126
+ "--role",
127
+ "-r",
128
+ help="Server role: 'all', 'gateway', 'worker-api', 'analytics', 'mcp', 'custom'",
129
+ ),
130
+ interfaces: str | None = typer.Option(
131
+ None,
132
+ "--interfaces",
133
+ help="Comma-separated interface list (e.g. 'runs,webhooks,collateral,mcp')",
134
+ ),
135
+ mcp: bool | None = typer.Option(
136
+ None,
137
+ "--mcp/--no-mcp",
138
+ help="Explicitly enable or disable MCP driving adapter",
139
+ ),
140
+ workers: int | None = typer.Option(
141
+ None, "--workers", "-w", help="Number of worker processes"
142
+ ),
143
+ reload: bool = typer.Option(
144
+ False, "--reload", help="Enable auto-reload on code changes"
145
+ ),
146
+ ) -> None:
147
+ """Start Hexaqueue central scheduler and API server."""
148
+ try:
149
+ cfg = _build_server_config(
150
+ config_file=config_file,
151
+ host=host,
152
+ port=port,
153
+ engine=engine,
154
+ role=role,
155
+ interfaces=interfaces,
156
+ mcp=mcp,
157
+ workers=workers,
158
+ reload=reload,
159
+ )
160
+ except ValueError:
161
+ console.print(f"[bold red]Error:[/] Invalid server role '{role}'.")
162
+ raise typer.Exit(code=1) from None
163
+ except Exception as exc:
164
+ console.print(f"[bold red]Configuration error:[/] {exc}")
165
+ raise typer.Exit(code=1) from exc
166
+
167
+ console.print(
168
+ f"[bold green]Starting Hexaqueue Server[/] (engine=[cyan]{cfg.engine}[/], "
169
+ f"role=[cyan]{cfg.role.value}[/], port=[cyan]{cfg.port}[/])..."
170
+ )
171
+
172
+ try:
173
+ run_hexaqueue_server(config=cfg, fallback_to_uvicorn=True)
174
+ except Exception as exc:
175
+ console.print(f"[bold red]Failed to start server:[/] {exc}")
176
+ raise typer.Exit(code=1) from exc
177
+
178
+
179
+ __all__ = [
180
+ "app",
181
+ ]
@@ -95,7 +95,11 @@ def load_workflow_from_target(target: str) -> WorkflowDefinition:
95
95
  raise typer.BadParameter(msg)
96
96
 
97
97
  if isinstance(wf_candidate, Workflow):
98
- return wf_candidate.compile()
98
+ return (
99
+ wf_candidate.to_definition()
100
+ if hasattr(wf_candidate, "to_definition")
101
+ else wf_candidate.compile()
102
+ )
99
103
  if isinstance(wf_candidate, WorkflowDefinition):
100
104
  return wf_candidate
101
105
 
@@ -12,10 +12,12 @@ from hexaqueue_core.adapters.logging.broadcast import (
12
12
  )
13
13
  from hexaqueue_core.adapters.queue.in_memory import InMemoryJobQueueAdapter
14
14
  from hexaqueue_core.adapters.storage.in_memory import InMemoryStorageVolumeAdapter
15
+ from hexaqueue_core.adapters.storage.presigned import InMemoryPresignedStorageAdapter
15
16
  from hexaqueue_core.domain.config import ExecutionMode
16
17
  from hexaqueue_core.domain.freetier import FreeTierGovernor
17
18
  from hexaqueue_core.infra.notification import NotificationDispatcher
18
19
  from hexaqueue_server.adapters.local import LocalSchedulerControllerAdapter
20
+ from hexaqueue_server.infra.cqrs import create_hexaqueue_execution_pipeline
19
21
  from hexaqueue_worker.adapters.local import LocalSubprocessWorker
20
22
  from hexaqueue_worker.adapters.pty import LocalPtyBridgeAdapter
21
23
  from hexaqueue_worker.adapters.telemetry import LocalTelemetryCollector
@@ -37,20 +39,9 @@ class LocalCliSession:
37
39
  self.log_stream = BroadcastLogStreamAdapter()
38
40
  self.telemetry = LocalTelemetryCollector()
39
41
  self.pty = LocalPtyBridgeAdapter()
40
- if notification_dispatcher is not None:
41
- self.notification_dispatcher = notification_dispatcher
42
- else:
43
- try:
44
- from hexastack_events.adapters.notifications.apprise import (
45
- AppriseNotificationAdapter,
46
- )
47
-
48
- port = AppriseNotificationAdapter()
49
- except Exception:
50
- port = None
51
- self.notification_dispatcher = NotificationDispatcher(
52
- notification_port=port
53
- )
42
+ self.notification_dispatcher = (
43
+ notification_dispatcher or NotificationDispatcher()
44
+ )
54
45
 
55
46
  resolved_mode = mode or (
56
47
  ExecutionMode.FREE_TIER
@@ -63,12 +54,18 @@ class LocalCliSession:
63
54
  governor=governor,
64
55
  mode=resolved_mode,
65
56
  )
57
+ self.presigned_storage = InMemoryPresignedStorageAdapter()
58
+ self.pipeline = create_hexaqueue_execution_pipeline(
59
+ controller=self.controller,
60
+ storage_port=self.presigned_storage,
61
+ )
66
62
  self.worker = LocalSubprocessWorker(
67
63
  queue=self.queue,
68
64
  controller=self.controller,
69
65
  storage=self.storage,
70
66
  log_port=self.log_stream,
71
67
  config=WorkerConfig(concurrency=concurrency, poll_interval_seconds=0.01),
68
+ presigned_storage=self.presigned_storage,
72
69
  )
73
70
 
74
71
  async def start(self) -> None:
@@ -87,11 +84,21 @@ _DEFAULT_SESSION: LocalCliSession | None = None
87
84
  def get_default_session(
88
85
  mode: ExecutionMode | None = None,
89
86
  governor: FreeTierGovernor | None = None,
87
+ notification_dispatcher: NotificationDispatcher | None = None,
90
88
  ) -> LocalCliSession:
91
89
  """Get or initialize the global in-process CLI session."""
92
90
  global _DEFAULT_SESSION
93
- if _DEFAULT_SESSION is None or mode is not None or governor is not None:
94
- _DEFAULT_SESSION = LocalCliSession(mode=mode, governor=governor)
91
+ if (
92
+ _DEFAULT_SESSION is None
93
+ or mode is not None
94
+ or governor is not None
95
+ or notification_dispatcher is not None
96
+ ):
97
+ _DEFAULT_SESSION = LocalCliSession(
98
+ mode=mode,
99
+ governor=governor,
100
+ notification_dispatcher=notification_dispatcher,
101
+ )
95
102
  return _DEFAULT_SESSION
96
103
 
97
104
 
@@ -16,9 +16,13 @@ from rich.console import Console
16
16
 
17
17
  from hexaqueue_cli.adapters.local import LocalClientAdapter
18
18
  from hexaqueue_cli.adapters.presenter import CliPresenter
19
+ from hexaqueue_cli.commands.admin import app as admin_app
19
20
  from hexaqueue_cli.commands.collateral import app as collateral_app
21
+ from hexaqueue_cli.commands.mcp import app as mcp_app
20
22
  from hexaqueue_cli.commands.node import app as node_app
21
23
  from hexaqueue_cli.commands.run import app as run_app
24
+ from hexaqueue_cli.commands.scanner import app as scanner_app
25
+ from hexaqueue_cli.commands.server import app as server_app
22
26
  from hexaqueue_cli.commands.suite import app as suite_app
23
27
  from hexaqueue_cli.commands.workflow import app as workflow_app
24
28
  from hexaqueue_cli.infra.options import format_option, resolve_format
@@ -30,11 +34,16 @@ app = typer.Typer(
30
34
  help="Hexaqueue - Cloud-Agnostic HPC Batch Scheduler and Distributed Job Orchestrator",
31
35
  no_args_is_help=True,
32
36
  )
37
+ app.add_typer(admin_app, name="admin")
33
38
  app.add_typer(run_app, name="run")
34
39
  app.add_typer(workflow_app, name="workflow")
35
40
  app.add_typer(suite_app, name="suite")
36
41
  app.add_typer(collateral_app, name="collateral")
37
42
  app.add_typer(node_app, name="node")
43
+ app.add_typer(server_app, name="server")
44
+ app.add_typer(mcp_app, name="mcp")
45
+ app.add_typer(scanner_app, name="scanner")
46
+ app.add_typer(scanner_app, name="scan")
38
47
 
39
48
  console = Console()
40
49
 
@@ -162,6 +171,9 @@ def logs_cmd(
162
171
  tail: int | None = typer.Option(
163
172
  None, "--tail", "-n", help="Number of lines to show from end"
164
173
  ),
174
+ url_only: bool = typer.Option(
175
+ False, "--url", help="Print presigned direct download URL instead of fetching"
176
+ ),
165
177
  ) -> None:
166
178
  """View stdout and stderr logs for a job.
167
179
 
@@ -169,13 +181,20 @@ def logs_cmd(
169
181
  job_id: Target job identifier.
170
182
  follow: Stream chunks asynchronously in real time.
171
183
  tail: Number of historical lines to tail.
184
+ url_only: Print preauthenticated direct storage download URL.
172
185
 
173
186
  Notes/Architectural Intent:
174
187
  Demuxes real-time stdout, stderr, and system log chunks with ANSI fidelity.
188
+ Supports control-plane deference via direct presigned object storage download URLs.
175
189
  """
176
190
 
177
191
  async def _logs() -> None:
178
192
  client = LocalClientAdapter()
193
+ if url_only:
194
+ dl_url = await client.get_log_download_url(job_id)
195
+ console.print(dl_url)
196
+ return
197
+
179
198
  if follow:
180
199
  await _stream_live_logs(client, job_id, tail)
181
200
  return
@@ -81,6 +81,26 @@ class ClientPort(ABC):
81
81
  async def get_logs(self, job_id: str) -> list[LogChunk]:
82
82
  """Retrieve historical logs for a job."""
83
83
 
84
+ @abstractmethod
85
+ async def get_log_download_url(
86
+ self,
87
+ job_id: str,
88
+ expires_in_seconds: int = 900,
89
+ user_id: str = "default",
90
+ elevate: bool = False,
91
+ ) -> str:
92
+ """Retrieve presigned direct download URL for job execution logs.
93
+
94
+ Args:
95
+ job_id: Target job identifier.
96
+ expires_in_seconds: Presigned download link expiration TTL in seconds.
97
+ user_id: Identity of requesting user.
98
+ elevate: Explicit administrative privilege elevation flag.
99
+
100
+ Returns:
101
+ Preauthenticated direct object storage download URL.
102
+ """
103
+
84
104
  @abstractmethod
85
105
  def stream_logs(
86
106
  self, job_id: str, follow: bool = False, tail: int | None = None
File without changes