diff --git a/README.md b/README.md index 83b2e12..8ded55f 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ These add a page to magpie's window, in the app and in `magpie web`, under Plugi | [usage](packages/usage) | Usage glance: calls, errors, tokens and cost for today, 7 or 30 days, and the models behind them | `usage:summary` | | [powercontext](packages/powercontext) | Connection settings for an independently deployed PowerContext service | None | | [nowledge-mem](packages/nowledge-mem) | Connection settings, recall and capture switches, a real connection test, and the scope of what is sent | None | -| [agent-office](packages/agent-office) | What are my agents doing: live sessions as workers in a voxel office (3D/2D) or a list, with status, current step and resume commands | no `magpie.read`; its host part reads the local session files of Claude Code, Codex, dsh, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy and CodeBuddy, including prompts, replies and tool commands (`text:false` keeps statuses and tool names only) | +| [agent-office](packages/agent-office) | What are my agents doing: a real WebGL 3D office with six scenes, an isometric/2D office, grouped workbench, Today usage and recent conversations | no `magpie.read`; its host part reads local session files of Claude Code, Codex, Copilot CLI, Kimi Code, dsh, Gemini CLI, Qwen Code, Pi, omp, Qoder, WorkBuddy, CodeBuddy and Grok Build, including prompts, replies and tool commands (`text:false` keeps statuses and tool names only) | | [fingerprint](packages/fingerprint) | Numeric response fingerprints to investigate suspected model substitution across providers, with shared challenges, candidate rankings, local evidence and JSON export | none (its local service calls magpie’s gateway; sampling uses provider quota) | | [chat](packages/chat) | Chat with magpie's models, your MCP servers, instructions and skills, by Magic_zero ([Magiczerowxy](https://github.com/Magiczerowxy)). Has a host part: a local service the page goes to | none (its service calls magpie's gateway) | diff --git a/packages/agent-office/CHANGELOG.md b/packages/agent-office/CHANGELOG.md index 6e43ad5..8718a65 100644 --- a/packages/agent-office/CHANGELOG.md +++ b/packages/agent-office/CHANGELOG.md @@ -1,11 +1,44 @@ # Changelog -## 0.1.1 · 2026-10-31 +## 0.2.0 · 2026-10-31 + +功能对齐 [whatsmyagentdoing](https://github.com/Charonyuu/whatsmyagentdoing),并加入真正的 3D 与独立运行方式。 + +### Added + +- Real WebGL 3D office (`page/scene3d.js`, bundled three.js r169): orthographic orbit camera, wheel zoom, lighting, shadows, six procedural scenes (office, station, cafe, castle, pirate, graveyard), animated workers and DOM name-tag anchors. +- ISO canvas view between 2D and 3D: five activity venues (reading, arcade, huddle, ping-pong, coffee), an office cat, day/night window light, drag-pan and wheel/pinch zoom. +- Copilot CLI, Kimi Code and Grok Build readers, Claude Code subagents, OMP profiles, and parent/subagent metadata. +- Workbench: Needs you → Working → Finished groups, agent-mix / subagent / idle filters, grouped side rail. +- Today panel: turns, tokens, top folders and context bars (60% warn, 85% full). +- Recent conversation in the agent panel (last 8 messages), with privacy redaction. +- No-progress badges at 8 minutes thinking and 10 minutes running; completed agents wander the venues and sofa. +- In-page toast for new waiting/error sessions; tab-title need-you count. +- Claude process-liveness check: a session mid-turn with no live process (for example `claude -p` killed from another agent) is **stopped**, not stuck. +- **Clear** removes a finished/stopped/waiting/stuck agent until its session moves again. +- Nine-language UI: English, 简体中文, 繁體中文, 日本語, 한국어, Español, Français, Deutsch, Português, with prompt-script, theme and browser fallback. +- Standalone `bin/agent-office.mjs` (`--json`, `--private`, `--hours`, local page server) and `SKILL.md` for Claude Code / Codex skills. ### Fixed -- An agent another agent ran and then interrupted from the shell (`claude -p` or `codex exec` killed by SIGTERM or SIGKILL) no longer stays in the office as at work, then stuck, until its session is deleted in magpie. A Claude Code session with no running process in Claude Code's `sessions/.json` files is stopped (also Qoder, WorkBuddy and CodeBuddy when their folder keeps such files). -- **Clear** (清除) in an agent's panel takes a stuck, failed, stopped, finished or waiting agent out of the office until its session moves again. Before, nothing could take one out but `hideAfter`, and a waiting one never left. +- Secure the standalone server with per-run capability URLs, validated Host and same-origin JSON writes; reject cross-site data/script access. +- Scrub hidden rail, list, conversation and closed-panel DOM when text is disabled. +- Keep stopped 3D renderers stopped across visibility and context restoration; avoid hidden-canvas DPR growth. +- Execute bundled THREE in renderer tests; batch articulated worker meshes with InstancedMesh, preserve crowd capacity and keep six-scene props clear of seating routes. +- Refresh Today usage at local midnight and read Grok's vendor-documented usage sidecar. JSONL now retains per-file byte cursors and reader state; normal polls parse only appended records instead of replaying growing history every 1.5 s. +- Handle partial UTF-8/JSON writes and delayed newlines, reset on truncation/inode replacement/same-size rewrites, and check at most 128 old bytes for truncate-and-regrow. Codex titles use the same incremental framing; unchanged sidecars are not re-parsed or retained as full usage snapshots. +- Preserve incremental tool/stream/usage state, Claude response corrections and metadata removal/fallback precedence; incomplete quoted braces do not trigger repeated full-record parsing. Byte-count regression tests cover 100 MiB logs and fragmented image/text writes. +- Recompute time-based states without new log writes; allow clearing No progress sessions, unify rail/list labels and retain alert history across filters. +- Bound menus and panels to the current CSS viewport; fingerprint static assets to prevent mixing old resources after a same-version update. +- Translate scene/quality/fallback/venue labels and scope camera shortcuts to a focused canvas. + +- Inactive canvas is hidden explicitly, so switching between 3D, ISO and 2D never leaves the previous renderer visible. +- The grouped rail and menus no longer sit under the agent detail panel. +- The security test distinguishes the vendored three.js bundle from our own page code; `scene3d.js` still has no network calls. +- Toolbar controls are grouped, so Settings never wraps alone on a second row. +- The page fills the plugin frame without an outer scrollbar; the stage shrinks instead of overflowing. +- Name tags use their laid-out position for collision stacking, stay inside the stage, and are capped by priority so they cannot cover the office. +- The grouped side rail now defaults to **closed** (previous default: open), leaving more space for the office. Open it with **Panel**; an old saved `side:true` is ignored once unless it carries the current preference version. ## 0.1.0 · 2026-10-29 diff --git a/packages/agent-office/README.md b/packages/agent-office/README.md index 091d815..b216b6f 100644 --- a/packages/agent-office/README.md +++ b/packages/agent-office/README.md @@ -2,140 +2,169 @@ [![Latest release](https://img.shields.io/github/v/release/QingJ01/magpie-agent-office)](https://github.com/QingJ01/magpie-agent-office/releases) [![magpie ≥ 0.1.1318](https://img.shields.io/badge/magpie-%E2%89%A5%200.1.1318-4f46e5)](https://usemagpie.ai) -[![Tests](https://img.shields.io/badge/tests-54%20passing-22a35a)](#test) +[![Tests](https://img.shields.io/badge/tests-163%20passing-22a35a)](#test) [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE) -**一个住在 magpie 窗口里的实时 Agent 办公室。** 直接读取各 Agent 自己的会话记录,把正在思考、执行工具、等待批准或已经完成的工作,变成太空站里的小人。支持等距 3D、俯视 2D、实时列表和可拖动的悬浮小窗。 +**一个住在 magpie 窗口里的实时 Agent 办公室。** 直接读取各 Agent 自己的会话记录,把正在思考、执行工具、等待批准或已经完成的工作,变成真 3D 办公室里的小人;也可以切到等距画布、俯视 2D 或分组列表。 -A live activity dashboard for your coding agents inside [magpie](https://usemagpie.ai): every session becomes a little worker in a voxel space-station office, driven by the agent's own session files rather than guesses from network traffic. +A live activity dashboard for your coding agents inside [magpie](https://usemagpie.ai). Every session becomes a worker in a real WebGL office, an isometric canvas room, or a grouped workbench — driven by the agent's own session files, not guesses from network traffic. ![Agent Office in magpie's window](https://raw.githubusercontent.com/QingJ01/magpie-agent-office/main/docs/in-magpie.png) +![The real 3D office, six scenes, orbit camera](https://raw.githubusercontent.com/QingJ01/magpie-agent-office/main/docs/office-3d.png) + ## 快速开始 · Quick start +**magpie 插件(推荐)** + ```sh magpie plugin add @magpie-community/page-agent-office ``` -安装后打开 **插件 › Agent 办公室**。默认显示真实会话,不是演示数据;第一次没有会话时会看到空办公室。想预览完整效果,可在 **设置 › 示例 Agent** 临时打开示例。 +安装后打开 **插件 › Agent 办公室**。第一次没有会话时会看到空办公室;想预览完整效果,可在 **设置 › 示例 Agent** 临时打开示例。 -- **3D / 2D**:等距太空站或俯视图。 -- **办公室 / 列表**:实时状态、当前步骤、目录、模型和最近活动时间。 -- **点击小人或列表行**:查看任务、最近提问、工具步骤、回复摘要和续接命令。 -- **画中画**:可拖动、可缩放的悬浮小窗,✕ 或 Esc 放回。 +**独立运行(没有 magpie 时)** -支持直接读取会话文件的 Agent:Claude Code、Codex、DeepSeek Harness、Gemini CLI、Qwen Code、Pi、omp、Qoder、WorkBuddy、CodeBuddy。其他 Agent(Cursor、OpenCode、Copilot、Kimi 等)在通过 magpie 的模型工作时也会显示。 +```sh +bun bin/agent-office.mjs # 本地页面,默认 127.0.0.1:4545 +bun bin/agent-office.mjs --json # 一次性快照,适合让 Agent 在聊天里汇报 +``` -**它会读取什么:** 这些 Agent 写在本机的会话文件,包括提问、回复和工具命令,并在插件自己的目录里生成 `page/live.js` 供页面显示。设置里关闭「显示提问和回复」后只保留状态与工具名,不再写入提问、回复或命令参数。 +独立服务会打印带随机访问令牌的完整 URL,请用该 URL 打开;固定的 `/live.js` 和数据 API 不公开。服务拒绝不匹配的 Host、跨站请求和缺少同源 Origin 的写入。端口占用时会报错,可用 `--port 0` 自动选择空闲端口。 -仓库带有 `magpie-plugin` topic,因此也会出现在 **插件 › 发现 › 非官方插件 · GitHub**。插件市场的收录进展见 [magpie-community/plugins](https://github.com/magpie-community/plugins)。 +仓库也带 `SKILL.md`,可放进 Claude Code / Codex 的 skills 目录,用 `/agent-office` 启动。 -[功能与状态](#where-a-worker-is-is-what-it-is-doing) · [数据来源](#how-it-knows) · [隐私](#privacy) · [设置](#options) · [限制](#what-it-cannot-know) · [开发测试](#test) +### 主要功能 -## Where a worker is, is what it is doing +- **真 3D(WebGL)**:等距相机、拖拽旋转、滚轮缩放、实时光照与阴影;办公室、空间站、咖啡店、城堡、海盗湾、幽灵谷六种程序化场景。 +- **ISO / 2D**:不依赖 WebGL 的等距画布与俯视图;相机拖拽、滚轮缩放、昼夜窗光、办公室猫和五个活动点。 -| Status | Where | Sign | -|---|---|---| -| Thinking · 思考中 | at a desk | … | -| Running tools · 执行中 | at a desk, typing, its screen lit | spinner, how long it has run | -| Replying · 回复中 | at a desk | lines | -| Waiting for you · 等你回应 | in the purple square, waving | **!** | -| Done · 已完成 | on the sofa, asleep after 20 minutes | z | -| Error · 错误 | at the broken console | × | +![The isometric canvas office, with venues and the cat](https://raw.githubusercontent.com/QingJ01/magpie-agent-office/main/docs/office-iso.png) +- **分组工作台**:按 **需要你 → 工作中 → 已结束** 分组;可按 Agent、子 Agent、摸鱼 Agent 过滤。 +- **今日面板**:今天的轮次、tokens、按 Agent 与目录汇总,以及上下文使用率条(60% 黄、85% 红)。 -The counts at the top are how many need you (waiting for an approval or an answer, failed, or stuck), how many are working and how many are done. Below, real sessions: DeepSeek Harness running a tool, Codex done on the sofa, the panel of the first opened by a click: +![Today usage and context](https://raw.githubusercontent.com/QingJ01/magpie-agent-office/main/docs/today.png) +- **最近对话**:点击 Agent 查看任务、当前步骤、最近消息、模型、目录、上下文和续接命令。 +- **页内提醒**:新出现的「需要你」或错误会在页面右下角弹出提示;标题栏显示需要你的数量。magpie 的 iframe 没有系统通知权限,所以不调用浏览器通知。 +- **9 种语言**:English、简体中文、繁體中文、日本語、한국어、Español、Français、Deutsch、Português。自动按最近提问的语言选择,也可手动指定。 +- **画中画**:可拖动、可缩放的页内悬浮小窗,✕ 或 Esc 放回。 -![A real session's panel](https://raw.githubusercontent.com/QingJ01/magpie-agent-office/main/docs/panel.png) +## 支持哪些 Agent -## Which way each worker faces +直接读取会话文件: -A seat says which way its owner looks: at a desk the sitter faces the desk, so the monitor stands on the desk's far edge with its lit side toward them and the chair's back behind; on the left wall's sofa they look east and on the front sofa north, away from the backrest. The head shows a face when that side is toward the camera, a profile when it is east, and the back of the head when it is away. - -## Movement and idle gestures - -Completed agents occasionally stretch, glance sideways, swing their legs or nod off. Their schedules differ, and these gestures pause while walking or working. The new gestures respect the system's reduced-motion preference; name tags remain steady. - -Sofas are blocked to normal foot traffic, including the space behind their backrests. Each seat has a front approach: walk through the aisle, board from the front, then leave by that same approach. Rerouting midway through boarding first returns to the aisle. Path smoothing checks every crossed grid cell, and an unreachable destination never falls back to walking straight through furniture. - -## How it knows - -From each agent's **own session file**, as the agent writes it — not a guess from traffic. The plugin's host part (it runs in magpie's plugin host while magpie is open) reads them every 1.5 seconds, only what changed: - -| Agent | File it reads | +| Agent | 文件 | |---|---| -| Claude Code | `~/.claude/projects/*/*.jsonl` | -| Codex | `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` (+ `session_index.jsonl` for titles) | -| DeepSeek Harness | `~/.dsh/sessions/*/*/session.v4.jsonl.zstd` | +| Claude Code | `~/.claude/projects/*/*.jsonl`(以及 `subagents/*.jsonl`;`sessions/*.json` 只用来判断进程是否还在) | +| Codex | `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl`(+ `session_index.jsonl`) | +| Copilot CLI | `~/.copilot/session-state/*/events.jsonl` | +| Kimi Code | `~/.kimi-code/sessions/*/*/agents/*/wire.jsonl` | +| DeepSeek Harness | `~/.dsh/sessions/*/*/session.v4.jsonl[.zstd]` | | Gemini CLI · Qwen Code | `~/.gemini/tmp/*/chats/session-*`, `~/.qwen/tmp/*/chats/session-*` | -| Pi · omp | `~/.pi/agent/sessions/*/*.jsonl`, `~/.omp/agent/sessions/*/*.jsonl` | -| Qoder · WorkBuddy · CodeBuddy | their `projects/*/*.jsonl` (Claude Code's format) | +| Pi · omp | `~/.pi/agent/sessions/*/*.jsonl`, `~/.omp/agent/sessions/*/*.jsonl`,以及 `~/.omp/profiles/*/agent/sessions` | +| Grok Build | `~/.grok/sessions/*/*/updates.jsonl` + `summary.json` | +| Qoder · WorkBuddy · CodeBuddy | 各自的 `projects/*/*.jsonl`(Claude Code 格式) | -The `*_HOME` / `*_CONFIG_DIR` variables those agents honour are honoured here too. What each file says decides the status outright: a tool call with no result yet is **running**, an approval asked (Codex's `exec_approval_request`, DeepSeek Harness's `approval/asked`, Gemini's `awaiting_approval`) is **waiting for you**, a question tool is **asked you something**, the turn's end is **done**, an interruption is **stopped**, an error turn is **error**. A turn whose file hasn't moved for ten minutes is shown as stuck. +`*_HOME` / `*_CONFIG_DIR` 覆盖变量都支持。Claude 子 Agent、Kimi 子 Agent、Grok 子 Agent 会标为子 Agent,并带父会话;OMP profiles 带 profile 名。其他 Agent(Cursor、OpenCode、Copilot 等)在通过 magpie 的模型工作时,仍会由异步网关钩子看到。 -An agent killed mid-turn writes no end at all: one agent running another (`claude -p` or `codex exec` from a Bash tool) and interrupting it leaves the other's file mid-turn. Claude Code keeps a file per running process (`sessions/.json`), so a Claude Code session with no running process is **stopped**, at once. Codex and the other agents keep nothing a reader can check, so such a session shows as stuck. Any agent not at work — stuck, failed, stopped, done or waiting — can be taken out of the office with **Clear** (清除) in its panel; it comes back when its session moves again. +## 状态与办公室 -Every other agent (Cursor, OpenCode, Copilot, Kimi…) shows while it works through magpie: the module is also an [asynchronous gateway hook](https://usemagpie.ai/docs/plugins#gateway-request) that sees its requests. The hook returns no body, so no request changes. +| 状态 | 在哪里 | 标记 | +|---|---|---| +| Thinking · 思考中 | 工位 | … | +| Running tools · 执行中 | 工位,屏幕亮着 | 工具名、已运行时间 | +| Replying · 回复中 | 工位 | 正在写入的回复 | +| Waiting for you · 等你回应 | 紫色区域,挥手 | **!** | +| Done · 已完成 | 沙发、书架、咖啡台、乒乓球、街机、白板或电话亭 | ✓ / 摸鱼 | +| Error · 错误 | 故障终端 | × | -Both write `page/live.js` beside the page, which the page loads every second (a plugin page has no network; its own files it may load). The green **live** dot by the title turns grey if the host stops writing. +工作 8 分钟没有新动静标 **No progress**,工具运行 10 分钟标 **No progress · 10m**,仍留在「工作中」;20 分钟后的完成会话进入摸鱼状态。办公室有五个活动点、可撸的猫、随本地时间变化的窗光,以及可拖拽缩放的相机。 -All 60 agents magpie knows are named with their own icons, the files magpie itself shows (`page/icons`, from magpie's assets, MIT). +## 怎么知道 -## Using it +每个 Agent 自己写在本机的会话文件是唯一事实来源。host 每 1.5 秒读取变化,页面每秒加载一次 `page/live.js`: -Hovering only highlights a worker. **Click** a worker, its name tag or a row in the list to open its panel — the task, the last thing you asked, the step it's on, how its answer begins, its model and folder, and **Resume command**, shown selected so ⌘C / Ctrl+C copies it — which stays at the side until you close it (✕ or Esc) or click another agent. +- 工具有调用没结果 → **执行中** +- 请求批准 / 提问(Codex、DSH、Gemini、Kimi 等)→ **需要你** +- 本轮结束 → **完成**;中断 → **已结束**;错误 → **错误** +- 会话文件 8 / 10 分钟没动 → **No progress** -## Privacy +通过网关看到、没有本地文件的 Agent,按请求推断;它不会因为一次请求结束就冒充「完成」。hook 返回空 body,不修改任何请求。 -- It reads the agents' session files on this computer, only reads them, and only the last two days'. Through the gateway it records only requests made on this computer (magpie's `origin: local`) unless you set `"remote": true`. -- `live.js` holds the agent, the session id, the folder name and path, the model, the last prompt (200 characters), the first 280 characters of the last answer, and the names and targets of the last tool calls. It never holds a key, a header or a whole conversation. With `"text": false` (Settings › Show prompts and replies, off) it keeps statuses and tool names only. -- `live.js` stays in the plugin's folder and is never sent anywhere. The page asks magpie for no data at all: its `permissions` list is empty. +**它会读取什么:** 本机的会话文件,包括提问、回复、工具命令、最近 8 条消息和用量字段,并在插件目录生成 `page/live.js`。设置里关闭「显示提问和回复」后只保留状态与工具名,不写入提问、回复、消息或命令参数;配置读不到时默认关闭文本(fail closed)。 -## Picture in picture +## 隐私 -**Picture in picture** (画中画) lifts the office into a small window of the page's own, over the rest of it: drag its bar to move it, drag its corner to reshape it, click ✕ or press Esc to put it back. Only the agents that need you keep their name tags there; hover any of them for the card. +- 只读本机 Agent 会话;默认只看最近两天、最多 40 个会话,CLI 可放到 200 个。 +- `live.js` 保存在插件自己的目录,不发送到任何地方;页面 `permissions` 为空,不读 magpie 的会话 API。 +- `text:false` 同时由 host 和页面执行:标题回退到目录名,步骤只留工具名,最近对话整段清空。即使 `live.js` 是旧的,页面也不会把被关闭的文本画出来。 +- 独立 CLI 只监听 `127.0.0.1`;`--private` 与插件里的开关等价。 -![The office in its own window, in magpie](https://raw.githubusercontent.com/QingJ01/magpie-agent-office/main/docs/picture-in-picture.png) - -magpie frames a plugin's page with `allow=""` and `sandbox="allow-scripts"`, so the browser's own floating window (a `