deliberaide-cli 0.1.0__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.
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: deliberaide-cli
3
+ Version: 0.1.0
4
+ Summary: Stateful, agent-native CLI for the deliberAIde v2 API
5
+ Home-page: https://deliberaide.com
6
+ Author: deliberAIde
7
+ Author-email: hello@deliberaide.com
8
+ License: Proprietary
9
+ Project-URL: Homepage, https://deliberaide.com
10
+ Project-URL: Platform, https://platform.deliberaide.com
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Environment :: Console
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: click>=8.1.7
23
+ Requires-Dist: httpx>=0.28.1
24
+ Requires-Dist: prompt-toolkit>=3.0.48
25
+ Requires-Dist: websockets>=12.0
26
+ Dynamic: author
27
+ Dynamic: author-email
28
+ Dynamic: classifier
29
+ Dynamic: description
30
+ Dynamic: description-content-type
31
+ Dynamic: home-page
32
+ Dynamic: license
33
+ Dynamic: project-url
34
+ Dynamic: requires-dist
35
+ Dynamic: requires-python
36
+ Dynamic: summary
37
+
38
+ # deliberaide-cli
39
+
40
+ `deliberaide-cli` is a stateful command-line harness for the DeliberAIde v2 API.
41
+ It wraps the running FastAPI server over HTTP and WebSockets, keeps a saved profile,
42
+ and exposes every discovered route through generated command groups.
43
+
44
+ ## What it supports
45
+
46
+ - One-shot commands for the current HTTP route surface
47
+ - One-shot commands for the current WebSocket route surface
48
+ - Interactive shell mode when you run `deliberaide-cli` with no subcommand
49
+ - Browser-based CLI sign-in through the DeliberAIde web app
50
+ - Saved base URLs, cookies, and default IDs per profile
51
+ - Machine-readable output with `--json`
52
+ - Binary downloads with `--download`
53
+
54
+ ## Install
55
+
56
+ From the repository root:
57
+
58
+ ```powershell
59
+ python -m pip install -e .\agent-harness
60
+ ```
61
+
62
+ If you prefer a project virtual environment, run the same command with that Python executable instead.
63
+
64
+ ## Basic usage
65
+
66
+ ```powershell
67
+ deliberaide-cli --help
68
+ deliberaide-cli routes list
69
+ deliberaide-cli auth login
70
+ deliberaide-cli users get-current-user-info
71
+ deliberaide-cli context set org_id 11111111-1111-1111-1111-111111111111
72
+ deliberaide-cli projects create-project --name "Pilot workspace"
73
+ ```
74
+
75
+ ## Sign in from the browser
76
+
77
+ By default, `auth login` starts a CLI approval session, opens your browser, and waits for approval:
78
+
79
+ ```powershell
80
+ deliberaide-cli --base-url http://127.0.0.1:8000 auth login
81
+ ```
82
+
83
+ If the browser does not open automatically, copy the URL printed in the terminal into any browser on the same machine.
84
+ After you sign in and approve the request, the CLI saves the returned cookies in your active profile.
85
+
86
+ You can still fall back to direct credentials when needed:
87
+
88
+ ```powershell
89
+ deliberaide-cli --base-url http://127.0.0.1:8000 auth login --email you@example.com --password secret
90
+ ```
91
+
92
+ ## JSON request bodies
93
+
94
+ Use direct field flags for simple object bodies:
95
+
96
+ ```powershell
97
+ deliberaide-cli projects create-project --name "Pilot workspace" --description "CLI-created"
98
+ ```
99
+
100
+ Use raw JSON for richer payloads:
101
+
102
+ ```powershell
103
+ deliberaide-cli projects create-project --body '{"name":"Pilot workspace","target_language":"en"}'
104
+ ```
105
+
106
+ Or load JSON from a file:
107
+
108
+ ```powershell
109
+ deliberaide-cli projects create-project --body-file .\payload.json
110
+ ```
111
+
112
+ ## Multipart uploads
113
+
114
+ ```powershell
115
+ deliberaide-cli upload upload-audio --file .\meeting.mp3 --discussion-id 22222222-2222-2222-2222-222222222222 --config '{"language":"en"}'
116
+ ```
117
+
118
+ ```powershell
119
+ deliberaide-cli upload upload-bulk --files .\a.wav --files .\b.wav --session-id 33333333-3333-3333-3333-333333333333
120
+ ```
121
+
122
+ ## Binary responses
123
+
124
+ ```powershell
125
+ deliberaide-cli qr get-session-qr-codes-zip --session-id 44444444-4444-4444-4444-444444444444 --download .\session-qr.zip
126
+ ```
127
+
128
+ ## Profiles and saved defaults
129
+
130
+ ```powershell
131
+ deliberaide-cli profile show
132
+ deliberaide-cli profile set-base-url http://127.0.0.1:8000
133
+ deliberaide-cli context set discussion_id 55555555-5555-5555-5555-555555555555
134
+ deliberaide-cli context show
135
+ deliberaide-cli context undo
136
+ ```
137
+
138
+ ## Interactive shell
139
+
140
+ Run with no subcommand to enter the shell:
141
+
142
+ ```powershell
143
+ deliberaide-cli
144
+ ```
145
+
146
+ Inside the shell, enter the same commands you would run normally, for example:
147
+
148
+ ```text
149
+ routes list
150
+ auth login
151
+ users get-current-user-info
152
+ exit
153
+ ```
154
+
155
+ ## Tests
156
+
157
+ ```powershell
158
+ python -m pytest .\agent-harness\deliberaide_cli\tests -v
159
+ ```
@@ -0,0 +1,122 @@
1
+ # deliberaide-cli
2
+
3
+ `deliberaide-cli` is a stateful command-line harness for the DeliberAIde v2 API.
4
+ It wraps the running FastAPI server over HTTP and WebSockets, keeps a saved profile,
5
+ and exposes every discovered route through generated command groups.
6
+
7
+ ## What it supports
8
+
9
+ - One-shot commands for the current HTTP route surface
10
+ - One-shot commands for the current WebSocket route surface
11
+ - Interactive shell mode when you run `deliberaide-cli` with no subcommand
12
+ - Browser-based CLI sign-in through the DeliberAIde web app
13
+ - Saved base URLs, cookies, and default IDs per profile
14
+ - Machine-readable output with `--json`
15
+ - Binary downloads with `--download`
16
+
17
+ ## Install
18
+
19
+ From the repository root:
20
+
21
+ ```powershell
22
+ python -m pip install -e .\agent-harness
23
+ ```
24
+
25
+ If you prefer a project virtual environment, run the same command with that Python executable instead.
26
+
27
+ ## Basic usage
28
+
29
+ ```powershell
30
+ deliberaide-cli --help
31
+ deliberaide-cli routes list
32
+ deliberaide-cli auth login
33
+ deliberaide-cli users get-current-user-info
34
+ deliberaide-cli context set org_id 11111111-1111-1111-1111-111111111111
35
+ deliberaide-cli projects create-project --name "Pilot workspace"
36
+ ```
37
+
38
+ ## Sign in from the browser
39
+
40
+ By default, `auth login` starts a CLI approval session, opens your browser, and waits for approval:
41
+
42
+ ```powershell
43
+ deliberaide-cli --base-url http://127.0.0.1:8000 auth login
44
+ ```
45
+
46
+ If the browser does not open automatically, copy the URL printed in the terminal into any browser on the same machine.
47
+ After you sign in and approve the request, the CLI saves the returned cookies in your active profile.
48
+
49
+ You can still fall back to direct credentials when needed:
50
+
51
+ ```powershell
52
+ deliberaide-cli --base-url http://127.0.0.1:8000 auth login --email you@example.com --password secret
53
+ ```
54
+
55
+ ## JSON request bodies
56
+
57
+ Use direct field flags for simple object bodies:
58
+
59
+ ```powershell
60
+ deliberaide-cli projects create-project --name "Pilot workspace" --description "CLI-created"
61
+ ```
62
+
63
+ Use raw JSON for richer payloads:
64
+
65
+ ```powershell
66
+ deliberaide-cli projects create-project --body '{"name":"Pilot workspace","target_language":"en"}'
67
+ ```
68
+
69
+ Or load JSON from a file:
70
+
71
+ ```powershell
72
+ deliberaide-cli projects create-project --body-file .\payload.json
73
+ ```
74
+
75
+ ## Multipart uploads
76
+
77
+ ```powershell
78
+ deliberaide-cli upload upload-audio --file .\meeting.mp3 --discussion-id 22222222-2222-2222-2222-222222222222 --config '{"language":"en"}'
79
+ ```
80
+
81
+ ```powershell
82
+ deliberaide-cli upload upload-bulk --files .\a.wav --files .\b.wav --session-id 33333333-3333-3333-3333-333333333333
83
+ ```
84
+
85
+ ## Binary responses
86
+
87
+ ```powershell
88
+ deliberaide-cli qr get-session-qr-codes-zip --session-id 44444444-4444-4444-4444-444444444444 --download .\session-qr.zip
89
+ ```
90
+
91
+ ## Profiles and saved defaults
92
+
93
+ ```powershell
94
+ deliberaide-cli profile show
95
+ deliberaide-cli profile set-base-url http://127.0.0.1:8000
96
+ deliberaide-cli context set discussion_id 55555555-5555-5555-5555-555555555555
97
+ deliberaide-cli context show
98
+ deliberaide-cli context undo
99
+ ```
100
+
101
+ ## Interactive shell
102
+
103
+ Run with no subcommand to enter the shell:
104
+
105
+ ```powershell
106
+ deliberaide-cli
107
+ ```
108
+
109
+ Inside the shell, enter the same commands you would run normally, for example:
110
+
111
+ ```text
112
+ routes list
113
+ auth login
114
+ users get-current-user-info
115
+ exit
116
+ ```
117
+
118
+ ## Tests
119
+
120
+ ```powershell
121
+ python -m pytest .\agent-harness\deliberaide_cli\tests -v
122
+ ```
@@ -0,0 +1,3 @@
1
+ __all__ = ["__version__"]
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,5 @@
1
+ from deliberaide_cli.deliberaide_cli import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ main()
@@ -0,0 +1 @@
1
+ """Core helpers for deliberaide-cli."""
@@ -0,0 +1,161 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from dataclasses import dataclass, field
5
+ from functools import lru_cache
6
+ from importlib.resources import files
7
+ from typing import Any
8
+
9
+
10
+ @dataclass(slots=True)
11
+ class FieldSpec:
12
+ name: str
13
+ cli_name: str
14
+ required: bool
15
+ description: str | None = None
16
+ schema: dict[str, Any] = field(default_factory=dict)
17
+ is_file: bool = False
18
+ allows_multiple: bool = False
19
+
20
+ @classmethod
21
+ def from_dict(cls, payload: dict[str, Any]) -> "FieldSpec":
22
+ return cls(
23
+ name=payload["name"],
24
+ cli_name=payload["cli_name"],
25
+ required=payload["required"],
26
+ description=payload.get("description"),
27
+ schema=payload.get("schema") or {},
28
+ is_file=payload.get("is_file", False),
29
+ allows_multiple=payload.get("allows_multiple", False),
30
+ )
31
+
32
+
33
+ @dataclass(slots=True)
34
+ class ParameterSpec:
35
+ name: str
36
+ cli_name: str
37
+ location: str
38
+ required: bool
39
+ description: str | None = None
40
+ schema: dict[str, Any] = field(default_factory=dict)
41
+
42
+ @classmethod
43
+ def from_dict(cls, payload: dict[str, Any]) -> "ParameterSpec":
44
+ return cls(
45
+ name=payload["name"],
46
+ cli_name=payload["cli_name"],
47
+ location=payload["location"],
48
+ required=payload["required"],
49
+ description=payload.get("description"),
50
+ schema=payload.get("schema") or {},
51
+ )
52
+
53
+
54
+ @dataclass(slots=True)
55
+ class RequestBodySpec:
56
+ required: bool
57
+ content_types: tuple[str, ...] = ()
58
+ schema: dict[str, Any] = field(default_factory=dict)
59
+ fields: tuple[FieldSpec, ...] = ()
60
+
61
+ @classmethod
62
+ def from_dict(cls, payload: dict[str, Any] | None) -> "RequestBodySpec | None":
63
+ if payload is None:
64
+ return None
65
+ return cls(
66
+ required=payload.get("required", False),
67
+ content_types=tuple(payload.get("content_types", [])),
68
+ schema=payload.get("schema") or {},
69
+ fields=tuple(FieldSpec.from_dict(item) for item in payload.get("fields", [])),
70
+ )
71
+
72
+ @property
73
+ def is_json(self) -> bool:
74
+ return any(item.endswith("/json") or item == "application/json" for item in self.content_types)
75
+
76
+ @property
77
+ def is_form(self) -> bool:
78
+ return any(item in {"multipart/form-data", "application/x-www-form-urlencoded"} for item in self.content_types)
79
+
80
+
81
+ @dataclass(slots=True)
82
+ class OperationSpec:
83
+ kind: str
84
+ group: str
85
+ command_name: str
86
+ operation_key: str
87
+ path: str
88
+ route_name: str
89
+ method: str | None = None
90
+ summary: str | None = None
91
+ description: str | None = None
92
+ parameters: tuple[ParameterSpec, ...] = ()
93
+ request_body: RequestBodySpec | None = None
94
+ response_content_types: tuple[str, ...] = ()
95
+
96
+ @classmethod
97
+ def from_dict(cls, payload: dict[str, Any]) -> "OperationSpec":
98
+ return cls(
99
+ kind=payload["kind"],
100
+ group=payload["group"],
101
+ command_name=payload["command_name"],
102
+ operation_key=payload["operation_key"],
103
+ method=payload.get("method"),
104
+ path=payload["path"],
105
+ route_name=payload["route_name"],
106
+ summary=payload.get("summary"),
107
+ description=payload.get("description"),
108
+ parameters=tuple(ParameterSpec.from_dict(item) for item in payload.get("parameters", [])),
109
+ request_body=RequestBodySpec.from_dict(payload.get("request_body")),
110
+ response_content_types=tuple(payload.get("response_content_types", [])),
111
+ )
112
+
113
+ @property
114
+ def path_parameters(self) -> tuple[ParameterSpec, ...]:
115
+ return tuple(item for item in self.parameters if item.location == "path")
116
+
117
+ @property
118
+ def query_parameters(self) -> tuple[ParameterSpec, ...]:
119
+ return tuple(item for item in self.parameters if item.location == "query")
120
+
121
+ @property
122
+ def header_parameters(self) -> tuple[ParameterSpec, ...]:
123
+ return tuple(item for item in self.parameters if item.location == "header")
124
+
125
+
126
+ @dataclass(slots=True)
127
+ class RouteManifest:
128
+ generated_at: str
129
+ source_path: str
130
+ http_operations: tuple[OperationSpec, ...]
131
+ websocket_operations: tuple[OperationSpec, ...]
132
+
133
+ @classmethod
134
+ def from_dict(cls, payload: dict[str, Any]) -> "RouteManifest":
135
+ return cls(
136
+ generated_at=payload["generated_at"],
137
+ source_path=payload["source_path"],
138
+ http_operations=tuple(
139
+ OperationSpec.from_dict(item) for item in payload.get("http_operations", [])
140
+ ),
141
+ websocket_operations=tuple(
142
+ OperationSpec.from_dict(item) for item in payload.get("websocket_operations", [])
143
+ ),
144
+ )
145
+
146
+ @property
147
+ def all_operations(self) -> tuple[OperationSpec, ...]:
148
+ return (*self.http_operations, *self.websocket_operations)
149
+
150
+ def find_operation(self, operation_key: str) -> OperationSpec | None:
151
+ for operation in self.all_operations:
152
+ if operation.operation_key == operation_key:
153
+ return operation
154
+ return None
155
+
156
+
157
+ @lru_cache
158
+ def load_manifest() -> RouteManifest:
159
+ manifest_path = files("deliberaide_cli").joinpath("route_manifest.json")
160
+ payload = json.loads(manifest_path.read_text(encoding="utf-8"))
161
+ return RouteManifest.from_dict(payload)
@@ -0,0 +1,140 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import os
5
+ from dataclasses import asdict, dataclass, field
6
+ from pathlib import Path
7
+ from typing import Any
8
+
9
+
10
+ DEFAULT_BASE_URL = "http://127.0.0.1:8000"
11
+ DEFAULT_TIMEOUT_SECONDS = 30.0
12
+ HOME_ENV_VAR = "DELIBERAIDE_CLI_HOME"
13
+ UNDO_LIMIT = 20
14
+
15
+
16
+ @dataclass(slots=True)
17
+ class CookieRecord:
18
+ name: str
19
+ value: str
20
+ domain: str
21
+ path: str
22
+ secure: bool = False
23
+ expires: int | None = None
24
+
25
+
26
+ @dataclass(slots=True)
27
+ class ProfileState:
28
+ name: str
29
+ base_url: str = DEFAULT_BASE_URL
30
+ timeout_seconds: float = DEFAULT_TIMEOUT_SECONDS
31
+ defaults: dict[str, str] = field(default_factory=dict)
32
+ cookies: list[CookieRecord] = field(default_factory=list)
33
+ undo_stack: list[dict[str, str]] = field(default_factory=list)
34
+ redo_stack: list[dict[str, str]] = field(default_factory=list)
35
+
36
+ @classmethod
37
+ def from_dict(cls, payload: dict[str, Any]) -> "ProfileState":
38
+ return cls(
39
+ name=payload["name"],
40
+ base_url=payload.get("base_url", DEFAULT_BASE_URL),
41
+ timeout_seconds=float(payload.get("timeout_seconds", DEFAULT_TIMEOUT_SECONDS)),
42
+ defaults=dict(payload.get("defaults", {})),
43
+ cookies=[CookieRecord(**item) for item in payload.get("cookies", [])],
44
+ undo_stack=[dict(item) for item in payload.get("undo_stack", [])],
45
+ redo_stack=[dict(item) for item in payload.get("redo_stack", [])],
46
+ )
47
+
48
+ def to_dict(self) -> dict[str, Any]:
49
+ payload = asdict(self)
50
+ payload["base_url"] = normalize_base_url(payload["base_url"])
51
+ return payload
52
+
53
+
54
+ class ProfileStore:
55
+ def __init__(self, home_dir: Path | None = None) -> None:
56
+ base_dir = home_dir or _default_home_dir()
57
+ self.home_dir = base_dir
58
+ self.profiles_dir = self.home_dir / "profiles"
59
+ self.profiles_dir.mkdir(parents=True, exist_ok=True)
60
+
61
+ def profile_path(self, profile_name: str) -> Path:
62
+ return self.profiles_dir / f"{profile_name}.json"
63
+
64
+ def load(self, profile_name: str) -> ProfileState:
65
+ path = self.profile_path(profile_name)
66
+ if not path.exists():
67
+ return ProfileState(name=profile_name)
68
+ payload = json.loads(path.read_text(encoding="utf-8"))
69
+ return ProfileState.from_dict(payload)
70
+
71
+ def save(self, profile: ProfileState) -> None:
72
+ path = self.profile_path(profile.name)
73
+ path.write_text(json.dumps(profile.to_dict(), indent=2), encoding="utf-8")
74
+
75
+ def list_profiles(self) -> list[str]:
76
+ return sorted(path.stem for path in self.profiles_dir.glob("*.json"))
77
+
78
+ def set_default(self, profile: ProfileState, key: str, value: str) -> bool:
79
+ if profile.defaults.get(key) == value:
80
+ return False
81
+ _push_undo_snapshot(profile)
82
+ profile.defaults[key] = value
83
+ return True
84
+
85
+ def unset_default(self, profile: ProfileState, key: str) -> bool:
86
+ if key not in profile.defaults:
87
+ return False
88
+ _push_undo_snapshot(profile)
89
+ profile.defaults.pop(key, None)
90
+ return True
91
+
92
+ def clear_defaults(self, profile: ProfileState) -> bool:
93
+ if not profile.defaults:
94
+ return False
95
+ _push_undo_snapshot(profile)
96
+ profile.defaults.clear()
97
+ return True
98
+
99
+ def undo_defaults(self, profile: ProfileState) -> bool:
100
+ if not profile.undo_stack:
101
+ return False
102
+ profile.redo_stack.append(dict(profile.defaults))
103
+ profile.defaults = profile.undo_stack.pop()
104
+ return True
105
+
106
+ def redo_defaults(self, profile: ProfileState) -> bool:
107
+ if not profile.redo_stack:
108
+ return False
109
+ profile.undo_stack.append(dict(profile.defaults))
110
+ profile.defaults = profile.redo_stack.pop()
111
+ return True
112
+
113
+ def clear_cookies(self, profile: ProfileState) -> bool:
114
+ if not profile.cookies:
115
+ return False
116
+ profile.cookies.clear()
117
+ return True
118
+
119
+
120
+ def normalize_base_url(url: str | None) -> str:
121
+ value = (url or DEFAULT_BASE_URL).strip()
122
+ if not value:
123
+ return DEFAULT_BASE_URL
124
+ return value.rstrip("/")
125
+
126
+
127
+ def _default_home_dir() -> Path:
128
+ override = os.environ.get(HOME_ENV_VAR)
129
+ if override:
130
+ return Path(override).expanduser().resolve()
131
+ return Path.home() / ".deliberaide-cli"
132
+
133
+
134
+ def _push_undo_snapshot(profile: ProfileState) -> None:
135
+ snapshot = dict(profile.defaults)
136
+ if profile.undo_stack and profile.undo_stack[-1] == snapshot:
137
+ return
138
+ profile.undo_stack.append(snapshot)
139
+ profile.undo_stack = profile.undo_stack[-UNDO_LIMIT:]
140
+ profile.redo_stack.clear()