@klarkxy/dsh-current-title 0.3.1 → 0.3.3
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.md +7 -4
- package/docs/README.zh-CN.md +8 -5
- package/lib/client.inner.cjs +965 -280
- package/lib/client.inner.cjs.map +1 -1
- package/lib/client.js +965 -280
- package/lib/contracts.d.ts +53 -3
- package/lib/contracts.js +2 -55
- package/lib/contracts2.d.ts +2 -0
- package/lib/contracts2.js +105 -0
- package/lib/contracts2.js.map +1 -0
- package/lib/index.d.ts +5 -3
- package/lib/index.js +904 -11
- package/lib/index.js.map +1 -1
- package/package.json +8 -5
- package/lib/contracts.js.map +0 -1
package/lib/contracts.d.ts
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ContextFormed } from "@deepseek-ai/dsh-llm";
|
|
2
|
+
//#region ../dsh-model-route/src/route.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Shared model-route value contract.
|
|
5
|
+
*
|
|
6
|
+
* A feature plugin stores its model override as a ModelRoute on its own
|
|
7
|
+
* settings page. Empty provider/model means "follow the host default model".
|
|
8
|
+
* Pure and browser-safe: no cordis, no React, no schema library.
|
|
9
|
+
*/
|
|
10
|
+
/** A concrete provider model a feature call should use. */
|
|
11
|
+
interface ModelRoute {
|
|
12
|
+
provider: string;
|
|
13
|
+
model: string;
|
|
14
|
+
reasoningEffort?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Empty route: no explicit model, the feature follows the host default. */
|
|
17
|
+
declare function defaultModelRoute(): ModelRoute;
|
|
18
|
+
/**
|
|
19
|
+
* Coerce a stored value into a ModelRoute. Anything malformed collapses to the
|
|
20
|
+
* empty route, matching the per-plugin normalizers this contract replaces.
|
|
21
|
+
*/
|
|
22
|
+
declare function normalizeModelRoute(value: unknown): ModelRoute;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region ../dsh-plugin-kit/src/contracts.d.ts
|
|
25
|
+
/** Public, browser-safe contracts. Host implementations stay in their owning packages. */
|
|
26
|
+
type ProducerSourceKind = `plugin:${string}`;
|
|
27
|
+
type ProducerMessageSource = {
|
|
28
|
+
kind: ProducerSourceKind;
|
|
29
|
+
plugin: string;
|
|
30
|
+
} & ContextFormed;
|
|
31
|
+
/**
|
|
32
|
+
* V4 sessions persist the producing extension in `kind`; the retired generic
|
|
33
|
+
* `plugin` wrapper is not admitted. Each feature plugin declares its own kind.
|
|
34
|
+
*/
|
|
35
|
+
declare module '@deepseek-ai/dsh-llm' {
|
|
36
|
+
interface MessageSourceMap {
|
|
37
|
+
[kind: ProducerSourceKind]: ProducerMessageSource;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
type RpcResult<T = unknown> = {
|
|
41
|
+
ok: true;
|
|
42
|
+
value: T;
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
error: {
|
|
46
|
+
code: string;
|
|
47
|
+
message: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
3
51
|
//#region src/contracts.d.ts
|
|
4
52
|
declare const PLUGIN_NAME = "@klarkxy/dsh-current-title";
|
|
5
53
|
declare const FEATURE_ID = "current-title";
|
|
@@ -8,6 +56,8 @@ declare const PURPOSE_ID = "current-title.generate";
|
|
|
8
56
|
declare const RPC_CHANNEL = "/dsh-current-title";
|
|
9
57
|
declare const TITLE_CLIENT_SERVICE = "dshCurrentTitleClient";
|
|
10
58
|
declare const PROMPT_VERSION = "current-title.v2";
|
|
59
|
+
/** Feature id stamped on the auxiliary-context envelope for this call. */
|
|
60
|
+
declare const TITLE_CALL_FEATURE = "session-title";
|
|
11
61
|
declare const SCHEMA_VERSION = "title-json.v1";
|
|
12
62
|
declare const CONTRACT_VERSION = 1;
|
|
13
63
|
declare const SETTINGS_KEY = "current";
|
|
@@ -86,5 +136,5 @@ declare function normalizePrompt(value: unknown): string;
|
|
|
86
136
|
declare function defaultGenerateConfig(locale?: TitleLocaleMode): GenerateConfig;
|
|
87
137
|
declare function isTitleLocaleMode(value: unknown): value is TitleLocaleMode;
|
|
88
138
|
//#endregion
|
|
89
|
-
export {
|
|
139
|
+
export { TitleSupport as A, TitleLocaleMode as C, TitleSnapshot as D, TitleSettings as E, normalizePrompt as F, RpcResult as I, defaultModelRoute as L, defaultSettings as M, isTitleLocaleMode as N, TitleSourceKind as O, normalizeCadence as P, normalizeModelRoute as R, TitleClientMarker as S, TitleModelRoute as T, SCHEMA_VERSION as _, DEFAULT_MAX_TITLE_BYTES as a, TITLE_CLIENT_SERVICE as b, DEFAULT_TIMEOUT_MS as c, MAX_PROMPT_CHARS as d, PLUGIN_NAME as f, RPC_CHANNEL as g, PURPOSE_ID as h, DEFAULT_MAX_RECENT_MESSAGES as i, defaultGenerateConfig as j, TitleStatus as k, FEATURE_ID as l, PROVIDER_ID as m, DEFAULT_MAX_INPUT_BYTES as n, DEFAULT_TARGET_CJK as o, PROMPT_VERSION as p, DEFAULT_MAX_OUTPUT_TOKENS as r, DEFAULT_TARGET_WORDS as s, CONTRACT_VERSION as t, GenerateConfig as u, SETTINGS_KEY as v, TitleMessage as w, TitleCadence as x, TITLE_CALL_FEATURE as y };
|
|
90
140
|
//# sourceMappingURL=contracts.d.ts.map
|
package/lib/contracts.js
CHANGED
|
@@ -1,55 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const PLUGIN_NAME = "@klarkxy/dsh-current-title";
|
|
4
|
-
const FEATURE_ID = "current-title";
|
|
5
|
-
const PROVIDER_ID = "@klarkxy/dsh-current-title";
|
|
6
|
-
const PURPOSE_ID = "current-title.generate";
|
|
7
|
-
const RPC_CHANNEL = "/dsh-current-title";
|
|
8
|
-
const TITLE_CLIENT_SERVICE = "dshCurrentTitleClient";
|
|
9
|
-
const PROMPT_VERSION = "current-title.v2";
|
|
10
|
-
const SCHEMA_VERSION = "title-json.v1";
|
|
11
|
-
const CONTRACT_VERSION = 1;
|
|
12
|
-
const SETTINGS_KEY = "current";
|
|
13
|
-
const MAX_PROMPT_CHARS = 4e3;
|
|
14
|
-
const DEFAULT_MAX_RECENT_MESSAGES = 8;
|
|
15
|
-
const DEFAULT_TARGET_WORDS = 5;
|
|
16
|
-
const DEFAULT_TARGET_CJK = 10;
|
|
17
|
-
const DEFAULT_MAX_INPUT_BYTES = 4096;
|
|
18
|
-
const DEFAULT_MAX_OUTPUT_TOKENS = 256;
|
|
19
|
-
const DEFAULT_TIMEOUT_MS = 6e4;
|
|
20
|
-
const DEFAULT_MAX_TITLE_BYTES = 80;
|
|
21
|
-
function defaultSettings(locale = "auto") {
|
|
22
|
-
return {
|
|
23
|
-
revision: 0,
|
|
24
|
-
locale,
|
|
25
|
-
prompt: "",
|
|
26
|
-
model: defaultModelRoute(),
|
|
27
|
-
cadence: "all-prompts"
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function normalizeCadence(value) {
|
|
31
|
-
return value === "first-prompt" ? "first-prompt" : "all-prompts";
|
|
32
|
-
}
|
|
33
|
-
function normalizePrompt(value) {
|
|
34
|
-
if (typeof value !== "string") return "";
|
|
35
|
-
return value.replace(/\u0000/gu, "").trim().slice(0, MAX_PROMPT_CHARS);
|
|
36
|
-
}
|
|
37
|
-
function defaultGenerateConfig(locale = "auto") {
|
|
38
|
-
return {
|
|
39
|
-
maxRecentMessages: 8,
|
|
40
|
-
locale,
|
|
41
|
-
targetWords: 5,
|
|
42
|
-
targetCjkCharacters: 10,
|
|
43
|
-
maxInputBytes: DEFAULT_MAX_INPUT_BYTES,
|
|
44
|
-
maxOutputTokens: 256,
|
|
45
|
-
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
46
|
-
maxTitleBytes: 80
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
function isTitleLocaleMode(value) {
|
|
50
|
-
return value === "auto" || value === "zh" || value === "en";
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
|
-
export { CONTRACT_VERSION, DEFAULT_MAX_INPUT_BYTES, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_MAX_RECENT_MESSAGES, DEFAULT_MAX_TITLE_BYTES, DEFAULT_TARGET_CJK, DEFAULT_TARGET_WORDS, DEFAULT_TIMEOUT_MS, FEATURE_ID, MAX_PROMPT_CHARS, PLUGIN_NAME, PROMPT_VERSION, PROVIDER_ID, PURPOSE_ID, RPC_CHANNEL, SCHEMA_VERSION, SETTINGS_KEY, TITLE_CLIENT_SERVICE, defaultGenerateConfig, defaultModelRoute, defaultSettings, isTitleLocaleMode, normalizeCadence, normalizeModelRoute, normalizePrompt };
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=contracts.js.map
|
|
1
|
+
import { C as normalizeCadence, D as normalizeModelRoute, S as isTitleLocaleMode, T as defaultModelRoute, _ as SETTINGS_KEY, a as DEFAULT_MAX_TITLE_BYTES, b as defaultGenerateConfig, c as DEFAULT_TIMEOUT_MS, d as PLUGIN_NAME, f as PROMPT_VERSION, g as SCHEMA_VERSION, h as RPC_CHANNEL, i as DEFAULT_MAX_RECENT_MESSAGES, l as FEATURE_ID, m as PURPOSE_ID, n as DEFAULT_MAX_INPUT_BYTES, o as DEFAULT_TARGET_CJK, p as PROVIDER_ID, r as DEFAULT_MAX_OUTPUT_TOKENS, s as DEFAULT_TARGET_WORDS, t as CONTRACT_VERSION, u as MAX_PROMPT_CHARS, v as TITLE_CALL_FEATURE, w as normalizePrompt, x as defaultSettings, y as TITLE_CLIENT_SERVICE } from "./contracts2.js";
|
|
2
|
+
export { CONTRACT_VERSION, DEFAULT_MAX_INPUT_BYTES, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_MAX_RECENT_MESSAGES, DEFAULT_MAX_TITLE_BYTES, DEFAULT_TARGET_CJK, DEFAULT_TARGET_WORDS, DEFAULT_TIMEOUT_MS, FEATURE_ID, MAX_PROMPT_CHARS, PLUGIN_NAME, PROMPT_VERSION, PROVIDER_ID, PURPOSE_ID, RPC_CHANNEL, SCHEMA_VERSION, SETTINGS_KEY, TITLE_CALL_FEATURE, TITLE_CLIENT_SERVICE, defaultGenerateConfig, defaultModelRoute, defaultSettings, isTitleLocaleMode, normalizeCadence, normalizeModelRoute, normalizePrompt };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as TitleSupport, C as TitleLocaleMode, D as TitleSnapshot, E as TitleSettings, F as normalizePrompt, I as RpcResult, L as defaultModelRoute, M as defaultSettings, N as isTitleLocaleMode, O as TitleSourceKind, P as normalizeCadence, R as normalizeModelRoute, S as TitleClientMarker, T as TitleModelRoute, _ as SCHEMA_VERSION, a as DEFAULT_MAX_TITLE_BYTES, b as TITLE_CLIENT_SERVICE, c as DEFAULT_TIMEOUT_MS, d as MAX_PROMPT_CHARS, f as PLUGIN_NAME, g as RPC_CHANNEL, h as PURPOSE_ID, i as DEFAULT_MAX_RECENT_MESSAGES, j as defaultGenerateConfig, k as TitleStatus, l as FEATURE_ID, m as PROVIDER_ID, n as DEFAULT_MAX_INPUT_BYTES, o as DEFAULT_TARGET_CJK, p as PROMPT_VERSION, r as DEFAULT_MAX_OUTPUT_TOKENS, s as DEFAULT_TARGET_WORDS, t as CONTRACT_VERSION, u as GenerateConfig, v as SETTINGS_KEY, w as TitleMessage, x as TitleCadence, y as TITLE_CALL_FEATURE } from "./contracts.js";
|
|
2
|
+
export { CONTRACT_VERSION, DEFAULT_MAX_INPUT_BYTES, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_MAX_RECENT_MESSAGES, DEFAULT_MAX_TITLE_BYTES, DEFAULT_TARGET_CJK, DEFAULT_TARGET_WORDS, DEFAULT_TIMEOUT_MS, FEATURE_ID, GenerateConfig, MAX_PROMPT_CHARS, PLUGIN_NAME, PROMPT_VERSION, PROVIDER_ID, PURPOSE_ID, RPC_CHANNEL, type RpcResult, SCHEMA_VERSION, SETTINGS_KEY, TITLE_CALL_FEATURE, TITLE_CLIENT_SERVICE, TitleCadence, TitleClientMarker, TitleLocaleMode, TitleMessage, TitleModelRoute, TitleSettings, TitleSnapshot, TitleSourceKind, TitleStatus, TitleSupport, defaultGenerateConfig, defaultModelRoute, defaultSettings, isTitleLocaleMode, normalizeCadence, normalizeModelRoute, normalizePrompt };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//#region ../dsh-model-route/src/route.ts
|
|
2
|
+
/** Empty route: no explicit model, the feature follows the host default. */
|
|
3
|
+
function defaultModelRoute() {
|
|
4
|
+
return {
|
|
5
|
+
provider: "",
|
|
6
|
+
model: ""
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const MAX_ID_CHARS = 250;
|
|
10
|
+
const MAX_EFFORT_CHARS = 80;
|
|
11
|
+
function asText(value) {
|
|
12
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Coerce a stored value into a ModelRoute. Anything malformed collapses to the
|
|
16
|
+
* empty route, matching the per-plugin normalizers this contract replaces.
|
|
17
|
+
*/
|
|
18
|
+
function normalizeModelRoute(value) {
|
|
19
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return defaultModelRoute();
|
|
20
|
+
const row = value;
|
|
21
|
+
const provider = asText(row.provider) ?? "";
|
|
22
|
+
const model = asText(row.model) ?? "";
|
|
23
|
+
const effort = asText(row.reasoningEffort);
|
|
24
|
+
if (!provider || !model || provider.length > MAX_ID_CHARS || model.length > MAX_ID_CHARS) return defaultModelRoute();
|
|
25
|
+
return effort && effort.length <= MAX_EFFORT_CHARS ? {
|
|
26
|
+
provider,
|
|
27
|
+
model,
|
|
28
|
+
reasoningEffort: effort
|
|
29
|
+
} : {
|
|
30
|
+
provider,
|
|
31
|
+
model
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** The override to actually call with: undefined when the route is empty. */
|
|
35
|
+
function modelRouteOverride(route) {
|
|
36
|
+
const provider = route?.provider?.trim();
|
|
37
|
+
const model = route?.model?.trim();
|
|
38
|
+
if (!provider || !model) return void 0;
|
|
39
|
+
const effort = route?.reasoningEffort?.trim();
|
|
40
|
+
return effort ? {
|
|
41
|
+
provider,
|
|
42
|
+
model,
|
|
43
|
+
reasoningEffort: effort
|
|
44
|
+
} : {
|
|
45
|
+
provider,
|
|
46
|
+
model
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/contracts.ts
|
|
51
|
+
const PLUGIN_NAME = "@klarkxy/dsh-current-title";
|
|
52
|
+
const FEATURE_ID = "current-title";
|
|
53
|
+
const PROVIDER_ID = "@klarkxy/dsh-current-title";
|
|
54
|
+
const PURPOSE_ID = "current-title.generate";
|
|
55
|
+
const RPC_CHANNEL = "/dsh-current-title";
|
|
56
|
+
const TITLE_CLIENT_SERVICE = "dshCurrentTitleClient";
|
|
57
|
+
const PROMPT_VERSION = "current-title.v2";
|
|
58
|
+
/** Feature id stamped on the auxiliary-context envelope for this call. */
|
|
59
|
+
const TITLE_CALL_FEATURE = "session-title";
|
|
60
|
+
const SCHEMA_VERSION = "title-json.v1";
|
|
61
|
+
const CONTRACT_VERSION = 1;
|
|
62
|
+
const SETTINGS_KEY = "current";
|
|
63
|
+
const MAX_PROMPT_CHARS = 4e3;
|
|
64
|
+
const DEFAULT_MAX_RECENT_MESSAGES = 8;
|
|
65
|
+
const DEFAULT_TARGET_WORDS = 5;
|
|
66
|
+
const DEFAULT_TARGET_CJK = 10;
|
|
67
|
+
const DEFAULT_MAX_INPUT_BYTES = 4096;
|
|
68
|
+
const DEFAULT_MAX_OUTPUT_TOKENS = 256;
|
|
69
|
+
const DEFAULT_TIMEOUT_MS = 6e4;
|
|
70
|
+
const DEFAULT_MAX_TITLE_BYTES = 80;
|
|
71
|
+
function defaultSettings(locale = "auto") {
|
|
72
|
+
return {
|
|
73
|
+
revision: 0,
|
|
74
|
+
locale,
|
|
75
|
+
prompt: "",
|
|
76
|
+
model: defaultModelRoute(),
|
|
77
|
+
cadence: "all-prompts"
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function normalizeCadence(value) {
|
|
81
|
+
return value === "first-prompt" ? "first-prompt" : "all-prompts";
|
|
82
|
+
}
|
|
83
|
+
function normalizePrompt(value) {
|
|
84
|
+
if (typeof value !== "string") return "";
|
|
85
|
+
return value.replace(/\u0000/gu, "").trim().slice(0, MAX_PROMPT_CHARS);
|
|
86
|
+
}
|
|
87
|
+
function defaultGenerateConfig(locale = "auto") {
|
|
88
|
+
return {
|
|
89
|
+
maxRecentMessages: 8,
|
|
90
|
+
locale,
|
|
91
|
+
targetWords: 5,
|
|
92
|
+
targetCjkCharacters: 10,
|
|
93
|
+
maxInputBytes: DEFAULT_MAX_INPUT_BYTES,
|
|
94
|
+
maxOutputTokens: 256,
|
|
95
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
96
|
+
maxTitleBytes: 80
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function isTitleLocaleMode(value) {
|
|
100
|
+
return value === "auto" || value === "zh" || value === "en";
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { normalizeCadence as C, normalizeModelRoute as D, modelRouteOverride as E, isTitleLocaleMode as S, defaultModelRoute as T, SETTINGS_KEY as _, DEFAULT_MAX_TITLE_BYTES as a, defaultGenerateConfig as b, DEFAULT_TIMEOUT_MS as c, PLUGIN_NAME as d, PROMPT_VERSION as f, SCHEMA_VERSION as g, RPC_CHANNEL as h, DEFAULT_MAX_RECENT_MESSAGES as i, FEATURE_ID as l, PURPOSE_ID as m, DEFAULT_MAX_INPUT_BYTES as n, DEFAULT_TARGET_CJK as o, PROVIDER_ID as p, DEFAULT_MAX_OUTPUT_TOKENS as r, DEFAULT_TARGET_WORDS as s, CONTRACT_VERSION as t, MAX_PROMPT_CHARS as u, TITLE_CALL_FEATURE as v, normalizePrompt as w, defaultSettings as x, TITLE_CLIENT_SERVICE as y };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=contracts2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts2.js","names":[],"sources":["../../dsh-model-route/src/route.ts","../src/contracts.ts"],"sourcesContent":["/**\n * Shared model-route value contract.\n *\n * A feature plugin stores its model override as a ModelRoute on its own\n * settings page. Empty provider/model means \"follow the host default model\".\n * Pure and browser-safe: no cordis, no React, no schema library.\n */\n\n/** A concrete provider model a feature call should use. */\nexport interface ModelRoute {\n provider: string\n model: string\n reasoningEffort?: string\n}\n\n/** Empty route: no explicit model, the feature follows the host default. */\nexport function defaultModelRoute(): ModelRoute {\n return { provider: '', model: '' }\n}\n\n/** Structural check: both id fields are strings (either may be empty). */\nexport function isModelRouteValue(value: unknown): value is ModelRoute {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return false\n const row = value as Record<string, unknown>\n return typeof row.provider === 'string' && typeof row.model === 'string'\n}\n\nconst MAX_ID_CHARS = 250\nconst MAX_EFFORT_CHARS = 80\n\nfunction asText(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\n/**\n * Coerce a stored value into a ModelRoute. Anything malformed collapses to the\n * empty route, matching the per-plugin normalizers this contract replaces.\n */\nexport function normalizeModelRoute(value: unknown): ModelRoute {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return defaultModelRoute()\n const row = value as Record<string, unknown>\n const provider = asText(row.provider) ?? ''\n const model = asText(row.model) ?? ''\n const effort = asText(row.reasoningEffort)\n if (!provider || !model || provider.length > MAX_ID_CHARS || model.length > MAX_ID_CHARS) return defaultModelRoute()\n return effort && effort.length <= MAX_EFFORT_CHARS ? { provider, model, reasoningEffort: effort } : { provider, model }\n}\n\n/** The override to actually call with: undefined when the route is empty. */\nexport function modelRouteOverride(route: ModelRoute | undefined): ModelRoute | undefined {\n const provider = route?.provider?.trim()\n const model = route?.model?.trim()\n if (!provider || !model) return undefined\n const effort = route?.reasoningEffort?.trim()\n return effort ? { provider, model, reasoningEffort: effort } : { provider, model }\n}\n\nconst KEY_SEPARATOR = '\\u001f'\n\n/** Stable key for one route, safe to use as a select-option value. */\nexport function modelRouteKey(provider: string, model: string): string {\n return provider && model ? `${provider}${KEY_SEPARATOR}${model}` : ''\n}\n\n/** Inverse of modelRouteKey; undefined for malformed keys. */\nexport function parseModelRouteKey(value: string): { provider: string; model: string } | undefined {\n const index = value.indexOf(KEY_SEPARATOR)\n if (index <= 0) return undefined\n const provider = value.slice(0, index)\n const model = value.slice(index + KEY_SEPARATOR.length)\n if (!provider || !model) return undefined\n return { provider, model }\n}\n\n/** True when both routes name the same target; two empty routes are equal. */\nexport function sameModelRoute(a: ModelRoute | undefined, b: ModelRoute | undefined): boolean {\n const left = modelRouteOverride(a)\n const right = modelRouteOverride(b)\n if (!left || !right) return !left === !right\n return left.provider === right.provider && left.model === right.model\n && (left.reasoningEffort ?? '') === (right.reasoningEffort ?? '')\n}\n","import { defaultModelRoute, normalizeModelRoute, type ModelRoute } from '@klarkxy/dsh-model-route'\nexport { defaultModelRoute, normalizeModelRoute }\n\n/** Browser-safe contracts. Shared RPC/result types stay on @klarkxy/dsh-plugin-kit. */\nexport type { RpcResult } from '@klarkxy/dsh-plugin-kit/contracts'\n\nexport const PLUGIN_NAME = '@klarkxy/dsh-current-title'\nexport const FEATURE_ID = 'current-title'\nexport const PROVIDER_ID = '@klarkxy/dsh-current-title'\nexport const PURPOSE_ID = 'current-title.generate'\nexport const RPC_CHANNEL = '/dsh-current-title'\nexport const TITLE_CLIENT_SERVICE = 'dshCurrentTitleClient'\nexport const PROMPT_VERSION = 'current-title.v2'\n/** Feature id stamped on the auxiliary-context envelope for this call. */\nexport const TITLE_CALL_FEATURE = 'session-title'\nexport const SCHEMA_VERSION = 'title-json.v1'\nexport const CONTRACT_VERSION = 1\nexport const SETTINGS_KEY = 'current'\nexport const MAX_PROMPT_CHARS = 4000\n\nexport const DEFAULT_MAX_RECENT_MESSAGES = 8\nexport const DEFAULT_TARGET_WORDS = 5\nexport const DEFAULT_TARGET_CJK = 10\nexport const DEFAULT_MAX_INPUT_BYTES = 4096\nexport const DEFAULT_MAX_OUTPUT_TOKENS = 256\nexport const DEFAULT_TIMEOUT_MS = 60_000\nexport const DEFAULT_MAX_TITLE_BYTES = 80\n\nexport type TitleLocaleMode = 'auto' | 'zh' | 'en'\nexport type TitleSourceKind = 'fallback' | 'provider' | 'user'\n/** Automatic generation cadence: every eligible message, or only the first. */\nexport type TitleCadence = 'all-prompts' | 'first-prompt'\n\nexport interface TitleMessage {\n readonly seq: number\n readonly text: string\n}\n\nexport interface TitleSnapshot {\n readonly title: string\n readonly messageSeqs: readonly number[]\n readonly source: { readonly kind: TitleSourceKind; readonly provider?: string }\n readonly eventSeq: number\n readonly updatedAt: number\n}\n\n/**\n * Empty provider and model means the shared weak role. Both must be set together.\n * No title-only fields: the stored value is the shared ModelRoute (250/80 caps\n * live in @klarkxy/dsh-model-route). The alias keeps the title-specific name.\n */\nexport type TitleModelRoute = ModelRoute\n\nexport interface TitleSettings {\n revision: number\n locale: TitleLocaleMode\n /** Empty keeps the built-in title instruction. */\n prompt: string\n model: TitleModelRoute\n cadence: TitleCadence\n}\n\nexport interface TitleSupport {\n nativeOwner: string | null\n weOwn: boolean\n limitation?: string\n}\n\nexport interface TitleStatus {\n settings: TitleSettings\n support: TitleSupport\n session?: {\n sessionId: string\n title?: string\n sourceKind?: TitleSourceKind\n generating: boolean\n pinned: boolean\n }\n}\n\nexport interface TitleClientMarker {\n active: boolean\n}\n\nexport interface GenerateConfig {\n readonly maxRecentMessages: number\n readonly locale: TitleLocaleMode\n readonly targetWords: number\n readonly targetCjkCharacters: number\n readonly maxInputBytes: number\n readonly maxOutputTokens: number\n readonly timeoutMs: number\n readonly maxTitleBytes: number\n}\n\nexport function defaultSettings(locale: TitleLocaleMode = 'auto'): TitleSettings {\n return { revision: 0, locale, prompt: '', model: defaultModelRoute(), cadence: 'all-prompts' }\n}\n\nexport function normalizeCadence(value: unknown): TitleCadence {\n return value === 'first-prompt' ? 'first-prompt' : 'all-prompts'\n}\n\nexport function normalizePrompt(value: unknown): string {\n if (typeof value !== 'string') return ''\n return value.replace(/\\u0000/gu, '').trim().slice(0, MAX_PROMPT_CHARS)\n}\n\nexport function defaultGenerateConfig(locale: TitleLocaleMode = 'auto'): GenerateConfig {\n return {\n maxRecentMessages: DEFAULT_MAX_RECENT_MESSAGES,\n locale,\n targetWords: DEFAULT_TARGET_WORDS,\n targetCjkCharacters: DEFAULT_TARGET_CJK,\n maxInputBytes: DEFAULT_MAX_INPUT_BYTES,\n maxOutputTokens: DEFAULT_MAX_OUTPUT_TOKENS,\n timeoutMs: DEFAULT_TIMEOUT_MS,\n maxTitleBytes: DEFAULT_MAX_TITLE_BYTES,\n }\n}\n\nexport function isTitleLocaleMode(value: unknown): value is TitleLocaleMode {\n return value === 'auto' || value === 'zh' || value === 'en'\n}\n"],"mappings":";;AAgBA,SAAgB,oBAAgC;CAC9C,OAAO;EAAE,UAAU;EAAI,OAAO;CAAG;AACnC;AASA,MAAM,eAAe;AACrB,MAAM,mBAAmB;AAEzB,SAAS,OAAO,OAAoC;CAClD,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,KAAA;AACpE;;;;;AAMA,SAAgB,oBAAoB,OAA4B;CAC9D,IAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO,kBAAkB;CAC1F,MAAM,MAAM;CACZ,MAAM,WAAW,OAAO,IAAI,QAAQ,KAAK;CACzC,MAAM,QAAQ,OAAO,IAAI,KAAK,KAAK;CACnC,MAAM,SAAS,OAAO,IAAI,eAAe;CACzC,IAAI,CAAC,YAAY,CAAC,SAAS,SAAS,SAAS,gBAAgB,MAAM,SAAS,cAAc,OAAO,kBAAkB;CACnH,OAAO,UAAU,OAAO,UAAU,mBAAmB;EAAE;EAAU;EAAO,iBAAiB;CAAO,IAAI;EAAE;EAAU;CAAM;AACxH;;AAGA,SAAgB,mBAAmB,OAAuD;CACxF,MAAM,WAAW,OAAO,UAAU,KAAK;CACvC,MAAM,QAAQ,OAAO,OAAO,KAAK;CACjC,IAAI,CAAC,YAAY,CAAC,OAAO,OAAO,KAAA;CAChC,MAAM,SAAS,OAAO,iBAAiB,KAAK;CAC5C,OAAO,SAAS;EAAE;EAAU;EAAO,iBAAiB;CAAO,IAAI;EAAE;EAAU;CAAM;AACnF;;;ACjDA,MAAa,cAAc;AAC3B,MAAa,aAAa;AAC1B,MAAa,cAAc;AAC3B,MAAa,aAAa;AAC1B,MAAa,cAAc;AAC3B,MAAa,uBAAuB;AACpC,MAAa,iBAAiB;;AAE9B,MAAa,qBAAqB;AAClC,MAAa,iBAAiB;AAC9B,MAAa,mBAAmB;AAChC,MAAa,eAAe;AAC5B,MAAa,mBAAmB;AAEhC,MAAa,8BAA8B;AAC3C,MAAa,uBAAuB;AACpC,MAAa,qBAAqB;AAClC,MAAa,0BAA0B;AACvC,MAAa,4BAA4B;AACzC,MAAa,qBAAqB;AAClC,MAAa,0BAA0B;AAqEvC,SAAgB,gBAAgB,SAA0B,QAAuB;CAC/E,OAAO;EAAE,UAAU;EAAG;EAAQ,QAAQ;EAAI,OAAO,kBAAkB;EAAG,SAAS;CAAc;AAC/F;AAEA,SAAgB,iBAAiB,OAA8B;CAC7D,OAAO,UAAU,iBAAiB,iBAAiB;AACrD;AAEA,SAAgB,gBAAgB,OAAwB;CACtD,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,MAAM,QAAQ,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,gBAAgB;AACvE;AAEA,SAAgB,sBAAsB,SAA0B,QAAwB;CACtF,OAAO;EACL,mBAAA;EACA;EACA,aAAA;EACA,qBAAA;EACA,eAAe;EACf,iBAAA;EACA,WAAW;EACX,eAAA;CACF;AACF;AAEA,SAAgB,kBAAkB,OAA0C;CAC1E,OAAO,UAAU,UAAU,UAAU,QAAQ,UAAU;AACzD"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "@
|
|
3
|
-
import { LlmTextCaller } from "@klarkxy/dsh-plugin-kit";
|
|
1
|
+
import { A as TitleSupport, C as TitleLocaleMode$1, D as TitleSnapshot, E as TitleSettings, k as TitleStatus, w as TitleMessage } from "./contracts.js";
|
|
2
|
+
import { LlmRuntime } from "@deepseek-ai/dsh-llm";
|
|
4
3
|
import { Context } from "@deepseek-ai/cordis";
|
|
4
|
+
//#region ../dsh-plugin-kit/src/llm-call.d.ts
|
|
5
|
+
type LlmTextCaller = Pick<LlmRuntime, 'prepareCall' | 'resolveCallConfig'>;
|
|
6
|
+
//#endregion
|
|
5
7
|
//#region src/messages.d.ts
|
|
6
8
|
interface SessionEventLike {
|
|
7
9
|
readonly type: string;
|