dsh-client-auto-continue 0.9.0 → 0.10.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/README.md +19 -15
- package/README.zh.md +10 -6
- package/lib/client.js +71 -38
- package/lib/client.js.map +3 -3
- package/lib/index.js +72 -28
- package/lib/types/client/locales.d.ts +5 -5
- package/lib/types/index.d.ts +5 -1
- package/lib/types/shared/core.d.ts +22 -1
- package/package.json +2 -2
- package/src/client/index.ts +12 -1
- package/src/client/locales.ts +12 -1
- package/src/client/settings-card.tsx +6 -6
- package/src/host/engine.ts +46 -12
- package/src/index.ts +8 -6
- package/src/shared/core.ts +37 -11
package/src/shared/core.ts
CHANGED
|
@@ -6,8 +6,34 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session/types';
|
|
8
8
|
|
|
9
|
+
/** Supported UI/config locales. Any unknown browser locale falls back to Chinese. */
|
|
10
|
+
export type AutoContinueLocale = 'en' | 'zh';
|
|
11
|
+
|
|
12
|
+
/** Locale-owned defaults for the user-editable text fields. */
|
|
13
|
+
export const LOCALIZED_TEXT_DEFAULTS = {
|
|
14
|
+
zh: {
|
|
15
|
+
continueText: '继续',
|
|
16
|
+
continueTextMaxTokens: '继续',
|
|
17
|
+
guardPendingText: '(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)',
|
|
18
|
+
guardDoneText: '(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)',
|
|
19
|
+
loopText: '(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)',
|
|
20
|
+
},
|
|
21
|
+
en: {
|
|
22
|
+
continueText: 'Continue',
|
|
23
|
+
continueTextMaxTokens: 'Continue',
|
|
24
|
+
guardPendingText:
|
|
25
|
+
'(The previous tool "{tool}" may not have completed. Check its state before continuing and do not run it again.)',
|
|
26
|
+
guardDoneText:
|
|
27
|
+
'(The previous tool "{tool}" completed successfully. Result: {result}; do not run it again. Continue from there.)',
|
|
28
|
+
loopText:
|
|
29
|
+
'(You may be stuck in a loop. Stop repeating the last action and continue with a different approach.)',
|
|
30
|
+
},
|
|
31
|
+
} as const satisfies Record<AutoContinueLocale, Record<string, string>>;
|
|
32
|
+
|
|
9
33
|
/** The `auto-continue` settings section (all fields optional on the wire; the host schema carries defaults). */
|
|
10
34
|
export interface AutoContinueSettings {
|
|
35
|
+
/** Active browser/UI locale mirrored by the client. */
|
|
36
|
+
locale?: AutoContinueLocale;
|
|
11
37
|
/** Text automatically sent after an interruption. */
|
|
12
38
|
continueText?: string;
|
|
13
39
|
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
@@ -63,13 +89,11 @@ export interface AutoContinueSettings {
|
|
|
63
89
|
/** Fully resolved configuration (built-in defaults + user overrides). */
|
|
64
90
|
export type AutoContinueConfig = Required<AutoContinueSettings>;
|
|
65
91
|
|
|
66
|
-
/**
|
|
92
|
+
/** Effective built-in defaults; localized text fields use Chinese until a browser locale is mirrored. */
|
|
67
93
|
export const DEFAULT_CONFIG: AutoContinueConfig = {
|
|
68
|
-
|
|
69
|
-
|
|
94
|
+
locale: 'zh',
|
|
95
|
+
...LOCALIZED_TEXT_DEFAULTS.zh,
|
|
70
96
|
guardTools: true,
|
|
71
|
-
guardPendingText: '(上一步工具「{tool}」可能未完成, 先确认状态再继续, 不要重复执行)',
|
|
72
|
-
guardDoneText: '(上一步工具「{tool}」已完成, 结果: {result}; 不要重复执行, 直接继续)',
|
|
73
97
|
graceMs: 3000,
|
|
74
98
|
cooldownMs: 20000,
|
|
75
99
|
maxConsecutive: 3,
|
|
@@ -89,7 +113,6 @@ export const DEFAULT_CONFIG: AutoContinueConfig = {
|
|
|
89
113
|
loopShortCount: 12,
|
|
90
114
|
loopRepeatText: 4,
|
|
91
115
|
loopToolRepeat: 5,
|
|
92
|
-
loopText: '(检测到你可能陷入循环, 请停止重复刚才的动作, 换一种方式继续)',
|
|
93
116
|
};
|
|
94
117
|
|
|
95
118
|
function numberOr(value: unknown, fallback: number): number {
|
|
@@ -103,23 +126,26 @@ function booleanOr(value: unknown, fallback: boolean): boolean {
|
|
|
103
126
|
/** Resolve a (possibly partial / not-yet-loaded) settings section to a full config. */
|
|
104
127
|
export function resolveConfig(section: AutoContinueSettings | undefined): AutoContinueConfig {
|
|
105
128
|
const value = section ?? {};
|
|
129
|
+
const locale: AutoContinueLocale = value.locale === 'en' ? 'en' : 'zh';
|
|
130
|
+
const localized = LOCALIZED_TEXT_DEFAULTS[locale];
|
|
106
131
|
const text =
|
|
107
132
|
typeof value.continueText === 'string' && value.continueText.trim() !== ''
|
|
108
133
|
? value.continueText
|
|
109
|
-
:
|
|
134
|
+
: localized.continueText;
|
|
110
135
|
const maxTokensText =
|
|
111
136
|
typeof value.continueTextMaxTokens === 'string' && value.continueTextMaxTokens.trim() !== ''
|
|
112
137
|
? value.continueTextMaxTokens
|
|
113
|
-
:
|
|
138
|
+
: localized.continueTextMaxTokens;
|
|
114
139
|
const guardPendingText =
|
|
115
140
|
typeof value.guardPendingText === 'string' && value.guardPendingText.trim() !== ''
|
|
116
141
|
? value.guardPendingText
|
|
117
|
-
:
|
|
142
|
+
: localized.guardPendingText;
|
|
118
143
|
const guardDoneText =
|
|
119
144
|
typeof value.guardDoneText === 'string' && value.guardDoneText.trim() !== ''
|
|
120
145
|
? value.guardDoneText
|
|
121
|
-
:
|
|
146
|
+
: localized.guardDoneText;
|
|
122
147
|
return {
|
|
148
|
+
locale,
|
|
123
149
|
continueText: text,
|
|
124
150
|
continueTextMaxTokens: maxTokensText,
|
|
125
151
|
guardTools: booleanOr(value.guardTools, DEFAULT_CONFIG.guardTools),
|
|
@@ -150,7 +176,7 @@ export function resolveConfig(section: AutoContinueSettings | undefined): AutoCo
|
|
|
150
176
|
loopText:
|
|
151
177
|
typeof value.loopText === 'string' && value.loopText.trim() !== ''
|
|
152
178
|
? value.loopText
|
|
153
|
-
:
|
|
179
|
+
: localized.loopText,
|
|
154
180
|
};
|
|
155
181
|
}
|
|
156
182
|
|