testzeus-cli 0.0.28__tar.gz → 0.0.29__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.
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/PKG-INFO +1 -1
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/pyproject.toml +1 -1
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/agent_harness.py +28 -28
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/utils/auth.py +43 -18
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/LICENSE +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/README.md +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/__init__.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/auth.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/cli.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/__init__.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/connected_environments.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/daemon.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/device_pool.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/environments.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/extensions.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/hypermind_code_blocks.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/knowledge_bases.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/notification_channels.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/tags.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_data.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_report_runs.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_report_schedules.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_run_groups.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_runs.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_suite_node_runs.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_suite_runs.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_suite_schedules.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/test_suites.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/tests.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/tests_ai_generator.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/tests_authoring.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/commands/user_integrations.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/config.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/utils/__init__.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/utils/client.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/utils/files.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/utils/formatters.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/utils/links.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/utils/profile.py +0 -0
- {testzeus_cli-0.0.28 → testzeus_cli-0.0.29}/testzeus_cli/utils/validators.py +0 -0
|
@@ -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.
|
|
7
|
+
version = "0.0.29"
|
|
8
8
|
description = "Command-line interface for TestZeus testing platform"
|
|
9
9
|
authors = ["Shriyansh Agnihotri <shriyansh@testzeus.com>"]
|
|
10
10
|
readme = "README.md"
|
|
@@ -6,7 +6,7 @@ generate adversarial pathways, run simulations, and monitor / cancel them.
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import asyncio
|
|
9
|
-
from typing import Any, Dict
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
10
10
|
|
|
11
11
|
import click
|
|
12
12
|
from rich.console import Console
|
|
@@ -65,12 +65,12 @@ def _client(ctx):
|
|
|
65
65
|
return TestZeusClient(**config), token, tenant_id, user_id
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
async def _auth(client, token, tenant_id=None):
|
|
68
|
+
async def _auth(client, token, tenant_id: Optional[str] = None, user_id: Optional[str] = None):
|
|
69
69
|
if token:
|
|
70
|
-
# Thread the profile tenant so
|
|
71
|
-
# has no tenant claim; otherwise create/run fails
|
|
72
|
-
# "No tenant ID available
|
|
73
|
-
initialize_client_with_token(client, token, profile_tenant_id=tenant_id)
|
|
70
|
+
# Thread the profile tenant and user id so owner-field injection works
|
|
71
|
+
# even when the token has no tenant/id claim; otherwise create/run fails
|
|
72
|
+
# deep in the SDK ("No tenant ID available" / blank created_by).
|
|
73
|
+
initialize_client_with_token(client, token, profile_tenant_id=tenant_id, profile_user_id=user_id)
|
|
74
74
|
else:
|
|
75
75
|
await client.ensure_authenticated()
|
|
76
76
|
if not hasattr(client, "agent_harness"):
|
|
@@ -93,9 +93,9 @@ def list_agents(ctx, page, per_page, status, search):
|
|
|
93
93
|
"""List available agents"""
|
|
94
94
|
|
|
95
95
|
async def _run():
|
|
96
|
-
client, token, tenant_id,
|
|
96
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
97
97
|
async with client:
|
|
98
|
-
await _auth(client, token, tenant_id)
|
|
98
|
+
await _auth(client, token, tenant_id, user_id)
|
|
99
99
|
return await client.agent_harness.list_agents(page=page, per_page=per_page, status=status, search=search)
|
|
100
100
|
|
|
101
101
|
try:
|
|
@@ -119,9 +119,9 @@ def list_pathways(ctx, agent_id, page, per_page):
|
|
|
119
119
|
# argument instead. The SDK builds the agent_id filter via the shared filter
|
|
120
120
|
# builder; add --filters/--sort here if the manager grows to support them.
|
|
121
121
|
async def _run():
|
|
122
|
-
client, token, tenant_id,
|
|
122
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
123
123
|
async with client:
|
|
124
|
-
await _auth(client, token, tenant_id)
|
|
124
|
+
await _auth(client, token, tenant_id, user_id)
|
|
125
125
|
agent = validate_id(agent_id, "agent")
|
|
126
126
|
res = await client.agent_harness.list_pathways(agent_id=agent, page=page, per_page=per_page)
|
|
127
127
|
# get_list returns AdversaryPathways models. For the table, project to
|
|
@@ -154,9 +154,9 @@ def generate_pathways(ctx, agent_profile, prompt, name, agent_name, num, allow_d
|
|
|
154
154
|
"""Start an AI pathway-generation job for a Salesforce agent profile"""
|
|
155
155
|
|
|
156
156
|
async def _run():
|
|
157
|
-
client, token, tenant_id,
|
|
157
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
158
158
|
async with client:
|
|
159
|
-
await _auth(client, token, tenant_id)
|
|
159
|
+
await _auth(client, token, tenant_id, user_id)
|
|
160
160
|
# tenant/created_by/modified_by are auto-filled by the SDK manager.
|
|
161
161
|
return await client.agent_harness.generate_pathways(
|
|
162
162
|
agent_profile=agent_profile,
|
|
@@ -190,9 +190,9 @@ def run(ctx, agent_id, pathways, name, agent_name, run_as_profile, wait, timeout
|
|
|
190
190
|
"""Run adversarial simulations for the given pathways"""
|
|
191
191
|
|
|
192
192
|
async def _run():
|
|
193
|
-
client, token, tenant_id,
|
|
193
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
194
194
|
async with client:
|
|
195
|
-
await _auth(client, token, tenant_id)
|
|
195
|
+
await _auth(client, token, tenant_id, user_id)
|
|
196
196
|
agent = validate_id(agent_id, "agent")
|
|
197
197
|
# tenant/created_by/modified_by are auto-filled by the SDK manager.
|
|
198
198
|
if wait:
|
|
@@ -237,9 +237,9 @@ def status(ctx, group_id):
|
|
|
237
237
|
"""Get the status/results of a simulation run group"""
|
|
238
238
|
|
|
239
239
|
async def _run():
|
|
240
|
-
client, token, tenant_id,
|
|
240
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
241
241
|
async with client:
|
|
242
|
-
await _auth(client, token, tenant_id)
|
|
242
|
+
await _auth(client, token, tenant_id, user_id)
|
|
243
243
|
return await client.agent_harness.get_status(validate_id(group_id, "group"))
|
|
244
244
|
|
|
245
245
|
try:
|
|
@@ -256,9 +256,9 @@ def cancel(ctx, group_id):
|
|
|
256
256
|
"""Cancel a running simulation group"""
|
|
257
257
|
|
|
258
258
|
async def _run():
|
|
259
|
-
client, token, tenant_id,
|
|
259
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
260
260
|
async with client:
|
|
261
|
-
await _auth(client, token, tenant_id)
|
|
261
|
+
await _auth(client, token, tenant_id, user_id)
|
|
262
262
|
return await client.agent_harness.cancel(validate_id(group_id, "group"))
|
|
263
263
|
|
|
264
264
|
try:
|
|
@@ -276,9 +276,9 @@ def get_agent(ctx, agent_id):
|
|
|
276
276
|
"""Get full detail for a single agent"""
|
|
277
277
|
|
|
278
278
|
async def _run():
|
|
279
|
-
client, token, tenant_id,
|
|
279
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
280
280
|
async with client:
|
|
281
|
-
await _auth(client, token, tenant_id)
|
|
281
|
+
await _auth(client, token, tenant_id, user_id)
|
|
282
282
|
return await client.agent_harness.get_agent(validate_id(agent_id, "agent"))
|
|
283
283
|
|
|
284
284
|
try:
|
|
@@ -301,9 +301,9 @@ def get_pathway(ctx, pathway_id):
|
|
|
301
301
|
"""Get full detail for a single adversarial pathway"""
|
|
302
302
|
|
|
303
303
|
async def _run():
|
|
304
|
-
client, token, tenant_id,
|
|
304
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
305
305
|
async with client:
|
|
306
|
-
await _auth(client, token, tenant_id)
|
|
306
|
+
await _auth(client, token, tenant_id, user_id)
|
|
307
307
|
# The facade has no get_pathway method; adversary_pathways is a plain
|
|
308
308
|
# PocketBase collection, so go through the sub-manager's get_one.
|
|
309
309
|
return await client.agent_harness.pathways.get_one(validate_id(pathway_id, "pathway"))
|
|
@@ -326,9 +326,9 @@ def list_simulations(ctx, group_id, page, per_page):
|
|
|
326
326
|
"""List the simulations of a run group"""
|
|
327
327
|
|
|
328
328
|
async def _run():
|
|
329
|
-
client, token, tenant_id,
|
|
329
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
330
330
|
async with client:
|
|
331
|
-
await _auth(client, token, tenant_id)
|
|
331
|
+
await _auth(client, token, tenant_id, user_id)
|
|
332
332
|
group = validate_id(group_id, "group")
|
|
333
333
|
res = await client.agent_harness.list_simulations(group_id=group, page=page, per_page=per_page)
|
|
334
334
|
# Same format-aware projection as list-pathways: useful columns for
|
|
@@ -354,9 +354,9 @@ def get_simulation(ctx, simulation_id):
|
|
|
354
354
|
"""Get full detail for a single simulation"""
|
|
355
355
|
|
|
356
356
|
async def _run():
|
|
357
|
-
client, token, tenant_id,
|
|
357
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
358
358
|
async with client:
|
|
359
|
-
await _auth(client, token, tenant_id)
|
|
359
|
+
await _auth(client, token, tenant_id, user_id)
|
|
360
360
|
return await client.agent_harness.get_simulation(validate_id(simulation_id, "simulation"))
|
|
361
361
|
|
|
362
362
|
try:
|
|
@@ -375,9 +375,9 @@ def delete_pathway(ctx, pathway_id):
|
|
|
375
375
|
"""Soft-delete an adversarial pathway"""
|
|
376
376
|
|
|
377
377
|
async def _run():
|
|
378
|
-
client, token, tenant_id,
|
|
378
|
+
client, token, tenant_id, user_id = _client(ctx)
|
|
379
379
|
async with client:
|
|
380
|
-
await _auth(client, token, tenant_id)
|
|
380
|
+
await _auth(client, token, tenant_id, user_id)
|
|
381
381
|
return await client.agent_harness.delete_pathway(validate_id(pathway_id, "pathway"))
|
|
382
382
|
|
|
383
383
|
try:
|
|
@@ -6,13 +6,27 @@ import base64
|
|
|
6
6
|
import json
|
|
7
7
|
import os
|
|
8
8
|
import logging
|
|
9
|
+
import time
|
|
9
10
|
from testzeus_sdk import TestZeusClient
|
|
10
11
|
from typing import Dict, Any, Optional, cast
|
|
11
12
|
|
|
12
|
-
|
|
13
13
|
logger = logging.getLogger("testzeus_cli.utils.auth")
|
|
14
14
|
|
|
15
15
|
|
|
16
|
+
class _MinimalAuthRecord:
|
|
17
|
+
"""Stand-in auth model for the token path (the SDK reads auth_store.model.id).
|
|
18
|
+
|
|
19
|
+
Any attribute other than ``id`` resolves to None instead of raising
|
|
20
|
+
AttributeError, so SDK/PocketBase code that probes e.g. ``.collectionId``
|
|
21
|
+
or ``.email`` degrades gracefully."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, id: str):
|
|
24
|
+
self.id = id
|
|
25
|
+
|
|
26
|
+
def __getattr__(self, name: str) -> None:
|
|
27
|
+
return None
|
|
28
|
+
|
|
29
|
+
|
|
16
30
|
def _auth_debug_enabled() -> bool:
|
|
17
31
|
return str(os.environ.get("TESTZEUS_AUTH_DEBUG", "")).lower() in {"1", "true", "yes", "on"}
|
|
18
32
|
|
|
@@ -50,7 +64,7 @@ def decode_jwt_payload(token: str) -> Optional[Dict[str, Any]]:
|
|
|
50
64
|
return None
|
|
51
65
|
|
|
52
66
|
|
|
53
|
-
def initialize_client_with_token(client: TestZeusClient, token: str, profile_tenant_id: Optional[str] = None) -> None:
|
|
67
|
+
def initialize_client_with_token(client: TestZeusClient, token: str, profile_tenant_id: Optional[str] = None, profile_user_id: Optional[str] = None) -> None:
|
|
54
68
|
"""
|
|
55
69
|
Initialize a TestZeusClient with a token, properly setting up the auth store model.
|
|
56
70
|
|
|
@@ -58,16 +72,25 @@ def initialize_client_with_token(client: TestZeusClient, token: str, profile_ten
|
|
|
58
72
|
client: The TestZeusClient instance
|
|
59
73
|
token: JWT token
|
|
60
74
|
profile_tenant_id: Optional tenant ID from profile config, used as fallback when token has no tenant claim.
|
|
75
|
+
profile_user_id: Optional user ID from profile config, used as fallback when token has no id claim.
|
|
61
76
|
"""
|
|
62
|
-
# Set the token
|
|
63
|
-
client.token = token
|
|
64
|
-
client._authenticated = True
|
|
65
|
-
|
|
66
77
|
# Extract token data
|
|
67
78
|
claims = decode_jwt_payload(token)
|
|
68
79
|
tenant_id = None
|
|
69
80
|
user_id = None
|
|
70
81
|
|
|
82
|
+
# Fail fast on tokens that can't work, with an actionable message. Without
|
|
83
|
+
# this the user gets raw gateway 401s ("requires valid record authorization
|
|
84
|
+
# token") or, worse, silently empty collection lists.
|
|
85
|
+
if claims is None:
|
|
86
|
+
raise ValueError("Could not decode saved auth token - run 'testzeus login' to re-authenticate")
|
|
87
|
+
if isinstance(claims.get("exp"), (int, float)) and claims["exp"] < time.time():
|
|
88
|
+
raise ValueError("Saved auth token has expired - run 'testzeus login' to re-authenticate")
|
|
89
|
+
|
|
90
|
+
# Set the token
|
|
91
|
+
client.token = token
|
|
92
|
+
client._authenticated = True
|
|
93
|
+
|
|
71
94
|
if claims:
|
|
72
95
|
# Check for tenant ID in various possible locations within the token
|
|
73
96
|
if "tenant" in claims:
|
|
@@ -86,18 +109,24 @@ def initialize_client_with_token(client: TestZeusClient, token: str, profile_ten
|
|
|
86
109
|
elif "record" in claims and "id" in claims["record"]:
|
|
87
110
|
user_id = claims["record"]["id"]
|
|
88
111
|
|
|
112
|
+
# Fallback to the user ID saved in the profile config (mirrors the
|
|
113
|
+
# profile_tenant_id fallback) for tokens that carry no id claim.
|
|
114
|
+
if not user_id and profile_user_id:
|
|
115
|
+
user_id = profile_user_id
|
|
116
|
+
|
|
89
117
|
# Save the token to the auth store - this should properly populate auth_store.model
|
|
90
118
|
client.pb.auth_store.save(token, None)
|
|
91
119
|
|
|
92
|
-
#
|
|
93
|
-
|
|
120
|
+
# Attach the user id to the auth model. save(token, None) leaves model=None,
|
|
121
|
+
# so a minimal record stand-in is stored when needed - otherwise the SDK's
|
|
122
|
+
# get_user_id() (which reads auth_store.model.id) returns "" on the token
|
|
123
|
+
# path and every create fails with blank created_by/modified_by.
|
|
124
|
+
if user_id:
|
|
94
125
|
try:
|
|
95
|
-
|
|
96
|
-
if hasattr(client.pb.auth_store.model, "id"):
|
|
97
|
-
client.pb.auth_store.model.id = user_id
|
|
98
|
-
else:
|
|
99
|
-
# Add ID attribute to existing model
|
|
126
|
+
if client.pb.auth_store.model:
|
|
100
127
|
setattr(client.pb.auth_store.model, "id", user_id)
|
|
128
|
+
else:
|
|
129
|
+
client.pb.auth_store.save(token, _MinimalAuthRecord(id=user_id))
|
|
101
130
|
except Exception:
|
|
102
131
|
# If we can't set the model, that's okay - the SDK might handle it differently
|
|
103
132
|
pass
|
|
@@ -149,11 +178,7 @@ def extract_tenant_from_token(token: str) -> str:
|
|
|
149
178
|
elif "collectionId" in claims:
|
|
150
179
|
return str(claims["collectionId"])
|
|
151
180
|
# Look for tenant in other possible locations
|
|
152
|
-
elif (
|
|
153
|
-
"record" in claims
|
|
154
|
-
and claims["record"].get("collectionId")
|
|
155
|
-
and claims["record"]["collectionId"] != "_pb_users_auth_"
|
|
156
|
-
):
|
|
181
|
+
elif "record" in claims and claims["record"].get("collectionId") and claims["record"]["collectionId"] != "_pb_users_auth_":
|
|
157
182
|
return str(claims["record"]["collectionId"])
|
|
158
183
|
|
|
159
184
|
# No default value - let the API determine the appropriate tenant
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|