dsh-client-auto-continue 0.15.0 → 0.16.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.
@@ -9,6 +9,22 @@ import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session/types';
9
9
  /** Supported UI/config locales. Any unknown browser locale falls back to Chinese. */
10
10
  export type AutoContinueLocale = 'en' | 'zh';
11
11
 
12
+ export type SessionMode = 'default' | 'off' | 'recover' | 'loop';
13
+
14
+ export interface SessionPolicy {
15
+ modes: Record<string, SessionMode>;
16
+ defaultMode: 'recover' | 'loop';
17
+ paused: boolean;
18
+ writable: boolean;
19
+ }
20
+
21
+ export const isSessionMode = (value: unknown): value is SessionMode =>
22
+ value === 'default' || value === 'off' || value === 'recover' || value === 'loop';
23
+
24
+ export function sessionMode(modes: Record<string, SessionMode>, sessionId: string): SessionMode {
25
+ return Object.prototype.hasOwnProperty.call(modes, sessionId) && isSessionMode(modes[sessionId]) ? modes[sessionId]! : 'default';
26
+ }
27
+
12
28
  /** Locale-owned defaults for the user-editable text fields. */
13
29
  export const LOCALIZED_TEXT_DEFAULTS = {
14
30
  zh: {
@@ -90,7 +106,9 @@ export interface AutoContinueSettings {
90
106
  notify?: boolean;
91
107
  /** Globally pause auto-continue: no live or scan send, queued pending sends cancelled. */
92
108
  paused?: boolean;
93
- /** Show the global auto-continue switch in the conversation composer. */
109
+ /** Persistent per-session overrides; default explicitly inherits the profile default. */
110
+ sessionModes?: Record<string, SessionMode>;
111
+ /** Show the session mode selector in the conversation composer. */
94
112
  showComposerToggle?: boolean;
95
113
  /** Loop guard: detect a running turn spinning in place (short talk without tools, or the same tool repeating) and restart it. */
96
114
  loopGuard?: boolean;
@@ -132,6 +150,7 @@ export const DEFAULT_CONFIG: AutoContinueConfig = {
132
150
  backoffMaxMs: 300000,
133
151
  notify: false,
134
152
  paused: false,
153
+ sessionModes: {},
135
154
  showComposerToggle: true,
136
155
  loopGuard: true,
137
156
  loopShortChars: 40,
@@ -210,6 +229,8 @@ export function resolveConfig(section: AutoContinueSettings | undefined): AutoCo
210
229
  backoffMaxMs: numberOr(value.backoffMaxMs, DEFAULT_CONFIG.backoffMaxMs),
211
230
  notify: booleanOr(value.notify, DEFAULT_CONFIG.notify),
212
231
  paused: booleanOr(value.paused, DEFAULT_CONFIG.paused),
232
+ sessionModes: value.sessionModes !== null && typeof value.sessionModes === 'object' && !Array.isArray(value.sessionModes)
233
+ ? value.sessionModes : {},
213
234
  showComposerToggle: booleanOr(value.showComposerToggle, DEFAULT_CONFIG.showComposerToggle),
214
235
  loopGuard: booleanOr(value.loopGuard, DEFAULT_CONFIG.loopGuard),
215
236
  loopShortChars: Math.max(1, numberOr(value.loopShortChars, DEFAULT_CONFIG.loopShortChars)),
@@ -849,6 +870,7 @@ export interface SessionState {
849
870
  pendingEchoMessageIds: Map<string, number>;
850
871
  /** 宽限期定时器(进行中的待发送)。 */
851
872
  pendingTimer: ReturnType<typeof setTimeout> | undefined;
873
+ pendingReason?: string;
852
874
  /** 宿主权威 running 位(来自 host/session-status 与回合事件)。 */
853
875
  running: boolean | undefined;
854
876
  /** 当前排队消息数(来自 session/queue 帧)。 */