billion-context-pi 0.1.37 → 0.1.39

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/dist/runtime.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { ExtensionContext, SessionEntry, SessionMessageEntry } from "@earendil-works/pi-coding-agent";
2
2
  import { type CompressionCore, type CompressionState, type Config, type Prompts } from "acp-kernel";
3
3
  import { type AdapterConfig } from "./config.js";
4
+ import { DensityEstimator } from "./density.js";
4
5
  import { entriesToCoreMessages } from "./messages.js";
5
6
  import { SessionStateStore } from "./state.js";
6
7
  type AgentMessage = SessionMessageEntry["message"];
@@ -9,6 +10,17 @@ export declare function isPiHost(sm: ExtensionContext["sessionManager"]): boolea
9
10
  export interface AcpRuntime {
10
11
  core: CompressionCore;
11
12
  store: SessionStateStore;
13
+ density: DensityEstimator;
14
+ /** 设置 countTokens 闭包使用的 modelId(每轮 context 事件调用)。 */
15
+ setCountModel(modelId: string): void;
16
+ /** Record this session's active block ids for the current context round;
17
+ * returns true when a new active block appeared since the previous round
18
+ * (i.e. a compress happened out-of-band — blocks are created by the
19
+ * compress tool between context events, so they can never be detected by
20
+ * comparing a single processTurn's input/output state). */
21
+ noteActiveBlocks(sid: string, activeBlockIds: string[]): boolean;
22
+ /** Drop per-session tracking state (session_start). */
23
+ clearSessionTracking(sid: string): void;
12
24
  adapter: AdapterConfig;
13
25
  setAdapter(adapter: AdapterConfig): void;
14
26
  prompts: Prompts;
package/dist/tokens.d.ts CHANGED
@@ -6,6 +6,12 @@ export declare function collectCoveredMessageIds(state: {
6
6
  }[];
7
7
  }): Set<string>;
8
8
  export declare function estimateTokens(messages: CoreMessage[], coveredIds?: Set<string>): number;
9
+ /** Scale a raw (uncalibrated) sent-view estimate by the per-model density
10
+ * learned from provider usage (density = real/estimate). Used for nudge /
11
+ * usage / emergency arbitration at every processTurn site so the decision
12
+ * runs on the provider-anchored scale; the estimator itself is always fed
13
+ * the RAW estimate — see density.ts. */
14
+ export declare function calibrateTokens(estimate: number, density: number): number;
9
15
  /** Id of the last user-role entry — used as a per-turn key so a nudge prints at
10
16
  * most once per turn. Returns undefined if there is no user message yet. */
11
17
  export declare function lastUserMessageId(entries: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billion-context-pi",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
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",
@@ -60,9 +60,15 @@
60
60
  "devDependencies": {
61
61
  "@earendil-works/pi-coding-agent": "0.83.0",
62
62
  "@types/node": "^26.1.2",
63
- "acp-kernel": "0.0.23",
63
+ "acp-kernel": "0.0.28",
64
+ "billion-context-kit": "0.2.0",
64
65
  "tsup": "^8.5.1",
65
66
  "tsx": "^4.23.1",
66
67
  "typescript": "^7.0.2"
68
+ },
69
+ "overrides": {
70
+ "billion-context-kit": {
71
+ "acp-kernel": "$acp-kernel"
72
+ }
67
73
  }
68
74
  }