billion-context-dsh 0.2.1 → 0.2.2

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/region.d.ts CHANGED
@@ -143,6 +143,50 @@ export interface SeqCompressibleRange {
143
143
  readonly count: number;
144
144
  readonly tokens: number;
145
145
  }
146
+ /**
147
+ * Hide one successful `compress` tool's call/result pair after its tool/result
148
+ * has been logged. The durable compaction summary is inserted BEFORE the
149
+ * current tool result (the compress tool runs mid-turn), so leaving the pair on
150
+ * the surface would produce `assistant(tool_calls) → user(summary) →
151
+ * tool(result)` — rejected by strict providers. Replacing both nodes with a
152
+ * plain user message (the result text) removes the pair from the derived
153
+ * surface without touching the compaction block.
154
+ */
155
+ export declare function hideCompressToolPair(session: Session, callId: string, resultSeq?: number): boolean;
156
+ /**
157
+ * Surface-level orphan cleanup: hide tool/result nodes with no matching call,
158
+ * assistant tool-call nodes whose calls all lack results, and "broken pairs"
159
+ * whose result is NOT adjacent to the call node on the surface (a
160
+ * non-tool/result node — typically the compaction summary a buggy older
161
+ * version inserted between a compress call and its result — sits between
162
+ * them). A single orphan result corrupts the whole tool-pairing balance cache
163
+ * (every range resolve throws), orphan calls fragment large ranges into tiny
164
+ * uncompressed fragments, and a broken pair cannot serialize for strict
165
+ * providers — the mechanisms behind issue #18's "only ~28 tokens visible".
166
+ * Uses the same durable prune protocol as `hideSurfaceSeqs`, so the removed
167
+ * nodes stay recoverable from the append-only log.
168
+ */
169
+ export declare function stripOrphanedSurfaceToolMessages(session: Session, inFlightCallIds?: ReadonlySet<string>): number;
170
+ /**
171
+ * All tool-call ids currently visible on the surface with no matching
172
+ * tool/result yet — the in-flight calls of the current step. Sibling tools
173
+ * called in the same assistant message as `compress` are in-flight too, so
174
+ * `handleCompress` must protect the whole set (not just its own call id) or
175
+ * the sibling call would be pruned as an orphan and its result would land
176
+ * orphaned (HTTP 400 until the next cleanup).
177
+ */
178
+ export declare function openToolCallIds(session: Session): Set<string>;
179
+ /**
180
+ * Schedule `hideCompressToolPair` on the microtask queue. `session.append`
181
+ * is NOT reentrant: running it synchronously inside a `session/event`
182
+ * listener (while the outer append is still publishing) throws "session
183
+ * append cannot reenter while another append is being published" on live,
184
+ * store-attached sessions, and the dispatcher silently swallows the error —
185
+ * so a synchronous hide is a silent no-op in production. A microtask drains
186
+ * after the current append fully publishes and before the agent loop resumes,
187
+ * so the pair is hidden before the next request is built.
188
+ */
189
+ export declare function deferCompressPairHide(session: Session, callId: string, resultSeq: number, onError?: (error: unknown) => void): void;
146
190
  /**
147
191
  * Compute compressible spans directly from the surface — independent of the
148
192
  * kernel's ref map, which can drift after surface replacements in long
package/dist/tools.d.ts CHANGED
@@ -23,6 +23,13 @@ export interface ToolEnvironment extends KernelConfigInput {
23
23
  readonly windowFor?: (agent: Agent) => Promise<AcpWindow>;
24
24
  /** Resolved prompt templates (optional: falls back to DEFAULT_RESOLVED). */
25
25
  readonly prompts?: ResolvedPrompts;
26
+ /**
27
+ * Call ids of compress invocations that created a durable block. The engine
28
+ * listens for the matching `tool/result` and hides the call/result pair from
29
+ * the surface, preventing the compaction summary from sitting between them
30
+ * (strict providers reject that sequence with HTTP 400).
31
+ */
32
+ readonly compressCallIdsToHide?: Set<string>;
26
33
  }
27
34
  /** Build the four ACP model tools bound to one engine. */
28
35
  export declare function makeTools(env: ToolEnvironment): ToolDefinition[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billion-context-dsh",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Active Context Pruning (ACP) for the DeepSeek Harness — model-driven context management as a CompactionEngine backend.",
5
5
  "keywords": [
6
6
  "deepseek",