@serkanalgur/opencodev2-slim 2.0.13 → 2.0.15
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/package.json +1 -1
- package/src/index.ts +138 -122
- package/src/lib/config.ts +57 -8
- package/src/lib/prompts.ts +28 -12
- package/src/lib/state.ts +25 -2
- package/src/lib/strategies.ts +704 -17
- package/src/lib/types.ts +52 -3
package/src/lib/types.ts
CHANGED
|
@@ -6,15 +6,30 @@ export interface SlimConfig {
|
|
|
6
6
|
enabled: boolean
|
|
7
7
|
debug: boolean
|
|
8
8
|
|
|
9
|
-
// Compression settings
|
|
9
|
+
// Compression settings (DCP-compatible semantics)
|
|
10
10
|
compress: {
|
|
11
11
|
enabled: boolean
|
|
12
|
+
/** DCP mode: "range" (contiguous spans) or "message" (surgical, single messages) */
|
|
13
|
+
mode?: "range" | "message"
|
|
12
14
|
permission: "allow" | "ask" | "deny"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
/** Absolute token count or percent string like "80%" (DCP default: 100000) */
|
|
16
|
+
maxContextLimit: number | string
|
|
17
|
+
/** Absolute token count or percent string like "40%" (DCP default: 50000) */
|
|
18
|
+
minContextLimit: number | string
|
|
19
|
+
/** Per-model overrides, keyed "providerId/modelId" (DCP: compress.modelMaxLimits) */
|
|
20
|
+
modelMaxLimits?: Record<string, number | string>
|
|
21
|
+
/** Per-model overrides, keyed "providerId/modelId" (DCP: compress.modelMinLimits) */
|
|
22
|
+
modelMinLimits?: Record<string, number | string>
|
|
23
|
+
/** At most one limit-nudge per this many messages (DCP default: 5) */
|
|
15
24
|
nudgeFrequency: number
|
|
25
|
+
/** Messages since last user message before iteration nudge fires (DCP default: 15) */
|
|
26
|
+
iterationNudgeThreshold?: number
|
|
27
|
+
/** Where the turn nudge is anchored: "strong" -> user, "soft" -> assistant (DCP default: soft) */
|
|
28
|
+
nudgeForce?: "strong" | "soft"
|
|
16
29
|
protectUserMessages: boolean
|
|
17
30
|
protectedTools: string[]
|
|
31
|
+
/** Number of recent messages to always keep during auto-compress (default: 5) */
|
|
32
|
+
keepRecent?: number
|
|
18
33
|
}
|
|
19
34
|
|
|
20
35
|
// Strategy settings
|
|
@@ -67,6 +82,40 @@ export interface SessionState {
|
|
|
67
82
|
|
|
68
83
|
// Tool call tracking
|
|
69
84
|
toolCalls: Map<string, ToolCallInfo>
|
|
85
|
+
|
|
86
|
+
// DCP-style compression blocks (range -> summary placeholders)
|
|
87
|
+
compressionBlocks?: CompressionBlock[]
|
|
88
|
+
nextBlockId?: number
|
|
89
|
+
// DCP-style nudge anchors
|
|
90
|
+
nudges?: NudgeState
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A DCP-style compression block. When active, the covered messages are
|
|
95
|
+
* removed from every outgoing request and replaced by a synthetic summary
|
|
96
|
+
* message injected at the anchor message (the message right after the range).
|
|
97
|
+
*/
|
|
98
|
+
export interface CompressionBlock {
|
|
99
|
+
blockId: number
|
|
100
|
+
topic: string
|
|
101
|
+
summary: string
|
|
102
|
+
/** Message id where the summary is injected (first message after the range, or the last message when the range reaches the end). */
|
|
103
|
+
anchorMessageId: string
|
|
104
|
+
/** The assistant message that executed the compress call; used to deactivate blocks when the source is gone. */
|
|
105
|
+
compressMessageId: string
|
|
106
|
+
/** Original message ids covered (excluded) by this block. */
|
|
107
|
+
coveredMessageIds: string[]
|
|
108
|
+
/** Older blocks swallowed by this block (nested compression). */
|
|
109
|
+
consumedBlockIds: number[]
|
|
110
|
+
active: boolean
|
|
111
|
+
createdAt: number
|
|
112
|
+
summaryTokens: number
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface NudgeState {
|
|
116
|
+
contextLimitAnchors: string[]
|
|
117
|
+
turnNudgeAnchors: string[]
|
|
118
|
+
iterationNudgeAnchors: string[]
|
|
70
119
|
}
|
|
71
120
|
|
|
72
121
|
export interface CompressionRecord {
|