deepflow-openagent-cli 0.1.0__tar.gz → 0.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.
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/PKG-INFO +29 -9
- deepflow_openagent_cli-0.1.1/README.md +67 -0
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/pyproject.toml +4 -4
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli/__init__.py +1 -1
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli/cli.py +85 -9
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli.egg-info/PKG-INFO +29 -9
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli.egg-info/SOURCES.txt +2 -1
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli.egg-info/requires.txt +1 -0
- deepflow_openagent_cli-0.1.1/tests/test_cli.py +165 -0
- deepflow_openagent_cli-0.1.0/README.md +0 -48
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/setup.cfg +0 -0
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli/__main__.py +0 -0
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli.egg-info/dependency_links.txt +0 -0
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli.egg-info/entry_points.txt +0 -0
- {deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli.egg-info/top_level.txt +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deepflow-openagent-cli
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: Command-line client for
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Command-line client for OpenAgent OpenAPI (agents, conversations, SSE chat, tools, channels, knowledge bases).
|
|
5
5
|
Author: DeepFlow AI
|
|
6
|
-
Project-URL: Repository, https://github.com/DeepFlowAI/
|
|
6
|
+
Project-URL: Repository, https://github.com/DeepFlowAI/OpenAgent
|
|
7
7
|
Keywords: deepflow,openagent,newagent,openapi,cli,sse,chat
|
|
8
8
|
Classifier: Development Status :: 4 - Beta
|
|
9
9
|
Classifier: Environment :: Console
|
|
@@ -16,11 +16,12 @@ Requires-Python: >=3.11
|
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
Provides-Extra: dev
|
|
18
18
|
Requires-Dist: build>=1.0; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
19
20
|
Requires-Dist: twine>=5.0; extra == "dev"
|
|
20
21
|
|
|
21
22
|
# deepflow-openagent-cli
|
|
22
23
|
|
|
23
|
-
Python command-line client for the
|
|
24
|
+
Python command-line client for the OpenAgent OpenAPI: agents, conversations, SSE chat, tools, channels, documents, and knowledge bases.
|
|
24
25
|
|
|
25
26
|
## Install
|
|
26
27
|
|
|
@@ -31,8 +32,8 @@ pip install deepflow-openagent-cli
|
|
|
31
32
|
## Usage
|
|
32
33
|
|
|
33
34
|
```bash
|
|
34
|
-
export
|
|
35
|
-
export
|
|
35
|
+
export OPENAGENT_HOST="https://your-api-host"
|
|
36
|
+
export OPENAGENT_API_KEY="sk-..."
|
|
36
37
|
deepflow_openagent_cli docs list
|
|
37
38
|
deepflow_openagent_cli agents list
|
|
38
39
|
```
|
|
@@ -47,15 +48,34 @@ python -m deepflow_openagent_cli docs list
|
|
|
47
48
|
|
|
48
49
|
| Method | Variable / flag |
|
|
49
50
|
|--------|------------------|
|
|
50
|
-
| Host | `
|
|
51
|
-
| API key | `
|
|
51
|
+
| Host | `OPENAGENT_HOST` or `--host` |
|
|
52
|
+
| API key | `OPENAGENT_API_KEY` or `--api-key` |
|
|
53
|
+
|
|
54
|
+
Legacy `NEWAGENT_HOST` and `NEWAGENT_API_KEY` are still read as fallbacks.
|
|
55
|
+
|
|
56
|
+
When using flags, put global flags before the command:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
deepflow_openagent_cli --host http://localhost:5001 --api-key sk-... agents list
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Common commands
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
deepflow_openagent_cli docs show chat.stream --json
|
|
66
|
+
deepflow_openagent_cli knowledge list --page 1 --per-page 10
|
|
67
|
+
deepflow_openagent_cli knowledge documents 1
|
|
68
|
+
deepflow_openagent_cli knowledge query-document 6670 --slice-id 512208 --line 1720
|
|
69
|
+
deepflow_openagent_cli chat 1 --message "Hello"
|
|
70
|
+
```
|
|
52
71
|
|
|
53
72
|
## Development (build wheel/sdist locally)
|
|
54
73
|
|
|
55
74
|
From this directory:
|
|
56
75
|
|
|
57
76
|
```bash
|
|
58
|
-
pip install
|
|
77
|
+
pip install -e ".[dev]"
|
|
78
|
+
pytest
|
|
59
79
|
python -m build
|
|
60
80
|
```
|
|
61
81
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# deepflow-openagent-cli
|
|
2
|
+
|
|
3
|
+
Python command-line client for the OpenAgent OpenAPI: agents, conversations, SSE chat, tools, channels, documents, and knowledge bases.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install deepflow-openagent-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
export OPENAGENT_HOST="https://your-api-host"
|
|
15
|
+
export OPENAGENT_API_KEY="sk-..."
|
|
16
|
+
deepflow_openagent_cli docs list
|
|
17
|
+
deepflow_openagent_cli agents list
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Equivalent module invocation:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
python -m deepflow_openagent_cli docs list
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Configure API host and key
|
|
27
|
+
|
|
28
|
+
| Method | Variable / flag |
|
|
29
|
+
|--------|------------------|
|
|
30
|
+
| Host | `OPENAGENT_HOST` or `--host` |
|
|
31
|
+
| API key | `OPENAGENT_API_KEY` or `--api-key` |
|
|
32
|
+
|
|
33
|
+
Legacy `NEWAGENT_HOST` and `NEWAGENT_API_KEY` are still read as fallbacks.
|
|
34
|
+
|
|
35
|
+
When using flags, put global flags before the command:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
deepflow_openagent_cli --host http://localhost:5001 --api-key sk-... agents list
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Common commands
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
deepflow_openagent_cli docs show chat.stream --json
|
|
45
|
+
deepflow_openagent_cli knowledge list --page 1 --per-page 10
|
|
46
|
+
deepflow_openagent_cli knowledge documents 1
|
|
47
|
+
deepflow_openagent_cli knowledge query-document 6670 --slice-id 512208 --line 1720
|
|
48
|
+
deepflow_openagent_cli chat 1 --message "Hello"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Development (build wheel/sdist locally)
|
|
52
|
+
|
|
53
|
+
From this directory:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install -e ".[dev]"
|
|
57
|
+
pytest
|
|
58
|
+
python -m build
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Upload to PyPI (use a **new** API token; never commit tokens):
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
python -m twine upload dist/*
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
When prompted, username is `__token__` and password is the token value.
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "deepflow-openagent-cli"
|
|
7
|
-
version = "0.1.
|
|
8
|
-
description = "Command-line client for
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "Command-line client for OpenAgent OpenAPI (agents, conversations, SSE chat, tools, channels, knowledge bases)."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
authors = [{ name = "DeepFlow AI" }]
|
|
@@ -23,10 +23,10 @@ classifiers = [
|
|
|
23
23
|
dependencies = []
|
|
24
24
|
|
|
25
25
|
[project.optional-dependencies]
|
|
26
|
-
dev = ["build>=1.0", "twine>=5.0"]
|
|
26
|
+
dev = ["build>=1.0", "pytest>=8.0", "twine>=5.0"]
|
|
27
27
|
|
|
28
28
|
[project.urls]
|
|
29
|
-
Repository = "https://github.com/DeepFlowAI/
|
|
29
|
+
Repository = "https://github.com/DeepFlowAI/OpenAgent"
|
|
30
30
|
|
|
31
31
|
[project.scripts]
|
|
32
32
|
deepflow_openagent_cli = "deepflow_openagent_cli.cli:main"
|
{deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli/cli.py
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
OpenAgent OpenAPI command line client.
|
|
3
3
|
|
|
4
4
|
Run with:
|
|
5
5
|
deepflow_openagent_cli docs list
|
|
@@ -20,8 +20,10 @@ from urllib.request import Request, urlopen
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
DEFAULT_HOST = "http://localhost:5001"
|
|
23
|
-
ENV_HOST = "
|
|
24
|
-
ENV_API_KEY = "
|
|
23
|
+
ENV_HOST = "OPENAGENT_HOST"
|
|
24
|
+
ENV_API_KEY = "OPENAGENT_API_KEY"
|
|
25
|
+
LEGACY_ENV_HOST = "NEWAGENT_HOST"
|
|
26
|
+
LEGACY_ENV_API_KEY = "NEWAGENT_API_KEY"
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
class CliError(Exception):
|
|
@@ -56,6 +58,20 @@ def _param(name: str, type_: str, required: bool, description: str) -> ParamDoc:
|
|
|
56
58
|
|
|
57
59
|
|
|
58
60
|
ENDPOINTS: tuple[EndpointDoc, ...] = (
|
|
61
|
+
EndpointDoc(
|
|
62
|
+
key="knowledge.list",
|
|
63
|
+
method="GET",
|
|
64
|
+
path="/api/v1/knowledge-bases",
|
|
65
|
+
scope="chat",
|
|
66
|
+
summary="List knowledge bases for the current tenant.",
|
|
67
|
+
query_params=[
|
|
68
|
+
_param("page", "integer", False, "Page number."),
|
|
69
|
+
_param("per_page", "integer", False, "Items per page, 1-100."),
|
|
70
|
+
],
|
|
71
|
+
response="Paginated list of public knowledge base fields.",
|
|
72
|
+
errors=["401 missing or invalid API key", "403 scope missing", "422 validation error"],
|
|
73
|
+
example="deepflow_openagent_cli knowledge list --page 1 --per-page 10",
|
|
74
|
+
),
|
|
59
75
|
EndpointDoc(
|
|
60
76
|
key="knowledge.search",
|
|
61
77
|
method="POST",
|
|
@@ -90,6 +106,36 @@ ENDPOINTS: tuple[EndpointDoc, ...] = (
|
|
|
90
106
|
errors=["401 missing or invalid API key", "404 document not found"],
|
|
91
107
|
example="deepflow_openagent_cli knowledge markdown 1 20 --raw",
|
|
92
108
|
),
|
|
109
|
+
EndpointDoc(
|
|
110
|
+
key="knowledge.documents",
|
|
111
|
+
method="GET",
|
|
112
|
+
path="/api/v1/knowledge-bases/{kb_id}/documents",
|
|
113
|
+
scope="chat",
|
|
114
|
+
summary="List documents in a knowledge base without embedding Markdown content.",
|
|
115
|
+
path_params=[_param("kb_id", "integer", True, "Knowledge base ID.")],
|
|
116
|
+
query_params=[
|
|
117
|
+
_param("page", "integer", False, "Page number."),
|
|
118
|
+
_param("per_page", "integer", False, "Items per page, 1-100."),
|
|
119
|
+
],
|
|
120
|
+
response="Paginated list with id, file_path, title, slice_count, updated_at, doc_meta, and markdown_url.",
|
|
121
|
+
errors=["401 missing or invalid API key", "403 scope missing", "404 knowledge base not found", "422 validation error"],
|
|
122
|
+
example="deepflow_openagent_cli knowledge documents 1 --page 1 --per-page 20",
|
|
123
|
+
),
|
|
124
|
+
EndpointDoc(
|
|
125
|
+
key="documents.query",
|
|
126
|
+
method="POST",
|
|
127
|
+
path="/api/v1/documents/query",
|
|
128
|
+
scope="chat",
|
|
129
|
+
summary="Resolve a document reference by doc_id with optional slice_id and line.",
|
|
130
|
+
body_fields=[
|
|
131
|
+
_param("doc_id", "integer", True, "Document ID, positive integer."),
|
|
132
|
+
_param("slice_id", "integer", False, "Optional slice ID, must belong to doc_id when provided."),
|
|
133
|
+
_param("line", "integer", False, "Optional Markdown source line number, starting at 1."),
|
|
134
|
+
],
|
|
135
|
+
response="Resolved document fields with optional slice and line details.",
|
|
136
|
+
errors=["401 missing or invalid API key", "403 scope missing", "422 validation error"],
|
|
137
|
+
example="deepflow_openagent_cli knowledge query-document 6670 --slice-id 512208 --line 1720",
|
|
138
|
+
),
|
|
93
139
|
EndpointDoc(
|
|
94
140
|
key="conversations.create",
|
|
95
141
|
method="POST",
|
|
@@ -301,7 +347,7 @@ ENDPOINTS: tuple[EndpointDoc, ...] = (
|
|
|
301
347
|
body_fields=[
|
|
302
348
|
_param("name", "string", True, "Tool name, 1-128 chars."),
|
|
303
349
|
_param("description", "string", False, "Tool description."),
|
|
304
|
-
_param("tool_type", "string", True, "search, doc_query, notebook, tool_response_fetch, or python_code."),
|
|
350
|
+
_param("tool_type", "string", True, "search, doc_query, doc_grep, notebook, tool_response_fetch, or python_code."),
|
|
305
351
|
_param("config", "object", False, "Tool config."),
|
|
306
352
|
],
|
|
307
353
|
response="AgentToolResponse.",
|
|
@@ -475,7 +521,7 @@ ENDPOINT_BY_KEY = {endpoint.key: endpoint for endpoint in ENDPOINTS}
|
|
|
475
521
|
|
|
476
522
|
|
|
477
523
|
class OpenApiClient:
|
|
478
|
-
"""Small HTTP client for
|
|
524
|
+
"""Small HTTP client for OpenAgent OpenAPI endpoints."""
|
|
479
525
|
|
|
480
526
|
def __init__(self, host: str, api_key: str | None) -> None:
|
|
481
527
|
self.host = host.rstrip("/")
|
|
@@ -639,8 +685,8 @@ def handle_docs(args: argparse.Namespace) -> int:
|
|
|
639
685
|
|
|
640
686
|
|
|
641
687
|
def client_from_args(args: argparse.Namespace) -> OpenApiClient:
|
|
642
|
-
host = args.host or os.getenv(ENV_HOST) or DEFAULT_HOST
|
|
643
|
-
api_key = args.api_key or os.getenv(ENV_API_KEY)
|
|
688
|
+
host = args.host or os.getenv(ENV_HOST) or os.getenv(LEGACY_ENV_HOST) or DEFAULT_HOST
|
|
689
|
+
api_key = args.api_key or os.getenv(ENV_API_KEY) or os.getenv(LEGACY_ENV_API_KEY)
|
|
644
690
|
return OpenApiClient(host=host, api_key=api_key)
|
|
645
691
|
|
|
646
692
|
|
|
@@ -665,9 +711,28 @@ def run_request(
|
|
|
665
711
|
|
|
666
712
|
|
|
667
713
|
def handle_knowledge(args: argparse.Namespace) -> int:
|
|
714
|
+
if args.knowledge_action == "list":
|
|
715
|
+
return run_request(args, "knowledge.list", query={"page": args.page, "per_page": args.per_page})
|
|
668
716
|
if args.knowledge_action == "search":
|
|
669
717
|
body = merge_payload(args, {"query": args.query})
|
|
670
718
|
return run_request(args, "knowledge.search", {"kb_id": args.kb_id}, body=body)
|
|
719
|
+
if args.knowledge_action == "documents":
|
|
720
|
+
return run_request(
|
|
721
|
+
args,
|
|
722
|
+
"knowledge.documents",
|
|
723
|
+
{"kb_id": args.kb_id},
|
|
724
|
+
query={"page": args.page, "per_page": args.per_page},
|
|
725
|
+
)
|
|
726
|
+
if args.knowledge_action == "query-document":
|
|
727
|
+
return run_request(
|
|
728
|
+
args,
|
|
729
|
+
"documents.query",
|
|
730
|
+
body={
|
|
731
|
+
"doc_id": args.doc_id,
|
|
732
|
+
"slice_id": args.slice_id,
|
|
733
|
+
"line": args.line,
|
|
734
|
+
},
|
|
735
|
+
)
|
|
671
736
|
return run_request(args, "knowledge.markdown", {"kb_id": args.kb_id, "doc_id": args.doc_id})
|
|
672
737
|
|
|
673
738
|
|
|
@@ -829,7 +894,7 @@ def add_common_args(parser: argparse.ArgumentParser) -> None:
|
|
|
829
894
|
|
|
830
895
|
|
|
831
896
|
def build_parser() -> argparse.ArgumentParser:
|
|
832
|
-
parser = argparse.ArgumentParser(description="
|
|
897
|
+
parser = argparse.ArgumentParser(description="OpenAgent OpenAPI CLI")
|
|
833
898
|
add_common_args(parser)
|
|
834
899
|
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
835
900
|
|
|
@@ -843,10 +908,21 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
843
908
|
|
|
844
909
|
knowledge = subparsers.add_parser("knowledge", help="Knowledge base endpoints.")
|
|
845
910
|
knowledge_sub = knowledge.add_subparsers(dest="knowledge_action", required=True)
|
|
911
|
+
knowledge_list = knowledge_sub.add_parser("list")
|
|
912
|
+
knowledge_list.add_argument("--page", type=int)
|
|
913
|
+
knowledge_list.add_argument("--per-page", type=int)
|
|
846
914
|
knowledge_search = knowledge_sub.add_parser("search")
|
|
847
915
|
knowledge_search.add_argument("kb_id", type=int)
|
|
848
916
|
knowledge_search.add_argument("--query", required=True)
|
|
849
917
|
add_json_args(knowledge_search)
|
|
918
|
+
knowledge_documents = knowledge_sub.add_parser("documents")
|
|
919
|
+
knowledge_documents.add_argument("kb_id", type=int)
|
|
920
|
+
knowledge_documents.add_argument("--page", type=int)
|
|
921
|
+
knowledge_documents.add_argument("--per-page", type=int)
|
|
922
|
+
knowledge_query_document = knowledge_sub.add_parser("query-document")
|
|
923
|
+
knowledge_query_document.add_argument("doc_id", type=int)
|
|
924
|
+
knowledge_query_document.add_argument("--slice-id", type=int)
|
|
925
|
+
knowledge_query_document.add_argument("--line", type=int)
|
|
850
926
|
knowledge_markdown = knowledge_sub.add_parser("markdown")
|
|
851
927
|
knowledge_markdown.add_argument("kb_id", type=int)
|
|
852
928
|
knowledge_markdown.add_argument("doc_id", type=int)
|
|
@@ -929,7 +1005,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
929
1005
|
tool_create.add_argument("agent_id", type=int)
|
|
930
1006
|
tool_create.add_argument("--name", required=True)
|
|
931
1007
|
tool_create.add_argument("--description")
|
|
932
|
-
tool_create.add_argument("--tool-type", required=True, choices=["search", "doc_query", "notebook", "tool_response_fetch", "python_code"])
|
|
1008
|
+
tool_create.add_argument("--tool-type", required=True, choices=["search", "doc_query", "doc_grep", "notebook", "tool_response_fetch", "python_code"])
|
|
933
1009
|
add_json_args(tool_create)
|
|
934
1010
|
for name in ("get", "delete"):
|
|
935
1011
|
tool_item = tool_sub.add_parser(name)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: deepflow-openagent-cli
|
|
3
|
-
Version: 0.1.
|
|
4
|
-
Summary: Command-line client for
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Command-line client for OpenAgent OpenAPI (agents, conversations, SSE chat, tools, channels, knowledge bases).
|
|
5
5
|
Author: DeepFlow AI
|
|
6
|
-
Project-URL: Repository, https://github.com/DeepFlowAI/
|
|
6
|
+
Project-URL: Repository, https://github.com/DeepFlowAI/OpenAgent
|
|
7
7
|
Keywords: deepflow,openagent,newagent,openapi,cli,sse,chat
|
|
8
8
|
Classifier: Development Status :: 4 - Beta
|
|
9
9
|
Classifier: Environment :: Console
|
|
@@ -16,11 +16,12 @@ Requires-Python: >=3.11
|
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
Provides-Extra: dev
|
|
18
18
|
Requires-Dist: build>=1.0; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
19
20
|
Requires-Dist: twine>=5.0; extra == "dev"
|
|
20
21
|
|
|
21
22
|
# deepflow-openagent-cli
|
|
22
23
|
|
|
23
|
-
Python command-line client for the
|
|
24
|
+
Python command-line client for the OpenAgent OpenAPI: agents, conversations, SSE chat, tools, channels, documents, and knowledge bases.
|
|
24
25
|
|
|
25
26
|
## Install
|
|
26
27
|
|
|
@@ -31,8 +32,8 @@ pip install deepflow-openagent-cli
|
|
|
31
32
|
## Usage
|
|
32
33
|
|
|
33
34
|
```bash
|
|
34
|
-
export
|
|
35
|
-
export
|
|
35
|
+
export OPENAGENT_HOST="https://your-api-host"
|
|
36
|
+
export OPENAGENT_API_KEY="sk-..."
|
|
36
37
|
deepflow_openagent_cli docs list
|
|
37
38
|
deepflow_openagent_cli agents list
|
|
38
39
|
```
|
|
@@ -47,15 +48,34 @@ python -m deepflow_openagent_cli docs list
|
|
|
47
48
|
|
|
48
49
|
| Method | Variable / flag |
|
|
49
50
|
|--------|------------------|
|
|
50
|
-
| Host | `
|
|
51
|
-
| API key | `
|
|
51
|
+
| Host | `OPENAGENT_HOST` or `--host` |
|
|
52
|
+
| API key | `OPENAGENT_API_KEY` or `--api-key` |
|
|
53
|
+
|
|
54
|
+
Legacy `NEWAGENT_HOST` and `NEWAGENT_API_KEY` are still read as fallbacks.
|
|
55
|
+
|
|
56
|
+
When using flags, put global flags before the command:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
deepflow_openagent_cli --host http://localhost:5001 --api-key sk-... agents list
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Common commands
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
deepflow_openagent_cli docs show chat.stream --json
|
|
66
|
+
deepflow_openagent_cli knowledge list --page 1 --per-page 10
|
|
67
|
+
deepflow_openagent_cli knowledge documents 1
|
|
68
|
+
deepflow_openagent_cli knowledge query-document 6670 --slice-id 512208 --line 1720
|
|
69
|
+
deepflow_openagent_cli chat 1 --message "Hello"
|
|
70
|
+
```
|
|
52
71
|
|
|
53
72
|
## Development (build wheel/sdist locally)
|
|
54
73
|
|
|
55
74
|
From this directory:
|
|
56
75
|
|
|
57
76
|
```bash
|
|
58
|
-
pip install
|
|
77
|
+
pip install -e ".[dev]"
|
|
78
|
+
pytest
|
|
59
79
|
python -m build
|
|
60
80
|
```
|
|
61
81
|
|
|
@@ -8,4 +8,5 @@ src/deepflow_openagent_cli.egg-info/SOURCES.txt
|
|
|
8
8
|
src/deepflow_openagent_cli.egg-info/dependency_links.txt
|
|
9
9
|
src/deepflow_openagent_cli.egg-info/entry_points.txt
|
|
10
10
|
src/deepflow_openagent_cli.egg-info/requires.txt
|
|
11
|
-
src/deepflow_openagent_cli.egg-info/top_level.txt
|
|
11
|
+
src/deepflow_openagent_cli.egg-info/top_level.txt
|
|
12
|
+
tests/test_cli.py
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from deepflow_openagent_cli import __version__
|
|
6
|
+
from deepflow_openagent_cli.cli import (
|
|
7
|
+
CliError,
|
|
8
|
+
ENDPOINTS,
|
|
9
|
+
OpenApiClient,
|
|
10
|
+
build_parser,
|
|
11
|
+
client_from_args,
|
|
12
|
+
get_endpoint,
|
|
13
|
+
load_json_payload,
|
|
14
|
+
main,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_version_matches_release() -> None:
|
|
19
|
+
assert __version__ == "0.1.1"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_catalog_has_stable_unique_keys() -> None:
|
|
23
|
+
keys = [endpoint.key for endpoint in ENDPOINTS]
|
|
24
|
+
|
|
25
|
+
assert len(keys) == len(set(keys))
|
|
26
|
+
assert "knowledge.list" in keys
|
|
27
|
+
assert "knowledge.documents" in keys
|
|
28
|
+
assert "documents.query" in keys
|
|
29
|
+
assert "chat.stream" in keys
|
|
30
|
+
assert "channels.secret_key" in keys
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_get_endpoint_unknown_key_raises_clear_error() -> None:
|
|
34
|
+
with pytest.raises(CliError, match="Unknown endpoint"):
|
|
35
|
+
get_endpoint("missing.endpoint")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_load_json_payload_rejects_non_object() -> None:
|
|
39
|
+
with pytest.raises(CliError, match="must be an object"):
|
|
40
|
+
load_json_payload("[1, 2, 3]", None)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_build_url_formats_path_and_query() -> None:
|
|
44
|
+
client = OpenApiClient("http://localhost:5001/", "sk-test")
|
|
45
|
+
endpoint = get_endpoint("knowledge.documents")
|
|
46
|
+
|
|
47
|
+
url = client._build_url(
|
|
48
|
+
endpoint,
|
|
49
|
+
{"kb_id": 1},
|
|
50
|
+
{"page": 2, "per_page": 20, "source": None},
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
assert url == "http://localhost:5001/api/v1/knowledge-bases/1/documents?page=2&per_page=20"
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_client_from_args_reads_openagent_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
57
|
+
monkeypatch.setenv("OPENAGENT_HOST", "https://api.example.com")
|
|
58
|
+
monkeypatch.setenv("OPENAGENT_API_KEY", "sk-openagent")
|
|
59
|
+
args = build_parser().parse_args(["docs", "list"])
|
|
60
|
+
|
|
61
|
+
client = client_from_args(args)
|
|
62
|
+
|
|
63
|
+
assert client.host == "https://api.example.com"
|
|
64
|
+
assert client.api_key == "sk-openagent"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def test_client_from_args_reads_legacy_newagent_env(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
68
|
+
monkeypatch.delenv("OPENAGENT_HOST", raising=False)
|
|
69
|
+
monkeypatch.delenv("OPENAGENT_API_KEY", raising=False)
|
|
70
|
+
monkeypatch.setenv("NEWAGENT_HOST", "https://legacy.example.com")
|
|
71
|
+
monkeypatch.setenv("NEWAGENT_API_KEY", "sk-legacy")
|
|
72
|
+
args = build_parser().parse_args(["docs", "list"])
|
|
73
|
+
|
|
74
|
+
client = client_from_args(args)
|
|
75
|
+
|
|
76
|
+
assert client.host == "https://legacy.example.com"
|
|
77
|
+
assert client.api_key == "sk-legacy"
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_docs_show_json_outputs_endpoint_detail(capsys: pytest.CaptureFixture[str]) -> None:
|
|
81
|
+
exit_code = main(["docs", "show", "documents.query", "--json"])
|
|
82
|
+
|
|
83
|
+
captured = capsys.readouterr()
|
|
84
|
+
assert exit_code == 0
|
|
85
|
+
payload = json.loads(captured.out)
|
|
86
|
+
assert payload["method"] == "POST"
|
|
87
|
+
assert payload["scope"] == "chat"
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_query_document_command_posts_body(
|
|
91
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
92
|
+
capsys: pytest.CaptureFixture[str],
|
|
93
|
+
) -> None:
|
|
94
|
+
calls = []
|
|
95
|
+
|
|
96
|
+
def fake_request(self, endpoint_key, path_params=None, query=None, body=None, *, stream=False):
|
|
97
|
+
calls.append((endpoint_key, path_params, query, body, stream))
|
|
98
|
+
return b'{"ok": true}'
|
|
99
|
+
|
|
100
|
+
monkeypatch.setattr(OpenApiClient, "request", fake_request)
|
|
101
|
+
|
|
102
|
+
exit_code = main(
|
|
103
|
+
[
|
|
104
|
+
"--host",
|
|
105
|
+
"http://localhost:5001",
|
|
106
|
+
"--api-key",
|
|
107
|
+
"sk-test",
|
|
108
|
+
"knowledge",
|
|
109
|
+
"query-document",
|
|
110
|
+
"6670",
|
|
111
|
+
"--slice-id",
|
|
112
|
+
"512208",
|
|
113
|
+
"--line",
|
|
114
|
+
"1720",
|
|
115
|
+
]
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
captured = capsys.readouterr()
|
|
119
|
+
assert exit_code == 0
|
|
120
|
+
assert json.loads(captured.out) == {"ok": True}
|
|
121
|
+
assert calls == [
|
|
122
|
+
(
|
|
123
|
+
"documents.query",
|
|
124
|
+
None,
|
|
125
|
+
None,
|
|
126
|
+
{"doc_id": 6670, "slice_id": 512208, "line": 1720},
|
|
127
|
+
False,
|
|
128
|
+
)
|
|
129
|
+
]
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_tools_create_accepts_doc_grep(
|
|
133
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
134
|
+
capsys: pytest.CaptureFixture[str],
|
|
135
|
+
) -> None:
|
|
136
|
+
calls = []
|
|
137
|
+
|
|
138
|
+
def fake_request(self, endpoint_key, path_params=None, query=None, body=None, *, stream=False):
|
|
139
|
+
calls.append((endpoint_key, path_params, query, body, stream))
|
|
140
|
+
return b'{"ok": true}'
|
|
141
|
+
|
|
142
|
+
monkeypatch.setattr(OpenApiClient, "request", fake_request)
|
|
143
|
+
|
|
144
|
+
exit_code = main(
|
|
145
|
+
[
|
|
146
|
+
"--host",
|
|
147
|
+
"http://localhost:5001",
|
|
148
|
+
"--api-key",
|
|
149
|
+
"sk-test",
|
|
150
|
+
"tools",
|
|
151
|
+
"create",
|
|
152
|
+
"1",
|
|
153
|
+
"--name",
|
|
154
|
+
"Doc Grep",
|
|
155
|
+
"--tool-type",
|
|
156
|
+
"doc_grep",
|
|
157
|
+
]
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
captured = capsys.readouterr()
|
|
161
|
+
assert exit_code == 0
|
|
162
|
+
assert json.loads(captured.out) == {"ok": True}
|
|
163
|
+
assert calls[0][0] == "tools.create"
|
|
164
|
+
assert calls[0][1] == {"agent_id": 1}
|
|
165
|
+
assert calls[0][3]["tool_type"] == "doc_grep"
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# deepflow-openagent-cli
|
|
2
|
-
|
|
3
|
-
Python command-line client for the NewAgent OpenAPI: agents, conversations, SSE chat, tools, channels, and knowledge bases.
|
|
4
|
-
|
|
5
|
-
## Install
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
pip install deepflow-openagent-cli
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
export NEWAGENT_HOST="https://your-api-host"
|
|
15
|
-
export NEWAGENT_API_KEY="sk-..."
|
|
16
|
-
deepflow_openagent_cli docs list
|
|
17
|
-
deepflow_openagent_cli agents list
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Equivalent module invocation:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
python -m deepflow_openagent_cli docs list
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Configure API host and key
|
|
27
|
-
|
|
28
|
-
| Method | Variable / flag |
|
|
29
|
-
|--------|------------------|
|
|
30
|
-
| Host | `NEWAGENT_HOST` or `--host` |
|
|
31
|
-
| API key | `NEWAGENT_API_KEY` or `--api-key` |
|
|
32
|
-
|
|
33
|
-
## Development (build wheel/sdist locally)
|
|
34
|
-
|
|
35
|
-
From this directory:
|
|
36
|
-
|
|
37
|
-
```bash
|
|
38
|
-
pip install build twine
|
|
39
|
-
python -m build
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
Upload to PyPI (use a **new** API token; never commit tokens):
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
python -m twine upload dist/*
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
When prompted, username is `__token__` and password is the token value.
|
|
File without changes
|
{deepflow_openagent_cli-0.1.0 → deepflow_openagent_cli-0.1.1}/src/deepflow_openagent_cli/__main__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|