@crazx/dsh-compaction-basic 0.1.2-alpha.3.zw.2 → 0.1.2-alpha.5.zw.1
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: f57fcc16ab27d461e4371506af32d09c7db2a698
|
|
6
|
+
README.zh.md: a71a63f1973d87096d1ea0d94353c6e74cdb10e2
|
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ The transaction validates the surface span and the durable lock, appends `compac
|
|
|
139
139
|
| [`src/summarizer.ts`](src/summarizer.ts) | Default `ctx.llm.stream()` summarization, checkpoint framing, safe-summary projection |
|
|
140
140
|
| [`src/config.ts`](src/config.ts) | Load-time validation and routed-model policy resolution |
|
|
141
141
|
| [`src/types.ts`](src/types.ts) | `BasicCompactionConfig` and resolved policy vocabulary |
|
|
142
|
-
|
|
|
142
|
+
| — | No runtime invariant companion is published; this package exposes no independent event sequence or mutable data relation beyond contracts enforced at its owning seam. |
|
|
143
143
|
|
|
144
144
|
</details>
|
|
145
145
|
|
package/README.zh.md
CHANGED
|
@@ -139,7 +139,7 @@ kind: "package-reference"
|
|
|
139
139
|
| [`src/summarizer.ts`](src/summarizer.ts) | 默认 `ctx.llm.stream()` 摘要、检查点框定、安全摘要投影 |
|
|
140
140
|
| [`src/config.ts`](src/config.ts) | 加载时验证与路由模型策略解析 |
|
|
141
141
|
| [`src/types.ts`](src/types.ts) | `BasicCompactionConfig` 与已解析策略词汇 |
|
|
142
|
-
|
|
|
142
|
+
| — | 不发布运行时不变式伴生入口;持久标记对可在会话日志中观察。 |
|
|
143
143
|
|
|
144
144
|
</details>
|
|
145
145
|
|
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.
|
|
@@ -463,7 +464,7 @@ function selectCompactableRange(session, measurement, retainTokens) {
|
|
|
463
464
|
async function compactSurfaceRegion(dependencies, session, start, end, agent, options, signal) {
|
|
464
465
|
if (options.owner === null) signal?.throwIfAborted();
|
|
465
466
|
const selection = validateSurfaceRegion(session, start, end);
|
|
466
|
-
const entryState = inspectCompactionEntryState(session
|
|
467
|
+
const entryState = inspectCompactionEntryState(session);
|
|
467
468
|
assertCompactionInactive(entryState.unmatchedCompactionStart, entryState.latestEndSeedSeq, "compaction");
|
|
468
469
|
let owner;
|
|
469
470
|
if (options.owner === null) {
|
|
@@ -556,7 +557,7 @@ function assertCompactionInactive(unmatchedCompactionStart, latestEndSeedSeq, st
|
|
|
556
557
|
* @param stage - operation label included in the busy diagnostic.
|
|
557
558
|
*/
|
|
558
559
|
function assertNoActiveCompaction(session, stage) {
|
|
559
|
-
const entryState = inspectCompactionEntryState(session
|
|
560
|
+
const entryState = inspectCompactionEntryState(session);
|
|
560
561
|
assertCompactionInactive(entryState.unmatchedCompactionStart, entryState.latestEndSeedSeq, stage);
|
|
561
562
|
}
|
|
562
563
|
/** Validate one requested surface-position span before asynchronous work begins. */
|
|
@@ -693,8 +694,7 @@ function completeCompaction(pending, endEvent) {
|
|
|
693
694
|
*/
|
|
694
695
|
function buildSummarizationInput(session, shadowedSeqs) {
|
|
695
696
|
const header = session.requestHeader();
|
|
696
|
-
const
|
|
697
|
-
const regionMessages = shadowedSeqs.map((seq) => session.deriveEventMessage(events[seq])).filter((message) => message !== null);
|
|
697
|
+
const regionMessages = shadowedSeqs.map((seq) => session.deriveEventMessage(session.eventAt(seq))).filter((message) => message !== null);
|
|
698
698
|
return {
|
|
699
699
|
...header?.system === void 0 ? {} : { system: header.system },
|
|
700
700
|
...header?.tools === void 0 ? {} : { tools: header.tools },
|
|
@@ -702,14 +702,14 @@ function buildSummarizationInput(session, shadowedSeqs) {
|
|
|
702
702
|
};
|
|
703
703
|
}
|
|
704
704
|
/** Inspect open-turn, unmatched-compaction, and latest seed-boundary state independently. */
|
|
705
|
-
function inspectCompactionEntryState(
|
|
705
|
+
function inspectCompactionEntryState(session) {
|
|
706
706
|
let openTurn = null;
|
|
707
707
|
let openTurnStateKnown = false;
|
|
708
708
|
let unmatchedCompactionStart;
|
|
709
709
|
let compactionEntryStateKnown = false;
|
|
710
710
|
let latestEndSeedSeq;
|
|
711
|
-
for (let
|
|
712
|
-
const event =
|
|
711
|
+
for (let seq = session.seq - 1; seq >= 0; seq -= 1) {
|
|
712
|
+
const event = session.eventAt(SessionSeq(seq));
|
|
713
713
|
if (latestEndSeedSeq === void 0 && event.type === "session/end-seed") latestEndSeedSeq = event.seq;
|
|
714
714
|
if (!compactionEntryStateKnown) {
|
|
715
715
|
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": "@crazx/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.5.zw.1",
|
|
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.5",
|
|
32
|
+
"@deepseek-ai/dsh-commands": "^0.1.2-alpha.5",
|
|
33
|
+
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.5",
|
|
34
|
+
"@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.5",
|
|
35
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
|
|
36
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
|
|
37
|
+
"@deepseek-ai/dsh-token-meter": "^0.1.2-alpha.5"
|
|
44
38
|
},
|
|
45
39
|
"peerDependenciesMeta": {
|
|
46
40
|
"@deepseek-ai/dsh-compaction-tool-result-pruner": {
|
|
@@ -48,25 +42,25 @@
|
|
|
48
42
|
}
|
|
49
43
|
},
|
|
50
44
|
"dependencies": {
|
|
51
|
-
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.
|
|
45
|
+
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.5",
|
|
52
46
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
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-agent-loop-testkit": "^0.1.2-alpha.
|
|
61
|
-
"@deepseek-ai/dsh-commands": "^0.1.2-alpha.
|
|
62
|
-
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.
|
|
63
|
-
"@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.
|
|
64
|
-
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.
|
|
65
|
-
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.
|
|
66
|
-
"@deepseek-ai/dsh-llm-retry": "^0.1.2-alpha.
|
|
67
|
-
"@deepseek-ai/dsh-session": "^0.1.2-alpha.
|
|
68
|
-
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.
|
|
69
|
-
"@deepseek-ai/dsh-token-meter": "^0.1.2-alpha.
|
|
70
|
-
"@deepseek-ai/dsh-tools": "^0.1.2-alpha.
|
|
52
|
+
"@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
|
|
53
|
+
"@deepseek-ai/dsh-agent-loop": "^0.1.2-alpha.5",
|
|
54
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "^0.1.2-alpha.5",
|
|
55
|
+
"@deepseek-ai/dsh-commands": "^0.1.2-alpha.5",
|
|
56
|
+
"@deepseek-ai/dsh-compaction": "^0.1.2-alpha.5",
|
|
57
|
+
"@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.5",
|
|
58
|
+
"@deepseek-ai/dsh-invariants": "^0.1.2-alpha.5",
|
|
59
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
|
|
60
|
+
"@deepseek-ai/dsh-llm-retry": "^0.1.2-alpha.5",
|
|
61
|
+
"@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
|
|
62
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.5",
|
|
63
|
+
"@deepseek-ai/dsh-token-meter": "^0.1.2-alpha.5",
|
|
64
|
+
"@deepseek-ai/dsh-tools": "^0.1.2-alpha.5"
|
|
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
|