@eddyskywalker/dsh-chatgpt-subscription 0.64.1 → 0.66.0
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/CHANGELOG.md +52 -0
- package/lib/client.js +120 -9
- package/lib/client.js.map +1 -1
- package/lib/index.js +2286 -1054
- package/lib/types/client/kimi-code/KimiCodeSection.d.ts.map +1 -1
- package/lib/types/client/kimi-code/locales.d.ts +8 -2
- package/lib/types/client/kimi-code/locales.d.ts.map +1 -1
- package/lib/types/client/locales-ru/kimi-code.d.ts.map +1 -1
- package/lib/types/client/locales-ru/progress-updates.d.ts.map +1 -1
- package/lib/types/client/locales-ru/step-code.d.ts.map +1 -1
- package/lib/types/client/progress-updates/locales.d.ts +23 -11
- package/lib/types/client/progress-updates/locales.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts +11 -1
- package/lib/types/client/progress-updates/settings-binding.d.ts.map +1 -1
- package/lib/types/client/progress-updates/settings-section.d.ts +2 -2
- package/lib/types/client/progress-updates/settings-section.d.ts.map +1 -1
- package/lib/types/client/step-code/StepCodeSection.d.ts.map +1 -1
- package/lib/types/client/step-code/locales.d.ts +5 -2
- package/lib/types/client/step-code/locales.d.ts.map +1 -1
- package/lib/types/compat.d.ts +1 -1
- package/lib/types/host/antigravity/adapter.d.ts +2 -0
- package/lib/types/host/antigravity/adapter.d.ts.map +1 -1
- package/lib/types/host/antigravity/client-version.d.ts +55 -0
- package/lib/types/host/antigravity/client-version.d.ts.map +1 -0
- package/lib/types/host/antigravity/client.d.ts +13 -1
- package/lib/types/host/antigravity/client.d.ts.map +1 -1
- package/lib/types/host/antigravity/image-tool.d.ts.map +1 -1
- package/lib/types/host/antigravity/mapper.d.ts.map +1 -1
- package/lib/types/host/antigravity/oauth.d.ts +9 -0
- package/lib/types/host/antigravity/oauth.d.ts.map +1 -1
- package/lib/types/host/antigravity/types.d.ts +52 -3
- package/lib/types/host/antigravity/types.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/budget.d.ts +2 -2
- package/lib/types/host/cache-warmup/budget.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/contracts.d.ts +2 -0
- package/lib/types/host/cache-warmup/contracts.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/install.d.ts +4 -4
- package/lib/types/host/cache-warmup/install.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/result-tool.d.ts +3 -1
- package/lib/types/host/cache-warmup/result-tool.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/settings.d.ts +5 -1
- package/lib/types/host/cache-warmup/settings.d.ts.map +1 -1
- package/lib/types/host/cache-warmup/usage.d.ts +1 -1
- package/lib/types/host/cache-warmup/usage.d.ts.map +1 -1
- package/lib/types/host/claude/adapter.d.ts +3 -0
- package/lib/types/host/claude/adapter.d.ts.map +1 -1
- package/lib/types/host/cline-pass/mapper.d.ts.map +1 -1
- package/lib/types/host/common/account-pool.d.ts +27 -1
- package/lib/types/host/common/account-pool.d.ts.map +1 -1
- package/lib/types/host/common/cache-activity.d.ts +14 -0
- package/lib/types/host/common/cache-activity.d.ts.map +1 -0
- package/lib/types/host/common/cache-affinity.d.ts +23 -0
- package/lib/types/host/common/cache-affinity.d.ts.map +1 -0
- package/lib/types/host/common/cache-hint.d.ts +18 -0
- package/lib/types/host/common/cache-hint.d.ts.map +1 -0
- package/lib/types/host/common/failure-classification.d.ts +21 -0
- package/lib/types/host/common/failure-classification.d.ts.map +1 -0
- package/lib/types/host/common/hosted-media.d.ts +36 -0
- package/lib/types/host/common/hosted-media.d.ts.map +1 -0
- package/lib/types/host/common/prefix-request-coordinator.d.ts +46 -0
- package/lib/types/host/common/prefix-request-coordinator.d.ts.map +1 -0
- package/lib/types/host/common/prefix-stability.d.ts +24 -0
- package/lib/types/host/common/prefix-stability.d.ts.map +1 -0
- package/lib/types/host/common/prompt-cache-policy.d.ts +43 -0
- package/lib/types/host/common/prompt-cache-policy.d.ts.map +1 -0
- package/lib/types/host/common/reasoning-dialect.d.ts +24 -0
- package/lib/types/host/common/reasoning-dialect.d.ts.map +1 -0
- package/lib/types/host/common/session-cache-state.d.ts +29 -0
- package/lib/types/host/common/session-cache-state.d.ts.map +1 -0
- package/lib/types/host/common/sticky-image-budget.d.ts +10 -0
- package/lib/types/host/common/sticky-image-budget.d.ts.map +1 -0
- package/lib/types/host/common/tool-runaway.d.ts +52 -0
- package/lib/types/host/common/tool-runaway.d.ts.map +1 -0
- package/lib/types/host/kimi-code/account-pool.d.ts +19 -2
- package/lib/types/host/kimi-code/account-pool.d.ts.map +1 -1
- package/lib/types/host/kimi-code/adapter.d.ts +44 -30
- package/lib/types/host/kimi-code/adapter.d.ts.map +1 -1
- package/lib/types/host/kimi-code/cache-affinity.d.ts +112 -0
- package/lib/types/host/kimi-code/cache-affinity.d.ts.map +1 -0
- package/lib/types/host/kimi-code/cache-hint.d.ts +3 -28
- package/lib/types/host/kimi-code/cache-hint.d.ts.map +1 -1
- package/lib/types/host/kimi-code/cache-wait.d.ts +6 -4
- package/lib/types/host/kimi-code/cache-wait.d.ts.map +1 -1
- package/lib/types/host/kimi-code/mapper.d.ts +2 -6
- package/lib/types/host/kimi-code/mapper.d.ts.map +1 -1
- package/lib/types/host/kimi-code/media-files.d.ts +2 -28
- package/lib/types/host/kimi-code/media-files.d.ts.map +1 -1
- package/lib/types/host/kimi-code/repeat-breaker.d.ts +13 -16
- package/lib/types/host/kimi-code/repeat-breaker.d.ts.map +1 -1
- package/lib/types/host/kimi-code/routes.d.ts.map +1 -1
- package/lib/types/host/kimi-code/session-cache-state.d.ts +16 -53
- package/lib/types/host/kimi-code/session-cache-state.d.ts.map +1 -1
- package/lib/types/host/minimax-code/adapter.d.ts +5 -1
- package/lib/types/host/minimax-code/adapter.d.ts.map +1 -1
- package/lib/types/host/minimax-code/files-api.d.ts.map +1 -1
- package/lib/types/host/minimax-code/runtime-enhancements.d.ts.map +1 -1
- package/lib/types/host/opendesign/mapper.d.ts.map +1 -1
- package/lib/types/host/proxy-manager.d.ts +87 -1
- package/lib/types/host/proxy-manager.d.ts.map +1 -1
- package/lib/types/host/qoder/mapper.d.ts.map +1 -1
- package/lib/types/host/responses-client.d.ts +4 -0
- package/lib/types/host/responses-client.d.ts.map +1 -1
- package/lib/types/host/step-code/account-pool.d.ts +2 -2
- package/lib/types/host/step-code/account-pool.d.ts.map +1 -1
- package/lib/types/host/step-code/adapter.d.ts +10 -0
- package/lib/types/host/step-code/adapter.d.ts.map +1 -1
- package/lib/types/host/step-code/routes.d.ts +3 -0
- package/lib/types/host/step-code/routes.d.ts.map +1 -1
- package/lib/types/index.d.ts +22 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/kimi-code-contracts.d.ts +16 -0
- package/lib/types/shared/kimi-code-contracts.d.ts.map +1 -1
- package/lib/types/shared/step-code-contracts.d.ts +5 -0
- package/lib/types/shared/step-code-contracts.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefix-request-coordinator.d.ts","sourceRoot":"","sources":["../../../../src/host/common/prefix-request-coordinator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,OAAO,IAAI,IAAI,CAAA;IACf,QAAQ,IAAI,IAAI,CAAA;CACjB;AAcD,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAC5B;AAED,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAiC;IAC7D,OAAO,CAAC,QAAQ,CAAC,IAA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CAAC,CAAC,CAAC,GACjC,OAAO,CAAC,QAAQ,CAAC,CAqBnB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable bootstrap-prefix ordering for providers that reuse content prefixes.
|
|
3
|
+
* Dynamic mid-conversation updates stay at their original history position;
|
|
4
|
+
* only the initial harness bootstrap run is normalised ahead of the user task.
|
|
5
|
+
*/
|
|
6
|
+
import type { GenerateOptions, Message } from './llm-compat.ts';
|
|
7
|
+
import { type PromptCacheOverride } from './prompt-cache-policy.ts';
|
|
8
|
+
/** Stability tier for an initial bootstrap reminder; null means dynamic/history-bound. */
|
|
9
|
+
export declare function classifyBootstrapUserMessage(message: Message): 1 | 2 | 3 | 4 | null;
|
|
10
|
+
/** Normalise the initial bootstrap run, including the post-compaction shape. */
|
|
11
|
+
export declare function orderStaticPrefixMessages(messages: readonly Message[]): Message[];
|
|
12
|
+
/** Apply the policy at an adapter boundary; disabled providers keep object identity. */
|
|
13
|
+
export declare function withStaticPrefixOrdering<T extends GenerateOptions>(provider: string, options: T, override?: PromptCacheOverride): T;
|
|
14
|
+
/** Provider-neutral identity for requests that may share one cold prefix. */
|
|
15
|
+
export declare function sharedPrefixGroupKey(provider: string, options: GenerateOptions, namespace: string, accountScope: string): string | undefined;
|
|
16
|
+
export interface SharedPrefixSnapshot {
|
|
17
|
+
readonly systemPromptHash: string | null;
|
|
18
|
+
readonly toolsHash: string | null;
|
|
19
|
+
readonly cacheKey: string | null;
|
|
20
|
+
}
|
|
21
|
+
export type SharedPrefixDriftCause = 'first-request' | 'stable' | 'system-prompt' | 'tools' | 'cache-key' | 'cold-key';
|
|
22
|
+
/** Pure prefix-diff policy shared by provider-specific telemetry stores. */
|
|
23
|
+
export declare function classifyPrefixDrift(previous: SharedPrefixSnapshot | undefined, current: SharedPrefixSnapshot): SharedPrefixDriftCause;
|
|
24
|
+
//# sourceMappingURL=prefix-stability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-owned prompt-cache semantics, separated from reusable mechanisms.
|
|
3
|
+
*
|
|
4
|
+
* A cache read counter is not proof that a deployment supports cache keys,
|
|
5
|
+
* account affinity, or keepalive traffic. This registry is therefore the single
|
|
6
|
+
* place where those assumptions become explicit. Missing evidence disables the
|
|
7
|
+
* corresponding behaviour; a deployment override may enable it only when its
|
|
8
|
+
* required facts are present too.
|
|
9
|
+
*/
|
|
10
|
+
export type PromptCacheMode = 'automatic' | 'explicit' | 'none';
|
|
11
|
+
export type PromptCacheScope = 'account' | 'shared' | 'unknown';
|
|
12
|
+
export type ColdStartMode = 'off' | 'in-flight' | 'warm';
|
|
13
|
+
export interface PromptCachePolicy {
|
|
14
|
+
readonly mode: PromptCacheMode;
|
|
15
|
+
readonly scope: PromptCacheScope;
|
|
16
|
+
readonly ttlMs?: number;
|
|
17
|
+
readonly staticPrefix: boolean;
|
|
18
|
+
readonly coldStart: ColdStartMode;
|
|
19
|
+
readonly stickyImages: boolean;
|
|
20
|
+
readonly affinity: boolean;
|
|
21
|
+
readonly waitWarmup: boolean;
|
|
22
|
+
readonly hint: boolean;
|
|
23
|
+
}
|
|
24
|
+
export type PromptCacheOverride = Partial<Omit<PromptCachePolicy, 'ttlMs'>> & {
|
|
25
|
+
ttlMs?: number;
|
|
26
|
+
};
|
|
27
|
+
export type PromptCacheOverrides = Readonly<Record<string, PromptCacheOverride>>;
|
|
28
|
+
/** Built-in facts already represented by a line's mapper, adapter, or official client. */
|
|
29
|
+
export declare const PROMPT_CACHE_POLICIES: Readonly<Record<string, PromptCachePolicy>>;
|
|
30
|
+
/** Validate one provider override without silently dropping unknown keys. */
|
|
31
|
+
export declare function parsePromptCacheOverride(provider: string, value: unknown): PromptCacheOverride;
|
|
32
|
+
/** Validate a whole config-owned map. Undefined means no overrides. */
|
|
33
|
+
export declare function parsePromptCacheOverrides(value: unknown): PromptCacheOverrides;
|
|
34
|
+
/** Resolve one line, applying an already-validated or config-shaped override. */
|
|
35
|
+
export declare function promptCachePolicyOf(provider: string, override?: PromptCacheOverride): PromptCachePolicy;
|
|
36
|
+
/** Resolve the built-in matrix plus optional deployment overrides. */
|
|
37
|
+
export declare function resolvePromptCachePolicies(overrides?: unknown): Readonly<Record<string, PromptCachePolicy>>;
|
|
38
|
+
/** A volatile config field or an ordinary value, matching the host's loader seam. */
|
|
39
|
+
export type PromptCacheConfigField<T> = T | {
|
|
40
|
+
get(): T | undefined;
|
|
41
|
+
} | undefined;
|
|
42
|
+
export declare function readPromptCacheConfigField<T>(field: PromptCacheConfigField<T>): T | undefined;
|
|
43
|
+
//# sourceMappingURL=prompt-cache-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-cache-policy.d.ts","sourceRoot":"","sources":["../../../../src/host/common/prompt-cache-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,GAAG,MAAM,CAAA;AAC/D,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;AAC/D,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,CAAA;AAExD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAA;IAC9B,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAA;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAA;IACjC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAChG,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAA;AAoBhF,0FAA0F;AAC1F,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAkC5E,CAAA;AAYF,6EAA6E;AAC7E,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,mBAAmB,CAsB9F;AAED,uEAAuE;AACvE,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAS9E;AAcD,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,mBAAmB,GAAG,iBAAiB,CAIvG;AAED,sEAAsE;AACtE,wBAAgB,0BAA0B,CAAC,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAM3G;AAED,qFAAqF;AACrF,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,GAAG,IAAI,CAAC,GAAG,SAAS,CAAA;CAAE,GAAG,SAAS,CAAA;AAEhF,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAK7F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Learn the reasoning field a concrete OpenAI-compatible endpoint speaks. */
|
|
2
|
+
export declare const KNOWN_REASONING_KEYS: readonly ["reasoning_content", "reasoning_details", "reasoning"];
|
|
3
|
+
export declare class ReasoningKeyDialect {
|
|
4
|
+
private readonly defaultKey;
|
|
5
|
+
private readonly keys;
|
|
6
|
+
private detected;
|
|
7
|
+
constructor(defaultKey?: string, keys?: readonly string[]);
|
|
8
|
+
/** Record an observed field and return its text. Empty strings still teach the key. */
|
|
9
|
+
observe(source: unknown): string | undefined;
|
|
10
|
+
/** Record a previously parsed fragment without re-reading the wire object. */
|
|
11
|
+
observeKey(key: string): void;
|
|
12
|
+
protected learn(key: string): void;
|
|
13
|
+
outboundKey(): string;
|
|
14
|
+
reset(): void;
|
|
15
|
+
}
|
|
16
|
+
/** Provider+endpoint isolation; one gateway's dialect never contaminates another. */
|
|
17
|
+
export declare class ReasoningDialectRegistry {
|
|
18
|
+
private readonly maxEntries;
|
|
19
|
+
private readonly dialects;
|
|
20
|
+
constructor(maxEntries?: number);
|
|
21
|
+
for(provider: string, endpoint: string, defaultKey?: string): ReasoningKeyDialect;
|
|
22
|
+
reset(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=reasoning-dialect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reasoning-dialect.d.ts","sourceRoot":"","sources":["../../../../src/host/common/reasoning-dialect.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAE9E,eAAO,MAAM,oBAAoB,kEAAmE,CAAA;AAEpG,qBAAa,mBAAmB;IAI5B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJvB,OAAO,CAAC,QAAQ,CAAoB;gBAGjB,UAAU,GAAE,MAAgC,EAC5C,IAAI,GAAE,SAAS,MAAM,EAAyB;IAGjE,uFAAuF;IACvF,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS;IAa5C,8EAA8E;IAC9E,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI7B,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIlC,WAAW,IAAI,MAAM;IAIrB,KAAK,IAAI,IAAI;CAGd;AAED,qFAAqF;AACrF,qBAAa,wBAAwB;IAGvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;gBAErC,UAAU,SAAK;IAE5C,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,mBAAmB;IAgBjF,KAAK,IAAI,IAAI;CACd"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface SessionCacheRecordShape {
|
|
2
|
+
readonly updatedAt: number;
|
|
3
|
+
}
|
|
4
|
+
export interface CommonSessionCacheStateOptions<T extends SessionCacheRecordShape> {
|
|
5
|
+
readonly filePath: string;
|
|
6
|
+
readonly maxEntries?: number;
|
|
7
|
+
readonly allowWrite?: boolean;
|
|
8
|
+
readonly normalizeRecord: (value: unknown) => T | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare class CommonSessionCacheStateStore<T extends SessionCacheRecordShape> {
|
|
11
|
+
private document;
|
|
12
|
+
private pending;
|
|
13
|
+
private readonly filePath;
|
|
14
|
+
private readonly maxEntries;
|
|
15
|
+
private readonly allowWrite;
|
|
16
|
+
private readonly normalizeRecord;
|
|
17
|
+
private static writeSequence;
|
|
18
|
+
constructor(options: CommonSessionCacheStateOptions<T>);
|
|
19
|
+
read(sessionId?: string): T | undefined;
|
|
20
|
+
write(sessionId: string, record: T): void;
|
|
21
|
+
/** Update an existing record; absence is not created implicitly. */
|
|
22
|
+
update(sessionId: string, update: (record: T) => T): boolean;
|
|
23
|
+
flush(): void;
|
|
24
|
+
private load;
|
|
25
|
+
private schedule;
|
|
26
|
+
private cancelPending;
|
|
27
|
+
private persist;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=session-cache-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-cache-state.d.ts","sourceRoot":"","sources":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getStore {
|
|
2
|
+
private readonly store;
|
|
3
|
+
constructor(provider: string, filePath?: string);
|
|
4
|
+
/** Identities already omitted in this session, including before a restart. */
|
|
5
|
+
priorDroppedKeys(sessionId?: string): ReadonlySet<string>;
|
|
6
|
+
/** Persist the complete set, not just the newest omissions. */
|
|
7
|
+
record(sessionId: string | undefined, keys: ReadonlySet<string>): void;
|
|
8
|
+
flush(): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=sticky-image-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sticky-image-budget.d.ts","sourceRoot":"","sources":["../../../../src/host/common/sticky-image-budget.ts"],"names":[],"mappings":"AAyBA,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiD;gBAE3D,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAS/C,8EAA8E;IAC9E,gBAAgB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAKzD,+DAA+D;IAC/D,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI;IAKtE,KAAK,IAAI,IAAI;CACd"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral tool-call repetition primitives.
|
|
3
|
+
*
|
|
4
|
+
* The detector knows nothing about model wire formats. Providers supply reminder
|
|
5
|
+
* text and may opt into a hard handoff threshold; coordination tools are exempt
|
|
6
|
+
* because they are expected to recur while real work continues.
|
|
7
|
+
*/
|
|
8
|
+
/** Stable identity for one tool call, independent of object key order. */
|
|
9
|
+
export declare function canonicalToolCallKey(toolName: string, args: unknown): string;
|
|
10
|
+
export interface ExactRepeatObservation {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly count: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ExactRepeatTracker {
|
|
15
|
+
observe(toolName: string, args: unknown): ExactRepeatObservation;
|
|
16
|
+
current(): ExactRepeatObservation | undefined;
|
|
17
|
+
reset(): void;
|
|
18
|
+
}
|
|
19
|
+
/** One immediately-repeated action streak. A different action starts at one. */
|
|
20
|
+
export declare function createExactRepeatTracker(): ExactRepeatTracker;
|
|
21
|
+
/** Coordination calls that must not break or inflate an action streak. */
|
|
22
|
+
export declare const TOOL_RUNAWAY_EXEMPT_TOOLS: readonly string[];
|
|
23
|
+
export declare function isToolRunawayExemptTool(toolName: string): boolean;
|
|
24
|
+
export interface ToolRunawayGuardConfig {
|
|
25
|
+
readonly toolRunawayGuard?: boolean | {
|
|
26
|
+
get(): boolean | undefined;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** Read the live global switch; legacy Kimi-only installs without it stay on. */
|
|
30
|
+
export declare function resolveToolRunawayGuardEnabled(config?: ToolRunawayGuardConfig): boolean;
|
|
31
|
+
export interface ExactRepeatBreakerOptions {
|
|
32
|
+
/** Reminder for a completed execution; undefined leaves the decision untouched. */
|
|
33
|
+
readonly reminder: (count: number) => string | undefined;
|
|
34
|
+
/** Optional execution veto once the same call reaches this count. */
|
|
35
|
+
readonly forceStopAt?: number;
|
|
36
|
+
readonly handoffReminder?: string;
|
|
37
|
+
readonly handoffVeto?: string;
|
|
38
|
+
readonly exemptTools?: readonly string[];
|
|
39
|
+
/** Bound on remembered sessions; least-recently-written is evicted first. */
|
|
40
|
+
readonly maxSessions?: number;
|
|
41
|
+
}
|
|
42
|
+
export interface ExactRepeatBreaker {
|
|
43
|
+
checkBeforeExecute(sessionId: string, toolName: string, args: unknown): string | undefined;
|
|
44
|
+
recordAfterExecute(sessionId: string, toolName: string, args: unknown): string | undefined;
|
|
45
|
+
resetSession(sessionId: string): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Exact-repeat state machine shared by provider profiles. A missing forceStopAt
|
|
49
|
+
* gives reminders only; no provider inherits Kimi's hard stop accidentally.
|
|
50
|
+
*/
|
|
51
|
+
export declare function createExactRepeatBreaker(options: ExactRepeatBreakerOptions): ExactRepeatBreaker;
|
|
52
|
+
//# sourceMappingURL=tool-runaway.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-runaway.d.ts","sourceRoot":"","sources":["../../../../src/host/common/tool-runaway.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoBH,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAQ5E;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,sBAAsB,CAAA;IAChE,OAAO,IAAI,sBAAsB,GAAG,SAAS,CAAA;IAC7C,KAAK,IAAI,IAAI,CAAA;CACd;AAED,gFAAgF;AAChF,wBAAgB,wBAAwB,IAAI,kBAAkB,CAc7D;AAED,0EAA0E;AAC1E,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAYrD,CAAA;AAEF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,GAAG;QAAE,GAAG,IAAI,OAAO,GAAG,SAAS,CAAA;KAAE,CAAA;CACrE;AAED,iFAAiF;AACjF,wBAAgB,8BAA8B,CAAC,MAAM,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAMvF;AAED,MAAM,WAAW,yBAAyB;IACxC,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;IACxD,qEAAqE;IACrE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,6EAA6E;IAC7E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;IAC1F,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;IAC1F,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACtC;AAQD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CA6C/F"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountPoolCore, type AccountPoolRefreshOptions, type PoolAccountShape, type PoolData } from '../common/account-pool.ts';
|
|
1
|
+
import { AccountPoolCore, type AccountPoolRefreshOptions, type AccountSelectionHint, type PoolAccountShape, type PoolData } from '../common/account-pool.ts';
|
|
2
2
|
import type { CredentialStore } from '../token-store.ts';
|
|
3
3
|
import { FileCredentialStore, type KimiCodeCredentials } from './token-store.ts';
|
|
4
4
|
import type { PoolAccountQuotaDto } from '../../shared/account-pool-contracts.ts';
|
|
@@ -68,11 +68,28 @@ export declare class KimiCodeAccountPool extends AccountPoolCore<KimiCodeCredent
|
|
|
68
68
|
*
|
|
69
69
|
* The returned credential carries its own region, OAuth host and base URL, so
|
|
70
70
|
* the caller must use those rather than the process-wide defaults.
|
|
71
|
+
*
|
|
72
|
+
* @param selection - this request's own preference, used by the cache-affinity
|
|
73
|
+
* routing to put an account whose prefix cache is still warm first. Absent
|
|
74
|
+
* means the rotation strategy decides alone.
|
|
71
75
|
*/
|
|
72
|
-
getEffectiveCredential(excludeIds?: ReadonlySet<string>, fetchFn?: typeof fetch, options?: AccountPoolRefreshOptions): Promise<{
|
|
76
|
+
getEffectiveCredential(excludeIds?: ReadonlySet<string>, fetchFn?: typeof fetch, options?: AccountPoolRefreshOptions, selection?: AccountSelectionHint): Promise<{
|
|
73
77
|
account: KimiCodePoolAccount;
|
|
74
78
|
credentials: KimiCodeCredentials;
|
|
75
79
|
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Every pooled account's id with the region that decides its prefix group.
|
|
82
|
+
*
|
|
83
|
+
* The cache-affinity routing needs exactly two facts per account — which one
|
|
84
|
+
* it is, and which regional service answers it, because each region keeps its
|
|
85
|
+
* own prefix cache — and nothing else. Deliberately a narrow projection over
|
|
86
|
+
* the pool document rather than a credential read: tokens never leave the
|
|
87
|
+
* pool, and nothing here can be mistaken for a credential accessor.
|
|
88
|
+
*/
|
|
89
|
+
accountScopes(): Promise<Array<{
|
|
90
|
+
id: string;
|
|
91
|
+
region: KimiCodeRegion | null;
|
|
92
|
+
}>>;
|
|
76
93
|
/** The pre-pool credential file this pool mirrors its primary account into. */
|
|
77
94
|
mirrorStore(): FileCredentialStore;
|
|
78
95
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-pool.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/account-pool.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAGf,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACd,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EACL,mBAAmB,EAEnB,KAAK,mBAAmB,EACzB,MAAM,kBAAkB,CAAA;AAKzB,OAA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oBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI,GAAG,mBAAmB,GAAG,SAAS,CAOxG;AAED;;;;;;GAMG;AACH,qBAAa,mBAAoB,SAAQ,eAAe,CACtD,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,CAC1B;IACC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;gBAE/B,OAAO,GAAE,0BAA+B;IAkHpD;;;;;;;;;OASG;IACG,sBAAsB,CAC1B,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,OAAO,GAAE,OAAO,KAAa,EAC7B,OAAO,CAAC,EAAE,yBAAyB,EACnC,SAAS,CAAC,EAAE,oBAAoB,GAC/B,OAAO,CAAC;QAAE,OAAO,EAAE,mBAAmB,CAAC;QAAC,WAAW,EAAE,mBAAmB,CAAA;KAAE,CAAC;IAI9E;;;;;;;;OAQG;IACG,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IAQpF,+EAA+E;IAC/E,WAAW,IAAI,mBAAmB;IAIlC;;;;;;;;;;;;;;;OAeG;IACG,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CA8B/E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ProviderFailureClassification } from '../common/failure-classification.ts';
|
|
1
2
|
import { LlmAdapter, ReasoningEffortId, type GenerateOptions, type LlmModelInfo, type LlmProviderInfo, type LlmResolvedModelInfo, type PreparedAdapterCall, type ResolvedRetryPolicy, type StreamChunk } from '@deepseek-ai/dsh-llm';
|
|
2
3
|
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
3
4
|
import { PROVIDER_ID, reasoningEffortsFor } from './types.ts';
|
|
@@ -70,7 +71,7 @@ export declare function resolveDefaultReasoningEffort(efforts: readonly string[]
|
|
|
70
71
|
* retried. The body text is what separates them, so the classification reads
|
|
71
72
|
* it rather than trusting the status alone.
|
|
72
73
|
*/
|
|
73
|
-
export interface KimiFailureClassification {
|
|
74
|
+
export interface KimiFailureClassification extends ProviderFailureClassification {
|
|
74
75
|
/** DSH error code; decides whether the route retries. */
|
|
75
76
|
code: string;
|
|
76
77
|
/** Message shown to the user, with the provider's own text appended. */
|
|
@@ -241,6 +242,15 @@ export interface KimiCodeAdapterOptions {
|
|
|
241
242
|
* per account rather than once per turn.
|
|
242
243
|
*/
|
|
243
244
|
mediaFiles?: KimiMediaFilesUploader;
|
|
245
|
+
/**
|
|
246
|
+
* Whether a request may state an account preference from the prefix cache.
|
|
247
|
+
*
|
|
248
|
+
* A live getter rather than a captured boolean: the switch is volatile in
|
|
249
|
+
* settings, and a captured value would keep routing by an answer the user has
|
|
250
|
+
* already changed. Absent means enabled — the behaviour the routing has when
|
|
251
|
+
* nothing turns it off.
|
|
252
|
+
*/
|
|
253
|
+
cacheAffinity?: () => boolean;
|
|
244
254
|
}
|
|
245
255
|
/**
|
|
246
256
|
* Longest edge of the request version this route asks the attachment store for.
|
|
@@ -284,37 +294,16 @@ export declare const KIMI_CODE_REQUEST_IMAGE_MAX_EDGE = 2000;
|
|
|
284
294
|
* @returns the tool-update mode, or undefined when this route must resend everything.
|
|
285
295
|
*/
|
|
286
296
|
export declare function toolUpdateMode(modelId: string, catalog: readonly KimiCodeCatalogModel[]): 'in-history' | undefined;
|
|
287
|
-
/**
|
|
288
|
-
* How long a cold-start follower waits for the leader warming the same prefix.
|
|
289
|
-
*
|
|
290
|
-
* The leader only has to reach the response headers: past that the service is
|
|
291
|
-
* already processing the prefix, and a follower that waited out the whole
|
|
292
|
-
* budget would have lost more than the shared warm-up was worth.
|
|
293
|
-
*/
|
|
297
|
+
/** How long a cold-start follower waits for the leader warming the same prefix. */
|
|
294
298
|
export declare const COLD_START_WARMUP_WAIT_MS = 2500;
|
|
295
|
-
/**
|
|
296
|
-
* Forget every remembered prefix and release every waiting follower.
|
|
297
|
-
*
|
|
298
|
-
* Test seam only: these maps are process-wide, and a test that asserts on the
|
|
299
|
-
* cold-start gate must start from a clean slate.
|
|
300
|
-
*/
|
|
299
|
+
/** Forget every remembered prefix and release every waiting follower. */
|
|
301
300
|
export declare function resetColdStartSingleflightForTests(): void;
|
|
302
|
-
/**
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
* the key because each region is a separate service with a cache of its own.
|
|
309
|
-
*
|
|
310
|
-
* A request with no system prompt has no prefix worth warming, and gets no
|
|
311
|
-
* group at all.
|
|
312
|
-
*
|
|
313
|
-
* @param region - The region the request will be answered from.
|
|
314
|
-
* @param options - The request about to be sent.
|
|
315
|
-
* @returns The group key, or undefined when the request has no prefix.
|
|
316
|
-
*/
|
|
317
|
-
export declare function coldStartGroupKey(region: string, options: NormalizedGenerateOptions): string | undefined;
|
|
301
|
+
/** The prefix identity shared by requests on one region/model. */
|
|
302
|
+
export declare function prefixGroupKey(region: string, options: NormalizedGenerateOptions): string | undefined;
|
|
303
|
+
/** The cache group on one account; cross-account warmth is never inferred. */
|
|
304
|
+
export declare function coldStartGroupKey(region: string, options: NormalizedGenerateOptions, accountScope: string): string | undefined;
|
|
305
|
+
/** Whether this account's prefix is still warm under the measured Kimi TTL. */
|
|
306
|
+
export declare function isWarmPrefixGroup(region: string, options: NormalizedGenerateOptions, accountScope: string, now?: number): boolean;
|
|
318
307
|
export declare class KimiCodeAdapter extends LlmAdapter {
|
|
319
308
|
private readonly store;
|
|
320
309
|
private readonly modelSettings;
|
|
@@ -380,6 +369,31 @@ export declare class KimiCodeAdapter extends LlmAdapter {
|
|
|
380
369
|
maxBytes: number;
|
|
381
370
|
};
|
|
382
371
|
private settings;
|
|
372
|
+
/** Whether this deployment routes by warm prefix cache; on unless switched off. */
|
|
373
|
+
private cacheAffinityEnabled;
|
|
374
|
+
/**
|
|
375
|
+
* Which accounts this request would rather be served by, when the prefix cache
|
|
376
|
+
* can say something useful about it.
|
|
377
|
+
*
|
|
378
|
+
* The service keeps one prefix cache per account, so rotation — which knows
|
|
379
|
+
* cooldowns, tokens and last use, never prompt content — can spend a request on
|
|
380
|
+
* an account that has never seen this prompt while another one has it hot. Both
|
|
381
|
+
* facts needed to do better are already in this process: the cold-start gate
|
|
382
|
+
* records which (prefix, account) pairs are warm, and the quota cache says how
|
|
383
|
+
* much each account has left.
|
|
384
|
+
*
|
|
385
|
+
* Returns undefined — no preference at all — wherever a preference would be a
|
|
386
|
+
* guess: the switch is off, there is no pool or only one account, the pool
|
|
387
|
+
* document cannot be read, a region cannot be resolved, or no account has this
|
|
388
|
+
* prefix warm. The pool then applies its rotation strategy exactly as it would
|
|
389
|
+
* have without this method.
|
|
390
|
+
*
|
|
391
|
+
* @param pool - The account pool serving this route, or null when none is installed.
|
|
392
|
+
* @param options - The request about to be sent; its system prompt, tools and
|
|
393
|
+
* static bootstrap are what decide the prefix identity.
|
|
394
|
+
* @returns a preference for the pool, or undefined for "strategy decides".
|
|
395
|
+
*/
|
|
396
|
+
private cacheAffinityHint;
|
|
383
397
|
/**
|
|
384
398
|
* Catalog for the picker: the live managed listing when reachable, the
|
|
385
399
|
* shipped fallback otherwise, narrowed by the user's enabled selection.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,qCAAqC,CAAA;AAG5C,OAAO,EACL,UAAU,EAEV,iBAAiB,EAGjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KA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IAQ5B;;;;;;;;;;;;;;;;;;;;;OAqBG;YACW,iBAAiB;IA6C/B;;;OAGG;YACW,OAAO;IA0BrB;;;;;;;;;;;;;;;;;;OAkBG;IACH,OAAO,CAAC,gBAAgB;IAYlB,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC;IAmB/D,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA6CpG,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/F,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,aAAa,CAAC,WAAW,CAAC;YAgBpD,aAAa;IAipB5B;;;;;;;;;;;;;;;OAeG;YACW,mBAAmB;IA6DjC;;;;;;;;OAQG;YACW,mBAAmB;CASlC;AAqFD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which account should serve this request when one of them still has it warm.
|
|
3
|
+
*
|
|
4
|
+
* Kimi's prefix cache lives on the service, one cache per account, so two
|
|
5
|
+
* accounts in the same pool do not share a warm prefix: the account that
|
|
6
|
+
* answered this exact prompt a minute ago reads it back at the cache price,
|
|
7
|
+
* while the account the rotation strategy happens to pick reprocesses the whole
|
|
8
|
+
* thing. Rotation cannot see that difference — it knows cooldowns, tokens and
|
|
9
|
+
* last use, never prompt content — so the request names the accounts it would
|
|
10
|
+
* rather use and the pool honours the order.
|
|
11
|
+
*
|
|
12
|
+
* The whole decision is here, as a pure function of four inputs, for the same
|
|
13
|
+
* reason `cache-hint` is: the numbers behind it (how long an entry survives, how
|
|
14
|
+
* much a cache read costs against a fresh one) are measured elsewhere, and
|
|
15
|
+
* swapping a source must change only where a value comes from, never the rule.
|
|
16
|
+
*
|
|
17
|
+
* @module dsh-chatgpt-subscription/kimi-code-cache-affinity
|
|
18
|
+
*/
|
|
19
|
+
import type { KimiCodeAccountQuota } from '../../shared/kimi-code-contracts.ts';
|
|
20
|
+
/**
|
|
21
|
+
* Remaining share below which a warm account stops being preferred.
|
|
22
|
+
*
|
|
23
|
+
* Affinity is a discount, not a right: an account holding 4% of its window can
|
|
24
|
+
* serve a few cheap cache reads and then take the line offline mid-conversation,
|
|
25
|
+
* which costs far more than the prefix it saved. 20% is the same floor the
|
|
26
|
+
* background warmup uses before it spends anything (`DEFAULT_MIN_WARMUP_QUOTA_RATIO`),
|
|
27
|
+
* so the two decisions agree about when an account is running dry instead of
|
|
28
|
+
* each inventing its own answer.
|
|
29
|
+
*/
|
|
30
|
+
export declare const AFFINITY_QUOTA_FLOOR_SHARE = 0.2;
|
|
31
|
+
/**
|
|
32
|
+
* The share of its tightest window an account has left, or null when unknown.
|
|
33
|
+
*
|
|
34
|
+
* The TIGHTEST window is the only honest answer: a pool row can carry several
|
|
35
|
+
* at once, and an account with 90% of a weekly window but 2% of its five-hour
|
|
36
|
+
* one is about to be refused. A window whose consumption was never measured
|
|
37
|
+
* is skipped rather than read as empty or full, and a snapshot with no measured
|
|
38
|
+
* window at all answers null — "unknown", which the caller treats as "not
|
|
39
|
+
* provably short" instead of blocking the account on a number nobody measured.
|
|
40
|
+
*
|
|
41
|
+
* @param quota - The account's newest quota snapshot, when one was ever read.
|
|
42
|
+
* @returns the smallest remaining fraction in `[0, 1]`, or null when unknown.
|
|
43
|
+
*/
|
|
44
|
+
export declare function remainingQuotaShare(quota: KimiCodeAccountQuota | null | undefined): number | null;
|
|
45
|
+
/** Settings-card description for the cache-affinity switch. */
|
|
46
|
+
export declare const CACHE_AFFINITY_SETTING_DESCRIPTION: string;
|
|
47
|
+
/**
|
|
48
|
+
* Environment override for the affinity switch.
|
|
49
|
+
*
|
|
50
|
+
* The same contract as the wait-time warmup switch beside it in settings: an
|
|
51
|
+
* explicit value wins over the stored setting, so a deployment can pin the
|
|
52
|
+
* behavioural change without editing preferences on disk.
|
|
53
|
+
*/
|
|
54
|
+
export declare const CACHE_AFFINITY_ENV = "DSH_KIMI_CODE_CACHE_AFFINITY";
|
|
55
|
+
/**
|
|
56
|
+
* Resolve whether cache-affinity routing is enabled.
|
|
57
|
+
*
|
|
58
|
+
* Enabled by default. `0`/`false`/`no`/`off` and `1`/`true`/`yes`/`on` override
|
|
59
|
+
* the stored setting; otherwise the live `cacheAffinity` setting (default
|
|
60
|
+
* `true`) governs. Anything unreadable falls back to enabled rather than
|
|
61
|
+
* throwing inside a request path.
|
|
62
|
+
*
|
|
63
|
+
* @param config - Plugin config carrying the live setting.
|
|
64
|
+
* @param env - Environment to consult; `process.env` in production.
|
|
65
|
+
* @returns whether a request may state an account preference.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveCacheAffinityEnabled(config?: {
|
|
68
|
+
cacheAffinity?: {
|
|
69
|
+
get(): boolean | undefined;
|
|
70
|
+
} | boolean;
|
|
71
|
+
}, env?: Record<string, string | undefined>): boolean;
|
|
72
|
+
/** One account the request could be served by. */
|
|
73
|
+
export interface AffinityCandidate {
|
|
74
|
+
/** Pool account id. */
|
|
75
|
+
readonly id: string;
|
|
76
|
+
/**
|
|
77
|
+
* Whether this account's own prefix group for this request is warm right now.
|
|
78
|
+
*
|
|
79
|
+
* Per account by design: the pool's cache is per account, so "the prefix is
|
|
80
|
+
* warm" is a fact about one account, never about the pool.
|
|
81
|
+
*/
|
|
82
|
+
readonly warm: boolean;
|
|
83
|
+
}
|
|
84
|
+
export interface AffinityOrderInput {
|
|
85
|
+
/** Accounts that may serve this request right now, in pool order. */
|
|
86
|
+
readonly candidates: readonly AffinityCandidate[];
|
|
87
|
+
/** Remaining share per account id; a missing or null entry means unknown. */
|
|
88
|
+
readonly remainingShareById?: Readonly<Record<string, number | null | undefined>>;
|
|
89
|
+
/** Floor below which a warm account gives way; defaults to {@link AFFINITY_QUOTA_FLOOR_SHARE}. */
|
|
90
|
+
readonly floorShare?: number;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Order the accounts this request would rather use, warmest and safest first.
|
|
94
|
+
*
|
|
95
|
+
* Only accounts whose prefix is warm AND whose remaining share is either
|
|
96
|
+
* unknown or at least the floor are returned: a warm account that is nearly
|
|
97
|
+
* spent is deliberately absent, because the pool then falls back to its own
|
|
98
|
+
* rotation instead of spending the last of a window on a discount. An empty
|
|
99
|
+
* result means "no preference" — the caller passes no hint at all and the
|
|
100
|
+
* strategy behaves exactly as it would have without this module.
|
|
101
|
+
*
|
|
102
|
+
* Order: a warm account with a known-and-sufficient share first (largest
|
|
103
|
+
* remaining first, so two warm accounts spread the load instead of always
|
|
104
|
+
* spending one), then a warm account whose share nobody measured. Unknown last
|
|
105
|
+
* because a measured account is a better bet than an unmeasured one, but still
|
|
106
|
+
* listed: an unmeasured warm account is not evidence of anything bad.
|
|
107
|
+
*
|
|
108
|
+
* @param input - candidates plus the quota evidence behind them.
|
|
109
|
+
* @returns account ids in preference order; empty when nothing is preferred.
|
|
110
|
+
*/
|
|
111
|
+
export declare function orderAffinityCandidates(input: AffinityOrderInput): string[];
|
|
112
|
+
//# sourceMappingURL=cache-affinity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-affinity.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/cache-affinity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAO/E;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,MAAqC,CAAA;AAE5E;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAEjG;AAED,+DAA+D;AAC/D,eAAO,MAAM,kCAAkC,QAEwB,CAAA;AAEvE;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,iCAAiC,CAAA;AAEhE;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE;QAAE,GAAG,IAAI,OAAO,GAAG,SAAS,CAAA;KAAE,GAAG,OAAO,CAAA;CAAE,EACrE,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAcT;AAED,kDAAkD;AAClD,MAAM,WAAW,iBAAiB;IAChC,uBAAuB;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,CAAA;IACjD,6EAA6E;IAC7E,QAAQ,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,CAAA;IACjF,kGAAkG;IAClG,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAE3E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CacheHintDecision, type CacheHintInput } from '../common/cache-hint.ts';
|
|
1
2
|
/**
|
|
2
3
|
* When it is worth telling the user their prompt cache has gone cold.
|
|
3
4
|
*
|
|
@@ -58,33 +59,7 @@ export declare function markSessionActive(sessionId: string | undefined, now?: n
|
|
|
58
59
|
export declare function sessionLastActiveAt(sessionId: string | undefined): number | undefined;
|
|
59
60
|
/** Forget one session's activity, or all of it. Test seam and teardown. */
|
|
60
61
|
export declare function resetSessionActivity(sessionId?: string): void;
|
|
61
|
-
export
|
|
62
|
-
|
|
63
|
-
readonly now: number;
|
|
64
|
-
/**
|
|
65
|
-
* When the conversation last did anything, epoch ms.
|
|
66
|
-
*
|
|
67
|
-
* Absent means nothing is known, and the hint is skipped: a client that
|
|
68
|
-
* cannot say how long the session was idle cannot claim the entry expired.
|
|
69
|
-
*/
|
|
70
|
-
readonly lastActiveAt?: number;
|
|
71
|
-
/** Context currently loaded, in tokens. Absent means no local estimate. */
|
|
72
|
-
readonly totalTokens?: number;
|
|
73
|
-
}
|
|
74
|
-
export type CacheHintDecision = {
|
|
75
|
-
readonly kind: 'skip';
|
|
76
|
-
} | {
|
|
77
|
-
readonly kind: 'hint';
|
|
78
|
-
readonly idleMs: number;
|
|
79
|
-
readonly totalTokens: number;
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Whether one conversation should be warned about a cold cache.
|
|
83
|
-
*
|
|
84
|
-
* Every missing-data branch skips. That asymmetry is deliberate and matches
|
|
85
|
-
* the official client: a false negative costs one turn nobody noticed, while a
|
|
86
|
-
* false positive teaches the user the notice is noise and stops them reading
|
|
87
|
-
* the one that mattered.
|
|
88
|
-
*/
|
|
62
|
+
export type { CacheHintDecision, CacheHintInput } from '../common/cache-hint.ts';
|
|
63
|
+
/** Kimi supplies its measured defaults; other providers call the common pure function directly. */
|
|
89
64
|
export declare function evaluateCacheHint(input: CacheHintInput): CacheHintDecision;
|
|
90
65
|
//# sourceMappingURL=cache-hint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-hint.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/cache-hint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,YAAY,QAAiB,CAAA;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,SAAU,CAAA;AAczC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,MAAmB,GAAG,IAAI,CAS/F;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGrF;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAM7D;AAED,
|
|
1
|
+
{"version":3,"file":"cache-hint.d.ts","sourceRoot":"","sources":["../../../../src/host/kimi-code/cache-hint.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,MAAM,yBAAyB,CAAA;AAEhC;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,YAAY,QAAiB,CAAA;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,SAAU,CAAA;AAczC;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,MAAmB,GAAG,IAAI,CAS/F;AAED,yEAAyE;AACzE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGrF;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAM7D;AAED,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAEhF,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,cAAc,GAAG,iBAAiB,CAM1E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PromptCacheOverride } from '../common/prompt-cache-policy.ts';
|
|
1
2
|
/** When an idle parent reaches its cache decision point (five minutes before TTL). */
|
|
2
3
|
export declare const CACHE_WAIT_DECISION_MS: number;
|
|
3
4
|
/** Minimum prompt tokens required before a wait warmup is sent (0 = any active context). */
|
|
@@ -5,7 +6,7 @@ export declare const DEFAULT_MIN_WARMUP_TOKENS = 0;
|
|
|
5
6
|
/** Environment override for wait-time cache keepalive warmup. */
|
|
6
7
|
export declare const CACHE_WAIT_WARMUP_ENV = "DSH_KIMI_CODE_CACHE_WAIT_WARMUP";
|
|
7
8
|
/** Settings description for the progress-updates / Kimi cache-wait switch. */
|
|
8
|
-
export declare const CACHE_WAIT_WARMUP_SETTING_DESCRIPTION = "
|
|
9
|
+
export declare const CACHE_WAIT_WARMUP_SETTING_DESCRIPTION = "\u7B49\u5F85\u5B50\u4EE3\u7406\u5B8C\u6210\u671F\u95F4\u6309\u7EBF\u8DEF\u7F13\u5B58 TTL \u8F7B\u91CF\u7EED\u70ED\uFF1B\u9ED8\u8BA4\u7528\u4E8E Kimi\uFF0820/25 \u5206\u949F\uFF09\uFF0C\u5176\u4ED6\u7EBF\u8DEF\u9700\u660E\u786E TTL \u5E76\u5728 promptCacheOverrides \u4E2D\u663E\u5F0F\u542F\u7528\u3002";
|
|
9
10
|
export interface CacheWaitSession {
|
|
10
11
|
readonly id: string;
|
|
11
12
|
requestHeader?(): {
|
|
@@ -43,8 +44,10 @@ export interface CacheWaitOptions {
|
|
|
43
44
|
readonly now?: () => number;
|
|
44
45
|
readonly timer?: CacheWaitTimer;
|
|
45
46
|
readonly agents?: CacheWaitAgents;
|
|
46
|
-
readonly activity?: (sessionId: string) => CacheWaitActivity | undefined;
|
|
47
|
+
readonly activity?: (sessionId: string, provider?: string) => CacheWaitActivity | undefined;
|
|
47
48
|
readonly kimiSession?: (session: CacheWaitSession) => boolean;
|
|
49
|
+
/** Deployment policy overrides; unknown providers remain inert. */
|
|
50
|
+
readonly overrides?: Readonly<Record<string, PromptCacheOverride>>;
|
|
48
51
|
readonly logger?: CacheWaitLogger;
|
|
49
52
|
readonly decisionMs?: number;
|
|
50
53
|
readonly ttlMs?: number;
|
|
@@ -113,7 +116,6 @@ export declare class KimiCacheWaitController {
|
|
|
113
116
|
private readonly warmup;
|
|
114
117
|
private readonly logger?;
|
|
115
118
|
private readonly decisionMs;
|
|
116
|
-
private readonly ttlMs;
|
|
117
119
|
private readonly minWarmupTokens;
|
|
118
120
|
private disposed;
|
|
119
121
|
constructor(options?: CacheWaitOptions);
|
|
@@ -132,7 +134,7 @@ export declare class KimiCacheWaitController {
|
|
|
132
134
|
private dropState;
|
|
133
135
|
private removeChild;
|
|
134
136
|
private clearTimer;
|
|
135
|
-
private
|
|
137
|
+
private providerForSession;
|
|
136
138
|
private isWarmupEnabled;
|
|
137
139
|
private reconcile;
|
|
138
140
|
}
|