@infituit/opencode-acp 0.0.0-stage → 2.0.0-alpha.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/LICENSE +622 -0
- package/NOTICE +29 -0
- package/README.md +203 -2
- package/dist/auth.d.ts +4 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/commands/compression-targets.d.ts +13 -0
- package/dist/commands/compression-targets.d.ts.map +1 -0
- package/dist/commands/context.d.ts +52 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/export.d.ts +56 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/index.d.ts +4 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/stats.d.ts +19 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/compress/decompress-logic.d.ts +62 -0
- package/dist/compress/decompress-logic.d.ts.map +1 -0
- package/dist/compress/decompress.d.ts +4 -0
- package/dist/compress/decompress.d.ts.map +1 -0
- package/dist/compress/hide-consumed.d.ts +15 -0
- package/dist/compress/hide-consumed.d.ts.map +1 -0
- package/dist/compress/hide-failed.d.ts +3 -0
- package/dist/compress/hide-failed.d.ts.map +1 -0
- package/dist/compress/image-archive.d.ts +43 -0
- package/dist/compress/image-archive.d.ts.map +1 -0
- package/dist/compress/index.d.ts +9 -0
- package/dist/compress/index.d.ts.map +1 -0
- package/dist/compress/keep-markers.d.ts +11 -0
- package/dist/compress/keep-markers.d.ts.map +1 -0
- package/dist/compress/parts.d.ts +4 -0
- package/dist/compress/parts.d.ts.map +1 -0
- package/dist/compress/pipeline.d.ts +141 -0
- package/dist/compress/pipeline.d.ts.map +1 -0
- package/dist/compress/protected-content.d.ts +12 -0
- package/dist/compress/protected-content.d.ts.map +1 -0
- package/dist/compress/quality-gate/algorithms/index.d.ts +3 -0
- package/dist/compress/quality-gate/algorithms/index.d.ts.map +1 -0
- package/dist/compress/quality-gate/evaluate.d.ts +21 -0
- package/dist/compress/quality-gate/evaluate.d.ts.map +1 -0
- package/dist/compress/quality-gate/index.d.ts +7 -0
- package/dist/compress/quality-gate/index.d.ts.map +1 -0
- package/dist/compress/quality-gate/registry.d.ts +6 -0
- package/dist/compress/quality-gate/registry.d.ts.map +1 -0
- package/dist/compress/quality-gate/rejection.d.ts +18 -0
- package/dist/compress/quality-gate/rejection.d.ts.map +1 -0
- package/dist/compress/quality-gate/types.d.ts +51 -0
- package/dist/compress/quality-gate/types.d.ts.map +1 -0
- package/dist/compress/range-utils.d.ts +28 -0
- package/dist/compress/range-utils.d.ts.map +1 -0
- package/dist/compress/range.d.ts +8 -0
- package/dist/compress/range.d.ts.map +1 -0
- package/dist/compress/recap.d.ts +4 -0
- package/dist/compress/recap.d.ts.map +1 -0
- package/dist/compress/search.d.ts +17 -0
- package/dist/compress/search.d.ts.map +1 -0
- package/dist/compress/smart-plan.d.ts +28 -0
- package/dist/compress/smart-plan.d.ts.map +1 -0
- package/dist/compress/state.d.ts +10 -0
- package/dist/compress/state.d.ts.map +1 -0
- package/dist/compress/status.d.ts +19 -0
- package/dist/compress/status.d.ts.map +1 -0
- package/dist/compress/timing.d.ts +17 -0
- package/dist/compress/timing.d.ts.map +1 -0
- package/dist/compress/types.d.ts +120 -0
- package/dist/compress/types.d.ts.map +1 -0
- package/dist/compress-permission.d.ts +6 -0
- package/dist/compress-permission.d.ts.map +1 -0
- package/dist/config-validation.d.ts +13 -0
- package/dist/config-validation.d.ts.map +1 -0
- package/dist/config.d.ts +248 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/gc/merge.d.ts +17 -0
- package/dist/gc/merge.d.ts.map +1 -0
- package/dist/hooks.d.ts +41 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/host-permissions.d.ts +31 -0
- package/dist/host-permissions.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14411 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +48 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/message-ids.d.ts +27 -0
- package/dist/message-ids.d.ts.map +1 -0
- package/dist/messages/enforce-budget.d.ts +65 -0
- package/dist/messages/enforce-budget.d.ts.map +1 -0
- package/dist/messages/filter/apply.d.ts +14 -0
- package/dist/messages/filter/apply.d.ts.map +1 -0
- package/dist/messages/filter/builtin/index.d.ts +2 -0
- package/dist/messages/filter/builtin/index.d.ts.map +1 -0
- package/dist/messages/filter/builtin/omo-context.d.ts +4 -0
- package/dist/messages/filter/builtin/omo-context.d.ts.map +1 -0
- package/dist/messages/filter/builtin/omo-mode-injection.d.ts +4 -0
- package/dist/messages/filter/builtin/omo-mode-injection.d.ts.map +1 -0
- package/dist/messages/filter/builtin/omo-system-reminder.d.ts +4 -0
- package/dist/messages/filter/builtin/omo-system-reminder.d.ts.map +1 -0
- package/dist/messages/filter/builtin/omo-task-directive.d.ts +4 -0
- package/dist/messages/filter/builtin/omo-task-directive.d.ts.map +1 -0
- package/dist/messages/filter/builtin/omo-todo-continuation.d.ts +4 -0
- package/dist/messages/filter/builtin/omo-todo-continuation.d.ts.map +1 -0
- package/dist/messages/filter/index.d.ts +6 -0
- package/dist/messages/filter/index.d.ts.map +1 -0
- package/dist/messages/filter/registry.d.ts +6 -0
- package/dist/messages/filter/registry.d.ts.map +1 -0
- package/dist/messages/filter/types.d.ts +95 -0
- package/dist/messages/filter/types.d.ts.map +1 -0
- package/dist/messages/index.d.ts +9 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/inject/candidates.d.ts +30 -0
- package/dist/messages/inject/candidates.d.ts.map +1 -0
- package/dist/messages/inject/inject.d.ts +26 -0
- package/dist/messages/inject/inject.d.ts.map +1 -0
- package/dist/messages/inject/policy/index.d.ts +5 -0
- package/dist/messages/inject/policy/index.d.ts.map +1 -0
- package/dist/messages/inject/policy/registry.d.ts +8 -0
- package/dist/messages/inject/policy/registry.d.ts.map +1 -0
- package/dist/messages/inject/policy/types.d.ts +2 -0
- package/dist/messages/inject/policy/types.d.ts.map +1 -0
- package/dist/messages/inject/utils.d.ts +235 -0
- package/dist/messages/inject/utils.d.ts.map +1 -0
- package/dist/messages/priority.d.ts +13 -0
- package/dist/messages/priority.d.ts.map +1 -0
- package/dist/messages/prune.d.ts +5 -0
- package/dist/messages/prune.d.ts.map +1 -0
- package/dist/messages/query.d.ts +36 -0
- package/dist/messages/query.d.ts.map +1 -0
- package/dist/messages/reasoning-strip.d.ts +32 -0
- package/dist/messages/reasoning-strip.d.ts.map +1 -0
- package/dist/messages/shape.d.ts +5 -0
- package/dist/messages/shape.d.ts.map +1 -0
- package/dist/messages/sticky-truncation.d.ts +55 -0
- package/dist/messages/sticky-truncation.d.ts.map +1 -0
- package/dist/messages/sync.d.ts +4 -0
- package/dist/messages/sync.d.ts.map +1 -0
- package/dist/messages/truncate-tools.d.ts +12 -0
- package/dist/messages/truncate-tools.d.ts.map +1 -0
- package/dist/messages/utils.d.ts +30 -0
- package/dist/messages/utils.d.ts.map +1 -0
- package/dist/prompts/compress-range.d.ts +10 -0
- package/dist/prompts/compress-range.d.ts.map +1 -0
- package/dist/prompts/context-limit-nudge.d.ts +8 -0
- package/dist/prompts/context-limit-nudge.d.ts.map +1 -0
- package/dist/prompts/extensions/nudge.d.ts +16 -0
- package/dist/prompts/extensions/nudge.d.ts.map +1 -0
- package/dist/prompts/extensions/system.d.ts +4 -0
- package/dist/prompts/extensions/system.d.ts.map +1 -0
- package/dist/prompts/extensions/tool.d.ts +3 -0
- package/dist/prompts/extensions/tool.d.ts.map +1 -0
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/iteration-nudge.d.ts +7 -0
- package/dist/prompts/iteration-nudge.d.ts.map +1 -0
- package/dist/prompts/store.d.ts +25 -0
- package/dist/prompts/store.d.ts.map +1 -0
- package/dist/prompts/system.d.ts +11 -0
- package/dist/prompts/system.d.ts.map +1 -0
- package/dist/prompts/turn-nudge.d.ts +7 -0
- package/dist/prompts/turn-nudge.d.ts.map +1 -0
- package/dist/protected-patterns.d.ts +5 -0
- package/dist/protected-patterns.d.ts.map +1 -0
- package/dist/state/index.d.ts +6 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/message-types.d.ts +90 -0
- package/dist/state/message-types.d.ts.map +1 -0
- package/dist/state/model-limits.d.ts +27 -0
- package/dist/state/model-limits.d.ts.map +1 -0
- package/dist/state/persistence.d.ts +93 -0
- package/dist/state/persistence.d.ts.map +1 -0
- package/dist/state/rebuild.d.ts +40 -0
- package/dist/state/rebuild.d.ts.map +1 -0
- package/dist/state/state.d.ts +36 -0
- package/dist/state/state.d.ts.map +1 -0
- package/dist/state/tool-cache.d.ts +13 -0
- package/dist/state/tool-cache.d.ts.map +1 -0
- package/dist/state/types.d.ts +221 -0
- package/dist/state/types.d.ts.map +1 -0
- package/dist/state/utils.d.ts +57 -0
- package/dist/state/utils.d.ts.map +1 -0
- package/dist/token-utils.d.ts +42 -0
- package/dist/token-utils.d.ts.map +1 -0
- package/dist/ui/notification.d.ts +13 -0
- package/dist/ui/notification.d.ts.map +1 -0
- package/dist/ui/utils.d.ts +6 -0
- package/dist/ui/utils.d.ts.map +1 -0
- package/dist/update.d.ts +24 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/v2/messages.d.ts +7 -0
- package/dist/v2/messages.d.ts.map +1 -0
- package/dist/v2/plugin.d.ts +3 -0
- package/dist/v2/plugin.d.ts.map +1 -0
- package/package.json +76 -5
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import type { SessionState, WithParts } from "../../state";
|
|
2
|
+
import type { PluginConfig, CompressModelOverrides } from "../../config";
|
|
3
|
+
import type { RuntimePrompts } from "../../prompts/store";
|
|
4
|
+
import { type CompressionPriorityMap } from "../priority";
|
|
5
|
+
export interface LastUserModelContext {
|
|
6
|
+
providerId: string | undefined;
|
|
7
|
+
modelId: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface LastNonIgnoredMessage {
|
|
10
|
+
message: WithParts;
|
|
11
|
+
index: number;
|
|
12
|
+
}
|
|
13
|
+
interface ModelLimit {
|
|
14
|
+
context: number;
|
|
15
|
+
input?: number;
|
|
16
|
+
output?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function computeInputBudget(limit: ModelLimit): number | undefined;
|
|
19
|
+
export declare function getNudgeFrequency(config: PluginConfig): number;
|
|
20
|
+
export declare function getIterationNudgeThreshold(config: PluginConfig): number;
|
|
21
|
+
export declare function findLastNonIgnoredMessage(messages: WithParts[]): LastNonIgnoredMessage | null;
|
|
22
|
+
export declare function countMessagesAfterIndex(messages: WithParts[], index: number): number;
|
|
23
|
+
export declare function getModelInfo(messages: WithParts[]): LastUserModelContext;
|
|
24
|
+
export declare function resolveContextTokenLimit(config: PluginConfig, state: SessionState, providerId: string | undefined, modelId: string | undefined, threshold: "max" | "min"): number | undefined;
|
|
25
|
+
export declare function isContextOverLimits(config: PluginConfig, state: SessionState, providerId: string | undefined, modelId: string | undefined, messages: WithParts[]): {
|
|
26
|
+
overMaxLimit: boolean;
|
|
27
|
+
overMinLimit: boolean;
|
|
28
|
+
currentTokens: number;
|
|
29
|
+
modelContextLimit: number | undefined;
|
|
30
|
+
};
|
|
31
|
+
export type TipsVariant = "maxLimit" | "minLimit" | "normal";
|
|
32
|
+
export interface NudgeDecision {
|
|
33
|
+
shouldNudge: boolean;
|
|
34
|
+
tipsVariant: TipsVariant | null;
|
|
35
|
+
}
|
|
36
|
+
export declare function computeShouldNudge(params: {
|
|
37
|
+
currentTokens: number | undefined;
|
|
38
|
+
modelContextLimit: number | undefined;
|
|
39
|
+
overMinLimit: boolean;
|
|
40
|
+
overMaxLimit: boolean;
|
|
41
|
+
lastNudgeTokens: number | undefined;
|
|
42
|
+
/** Passed through to the trigger policy (currently ignored by it). The growth-nudge floor derived from this field is computed separately in inject.ts (minNudgeContextPercent × model context). */
|
|
43
|
+
minNudgeContextPercent: number;
|
|
44
|
+
nudgeGrowthTokens: number;
|
|
45
|
+
}): NudgeDecision;
|
|
46
|
+
export declare const DEFAULT_NUDGE_GROWTH_TOKENS = 50000;
|
|
47
|
+
/** Default growth-nudge floor percent when unset everywhere (#343: deliberately low — see inject.ts rationale). */
|
|
48
|
+
export declare const DEFAULT_MIN_NUDGE_CONTEXT_PERCENT = 5;
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the effective growth-nudge floor percent for the active model,
|
|
51
|
+
* cascading field-by-field:
|
|
52
|
+
*
|
|
53
|
+
* compress.providers[providerId].models[modelId].minNudgeContextPercent
|
|
54
|
+
* → compress.providers[providerId].minNudgeContextPercent
|
|
55
|
+
* → compress.minNudgeContextPercent
|
|
56
|
+
*
|
|
57
|
+
* - Deeper levels only override when the field is explicitly set; unset
|
|
58
|
+
* fields never clear shallower values.
|
|
59
|
+
* - 0 is an explicit "disable the floor" value, not "unset".
|
|
60
|
+
* - Unknown provider/model ids fall back up the cascade.
|
|
61
|
+
* - Returns undefined only when the field is unset everywhere (callers apply
|
|
62
|
+
* DEFAULT_MIN_NUDGE_CONTEXT_PERCENT).
|
|
63
|
+
*/
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the full per-model / per-provider override set for the active
|
|
66
|
+
* provider/model, merged field-by-field: model-level fields win over
|
|
67
|
+
* provider-level fields. Unset fields are simply absent from the result —
|
|
68
|
+
* they never clear the global value. `0` / `false`-style explicit values are
|
|
69
|
+
* honored as set (only `undefined` means "unset"). Unknown provider/model
|
|
70
|
+
* ids resolve to an empty override set (global values apply).
|
|
71
|
+
*
|
|
72
|
+
* The `models` sub-map of a provider entry is structural and never leaks
|
|
73
|
+
* into the merged result.
|
|
74
|
+
*/
|
|
75
|
+
export declare function resolveCompressOverrides(config: PluginConfig, providerId?: string, modelId?: string): CompressModelOverrides;
|
|
76
|
+
export declare function resolveMinNudgeContextPercent(config: PluginConfig, providerId?: string, modelId?: string): number | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Convert the resolved floor percent to absolute tokens against the active
|
|
79
|
+
* model's context window. The percent is clamped to 0–100 (mirroring
|
|
80
|
+
* resolveContextTokenLimit) and rounded. Returns undefined when the model
|
|
81
|
+
* context limit is unknown — whichever level set the percent, the floor then
|
|
82
|
+
* stays open (growth-only behavior, #343).
|
|
83
|
+
*/
|
|
84
|
+
export declare function resolveMinNudgeFloorTokens(config: PluginConfig, modelContextLimit: number | undefined, providerId?: string, modelId?: string): number | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Build the effective PluginConfig for the active provider/model: a shallow
|
|
87
|
+
* clone whose `compress` section has every nested override (model > provider)
|
|
88
|
+
* applied field-by-field on top of the global values. Callers pass the result
|
|
89
|
+
* down instead of the raw config, so every `config.compress.X` read in the
|
|
90
|
+
* pipeline picks up the cascade automatically. No override set → returns the
|
|
91
|
+
* input unchanged (identity, zero allocation).
|
|
92
|
+
*/
|
|
93
|
+
export declare function applyCompressOverrides(config: PluginConfig, providerId?: string, modelId?: string): PluginConfig;
|
|
94
|
+
export declare function addAnchor(anchorMessageIds: Set<string>, anchorMessageId: string, anchorMessageIndex: number, messages: WithParts[], interval: number): boolean;
|
|
95
|
+
export declare function applyAnchoredNudges(state: SessionState, config: PluginConfig, messages: WithParts[], prompts: RuntimePrompts, compressionPriorities?: CompressionPriorityMap, currentTokens?: number, modelContextLimit?: number, suffixMessage?: WithParts | null): void;
|
|
96
|
+
export interface ContextComposition {
|
|
97
|
+
toolTokens: number;
|
|
98
|
+
codeTokens: number;
|
|
99
|
+
summaryTokens: number;
|
|
100
|
+
messageTokens: number;
|
|
101
|
+
textTokens: number;
|
|
102
|
+
systemTokens: number;
|
|
103
|
+
protectedTokens: number;
|
|
104
|
+
reasoningTokens: number;
|
|
105
|
+
total: number;
|
|
106
|
+
largestRanges: {
|
|
107
|
+
ref: string;
|
|
108
|
+
tokens: number;
|
|
109
|
+
}[];
|
|
110
|
+
largestToolRanges: {
|
|
111
|
+
ref: string;
|
|
112
|
+
tokens: number;
|
|
113
|
+
tool?: string;
|
|
114
|
+
}[];
|
|
115
|
+
largestCodeRanges: {
|
|
116
|
+
ref: string;
|
|
117
|
+
tokens: number;
|
|
118
|
+
}[];
|
|
119
|
+
largestMessageRanges: {
|
|
120
|
+
ref: string;
|
|
121
|
+
tokens: number;
|
|
122
|
+
}[];
|
|
123
|
+
toolTypeBreakdown: {
|
|
124
|
+
tool: string;
|
|
125
|
+
tokens: number;
|
|
126
|
+
}[];
|
|
127
|
+
}
|
|
128
|
+
export declare function estimateContextComposition(messages: WithParts[], state?: SessionState, protectedTools?: string[], protectedFilePatterns?: string[]): ContextComposition;
|
|
129
|
+
export interface CompressibleRange {
|
|
130
|
+
startRef: string;
|
|
131
|
+
endRef: string;
|
|
132
|
+
count: number;
|
|
133
|
+
tokens: number;
|
|
134
|
+
/**
|
|
135
|
+
* Tokens that would actually survive the compress pipeline's soft
|
|
136
|
+
* filters (last-user-message, no-meaningful-content). The pipeline
|
|
137
|
+
* silently drops those messages from plans, so `tokens` overstates
|
|
138
|
+
* what a compression would free. Recommendations and displays use
|
|
139
|
+
* this field to stay honest (phantom-loop fix, issue #37 session
|
|
140
|
+
* ses_7fb5cbc8: ranges shown as "10.8K compressible" resolved to
|
|
141
|
+
* 3066 chars in the pipeline → min-size rejection → retry loop).
|
|
142
|
+
*/
|
|
143
|
+
effectiveTokens: number;
|
|
144
|
+
toolPct: number;
|
|
145
|
+
textPct: number;
|
|
146
|
+
dangerous?: boolean;
|
|
147
|
+
}
|
|
148
|
+
export interface ProtectedRange {
|
|
149
|
+
startRef: string;
|
|
150
|
+
endRef: string;
|
|
151
|
+
count: number;
|
|
152
|
+
tokens: number;
|
|
153
|
+
tools: string[];
|
|
154
|
+
}
|
|
155
|
+
export interface ContextRanges {
|
|
156
|
+
compressible: CompressibleRange[];
|
|
157
|
+
protected: ProtectedRange[];
|
|
158
|
+
}
|
|
159
|
+
export declare function buildCompressibleRanges(messages: WithParts[], state: SessionState, protectedTools?: string[], protectedFilePatterns?: string[], protectedZoneRefs?: Set<string>): ContextRanges;
|
|
160
|
+
export interface RangeFilterOptions {
|
|
161
|
+
logger?: {
|
|
162
|
+
debug: (msg: string, data?: any) => void;
|
|
163
|
+
};
|
|
164
|
+
minEffectiveTokens?: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* DEFAULT token floor for a range to stay in the recommendation list, aligned
|
|
168
|
+
* with the compress pipeline's default minCompressRange (5000 chars ÷ 4
|
|
169
|
+
* chars/token). The actual floor is derived from the configured
|
|
170
|
+
* `compress.minCompressRange` via `resolveEffectiveFloor` so the recommendation
|
|
171
|
+
* tracks the pipeline's real rejection threshold. Ranges whose effective
|
|
172
|
+
* compressible content falls below the floor would be rejected by the
|
|
173
|
+
* pipeline's minimum-size check, so recommending them only invites
|
|
174
|
+
* guaranteed-failed compress calls (the retry loop observed in issue #37
|
|
175
|
+
* session ses_7fb5cbc8: displayed "10.8K compressible" resolved to 3066 chars
|
|
176
|
+
* in the pipeline → rejected → model retried ×10).
|
|
177
|
+
*/
|
|
178
|
+
export declare const EFFECTIVE_MIN_COMPRESSIBLE_TOKENS = 1250;
|
|
179
|
+
/**
|
|
180
|
+
* Derive the effective-token recommendation floor from the pipeline's
|
|
181
|
+
* char-based `compress.minCompressRange` (÷ 4 chars/token). When
|
|
182
|
+
* minCompressRange is 0 the pipeline's size check is disabled, so the floor
|
|
183
|
+
* is 0 — but the universal phantom guard (`effective > 0`) still applies in
|
|
184
|
+
* filterRecommendedRanges: a range whose every message is soft-filtered
|
|
185
|
+
* produces a phantom plan the pipeline always rejects.
|
|
186
|
+
*/
|
|
187
|
+
export declare function resolveEffectiveFloor(config: {
|
|
188
|
+
compress?: {
|
|
189
|
+
minCompressRange?: number;
|
|
190
|
+
};
|
|
191
|
+
}): number;
|
|
192
|
+
/**
|
|
193
|
+
* Filter compressible ranges for the recommendation list.
|
|
194
|
+
*
|
|
195
|
+
* Ranges whose effective compressible content (after the pipeline's soft
|
|
196
|
+
* filters: last-user-message, no-meaningful-content) falls below
|
|
197
|
+
* EFFECTIVE_MIN_COMPRESSIBLE_TOKENS are dropped — the pipeline's
|
|
198
|
+
* minCompressRange check would reject them anyway. The last surviving
|
|
199
|
+
* segment is marked `dangerous: true` (it may still be in active use).
|
|
200
|
+
*
|
|
201
|
+
* Issue #251: Previously this function used `growthThreshold` (5% of context
|
|
202
|
+
* window = 50K at 1M) as an aggregate gate — if "effective compressible"
|
|
203
|
+
* was below the threshold, ALL ranges were suppressed and the nudge was
|
|
204
|
+
* hidden. At large context windows, individual ranges rarely exceeded this
|
|
205
|
+
* threshold, so compression was permanently blocked. The aggregate gate
|
|
206
|
+
* has been removed. The per-range effective floor below is 1250 tokens —
|
|
207
|
+
* far below #251's 50K, and matched to the pipeline's own acceptance
|
|
208
|
+
* criteria rather than the context size.
|
|
209
|
+
*/
|
|
210
|
+
export declare function filterRecommendedRanges(compressible: CompressibleRange[], _protectedRanges: ProtectedRange[], options: RangeFilterOptions): CompressibleRange[];
|
|
211
|
+
export declare function formatCompressibleRanges(ranges: CompressibleRange[], protectedRanges?: ProtectedRange[]): string;
|
|
212
|
+
/**
|
|
213
|
+
* Compute the set of protected message refs (mNNNNN) that should be excluded
|
|
214
|
+
* from compression recommendations. Combines two rules:
|
|
215
|
+
* 1. Last N messages (preserveRecentMessages, default 5)
|
|
216
|
+
* 2. Last N tokens expanding backward (preserveRecentTokens, default 5000)
|
|
217
|
+
*
|
|
218
|
+
* Note: preserveLastUserMessage is no longer handled here (moved to soft
|
|
219
|
+
* filtering in the compress pipeline — see filterLastUserMessage). The last
|
|
220
|
+
* user message is filtered from the compress plan instead of causing a hard
|
|
221
|
+
* rejection.
|
|
222
|
+
*
|
|
223
|
+
* Only considers visible, non-synthetic, non-pruned messages.
|
|
224
|
+
*/
|
|
225
|
+
export declare function computeProtectedRefs(messages: WithParts[], state: SessionState, compress: PluginConfig["compress"]): Set<string>;
|
|
226
|
+
/**
|
|
227
|
+
* Filter compressible ranges to exclude those overlapping the protected zone.
|
|
228
|
+
* Since the protected zone is always at the tail of the conversation, a range
|
|
229
|
+
* whose startRef or endRef is protected is partially or fully within the zone.
|
|
230
|
+
* Compressing such a range would either be rejected by the enforcement check
|
|
231
|
+
* or waste model effort — exclude it preemptively.
|
|
232
|
+
*/
|
|
233
|
+
export declare function excludeProtectedRanges(ranges: CompressibleRange[], protectedRefs: Set<string>): CompressibleRange[];
|
|
234
|
+
export {};
|
|
235
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/messages/inject/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAkB,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAYxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAEzD,OAAO,EACH,KAAK,sBAAsB,EAG9B,MAAM,aAAa,CAAA;AAepB,MAAM,WAAW,oBAAoB;IACjC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B;AAED,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,SAAS,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CAChB;AAED,UAAU,UAAU;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAMxE;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAE9D;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAEvE;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,qBAAqB,GAAG,IAAI,CAa7F;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E,YAAY,CAAC,UAAU,CAAC,GACnC,GAAG,CAAC,MAAM,CAAC,CA0Cb;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAClC,MAAM,EAAE,iBAAiB,EAAE,EAC3B,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GAC3B,iBAAiB,EAAE,CAGrB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PluginConfig } from "../config";
|
|
2
|
+
import type { SessionState, WithParts } from "../state";
|
|
3
|
+
export type MessagePriority = "low" | "medium" | "high";
|
|
4
|
+
export interface CompressionPriorityEntry {
|
|
5
|
+
ref: string;
|
|
6
|
+
tokenCount: number;
|
|
7
|
+
priority: MessagePriority;
|
|
8
|
+
}
|
|
9
|
+
export type CompressionPriorityMap = Map<string, CompressionPriorityEntry>;
|
|
10
|
+
export declare function buildPriorityMap(_config: PluginConfig, _state: SessionState, _messages: WithParts[]): CompressionPriorityMap;
|
|
11
|
+
export declare function classifyMessagePriority(tokenCount: number): MessagePriority;
|
|
12
|
+
export declare function listPriorityRefsBeforeIndex(messages: WithParts[], priorities: CompressionPriorityMap, anchorIndex: number, priority: MessagePriority): string[];
|
|
13
|
+
//# sourceMappingURL=priority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"priority.d.ts","sourceRoot":"","sources":["../../src/messages/priority.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAKvD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEvD,MAAM,WAAW,wBAAwB;IACrC,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,eAAe,CAAA;CAC5B;AAED,MAAM,MAAM,sBAAsB,GAAG,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAA;AAE1E,wBAAgB,gBAAgB,CAC5B,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,SAAS,EAAE,GACvB,sBAAsB,CAExB;AAED,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,eAAe,CAU3E;AAED,wBAAgB,2BAA2B,CACvC,QAAQ,EAAE,SAAS,EAAE,EACrB,UAAU,EAAE,sBAAsB,EAClC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,eAAe,GAC1B,MAAM,EAAE,CAqBV"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SessionState, WithParts } from "../state";
|
|
2
|
+
import type { Logger } from "../logger";
|
|
3
|
+
import type { PluginConfig } from "../config";
|
|
4
|
+
export declare const prune: (state: SessionState, logger: Logger, config: PluginConfig, messages: WithParts[]) => void;
|
|
5
|
+
//# sourceMappingURL=prune.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prune.d.ts","sourceRoot":"","sources":["../../src/messages/prune.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAE7C,eAAO,MAAM,KAAK,GACd,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,QAAQ,YAAY,EACpB,UAAU,SAAS,EAAE,KACtB,IAGF,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { PluginConfig } from "../config";
|
|
2
|
+
import type { WithParts } from "../state";
|
|
3
|
+
export declare function isSyntheticMessage(message: WithParts): boolean;
|
|
4
|
+
export declare const getLastUserMessage: (messages: WithParts[], startIndex?: number) => WithParts | null;
|
|
5
|
+
export declare const messageHasCompress: (message: WithParts) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Detects ANY compress tool call — including failed/rejected ones.
|
|
8
|
+
*
|
|
9
|
+
* Used for nudge state management: a failed compress attempt means the model
|
|
10
|
+
* DID respond to the nudge (it tried to compress), so the pending-nudge state
|
|
11
|
+
* should be cleared. Without this, the threshold stays permanently halved
|
|
12
|
+
* after a rejected compress, creating a self-accelerating nudge loop.
|
|
13
|
+
*
|
|
14
|
+
* For priority/state queries that only care about SUCCESSFUL compressions
|
|
15
|
+
* (e.g. message priority classification), use `messageHasCompress` instead.
|
|
16
|
+
*/
|
|
17
|
+
export declare const messageHasCompressAttempt: (message: WithParts) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Classifies a compress tool call by its range boundaries to detect whether it is
|
|
20
|
+
* a raw-message capture (T1) or a summary distillation/condensation (T2/T3).
|
|
21
|
+
*
|
|
22
|
+
* Returns `true` ONLY when the call is positively identified as a T1 capture: at
|
|
23
|
+
* least one range boundary is present and NONE of them is a block ref (`bN`). A
|
|
24
|
+
* block-ref boundary means the call consumes existing summaries (T2/T3); those
|
|
25
|
+
* must keep resetting the tier cadence baselines to prevent re-trigger loops
|
|
26
|
+
* (issue #235). A pure message capture (`mNNNNN` boundaries) only ADDS tier-1
|
|
27
|
+
* summaries, so resetting the baselines after every capture is what starves T2
|
|
28
|
+
* distillation (issue #364 P1) — callers skip the reset for these.
|
|
29
|
+
*
|
|
30
|
+
* Returns `false` when any boundary is a block ref OR when no parsable boundary
|
|
31
|
+
* is found (conservative: preserve the loop-prevention reset).
|
|
32
|
+
*/
|
|
33
|
+
export declare const isCaptureOnlyCompress: (message: WithParts | undefined) => boolean;
|
|
34
|
+
export declare const isIgnoredUserMessage: (message: WithParts) => boolean;
|
|
35
|
+
export declare function isProtectedUserMessage(_config: PluginConfig, message: WithParts): boolean;
|
|
36
|
+
//# sourceMappingURL=query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/messages/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,CAQ9D;AAED,eAAO,MAAM,kBAAkB,GAC3B,UAAU,SAAS,EAAE,EACrB,aAAa,MAAM,KACpB,SAAS,GAAG,IAYd,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,SAAS,SAAS,KAAG,OAgBvD,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,GAAI,SAAS,SAAS,KAAG,OAW9D,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GAAI,SAAS,SAAS,GAAG,SAAS,KAAG,OAuBtE,CAAA;AAqCD,eAAO,MAAM,oBAAoB,GAAI,SAAS,SAAS,KAAG,OAqBzD,CAAA;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAMzF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { WithParts } from "../state";
|
|
2
|
+
/**
|
|
3
|
+
* Mirrors opencode's differentModel handling by preserving part content while
|
|
4
|
+
* dropping provider metadata on assistant parts that came from a different
|
|
5
|
+
* model/provider than the current turn's user message.
|
|
6
|
+
*/
|
|
7
|
+
export declare function stripStaleMetadata(messages: WithParts[]): void;
|
|
8
|
+
/**
|
|
9
|
+
* Drop `reasoning` parts from HISTORICAL `compress` tool-call messages (#368).
|
|
10
|
+
*
|
|
11
|
+
* `compress` tool-call messages are hard-excluded from every compression
|
|
12
|
+
* selection (Bug 39) and therefore re-sent every request, with their
|
|
13
|
+
* `reasoning` riding along — a monotonically growing floor that compression
|
|
14
|
+
* can never reclaim. This request-time pass removes ONLY the `reasoning`
|
|
15
|
+
* parts from such messages when BOTH gates hold:
|
|
16
|
+
*
|
|
17
|
+
* 1. turn-closure: the message is strictly before the last genuine user
|
|
18
|
+
* message. The current, possibly-open round is never touched — providers
|
|
19
|
+
* may require replaying the active round's thinking.
|
|
20
|
+
* 2. per-message size: the message's total reasoning length EXCEEDS
|
|
21
|
+
* `threshold` chars (owner decision: single-thinking size — small
|
|
22
|
+
* thinkings are left alone; only oversized ones are dropped; not
|
|
23
|
+
* accumulated). `threshold: 0` drops unconditionally.
|
|
24
|
+
*
|
|
25
|
+
* The tool call and every non-reasoning part are preserved. Only messages
|
|
26
|
+
* carrying a `compress` tool part are selected (NOT other protected tools).
|
|
27
|
+
* No state/DB writes; deterministic (prefix-cache-stable within a turn).
|
|
28
|
+
*
|
|
29
|
+
* @returns the number of `reasoning` parts removed.
|
|
30
|
+
*/
|
|
31
|
+
export declare function dropCompressReasoning(messages: WithParts[], threshold: number): number;
|
|
32
|
+
//# sourceMappingURL=reasoning-strip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning-strip.d.ts","sourceRoot":"","sources":["../../src/messages/reasoning-strip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAkC9D;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAiDtF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WithParts } from "../state";
|
|
2
|
+
export declare function isMessageWithInfo(message: unknown): message is WithParts;
|
|
3
|
+
export declare function filterMessages(messages: unknown): WithParts[];
|
|
4
|
+
export declare function filterMessagesInPlace(messages: unknown): WithParts[];
|
|
5
|
+
//# sourceMappingURL=shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shape.d.ts","sourceRoot":"","sources":["../../src/messages/shape.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,SAAS,CAsBxE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,EAAE,CAM7D;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,EAAE,CAepE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* [Issue #485] Sticky emergency truncation.
|
|
3
|
+
*
|
|
4
|
+
* The emergency guards (`truncateLargeToolOutputs` + `enforceContextBudget`)
|
|
5
|
+
* operate on a fresh pristine copy of `output.messages` every request and
|
|
6
|
+
* gate on the LAST assistant's reported usage — which reflects the
|
|
7
|
+
* *truncated* request, not the pristine one. A session hovering at the guard
|
|
8
|
+
* threshold therefore oscillates: truncate (A→B) → smaller usage → no
|
|
9
|
+
* truncation next request (full A restored) → cache miss → over budget
|
|
10
|
+
* again. Every flip invalidates the provider prefix cache from that message
|
|
11
|
+
* onward, and with opencode auto-retrying on a busy backend the churn can
|
|
12
|
+
* take down the serving cluster.
|
|
13
|
+
*
|
|
14
|
+
* Stickiness makes the guard decision one-way: the first time a guard
|
|
15
|
+
* truncates (or clears) a tool output, the result is frozen in
|
|
16
|
+
* `state.stickyTruncations` keyed by tool call ID and replayed verbatim on
|
|
17
|
+
* every later request BEFORE the guards run. A→B→B→B — the truncated form
|
|
18
|
+
* never grows back. The full content stays in the session store (and on
|
|
19
|
+
* disk), so nothing is lost; the wire view is simply stable.
|
|
20
|
+
*/
|
|
21
|
+
import type { Logger } from "../logger";
|
|
22
|
+
import type { SessionState, WithParts } from "../state";
|
|
23
|
+
/**
|
|
24
|
+
* Replay frozen truncations onto the request copy, and prune entries whose
|
|
25
|
+
* call no longer exists in the projected view.
|
|
26
|
+
*
|
|
27
|
+
* [#485 review] Prune-on-vanish is intentionally coarse: a call absent from
|
|
28
|
+
* ONE request's projected view (content-based filter, mid-abort partial
|
|
29
|
+
* fetch) is treated like a deleted call and unfrozen. That is self-healing —
|
|
30
|
+
* if the call reappears pristine and a guard truncates it again, the new
|
|
31
|
+
* form is re-frozen — at the cost of a single pristine flip in that rare
|
|
32
|
+
* window.
|
|
33
|
+
*
|
|
34
|
+
* [#485 review] Replayed values are wire-only. If a provider legitimately
|
|
35
|
+
* reuses a callID for genuinely new output (not observed), the replay would
|
|
36
|
+
* mask the new content on the wire until the entry is pruned; the session
|
|
37
|
+
* store always keeps the authoritative full output.
|
|
38
|
+
*/
|
|
39
|
+
export declare function applyStickyTruncations(state: SessionState, messages: WithParts[], logger: Logger): void;
|
|
40
|
+
/**
|
|
41
|
+
* Snapshot callID → output for every completed tool part. Non-string
|
|
42
|
+
* outputs are stringified via `extractCompletedToolOutput` — the same
|
|
43
|
+
* normalization the guards use before truncating — so a guard turning an
|
|
44
|
+
* object output into a truncated string is detected as a change and frozen.
|
|
45
|
+
*/
|
|
46
|
+
export declare function snapshotToolOutputs(messages: WithParts[]): Map<string, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Freeze any output the guards changed since `before`: a changed output is
|
|
49
|
+
* either a fresh truncation or a phase-2 clear — both must stick. Returns
|
|
50
|
+
* the number of entries frozen so the caller can persist immediately
|
|
51
|
+
* (every other save trigger in the transform hook fires EARLIER, so a quiet
|
|
52
|
+
* session would otherwise reach disk only via an unrelated later save).
|
|
53
|
+
*/
|
|
54
|
+
export declare function recordStickyTruncations(state: SessionState, messages: WithParts[], before: Map<string, string>, logger: Logger): number;
|
|
55
|
+
//# sourceMappingURL=sticky-truncation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky-truncation.d.ts","sourceRoot":"","sources":["../../src/messages/sticky-truncation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAuBvD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,SAAS,EAAE,EACrB,MAAM,EAAE,MAAM,GACf,IAAI,CAgCN;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAU9E;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,SAAS,EAAE,EACrB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,MAAM,EAAE,MAAM,GACf,MAAM,CAgBR"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/messages/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAkBvC,eAAO,MAAM,qBAAqB,GAC9B,OAAO,YAAY,EACnB,QAAQ,MAAM,EACd,UAAU,SAAS,EAAE,KACtB,OAoJF,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SessionState, WithParts } from "../state";
|
|
2
|
+
import type { PluginConfig } from "../config";
|
|
3
|
+
import { Logger } from "../logger";
|
|
4
|
+
export declare const OUTPUT_RESERVE_TOKENS = 16384;
|
|
5
|
+
export declare const MAX_OVERHEAD_ERROR_SESSIONS = 1024;
|
|
6
|
+
/**
|
|
7
|
+
* When context reaches the GC threshold, truncate the largest visible tool outputs
|
|
8
|
+
* (keeping prefix + suffix) to free space. Summaries are never touched — they contain
|
|
9
|
+
* distilled information. Only verbose tool outputs (build logs, listings) are truncated.
|
|
10
|
+
*/
|
|
11
|
+
export declare function truncateLargeToolOutputs(state: SessionState, config: PluginConfig, logger: Logger, messages: WithParts[]): void;
|
|
12
|
+
//# sourceMappingURL=truncate-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truncate-tools.d.ts","sourceRoot":"","sources":["../../src/messages/truncate-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAgBlC,eAAO,MAAM,qBAAqB,QAAQ,CAAA;AAS1C,eAAO,MAAM,2BAA2B,OAAO,CAAA;AAyB/C;;;;GAIG;AACH,wBAAgB,wBAAwB,CACpC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,SAAS,EAAE,GACtB,IAAI,CAwGN"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SessionState, WithParts } from "../state";
|
|
2
|
+
export declare const createSyntheticMessage: (baseMessage: WithParts, content: string, stableSeed?: string, role?: "user" | "assistant") => WithParts;
|
|
3
|
+
export declare const createSyntheticUserMessage: (baseMessage: WithParts, content: string, stableSeed?: string) => WithParts;
|
|
4
|
+
export declare const createSyntheticTextPart: (baseMessage: WithParts, content: string, stableSeed?: string) => {
|
|
5
|
+
id: string;
|
|
6
|
+
sessionID: string;
|
|
7
|
+
messageID: string;
|
|
8
|
+
type: "text";
|
|
9
|
+
text: string;
|
|
10
|
+
};
|
|
11
|
+
type MessagePart = WithParts["parts"][number];
|
|
12
|
+
type TextPart = Extract<MessagePart, {
|
|
13
|
+
type: "text";
|
|
14
|
+
}>;
|
|
15
|
+
export declare const appendToLastTextPart: (message: WithParts, injection: string) => boolean;
|
|
16
|
+
export declare const appendToTextPart: (part: TextPart, injection: string) => boolean;
|
|
17
|
+
export declare const appendToAllToolParts: (message: WithParts, tag: string) => boolean;
|
|
18
|
+
export declare const hasContent: (message: WithParts) => boolean;
|
|
19
|
+
export declare function buildToolIdList(state: SessionState, messages: WithParts[]): string[];
|
|
20
|
+
export declare const replaceBlockIdsWithBlocked: (text: string) => string;
|
|
21
|
+
export declare const stripStaleMessageRefs: (text: string) => string;
|
|
22
|
+
export declare const stripHallucinationsFromString: (text: string) => string;
|
|
23
|
+
export declare const stripLeakedTrailingRefs: (text: string, bounds: {
|
|
24
|
+
nextMessageRef?: number | null;
|
|
25
|
+
nextBlockRef?: number | null;
|
|
26
|
+
}) => string;
|
|
27
|
+
export declare const stripHallucinations: (messages: WithParts[]) => void;
|
|
28
|
+
export declare const dropEmptyMessages: (messages: WithParts[]) => number;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/messages/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAiBvD,eAAO,MAAM,sBAAsB,GAC/B,aAAa,SAAS,EACtB,SAAS,MAAM,EACf,aAAa,MAAM,EACnB,OAAM,MAAM,GAAG,WAAoB,KACpC,SAiDF,CAAA;AAED,eAAO,MAAM,0BAA0B,GACnC,aAAa,SAAS,EACtB,SAAS,MAAM,EACf,aAAa,MAAM,KACpB,SAA6E,CAAA;AAEhF,eAAO,MAAM,uBAAuB,GAChC,aAAa,SAAS,EACtB,SAAS,MAAM,EACf,aAAa,MAAM;;;;;;CAatB,CAAA;AAED,KAAK,WAAW,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAA;AAE7C,KAAK,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEtD,eAAO,MAAM,oBAAoB,GAAI,SAAS,SAAS,EAAE,WAAW,MAAM,KAAG,OAO5E,CAAA;AAaD,eAAO,MAAM,gBAAgB,GAAI,MAAM,QAAQ,EAAE,WAAW,MAAM,KAAG,OAgBpE,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,SAAS,SAAS,EAAE,KAAK,MAAM,KAAG,OAQtE,CAAA;AAcD,eAAO,MAAM,UAAU,GAAI,SAAS,SAAS,KAAG,OAU/C,CAAA;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAiBpF;AAED,eAAO,MAAM,0BAA0B,GAAI,MAAM,MAAM,KAAG,MAEzD,CAAA;AAGD,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,KAAG,MAEpD,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAI,MAAM,MAAM,KAAG,MAE5D,CAAA;AAkCD,eAAO,MAAM,uBAAuB,GAChC,MAAM,MAAM,EACZ,QAAQ;IAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,KACzE,MAgCF,CAAA;AAED,eAAO,MAAM,mBAAmB,GAAI,UAAU,SAAS,EAAE,KAAG,IAgB3D,CAAA;AAeD,eAAO,MAAM,iBAAiB,GAAI,UAAU,SAAS,EAAE,KAAG,MAiBzD,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the range-mode compress tool prompt.
|
|
3
|
+
*
|
|
4
|
+
* candidatesEnabled mirrors `compress.candidates`: false omits the CANDIDATE
|
|
5
|
+
* GUIDANCE section (behavior identical to pre-candidate master), true includes it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildCompressRangePrompt(candidatesEnabled: boolean): string;
|
|
8
|
+
/** Bundled range-mode compress prompt with candidate guidance enabled. */
|
|
9
|
+
export declare const COMPRESS_RANGE: string;
|
|
10
|
+
//# sourceMappingURL=compress-range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compress-range.d.ts","sourceRoot":"","sources":["../../src/prompts/compress-range.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,OAAO,GAAG,MAAM,CAmE3E;AAED,0EAA0E;AAC1E,eAAO,MAAM,cAAc,QAAiC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const CONTEXT_LIMIT_NUDGE = "\n<system-reminder>\n\u26A0\uFE0F Context limit reached \u2014 time to compress the largest ranges you no longer need. Prioritize completed tool outputs and resolved work. You can decompress specific blocks later if you need details. Keeping context lean helps you stay accurate.\n\nIf mid-atomic-operation, finish that step first, then compress.\n\nHOW TO CALL COMPRESS:\n{\n \"topic\": \"Short Label\",\n \"content\": [\n {\n \"startId\": \"<ID from early in this conversation>\",\n \"endId\": \"<ID from later in this conversation>\",\n \"summary\": \"Complete technical summary of everything in the range\"\n }\n ]\n}\n\n\u26A0\uFE0F ID RULES \u2014 MOST COMMON CAUSE OF ERRORS:\n- ONLY use IDs you can see in tags in the messages ABOVE.\n- Do NOT copy IDs from this example. Do NOT invent IDs.\n- Do NOT use IDs from compressed block summaries \u2014 they are stale.\n- startId must appear BEFORE endId in the conversation.\n\nRANGE STRATEGY:\n- Prefer one large range over multiple small ones.\n- Compress OLDER resolved history first. Keep recent active work.\n</system-reminder>\n";
|
|
2
|
+
/**
|
|
3
|
+
* Candidate-mode guidance appended to the context-limit nudge when
|
|
4
|
+
* `compress.candidates` is enabled. Describes the MICRO/EPISODE candidate
|
|
5
|
+
* list that replaces the raw range strategy above in that mode.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CANDIDATE_GUIDANCE = "\n<system-reminder>\nCOMPRESSION CANDIDATES:\n- MICRO identifies one large message or complete tool transaction.\n- EPISODE identifies a contiguous historical segment made from smaller units.\n- Candidate entries are independent and non-overlapping, so they can be batched in one `content[]` array.\n- Candidates are suggestions, not mandatory targets. Choose only content no longer needed for the current task and do not invent a target when none is listed.\n- Use `acp_status` for a fresh candidate view if the list is stale or missing.\n- When the context limit is reached and candidates are listed, select at least one clearly stale candidate and call the `compress` tool in your next reply. Batch only additional candidates that are also clearly stale. Do not merely recommend compression.\n</system-reminder>\n";
|
|
8
|
+
//# sourceMappingURL=context-limit-nudge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-limit-nudge.d.ts","sourceRoot":"","sources":["../../src/prompts/context-limit-nudge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,8lCA4B/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,qzBAU9B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SessionState } from "../../state";
|
|
2
|
+
export interface BlockGuidanceContext {
|
|
3
|
+
currentTokens?: number;
|
|
4
|
+
modelContextLimit?: number;
|
|
5
|
+
includeHint?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Raw message IDs currently visible in the model's context window.
|
|
8
|
+
* When provided, the directive nudge only suggests ranges whose anchor
|
|
9
|
+
* messages are still visible, preventing stale-ID and backwards-range bugs.
|
|
10
|
+
*/
|
|
11
|
+
visibleMessageIds?: Set<string>;
|
|
12
|
+
}
|
|
13
|
+
export declare function buildCompressedBlockGuidance(state: SessionState, context?: BlockGuidanceContext): string;
|
|
14
|
+
export declare function renderMessagePriorityGuidance(priorityLabel: string, refs: string[]): string;
|
|
15
|
+
export declare function appendGuidanceToAcpTag(nudgeText: string, guidance: string): string;
|
|
16
|
+
//# sourceMappingURL=nudge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nudge.d.ts","sourceRoot":"","sources":["../../../src/prompts/extensions/nudge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAA;AAGjE,MAAM,WAAW,oBAAoB;IACjC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAClC;AAED,wBAAgB,4BAA4B,CACxC,KAAK,EAAE,YAAY,EACnB,OAAO,CAAC,EAAE,oBAAoB,GAC/B,MAAM,CA0ER;AAED,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAQ3F;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAelF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const SUBAGENT_SYSTEM_EXTENSION = "<acp-system-reminder>\nYou are operating in a subagent environment.\n\nThe initial subagent instruction is imperative and must be followed exactly.\nIt is the only user message intentionally not assigned a message ID, and therefore is not eligible for compression.\nAll subsequent messages in the session will have IDs.\n</acp-system-reminder>\n";
|
|
2
|
+
export declare function buildProtectedToolsExtension(protectedTools: string[]): string;
|
|
3
|
+
export declare const DECOMPRESS_SYSTEM_EXTENSION = "<acp-system-reminder>\nTHE PHILOSOPHY OF DECOMPRESS\n`decompress` restores previously compressed content. Use it when you need exact details\nthat were lost in compression.\n\nDECOMPRESS WHEN\n- You need exact code, error messages, or file contents from a compressed block\n- A summary lacks the precision needed for your next step\n- You discovered the compressed content is still relevant\n\nDO NOT DECOMPRESS IF\n- Context usage is already high (>70%) \u2014 decompressing inflates context\n- The summary is sufficient for your needs\n- You plan to immediately recompress the same content\n\nBefore decompressing, check context usage. Decompressing restores full messages,\nwhich can significantly increase context size.\n\nNOTE: Message-mode blocks created in the same batch (same runId) are restored together.\nDecompressing one block from a batch restores all blocks in that batch.\n</acp-system-reminder>\n";
|
|
4
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../../src/prompts/extensions/system.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,8VAOrC,CAAA;AAED,wBAAgB,4BAA4B,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,CAW7E;AAED,eAAO,MAAM,2BAA2B,s5BAqBvC,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const RANGE_FORMAT_EXTENSION = "\n\nTHE FORMAT OF COMPRESS\n\n```\n{\n topic?: string, // OPTIONAL fallback topic for entries without their own.\n // Omit when every content entry specifies its own topic.\n content: [ // One or more ranges to compress\n {\n topic?: string, // OPTIONAL per-entry topic for this range.\n // Falls back to top-level topic.\n // Give each entry its own topic when compressing\n // unrelated ranges in one call.\n startId: string, // Boundary ID at range start: mNNNNN or bN\n endId: string, // Boundary ID at range end: mNNNNN or bN\n summary: string // Complete technical summary replacing all content in range\n }\n ]\n}\n```\nEach entry needs a topic \u2014 either its own or the top-level fallback.";
|
|
2
|
+
export declare const MESSAGE_FORMAT_EXTENSION = "\nTHE FORMAT OF COMPRESS\n\n```\n{\n topic: string, // Short label (3-5 words) for the overall batch\n content: [ // One or more messages to compress independently\n {\n messageId: string, // Raw message ID only: mNNNNN (ignore metadata attributes like priority)\n topic: string, // Short label (3-5 words) for this one message summary\n summary: string // Complete technical summary replacing that one message\n }\n ]\n}\n```";
|
|
3
|
+
//# sourceMappingURL=tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../../src/prompts/extensions/tool.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,y3BAqBkC,CAAA;AAErE,eAAO,MAAM,wBAAwB,4eAc9B,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RuntimePrompts } from "./store";
|
|
2
|
+
export type { PromptStore, RuntimePrompts } from "./store";
|
|
3
|
+
export declare function renderSystemPrompt(prompts: RuntimePrompts, protectedToolsExtension?: string, subagent?: boolean): string;
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAC7C,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE1D,wBAAgB,kBAAkB,CAC9B,OAAO,EAAE,cAAc,EACvB,uBAAuB,CAAC,EAAE,MAAM,EAChC,QAAQ,CAAC,EAAE,OAAO,GACnB,MAAM,CAoBR"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ITERATION_NUDGE = "\n<system-reminder>\nYou've been iterating for a while. If any earlier work is closed and unlikely to be referenced, compress it now.\n\n{\n \"topic\": \"Short Label\",\n \"content\": [{ \"startId\": \"<visible message ID>\", \"endId\": \"<visible message ID>\", \"summary\": \"...\" }]\n}\n\n\u26A0\uFE0F ONLY use IDs from tags visible above. Do NOT invent or copy example IDs.\n</system-reminder>\n";
|
|
2
|
+
/**
|
|
3
|
+
* Candidate-mode guidance appended to the iteration nudge when
|
|
4
|
+
* `compress.candidates` is enabled.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ITERATION_CANDIDATE_GUIDANCE = "\nMICRO candidates are complete large messages or tool transactions. EPISODE candidates are contiguous historical segments. They are independent suggestions and may be batched, but preserve anything still needed for the current task. Do not compress active work or every candidate.\n";
|
|
7
|
+
//# sourceMappingURL=iteration-nudge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration-nudge.d.ts","sourceRoot":"","sources":["../../src/prompts/iteration-nudge.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,wZAW3B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,gSAExC,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Logger } from "../logger";
|
|
2
|
+
export type PromptKey = "system" | "compress-range" | "context-limit-nudge" | "turn-nudge" | "iteration-nudge";
|
|
3
|
+
export interface RuntimePrompts {
|
|
4
|
+
system: string;
|
|
5
|
+
compressRange: string;
|
|
6
|
+
contextLimitNudge: string;
|
|
7
|
+
turnNudge: string;
|
|
8
|
+
iterationNudge: string;
|
|
9
|
+
subagentExtension: string;
|
|
10
|
+
decompressExtension: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const PROMPT_KEYS: PromptKey[];
|
|
13
|
+
export declare class PromptStore {
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private readonly paths;
|
|
16
|
+
private readonly customPromptsEnabled;
|
|
17
|
+
private readonly candidatesEnabled;
|
|
18
|
+
private runtimePrompts;
|
|
19
|
+
constructor(logger: Logger, workingDirectory: string, customPromptsEnabled?: boolean, candidatesEnabled?: boolean);
|
|
20
|
+
getRuntimePrompts(): RuntimePrompts;
|
|
21
|
+
reload(): void;
|
|
22
|
+
private getOverrideCandidates;
|
|
23
|
+
private ensureDefaultFiles;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/prompts/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAQvC,MAAM,MAAM,SAAS,GACjB,QAAQ,GAAG,gBAAgB,GAAG,qBAAqB,GAAG,YAAY,GAAG,iBAAiB,CAAA;AAyB1F,MAAM,WAAW,cAAc;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,iBAAiB,EAAE,MAAM,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,cAAc,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,MAAM,CAAA;IACzB,mBAAmB,EAAE,MAAM,CAAA;CAC9B;AA6CD,eAAO,MAAM,WAAW,EAAE,SAAS,EAMlC,CAAA;AAiND,qBAAa,WAAW;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAS;IAC3C,OAAO,CAAC,cAAc,CAAgB;gBAGlC,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,oBAAoB,UAAQ,EAC5B,iBAAiB,UAAQ;IAc7B,iBAAiB,IAAI,cAAc;IAInC,MAAM,IAAI,IAAI;IAmDd,OAAO,CAAC,qBAAqB;IAsB7B,OAAO,CAAC,kBAAkB;CAmD7B"}
|