@deepseek-ai/dsh-compaction-basic 0.1.2-alpha.3 → 0.1.2-alpha.5

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 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: 60b6bb7fb3e4d7a36f0e609e64238ea1020def4d
6
- README.zh.md: e9f081c39720999f5ba537780a91582c41268fba
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
- | [`src/invariant.ts`](src/invariant.ts) | Invariant companion (no runtime invariant; the durable bracket is observable in the session log) |
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
- | [`src/invariant.ts`](src/invariant.ts) | 不变式伴生插件(无运行时不变式;持久标记对可在会话日志中观察) |
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.events);
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.events);
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 events = session.events;
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(events) {
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 index = events.length - 1; index >= 0; index -= 1) {
668
- const event = events[index];
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") {
@@ -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: number, end: number, agent: Agent, signal?: AbortSignal): Promise<CompactionResult>;
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.
@@ -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 { Session } from '@deepseek-ai/dsh-session';
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: number;
37
- end: number;
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: number, end: number, agent: Agent, options: CompactionTransactionOptions, signal?: AbortSignal): Promise<CompactionResult>;
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.3",
4
+ "version": "0.1.2-alpha.5",
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.3",
37
- "@deepseek-ai/dsh-commands": "^0.1.2-alpha.3",
38
- "@deepseek-ai/dsh-compaction": "^0.1.2-alpha.3",
39
- "@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.3",
40
- "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.3",
41
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.3",
42
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.3",
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/schemastery": "^3.18.2",
52
- "@deepseek-ai/dsh-util-values": "^0.1.2-alpha.3"
45
+ "@deepseek-ai/dsh-util-values": "^0.1.2-alpha.5",
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.3",
59
- "@deepseek-ai/dsh-agent-loop": "^0.1.2-alpha.3",
60
- "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.2-alpha.3",
61
- "@deepseek-ai/dsh-compaction": "^0.1.2-alpha.3",
62
- "@deepseek-ai/dsh-commands": "^0.1.2-alpha.3",
63
- "@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.3",
64
- "@deepseek-ai/dsh-llm": "^0.1.2-alpha.3",
65
- "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.3",
66
- "@deepseek-ai/dsh-llm-retry": "^0.1.2-alpha.3",
67
- "@deepseek-ai/dsh-session": "^0.1.2-alpha.3",
68
- "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.3",
69
- "@deepseek-ai/dsh-token-meter": "^0.1.2-alpha.3",
70
- "@deepseek-ai/dsh-tools": "^0.1.2-alpha.3"
52
+ "@deepseek-ai/dsh-agent": "^0.1.2-alpha.5",
53
+ "@deepseek-ai/dsh-agent-loop-testkit": "^0.1.2-alpha.5",
54
+ "@deepseek-ai/dsh-commands": "^0.1.2-alpha.5",
55
+ "@deepseek-ai/dsh-compaction": "^0.1.2-alpha.5",
56
+ "@deepseek-ai/dsh-compaction-tool-result-pruner": "^0.1.2-alpha.5",
57
+ "@deepseek-ai/dsh-invariants": "^0.1.2-alpha.5",
58
+ "@deepseek-ai/dsh-llm": "^0.1.2-alpha.5",
59
+ "@deepseek-ai/dsh-llm-retry": "^0.1.2-alpha.5",
60
+ "@deepseek-ai/dsh-session": "^0.1.2-alpha.5",
61
+ "@deepseek-ai/dsh-session-projection": "^0.1.2-alpha.5",
62
+ "@deepseek-ai/dsh-token-meter": "^0.1.2-alpha.5",
63
+ "@deepseek-ai/dsh-tools": "^0.1.2-alpha.5",
64
+ "@deepseek-ai/dsh-agent-loop": "^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 };
@@ -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