4794de398ea8337d223a91e207181c56fcf4ad76
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a3f2097ede |
sessions: CodeBuddy Code's own calls reach Usage, read from its session files as WorkBuddy's are, and its calls through magpie's gateway are left to the gateway (#1779)
CodeBuddy Code was wired on the Agents page, but nothing read its session files, so a call it made straight to its vendor never reached the usage ledger. Only the calls it made through magpie's gateway showed, logged by the gateway. CodeBuddy Code writes its sessions the way WorkBuddy does: projects/<cwd>/<id>.jsonl under $CODEBUDDY_CONFIG_DIR, else ~/.codebuddy. A reply's usage sits in providerData.usage on its function_call or assistant message line, keyed by providerData.messageId, and models.json has the same format. So WorkBuddy's reader is now parameterized by agent: - buddyFiles(agent, dir) lists the files. - buddyGateway(dir, id) reads that agent's own models.json. Its stamp cache is kept per path. - readWorkBuddyCalls takes the agent from the file. "codebuddy" is registered in callSources and wholeCallReaders. A model CodeBuddy asks for as custom-local:<id>, where models.json names <id> with vendor "magpie", went to the gateway, and is skipped as WorkBuddy's are. The fixtures in testdata/codebuddy are CodeBuddy Code 2.164.0's own files (npm @tencent-ai/codebuddy-code), with only the cwd path shortened. They come from two `codebuddy -p` runs in a sandbox HOME against a local OpenAI fake: one on a model the user added for another vendor (counted: two replies, 521 in + 26496 cache read, 115 out), and one on a vendor "magpie" entry (skipped). Run: - TestCodeBuddyCalls goes red (0 calls) with codebuddyCallFiles taken out of callSources, and green with it in. - TestCodeBuddyGatewayIsItsOwn checks that each agent's models.json is its own. - go test ./internal/sessions passes. - gofmt, go vet, Linux nogui vet and Windows vet are clean. - Sandboxed go test ./... at the rebased head. Not done: - The Sessions page still doesn't list CodeBuddy Code's sessions. This commit is the Usage side only. - Reasoning tokens (outputTokensDetails) aren't recorded, as for WorkBuddy. - Not run against the reporter's China-edition session (47 calls). The line shapes match those in the issue. |
||
|
|
2086884bef | sessions: a session goes by the name its agent shows for it — Codex's thread name (session_index.jsonl), the one a Claude Code session was renamed to (/rename), else the title the agent made — and by its first prompt only when it has none (TJHHHH on Discord) | ||
|
|
21702d01ff |
Add German translation; harden paths against unset env vars (#770)
* Add German translation and harden paths against unset env vars Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows. * Makefile: know magpie's folder by its go.mod, so paths with spaces work The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs. * i18n: German for the strings main added since, with a parity test 75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system. * appdir: ignore relative folder variables when reading, keep them for children CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder. * Sandbox the tests main added since internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE. * agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over. * i18n: German for the Library's multi-select and System One's decision API The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes. * appdir: tidy the import into magpie's group; say what Go makes of /c/x The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x. |
||
|
|
e927f027f3 |
sessions: Grok Build's and WorkBuddy's sessions are counted too (Aimer779: 用量→会话 增加 Grok Build 和 WorkBuddy 的本地会话统计)
Usage → Sessions and the stats now list Grok Build's and WorkBuddy's local sessions next to the other agents'. The GUI and CLI filters already name them from agent.Clients(), so nothing else needed changing. Grok Build: the reader looks under $GROK_HOME/sessions (else ~/.grok/sessions), at <url-encoded cwd>/<id>/, reading summary.json and updates.jsonl. - Tokens come from each turn_completed's usage.modelUsage, per model. Input is counted without the cache it read (inputTokens already includes cachedReadTokens), so the cache isn't counted twice. - A subagent's session (session_kind "subagent…") counts once, inside the session it ran in. - A fork's copied updates count only in the session they came from. The fork itself counts from its created_at on. - The title is the first prompt typed, else Grok's generated_title. - The hooks that fire on start and end don't count as time at work, so a session closed the next day doesn't run overnight. - It resumes with `cd <cwd> && grok --resume <id>`. WorkBuddy: the reader looks at $WORKBUDDY_CONFIG_DIR/projects/**/*.jsonl (else ~/.workbuddy). - Tokens come from providerData.usage and count once per reply (providerData.messageId), however many of its lines carry it. Cached tokens (inputTokensDetails) are taken out of the input. - The older snake_case input_tokens/output_tokens are read as well, with the cwd from <id>.meta.json for sessions migrated from its old history. - The title is custom-title, then ai-title, then the first prompt (without WorkBuddy's <system-reminder> and @scene: blocks). - There is no resume command, since it is a desktop app. Tested: - go test -tags nogui ./... passes. New sanitized fixtures cover both readers: a Grok main session with a subagent, a fork and a hooks-only session, plus a WorkBuddy session with repeated usage lines and a migrated one. - go build -tags nogui passes for darwin, linux and windows (CGO_ENABLED=0). - A read-only run against real ~/.grok and ~/.workbuddy: 7 Grok sessions (an 8th, hooks only, left out) and 16 WorkBuddy sessions. Token totals match a raw jq tally of the same files: Grok 293910 in / 4396 out / 610560 cache read, WorkBuddy 13548053 / 621856 / 32321668. |