@logictan/dsh-verbatim-compaction 0.13.1 → 0.13.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/cordis.patch.yml +2 -0
- package/lib/index.js +3 -25
- package/lib/purpose.js +25 -0
- package/lib/types/index.d.ts +1 -26
- package/lib/types/purpose.d.ts +27 -0
- package/package.json +6 -2
package/cordis.patch.yml
CHANGED
package/lib/index.js
CHANGED
|
@@ -32,15 +32,9 @@
|
|
|
32
32
|
*/
|
|
33
33
|
import { BasicCompactionEngine } from '@deepseek-ai/dsh-compaction-basic';
|
|
34
34
|
import { ReasoningEffortId } from '@deepseek-ai/dsh-llm';
|
|
35
|
-
import
|
|
35
|
+
import { getLiveConfig } from './purpose.js';
|
|
36
36
|
/** Cordis companion plugin name. Must equal this plugin's `cordis.patch.yml` row id. */
|
|
37
37
|
export const name = 'verbatim-compaction';
|
|
38
|
-
/** Three editable scalars; empty strings mean "follow the chat model". */
|
|
39
|
-
export const OVERRIDE_FIELDS = {
|
|
40
|
-
provider: Schema.string().default('').volatile(),
|
|
41
|
-
model: Schema.string().default('').volatile(),
|
|
42
|
-
reasoningEffort: Schema.string().default('').volatile(),
|
|
43
|
-
};
|
|
44
38
|
/** A provider/model override takes effect only as a complete pair. */
|
|
45
39
|
export function pairedRouteOf(config) {
|
|
46
40
|
const provider = config?.provider?.get().trim();
|
|
@@ -1479,22 +1473,6 @@ async function extractOnce(ctx, agent, batch, signal, override) {
|
|
|
1479
1473
|
* subclass cannot diverge from the host's transaction semantics.
|
|
1480
1474
|
*/
|
|
1481
1475
|
export default class VerbatimCompactionEngine extends BasicCompactionEngine {
|
|
1482
|
-
/**
|
|
1483
|
-
* The Loader reads Config from the default-exported class, and the base
|
|
1484
|
-
* constructor rejects unknown keys, so the base schema is merged instead of
|
|
1485
|
-
* replaced. Only the three new fields are volatile: existing keys stay
|
|
1486
|
-
* ordinary patch-level configuration.
|
|
1487
|
-
*/
|
|
1488
|
-
static Config = Schema.object({
|
|
1489
|
-
...BasicCompactionEngine.Config.dict,
|
|
1490
|
-
...OVERRIDE_FIELDS,
|
|
1491
|
-
});
|
|
1492
|
-
purposeConfig;
|
|
1493
|
-
constructor(ctx, config) {
|
|
1494
|
-
const { provider, model, reasoningEffort, ...base } = config ?? {};
|
|
1495
|
-
super(ctx, base);
|
|
1496
|
-
this.purposeConfig = { provider, model, reasoningEffort };
|
|
1497
|
-
}
|
|
1498
1476
|
/**
|
|
1499
1477
|
* Extraction results, keyed by a hash of the material they were derived from.
|
|
1500
1478
|
*
|
|
@@ -1550,12 +1528,12 @@ export default class VerbatimCompactionEngine extends BasicCompactionEngine {
|
|
|
1550
1528
|
// size independent of history length; the guard bound only exists for the
|
|
1551
1529
|
// degenerate case of a span smaller than the ceiling.
|
|
1552
1530
|
const budget = Math.max(0, Math.min(DIGEST_TOKEN_CEILING, shadowedPrice - FRAME_TOKENS - SHRINK_MARGIN_TOKENS));
|
|
1553
|
-
const extracted = await this.extractAll(source, agent, signal,
|
|
1531
|
+
const extracted = await this.extractAll(source, agent, signal, getLiveConfig());
|
|
1554
1532
|
// Fold the oldest turns up only when the plain digest overflows. The fold is an
|
|
1555
1533
|
// LLM call, so a digest that already fits must not pay for one.
|
|
1556
1534
|
let condensed;
|
|
1557
1535
|
if (renderDigest(source, budget, extracted).length > budget * 4) {
|
|
1558
|
-
condensed = await this.condenseOldest(source, extracted, agent, budget, signal,
|
|
1536
|
+
condensed = await this.condenseOldest(source, extracted, agent, budget, signal, getLiveConfig());
|
|
1559
1537
|
}
|
|
1560
1538
|
// The fold path returns its digest whole, so it can still overflow when every
|
|
1561
1539
|
// group has been folded and the user lines alone are too long. The budget is a
|
package/lib/purpose.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Schema from '@deepseek-ai/schemastery';
|
|
2
|
+
/** Settings namespace for the optional model override used by compaction. */
|
|
3
|
+
export const name = 'verbatim-compaction-purpose';
|
|
4
|
+
/** The three editable scalars; empty strings mean "follow the chat model". */
|
|
5
|
+
export const Config = Schema.object({
|
|
6
|
+
provider: Schema.string().default('').volatile(),
|
|
7
|
+
model: Schema.string().default('').volatile(),
|
|
8
|
+
reasoningEffort: Schema.string().default('').volatile(),
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* The compaction engine runs inside isolated preset groups, while this
|
|
12
|
+
* settings row lives in the root realm. A module-level live reference is the
|
|
13
|
+
* one channel both halves can see without registering a second service.
|
|
14
|
+
*/
|
|
15
|
+
let liveConfig;
|
|
16
|
+
export function setLiveConfig(config) {
|
|
17
|
+
liveConfig = config;
|
|
18
|
+
}
|
|
19
|
+
export function getLiveConfig() {
|
|
20
|
+
return liveConfig;
|
|
21
|
+
}
|
|
22
|
+
/** Root-realm settings row. It registers no service. */
|
|
23
|
+
export function apply(_ctx, config) {
|
|
24
|
+
setLiveConfig(config);
|
|
25
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -33,26 +33,10 @@
|
|
|
33
33
|
import { BasicCompactionEngine } from '@deepseek-ai/dsh-compaction-basic';
|
|
34
34
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
35
35
|
import { type ContentBlock, type Message } from '@deepseek-ai/dsh-llm';
|
|
36
|
-
import Schema from '@deepseek-ai/schemastery';
|
|
37
36
|
import type { Session, SessionEvent, SessionSeq } from '@deepseek-ai/dsh-session';
|
|
37
|
+
import { type PurposeConfig } from './purpose.js';
|
|
38
38
|
/** Cordis companion plugin name. Must equal this plugin's `cordis.patch.yml` row id. */
|
|
39
39
|
export declare const name = "verbatim-compaction";
|
|
40
|
-
/** Live reference Cordis hands over for a volatile Config field. */
|
|
41
|
-
interface ConfigRef<T> {
|
|
42
|
-
get(): T;
|
|
43
|
-
}
|
|
44
|
-
/** Optional model/effort override for compaction's two LLM calls. */
|
|
45
|
-
export interface PurposeConfig {
|
|
46
|
-
provider?: ConfigRef<string>;
|
|
47
|
-
model?: ConfigRef<string>;
|
|
48
|
-
reasoningEffort?: ConfigRef<string>;
|
|
49
|
-
}
|
|
50
|
-
/** Three editable scalars; empty strings mean "follow the chat model". */
|
|
51
|
-
export declare const OVERRIDE_FIELDS: {
|
|
52
|
-
provider: Schema<string, string, "volatile-defined">;
|
|
53
|
-
model: Schema<string, string, "volatile-defined">;
|
|
54
|
-
reasoningEffort: Schema<string, string, "volatile-defined">;
|
|
55
|
-
};
|
|
56
40
|
/** A provider/model override takes effect only as a complete pair. */
|
|
57
41
|
export declare function pairedRouteOf(config: PurposeConfig | undefined): {
|
|
58
42
|
provider: string;
|
|
@@ -358,15 +342,6 @@ export declare function buildExtractionMaterial(turn: readonly SessionEvent[], p
|
|
|
358
342
|
* subclass cannot diverge from the host's transaction semantics.
|
|
359
343
|
*/
|
|
360
344
|
export default class VerbatimCompactionEngine extends BasicCompactionEngine {
|
|
361
|
-
/**
|
|
362
|
-
* The Loader reads Config from the default-exported class, and the base
|
|
363
|
-
* constructor rejects unknown keys, so the base schema is merged instead of
|
|
364
|
-
* replaced. Only the three new fields are volatile: existing keys stay
|
|
365
|
-
* ordinary patch-level configuration.
|
|
366
|
-
*/
|
|
367
|
-
static Config: typeof BasicCompactionEngine.Config;
|
|
368
|
-
private readonly purposeConfig;
|
|
369
|
-
constructor(ctx: ConstructorParameters<typeof BasicCompactionEngine>[0], config: any);
|
|
370
345
|
/**
|
|
371
346
|
* Extraction results, keyed by a hash of the material they were derived from.
|
|
372
347
|
*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Schema from '@deepseek-ai/schemastery';
|
|
2
|
+
/** Settings namespace for the optional model override used by compaction. */
|
|
3
|
+
export declare const name = "verbatim-compaction-purpose";
|
|
4
|
+
/** A live reference Cordis hands over for a volatile Config field. */
|
|
5
|
+
export interface ConfigRef<T> {
|
|
6
|
+
get(): T;
|
|
7
|
+
}
|
|
8
|
+
/** The three editable scalars; empty strings mean "follow the chat model". */
|
|
9
|
+
export declare const Config: Schema<Schemastery.ObjectS<NoInfer<{
|
|
10
|
+
provider: Schema<string, string, "volatile-defined">;
|
|
11
|
+
model: Schema<string, string, "volatile-defined">;
|
|
12
|
+
reasoningEffort: Schema<string, string, "volatile-defined">;
|
|
13
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
14
|
+
provider: Schema<string, string, "volatile-defined">;
|
|
15
|
+
model: Schema<string, string, "volatile-defined">;
|
|
16
|
+
reasoningEffort: Schema<string, string, "volatile-defined">;
|
|
17
|
+
}>>, "plain">;
|
|
18
|
+
/** The shape of the live configuration Cordis passes to the plugin. */
|
|
19
|
+
export interface PurposeConfig {
|
|
20
|
+
provider?: ConfigRef<string>;
|
|
21
|
+
model?: ConfigRef<string>;
|
|
22
|
+
reasoningEffort?: ConfigRef<string>;
|
|
23
|
+
}
|
|
24
|
+
export declare function setLiveConfig(config: PurposeConfig): void;
|
|
25
|
+
export declare function getLiveConfig(): PurposeConfig | undefined;
|
|
26
|
+
/** Root-realm settings row. It registers no service. */
|
|
27
|
+
export declare function apply(_ctx: unknown, config: PurposeConfig): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logictan/dsh-verbatim-compaction",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "Deterministic compaction backend that keeps conversation prose verbatim in the checkpoint instead of re-summarizing it: user and assistant text survive word for word, tool results collapse to one-line pointers, reasoning is never read, and no model call is made.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"types": "./lib/types/index.d.ts",
|
|
11
11
|
"default": "./lib/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./package.json": "./package.json"
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
"./purpose": {
|
|
15
|
+
"types": "./lib/types/purpose.d.ts",
|
|
16
|
+
"default": "./lib/purpose.js"
|
|
17
|
+
}
|
|
14
18
|
},
|
|
15
19
|
"dsh": {
|
|
16
20
|
"bundle": {
|