dsh-thinking-lang 1.0.6 → 1.0.7
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/DEVELOPMENT.md +156 -0
- package/README.md +24 -178
- package/assets/plugin-config.png +0 -0
- package/client/client.js +231 -51
- package/client/client.raw.cjs +231 -51
- package/lib/core.d.ts +25 -4
- package/lib/core.js +43 -6
- package/lib/index.js +21 -13
- package/package.json +2 -1
- package/src/client/index.ts +32 -1
- package/src/client/locales.ts +37 -61
- package/src/client/panel.ts +232 -72
- package/src/core.ts +53 -6
- package/src/index.ts +23 -13
package/src/index.ts
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
* 注入形态(设计理由见 README):
|
|
7
7
|
*
|
|
8
8
|
* section order 1 → the authoritative rule, once per session
|
|
9
|
-
* pre-step step 1 → a short reminder, at most once per turn (
|
|
9
|
+
* pre-step step 1 → a short reminder, at most once per turn (interval configurable, default 30 min)
|
|
10
10
|
*
|
|
11
11
|
* section order 1 → 权威规则,每会话组装一次
|
|
12
|
-
* pre-step step 1 →
|
|
12
|
+
* pre-step step 1 → 短提醒,每轮最多一次(间隔可配置,默认 30 分钟)
|
|
13
13
|
*
|
|
14
14
|
* The host context is described by a local structural interface rather than the
|
|
15
15
|
* `@deepseek-ai/cordis` type, so this package carries no DSH type dependency.
|
|
@@ -20,7 +20,10 @@ import { randomUUID } from "node:crypto";
|
|
|
20
20
|
import z from "@deepseek-ai/schemastery";
|
|
21
21
|
import {
|
|
22
22
|
AUTO,
|
|
23
|
+
DEFAULT_REMINDER_MINUTES,
|
|
23
24
|
FIELD_LANGUAGE,
|
|
25
|
+
FIELD_REMINDER,
|
|
26
|
+
REMINDER_OFF,
|
|
24
27
|
SELECTABLE_TAGS,
|
|
25
28
|
SETTINGS_NAMESPACE,
|
|
26
29
|
type Reader,
|
|
@@ -28,6 +31,7 @@ import {
|
|
|
28
31
|
effectiveCode,
|
|
29
32
|
nativeNameFor,
|
|
30
33
|
normalizeSettings,
|
|
34
|
+
reminderDelayMs,
|
|
31
35
|
reminderText,
|
|
32
36
|
sectionText
|
|
33
37
|
} from "./core.js";
|
|
@@ -47,9 +51,6 @@ export const inject: string[] = [];
|
|
|
47
51
|
*/
|
|
48
52
|
const SECTION_ORDER = 1;
|
|
49
53
|
|
|
50
|
-
/** Minimum milliseconds between two per-turn reminders in one session. / 同一会话中两次每轮提醒之间的最小毫秒数。 */
|
|
51
|
-
const REMINDER_INTERVAL_MS = 600_000;
|
|
52
|
-
|
|
53
54
|
/** Settings namespace holding the desktop UI locale. / 保存桌面 UI 语言的设置命名空间。 */
|
|
54
55
|
const LOCALE_NAMESPACE = "locale";
|
|
55
56
|
|
|
@@ -118,7 +119,10 @@ function labelled<T>(node: z<T>, label: string | undefined): z<T> {
|
|
|
118
119
|
*/
|
|
119
120
|
function buildSchema(): z<ThinkingSettings> {
|
|
120
121
|
const choices = [AUTO, ...SELECTABLE_TAGS].map((value) => labelled(z.const(value), nativeNameFor(value)));
|
|
121
|
-
return z.object({
|
|
122
|
+
return z.object({
|
|
123
|
+
[FIELD_LANGUAGE]: live(z.union(choices).default(AUTO)),
|
|
124
|
+
[FIELD_REMINDER]: live(z.number().default(DEFAULT_REMINDER_MINUTES))
|
|
125
|
+
});
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
/** Durable settings schema; the field defaults to {@link AUTO}. / 持久化设置 schema;字段默认为 {@link AUTO}。 */
|
|
@@ -261,13 +265,16 @@ function osLocale(): string | undefined {
|
|
|
261
265
|
}
|
|
262
266
|
|
|
263
267
|
/**
|
|
264
|
-
* Resolve the
|
|
265
|
-
*
|
|
268
|
+
* Resolve the configuration in effect for one prompt build.
|
|
269
|
+
* 为一次提示词构建解析出当前生效的配置。
|
|
266
270
|
*/
|
|
267
|
-
function
|
|
271
|
+
function currentSettings(reader: Reader): ThinkingSettings {
|
|
268
272
|
const settings = normalizeSettings(sectionOf(reader, SETTINGS_NAMESPACE));
|
|
269
273
|
const desktop = sectionOf(reader, LOCALE_NAMESPACE)?.[LOCALE_FIELD];
|
|
270
|
-
return
|
|
274
|
+
return {
|
|
275
|
+
...settings,
|
|
276
|
+
language: effectiveCode(settings, osLocale(), typeof desktop === "string" ? desktop : undefined)
|
|
277
|
+
};
|
|
271
278
|
}
|
|
272
279
|
|
|
273
280
|
/** One pre-step payload slice this entry reads. / 本入口读取的 pre-step 载荷切片。 */
|
|
@@ -332,7 +339,7 @@ export function apply(ctx: HostContext): void {
|
|
|
332
339
|
promptCtx.systemPrompt.section({
|
|
333
340
|
name: "app:tk-lang",
|
|
334
341
|
order: SECTION_ORDER,
|
|
335
|
-
text: () => sectionText(
|
|
342
|
+
text: () => sectionText(currentSettings(reader()).language)
|
|
336
343
|
});
|
|
337
344
|
|
|
338
345
|
// The reminder runs before the other pre-step listeners, so its message is
|
|
@@ -341,10 +348,13 @@ export function apply(ctx: HostContext): void {
|
|
|
341
348
|
promptCtx.on("agent/pre-step", async (payload, next) => {
|
|
342
349
|
const decision = await next();
|
|
343
350
|
if (decision.kind !== "enter" || payload.signal.aborted || payload.step !== 1) return decision;
|
|
351
|
+
const settings = currentSettings(reader());
|
|
352
|
+
const delay = reminderDelayMs(settings.reminderMinutes);
|
|
353
|
+
if (delay === REMINDER_OFF) return decision;
|
|
344
354
|
const now = Date.now();
|
|
345
355
|
const previous = lastReminderAt.get(payload.agent.session.id);
|
|
346
|
-
if (previous !== undefined && now - previous <
|
|
347
|
-
const text = reminderText(
|
|
356
|
+
if (delay > 0 && previous !== undefined && now - previous < delay) return decision;
|
|
357
|
+
const text = reminderText(settings.language);
|
|
348
358
|
if (text === "") return decision;
|
|
349
359
|
lastReminderAt.set(payload.agent.session.id, now);
|
|
350
360
|
return { ...decision, messages: [...decision.messages, reminderMessage(text)] };
|