billion-context-pi 0.1.82 → 0.1.83-pr.241.511
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 +26 -1
- package/README.zh-CN.md +2 -1
- package/dist/{chunk-AKZJYVLH.js → chunk-LLFL3CNI.js} +2 -2
- package/dist/compress-model.d.ts +76 -0
- package/dist/compress-tool.d.ts +2 -2
- package/dist/config-dir.d.ts +31 -0
- package/dist/config.d.ts +14 -0
- package/dist/contract.js +1 -1
- package/dist/floor-stale.d.ts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20619 -19858
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +7 -0
- package/dist/runtime.d.ts +43 -4
- package/dist/session-log.d.ts +11 -0
- package/dist/state.d.ts +2 -0
- package/dist/turn-boundary.d.ts +11 -1
- package/dist/user-config.d.ts +9 -0
- package/package.json +2 -1
- /package/dist/{chunk-AKZJYVLH.js.map → chunk-LLFL3CNI.js.map} +0 -0
package/dist/messages.d.ts
CHANGED
|
@@ -13,6 +13,13 @@ export declare const ACP_EXPORT_CUSTOM_TYPE = "acp-export";
|
|
|
13
13
|
* reach the model through the feature's own channel, so the human-facing
|
|
14
14
|
* report must never be re-billed as model context. */
|
|
15
15
|
export declare const ACP_RULE_CUSTOM_TYPE = "acp-rule";
|
|
16
|
+
/** Nudge persistence record (issue #326): written via pi.appendEntry as a
|
|
17
|
+
* type:"custom" entry — never projected into the sent view (see above), so
|
|
18
|
+
* the compact one-liner stays out of model context while surviving restarts. */
|
|
19
|
+
export declare const ACP_NUDGE_CUSTOM_TYPE = "acp-nudge";
|
|
20
|
+
export interface AcpNudgeRecord {
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
16
23
|
/** True for host-injected custom_message entries that participate in LLM
|
|
17
24
|
* context: non-empty custom_message except the UI-only types in
|
|
18
25
|
* CONTEXT_EXCLUDED_CUSTOM_TYPES (acp-status panels, acp-export docs,
|
package/dist/runtime.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type AdapterConfig } from "./config.js";
|
|
|
4
4
|
import { type CompressReasoningConfig } from "./reasoning-drop.js";
|
|
5
5
|
import { entriesToCoreMessages } from "./messages.js";
|
|
6
6
|
import { SessionStateStore } from "./state.js";
|
|
7
|
+
import { CompressionModelClient } from "./compress-model.js";
|
|
7
8
|
import { ThrottleEpisode } from "./throttle-retry.js";
|
|
8
9
|
import { OverflowEpisode } from "./overflow-selfheal.js";
|
|
9
10
|
import { type TurnBoundaryPolicy } from "./turn-boundary.js";
|
|
@@ -51,10 +52,27 @@ export interface AcpRuntime {
|
|
|
51
52
|
* that cycles through many sessions doesn't accumulate them. */
|
|
52
53
|
throttleDrop: (sid: string) => void;
|
|
53
54
|
/** Per-session tokenCount scale tracker (estimate vs provider). Returns true
|
|
54
|
-
* when the
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
|
|
55
|
+
* when the dominant ruler (hostFloor vs sentTokens) just switched by more
|
|
56
|
+
* than the hysteresis dead-band, so the caller can reset the growth baseline
|
|
57
|
+
* — a cross-scale delta is a false artifact, not real growth (issue #267).
|
|
58
|
+
* Near-tied rulers jittering inside the band do NOT report a flip (#598).
|
|
59
|
+
* The first observation for a session never reports a flip. */
|
|
60
|
+
noteTokenScale: (sid: string, hostFloor: number, sentTokens: number) => boolean;
|
|
61
|
+
/** Settle the previous request's pending estimate against the usage that
|
|
62
|
+
* arrived for it; learn/publish/clear the k̂ calibration factor. Returns
|
|
63
|
+
* the current k̂ (null while unpublished) and whether the meter's ruler
|
|
64
|
+
* just changed (model switch, k̂ publish or disagreement clear) — the
|
|
65
|
+
* caller re-anchors growth baselines on that transition (#598 root fix). */
|
|
66
|
+
noteKhatUsage: (sid: string, model: string, usageTokens: number) => {
|
|
67
|
+
khat: number | null;
|
|
68
|
+
scaleChanged: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** Current published k̂ for the session+model, or null. */
|
|
71
|
+
khatFor: (sid: string, model: string) => number | null;
|
|
72
|
+
/** Record the estimate of the request being assembled; settled next turn. */
|
|
73
|
+
setKhatPending: (sid: string, model: string, estimate: number) => void;
|
|
74
|
+
/** Drop a session's k̂ calibration state (session_shutdown). */
|
|
75
|
+
dropKhat: (sid: string) => void;
|
|
58
76
|
/** Drop a session's token-scale tracker (session_shutdown). */
|
|
59
77
|
dropTokenScale: (sid: string) => void;
|
|
60
78
|
store: SessionStateStore;
|
|
@@ -68,6 +86,11 @@ export interface AcpRuntime {
|
|
|
68
86
|
nudgeShownTokensFor(sid: string, turnKey: string): number | undefined;
|
|
69
87
|
/** Clears the token-count stamps recorded by markNudgeShown — used on a token-scale flip (issue #267) so the same-turn re-inject floor (#269 / PR #316) is not computed against an old-scale stamp. */
|
|
70
88
|
clearNudgeTokenStamps(sid: string): void;
|
|
89
|
+
/** Like the nudgeShown* pair but tracks the persisted display-only session
|
|
90
|
+
* entry (issue #326): at most one record per user turn even when the
|
|
91
|
+
* emergency nudge re-injects on every LLM call. */
|
|
92
|
+
markNudgeRecorded(sid: string, turnKey: string): void;
|
|
93
|
+
nudgeRecordedFor(sid: string, turnKey: string): boolean;
|
|
71
94
|
/** Process compress toolResults for the CURRENT user turn only (the caller
|
|
72
95
|
* scopes the list — see collectCompressOutcomes in src/index.ts); idempotent
|
|
73
96
|
* per toolCallId. turnKey MUST be the stable persisted-boundary key
|
|
@@ -158,6 +181,22 @@ export interface AcpRuntime {
|
|
|
158
181
|
* the map entry so a long-lived process cycling through many sessions
|
|
159
182
|
* doesn't accumulate them. */
|
|
160
183
|
overflowDrop(sid: string): void;
|
|
184
|
+
/** Client for the dedicated compression model (reads models.json). */
|
|
185
|
+
compressionModel: CompressionModelClient;
|
|
186
|
+
/** The configured compression model ref, or undefined (main model writes). */
|
|
187
|
+
getCompressionModelRef(): string | undefined;
|
|
188
|
+
/** Persist the compression model ref to ~/.pi/acp.json and update the
|
|
189
|
+
* in-memory adapter so it takes effect immediately. null clears it. */
|
|
190
|
+
setCompressionModelRef(value: string | null): Promise<void>;
|
|
191
|
+
/** Store the exact transformed AgentMessage[] Pi sent in the last context
|
|
192
|
+
* round. The dedicated compression model reuses this as a prompt prefix so
|
|
193
|
+
* its call hits the provider's prompt cache (same system prompt + tools +
|
|
194
|
+
* messages the main model just saw). */
|
|
195
|
+
setLastSentMessages(sid: string, messages: AgentMessage[]): void;
|
|
196
|
+
/** The transformed messages from the last context round, or null. */
|
|
197
|
+
getLastSentMessages(sid: string): AgentMessage[] | null;
|
|
198
|
+
/** Drop a session's stored last-sent messages (session_shutdown). */
|
|
199
|
+
clearLastSentMessages(sid: string): void;
|
|
161
200
|
/** Record a compress call whose every requested range is dead (refs stale or
|
|
162
201
|
* unknown — the kernel cannot create a block from it no matter what summary
|
|
163
202
|
* is written). Returns the failure count for this exact range fingerprint
|
package/dist/session-log.d.ts
CHANGED
|
@@ -10,3 +10,14 @@ export declare function parseSessionLog(text: string): SessionEntry[];
|
|
|
10
10
|
* returns entries whose base id is in `wantedBaseIds`. The starting session
|
|
11
11
|
* itself is never included; nearest-ancestor entries win on duplicate ids. */
|
|
12
12
|
export declare function loadAncestorEntries(sessionFile: string | undefined, wantedBaseIds: Set<string>): Promise<SessionEntry[]>;
|
|
13
|
+
/** Read-only content recovery for content-addressed `live-*` refs (issue
|
|
14
|
+
* #579): fork hosts alias not-yet-persisted tail messages with `live-*` ids
|
|
15
|
+
* (runtime.ts mergeLiveEntries); those aliases appear in NO jsonl, so the
|
|
16
|
+
* entry-id lookup above can never find them. The rawId→identity bridge lives
|
|
17
|
+
* in each session's OWN sidecar (liveRefOrigins). Walks the chain — itself
|
|
18
|
+
* first, then ancestors, same depth/cycle rules as loadAncestorEntries — and
|
|
19
|
+
* at each level pairs that level's declared origins with that same level's
|
|
20
|
+
* log entries matched by messageIdentity. First matching entry wins per rawId
|
|
21
|
+
* (identical identities are interchangeable: identity covers full normalized
|
|
22
|
+
* content). Never writes any sidecar. */
|
|
23
|
+
export declare function loadLiveRefEntries(sessionFile: string | undefined, wantedRawIds: Set<string>): Promise<Map<string, SessionEntry>>;
|
package/dist/state.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type CompressionState } from "acp-kernel";
|
|
2
|
+
export declare const STATE_SUFFIX = ".acp.json";
|
|
2
3
|
export interface LiveRefOrigin {
|
|
3
4
|
rawId: string;
|
|
4
5
|
identity: string;
|
|
@@ -38,3 +39,4 @@ export declare class SessionStateStore {
|
|
|
38
39
|
* use this: their session files carry a parentSession header that already
|
|
39
40
|
* inherits the parent state verbatim. */
|
|
40
41
|
export declare function deriveChildState(parent: CompressionState): CompressionState;
|
|
42
|
+
export declare function parseLiveRefOrigins(value: unknown): LiveRefOrigin[];
|
package/dist/turn-boundary.d.ts
CHANGED
|
@@ -27,10 +27,20 @@ export interface TurnBoundaryEntry {
|
|
|
27
27
|
* standalone pi users' nudge cadence unchanged. */
|
|
28
28
|
export interface TurnBoundaryPolicy {
|
|
29
29
|
countCustomMessages?: boolean;
|
|
30
|
+
/** #578: optional customType allowlist refining countCustomMessages. When
|
|
31
|
+
* set, only injected entries whose customType is listed delimit turns —
|
|
32
|
+
* host metadata injections (harness_digest, ipython_state, …) that enter
|
|
33
|
+
* LLM context without being a real host turn stay out of turn accounting.
|
|
34
|
+
* Unset = every non-empty injected message counts (pre-#578 behavior).
|
|
35
|
+
* Entries without a customType never match; UI-only types stay excluded
|
|
36
|
+
* even when listed. Ignored unless countCustomMessages is true. */
|
|
37
|
+
customMessageTypes?: readonly string[];
|
|
30
38
|
}
|
|
31
39
|
/** The ONE turn-boundary predicate (#364): does this entry start a new turn?
|
|
32
40
|
* Genuine user-role messages always do (pi-native); host-injected
|
|
33
|
-
* custom_message entries do only when the host opts in via policy
|
|
41
|
+
* custom_message entries do only when the host opts in via policy, optionally
|
|
42
|
+
* refined by a customMessageTypes allowlist so metadata injections
|
|
43
|
+
* (harness_digest, ipython_state) stay out of turn accounting (#578). */
|
|
34
44
|
export declare function isTurnBoundary(entry: TurnBoundaryEntry, policy?: TurnBoundaryPolicy): boolean;
|
|
35
45
|
/** Id of the last turn-boundary entry — the per-turn key for nudge
|
|
36
46
|
* accounting, retry caps and outcome scoping. Defaults to pi-native
|
package/dist/user-config.d.ts
CHANGED
|
@@ -27,6 +27,9 @@ export interface UserAcpConfig {
|
|
|
27
27
|
displayUsage?: "merged" | "separate";
|
|
28
28
|
prompts?: Partial<Prompts>;
|
|
29
29
|
acknowledgePromptsRisk?: boolean;
|
|
30
|
+
/** Model ref (bare id or "provider/id") from models.json used for compression
|
|
31
|
+
* summaries. Absent = main model writes summaries (default). */
|
|
32
|
+
compressionModelId?: string;
|
|
30
33
|
promptSections?: PiPromptSections;
|
|
31
34
|
nudgeSections?: NudgeSectionsConfig;
|
|
32
35
|
toolPrompts?: ToolPromptsConfig;
|
|
@@ -56,3 +59,9 @@ export declare function parseAcpJson(file: string, raw: string): AcpJsonParse;
|
|
|
56
59
|
* and a malformed value must warn + fall back, never fail the session or feed
|
|
57
60
|
* garbage to the kernel (#499). */
|
|
58
61
|
export declare function applyUserConfig(adapter: AdapterConfig, user: UserAcpConfig): AdapterConfig;
|
|
62
|
+
/** Persist compressionModelId to the GLOBAL acp.json (~/.pi/acp.json under Pi;
|
|
63
|
+
* other keys preserved). Pass null to clear it (reverts to main-model
|
|
64
|
+
* compression). The path resolves through the same helper the loader uses,
|
|
65
|
+
* and a malformed-but-repairable file is salvaged like on load (#467) —
|
|
66
|
+
* never clobbered by a single-key rewrite. */
|
|
67
|
+
export declare function saveCompressionModelId(value: string | null): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billion-context-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.83-pr.241.511",
|
|
4
4
|
"description": "One billion, not one million. Model-driven context management for the Pi coding agent.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"typebox": "*"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
+
"@earendil-works/pi-ai": "0.83.0",
|
|
67
68
|
"@earendil-works/pi-coding-agent": "0.83.0",
|
|
68
69
|
"@earendil-works/pi-tui": "0.83.0",
|
|
69
70
|
"@types/node": "^26.1.2",
|
|
File without changes
|