billion-context-pi 0.1.70 → 0.1.71-pr.449.267
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.
- package/README.md +6 -1
- package/README.zh-CN.md +4 -0
- package/dist/cache-tool.d.ts +10 -0
- package/dist/config.d.ts +10 -0
- package/dist/index.js +825 -170
- package/dist/index.js.map +1 -1
- package/dist/omp.d.ts +10 -0
- package/dist/proxy-detect.d.ts +13 -0
- package/dist/runtime.d.ts +35 -4
- package/dist/setup-subagent-tools.d.ts +11 -0
- package/dist/surface.d.ts +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -79,6 +79,8 @@ That's it. The extension auto-loads on next Pi startup. No configuration needed
|
|
|
79
79
|
> **Using another sub-agent extension?** billion-context-pi ships its own `acp_delegate` sub-agent tool (see below) at a fraction of the context cost (~600 tok vs ~7K tok/turn). Two delegation tools in one session only make the model's choice noisier, so pick one:
|
|
80
80
|
> - **Use ACP's delegate** — remove the other extension: `pi remove npm:pi-subagents`
|
|
81
81
|
> - **Keep your own sub-agent** — turn ACP's delegate off in `acp.json`: `{ "delegate": false }` (see *Using your own sub-agent instead* below)
|
|
82
|
+
>
|
|
83
|
+
> If you keep `pi-subagents` installed, billion-context-pi detects it at session start: a **project-level** install (`<cwd>/.pi/npm` or the project extensions dir) automatically stands `acp_delegate` down for that project — a reminder then tells you how to give pi-subagents' agents ACP compression via `/acp-subagents`. A **user-level-only** install (`~/.pi/npm`, user extensions dir) leaves `acp_delegate` active and logs a warning instead. Set `"delegate": { "forceEnable": true }` in `acp.json` to keep `acp_delegate` active regardless of detection.
|
|
82
84
|
|
|
83
85
|
## How it works
|
|
84
86
|
|
|
@@ -120,6 +122,8 @@ billion-context-pi is built for the **Pi** coding agent (`@earendil-works/pi-cod
|
|
|
120
122
|
|
|
121
123
|
- **Coexisting with the [billion-context](https://github.com/ranxianglei/billion-context) wire proxy** — running both on the same session double-compresses every request (wasted tokens, nested summaries, two ref coordinate systems). This is prevented automatically: launcher paths (`bili pi`, …) export `BILLION_CONTEXT_PROXY`, and models whose `baseUrl` routes through the proxy (`…/bili/https://upstream…`) are detected at session start — in both cases billion-context-pi stands down with a warning and leaves the proxy as the sole compressor. One exception: transparent mode, where traffic reaches the proxy via `HTTPS_PROXY` so the URL carries no `/bili/` prefix — that is undetectable from the URL, so export `BILLION_CONTEXT_PROXY=1` before starting pi in that case.
|
|
122
124
|
|
|
125
|
+
- **Reverse collision — the `billion-context` thin plugin shadows `/acp`.** If the pi plugin shipped inside [`billion-context`](https://github.com/ranxianglei/billion-context) is also installed (an entry pointing at a `billion-context` install in `"packages"` of `~/.pi/agent/settings.json`, e.g. from `bili plugin install pi`), it registers its own `/acp` command, and Pi has no duplicate-command guard — which one answers depends on load order. Telling symptom: on a plain `pi` launch, typing `/acp` shows ``bili: no proxy detected (run via `bili <client>` or set a /bili/ baseURL)`` — that string is emitted by the thin plugin, **not** by billion-context-pi, and pi does not need `bili` running. Fix: the collision only bites when you launch plain `pi` — remove the thin plugin there (`bili plugin remove pi`, or drop the non-`npm:billion-context-pi` entry from that settings file) so billion-context-pi owns `/acp`. If you launch via `bili pi` instead, nothing needs removing: the launcher exports `BILLION_CONTEXT_PROXY` and billion-context-pi stands down entirely (bullet above), so both plugins may stay installed side by side. Note: `bili plugin install pi` removes an existing `npm:billion-context-pi` entry from that file without saying so ([billion-context#788](https://github.com/ranxianglei/billion-context/issues/788)).
|
|
126
|
+
|
|
123
127
|
## Model-facing tools
|
|
124
128
|
|
|
125
129
|
| Tool | What it does |
|
|
@@ -128,6 +132,7 @@ billion-context-pi is built for the **Pi** coding agent (`@earendil-works/pi-cod
|
|
|
128
132
|
| `decompress` | Restore a previously compressed block's content |
|
|
129
133
|
| `search_context` | Search compressed block summaries (and visible messages) by keyword |
|
|
130
134
|
| `acp_status` | Show context usage, compressed blocks, compressible ranges |
|
|
135
|
+
| `acp_cache` | Prompt-cache reconciliation: grand ledger (input/cached/hit rate), per-request miss attribution, per-fold economics |
|
|
131
136
|
| `acp_delegate` | Spawn a clean-context sub-agent for a task (review / research / implement / plan / advise) |
|
|
132
137
|
| `acp_delegate_wait` | Block until a delegate run finishes (returns its result; times out otherwise) |
|
|
133
138
|
| `acp_delegate_cancel` | Cancel a running delegate by runId |
|
|
@@ -167,7 +172,7 @@ If you already run another sub-agent extension (pi-subagents, pi-lens, …), tur
|
|
|
167
172
|
```
|
|
168
173
|
|
|
169
174
|
- Equivalent object form: `{ "delegate": { "enabled": false } }`.
|
|
170
|
-
- **What it removes:** the `acp_delegate`, `acp_delegate_wait` and `acp_delegate_cancel` tools, the `ACP_DELEGATE NOTIFICATIONS` system-prompt section, and the `ctrl+alt+f` fleet shortcut (`/acp-fleet` then reports that delegate is off). Compression is unaffected — `compress`, `decompress`, `search_context` and `
|
|
175
|
+
- **What it removes:** the `acp_delegate`, `acp_delegate_wait` and `acp_delegate_cancel` tools, the `ACP_DELEGATE NOTIFICATIONS` system-prompt section, and the `ctrl+alt+f` fleet shortcut (`/acp-fleet` then reports that delegate is off). Compression is unaffected — `compress`, `decompress`, `search_context`, `acp_status` and `acp_cache` stay.
|
|
171
176
|
- **When it applies:** the three tools are registered at session start, so a change needs a **new session** (or a Pi restart). The system-prompt section is resolved live on every turn, so it can disappear mid-session before the tools do.
|
|
172
177
|
- Want to drop only the prompt section and keep the tools? Set `{ "delegatePrompt": null }`.
|
|
173
178
|
- Pi's `--exclude-tools acp_delegate,acp_delegate_wait,acp_delegate_cancel` is **not** a substitute: it hides the tools but the model still receives the `ACP_DELEGATE NOTIFICATIONS` section describing tools it cannot call. Use `delegate: false`.
|
package/README.zh-CN.md
CHANGED
|
@@ -78,6 +78,8 @@ pi install npm:billion-context-pi
|
|
|
78
78
|
> **你另有子代理扩展?** billion-context-pi 自带 `acp_delegate` 子代理工具(见下文),上下文成本极低(~600 tok vs ~7K tok/轮)。同一会话里两套委派工具只会让模型的选择更混乱,二选一:
|
|
79
79
|
> - **用 ACP 的 delegate** —— 卸载另一个扩展:`pi remove npm:pi-subagents`
|
|
80
80
|
> - **保留你自己的子代理** —— 在 `acp.json` 里关掉 ACP 的 delegate:`{ "delegate": false }`(见下文*改用你自己的子代理*)
|
|
81
|
+
>
|
|
82
|
+
> 若保留已安装的 `pi-subagents`,billion-context-pi 会在会话启动时检测:**项目级**安装(`<cwd>/.pi/npm` 或项目内 extensions 目录)会自动停用该项目的 `acp_delegate`,并提醒你运行 `/acp-subagents` 让 pi-subagents 的子代理获得 ACP 压缩;仅**用户级**(全局)安装时只记一条警告日志,`acp_delegate` 保持启用。在 `acp.json` 中设置 `"delegate": { "forceEnable": true }` 可在检测到第三方子代理时仍强制保留 `acp_delegate`。
|
|
81
83
|
|
|
82
84
|
## 工作原理
|
|
83
85
|
|
|
@@ -119,6 +121,8 @@ billion-context-pi 面向 **Pi** 编码代理(`@earendil-works/pi-coding-agent`)
|
|
|
119
121
|
|
|
120
122
|
- **与 [billion-context](https://github.com/ranxianglei/billion-context) 线代理共存** —— 两者同时作用于同一会话会对每个请求双重压缩(token 浪费、嵌套摘要、两套 ref 坐标系)。这会被自动防止:launcher 路径(`bili pi` 等)导出 `BILLION_CONTEXT_PROXY`;模型 `baseUrl` 经代理路由(`…/bili/https://upstream…`)时在会话开始即被检测到 —— 两种情况下 billion-context-pi 都会带警告让位,由代理独占压缩。一个例外:透明模式(流量经 `HTTPS_PROXY` 到达代理、URL 无 `/bili/` 前缀)无法从 URL 识别 —— 此时请在启动 pi 前导出 `BILLION_CONTEXT_PROXY=1`。
|
|
121
123
|
|
|
124
|
+
- **反向冲突 —— `billion-context` 薄插件抢占 `/acp`。** 如果 [`billion-context`](https://github.com/ranxianglei/billion-context) 内置的 pi 插件也被安装了(`~/.pi/agent/settings.json` 的 `"packages"` 里存在指向某个 `billion-context` 安装目录的条目,例如来自 `bili plugin install pi`),它会注册自己的 `/acp` 命令,而 Pi 没有重复命令防护 —— 哪个生效取决于加载顺序。典型症状:在普通 `pi` 启动下输入 `/acp` 显示 ``bili: no proxy detected (run via `bili <client>` or set a /bili/ baseURL)`` —— 这行字符串由薄插件发出,**不是** billion-context-pi 发出的,而且 pi 并不需要运行 `bili`。修复:该冲突只在你用普通 `pi` 启动时才有实际影响 —— 移除薄插件(`bili plugin remove pi`,或从该设置文件中删除除 `npm:billion-context-pi` 之外的条目),让 `/acp` 由 billion-context-pi 接管;若改用 `bili pi` 启动则无需移除任何东西:launcher 会导出 `BILLION_CONTEXT_PROXY`,billion-context-pi 整体让位(见上一条),两个插件可以并存。注意:`bili plugin install pi` 会静默删除该文件中已有的 `npm:billion-context-pi` 条目且不提示([billion-context#788](https://github.com/ranxianglei/billion-context/issues/788))。
|
|
125
|
+
|
|
122
126
|
## 模型工具
|
|
123
127
|
|
|
124
128
|
| 工具 | 作用 |
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Type } from "typebox";
|
|
2
|
+
import type { ExtensionContext, SessionEntry, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import type { AcpRuntime } from "./runtime.js";
|
|
4
|
+
import { type ToolPromptOverrides } from "./surface.js";
|
|
5
|
+
import { type CacheSample } from "acp-kernel";
|
|
6
|
+
declare const CacheParams: Type.TObject<{}>;
|
|
7
|
+
export declare function cacheSamples(entries: SessionEntry[]): CacheSample[];
|
|
8
|
+
export declare function cacheReportText(runtime: AcpRuntime, ctx: ExtensionContext): Promise<string>;
|
|
9
|
+
export declare function makeCacheTool(runtime: AcpRuntime, overrides?: ToolPromptOverrides): ToolDefinition<typeof CacheParams>;
|
|
10
|
+
export {};
|
package/dist/config.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ export interface DelegateConfig {
|
|
|
29
29
|
/** Enable acp_delegate tools (delegate/wait/cancel) and their system-prompt
|
|
30
30
|
* section. Default: true. Set `enabled: false` to skip registering them. */
|
|
31
31
|
enabled?: boolean;
|
|
32
|
+
/** Keep acp_delegate active even when a third-party subagent extension
|
|
33
|
+
* (pi-subagents) is installed. Default: false — when pi-subagents is
|
|
34
|
+
* detected at session start, acp_delegate stands down (tools, fleet
|
|
35
|
+
* shortcut and system-prompt section skipped) to avoid two overlapping
|
|
36
|
+
* sub-agent systems, and a reminder points at /acp-subagents so the
|
|
37
|
+
* third-party agents can still get ACP compression tools (#415). */
|
|
38
|
+
forceEnable?: boolean;
|
|
32
39
|
/** How delegate usage is reported back to the main session.
|
|
33
40
|
* "separate" (default) — delegate tokens tracked in a separate accumulator;
|
|
34
41
|
* main session totals stay clean, delegate usage shows as its own block in
|
|
@@ -89,6 +96,9 @@ export interface DelegateConfig {
|
|
|
89
96
|
* corresponding timeout/watchdog is disabled. */
|
|
90
97
|
export interface DelegatePolicy {
|
|
91
98
|
enabled: boolean;
|
|
99
|
+
/** Resolved delegate.forceEnable (default false): keep acp_delegate even
|
|
100
|
+
* when a third-party subagent extension (pi-subagents) is installed (#415). */
|
|
101
|
+
forceEnable: boolean;
|
|
92
102
|
displayUsage: "merged" | "separate";
|
|
93
103
|
maxDepth: number;
|
|
94
104
|
syncTimeoutMs: number | null;
|