dsh-manual-compact-plugin 0.2.2 → 0.2.4
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/lib/index.js +14 -7
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -17,7 +17,7 @@ import { mkdir, appendFile } from 'node:fs/promises'
|
|
|
17
17
|
import os from 'node:os'
|
|
18
18
|
|
|
19
19
|
const name = 'dsh-manual-compact-plugin'
|
|
20
|
-
const inject = ['settings', 'agents']
|
|
20
|
+
const inject = ['settings', 'agents', 'compaction']
|
|
21
21
|
const NS = 'manual-compact'
|
|
22
22
|
|
|
23
23
|
/** Composition-row configuration (also the settings schema). */
|
|
@@ -129,13 +129,15 @@ function resolveAgent(agents, sessionId) {
|
|
|
129
129
|
* Supports cancellation through `signal` and reports progress through
|
|
130
130
|
* `onProgress`. Returns the outcome including a readable file path.
|
|
131
131
|
*/
|
|
132
|
-
async function executeCompact(ctx, agents, request, signal, onProgress) {
|
|
132
|
+
async function executeCompact(ctx, agents, request, signal, onProgress, resolvedCompaction) {
|
|
133
133
|
const resolved = resolveAgent(agents, request.sessionId)
|
|
134
134
|
const agent = resolved.agent
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
const rootCompaction =
|
|
135
|
+
// Prefer the compaction reference captured at plugin activation (the same
|
|
136
|
+
// seam `/compact` uses). Fall back to the agent's own context, then to a
|
|
137
|
+
// request-time lookup, and report exactly which source is available.
|
|
138
|
+
const rootCompaction = resolvedCompaction !== undefined
|
|
139
|
+
? resolvedCompaction
|
|
140
|
+
: (ctx && typeof ctx.get === 'function' ? ctx.get('compaction') : undefined)
|
|
139
141
|
const agentCompaction = agent && agent.ctx && typeof agent.ctx.get === 'function' ? agent.ctx.get('compaction') : undefined
|
|
140
142
|
const compaction = rootCompaction || agentCompaction
|
|
141
143
|
if (!agent || !compaction) {
|
|
@@ -190,6 +192,11 @@ function apply(ctx, config) {
|
|
|
190
192
|
let lastHandledNonce = null
|
|
191
193
|
let handling = null
|
|
192
194
|
const controllers = new Map() // sessionId -> AbortController
|
|
195
|
+
// Capture the compaction seam at activation. Declared as a hard dependency
|
|
196
|
+
// (inject: ['compaction']) so Cordis only activates this plugin once the
|
|
197
|
+
// compaction provider is live — mirroring /compact's contract. Fall back to
|
|
198
|
+
// a request-time ctx lookup and the agent ctx if it is ever absent.
|
|
199
|
+
const compactionAtApply = (typeof ctx.get === 'function') ? ctx.get('compaction') : undefined
|
|
193
200
|
|
|
194
201
|
const handle = () => {
|
|
195
202
|
const current = getter()
|
|
@@ -217,7 +224,7 @@ function apply(ctx, config) {
|
|
|
217
224
|
const onProgress = async (p) => {
|
|
218
225
|
try { await ctx.settings.update(NS, { progress: p }) } catch {}
|
|
219
226
|
}
|
|
220
|
-
const result = await executeCompact(ctx, ctx.agents, request, controller.signal, onProgress)
|
|
227
|
+
const result = await executeCompact(ctx, ctx.agents, request, controller.signal, onProgress, compactionAtApply)
|
|
221
228
|
await ctx.settings.update(NS, {
|
|
222
229
|
request: null,
|
|
223
230
|
progress: null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-manual-compact-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Manual context compaction for DeepSeek Harness: keep the latest N conversation items with stop or batch mode and a per-session compaction archive — embedded in the context meter popup when the meter panel slot exists, or a composer button otherwise.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|