dsh-client-auto-continue 0.17.4 → 0.19.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/CHANGELOG.md +47 -0
- package/README.md +230 -281
- package/README.ru.md +382 -0
- package/README.zh.md +229 -279
- package/docs/auto-continue-workflow.archify.json +3 -3
- package/docs/auto-continue-workflow.en.archify.json +3 -3
- package/docs/auto-continue-workflow.en.html +1 -1
- package/docs/auto-continue-workflow.html +1 -1
- package/docs/auto-continue-workflow.ru.svg +530 -0
- package/docs/banner-ru-dark.svg +38 -0
- package/docs/banner-ru.svg +38 -0
- package/docs/demo-ru-static.svg +115 -0
- package/docs/demo-ru.svg +147 -0
- package/docs/releases/v0.18.0.md +58 -0
- package/docs/releases/v0.19.0.md +62 -0
- package/docs/social-preview.png +0 -0
- package/docs/social-preview.svg +30 -1
- package/lib/client.js +347 -100
- package/lib/client.js.map +3 -3
- package/lib/index.js +790 -49
- package/lib/types/client/auto-continue-icon.d.ts +7 -0
- package/lib/types/client/bridge.d.ts +2 -0
- package/lib/types/client/composer-toggle.d.ts +2 -0
- package/lib/types/client/locales.d.ts +19 -0
- package/lib/types/client/settings-card.d.ts +8 -0
- package/lib/types/host/connectivity.d.ts +4 -0
- package/lib/types/host/engine.d.ts +97 -5
- package/lib/types/index.d.ts +64 -0
- package/lib/types/shared/core.d.ts +54 -1
- package/locale/ru.json +6 -0
- package/package.json +6 -4
- package/scripts/build-docs-assets.mjs +126 -0
- package/src/client/auto-continue-icon.tsx +6 -27
- package/src/client/bridge.ts +26 -6
- package/src/client/composer-toggle.tsx +22 -11
- package/src/client/index.ts +5 -1
- package/src/client/locales.ts +241 -38
- package/src/client/settings-card.tsx +31 -4
- package/src/client/settings-notifications.ts +3 -2
- package/src/client/styles.ts +17 -19
- package/src/host/connectivity.ts +54 -0
- package/src/host/engine.ts +852 -40
- package/src/host/settings-migration.ts +1 -1
- package/src/index.ts +26 -1
- package/src/shared/core.ts +94 -3
package/src/client/styles.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const css = `
|
|
9
|
-
.dshAcComposer { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; min-height:
|
|
9
|
+
.dshAcComposer { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; min-height: 28px; max-width: 100%; font: inherit; }
|
|
10
10
|
.dshAcComposerCore { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
|
|
11
11
|
.dshAcComposerCore > span { min-width: 0; }
|
|
12
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; }
|
|
@@ -29,13 +29,24 @@ const css = `
|
|
|
29
29
|
.dshAcCard .dshAcMode:disabled { opacity: .5; }
|
|
30
30
|
.dshAcCard .dshAcMode:focus-visible { outline: 2px solid var(--dsh-ac-text); outline-offset: 3px; }
|
|
31
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
|
-
.
|
|
33
|
-
.
|
|
34
|
-
.
|
|
35
|
-
.
|
|
32
|
+
.dshAcIconBtn { position: relative; display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 999px; background-color: transparent; color: var(--dsw-alias-label-secondary, inherit); opacity: .9; cursor: pointer; transition: opacity .15s ease, background-color .15s ease, color .15s ease; }
|
|
33
|
+
.dshAcIconBtn > svg { display: block; width: 14px; height: 14px; }
|
|
34
|
+
.dshAcIconBtn[data-state="on"] { color: var(--dsw-alias-brand-primary, #4d8cff); opacity: 1; background-color: rgba(77, 140, 255, .14); background-color: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d8cff) 14%, transparent); }
|
|
35
|
+
.dshAcIconBtn[data-state="on"]:hover:not(:disabled) { background-color: rgba(77, 140, 255, .22); background-color: color-mix(in srgb, var(--dsw-alias-brand-primary, #4d8cff) 22%, transparent); }
|
|
36
|
+
.dshAcIconBtn[data-state="off"] { opacity: .5; }
|
|
37
|
+
.dshAcIconBtn[data-state="off"]:hover:not(:disabled) { opacity: .8; background: var(--dsw-alias-interactive-bg-hover); }
|
|
38
|
+
.dshAcIconBtn:disabled { cursor: default; opacity: .4; }
|
|
39
|
+
/* Reconnecting keeps the last known state visible, just dimmed. */
|
|
40
|
+
.dshAcIconBtn[data-stale="true"]:disabled { opacity: .65; }
|
|
41
|
+
.dshAcIconBtn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-brand-primary)); }
|
|
42
|
+
.dshAcGlyph { fill: none; stroke: currentColor; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; }
|
|
43
|
+
.dshAcIconBtn[data-state="on"] > .dshAcGlyph { stroke-width: 1.6; }
|
|
44
|
+
/* In the composer the mode name moves into the menu and tooltip; only the chevron stays. */
|
|
45
|
+
.dshAcComposer .dshAcModeTriggerLabel { display: none; }
|
|
46
|
+
.dshAcComposer .dshAcModeTrigger, .dshAcComposer .dshAcModeMenu { max-width: 28px; margin-left: -4px; padding: 0 2px; }
|
|
36
47
|
.dshAcSwitchTarget { display: inline-flex; align-items: center; flex: none; min-height: 32px; }
|
|
37
48
|
.dshAcSwitchTarget > button { position: relative; }
|
|
38
|
-
.dshAcSwitchTarget > button::before { content: ''; position: absolute; inset: -
|
|
49
|
+
.dshAcSwitchTarget > button::before { content: ''; position: absolute; inset: -4px; }
|
|
39
50
|
.dshAcComposerError { color: var(--dsw-alias-state-error-primary, var(--dsw-alias-label-secondary)); font-size: 12px; max-width: 160px; }
|
|
40
51
|
.dshAcComposerError:empty { display: none; }
|
|
41
52
|
.dshAcToastIcon { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
|
|
@@ -148,23 +159,10 @@ const css = `
|
|
|
148
159
|
.dshAcFooter { align-items: flex-start; flex-direction: column; gap: 10px; }
|
|
149
160
|
.dshAcFooter > div { width: 100%; justify-content: flex-end; }
|
|
150
161
|
}
|
|
151
|
-
/* Match the native picker breakpoints when the composer provides a query container. */
|
|
152
|
-
@container (width <= 640px) {
|
|
153
|
-
.dshAcComposerCore { gap: 5px; }
|
|
154
|
-
.dshAcModeTrigger, .dshAcModeMenu { max-width: 104px; padding: 0 3px 0 6px; }
|
|
155
|
-
}
|
|
156
|
-
@container (width <= 460px) {
|
|
157
|
-
.dshAcComposerText { display: none; }
|
|
158
|
-
.dshAcModeTrigger, .dshAcModeMenu { max-width: 28px; padding: 0 2px; }
|
|
159
|
-
.dshAcModeTriggerLabel { display: none; }
|
|
160
|
-
}
|
|
161
162
|
/* DS-Bot can remove the query container with display: contents. */
|
|
162
163
|
@media (max-width: 640px) {
|
|
163
164
|
.dshAcComposer { flex-direction: column; align-items: flex-start; width: min-content; }
|
|
164
165
|
.dshAcComposer > .dshAcComposerLabel { white-space: normal; }
|
|
165
|
-
.dshAcComposerCore { gap: 5px; }
|
|
166
|
-
.dshAcComposerText, .dshAcModeTriggerLabel { display: none; }
|
|
167
|
-
.dshAcModeTrigger, .dshAcModeMenu { max-width: 28px; padding: 0 2px; }
|
|
168
166
|
}
|
|
169
167
|
|
|
170
168
|
`;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import dns from 'node:dns';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
|
|
4
|
+
/** Resolves `true` when the host looks online. Must never reject. */
|
|
5
|
+
export type ConnectivityProbe = () => Promise<boolean>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 任一可解析即视为在线。覆盖国内外网络; 只做 DNS 解析, 不建立连接、不发请求。
|
|
9
|
+
* 走 fake-ip / TUN 代理时解析总会成功, 结果是"放行", 与关闭本功能等价, 不会误挂起。
|
|
10
|
+
*/
|
|
11
|
+
const PROBE_HOSTS = ['api.deepseek.com', 'www.baidu.com', 'one.one.one.one'] as const;
|
|
12
|
+
const PROBE_TIMEOUT_MS = 3000;
|
|
13
|
+
|
|
14
|
+
function hasExternalInterface(): boolean {
|
|
15
|
+
try {
|
|
16
|
+
return Object.values(os.networkInterfaces()).some(list =>
|
|
17
|
+
list?.some(entry => !entry.internal) ?? false);
|
|
18
|
+
} catch {
|
|
19
|
+
return true; // 读不到网卡信息时不猜, 放行
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** 显式 HTTP(S) 代理下本地 DNS 可能本就不可用, 只看网卡, 避免永久误判断网。 */
|
|
24
|
+
function usesExplicitProxy(): boolean {
|
|
25
|
+
const env = process.env;
|
|
26
|
+
return [env.HTTPS_PROXY, env.https_proxy, env.HTTP_PROXY, env.http_proxy, env.ALL_PROXY, env.all_proxy]
|
|
27
|
+
.some(value => typeof value === 'string' && value.trim() !== '');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function lookupWithin(host: string, ms: number): Promise<unknown> {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const timer = setTimeout(() => reject(new Error(`dns lookup timed out: ${host}`)), ms);
|
|
33
|
+
(timer as { unref?: () => void }).unref?.();
|
|
34
|
+
dns.promises.lookup(host).then(
|
|
35
|
+
value => { clearTimeout(timer); resolve(value); },
|
|
36
|
+
error => { clearTimeout(timer); reject(error); },
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Host-side connectivity check: a non-loopback interface plus one resolvable public name. */
|
|
42
|
+
export const probeConnectivity: ConnectivityProbe = async () => {
|
|
43
|
+
if (!hasExternalInterface()) return false;
|
|
44
|
+
if (usesExplicitProxy()) return true;
|
|
45
|
+
return new Promise<boolean>((resolve) => {
|
|
46
|
+
let pending: number = PROBE_HOSTS.length;
|
|
47
|
+
for (const host of PROBE_HOSTS) {
|
|
48
|
+
lookupWithin(host, PROBE_TIMEOUT_MS).then(
|
|
49
|
+
() => resolve(true),
|
|
50
|
+
() => { pending -= 1; if (pending === 0) resolve(false); },
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|