billion-context-pi 0.1.35 → 0.1.37
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 +18 -2
- package/README.zh-CN.md +18 -2
- package/dist/config.d.ts +55 -11
- package/dist/delegate-tool.d.ts +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +525 -142
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +3 -1
- package/dist/sequence-match.d.ts +6 -0
- package/dist/system-prompt.d.ts +2 -1
- package/dist/user-config.d.ts +7 -3
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -148,7 +148,18 @@ Create `~/.pi/acp.json` (global) and/or `<project>/.pi/acp.json` (project-local,
|
|
|
148
148
|
"modelContextLimit": 200000,
|
|
149
149
|
"delegate": true,
|
|
150
150
|
"toolBashDefaultTimeout": 60,
|
|
151
|
-
"toolOutputMaxBytes": 200000
|
|
151
|
+
"toolOutputMaxBytes": 200000,
|
|
152
|
+
"maxContextLimit": "75%",
|
|
153
|
+
"emergencyThresholdPercent": "95%",
|
|
154
|
+
"nudgeGrowthTokens": 50000,
|
|
155
|
+
|
|
156
|
+
"prompts": {
|
|
157
|
+
"compressPhilosophy": "Override the compression philosophy...",
|
|
158
|
+
"howToCompressRules": "Override tier-1 rules...",
|
|
159
|
+
"tier2DistillRules": "Override tier-2 distillation rules...",
|
|
160
|
+
"tier3CondenseRules": "Override tier-3 condensation rules..."
|
|
161
|
+
},
|
|
162
|
+
"acknowledgePromptsRisk": true
|
|
152
163
|
}
|
|
153
164
|
```
|
|
154
165
|
|
|
@@ -160,8 +171,13 @@ Create `~/.pi/acp.json` (global) and/or `<project>/.pi/acp.json` (project-local,
|
|
|
160
171
|
| `delegate` | `true` | Enable the `acp_delegate` tools (delegate/wait/cancel) and their system-prompt section. Set `false` to skip registering them (e.g. you use a different sub-agent extension, or run headless where async injection adds no value). |
|
|
161
172
|
| `toolBashDefaultTimeout` | `60` | Seconds injected into the `bash` tool when the model omits `timeout`. Pi has **no** default of its own, so without this a forgotten timeout can hang for thousands of seconds. On timeout the model is guided to re-run with a larger `timeout`. `0` restores Pi's unbounded behavior. |
|
|
162
173
|
| `toolOutputMaxBytes` | `200000` | Hard byte cap on tool result text (~5000 lines at ~40 B/line; applied via the `tool_result` hook). Stops runaway output that Pi's own 50KB/2000-line cap can't catch (e.g. tools Pi doesn't cap). When it fires the model is told how to see the full output — for `bash` the full output is in its temp file (`BashToolDetails.fullOutputPath`); set lower (e.g. `8192`) for a tighter context budget, or `0` to disable. |
|
|
174
|
+
| `maxContextLimit` | `"75%"` | Context usage threshold that triggers **forced compression** nudges (bypasses growth-gate + cadence). Accepts a ratio (`0.75`) or percent string (`"75%"`). Lower = compress earlier / more aggressively. Maps to kernel `nudge.maxContextLimitPct`. |
|
|
175
|
+
| `emergencyThresholdPercent` | `"95%"` | Context usage threshold that triggers **emergency truncation** of large tool outputs to keep the session alive. Accepts a ratio (`0.95`) or percent string (`"95%"`). Must be ≥ `maxContextLimit`. Maps to kernel `nudge.emergencyThresholdPct` + `truncate.threshold`. |
|
|
176
|
+
| `nudgeGrowthTokens` | `50000` | Token growth step for soft compression nudges. A nudge fires roughly every time this many tokens become compressible. Lower = compress more often; higher = compress less often. Maps to kernel `nudge.growthFloor` + `nudge.growthCap`. |
|
|
177
|
+
| `prompts` | *(kernel defaults)* | Override acp-kernel's 4 load-bearing compression prompt rules (`compressPhilosophy`, `howToCompressRules`, `tier2DistillRules`, `tier3CondenseRules`). Each set field replaces the default verbatim; omitted fields are inherited. Non-string values are dropped. Requires `acknowledgePromptsRisk: true` — otherwise overrides are ignored and defaults are used. |
|
|
178
|
+
| `acknowledgePromptsRisk` | `false` | Safety gate for `prompts` overrides. Set `true` to acknowledge that replacing the tuned compression rules may reduce summary quality (lost paths/signatures/decisions → worse retrieval) and to make overrides take effect. |
|
|
163
179
|
|
|
164
|
-
> **Only these
|
|
180
|
+
> **Only these eleven keys are read from `acp.json`.** Other tuning knobs (`preserveRecentMessages`, `protectedTools`) are code-level and not user-overridable. The three nudge thresholds (`maxContextLimit`, `emergencyThresholdPercent`, `nudgeGrowthTokens`) form a three-tier escalation: growth-driven soft nudges → forced nudges at `maxContextLimit` → emergency truncation at `emergencyThresholdPercent`.
|
|
165
181
|
|
|
166
182
|
### Environment variables
|
|
167
183
|
|
package/README.zh-CN.md
CHANGED
|
@@ -147,7 +147,18 @@ billion-context-pi 开箱即用,无需任何配置。可以在 JSON 配置文件
|
|
|
147
147
|
"modelContextLimit": 200000,
|
|
148
148
|
"delegate": true,
|
|
149
149
|
"toolBashDefaultTimeout": 60,
|
|
150
|
-
"toolOutputMaxBytes": 200000
|
|
150
|
+
"toolOutputMaxBytes": 200000,
|
|
151
|
+
"maxContextLimit": "75%",
|
|
152
|
+
"emergencyThresholdPercent": "95%",
|
|
153
|
+
"nudgeGrowthTokens": 50000,
|
|
154
|
+
|
|
155
|
+
"prompts": {
|
|
156
|
+
"compressPhilosophy": "覆盖压缩理念……",
|
|
157
|
+
"howToCompressRules": "覆盖 tier-1 规则……",
|
|
158
|
+
"tier2DistillRules": "覆盖 tier-2 蒸馏规则……",
|
|
159
|
+
"tier3CondenseRules": "覆盖 tier-3 浓缩规则……"
|
|
160
|
+
},
|
|
161
|
+
"acknowledgePromptsRisk": true
|
|
151
162
|
}
|
|
152
163
|
```
|
|
153
164
|
|
|
@@ -159,8 +170,13 @@ billion-context-pi 开箱即用,无需任何配置。可以在 JSON 配置文件
|
|
|
159
170
|
| `delegate` | `true` | 启用 `acp_delegate` 工具(delegate/wait/cancel)及其系统提示词段落。设为 `false` 则不注册这些工具(例如你用了别的子代理扩展,或跑 headless 场景异步注入没有意义)。 |
|
|
160
171
|
| `toolBashDefaultTimeout` | `60` | 当模型未指定 `timeout` 时注入 `bash` 工具的超时秒数。Pi **本身没有默认超时**,不加这个,一次遗漏的超时可能挂起几千秒。超时后会提示模型用更大的 `timeout` 重跑。设为 `0` 恢复 Pi 的无界行为。 |
|
|
161
172
|
| `toolOutputMaxBytes` | `200000` | 工具结果文本硬上限(字节,约 5000 行 @ ~40 字节/行,通过 `tool_result` hook 应用)。用于兜住 Pi 自身 50KB/2000 行截断管不到的输出(例如 Pi 未加限制的工具)。触发截断时会告诉模型如何查看完整输出——对 `bash`,完整输出在其临时文件(`BashToolDetails.fullOutputPath`)中;设更小(如 `8192`)可更省上下文,设 `0` 关闭。 |
|
|
173
|
+
| `maxContextLimit` | `"75%"` | 上下文使用率达到此值时触发**强制压缩** nudge(绕过增长门控 + 频率限制)。支持比例(`0.75`)或百分比字符串(`"75%"`)。调小 → 更早/更激进压缩。映射到内核 `nudge.maxContextLimitPct`。 |
|
|
174
|
+
| `emergencyThresholdPercent` | `"95%"` | 上下文使用率达到此值时触发**紧急截断**,硬截断大块工具输出以保住会话。支持比例(`0.95`)或百分比字符串(`"95%"`)。必须 ≥ `maxContextLimit`。映射到内核 `nudge.emergencyThresholdPct` + `truncate.threshold`。 |
|
|
175
|
+
| `nudgeGrowthTokens` | `50000` | 软压缩 nudge 的增长步长(token)。大约每积累这么多可压缩 token 就触发一次 nudge。调小 → 压得更频繁;调大 → 压得更少。映射到内核 `nudge.growthFloor` + `nudge.growthCap`。 |
|
|
176
|
+
| `prompts` | *(内核默认)* | 覆盖 acp-kernel 的 4 条承重压缩提示词规则(`compressPhilosophy`、`howToCompressRules`、`tier2DistillRules`、`tier3CondenseRules`)。每个设置的字段逐字替换默认值;省略的字段继承默认。非字符串值被丢弃。需要 `acknowledgePromptsRisk: true`——否则覆盖被忽略,使用默认值。 |
|
|
177
|
+
| `acknowledgePromptsRisk` | `false` | `prompts` 覆盖的安全门禁。设为 `true` 以确认替换调优过的压缩规则可能降低摘要质量(丢失路径/签名/决策 → 检索变差),并使覆盖生效。 |
|
|
162
178
|
|
|
163
|
-
>
|
|
179
|
+
> **只有这十一个 key 会被 `acp.json` 读取。** 其他调优参数(`preserveRecentMessages`、`protectedTools`)是代码级的,不向用户开放。三个 nudge 阈值(`maxContextLimit`、`emergencyThresholdPercent`、`nudgeGrowthTokens`)构成三级触发:增长驱动的软 nudge → `maxContextLimit` 强制 nudge → `emergencyThresholdPercent` 紧急截断。
|
|
164
180
|
|
|
165
181
|
### 环境变量
|
|
166
182
|
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
|
-
import { type Config } from "acp-kernel";
|
|
1
|
+
import { type Config, type Prompts } from "acp-kernel";
|
|
2
|
+
/** Delegate sub-agent configuration. */
|
|
3
|
+
export interface DelegateConfig {
|
|
4
|
+
/** Enable acp_delegate tools (delegate/wait/cancel) and their system-prompt
|
|
5
|
+
* section. Default: true. Set `enabled: false` to skip registering them. */
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
/** How delegate usage is reported back to the main session.
|
|
8
|
+
* "separate" (default) — delegate tokens tracked in a separate accumulator;
|
|
9
|
+
* main session totals stay clean, delegate usage shows as its own block in
|
|
10
|
+
* acp_status (excluded from main totals).
|
|
11
|
+
* "merged" — delegate token usage folded into the tool-result usage field,
|
|
12
|
+
* counted as part of the main session totals. */
|
|
13
|
+
displayUsage?: "merged" | "separate";
|
|
14
|
+
}
|
|
15
|
+
/** Compression tuning. All fields accept a ratio (0.75) or percent string
|
|
16
|
+
* ("75%") where noted. */
|
|
17
|
+
export interface CompressConfig {
|
|
18
|
+
/** Context usage percentage that triggers forced compression nudges
|
|
19
|
+
* (bypasses growth-gate + cadence). Accepts a ratio (0.75) or percent
|
|
20
|
+
* string ("75%"). Default: 0.75. Maps to kernel nudge.maxContextLimitPct. */
|
|
21
|
+
maxContextLimit?: number | string;
|
|
22
|
+
/** Context usage percentage that triggers emergency truncation of large
|
|
23
|
+
* tool outputs. Accepts a ratio (0.95) or percent string ("95%").
|
|
24
|
+
* Default: 0.95. Must be >= maxContextLimit. Maps to kernel
|
|
25
|
+
* nudge.emergencyThresholdPct + truncate.threshold. */
|
|
26
|
+
emergencyThresholdPercent?: number | string;
|
|
27
|
+
/** Token growth threshold for soft compression nudges. Default: 50000.
|
|
28
|
+
* Maps to kernel nudge.growthFloor + nudge.growthCap. */
|
|
29
|
+
nudgeGrowthTokens?: number;
|
|
30
|
+
}
|
|
2
31
|
/**
|
|
3
32
|
* Adapter configuration. Maps onto acp-kernel's `Config` plus Pi-specific knobs
|
|
4
33
|
* (live model context window, protected tools, state persistence).
|
|
@@ -18,16 +47,6 @@ export interface AdapterConfig {
|
|
|
18
47
|
* warnings) are written regardless; `debug` only adds verbose diagnostics.
|
|
19
48
|
* Default: false (or env ACP_DEBUG=1/true). */
|
|
20
49
|
debug?: boolean;
|
|
21
|
-
/** Enable acp_delegate tools (delegate/wait/cancel) and their system-prompt
|
|
22
|
-
* section. Default: true. Set `delegate: false` (adapter config or
|
|
23
|
-
* ~/.pi/acp.json) to skip registering them. */
|
|
24
|
-
delegate?: boolean;
|
|
25
|
-
/** How to display delegate usage in session totals.
|
|
26
|
-
* "merged" — delegate usage is added to main session totals (Pi default).
|
|
27
|
-
* "separate" — delegate usage is tracked separately, displayed in
|
|
28
|
-
* system notifications (excluded from main session totals).
|
|
29
|
-
* Default: "separate" */
|
|
30
|
-
displayUsage?: "merged" | "separate";
|
|
31
50
|
/** Default timeout in seconds injected into the bash tool when the model
|
|
32
51
|
* omits `timeout`. Pi has NO built-in default, so without this a command
|
|
33
52
|
* that the model forgets to time out can hang for thousands of seconds.
|
|
@@ -44,8 +63,33 @@ export interface AdapterConfig {
|
|
|
44
63
|
* head-truncated with a notice telling the model how to see the full output
|
|
45
64
|
* (bash: read BashToolDetails.fullOutputPath). */
|
|
46
65
|
toolOutputMaxBytes?: number;
|
|
66
|
+
/** Delegate sub-agent config. Accepts a boolean shorthand (`true` →
|
|
67
|
+
* `{ enabled: true }`, `false` → `{ enabled: false }`) or a DelegateConfig
|
|
68
|
+
* object. Default: enabled. */
|
|
69
|
+
delegate?: boolean | DelegateConfig;
|
|
70
|
+
/** Compression tuning. */
|
|
71
|
+
compress?: CompressConfig;
|
|
72
|
+
/** Legacy flat alias for `delegate.displayUsage`. Kept for backward
|
|
73
|
+
* compatibility with existing acp.json files. Prefer `delegate.displayUsage`. */
|
|
74
|
+
displayUsage?: "merged" | "separate";
|
|
75
|
+
/** Override acp-kernel's load-bearing compression prompt rules (the 4
|
|
76
|
+
* Prompts fields). Each set field replaces the kernel default verbatim.
|
|
77
|
+
* Requires acknowledgePromptsRisk: true — without it, overrides are dropped
|
|
78
|
+
* (defaults used) and a warning is logged. Set via ~/.pi/acp.json. */
|
|
79
|
+
prompts?: Partial<Prompts>;
|
|
80
|
+
/** Must be true for `prompts` overrides to take effect. Acknowledges that
|
|
81
|
+
* replacing the kernel's tuned compression rules may reduce summary quality
|
|
82
|
+
* (lost paths/signatures/decisions → worse retrieval). */
|
|
83
|
+
acknowledgePromptsRisk?: boolean;
|
|
47
84
|
coreOverrides?: Partial<Config>;
|
|
48
85
|
}
|
|
49
86
|
export declare const DEFAULT_TOOL_BASH_TIMEOUT = 60;
|
|
50
87
|
export declare const DEFAULT_TOOL_OUTPUT_MAX_BYTES = 200000;
|
|
88
|
+
/** Resolve delegate config from the adapter, handling the boolean shorthand
|
|
89
|
+
* and the legacy flat `displayUsage` alias. */
|
|
90
|
+
export declare function resolveDelegate(adapter: AdapterConfig): {
|
|
91
|
+
enabled: boolean;
|
|
92
|
+
displayUsage: "merged" | "separate";
|
|
93
|
+
};
|
|
51
94
|
export declare function resolveConfig(adapter: AdapterConfig, liveContextLimit: number): Config;
|
|
95
|
+
export declare function parsePercent(v: number | string): number;
|
package/dist/delegate-tool.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { Type, type Static } from "typebox";
|
|
|
3
3
|
import type { AgentToolResult, ExtensionAPI, ExtensionContext, ToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { type Usage } from "./delegate-events.js";
|
|
5
5
|
export declare function delegateSpawnOptions(cwd: string, env: NodeJS.ProcessEnv): SpawnOptions;
|
|
6
|
+
/** Resolve the pi CLI entry for delegate child processes.
|
|
7
|
+
* argv[1] is only the pi CLI under a CLI host; embedded hosts (e.g. pi-web)
|
|
8
|
+
* run the SDK inside another node process, so probe instead. Non-pi hosts
|
|
9
|
+
* (omp) keep argv[1] untouched. */
|
|
10
|
+
export declare function resolvePiCliEntry(argv1: string, env?: NodeJS.ProcessEnv, piHost?: boolean): string;
|
|
6
11
|
type RunStatus = "running" | "completed" | "failed" | "cancelled";
|
|
7
12
|
interface DelegateRun {
|
|
8
13
|
runId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type
|
|
2
|
+
import { type AdapterConfig } from "./config.js";
|
|
3
3
|
export declare function createAcpExtension(adapter?: AdapterConfig): ExtensionFactory;
|
|
4
4
|
declare const _default: ExtensionFactory;
|
|
5
5
|
export default _default;
|