dsh-client-auto-continue 0.17.1 → 0.17.2
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 +15 -0
- package/README.md +4 -4
- package/README.zh.md +6 -4
- package/docs/releases/v0.17.2.md +42 -0
- package/lib/client.js +9 -5
- package/lib/client.js.map +2 -2
- package/lib/index.js +7 -4
- package/lib/types/shared/core.d.ts +3 -2
- package/package.json +1 -1
- package/src/client/index.ts +4 -3
- package/src/client/settings-notifications.ts +2 -1
- package/src/index.ts +1 -1
- package/src/shared/core.ts +9 -5
package/lib/index.js
CHANGED
|
@@ -1119,6 +1119,9 @@ function foldRequestHeader(events, from) {
|
|
|
1119
1119
|
}
|
|
1120
1120
|
|
|
1121
1121
|
// src/shared/core.ts
|
|
1122
|
+
function resolveLocale(locale) {
|
|
1123
|
+
return typeof locale === "string" && /^zh(?:-|$)/i.test(locale) ? "zh" : "en";
|
|
1124
|
+
}
|
|
1122
1125
|
var isSessionMode = (value) => value === "default" || value === "off" || value === "recover" || value === "loop";
|
|
1123
1126
|
function sessionMode(modes, sessionId) {
|
|
1124
1127
|
return Object.prototype.hasOwnProperty.call(modes, sessionId) && isSessionMode(modes[sessionId]) ? modes[sessionId] : "default";
|
|
@@ -1146,8 +1149,8 @@ var LOCALIZED_TEXT_DEFAULTS = {
|
|
|
1146
1149
|
}
|
|
1147
1150
|
};
|
|
1148
1151
|
var DEFAULT_CONFIG = {
|
|
1149
|
-
locale: "
|
|
1150
|
-
...LOCALIZED_TEXT_DEFAULTS.
|
|
1152
|
+
locale: "en",
|
|
1153
|
+
...LOCALIZED_TEXT_DEFAULTS.en,
|
|
1151
1154
|
resumeSilentTurns: true,
|
|
1152
1155
|
resumeCompletedTurns: false,
|
|
1153
1156
|
continueTextLoop: "",
|
|
@@ -1182,7 +1185,7 @@ function booleanOr(value, fallback) {
|
|
|
1182
1185
|
}
|
|
1183
1186
|
function resolveConfig(section) {
|
|
1184
1187
|
const value = section ?? {};
|
|
1185
|
-
const locale = value.locale
|
|
1188
|
+
const locale = resolveLocale(value.locale);
|
|
1186
1189
|
const localized = LOCALIZED_TEXT_DEFAULTS[locale];
|
|
1187
1190
|
const text = typeof value.continueText === "string" && value.continueText.trim() !== "" ? value.continueText : localized.continueText;
|
|
1188
1191
|
const maxTokensText = typeof value.continueTextMaxTokens === "string" && value.continueTextMaxTokens.trim() !== "" ? value.continueTextMaxTokens : localized.continueTextMaxTokens;
|
|
@@ -9267,7 +9270,7 @@ function migrateLegacySettings(ctx, config, fields, validate) {
|
|
|
9267
9270
|
var AUTO_CONTINUE_NS = "auto-continue";
|
|
9268
9271
|
var settingsFields = {
|
|
9269
9272
|
/** Active browser/UI locale mirrored by the client. */
|
|
9270
|
-
locale: z2.string().default("
|
|
9273
|
+
locale: z2.string().default("en"),
|
|
9271
9274
|
/** Text automatically sent after an interruption. */
|
|
9272
9275
|
continueText: z2.string().default(""),
|
|
9273
9276
|
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* 以及回显识别。引擎迁入 host 后(0.8.0), 浏览器半侧只 re-export 本模块。
|
|
6
6
|
*/
|
|
7
7
|
import type { SessionEvent } from '@deepseek-ai/dsh-session/types';
|
|
8
|
-
/** Supported UI/config locales
|
|
8
|
+
/** Supported UI/config locales; missing and unsupported values use English. */
|
|
9
9
|
export type AutoContinueLocale = 'en' | 'zh';
|
|
10
|
+
export declare function resolveLocale(locale: unknown): AutoContinueLocale;
|
|
10
11
|
export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
|
|
11
12
|
export interface SessionPolicy {
|
|
12
13
|
modes: Record<string, SessionMode>;
|
|
@@ -110,7 +111,7 @@ export interface AutoContinueSettings {
|
|
|
110
111
|
}
|
|
111
112
|
/** Fully resolved configuration (built-in defaults + user overrides). */
|
|
112
113
|
export type AutoContinueConfig = Required<AutoContinueSettings>;
|
|
113
|
-
/** Effective built-in defaults; localized text fields use
|
|
114
|
+
/** Effective built-in defaults; localized text fields use English until a browser locale is mirrored. */
|
|
114
115
|
export declare const DEFAULT_CONFIG: AutoContinueConfig;
|
|
115
116
|
/** Resolve a (possibly partial / not-yet-loaded) settings section to a full config. */
|
|
116
117
|
export declare function resolveConfig(section: AutoContinueSettings | undefined): AutoContinueConfig;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-client-auto-continue",
|
|
3
3
|
"description": "DSH Web UI plugin: automatically sends a localized continue prompt when a request is interrupted by network errors or other non-human causes",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/types/index.d.ts",
|
package/src/client/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ import type {} from '@deepseek-ai/dsh-client-locale/client';
|
|
|
19
19
|
import type {} from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
20
20
|
// Type-only: pulls the `settings.plugin.item` SlotMap merge.
|
|
21
21
|
import type {} from '@deepseek-ai/dsh-client-ui-settings-plugins/client';
|
|
22
|
-
import { type AutoContinueSettings } from '
|
|
22
|
+
import { resolveLocale, type AutoContinueSettings } from '../shared/core.ts';
|
|
23
23
|
import { en, zh, type SettingsCardKey } from './locales.ts';
|
|
24
24
|
import {
|
|
25
25
|
AutoContinueSettingsCard,
|
|
@@ -125,6 +125,7 @@ function mountSettings(ctx: ClientContext, scope: SettingsScope<AutoContinueSett
|
|
|
125
125
|
let mirrorAttempts = 0;
|
|
126
126
|
const syncLocale = (): void => {
|
|
127
127
|
const active = ctx.locale.getLocale().active;
|
|
128
|
+
const target = resolveLocale(active);
|
|
128
129
|
const snapshot = scope.getSnapshot();
|
|
129
130
|
if (!canWriteSettings(snapshot)) return;
|
|
130
131
|
// A genuine language switch is the only thing that earns a fresh budget: the
|
|
@@ -136,10 +137,10 @@ function mountSettings(ctx: ClientContext, scope: SettingsScope<AutoContinueSett
|
|
|
136
137
|
mirrorAttempts = 0;
|
|
137
138
|
}
|
|
138
139
|
// Converged: nothing to write.
|
|
139
|
-
if (snapshot.value?.locale ===
|
|
140
|
+
if (snapshot.value?.locale === target) return;
|
|
140
141
|
if (mirrorAttempts >= MAX_MIRROR_ATTEMPTS) return;
|
|
141
142
|
mirrorAttempts += 1;
|
|
142
|
-
void scope.set('locale',
|
|
143
|
+
void scope.set('locale', target);
|
|
143
144
|
};
|
|
144
145
|
ctx.effect(() => scope.subscribe(syncLocale), 'auto-continue: locale settings sync');
|
|
145
146
|
ctx.on('locale/change', syncLocale);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { en, zh, type SettingsCardKey } from './locales.ts';
|
|
2
|
+
import { resolveLocale } from '../shared/core.ts';
|
|
2
3
|
|
|
3
4
|
type Permission = NotificationPermission | 'unsupported' | 'failed';
|
|
4
5
|
export type SettingsNotice = 'enabled' | 'disabled' | 'saved';
|
|
@@ -30,7 +31,7 @@ export function showSettingsNotification(notice: SettingsNotice, locale: string,
|
|
|
30
31
|
: permission === 'failed' ? 'notification.failed' : 'notification.blocked';
|
|
31
32
|
}
|
|
32
33
|
try {
|
|
33
|
-
const copy = locale
|
|
34
|
+
const copy = resolveLocale(locale) === 'zh' ? zh : en;
|
|
34
35
|
const notification = new Notification(copy['notification.title'], { body: copy[message] });
|
|
35
36
|
notification.onclick = () => {
|
|
36
37
|
try { globalThis.focus?.(); } catch { /* Focusing is best effort. */ }
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const AUTO_CONTINUE_NS = 'auto-continue';
|
|
|
27
27
|
/** Wire schema; blank localized text fields tell resolveConfig() to select the active locale's defaults. */
|
|
28
28
|
const settingsFields = {
|
|
29
29
|
/** Active browser/UI locale mirrored by the client. */
|
|
30
|
-
locale: z.string().default('
|
|
30
|
+
locale: z.string().default('en'),
|
|
31
31
|
/** Text automatically sent after an interruption. */
|
|
32
32
|
continueText: z.string().default(''),
|
|
33
33
|
/** Text sent when the output token ceiling is reached (same placeholders as `continueText`). */
|
package/src/shared/core.ts
CHANGED
|
@@ -6,9 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session/types';
|
|
8
8
|
|
|
9
|
-
/** Supported UI/config locales
|
|
9
|
+
/** Supported UI/config locales; missing and unsupported values use English. */
|
|
10
10
|
export type AutoContinueLocale = 'en' | 'zh';
|
|
11
11
|
|
|
12
|
+
export function resolveLocale(locale: unknown): AutoContinueLocale {
|
|
13
|
+
return typeof locale === 'string' && /^zh(?:-|$)/i.test(locale) ? 'zh' : 'en';
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
|
|
13
17
|
|
|
14
18
|
export interface SessionPolicy {
|
|
@@ -129,10 +133,10 @@ export interface AutoContinueSettings {
|
|
|
129
133
|
/** Fully resolved configuration (built-in defaults + user overrides). */
|
|
130
134
|
export type AutoContinueConfig = Required<AutoContinueSettings>;
|
|
131
135
|
|
|
132
|
-
/** Effective built-in defaults; localized text fields use
|
|
136
|
+
/** Effective built-in defaults; localized text fields use English until a browser locale is mirrored. */
|
|
133
137
|
export const DEFAULT_CONFIG: AutoContinueConfig = {
|
|
134
|
-
locale: '
|
|
135
|
-
...LOCALIZED_TEXT_DEFAULTS.
|
|
138
|
+
locale: 'en',
|
|
139
|
+
...LOCALIZED_TEXT_DEFAULTS.en,
|
|
136
140
|
resumeSilentTurns: true,
|
|
137
141
|
resumeCompletedTurns: false,
|
|
138
142
|
continueTextLoop: '',
|
|
@@ -171,7 +175,7 @@ function booleanOr(value: unknown, fallback: boolean): boolean {
|
|
|
171
175
|
/** Resolve a (possibly partial / not-yet-loaded) settings section to a full config. */
|
|
172
176
|
export function resolveConfig(section: AutoContinueSettings | undefined): AutoContinueConfig {
|
|
173
177
|
const value = section ?? {};
|
|
174
|
-
const locale
|
|
178
|
+
const locale = resolveLocale(value.locale);
|
|
175
179
|
const localized = LOCALIZED_TEXT_DEFAULTS[locale];
|
|
176
180
|
const text =
|
|
177
181
|
typeof value.continueText === 'string' && value.continueText.trim() !== ''
|