ot-cli 0.2.1__py3-none-any.whl
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.
- openterminal/__init__.py +3 -0
- openterminal/agent/__init__.py +39 -0
- openterminal/agent/backend.py +180 -0
- openterminal/agent/build.py +115 -0
- openterminal/agent/middleware.py +111 -0
- openterminal/agent/model.py +41 -0
- openterminal/agent/prompt.py +63 -0
- openterminal/agent/runner.py +340 -0
- openterminal/agent/sysprobe.py +164 -0
- openterminal/agent/token_est.py +49 -0
- openterminal/app.py +52 -0
- openterminal/approval.py +7 -0
- openterminal/backend.py +3 -0
- openterminal/banner.py +7 -0
- openterminal/cli.py +426 -0
- openterminal/cmdset.py +7 -0
- openterminal/config.py +322 -0
- openterminal/connections/__init__.py +20 -0
- openterminal/connections/db.py +240 -0
- openterminal/connections/models.py +289 -0
- openterminal/connections/secrets.py +68 -0
- openterminal/connections_db.py +6 -0
- openterminal/core/__init__.py +41 -0
- openterminal/core/ai_flow.py +781 -0
- openterminal/core/auth.py +499 -0
- openterminal/core/cmdset_runner.py +352 -0
- openterminal/core/exec_events.py +650 -0
- openterminal/core/history.py +79 -0
- openterminal/core/hook_gate.py +415 -0
- openterminal/core/messages.py +193 -0
- openterminal/core/nested_ssh.py +178 -0
- openterminal/core/pipeline.py +1187 -0
- openterminal/core/pump.py +190 -0
- openterminal/core/transcript.py +26 -0
- openterminal/frontend/__init__.py +21 -0
- openterminal/frontend/approval.py +40 -0
- openterminal/frontend/banner.py +40 -0
- openterminal/frontend/headless.py +290 -0
- openterminal/frontend/render.py +41 -0
- openterminal/frontend/taskview.py +184 -0
- openterminal/frontend/term.py +1417 -0
- openterminal/headless.py +7 -0
- openterminal/history_db.py +7 -0
- openterminal/local_pty.py +3 -0
- openterminal/local_win.py +3 -0
- openterminal/policy.py +362 -0
- openterminal/render.py +7 -0
- openterminal/secrets_store.py +5 -0
- openterminal/session/__init__.py +17 -0
- openterminal/session/base.py +328 -0
- openterminal/session/local_posix.py +184 -0
- openterminal/session/local_win.py +173 -0
- openterminal/session/ssh.py +321 -0
- openterminal/shell/__init__.py +17 -0
- openterminal/shell/cmdset.py +49 -0
- openterminal/shell/integration.py +1298 -0
- openterminal/shell_integration.py +7 -0
- openterminal/shell_session.py +8 -0
- openterminal/skills/__init__.py +45 -0
- openterminal/skills/markdown-tables/SKILL.md +247 -0
- openterminal/ssh_pty.py +6 -0
- openterminal/sysprobe.py +7 -0
- openterminal/taskview.py +7 -0
- openterminal/term_frontend.py +7 -0
- openterminal/token_est.py +3 -0
- openterminal/transcript.py +7 -0
- openterminal/web/__init__.py +1 -0
- openterminal/web/files_api.py +789 -0
- openterminal/web/frontend/index.html +37 -0
- openterminal/web/frontend/static/app.js +3632 -0
- openterminal/web/frontend/static/block_stream.js +274 -0
- openterminal/web/frontend/static/block_view.js +383 -0
- openterminal/web/frontend/static/files_panel.js +782 -0
- openterminal/web/frontend/static/md_lite.js +127 -0
- openterminal/web/frontend/static/modal.js +122 -0
- openterminal/web/frontend/static/pad_ledger.js +46 -0
- openterminal/web/frontend/static/style.css +915 -0
- openterminal/web/frontend/static/ui/ui.css +1 -0
- openterminal/web/frontend/static/ui/ui.js +6292 -0
- openterminal/web/frontend/vendor/addon-fit.js +2 -0
- openterminal/web/frontend/vendor/xterm.css +8 -0
- openterminal/web/frontend/vendor/xterm.js +8 -0
- openterminal/web/protocol.py +41 -0
- openterminal/web/server.py +322 -0
- openterminal/web/worker.py +62 -0
- ot_cli-0.2.1.dist-info/METADATA +439 -0
- ot_cli-0.2.1.dist-info/RECORD +91 -0
- ot_cli-0.2.1.dist-info/WHEEL +5 -0
- ot_cli-0.2.1.dist-info/entry_points.txt +3 -0
- ot_cli-0.2.1.dist-info/licenses/LICENSE +202 -0
- ot_cli-0.2.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""旧路径壳(阶段二 Task 12):实现已迁至 session/base.py。"""
|
|
2
|
+
|
|
3
|
+
from .session.base import ( # noqa: F401
|
|
4
|
+
BEGIN_MARKER, END_MARKER, BasePtySession, CommandResult, ShellSession,
|
|
5
|
+
_ANSI_RE, _BEGIN_RE, _END_RE, _PASSWORD_PROMPT_RE, _clean,
|
|
6
|
+
_needs_password_prompt, slice_capture, truncate_output, wrap_command,
|
|
7
|
+
wrap_passthrough,
|
|
8
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""内置 Agent Skills(数据包)。
|
|
2
|
+
|
|
3
|
+
目录结构遵循 Anthropic Agent Skills 约定:每个 skill 一个子目录,
|
|
4
|
+
内含带 YAML frontmatter(name + description)的 SKILL.md。加载、
|
|
5
|
+
校验与渐进式披露由 deepagents 的 SkillsMiddleware 完成(见 agent.py
|
|
6
|
+
的 build_agent),本包只承载数据并描述内置/用户两层挂载点。
|
|
7
|
+
|
|
8
|
+
挂载方式:内置与用户目录都不在 agent 文件沙箱(shell cwd)内,故经
|
|
9
|
+
CompositeBackend 以虚拟前缀挂进文件系统——模型用 read_file 读
|
|
10
|
+
/skills/.../SKILL.md 即可加载全文,用户目录后挂、同名覆盖内置。
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from __future__ import annotations
|
|
14
|
+
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
# 打包后的内置 skill 根目录(wheel/sdist 均为真实目录)
|
|
18
|
+
BUILTIN_DIR = Path(__file__).resolve().parent
|
|
19
|
+
|
|
20
|
+
# 虚拟挂载前缀:出现在系统提示词与模型 read_file 的路径里
|
|
21
|
+
BUILTIN_PREFIX = "/skills/builtin/"
|
|
22
|
+
USER_PREFIX = "/skills/user/"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def user_skills_dir() -> Path:
|
|
26
|
+
"""用户级 skill 目录:同名 skill 覆盖内置版。"""
|
|
27
|
+
return Path.home() / ".openterminal" / "skills"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def skill_routes() -> dict[str, Path]:
|
|
31
|
+
"""虚拟前缀 → 实际 skill 目录。用户目录不存在时不挂载,
|
|
32
|
+
避免无意义的加载告警。"""
|
|
33
|
+
routes = {BUILTIN_PREFIX: BUILTIN_DIR}
|
|
34
|
+
user = user_skills_dir()
|
|
35
|
+
if user.is_dir():
|
|
36
|
+
routes[USER_PREFIX] = user
|
|
37
|
+
return routes
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def skill_sources() -> list[tuple[str, str]]:
|
|
41
|
+
"""SkillsMiddleware 的 sources:内置在前、用户在后(后源覆盖先源)。"""
|
|
42
|
+
return [
|
|
43
|
+
(prefix, "内置" if prefix == BUILTIN_PREFIX else "用户")
|
|
44
|
+
for prefix in skill_routes()
|
|
45
|
+
]
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: markdown-tables
|
|
3
|
+
description: Use when creating or formatting tables in markdown. Covers table syntax, alignment, escaping, and best practices.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Markdown Tables
|
|
7
|
+
|
|
8
|
+
Comprehensive guide to creating and formatting tables in markdown.
|
|
9
|
+
|
|
10
|
+
## Basic Table Syntax
|
|
11
|
+
|
|
12
|
+
```markdown
|
|
13
|
+
| Header 1 | Header 2 | Header 3 |
|
|
14
|
+
|----------|----------|----------|
|
|
15
|
+
| Cell 1 | Cell 2 | Cell 3 |
|
|
16
|
+
| Cell 4 | Cell 5 | Cell 6 |
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Renders as:
|
|
20
|
+
|
|
21
|
+
| Header 1 | Header 2 | Header 3 |
|
|
22
|
+
|----------|----------|----------|
|
|
23
|
+
| Cell 1 | Cell 2 | Cell 3 |
|
|
24
|
+
| Cell 4 | Cell 5 | Cell 6 |
|
|
25
|
+
|
|
26
|
+
## Column Alignment
|
|
27
|
+
|
|
28
|
+
```markdown
|
|
29
|
+
| Left | Center | Right |
|
|
30
|
+
|:---------|:--------:|---------:|
|
|
31
|
+
| Left | Center | Right |
|
|
32
|
+
| aligned | aligned | aligned |
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Renders as:
|
|
36
|
+
|
|
37
|
+
| Left | Center | Right |
|
|
38
|
+
|:---------|:--------:|---------:|
|
|
39
|
+
| Left | Center | aligned |
|
|
40
|
+
| text | text | text |
|
|
41
|
+
|
|
42
|
+
- `:---` Left align (default)
|
|
43
|
+
- `:--:` Center align
|
|
44
|
+
- `---:` Right align
|
|
45
|
+
|
|
46
|
+
## Minimum Syntax
|
|
47
|
+
|
|
48
|
+
The pipes and dashes don't need to align:
|
|
49
|
+
|
|
50
|
+
```markdown
|
|
51
|
+
|Header|Header|
|
|
52
|
+
|-|-|
|
|
53
|
+
|Cell|Cell|
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
However, aligned tables are more readable in source.
|
|
57
|
+
|
|
58
|
+
## Escaping Pipe Characters
|
|
59
|
+
|
|
60
|
+
Use `\|` to include a literal pipe in a cell:
|
|
61
|
+
|
|
62
|
+
```markdown
|
|
63
|
+
| Command | Description |
|
|
64
|
+
|---------|-------------|
|
|
65
|
+
| `a \| b` | Pipe operator |
|
|
66
|
+
| `cmd \|\| exit` | Or operator |
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Inline Formatting in Tables
|
|
70
|
+
|
|
71
|
+
Tables support inline markdown:
|
|
72
|
+
|
|
73
|
+
```markdown
|
|
74
|
+
| Feature | Syntax |
|
|
75
|
+
|---------|--------|
|
|
76
|
+
| **Bold** | `**text**` |
|
|
77
|
+
| *Italic* | `*text*` |
|
|
78
|
+
| `Code` | `` `code` `` |
|
|
79
|
+
| [Link](url) | `[text](url)` |
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Multi-line Cell Content
|
|
83
|
+
|
|
84
|
+
Standard markdown tables don't support multi-line cells. Workarounds:
|
|
85
|
+
|
|
86
|
+
### Using `<br>` Tags
|
|
87
|
+
|
|
88
|
+
```markdown
|
|
89
|
+
| Step | Description |
|
|
90
|
+
|------|-------------|
|
|
91
|
+
| 1 | First line<br>Second line |
|
|
92
|
+
| 2 | Another step |
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Using HTML Tables
|
|
96
|
+
|
|
97
|
+
For complex layouts, use HTML:
|
|
98
|
+
|
|
99
|
+
```html
|
|
100
|
+
<table>
|
|
101
|
+
<tr>
|
|
102
|
+
<th>Header</th>
|
|
103
|
+
<th>Description</th>
|
|
104
|
+
</tr>
|
|
105
|
+
<tr>
|
|
106
|
+
<td>Item</td>
|
|
107
|
+
<td>
|
|
108
|
+
<ul>
|
|
109
|
+
<li>Point one</li>
|
|
110
|
+
<li>Point two</li>
|
|
111
|
+
</ul>
|
|
112
|
+
</td>
|
|
113
|
+
</tr>
|
|
114
|
+
</table>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Empty Cells
|
|
118
|
+
|
|
119
|
+
Use a space or leave empty:
|
|
120
|
+
|
|
121
|
+
```markdown
|
|
122
|
+
| A | B | C |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| 1 | | 3 |
|
|
125
|
+
| 4 | 5 | |
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Wide Tables
|
|
129
|
+
|
|
130
|
+
For tables with many columns, consider:
|
|
131
|
+
|
|
132
|
+
### Scrollable Container (HTML)
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<div style="overflow-x: auto;">
|
|
136
|
+
|
|
137
|
+
| Col 1 | Col 2 | Col 3 | Col 4 | Col 5 | Col 6 |
|
|
138
|
+
|-------|-------|-------|-------|-------|-------|
|
|
139
|
+
| Data | Data | Data | Data | Data | Data |
|
|
140
|
+
|
|
141
|
+
</div>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Vertical Layout
|
|
145
|
+
|
|
146
|
+
Transform wide tables into key-value pairs:
|
|
147
|
+
|
|
148
|
+
```markdown
|
|
149
|
+
### Item 1
|
|
150
|
+
|
|
151
|
+
| Property | Value |
|
|
152
|
+
|----------|-------|
|
|
153
|
+
| Name | Foo |
|
|
154
|
+
| Type | Bar |
|
|
155
|
+
| Status | Active |
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Common Table Patterns
|
|
159
|
+
|
|
160
|
+
### Comparison Table
|
|
161
|
+
|
|
162
|
+
```markdown
|
|
163
|
+
| Feature | Free | Pro | Enterprise |
|
|
164
|
+
|---------|:----:|:---:|:----------:|
|
|
165
|
+
| Users | 5 | 50 | Unlimited |
|
|
166
|
+
| Storage | 1GB | 10GB| 100GB |
|
|
167
|
+
| Support | ❌ | ✅ | ✅ |
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### API Reference
|
|
171
|
+
|
|
172
|
+
```markdown
|
|
173
|
+
| Parameter | Type | Required | Description |
|
|
174
|
+
|-----------|------|:--------:|-------------|
|
|
175
|
+
| `id` | string | ✅ | Unique identifier |
|
|
176
|
+
| `name` | string | ✅ | Display name |
|
|
177
|
+
| `limit` | number | ❌ | Max results (default: 10) |
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Keyboard Shortcuts
|
|
181
|
+
|
|
182
|
+
```markdown
|
|
183
|
+
| Action | Windows/Linux | macOS |
|
|
184
|
+
|--------|---------------|-------|
|
|
185
|
+
| Copy | `Ctrl+C` | `⌘+C` |
|
|
186
|
+
| Paste | `Ctrl+V` | `⌘+V` |
|
|
187
|
+
| Undo | `Ctrl+Z` | `⌘+Z` |
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Changelog
|
|
191
|
+
|
|
192
|
+
```markdown
|
|
193
|
+
| Version | Date | Changes |
|
|
194
|
+
|---------|------|---------|
|
|
195
|
+
| 2.0.0 | 2024-01-15 | Breaking: New API |
|
|
196
|
+
| 1.2.0 | 2024-01-01 | Added feature X |
|
|
197
|
+
| 1.1.0 | 2023-12-15 | Bug fixes |
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Best Practices
|
|
201
|
+
|
|
202
|
+
1. **Keep tables simple**: If content is complex, consider alternatives
|
|
203
|
+
2. **Use consistent alignment**: Align source pipes for readability
|
|
204
|
+
3. **Header row required**: Always include a header row
|
|
205
|
+
4. **Escape special characters**: Use `\|` for literal pipes
|
|
206
|
+
5. **Limit columns**: Wide tables are hard to read
|
|
207
|
+
6. **Consider alternatives**: Lists or definition lists may work better
|
|
208
|
+
7. **Test rendering**: Tables render differently across platforms
|
|
209
|
+
|
|
210
|
+
## Markdownlint Rules for Tables
|
|
211
|
+
|
|
212
|
+
| Rule | Description |
|
|
213
|
+
|------|-------------|
|
|
214
|
+
| MD055 | Table pipe style should be consistent |
|
|
215
|
+
| MD056 | Table column count should match header |
|
|
216
|
+
| MD058 | Tables should be surrounded by blank lines |
|
|
217
|
+
|
|
218
|
+
## Alternatives to Tables
|
|
219
|
+
|
|
220
|
+
### Definition Lists (Some Parsers)
|
|
221
|
+
|
|
222
|
+
```markdown
|
|
223
|
+
Term 1
|
|
224
|
+
: Definition 1
|
|
225
|
+
|
|
226
|
+
Term 2
|
|
227
|
+
: Definition 2
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Bullet Lists with Bold Keys
|
|
231
|
+
|
|
232
|
+
```markdown
|
|
233
|
+
- **Name**: John Doe
|
|
234
|
+
- **Email**: john@example.com
|
|
235
|
+
- **Role**: Developer
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Nested Lists
|
|
239
|
+
|
|
240
|
+
```markdown
|
|
241
|
+
- Item 1
|
|
242
|
+
- Property A: Value
|
|
243
|
+
- Property B: Value
|
|
244
|
+
- Item 2
|
|
245
|
+
- Property A: Value
|
|
246
|
+
- Property B: Value
|
|
247
|
+
```
|
openterminal/ssh_pty.py
ADDED
openterminal/sysprobe.py
ADDED
openterminal/taskview.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Web 终端:ot web(FastAPI + xterm.js + WebSocket)。"""
|