contree-cli 0.9.1__tar.gz → 0.9.4__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 (71) hide show
  1. {contree_cli-0.9.1 → contree_cli-0.9.4}/PKG-INFO +2 -2
  2. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/auth.py +4 -3
  3. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/cd.py +2 -2
  4. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/images.py +2 -2
  5. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/ls.py +1 -1
  6. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/operation.py +5 -5
  7. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/run.py +18 -11
  8. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/session.py +3 -1
  9. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/config.py +7 -1
  10. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_from.py +3 -3
  11. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/repl.py +3 -3
  12. {contree_cli-0.9.1 → contree_cli-0.9.4}/pyproject.toml +2 -2
  13. {contree_cli-0.9.1 → contree_cli-0.9.4}/pyproject.toml.orig +2 -2
  14. {contree_cli-0.9.1 → contree_cli-0.9.4}/LICENSE +0 -0
  15. {contree_cli-0.9.1 → contree_cli-0.9.4}/README.md +0 -0
  16. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/__init__.py +0 -0
  17. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/__main__.py +0 -0
  18. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/agent.md +0 -0
  19. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/arguments.py +0 -0
  20. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/__init__.py +0 -0
  21. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/agent.py +0 -0
  22. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/build.py +0 -0
  23. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/cat.py +0 -0
  24. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/cp.py +0 -0
  25. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/env.py +0 -0
  26. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/export.py +0 -0
  27. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/file.py +0 -0
  28. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/grep.py +0 -0
  29. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/show.py +0 -0
  30. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/skill.py +0 -0
  31. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/tag.py +0 -0
  32. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/cli/use.py +0 -0
  33. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/client.py +0 -0
  34. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/__init__.py +0 -0
  35. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/context.py +0 -0
  36. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/dockerignore.py +0 -0
  37. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/keyword.py +0 -0
  38. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_add.py +0 -0
  39. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_arg.py +0 -0
  40. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_copy.py +0 -0
  41. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_env.py +0 -0
  42. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_run.py +0 -0
  43. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_skipped.py +0 -0
  44. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_user.py +0 -0
  45. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/kw_workdir.py +0 -0
  46. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/local_context.py +0 -0
  47. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/parser.py +0 -0
  48. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/docker/url_fetch.py +0 -0
  49. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/log.py +0 -0
  50. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/man.py +0 -0
  51. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/manual.md +0 -0
  52. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/mapped_file.py +0 -0
  53. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/migrations.py +0 -0
  54. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/output.py +0 -0
  55. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/pty_utils.py +0 -0
  56. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/py.typed +0 -0
  57. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/refs.py +0 -0
  58. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/session.py +0 -0
  59. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/__init__.py +0 -0
  60. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/argmap.py +0 -0
  61. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/argspec.py +0 -0
  62. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/cache.py +0 -0
  63. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/completer.py +0 -0
  64. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/history.py +0 -0
  65. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/parser.py +0 -0
  66. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/sources.py +0 -0
  67. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/shell/trie.py +0 -0
  68. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/skill.py +0 -0
  69. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/skill_body.md +0 -0
  70. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/types.py +0 -0
  71. {contree_cli-0.9.1 → contree_cli-0.9.4}/contree_cli/update_check.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: contree-cli
3
- Version: 0.9.1
3
+ Version: 0.9.4
4
4
  Summary: CLI client for the ConTree sandbox platform
5
5
  Keywords: sandbox,cli,vm,ai-agent,contree
6
6
  Author: Dmitry Orlov
@@ -197,7 +197,7 @@ Classifier: Programming Language :: Python :: 3.14
197
197
  Classifier: Topic :: Software Development :: Build Tools
198
198
  Classifier: Topic :: System :: Shells
199
199
  Classifier: Typing :: Typed
200
- Requires-Dist: contree-client>=0.2.1
200
+ Requires-Dist: contree-client~=0.4.0
201
201
  Requires-Python: >=3.10
202
202
  Project-URL: Homepage, https://contree.dev
203
203
  Project-URL: Documentation, https://docs.contree.dev/cli/
@@ -31,7 +31,7 @@ import os
31
31
  from dataclasses import dataclass
32
32
  from multiprocessing.pool import ThreadPool
33
33
 
34
- from contree_client.exceptions import ContreeAPIError
34
+ from contree_client.exceptions import APIStatusError
35
35
  from contree_client.models import WhoAmIResponse
36
36
 
37
37
  from contree_cli import FORMATTER, ArgumentsProtocol, SetupResult
@@ -263,12 +263,13 @@ def cmd_auth(args: AuthArgs) -> int | None:
263
263
  try:
264
264
  with client:
265
265
  whoami = client.whoami()
266
- except ContreeAPIError as exc:
266
+ except (APIStatusError, ValueError) as exc:
267
+ # ValueError covers parse_whoami's own non-2xx status check.
267
268
  # Logs the API error message, not the token itself.
268
269
  # nosemgrep: python-logger-credential-disclosure
269
270
  logger.error("Token verification failed: %s. Profile not changed.", exc)
270
271
  return 1
271
- except (KeyError, TypeError, ValueError) as exc:
272
+ except (KeyError, TypeError) as exc:
272
273
  # Strict contree-client models raise TypeError (missing required
273
274
  # field) or KeyError (parse_fields lookup) on incomplete payloads.
274
275
  logger.error("Could not parse /v1/whoami response: %s", exc)
@@ -14,7 +14,7 @@ import logging
14
14
  import posixpath
15
15
  from dataclasses import dataclass
16
16
 
17
- from contree_client.exceptions import ContreeAPIError
17
+ from contree_client.exceptions import APIStatusError
18
18
 
19
19
  from contree_cli import CLIENT, SESSION_STORE, ArgumentsProtocol, SetupResult
20
20
 
@@ -64,7 +64,7 @@ def cmd_cd(args: CdArgs) -> int | None:
64
64
  client = CLIENT.get()
65
65
  uuid = client.resolve_image(session.current_image)
66
66
  client.inspect_image_list(uuid, new_cwd)
67
- except ContreeAPIError as exc:
67
+ except APIStatusError as exc:
68
68
  if exc.status == 404:
69
69
  logger.error("cd: %s: no such directory", new_cwd)
70
70
  return 1
@@ -16,7 +16,7 @@ import time
16
16
  from dataclasses import dataclass, field
17
17
  from datetime import datetime
18
18
 
19
- from contree_client.exceptions import ContreeAPIError
19
+ from contree_client.exceptions import APIStatusError
20
20
  from contree_client.models import (
21
21
  TERMINAL_STATUSES,
22
22
  ImageImportRegistry,
@@ -393,7 +393,7 @@ def cmd_import(args: ImportArgs) -> int | None:
393
393
  try:
394
394
  client.cancel_operation(op_uuid)
395
395
  logger.info("Cancelled operation %s", op_uuid)
396
- except (ContreeAPIError, KeyboardInterrupt, OSError):
396
+ except (APIStatusError, KeyboardInterrupt, OSError):
397
397
  pass
398
398
  raise
399
399
 
@@ -71,7 +71,7 @@ def cmd_ls(args: LsArgs) -> None:
71
71
  )
72
72
  )
73
73
  if response.status != 200:
74
- raise error_for_response(response)
74
+ raise error_for_response(response.status, response.headers, response.body)
75
75
  sys.stdout.write(response.body.decode())
76
76
  return
77
77
 
@@ -21,7 +21,7 @@ from dataclasses import dataclass, field
21
21
  from datetime import datetime
22
22
  from typing import Any
23
23
 
24
- from contree_client.exceptions import ContreeAPIError
24
+ from contree_client.exceptions import APIStatusError
25
25
  from contree_client.models import ACTIVE_STATUSES, TERMINAL_STATUSES
26
26
 
27
27
  from contree_cli import CLIENT, FORMATTER, SESSION_STORE, ArgumentsProtocol, SetupResult
@@ -460,7 +460,7 @@ def cmd_show_multi(args: ShowMultiArgs) -> int | None:
460
460
  for uuid in args.uuids:
461
461
  try:
462
462
  result = cmd_show(ShowArgs(uuid=uuid, raw=args.raw))
463
- except ContreeAPIError as exc:
463
+ except APIStatusError as exc:
464
464
  logger.error("Failed to fetch %s: %s", uuid, exc)
465
465
  exit_code = max(exit_code, 1)
466
466
  continue
@@ -490,7 +490,7 @@ def cmd_cancel(args: CancelArgs) -> int | None:
490
490
  try:
491
491
  client.cancel_operation(uuid)
492
492
  logger.info("Cancelled operation %s", uuid)
493
- except ContreeAPIError as exc:
493
+ except APIStatusError as exc:
494
494
  logger.error("Failed to cancel %s: %s", uuid, exc)
495
495
  failed += 1
496
496
  return 1 if failed else None
@@ -506,7 +506,7 @@ def cmd_events(args: EventsArgs) -> int | None:
506
506
  try:
507
507
  for ev in client.iter_operation_events(uuid, follow=False):
508
508
  formatter(uuid=uuid, **ev.to_dict())
509
- except ContreeAPIError as exc:
509
+ except APIStatusError as exc:
510
510
  logger.error("Failed to fetch events for %s: %s", uuid, exc)
511
511
  exit_code = 1
512
512
  formatter.flush()
@@ -592,7 +592,7 @@ def cmd_wait(args: WaitArgs) -> int | None:
592
592
  for uuid in sorted(pending):
593
593
  try:
594
594
  op = client.get_operation_status(uuid).to_dict()
595
- except ContreeAPIError as exc:
595
+ except APIStatusError as exc:
596
596
  logger.error("Failed to fetch %s: %s", uuid, exc)
597
597
  continue
598
598
  formatter(**{**op, "timed_out": True})
@@ -65,7 +65,7 @@ from dataclasses import dataclass, field
65
65
  from multiprocessing.pool import ThreadPool
66
66
  from typing import Any
67
67
 
68
- from contree_client.exceptions import ContreeAPIError
68
+ from contree_client.exceptions import APIStatusError, ContreeError
69
69
  from contree_client.models import (
70
70
  TERMINAL_STATUSES,
71
71
  ClosableStreamRepr,
@@ -94,14 +94,8 @@ from contree_cli.types import FLAGS
94
94
 
95
95
  logger = logging.getLogger(__name__)
96
96
 
97
- # Backend transport exceptions (httpx/urllib3/aiohttp/...) don't inherit
98
- # from OSError, so ContreeAPIError/OSError alone miss a lost connection.
99
- SIGNAL_ERRORS: tuple[type[BaseException], ...] = (
100
- ContreeAPIError,
101
- OSError,
102
- *CliClient.retryable_errors,
103
- *CliClient.nonretryable_errors,
104
- )
97
+ # ContreeError covers APIConnectionError from any transport backend.
98
+ SIGNAL_ERRORS: tuple[type[BaseException], ...] = (ContreeError, OSError)
105
99
 
106
100
  EPILOG = """\
107
101
  examples:
@@ -157,6 +151,11 @@ class StdinForwarder(threading.Thread):
157
151
  self.source = source
158
152
  self.spid = spid
159
153
  self.error: Exception | None = None
154
+ self.abandoned = threading.Event()
155
+
156
+ def abandon(self) -> None:
157
+ """Drop further queue items instead of sending them to a terminal operation."""
158
+ self.abandoned.set()
160
159
 
161
160
  def send(self, sr: ClosableStreamRepr) -> None:
162
161
  # This POST is non-idempotent and a lost response is ambiguous
@@ -174,6 +173,8 @@ class StdinForwarder(threading.Thread):
174
173
  def run(self) -> None:
175
174
  while True:
176
175
  sr = self.source.get()
176
+ if self.abandoned.is_set():
177
+ return
177
178
  try:
178
179
  self.send(sr)
179
180
  except Exception as exc:
@@ -649,6 +650,8 @@ def stream_events_until_close(
649
650
  logger.debug("event: %s", ev)
650
651
  case _:
651
652
  logger.debug("event: %s", ev)
653
+ if stdin_forwarder is not None:
654
+ stdin_forwarder.abandon()
652
655
  break
653
656
  except KeyboardInterrupt as interrupt:
654
657
  if not sigint_sent:
@@ -667,6 +670,8 @@ def stream_events_until_close(
667
670
  # Either the signal itself failed, or this is a second
668
671
  # Ctrl-C after it was already sent: give up and tear down
669
672
  # the whole operation.
673
+ if stdin_forwarder is not None:
674
+ stdin_forwarder.abandon()
670
675
  with contextlib.suppress(KeyboardInterrupt, *SIGNAL_ERRORS):
671
676
  client.cancel_operation(op_uuid)
672
677
  logger.info("Cancelled operation %s", op_uuid)
@@ -677,7 +682,7 @@ def stream_events_until_close(
677
682
  # payload the caller would otherwise build from `completion`.
678
683
  try:
679
684
  op = client.get_operation_status(op_uuid).to_dict()
680
- except ContreeAPIError as exc:
685
+ except APIStatusError as exc:
681
686
  logger.debug("terminal op fetch failed: %s", exc)
682
687
  return summary
683
688
  if op.get("status") in TERMINAL_STATUSES:
@@ -1014,7 +1019,9 @@ def cmd_run(args: RunArgs) -> int | None:
1014
1019
  # Local stdout/stderr was closed (e.g. `contree run | head`).
1015
1020
  # Cancel the op, silence further stdio writes, then exit 141
1016
1021
  # so callers see the SIGPIPE convention (128 + 13).
1017
- with contextlib.suppress(ContreeAPIError, OSError):
1022
+ if forwarder is not None:
1023
+ forwarder.abandon()
1024
+ with contextlib.suppress(APIStatusError, OSError):
1018
1025
  client.cancel_operation(op_uuid)
1019
1026
  with contextlib.suppress(OSError):
1020
1027
  devnull = os.open(os.devnull, os.O_WRONLY)
@@ -664,7 +664,9 @@ def cmd_wait(args: WaitArgs) -> int | None:
664
664
  RequestSpec(method="GET", path="/operations", idempotent=True)
665
665
  )
666
666
  if response.status != 200:
667
- raise error_for_response(response)
667
+ raise error_for_response(
668
+ response.status, response.headers, response.body
669
+ )
668
670
  operations = json.loads(response.body)
669
671
  api_op_ids: list[str] = []
670
672
  for op in operations:
@@ -78,7 +78,13 @@ EDITOR = (
78
78
 
79
79
 
80
80
  def session_db_path(profile_name: str) -> Path:
81
- """Per-profile session database location (CLI-owned layout)."""
81
+ """Per-profile session database location (CLI-owned layout).
82
+
83
+ ``CONTREE_SESSION_DB`` overrides the computed path entirely.
84
+ """
85
+ override = os.getenv("CONTREE_SESSION_DB")
86
+ if override:
87
+ return Path(override).expanduser()
82
88
  return CONTREE_HOME / "cli" / "sessions" / f"{profile_name}.db"
83
89
 
84
90
 
@@ -8,7 +8,7 @@ import logging
8
8
  from dataclasses import dataclass
9
9
  from typing import ClassVar
10
10
 
11
- from contree_client.exceptions import ContreeAPIError
11
+ from contree_client.exceptions import APIStatusError
12
12
  from contree_client.models import ImageImportRegistry
13
13
 
14
14
  from contree_cli.cli.images import normalize_registry_url
@@ -110,7 +110,7 @@ def resolve_or_import(ctx: BuildContext, ref: str) -> str:
110
110
  """Resolve ``ref`` to a UUID, importing from a registry on miss."""
111
111
  try:
112
112
  return ctx.client.resolve_image(ref)
113
- except ContreeAPIError as exc:
113
+ except APIStatusError as exc:
114
114
  if exc.status != 404:
115
115
  raise
116
116
 
@@ -127,7 +127,7 @@ def resolve_or_import(ctx: BuildContext, ref: str) -> str:
127
127
  try:
128
128
  return wait_import(ctx, op_uuid, tag)
129
129
  except KeyboardInterrupt:
130
- with contextlib.suppress(ContreeAPIError, OSError):
130
+ with contextlib.suppress(APIStatusError, OSError):
131
131
  ctx.client.cancel_operation(op_uuid)
132
132
  raise
133
133
 
@@ -11,7 +11,7 @@ import sys
11
11
  from dataclasses import dataclass
12
12
  from functools import cached_property
13
13
 
14
- from contree_client.exceptions import ContreeAPIError
14
+ from contree_client.exceptions import APIStatusError
15
15
 
16
16
  from contree_cli import FORMATTER, IN_SHELL, PROFILE, SESSION_STORE, ArgumentsProtocol
17
17
  from contree_cli.output import FORMATTERS, OutputFormatter
@@ -519,7 +519,7 @@ class ContreeShell:
519
519
  before = self.session_snapshot()
520
520
  try:
521
521
  handler(loader.from_args(ns))
522
- except ContreeAPIError as exc:
522
+ except APIStatusError as exc:
523
523
  print(f"API error: {exc}", file=sys.stderr)
524
524
  except KeyboardInterrupt:
525
525
  print()
@@ -558,7 +558,7 @@ class ContreeShell:
558
558
  before = self.session_snapshot()
559
559
  try:
560
560
  cmd_run(args)
561
- except ContreeAPIError as exc:
561
+ except APIStatusError as exc:
562
562
  print(f"API error: {exc}", file=sys.stderr)
563
563
  except KeyboardInterrupt:
564
564
  print()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "contree-cli"
3
- version = "0.9.1"
3
+ version = "0.9.4"
4
4
  description = "CLI client for the ConTree sandbox platform"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -28,7 +28,7 @@ classifiers = [
28
28
  "Topic :: System :: Shells",
29
29
  "Typing :: Typed",
30
30
  ]
31
- dependencies = ["contree-client>=0.2.1"]
31
+ dependencies = ["contree-client~=0.4.0"]
32
32
 
33
33
  [project.license]
34
34
  file = "LICENSE"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "contree-cli"
3
- version = "0.9.1"
3
+ version = "0.9.4"
4
4
  description = "CLI client for the ConTree sandbox platform"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -27,7 +27,7 @@ classifiers = [
27
27
  "Typing :: Typed",
28
28
  ]
29
29
  dependencies = [
30
- "contree-client>=0.2.1",
30
+ "contree-client~=0.4.0",
31
31
  ]
32
32
 
33
33
  [project.urls]
File without changes
File without changes