@stackstackstack/dsh-compaction-basic 0.1.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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +164 -0
- package/README.zh.md +164 -0
- package/lib/index.js +962 -0
- package/lib/invariant.js +23 -0
- package/lib/types/config.d.ts +37 -0
- package/lib/types/index.d.ts +83 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/region.d.ts +63 -0
- package/lib/types/summarizer.d.ts +66 -0
- package/lib/types/types.d.ts +73 -0
- package/package.json +70 -0
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/**
|
|
3
|
+
* Package-owned invariant companion for `@stackstackstack/dsh-compaction-basic`.
|
|
4
|
+
* @module @stackstackstack/dsh-compaction-basic/invariant
|
|
5
|
+
*/
|
|
6
|
+
const PACKAGE_NAME = "@stackstackstack/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 };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Load-time validation and routed-model policy resolution for compaction-basic.
|
|
3
|
+
*
|
|
4
|
+
* @module @stackstackstack/dsh-compaction-basic/config
|
|
5
|
+
*/
|
|
6
|
+
import type { LlmCallConfig } from '@stackstackstack/dsh-llm';
|
|
7
|
+
import type { BasicCompactionConfig, ResolvedCompactSpec, ResolvedConfig, ResolvedTargetPolicy } from './types.ts';
|
|
8
|
+
/** Target-specific pressure configuration failure eligible for warning suppression. */
|
|
9
|
+
export declare class TargetPressureConfigError extends Error {
|
|
10
|
+
readonly targetKey: string;
|
|
11
|
+
/**
|
|
12
|
+
* @param targetKey - exact provider/model route used as the warning key.
|
|
13
|
+
* @param message - actionable configuration failure detail.
|
|
14
|
+
*/
|
|
15
|
+
constructor(targetKey: string, message: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Resolve and validate service defaults plus exact-target partial overrides.
|
|
19
|
+
* @param config - untrusted plugin configuration after Loader normalization.
|
|
20
|
+
* @returns detached immutable defaults and validated exact-target overrides.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveConfig(config?: BasicCompactionConfig): ResolvedConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Merge the exact provider/model override over the validated default policy.
|
|
25
|
+
* @param config - validated service defaults and override table.
|
|
26
|
+
* @param target - exact durable provider/model route to match.
|
|
27
|
+
* @returns detached immutable policy before model-capacity scaling.
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveTargetPolicy(config: ResolvedConfig, target: Pick<LlmCallConfig, 'provider' | 'model'>): ResolvedTargetPolicy;
|
|
30
|
+
/**
|
|
31
|
+
* Scale one routed policy into concrete token budgets for its model capacity.
|
|
32
|
+
* @param policy - merged policy for the exact routed target.
|
|
33
|
+
* @param contextWindow - positive adapter-owned capacity for that target.
|
|
34
|
+
* @returns detached immutable pressure and retention budgets.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveCompactSpec(policy: ResolvedTargetPolicy, contextWindow: number): ResolvedCompactSpec;
|
|
37
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic replay-aware compaction backend.
|
|
3
|
+
*
|
|
4
|
+
* @module @stackstackstack/dsh-compaction-basic
|
|
5
|
+
*/
|
|
6
|
+
import { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
import z from '@deepseek-ai/schemastery';
|
|
8
|
+
import { CompactionEngine } from '@stackstackstack/dsh-compaction';
|
|
9
|
+
import type { CompactionResult, CompactionTrigger } from '@stackstackstack/dsh-compaction';
|
|
10
|
+
import type { Agent } from '@stackstackstack/dsh-agent';
|
|
11
|
+
import type { CommandId } from '@stackstackstack/dsh-commands/brand';
|
|
12
|
+
import type { SummarizationInput, SummaryResult } from './summarizer.ts';
|
|
13
|
+
import type { BasicCompactionConfig, ResolvedConfig } from './types.ts';
|
|
14
|
+
export type { BasicCompactionConfig, CompactionPolicyConfig, ModelCompactPolicyConfig, ResolvedCompactSpec, ResolvedConfig, ResolvedRetention, ResolvedTargetPolicy, } from './types.ts';
|
|
15
|
+
/**
|
|
16
|
+
* Dependency-light compaction backend using `ctx.tokenMeter` for pressure,
|
|
17
|
+
* retention, cited source events, and summary-convergence pricing.
|
|
18
|
+
*
|
|
19
|
+
* `summarize()` is the sole subclass customization hook; the replay and durable
|
|
20
|
+
* mutation strategy stays fixed so every pricing decision uses the singleton
|
|
21
|
+
* token meter.
|
|
22
|
+
*/
|
|
23
|
+
export declare class BasicCompactionEngine extends CompactionEngine {
|
|
24
|
+
static inject: string[];
|
|
25
|
+
static Config: z<BasicCompactionConfig>;
|
|
26
|
+
/** Resolved and validated compaction configuration. */
|
|
27
|
+
readonly config: ResolvedConfig;
|
|
28
|
+
private readonly warnedPressureConfigTargets;
|
|
29
|
+
private readonly overflowRetries;
|
|
30
|
+
private readonly overflowAgents;
|
|
31
|
+
constructor(ctx: Context, config?: BasicCompactionConfig);
|
|
32
|
+
/**
|
|
33
|
+
* Register automatic between-step pressure and model-request overflow
|
|
34
|
+
* recovery. `compactIfNeeded` stays dynamically dispatched so subclass
|
|
35
|
+
* overrides are honored at event time.
|
|
36
|
+
*/
|
|
37
|
+
private _registerAutomaticCompaction;
|
|
38
|
+
/**
|
|
39
|
+
* Summarize the replayed conversation region through a direct one-shot
|
|
40
|
+
* `ctx.llm.stream()` call whose prefix reuses the conversation's own system
|
|
41
|
+
* prompt, tools, and messages so the provider's KV cache is not invalidated.
|
|
42
|
+
* Override this sole hook for a template or remote summarizer.
|
|
43
|
+
* @param input - replayed conversation prefix (system, tools, and leading messages) to condense.
|
|
44
|
+
* @param agent - supplies routed-model history, fallback model, and session id.
|
|
45
|
+
* @param signal - optional cancellation forwarded to the adapter.
|
|
46
|
+
* @returns safe text summary blocks and the exact auxiliary call envelope and output.
|
|
47
|
+
*/
|
|
48
|
+
protected summarize(input: SummarizationInput, agent: Agent, signal?: AbortSignal): Promise<SummaryResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Compact for replayed step-boundary pressure or one provider-confirmed context
|
|
51
|
+
* overflow. Both triggers price the latest durable routed request envelope;
|
|
52
|
+
* overflow bypasses the normal threshold and retained-tail policy so it can
|
|
53
|
+
* force one useful balanced reduction.
|
|
54
|
+
* @param agent - agent whose latest durable routed request is measured.
|
|
55
|
+
* @param trigger - normal step-boundary pressure or context-overflow recovery.
|
|
56
|
+
* @param signal - live turn cancellation signal forwarded to summarization.
|
|
57
|
+
* @returns the latest summary compaction result, or `null` when no summary ran.
|
|
58
|
+
*/
|
|
59
|
+
compactIfNeeded(agent: Agent, trigger: CompactionTrigger, signal: AbortSignal): Promise<CompactionResult | null>;
|
|
60
|
+
/**
|
|
61
|
+
* Compact one inclusive positional range from the agent-owned surface using
|
|
62
|
+
* the effective token meter for all retention and shrink pricing.
|
|
63
|
+
* @param start - inclusive first surface-node seq.
|
|
64
|
+
* @param end - inclusive last surface-node seq.
|
|
65
|
+
* @param agent - owner of the target session, used by the summarizer.
|
|
66
|
+
* @param signal - optional summarization cancellation signal.
|
|
67
|
+
* @returns the successful durable compaction result.
|
|
68
|
+
*/
|
|
69
|
+
compactRegion(start: number, end: number, agent: Agent, signal?: AbortSignal): Promise<CompactionResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Force one useful idle-session compaction below the pressure threshold, and
|
|
72
|
+
* resolve only after its standalone marker pair is durably checkpointed.
|
|
73
|
+
* @param agent - idle agent whose next-turn admission this call reserves.
|
|
74
|
+
* @param signal - cancellation scoped to this compaction request.
|
|
75
|
+
* @param sourceCommandId - initiating command identity for presentation correlation.
|
|
76
|
+
* @returns the committed result, or `null` when no safe useful range exists.
|
|
77
|
+
*/
|
|
78
|
+
compactNow(agent: Agent, signal: AbortSignal, sourceCommandId?: CommandId): Promise<CompactionResult | null>;
|
|
79
|
+
/** Bind the effective token meter and dynamically dispatched summarizer hook. */
|
|
80
|
+
private regionDependencies;
|
|
81
|
+
}
|
|
82
|
+
export default BasicCompactionEngine;
|
|
83
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@stackstackstack/dsh-compaction-basic`.
|
|
3
|
+
* @module @stackstackstack/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
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surface retention selection and the shared log-recorded compaction
|
|
3
|
+
* transaction for automatic open-turn and manual idle-session compaction.
|
|
4
|
+
*
|
|
5
|
+
* @module @stackstackstack/dsh-compaction-basic/region
|
|
6
|
+
*/
|
|
7
|
+
import type { CompactionResult } from '@stackstackstack/dsh-compaction';
|
|
8
|
+
import type { CommandId } from '@stackstackstack/dsh-commands/brand';
|
|
9
|
+
import type { TokenMeasurement, TokenMeter } from '@stackstackstack/dsh-token-meter';
|
|
10
|
+
import type { Session } from '@stackstackstack/dsh-session';
|
|
11
|
+
import type { Agent } from '@stackstackstack/dsh-agent';
|
|
12
|
+
import type { SummarizationInput, SummaryResult } from './summarizer.ts';
|
|
13
|
+
interface RegionDependencies {
|
|
14
|
+
readonly meter: TokenMeter;
|
|
15
|
+
summarize(input: SummarizationInput, agent: Agent, signal?: AbortSignal): Promise<SummaryResult>;
|
|
16
|
+
}
|
|
17
|
+
interface CompactionTransactionOptions {
|
|
18
|
+
/** `current-turn` derives a numbered owner; `null` writes a standalone bracket. */
|
|
19
|
+
readonly owner: 'current-turn' | null;
|
|
20
|
+
/** Surface relationship that must survive asynchronous summarization. */
|
|
21
|
+
readonly stability: 'whole-surface' | 'selected-span';
|
|
22
|
+
/** Optional durability checkpoint after a successfully closed bracket. */
|
|
23
|
+
readonly flush?: () => Promise<void>;
|
|
24
|
+
/** Manual command that initiated this transaction, when present. */
|
|
25
|
+
readonly sourceCommandId?: CommandId;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve the next head-anchored range while retaining a priced recent tail
|
|
29
|
+
* and never splitting an assistant tool-call/result pair.
|
|
30
|
+
* @param session - session supplying authoritative current surface positions.
|
|
31
|
+
* @param measurement - unified pressure and surface measurement from the conversation meter.
|
|
32
|
+
* @param retainTokens - minimum recent tail budget retained verbatim.
|
|
33
|
+
* @returns the inclusive positional seq range to compact, or `null`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function selectCompactableRange(session: Session, measurement: TokenMeasurement, retainTokens: number): {
|
|
36
|
+
start: number;
|
|
37
|
+
end: number;
|
|
38
|
+
} | null;
|
|
39
|
+
/**
|
|
40
|
+
* Run the single compaction transaction over one selected positional span.
|
|
41
|
+
* Selection and validation are read-only. Idle/log validation and
|
|
42
|
+
* `compaction/start` are synchronously adjacent, so the durable opening marker is
|
|
43
|
+
* the compaction lock before summarization yields. Every later failure makes
|
|
44
|
+
* exactly one `compaction/end` attempt; a failed close deliberately leaves the
|
|
45
|
+
* unmatched start detectable.
|
|
46
|
+
* @param dependencies - conversation meter and dynamically dispatched summarizer hook.
|
|
47
|
+
* @param session - session whose surface is mutated.
|
|
48
|
+
* @param start - inclusive first surface-node seq.
|
|
49
|
+
* @param end - inclusive last surface-node seq.
|
|
50
|
+
* @param agent - agent used by the summarizer.
|
|
51
|
+
* @param options - bracket owner, stability rule, and optional durability checkpoint.
|
|
52
|
+
* @param signal - optional summarization cancellation signal.
|
|
53
|
+
* @returns the successful durable compaction result.
|
|
54
|
+
*/
|
|
55
|
+
export declare function compactSurfaceRegion(dependencies: RegionDependencies, session: Session, start: number, end: number, agent: Agent, options: CompactionTransactionOptions, signal?: AbortSignal): Promise<CompactionResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Recheck the durable compaction lock after an asynchronous policy decision.
|
|
58
|
+
* @param session - session whose latest marker state is inspected.
|
|
59
|
+
* @param stage - operation label included in the busy diagnostic.
|
|
60
|
+
*/
|
|
61
|
+
export declare function assertNoActiveCompaction(session: Session, stage: string): void;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=region.d.ts.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default one-shot summarization and durable checkpoint framing.
|
|
3
|
+
*
|
|
4
|
+
* @module @stackstackstack/dsh-compaction-basic/summarizer
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
7
|
+
import type { ContentBlock, Message, TokenUsage, ToolSchema } from '@stackstackstack/dsh-llm';
|
|
8
|
+
import type { Agent } from '@stackstackstack/dsh-agent';
|
|
9
|
+
interface SummaryConfig {
|
|
10
|
+
readonly summarizationProvider: string;
|
|
11
|
+
readonly summarizationModel: string;
|
|
12
|
+
readonly maxTokens: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The replayed conversation surface the summarizer condenses. Reproducing the
|
|
16
|
+
* last routed request's system prompt, tools, and leading messages verbatim
|
|
17
|
+
* lets the auxiliary call reuse the provider's warm prefix cache; the trailing
|
|
18
|
+
* compaction instruction is then the only novel input.
|
|
19
|
+
*/
|
|
20
|
+
export interface SummarizationInput {
|
|
21
|
+
/** The conversation's own system prompt, reused for prefix-cache alignment; absent for a system-less request. */
|
|
22
|
+
readonly system?: string;
|
|
23
|
+
/** The conversation's tool schemas, reused for prefix-cache alignment; absent when the request carried none. */
|
|
24
|
+
readonly tools?: readonly ToolSchema[];
|
|
25
|
+
/** The shadowed region, in surface order, that precedes the compaction instruction. */
|
|
26
|
+
readonly messages: readonly Message[];
|
|
27
|
+
}
|
|
28
|
+
/** Safe summary content plus the exact auxiliary call envelope recorded with it. */
|
|
29
|
+
export type SummaryResult = {
|
|
30
|
+
summary: ContentBlock[];
|
|
31
|
+
provider: string;
|
|
32
|
+
model: string;
|
|
33
|
+
maxTokens?: number;
|
|
34
|
+
/** Provider-reported usage for this summarization request. */
|
|
35
|
+
usage?: TokenUsage;
|
|
36
|
+
} & ({
|
|
37
|
+
/** Complete provider output before the text-only summary projection. */
|
|
38
|
+
rawOutput: ContentBlock[];
|
|
39
|
+
/** Identifies exactly one call through this context's `ctx.llm.stream()`. */
|
|
40
|
+
llmStreamCall: true;
|
|
41
|
+
} | {
|
|
42
|
+
/** Optional complete output from an unmarked template, remote, or other summarizer. */
|
|
43
|
+
rawOutput?: ContentBlock[];
|
|
44
|
+
/** An unmarked result does not identify a call through this context's LLM seam. */
|
|
45
|
+
llmStreamCall?: never;
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Run the default cache-reusing `ctx.llm.stream()` summarization call: replay
|
|
49
|
+
* the conversation prefix, then append the compaction instruction as the final
|
|
50
|
+
* user message so the provider's warm prefix cache is reused.
|
|
51
|
+
* @param ctx - context providing the LLM service.
|
|
52
|
+
* @param config - resolved backend configuration.
|
|
53
|
+
* @param input - replayed conversation prefix (system, tools, and leading messages) to condense.
|
|
54
|
+
* @param agent - supplies routed-model history, fallback model, and session id.
|
|
55
|
+
* @param signal - optional cancellation forwarded to the adapter.
|
|
56
|
+
* @returns safe text-only summary blocks and the exact call envelope and output.
|
|
57
|
+
*/
|
|
58
|
+
export declare function summarizeWithLlm(ctx: Context, config: SummaryConfig, input: SummarizationInput, agent: Agent, signal?: AbortSignal): Promise<SummaryResult>;
|
|
59
|
+
/**
|
|
60
|
+
* Wrap raw summary blocks in the durable checkpoint framing.
|
|
61
|
+
* @param summary - safe text-only model output.
|
|
62
|
+
* @returns content for the synthesized replacement user message.
|
|
63
|
+
*/
|
|
64
|
+
export declare function frameSummary(summary: readonly ContentBlock[]): ContentBlock[];
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=summarizer.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration vocabulary for the replay-aware basic compaction backend.
|
|
3
|
+
*
|
|
4
|
+
* @module @stackstackstack/dsh-compaction-basic/types
|
|
5
|
+
*/
|
|
6
|
+
import type { LlmCallConfig } from '@stackstackstack/dsh-llm';
|
|
7
|
+
/** Policy fields shared by the default policy and exact model overrides. */
|
|
8
|
+
export interface CompactionPolicyConfig {
|
|
9
|
+
/** Compact at this fraction of the model's context window. Defaults to `0.8`. */
|
|
10
|
+
thresholdRatio?: number;
|
|
11
|
+
/** Recent context retained as a fraction of the model's window. Defaults to `0.16`. */
|
|
12
|
+
retainRatio?: number;
|
|
13
|
+
/** Absolute recent-context budget; mutually exclusive with `retainRatio`. */
|
|
14
|
+
retainTokens?: number;
|
|
15
|
+
/** Summary provider; set together with `summarizationModel`, or inherit the conversation target. */
|
|
16
|
+
summarizationProvider?: string;
|
|
17
|
+
/** Summary model; set together with `summarizationProvider`, or inherit the conversation target. */
|
|
18
|
+
summarizationModel?: string;
|
|
19
|
+
/** Provider generation cap for summarization. Defaults to `8192`. */
|
|
20
|
+
maxTokens?: number;
|
|
21
|
+
/** Extra attempts after the first compaction when pressure remains above threshold. Defaults to `1`. */
|
|
22
|
+
compactionRetries?: number;
|
|
23
|
+
/** Maximum retries after canonical context overflow; `0` disables recovery. Defaults to `1`. */
|
|
24
|
+
maxOverflowRetries?: number;
|
|
25
|
+
}
|
|
26
|
+
/** Exact provider/model override merged over the default compaction policy. */
|
|
27
|
+
export interface ModelCompactPolicyConfig extends CompactionPolicyConfig {
|
|
28
|
+
/** Registered provider route to match. */
|
|
29
|
+
provider: string;
|
|
30
|
+
/** Exact routed model id to match within `provider`. */
|
|
31
|
+
model: string;
|
|
32
|
+
}
|
|
33
|
+
/** Basic compaction configuration with an optional exact-target policy table. */
|
|
34
|
+
export interface BasicCompactionConfig extends CompactionPolicyConfig {
|
|
35
|
+
/** Exact provider/model overrides; duplicate targets fail plugin load. */
|
|
36
|
+
modelPolicies?: ModelCompactPolicyConfig[];
|
|
37
|
+
/** Enable automatic step-boundary pressure and overflow-recovery listeners. Defaults to `true`. */
|
|
38
|
+
auto?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Exactly one validated retention form. */
|
|
41
|
+
export type ResolvedRetention = {
|
|
42
|
+
readonly retainRatio: number;
|
|
43
|
+
readonly retainTokens?: never;
|
|
44
|
+
} | {
|
|
45
|
+
readonly retainRatio?: never;
|
|
46
|
+
readonly retainTokens: number;
|
|
47
|
+
};
|
|
48
|
+
/** Validated policy fields shared before and after exact-target matching. */
|
|
49
|
+
interface ResolvedPolicyFields {
|
|
50
|
+
readonly thresholdRatio: number;
|
|
51
|
+
readonly summarizationProvider: string;
|
|
52
|
+
readonly summarizationModel: string;
|
|
53
|
+
readonly maxTokens: number;
|
|
54
|
+
readonly compactionRetries: number;
|
|
55
|
+
readonly maxOverflowRetries: number;
|
|
56
|
+
}
|
|
57
|
+
/** Validated immutable config whose target-specific defaults remain unresolved. */
|
|
58
|
+
export type ResolvedConfig = ResolvedPolicyFields & ResolvedRetention & {
|
|
59
|
+
readonly modelPolicies: readonly Readonly<ModelCompactPolicyConfig>[];
|
|
60
|
+
readonly auto: boolean;
|
|
61
|
+
};
|
|
62
|
+
/** Fully merged policy for one routed conversation target, before capacity scaling. */
|
|
63
|
+
export type ResolvedTargetPolicy = ResolvedPolicyFields & ResolvedRetention & {
|
|
64
|
+
readonly target: Pick<LlmCallConfig, 'provider' | 'model'>;
|
|
65
|
+
};
|
|
66
|
+
/** One routed model's concrete pressure and retention budget. */
|
|
67
|
+
export type ResolvedCompactSpec = Omit<ResolvedTargetPolicy, 'retainRatio' | 'retainTokens'> & {
|
|
68
|
+
readonly contextWindow: number;
|
|
69
|
+
readonly thresholdTokens: number;
|
|
70
|
+
readonly retainTokens: number;
|
|
71
|
+
};
|
|
72
|
+
export {};
|
|
73
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stackstackstack/dsh-compaction-basic",
|
|
3
|
+
"description": "Token-meter-driven compaction policy and LLM summarization backend for the DeepSeek Harness",
|
|
4
|
+
"version": "0.1.5",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/compaction/compaction-basic"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./invariant": {
|
|
22
|
+
"types": "./lib/types/invariant.d.ts",
|
|
23
|
+
"default": "./lib/invariant.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/invariant.js",
|
|
31
|
+
"lib/types/**/*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@stackstackstack/dsh-agent": "^0.1.5",
|
|
36
|
+
"@stackstackstack/dsh-compaction": "^0.1.5",
|
|
37
|
+
"@stackstackstack/dsh-commands": "^0.1.5",
|
|
38
|
+
"@stackstackstack/dsh-llm": "^0.1.5",
|
|
39
|
+
"@stackstackstack/dsh-session": "^0.1.5",
|
|
40
|
+
"@stackstackstack/dsh-invariants": "^0.1.5",
|
|
41
|
+
"@stackstackstack/dsh-token-meter": "^0.1.5",
|
|
42
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
43
|
+
"@stackstackstack/dsh-compaction-tool-result-pruner": "^0.1.5"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@stackstackstack/dsh-compaction-tool-result-pruner": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@deepseek-ai/schemastery": "^3.18.1"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@deepseek-ai/cordis-plugin-loader": "^1.0.2",
|
|
55
|
+
"@stackstackstack/dsh-agent": "^0.1.5",
|
|
56
|
+
"@deepseek-ai/cordis-plugin-include": "^1.0.6",
|
|
57
|
+
"@stackstackstack/dsh-agent-loop-testkit": "^0.1.5",
|
|
58
|
+
"@stackstackstack/dsh-agent-loop": "^0.1.5",
|
|
59
|
+
"@stackstackstack/dsh-compaction": "^0.1.5",
|
|
60
|
+
"@stackstackstack/dsh-llm": "^0.1.5",
|
|
61
|
+
"@stackstackstack/dsh-llm-retry": "^0.1.5",
|
|
62
|
+
"@stackstackstack/dsh-invariants": "^0.1.5",
|
|
63
|
+
"@stackstackstack/dsh-session": "^0.1.5",
|
|
64
|
+
"@stackstackstack/dsh-commands": "^0.1.5",
|
|
65
|
+
"@stackstackstack/dsh-compaction-tool-result-pruner": "^0.1.5",
|
|
66
|
+
"@stackstackstack/dsh-tools": "^0.1.5",
|
|
67
|
+
"@stackstackstack/dsh-token-meter": "^0.1.5",
|
|
68
|
+
"@deepseek-ai/cordis": "^4.0.1"
|
|
69
|
+
}
|
|
70
|
+
}
|