@herbertgao/sol-pi 0.2.0 → 0.3.1
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 +3 -3
- package/THIRD_PARTY_NOTICES.md +4 -4
- package/agents-install.md +4 -4
- package/docs/compatibility.md +7 -7
- package/package.json +2 -2
- package/src/sol-pi/extensions/action-fusion/index.ts +0 -5
- package/src/sol-pi/extensions/online-context-compact/economics.ts +4 -4
- package/src/sol-pi/extensions/online-context-compact/extension.ts +41 -1
- package/src/sol-pi/extensions/online-context-compact/state.ts +3 -1
package/README.md
CHANGED
|
@@ -56,16 +56,16 @@ Read the [SoL-Pi blog](https://nvlabs.github.io/SoL-Pi/) for a deeper look at th
|
|
|
56
56
|
|
|
57
57
|
### Requirements
|
|
58
58
|
|
|
59
|
-
- Node.js
|
|
59
|
+
- Node.js 24 or newer
|
|
60
60
|
- npm
|
|
61
|
-
- `@earendil-works/pi-coding-agent` 0.
|
|
61
|
+
- `@earendil-works/pi-coding-agent` 0.85.1
|
|
62
62
|
|
|
63
63
|
### Install
|
|
64
64
|
|
|
65
65
|
Install the tested Pi release:
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
npm install --global @earendil-works/pi-coding-agent@0.
|
|
68
|
+
npm install --global @earendil-works/pi-coding-agent@0.85.1
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
Then install SoL-Pi directly from [NVlabs/SoL-Pi](https://github.com/NVlabs/SoL-Pi):
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -8,10 +8,10 @@ The following packages are supplied by the user's Pi installation and retain the
|
|
|
8
8
|
|
|
9
9
|
| Package | Development-tested version | License | Source |
|
|
10
10
|
| --- | ---: | --- | --- |
|
|
11
|
-
| `@earendil-works/pi-agent-core` | 0.
|
|
12
|
-
| `@earendil-works/pi-ai` | 0.
|
|
13
|
-
| `@earendil-works/pi-coding-agent` | 0.
|
|
14
|
-
| `@earendil-works/pi-tui` | 0.
|
|
11
|
+
| `@earendil-works/pi-agent-core` | 0.85.1 | MIT | <https://github.com/earendil-works/pi> |
|
|
12
|
+
| `@earendil-works/pi-ai` | 0.85.1 | MIT | <https://github.com/earendil-works/pi> |
|
|
13
|
+
| `@earendil-works/pi-coding-agent` | 0.85.1 | MIT | <https://github.com/earendil-works/pi> |
|
|
14
|
+
| `@earendil-works/pi-tui` | 0.85.1 | MIT | <https://github.com/earendil-works/pi> |
|
|
15
15
|
| `typebox` | 1.3.7 | MIT | <https://github.com/sinclairzx81/typebox> |
|
|
16
16
|
|
|
17
17
|
## Development-only dependencies
|
package/agents-install.md
CHANGED
|
@@ -7,7 +7,7 @@ Installation and configuration are complete only when Pi remains unmodified, the
|
|
|
7
7
|
## Rules
|
|
8
8
|
|
|
9
9
|
- Do not modify, patch, fork, or vendor upstream Pi. SoL-Pi must load as a standalone extension through Pi's public package interface.
|
|
10
|
-
- Use Node.js
|
|
10
|
+
- Use Node.js 24 or newer and the tested Pi release `@earendil-works/pi-coding-agent@0.85.1`. Treat a different Pi version as a compatibility change and rerun the full suite before using it.
|
|
11
11
|
- Do not clean, reset, switch, or overwrite unrelated repository changes.
|
|
12
12
|
- Do not print, log, commit, upload, or include any secret in a command line. Check only whether a credential is present.
|
|
13
13
|
- Keep SoL-Pi settings in `sol-pi.json`. The Evidence-Preserving Reducer provider/model route is a SoL-Pi setting; provider URLs, credentials, the main agent model, and shell behavior remain Pi settings.
|
|
@@ -35,7 +35,7 @@ node --version
|
|
|
35
35
|
npm --version
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Require Node.js
|
|
38
|
+
Require Node.js 24 or newer. Install from the lockfile and run the source checks:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
41
|
npm ci --ignore-scripts
|
|
@@ -54,11 +54,11 @@ Stop if any command fails. Do not hide a failure with `|| true` or replace `npm
|
|
|
54
54
|
Install the tested Pi release without changing its source:
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
npm install --global --ignore-scripts @earendil-works/pi-coding-agent@0.
|
|
57
|
+
npm install --global --ignore-scripts @earendil-works/pi-coding-agent@0.85.1
|
|
58
58
|
pi --version
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
Require `pi --version` to report `0.
|
|
61
|
+
Require `pi --version` to report `0.85.1`.
|
|
62
62
|
|
|
63
63
|
For a project-local registration, run this from `target_project` and substitute the resolved absolute `sol_pi_root`:
|
|
64
64
|
|
package/docs/compatibility.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Pi Compatibility
|
|
2
2
|
|
|
3
|
-
SoL-Pi is developed and tested against `@earendil-works/pi-coding-agent` 0.
|
|
3
|
+
SoL-Pi is developed and tested against `@earendil-works/pi-coding-agent` 0.85.1. Its public API surface is also type-checked and exercised against Pi 0.81.1, the base used by the original Pi fork. The runtime range is deliberately expressed as a peer dependency because Pi owns installation and upgrade of its packages.
|
|
4
4
|
|
|
5
5
|
SoL-Pi imports only public package exports:
|
|
6
6
|
|
|
@@ -21,7 +21,7 @@ Action Fusion decodes `file://` targets with Node's `fileURLToPath()` before res
|
|
|
21
21
|
|
|
22
22
|
The queue covers only fused operations registered by this SoL-Pi instance. External processes, direct built-in-tool calls outside the replacement, and unrelated extensions are not globally locked. SoL-Pi hashes the target immediately before launching `then_run` and skips the command if it observes an intervening content change.
|
|
23
23
|
|
|
24
|
-
When another extension already owns `write`, Action Fusion leaves that tool in place and only registers its `edit` replacement.
|
|
24
|
+
When another extension already owns `write`, Action Fusion leaves that tool in place and only registers its `edit` replacement.
|
|
25
25
|
|
|
26
26
|
## ObservationPack
|
|
27
27
|
|
|
@@ -31,7 +31,7 @@ ObservationPack changes only the messages projected through the public `context`
|
|
|
31
31
|
|
|
32
32
|
The reducer handles public `tool_result` events and resolves the configured reducer provider/model through Pi's model registry before calling `ExtensionContext.modelRegistry.complete()` when available. For the Pi 0.81.1 fork, which exposes no registry `complete()` method, it resolves authentication for that reducer model through `getApiKeyAndHeaders()` and calls the shared `@earendil-works/pi-ai/compat` completion API. The reducer preserves the original result whenever the configured reducer model is unavailable or eligibility, model-call, schema, source-hash, exact-quote, size, or likely-secret checks fail.
|
|
33
33
|
|
|
34
|
-
All persistent paths use `SessionManager.getSessionDir()` and `getSessionId()`, which are present in both the fork and Pi 0.
|
|
34
|
+
All persistent paths use `SessionManager.getSessionDir()` and `getSessionId()`, which are present in both the fork and Pi 0.85.1. SoL-Pi creates no configurable storage-path surface.
|
|
35
35
|
|
|
36
36
|
The unpublished shared artifact layout is not read or migrated. Each session starts from its own `<sessionDir>/sol-pi/<sessionId>/` directory.
|
|
37
37
|
|
|
@@ -41,13 +41,13 @@ Online Context Compact uses ordinary public `context` and `before_provider_reque
|
|
|
41
41
|
|
|
42
42
|
Before selecting or executing a boundary compaction, it also checks the optional `Symbol.for("pi-subagents:manager")` registry exposed by `pi-subagents`. A running top-level subagent, or an unreadable registry, suppresses that compaction rather than risking a context rewrite during delegated work. When the registry is absent, the check is a no-op.
|
|
43
43
|
|
|
44
|
-
Pi does not expose its active retained-tail compaction setting through the public extension context. The standalone extension therefore uses the documented Pi 0.
|
|
44
|
+
Pi does not expose its active retained-tail compaction setting through the public extension context. The standalone extension therefore uses the documented Pi 0.85.1 default of 20,000 tokens for its economic estimate. Its programmatic factory accepts an explicit matching value for a non-default Pi setting.
|
|
45
45
|
|
|
46
|
-
Pi 0.
|
|
46
|
+
Pi 0.85.1's `ExtensionContext.compact()` aborts the active agent before it summarizes, and `agent_settled` fires only once a whole run has drained every turn, retry, auto-compaction, and queued continuation. A plan boundary that selects compaction therefore saves its plan and progress state, calls `ExtensionContext.abort()` to stop the run, and runs compaction from the `agent_settled` that stop produces. The handler awaits the compaction's own `onComplete`/`onError` callbacks. On success, the extension sends a hidden reminder through public `ExtensionAPI.sendMessage()` with `triggerTurn: true`, so Pi starts a new turn against the compacted context and rebuilds the plan even when the native summary omits that instruction.
|
|
47
47
|
|
|
48
48
|
A settlement barrier keeps the original `agent_settled` dispatch open until the triggered continuation settles. Print- and JSON-mode processes therefore complete the compact-and-continue sequence within the same Pi invocation; an outer driver does not need to resume the session or send `Continue working`. This continuation is armed only by a successful boundary compaction. Cancelling or exiting does not schedule one. A Pi build that never emits `agent_settled` starts no boundary compaction.
|
|
49
49
|
|
|
50
|
-
Pi 0.
|
|
50
|
+
Pi 0.85.1 does not return a promise from `ExtensionAPI.sendMessage()`. The barrier is therefore verified for standalone SoL-Pi and depends on Pi starting the requested turn synchronously. A later-loaded third-party extension that performs long asynchronous work in its own `agent_settled` handler is outside this guarantee and needs an integration test with that extension set.
|
|
51
51
|
|
|
52
52
|
Pi reports the session as idle while an extension-requested manual compaction is running. SoL-Pi cancels `session_before_tree` during that interval to prevent tree navigation from moving the active leaf underneath the compaction. Navigation works normally after the compaction callback settles.
|
|
53
53
|
|
|
@@ -57,7 +57,7 @@ The standalone entry passes `cacheWriteReadRatio` from `sol-pi.json` directly in
|
|
|
57
57
|
|
|
58
58
|
## Interactive TUI
|
|
59
59
|
|
|
60
|
-
The lightning savings treatment uses Pi 0.
|
|
60
|
+
The lightning savings treatment uses Pi 0.85.1's public `renderCall`,
|
|
61
61
|
`renderResult`, `ctx.ui.notify()`, and keyed `ctx.ui.setStatus()` APIs. It checks
|
|
62
62
|
`ctx.mode === "tui"` rather than `ctx.hasUI`, because RPC mode also reports UI
|
|
63
63
|
support. The renderer therefore changes only the interactive terminal display;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herbertgao/sol-pi",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Token-efficient context and tool extensions for Pi, maintained from NVlabs/SoL-Pi.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"vitest": "^4.0.18"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
62
|
+
"node": ">=24"
|
|
63
63
|
},
|
|
64
64
|
"pi": {
|
|
65
65
|
"extensions": [
|
|
@@ -80,11 +80,6 @@ export function createActionFusionExtension(options: ActionFusionOptions = {}):
|
|
|
80
80
|
const baseWrite = memoizeByCwd((cwd: string) => createWriteToolDefinition(cwd, options.writeOptions));
|
|
81
81
|
|
|
82
82
|
return (pi: ExtensionAPI) => {
|
|
83
|
-
// then_run executes Bash inside the mutation tool, so it cannot pass through
|
|
84
|
-
// Pi's public tool_call permission handlers. Leave it to automode instead of
|
|
85
|
-
// creating a nested shell escape hatch.
|
|
86
|
-
if (hasExternalToolOwner(pi, "automode_inspect")) return;
|
|
87
|
-
|
|
88
83
|
const editTemplate = baseEdit(process.cwd());
|
|
89
84
|
const writeTemplate = baseWrite(process.cwd());
|
|
90
85
|
|
|
@@ -218,9 +218,8 @@ export function decideCompaction(input: {
|
|
|
218
218
|
carriedDebtTokens: input.carriedDebtTokens,
|
|
219
219
|
cacheDebtRepaymentTokens: input.cacheDebtRepaymentTokens,
|
|
220
220
|
compact,
|
|
221
|
-
reason:
|
|
222
|
-
?
|
|
223
|
-
: windowProtection
|
|
221
|
+
reason: compressible
|
|
222
|
+
? windowProtection
|
|
224
223
|
? "window_protection"
|
|
225
224
|
: economic
|
|
226
225
|
? "economic"
|
|
@@ -232,6 +231,7 @@ export function decideCompaction(input: {
|
|
|
232
231
|
? "deferred_subsequent_margin"
|
|
233
232
|
: !firstCompaction && baseEconomic && !carriedDebtGateOpen
|
|
234
233
|
? "deferred_carried_debt"
|
|
235
|
-
: "deferred_economic"
|
|
234
|
+
: "deferred_economic"
|
|
235
|
+
: "non_positive_saving",
|
|
236
236
|
};
|
|
237
237
|
}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import type { AgentMessage, AgentToolResult } from "@earendil-works/pi-agent-core";
|
|
5
|
+
import type { AgentMessage, AgentToolResult, ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
6
6
|
import {
|
|
7
7
|
buildSessionContext,
|
|
8
8
|
estimateTokens,
|
|
9
9
|
findCutPoint,
|
|
10
10
|
sessionEntryToContextMessages,
|
|
11
|
+
type ExtensionAPI,
|
|
11
12
|
type ExtensionContext,
|
|
12
13
|
type ExtensionFactory,
|
|
13
14
|
type SessionEntry,
|
|
@@ -165,6 +166,37 @@ function validPositiveInteger(value: unknown): value is number {
|
|
|
165
166
|
return typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
166
167
|
}
|
|
167
168
|
|
|
169
|
+
type CompactionThinkingOverride = {
|
|
170
|
+
readonly previous: ThinkingLevel;
|
|
171
|
+
readonly applied: ThinkingLevel;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// Native summaries share their output cap with reasoning; reserve the cap for summary text.
|
|
175
|
+
function lowerCompactionThinking(
|
|
176
|
+
pi: ExtensionAPI,
|
|
177
|
+
reasoning: boolean,
|
|
178
|
+
): CompactionThinkingOverride | undefined {
|
|
179
|
+
if (!reasoning) return;
|
|
180
|
+
try {
|
|
181
|
+
const previous = pi.getThinkingLevel();
|
|
182
|
+
if (previous !== "high" && previous !== "xhigh" && previous !== "max") return;
|
|
183
|
+
pi.setThinkingLevel("medium");
|
|
184
|
+
const applied = pi.getThinkingLevel();
|
|
185
|
+
return applied === previous ? undefined : { previous, applied };
|
|
186
|
+
} catch {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function restoreCompactionThinking(pi: ExtensionAPI, override: CompactionThinkingOverride | undefined): void {
|
|
192
|
+
if (!override) return;
|
|
193
|
+
try {
|
|
194
|
+
if (pi.getThinkingLevel() === override.applied) pi.setThinkingLevel(override.previous);
|
|
195
|
+
} catch {
|
|
196
|
+
// A compaction result must not be masked by a best-effort state restore.
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
168
200
|
function releaseParentContinuation(continuation: PendingContinuation | undefined): void {
|
|
169
201
|
if (continuation) setTimeout(continuation.resolve, 0);
|
|
170
202
|
}
|
|
@@ -182,6 +214,7 @@ export function createOnlineContextCompactExtension(options: OnlineContextCompac
|
|
|
182
214
|
let activeDebt: CacheDebt | undefined;
|
|
183
215
|
let nextContinuation: PendingContinuation | undefined;
|
|
184
216
|
let compactionInFlight = false;
|
|
217
|
+
let compactionThinkingOverride: CompactionThinkingOverride | undefined;
|
|
185
218
|
|
|
186
219
|
const releaseContinuation = (): void => {
|
|
187
220
|
const continuation = nextContinuation;
|
|
@@ -349,6 +382,7 @@ export function createOnlineContextCompactExtension(options: OnlineContextCompac
|
|
|
349
382
|
let compactionError: Error | undefined;
|
|
350
383
|
try {
|
|
351
384
|
compactionInFlight = true;
|
|
385
|
+
compactionThinkingOverride = lowerCompactionThinking(pi, context.model?.reasoning === true);
|
|
352
386
|
await new Promise<void>((resolve) => {
|
|
353
387
|
let finished = false;
|
|
354
388
|
const finish = (): void => {
|
|
@@ -382,6 +416,8 @@ export function createOnlineContextCompactExtension(options: OnlineContextCompac
|
|
|
382
416
|
},
|
|
383
417
|
});
|
|
384
418
|
});
|
|
419
|
+
restoreCompactionThinking(pi, compactionThinkingOverride);
|
|
420
|
+
compactionThinkingOverride = undefined;
|
|
385
421
|
compactionInFlight = false;
|
|
386
422
|
if (
|
|
387
423
|
compactionError &&
|
|
@@ -422,6 +458,8 @@ export function createOnlineContextCompactExtension(options: OnlineContextCompac
|
|
|
422
458
|
await continuation.promise;
|
|
423
459
|
}
|
|
424
460
|
} finally {
|
|
461
|
+
restoreCompactionThinking(pi, compactionThinkingOverride);
|
|
462
|
+
compactionThinkingOverride = undefined;
|
|
425
463
|
compactionInFlight = false;
|
|
426
464
|
activeDebt = undefined;
|
|
427
465
|
releaseParentContinuation(parentContinuation);
|
|
@@ -445,6 +483,8 @@ export function createOnlineContextCompactExtension(options: OnlineContextCompac
|
|
|
445
483
|
});
|
|
446
484
|
|
|
447
485
|
pi.on("session_shutdown", () => {
|
|
486
|
+
restoreCompactionThinking(pi, compactionThinkingOverride);
|
|
487
|
+
compactionThinkingOverride = undefined;
|
|
448
488
|
releaseContinuation();
|
|
449
489
|
pendingBoundary = undefined;
|
|
450
490
|
selected = undefined;
|
|
@@ -180,7 +180,9 @@ export function recordCompaction(
|
|
|
180
180
|
return {
|
|
181
181
|
...state,
|
|
182
182
|
epoch: state.epoch + 1,
|
|
183
|
-
plan
|
|
183
|
+
// Keep the plan so the post-compaction rebuild does not reclassify
|
|
184
|
+
// already-completed steps as a new boundary.
|
|
185
|
+
plan: [...state.plan],
|
|
184
186
|
pendingProgress: [],
|
|
185
187
|
lastContextTokens: null,
|
|
186
188
|
positiveContextDeltaTotal: 0,
|