telos-cli 0.1.0__py3-none-win_amd64.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.
Binary file
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.4
2
+ Name: telos-cli
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Environment :: Console
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Rust
9
+ Classifier: Topic :: Software Development
10
+ Classifier: Topic :: Terminals
11
+ License-File: LICENSE
12
+ Summary: Terminal interface for telos-agent
13
+ Keywords: agent,ai,cli,llm,terminal
14
+ License-Expression: MIT
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
17
+ Project-URL: Changelog, https://github.com/future-re/telos-agent/blob/main/CHANGELOG.md
18
+ Project-URL: Repository, https://github.com/future-re/telos-agent
19
+
20
+ # telos
21
+
22
+ **telos** 是一个 Rust 编写的意图驱动 agent runtime,封装「用户输入 → 模型采样 → 工具执行 → 结果回注」的完整 turn 循环。可作为 AI 编码助手、聊天机器人、自动化工作流的内核。
23
+
24
+ > Loop: intent → execute → think → complete
25
+
26
+ Repository: <https://github.com/future-re/telos-agent>
27
+
28
+ ## 快速开始
29
+
30
+ ### CLI
31
+
32
+ ```bash
33
+ # 从 PyPI 安装(推荐给 Python 用户)
34
+ pip install telos-cli
35
+
36
+ # 或从 crates.io 安装
37
+ cargo install telos-cli
38
+
39
+ # 查看命令帮助
40
+ telos --help
41
+
42
+ # 设置环境变量(推荐)
43
+ export DEEPSEEK_API_KEY=sk-...
44
+
45
+ # 全屏 TUI
46
+ telos
47
+
48
+ # 单次调用
49
+ telos "Review src/lib.rs"
50
+
51
+ # 指定 provider 和模型
52
+ telos --provider deepseek --model deepseek-v4-pro "Refactor error handling"
53
+
54
+ # 使用双模型路由:thinking 负责规划/恢复,fast 负责工具执行
55
+ telos --provider deepseek \
56
+ --thinking-model deepseek-v4-pro \
57
+ --fast-model deepseek-v4-flash \
58
+ "Refactor error handling"
59
+
60
+ # 生成 shell 补全
61
+ telos completion bash > /usr/share/bash-completion/completions/telos
62
+ ```
63
+
64
+ 当前 CLI 支持 `deepseek` 和 `mock` provider。API key 按以下优先级解析:`--api-key` 标志 → `DEEPSEEK_API_KEY` 环境变量 → 配置文件 `[env]` → 交互式输入。详细用法见 [cli/README.md](cli/README.md)。
65
+
66
+ ### 库
67
+
68
+ ```bash
69
+ cargo add telos_agent
70
+ ```
71
+
72
+ ```rust
73
+ use telos_agent::{
74
+ AgentConfig, AgentError, AgentSession, CompletionResponse, Message, MockProvider,
75
+ StopReason, Tool, ToolContext, ToolDefinition, ToolOutput, ToolRegistry,
76
+ };
77
+ use serde_json::{json, Value};
78
+
79
+ struct EchoTool;
80
+
81
+ #[async_trait::async_trait]
82
+ impl Tool for EchoTool {
83
+ fn definition(&self) -> ToolDefinition {
84
+ ToolDefinition {
85
+ name: "echo".into(),
86
+ description: "Echo input text.".into(),
87
+ input_schema: json!({
88
+ "type": "object",
89
+ "properties": { "text": { "type": "string" } },
90
+ "required": ["text"]
91
+ }),
92
+ }
93
+ }
94
+
95
+ async fn invoke(&self, args: Value, _ctx: ToolContext) -> Result<ToolOutput, AgentError> {
96
+ Ok(ToolOutput { content: json!({ "echo": args }) })
97
+ }
98
+ }
99
+
100
+ #[tokio::main]
101
+ async fn main() -> Result<(), AgentError> {
102
+ let provider = MockProvider::new(vec![CompletionResponse {
103
+ message: Message::assistant("done"),
104
+ stop_reason: StopReason::EndTurn,
105
+ usage: None,
106
+ }]);
107
+
108
+ let mut tools = ToolRegistry::new();
109
+ tools.register(EchoTool);
110
+
111
+ let mut session = AgentSession::new(AgentConfig {
112
+ base_system_prompt: Some("You are a concise assistant.".into()),
113
+ ..Default::default()
114
+ })?;
115
+
116
+ let result = session.run_turn(&provider, &tools, "hello").await?;
117
+ println!("{}", result.final_message.text_content());
118
+ Ok(())
119
+ }
120
+ ```
121
+
122
+ ## 功能概览
123
+
124
+ ### 核心循环
125
+ - `AgentSession` 驱动 turn 循环(采样 → 工具执行 → 结果回注)
126
+ - `TurnEvent` 流式事件,暴露采样、工具、compaction、停止等阶段
127
+ - hook phase:当前 turn loop 内执行 `PostSampling` 和 `Stop`,hook 注册表保留扩展接口
128
+ - 取消检查点,可在 provider 调用或迭代间隙安全中断
129
+
130
+ ### Provider
131
+ - 统一的 `ModelProvider` trait,内置 DeepSeek、双模型 `RoutedProvider`、Mock 实现
132
+ - DeepSeek 使用原生 Chat Completions / SSE streaming 请求层,支持 DeepSeek `thinking`、准确 usage 明细和指数退避重试
133
+ - `ModelHint` 将请求标记为 thinking、execution、recovery 或 summarization;DeepSeek 仅在 `Thinking` / `Recovery` 请求中开启 thinking,并把 `reasoning_content` 作为 thinking 输出流式展示
134
+ - Provider 返回的 `usage` 是准确用量语义,包含输入/输出 token、总 token、prompt cache hit/miss 和 reasoning token(如 API 返回)
135
+ - `ErasedProvider` 辅助类型擦除
136
+
137
+ ### DeepSeek API 支持范围
138
+ - 已支持:Chat Completions、SSE streaming、tool calls、JSON Output、Beta Prefix Completion、Beta FIM Completion、模型列表、余额查询、`thinking`、`reasoning_content`、`stream_options.include_usage`、usage 明细、400/401/402/422/429/500/503 错误语义和 retry 判断
139
+ - Context Caching 在 DeepSeek API 侧默认生效;当前通过 provider usage 暴露 `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens`,不额外伪造管理接口
140
+ - 当前中文 API 文档未看到 Batch 端点,因此未封装 Batch
141
+
142
+ ### 工具系统
143
+ - `Tool` trait + `ToolRegistry`,支持别名、JSON Schema 自动校验
144
+ - 内置工具:Bash、Read、Edit、Write、Glob、Grep、WebFetch、WebSearch、AskUserQuestion
145
+ - `SubagentTool`(完整子会话 + fork 并发多视角)、`SkillTool`(slash-command)
146
+ - Memory 工具(Read/Write/Grep/Edit/Status)、Task 工具(Create/Get/List/Update)
147
+ - MCP 工具桥接(stdio JSON-RPC,自动注册为 `mcp__<server>__<tool>`)
148
+ - 插件系统可加载 manifest、tool specs、skills、prompt sections 和 MCP 声明;core 层已提供 registry/apply 能力
149
+ - 工具超时、panic 隔离、文件写冲突保护
150
+
151
+ ### 权限与安全
152
+ - `PermissionEngine` 规则引擎(通配、command_prefix、cwd_prefix)
153
+ - Bash AST 安全分析(fail-closed)
154
+ - `ApprovalHandler` 人机审批(Allow / Deny / Modify)
155
+
156
+ ### Prompt / Skills / Memory
157
+ - 动态 system prompt 组装(`PromptAssembly` + 14 个内置 section)
158
+ - Markdown skill 系统(YAML frontmatter → prompt 注入)
159
+ - 跨会话持久记忆(`MemoryStore`)+ 上下文画像(`ProfileManager`)
160
+
161
+ ### 存储与会话管理
162
+ - `JsonlStorage` JSONL 持久化,`NoopStorage` 用于无持久化场景
163
+ - Token 预算感知 compaction(`SummaryCompaction` + 字符截断)
164
+ - 任务管理系统(`TaskManager`,支持 blocked_by/blocks 依赖)
165
+
166
+ ### CLI / TUI
167
+ - `telos` 无 prompt 时启动全屏 TUI,`telos "..."` 执行单次调用,`telos chat` 进入交互会话
168
+ - TUI 使用后台 agent task 消费 `TurnEvent`,支持流式 markdown、工具状态、审批 overlay、自动审批、会话保存/恢复和模型切换
169
+ - CLI 启动时加载项目上下文、memory runtime,并注册轻量 CodeIndex 工具用于代码搜索和行号定位
170
+
171
+ ## 架构
172
+
173
+ | 层 | 职责 |
174
+ |---|---|
175
+ | **Session** | `AgentSession` 持有消息历史、配置、文件读状态,暴露 `run_turn` / `run_turn_stream` |
176
+ | **Runtime** | 单轮 turn 内的迭代循环、provider 调用、compaction、hook、工具编排、持久化 |
177
+ | **Provider** | `ModelProvider` 统一封装不同 LLM 后端,流式输出统一为 `ProviderEvent` |
178
+ | **Tool** | `Tool` trait + 执行器:参数校验、权限判定、审批、调用、结果格式化 |
179
+ | **Prompt** | `PromptAssembly` 动态组装 system prompt,缓存静态 section |
180
+ | **Permissions** | `PermissionEngine` 规则引擎 + bash AST 分析 + `ApprovalHandler` 审批 |
181
+ | **MCP** | `McpManager` + `McpToolBridge`,stdio JSON-RPC 接入 MCP 生态 |
182
+ | **Fork** | `Synapse` + `ForkLens`,轻量级上下文分叉,多视角并发执行 |
183
+ | **Storage** | `Storage` trait → JSONL / Noop 后端,含回滚与恢复 |
184
+
185
+ ## 配置
186
+
187
+ 支持用户级 `~/.config/telos/config.toml` 和项目级 `.telos.toml`,项目配置覆盖用户配置:
188
+
189
+ ```toml
190
+ [agent]
191
+ provider = "deepseek"
192
+ max_iterations = 16
193
+
194
+ [agent.models]
195
+ thinking = "deepseek-v4-pro"
196
+ fast = "deepseek-v4-flash"
197
+
198
+ [env]
199
+ DEEPSEEK_API_KEY = "sk-..."
200
+
201
+ [approval]
202
+ default_policy = "ask"
203
+
204
+ [approval.policies]
205
+ read = "allow"
206
+ shell = "ask"
207
+ write = "deny"
208
+
209
+ [diagnostics]
210
+ # CLI 默认启用本地工具失败诊断,写入 .telos/diagnostics/
211
+ enabled = true
212
+ retention_days = 14
213
+
214
+ [diagnostics.github]
215
+ # GitHub issue 上报默认关闭;开启后需要 GITHUB_TOKEN
216
+ enabled = false
217
+ repository = "future-re/telos-agent"
218
+ interval_hours = 24
219
+ min_occurrences = 3
220
+ ```
221
+
222
+ 诊断日志只保存脱敏后的工具失败摘要,用于本地分析;不会保存原始命令、完整 stdout/stderr、环境变量值、模型消息或会话转录。开启 `[diagnostics.github].enabled = true` 后,CLI 会按间隔把重复失败聚合成隐私清洗后的 GitHub Issue。
223
+
224
+ ## 开发
225
+
226
+ ```bash
227
+ # 全量测试
228
+ cargo test --workspace
229
+
230
+ # Lint
231
+ cargo clippy --workspace --all-targets
232
+
233
+ # 安装 CLI
234
+ cd cli && cargo install --path .
235
+ ```
236
+
237
+ ## License
238
+
239
+ MIT
240
+
@@ -0,0 +1,6 @@
1
+ telos_cli-0.1.0.data/scripts/telos.exe,sha256=nnwjsl4kSfmPRzGZ2S_1iCtu7Ydl9Yyow39uhht216A,16989184
2
+ telos_cli-0.1.0.dist-info/METADATA,sha256=_8M1CjAme0x40B_7ahbe3O4Org0H7yOYqtUR_704U8M,9157
3
+ telos_cli-0.1.0.dist-info/WHEEL,sha256=2zDlIYIdD4m4N3p5DVEG3iJhGLdhsBQgdH-FqVkAur8,94
4
+ telos_cli-0.1.0.dist-info/licenses/LICENSE,sha256=3feZbDXi6_UbXw_cYHhQk1iw9_sA7740MIVSiLU8bYA,1106
5
+ telos_cli-0.1.0.dist-info/sboms/telos-cli.cyclonedx.json,sha256=Xp7aEw-zPwkcKm6Kuunh7DxOO8MAEOmT28KxjRDnMKc,365162
6
+ telos_cli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.14.1)
3
+ Root-Is-Purelib: false
4
+ Tag: py3-none-win_amd64
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tiny_agent_core contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.