dremio-cli 2.0.0__tar.gz → 2.1.1__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.
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/.github/workflows/ci.yml +1 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/.gitignore +2 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/PKG-INFO +19 -7
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/README.md +12 -3
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/.claude-plugin/plugin.json +1 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/pyproject.toml +6 -3
- dremio_cli-2.1.1/src/drs/_version.py +24 -0
- dremio_cli-2.1.1/src/drs/chat_render.py +314 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/cli.py +61 -7
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/client.py +96 -1
- dremio_cli-2.1.1/src/drs/commands/chat.py +703 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/engine.py +1 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/folder.py +3 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/grant.py +4 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/job.py +1 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/project.py +1 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/query.py +38 -3
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/reflection.py +50 -13
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/role.py +1 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/schema.py +4 -1
- dremio_cli-2.1.1/src/drs/commands/setup.py +249 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/tag.py +3 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/user.py +1 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/wiki.py +4 -1
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/introspect.py +7 -3
- dremio_cli-2.1.1/src/drs/sse.py +78 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/utils.py +34 -9
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_client.py +39 -0
- dremio_cli-2.1.1/tests/test_commands/test_chat.py +115 -0
- dremio_cli-2.1.1/tests/test_commands/test_reflection.py +124 -0
- dremio_cli-2.1.1/tests/test_commands/test_setup.py +273 -0
- dremio_cli-2.1.1/tests/test_sse.py +130 -0
- dremio_cli-2.1.1/uv.lock +608 -0
- dremio_cli-2.0.0/src/drs/_version.py +0 -34
- dremio_cli-2.0.0/tests/test_commands/test_reflection.py +0 -45
- dremio_cli-2.0.0/uv.lock +0 -578
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/.claude-plugin/marketplace.json +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/.github/workflows/release.yml +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/.license-header.txt +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/.pre-commit-config.yaml +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/.python-version +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/CODE_OF_CONDUCT.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/CONTRIBUTING.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/DISCOVERY_SERVICE_PLAN.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/LICENSE +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/SPIKE_NOTES.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/TESTING.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/skills/audit-dataset-access/SKILL.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/skills/document-dataset/SKILL.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/skills/dremio/SKILL.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/skills/dremio-dbt/SKILL.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/skills/dremio-setup/SKILL.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/skills/investigate-data-quality/SKILL.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/skills/investigate-slow-query/SKILL.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/plugins/dremio/skills/onboard-new-source/SKILL.md +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/scripts/parse_jssdk.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/scripts/validate_api_coverage.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/__init__.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/auth.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/commands/__init__.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/src/drs/output.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/__init__.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/conftest.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_auth.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_client_retry.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/__init__.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_engine.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_folder.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_grant.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_project.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_query.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_role.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_tag.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_user.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_commands/test_wiki.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_output.py +0 -0
- {dremio_cli-2.0.0 → dremio_cli-2.1.1}/tests/test_utils.py +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dremio-cli
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.1.1
|
|
4
|
+
Summary: Official developer CLI for Dremio Cloud — install with: pipx install dremio-cli
|
|
5
5
|
Project-URL: Homepage, https://github.com/dremio/cli
|
|
6
6
|
Project-URL: Repository, https://github.com/dremio/cli
|
|
7
7
|
Project-URL: Issues, https://github.com/dremio/cli/issues
|
|
8
8
|
Author: Dremio Corporation
|
|
9
9
|
License-Expression: Apache-2.0
|
|
10
10
|
License-File: LICENSE
|
|
11
|
-
Keywords: cli,data-lake,dremio,sql
|
|
11
|
+
Keywords: cli,data-lake,dremio,dremio-cloud,official,sql
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Environment :: Console
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
@@ -17,12 +17,15 @@ Classifier: Programming Language :: Python :: 3
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
21
|
Classifier: Topic :: Database
|
|
21
22
|
Requires-Python: >=3.11
|
|
22
23
|
Requires-Dist: httpx>=0.27
|
|
24
|
+
Requires-Dist: prompt-toolkit>=3.0
|
|
23
25
|
Requires-Dist: pydantic>=2
|
|
24
26
|
Requires-Dist: pyyaml>=6
|
|
25
|
-
Requires-Dist:
|
|
27
|
+
Requires-Dist: rich>=13
|
|
28
|
+
Requires-Dist: typer>=0.9
|
|
26
29
|
Description-Content-Type: text/markdown
|
|
27
30
|
|
|
28
31
|
[](https://github.com/dremio/cli/actions/workflows/ci.yml)
|
|
@@ -59,13 +62,18 @@ Dremio Cloud has a powerful REST API and rich system tables, but no official CLI
|
|
|
59
62
|
|
|
60
63
|
### 1. Install
|
|
61
64
|
|
|
65
|
+
The package name is **`dremio-cli`** (not `dremio-client`, which is an unrelated third-party package).
|
|
66
|
+
|
|
62
67
|
```bash
|
|
63
|
-
#
|
|
64
|
-
|
|
68
|
+
# Recommended — isolated install, no venv needed
|
|
69
|
+
pipx install dremio-cli
|
|
65
70
|
|
|
66
|
-
# Or with uv
|
|
71
|
+
# Or with uv (fast, also isolated)
|
|
67
72
|
uv tool install dremio-cli
|
|
68
73
|
|
|
74
|
+
# Or with pip (requires a virtual environment on modern Python)
|
|
75
|
+
pip install dremio-cli
|
|
76
|
+
|
|
69
77
|
# Or install from source
|
|
70
78
|
git clone https://github.com/dremio/cli.git
|
|
71
79
|
cd cli
|
|
@@ -75,6 +83,10 @@ uv tool install .
|
|
|
75
83
|
uv sync
|
|
76
84
|
```
|
|
77
85
|
|
|
86
|
+
> **Tip:** On macOS and recent Linux distros, `pip install` into the system Python is blocked
|
|
87
|
+
> (`externally-managed-environment` error). Use `pipx` or `uv tool install` instead — they
|
|
88
|
+
> automatically create an isolated environment for you.
|
|
89
|
+
|
|
78
90
|
After install, verify the binary is available:
|
|
79
91
|
|
|
80
92
|
```bash
|
|
@@ -32,13 +32,18 @@ Dremio Cloud has a powerful REST API and rich system tables, but no official CLI
|
|
|
32
32
|
|
|
33
33
|
### 1. Install
|
|
34
34
|
|
|
35
|
+
The package name is **`dremio-cli`** (not `dremio-client`, which is an unrelated third-party package).
|
|
36
|
+
|
|
35
37
|
```bash
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
+
# Recommended — isolated install, no venv needed
|
|
39
|
+
pipx install dremio-cli
|
|
38
40
|
|
|
39
|
-
# Or with uv
|
|
41
|
+
# Or with uv (fast, also isolated)
|
|
40
42
|
uv tool install dremio-cli
|
|
41
43
|
|
|
44
|
+
# Or with pip (requires a virtual environment on modern Python)
|
|
45
|
+
pip install dremio-cli
|
|
46
|
+
|
|
42
47
|
# Or install from source
|
|
43
48
|
git clone https://github.com/dremio/cli.git
|
|
44
49
|
cd cli
|
|
@@ -48,6 +53,10 @@ uv tool install .
|
|
|
48
53
|
uv sync
|
|
49
54
|
```
|
|
50
55
|
|
|
56
|
+
> **Tip:** On macOS and recent Linux distros, `pip install` into the system Python is blocked
|
|
57
|
+
> (`externally-managed-environment` error). Use `pipx` or `uv tool install` instead — they
|
|
58
|
+
> automatically create an isolated environment for you.
|
|
59
|
+
|
|
51
60
|
After install, verify the binary is available:
|
|
52
61
|
|
|
53
62
|
```bash
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": "1.0",
|
|
3
3
|
"name": "dremio",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"description": "Dremio Cloud developer skills — SQL reference, setup wizard, dbt integration, and workflow automations powered by the drs CLI.",
|
|
6
6
|
"skills": [
|
|
7
7
|
"skills/dremio",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dremio-cli"
|
|
3
3
|
dynamic = ["version"]
|
|
4
|
-
description = "
|
|
4
|
+
description = "Official developer CLI for Dremio Cloud — install with: pipx install dremio-cli"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.11"
|
|
7
7
|
license = "Apache-2.0"
|
|
@@ -15,14 +15,17 @@ classifiers = [
|
|
|
15
15
|
"Programming Language :: Python :: 3.11",
|
|
16
16
|
"Programming Language :: Python :: 3.12",
|
|
17
17
|
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Programming Language :: Python :: 3.14",
|
|
18
19
|
"Topic :: Database",
|
|
19
20
|
]
|
|
20
|
-
keywords = ["dremio", "cli", "data-lake", "sql"]
|
|
21
|
+
keywords = ["dremio", "dremio-cloud", "cli", "data-lake", "sql", "official"]
|
|
21
22
|
dependencies = [
|
|
22
|
-
"typer
|
|
23
|
+
"typer>=0.9",
|
|
23
24
|
"httpx>=0.27",
|
|
24
25
|
"pyyaml>=6",
|
|
25
26
|
"pydantic>=2",
|
|
27
|
+
"rich>=13",
|
|
28
|
+
"prompt-toolkit>=3.0",
|
|
26
29
|
]
|
|
27
30
|
|
|
28
31
|
[project.scripts]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '2.1.1'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 1, 1)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (C) 2017-2026 Dremio Corporation
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
#
|
|
16
|
+
"""Rich terminal renderer for Dremio AI Agent chat sessions."""
|
|
17
|
+
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
import json
|
|
21
|
+
import sys
|
|
22
|
+
import threading
|
|
23
|
+
from typing import Any
|
|
24
|
+
|
|
25
|
+
from rich.console import Console
|
|
26
|
+
from rich.markdown import Markdown
|
|
27
|
+
from rich.panel import Panel
|
|
28
|
+
from rich.syntax import Syntax
|
|
29
|
+
from rich.text import Text
|
|
30
|
+
|
|
31
|
+
# Spinner frames for the "Thinking..." animation.
|
|
32
|
+
_SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
|
|
33
|
+
_SPINNER_INTERVAL = 0.08
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class _Spinner:
|
|
37
|
+
"""A lightweight terminal spinner that does NOT use Rich's Live display.
|
|
38
|
+
|
|
39
|
+
Rich's ``Status`` / ``Live`` captures all ``console.print()`` calls and
|
|
40
|
+
renders them on its own refresh cycle, which can visually delay SSE events.
|
|
41
|
+
This spinner writes its animation directly to *stderr* using ANSI escape
|
|
42
|
+
codes so that ``console.print()`` output flows to the terminal immediately.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(self, message: str = "Thinking...") -> None:
|
|
46
|
+
self._message = message
|
|
47
|
+
self._stop_event = threading.Event()
|
|
48
|
+
self._thread: threading.Thread | None = None
|
|
49
|
+
|
|
50
|
+
def start(self) -> None:
|
|
51
|
+
if self._thread is not None:
|
|
52
|
+
return
|
|
53
|
+
self._stop_event.clear()
|
|
54
|
+
self._thread = threading.Thread(target=self._run, daemon=True)
|
|
55
|
+
self._thread.start()
|
|
56
|
+
|
|
57
|
+
def stop(self) -> None:
|
|
58
|
+
if self._thread is None:
|
|
59
|
+
return
|
|
60
|
+
self._stop_event.set()
|
|
61
|
+
self._thread.join(timeout=1.0)
|
|
62
|
+
self._thread = None
|
|
63
|
+
# Clear the spinner line
|
|
64
|
+
sys.stderr.write("\r\033[K")
|
|
65
|
+
sys.stderr.flush()
|
|
66
|
+
|
|
67
|
+
def _run(self) -> None:
|
|
68
|
+
idx = 0
|
|
69
|
+
while not self._stop_event.is_set():
|
|
70
|
+
frame = _SPINNER_FRAMES[idx % len(_SPINNER_FRAMES)]
|
|
71
|
+
sys.stderr.write(f"\r{frame} {self._message}")
|
|
72
|
+
sys.stderr.flush()
|
|
73
|
+
idx += 1
|
|
74
|
+
self._stop_event.wait(_SPINNER_INTERVAL)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class ChatRenderer:
|
|
78
|
+
"""Renders agent SSE events to a Rich console (interactive mode)."""
|
|
79
|
+
|
|
80
|
+
def __init__(self, console: Console | None = None) -> None:
|
|
81
|
+
self.console = console or Console()
|
|
82
|
+
self._spinner: _Spinner | None = None
|
|
83
|
+
|
|
84
|
+
# -- Model output --
|
|
85
|
+
|
|
86
|
+
def render_model_chunk(self, name: str, result: dict) -> None:
|
|
87
|
+
"""Render a model output chunk based on the task type."""
|
|
88
|
+
text = result.get("text", "")
|
|
89
|
+
if not text:
|
|
90
|
+
return
|
|
91
|
+
|
|
92
|
+
if name == "modelGenerateSql":
|
|
93
|
+
self.console.print(Syntax(text, "sql", theme="monokai", line_numbers=False))
|
|
94
|
+
elif name == "modelReject":
|
|
95
|
+
self.console.print(Text(text, style="bold yellow"))
|
|
96
|
+
else:
|
|
97
|
+
# modelGeneric, modelSqlAnswer, and others
|
|
98
|
+
self.console.print(Markdown(text))
|
|
99
|
+
|
|
100
|
+
# -- Tool events --
|
|
101
|
+
|
|
102
|
+
def render_tool_request(
|
|
103
|
+
self,
|
|
104
|
+
call_id: str,
|
|
105
|
+
name: str,
|
|
106
|
+
arguments: dict | None = None,
|
|
107
|
+
title: str | None = None,
|
|
108
|
+
) -> None:
|
|
109
|
+
"""Show a tool call request in a bordered panel."""
|
|
110
|
+
display_name = title or name
|
|
111
|
+
args_summary = ""
|
|
112
|
+
if arguments:
|
|
113
|
+
args_summary = _summarize_args(arguments)
|
|
114
|
+
|
|
115
|
+
body = Text(args_summary, style="dim") if args_summary else Text("(no arguments)", style="dim")
|
|
116
|
+
self.console.print(
|
|
117
|
+
Panel(body, title=f"[bold cyan]Tool: {display_name}[/]", border_style="cyan", expand=False),
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
def render_tool_response(self, call_id: str, name: str, result: Any) -> None:
|
|
121
|
+
"""Show a tool result in a muted panel."""
|
|
122
|
+
if isinstance(result, dict):
|
|
123
|
+
text = json.dumps(result, indent=2, default=str)
|
|
124
|
+
if len(text) > 500:
|
|
125
|
+
text = text[:500] + "\n..."
|
|
126
|
+
elif isinstance(result, str):
|
|
127
|
+
text = result[:500] + ("..." if len(result) > 500 else "")
|
|
128
|
+
else:
|
|
129
|
+
text = str(result)[:500]
|
|
130
|
+
|
|
131
|
+
self.console.print(
|
|
132
|
+
Panel(Text(text, style="dim"), title=f"[dim]{name} result[/]", border_style="dim", expand=False),
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
def render_tool_progress(self, status: str, message: str) -> None:
|
|
136
|
+
"""Inline progress for long-running tools."""
|
|
137
|
+
self.console.print(Text(f" ⏳ {message}", style="dim italic"))
|
|
138
|
+
|
|
139
|
+
# -- Errors --
|
|
140
|
+
|
|
141
|
+
def render_error(self, error_type: str, message: str) -> None:
|
|
142
|
+
"""Red error display."""
|
|
143
|
+
self.console.print(Text(f"Error ({error_type}): {message}", style="bold red"))
|
|
144
|
+
|
|
145
|
+
# -- Conversation metadata --
|
|
146
|
+
|
|
147
|
+
def render_conversation_title(self, title: str) -> None:
|
|
148
|
+
"""Show conversation title update."""
|
|
149
|
+
self.console.print(Text(f"📝 {title}", style="bold"))
|
|
150
|
+
|
|
151
|
+
# -- Spinner --
|
|
152
|
+
|
|
153
|
+
def start_spinner(self) -> None:
|
|
154
|
+
"""Start an animated 'Thinking...' indicator."""
|
|
155
|
+
if self._spinner is None:
|
|
156
|
+
self._spinner = _Spinner()
|
|
157
|
+
self._spinner.start()
|
|
158
|
+
|
|
159
|
+
def stop_spinner(self) -> None:
|
|
160
|
+
"""Stop the spinner."""
|
|
161
|
+
if self._spinner is not None:
|
|
162
|
+
self._spinner.stop()
|
|
163
|
+
self._spinner = None
|
|
164
|
+
|
|
165
|
+
# -- Tool approval --
|
|
166
|
+
|
|
167
|
+
def prompt_tool_approval(self, nonce: str, tools: list[dict]) -> dict:
|
|
168
|
+
"""Ask user Y/n for each pending tool call; return approval payload.
|
|
169
|
+
|
|
170
|
+
Returns a dict suitable for the ``approvals`` field of the message body.
|
|
171
|
+
"""
|
|
172
|
+
decisions: list[dict] = []
|
|
173
|
+
for tool in tools:
|
|
174
|
+
tool_name = tool.get("name", "unknown")
|
|
175
|
+
tool_id = tool.get("callId", tool.get("id", ""))
|
|
176
|
+
args = tool.get("arguments", {})
|
|
177
|
+
self.render_tool_request(tool_id, tool_name, args)
|
|
178
|
+
try:
|
|
179
|
+
answer = self.console.input(f" Approve [bold cyan]{tool_name}[/]? [Y/n] ").strip().lower()
|
|
180
|
+
except (EOFError, KeyboardInterrupt):
|
|
181
|
+
answer = "n"
|
|
182
|
+
approved = answer in ("", "y", "yes")
|
|
183
|
+
decisions.append(
|
|
184
|
+
{
|
|
185
|
+
"callId": tool_id,
|
|
186
|
+
"decision": "approved" if approved else "denied",
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
return {
|
|
190
|
+
"approvalNonce": nonce,
|
|
191
|
+
"toolDecisions": decisions,
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
# -- Separators --
|
|
195
|
+
|
|
196
|
+
def print_separator(self) -> None:
|
|
197
|
+
"""Print a visual separator between exchanges."""
|
|
198
|
+
self.console.print(Text("─" * 40, style="dim"))
|
|
199
|
+
|
|
200
|
+
def print_welcome(self, conv_id: str | None = None) -> None:
|
|
201
|
+
"""Print welcome banner for interactive mode."""
|
|
202
|
+
self.console.print(
|
|
203
|
+
Panel(
|
|
204
|
+
"[bold]Dremio AI Chat[/]\n"
|
|
205
|
+
"Type a question or use /help for commands.\n"
|
|
206
|
+
"Press [bold]Ctrl+D[/] or type [bold]/quit[/] to exit.",
|
|
207
|
+
border_style="blue",
|
|
208
|
+
expand=False,
|
|
209
|
+
),
|
|
210
|
+
)
|
|
211
|
+
if conv_id:
|
|
212
|
+
self.console.print(Text(f"Resuming conversation: {conv_id}", style="dim"))
|
|
213
|
+
|
|
214
|
+
def print_help(self) -> None:
|
|
215
|
+
"""Print slash command help."""
|
|
216
|
+
help_text = (
|
|
217
|
+
"[bold]Commands:[/]\n"
|
|
218
|
+
" /new Start a new conversation\n"
|
|
219
|
+
" /list List recent conversations\n"
|
|
220
|
+
" /continue <id> Resume a conversation by ID\n"
|
|
221
|
+
" /history Show message history for current conversation\n"
|
|
222
|
+
" /cancel Cancel the active run\n"
|
|
223
|
+
" /delete [id] Delete current or specified conversation\n"
|
|
224
|
+
" /info Show current conversation metadata\n"
|
|
225
|
+
" /quit Exit (or Ctrl+D)"
|
|
226
|
+
)
|
|
227
|
+
self.console.print(Panel(help_text, border_style="blue", expand=False))
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class PlainRenderer:
|
|
231
|
+
"""Non-interactive renderer.
|
|
232
|
+
|
|
233
|
+
When stdout is a terminal, model output is rendered as Rich Markdown.
|
|
234
|
+
When piped, plain text is written with no ANSI codes.
|
|
235
|
+
Tool events and progress always go to stderr.
|
|
236
|
+
"""
|
|
237
|
+
|
|
238
|
+
def __init__(self) -> None:
|
|
239
|
+
self._is_tty = sys.stdout.isatty()
|
|
240
|
+
self._console = Console() if self._is_tty else None
|
|
241
|
+
self._stderr_console = Console(stderr=True, highlight=False)
|
|
242
|
+
self._spinner: _Spinner | None = None
|
|
243
|
+
|
|
244
|
+
def render_model_chunk(self, name: str, result: dict) -> None:
|
|
245
|
+
text = result.get("text", "")
|
|
246
|
+
if not text:
|
|
247
|
+
return
|
|
248
|
+
if self._console is not None:
|
|
249
|
+
if name == "modelGenerateSql":
|
|
250
|
+
self._console.print(Syntax(text, "sql", theme="monokai", line_numbers=False))
|
|
251
|
+
elif name == "modelReject":
|
|
252
|
+
self._console.print(Text(text, style="bold yellow"))
|
|
253
|
+
else:
|
|
254
|
+
self._console.print(Markdown(text))
|
|
255
|
+
else:
|
|
256
|
+
sys.stdout.write(text)
|
|
257
|
+
sys.stdout.flush()
|
|
258
|
+
|
|
259
|
+
def render_tool_request(
|
|
260
|
+
self,
|
|
261
|
+
call_id: str,
|
|
262
|
+
name: str,
|
|
263
|
+
arguments: dict | None = None,
|
|
264
|
+
title: str | None = None,
|
|
265
|
+
) -> None:
|
|
266
|
+
self._stderr_console.print(
|
|
267
|
+
Text(f" ⚙ {title or name}", style="dim cyan"),
|
|
268
|
+
)
|
|
269
|
+
|
|
270
|
+
def render_tool_response(self, call_id: str, name: str, result: Any) -> None:
|
|
271
|
+
self._stderr_console.print(
|
|
272
|
+
Text(f" ✓ {name} done", style="dim"),
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
def render_tool_progress(self, status: str, message: str) -> None:
|
|
276
|
+
self._stderr_console.print(
|
|
277
|
+
Text(f" ⏳ {message}", style="dim italic"),
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
def render_error(self, error_type: str, message: str) -> None:
|
|
281
|
+
self._stderr_console.print(
|
|
282
|
+
Text(f"Error ({error_type}): {message}", style="bold red"),
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
def render_conversation_title(self, title: str) -> None:
|
|
286
|
+
pass
|
|
287
|
+
|
|
288
|
+
def start_spinner(self) -> None:
|
|
289
|
+
if self._is_tty and self._spinner is None:
|
|
290
|
+
self._spinner = _Spinner()
|
|
291
|
+
self._spinner.start()
|
|
292
|
+
|
|
293
|
+
def stop_spinner(self) -> None:
|
|
294
|
+
if self._spinner is not None:
|
|
295
|
+
self._spinner.stop()
|
|
296
|
+
self._spinner = None
|
|
297
|
+
|
|
298
|
+
def print_separator(self) -> None:
|
|
299
|
+
sys.stdout.write("\n")
|
|
300
|
+
sys.stdout.flush()
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def _summarize_args(args: dict, max_len: int = 200) -> str:
|
|
304
|
+
"""Produce a compact summary of tool arguments."""
|
|
305
|
+
parts: list[str] = []
|
|
306
|
+
for k, v in args.items():
|
|
307
|
+
s = str(v)
|
|
308
|
+
if len(s) > 60:
|
|
309
|
+
s = s[:57] + "..."
|
|
310
|
+
parts.append(f"{k}={s}")
|
|
311
|
+
text = ", ".join(parts)
|
|
312
|
+
if len(text) > max_len:
|
|
313
|
+
text = text[:max_len] + "..."
|
|
314
|
+
return text
|
|
@@ -19,6 +19,7 @@ from __future__ import annotations
|
|
|
19
19
|
|
|
20
20
|
import asyncio
|
|
21
21
|
import json
|
|
22
|
+
import logging
|
|
22
23
|
import sys
|
|
23
24
|
from pathlib import Path
|
|
24
25
|
|
|
@@ -27,12 +28,30 @@ import typer
|
|
|
27
28
|
|
|
28
29
|
from drs.auth import DrsConfig, load_config
|
|
29
30
|
from drs.client import DremioClient
|
|
30
|
-
from drs.commands import
|
|
31
|
+
from drs.commands import (
|
|
32
|
+
chat,
|
|
33
|
+
engine,
|
|
34
|
+
folder,
|
|
35
|
+
grant,
|
|
36
|
+
job,
|
|
37
|
+
project,
|
|
38
|
+
query,
|
|
39
|
+
reflection,
|
|
40
|
+
role,
|
|
41
|
+
schema,
|
|
42
|
+
setup,
|
|
43
|
+
tag,
|
|
44
|
+
user,
|
|
45
|
+
wiki,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
|
|
31
49
|
|
|
32
50
|
app = typer.Typer(
|
|
33
51
|
name="dremio",
|
|
34
52
|
help="Developer CLI for Dremio Cloud.",
|
|
35
53
|
no_args_is_help=True,
|
|
54
|
+
context_settings=CONTEXT_SETTINGS,
|
|
36
55
|
)
|
|
37
56
|
|
|
38
57
|
# Register command groups
|
|
@@ -48,6 +67,8 @@ app.add_typer(user.app, name="user")
|
|
|
48
67
|
app.add_typer(role.app, name="role")
|
|
49
68
|
app.add_typer(grant.app, name="grant")
|
|
50
69
|
app.add_typer(project.app, name="project")
|
|
70
|
+
app.add_typer(chat.app, name="chat")
|
|
71
|
+
app.command("setup")(setup.setup_command)
|
|
51
72
|
|
|
52
73
|
# Global state for config
|
|
53
74
|
_config: DrsConfig | None = None
|
|
@@ -56,14 +77,36 @@ _cli_opts: dict = {}
|
|
|
56
77
|
|
|
57
78
|
@app.callback()
|
|
58
79
|
def main(
|
|
80
|
+
ctx: typer.Context,
|
|
59
81
|
config: str | None = typer.Option(None, "--config", "-c", help="Path to config file"),
|
|
60
82
|
token: str | None = typer.Option(None, "--token", help="Dremio personal access token (PAT)"),
|
|
61
83
|
project_id: str | None = typer.Option(None, "--project-id", help="Dremio Cloud project ID"),
|
|
62
84
|
uri: str | None = typer.Option(
|
|
63
85
|
None, "--uri", help="Dremio API base URI (e.g., https://api.dremio.cloud, https://api.eu.dremio.cloud)"
|
|
64
86
|
),
|
|
87
|
+
verbose: int = typer.Option(
|
|
88
|
+
0, "--verbose", "-v", count=True, help="Increase logging verbosity (-v for debug, -vv for trace)"
|
|
89
|
+
),
|
|
65
90
|
) -> None:
|
|
66
91
|
"""Global options for dremio CLI."""
|
|
92
|
+
# Configure logging based on verbosity
|
|
93
|
+
if verbose >= 2:
|
|
94
|
+
log_level = logging.DEBUG
|
|
95
|
+
# Also enable httpx/httpcore debug logging for -vv
|
|
96
|
+
logging.getLogger("httpx").setLevel(logging.DEBUG)
|
|
97
|
+
logging.getLogger("httpcore").setLevel(logging.DEBUG)
|
|
98
|
+
elif verbose == 1:
|
|
99
|
+
log_level = logging.DEBUG
|
|
100
|
+
else:
|
|
101
|
+
log_level = logging.WARNING
|
|
102
|
+
|
|
103
|
+
logging.basicConfig(
|
|
104
|
+
level=log_level,
|
|
105
|
+
format="%(asctime)s %(levelname)s [%(name)s] %(message)s",
|
|
106
|
+
datefmt="%H:%M:%S",
|
|
107
|
+
stream=sys.stderr,
|
|
108
|
+
)
|
|
109
|
+
|
|
67
110
|
global _cli_opts
|
|
68
111
|
_cli_opts = {
|
|
69
112
|
"config_path": Path(config) if config else None,
|
|
@@ -72,6 +115,10 @@ def main(
|
|
|
72
115
|
"cli_uri": uri,
|
|
73
116
|
}
|
|
74
117
|
|
|
118
|
+
# Make config_path available to subcommands via typer context
|
|
119
|
+
ctx.ensure_object(dict)
|
|
120
|
+
ctx.obj["config_path"] = _cli_opts["config_path"]
|
|
121
|
+
|
|
75
122
|
|
|
76
123
|
def get_config() -> DrsConfig:
|
|
77
124
|
global _config
|
|
@@ -83,12 +130,19 @@ def get_config() -> DrsConfig:
|
|
|
83
130
|
cli_project_id=_cli_opts.get("cli_project_id"),
|
|
84
131
|
cli_uri=_cli_opts.get("cli_uri"),
|
|
85
132
|
)
|
|
86
|
-
except Exception
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
133
|
+
except Exception:
|
|
134
|
+
from rich.console import Console
|
|
135
|
+
|
|
136
|
+
from drs.auth import DEFAULT_CONFIG_PATH
|
|
137
|
+
|
|
138
|
+
Console(stderr=True).print(
|
|
139
|
+
"\n[bold red]Configuration required[/bold red]\n\n"
|
|
140
|
+
"The Dremio CLI needs a Personal Access Token and Project ID.\n\n"
|
|
141
|
+
" [bold]Quick setup:[/] Run [bold cyan]dremio setup[/bold cyan]\n\n"
|
|
142
|
+
" [dim]Or provide credentials manually:[/dim]\n"
|
|
143
|
+
" --token / DREMIO_TOKEN env var\n"
|
|
144
|
+
" --project-id / DREMIO_PROJECT_ID env var\n"
|
|
145
|
+
f" Config file: {DEFAULT_CONFIG_PATH}\n",
|
|
92
146
|
)
|
|
93
147
|
raise typer.Exit(1)
|
|
94
148
|
return _config
|