dsh-session-guard 0.1.2 → 0.2.0-beta.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/INSTALL.ko.md CHANGED
@@ -1,42 +1,83 @@
1
- # 설치 안내(공식 DSH CLI)
2
-
3
- - [한국어 설치 안내](./INSTALL.ko.md)
4
- - [English installation guide](./INSTALL.md)
5
- - [中文安装指南](./INSTALL.zh.md)
6
- - [日本語インストールガイド](./INSTALL.ja.md)
7
- - [한국어 README](./README.ko.md)
8
- - [English README](./README.en.md)
9
- - [中文 README](./README.md)
10
- - [日本語 README](./README.ja.md)
11
- - [Changelog](./CHANGELOG.md)
12
- - [日本語 changelog](./CHANGELOG.ja.md)
13
- - [한국어 changelog](./CHANGELOG.ko.md)
14
-
15
- ## 0. 사전 확인
16
-
17
- ```bash
18
- echo "DSH_HOME=${DSH_HOME:-$HOME/.dsh}"
19
- dsh --version
20
- ```
21
-
22
- ## 1. 설치
23
-
24
- ```bash
25
- dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
26
- ```
27
-
28
- dsh web을 재시작하고 페이지를 새로고침.
29
-
30
- ## 2. 검증
31
-
32
- **설정 → 플러그인 → session-guard** 열기. 스위치: `enabled`, `offPeakAutoResume`, `weekendMode`, `queueFallback`, `retryEnabled`.
33
-
34
- 세션 UI의 상태 배지 확인—현재 단계(NORMAL / PAUSED_PEAK) 표시.
35
-
36
- ## 3. 제거
37
-
38
- ```bash
39
- dsh plugin --profile web remove dsh-session-guard
40
- ```
41
-
42
- dsh web 재시작.
1
+ # 설치 안내(공식 DSH CLI)
2
+
3
+ - [한국어 설치 안내](./INSTALL.ko.md)
4
+ - [English installation guide](./INSTALL.md)
5
+ - [中文安装指南](./INSTALL.zh.md)
6
+ - [日本語インストールガイド](./INSTALL.ja.md)
7
+ - [한국어 README](./README.ko.md)
8
+ - [English README](./README.en.md)
9
+ - [中文 README](./README.md)
10
+ - [日本語 README](./README.ja.md)
11
+ - [Changelog](./CHANGELOG.md)
12
+ - [日本語 changelog](./CHANGELOG.ja.md)
13
+ - [한국어 changelog](./CHANGELOG.ko.md)
14
+
15
+ ## 0. 사전 확인
16
+
17
+ ```bash
18
+ echo "DSH_HOME=${DSH_HOME:-$HOME/.dsh}"
19
+ dsh --version
20
+ ```
21
+
22
+ ## 1. 설치
23
+
24
+ ```bash
25
+ dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
26
+ ```
27
+
28
+ dsh web을 재시작하고 페이지를 새로고침.
29
+
30
+ ## 2. 검증
31
+
32
+ **설정 → 플러그인 → session-guard** 열기. 스위치: `enabled`, `providerGuard`, `guardSubagents`,
33
+ `offPeakAutoResume`, `weekendMode`, `deferredResume`, `queueFallback`, `retryEnabled`;
34
+ 텍스트/목록 항목: `officialProviders`, `officialBaseURLs`, `deferredResumeText`.
35
+
36
+ 세션 UI의 상태 배지 확인—현재 단계(`高峰·拦官方` / `高峰·全部暂停` / `谷时` / `周末`) 표시.
37
+
38
+ 특정 라우트의 공식 소스 판정 확인(host 라우트, 재시작 불필요):
39
+
40
+ ```bash
41
+ curl -s 'http://127.0.0.1:3080/session-guard/provider?provider=deepseek-official'
42
+ # {"ok":true,"verdict":{"provider":"deepseek-official","official":true,"matchedBy":"endpoint","endpoint":"https://api.deepseek.com"}}
43
+ ```
44
+
45
+ 테스트 실행(네트워크·자격 증명 불필요):
46
+
47
+ ```bash
48
+ npm test
49
+ ```
50
+
51
+ ## 3. 업그레이드
52
+
53
+ ```bash
54
+ dsh plugin --profile web remove dsh-session-guard
55
+ dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
56
+ ```
57
+
58
+ dsh web을 재시작하고 페이지를 새로고침. 설정은 `$DSH_HOME/settings.yaml`의 `session-guard`
59
+ 네임스페이스에 있어 업그레이드 후에도 유지됩니다. 새 키(`providerGuard`, `deferredMode` 등)는
60
+ 건드리기 전까지 기본값입니다.
61
+
62
+ `0.1.3`/`0.1.4-beta.1`에서 `0.1.5-beta.1`로의 유일한 동작 변경은 피크 시 기본적으로
63
+ **공식 소스만** 차단한다는 점입니다. 예전의 전체 정지로 되돌리려면 `providerGuard: false`
64
+ (또는 `officialProviders` / `officialBaseURLs`로 판정을 좁히기).
65
+
66
+ ## 4. 문제 해결
67
+
68
+ | 증상 | 확인 |
69
+ |---|---|
70
+ | 피크인데 세션이 계속 실행 | `GET /session-guard/status` → `phase`가 `peak`; `GET /session-guard/settings` → `enabled: true` |
71
+ | 로컬 provider가 차단됨 | `GET /session-guard/provider?provider=<id>` → `matchedBy`가 `endpoint`/`unknown`이고 `official: false`여야 함. `explicit`이면 `officialProviders`에서 제거 |
72
+ | 공식 요청이 차단되지 않음 | `matchedBy: 'endpoint'`에 `official: false`면 `baseURL`이 `officialBaseURLs`에 없음; host를 추가하거나 라우트 id를 `officialProviders`에 추가 |
73
+ | 요청이 계속 보류됨 | `hold` 모드의 설계된 동작. 명시적 오류로 만들려면 `deferredMode: 'error'` 또는 `deferredMaxHoldMs`를 줄이기 |
74
+ | 피크 후 재개되지 않음 | `deferredResume`이 켜져 있어야 함(또는 `/resume`); 세션급은 `offPeakAutoResume` |
75
+ | 판정 진단 불가 | `GET /session-guard/diag` → `providerGuard`, `configurableProviders`, `held`, `deferred` |
76
+
77
+ ## 5. 제거
78
+
79
+ ```bash
80
+ dsh plugin --profile web remove dsh-session-guard
81
+ ```
82
+
83
+ dsh web 재시작. 언로드 시 보류 중인 요청은 해제(reject)되며 promise 누수는 없습니다.
package/INSTALL.md CHANGED
@@ -1,44 +1,86 @@
1
- # Installation Guide (Official DSH CLI)
2
-
3
- This guide uses only the official DSH `dsh plugin` command.
4
-
5
- - [English installation guide](./INSTALL.md)
6
- - [中文安装指南](./INSTALL.zh.md)
7
- - [日本語インストールガイド](./INSTALL.ja.md)
8
- - [한국어 설치 안내](./INSTALL.ko.md)
9
- - [English README](./README.en.md)
10
- - [中文 README](./README.md)
11
- - [日本語 README](./README.ja.md)
12
- - [한국어 README](./README.ko.md)
13
- - [Changelog](./CHANGELOG.md)
14
- - [日本語 changelog](./CHANGELOG.ja.md)
15
- - [한국어 changelog](./CHANGELOG.ko.md)
16
-
17
- ## 0. Prerequisites
18
-
19
- ```bash
20
- echo "DSH_HOME=${DSH_HOME:-$HOME/.dsh}"
21
- dsh --version
22
- ```
23
-
24
- ## 1. Install
25
-
26
- ```bash
27
- dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
28
- ```
29
-
30
- Restart dsh web and refresh the page.
31
-
32
- ## 2. Verify
33
-
34
- Open **Settings → Plugins → session-guard**. Toggles: `enabled`, `offPeakAutoResume`, `weekendMode`, `queueFallback`, `retryEnabled`.
35
-
36
- Check status badge in the session UI — it shows the current phase (NORMAL / PAUSED_PEAK).
37
-
38
- ## 3. Uninstall
39
-
40
- ```bash
41
- dsh plugin --profile web remove dsh-session-guard
42
- ```
43
-
44
- Restart dsh web.
1
+ # Installation Guide (Official DSH CLI)
2
+
3
+ This guide uses only the official DSH `dsh plugin` command.
4
+
5
+ - [English installation guide](./INSTALL.md)
6
+ - [中文安装指南](./INSTALL.zh.md)
7
+ - [日本語インストールガイド](./INSTALL.ja.md)
8
+ - [한국어 설치 안내](./INSTALL.ko.md)
9
+ - [English README](./README.en.md)
10
+ - [中文 README](./README.md)
11
+ - [日本語 README](./README.ja.md)
12
+ - [한국어 README](./README.ko.md)
13
+ - [Changelog](./CHANGELOG.md)
14
+ - [日本語 changelog](./CHANGELOG.ja.md)
15
+ - [한국어 changelog](./CHANGELOG.ko.md)
16
+
17
+ ## 0. Prerequisites
18
+
19
+ ```bash
20
+ echo "DSH_HOME=${DSH_HOME:-$HOME/.dsh}"
21
+ dsh --version
22
+ ```
23
+
24
+ ## 1. Install
25
+
26
+ ```bash
27
+ dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
28
+ ```
29
+
30
+ Restart dsh web and refresh the page.
31
+
32
+ ## 2. Verify
33
+
34
+ Open **Settings → Plugins → session-guard**. Toggles: `enabled`, `providerGuard`, `guardSubagents`,
35
+ `offPeakAutoResume`, `weekendMode`, `deferredResume`, `queueFallback`, `retryEnabled`; text/list
36
+ fields: `officialProviders`, `officialBaseURLs`, `deferredResumeText`.
37
+
38
+ Check the status badge in the session UI — it shows the current phase (`高峰·拦官方` / `高峰·全部暂停`
39
+ / `谷时` / `周末`).
40
+
41
+ Check the official-source verdict for one route (host route, no restart needed):
42
+
43
+ ```bash
44
+ curl -s 'http://127.0.0.1:3080/session-guard/provider?provider=deepseek-official'
45
+ # {"ok":true,"verdict":{"provider":"deepseek-official","official":true,"matchedBy":"endpoint","endpoint":"https://api.deepseek.com"}}
46
+ ```
47
+
48
+ Run the test suite (no network, no credentials):
49
+
50
+ ```bash
51
+ npm test
52
+ ```
53
+
54
+ ## 3. Upgrade
55
+
56
+ ```bash
57
+ dsh plugin --profile web remove dsh-session-guard
58
+ dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
59
+ ```
60
+
61
+ Restart dsh web and refresh the page. Settings live in `$DSH_HOME/settings.yaml` under the
62
+ `session-guard` namespace and survive the upgrade; new keys (`providerGuard`, `deferredMode`, …)
63
+ fall back to their defaults until you touch them.
64
+
65
+ From `0.1.3`/`0.1.4-beta.1` to `0.1.5-beta.1` the only behavior change is that peak hours now
66
+ block **only** official-source targets by default. To restore the old blanket behavior set
67
+ `providerGuard: false` (or `officialProviders` / `officialBaseURLs` to narrow the verdict).
68
+
69
+ ## 4. Troubleshooting
70
+
71
+ | Symptom | Check |
72
+ |---|---|
73
+ | Sessions still run during peak | `GET /session-guard/status` → `phase` must be `peak`; `GET /session-guard/settings` → `enabled: true` |
74
+ | A local provider is blocked during peak | `GET /session-guard/provider?provider=<id>` → `matchedBy` should be `endpoint`/`unknown` with `official: false`. If it says `explicit`, remove the id from `officialProviders` |
75
+ | An official request is NOT blocked | `matchedBy: 'endpoint'` with `official: false` means the route's `baseURL` is not in `officialBaseURLs`; add the host there, or add the route id to `officialProviders` |
76
+ | Requests hang instead of failing | That is `hold` mode by design. Set `deferredMode: 'error'` for an explicit error, or lower `deferredMaxHoldMs` |
77
+ | Nothing resumes after peak | `deferredResume` must be on (or run `/resume`); `offPeakAutoResume` controls session-level resume |
78
+ | Verdict diagnostics unavailable | `GET /session-guard/diag` → `providerGuard`, `configurableProviders`, `held`, `deferred` |
79
+
80
+ ## 5. Uninstall
81
+
82
+ ```bash
83
+ dsh plugin --profile web remove dsh-session-guard
84
+ ```
85
+
86
+ Restart dsh web. Held requests are released (rejected) on unload — no promise leaks.
package/INSTALL.zh.md CHANGED
@@ -1,42 +1,82 @@
1
- # 安装指南(官方 DSH CLI)
2
-
3
- - [安装指南](./INSTALL.zh.md)
4
- - [English installation guide](./INSTALL.md)
5
- - [日本語インストールガイド](./INSTALL.ja.md)
6
- - [한국어 설치 안내](./INSTALL.ko.md)
7
- - [中文 README](./README.md)
8
- - [English README](./README.en.md)
9
- - [日本語 README](./README.ja.md)
10
- - [한국어 README](./README.ko.md)
11
- - [版本更新日志](./CHANGELOG.md)
12
- - [日本語 changelog](./CHANGELOG.ja.md)
13
- - [한국어 changelog](./CHANGELOG.ko.md)
14
-
15
- ## 0. 前置条件
16
-
17
- ```bash
18
- echo "DSH_HOME=${DSH_HOME:-$HOME/.dsh}"
19
- dsh --version
20
- ```
21
-
22
- ## 1. 安装
23
-
24
- ```bash
25
- dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
26
- ```
27
-
28
- 重启 dsh web 并刷新页面。
29
-
30
- ## 2. 验证
31
-
32
- 打开「设置 → 插件 → session-guard」。开关:`enabled`、`offPeakAutoResume`、`weekendMode`、`queueFallback`、`retryEnabled`。
33
-
34
- 检查会话界面中的状态徽标——显示当前阶段(NORMAL / PAUSED_PEAK)。
35
-
36
- ## 3. 卸载
37
-
38
- ```bash
39
- dsh plugin --profile web remove dsh-session-guard
40
- ```
41
-
42
- 重启 dsh web。
1
+ # 安装指南(官方 DSH CLI)
2
+
3
+ - [安装指南](./INSTALL.zh.md)
4
+ - [English installation guide](./INSTALL.md)
5
+ - [日本語インストールガイド](./INSTALL.ja.md)
6
+ - [한국어 설치 안내](./INSTALL.ko.md)
7
+ - [中文 README](./README.md)
8
+ - [English README](./README.en.md)
9
+ - [日本語 README](./README.ja.md)
10
+ - [한국어 README](./README.ko.md)
11
+ - [版本更新日志](./CHANGELOG.md)
12
+ - [日本語 changelog](./CHANGELOG.ja.md)
13
+ - [한국어 changelog](./CHANGELOG.ko.md)
14
+
15
+ ## 0. 前置条件
16
+
17
+ ```bash
18
+ echo "DSH_HOME=${DSH_HOME:-$HOME/.dsh}"
19
+ dsh --version
20
+ ```
21
+
22
+ ## 1. 安装
23
+
24
+ ```bash
25
+ dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
26
+ ```
27
+
28
+ 重启 dsh web 并刷新页面。
29
+
30
+ ## 2. 验证
31
+
32
+ 打开「设置 → 插件 → session-guard」。开关:`enabled`、`providerGuard`、`guardSubagents`、
33
+ `offPeakAutoResume`、`weekendMode`、`deferredResume`、`queueFallback`、`retryEnabled`;
34
+ 文本/列表项:`officialProviders`、`officialBaseURLs`、`deferredResumeText`。
35
+
36
+ 检查会话界面中的状态徽标——显示当前阶段(`高峰·拦官方` / `高峰·全部暂停` / `谷时` / `周末`)。
37
+
38
+ 查看某个路由的官方源判定(host 路由,无需重启):
39
+
40
+ ```bash
41
+ curl -s 'http://127.0.0.1:3080/session-guard/provider?provider=deepseek-official'
42
+ # {"ok":true,"verdict":{"provider":"deepseek-official","official":true,"matchedBy":"endpoint","endpoint":"https://api.deepseek.com"}}
43
+ ```
44
+
45
+ 跑测试(不联网、不读凭据):
46
+
47
+ ```bash
48
+ npm test
49
+ ```
50
+
51
+ ## 3. 升级
52
+
53
+ ```bash
54
+ dsh plugin --profile web remove dsh-session-guard
55
+ dsh plugin --profile web add github:drscrewdriver/dsh-session-guard
56
+ ```
57
+
58
+ 重启 dsh web 并刷新页面。设置在 `$DSH_HOME/settings.yaml` 的 `session-guard` 命名空间下,升级不会丢;
59
+ 新增键(`providerGuard`、`deferredMode` 等)在你没动之前用默认值。
60
+
61
+ 从 `0.1.3`/`0.1.4-beta.1` 升到 `0.1.5-beta.1`,唯一的行为变化是高峰期默认**只拦官方源**。
62
+ 要恢复旧的「一律暂停」,把 `providerGuard` 设为 `false`(或用 `officialProviders` /
63
+ `officialBaseURLs` 收窄判定)。
64
+
65
+ ## 4. 故障排查
66
+
67
+ | 现象 | 怎么查 |
68
+ |---|---|
69
+ | 高峰期会话照常跑 | `GET /session-guard/status` → `phase` 必须是 `peak`;`GET /session-guard/settings` → `enabled: true` |
70
+ | 本地 provider 被拦 | `GET /session-guard/provider?provider=<id>` → `matchedBy` 应为 `endpoint`/`unknown` 且 `official: false`。若是 `explicit`,把它从 `officialProviders` 里删掉 |
71
+ | 官方请求没被拦 | `matchedBy: 'endpoint'` 且 `official: false` 说明该路由 `baseURL` 不在 `officialBaseURLs` 里;把 host 加进去,或把路由 id 加进 `officialProviders` |
72
+ | 请求挂着不报错 | 这是 `hold` 模式的预期行为。要显式报错设 `deferredMode: 'error'`,或调小 `deferredMaxHoldMs` |
73
+ | 退峰后不自动继续 | `deferredResume` 必须开着(或手动 `/resume`);会话级恢复看 `offPeakAutoResume` |
74
+ | 判定诊断不可用 | `GET /session-guard/diag` → `providerGuard`、`configurableProviders`、`held`、`deferred` |
75
+
76
+ ## 5. 卸载
77
+
78
+ ```bash
79
+ dsh plugin --profile web remove dsh-session-guard
80
+ ```
81
+
82
+ 重启 dsh web。卸载时挂起的请求会被释放(reject),不会泄漏 promise。