session-trail 0.3.1__tar.gz → 0.3.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.
- {session_trail-0.3.1/src/session_trail.egg-info → session_trail-0.3.3}/PKG-INFO +14 -5
- {session_trail-0.3.1 → session_trail-0.3.3}/README.en.md +9 -4
- {session_trail-0.3.1 → session_trail-0.3.3}/README.md +9 -4
- {session_trail-0.3.1 → session_trail-0.3.3}/pyproject.toml +5 -1
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/codebuddy.py +25 -5
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/kimi_code.py +2 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/minimax_code.py +2 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/zcode.py +2 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/cli.py +21 -7
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/launcher.py +3 -1
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/tray/app.py +224 -10
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/watcher.py +4 -1
- {session_trail-0.3.1 → session_trail-0.3.3/src/session_trail.egg-info}/PKG-INFO +14 -5
- {session_trail-0.3.1 → session_trail-0.3.3}/src/session_trail.egg-info/SOURCES.txt +1 -0
- session_trail-0.3.3/src/session_trail.egg-info/requires.txt +5 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/LICENSE +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/MANIFEST.in +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/setup.cfg +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/__init__.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/__main__.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/__init__.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/base.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/claude_code.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/codex.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/deepseek_harness.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/jsonl_utils.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/opencode.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/pi.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/adapters/sqlite_utils.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/models.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/scanner.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/server.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/static/app.js +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/static/i18n.js +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/static/index.html +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/static/styles.css +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/store.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/tray/__init__.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/tray/desktop.template +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/tray/icon.png +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/agent_trail/tray/sni.py +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/session_trail.egg-info/dependency_links.txt +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/session_trail.egg-info/entry_points.txt +0 -0
- {session_trail-0.3.1 → session_trail-0.3.3}/src/session_trail.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: session-trail
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Local cross-agent work timeline: discover, browse and resume coding-agent sessions on your machine
|
|
5
5
|
Author: fwt11
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,6 +24,10 @@ Classifier: Topic :: Software Development
|
|
|
24
24
|
Requires-Python: >=3.10
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
|
+
Provides-Extra: tray
|
|
28
|
+
Requires-Dist: pystray>=0.19; extra == "tray"
|
|
29
|
+
Requires-Dist: Pillow>=9.0; extra == "tray"
|
|
30
|
+
Requires-Dist: pywebview>=5.0; extra == "tray"
|
|
27
31
|
Dynamic: license-file
|
|
28
32
|
|
|
29
33
|
# Agent 足迹(agent-trail)
|
|
@@ -55,7 +59,7 @@ Dynamic: license-file
|
|
|
55
59
|
| 系统托盘 + 内嵌窗口 | ✅(原生 SNI + WebKit2GTK) | 规划中 | 规划中 |
|
|
56
60
|
| 回到原会话(已验证工具) | ✅ | 取决于该 Agent 的 CLI 是否存在 | 同左 |
|
|
57
61
|
|
|
58
|
-
数据目录路径:开源工具的 Windows/macOS 路径已按其源码/官方文档确认——Codex(`dirs::home_dir()/.codex`,全平台同布局)、Claude Code(`%USERPROFILE%/.claude`)、OpenCode(Windows = `%LOCALAPPDATA%/opencode`,macOS 同 Linux)、Pi(`~/.pi/agent` 全平台一致);三者并尊重各自的官方覆盖变量(`CODEX_HOME` / `CLAUDE_CONFIG_DIR` / `OPENCODE_DATA
|
|
62
|
+
数据目录路径:开源工具的 Windows/macOS 路径已按其源码/官方文档确认——Codex(`dirs::home_dir()/.codex`,全平台同布局)、Claude Code(`%USERPROFILE%/.claude`)、OpenCode(Windows = `%LOCALAPPDATA%/opencode`,macOS 同 Linux)、Pi(`~/.pi/agent` 全平台一致);三者并尊重各自的官方覆盖变量(`CODEX_HOME` / `CLAUDE_CONFIG_DIR` / `OPENCODE_DATA`)。闭源五家已在真机 Windows 上用快照对比实测:Kimi Code、ZCode、MiniMax Code 的目录与 Linux 完全一致(适配器直接可用);DeepSeek 在 Windows 是 desktop 版,仅 `.dsh/storages` 子集可用;CodeBuddy 的 Windows 产品(CodeBuddy CN)改用 `%LOCALAPPDATA%/CodeBuddyExtension/Data` 存储,暂不支持。
|
|
59
63
|
|
|
60
64
|
## 支持的 Agent
|
|
61
65
|
|
|
@@ -119,13 +123,18 @@ agent-trail tray --install # 手动写入应用菜单入口;--uninstall 反
|
|
|
119
123
|
|
|
120
124
|
pip 安装后首次运行 `agent-trail tray` 会自动把"Agent 足迹"注册进系统应用菜单(应用启动器可直接搜索到)。Deepin 的自启动加载器会劫持指向 Python 脚本的 Exec 强制用系统解释器执行,故自启条目以 `/bin/sh -c exec` 包装规避"Agent 足迹"注册进系统应用菜单(应用启动器可直接搜索到),之后升级换路径也会自动刷新;无桌面会话(SSH/服务器)不写入。
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
托盘分两个后端:
|
|
127
|
+
|
|
128
|
+
- **Linux**:原生 SNI + WebKit2GTK(系统 Python 的 GI 绑定,无 pip 依赖)。当前解释器缺 GI 时自动重执行到系统 Python;缺绑定时 `sudo apt install python3-gi gir1.2-webkit2-4.1`
|
|
129
|
+
- **Windows/macOS**:pystray + pywebview 实现,装可选依赖即可:
|
|
123
130
|
|
|
124
131
|
```bash
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
pip install "session-trail[tray]"
|
|
133
|
+
agent-trail tray # 自动后台运行(Windows 经 pythonw 脱离终端)
|
|
127
134
|
```
|
|
128
135
|
|
|
136
|
+
Windows 自启动写注册表 HKCU Run 键;后台运行经 pythonw 脱离终端。注意 Windows 上 CodeBuddy(CN 桌面版)的会话存储格式不同,暂不支持该来源。
|
|
137
|
+
|
|
129
138
|
`agent-trail tray` 默认脱离终端后台运行:命令立即返回,日志追加在 `~/.agent-trail/tray.log`,关闭终端不影响托盘;`--foreground` 可前台运行调试。托盘以子进程方式管理 `agent-trail serve`——**启动托盘即自动拉起服务**(菜单里可停止/启动,异常退出自动重启)。窗口直接关闭只是隐藏,退出走托盘菜单,或 `kill $(cat ~/.agent-trail/tray.lock)`;flock 单实例锁防止重复启动(重复执行会提示"已在运行")。
|
|
130
139
|
|
|
131
140
|
托盘图标走原生 StatusNotifierItem/DBusMenu 协议(`agent_trail/tray/sni.py`,Gio 实现——libayatana 在 Deepin 23 的托盘守护上不工作,详见源码注释)。内嵌 WebView 默认使用软件合成(`WEBKIT_DISABLE_DMABUF_RENDERER` / `WEBKIT_DISABLE_COMPOSITING_MODE`,可用同名环境变量覆盖),避免在无 DRM 权限的会话里出现空白窗口。`serve` 的所有命令行形态保持不变,无托盘环境(SSH/无桌面)不受影响。
|
|
@@ -26,7 +26,7 @@ A local-first work memory for people who use multiple coding agents: it discover
|
|
|
26
26
|
| System tray + embedded window | ✅ (native SNI + WebKit2GTK) | planned | planned |
|
|
27
27
|
| Resume original session (verified tools) | ✅ | depends on each agent's CLI availability | same |
|
|
28
28
|
|
|
29
|
-
Data paths: Windows/macOS locations for the open-source CLIs are confirmed from their sources/docs — Codex (`dirs::home_dir()/.codex`, same layout everywhere), Claude Code (`%USERPROFILE%/.claude`), OpenCode (Windows = `%LOCALAPPDATA%/opencode`, macOS same as Linux), Pi (`~/.pi/agent` everywhere); the adapters also honor their official override vars (`CODEX_HOME` / `CLAUDE_CONFIG_DIR` / `OPENCODE_DATA`).
|
|
29
|
+
Data paths: Windows/macOS locations for the open-source CLIs are confirmed from their sources/docs — Codex (`dirs::home_dir()/.codex`, same layout everywhere), Claude Code (`%USERPROFILE%/.claude`), OpenCode (Windows = `%LOCALAPPDATA%/opencode`, macOS same as Linux), Pi (`~/.pi/agent` everywhere); the adapters also honor their official override vars (`CODEX_HOME` / `CLAUDE_CONFIG_DIR` / `OPENCODE_DATA`). Closed-source tools were verified on a real Windows machine via snapshot diffing: Kimi Code, ZCode and MiniMax Code use the exact same layout as Linux (adapters work as-is); DeepSeek on Windows is a desktop product where only the `.dsh/storages` subset applies; CodeBuddy CN stores sessions under `%LOCALAPPDATA%/CodeBuddyExtension/Data` and is not supported yet.
|
|
30
30
|
|
|
31
31
|
## Supported agents
|
|
32
32
|
|
|
@@ -90,13 +90,18 @@ agent-trail tray --install # manually add an applications-menu entry; --uninst
|
|
|
90
90
|
|
|
91
91
|
The first `agent-trail tray` run after pip install automatically registers "Agent Trail" in the desktop applications menu (searchable from your launcher) and refreshes it on upgrades; headless sessions (SSH/servers) write nothing. Deepin's autostart launcher forces Python-script Exec entries through the system interpreter, so the entry is wrapped as `/bin/sh -c exec '<path>' tray` to keep the venv shebang working.
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
Two backends:
|
|
94
|
+
|
|
95
|
+
- **Linux**: native SNI + WebKit2GTK via system GI bindings. If the interpreter running agent-trail lacks them, the CLI re-executes with a system Python automatically; otherwise `sudo apt install python3-gi gir1.2-webkit2-4.1`
|
|
96
|
+
- **Windows/macOS**: pystray + pywebview via an optional extra:
|
|
94
97
|
|
|
95
98
|
```bash
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
pip install "session-trail[tray]"
|
|
100
|
+
agent-trail tray # detaches to the background (pythonw on Windows)
|
|
98
101
|
```
|
|
99
102
|
|
|
103
|
+
Windows launch-at-login writes the HKCU Run registry key; background mode relaunches through pythonw. Note CodeBuddy's Windows product (CN desktop IDE) stores sessions elsewhere and is not supported as a source yet.
|
|
104
|
+
|
|
100
105
|
`agent-trail tray` detaches from the terminal by default: the command returns immediately, logs append to `~/.agent-trail/tray.log`, and closing the terminal does not affect the tray; use `--foreground` to debug in the foreground. The tray manages `agent-trail serve` as a subprocess — **starting the tray starts the service** (stop/start from the menu; automatic restart with backoff if it dies). Closing the window only hides it; quit lives in the tray menu, or `kill $(cat ~/.agent-trail/tray.lock)`. A flock single-instance lock prevents duplicates (a second invocation prints "already running").
|
|
101
106
|
|
|
102
107
|
The tray icon speaks the native StatusNotifierItem/DBusMenu protocol (`agent_trail/tray/sni.py`, implemented with Gio — libayatana does not work against Deepin 23's tray daemon; see source comments). The embedded WebView defaults to software compositing (`WEBKIT_DISABLE_DMABUF_RENDERER` / `WEBKIT_DISABLE_COMPOSITING_MODE`, overridable via env), avoiding blank windows on sessions without DRM access. All `serve`/CLI forms keep working without a desktop.
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
| 系统托盘 + 内嵌窗口 | ✅(原生 SNI + WebKit2GTK) | 规划中 | 规划中 |
|
|
28
28
|
| 回到原会话(已验证工具) | ✅ | 取决于该 Agent 的 CLI 是否存在 | 同左 |
|
|
29
29
|
|
|
30
|
-
数据目录路径:开源工具的 Windows/macOS 路径已按其源码/官方文档确认——Codex(`dirs::home_dir()/.codex`,全平台同布局)、Claude Code(`%USERPROFILE%/.claude`)、OpenCode(Windows = `%LOCALAPPDATA%/opencode`,macOS 同 Linux)、Pi(`~/.pi/agent` 全平台一致);三者并尊重各自的官方覆盖变量(`CODEX_HOME` / `CLAUDE_CONFIG_DIR` / `OPENCODE_DATA
|
|
30
|
+
数据目录路径:开源工具的 Windows/macOS 路径已按其源码/官方文档确认——Codex(`dirs::home_dir()/.codex`,全平台同布局)、Claude Code(`%USERPROFILE%/.claude`)、OpenCode(Windows = `%LOCALAPPDATA%/opencode`,macOS 同 Linux)、Pi(`~/.pi/agent` 全平台一致);三者并尊重各自的官方覆盖变量(`CODEX_HOME` / `CLAUDE_CONFIG_DIR` / `OPENCODE_DATA`)。闭源五家已在真机 Windows 上用快照对比实测:Kimi Code、ZCode、MiniMax Code 的目录与 Linux 完全一致(适配器直接可用);DeepSeek 在 Windows 是 desktop 版,仅 `.dsh/storages` 子集可用;CodeBuddy 的 Windows 产品(CodeBuddy CN)改用 `%LOCALAPPDATA%/CodeBuddyExtension/Data` 存储,暂不支持。
|
|
31
31
|
|
|
32
32
|
## 支持的 Agent
|
|
33
33
|
|
|
@@ -91,13 +91,18 @@ agent-trail tray --install # 手动写入应用菜单入口;--uninstall 反
|
|
|
91
91
|
|
|
92
92
|
pip 安装后首次运行 `agent-trail tray` 会自动把"Agent 足迹"注册进系统应用菜单(应用启动器可直接搜索到)。Deepin 的自启动加载器会劫持指向 Python 脚本的 Exec 强制用系统解释器执行,故自启条目以 `/bin/sh -c exec` 包装规避"Agent 足迹"注册进系统应用菜单(应用启动器可直接搜索到),之后升级换路径也会自动刷新;无桌面会话(SSH/服务器)不写入。
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
托盘分两个后端:
|
|
95
|
+
|
|
96
|
+
- **Linux**:原生 SNI + WebKit2GTK(系统 Python 的 GI 绑定,无 pip 依赖)。当前解释器缺 GI 时自动重执行到系统 Python;缺绑定时 `sudo apt install python3-gi gir1.2-webkit2-4.1`
|
|
97
|
+
- **Windows/macOS**:pystray + pywebview 实现,装可选依赖即可:
|
|
95
98
|
|
|
96
99
|
```bash
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
pip install "session-trail[tray]"
|
|
101
|
+
agent-trail tray # 自动后台运行(Windows 经 pythonw 脱离终端)
|
|
99
102
|
```
|
|
100
103
|
|
|
104
|
+
Windows 自启动写注册表 HKCU Run 键;后台运行经 pythonw 脱离终端。注意 Windows 上 CodeBuddy(CN 桌面版)的会话存储格式不同,暂不支持该来源。
|
|
105
|
+
|
|
101
106
|
`agent-trail tray` 默认脱离终端后台运行:命令立即返回,日志追加在 `~/.agent-trail/tray.log`,关闭终端不影响托盘;`--foreground` 可前台运行调试。托盘以子进程方式管理 `agent-trail serve`——**启动托盘即自动拉起服务**(菜单里可停止/启动,异常退出自动重启)。窗口直接关闭只是隐藏,退出走托盘菜单,或 `kill $(cat ~/.agent-trail/tray.lock)`;flock 单实例锁防止重复启动(重复执行会提示"已在运行")。
|
|
102
107
|
|
|
103
108
|
托盘图标走原生 StatusNotifierItem/DBusMenu 协议(`agent_trail/tray/sni.py`,Gio 实现——libayatana 在 Deepin 23 的托盘守护上不工作,详见源码注释)。内嵌 WebView 默认使用软件合成(`WEBKIT_DISABLE_DMABUF_RENDERER` / `WEBKIT_DISABLE_COMPOSITING_MODE`,可用同名环境变量覆盖),避免在无 DRM 权限的会话里出现空白窗口。`serve` 的所有命令行形态保持不变,无托盘环境(SSH/无桌面)不受影响。
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "session-trail"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.3"
|
|
8
8
|
description = "Local cross-agent work timeline: discover, browse and resume coding-agent sessions on your machine"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -34,6 +34,10 @@ Homepage = "https://github.com/fwt11/agent_trail"
|
|
|
34
34
|
Repository = "https://github.com/fwt11/agent_trail"
|
|
35
35
|
Issues = "https://github.com/fwt11/agent_trail/issues"
|
|
36
36
|
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
# Linux 托盘用系统 GI(无需 extras);Windows/macOS 托盘用这组
|
|
39
|
+
tray = ["pystray>=0.19", "Pillow>=9.0", "pywebview>=5.0"]
|
|
40
|
+
|
|
37
41
|
[project.scripts]
|
|
38
42
|
agent-trail = "agent_trail.cli:main"
|
|
39
43
|
|
|
@@ -2,15 +2,26 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
5
6
|
|
|
6
7
|
from ..models import ActivitySession, AdapterStatus, ResumePlan, ScanResult
|
|
7
8
|
from .base import BaseAdapter
|
|
8
9
|
from .jsonl_utils import fingerprint_paths, read_jsonl_metadata, to_utc_iso
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
def _latest_text(records: list[dict[str, Any]], record_type: str, field: str) -> str | None:
|
|
13
|
+
for record in reversed(records):
|
|
14
|
+
if record.get("type") != record_type:
|
|
15
|
+
continue
|
|
16
|
+
value = record.get(field)
|
|
17
|
+
if isinstance(value, str) and value.strip():
|
|
18
|
+
return value.strip()
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
|
|
11
22
|
class CodeBuddyAdapter(BaseAdapter):
|
|
12
23
|
source = "codebuddy"
|
|
13
|
-
adapter_version =
|
|
24
|
+
adapter_version = 2
|
|
14
25
|
|
|
15
26
|
@property
|
|
16
27
|
def projects_path(self) -> Path:
|
|
@@ -29,7 +40,11 @@ class CodeBuddyAdapter(BaseAdapter):
|
|
|
29
40
|
discovery = self.discover()
|
|
30
41
|
if discovery.kind == "unavailable":
|
|
31
42
|
return ScanResult(discovery, None, [], True)
|
|
32
|
-
paths =
|
|
43
|
+
paths = [
|
|
44
|
+
path
|
|
45
|
+
for path in self.projects_path.glob("**/*.jsonl")
|
|
46
|
+
if "subagents" not in path.relative_to(self.projects_path).parts
|
|
47
|
+
]
|
|
33
48
|
fingerprint = fingerprint_paths(paths, self.adapter_version)
|
|
34
49
|
if fingerprint == previous_fingerprint:
|
|
35
50
|
return ScanResult(
|
|
@@ -41,7 +56,9 @@ class CodeBuddyAdapter(BaseAdapter):
|
|
|
41
56
|
sessions: list[ActivitySession] = []
|
|
42
57
|
error_count = 0
|
|
43
58
|
for path in paths:
|
|
44
|
-
result = read_jsonl_metadata(
|
|
59
|
+
result = read_jsonl_metadata(
|
|
60
|
+
path, {"sessionId", "cwd", "timestamp", "type", "aiTitle", "summary"}
|
|
61
|
+
)
|
|
45
62
|
error_count += result.error_count
|
|
46
63
|
records = [item for item in result.records if item.get("timestamp") is not None]
|
|
47
64
|
if not records:
|
|
@@ -52,14 +69,17 @@ class CodeBuddyAdapter(BaseAdapter):
|
|
|
52
69
|
error_count += 1
|
|
53
70
|
continue
|
|
54
71
|
session_id = str(records[0].get("sessionId") or path.stem)
|
|
72
|
+
title = _latest_text(result.records, "ai-title", "aiTitle") or _latest_text(
|
|
73
|
+
result.records, "summary", "summary"
|
|
74
|
+
)
|
|
55
75
|
timestamps = [float(item["timestamp"]) for item in records]
|
|
56
76
|
sessions.append(
|
|
57
77
|
ActivitySession(
|
|
58
78
|
source=self.source,
|
|
59
79
|
session_id=session_id,
|
|
60
80
|
workdir=workdir,
|
|
61
|
-
title=
|
|
62
|
-
title_source="fallback",
|
|
81
|
+
title=title,
|
|
82
|
+
title_source="native" if title else "fallback",
|
|
63
83
|
created_at=to_utc_iso(min(timestamps)),
|
|
64
84
|
updated_at=to_utc_iso(max(timestamps)),
|
|
65
85
|
source_locator=str(path),
|
|
@@ -18,6 +18,8 @@ class MiniMaxCodeAdapter(BaseAdapter):
|
|
|
18
18
|
|
|
19
19
|
@property
|
|
20
20
|
def database_path(self) -> Path:
|
|
21
|
+
# Windows 已实测同布局(2026-11-08 用户机快照:runtime-state.sqlite-wal
|
|
22
|
+
# 在 ~/.minimax/v2/sqlite 下;另有 Linux 上没有的 v2/sessions/ 会话树)。
|
|
21
23
|
return self.home / ".minimax" / "v2" / "sqlite" / "runtime-state.sqlite"
|
|
22
24
|
|
|
23
25
|
def watch_roots(self) -> list[tuple[Path, bool]]:
|
|
@@ -14,7 +14,7 @@ from .models import SessionFilter
|
|
|
14
14
|
from .scanner import ScanService
|
|
15
15
|
from .server import LocalServer
|
|
16
16
|
from .store import LocalStore
|
|
17
|
-
from .watcher import
|
|
17
|
+
from .watcher import PollingWatcher, create_watcher
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def build_parser() -> argparse.ArgumentParser:
|
|
@@ -29,7 +29,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
29
29
|
serve.add_argument("--no-browser", action="store_true")
|
|
30
30
|
serve.add_argument("--interval", type=float, default=30)
|
|
31
31
|
serve.add_argument("--no-watch", action="store_true")
|
|
32
|
-
tray = commands.add_parser("tray", help="system tray app (Linux)")
|
|
32
|
+
tray = commands.add_parser("tray", help="system tray app (Linux native; Windows/macOS via [tray] extra)")
|
|
33
33
|
tray.add_argument("--show", action="store_true", help="open the console window at startup")
|
|
34
34
|
tray.add_argument("--foreground", action="store_true", help="run in the foreground (default: detach with logs in ~/.agent-trail/tray.log)")
|
|
35
35
|
tray.add_argument("--install", action="store_true", help="add an applications-menu entry")
|
|
@@ -86,24 +86,38 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
86
86
|
print(url, flush=True)
|
|
87
87
|
if not args.no_browser:
|
|
88
88
|
webbrowser.open(url)
|
|
89
|
-
watcher
|
|
89
|
+
watcher = None
|
|
90
90
|
if not args.no_watch:
|
|
91
91
|
roots: list[tuple[Path, bool]] = []
|
|
92
92
|
for adapter in adapters:
|
|
93
93
|
roots.extend(adapter.watch_roots())
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
# 工厂按平台分发:Linux=inotify,Windows/macOS=轮询。
|
|
95
|
+
# 不要直接构造 SourceWatcher——它依赖 POSIX 的
|
|
96
|
+
# ctypes.CDLL(None),在 Windows 上会 TypeError。
|
|
97
|
+
watcher = create_watcher(roots, on_change=scanner.scan_all)
|
|
98
|
+
if not watcher.start():
|
|
99
|
+
# 首选后端不可用(如 Linux 上 inotify 被禁):退到可移植
|
|
100
|
+
# 的轮询后端,再失败才降级为纯 --interval 轮询。
|
|
101
|
+
fallback = PollingWatcher(roots, on_change=scanner.scan_all)
|
|
102
|
+
if fallback.start():
|
|
103
|
+
watcher = fallback
|
|
104
|
+
if watcher is not None and watcher.healthy:
|
|
96
105
|
print(
|
|
97
106
|
json.dumps(
|
|
98
|
-
{
|
|
107
|
+
{
|
|
108
|
+
"event": "watch_started",
|
|
109
|
+
"kind": watcher.kind,
|
|
110
|
+
"watches": watcher.watch_count,
|
|
111
|
+
},
|
|
99
112
|
ensure_ascii=False,
|
|
100
113
|
),
|
|
101
114
|
flush=True,
|
|
102
115
|
)
|
|
103
116
|
else:
|
|
117
|
+
reason = watcher.last_error if watcher is not None else "unavailable"
|
|
104
118
|
print(
|
|
105
119
|
json.dumps(
|
|
106
|
-
{"event": "watch_unavailable", "reason":
|
|
120
|
+
{"event": "watch_unavailable", "reason": reason},
|
|
107
121
|
ensure_ascii=False,
|
|
108
122
|
),
|
|
109
123
|
flush=True,
|
|
@@ -24,9 +24,11 @@ class TerminalLauncher:
|
|
|
24
24
|
)
|
|
25
25
|
# Linux 检测列表;Windows/macOS 见 _terminals_for_platform()。
|
|
26
26
|
_terminals = (
|
|
27
|
+
# wezterm 不保证在 PATH 尾部,且 -e 与 `--` 不等价,故先于 x-terminal-emulator 探测。
|
|
28
|
+
("wezterm", ("start", "--cwd", "{workdir}", "--")),
|
|
29
|
+
# 部分发行版把 x-terminal-emulator 指向包装脚本,不兼容 -e。
|
|
27
30
|
("x-terminal-emulator", ("-e",)),
|
|
28
31
|
("gnome-terminal", ("--",)),
|
|
29
|
-
("wezterm", ("start", "--cwd", "{workdir}", "--")),
|
|
30
32
|
("konsole", ("-e",)),
|
|
31
33
|
("xfce4-terminal", ("-x",)),
|
|
32
34
|
("kitty", ("--",)),
|
|
@@ -15,7 +15,6 @@ TrayApp 是 GTK 胶水。Windows/macOS 后端(pystray + pywebview)预留为
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import argparse
|
|
18
|
-
import fcntl
|
|
19
18
|
import json
|
|
20
19
|
import os
|
|
21
20
|
import re
|
|
@@ -29,6 +28,28 @@ import urllib.error
|
|
|
29
28
|
import urllib.request
|
|
30
29
|
from pathlib import Path
|
|
31
30
|
|
|
31
|
+
if os.name == "posix":
|
|
32
|
+
import fcntl
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _lock_fd(fd: int) -> None:
|
|
36
|
+
"""阻塞式位置锁的平台分派(单实例检测用,非阻塞尝试)。"""
|
|
37
|
+
if os.name == "posix":
|
|
38
|
+
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
39
|
+
else:
|
|
40
|
+
import msvcrt
|
|
41
|
+
os.lseek(fd, 0, os.SEEK_SET)
|
|
42
|
+
msvcrt.locking(fd, msvcrt.LK_NBLCK, 1)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _unlock_fd(fd: int) -> None:
|
|
46
|
+
if os.name == "posix":
|
|
47
|
+
fcntl.flock(fd, fcntl.LOCK_UN)
|
|
48
|
+
else:
|
|
49
|
+
import msvcrt
|
|
50
|
+
os.lseek(fd, 0, os.SEEK_SET)
|
|
51
|
+
msvcrt.locking(fd, msvcrt.LK_UNLCK, 1)
|
|
52
|
+
|
|
32
53
|
def _detect_locale() -> str:
|
|
33
54
|
override = os.environ.get("AGENT_TRAIL_LANG")
|
|
34
55
|
if override:
|
|
@@ -359,6 +380,24 @@ def autostart_enabled(target: Path = AUTOSTART_PATH) -> bool:
|
|
|
359
380
|
def set_autostart(enabled: bool, executable: str, icon: Path,
|
|
360
381
|
target: Path = AUTOSTART_PATH,
|
|
361
382
|
template: Path = DESKTOP_TEMPLATE) -> None:
|
|
383
|
+
if sys.platform == "win32":
|
|
384
|
+
# Windows:写 HKCU Run 键(注册表自启),无 desktop 文件概念
|
|
385
|
+
import winreg
|
|
386
|
+
key_path = WINRUN_KEY
|
|
387
|
+
if enabled:
|
|
388
|
+
key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, key_path)
|
|
389
|
+
winreg.SetValueEx(key, WINRUN_NAME, 0, winreg.REG_SZ,
|
|
390
|
+
f'"{executable}" tray')
|
|
391
|
+
winreg.CloseKey(key)
|
|
392
|
+
else:
|
|
393
|
+
try:
|
|
394
|
+
key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path, 0,
|
|
395
|
+
winreg.KEY_SET_VALUE)
|
|
396
|
+
winreg.DeleteValue(key, WINRUN_NAME)
|
|
397
|
+
winreg.CloseKey(key)
|
|
398
|
+
except FileNotFoundError:
|
|
399
|
+
pass
|
|
400
|
+
return
|
|
362
401
|
if enabled:
|
|
363
402
|
target.parent.mkdir(parents=True, exist_ok=True)
|
|
364
403
|
target.write_text(render_desktop_entry(executable, icon, template), encoding="utf-8")
|
|
@@ -377,7 +416,7 @@ class SingleInstance:
|
|
|
377
416
|
self.path.parent.mkdir(parents=True, exist_ok=True)
|
|
378
417
|
self._fd = os.open(self.path, os.O_RDWR | os.O_CREAT, 0o600)
|
|
379
418
|
try:
|
|
380
|
-
|
|
419
|
+
_lock_fd(self._fd)
|
|
381
420
|
except (BlockingIOError, OSError):
|
|
382
421
|
os.close(self._fd)
|
|
383
422
|
self._fd = None
|
|
@@ -396,7 +435,7 @@ class SingleInstance:
|
|
|
396
435
|
def release(self) -> None:
|
|
397
436
|
if self._fd is not None:
|
|
398
437
|
try:
|
|
399
|
-
|
|
438
|
+
_unlock_fd(self._fd)
|
|
400
439
|
except OSError:
|
|
401
440
|
pass
|
|
402
441
|
os.close(self._fd)
|
|
@@ -560,6 +599,149 @@ def run_gtk(icon_path: Path, show: bool = False) -> int:
|
|
|
560
599
|
return 0
|
|
561
600
|
|
|
562
601
|
|
|
602
|
+
def run_web(icon_path: Path, show: bool = False) -> int:
|
|
603
|
+
"""pystray(托盘)+ pywebview(内嵌窗口)后端(Windows/macOS)。"""
|
|
604
|
+
try:
|
|
605
|
+
import pystray
|
|
606
|
+
import webview
|
|
607
|
+
from PIL import Image
|
|
608
|
+
except ImportError as error:
|
|
609
|
+
print(
|
|
610
|
+
tr("error.tray_extra") + "\n"
|
|
611
|
+
' pip install "session-trail[tray]"\n'
|
|
612
|
+
+ tr("error.original", error=error),
|
|
613
|
+
file=sys.stderr,
|
|
614
|
+
)
|
|
615
|
+
return 1
|
|
616
|
+
|
|
617
|
+
icon_image = Image.open(icon_path)
|
|
618
|
+
|
|
619
|
+
class WebTrayApp:
|
|
620
|
+
"""与 Linux 版 TrayApp 同一套菜单/行为契约,pystray + pywebview 实现。"""
|
|
621
|
+
|
|
622
|
+
def __init__(self) -> None:
|
|
623
|
+
self.core = TrailCore(on_event=self._on_core_event)
|
|
624
|
+
self.console_window = None
|
|
625
|
+
self.pending_open = show
|
|
626
|
+
|
|
627
|
+
self.icon = pystray.Icon(
|
|
628
|
+
"agent-trail",
|
|
629
|
+
icon_image,
|
|
630
|
+
tr("app.title"),
|
|
631
|
+
pystray.Menu(
|
|
632
|
+
pystray.MenuItem(self._status_text, None, enabled=False),
|
|
633
|
+
pystray.MenuItem(tr("menu.open"), self.open_console,
|
|
634
|
+
enabled=lambda *a: self.core.state == "running"),
|
|
635
|
+
pystray.MenuItem(tr("menu.refresh"), self.refresh_now,
|
|
636
|
+
enabled=lambda *a: self.core.state == "running"),
|
|
637
|
+
pystray.Menu.SEPARATOR,
|
|
638
|
+
pystray.MenuItem(self._service_text, self.toggle_service,
|
|
639
|
+
enabled=lambda *a: self.core.available),
|
|
640
|
+
pystray.MenuItem(tr("menu.autostart"), self.toggle_autostart,
|
|
641
|
+
checked=lambda *a: autostart_enabled()),
|
|
642
|
+
pystray.Menu.SEPARATOR,
|
|
643
|
+
pystray.MenuItem(tr("menu.quit"), self.quit),
|
|
644
|
+
),
|
|
645
|
+
)
|
|
646
|
+
|
|
647
|
+
# -- pystray 动态文案(菜单打开时求值)--------------------------------
|
|
648
|
+
def _status_text(self, icon, item):
|
|
649
|
+
core = self.core
|
|
650
|
+
if not core.available:
|
|
651
|
+
return tr("status.no_agent")
|
|
652
|
+
if core.state == "running":
|
|
653
|
+
return tr("status.running", port=core.port)
|
|
654
|
+
if core.state == "starting":
|
|
655
|
+
return tr("status.starting")
|
|
656
|
+
if core.state == "crashed":
|
|
657
|
+
return tr("status.crashed", n=core.max_restarts)
|
|
658
|
+
return tr("status.stopped")
|
|
659
|
+
|
|
660
|
+
def _service_text(self, icon, item):
|
|
661
|
+
return tr("menu.stop") if self.core.process is not None else tr("menu.start")
|
|
662
|
+
|
|
663
|
+
# -- 动作 -------------------------------------------------------------
|
|
664
|
+
def open_console(self, *args):
|
|
665
|
+
if self.core.state == "running" and self.core.url:
|
|
666
|
+
self.show_window(self.core.url)
|
|
667
|
+
elif self.core.available:
|
|
668
|
+
self.pending_open = True
|
|
669
|
+
if self.core.state != "starting":
|
|
670
|
+
self.core.start()
|
|
671
|
+
|
|
672
|
+
def show_window(self, url):
|
|
673
|
+
if self.console_window is None:
|
|
674
|
+
self.console_window = webview.create_window(
|
|
675
|
+
tr("app.title"), url=url, width=1280, height=820)
|
|
676
|
+
self.console_window.events.closed += self._console_closed
|
|
677
|
+
else:
|
|
678
|
+
self.console_window.load_url(url)
|
|
679
|
+
self.console_window.show()
|
|
680
|
+
|
|
681
|
+
def _console_closed(self):
|
|
682
|
+
self.console_window = None
|
|
683
|
+
|
|
684
|
+
def toggle_service(self, *args):
|
|
685
|
+
if self.core.process is not None:
|
|
686
|
+
self.core.stop()
|
|
687
|
+
else:
|
|
688
|
+
self.core.start()
|
|
689
|
+
|
|
690
|
+
def toggle_autostart(self, *args):
|
|
691
|
+
set_autostart(not autostart_enabled(), self._agent_trail_bin(), icon_path)
|
|
692
|
+
|
|
693
|
+
def refresh_now(self, *args):
|
|
694
|
+
def worker():
|
|
695
|
+
self.core.refresh()
|
|
696
|
+
if self.core.state == "running" and self.console_window is not None:
|
|
697
|
+
try:
|
|
698
|
+
self.console_window.load_url(self.core.url)
|
|
699
|
+
except Exception:
|
|
700
|
+
pass
|
|
701
|
+
threading.Thread(target=worker, name="tray-refresh", daemon=True).start()
|
|
702
|
+
|
|
703
|
+
def quit(self, *args):
|
|
704
|
+
self.core.stop()
|
|
705
|
+
try:
|
|
706
|
+
self.icon.stop()
|
|
707
|
+
except Exception:
|
|
708
|
+
pass
|
|
709
|
+
for window in list(webview.windows):
|
|
710
|
+
try:
|
|
711
|
+
window.destroy()
|
|
712
|
+
except Exception:
|
|
713
|
+
pass
|
|
714
|
+
threading.Timer(2.0, lambda: os._exit(0)).start() # 循环卡死的兜底
|
|
715
|
+
|
|
716
|
+
@staticmethod
|
|
717
|
+
def _agent_trail_bin() -> str:
|
|
718
|
+
return shutil.which("agent-trail") or sys.argv[0]
|
|
719
|
+
|
|
720
|
+
# -- 核心事件(子线程触发;pywebview 的窗口操作内部自带跨线程代理)------
|
|
721
|
+
def _on_core_event(self, event):
|
|
722
|
+
if event.get("event") != "running":
|
|
723
|
+
return
|
|
724
|
+
url = event["url"]
|
|
725
|
+
if self.pending_open:
|
|
726
|
+
self.pending_open = False
|
|
727
|
+
try:
|
|
728
|
+
self.show_window(url)
|
|
729
|
+
except Exception:
|
|
730
|
+
pass
|
|
731
|
+
elif self.console_window is not None:
|
|
732
|
+
try:
|
|
733
|
+
self.console_window.load_url(url)
|
|
734
|
+
except Exception:
|
|
735
|
+
pass
|
|
736
|
+
|
|
737
|
+
app = WebTrayApp()
|
|
738
|
+
app.core.start() # 托盘启动即拉起服务
|
|
739
|
+
if show:
|
|
740
|
+
app.pending_open = True
|
|
741
|
+
webview.start()
|
|
742
|
+
return 0
|
|
743
|
+
|
|
744
|
+
|
|
563
745
|
# -- 入口 --------------------------------------------------------------------
|
|
564
746
|
|
|
565
747
|
|
|
@@ -623,6 +805,11 @@ def _reexec_with_system_python(argv: list[str], guard: "SingleInstance | None" =
|
|
|
623
805
|
|
|
624
806
|
|
|
625
807
|
def main(argv: list[str] | None = None) -> int:
|
|
808
|
+
# pythonw(无控制台)下 stdout/stderr 是 None,print 会炸——接到日志文件
|
|
809
|
+
if sys.stdout is None:
|
|
810
|
+
sys.stdout = open(LOG_PATH, "a", encoding="utf-8", errors="replace")
|
|
811
|
+
if sys.stderr is None:
|
|
812
|
+
sys.stderr = open(LOG_PATH, "a", encoding="utf-8", errors="replace")
|
|
626
813
|
replay = list(argv) if argv is not None else sys.argv[1:]
|
|
627
814
|
parser = argparse.ArgumentParser(prog="agent-trail tray", description=f"{tr('app.title')} tray")
|
|
628
815
|
parser.add_argument("--install", action="store_true", help="写入应用菜单入口")
|
|
@@ -647,6 +834,22 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
647
834
|
if not ICON_PATH.is_file():
|
|
648
835
|
print(tr("error.no_icon", path=ICON_PATH), file=sys.stderr)
|
|
649
836
|
return 1
|
|
837
|
+
if sys.platform == "win32" and not args.foreground:
|
|
838
|
+
# Windows 后台运行:用 pythonw 重启自己(无控制台窗口),父进程立即退出
|
|
839
|
+
pre = SingleInstance()
|
|
840
|
+
if not pre.acquire():
|
|
841
|
+
print(tr("error.already_running"), flush=True)
|
|
842
|
+
return 0
|
|
843
|
+
pre.release() # 锁让给 pythonw 子进程
|
|
844
|
+
pythonw = Path(sys.executable).with_name("pythonw.exe")
|
|
845
|
+
if pythonw.is_file():
|
|
846
|
+
DETACHED_PROCESS, CREATE_NO_WINDOW = 0x00000008, 0x08000000
|
|
847
|
+
subprocess.Popen(
|
|
848
|
+
[str(pythonw), "-m", "agent_trail", "tray", *replay, "--foreground"],
|
|
849
|
+
creationflags=DETACHED_PROCESS | CREATE_NO_WINDOW, close_fds=True,
|
|
850
|
+
)
|
|
851
|
+
return 0
|
|
852
|
+
# 没有 pythonw → 前台运行
|
|
650
853
|
ensure_desktop_entry()
|
|
651
854
|
# 锁在前台获取:重复启动时提示直接出现在用户终端;fd 由守护进程继承
|
|
652
855
|
guard = SingleInstance()
|
|
@@ -656,16 +859,27 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
656
859
|
if not args.foreground and not _daemonize(LOG_PATH):
|
|
657
860
|
return 0 # 父进程:立即把终端还给用户;托盘在后台继续
|
|
658
861
|
guard.rewrite_pid() # 锁文件写守护进程的 pid,kill $(cat 锁文件) 才有效
|
|
862
|
+
if sys.platform == "linux":
|
|
863
|
+
try:
|
|
864
|
+
return run_gtk(ICON_PATH, show=args.show)
|
|
865
|
+
except (ImportError, ValueError) as error:
|
|
866
|
+
code = _reexec_with_system_python(replay, guard)
|
|
867
|
+
if code is not None:
|
|
868
|
+
return code
|
|
869
|
+
print(
|
|
870
|
+
tr("error.no_gi") + "\n"
|
|
871
|
+
" Debian/Ubuntu/deepin: sudo apt install python3-gi "
|
|
872
|
+
"gir1.2-webkit2-4.1\n"
|
|
873
|
+
+ tr("error.original", error=error),
|
|
874
|
+
file=sys.stderr,
|
|
875
|
+
)
|
|
876
|
+
return 1
|
|
659
877
|
try:
|
|
660
|
-
return
|
|
878
|
+
return run_web(ICON_PATH, show=args.show)
|
|
661
879
|
except (ImportError, ValueError) as error:
|
|
662
|
-
code = _reexec_with_system_python(replay, guard)
|
|
663
|
-
if code is not None:
|
|
664
|
-
return code
|
|
665
880
|
print(
|
|
666
|
-
tr("error.
|
|
667
|
-
"
|
|
668
|
-
"gir1.2-webkit2-4.1\n"
|
|
881
|
+
tr("error.tray_extra") + "\n"
|
|
882
|
+
" pip install \"session-trail[tray]\"\n"
|
|
669
883
|
+ tr("error.original", error=error),
|
|
670
884
|
file=sys.stderr,
|
|
671
885
|
)
|
|
@@ -61,6 +61,9 @@ class LibcInotify:
|
|
|
61
61
|
|
|
62
62
|
def __init__(self) -> None:
|
|
63
63
|
self.libc: ctypes.CDLL | None = None
|
|
64
|
+
if not sys.platform.startswith("linux"):
|
|
65
|
+
# dlopen(None) 是 POSIX 约定;Windows 上 CDLL(None) 直接 TypeError
|
|
66
|
+
return
|
|
64
67
|
try:
|
|
65
68
|
libc = ctypes.CDLL(None, use_errno=True)
|
|
66
69
|
self.inotify_init1 = libc.inotify_init1
|
|
@@ -77,7 +80,7 @@ class LibcInotify:
|
|
|
77
80
|
self.inotify_rm_watch.argtypes = [ctypes.c_int, ctypes.c_int]
|
|
78
81
|
self.inotify_rm_watch.restype = ctypes.c_int
|
|
79
82
|
self.libc = libc
|
|
80
|
-
except (OSError, AttributeError):
|
|
83
|
+
except (OSError, AttributeError, TypeError):
|
|
81
84
|
self.libc = None
|
|
82
85
|
|
|
83
86
|
@property
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: session-trail
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.3
|
|
4
4
|
Summary: Local cross-agent work timeline: discover, browse and resume coding-agent sessions on your machine
|
|
5
5
|
Author: fwt11
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,6 +24,10 @@ Classifier: Topic :: Software Development
|
|
|
24
24
|
Requires-Python: >=3.10
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
License-File: LICENSE
|
|
27
|
+
Provides-Extra: tray
|
|
28
|
+
Requires-Dist: pystray>=0.19; extra == "tray"
|
|
29
|
+
Requires-Dist: Pillow>=9.0; extra == "tray"
|
|
30
|
+
Requires-Dist: pywebview>=5.0; extra == "tray"
|
|
27
31
|
Dynamic: license-file
|
|
28
32
|
|
|
29
33
|
# Agent 足迹(agent-trail)
|
|
@@ -55,7 +59,7 @@ Dynamic: license-file
|
|
|
55
59
|
| 系统托盘 + 内嵌窗口 | ✅(原生 SNI + WebKit2GTK) | 规划中 | 规划中 |
|
|
56
60
|
| 回到原会话(已验证工具) | ✅ | 取决于该 Agent 的 CLI 是否存在 | 同左 |
|
|
57
61
|
|
|
58
|
-
数据目录路径:开源工具的 Windows/macOS 路径已按其源码/官方文档确认——Codex(`dirs::home_dir()/.codex`,全平台同布局)、Claude Code(`%USERPROFILE%/.claude`)、OpenCode(Windows = `%LOCALAPPDATA%/opencode`,macOS 同 Linux)、Pi(`~/.pi/agent` 全平台一致);三者并尊重各自的官方覆盖变量(`CODEX_HOME` / `CLAUDE_CONFIG_DIR` / `OPENCODE_DATA
|
|
62
|
+
数据目录路径:开源工具的 Windows/macOS 路径已按其源码/官方文档确认——Codex(`dirs::home_dir()/.codex`,全平台同布局)、Claude Code(`%USERPROFILE%/.claude`)、OpenCode(Windows = `%LOCALAPPDATA%/opencode`,macOS 同 Linux)、Pi(`~/.pi/agent` 全平台一致);三者并尊重各自的官方覆盖变量(`CODEX_HOME` / `CLAUDE_CONFIG_DIR` / `OPENCODE_DATA`)。闭源五家已在真机 Windows 上用快照对比实测:Kimi Code、ZCode、MiniMax Code 的目录与 Linux 完全一致(适配器直接可用);DeepSeek 在 Windows 是 desktop 版,仅 `.dsh/storages` 子集可用;CodeBuddy 的 Windows 产品(CodeBuddy CN)改用 `%LOCALAPPDATA%/CodeBuddyExtension/Data` 存储,暂不支持。
|
|
59
63
|
|
|
60
64
|
## 支持的 Agent
|
|
61
65
|
|
|
@@ -119,13 +123,18 @@ agent-trail tray --install # 手动写入应用菜单入口;--uninstall 反
|
|
|
119
123
|
|
|
120
124
|
pip 安装后首次运行 `agent-trail tray` 会自动把"Agent 足迹"注册进系统应用菜单(应用启动器可直接搜索到)。Deepin 的自启动加载器会劫持指向 Python 脚本的 Exec 强制用系统解释器执行,故自启条目以 `/bin/sh -c exec` 包装规避"Agent 足迹"注册进系统应用菜单(应用启动器可直接搜索到),之后升级换路径也会自动刷新;无桌面会话(SSH/服务器)不写入。
|
|
121
125
|
|
|
122
|
-
|
|
126
|
+
托盘分两个后端:
|
|
127
|
+
|
|
128
|
+
- **Linux**:原生 SNI + WebKit2GTK(系统 Python 的 GI 绑定,无 pip 依赖)。当前解释器缺 GI 时自动重执行到系统 Python;缺绑定时 `sudo apt install python3-gi gir1.2-webkit2-4.1`
|
|
129
|
+
- **Windows/macOS**:pystray + pywebview 实现,装可选依赖即可:
|
|
123
130
|
|
|
124
131
|
```bash
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
pip install "session-trail[tray]"
|
|
133
|
+
agent-trail tray # 自动后台运行(Windows 经 pythonw 脱离终端)
|
|
127
134
|
```
|
|
128
135
|
|
|
136
|
+
Windows 自启动写注册表 HKCU Run 键;后台运行经 pythonw 脱离终端。注意 Windows 上 CodeBuddy(CN 桌面版)的会话存储格式不同,暂不支持该来源。
|
|
137
|
+
|
|
129
138
|
`agent-trail tray` 默认脱离终端后台运行:命令立即返回,日志追加在 `~/.agent-trail/tray.log`,关闭终端不影响托盘;`--foreground` 可前台运行调试。托盘以子进程方式管理 `agent-trail serve`——**启动托盘即自动拉起服务**(菜单里可停止/启动,异常退出自动重启)。窗口直接关闭只是隐藏,退出走托盘菜单,或 `kill $(cat ~/.agent-trail/tray.lock)`;flock 单实例锁防止重复启动(重复执行会提示"已在运行")。
|
|
130
139
|
|
|
131
140
|
托盘图标走原生 StatusNotifierItem/DBusMenu 协议(`agent_trail/tray/sni.py`,Gio 实现——libayatana 在 Deepin 23 的托盘守护上不工作,详见源码注释)。内嵌 WebView 默认使用软件合成(`WEBKIT_DISABLE_DMABUF_RENDERER` / `WEBKIT_DISABLE_COMPOSITING_MODE`,可用同名环境变量覆盖),避免在无 DRM 权限的会话里出现空白窗口。`serve` 的所有命令行形态保持不变,无托盘环境(SSH/无桌面)不受影响。
|
|
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
|