@optima-chat/optima-agent 0.4.17 → 0.4.18

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.
Files changed (43) hide show
  1. package/.claude/settings.local.json +56 -0
  2. package/.claude/skills/collection/SKILL.md +24 -17
  3. package/.claude/skills/homepage/SKILL.md +0 -2
  4. package/.claude/skills/product/SKILL.md +2 -139
  5. package/dist/bin/bi-cli.js +0 -0
  6. package/dist/bin/comfy.js +0 -0
  7. package/dist/bin/commerce.js +0 -0
  8. package/dist/bin/google-ads.js +0 -0
  9. package/dist/bin/optima.js +0 -0
  10. package/dist/bin/scout.js +0 -0
  11. package/dist/src/ui/App.d.ts +6 -0
  12. package/dist/src/ui/App.d.ts.map +1 -0
  13. package/dist/src/ui/App.js +164 -0
  14. package/dist/src/ui/App.js.map +1 -0
  15. package/dist/src/ui/components/Composer.d.ts +10 -0
  16. package/dist/src/ui/components/Composer.d.ts.map +1 -0
  17. package/dist/src/ui/components/Composer.js +13 -0
  18. package/dist/src/ui/components/Composer.js.map +1 -0
  19. package/dist/src/ui/components/Header.d.ts +7 -0
  20. package/dist/src/ui/components/Header.d.ts.map +1 -0
  21. package/dist/src/ui/components/Header.js +7 -0
  22. package/dist/src/ui/components/Header.js.map +1 -0
  23. package/dist/src/ui/components/Message.d.ts +12 -0
  24. package/dist/src/ui/components/Message.d.ts.map +1 -0
  25. package/dist/src/ui/components/Message.js +21 -0
  26. package/dist/src/ui/components/Message.js.map +1 -0
  27. package/dist/src/ui/components/MessageList.d.ts +9 -0
  28. package/dist/src/ui/components/MessageList.d.ts.map +1 -0
  29. package/dist/src/ui/components/MessageList.js +18 -0
  30. package/dist/src/ui/components/MessageList.js.map +1 -0
  31. package/dist/src/ui/components/Spinner.d.ts +6 -0
  32. package/dist/src/ui/components/Spinner.d.ts.map +1 -0
  33. package/dist/src/ui/components/Spinner.js +7 -0
  34. package/dist/src/ui/components/Spinner.js.map +1 -0
  35. package/dist/src/ui/components/StatusBar.d.ts +11 -0
  36. package/dist/src/ui/components/StatusBar.d.ts.map +1 -0
  37. package/dist/src/ui/components/StatusBar.js +7 -0
  38. package/dist/src/ui/components/StatusBar.js.map +1 -0
  39. package/dist/src/ui/components/index.d.ts +7 -0
  40. package/dist/src/ui/components/index.d.ts.map +1 -0
  41. package/dist/src/ui/components/index.js +7 -0
  42. package/dist/src/ui/components/index.js.map +1 -0
  43. package/package.json +1 -1
@@ -0,0 +1,56 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(gh api:*)",
5
+ "WebFetch(domain:platform.claude.com)",
6
+ "Bash(git init:*)",
7
+ "Bash(mkdir:*)",
8
+ "Bash(npm run typecheck:*)",
9
+ "Bash(npm view:*)",
10
+ "WebSearch",
11
+ "Bash(commerce --help)",
12
+ "Bash(done)",
13
+ "Bash(commerce product:*)",
14
+ "Bash(commerce order:*)",
15
+ "Bash(commerce i18n:*)",
16
+ "Bash(google-ads:*)",
17
+ "Bash(scout --help:*)",
18
+ "Bash(tree:*)",
19
+ "Bash(cloc:*)",
20
+ "Bash(npm run build:*)",
21
+ "Bash(git restore:*)",
22
+ "Bash(gh repo view:*)",
23
+ "Bash(mv:*)",
24
+ "Bash(rmdir:*)",
25
+ "Bash(git add:*)",
26
+ "Bash(git commit:*)",
27
+ "Bash(git push)",
28
+ "Bash(timeout 5 npm run optima:*)",
29
+ "Bash(npm install:*)",
30
+ "Bash(cat:*)",
31
+ "Bash(gh issue create:*)",
32
+ "Bash(npx tsx:*)",
33
+ "Bash(timeout 30 npx tsx:*)",
34
+ "Bash(git push origin feature/ask-user-question)",
35
+ "Bash(node:*)",
36
+ "Bash(npm version:*)",
37
+ "Bash(git push:*)",
38
+ "Bash(npm publish:*)",
39
+ "Bash(pkill:*)",
40
+ "Bash(git -C /Users/verypro/optima-agent log --oneline --all -- \".claude/\")",
41
+ "Bash(wc:*)",
42
+ "Bash(grep:*)",
43
+ "Bash(find:*)",
44
+ "Bash(commerce collection --help:*)",
45
+ "Bash(commerce collection update --help:*)",
46
+ "Bash(commerce collection set-cover:*)",
47
+ "Bash(commerce collection get --help:*)",
48
+ "Bash(commerce collection list --help:*)",
49
+ "Bash(commerce collection create --help:*)",
50
+ "Bash(commerce collection remove-products:*)",
51
+ "Bash(commerce collection list-products:*)"
52
+ ],
53
+ "deny": [],
54
+ "ask": []
55
+ }
56
+ }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: collection
3
- description: 商品集合管理。创建、编辑集合,管理集合中的商品。当用户需要对商品进行分组、创建促销专区、管理商品分类时使用。
3
+ description: 商品集合管理。创建、编辑集合,设置封面图,管理集合中的商品。当用户需要对商品进行分组、创建促销专区、管理商品分类、设置集合封面时使用。
4
4
  ---
5
5
 
6
6
  ## 概念
@@ -37,40 +37,47 @@ Collection
37
37
  当用户说:
38
38
  - "查看所有集合" / "集合列表" → `commerce collection list`
39
39
  - "创建集合 XX" → `commerce collection create --name "XX" --slug xx`
40
- - "查看集合详情" → `commerce collection get --slug xx`
41
- - "删除集合 XX" → `commerce collection delete --slug xx --yes`
42
- - "把商品加到集合" → `commerce collection add-products --slug xx --product-ids p1,p2`
43
- - "从集合移除商品" → `commerce collection remove-products --slug xx --product-ids p1`
44
- - "查看集合里有哪些商品" → `commerce collection list-products --slug xx`
40
+ - "查看集合详情" → `commerce collection get --id xx`
41
+ - "删除集合 XX" → `commerce collection delete --id xx --yes`
42
+ - "把商品加到集合" → `commerce collection add-products --id xx --product-ids p1,p2`
43
+ - "从集合移除商品" → `commerce collection remove-products --id xx --product-ids p1`
44
+ - "查看集合里有哪些商品" → `commerce collection list-products --id xx`
45
+ - "设置集合封面" / "给集合加封面图" → `commerce collection set-cover --id xx --path ./cover.jpg`
45
46
 
46
47
  ## 命令参考
47
48
 
48
49
  ### 集合 CRUD
49
50
  - `commerce collection list` - 列出所有集合
50
- - `commerce collection create` - 创建集合
51
- - `commerce collection get --slug <slug>` - 查看集合详情
52
- - `commerce collection update --slug <slug>` - 更新集合
53
- - `commerce collection delete --slug <slug> --yes` - 删除集合
54
- - `commerce collection set-cover --slug <slug> --media-id <id>` - 设置封面图
51
+ - `commerce collection create --name <name> --slug <slug>` - 创建集合
52
+ - `commerce collection get --id <id>` - 查看集合详情
53
+ - `commerce collection update --id <id>` - 更新集合(支持 --name, --slug, --description 等)
54
+ - `commerce collection delete --id <id> --yes` - 删除集合
55
+ - `commerce collection set-cover --id <id>` - 设置封面图(支持 --media-id, --url, --path)
55
56
 
56
57
  ### 商品管理
57
- - `commerce collection add-products --slug <slug> --product-ids <ids>` - 添加商品
58
- - `commerce collection remove-products --slug <slug> --product-ids <ids>` - 移除商品
59
- - `commerce collection list-products --slug <slug>` - 列出集合中的商品
58
+ - `commerce collection add-products --id <id> --product-ids <ids>` - 添加商品
59
+ - `commerce collection remove-products --id <id> --product-ids <ids>` - 移除商品
60
+ - `commerce collection list-products --id <id>` - 列出集合中的商品
60
61
 
61
62
  ## 创建集合示例
62
63
 
63
64
  ```bash
64
- # 创建促销集合
65
+ # 创建促销集合(返回 id,用于后续操作)
65
66
  commerce collection create \
66
67
  --name "Summer Sale 2024" \
67
68
  --slug summer-sale-2024 \
68
69
  --description "Hot deals for summer"
70
+ # 输出: { "id": "coll_xxx", ... }
69
71
 
70
- # 添加商品到集合
72
+ # 添加商品到集合(使用返回的 id)
71
73
  commerce collection add-products \
72
- --slug summer-sale-2024 \
74
+ --id coll_xxx \
73
75
  --product-ids prod_123,prod_456,prod_789
76
+
77
+ # 设置封面图
78
+ commerce collection set-cover \
79
+ --id coll_xxx \
80
+ --path ./summer-sale-cover.jpg
74
81
  ```
75
82
 
76
83
  ## 注意事项
@@ -16,8 +16,6 @@ Homepage(首页)是店铺的入口页面,由多个 Section(区块)组
16
16
  - `collection_products` 区块:展示某个集合的商品(引用单个 collection slug)
17
17
  - `featured` 区块:可推荐某个集合(target_type=collection)
18
18
 
19
- → 参考 [Collection Skill](../collection/SKILL.md) 了解集合管理
20
-
21
19
  ## 结构
22
20
 
23
21
  ```
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: product
3
- description: Product catalog management for e-commerce stores. Create and update products, manage variants/SKUs, upload product images, organize tags, manage collections. Use when user needs to add new products, update pricing, manage product inventory, upload photos, organize product catalog, or manage product collections.
3
+ description: Product catalog management for e-commerce stores. Create and update products, manage variants/SKUs, upload product images, organize tags. Use when user needs to add new products, update pricing, manage product inventory, upload photos, or organize product catalog.
4
4
  ---
5
5
 
6
6
  # Commerce CLI - Product Management
7
7
 
8
- 商品管理模块,用于电商商品目录的创建、编辑、组织和集合管理。
8
+ 商品管理模块,用于电商商品目录的创建、编辑和组织。
9
9
 
10
10
  ## 典型场景
11
11
 
@@ -73,45 +73,6 @@ commerce upload image --path ./new-photo.jpg # 获得 media_new
73
73
  commerce product add-images --id prod_123 --media-id media_new
74
74
  ```
75
75
 
76
- ### 场景6:创建商品集合
77
-
78
- **推荐集合类型**:
79
- - **时令集合** - 春夏秋冬、节日促销(如"Christmas Sale")
80
- - **品类集合** - 按商品类型分组(如"T-Shirts", "Dresses")
81
- - **主题集合** - 按场景分组(如"Office Wear", "Casual Style")
82
- - **促销集合** - 新品、热卖、折扣(如"New Arrivals", "Best Sellers")
83
-
84
- **创建流程**:
85
- ```bash
86
- # 1. 创建集合
87
- commerce collection create \
88
- --name "Summer Sale 2024" \
89
- --slug "summer-sale-2024" \
90
- --description "Hot deals for summer"
91
-
92
- # 2. 添加商品到集合
93
- commerce collection add-products \
94
- --slug summer-sale-2024 \
95
- --product-ids prod_123,prod_456,prod_789
96
- ```
97
-
98
- ### 场景7:设置集合封面图
99
-
100
- **三种方式**:
101
-
102
- ```bash
103
- # 方式 1:使用 Media ID(推荐,可复用已上传图片)
104
- commerce upload image --path ./cover.jpg
105
- # 获取 media_id: media_456
106
- commerce collection set-cover --id coll-123 --media-id media_456
107
-
108
- # 方式 2:使用 URL
109
- commerce collection set-cover --id coll-123 --url "https://example.com/cover.jpg"
110
-
111
- # 方式 3:上传本地文件
112
- commerce collection set-cover --id coll-123 --path ./cover.jpg
113
- ```
114
-
115
76
  ### 场景决策表
116
77
 
117
78
  | 用户需求 | 推荐命令 | 关键注意点 |
@@ -122,8 +83,6 @@ commerce collection set-cover --id coll-123 --path ./cover.jpg
122
83
  | 更新价格 | `product update --price` | 如有变体,需逐个更新变体价格 |
123
84
  | 促销标签 | `product update --tags` | 用逗号分隔,保留原有标签 |
124
85
  | 图片更新 | `upload` + `add-images` | 先上传再关联,不要直接删除旧图 |
125
- | 创建促销集合 | `collection create --slug sale` | slug 简短有意义,添加10-30个商品 |
126
- | 设置集合封面 | `collection set-cover --id XX` | 支持 media-id/url/path 三种方式 |
127
86
 
128
87
  ## 卓越标准
129
88
 
@@ -219,54 +178,6 @@ commerce product update --id prod_123 --tags "featured,new,sale"
219
178
  commerce product create --title "T恤" --price 99 --stock 50 # 确保真实有50件
220
179
  ```
221
180
 
222
- ### ❌ 问题6:集合命名随意,无规划
223
-
224
- **错误做法**:
225
- ```bash
226
- # 命名不规范,slug 无意义
227
- commerce collection create --name "aaa" --slug "test123"
228
- commerce collection create --name "商品111" --slug "product-collection"
229
- ```
230
-
231
- **正确做法**:
232
- ```bash
233
- # 命名清晰,slug 符合 SEO 规范
234
- commerce collection create --name "Summer Sale 2024" --slug "summer-sale-2024"
235
- commerce collection create --name "Men's T-Shirts" --slug "mens-tshirts"
236
- ```
237
-
238
- ### ❌ 问题7:集合缺少商品
239
-
240
- **错误做法**:
241
- ```bash
242
- # 创建集合后忘记添加商品
243
- commerce collection create --name "New Arrivals" --slug "new-arrivals"
244
- # 集合页面显示空白
245
- ```
246
-
247
- **正确做法**:
248
- ```bash
249
- # 创建集合后立即添加商品(至少5个)
250
- commerce collection create --name "New Arrivals" --slug "new-arrivals"
251
- commerce collection add-products --slug new-arrivals --product-ids prod_1,prod_2,prod_3,prod_4,prod_5
252
- ```
253
-
254
- ### ❌ 问题8:slug 使用中文或特殊字符
255
-
256
- **错误做法**:
257
- ```bash
258
- # slug 包含中文或特殊字符,影响 SEO 和 URL 可读性
259
- commerce collection create --name "夏季促销" --slug "夏季促销"
260
- commerce collection create --name "Sale!!!" --slug "sale!!!"
261
- ```
262
-
263
- **正确做法**:
264
- ```bash
265
- # slug 使用英文、数字、连字符
266
- commerce collection create --name "夏季促销" --slug "summer-sale"
267
- commerce collection create --name "Sale!!!" --slug "sale"
268
- ```
269
-
270
181
  ## 命令参考
271
182
 
272
183
  ### 自然语言映射
@@ -278,11 +189,6 @@ commerce collection create --name "Sale!!!" --slug "sale"
278
189
  - "更新商品价格" → `commerce product update --id XX --price YY`
279
190
  - "给商品打标签" → `commerce product update --id XX --tags "featured,new"`
280
191
  - "查看所有商品" → `commerce product list`
281
- - "创建商品集合" → `commerce collection create --name XX --slug YY`
282
- - "把商品添加到集合" → `commerce collection add-products --slug XX --product-ids YY`
283
- - "设置集合封面图" → `commerce collection set-cover --id XX --media-id YY`
284
- - "上传集合封面" → `commerce collection set-cover --id XX --path ./cover.jpg`
285
- - "集合封面图 URL 是 https://..." → `commerce collection set-cover --id XX --url "https://..."`
286
192
 
287
193
  ### 核心功能
288
194
 
@@ -304,15 +210,6 @@ commerce collection create --name "Sale!!!" --slug "sale"
304
210
  - `commerce product add-images` - 关联图片到商品
305
211
  - `commerce product remove-images` - 移除商品图片
306
212
 
307
- **商品集合**:
308
- - `commerce collection create` - 创建集合
309
- - `commerce collection list` - 查看集合列表
310
- - `commerce collection update` - 更新集合
311
- - `commerce collection delete` - 删除集合
312
- - `commerce collection add-products` - 添加商品到集合
313
- - `commerce collection remove-products` - 从集合移除商品
314
- - `commerce collection set-cover` - 设置集合封面图(支持 media-id/url/path)
315
-
316
213
  ## 详细示例
317
214
 
318
215
  ### 示例1:创建单个商品
@@ -398,38 +295,6 @@ commerce product add-images --id prod_123 --media-id media_red,media_blue
398
295
  commerce product get --id prod_123
399
296
  ```
400
297
 
401
- ### 示例7:创建商品集合
402
- ```bash
403
- # 用户说:"创建夏季促销集合"
404
- commerce collection create \
405
- --name "Summer Sale" \
406
- --slug summer-sale \
407
- --description "Hot deals for summer"
408
- ```
409
-
410
- ### 示例8:添加商品到集合
411
- ```bash
412
- # 用户说:"把商品prod_123和prod_456添加到summer-sale集合"
413
- commerce collection add-products \
414
- --slug summer-sale \
415
- --product-ids prod_123,prod_456
416
- ```
417
-
418
- ### 示例9:设置集合封面图
419
- ```bash
420
- # 用户说:"给集合设置封面图"
421
-
422
- # 方式 1:使用 Media ID(推荐)
423
- commerce upload image --path ./cover.jpg # 获得 media_456
424
- commerce collection set-cover --id coll-123 --media-id media_456
425
-
426
- # 方式 2:使用 URL
427
- commerce collection set-cover --id coll-123 --url "https://example.com/cover.jpg"
428
-
429
- # 方式 3:上传本地文件
430
- commerce collection set-cover --id coll-123 --path ./cover.jpg
431
- ```
432
-
433
298
  ## 重要提示
434
299
 
435
300
  - 所有命令默认 JSON 输出,便于 AI 解析
@@ -440,5 +305,3 @@ commerce collection set-cover --id coll-123 --path ./cover.jpg
440
305
  - 使用 `--help` 查看命令详细参数
441
306
  - 删除商品会同时删除所有变体和图片关联
442
307
  - 价格单位默认为美元(USD),可通过后台配置修改
443
- - 集合 slug 必须唯一,用于 URL,使用英文和连字符
444
- - 集合封面支持三种方式:`--media-id`(推荐)、`--url`、`--path`
File without changes
package/dist/bin/comfy.js CHANGED
File without changes
File without changes
File without changes
File without changes
package/dist/bin/scout.js CHANGED
File without changes
@@ -0,0 +1,6 @@
1
+ interface AppProps {
2
+ cwd?: string;
3
+ }
4
+ export declare function App({ cwd }: AppProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
6
+ //# sourceMappingURL=App.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../src/ui/App.tsx"],"names":[],"mappings":"AAcA,UAAU,QAAQ;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,GAAG,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,2CAqMpC"}
@@ -0,0 +1,164 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useCallback, useRef } from "react";
3
+ import { Box, useApp, useInput } from "ink";
4
+ import { Header, Composer, MessageList, StatusBar, Spinner, } from "./components/index.js";
5
+ import { OptimaAgent } from "../agent.js";
6
+ const VERSION = "0.1.25";
7
+ export function App({ cwd }) {
8
+ const { exit } = useApp();
9
+ const [input, setInput] = useState("");
10
+ const [messages, setMessages] = useState([]);
11
+ const [isProcessing, setIsProcessing] = useState(false);
12
+ const [skills, setSkills] = useState([]);
13
+ const [tokens, setTokens] = useState();
14
+ const [agent] = useState(() => new OptimaAgent({ cwd }));
15
+ const abortControllerRef = useRef(null);
16
+ // 处理斜杠命令
17
+ const handleSlashCommand = useCallback((command) => {
18
+ const cmd = command.toLowerCase().trim();
19
+ if (cmd === "/help") {
20
+ setMessages((prev) => [
21
+ ...prev,
22
+ {
23
+ role: "assistant",
24
+ content: `可用命令:
25
+ /help - 显示帮助
26
+ /clear - 清空对话
27
+ /skills - 查看已加载技能
28
+ /exit - 退出`,
29
+ },
30
+ ]);
31
+ return true;
32
+ }
33
+ if (cmd === "/clear") {
34
+ setMessages([]);
35
+ agent.reset();
36
+ setSkills([]);
37
+ setTokens(undefined);
38
+ return true;
39
+ }
40
+ if (cmd === "/skills") {
41
+ setMessages((prev) => [
42
+ ...prev,
43
+ {
44
+ role: "assistant",
45
+ content: skills.length > 0
46
+ ? `已加载技能: ${skills.join(", ")}`
47
+ : "暂无已加载技能",
48
+ },
49
+ ]);
50
+ return true;
51
+ }
52
+ if (cmd === "/exit") {
53
+ exit();
54
+ return true;
55
+ }
56
+ return false;
57
+ }, [agent, exit, skills]);
58
+ // 取消当前请求
59
+ const handleCancel = useCallback(() => {
60
+ if (abortControllerRef.current) {
61
+ abortControllerRef.current.abort();
62
+ abortControllerRef.current = null;
63
+ setIsProcessing(false);
64
+ setMessages((prev) => [
65
+ ...prev,
66
+ { role: "system", content: "已取消" },
67
+ ]);
68
+ }
69
+ }, []);
70
+ // 处理消息提交
71
+ const handleSubmit = useCallback(async (text) => {
72
+ // 检查斜杠命令
73
+ if (text.startsWith("/")) {
74
+ if (handleSlashCommand(text)) {
75
+ setInput("");
76
+ return;
77
+ }
78
+ }
79
+ // 添加用户消息
80
+ setMessages((prev) => [...prev, { role: "user", content: text }]);
81
+ setInput("");
82
+ setIsProcessing(true);
83
+ // 创建 AbortController
84
+ const abortController = new AbortController();
85
+ abortControllerRef.current = abortController;
86
+ let assistantContent = "";
87
+ try {
88
+ for await (const msg of agent.chat(text, { signal: abortController.signal })) {
89
+ // 处理系统消息(获取 skills)
90
+ if (msg.type === "system" && "skills" in msg && msg.skills) {
91
+ const skillsData = msg.skills;
92
+ setSkills(skillsData.filter(Boolean));
93
+ }
94
+ // 处理助手消息
95
+ if (msg.type === "assistant" && msg.message?.content) {
96
+ for (const block of msg.message.content) {
97
+ if (block.type === "text") {
98
+ assistantContent += block.text;
99
+ }
100
+ else if (block.type === "tool_use") {
101
+ // 显示工具调用
102
+ setMessages((prev) => [
103
+ ...prev,
104
+ {
105
+ role: "tool",
106
+ toolName: block.name,
107
+ content: typeof block.input === "string"
108
+ ? block.input
109
+ : JSON.stringify(block.input, null, 2),
110
+ },
111
+ ]);
112
+ }
113
+ }
114
+ }
115
+ // 处理结果(累计 tokens)
116
+ if (msg.type === "result") {
117
+ const usage = msg.usage;
118
+ setTokens((prev) => ({
119
+ input: (prev?.input ?? 0) + (usage?.input_tokens ?? 0),
120
+ output: (prev?.output ?? 0) + (usage?.output_tokens ?? 0),
121
+ }));
122
+ }
123
+ }
124
+ // 添加助手回复
125
+ if (assistantContent) {
126
+ setMessages((prev) => [
127
+ ...prev,
128
+ { role: "assistant", content: assistantContent },
129
+ ]);
130
+ }
131
+ }
132
+ catch (error) {
133
+ // 用户取消不显示错误
134
+ const errorMsg = error instanceof Error ? error.message : "未知错误";
135
+ if (!errorMsg.includes("aborted")) {
136
+ setMessages((prev) => [
137
+ ...prev,
138
+ {
139
+ role: "error",
140
+ content: errorMsg,
141
+ },
142
+ ]);
143
+ }
144
+ }
145
+ finally {
146
+ setIsProcessing(false);
147
+ abortControllerRef.current = null;
148
+ }
149
+ }, [agent, handleSlashCommand]);
150
+ // 快捷键
151
+ useInput((input, key) => {
152
+ if (key.ctrl && input === "c") {
153
+ exit();
154
+ }
155
+ if (key.ctrl && input === "l") {
156
+ setMessages([]);
157
+ }
158
+ if (key.escape && isProcessing) {
159
+ handleCancel();
160
+ }
161
+ });
162
+ return (_jsxs(Box, { flexDirection: "column", height: "100%", children: [_jsx(Header, { version: VERSION }), _jsxs(Box, { flexDirection: "column", flexGrow: 1, paddingX: 1, children: [_jsx(MessageList, { messages: messages }), isProcessing && _jsx(Spinner, {})] }), _jsx(StatusBar, { skills: skills, tokens: tokens }), _jsx(Composer, { value: input, onChange: setInput, onSubmit: handleSubmit, disabled: isProcessing })] }));
163
+ }
164
+ //# sourceMappingURL=App.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"App.js","sourceRoot":"","sources":["../../../src/ui/App.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,GAAG,EAAQ,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAClD,OAAO,EACL,MAAM,EACN,QAAQ,EACR,WAAW,EACX,SAAS,EACT,OAAO,GAER,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,OAAO,GAAG,QAAQ,CAAC;AAMzB,MAAM,UAAU,GAAG,CAAC,EAAE,GAAG,EAAY;IACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC;IAC1B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,Q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I,CAAC;QACpC,CAAC;IACH,CAAC,EACD,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAC5B,CAAC;IAEF,MAAM;IACN,QAAQ,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACtB,IAAI,GAAG,CAAC,IAAI,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YAC9B,IAAI,EAAE,CAAC;QACT,CAAC;QACD,IAAI,GAAG,CAAC,IAAI,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;YAC9B,WAAW,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,IAAI,YAAY,EAAE,CAAC;YAC/B,YAAY,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,MAAM,EAAC,MAAM,aACvC,KAAC,MAAM,IAAC,OAAO,EAAE,OAAO,GAAI,EAE5B,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,aAClD,KAAC,WAAW,IAAC,QAAQ,EAAE,QAAQ,GAAI,EAElC,YAAY,IAAI,KAAC,OAAO,KAAG,IACxB,EAEN,KAAC,SAAS,IAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAI,EAE7C,KAAC,QAAQ,IACP,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,YAAY,GACtB,IACE,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ interface ComposerProps {
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ onSubmit: (value: string) => void;
6
+ disabled?: boolean;
7
+ }
8
+ export declare const Composer: React.NamedExoticComponent<ComposerProps>;
9
+ export {};
10
+ //# sourceMappingURL=Composer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Composer.d.ts","sourceRoot":"","sources":["../../../../src/ui/components/Composer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAIjD,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,QAAQ,2CA6BnB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo, useCallback } from "react";
3
+ import { Box, Text } from "ink";
4
+ import TextInput from "ink-text-input";
5
+ export const Composer = memo(function Composer({ value, onChange, onSubmit, disabled = false, }) {
6
+ const handleSubmit = useCallback((text) => {
7
+ if (text.trim()) {
8
+ onSubmit(text.trim());
9
+ }
10
+ }, [onSubmit]);
11
+ return (_jsxs(Box, { borderStyle: "single", borderColor: disabled ? "gray" : "green", paddingX: 1, children: [_jsxs(Text, { color: disabled ? "gray" : "green", bold: true, children: [">", " "] }), disabled ? (_jsx(Text, { color: "gray", children: "\u8BF7\u7B49\u5F85\u54CD\u5E94..." })) : (_jsx(TextInput, { value: value, onChange: onChange, onSubmit: handleSubmit, placeholder: "\u8F93\u5165\u6D88\u606F\u6216 /help \u83B7\u53D6\u5E2E\u52A9" }))] }));
12
+ });
13
+ //# sourceMappingURL=Composer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Composer.js","sourceRoot":"","sources":["../../../../src/ui/components/Composer.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,SAAS,MAAM,gBAAgB,CAAC;AASvC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,QAAQ,CAAC,EAC7C,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,QAAQ,GAAG,KAAK,GACF;IACd,MAAM,YAAY,GAAG,WAAW,CAAC,CAAC,IAAY,EAAE,EAAE;QAChD,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YAChB,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACL,MAAC,GAAG,IAAC,WAAW,EAAC,QAAQ,EAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,aAC7E,MAAC,IAAI,IAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,mBAC3C,GAAG,EAAE,GAAG,IACJ,EACN,QAAQ,CAAC,CAAC,CAAC,CACV,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,kDAAgB,CACnC,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IACR,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,YAAY,EACtB,WAAW,EAAC,+DAAkB,GAC9B,CACH,IACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ interface HeaderProps {
3
+ version: string;
4
+ }
5
+ export declare const Header: React.NamedExoticComponent<HeaderProps>;
6
+ export {};
7
+ //# sourceMappingURL=Header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Header.d.ts","sourceRoot":"","sources":["../../../../src/ui/components/Header.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AAGpC,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,MAAM,yCAWjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from "react";
3
+ import { Box, Text } from "ink";
4
+ export const Header = memo(function Header({ version }) {
5
+ return (_jsxs(Box, { borderStyle: "single", paddingX: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "Optima Agent" }), _jsxs(Text, { color: "gray", children: [" v", version] }), _jsx(Box, { flexGrow: 1 }), _jsx(Text, { color: "gray", children: "[Ctrl+C \u9000\u51FA]" })] }));
6
+ });
7
+ //# sourceMappingURL=Header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Header.js","sourceRoot":"","sources":["../../../../src/ui/components/Header.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAMhC,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,MAAM,CAAC,EAAE,OAAO,EAAe;IACjE,OAAO,CACL,MAAC,GAAG,IAAC,WAAW,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,aACnC,KAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAC,MAAM,6BAEhB,EACP,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,mBAAI,OAAO,IAAQ,EACrC,KAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,GAAI,EACpB,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,sCAAmB,IACjC,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+ export interface MessageItem {
3
+ role: "user" | "assistant" | "tool" | "error" | "system";
4
+ content: string;
5
+ toolName?: string;
6
+ }
7
+ interface MessageProps {
8
+ message: MessageItem;
9
+ }
10
+ export declare const Message: React.NamedExoticComponent<MessageProps>;
11
+ export {};
12
+ //# sourceMappingURL=Message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.d.ts","sourceRoot":"","sources":["../../../../src/ui/components/Message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AAGpC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IACzD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,eAAO,MAAM,OAAO,0CAmDlB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo } from "react";
3
+ import { Box, Text } from "ink";
4
+ export const Message = memo(function Message({ message }) {
5
+ const { role, content, toolName } = message;
6
+ if (role === "user") {
7
+ return (_jsxs(Box, { marginY: 1, children: [_jsxs(Text, { color: "green", bold: true, children: [">", " "] }), _jsx(Text, { children: content })] }));
8
+ }
9
+ if (role === "tool") {
10
+ return (_jsxs(Box, { marginY: 1, borderStyle: "round", borderColor: "gray", paddingX: 1, flexDirection: "column", children: [_jsx(Text, { color: "yellow", children: toolName || "Tool" }), _jsx(Text, { color: "gray", children: content })] }));
11
+ }
12
+ if (role === "error") {
13
+ return (_jsx(Box, { marginY: 1, children: _jsxs(Text, { color: "red", children: ["\u9519\u8BEF: ", content] }) }));
14
+ }
15
+ if (role === "system") {
16
+ return (_jsx(Box, { marginY: 1, children: _jsx(Text, { color: "gray", italic: true, children: content }) }));
17
+ }
18
+ // assistant
19
+ return (_jsx(Box, { marginY: 1, children: _jsx(Text, { children: content }) }));
20
+ });
21
+ //# sourceMappingURL=Message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../../src/ui/components/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OAAO,GAAQ,GACtC,CACP,CAAC;IACJ,CAAC;IAED,YAAY;IACZ,OAAO,CACL,KAAC,GAAG,IAAC,OAAO,EAAE,CAAC,YACb,KAAC,IAAI,cAAE,OAAO,GAAQ,GAClB,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { MessageItem } from "./Message.js";
3
+ interface MessageListProps {
4
+ messages: MessageItem[];
5
+ maxVisible?: number;
6
+ }
7
+ export declare const MessageList: React.NamedExoticComponent<MessageListProps>;
8
+ export {};
9
+ //# sourceMappingURL=MessageList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../../src/ui/components/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAW,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpD,UAAU,gBAAgB;IACxB,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,8CA6BtB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo, useMemo } from "react";
3
+ import { Box, Text } from "ink";
4
+ import { Message } from "./Message.js";
5
+ export const MessageList = memo(function MessageList({ messages, maxVisible = 10 }) {
6
+ // 只显示最近的消息,避免内容超出屏幕导致闪烁
7
+ const { visibleMessages, hiddenCount } = useMemo(() => {
8
+ if (messages.length <= maxVisible) {
9
+ return { visibleMessages: messages, hiddenCount: 0 };
10
+ }
11
+ return {
12
+ visibleMessages: messages.slice(-maxVisible),
13
+ hiddenCount: messages.length - maxVisible,
14
+ };
15
+ }, [messages, maxVisible]);
16
+ return (_jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [hiddenCount > 0 && (_jsx(Box, { marginBottom: 1, children: _jsxs(Text, { color: "gray", italic: true, children: ["... ", hiddenCount, " \u6761\u5386\u53F2\u6D88\u606F\u5DF2\u9690\u85CF (\u4F7F\u7528 /clear \u6E05\u7A7A)"] }) })), visibleMessages.map((msg, index) => (_jsx(Message, { message: msg }, messages.length - maxVisible + index)))] }));
17
+ });
18
+ //# sourceMappingURL=MessageList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageList.js","sourceRoot":"","sources":["../../../../src/ui/components/MessageList.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,OAAO,EAAe,MAAM,cAAc,CAAC;AAOpD,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,WAAW,CAAC,EACnD,QAAQ,EACR,UAAU,GAAG,EAAE,EACE;IACjB,wBAAwB;IACxB,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE;QACpD,IAAI,QAAQ,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;YAClC,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QACvD,CAAC;QACD,OAAO;YACL,eAAe,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC;YAC5C,WAAW,EAAE,QAAQ,CAAC,MAAM,GAAG,UAAU;SAC1C,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,QAAQ,EAAE,CAAC,aACpC,WAAW,GAAG,CAAC,IAAI,CAClB,KAAC,GAAG,IAAC,YAAY,EAAE,CAAC,YAClB,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,MAAM,2BAClB,WAAW,4FACX,GACH,CACP,EACA,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CACnC,KAAC,OAAO,IAA4C,OAAO,EAAE,GAAG,IAAlD,QAAQ,CAAC,MAAM,GAAG,UAAU,GAAG,KAAK,CAAkB,CACrE,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ interface SpinnerProps {
2
+ message?: string;
3
+ }
4
+ export declare function Spinner({ message }: SpinnerProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
6
+ //# sourceMappingURL=Spinner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spinner.d.ts","sourceRoot":"","sources":["../../../../src/ui/components/Spinner.tsx"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,OAAO,CAAC,EAAE,OAAkB,EAAE,EAAE,YAAY,2CAS3D"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ import InkSpinner from "ink-spinner";
4
+ export function Spinner({ message = "思考中..." }) {
5
+ return (_jsxs(Box, { children: [_jsx(Text, { color: "cyan", children: _jsx(InkSpinner, { type: "dots" }) }), _jsxs(Text, { color: "gray", children: [" ", message] })] }));
6
+ }
7
+ //# sourceMappingURL=Spinner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spinner.js","sourceRoot":"","sources":["../../../../src/ui/components/Spinner.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,UAAU,MAAM,aAAa,CAAC;AAMrC,MAAM,UAAU,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,EAAgB;IAC1D,OAAO,CACL,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,YAChB,KAAC,UAAU,IAAC,IAAI,EAAC,MAAM,GAAG,GACrB,EACP,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,kBAAG,OAAO,IAAQ,IAChC,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ interface StatusBarProps {
3
+ skills: string[];
4
+ tokens?: {
5
+ input: number;
6
+ output: number;
7
+ };
8
+ }
9
+ export declare const StatusBar: React.NamedExoticComponent<StatusBarProps>;
10
+ export {};
11
+ //# sourceMappingURL=StatusBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusBar.d.ts","sourceRoot":"","sources":["../../../../src/ui/components/StatusBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAe,MAAM,OAAO,CAAC;AAGpC,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5C;AAED,eAAO,MAAM,SAAS,4CAoBpB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo } from "react";
3
+ import { Box, Text } from "ink";
4
+ export const StatusBar = memo(function StatusBar({ skills, tokens }) {
5
+ return (_jsxs(Box, { paddingX: 1, justifyContent: "space-between", children: [_jsxs(Box, { children: [_jsx(Text, { color: "gray", children: "Skills: " }), skills.length > 0 ? (_jsx(Text, { color: "cyan", children: skills.join(", ") })) : (_jsx(Text, { color: "gray", children: "\u65E0" }))] }), tokens && (_jsx(Box, { children: _jsxs(Text, { color: "gray", children: ["Tokens: ", tokens.input.toLocaleString(), " in / ", tokens.output.toLocaleString(), " out"] }) }))] }));
6
+ });
7
+ //# sourceMappingURL=StatusBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StatusBar.js","sourceRoot":"","sources":["../../../../src/ui/components/StatusBar.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAOhC,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,EAAkB;IACjF,OAAO,CACL,MAAC,GAAG,IAAC,QAAQ,EAAE,CAAC,EAAE,cAAc,EAAC,eAAe,aAC9C,MAAC,GAAG,eACF,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,yBAAgB,EACjC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CACnB,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAQ,CAC9C,CAAC,CAAC,CAAC,CACF,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,uBAAS,CAC5B,IACG,EACL,MAAM,IAAI,CACT,KAAC,GAAG,cACF,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,yBACP,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,YAAQ,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,YACvE,GACH,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { Header } from "./Header.js";
2
+ export { Spinner } from "./Spinner.js";
3
+ export { Message, type MessageItem } from "./Message.js";
4
+ export { MessageList } from "./MessageList.js";
5
+ export { Composer } from "./Composer.js";
6
+ export { StatusBar } from "./StatusBar.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ui/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { Header } from "./Header.js";
2
+ export { Spinner } from "./Spinner.js";
3
+ export { Message } from "./Message.js";
4
+ export { MessageList } from "./MessageList.js";
5
+ export { Composer } from "./Composer.js";
6
+ export { StatusBar } from "./StatusBar.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/optima-agent",
3
- "version": "0.4.17",
3
+ "version": "0.4.18",
4
4
  "description": "基于 Claude Agent SDK 的电商运营 AI 助手",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",