qbraid-cli 0.17.1__tar.gz → 0.17.2__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.
- {qbraid_cli-0.17.1/qbraid_cli.egg-info → qbraid_cli-0.17.2}/PKG-INFO +4 -4
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/pyproject.toml +4 -4
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/agents/app.py +183 -9
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/ai/token.py +24 -3
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/registry.py +28 -14
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2/qbraid_cli.egg-info}/PKG-INFO +4 -4
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli.egg-info/requires.txt +3 -3
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/LICENSE +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/README.md +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/_build_info.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/_version.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/account/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/account/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/admin/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/admin/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/admin/headers.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/admin/validation.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/agents/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/agents/keep_alive.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/agents/permission_response.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/agents/provider_children.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/agents/queue.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/agents/work.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/ai/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/ai/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/artifacts/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/artifacts/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/comms/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/comms/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/compute/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/compute/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/compute/instances.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/compute/profiles.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/compute/server.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/compute/ssh.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/configure/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/configure/actions.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/configure/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/devices/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/devices/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/devices/validation.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/activate.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/create.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/data_handling.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/groups.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/publish.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/envs/share.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/exceptions.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/handlers.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/jobs/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/jobs/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/jobs/groups.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/kernels/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/kernels/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/lab/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/lab/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/main.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/pip/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/pip/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/pip/hooks.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/projects/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/projects/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/py.typed +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/skills/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/skills/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/troubleshoot/__init__.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli/troubleshoot/app.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli.egg-info/SOURCES.txt +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli.egg-info/dependency_links.txt +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli.egg-info/entry_points.txt +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/qbraid_cli.egg-info/top_level.txt +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/setup.cfg +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/tests/test_cli_e2e.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/tests/test_register_client.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/tests/test_status_colors.py +0 -0
- {qbraid_cli-0.17.1 → qbraid_cli-0.17.2}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: qbraid-cli
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.2
|
|
4
4
|
Summary: Command Line Interface for interacting with all parts of the qBraid platform.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License-Expression: LicenseRef-Proprietary
|
|
@@ -30,11 +30,11 @@ Requires-Dist: typer>=0.12.1
|
|
|
30
30
|
Requires-Dist: rich>=10.11.0
|
|
31
31
|
Requires-Dist: click<=8.5.1
|
|
32
32
|
Requires-Dist: questionary>=2.0.0
|
|
33
|
-
Requires-Dist: qbraid-core>=0.6.
|
|
33
|
+
Requires-Dist: qbraid-core>=0.6.56
|
|
34
34
|
Provides-Extra: compute
|
|
35
|
-
Requires-Dist: qbraid-core[compute]>=0.6.
|
|
35
|
+
Requires-Dist: qbraid-core[compute]>=0.6.56; extra == "compute"
|
|
36
36
|
Provides-Extra: envs
|
|
37
|
-
Requires-Dist: qbraid-core[environments]>=0.6.
|
|
37
|
+
Requires-Dist: qbraid-core[environments]>=0.6.56; extra == "envs"
|
|
38
38
|
Provides-Extra: dev
|
|
39
39
|
Requires-Dist: isort; extra == "dev"
|
|
40
40
|
Requires-Dist: black; extra == "dev"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "qbraid-cli"
|
|
7
|
-
version = "0.17.
|
|
7
|
+
version = "0.17.2"
|
|
8
8
|
description = "Command Line Interface for interacting with all parts of the qBraid platform."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "qBraid Development Team", email = "contact@qbraid.com" }]
|
|
@@ -32,7 +32,7 @@ dependencies = [
|
|
|
32
32
|
"rich>=10.11.0",
|
|
33
33
|
"click<=8.5.1",
|
|
34
34
|
"questionary>=2.0.0",
|
|
35
|
-
"qbraid-core>=0.6.
|
|
35
|
+
"qbraid-core>=0.6.56",
|
|
36
36
|
]
|
|
37
37
|
requires-python = ">= 3.10"
|
|
38
38
|
|
|
@@ -43,8 +43,8 @@ Documentation = "https://docs.qbraid.com/v2/cli/api-reference/qbraid"
|
|
|
43
43
|
Discord = "https://discord.gg/KugF6Cnncm"
|
|
44
44
|
|
|
45
45
|
[project.optional-dependencies]
|
|
46
|
-
compute = ["qbraid-core[compute]>=0.6.
|
|
47
|
-
envs = ["qbraid-core[environments]>=0.6.
|
|
46
|
+
compute = ["qbraid-core[compute]>=0.6.56"]
|
|
47
|
+
envs = ["qbraid-core[environments]>=0.6.56"]
|
|
48
48
|
dev = ["isort", "black", "pytest", "pytest-cov", "pytest-asyncio"]
|
|
49
49
|
|
|
50
50
|
[project.scripts]
|
|
@@ -2232,6 +2232,53 @@ def _messaging_setting(mode: Optional[str], as_json: bool) -> None:
|
|
|
2232
2232
|
console.print(f"Messaging: {current} (this machine). " + messaging_mode.describe(None))
|
|
2233
2233
|
|
|
2234
2234
|
|
|
2235
|
+
def _mail_wakes_module():
|
|
2236
|
+
"""qbraid-core's ``mail_wakes`` (#606), or None on an older Core."""
|
|
2237
|
+
try:
|
|
2238
|
+
# pylint: disable-next=import-outside-toplevel
|
|
2239
|
+
from qbraid_core.services.agents import mail_wakes # type: ignore[attr-defined]
|
|
2240
|
+
except ImportError:
|
|
2241
|
+
return None
|
|
2242
|
+
return mail_wakes
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
def _mail_wake_cap_setting(cap: int, as_json: bool) -> None:
|
|
2246
|
+
"""Set this machine's mail wake cap (anyone may lower it; only a person may raise it)."""
|
|
2247
|
+
mail_wakes = _mail_wakes_module()
|
|
2248
|
+
if mail_wakes is None:
|
|
2249
|
+
console.print("[red]--mail-wake-cap needs a newer qbraid-core[/red] (one with mail wakes).")
|
|
2250
|
+
raise typer.Exit(code=1)
|
|
2251
|
+
try:
|
|
2252
|
+
current = mail_wakes.set_wake_cap(cap)
|
|
2253
|
+
except mail_wakes.WakeCapError as err:
|
|
2254
|
+
console.print(f"[red]Not changed:[/red] {_plain(str(err))}")
|
|
2255
|
+
raise typer.Exit(code=1) from None
|
|
2256
|
+
if as_json:
|
|
2257
|
+
print(json.dumps({"mail_wake_cap": current}))
|
|
2258
|
+
return
|
|
2259
|
+
console.print(f"Mail wake cap: {current} (this machine). {_MAIL_WAKE_CAP_NOTE}", soft_wrap=True)
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
#: Said when the cap setting cannot be read (qbraid-core reads it as 0).
|
|
2263
|
+
_CAP_DAMAGED = "cap file damaged; showing 0"
|
|
2264
|
+
|
|
2265
|
+
|
|
2266
|
+
def _cap_damaged(mail_wakes) -> bool:
|
|
2267
|
+
"""Whether Core reports the cap setting as damaged (an older Core cannot say)."""
|
|
2268
|
+
check = getattr(mail_wakes, "wake_cap_damaged", None)
|
|
2269
|
+
try:
|
|
2270
|
+
return bool(check()) if callable(check) else False
|
|
2271
|
+
except Exception: # pylint: disable=broad-exception-caught
|
|
2272
|
+
return False
|
|
2273
|
+
|
|
2274
|
+
|
|
2275
|
+
#: What the mail wake cap does, for ``settings``.
|
|
2276
|
+
_MAIL_WAKE_CAP_NOTE = (
|
|
2277
|
+
"At most this many mail-triggered wakes per agent per hour with no message from you in "
|
|
2278
|
+
"between; past it, mail waits for your next message to that agent (0: mail never wakes)."
|
|
2279
|
+
)
|
|
2280
|
+
|
|
2281
|
+
|
|
2235
2282
|
@agents_app.command("settings")
|
|
2236
2283
|
def agents_settings(
|
|
2237
2284
|
execution_mode: Optional[ExecutionMode] = typer.Option(
|
|
@@ -2247,6 +2294,16 @@ def agents_settings(
|
|
|
2247
2294
|
"for agents that read untrusted input. Anyone may restrict; only a person may open."
|
|
2248
2295
|
),
|
|
2249
2296
|
),
|
|
2297
|
+
mail_wake_cap: Optional[int] = typer.Option(
|
|
2298
|
+
None,
|
|
2299
|
+
"--mail-wake-cap",
|
|
2300
|
+
min=0,
|
|
2301
|
+
max=1000,
|
|
2302
|
+
help=(
|
|
2303
|
+
"Mail-triggered wakes per agent per hour with no message from you in between "
|
|
2304
|
+
"(default 20; 0: mail never wakes). Anyone may lower it; only a person may raise it."
|
|
2305
|
+
),
|
|
2306
|
+
),
|
|
2250
2307
|
json_output: bool = typer.Option(
|
|
2251
2308
|
False, "--json", help="Print structured settings and sandbox readiness."
|
|
2252
2309
|
),
|
|
@@ -2256,13 +2313,22 @@ def agents_settings(
|
|
|
2256
2313
|
Inspect or change them. Defaults are shared by the CLI and dashboard on this machine.
|
|
2257
2314
|
"""
|
|
2258
2315
|
if messaging is not None:
|
|
2259
|
-
if reset or execution_mode is not None:
|
|
2316
|
+
if reset or execution_mode is not None or mail_wake_cap is not None:
|
|
2260
2317
|
console.print(
|
|
2261
|
-
"[red]Error:[/red] Set --messaging on its own (not with --reset
|
|
2318
|
+
"[red]Error:[/red] Set --messaging on its own (not with --reset, --execution-mode "
|
|
2319
|
+
"or --mail-wake-cap)."
|
|
2262
2320
|
)
|
|
2263
2321
|
raise typer.Exit(code=2)
|
|
2264
2322
|
_messaging_setting(messaging.value, json_output)
|
|
2265
2323
|
return
|
|
2324
|
+
if mail_wake_cap is not None:
|
|
2325
|
+
if reset or execution_mode is not None:
|
|
2326
|
+
console.print(
|
|
2327
|
+
"[red]Error:[/red] Set --mail-wake-cap on its own (not with --reset or --execution-mode)."
|
|
2328
|
+
)
|
|
2329
|
+
raise typer.Exit(code=2)
|
|
2330
|
+
_mail_wake_cap_setting(mail_wake_cap, json_output)
|
|
2331
|
+
return
|
|
2266
2332
|
try:
|
|
2267
2333
|
from qbraid_core.services.agents.execution import execution_settings, set_execution_default
|
|
2268
2334
|
|
|
@@ -2275,11 +2341,26 @@ def agents_settings(
|
|
|
2275
2341
|
else:
|
|
2276
2342
|
settings = execution_settings()
|
|
2277
2343
|
current_messaging = _current_messaging()
|
|
2344
|
+
mail_wakes = _mail_wakes_module()
|
|
2345
|
+
cap = mail_wakes.wake_cap() if mail_wakes is not None else None
|
|
2346
|
+
damaged = mail_wakes is not None and _cap_damaged(mail_wakes)
|
|
2278
2347
|
if json_output:
|
|
2279
|
-
print(
|
|
2348
|
+
print(
|
|
2349
|
+
json.dumps(
|
|
2350
|
+
{
|
|
2351
|
+
**settings,
|
|
2352
|
+
**({"messaging": current_messaging} if current_messaging else {}),
|
|
2353
|
+
**({"mail_wake_cap": cap} if cap is not None else {}),
|
|
2354
|
+
**({"mail_wake_cap_damaged": True} if damaged else {}),
|
|
2355
|
+
}
|
|
2356
|
+
)
|
|
2357
|
+
)
|
|
2280
2358
|
else:
|
|
2281
2359
|
if current_messaging:
|
|
2282
2360
|
console.print(f"Messaging: {current_messaging} (this machine).")
|
|
2361
|
+
if cap is not None:
|
|
2362
|
+
shown = f"{cap} ({_CAP_DAMAGED}; set it again with --mail-wake-cap)" if damaged else cap
|
|
2363
|
+
console.print(f"Mail wake cap: {shown} (this machine). {_MAIL_WAKE_CAP_NOTE}", soft_wrap=True)
|
|
2283
2364
|
console.print(
|
|
2284
2365
|
"Codex execution default: " + (settings["execution_mode"] or "not set (legacy defaults)")
|
|
2285
2366
|
)
|
|
@@ -3479,6 +3560,15 @@ def _report_typed(as_json: bool, target: str, compute: Optional[str]) -> None:
|
|
|
3479
3560
|
|
|
3480
3561
|
#: Why mail waits, for a ``held:<CODE>`` that a qBraid bridge (or its absence) reports.
|
|
3481
3562
|
_MAIL_WAITS = {
|
|
3563
|
+
"WAKE_COUNT_BUSY": (
|
|
3564
|
+
"qBraid could not update its mail wake count (busy), so it is not woken yet rather than "
|
|
3565
|
+
"risk passing the cap; it is told once the count can be kept."
|
|
3566
|
+
),
|
|
3567
|
+
"WAKE_CAP": (
|
|
3568
|
+
"the agent has used its mail wake cap (mail-triggered wakes in the last hour with no "
|
|
3569
|
+
"message from the person; qbraid agents settings --mail-wake-cap), so it is not woken "
|
|
3570
|
+
"now; it is told once its count frees up within the hour or the person messages it."
|
|
3571
|
+
),
|
|
3482
3572
|
"NEXT_TURN": "the agent has no qBraid bridge to wake it, so it sees the message on its next turn.",
|
|
3483
3573
|
"BRIDGE_STARTING": (
|
|
3484
3574
|
"the agent's qBraid bridge is still starting; it tells the agent as soon as it runs."
|
|
@@ -3542,6 +3632,13 @@ def _print_nudge(outcome) -> None:
|
|
|
3542
3632
|
)
|
|
3543
3633
|
return
|
|
3544
3634
|
reason = str(outcome or "held:UNKNOWN").split(":", 1)[-1]
|
|
3635
|
+
if reason == "SENDER_CANNOT_WAKE":
|
|
3636
|
+
console.print(
|
|
3637
|
+
f"[yellow]Mail waiting ({_plain(reason)}):[/yellow] the message is in the agent's "
|
|
3638
|
+
f"inbox; {_plain(_sender_cannot_wake_text())}",
|
|
3639
|
+
soft_wrap=True,
|
|
3640
|
+
)
|
|
3641
|
+
return
|
|
3545
3642
|
if reason in _MAIL_WAITS:
|
|
3546
3643
|
console.print(
|
|
3547
3644
|
f"[yellow]Mail waiting ({_plain(reason)}):[/yellow] the message is in the agent's "
|
|
@@ -4880,9 +4977,52 @@ def _parse_target_csv(csv: str, registry) -> list[str]:
|
|
|
4880
4977
|
return resolved
|
|
4881
4978
|
|
|
4882
4979
|
|
|
4980
|
+
#: Why ``send-to`` mail waits for the recipient's next turn (``_waits_for_next_turn``).
|
|
4981
|
+
_WAIT_WHY = {
|
|
4982
|
+
"WAKE_COUNT_BUSY": (
|
|
4983
|
+
"qBraid could not update its mail wake count (busy), so it is not woken yet; it is told "
|
|
4984
|
+
"once the count can be kept."
|
|
4985
|
+
),
|
|
4986
|
+
"WAKE_CAP": (
|
|
4987
|
+
"it has used its mail wake cap (mail-triggered wakes in the last hour with no message from "
|
|
4988
|
+
"the person; qbraid agents settings --mail-wake-cap); it is told once its count frees up "
|
|
4989
|
+
"within the hour or the person messages it."
|
|
4990
|
+
),
|
|
4991
|
+
}
|
|
4992
|
+
|
|
4993
|
+
|
|
4994
|
+
def _mail_wakes_label(wakes) -> Optional[str]:
|
|
4995
|
+
"""whoami's ``mail_wakes`` (qbraid-core #606) as one line, or None."""
|
|
4996
|
+
if not isinstance(wakes, dict) or "count" not in wakes:
|
|
4997
|
+
return None
|
|
4998
|
+
text = f"{wakes.get('count')} of {wakes.get('cap')} in the last hour"
|
|
4999
|
+
if wakes.get("cap_damaged"):
|
|
5000
|
+
text += f" ({_CAP_DAMAGED})"
|
|
5001
|
+
return text + (" (held: mail waits until it frees up or the person writes)" if wakes.get("held") else "")
|
|
5002
|
+
|
|
5003
|
+
|
|
5004
|
+
def _sender_cannot_wake_text() -> str:
|
|
5005
|
+
"""``SENDER_CANNOT_WAKE``'s meaning on the installed Core: since qbraid-core
|
|
5006
|
+
#606 only mail from another machine; before it, a sender that was not the
|
|
5007
|
+
person or a bypass agent they launched."""
|
|
5008
|
+
if _mail_wakes_module() is not None:
|
|
5009
|
+
return (
|
|
5010
|
+
"mail from another machine does not wake an agent in a bypass permission mode; it "
|
|
5011
|
+
"sees the message on its next turn."
|
|
5012
|
+
)
|
|
5013
|
+
return "only the person, or an agent they launched in a bypass mode, can wake it."
|
|
5014
|
+
|
|
5015
|
+
|
|
4883
5016
|
def _waits_for_next_turn(registry, msg) -> Optional[str]:
|
|
4884
|
-
"""
|
|
4885
|
-
|
|
5017
|
+
"""Why *msg* waits for its recipient's next turn, or None when it may wake.
|
|
5018
|
+
|
|
5019
|
+
``"WAKE_CAP"``: Core held it, the recipient's mail wake cap reached
|
|
5020
|
+
(``AgentMessage.held``, qbraid-core #606; for every recipient).
|
|
5021
|
+
``"SENDER_CANNOT_WAKE"``: an older Core marked it as not waking and its
|
|
5022
|
+
recipient holds such mail (``messaging_mode.holds_for``)."""
|
|
5023
|
+
held = getattr(msg, "held", None)
|
|
5024
|
+
if isinstance(held, str) and held:
|
|
5025
|
+
return held
|
|
4886
5026
|
if getattr(msg, "wakes", None) is not False:
|
|
4887
5027
|
return None
|
|
4888
5028
|
try:
|
|
@@ -4978,9 +5118,16 @@ def _deliver_to_many(
|
|
|
4978
5118
|
f"[dim](id={_plain(mid)}, type={_plain(message_type)})[/dim]"
|
|
4979
5119
|
)
|
|
4980
5120
|
if waits.get(mid):
|
|
5121
|
+
reason = str(waits[mid])
|
|
4981
5122
|
console.print(
|
|
4982
|
-
f"[dim]It waits for {_plain(sid[:8])}'s next turn ({
|
|
4983
|
-
|
|
5123
|
+
f"[dim]It waits for {_plain(sid[:8])}'s next turn ({_plain(reason)}): "
|
|
5124
|
+
+ _plain(
|
|
5125
|
+
_sender_cannot_wake_text()
|
|
5126
|
+
if reason == "SENDER_CANNOT_WAKE"
|
|
5127
|
+
else _WAIT_WHY.get(reason, "it is not woken for it.")
|
|
5128
|
+
)
|
|
5129
|
+
+ "[/dim]",
|
|
5130
|
+
soft_wrap=True,
|
|
4984
5131
|
)
|
|
4985
5132
|
for sid, reason in failed_shown:
|
|
4986
5133
|
# soft_wrap: a refusal stays one line, so grep-based checks still match.
|
|
@@ -5664,16 +5811,42 @@ def _render_messages_table(messages, session_id: str, full_ids: bool = False) ->
|
|
|
5664
5811
|
if machine:
|
|
5665
5812
|
# From another machine: answer with `qbraid agents reply <id>`.
|
|
5666
5813
|
from_display += f" @{machine if full_ids else machine[:8]}"
|
|
5814
|
+
label = _provenance_label(msg)
|
|
5815
|
+
if label:
|
|
5816
|
+
# Core's label on a row of its own, so no message text can draw a
|
|
5817
|
+
# line that passes for it.
|
|
5818
|
+
table.add_row("", "", "", "", f"[dim]{_plain(_printable(label))}[/dim]")
|
|
5667
5819
|
table.add_row(
|
|
5668
5820
|
ts,
|
|
5669
|
-
_plain(from_display),
|
|
5821
|
+
_plain(_printable(from_display)),
|
|
5670
5822
|
_plain(msg.type.value),
|
|
5671
5823
|
read_marker,
|
|
5672
|
-
_plain(msg.text),
|
|
5824
|
+
_plain(_printable(msg.text)),
|
|
5673
5825
|
)
|
|
5674
5826
|
console.print(table)
|
|
5675
5827
|
|
|
5676
5828
|
|
|
5829
|
+
def _printable(value) -> str:
|
|
5830
|
+
"""*value* without terminal control characters (ESC sequences could move
|
|
5831
|
+
the cursor and redraw rows above); tabs and new lines are kept."""
|
|
5832
|
+
import unicodedata # pylint: disable=import-outside-toplevel
|
|
5833
|
+
|
|
5834
|
+
return "".join(ch for ch in str(value) if ch in "\n\t" or unicodedata.category(ch) not in ("Cc", "Cf"))
|
|
5835
|
+
|
|
5836
|
+
|
|
5837
|
+
def _provenance_label(msg) -> Optional[str]:
|
|
5838
|
+
"""Core's one-line label of who sent *msg* (qbraid-core #606), or None on an older Core."""
|
|
5839
|
+
try:
|
|
5840
|
+
# pylint: disable-next=import-outside-toplevel
|
|
5841
|
+
from qbraid_core.services.agents.mail_wakes import provenance_label # type: ignore
|
|
5842
|
+
except ImportError:
|
|
5843
|
+
return None
|
|
5844
|
+
try:
|
|
5845
|
+
return provenance_label(msg)
|
|
5846
|
+
except Exception: # pylint: disable=broad-exception-caught
|
|
5847
|
+
return None
|
|
5848
|
+
|
|
5849
|
+
|
|
5677
5850
|
def _runs_in_agent(registry) -> bool:
|
|
5678
5851
|
"""Whether this command runs inside an agent session rather than for the person.
|
|
5679
5852
|
|
|
@@ -6216,6 +6389,7 @@ def agents_whoami(
|
|
|
6216
6389
|
("Canonical id", info.get("canonical_session_id")),
|
|
6217
6390
|
("Resumed from", info.get("resumed_from")),
|
|
6218
6391
|
("Mail waiting", _held_label(info.get("nudges_held"))),
|
|
6392
|
+
("Mail wakes", _mail_wakes_label(info.get("mail_wakes"))),
|
|
6219
6393
|
(
|
|
6220
6394
|
"Nudge left",
|
|
6221
6395
|
(
|
|
@@ -14,8 +14,11 @@ Going through ``qbraid_cli.main`` would import every command group in the CLI
|
|
|
14
14
|
— more to the point — keeps this path from getting slower every time a new
|
|
15
15
|
command group is added.
|
|
16
16
|
|
|
17
|
-
Deliberately has no argument
|
|
18
|
-
so an agent reading stdout can never pick up a stray banner or
|
|
17
|
+
Deliberately has no argument parser: it prints the credential and nothing else,
|
|
18
|
+
so an agent reading stdout can never pick up a stray banner, usage text or
|
|
19
|
+
prompt. The one argument it reads, ``--qbraid-gateway=<url>``, is the agent's
|
|
20
|
+
own gateway, which ``qbraid ai connect`` writes into the helper command; any
|
|
21
|
+
other argument is ignored.
|
|
19
22
|
|
|
20
23
|
The credential is written to the binary stdout buffer rather than via ``print``
|
|
21
24
|
so the bytes are identical on every platform. Text-mode stdout on Windows
|
|
@@ -25,6 +28,8 @@ to the credential an agent reads.
|
|
|
25
28
|
|
|
26
29
|
import sys
|
|
27
30
|
|
|
31
|
+
_GATEWAY_FLAG = "--qbraid-gateway="
|
|
32
|
+
|
|
28
33
|
|
|
29
34
|
def _emit(credential: str) -> None:
|
|
30
35
|
"""Write the credential and exactly one newline, byte-for-byte.
|
|
@@ -43,6 +48,22 @@ def _emit(credential: str) -> None:
|
|
|
43
48
|
buffer.flush()
|
|
44
49
|
|
|
45
50
|
|
|
51
|
+
def _gateway_url(argv: list[str]) -> str:
|
|
52
|
+
"""The agent's gateway from ``--qbraid-gateway=<url>``, or "" when absent.
|
|
53
|
+
|
|
54
|
+
Read here rather than left to Core's ``sys.argv`` fallback, which only
|
|
55
|
+
applies when the program is named ``qbraid-ai-token``: run as
|
|
56
|
+
``python -m qbraid_cli.ai.token`` or through a differently named link, the
|
|
57
|
+
helper would otherwise not count as bound to a gateway (#433). An empty
|
|
58
|
+
value means a helper written by an earlier connect, which Core treats as
|
|
59
|
+
bound to another gateway (fails closed).
|
|
60
|
+
"""
|
|
61
|
+
return next(
|
|
62
|
+
(arg[len(_GATEWAY_FLAG) :] for arg in argv if arg.startswith(_GATEWAY_FLAG)),
|
|
63
|
+
"",
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
|
|
46
67
|
def main() -> int:
|
|
47
68
|
"""Print the credential, or explain on stderr why there isn't one."""
|
|
48
69
|
try:
|
|
@@ -52,7 +73,7 @@ def main() -> int:
|
|
|
52
73
|
return 1
|
|
53
74
|
|
|
54
75
|
try:
|
|
55
|
-
credential, _ = resolve_credential()
|
|
76
|
+
credential, _ = resolve_credential(gateway_url=_gateway_url(sys.argv[1:]))
|
|
56
77
|
except AiGatewayError as err:
|
|
57
78
|
# stderr only — a failure must never look like a token on stdout.
|
|
58
79
|
print(str(err), file=sys.stderr)
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
"""Local environment registry management CLI commands."""
|
|
5
5
|
|
|
6
6
|
from pathlib import Path
|
|
7
|
-
from typing import Optional
|
|
7
|
+
from typing import Callable, Optional
|
|
8
8
|
|
|
9
9
|
import typer
|
|
10
10
|
from rich.console import Console
|
|
11
11
|
|
|
12
|
-
from qbraid_cli.handlers import handle_error, run_progress_task
|
|
12
|
+
from qbraid_cli.handlers import handle_error, require_tty, run_progress_task
|
|
13
13
|
|
|
14
14
|
registry_app = typer.Typer(
|
|
15
15
|
help="Manage the local environment registry.",
|
|
@@ -46,19 +46,23 @@ def registry_add(
|
|
|
46
46
|
|
|
47
47
|
# Get info first to show user
|
|
48
48
|
try:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
# Never run the env's interpreter here: that would run an untrusted env's code
|
|
50
|
+
# before the user has confirmed anything. Core's find_env_python is the rule
|
|
51
|
+
# core registers with; the fallback copies it for qbraid-core 0.6.55.
|
|
52
|
+
from qbraid_core.system import executables
|
|
53
|
+
|
|
54
|
+
def _fallback_find_env_python(env_path: Path) -> Optional[Path]:
|
|
55
|
+
candidates = (
|
|
56
|
+
env_path / "bin" / "python",
|
|
57
|
+
env_path / "bin" / "python3",
|
|
58
|
+
env_path / "Scripts" / "python.exe",
|
|
59
|
+
)
|
|
60
|
+
return next((c for c in candidates if executables.is_exe(c)), None)
|
|
56
61
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
break
|
|
62
|
+
find_env_python: Callable[[Path], Optional[Path]] = getattr(
|
|
63
|
+
executables, "find_env_python", _fallback_find_env_python
|
|
64
|
+
)
|
|
65
|
+
python_path = find_env_python(path)
|
|
62
66
|
|
|
63
67
|
if not python_path:
|
|
64
68
|
handle_error(
|
|
@@ -69,10 +73,18 @@ def registry_add(
|
|
|
69
73
|
|
|
70
74
|
# Confirm with user
|
|
71
75
|
if not auto_confirm:
|
|
76
|
+
require_tty(
|
|
77
|
+
"qbraid envs registry add",
|
|
78
|
+
"confirmation required",
|
|
79
|
+
"Re-run with --yes.",
|
|
80
|
+
)
|
|
72
81
|
console.print("\n[bold]📦 Registering external environment:[/bold]")
|
|
73
82
|
console.print(f" Path: {path}")
|
|
74
83
|
console.print(f" Name: {alias or name or path.name}")
|
|
75
84
|
console.print(f" Python: {python_path}")
|
|
85
|
+
console.print(
|
|
86
|
+
" Registering runs this interpreter (python -m pip freeze) to record its packages."
|
|
87
|
+
)
|
|
76
88
|
|
|
77
89
|
if not typer.confirm("\nProceed with registration?"):
|
|
78
90
|
typer.echo("❌ Registration cancelled.")
|
|
@@ -90,6 +102,8 @@ def registry_add(
|
|
|
90
102
|
typer.echo(f" - Add kernel: qbraid kernels add {result['name']}")
|
|
91
103
|
typer.echo(" - View in list: qbraid envs list")
|
|
92
104
|
|
|
105
|
+
except typer.Exit:
|
|
106
|
+
raise
|
|
93
107
|
except Exception as e:
|
|
94
108
|
handle_error(message=str(e))
|
|
95
109
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: qbraid-cli
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.2
|
|
4
4
|
Summary: Command Line Interface for interacting with all parts of the qBraid platform.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License-Expression: LicenseRef-Proprietary
|
|
@@ -30,11 +30,11 @@ Requires-Dist: typer>=0.12.1
|
|
|
30
30
|
Requires-Dist: rich>=10.11.0
|
|
31
31
|
Requires-Dist: click<=8.5.1
|
|
32
32
|
Requires-Dist: questionary>=2.0.0
|
|
33
|
-
Requires-Dist: qbraid-core>=0.6.
|
|
33
|
+
Requires-Dist: qbraid-core>=0.6.56
|
|
34
34
|
Provides-Extra: compute
|
|
35
|
-
Requires-Dist: qbraid-core[compute]>=0.6.
|
|
35
|
+
Requires-Dist: qbraid-core[compute]>=0.6.56; extra == "compute"
|
|
36
36
|
Provides-Extra: envs
|
|
37
|
-
Requires-Dist: qbraid-core[environments]>=0.6.
|
|
37
|
+
Requires-Dist: qbraid-core[environments]>=0.6.56; extra == "envs"
|
|
38
38
|
Provides-Extra: dev
|
|
39
39
|
Requires-Dist: isort; extra == "dev"
|
|
40
40
|
Requires-Dist: black; extra == "dev"
|
|
@@ -2,10 +2,10 @@ typer>=0.12.1
|
|
|
2
2
|
rich>=10.11.0
|
|
3
3
|
click<=8.5.1
|
|
4
4
|
questionary>=2.0.0
|
|
5
|
-
qbraid-core>=0.6.
|
|
5
|
+
qbraid-core>=0.6.56
|
|
6
6
|
|
|
7
7
|
[compute]
|
|
8
|
-
qbraid-core[compute]>=0.6.
|
|
8
|
+
qbraid-core[compute]>=0.6.56
|
|
9
9
|
|
|
10
10
|
[dev]
|
|
11
11
|
isort
|
|
@@ -15,4 +15,4 @@ pytest-cov
|
|
|
15
15
|
pytest-asyncio
|
|
16
16
|
|
|
17
17
|
[envs]
|
|
18
|
-
qbraid-core[environments]>=0.6.
|
|
18
|
+
qbraid-core[environments]>=0.6.56
|
|
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
|
|
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
|