nini-cli 0.4.2__tar.gz → 0.4.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.
- {nini_cli-0.4.2 → nini_cli-0.4.4}/PKG-INFO +4 -4
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/__init__.py +1 -1
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/i18n.py +2 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/permissions.py +23 -5
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/policy.py +10 -2
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/store.py +28 -2
- {nini_cli-0.4.2 → nini_cli-0.4.4}/pyproject.toml +4 -4
- {nini_cli-0.4.2 → nini_cli-0.4.4}/LICENSE +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/README.md +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/__main__.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/app.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/cli_util.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/__init__.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/attach.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/config_cmd.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/doctor.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/import_cmd.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/mcp.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/pair.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/provider_cmd.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/run.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/serve.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/sessions.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/status.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/token.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/commands/workspace.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/config.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/events.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/import_api.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/mcp_api.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/projects.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/relay_api.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/roots.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/service_boot.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/startup.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/__init__.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/app.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/app.tcss +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/client.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/clipboard.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/keymap.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/mark_art.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/markdown.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/models.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/palette.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/pointer.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/render.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/session_timeline.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/splash.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/status_line.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/stream.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui/widgets.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/tui_main.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/turn.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/nini_cli/ui.py +0 -0
- {nini_cli-0.4.2 → nini_cli-0.4.4}/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.4
|
|
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.4
|
|
17
|
+
Requires-Dist: nini-core==0.4.4
|
|
18
|
+
Requires-Dist: nini-protocol==0.4.4
|
|
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"]
|
|
@@ -8,6 +8,12 @@ contract:
|
|
|
8
8
|
``?since=``, duplicated frames, overlapping snapshot) is dropped when
|
|
9
9
|
``0 < seq <= last_seq``. ``resync.required`` is honoured *before* that
|
|
10
10
|
check, because the whole point of the event is that the cursor is stale.
|
|
11
|
+
The pointer frames stamped with the live max (``server.heartbeat``, ``ack``,
|
|
12
|
+
``error``) skip the check *and* never move the cursor, so a caught-up client
|
|
13
|
+
sees ``seq == last_seq`` without losing the frame (see
|
|
14
|
+
:data:`SEQ_SHARED_FRAMES`; ``server.hello`` is ``seq: 0`` and
|
|
15
|
+
``resync.required`` carries ``latest``, so for those two the exclusion is
|
|
16
|
+
inert — they are listed to keep the set identical across clients).
|
|
11
17
|
2. Text accumulates per ``(message_id, part_id)``. A part id reused by a
|
|
12
18
|
different message never absorbs another message's text.
|
|
13
19
|
3. A ``part.updated`` snapshot never shortens text that already streamed in.
|
|
@@ -55,6 +61,20 @@ DEFAULT_PAGE_SIZE = 50
|
|
|
55
61
|
"""Messages per page — the same number the service's snapshot/limit and the
|
|
56
62
|
TUI's ``messages?before=`` request use."""
|
|
57
63
|
|
|
64
|
+
SEQ_SHARED_FRAMES = frozenset(
|
|
65
|
+
{"server.hello", "server.heartbeat", "ack", "error", "resync.required"}
|
|
66
|
+
)
|
|
67
|
+
"""Frames whose ``seq`` is the *live maximum pointer*, not a durable position.
|
|
68
|
+
|
|
69
|
+
Contract §4. The service stamps ``server.heartbeat``, ``ack`` and ``error`` with
|
|
70
|
+
``stream.seq`` (``nini_service/ws.py``), so a caught-up client receives them with
|
|
71
|
+
``seq == last_seq``. Deduping them would swallow the frame (a failed turn would
|
|
72
|
+
never reach the notice line and the TUI would stay on 「停止」), and advancing the
|
|
73
|
+
cursor from one would skip the replay a reconnect just asked for. Kept in sync
|
|
74
|
+
with ``SEQ_SHARED_FRAMES`` in ``@nini/sdk-ts`` and ``SEQ_POINTER_FRAMES`` in
|
|
75
|
+
``apps/web/src/store/events.ts``.
|
|
76
|
+
"""
|
|
77
|
+
|
|
58
78
|
DEFAULT_SESSION_LIMIT = 500
|
|
59
79
|
"""Hard cap on the messages one session may keep in memory."""
|
|
60
80
|
|
|
@@ -990,10 +1010,16 @@ class TuiStore:
|
|
|
990
1010
|
return Change(resync=True)
|
|
991
1011
|
|
|
992
1012
|
seq = event.get("seq")
|
|
993
|
-
|
|
1013
|
+
shared = kind in SEQ_SHARED_FRAMES
|
|
1014
|
+
if (
|
|
1015
|
+
not shared
|
|
1016
|
+
and isinstance(seq, int)
|
|
1017
|
+
and not isinstance(seq, bool)
|
|
1018
|
+
and 0 < seq <= self.last_seq
|
|
1019
|
+
):
|
|
994
1020
|
return Change()
|
|
995
1021
|
change = self._dispatch(kind, data, session_id, ts=_str(event.get("ts")))
|
|
996
|
-
if isinstance(seq, int) and not isinstance(seq, bool):
|
|
1022
|
+
if not shared and isinstance(seq, int) and not isinstance(seq, bool):
|
|
997
1023
|
self.last_seq = max(self.last_seq, seq)
|
|
998
1024
|
return change
|
|
999
1025
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "nini-cli"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.4"
|
|
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.4",
|
|
21
|
+
"nini-protocol==0.4.4",
|
|
22
22
|
"textual>=0.89",
|
|
23
|
-
"nini-core==0.4.
|
|
23
|
+
"nini-core==0.4.4",
|
|
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
|