{"_id":"@buckeyestudio/toh-tmux-context","name":"@buckeyestudio/toh-tmux-context","dist-tags":{"next":"0.1.1-rc.2","latest":"0.1.1-rc.2"},"versions":{"0.1.1-rc.2":{"name":"@buckeyestudio/toh-tmux-context","description":"Opt-in durable per-step context with this agent's tmux pane and window location","version":"0.1.1-rc.2","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/dustinwloring1988/theopen-harness.git","directory":"packages/context/tmux-context"},"type":"module","main":"lib/index.js","types":"lib/types/index.d.ts","exports":{".":{"types":"./lib/types/index.d.ts","default":"./lib/index.js"},"./invariant":{"types":"./lib/types/invariant.d.ts","default":"./lib/invariant.js"},"./src/*":"./src/*","./package.json":"./package.json"},"license":"MIT","author":{"name":"buckeyestudio"},"dependencies":{"@buckeyestudio/schemastery":"^3.18.1"},"peerDependencies":{"@buckeyestudio/toh-agent":"^0.1.1-rc.2","@buckeyestudio/toh-invariants":"^0.1.1-rc.2","@buckeyestudio/toh-session":"^0.1.1-rc.2","@buckeyestudio/cordis":"^4.0.1","@buckeyestudio/toh-shell":"^0.1.1-rc.2"},"devDependencies":{"@buckeyestudio/toh-agent":"^0.1.1-rc.2","@buckeyestudio/toh-shell":"^0.1.1-rc.2","@buckeyestudio/toh-session":"^0.1.1-rc.2","@buckeyestudio/toh-system-prompt":"^0.1.1-rc.2","@buckeyestudio/toh-invariants":"^0.1.1-rc.2","@buckeyestudio/toh-llm":"^0.1.1-rc.2","@buckeyestudio/cordis":"^4.0.1"},"_id":"@buckeyestudio/toh-tmux-context@0.1.1-rc.2","bugs":{"url":"https://github.com/dustinwloring1988/theopen-harness/issues"},"homepage":"https://github.com/dustinwloring1988/theopen-harness#readme","_integrity":"sha512-ivgZE4BkPBALf2UiVv3nELFV8iPGUSSu4FV55gXvLEjNbmwBbIbaQDKhbG6rzA/98+1TRHLbtft4TY+5Ea2NMQ==","_resolved":"/home/runner/work/theopen-harness/theopen-harness/dist/npm/buckeyestudio-toh-tmux-context-0.1.1-rc.2.tgz","_from":"file:/home/runner/work/theopen-harness/theopen-harness/dist/npm/buckeyestudio-toh-tmux-context-0.1.1-rc.2.tgz","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-ivgZE4BkPBALf2UiVv3nELFV8iPGUSSu4FV55gXvLEjNbmwBbIbaQDKhbG6rzA/98+1TRHLbtft4TY+5Ea2NMQ==","shasum":"2e88507709311e6f040c2dc21360cc1f608bd24d","tarball":"https://registry.npmjs.org/@buckeyestudio/toh-tmux-context/-/toh-tmux-context-0.1.1-rc.2.tgz","fileCount":9,"unpackedSize":30893,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC9dPHXHB5qUC68lPtQOcNYmCvqOADz8d163gLQqLyhgQIgeMOaOGtJFFutZBzR4b847Omr7pujmlfIdzxU7bLKRtw="}]},"_npmUser":{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"},"directories":{},"maintainers":[{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/toh-tmux-context_0.1.1-rc.2_1787489557107_0.984361751451925"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-23T12:52:36.912Z","0.1.1-rc.2":"2026-08-23T12:52:37.264Z","modified":"2026-08-23T12:52:37.511Z"},"maintainers":[{"name":"buckeyestudio","email":"dustinwloring1988@gmail.com"}],"description":"Opt-in durable per-step context with this agent's tmux pane and window location","homepage":"https://github.com/dustinwloring1988/theopen-harness#readme","repository":{"type":"git","url":"git+https://github.com/dustinwloring1988/theopen-harness.git","directory":"packages/context/tmux-context"},"author":{"name":"buckeyestudio"},"bugs":{"url":"https://github.com/dustinwloring1988/theopen-harness/issues"},"license":"MIT","readme":"# @buckeyestudio/toh-tmux-context\n\n[English](README.md) | 中文\n\n可选启用的持久上下文，记录本 agent（智能体）进程所在的 tmux session、window、pane，以及该 window 的 pane 树布局。在准备模型请求时每轮采样一次；随附 Web／无头组合不包含它。决策记录见：[tmux-context Agent Note](../../../.agents/notes/implemented/feature/2026-07-27-tmux-location-context.zh.md)。\n\n## 配置\n\n```yaml\n- id: tmux-context\n  name: '@buckeyestudio/toh-tmux-context'\n  config:\n    refreshIntervalMs: 60000 # optional; omit or set to 0 to inject on every changed turn\n```\n\n`refreshIntervalMs` 必须是非负安全整数。省略或 `0` 表示只要 tmux 状态自上次注入以来发生变化就注入。正值会额外抑制距最近一次注入不足该毫秒数的注入。\n\n## 如何读取 tmux\n\n插件前置注册一个 `agent/pre-step` 监听器，仅在每轮的第一个步骤运行。当需要注入时，它通过 `ctx.shell` 执行器服务运行一条只读命令：\n\n```sh\n[ -n \"$TMUX_PANE\" ] || exit 1\nself_tty=$(ps -o tty= -p <pid> | tr -d ' ')\npane_tty=$(tmux display-message -t \"$TMUX_PANE\" -p '#{pane_tty}') || exit 1\n[ \"$pane_tty\" = \"/dev/$self_tty\" ] || exit 1\nexec tmux display-message -t \"$TMUX_PANE\" -p '<format>'\n```\n\n仅凭 `$TMUX_PANE` 并不足够：从 tmux shell 启动的终端（VS Code 集成终端、桌面启动器）会从该祖先进程**继承** `$TMUX` 与 `$TMUX_PANE`，因此即使进程并不位于那个 pane 中，这些变量依然存在。为此该命令还会把 pane 的 `#{pane_tty}` 与本进程自己的控制终端（对其 pid 执行 `ps -o tty=`）作比较：真正的 pane 拥有本进程的 tty，而继承而来的环境指向的是另一个 pane 的 tty。通过 `ctx.shell` 运行会应用部署方的沙箱与策略；插件不拥有任何子进程代码。当 `ctx.shell` 缺失、进程不在真实的 tmux pane 内（`$TMUX_PANE` 未设置，或 tty 不匹配 ⇒ 非零退出）或读取结果格式非法时，本次尝试为空操作，绝不报错。由于位置信息是可选的，执行器的拒绝——`resolve()` 的策略拒绝或 `run()` 的基础设施故障——会被兜住并记录为警告，而不会使该轮失败。\n\n状态在每个符合条件的轮次拉取——pane 被移动、改名或重新布局都会被感知，无需任何 tmux hook 或后台进程。插件仅在渲染出的 tmux 状态与上次注入不同时才重新注入，因此位置不变时不会新增任何内容。\n\n## 时序语义\n\n该插件会前置一个 `agent/pre-step` 监听器。需要注入且下游决策进入拟议步骤时，它会向返回的批次前置添加一条带来源的 `UserMessage`。AgentLoop 会在 `step/start` 之后记录该上下文，其来源为 `{ kind: 'plugin', plugin: 'tmux-context' }`。变化抑制与间隔调度会扫描原始持久会话事件中该来源的最近一次注入，因此调度可跨压缩（compaction）与恢复的进程存续，无需进程内缓存状态；各会话独立调度。下游在步骤前运行的监听器拒绝或失败时，该读数不会被记录。\n\n## 模型体验\n\n### 准备期 tmux 位置\n\n#### 模型看到的内容\n\n在 tmux 状态发生变化的每一轮，注入一条带来源标记、含以下三行的上下文消息。`<window-layout>` 是 tmux 紧凑的 pane 树描述；pane 与 window 的像素尺寸有意省略，相邻 pane 的内容从不采集。\n\n##### 变化轮次读数\n\n```markdown\ntmux location (turn <turn>):\nsession <session>, window <index> \"<name>\", pane <index> <pane-id>\nwindow active=<0|1>, pane active=<0|1>, layout <window-layout>\n```\n\n#### Token 影响\n\n每条两行读数会累积，直到压缩将其遮蔽。位置未变化以及间隔抑制不会新增内容。\n\n#### KV Cache 影响\n\n仅追加；新增可见内容位于可复用的请求前缀之后，不会使已有 KV Cache 条目失效。\n\n## 已知限制与后续工作\n\n- **仅第一个步骤**——轮次中途移动或缩放的 pane 会在下一轮反映，而非在步骤之间。\n- **仅自身位置**——插件从不采集相邻 pane 的可见文本。\n- **只有布局，没有尺寸**——省略 pane/window 像素尺寸；仅报告布局树与活动标志。\n- **制表符分隔字段**——若 tmux window 名称包含字面两字符序列 `\\t`，会使读数分割错误并作为非法读数跳过；常规名称不受影响。\n- **基于 tty 的 pane 判定**——只有当进程的控制终端与 `$TMUX_PANE` 的 `#{pane_tty}` 一致时，才视为「位于 tmux 中」。这会有意排除从 tmux 祖先进程继承 `$TMUX`／`$TMUX_PANE` 的终端（如 VS Code 集成终端）。`ps -o tty=` 属于 POSIX；在其或 `#{pane_tty}` 不可用的环境中，该检查即为空操作。\n","readmeFilename":"README.zh.md","_rev":"1-df410a860d7f909e35d29a23bef17e74"}