dsh-client-auto-continue 0.16.0 → 0.17.1-rc.1

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +14 -11
  3. package/README.zh.md +10 -10
  4. package/docs/releases/v0.17.0.md +62 -0
  5. package/docs/releases/v0.17.1-rc.1.md +55 -0
  6. package/docs/screenshots/01-settings-section.png +0 -0
  7. package/docs/screenshots/01-settings-section.zh.png +0 -0
  8. package/docs/screenshots/02-settings-card.png +0 -0
  9. package/docs/screenshots/02-settings-card.zh.png +0 -0
  10. package/docs/screenshots/07-card-panels.png +0 -0
  11. package/docs/screenshots/07-card-panels.zh.png +0 -0
  12. package/docs/screenshots/08-composer-toggle.png +0 -0
  13. package/docs/screenshots/08-composer-toggle.zh.png +0 -0
  14. package/docs/screenshots/README.md +8 -8
  15. package/lib/client.js +381 -118
  16. package/lib/client.js.map +4 -4
  17. package/lib/index.js +25 -10
  18. package/lib/types/client/auto-continue-icon.d.ts +1 -0
  19. package/lib/types/client/index.d.ts +1 -1
  20. package/lib/types/client/locales.d.ts +5 -8
  21. package/lib/types/client/mode-menu.d.ts +19 -0
  22. package/lib/types/client/native-toast.d.ts +17 -0
  23. package/lib/types/client/settings-card.d.ts +1 -1
  24. package/lib/types/shared/core.d.ts +2 -0
  25. package/locale/en.json +6 -0
  26. package/locale/zh.json +6 -0
  27. package/package.json +5 -3
  28. package/src/client/auto-continue-icon.tsx +35 -0
  29. package/src/client/composer-toggle.tsx +58 -14
  30. package/src/client/index.ts +1 -1
  31. package/src/client/locales.ts +12 -18
  32. package/src/client/mode-menu.tsx +110 -0
  33. package/src/client/native-toast.tsx +44 -0
  34. package/src/client/settings-card.tsx +130 -24
  35. package/src/client/styles.ts +61 -40
  36. package/src/host/engine.ts +29 -6
  37. package/src/shared/core.ts +4 -1
@@ -7,7 +7,7 @@
7
7
  * configuration section; styles live in `styles.ts` and use the DSH design
8
8
  * tokens so the card follows the active theme.
9
9
  */
10
- import { useEffect, useId, useState } from 'react';
10
+ import { useEffect, useId, useState, type ReactNode } from 'react';
11
11
  import type { InjectFace, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
12
12
  import { DEFAULT_CONFIG, type AutoContinueSettings } from './engine.ts';
13
13
  import type { SessionMode } from '../shared/core.ts';
@@ -42,6 +42,40 @@ import { prepareSettingsNotification, showSettingsNotification } from './setting
42
42
  // style bookkeeping (HMR) owns them.
43
43
  injectStyles();
44
44
 
45
+ /**
46
+ * Native plugin-settings primitives. Older hosts (and the unit-test fixture)
47
+ * do not export them; the legacy hand-built card stays as the fallback.
48
+ */
49
+ const nativeSettings = (() => {
50
+ try {
51
+ return require('@deepseek-ai/dsh-client-ui-primitives') as {
52
+ SettingsForm?: React.ComponentType<{
53
+ labels: { save: string; saving: string; saveFailed: string; readOnly: string; unavailable: string };
54
+ state: CardShell;
55
+ onSave: () => void;
56
+ onDiscard: () => void;
57
+ children: ReactNode;
58
+ }>;
59
+ SettingsValueField?: React.ComponentType<Record<string, unknown>>;
60
+ SegmentedControl?: React.ComponentType<{
61
+ id?: string;
62
+ options: ReadonlyArray<{ value: string; label: string }>;
63
+ value: string;
64
+ onChange: (value: string) => void;
65
+ label: string;
66
+ disabled?: boolean;
67
+ }>;
68
+ };
69
+ } catch {
70
+ return {};
71
+ }
72
+ })();
73
+
74
+ const NativeSettingsForm = nativeSettings.SettingsForm;
75
+ const NativeValueField = nativeSettings.SettingsValueField;
76
+ const NativeSegmentedControl = nativeSettings.SegmentedControl;
77
+ const hasNativeSettings = typeof NativeSettingsForm === 'function' && typeof NativeValueField === 'function';
78
+
45
79
  /** What the auto-continue card renders. */
46
80
  export interface AutoContinueSettingsCardState extends CardShell {
47
81
  /** Committed global state; a staged edit does not pause the engine yet. */
@@ -265,8 +299,6 @@ export function AutoContinueSettingsPage(props: AutoContinueSettingsCardProps) {
265
299
  );
266
300
  }
267
301
 
268
- const REPOSITORY_URL = 'https://github.com/HsiangNianian/dsh-auto-continue';
269
-
270
302
  type FieldName = Exclude<keyof AutoContinueSettingsCardState, keyof CardShell | 'enabled' | 'notificationFeedback'>;
271
303
  const groups = [
272
304
  { id: 'general', fields: ['paused', 'showComposerToggle', 'resumeSilentTurns', 'resumeCompletedTurns', 'notify'] },
@@ -284,18 +316,18 @@ const textDefaults: Partial<Record<FieldName, SettingsCardKey>> = {
284
316
  guardPendingText: 'default.guardPendingText', guardDoneText: 'default.guardDoneText', loopText: 'default.loopText',
285
317
  };
286
318
 
287
- function GitHubMark() {
288
- return <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 2.4a9.8 9.8 0 0 0-3.1 19.1c.5.1.7-.2.7-.5v-1.9c-2.8.6-3.4-1.2-3.4-1.2-.5-1.1-1.1-1.4-1.1-1.4-.9-.6.1-.6.1-.6 1 0 1.5 1 1.5 1 .9 1.5 2.3 1.1 2.9.8.1-.6.4-1.1.6-1.3-2.2-.3-4.6-1.1-4.6-4.9 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .8-.3 2.8 1a9.5 9.5 0 0 1 5 0c1.9-1.3 2.8-1 2.8-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.8-2.3 4.6-4.6 4.9.4.3.7.9.7 1.8V21c0 .3.2.6.7.5A9.8 9.8 0 0 0 12 2.4Z" /></svg>;
289
- }
319
+ const REPOSITORY_URL = 'https://github.com/HsiangNianian/dsh-auto-continue';
320
+
290
321
  function RepositoryInvite({ t }: { t: (key: SettingsCardKey) => string }) {
291
- return <aside className="dshAcRepository">
292
- <span className="dshAcStar" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m12 3 2.78 5.63L21 9.53l-4.5 4.39 1.06 6.2L12 17.2l-5.56 2.92 1.06-6.2L3 9.53l6.22-.9L12 3Z" /></svg></span>
293
- <span className="dshAcRepositoryCopy"><strong>{t('repo.star')}</strong><span>{t('repo.note')}</span></span>
294
- <a className="dshAcGithub" href={REPOSITORY_URL} target="_blank" rel="noopener noreferrer" aria-label={t('repo.aria')}>
295
- <GitHubMark /><span className="dshAcGithubLong">{t('repo.link')}</span><span className="dshAcGithubShort">GitHub</span>
322
+ return <p className="dshAcInvite">
323
+ <span className="dshAcInviteStar" aria-hidden="true">★</span>
324
+ <span>{t('repo.star')}</span>
325
+ <a className="dshAcRepoLink" href={REPOSITORY_URL} target="_blank" rel="noopener noreferrer" aria-label={t('repo.aria')}>
326
+ <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 2.4a9.8 9.8 0 0 0-3.1 19.1c.5.1.7-.2.7-.5v-1.9c-2.8.6-3.4-1.2-3.4-1.2-.5-1.1-1.1-1.4-1.1-1.4-.9-.6.1-.6.1-.6 1 0 1.5 1 1.5 1 .9 1.5 2.3 1.1 2.9.8.1-.6.4-1.1.6-1.3-2.2-.3-4.6-1.1-4.6-4.9 0-1.1.4-2 1-2.7-.1-.3-.4-1.3.1-2.7 0 0 .8-.3 2.8 1a9.5 9.5 0 0 1 5 0c1.9-1.3 2.8-1 2.8-1 .5 1.4.2 2.4.1 2.7.6.7 1 1.6 1 2.7 0 3.8-2.3 4.6-4.6 4.9.4.3.7.9.7 1.8V21c0 .3.2.6.7.5A9.8 9.8 0 0 0 12 2.4Z" /></svg>
327
+ {t('repo.link')}
296
328
  <svg className="dshAcExternal" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3h7v7M13 3 7 9M11 9v3a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1h3" /></svg>
297
329
  </a>
298
- </aside>;
330
+ </p>;
299
331
  }
300
332
 
301
333
  /** Controls edit the existing staged form; navigation never owns or discards drafts. */
@@ -329,6 +361,68 @@ function SettingField({ name, id, state, actions, disabled, t }: {
329
361
  </div>;
330
362
  }
331
363
 
364
+
365
+ /** One field rendered with the host's own settings primitives. */
366
+ function NativeSettingField({ name, id, state, actions, disabled, t }: {
367
+ name: FieldName; id: string; state: CardFieldState; actions: CardActions; disabled: boolean;
368
+ t: (key: SettingsCardKey) => string;
369
+ }) {
370
+ const boolean = typeof DEFAULT_CONFIG[name] === 'boolean';
371
+ const numeric = typeof DEFAULT_CONFIG[name] === 'number';
372
+ const label = t(`field.${name}` as SettingsCardKey);
373
+ const hint = t(`field.${name}Hint` as SettingsCardKey);
374
+ const value = state.text === '' ? DEFAULT_CONFIG[name] : state.text === 'true';
375
+ const placeholderKey = textDefaults[name];
376
+ const placeholder = placeholderKey ? t(placeholderKey) : name === 'retryableErrorPatterns' ? t('field.retryableErrorPatternsPlaceholder') : String(DEFAULT_CONFIG[name]);
377
+ const reset = state.overridden
378
+ ? <button type="button" className="dshAcNativeReset" disabled={disabled} aria-label={`${t('chrome.reset')}: ${label}`} onClick={() => actions.resetField(name)}>{t('chrome.reset')}</button>
379
+ : null;
380
+
381
+ if (name === 'resumeCompletedTurns') {
382
+ const items = [{ value: 'false', label: t('composer.recover') }, { value: 'true', label: t('composer.loop') }];
383
+ return <div className="dshAcNativeField" data-field={name}>
384
+ <div className="dshAcNativeHead"><label className="dshAcNativeLabel" htmlFor={id}>{label}</label>{reset}</div>
385
+ {NativeSegmentedControl
386
+ ? <NativeSegmentedControl id={id} options={items} value={value ? 'true' : 'false'} onChange={next => actions.edit(name, next)} label={label} disabled={disabled} />
387
+ : <select id={id} className="dshAcMode" aria-label={label} disabled={disabled} value={String(value)} onChange={event => actions.edit(name, event.target.value)}>
388
+ <option value="false">{t('composer.recover')}</option><option value="true">{t('composer.loop')}</option>
389
+ </select>}
390
+ <p className="dshAcNativeHint" id={`${id}-hint`}>{hint}</p>
391
+ </div>;
392
+ }
393
+
394
+ if (boolean) {
395
+ return <div className="dshAcNativeField" data-field={name}>
396
+ <div className="dshAcNativeToggleRow">
397
+ <label className="dshAcNativeLabel" htmlFor={id}>{label}</label>
398
+ <span className="dshAcNativeActions">
399
+ {reset}
400
+ <NativeSwitch label={label} title={hint} disabled={disabled}
401
+ checked={name === 'paused' ? !value : Boolean(value)}
402
+ onChange={checked => actions.edit(name, String(name === 'paused' ? !checked : checked))} />
403
+ </span>
404
+ </div>
405
+ <p className="dshAcNativeHint" id={`${id}-hint`}>{hint}</p>
406
+ </div>;
407
+ }
408
+
409
+ if (numeric) {
410
+ const ValueField = NativeValueField!;
411
+ return <ValueField id={id} label={label} hint={hint} overriddenLabel={t('chrome.overridden')}
412
+ resetLabel={t('chrome.reset')} invalidLabel={t('chrome.invalidNumber')} disabled={disabled}
413
+ numeric {...state} placeholder={placeholder}
414
+ onEdit={(text: string) => actions.edit(name, text)} onReset={() => actions.resetField(name)} />;
415
+ }
416
+
417
+ return <div className="dshAcNativeField" data-field={name}>
418
+ <div className="dshAcNativeHead"><label className="dshAcNativeLabel" htmlFor={id}>{label}</label>{reset}</div>
419
+ <textarea id={id} className="dshAcNativeTextarea" rows={name === 'retryableErrorPatterns' ? 3 : 2}
420
+ disabled={disabled} value={state.text} placeholder={placeholder} aria-invalid={state.invalid || undefined}
421
+ aria-describedby={`${id}-hint`} onChange={event => actions.edit(name, event.target.value)} />
422
+ <p className="dshAcNativeHint" id={`${id}-hint`}>{state.invalid ? t('chrome.invalidNumber') : hint}</p>
423
+ </div>;
424
+ }
425
+
332
426
  /** 实时面板: 今日统计 + 已暂停会话。浏览器本地状态, 每 5 秒刷新一次。 */
333
427
  function LivePanels(props: { t: (key: SettingsCardKey) => string }) {
334
428
  const { t } = props;
@@ -462,20 +556,18 @@ function LivePanels(props: { t: (key: SettingsCardKey) => string }) {
462
556
  );
463
557
  }
464
558
 
465
- /** Native category layout, with the selected B3 repository invitation beside the introduction. */
559
+ /** Native category layout; the plugin manager above already owns the title, version and status. */
466
560
  export function AutoContinueSettingsCard(props: AutoContinueSettingsCardProps) {
467
561
  const { t } = props;
468
562
  const state = props.useAutoContinueSettingsCard(snapshot => snapshot);
469
563
  const [active, setActive] = useState<Category>('general');
470
564
  const prefix = useId();
471
565
  const group = groups.find(item => item.id === active)!;
566
+ const native = hasNativeSettings;
472
567
  if (!state.available) return null;
473
568
  return <li className="dshAcCard">
474
- <header className="dshAcHeaderFrame">
475
- <div className="dshAcIntroduction"><div className="dshAcTitleLine"><h2>{t('card.title')}</h2><span className="dshAcStatus">{t(state.enabled ? 'chrome.enabled' : 'chrome.paused')}</span></div><p>{t('card.description')}</p></div>
476
- <RepositoryInvite t={t} />
477
- </header>
478
- {!state.writable && <p className="dshAcReadOnly" role="status">{t('chrome.readOnly')}</p>}
569
+ <RepositoryInvite t={t} />
570
+ {!native && !state.writable && <p className="dshAcReadOnly" role="status">{t('chrome.readOnly')}</p>}
479
571
  <div className="dshAcLayout">
480
572
  <div className="dshAcNav" role="tablist" aria-label={t('chrome.categories')}>
481
573
  {groups.map((item, index) => {
@@ -498,13 +590,27 @@ export function AutoContinueSettingsCard(props: AutoContinueSettingsCardProps) {
498
590
  </div>
499
591
  <section className="dshAcCategory" role="tabpanel" id={`${prefix}-panel-${active}`} aria-labelledby={`${prefix}-tab-${active}`}>
500
592
  <div className="dshAcCategoryHeading"><h3>{t(`category.${active}.title`)}</h3><p>{t(`category.${active}.description`)}</p></div>
501
- {group.fields.map(name => <SettingField key={name} name={name} id={`${prefix}-${name}`} state={state[name]} actions={props} disabled={!state.writable} t={t} />)}
502
- {active === 'status' && <LivePanels t={t} />}
593
+ {native ? (
594
+ <NativeSettingsForm labels={{
595
+ save: t('chrome.save'), saving: t('chrome.saving'), saveFailed: t('chrome.saveFailed'),
596
+ readOnly: t('chrome.readOnly'), unavailable: t('chrome.unavailable'),
597
+ }} state={state} onSave={props.save} onDiscard={props.discard}>
598
+ <div className="dshAcNativeFields">
599
+ {group.fields.map(name => <NativeSettingField key={name} name={name} id={`${prefix}-${name}`} state={state[name]} actions={props} disabled={!state.writable} t={t} />)}
600
+ {active === 'status' && <LivePanels t={t} />}
601
+ </div>
602
+ </NativeSettingsForm>
603
+ ) : (
604
+ <>
605
+ {group.fields.map(name => <SettingField key={name} name={name} id={`${prefix}-${name}`} state={state[name]} actions={props} disabled={!state.writable} t={t} />)}
606
+ {active === 'status' && <LivePanels t={t} />}
607
+ <footer className="dshAcFooter" data-dirty={state.dirty}>
608
+ <p className={state.failed || state.invalid ? 'dshAcInvalid' : 'dshAcHint'} role="status">{t(state.failed ? 'chrome.saveFailed' : state.invalid ? 'chrome.invalidNumber' : state.saving ? 'chrome.saving' : state.dirty ? 'chrome.unsaved' : state.notificationFeedback ?? 'chrome.saved')}</p>
609
+ <div><button type="button" className="dshAcDiscard" disabled={!state.dirty || state.saving} onClick={props.discard}>{t('chrome.discard')}</button><button type="button" className="dshAcSave" disabled={!state.dirty || state.invalid || state.saving || !state.writable} onClick={props.save}>{t(state.saving ? 'chrome.saving' : 'chrome.save')}</button></div>
610
+ </footer>
611
+ </>
612
+ )}
503
613
  </section>
504
614
  </div>
505
- <footer className="dshAcFooter" data-dirty={state.dirty}>
506
- <p className={state.failed || state.invalid ? 'dshAcInvalid' : 'dshAcHint'} role="status">{t(state.failed ? 'chrome.saveFailed' : state.invalid ? 'chrome.invalidNumber' : state.saving ? 'chrome.saving' : state.dirty ? 'chrome.unsaved' : state.notificationFeedback ?? 'chrome.saved')}</p>
507
- <div><button type="button" className="dshAcDiscard" disabled={!state.dirty || state.saving} onClick={props.discard}>{t('chrome.discard')}</button><button type="button" className="dshAcSave" disabled={!state.dirty || state.invalid || state.saving || !state.writable} onClick={props.save}>{t(state.saving ? 'chrome.saving' : 'chrome.save')}</button></div>
508
- </footer>
509
615
  </li>;
510
616
  }
@@ -6,16 +6,39 @@
6
6
  */
7
7
 
8
8
  const css = `
9
- .dshAcComposer { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 7px; min-height: 32px; max-width: 100%; font: inherit; }
10
- .dshAcMode { min-height: 32px; max-width: 100%; padding: 4px 6px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 6px; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; }
11
- .dshAcMode:disabled { opacity: .5; }
12
- .dshAcMode:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
13
- .dshAcComposerLabel { color: var(--dsw-alias-label-secondary); font-size: 12px; white-space: nowrap; }
14
- .dshAcSwitchTarget { display: inline-flex; align-items: center; min-height: 32px; }
9
+ .dshAcComposer { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; min-height: 32px; max-width: 100%; font: inherit; }
10
+ .dshAcComposerCore { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
11
+ .dshAcComposerCore > span { min-width: 0; }
12
+ .dshAcModeTrigger { display: inline-flex; align-items: center; gap: 3px; min-width: 0; max-width: 132px; height: 28px; margin-left: -1px; padding: 0 4px 0 7px; border: 0; border-radius: var(--dsw-radius-sm, 6px); background: none; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 13px; font-weight: 500; line-height: 20px; cursor: pointer; }
13
+ .dshAcModeTrigger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
14
+ .dshAcModeTrigger:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }
15
+ .dshAcModeTrigger:disabled { color: var(--dsw-alias-label-dimmed, var(--dsw-alias-label-tertiary)); cursor: default; }
16
+ .dshAcModeTriggerLabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
17
+ .dshAcModeChevron { display: inline-flex; flex: none; color: var(--dsw-alias-label-caption, var(--dsw-alias-label-tertiary)); transition: transform .12s ease; }
18
+ .dshAcModeChevron > svg { display: block; width: 14px; height: 14px; }
19
+ .dshAcModeChevronFallback { fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
20
+ .dshAcModeChevron[data-open=true] { transform: rotate(180deg); }
21
+ .dshAcModeMenu { position: relative; display: inline-flex; align-items: center; gap: 3px; min-width: 0; max-width: 132px; height: 28px; margin-left: -1px; padding: 0 4px 0 7px; border-radius: var(--dsw-radius-sm, 6px); color: var(--dsw-alias-label-secondary); font-size: 13px; font-weight: 500; line-height: 20px; }
22
+ .dshAcModeMenu:hover:not([data-disabled=true]) { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-interactive-bg-hover); }
23
+ .dshAcModeMenu[data-disabled=true] { color: var(--dsw-alias-label-dimmed, var(--dsw-alias-label-tertiary)); }
24
+ .dshAcComposerSelect { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); font: inherit; font-size: 12px; }
25
+ .dshAcComposerSelect:disabled { cursor: default; }
26
+ /* Settings-card select (default session mode); kept scoped so the composer's
27
+ invisible overlay cannot stretch it over the whole app. */
28
+ .dshAcCard .dshAcMode { min-height: 32px; max-width: 100%; padding: 4px 6px; border: 1px solid var(--dsh-ac-line); border-radius: 6px; background: var(--dsh-ac-bg); color: var(--dsh-ac-text); font: inherit; font-size: 12px; }
29
+ .dshAcCard .dshAcMode:disabled { opacity: .5; }
30
+ .dshAcCard .dshAcMode:focus-visible { outline: 2px solid var(--dsh-ac-text); outline-offset: 3px; }
31
+ .dshAcComposerLabel { display: inline-flex; align-items: center; gap: 5px; flex: none; color: var(--dsw-alias-label-secondary); font-size: 12px; white-space: nowrap; }
32
+ .dshAcComposerText { display: inline; }
33
+ .dshAcComposerIcon { display: inline-flex; flex: none; color: var(--dsw-alias-label-secondary); }
34
+ .dshAcComposerIcon > svg { display: block; width: 14px; height: 14px; }
35
+ .dshAcComposerIconFallback { fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
36
+ .dshAcSwitchTarget { display: inline-flex; align-items: center; flex: none; min-height: 32px; }
15
37
  .dshAcSwitchTarget > button { position: relative; }
16
38
  .dshAcSwitchTarget > button::before { content: ''; position: absolute; inset: -6px -3px; }
17
39
  .dshAcComposerError { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-secondary)); font-size: 12px; max-width: 160px; }
18
40
  .dshAcComposerError:empty { display: none; }
41
+ .dshAcToastIcon { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
19
42
  .dshAcSwitch { position: relative; box-sizing: border-box; flex: none; width: 36px; height: 20px; padding: 2px; border: 0; border-radius: 999px; background: var(--dsw-alias-border-l3); cursor: pointer; }
20
43
  .dshAcSwitch[aria-checked='true'] { background: var(--dsw-alias-brand-primary); }
21
44
  .dshAcSwitch > span { display: block; width: 16px; height: 16px; border-radius: 50%; background: var(--dsw-alias-label-primary-foreground); }
@@ -42,27 +65,28 @@ const css = `
42
65
  .dshAcCard button { cursor: pointer; }
43
66
  .dshAcCard button:disabled { opacity: .4; cursor: default; }
44
67
  .dshAcCard :is(a,button,input,textarea):focus-visible { outline: 2px solid var(--dsh-ac-text); outline-offset: 3px; }
45
- .dshAcHeaderFrame { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); align-items: center; gap: 24px; margin: 20px 0; padding: 16px 18px; border-radius: 9px; color: #f9fafb; background: #23262c; }
46
- .dshAcIntroduction { min-width: 0; }
47
- .dshAcTitleLine { display: flex; align-items: center; gap: 10px; }
48
- .dshAcTitleLine h2 { font-size: 17px; font-weight: 620; line-height: 1.4; white-space: nowrap; }
49
- .dshAcStatus { white-space: nowrap; font-size: 11px; color: #dce0e6; background: #ffffff14; border-radius: 5px; padding: 2px 7px; }
50
- .dshAcIntroduction p { margin-top: 5px; color: #b9bec8; font-size: 12px; line-height: 1.6; }
51
- .dshAcRepository { display: flex; align-items: center; gap: 12px; min-width: 0; }
52
- .dshAcStar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border: 1px solid #625032; border-radius: 50%; background: #302c25; color: #e9be6d; }
53
- .dshAcStar svg { width: 18px; height: 18px; fill: #e9be6d12; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
54
- .dshAcRepositoryCopy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 5px; }
55
- .dshAcRepositoryCopy strong { font-size: 13px; font-weight: 560; line-height: 1.5; }
56
- .dshAcRepositoryCopy > span { color: #b9bec8; font-size: 10px; line-height: 1.6; }
57
- .dshAcRepositoryCopy > * { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
58
- .dshAcCard a.dshAcGithub { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex: none; min-height: 38px; padding: 9px 11px; border: 1px solid transparent; border-radius: 6px; color: #202329; background: #f4f5f7; text-decoration: none; font-size: 12px; font-weight: 550; white-space: nowrap; transition: background-color 140ms ease, box-shadow 140ms ease; }
59
- .dshAcCard a.dshAcGithub:hover { background: #fff; box-shadow: 0 0 0 3px #ffffff18; }
60
- .dshAcCard a.dshAcGithub:focus-visible { outline-color: #e9be6d; }
61
- .dshAcGithub > svg { flex: none; width: 17px; height: 17px; fill: currentColor; }
62
- .dshAcGithub > svg.dshAcExternal { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; margin-left: 2px; }
63
- .dshAcGithubShort { display: none; }
68
+ .dshAcInvite { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 18px; color: var(--dsh-ac-muted); font-size: 12px; line-height: 1.6; }
69
+ .dshAcInviteStar { color: #e9be6d; font-size: 13px; line-height: 1; }
70
+ .dshAcRepoLink { display: inline-flex; align-items: center; gap: 5px; color: var(--dsh-ac-text); text-decoration: none; }
71
+ .dshAcRepoLink:hover { text-decoration: underline; }
72
+ .dshAcRepoLink > svg:first-child { width: 14px; height: 14px; fill: currentColor; }
73
+ .dshAcRepoLink > svg.dshAcExternal { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
74
+ .dshAcNativeFields { display: flex; flex-direction: column; min-width: 0; }
75
+ .dshAcNativeField { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px 0; }
76
+ .dshAcNativeHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
77
+ .dshAcNativeLabel { color: var(--dsh-ac-text); font-size: 13px; font-weight: 500; line-height: 19.5px; }
78
+ .dshAcNativeHint { color: var(--dsh-ac-muted); font-size: 12px; line-height: 18px; }
79
+ .dshAcNativeToggleRow { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
80
+ .dshAcNativeActions { display: inline-flex; align-items: center; flex: none; gap: 10px; }
81
+ .dshAcNativeReset { padding: 0; border: 0; background: none; color: var(--dsh-ac-muted); font-size: 11px; white-space: nowrap; }
82
+ .dshAcNativeReset:hover:not(:disabled) { color: var(--dsh-ac-text); text-decoration: underline; }
83
+ .dshAcNativeSegment { display: block; min-width: 0; }
84
+ .dshAcNativeSegment[data-disabled=true] { opacity: .5; pointer-events: none; }
85
+ .dshAcNativeTextarea { box-sizing: border-box; width: 100%; min-height: 66px; resize: vertical; padding: 8px 12px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 12px; background: var(--dsw-alias-bg-layer-2, #353638); color: var(--dsh-ac-text); font: inherit; font-size: 13px; line-height: 19.5px; }
86
+ .dshAcNativeTextarea::placeholder { color: var(--dsh-ac-muted); opacity: .7; }
87
+ .dshAcNativeTextarea[aria-invalid=true] { border-color: var(--dsw-alias-state-error-primary); }
64
88
  .dshAcReadOnly { padding: 10px 0; color: var(--dsh-ac-muted); }
65
- .dshAcLayout { display: grid; grid-template-columns: 164px minmax(0, 1fr); border-top: 1px solid var(--dsh-ac-line); min-height: 462px; }
89
+ .dshAcLayout { display: grid; grid-template-columns: 164px minmax(0, 1fr); min-height: 462px; }
66
90
  .dshAcNav { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px 16px 0; position: sticky; top: 16px; align-self: start; }
67
91
  .dshAcNav > button { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 37px; padding: 8px 11px; border: 0; border-radius: 6px; text-align: left; background: none; color: var(--dsw-alias-label-secondary); }
68
92
  .dshAcNav > button:hover, .dshAcNav > button[aria-selected=true] { color: var(--dsh-ac-text); background: var(--dsw-alias-interactive-bg-hover); }
@@ -109,9 +133,6 @@ const css = `
109
133
  .dshAcPauseId { flex: 1; font: 12px ui-monospace, SFMono-Regular, monospace; }
110
134
  .dshAcRecovery { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
111
135
  @container auto-continue-settings (max-width: 760px) {
112
- .dshAcHeaderFrame { grid-template-columns: minmax(0, 1fr) auto; gap: 16px; }
113
- .dshAcRepositoryCopy { display: none; }
114
- .dshAcRepository { gap: 10px; }
115
136
  .dshAcLayout { grid-template-columns: 136px minmax(0, 1fr); }
116
137
  .dshAcCategory { padding-left: 20px; }
117
138
  .dshAcFieldControl { flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
@@ -127,18 +148,18 @@ const css = `
127
148
  .dshAcFooter { align-items: flex-start; flex-direction: column; gap: 10px; }
128
149
  .dshAcFooter > div { width: 100%; justify-content: flex-end; }
129
150
  }
130
- @container auto-continue-settings (max-width: 440px) {
131
- .dshAcHeaderFrame { gap: 12px; padding: 14px; }
132
- .dshAcTitleLine { gap: 6px; }
133
- .dshAcTitleLine h2 { font-size: 15px; white-space: normal; }
134
- .dshAcStatus { padding: 2px 5px; font-size: 10px; }
135
- .dshAcIntroduction p { font-size: 11px; }
136
- .dshAcStar, .dshAcGithubLong { display: none; }
137
- .dshAcGithubShort { display: inline; }
138
- .dshAcCard a.dshAcGithub { gap: 6px; padding: 8px; font-size: 11px; }
139
- .dshAcGithub > svg.dshAcExternal { display: none; }
151
+ /* Match the composer's own pickers (permission/mode) instead of the viewport:
152
+ the nearest query container is the composer row, so the label collapses at
153
+ the same 460px threshold as the native permission picker. */
154
+ @container (width <= 640px) {
155
+ .dshAcComposerCore { gap: 5px; }
156
+ .dshAcModeTrigger, .dshAcModeMenu { max-width: 104px; padding: 0 3px 0 6px; }
157
+ }
158
+ @container (width <= 460px) {
159
+ .dshAcComposerText { display: none; }
160
+ .dshAcModeTrigger, .dshAcModeMenu { max-width: 28px; padding: 0 2px; }
161
+ .dshAcModeTriggerLabel { display: none; }
140
162
  }
141
- @media (prefers-reduced-motion: reduce) { .dshAcCard a.dshAcGithub { transition: none; } }
142
163
 
143
164
  `;
144
165
 
@@ -173,6 +173,19 @@ function validateSessionEvents(events: unknown): readonly SessionEvent[] {
173
173
  return events;
174
174
  }
175
175
 
176
+ function latestTurnStart(events: readonly SessionEvent[]): SessionEvent<'turn/start'> | undefined {
177
+ for (let i = events.length - 1; i >= 0; i -= 1) {
178
+ const event = events[i];
179
+ if (event?.type === 'turn/start') return event;
180
+ }
181
+ return undefined;
182
+ }
183
+
184
+ function isMaintenanceTurnStart(event: SessionEvent<'turn/start'> | undefined): boolean {
185
+ // shortcut: only message-ops defines this marker; extend when another producer has a verified contract.
186
+ return (event?.data as { reason?: unknown } | undefined)?.reason === 'message-ops';
187
+ }
188
+
176
189
  /** Interpret host failure payloads without trusting persisted or plugin-provided event shapes. */
177
190
  function parseFailureFacts(value: unknown): FailureFacts | undefined {
178
191
  if (typeof value !== 'object' || value === null || Array.isArray(value)) return undefined;
@@ -474,6 +487,9 @@ export class AutoContinueRunner {
474
487
  return;
475
488
  }
476
489
  if (sessionState?.subagent) return;
490
+ if (sessionState?.maintenanceTurn !== undefined &&
491
+ sessionState.maintenanceTurn === (event.data as { turn?: number }).turn &&
492
+ event.type !== 'turn/start' && event.type !== 'turn/end') return;
477
493
  if (
478
494
  (event.type === 'user/message' || event.type === 'assistant/message') &&
479
495
  typeof event.surfaceOp === 'object' &&
@@ -750,6 +766,8 @@ export class AutoContinueRunner {
750
766
  switch (event.type) {
751
767
  case 'turn/start':
752
768
  state.running = true;
769
+ state.maintenanceTurn = isMaintenanceTurnStart(event) ? event.data.turn : undefined;
770
+ if (state.maintenanceTurn !== undefined) state.pendingRecoveryAt = 0;
753
771
  // 新回合开始: 清空上一步工具调用状态, 避免跨回合误用护栏
754
772
  state.tools.startTurn(event.seq);
755
773
  // loop guard 状态按回合重置
@@ -778,6 +796,12 @@ export class AutoContinueRunner {
778
796
  const turnOutput = state.outputTurn === event.data.turn ? state.turnOutput : 'unknown';
779
797
  state.turnOutput = 'unknown';
780
798
  state.outputTurn = undefined;
799
+ const maintenance = state.maintenanceTurn !== undefined && state.maintenanceTurn === event.data.turn;
800
+ state.maintenanceTurn = undefined;
801
+ if (maintenance) {
802
+ this.log(`跳过维护回合 ${sessionId}(message-ops): 不触发自动继续`);
803
+ break;
804
+ }
781
805
  const reason = event.data.reason;
782
806
  const reasonKind = readReasonKind(reason);
783
807
  if (reasonKind === undefined) {
@@ -1352,12 +1376,14 @@ export class AutoContinueRunner {
1352
1376
  if (event?.type === 'turn/end') { lastEnd = event; break; }
1353
1377
  }
1354
1378
  const reasonKind = readReasonKind(lastEnd?.data.reason);
1379
+ const lastStart = latestTurnStart(events);
1380
+ const maintenance = lastStart?.data.turn === lastEnd?.data.turn && isMaintenanceTurnStart(lastStart);
1355
1381
  const silent = reasonKind === 'no-visible-output' && config.resumeSilentTurns;
1356
1382
  const superseded = lastEnd !== undefined && events.some((event) =>
1357
1383
  event.seq > lastEnd!.seq && (event.type === 'turn/start' ||
1358
1384
  (event.type === 'user/message' && event.data.source.kind === 'user')),
1359
1385
  );
1360
- if (lastEnd === undefined || reasonKind === undefined || (!isNonHumanReason(reasonKind) && !silent) ||
1386
+ if (lastEnd === undefined || maintenance || reasonKind === undefined || (!isNonHumanReason(reasonKind) && !silent) ||
1361
1387
  lastEnd.time < now - config.freshMs || superseded) {
1362
1388
  this.bootScannedSessions.add(session);
1363
1389
  continue;
@@ -1495,16 +1521,13 @@ export class AutoContinueRunner {
1495
1521
  const event = events[i];
1496
1522
  if (event?.type === 'turn/end') { lastEnd = event; break; }
1497
1523
  }
1498
- let lastStart: SessionEvent<'turn/start'> | undefined;
1499
- for (let i = events.length - 1; i >= 0; i -= 1) {
1500
- const event = events[i];
1501
- if (event?.type === 'turn/start') { lastStart = event; break; }
1502
- }
1524
+ const lastStart = latestTurnStart(events);
1503
1525
  // 兜底分支: 真实 sessionQuery 冷读会把内存中的 interruptedTurnClosers
1504
1526
  // 折叠进返回日志(尾部即合成 turn/end), 上方 closed-tail 才是生产主路
1505
1527
  // 径。这里覆盖两种例外——不折叠的宿主实现, 以及 listSessions 快照与
1506
1528
  // observeSession 之间客户端刚打开、切在轮次中间的 live 视图。
1507
1529
  const openTurn = lastStart !== undefined && (lastEnd === undefined || lastStart.seq > lastEnd.seq);
1530
+ if (isMaintenanceTurnStart(lastStart) && (openTurn || lastStart?.data.turn === lastEnd?.data.turn)) continue;
1508
1531
  let reasonKind: string | undefined;
1509
1532
  let freshAt: number;
1510
1533
  if (openTurn) {
@@ -288,7 +288,8 @@ export function isTransientFailure(failure: FailureFacts, retryableErrorPatterns
288
288
  /insufficient.*(balance|quota)|billing|payment|quota.*exceeded.*(?!retry)/i.test(haystack) ||
289
289
  /model.*not[_-]?found|unknown[_-]?model|model[_-]?not[_-]?found|not.*support.*model/i.test(haystack) ||
290
290
  /context.*(length|limit|overflow|exceed)|token.*limit|max.*context/i.test(haystack) ||
291
- /invalid[_-]?request|bad[_-]?request/i.test(haystack);
291
+ /invalid[_-]?request|bad[_-]?request/i.test(haystack) ||
292
+ /prompt variable "\{\{[^"\r\n]+\}\}" has no value for this assembly/i.test(haystack);
292
293
  return !permanent;
293
294
  }
294
295
 
@@ -891,6 +892,8 @@ export interface SessionState {
891
892
  turnOutput: 'unknown' | 'empty' | 'silent' | 'visible';
892
893
  outputTurn: number | undefined;
893
894
  outputStartSeq: number;
895
+ /** message-ops maintenance window, which must not enter model recovery or loop accounting. */
896
+ maintenanceTurn?: number;
894
897
  /** 当前连续短句数(loop guard 信号 1: 空转)。 */
895
898
  shortRun: number;
896
899
  /** 最后一条短句的时间(时间窗判定用)。 */