billion-context-omp 0.2.4 → 0.2.6

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.
@@ -20,7 +20,7 @@ export interface StreamCompressCall {
20
20
  }[];
21
21
  }
22
22
  export declare function findCompressCalls(message: AgentMessage): StreamCompressCall[];
23
- export declare function extractText(content: unknown): string;
23
+ export declare function extractText(content: unknown, stripTags?: boolean): string;
24
24
  export declare function messageIdentity(message: unknown): string;
25
25
  export declare function matchesStoredText(stored: string, visible: string): boolean;
26
26
  export declare function coreOutToAgentMessages(coreOut: CoreMessage[], originalById: Map<string, AgentMessage>): AgentMessage[];
package/dist/runtime.d.ts CHANGED
@@ -30,11 +30,13 @@ export interface AcpRuntime {
30
30
  * A re-fold (rewritten stream prefix) drops the slot and starts at 0. */
31
31
  noteCompressOutcome(ctx: ExtensionContext, ok: boolean): number;
32
32
  forgetSession(sid: string): void;
33
- /** Rebuild blocks from the persisted session view at session_start so /acp
34
- * and acp_status show them BEFORE the first LLM call of a resumed session.
35
- * The slot is marked preview and always re-folded authoritatively at the
36
- * first context event (the live stream is the truth source, not the
37
- * persisted view). */
33
+ /** Rebuild blocks from the persisted session at session_start so /acp and
34
+ * acp_status show them BEFORE the first LLM call of a resumed session.
35
+ * Provider mode folds the WIRE projection (viewToWireStream mirror the
36
+ * authoritative fold runs on the wire-synthesized stream, which differs
37
+ * from the raw session view; issue #64). The slot is marked preview and
38
+ * always re-folded authoritatively at the first live event (the live
39
+ * stream is the truth source, not the persisted view). */
38
40
  primeFold(ctx: ExtensionContext): void;
39
41
  acquireLock(sid: string): Promise<() => void>;
40
42
  }
@@ -47,6 +47,24 @@ export declare function synthesizeStream(payload: unknown, format: WireFormat):
47
47
  * byte-identical. Only synthesized messages (nudge) are built from scratch.
48
48
  * Returns the ORIGINAL payload object when nothing changed (cache-safe). */
49
49
  export declare function rebuildWirePayload(rebuilt: AgentMessage[], payload: unknown, synth: SynthesisResult): unknown;
50
+ /** Rebuild the WIRE-SHAPE view of the persisted session (the mirror of the
51
+ * host's convertToLlm) and run it through the SAME synthesizeStream the
52
+ * live provider fold uses, so primeFold (provider mode) folds exactly the
53
+ * authoritative projection. The raw session view is NOT equivalent: for
54
+ * openai-style payloads the system prompt is a message in the wire body —
55
+ * it becomes the first core piece and takes m00001 — and the openai
56
+ * synthesis cannot recover tool names for `role:"tool"` entries (a
57
+ * compress result gets toolName "" instead of "compress", so it is not
58
+ * ref-BLOCKED there). Folding the raw view puts the fold in a different
59
+ * ref/fingerprint space: stored span fingerprints mismatch, the guard
60
+ * rejects every in-stream replay, and a resumed session shows
61
+ * "Blocks: none" until the first provider request (issue #64).
62
+ *
63
+ * Message shapes mirror the captured live payload (openai chat):
64
+ * system first; assistant text and/or tool_calls (content "" when only
65
+ * calls); one `role:"tool"` message per tool result; thinking dropped
66
+ * (the host does not carry it in this format). */
67
+ export declare function viewToWireStream(view: AgentMessage[], systemText: string): AgentMessage[];
50
68
  /** True when the payload carries no messages we could fold (e.g. an empty
51
69
  * tools-only probe). The caller bypasses instead of transforming. */
52
70
  export declare function synthesisIsEmpty(synth: SynthesisResult): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billion-context-omp",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "One billion, not one million. Model-driven context management for the oh-my-pi (omp) coding agent.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,70 +0,0 @@
1
- import { complete } from "@oh-my-pi/pi-ai";
2
- import type { ExtensionContext } from "@oh-my-pi/pi-coding-agent";
3
- import { type CoreMessage, type CompressionState, type CompressibleRange, type Prompts } from "acp-kernel";
4
- import { type AgentMessage } from "./messages.js";
5
- /** Reads `compressModel` from `~/.<CONFIG_DIR_NAME>/acp-omp.json as `provider:modelId`. */
6
- export declare function readCompressModel(): string | null;
7
- export declare function resolveCompressModel<T extends {
8
- provider: string;
9
- id: string;
10
- }>(registry: {
11
- find(provider: string, modelId: string): T | undefined;
12
- }, currentModel: T | undefined, configured: string | null): {
13
- model: T;
14
- label: string;
15
- } | null;
16
- export declare function sliceRange(messages: CoreMessage[], state: CompressionState, startRef: string, endRef: string): CoreMessage[];
17
- /** Pick the compressible span to compress. The kernel's recommended ranges are
18
- * small groups (split at user boundaries and protected gaps) that routinely
19
- * fall below `minCompressRange`, which the kernel would reject. Seed on the
20
- * largest range and expand to adjacent ranges (smallest gap first) until the
21
- * span covers enough text — counting every message in the span, matching the
22
- * kernel's own validation. Returns null when even the whole compressible set
23
- * is below the threshold. */
24
- export declare function selectRangeSpan(ranges: CompressibleRange[], messages: CoreMessage[], state: CompressionState, minChars: number): {
25
- startRef: string;
26
- endRef: string;
27
- tokens: number;
28
- } | null;
29
- export declare function formatSlice(slice: CoreMessage[], state: CompressionState): string;
30
- export declare function parseSummary(text: string): string | null;
31
- /** Build the summary-generation system prompt FROM the kernel's load-bearing
32
- * compression rules (the same `Prompts` the compress tool and tier-1
33
- * compression use), so /compact honors `acp-omp.json` prompt overrides and stays
34
- * consistent with the rest of the ACP pipeline. `/compact` compresses an old
35
- * contiguous range, so the tier-1 `howToCompressRules` are the right rule
36
- * set (not tier-2/tier-3 distillation rules). */
37
- export declare function buildSummaryPrompt(prompts: Prompts): string;
38
- /** Generate ONE summary covering the FULL set of messages omp is about to
39
- * discard on /compact (messagesToSummarize + turnPrefixMessages), matching
40
- * native compaction semantics — the compaction entry omp stores afterwards
41
- * is the durable record, and it truncates everything before firstKeptEntryId
42
- * from the LLM view, so the summary must cover all of it. Kernel blocks are
43
- * deliberately NOT used here: fold blocks only replay from in-stream
44
- * compress tool calls, which the truncation removes. `previousSummary` (an
45
- * earlier compaction's summary) is folded in so iterative compactions never
46
- * drop it. On a failed attempt the LLM call is
47
- * retried ONCE (stochastic formatting failures recover on a fresh call);
48
- * returns null only when the retry also fails — the caller then CANCELS the
49
- * compaction (no native fallback: ACP owns compression, host-default
50
- * summaries are the failure mode this hook exists to prevent). */
51
- export declare function summarizeMessages(ctx: ExtensionContext, messages: AgentMessage[], prompts: Prompts, configuredModel?: string | null, opts?: {
52
- previousSummary?: string;
53
- customInstructions?: string;
54
- signal?: AbortSignal;
55
- completeFn?: typeof complete;
56
- /** Fold-slot messageRefs — when provided, formatSlice renders stable
57
- * mNNNNN refs instead of raw pN position ids (issue #14 Minor1: the
58
- * model was shown p-ids it must never echo back). */
59
- messageRefs?: CompressionState["messageRefs"];
60
- }): Promise<{
61
- summary: string;
62
- model: string;
63
- } | null>;
64
- /** Generate a summary for a message range using the compression model.
65
- * Currently unused by the extension (kept as the shared range-summary
66
- * surface); null = hard failure, caller decides. */
67
- export declare function summarizeRange(ctx: ExtensionContext, messages: CoreMessage[], state: CompressionState, startRef: string, endRef: string, prompts: Prompts, configuredModel?: string | null): Promise<{
68
- summary: string;
69
- model: string;
70
- } | null>;