billion-context-dsh 0.2.18 → 0.2.20

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
@@ -39,7 +39,19 @@ export interface AcpBlockLedgerEntry {
39
39
  }
40
40
  /** The open turn number, or null when the log ends between turns. */
41
41
  export declare function findOpenTurn(events: readonly SessionEvent[]): number | null;
42
- /** Reject a second concurrent compaction for the same session. */
42
+ /**
43
+ * Reject a second concurrent compaction for the same session.
44
+ *
45
+ * Compaction is synchronous and a session is single-writer, so a
46
+ * `compaction/start` with NO matching `compaction/end` in the durable log can
47
+ * only be a stale leftover from a prior run that died mid-write (a hard kill,
48
+ * not a caught throw — every caught throw is paired with a compensating
49
+ * `compaction/end` in runCompactionTransaction). Such a leftover must NOT
50
+ * permanently block every later compress call: this treats it as stale,
51
+ * surfaces it once, and lets a new compaction proceed. The old "already
52
+ * active" throw only fired when a genuine concurrent compaction existed,
53
+ * which the synchronous single-writer premise makes impossible.
54
+ */
43
55
  export declare function assertNoActiveCompaction(events: readonly SessionEvent[]): void;
44
56
  /**
45
57
  * A requested range whose EVERY live message was already shadowed by one or
package/dist/window.d.ts CHANGED
@@ -1,12 +1,17 @@
1
1
  /**
2
2
  * Auto context-window detection — resolve the model's real context window
3
- * from the host LLM runtime instead of trusting a hardcoded config default.
3
+ * from the host LLM runtime instead of trusting a hardcoded config default,
4
+ * plus the adapter's per-request output cap (the output reservation subtracted
5
+ * from it so pressure decisions run against the SUSTAINABLE input budget, not
6
+ * the raw window).
4
7
  *
5
8
  * `agent.ctx.llm` (the cordis `LlmRuntime` service) exposes
6
- * `resolveModelInfo(provider, model)` → `{ context: { contextWindow } }`, the
7
- * exact-route capacity the adapter learned from the provider API (pi-ai reads
8
- * `context_window`/`context_length` during discovery). Probing is a standalone
9
- * capability query no request is sent.
9
+ * `resolveModelInfo(provider, model)` →
10
+ * `{ context: { contextWindow }, defaultMaxTokens }` the exact-route
11
+ * capacity the adapter learned from the provider API (pi-ai reads
12
+ * `context_window`/`context_length` during discovery) plus the output cap it
13
+ * applies when callers omit one. Probing is a standalone capability query —
14
+ * no request is sent.
10
15
  * @module billion-context-dsh/window
11
16
  */
12
17
  import type { Agent } from '@deepseek-ai/dsh-agent';
@@ -34,6 +39,19 @@ export interface AcpWindow {
34
39
  * silently fell back to 128K and produced false emergency nudges).
35
40
  */
36
41
  readonly probeFailed?: boolean;
42
+ /**
43
+ * The model's TOTAL context window in tokens, before the output reservation
44
+ * was subtracted. Set only when `outputReserved` is set:
45
+ * `limit = rawLimit - outputReserved`.
46
+ */
47
+ readonly rawLimit?: number;
48
+ /**
49
+ * The adapter's per-request output cap (`defaultMaxTokens`) in tokens,
50
+ * subtracted from `rawLimit` to yield `limit` — the output reservation the
51
+ * provider guarantees at the end of the window on every request. Set only
52
+ * when the host discloses it and it is smaller than the raw window.
53
+ */
54
+ readonly outputReserved?: number;
37
55
  }
38
56
  /** Human label for an AcpWindow's source (used by /acp status). */
39
57
  export declare function windowSourceLabel(window: AcpWindow): string;
@@ -48,6 +66,26 @@ export declare function windowSourceLabel(window: AcpWindow): string;
48
66
  * Returns null when the host exposes no projection or disclosed no window.
49
67
  */
50
68
  export declare function projectedContextWindow(agent: Agent): number | null;
69
+ /** The model window plus the adapter's per-request output cap, in one probe. */
70
+ export interface ModelWindowProbe {
71
+ /** The model's total context window in tokens, when disclosed. */
72
+ readonly contextWindow: number | null;
73
+ /** The adapter's per-request output cap (`defaultMaxTokens`), when disclosed. */
74
+ readonly outputReservation: number | null;
75
+ }
76
+ /**
77
+ * Probe the model's real context window AND the adapter's per-request output
78
+ * cap in a single `resolveModelInfo` call. The cap is the output reservation
79
+ * the provider guarantees at the end of the window on every request —
80
+ * pressure decisions must run against the SUSTAINABLE input budget (window
81
+ * minus cap), not the raw window: a 96K window with a 16K cap carries at
82
+ * most 80K of input, so the raw denominator understates usage by cap/window
83
+ * (≈17% there — and far worse on short-window models, where the same cap is
84
+ * a quarter or more of the window). Returns nulls — never throws — when the
85
+ * host provides no llm service, discloses nothing, or the probe throws;
86
+ * callers keep the raw-window behavior in those cases.
87
+ */
88
+ export declare function probeModelWindow(agent: Agent, provider: string, model: string): Promise<ModelWindowProbe>;
51
89
  /**
52
90
  * Probe the model's real context window. Returns null when the host provides
53
91
  * no llm service, the adapter discloses no window, or the probe throws —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billion-context-dsh",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
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",