nini-cli 0.4.2__tar.gz → 0.4.3__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.
- {nini_cli-0.4.2 → nini_cli-0.4.3}/PKG-INFO +4 -4
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/__init__.py +1 -1
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/i18n.py +2 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/permissions.py +23 -5
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/policy.py +10 -2
- {nini_cli-0.4.2 → nini_cli-0.4.3}/pyproject.toml +4 -4
- {nini_cli-0.4.2 → nini_cli-0.4.3}/LICENSE +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/README.md +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/__main__.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/app.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/cli_util.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/__init__.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/attach.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/config_cmd.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/doctor.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/import_cmd.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/mcp.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/pair.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/provider_cmd.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/run.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/serve.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/sessions.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/status.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/token.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/commands/workspace.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/config.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/events.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/import_api.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/mcp_api.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/projects.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/relay_api.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/roots.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/service_boot.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/startup.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/__init__.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/app.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/app.tcss +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/client.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/clipboard.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/keymap.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/mark_art.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/markdown.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/models.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/palette.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/pointer.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/render.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/session_timeline.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/splash.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/status_line.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/store.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/stream.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui/widgets.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/tui_main.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/turn.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/ui.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.3}/nini_cli/workspace.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: nini-cli
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: Nini command line interface: start the daemon, stream a session, answer approvals
|
|
5
5
|
Project-URL: Homepage, https://nini.flygpt.cc
|
|
6
6
|
Project-URL: Repository, https://github.com/xusai2014/Nini
|
|
@@ -13,9 +13,9 @@ Classifier: Operating System :: OS Independent
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Requires-Python: >=3.12
|
|
15
15
|
Requires-Dist: httpx>=0.28
|
|
16
|
-
Requires-Dist: nini-client==0.4.
|
|
17
|
-
Requires-Dist: nini-core==0.4.
|
|
18
|
-
Requires-Dist: nini-protocol==0.4.
|
|
16
|
+
Requires-Dist: nini-client==0.4.3
|
|
17
|
+
Requires-Dist: nini-core==0.4.3
|
|
18
|
+
Requires-Dist: nini-protocol==0.4.3
|
|
19
19
|
Requires-Dist: rich>=13.9
|
|
20
20
|
Requires-Dist: textual>=0.89
|
|
21
21
|
Requires-Dist: typer>=0.15
|
|
@@ -74,6 +74,8 @@ CATALOG: Final[dict[str, tuple[str, str]]] = {
|
|
|
74
74
|
"approval.scopeName.once": ("单次", "single approval"),
|
|
75
75
|
"approval.toolAll": ("全部工具", "all tools"),
|
|
76
76
|
"approval.toolFallback": ("该操作", "this action"),
|
|
77
|
+
# `external_path` 是伪工具(契约 §21.1):审批的是「越出工作区」这件事。
|
|
78
|
+
"approval.tool.externalPath": ("工作区外路径", "path outside workspace"),
|
|
77
79
|
"approval.deny.label": ("拒绝", "Deny"),
|
|
78
80
|
# --------------------------------------------------------------- errors
|
|
79
81
|
"error.unauthorized.title": ("连接被拒绝", "Connection refused"),
|
|
@@ -46,6 +46,7 @@ from typing import Any
|
|
|
46
46
|
|
|
47
47
|
from nini_cli import ui
|
|
48
48
|
from nini_cli.i18n import t
|
|
49
|
+
from nini_cli.policy import EXTERNAL_PATH
|
|
49
50
|
|
|
50
51
|
DEFAULT_PROMPT_TIMEOUT = 30.0
|
|
51
52
|
PARAM_PREVIEW_CHARS = 500
|
|
@@ -92,9 +93,23 @@ def tool_name(request: dict[str, Any]) -> str:
|
|
|
92
93
|
return str(tool or "tool")
|
|
93
94
|
|
|
94
95
|
|
|
96
|
+
def tool_label(request: dict[str, Any]) -> str:
|
|
97
|
+
"""Display name for the request's tool.
|
|
98
|
+
|
|
99
|
+
Split from `tool_name` on purpose: that one is the *wire* value — it keys the
|
|
100
|
+
`always` set and travels back inside `scope` grants, so translating it would
|
|
101
|
+
send 「工作区外路径」 where the service expects `external_path`. Only what a
|
|
102
|
+
person reads is translated here.
|
|
103
|
+
"""
|
|
104
|
+
raw = tool_name(request)
|
|
105
|
+
if raw == EXTERNAL_PATH:
|
|
106
|
+
return t("approval.tool.externalPath")
|
|
107
|
+
return raw
|
|
108
|
+
|
|
109
|
+
|
|
95
110
|
def request_label(request: dict[str, Any]) -> str:
|
|
96
111
|
title = str(request.get("title") or "").strip()
|
|
97
|
-
return f"{
|
|
112
|
+
return f"{tool_label(request)} {title}".strip()
|
|
98
113
|
|
|
99
114
|
|
|
100
115
|
def parameter_preview(request: dict[str, Any], limit: int = PARAM_PREVIEW_CHARS) -> str:
|
|
@@ -153,7 +168,9 @@ class PermissionBroker:
|
|
|
153
168
|
# ------------------------------------------------------------ internals
|
|
154
169
|
async def _ask(self, request: dict[str, Any], tool: str) -> Decision:
|
|
155
170
|
_render_request(request, self.notice)
|
|
156
|
-
|
|
171
|
+
# `tool` stays raw for the grants below; only the wording is translated.
|
|
172
|
+
label = tool_label(request)
|
|
173
|
+
prompt = t("cli.permission.prompt", tool=label, choices=choices())
|
|
157
174
|
reader = self.reader or read_answer
|
|
158
175
|
call = reader(prompt, self.timeout)
|
|
159
176
|
try:
|
|
@@ -162,20 +179,20 @@ class PermissionBroker:
|
|
|
162
179
|
else: # 0 = wait forever
|
|
163
180
|
answer = await call
|
|
164
181
|
except TimeoutError:
|
|
165
|
-
self.notice(t("cli.permission.timeout", seconds=f"{self.timeout:g}", tool=
|
|
182
|
+
self.notice(t("cli.permission.timeout", seconds=f"{self.timeout:g}", tool=label))
|
|
166
183
|
return Decision("deny", "timeout")
|
|
167
184
|
except asyncio.CancelledError:
|
|
168
185
|
# Ctrl-C with the prompt up: deny *this* request and keep the turn
|
|
169
186
|
# (and the REPL) alive instead of tearing the client down.
|
|
170
187
|
_uncancel()
|
|
171
|
-
self.notice(t("cli.permission.interrupted", tool=
|
|
188
|
+
self.notice(t("cli.permission.interrupted", tool=label))
|
|
172
189
|
return Decision("deny", "interrupt")
|
|
173
190
|
except (EOFError, OSError):
|
|
174
191
|
return Decision("deny", "you")
|
|
175
192
|
|
|
176
193
|
if answer is None:
|
|
177
194
|
# The reader's own timeout fired (e.g. select() saw nothing to read).
|
|
178
|
-
self.notice(t("cli.permission.timeout", seconds=f"{self.timeout:g}", tool=
|
|
195
|
+
self.notice(t("cli.permission.timeout", seconds=f"{self.timeout:g}", tool=label))
|
|
179
196
|
return Decision("deny", "timeout")
|
|
180
197
|
|
|
181
198
|
# Case-sensitive on purpose: `a` (this tool, this session) and `A` (every
|
|
@@ -227,5 +244,6 @@ __all__ = [
|
|
|
227
244
|
"parameter_preview",
|
|
228
245
|
"read_answer",
|
|
229
246
|
"request_label",
|
|
247
|
+
"tool_label",
|
|
230
248
|
"tool_name",
|
|
231
249
|
]
|
|
@@ -39,11 +39,19 @@ def scope_name(tool: str | None, scope: str | None) -> str:
|
|
|
39
39
|
return t(key)
|
|
40
40
|
|
|
41
41
|
|
|
42
|
+
#: Pseudo-tool the service asks about before a tool leaves the workspace
|
|
43
|
+
#: (contract §21.1). It travels on the wire under this name; only its *label*
|
|
44
|
+
#: is translated, because 「对 external_path 授权」 explains nothing.
|
|
45
|
+
EXTERNAL_PATH = "external_path"
|
|
46
|
+
|
|
47
|
+
|
|
42
48
|
def tool_name(tool: str | None) -> str:
|
|
43
|
-
"""``*`` → 全部工具; missing → 该操作;
|
|
49
|
+
"""``*`` → 全部工具; missing → 该操作; ``external_path`` → 工作区外路径."""
|
|
44
50
|
|
|
45
51
|
if tool == "*":
|
|
46
52
|
return t("approval.toolAll")
|
|
53
|
+
if tool == EXTERNAL_PATH:
|
|
54
|
+
return t("approval.tool.externalPath")
|
|
47
55
|
return tool or t("approval.toolFallback")
|
|
48
56
|
|
|
49
57
|
|
|
@@ -87,4 +95,4 @@ class PolicyTally:
|
|
|
87
95
|
self._counts.clear()
|
|
88
96
|
|
|
89
97
|
|
|
90
|
-
__all__ = ["PolicyTally", "policy_text", "scope_name", "tool_name"]
|
|
98
|
+
__all__ = ["EXTERNAL_PATH", "PolicyTally", "policy_text", "scope_name", "tool_name"]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nini-cli"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.3"
|
|
4
4
|
description = "Nini command line interface: start the daemon, stream a session, answer approvals"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { text = "MIT" }
|
|
@@ -17,10 +17,10 @@ dependencies = [
|
|
|
17
17
|
"rich>=13.9",
|
|
18
18
|
"httpx>=0.28",
|
|
19
19
|
"websockets>=13",
|
|
20
|
-
"nini-client==0.4.
|
|
21
|
-
"nini-protocol==0.4.
|
|
20
|
+
"nini-client==0.4.3",
|
|
21
|
+
"nini-protocol==0.4.3",
|
|
22
22
|
"textual>=0.89",
|
|
23
|
-
"nini-core==0.4.
|
|
23
|
+
"nini-core==0.4.3",
|
|
24
24
|
]
|
|
25
25
|
|
|
26
26
|
[project.urls]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|