testzeus-cli 0.0.25__tar.gz → 0.0.27__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 (40) hide show
  1. testzeus_cli-0.0.25/README.md → testzeus_cli-0.0.27/PKG-INFO +81 -0
  2. testzeus_cli-0.0.25/PKG-INFO → testzeus_cli-0.0.27/README.md +51 -30
  3. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/pyproject.toml +4 -4
  4. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/cli.py +6 -0
  5. testzeus_cli-0.0.27/testzeus_cli/commands/agent_harness.py +289 -0
  6. testzeus_cli-0.0.27/testzeus_cli/commands/connected_environments.py +123 -0
  7. testzeus_cli-0.0.27/testzeus_cli/commands/test_report_runs.py +164 -0
  8. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/LICENSE +0 -0
  9. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/__init__.py +0 -0
  10. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/auth.py +0 -0
  11. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/__init__.py +0 -0
  12. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/daemon.py +0 -0
  13. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/device_pool.py +0 -0
  14. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/environments.py +0 -0
  15. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/extensions.py +0 -0
  16. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/hypermind_code_blocks.py +0 -0
  17. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/knowledge_bases.py +0 -0
  18. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/notification_channels.py +0 -0
  19. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/tags.py +0 -0
  20. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_data.py +0 -0
  21. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_report_schedules.py +0 -0
  22. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_run_groups.py +0 -0
  23. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_runs.py +0 -0
  24. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_suite_node_runs.py +0 -0
  25. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_suite_runs.py +0 -0
  26. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_suite_schedules.py +0 -0
  27. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/test_suites.py +0 -0
  28. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/tests.py +0 -0
  29. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/tests_ai_generator.py +0 -0
  30. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/tests_authoring.py +0 -0
  31. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/commands/user_integrations.py +0 -0
  32. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/config.py +0 -0
  33. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/utils/__init__.py +0 -0
  34. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/utils/auth.py +0 -0
  35. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/utils/client.py +0 -0
  36. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/utils/files.py +0 -0
  37. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/utils/formatters.py +0 -0
  38. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/utils/links.py +0 -0
  39. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/utils/profile.py +0 -0
  40. {testzeus_cli-0.0.25 → testzeus_cli-0.0.27}/testzeus_cli/utils/validators.py +0 -0
@@ -1,3 +1,32 @@
1
+ Metadata-Version: 2.4
2
+ Name: testzeus-cli
3
+ Version: 0.0.27
4
+ Summary: Command-line interface for TestZeus testing platform
5
+ License-File: LICENSE
6
+ Author: Shriyansh Agnihotri
7
+ Author-email: shriyansh@testzeus.com
8
+ Requires-Python: >=3.11,<3.14
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Provides-Extra: daemon
15
+ Requires-Dist: Pygments (==2.20.0)
16
+ Requires-Dist: aiohttp (>=3.14.1,<4.0.0)
17
+ Requires-Dist: click (>=8.1.3,<9.0.0)
18
+ Requires-Dist: cryptography (>=48.0.1,<49.0.0)
19
+ Requires-Dist: ipdb (>=0.13.13,<0.14.0)
20
+ Requires-Dist: keyring (>=24.0.0,<25.0.0)
21
+ Requires-Dist: pocketbase (>=0.15.0,<0.16.0)
22
+ Requires-Dist: pydantic (>=2.0.0,<3.0.0)
23
+ Requires-Dist: pyyaml (>=6.0,<7.0)
24
+ Requires-Dist: rich (>=13.3.1,<14.0.0)
25
+ Requires-Dist: testzeus-sdk (>=0.0.24,<0.1.0)
26
+ Requires-Dist: toml (>=0.10.2,<0.11.0)
27
+ Project-URL: Repository, https://github.com/test-zeus-ai/testzeus-cli
28
+ Description-Content-Type: text/markdown
29
+
1
30
  # TestZeus CLI
2
31
 
3
32
  A powerful command-line interface for the TestZeus testing platform.
@@ -937,6 +966,57 @@ testzeus tests-authoring manual --name my_test --feature "Feature: Login..."
937
966
 
938
967
  See `testzeus_cli/commands/tests_authoring.py` for implementation.
939
968
 
969
+ ## Agent Harness
970
+
971
+ Adversarial testing of AI agents (Salesforce Agentforce). List agents, list or
972
+ generate adversarial pathways, run simulations, and monitor / cancel them. Sits
973
+ on the `client.agent_harness` SDK manager.
974
+
975
+ ### List Agents
976
+
977
+ ```bash
978
+ testzeus agent-harness list-agents
979
+ testzeus agent-harness list-agents --status active --search billing
980
+ ```
981
+
982
+ ### Get Agent Details
983
+
984
+ ```bash
985
+ testzeus agent-harness get-agent <agent_id>
986
+ ```
987
+
988
+ ### Pathways
989
+
990
+ ```bash
991
+ # List adversarial pathways for an agent
992
+ testzeus agent-harness list-pathways <agent_id>
993
+
994
+ # Start an AI pathway-generation job for a Salesforce agent profile
995
+ testzeus agent-harness generate-pathways <agent_profile> --prompt "probe for PII leaks" --num 5
996
+
997
+ # Soft-delete a pathway
998
+ testzeus agent-harness delete-pathway <pathway_id>
999
+ ```
1000
+
1001
+ ### Run Simulations
1002
+
1003
+ ```bash
1004
+ # Start a run over one or more pathways
1005
+ testzeus agent-harness run <agent_id> --pathway <pathway_id> --pathway <pathway_id>
1006
+
1007
+ # Run and wait for it to finish (polls status)
1008
+ testzeus agent-harness run <agent_id> --pathway <pathway_id> --wait --timeout 1800
1009
+ ```
1010
+
1011
+ ### Monitor and Cancel
1012
+
1013
+ ```bash
1014
+ testzeus agent-harness status <group_id>
1015
+ testzeus agent-harness cancel <group_id>
1016
+ ```
1017
+
1018
+ See `testzeus_cli/commands/agent_harness.py` for implementation.
1019
+
940
1020
  ## Configuration
941
1021
 
942
1022
  The CLI stores configuration and credentials in your user's config directory. Different profiles can be used to manage multiple TestZeus environments.
@@ -1090,3 +1170,4 @@ The TestZeus CLI uses GitHub Actions for automated releases to PyPI. To create a
1090
1170
  - Commit and create a git tag
1091
1171
  - Push changes and tags to GitHub
1092
1172
  3. The tag push will automatically trigger the GitHub Actions publish workflow
1173
+
@@ -1,32 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: testzeus-cli
3
- Version: 0.0.25
4
- Summary: Command-line interface for TestZeus testing platform
5
- License-File: LICENSE
6
- Author: Shriyansh Agnihotri
7
- Author-email: shriyansh@testzeus.com
8
- Requires-Python: >=3.11,<3.14
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.11
12
- Classifier: Programming Language :: Python :: 3.12
13
- Classifier: Programming Language :: Python :: 3.13
14
- Provides-Extra: daemon
15
- Requires-Dist: Pygments (==2.20.0)
16
- Requires-Dist: aiohttp (==3.13.4)
17
- Requires-Dist: click (>=8.1.3,<9.0.0)
18
- Requires-Dist: cryptography (==46.0.7)
19
- Requires-Dist: ipdb (>=0.13.13,<0.14.0)
20
- Requires-Dist: keyring (>=24.0.0,<25.0.0)
21
- Requires-Dist: pocketbase (>=0.15.0,<0.16.0)
22
- Requires-Dist: pydantic (>=2.0.0,<3.0.0)
23
- Requires-Dist: pyyaml (>=6.0,<7.0)
24
- Requires-Dist: rich (>=13.3.1,<14.0.0)
25
- Requires-Dist: testzeus-sdk (>=0.0.19,<0.1.0)
26
- Requires-Dist: toml (>=0.10.2,<0.11.0)
27
- Project-URL: Repository, https://github.com/test-zeus-ai/testzeus-cli
28
- Description-Content-Type: text/markdown
29
-
30
1
  # TestZeus CLI
31
2
 
32
3
  A powerful command-line interface for the TestZeus testing platform.
@@ -966,6 +937,57 @@ testzeus tests-authoring manual --name my_test --feature "Feature: Login..."
966
937
 
967
938
  See `testzeus_cli/commands/tests_authoring.py` for implementation.
968
939
 
940
+ ## Agent Harness
941
+
942
+ Adversarial testing of AI agents (Salesforce Agentforce). List agents, list or
943
+ generate adversarial pathways, run simulations, and monitor / cancel them. Sits
944
+ on the `client.agent_harness` SDK manager.
945
+
946
+ ### List Agents
947
+
948
+ ```bash
949
+ testzeus agent-harness list-agents
950
+ testzeus agent-harness list-agents --status active --search billing
951
+ ```
952
+
953
+ ### Get Agent Details
954
+
955
+ ```bash
956
+ testzeus agent-harness get-agent <agent_id>
957
+ ```
958
+
959
+ ### Pathways
960
+
961
+ ```bash
962
+ # List adversarial pathways for an agent
963
+ testzeus agent-harness list-pathways <agent_id>
964
+
965
+ # Start an AI pathway-generation job for a Salesforce agent profile
966
+ testzeus agent-harness generate-pathways <agent_profile> --prompt "probe for PII leaks" --num 5
967
+
968
+ # Soft-delete a pathway
969
+ testzeus agent-harness delete-pathway <pathway_id>
970
+ ```
971
+
972
+ ### Run Simulations
973
+
974
+ ```bash
975
+ # Start a run over one or more pathways
976
+ testzeus agent-harness run <agent_id> --pathway <pathway_id> --pathway <pathway_id>
977
+
978
+ # Run and wait for it to finish (polls status)
979
+ testzeus agent-harness run <agent_id> --pathway <pathway_id> --wait --timeout 1800
980
+ ```
981
+
982
+ ### Monitor and Cancel
983
+
984
+ ```bash
985
+ testzeus agent-harness status <group_id>
986
+ testzeus agent-harness cancel <group_id>
987
+ ```
988
+
989
+ See `testzeus_cli/commands/agent_harness.py` for implementation.
990
+
969
991
  ## Configuration
970
992
 
971
993
  The CLI stores configuration and credentials in your user's config directory. Different profiles can be used to manage multiple TestZeus environments.
@@ -1119,4 +1141,3 @@ The TestZeus CLI uses GitHub Actions for automated releases to PyPI. To create a
1119
1141
  - Commit and create a git tag
1120
1142
  - Push changes and tags to GitHub
1121
1143
  3. The tag push will automatically trigger the GitHub Actions publish workflow
1122
-
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "testzeus-cli"
7
- version = "0.0.25"
7
+ version = "0.0.27"
8
8
  description = "Command-line interface for TestZeus testing platform"
9
9
  authors = ["Shriyansh Agnihotri <shriyansh@testzeus.com>"]
10
10
  readme = "README.md"
@@ -22,12 +22,12 @@ pydantic = "^2.0.0"
22
22
  pyyaml = "^6.0"
23
23
  keyring = "^24.0.0"
24
24
  ipdb = "^0.13.13"
25
- testzeus-sdk = ">=0.0.19,<0.1.0"
25
+ testzeus-sdk = ">=0.0.24,<0.1.0"
26
26
  pocketbase = "^0.15.0"
27
27
  toml = "^0.10.2"
28
- aiohttp = "3.13.4"
28
+ aiohttp = "^3.14.1"
29
29
  Pygments = "2.20.0"
30
- cryptography = "46.0.7"
30
+ cryptography = "^48.0.1"
31
31
 
32
32
  [tool.poetry.extras]
33
33
  daemon = [
@@ -27,7 +27,9 @@ from testzeus_cli.commands.test_data import test_data_group
27
27
  from testzeus_cli.commands.tags import tags_group
28
28
  from testzeus_cli.commands.device_pool import device_pool_group
29
29
  from testzeus_cli.commands.environments import environments_group
30
+ from testzeus_cli.commands.connected_environments import connected_environments_group
30
31
  from testzeus_cli.commands.test_report_schedules import test_report_schedules_group
32
+ from testzeus_cli.commands.test_report_runs import test_report_runs_group
31
33
  from testzeus_cli.commands.notification_channels import notification_channels_group
32
34
  from testzeus_cli.commands.extensions import extensions_group
33
35
  from testzeus_cli.commands.tests_ai_generator import tests_ai_generator_group
@@ -35,6 +37,7 @@ from testzeus_cli.commands.hypermind_code_blocks import hypermind_code_blocks_gr
35
37
  from testzeus_cli.commands.user_integrations import user_integrations_group
36
38
  from testzeus_cli.commands.tests_authoring import tests_authoring_group
37
39
  from testzeus_cli.commands.knowledge_bases import knowledge_bases_group
40
+ from testzeus_cli.commands.agent_harness import agent_harness_group
38
41
 
39
42
  # Daemon dependencies (fastapi/uvicorn/sse-starlette) are optional extras.
40
43
  # Keep CLI core commands (e.g. session-exchange) functional when extras are absent.
@@ -92,7 +95,9 @@ cli.add_command(test_data_group)
92
95
  cli.add_command(tags_group)
93
96
  cli.add_command(device_pool_group)
94
97
  cli.add_command(environments_group)
98
+ cli.add_command(connected_environments_group)
95
99
  cli.add_command(test_report_schedules_group)
100
+ cli.add_command(test_report_runs_group)
96
101
  cli.add_command(notification_channels_group)
97
102
  cli.add_command(extensions_group)
98
103
  cli.add_command(tests_ai_generator_group)
@@ -100,6 +105,7 @@ cli.add_command(hypermind_code_blocks_group)
100
105
  cli.add_command(user_integrations_group)
101
106
  cli.add_command(tests_authoring_group)
102
107
  cli.add_command(knowledge_bases_group)
108
+ cli.add_command(agent_harness_group)
103
109
  if daemon_command is not None:
104
110
  cli.add_command(daemon_command)
105
111
  # New command groups can be added here when implemented
@@ -0,0 +1,289 @@
1
+ """
2
+ Agent Harness commands for TestZeus CLI.
3
+
4
+ Adversarial testing of AI agents (Salesforce Agentforce): list agents, list or
5
+ generate adversarial pathways, run simulations, and monitor / cancel them.
6
+ """
7
+
8
+ import asyncio
9
+ from typing import Any, Dict
10
+
11
+ import click
12
+ from rich.console import Console
13
+ from testzeus_sdk import TestZeusClient
14
+ from testzeus_cli.config import get_client_config
15
+ from testzeus_cli.utils.formatters import format_output, print_message
16
+ from testzeus_cli.utils.auth import initialize_client_with_token
17
+ from testzeus_cli.utils.validators import validate_id
18
+ from testzeus_cli.utils.links import print_platform_link
19
+
20
+ console = Console()
21
+
22
+
23
+ def _pathway_row(data: Dict[str, Any]) -> Dict[str, Any]:
24
+ """Trim a pathway record to the columns worth showing in a list.
25
+
26
+ Dumping the raw record lets the generic 6-column table fill up with noise
27
+ (tenant/created_by/modified_by) and hide the useful fields, so project to
28
+ name/risk_level/objective/status explicitly.
29
+ """
30
+ objective = data.get("objective") or ""
31
+ if len(objective) > 80:
32
+ objective = objective[:77] + "..."
33
+ return {
34
+ "id": data.get("id"),
35
+ "name": data.get("name"),
36
+ "risk_level": data.get("risk_level"),
37
+ "objective": objective,
38
+ "status": data.get("status"),
39
+ }
40
+
41
+
42
+ def _client(ctx):
43
+ """Build the config + client tuple used by every command."""
44
+ config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
45
+ return TestZeusClient(**config), token, tenant_id, user_id
46
+
47
+
48
+ async def _auth(client, token, tenant_id=None):
49
+ if token:
50
+ # Thread the profile tenant so tenant injection works even when the token
51
+ # has no tenant claim; otherwise create/run fails deep in the SDK with
52
+ # "No tenant ID available when adding tenant ID".
53
+ initialize_client_with_token(client, token, profile_tenant_id=tenant_id)
54
+ else:
55
+ await client.ensure_authenticated()
56
+ if not hasattr(client, "agent_harness"):
57
+ raise click.ClickException("Agent Harness needs a newer testzeus-sdk. Upgrade with: pip install -U testzeus-sdk")
58
+
59
+
60
+ @click.group(name="agent-harness")
61
+ def agent_harness_group():
62
+ """Adversarial testing of AI agents (Agent Harness)"""
63
+ pass
64
+
65
+
66
+ @agent_harness_group.command(name="list-agents")
67
+ @click.option("--page", default=1, help="Page number")
68
+ @click.option("--per-page", default=50, help="Results per page")
69
+ @click.option("--status", help="Filter by status")
70
+ @click.option("--search", help="Search term")
71
+ @click.pass_context
72
+ def list_agents(ctx, page, per_page, status, search):
73
+ """List available agents"""
74
+
75
+ async def _run():
76
+ client, token, tenant_id, _ = _client(ctx)
77
+ async with client:
78
+ await _auth(client, token, tenant_id)
79
+ return await client.agent_harness.list_agents(page=page, per_page=per_page, status=status, search=search)
80
+
81
+ try:
82
+ print_platform_link(ctx, "agent-harness")
83
+ format_output(asyncio.run(_run()), ctx.obj["FORMAT"])
84
+ except Exception as e:
85
+ print_message(f"[red]Error listing agents: {str(e)}[/red]", ctx.obj["FORMAT"])
86
+ raise click.Abort()
87
+
88
+
89
+ @agent_harness_group.command(name="list-pathways")
90
+ @click.argument("agent_id")
91
+ @click.option("--page", default=1, help="Page number")
92
+ @click.option("--per-page", default=50, help="Results per page")
93
+ @click.pass_context
94
+ def list_pathways(ctx, agent_id, page, per_page):
95
+ """List adversarial pathways for an agent"""
96
+
97
+ # NOTE: unlike the generic `list` commands (which take --filters/-f + --sort),
98
+ # pathways are always scoped to a single agent, so this takes an agent_id
99
+ # argument instead. The SDK builds the agent_id filter via the shared filter
100
+ # builder; add --filters/--sort here if the manager grows to support them.
101
+ async def _run():
102
+ client, token, tenant_id, _ = _client(ctx)
103
+ async with client:
104
+ await _auth(client, token, tenant_id)
105
+ agent = validate_id(agent_id, "agent")
106
+ res = await client.agent_harness.list_pathways(agent_id=agent, page=page, per_page=per_page)
107
+ # get_list returns AdversaryPathways models; project to the useful
108
+ # columns (name/risk/objective/status) so they aren't crowded out.
109
+ res["items"] = [_pathway_row(p.data) for p in res.get("items", [])]
110
+ return res
111
+
112
+ try:
113
+ print_platform_link(ctx, "agent-harness")
114
+ format_output(asyncio.run(_run()), ctx.obj["FORMAT"])
115
+ except Exception as e:
116
+ print_message(f"[red]Error listing pathways: {str(e)}[/red]", ctx.obj["FORMAT"])
117
+ raise click.Abort()
118
+
119
+
120
+ @agent_harness_group.command(name="generate-pathways")
121
+ @click.argument("agent_profile")
122
+ @click.option("--prompt", required=True, help="Directional prompt for pathway generation")
123
+ @click.option("--name", help="Generation job name (auto-generated if omitted)")
124
+ @click.option("--agent-name", help="Agent display name")
125
+ @click.option("--num", type=int, help="Number of pathways to generate")
126
+ @click.option("--allow-destructive", is_flag=True, default=False, help="Allow destructive scenarios")
127
+ @click.pass_context
128
+ def generate_pathways(ctx, agent_profile, prompt, name, agent_name, num, allow_destructive):
129
+ """Start an AI pathway-generation job for a Salesforce agent profile"""
130
+
131
+ async def _run():
132
+ client, token, tenant_id, _ = _client(ctx)
133
+ async with client:
134
+ await _auth(client, token, tenant_id)
135
+ # tenant/created_by/modified_by are auto-filled by the SDK manager.
136
+ return await client.agent_harness.generate_pathways(
137
+ agent_profile=agent_profile,
138
+ directional_prompt=prompt,
139
+ name=name,
140
+ agent_name=agent_name,
141
+ num_pathways=num,
142
+ allow_destructive=allow_destructive,
143
+ )
144
+
145
+ try:
146
+ result = asyncio.run(_run())
147
+ print_message("[green]Pathway generation started[/green]", ctx.obj["FORMAT"])
148
+ print_platform_link(ctx, "agent-harness")
149
+ format_output(result.data, ctx.obj["FORMAT"])
150
+ except Exception as e:
151
+ print_message(f"[red]Error generating pathways: {str(e)}[/red]", ctx.obj["FORMAT"])
152
+ raise click.Abort()
153
+
154
+
155
+ @agent_harness_group.command(name="run")
156
+ @click.argument("agent_id")
157
+ @click.option("--pathway", "pathways", multiple=True, required=True, help="Pathway ID to run (repeatable)")
158
+ @click.option("--name", help="Run name (auto-generated if omitted)")
159
+ @click.option("--agent-name", help="Agent display name")
160
+ @click.option("--run-as-profile", help="Salesforce profile to run as (RBAC)")
161
+ @click.option("--wait", is_flag=True, default=False, help="Wait and poll until the run finishes")
162
+ @click.option("--timeout", default=1800.0, help="Max seconds to wait when --wait is set")
163
+ @click.pass_context
164
+ def run(ctx, agent_id, pathways, name, agent_name, run_as_profile, wait, timeout):
165
+ """Run adversarial simulations for the given pathways"""
166
+
167
+ async def _run():
168
+ client, token, tenant_id, _ = _client(ctx)
169
+ async with client:
170
+ await _auth(client, token, tenant_id)
171
+ agent = validate_id(agent_id, "agent")
172
+ # tenant/created_by/modified_by are auto-filled by the SDK manager.
173
+ if wait:
174
+ return await client.agent_harness.run_and_wait(
175
+ agent,
176
+ list(pathways),
177
+ name=name,
178
+ agent_name=agent_name,
179
+ run_as_profile=run_as_profile,
180
+ timeout=timeout,
181
+ )
182
+ return await client.agent_harness.run(
183
+ agent,
184
+ list(pathways),
185
+ name=name,
186
+ agent_name=agent_name,
187
+ run_as_profile=run_as_profile,
188
+ )
189
+
190
+ try:
191
+ result = asyncio.run(_run())
192
+ if not wait:
193
+ # run() returns an AdversaryPathwaysGroup model; run_and_wait returns a status dict.
194
+ group_id = result.id
195
+ print_message(
196
+ f"[green]Run started (group {group_id}). Poll with: testzeus agent-harness status {group_id}[/green]",
197
+ ctx.obj["FORMAT"],
198
+ )
199
+ print_platform_link(ctx, "agent-harness")
200
+ format_output(result.data, ctx.obj["FORMAT"])
201
+ else:
202
+ format_output(result, ctx.obj["FORMAT"])
203
+ except Exception as e:
204
+ print_message(f"[red]Error running simulations: {str(e)}[/red]", ctx.obj["FORMAT"])
205
+ raise click.Abort()
206
+
207
+
208
+ @agent_harness_group.command(name="status")
209
+ @click.argument("group_id")
210
+ @click.pass_context
211
+ def status(ctx, group_id):
212
+ """Get the status/results of a simulation run group"""
213
+
214
+ async def _run():
215
+ client, token, tenant_id, _ = _client(ctx)
216
+ async with client:
217
+ await _auth(client, token, tenant_id)
218
+ return await client.agent_harness.get_status(validate_id(group_id, "group"))
219
+
220
+ try:
221
+ format_output(asyncio.run(_run()), ctx.obj["FORMAT"])
222
+ except Exception as e:
223
+ print_message(f"[red]Error getting status: {str(e)}[/red]", ctx.obj["FORMAT"])
224
+ raise click.Abort()
225
+
226
+
227
+ @agent_harness_group.command(name="cancel")
228
+ @click.argument("group_id")
229
+ @click.pass_context
230
+ def cancel(ctx, group_id):
231
+ """Cancel a running simulation group"""
232
+
233
+ async def _run():
234
+ client, token, tenant_id, _ = _client(ctx)
235
+ async with client:
236
+ await _auth(client, token, tenant_id)
237
+ return await client.agent_harness.cancel(validate_id(group_id, "group"))
238
+
239
+ try:
240
+ asyncio.run(_run())
241
+ print_message(f"[green]Cancelled simulation group {group_id}[/green]", ctx.obj["FORMAT"])
242
+ except Exception as e:
243
+ print_message(f"[red]Error cancelling group: {str(e)}[/red]", ctx.obj["FORMAT"])
244
+ raise click.Abort()
245
+
246
+
247
+ @agent_harness_group.command(name="get-agent")
248
+ @click.argument("agent_id")
249
+ @click.pass_context
250
+ def get_agent(ctx, agent_id):
251
+ """Get full detail for a single agent"""
252
+
253
+ async def _run():
254
+ client, token, tenant_id, _ = _client(ctx)
255
+ async with client:
256
+ await _auth(client, token, tenant_id)
257
+ return await client.agent_harness.get_agent(validate_id(agent_id, "agent"))
258
+
259
+ try:
260
+ print_platform_link(ctx, "agent-harness")
261
+ result = asyncio.run(_run())
262
+ # The gateway wraps the agent under "item"; unwrap it so the full record
263
+ # renders as a field table instead of collapsing to one "name (id)" line.
264
+ if isinstance(result, dict) and isinstance(result.get("item"), dict):
265
+ result = result["item"]
266
+ format_output(result, ctx.obj["FORMAT"])
267
+ except Exception as e:
268
+ print_message(f"[red]Error getting agent: {str(e)}[/red]", ctx.obj["FORMAT"])
269
+ raise click.Abort()
270
+
271
+
272
+ @agent_harness_group.command(name="delete-pathway")
273
+ @click.argument("pathway_id")
274
+ @click.pass_context
275
+ def delete_pathway(ctx, pathway_id):
276
+ """Soft-delete an adversarial pathway"""
277
+
278
+ async def _run():
279
+ client, token, tenant_id, _ = _client(ctx)
280
+ async with client:
281
+ await _auth(client, token, tenant_id)
282
+ return await client.agent_harness.delete_pathway(validate_id(pathway_id, "pathway"))
283
+
284
+ try:
285
+ asyncio.run(_run())
286
+ print_message(f"[green]Deleted pathway {pathway_id}[/green]", ctx.obj["FORMAT"])
287
+ except Exception as e:
288
+ print_message(f"[red]Error deleting pathway: {str(e)}[/red]", ctx.obj["FORMAT"])
289
+ raise click.Abort()
@@ -0,0 +1,123 @@
1
+ """
2
+ Connected environment management commands for TestZeus CLI.
3
+
4
+ Scoped to read + rename only: connected environments are created and their code /
5
+ metadata files are managed from the web UI, so the CLI exposes just ``list``,
6
+ ``get`` and a name-only ``update``.
7
+ """
8
+
9
+ import asyncio
10
+ import click
11
+ from rich.console import Console
12
+ from testzeus_sdk import TestZeusClient
13
+ from testzeus_cli.config import get_client_config
14
+ from testzeus_cli.utils.formatters import format_output, print_message
15
+ from testzeus_cli.utils.auth import initialize_client_with_token
16
+ from testzeus_cli.utils.validators import parse_key_value_pairs, validate_tenant_ownership
17
+
18
+ console = Console()
19
+
20
+
21
+ @click.group()
22
+ def connected_environments_group():
23
+ """Manage connected environments in TestZeus"""
24
+ pass
25
+
26
+
27
+ @connected_environments_group.command(name="list")
28
+ @click.option("--filters", "-f", multiple=True, help="Filter results (format: key=value)")
29
+ @click.option("--sort", help="Sort by field")
30
+ @click.option("--expand", help="Expand related entities")
31
+ @click.pass_context
32
+ def list(ctx, filters, sort, expand):
33
+ """List all connected environments"""
34
+
35
+ async def _run():
36
+ config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
37
+ client = TestZeusClient(**config)
38
+ filter_dict = parse_key_value_pairs(filters) if filters else {}
39
+ async with client:
40
+ if token:
41
+ initialize_client_with_token(client, token)
42
+ else:
43
+ await client.ensure_authenticated()
44
+ result = await client.connected_environments.get_list(expand=expand, sort=sort, filters=filter_dict)
45
+ return result
46
+
47
+ try:
48
+ result = asyncio.run(_run())
49
+ format_output(result, ctx.obj["FORMAT"])
50
+ except Exception as e:
51
+ print_message(
52
+ f"[red]Error listing connected environments: {str(e)}[/red]",
53
+ ctx.obj["FORMAT"],
54
+ )
55
+ raise click.Abort()
56
+
57
+
58
+ @connected_environments_group.command(name="get")
59
+ @click.argument("conn_env_id")
60
+ @click.option("--expand", help="Expand related entities")
61
+ @click.pass_context
62
+ def get(ctx, conn_env_id, expand):
63
+ """Get a connected environment by ID"""
64
+
65
+ async def _run():
66
+ config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
67
+ client = TestZeusClient(**config)
68
+ async with client:
69
+ if token:
70
+ initialize_client_with_token(client, token)
71
+ else:
72
+ await client.ensure_authenticated()
73
+ conn_env = await client.connected_environments.get_one(conn_env_id, expand=expand)
74
+ return conn_env.data
75
+
76
+ try:
77
+ result = asyncio.run(_run())
78
+ format_output(result, ctx.obj["FORMAT"])
79
+ except Exception as e:
80
+ print_message(
81
+ f"[red]Error getting connected environment: {str(e)}[/red]",
82
+ ctx.obj["FORMAT"],
83
+ )
84
+ raise click.Abort()
85
+
86
+
87
+ @connected_environments_group.command(name="update")
88
+ @click.argument("conn_env_id")
89
+ @click.option("--name", required=True, help="New connected environment name")
90
+ @click.pass_context
91
+ def update(ctx, conn_env_id, name):
92
+ """Update a connected environment's name"""
93
+
94
+ async def _run():
95
+ config, token, tenant_id, user_id = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
96
+ client = TestZeusClient(**config)
97
+ async with client:
98
+ if token:
99
+ initialize_client_with_token(client, token)
100
+ else:
101
+ await client.ensure_authenticated()
102
+
103
+ # Validate tenant ownership before updating.
104
+ conn_env = await client.connected_environments.get_one(conn_env_id)
105
+ validate_tenant_ownership(conn_env.data, tenant_id, "connected environment")
106
+
107
+ updates = {"tenant": tenant_id, "modified_by": user_id, "name": name}
108
+ updated = await client.connected_environments.update(conn_env_id, updates)
109
+ return updated.data
110
+
111
+ try:
112
+ result = asyncio.run(_run())
113
+ print_message(
114
+ "[green]Connected environment updated successfully[/green]",
115
+ ctx.obj["FORMAT"],
116
+ )
117
+ format_output(result, ctx.obj["FORMAT"])
118
+ except Exception as e:
119
+ print_message(
120
+ f"[red]Error updating connected environment: {str(e)}[/red]",
121
+ ctx.obj["FORMAT"],
122
+ )
123
+ raise click.Abort()
@@ -0,0 +1,164 @@
1
+ """
2
+ Test report run management commands for TestZeus CLI.
3
+ """
4
+
5
+ import asyncio
6
+ import click
7
+ from rich.console import Console
8
+ from testzeus_sdk import TestZeusClient
9
+ from testzeus_cli.config import get_client_config
10
+ from testzeus_cli.utils.formatters import format_output, print_message
11
+ from testzeus_cli.utils.auth import initialize_client_with_token
12
+ from testzeus_cli.utils.validators import parse_key_value_pairs, validate_tenant_ownership
13
+
14
+ console = Console()
15
+
16
+
17
+ @click.group()
18
+ def test_report_runs_group():
19
+ """Manage test report runs in TestZeus"""
20
+ pass
21
+
22
+
23
+ @test_report_runs_group.command(name="list")
24
+ @click.option("--filters", "-f", multiple=True, help="Filter results (format: key=value)")
25
+ @click.option("--sort", help="Sort by field")
26
+ @click.option("--expand", help="Expand related entities")
27
+ @click.pass_context
28
+ def list(ctx, filters, sort, expand):
29
+ """List all test report runs"""
30
+
31
+ async def _run():
32
+ config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
33
+ client = TestZeusClient(**config)
34
+ filter_dict = parse_key_value_pairs(filters) if filters else {}
35
+ async with client:
36
+ if token:
37
+ initialize_client_with_token(client, token)
38
+ else:
39
+ await client.ensure_authenticated()
40
+ result = await client.test_report_runs.get_list(expand=expand, sort=sort, filters=filter_dict)
41
+ return result
42
+
43
+ try:
44
+ result = asyncio.run(_run())
45
+ format_output(result, ctx.obj["FORMAT"])
46
+ except Exception as e:
47
+ print_message(f"[red]Error listing test report runs: {str(e)}[/red]", ctx.obj["FORMAT"])
48
+ raise click.Abort()
49
+
50
+
51
+ @test_report_runs_group.command(name="get")
52
+ @click.argument("report_run_id")
53
+ @click.option("--expand", help="Expand related entities")
54
+ @click.pass_context
55
+ def get(ctx, report_run_id, expand):
56
+ """Get a test report run by ID"""
57
+
58
+ async def _run():
59
+ config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
60
+ client = TestZeusClient(**config)
61
+ async with client:
62
+ if token:
63
+ initialize_client_with_token(client, token)
64
+ else:
65
+ await client.ensure_authenticated()
66
+ report_run = await client.test_report_runs.get_one(report_run_id, expand=expand)
67
+ return report_run.data
68
+
69
+ try:
70
+ result = asyncio.run(_run())
71
+ format_output(result, ctx.obj["FORMAT"])
72
+ except Exception as e:
73
+ print_message(f"[red]Error getting test report run: {str(e)}[/red]", ctx.obj["FORMAT"])
74
+ raise click.Abort()
75
+
76
+
77
+ @test_report_runs_group.command(name="delete")
78
+ @click.argument("report_run_id")
79
+ @click.pass_context
80
+ def delete(ctx, report_run_id):
81
+ """Delete a test report run"""
82
+
83
+ async def _run():
84
+ config, token, stored_tenant_id, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
85
+ client = TestZeusClient(**config)
86
+ async with client:
87
+ if token:
88
+ initialize_client_with_token(client, token)
89
+ else:
90
+ await client.ensure_authenticated()
91
+
92
+ # Validate tenant ownership before deleting
93
+ report_run = await client.test_report_runs.get_one(report_run_id)
94
+ validate_tenant_ownership(report_run.data, stored_tenant_id, "test report run")
95
+
96
+ await client.test_report_runs.delete(report_run_id)
97
+ return {"id": report_run_id}
98
+
99
+ try:
100
+ result = asyncio.run(_run())
101
+ print_message(f"[green]Test report run {result['id']} deleted successfully[/green]", ctx.obj["FORMAT"])
102
+ except Exception as e:
103
+ print_message(f"[red]Error deleting test report run: {str(e)}[/red]", ctx.obj["FORMAT"])
104
+ raise click.Abort()
105
+
106
+
107
+ @test_report_runs_group.command(name="download")
108
+ @click.argument("report_run_id")
109
+ @click.option("--output-dir", default="downloads", help="Output directory for downloaded report (default: downloads)")
110
+ @click.option(
111
+ "--format",
112
+ "report_format",
113
+ type=click.Choice(["ctrf", "pdf", "csv", "zip"]),
114
+ default="pdf",
115
+ help="Report format (default: pdf)",
116
+ )
117
+ @click.pass_context
118
+ def download(ctx, report_run_id, output_dir, report_format):
119
+ """Download the report for a test report run"""
120
+
121
+ async def _run():
122
+ config, token, _, _ = get_client_config(ctx.obj["PROFILE"], api_url=ctx.obj.get("API_URL"))
123
+ client = TestZeusClient(**config)
124
+ async with client:
125
+ if token:
126
+ initialize_client_with_token(client, token)
127
+ else:
128
+ await client.ensure_authenticated()
129
+
130
+ if ctx.obj.get("VERBOSE"):
131
+ console.print(f"[blue]Downloading {report_format} report for test report run: {report_run_id}[/blue]")
132
+
133
+ downloaded_file = await client.test_report_runs.download_report(report_run_id, output_dir=output_dir, format=report_format)
134
+
135
+ if downloaded_file:
136
+ return {
137
+ "report_run_id": report_run_id,
138
+ "format": report_format,
139
+ "output_dir": output_dir,
140
+ "file_path": str(downloaded_file),
141
+ "success": True,
142
+ }
143
+ else:
144
+ return {
145
+ "report_run_id": report_run_id,
146
+ "format": report_format,
147
+ "output_dir": output_dir,
148
+ "file_path": None,
149
+ "success": False,
150
+ }
151
+
152
+ try:
153
+ result = asyncio.run(_run())
154
+ if result["success"]:
155
+ print_message(f"[green]Report downloaded successfully to: {result['file_path']}[/green]", ctx.obj["FORMAT"])
156
+ else:
157
+ print_message(
158
+ f"[yellow]Report download failed (run may not be completed): {result['report_run_id']}[/yellow]",
159
+ ctx.obj["FORMAT"],
160
+ )
161
+ format_output(result, ctx.obj["FORMAT"])
162
+ except Exception as e:
163
+ print_message(f"[red]Error downloading report: {str(e)}[/red]", ctx.obj["FORMAT"])
164
+ raise click.Abort()
File without changes