dsh-client-auto-continue 0.7.5 → 0.8.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 +8 -12
- package/README.zh.md +8 -12
- package/lib/client.js +208 -1157
- package/lib/client.js.map +4 -4
- package/lib/index.js +993 -28
- package/lib/types/client/bridge.d.ts +39 -0
- package/lib/types/client/index.d.ts +11 -14
- package/lib/types/host/engine.d.ts +258 -0
- package/lib/types/index.d.ts +11 -5
- package/package.json +4 -3
- package/src/client/bridge.ts +202 -0
- package/src/client/engine.ts +2 -2
- package/src/client/index.ts +19 -29
- package/src/client/settings-card.tsx +9 -4
- package/src/host/engine.ts +1270 -0
- package/src/index.ts +97 -5
- package/tsconfig.json +2 -1
package/src/client/index.ts
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Auto-continue plugin, browser half.
|
|
2
|
+
* Auto-continue plugin, browser half (thin shell).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Since 0.8.0 the auto-continue ENGINE runs inside the host process (single
|
|
5
|
+
* instance — see src/host/engine.ts), so this half only:
|
|
6
|
+
* - registers the `auto-continue` settings card (`settings.plugin.item`),
|
|
7
|
+
* - subscribes to the host status bridge (SSE) and shows browser
|
|
8
|
+
* notifications with action buttons (Resume now / Pause 1h) via the bridge
|
|
9
|
+
* action endpoint,
|
|
10
|
+
* - feeds the card's stats / paused-sessions panels from the bridge state.
|
|
8
11
|
*/
|
|
9
12
|
import type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client';
|
|
10
|
-
import type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client';
|
|
11
13
|
// Type-only: pulls the locale plugin's Context merge (ctx.locale).
|
|
12
14
|
import type {} from '@deepseek-ai/dsh-client-locale/client';
|
|
13
15
|
// Type-only: pulls the settings-surface SlotMap merge and ctx.settingsScope.
|
|
14
16
|
import type {} from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
15
17
|
// Type-only: pulls the `settings.plugin.item` SlotMap merge.
|
|
16
18
|
import type {} from '@deepseek-ai/dsh-client-ui-settings-plugins/client';
|
|
17
|
-
import {
|
|
19
|
+
import { type AutoContinueSettings } from './engine.ts';
|
|
18
20
|
import { en, zh, type SettingsCardKey } from './locales.ts';
|
|
19
21
|
import {
|
|
20
22
|
AutoContinueSettingsCard,
|
|
21
23
|
AutoContinueSettingsCardController,
|
|
22
24
|
} from './settings-card.tsx';
|
|
23
|
-
|
|
24
|
-
/** 客户端根上下文的 connection 服务(由 dsh-client-connection 挂载)。 */
|
|
25
|
-
declare module '@deepseek-ai/cordis' {
|
|
26
|
-
interface Context {
|
|
27
|
-
connection: ConnectionHandle;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
25
|
+
import { startBridge } from './bridge.ts';
|
|
30
26
|
|
|
31
27
|
/** Dictionary namespace owned by this plugin. */
|
|
32
28
|
const NS = 'auto-continue';
|
|
33
29
|
|
|
34
|
-
/** Settings namespace the
|
|
30
|
+
/** Settings namespace the settings card edits (the host engine reads it). */
|
|
35
31
|
const SETTINGS_NS = 'auto-continue';
|
|
36
32
|
|
|
37
33
|
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
@@ -42,39 +38,33 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
|
42
38
|
}
|
|
43
39
|
|
|
44
40
|
/** Services required by this plugin. */
|
|
45
|
-
export const inject = ['slots', 'locale', '
|
|
41
|
+
export const inject = ['slots', 'locale', 'settingsScope'];
|
|
46
42
|
|
|
47
|
-
// 浏览器侧辅助(
|
|
43
|
+
// 浏览器侧辅助(设置卡片用): 桥状态读取与暂停解除。
|
|
48
44
|
export {
|
|
49
|
-
fillTemplate,
|
|
50
|
-
pauseSession,
|
|
51
45
|
pausedSessions,
|
|
52
46
|
readTodayStats,
|
|
53
47
|
resetTodayStats,
|
|
54
|
-
sessionPauseUntil,
|
|
55
48
|
unpauseSession,
|
|
56
|
-
} from './
|
|
57
|
-
|
|
58
|
-
/** 当前 runner(HMR 重载时先销毁旧的再建新的)。 */
|
|
59
|
-
let current: AutoContinueRunner | null = null;
|
|
49
|
+
} from './bridge.ts';
|
|
60
50
|
|
|
61
51
|
/**
|
|
62
|
-
* Plugin body:
|
|
52
|
+
* Plugin body: settings card + host status bridge (notifications, stats,
|
|
53
|
+
* paused sessions).
|
|
63
54
|
* @param ctx - client root context.
|
|
64
55
|
*/
|
|
65
56
|
export function apply(ctx: ClientContext): void {
|
|
66
57
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'auto-continue: dictionaries');
|
|
67
58
|
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
current?.dispose();
|
|
71
|
-
current = new AutoContinueRunner(ctx.connection.api, () => resolveConfig(scope.getSnapshot().value));
|
|
59
|
+
// 状态桥: 订阅 host 的通知与运行时状态, 弹浏览器通知并驱动卡片面板。
|
|
60
|
+
ctx.effect(() => startBridge(), 'auto-continue: host bridge');
|
|
72
61
|
|
|
73
62
|
// Plugin configuration card: one staged form over the `auto-continue`
|
|
74
63
|
// settings namespace, contributed to the plugin-configuration section
|
|
75
64
|
// (Settings → Plugins). Since DSH 0.1.0-rc.7 `settings.plugin.item` is a
|
|
76
65
|
// keyed slot dispatched by the settings namespace it edits, so the entry
|
|
77
66
|
// registers with `key` (the namespace), like the official cards.
|
|
67
|
+
const scope = ctx.settingsScope.bind<AutoContinueSettings>({ namespace: SETTINGS_NS });
|
|
78
68
|
const controller = new AutoContinueSettingsCardController(scope);
|
|
79
69
|
ctx.slots.inject('settings.plugin.item', () =>
|
|
80
70
|
ctx.slots.register(
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
import { useEffect, useState, type ReactNode } from 'react';
|
|
11
11
|
import { createSnapshotStore, type SettingsScope, type SnapshotStore } from '@deepseek-ai/dsh-client-runtime/client';
|
|
12
12
|
import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
13
|
+
import { DEFAULT_CONFIG, type AutoContinueSettings } from './engine.ts';
|
|
13
14
|
import {
|
|
14
|
-
DEFAULT_CONFIG,
|
|
15
15
|
pausedSessions,
|
|
16
16
|
readTodayStats,
|
|
17
17
|
resetTodayStats,
|
|
18
|
+
subscribeBridge,
|
|
18
19
|
unpauseSession,
|
|
19
|
-
|
|
20
|
-
} from './engine.ts';
|
|
20
|
+
} from './bridge.ts';
|
|
21
21
|
import type { SettingsCardKey } from './locales.ts';
|
|
22
22
|
import {
|
|
23
23
|
booleanField,
|
|
@@ -304,8 +304,13 @@ function LivePanels(props: { t: (key: SettingsCardKey) => string }) {
|
|
|
304
304
|
const { t } = props;
|
|
305
305
|
const [, refresh] = useState(0);
|
|
306
306
|
useEffect(() => {
|
|
307
|
+
// host 状态桥推送时刷新; 5 秒轮询兜底(桥短暂断线时)
|
|
308
|
+
const unsubscribe = subscribeBridge(() => refresh((value) => value + 1));
|
|
307
309
|
const timer = setInterval(() => refresh((value) => value + 1), 5000);
|
|
308
|
-
return () =>
|
|
310
|
+
return () => {
|
|
311
|
+
unsubscribe();
|
|
312
|
+
clearInterval(timer);
|
|
313
|
+
};
|
|
309
314
|
}, []);
|
|
310
315
|
const stats = readTodayStats();
|
|
311
316
|
const hasStats = stats.sent + stats.skipped + stats.recovered + stats.failed + stats.gaveUp + stats.looped > 0;
|