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.
- package/CHANGELOG.md +38 -0
- package/README.md +14 -11
- package/README.zh.md +10 -10
- package/docs/releases/v0.17.0.md +62 -0
- package/docs/releases/v0.17.1-rc.1.md +55 -0
- package/docs/screenshots/01-settings-section.png +0 -0
- package/docs/screenshots/01-settings-section.zh.png +0 -0
- package/docs/screenshots/02-settings-card.png +0 -0
- package/docs/screenshots/02-settings-card.zh.png +0 -0
- package/docs/screenshots/07-card-panels.png +0 -0
- package/docs/screenshots/07-card-panels.zh.png +0 -0
- package/docs/screenshots/08-composer-toggle.png +0 -0
- package/docs/screenshots/08-composer-toggle.zh.png +0 -0
- package/docs/screenshots/README.md +8 -8
- package/lib/client.js +381 -118
- package/lib/client.js.map +4 -4
- package/lib/index.js +25 -10
- package/lib/types/client/auto-continue-icon.d.ts +1 -0
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/locales.d.ts +5 -8
- package/lib/types/client/mode-menu.d.ts +19 -0
- package/lib/types/client/native-toast.d.ts +17 -0
- package/lib/types/client/settings-card.d.ts +1 -1
- package/lib/types/shared/core.d.ts +2 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +5 -3
- package/src/client/auto-continue-icon.tsx +35 -0
- package/src/client/composer-toggle.tsx +58 -14
- package/src/client/index.ts +1 -1
- package/src/client/locales.ts +12 -18
- package/src/client/mode-menu.tsx +110 -0
- package/src/client/native-toast.tsx +44 -0
- package/src/client/settings-card.tsx +130 -24
- package/src/client/styles.ts +61 -40
- package/src/host/engine.ts +29 -6
- 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
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
319
|
+
const REPOSITORY_URL = 'https://github.com/HsiangNianian/dsh-auto-continue';
|
|
320
|
+
|
|
290
321
|
function RepositoryInvite({ t }: { t: (key: SettingsCardKey) => string }) {
|
|
291
|
-
return <
|
|
292
|
-
<span className="
|
|
293
|
-
<span
|
|
294
|
-
<a className="
|
|
295
|
-
<
|
|
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
|
-
</
|
|
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
|
|
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
|
-
<
|
|
475
|
-
|
|
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
|
-
{
|
|
502
|
-
|
|
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
|
}
|
package/src/client/styles.ts
CHANGED
|
@@ -6,16 +6,39 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const css = `
|
|
9
|
-
.dshAcComposer { display: inline-flex; align-items: center; flex-wrap: wrap; gap:
|
|
10
|
-
.
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
.
|
|
14
|
-
.
|
|
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
|
-
.
|
|
46
|
-
.
|
|
47
|
-
.
|
|
48
|
-
.
|
|
49
|
-
.
|
|
50
|
-
.
|
|
51
|
-
.
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
.
|
|
57
|
-
.
|
|
58
|
-
.
|
|
59
|
-
.
|
|
60
|
-
.
|
|
61
|
-
.
|
|
62
|
-
.
|
|
63
|
-
.
|
|
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);
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
.
|
|
135
|
-
.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
.
|
|
139
|
-
.
|
|
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
|
|
package/src/host/engine.ts
CHANGED
|
@@ -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
|
-
|
|
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) {
|
package/src/shared/core.ts
CHANGED
|
@@ -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
|
/** 最后一条短句的时间(时间窗判定用)。 */
|