@deepseek-ai/dsh-compaction-basic 0.1.2-alpha.3 → 0.1.2-alpha.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/README.i18n.yaml +2 -2
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/index.js +7 -7
- package/lib/types/index.d.ts +2 -1
- package/lib/types/region.d.ts +4 -4
- package/package.json +22 -28
- package/lib/invariant.js +0 -23
- package/lib/types/invariant.d.ts +0 -16
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/compaction/compaction-basic/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 026a54a3cc0d2bf45873acf4f607eb7b392e5dbf
|
|
6
|
+
README.zh.md: 60534f6ef1b065a0c19642c7d02315f66f2b19ca
|
package/README.md
CHANGED
|
@@ -134,7 +134,7 @@ The transaction validates the surface span and the durable lock, appends `compac
|
|
|
134
134
|
| [`src/summarizer.ts`](src/summarizer.ts) | Default `ctx.llm.stream()` summarization, checkpoint framing, safe-summary projection |
|
|
135
135
|
| [`src/config.ts`](src/config.ts) | Load-time validation and routed-model policy resolution |
|
|
136
136
|
| [`src/types.ts`](src/types.ts) | `BasicCompactionConfig` and resolved policy vocabulary |
|
|
137
|
-
|
|
|
137
|
+
| — | No runtime invariant companion is published; this package exposes no independent event sequence or mutable data relation beyond contracts enforced at its owning seam. |
|
|
138
138
|
|
|
139
139
|
</details>
|
|
140
140
|
|
package/README.zh.md
CHANGED
|
@@ -134,7 +134,7 @@ kind: "package-reference"
|
|
|
134
134
|
| [`src/summarizer.ts`](src/summarizer.ts) | 默认 `ctx.llm.stream()` 摘要、检查点框定、安全摘要投影 |
|
|
135
135
|
| [`src/config.ts`](src/config.ts) | 加载时验证与路由模型策略解析 |
|
|
136
136
|
| [`src/types.ts`](src/types.ts) | `BasicCompactionConfig` 与已解析策略词汇 |
|
|
137
|
-
|
|
|
137
|
+
| — | 不发布运行时不变式伴生入口;持久标记对可在会话日志中观察。 |
|
|
138
138
|
|
|
139
139
|
</details>
|
|
140
140
|
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { BlockAssembler, CONTEXT_WINDOW_EXCEEDED_CODE, LlmError, contentHasImage
|
|
|
4
4
|
import { assertNever, deepFreeze } from "@deepseek-ai/dsh-util-values";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
6
|
import { isDeepStrictEqual } from "node:util";
|
|
7
|
+
import { SessionSeq } from "@deepseek-ai/dsh-session";
|
|
7
8
|
//#region lib/types/config.js
|
|
8
9
|
/**
|
|
9
10
|
* Load-time validation and routed-model policy resolution for compaction-basic.
|
|
@@ -419,7 +420,7 @@ function selectCompactableRange(session, measurement, retainTokens) {
|
|
|
419
420
|
async function compactSurfaceRegion(dependencies, session, start, end, agent, options, signal) {
|
|
420
421
|
if (options.owner === null) signal?.throwIfAborted();
|
|
421
422
|
const selection = validateSurfaceRegion(session, start, end);
|
|
422
|
-
const entryState = inspectCompactionEntryState(session
|
|
423
|
+
const entryState = inspectCompactionEntryState(session);
|
|
423
424
|
assertCompactionInactive(entryState.unmatchedCompactionStart, entryState.latestEndSeedSeq, "compaction");
|
|
424
425
|
let owner;
|
|
425
426
|
if (options.owner === null) {
|
|
@@ -512,7 +513,7 @@ function assertCompactionInactive(unmatchedCompactionStart, latestEndSeedSeq, st
|
|
|
512
513
|
* @param stage - operation label included in the busy diagnostic.
|
|
513
514
|
*/
|
|
514
515
|
function assertNoActiveCompaction(session, stage) {
|
|
515
|
-
const entryState = inspectCompactionEntryState(session
|
|
516
|
+
const entryState = inspectCompactionEntryState(session);
|
|
516
517
|
assertCompactionInactive(entryState.unmatchedCompactionStart, entryState.latestEndSeedSeq, stage);
|
|
517
518
|
}
|
|
518
519
|
/** Validate one requested surface-position span before asynchronous work begins. */
|
|
@@ -649,8 +650,7 @@ function completeCompaction(pending, endEvent) {
|
|
|
649
650
|
*/
|
|
650
651
|
function buildSummarizationInput(session, shadowedSeqs) {
|
|
651
652
|
const header = session.requestHeader();
|
|
652
|
-
const
|
|
653
|
-
const regionMessages = shadowedSeqs.map((seq) => session.deriveEventMessage(events[seq])).filter((message) => message !== null);
|
|
653
|
+
const regionMessages = shadowedSeqs.map((seq) => session.deriveEventMessage(session.eventAt(seq))).filter((message) => message !== null);
|
|
654
654
|
return {
|
|
655
655
|
...header?.system === void 0 ? {} : { system: header.system },
|
|
656
656
|
...header?.tools === void 0 ? {} : { tools: header.tools },
|
|
@@ -658,14 +658,14 @@ function buildSummarizationInput(session, shadowedSeqs) {
|
|
|
658
658
|
};
|
|
659
659
|
}
|
|
660
660
|
/** Inspect open-turn, unmatched-compaction, and latest seed-boundary state independently. */
|
|
661
|
-
function inspectCompactionEntryState(
|
|
661
|
+
function inspectCompactionEntryState(session) {
|
|
662
662
|
let openTurn = null;
|
|
663
663
|
let openTurnStateKnown = false;
|
|
664
664
|
let unmatchedCompactionStart;
|
|
665
665
|
let compactionEntryStateKnown = false;
|
|
666
666
|
let latestEndSeedSeq;
|
|
667
|
-
for (let
|
|
668
|
-
const event =
|
|
667
|
+
for (let seq = session.seq - 1; seq >= 0; seq -= 1) {
|
|
668
|
+
const event = session.eventAt(SessionSeq(seq));
|
|
669
669
|
if (latestEndSeedSeq === void 0 && event.type === "session/end-seed") latestEndSeedSeq = event.seq;
|
|
670
670
|
if (!compactionEntryStateKnown) {
|
|
671
671
|
if (event.type === "compaction/start") {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { Context } from '@deepseek-ai/cordis';
|
|
|
7
7
|
import z from '@deepseek-ai/schemastery';
|
|
8
8
|
import { CompactionEngine } from '@deepseek-ai/dsh-compaction';
|
|
9
9
|
import type { CompactionResult, CompactionTrigger } from '@deepseek-ai/dsh-compaction';
|
|
10
|
+
import type { SessionSeq } from '@deepseek-ai/dsh-session';
|
|
10
11
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
11
12
|
import type { CommandId } from '@deepseek-ai/dsh-commands/brand';
|
|
12
13
|
import type { SummarizationInput, SummaryResult } from './summarizer.ts';
|
|
@@ -66,7 +67,7 @@ export declare class BasicCompactionEngine extends CompactionEngine {
|
|
|
66
67
|
* @param signal - optional summarization cancellation signal.
|
|
67
68
|
* @returns the successful durable compaction result.
|
|
68
69
|
*/
|
|
69
|
-
compactRegion(start:
|
|
70
|
+
compactRegion(start: SessionSeq, end: SessionSeq, agent: Agent, signal?: AbortSignal): Promise<CompactionResult>;
|
|
70
71
|
/**
|
|
71
72
|
* Force one useful idle-session compaction below the pressure threshold, and
|
|
72
73
|
* resolve only after its standalone marker pair is durably checkpointed.
|
package/lib/types/region.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { CompactionResult } from '@deepseek-ai/dsh-compaction';
|
|
8
8
|
import type { CommandId } from '@deepseek-ai/dsh-commands/brand';
|
|
9
9
|
import type { TokenMeasurement, TokenMeter } from '@deepseek-ai/dsh-token-meter';
|
|
10
|
-
import type
|
|
10
|
+
import { SessionSeq, type Session } from '@deepseek-ai/dsh-session';
|
|
11
11
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
12
12
|
import type { SummarizationInput, SummaryResult } from './summarizer.ts';
|
|
13
13
|
interface RegionDependencies {
|
|
@@ -33,8 +33,8 @@ interface CompactionTransactionOptions {
|
|
|
33
33
|
* @returns the inclusive positional seq range to compact, or `null`.
|
|
34
34
|
*/
|
|
35
35
|
export declare function selectCompactableRange(session: Session, measurement: TokenMeasurement, retainTokens: number): {
|
|
36
|
-
start:
|
|
37
|
-
end:
|
|
36
|
+
start: SessionSeq;
|
|
37
|
+
end: SessionSeq;
|
|
38
38
|
} | null;
|
|
39
39
|
/**
|
|
40
40
|
* Run the single compaction transaction over one selected positional span.
|
|
@@ -52,7 +52,7 @@ export declare function selectCompactableRange(session: Session, measurement: To
|
|
|
52
52
|
* @param signal - optional summarization cancellation signal.
|
|
53
53
|
* @returns the successful durable compaction result.
|
|
54
54
|
*/
|
|
55
|
-
export declare function compactSurfaceRegion(dependencies: RegionDependencies, session: Session, start:
|
|
55
|
+
export declare function compactSurfaceRegion(dependencies: RegionDependencies, session: Session, start: SessionSeq, end: SessionSeq, agent: Agent, options: CompactionTransactionOptions, signal?: AbortSignal): Promise<CompactionResult>;
|
|
56
56
|
/**
|
|
57
57
|
* Recheck the durable compaction lock after an asynchronous policy decision.
|
|
58
58
|
* @param session - session whose latest marker state is inspected.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-compaction-basic",
|
|
3
3
|
"description": "Token-meter-driven compaction policy and LLM summarization backend for the DeepSeek Harness",
|
|
4
|
-
"version": "0.1.2-alpha.
|
|
4
|
+
"version": "0.1.2-alpha.4",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -18,29 +18,23 @@
|
|
|
18
18
|
"types": "./lib/types/index.d.ts",
|
|
19
19
|
"default": "./lib/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./invariant": {
|
|
22
|
-
"types": "./lib/types/invariant.d.ts",
|
|
23
|
-
"default": "./lib/invariant.js"
|
|
24
|
-
},
|
|
25
21
|
"./src/*": "./src/*",
|
|
26
22
|
"./package.json": "./package.json"
|
|
27
23
|
},
|
|
28
24
|
"files": [
|
|
29
25
|
"lib/index.js",
|
|
30
|
-
"lib/invariant.js",
|
|
31
26
|
"lib/types/**/*.d.ts"
|
|
32
27
|
],
|
|
33
28
|
"license": "MIT",
|
|
34
29
|
"peerDependencies": {
|
|
35
30
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
36
|
-
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.
|
|
37
|
-
"@deepseek-ai/dsh-commands": "^0.1.2-alpha.
|
|
38
|
-
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.
|
|
39
|
-
"@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.
|
|
40
|
-
"@deepseek-ai/dsh-
|
|
41
|
-
"@deepseek-ai/dsh-
|
|
42
|
-
"@deepseek-ai/dsh-
|
|
43
|
-
"@deepseek-ai/dsh-token-meter": "^0.1.2-alpha.3"
|
|
31
|
+
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.4",
|
|
32
|
+
"@deepseek-ai/dsh-commands": "^0.1.2-alpha.4",
|
|
33
|
+
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.4",
|
|
34
|
+
"@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.4",
|
|
35
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.4",
|
|
36
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.4",
|
|
37
|
+
"@deepseek-ai/dsh-token-meter": "^0.1.2-alpha.4"
|
|
44
38
|
},
|
|
45
39
|
"peerDependenciesMeta": {
|
|
46
40
|
"@deepseek-ai/dsh-compaction-tool-result-pruner": {
|
|
@@ -49,24 +43,24 @@
|
|
|
49
43
|
},
|
|
50
44
|
"dependencies": {
|
|
51
45
|
"@deepseek-ai/schemastery": "^3.18.2",
|
|
52
|
-
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.
|
|
46
|
+
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.4"
|
|
53
47
|
},
|
|
54
48
|
"devDependencies": {
|
|
55
49
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
56
50
|
"@deepseek-ai/cordis-plugin-include": "^1.0.7",
|
|
57
51
|
"@deepseek-ai/cordis-plugin-loader": "^1.0.3",
|
|
58
|
-
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.
|
|
59
|
-
"@deepseek-ai/dsh-agent-loop": "^0.1.2-alpha.
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/dsh-
|
|
64
|
-
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.
|
|
65
|
-
"@deepseek-ai/dsh-
|
|
66
|
-
"@deepseek-ai/dsh-
|
|
67
|
-
"@deepseek-ai/dsh-session": "^0.1.2-alpha.
|
|
68
|
-
"@deepseek-ai/dsh-
|
|
69
|
-
"@deepseek-ai/dsh-
|
|
70
|
-
"@deepseek-ai/dsh-
|
|
52
|
+
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.4",
|
|
53
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "^0.1.2-alpha.4",
|
|
54
|
+
"@deepseek-ai/dsh-commands": "^0.1.2-alpha.4",
|
|
55
|
+
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.4",
|
|
56
|
+
"@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.4",
|
|
57
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.4",
|
|
58
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.4",
|
|
59
|
+
"@deepseek-ai/dsh-agent-loop": "^0.1.2-alpha.4",
|
|
60
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.4",
|
|
61
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.4",
|
|
62
|
+
"@deepseek-ai/dsh-token-meter": "^0.1.2-alpha.4",
|
|
63
|
+
"@deepseek-ai/dsh-tools": "^0.1.2-alpha.4",
|
|
64
|
+
"@deepseek-ai/dsh-llm-retry": "^0.1.2-alpha.4"
|
|
71
65
|
}
|
|
72
66
|
}
|
package/lib/invariant.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region lib/types/invariant.js
|
|
2
|
-
/**
|
|
3
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-compaction-basic`.
|
|
4
|
-
* @module @deepseek-ai/dsh-compaction-basic/invariant
|
|
5
|
-
*/
|
|
6
|
-
const PACKAGE_NAME = "@deepseek-ai/dsh-compaction-basic";
|
|
7
|
-
/** Cordis companion plugin name. */
|
|
8
|
-
const name = "compaction-basic-invariant";
|
|
9
|
-
/** Service required before the companion can reserve package ownership. */
|
|
10
|
-
const inject = ["invariants"];
|
|
11
|
-
/**
|
|
12
|
-
* No runtime invariant: this package exposes no independent event sequence or mutable data relation
|
|
13
|
-
* beyond contracts enforced at its owning seam.
|
|
14
|
-
*/
|
|
15
|
-
const install = () => {};
|
|
16
|
-
/**
|
|
17
|
-
* Register this package's invariant companion.
|
|
18
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
19
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
20
|
-
*/
|
|
21
|
-
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
22
|
-
//#endregion
|
|
23
|
-
export { apply, inject, name };
|
package/lib/types/invariant.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Package-owned invariant companion for `@deepseek-ai/dsh-compaction-basic`.
|
|
3
|
-
* @module @deepseek-ai/dsh-compaction-basic/invariant
|
|
4
|
-
*/
|
|
5
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
-
/** Cordis companion plugin name. */
|
|
7
|
-
export declare const name = "compaction-basic-invariant";
|
|
8
|
-
/** Service required before the companion can reserve package ownership. */
|
|
9
|
-
export declare const inject: string[];
|
|
10
|
-
/**
|
|
11
|
-
* Register this package's invariant companion.
|
|
12
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
-
*/
|
|
15
|
-
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
-
//# sourceMappingURL=invariant.d.ts.map
|