dsh-session-guard 0.1.1 → 0.1.2
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.ja.md +29 -0
- package/CHANGELOG.ko.md +29 -0
- package/CHANGELOG.md +29 -0
- package/INSTALL.ja.md +42 -0
- package/INSTALL.ko.md +42 -0
- package/INSTALL.md +44 -0
- package/INSTALL.zh.md +42 -0
- package/README.en.md +170 -0
- package/README.ja.md +106 -0
- package/README.ko.md +106 -0
- package/README.md +171 -128
- package/package.json +79 -69
- package/src/client/locales.ts +95 -0
- package/src/index.js +8 -4
- package/src/time.js +23 -7
package/CHANGELOG.ja.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 変更履歴
|
|
2
|
+
|
|
3
|
+
`dsh-session-guard` の主な変更を記録します。バージョンはセマンティックバージョニングに従います。
|
|
4
|
+
|
|
5
|
+
- [English changelog](./CHANGELOG.md)
|
|
6
|
+
- [日本語 changelog](./CHANGELOG.ja.md)
|
|
7
|
+
- [한국어 changelog](./CHANGELOG.ko.md)
|
|
8
|
+
|
|
9
|
+
## 0.1.1 — 2026-08-24
|
|
10
|
+
|
|
11
|
+
### 追加
|
|
12
|
+
|
|
13
|
+
- **バックエンド自動リトライ(D9)**:`turn/end` の瞬時失敗(error/429/max-tokens)はアダプティブバックオフの `followup(retryText)` で自動再開。永久失敗(認証/残高/モデル/コンテキスト上限)は停止。ユーザー介入または成功ターンで連続失敗カウントをリセット。
|
|
14
|
+
- **凍結/ゲート譲歩**:`isFrozen(sessionId)` が真のときリトライをスキップ、セッションゲートを迂回しません。
|
|
15
|
+
|
|
16
|
+
### 変更
|
|
17
|
+
|
|
18
|
+
- `sessionGuard` 冗余ポートが `state(sessionId)` を公開し、`{ queueLocked, lockReason, paused, taskControlAvailable, taskControl }` を返すように。
|
|
19
|
+
- HTTP ルート `GET /session-guard/diag` がリトライ状態を含むランタイム診断を返すように。
|
|
20
|
+
|
|
21
|
+
### 修正
|
|
22
|
+
|
|
23
|
+
- 週末検出を裸 `getUTCDay()` から `Intl.DateTimeFormat`(設定タイムゾーン使用)に変更し、北京タイムゾーンの 8 時間境界バグを修正。
|
|
24
|
+
|
|
25
|
+
## 0.1.0 — 2026-08-18
|
|
26
|
+
|
|
27
|
+
### 追加
|
|
28
|
+
|
|
29
|
+
- 初回リリース:ピーク自動一時停止(グローバル)、週末モード、`sessionGuard` 冗余ポート + RPC ブリッジによるセッションごとの凍結/再開、カスタムセッションゲート、設定パネル。
|
package/CHANGELOG.ko.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# 변경 기록
|
|
2
|
+
|
|
3
|
+
`dsh-session-guard`의 주요 변경 사항을 기록합니다. 버전은 시맨틱 버저닝을 따릅니다.
|
|
4
|
+
|
|
5
|
+
- [English changelog](./CHANGELOG.md)
|
|
6
|
+
- [日本語 changelog](./CHANGELOG.ja.md)
|
|
7
|
+
- [한국어 changelog](./CHANGELOG.ko.md)
|
|
8
|
+
|
|
9
|
+
## 0.1.1 — 2026-08-24
|
|
10
|
+
|
|
11
|
+
### 추가
|
|
12
|
+
|
|
13
|
+
- **백엔드 자동 재시도(D9)**: `turn/end` 일시적 실패(error/429/max-tokens)는 적응형 백오프의 `followup(retryText)`로 자동 재개; 영구 실패(인증/잔액/모델/컨텍스트 제한)는 중지; 사용자 개입 또는 성공 턴에서 연속 실패 카운트 리셋.
|
|
14
|
+
- **동결/게이트 양보**: `isFrozen(sessionId)`가 참일 때 재시도 건너뜀, 세션 게이트를 우회하지 않음.
|
|
15
|
+
|
|
16
|
+
### 변경
|
|
17
|
+
|
|
18
|
+
- `sessionGuard` 중복 포트가 `state(sessionId)`를 노출하여 `{ queueLocked, lockReason, paused, taskControlAvailable, taskControl }` 반환.
|
|
19
|
+
- HTTP 라우트 `GET /session-guard/diag`가 재시도 상태를 포함한 런타임 진단 반환.
|
|
20
|
+
|
|
21
|
+
### 수정
|
|
22
|
+
|
|
23
|
+
- 주말 감지를 벌거벗은 `getUTCDay()`에서 `Intl.DateTimeFormat`(설정된 타임존 사용)으로 변경, 베이징 타임존 8시간 경계 버그 수정.
|
|
24
|
+
|
|
25
|
+
## 0.1.0 — 2026-08-18
|
|
26
|
+
|
|
27
|
+
### 추가
|
|
28
|
+
|
|
29
|
+
- 최초 릴리스: 피크 자동 일시정지(글로벌), 주말 모드, `sessionGuard` 중복 포트 + RPC 브리지 기반 세션별 동결/재개, 커스텀 세션 게이트, 설정 패널.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `dsh-session-guard` are recorded here. Versions follow semver.
|
|
4
|
+
|
|
5
|
+
- [English changelog](./CHANGELOG.md)
|
|
6
|
+
- [日本語 changelog](./CHANGELOG.ja.md)
|
|
7
|
+
- [한국어 changelog](./CHANGELOG.ko.md)
|
|
8
|
+
|
|
9
|
+
## 0.1.1 — 2026-08-24
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **Backend auto-retry (D9)**: `turn/end` transient failures (error/429/max-tokens) trigger adaptive-backoff `followup(retryText)` resume; permanent failures (auth/balance/model/context limit) stop; user intervention or successful turn resets consecutive failure count.
|
|
14
|
+
- **Freeze/gate yield**: retry skips when `isFrozen(sessionId)` is true (queueLocked / paused / taskControl paused), never bypasses the session gate.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- `sessionGuard` redundant port now exposes `state(sessionId)` returning `{ queueLocked, lockReason, paused, taskControlAvailable, taskControl }`.
|
|
19
|
+
- HTTP route `GET /session-guard/diag` returns runtime diagnostics including retry state.
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Weekend detection now uses `Intl.DateTimeFormat` with the configured timezone instead of bare `getUTCDay()`, fixing an 8-hour boundary bug for Beijing timezone.
|
|
24
|
+
|
|
25
|
+
## 0.1.0 — 2026-08-18
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Initial release: peak auto-pause (global), weekend mode, per-session freeze/resume via `sessionGuard` redundant port + RPC bridge, custom session gate (`agent.cancel keepInbox + goals.pause + session/event safe boundary + followup resume`), settings panel (Settings → Plugins → session-guard).
|
package/INSTALL.ja.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# インストールガイド(公式 DSH CLI)
|
|
2
|
+
|
|
3
|
+
- [日本語インストールガイド](./INSTALL.ja.md)
|
|
4
|
+
- [English installation guide](./INSTALL.md)
|
|
5
|
+
- [中文安装指南](./INSTALL.zh.md)
|
|
6
|
+
- [한국어 설치 안내](./INSTALL.ko.md)
|
|
7
|
+
- [日本語 README](./README.ja.md)
|
|
8
|
+
- [English README](./README.en.md)
|
|
9
|
+
- [中文 README](./README.md)
|
|
10
|
+
- [한국어 README](./README.ko.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 を再起動。
|
package/INSTALL.ko.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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 재시작.
|
package/INSTALL.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
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.
|
package/INSTALL.zh.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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。
|
package/README.en.md
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>Peak auto session gate: weekend mode + peak auto-pause + session-level freeze + backend auto-retry</strong>
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<strong>English</strong> · <a href="README.md">中文</a> · <a href="README.ja.md">日本語</a> · <a href="README.ko.md">한국어</a>
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-263146?style=flat-square"></a>
|
|
9
|
+
<img src="https://camo.githubusercontent.com/2c11fb2e0e14bb9985c5acbe61123a7441c5ee63aa27fa6e04e2a707ebfd6022/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6473682d2d706c7567696e2d72656164792d3437384342463f6c6f676f3d646565707365656b266c6f676f436f6c6f723d7768697465" alt="dsh-plugin" style="max-width: 100%;">
|
|
10
|
+
<img alt="Public beta" src="https://img.shields.io/badge/status-public%20beta-7da1de?style=flat-square">
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
# dsh-session-guard
|
|
14
|
+
|
|
15
|
+
- [English README](./README.en.md)
|
|
16
|
+
- [中文 README](./README.md)
|
|
17
|
+
- [日本語 README](./README.ja.md)
|
|
18
|
+
- [한국어 README](./README.ko.md)
|
|
19
|
+
- [Installation guide](./INSTALL.md)
|
|
20
|
+
- [中文安装指南](./INSTALL.zh.md)
|
|
21
|
+
- [日本語インストールガイド](./INSTALL.ja.md)
|
|
22
|
+
- [한국어 설치 안내](./INSTALL.ko.md)
|
|
23
|
+
- [Changelog](./CHANGELOG.md)
|
|
24
|
+
- [日本語 changelog](./CHANGELOG.ja.md)
|
|
25
|
+
- [한국어 changelog](./CHANGELOG.ko.md)
|
|
26
|
+
|
|
27
|
+
> **Compatibility note:** v0.1.1 ships Japanese (`ja`) and Korean (`ko`) dictionaries, but the current official DSH releases expose only `zh` and `en` through `LocaleRuntime`. On stock DSH, selecting `ja` or `ko` fails with `locale "<id>" is not registered`. These languages will work after official DSH adds the locale IDs. Advanced users can use a DSH fork that updates `LOCALE_IDS` and `LOCALES` labels, then rebuild.
|
|
28
|
+
|
|
29
|
+
> Automatically pause running sessions during peak pricing hours and resume during off-peak/weekend; pair with input-traffic's freeze button for **per-session** locking; backend **auto-retry** yields during freeze/gate. Core based on a custom session gate (`agent.cancel keepInbox + goals.pause + session/event safe boundary + followup resume`), no longer depending on dsh-task-control.
|
|
30
|
+
|
|
31
|
+
A cordis plugin assembled via the `dsh plugin` command and a bundle patch — no dsh source changes, no PR required.
|
|
32
|
+
|
|
33
|
+
> 💡 **Why recommended**: DeepSeek moved to **peak/off-peak billing** on 2026-08-17 — the peak window (Beijing time 09:00-12:00, 14:00-18:00) costs **2×** the off-peak rate. This plugin auto-pauses running sessions during peak and auto-resumes off-peak, saving up to **50%** on long-running sessions; manual freeze (via input-traffic button) provides per-session precision.
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
- **Weekend mode**: detects weekends (timezone-correct via `Intl.DateTimeFormat`, no裸 `getUTCDay()` Beijing-boundary 8-hour bug) → weekends ignore peak/off-peak, run freely.
|
|
38
|
+
- **Peak auto-pause (global)**: on peak entry (and not weekend), auto-pauses all running root sessions; off-peak auto-resumes all — **global switch, no manual action needed**.
|
|
39
|
+
- **Per-session freeze / resume**: `sessionGuard` redundant port + `POST /session-guard/rpc`, input-traffic freeze button per-session passthrough; also provides `/pause /resume /cancel` manual commands.
|
|
40
|
+
- **Backend auto-retry (D9)**: turn/end transient failures (error/429/max-tokens) auto-retry with adaptive backoff; permanent failures stop; **yields during freeze/gate**, never bypasses the session gate.
|
|
41
|
+
- **Fail-open**: custom session gate unavailable, session-guard not installed, settings service missing — all silently degrade, never crash on dependencies.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
dsh plugin --profile web add github:<owner>/dsh-session-guard
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Restart dsh web and refresh the page after installation.
|
|
50
|
+
|
|
51
|
+
## Settings (Settings → Plugins → session-guard, simple toggles)
|
|
52
|
+
|
|
53
|
+
| Toggle | Default | Description |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `enabled` | on | **Peak auto-pause**: auto-pause running sessions during peak hours |
|
|
56
|
+
| `offPeakAutoResume` | on | **Off-peak auto-resume**: auto-resume paused sessions off-peak; off = no auto-resume (manual required) |
|
|
57
|
+
| `weekendMode` | on | **Weekend mode**: detect weekends → no auto-pause on weekends (no peak, run freely) |
|
|
58
|
+
| `queueFallback` | on | Fallback to lock-wait queue when custom session gate is unavailable (fail-open) |
|
|
59
|
+
| `retryEnabled` | off | **Auto-retry (backend)**: transient failure auto-resume (off by default, conservative) |
|
|
60
|
+
|
|
61
|
+
Additional configuration:
|
|
62
|
+
|
|
63
|
+
- `timezone` (default Asia/Shanghai) — used for **weekend detection** and badge display; **does not affect peak/off-peak detection** (always Beijing time);
|
|
64
|
+
- `peakWindows` (default 09:00–12:00 / 14:00–18:00) — peak windows in Beijing time (UTC+8), matching DeepSeek's official billing;
|
|
65
|
+
- `pauseMode` (`safe`/`force`), `pauseReason` (`wait`/`stop`);
|
|
66
|
+
- Retry parameters: `retryText`, `retryGraceMs`, `retryCooldownMs`, `retryBackoffFactor`, `retryBackoffMaxMs`, `retryMaxConsecutive`.
|
|
67
|
+
|
|
68
|
+
## Behavior
|
|
69
|
+
|
|
70
|
+
### Peak auto-gate (global)
|
|
71
|
+
|
|
72
|
+
- **Peak entry** (and not weekend): calls `gate.stopNextTurn` on all running root sessions — custom session gate truly pauses (doesn't interrupt reasoning, pauses at safe boundary before next tool dispatch), or falls back to lock-wait queue per `queueFallback`;
|
|
73
|
+
- **Off-peak / weekend**: `gate.resume` **all** sessions (auto-resume, no manual action) — controlled by `offPeakAutoResume` toggle;
|
|
74
|
+
- **Peak timezone**: hardcoded to Beijing time (`Asia/Shanghai`), matching DeepSeek's official billing basis — not affected by the `timezone` setting;
|
|
75
|
+
- State machine: single-instance `NORMAL ↔ PAUSED_PEAK` (`scheduler.js`), driven by a single 30s tick.
|
|
76
|
+
|
|
77
|
+
### Session locking (freeze)
|
|
78
|
+
|
|
79
|
+
- **Redundant port**: `ctx.provide('sessionGuard', service)` — `stopNextTurn(sessionId)` / `resume(sessionId)` / `lockQueue(sessionId)` / `unlockQueue(sessionId)` / `state(sessionId)`;
|
|
80
|
+
- **RPC bridge**: `POST /session-guard/rpc { action, sessionId }` — input-traffic freeze button calls `stopNextTurn` / `resume` per `sessionId`; silently skipped when session-guard is not installed (fail-open);
|
|
81
|
+
- **Manual commands**: `/pause [force|safe] [stop|wait]`, `/resume [confirm] [rerun|skip]`, `/cancel` —作用于调用它的会话.
|
|
82
|
+
|
|
83
|
+
### Backend auto-retry (D9)
|
|
84
|
+
|
|
85
|
+
Listens to `turn/end`, classifies failures:
|
|
86
|
+
|
|
87
|
+
- **Transient** (error/429/max-tokens) → adaptive backoff auto `followup(retryText)` resume;
|
|
88
|
+
- **Permanent** (auth/balance/model/context limit) → stop;
|
|
89
|
+
- **Yields during freeze/gate**: `isFrozen(sessionId)` true (queueLocked / paused / taskControl paused) → no retry;
|
|
90
|
+
- User intervention or successful turn resets consecutive failure count.
|
|
91
|
+
|
|
92
|
+
### Status badge (frontend display)
|
|
93
|
+
|
|
94
|
+
A **read-only** status badge is rendered on the right side of the composer input area, reflecting the current phase in real time:
|
|
95
|
+
|
|
96
|
+
| Phase | Label | CSS class | Meaning |
|
|
97
|
+
|---|---|---|---|
|
|
98
|
+
| `peak` | 高峰 | `sg-peak` | Weekday peak hours, sessions auto-paused |
|
|
99
|
+
| `off-peak` | 谷时 | `sg-off` | Off-peak hours, sessions running normally |
|
|
100
|
+
| `weekend` | 周末 | `sg-weekend` | Weekend (when weekend mode is on), ignore peak/off-peak |
|
|
101
|
+
|
|
102
|
+
- **Polling**: requests `GET /session-guard/status` every 15 seconds for the global `phase`;
|
|
103
|
+
- **Fail-open**: route unreachable, network error, or `enabled` off → badge silently hidden, no session affected;
|
|
104
|
+
- **Independent of input-traffic**: the badge is rendered by session-guard's client code alone — **input-traffic is not required**. input-traffic only provides the freeze button, which is unrelated to the badge;
|
|
105
|
+
- **Tooltip**: hovering shows `phase · timezone · weekend mode` (e.g. `周末 · Asia/Shanghai · 周末模式`).
|
|
106
|
+
|
|
107
|
+
### Timezone handling
|
|
108
|
+
|
|
109
|
+
- **Peak/off-peak detection**: always uses **Beijing time (UTC+8)** via `BILLING_TIMEZONE = 'Asia/Shanghai'`, matching DeepSeek's official billing basis. This is **hardcoded** and not affected by the `timezone` setting;
|
|
110
|
+
- **Weekend detection**: uses the user-configured `timezone` (e.g. `Asia/Tokyo`, `Asia/Seoul`), because "weekend" is a local concept;
|
|
111
|
+
- `Intl.DateTimeFormat` is used for timezone projection — invalid IANA timezone names throw `RangeError`, caught by fail-open and falling back to `Asia/Shanghai`;
|
|
112
|
+
- Peak windows are **left-closed, right-open** `[start, end)`, supporting cross-midnight windows (e.g. `22:00–06:00`);
|
|
113
|
+
- The `timezone` setting works identically across all UI languages (zh/en/ja/ko) — IANA timezone names are locale-independent.
|
|
114
|
+
|
|
115
|
+
### Coordination with input-traffic
|
|
116
|
+
|
|
117
|
+
- input-traffic's **freeze button** triggers via `sessionGuard.stopNextTurn` (RPC, per-session) on the server side;
|
|
118
|
+
- input-traffic **only does freeze enhancement** (queue freeze/unfreeze + composer block), retry is handled by this plugin's backend;
|
|
119
|
+
- Both share "session isolation" semantics: input-traffic freeze queue keyed by sessionId, session-guard RPC also keyed by sessionId.
|
|
120
|
+
|
|
121
|
+
## Redundant port `sessionGuard`
|
|
122
|
+
|
|
123
|
+
```js
|
|
124
|
+
{
|
|
125
|
+
stopNextTurn(sessionId, opts),
|
|
126
|
+
resume(sessionId, opts),
|
|
127
|
+
lockQueue(sessionId, reason),
|
|
128
|
+
unlockQueue(sessionId),
|
|
129
|
+
state(sessionId),
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## HTTP routes
|
|
134
|
+
|
|
135
|
+
- `GET /session-guard/state?session=<id>` — session state
|
|
136
|
+
- `GET /session-guard/settings` — settings + taskControl availability
|
|
137
|
+
- `GET /session-guard/status` — global current phase (status badge polling)
|
|
138
|
+
- `GET /session-guard/diag` — runtime diagnostics
|
|
139
|
+
- `POST /session-guard/rpc` — `{ action: stopNextTurn|resume|lockQueue|unlockQueue|state, sessionId }`
|
|
140
|
+
|
|
141
|
+
## State storage
|
|
142
|
+
|
|
143
|
+
Per-session JSON: `$DSH_HOME/.dsh/session-guard/<sessionId>.json` (atomic write; `DSH_SESSION_GUARD_STATE_DIR` override).
|
|
144
|
+
|
|
145
|
+
## Tests
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
npm test # node --test tests/*.test.mjs (timezone/weekend/state-machine/session-gate/bridge/retry)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Modules
|
|
152
|
+
|
|
153
|
+
| File | Responsibility |
|
|
154
|
+
|---|---|
|
|
155
|
+
| `src/time.js` | Peak/weekend detection (timezone-correct) |
|
|
156
|
+
| `src/scheduler.js` | Pure state machine NORMAL ↔ PAUSED_PEAK |
|
|
157
|
+
| `src/pause-gate.js` | Custom session gate engine |
|
|
158
|
+
| `src/pause-store.js` | Custom pause state persistence |
|
|
159
|
+
| `src/gate.js` | Session gate driver (custom true pause / fallback lock queue, fail-open) |
|
|
160
|
+
| `src/bridge.js` | `sessionGuard` redundant port |
|
|
161
|
+
| `src/retry.js` | Backend auto-retry (failure classification/backoff/freeze yield) |
|
|
162
|
+
| `src/detect.js` | Auto-detection (host taskControl / client input-traffic bridge) |
|
|
163
|
+
| `src/store.js` | Per-session persistent state |
|
|
164
|
+
| `src/settings.js` | Settings sub-panel (schemastery schema + fail-open registration) |
|
|
165
|
+
| `src/index.js` | Host apply (settings/routes/tick/provide service/retry wiring) |
|
|
166
|
+
| `src/client/` | Browser half (status badge + settings card) |
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
|
|
170
|
+
MIT — see [LICENSE](LICENSE).
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>ピーク自動セッションゲート:週末モード + ピーク自動一時停止 + セッション級凍結 + バックエンド自動リトライ</strong>
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="README.en.md">English</a> · <a href="README.md">中文</a> · <strong>日本語</strong> · <a href="README.ko.md">한국어</a>
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-263146?style=flat-square"></a>
|
|
9
|
+
<img src="https://camo.githubusercontent.com/2c11fb2e0e14bb9985c5acbe61123a7441c5ee63aa27fa6e04e2a707ebfd6022/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6473682d2d706c7567696e2d72656164792d3437384342463f6c6f676f3d646565707365656b266c6f676f436f6c6f723d7768697465" alt="dsh-plugin" style="max-width: 100%;">
|
|
10
|
+
<img alt="Public beta" src="https://img.shields.io/badge/status-public%20beta-7da1de?style=flat-square">
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
# dsh-session-guard
|
|
14
|
+
|
|
15
|
+
- [English README](./README.en.md)
|
|
16
|
+
- [中文 README](./README.md)
|
|
17
|
+
- [日本語 README](./README.ja.md)
|
|
18
|
+
- [한국어 README](./README.ko.md)
|
|
19
|
+
- [Installation guide](./INSTALL.md)
|
|
20
|
+
- [中文安装指南](./INSTALL.zh.md)
|
|
21
|
+
- [日本語インストールガイド](./INSTALL.ja.md)
|
|
22
|
+
- [한국어 설치 안내](./INSTALL.ko.md)
|
|
23
|
+
- [Changelog](./CHANGELOG.md)
|
|
24
|
+
- [日本語 changelog](./CHANGELOG.ja.md)
|
|
25
|
+
- [한국어 changelog](./CHANGELOG.ko.md)
|
|
26
|
+
|
|
27
|
+
> **互換性について:** v0.1.1 には日本語(`ja`)と韓国語(`ko`)の辞書が含まれていますが、現在の公式 DSH リリースは `LocaleRuntime` 経由で `zh` と `en` のみを提供しています。純正 DSH で `ja` または `ko` を選択すると `locale "<id>" is not registered` で失敗します。公式 DSH が对应的 locale ID を追加するまで利用できません。上級ユーザーは DSH フォークを保守して更新してください。
|
|
28
|
+
|
|
29
|
+
> ピーク課金時間帯に実行中のセッションを自動一時停止し、オフピーク/週末に自動再開。input-traffic の凍結ボタンと連携して**セッション級**ロックを実現。バックエンド**自動リトライ**は凍結/ゲート期間中は譲歩。カスタムセッションゲート(`agent.cancel keepInbox + goals.pause + session/event 安全境界 + followup 再開`)に基づき、dsh-task-control に依存しません。
|
|
30
|
+
|
|
31
|
+
`dsh plugin` コマンドで组装 + バンドルパッチで装配する cordis プラグイン。dsh ソース変更も PR も不要。
|
|
32
|
+
|
|
33
|
+
> 💡 **推奨理由**:DeepSeek は 2026-08-17 から**峰谷課金**を開始しました。ピーク時間帯の単価はオフピークの 2 倍。本プラグインはピーク時に実行セッションを自動一時停止、オフピーク時に自動再開し、長時間セッションの費用を最大 **50%** 削減。手動凍結(input-traffic ボタン経由)でセッションごとの精密制御が可能。
|
|
34
|
+
|
|
35
|
+
## 機能
|
|
36
|
+
|
|
37
|
+
- **週末モード**:`Intl.DateTimeFormat` で週末を正しく識別(タイムゾーン正確)→ 週末は峰谷を無視して自由実行。
|
|
38
|
+
- **ピーク自動一時停止(グローバル)**:ピーク入場時(かつ非週末)、全 running ルートセッションを自動一時停止。退峰時自動再開——**グローバルスイッチ、手動不要**。
|
|
39
|
+
- **セッション級凍結/再開**:`sessionGuard` 冗余ポート + `POST /session-guard/rpc`、input-traffic 凍結ボタンでセッションごと透伝。`/pause /resume /cancel` 手動コマンドも提供。
|
|
40
|
+
- **バックエンド自動リトライ(D9)**:turn/end 瞬時失敗(error/429/max-tokens)はアダプティブバックオフで自動再試行。永久失敗は停止。**凍結/ゲート期間中は譲歩**、セッションゲートを迂回しません。
|
|
41
|
+
- **fail-open**:カスタムセッションゲート利用不可、session-guard 未インストール、設定サービス欠如——すべて静的降格、依存でクラッシュしません。
|
|
42
|
+
|
|
43
|
+
## インストール
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
dsh plugin --profile web add github:<owner>/dsh-session-guard
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
インストール後 dsh web を再起動し、ページをリフレッシュ。
|
|
50
|
+
|
|
51
|
+
## 設定(設定 → プラグイン → session-guard)
|
|
52
|
+
|
|
53
|
+
| スイッチ | デフォルト | 説明 |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `enabled` | on | **ピーク自動一時停止**:ピーク時間帯に実行セッションを自動一時停止 |
|
|
56
|
+
| `offPeakAutoResume` | on | **オフピーク自動再開**:オフピーク時に一時停止セッションを自動再開 |
|
|
57
|
+
| `weekendMode` | on | **週末モード**:週末を認識→週末は自動一時停止しない |
|
|
58
|
+
| `queueFallback` | on | カスタムセッションゲート利用不可時にロック待機キューにフォールバック(fail-open) |
|
|
59
|
+
| `retryEnabled` | off | **自動リトライ(バックエンド)**:瞬時失敗自動再試行(デフォルトオフ、保守的) |
|
|
60
|
+
|
|
61
|
+
追加設定:
|
|
62
|
+
|
|
63
|
+
- `timezone`(デフォルト Asia/Shanghai)——**週末判定**とバッジ表示に使用。**峰谷判定には影響しない**(峰谷は常に北京時間);
|
|
64
|
+
- `peakWindows`(デフォルト 09:00–12:00 / 14:00–18:00)——北京時間(UTC+8)の峰谷ウィンドウ。DeepSeek 公式課金と一致;
|
|
65
|
+
- `pauseMode`(`safe`/`force`)、`pauseReason`(`wait`/`stop`);
|
|
66
|
+
- リトライパラメータ:`retryText`、`retryGraceMs`、`retryCooldownMs`、`retryBackoffFactor`、`retryBackoffMaxMs`、`retryMaxConsecutive`。
|
|
67
|
+
|
|
68
|
+
## 動作
|
|
69
|
+
|
|
70
|
+
### ピーク自動ゲート(グローバル)
|
|
71
|
+
|
|
72
|
+
- **ピーク入り**(かつ非週末):全 running ルートセッションに `gate.stopNextTurn` を呼び出し——カスタムセッションゲートで真の一時停止(推論を中断せず、安全境界で一時停止)、`queueFallback` でロック待機キューにフォールバック;
|
|
73
|
+
- **退峰 / 週末**:`gate.resume` **全**セッション(自動再開、手動不要)——`offPeakAutoResume` スイッチで制御;
|
|
74
|
+
- **峰谷タイムゾーン**:常に北京時間(`Asia/Shanghai`)を使用。DeepSeek 公式課金基準に一致。`timezone` 設定の影響を受けません;
|
|
75
|
+
- 状態機械:単一インスタンス `NORMAL ↔ PAUSED_PEAK`(`scheduler.js`)、単一 30s tick で駆動。
|
|
76
|
+
|
|
77
|
+
### タイムゾーン処理
|
|
78
|
+
|
|
79
|
+
- **峰谷判定**:常に **北京時間(UTC+8)** を使用(`BILLING_TIMEZONE = 'Asia/Shanghai'`)。DeepSeek 公式課金基準。`timezone` 設定で変更不可(ハードコード);
|
|
80
|
+
- **週末判定**:ユーザー設定の `timezone`(例:`Asia/Tokyo`、`Asia/Seoul`)を使用。「週末」はローカル概念のため;
|
|
81
|
+
- `Intl.DateTimeFormat` でタイムゾーン投影。無効な IANA タイムゾーン名は `RangeError` で fail-open し `Asia/Shanghai` にフォールバック;
|
|
82
|
+
- 峰谷ウィンドウは**左閉右開** `[start, end)`。深夜跨ぎウィンドウ(例:`22:00–06:00`)対応。
|
|
83
|
+
|
|
84
|
+
### status-badge(フロントエンド表示)
|
|
85
|
+
|
|
86
|
+
コンポーザー入力エリア右側に**読み取り専用**のステータスバッジを表示:
|
|
87
|
+
|
|
88
|
+
| 階層 | ラベル | CSS クラス | 意味 |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `peak` | 高峰 | `sg-peak` | 平日ピーク時間帯、セッション自動一時停止中 |
|
|
91
|
+
| `off-peak` | 谷時 | `sg-off` | オフピーク時間帯、セッション通常稼働 |
|
|
92
|
+
| `weekend` | 週末 | `sg-weekend` | 週末(週末モード有効時)、峰谷無視 |
|
|
93
|
+
|
|
94
|
+
- 15 秒ごとに `GET /session-guard/status` をポーリング;
|
|
95
|
+
- fail-open:ルート到達不可・ネットワークエラー・`enabled` オフ時→バッジ非表示;
|
|
96
|
+
- **input-traffic に依存しない**:session-guard クライアントコードが単独で描画。input-traffic は凍結ボタンのみ担当;
|
|
97
|
+
|
|
98
|
+
### input-traffic との連携
|
|
99
|
+
|
|
100
|
+
- input-traffic の**凍結ボタン**は `sessionGuard.stopNextTurn`(RPC、セッション経由)経由でサーバーサイドに伝達;
|
|
101
|
+
- input-traffic は**凍結強化のみ**(キュー凍結/解凍 + composer ブロック)、リトライは本プラグインのバックエンドが処理;
|
|
102
|
+
- 両方「セッション分離」セマンティスを共有:input-traffic 凍結キューは sessionId で分離、session-guard RPC も sessionId で分離。
|
|
103
|
+
|
|
104
|
+
## ライセンス
|
|
105
|
+
|
|
106
|
+
MIT — [LICENSE](LICENSE) 参照。
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<strong>피크 자동 세션 게이트: 주말 모드 + 피크 자동 일시정지 + 세션급 동결 + 백엔드 자동 재시도</strong>
|
|
3
|
+
</p>
|
|
4
|
+
<p align="center">
|
|
5
|
+
<a href="README.en.md">English</a> · <a href="README.md">中文</a> · <a href="README.ja.md">日本語</a> · <strong>한국어</strong>
|
|
6
|
+
</p>
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="LICENSE"><img alt="MIT License" src="https://img.shields.io/badge/license-MIT-263146?style=flat-square"></a>
|
|
9
|
+
<img src="https://camo.githubusercontent.com/2c11fb2e0e14bb9985c5acbe61123a7441c5ee63aa27fa6e04e2a707ebfd6022/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6473682d2d706c7567696e2d72656164792d3437384342463f6c6f676f3d646565707365656b266c6f676f436f6c6f723d7768697465" alt="dsh-plugin" style="max-width: 100%;">
|
|
10
|
+
<img alt="Public beta" src="https://img.shields.io/badge/status-public%20beta-7da1de?style=flat-square">
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
# dsh-session-guard
|
|
14
|
+
|
|
15
|
+
- [English README](./README.en.md)
|
|
16
|
+
- [中文 README](./README.md)
|
|
17
|
+
- [日本語 README](./README.ja.md)
|
|
18
|
+
- [한국어 README](./README.ko.md)
|
|
19
|
+
- [Installation guide](./INSTALL.md)
|
|
20
|
+
- [中文安装指南](./INSTALL.zh.md)
|
|
21
|
+
- [日本語インストールガイド](./INSTALL.ja.md)
|
|
22
|
+
- [한국어 설치 안내](./INSTALL.ko.md)
|
|
23
|
+
- [Changelog](./CHANGELOG.md)
|
|
24
|
+
- [日本語 changelog](./CHANGELOG.ja.md)
|
|
25
|
+
- [한국어 changelog](./CHANGELOG.ko.md)
|
|
26
|
+
|
|
27
|
+
> **호환성 참고:** v0.1.1에는 일본어(`ja`)와 한국어(`ko`) 사전이 포함되어 있지만, 현재 공식 DSH 릴리스는 `LocaleRuntime`을 통해 `zh`와 `en`만 제공합니다. 순정 DSH에서 `ja` 또는 `ko`를 선택하면 `locale "<id>" is not registered` 오류가 발생합니다. 공식 DSH가 해당 locale ID를 추가할 때까지 사용할 수 없습니다. 고급 사용자는 DSH 포크를 유지하면서 업데이트하세요.
|
|
28
|
+
|
|
29
|
+
> 피크 과금 시간대에 실행 중인 세션을 자동 일시정지하고 오피크/주말에 자동 재개; input-traffic의 동결 버튼과 페어링하여 **세션급** 잠금 구현; 백엔드 **자동 재시도**는 동결/게이트 기간 중 양보. 커스텀 세션 게이트(`agent.cancel keepInbox + goals.pause + session/event 안전 경계 + followup 재개`) 기반, dsh-task-control 의존성 제거.
|
|
30
|
+
|
|
31
|
+
`dsh plugin` 명령으로 조립 + 번들 패치로 장착하는 cordis 플러그인. dsh 소스 변경이나 PR 필요 없음.
|
|
32
|
+
|
|
33
|
+
> 💡 **권장 이유**: DeepSeek는 2026-08-17부터 **피크/오피크 과금**을 시행. 피크 시간대 단가 2배. 본 플러그인이 피크 시 실행 세션을 자동 일시정지하고 오피크에 자동 재개하여 장시간 세션 비용을 최대 **50%** 절감. 수동 동결(input-traffic 버튼 경유)로 세션별 정밀 제어 가능.
|
|
34
|
+
|
|
35
|
+
## 기능
|
|
36
|
+
|
|
37
|
+
- **주말 모드**: `Intl.DateTimeFormat`으로 주말을 정확히 인식(타임존 정확) → 주말은 피크/오피크 무시하고 자유 실행.
|
|
38
|
+
- **피크 자동 일시정지(글로벌)**: 피크 진입 시(그리고 주말이 아닌 경우) 모든 running 루트 세션을 자동 일시정지; 이탈 시 자동 재개 — **글로벌 스위치, 수동 불필요**.
|
|
39
|
+
- **세션급 동결/재개**: `sessionGuard` 중복 포트 + `POST /session-guard/rpc`, input-traffic 동결 버튼으로 세션별 패스스루. `/pause /resume /cancel` 수동 명령도 제공.
|
|
40
|
+
- **백엔드 자동 재시도(D9)**: turn/end 일시적 실패(error/429/max-tokens)는 적응형 백오프로 자동 재시도; 영구 실패는 중지; **동결/게이트 기간 중 양보**, 세션 게이트를 우회하지 않음.
|
|
41
|
+
- **fail-open**: 커스텀 세션 게이트 사용 불가, session-guard 미설치, 설정 서비스 누락 — 모두 조용히 성능 저하, 의존성으로 크래시하지 않음.
|
|
42
|
+
|
|
43
|
+
## 설치
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
dsh plugin --profile web add github:<owner>/dsh-session-guard
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
설치 후 dsh web을 재시작하고 페이지를 새로고침.
|
|
50
|
+
|
|
51
|
+
## 설정 (설정 → 플러그인 → session-guard)
|
|
52
|
+
|
|
53
|
+
| 스위치 | 기본값 | 설명 |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| `enabled` | on | **피크 자동 일시정지**: 피크 시간대에 실행 세션을 자동 일시정지 |
|
|
56
|
+
| `offPeakAutoResume` | on | **오피크 자동 재개**: 오피크에 일시정지 세션을 자동 재개 |
|
|
57
|
+
| `weekendMode` | on | **주말 모드**: 주말 인식 → 주말 자동 일시정지 안 함 |
|
|
58
|
+
| `queueFallback` | on | 커스텀 세션 게이트 사용 불가 시 락 대기 큐로 폴백 (fail-open) |
|
|
59
|
+
| `retryEnabled` | off | **자동 재시도 (백엔드)**: 일시적 실패 자동 재시도 (기본값 off, 보수적) |
|
|
60
|
+
|
|
61
|
+
추가 설정:
|
|
62
|
+
|
|
63
|
+
- `timezone` (기본값 Asia/Shanghai) — **주말判定**과 배지 표시에 사용. **피크/오피크判定에는 영향 없음** (피크는 항상 북경 시간);
|
|
64
|
+
- `peakWindows` (기본값 09:00–12:00 / 14:00–18:00) — 북경 시간(UTC+8) 기준 피크 윈도우. DeepSeek 공식 과금과 일치;
|
|
65
|
+
- `pauseMode` (`safe`/`force`), `pauseReason` (`wait`/`stop`);
|
|
66
|
+
- 재시도 매개변수: `retryText`, `retryGraceMs`, `retryCooldownMs`, `retryBackoffFactor`, `retryBackoffMaxMs`, `retryMaxConsecutive`.
|
|
67
|
+
|
|
68
|
+
## 동작
|
|
69
|
+
|
|
70
|
+
### 피크 자동 게이트 (글로벌)
|
|
71
|
+
|
|
72
|
+
- **피크 진입** (그리고 주말 아님): 모든 running 루트 세션에 `gate.stopNextTurn` 호출 — 커스텀 세션 게이트로 진정한 일시정지 (추론 중단 안 함, 안전 경계에서 일시정지), `queueFallback`으로 락 대기 큐 폴백;
|
|
73
|
+
- **오피크 / 주말**: `gate.resume` **모든** 세션 (자동 재개, 수동 불필요) — `offPeakAutoResume` 스위치로 제어;
|
|
74
|
+
- **피크 타임존**: 하드코딩된 북경 시간 (`Asia/Shanghai`), DeepSeek 공식 과금 기준과 일치 — `timezone` 설정의 영향을 받지 않음;
|
|
75
|
+
- 상태 머신: 단일 인스턴스 `NORMAL ↔ PAUSED_PEAK` (`scheduler.js`), 단일 30s tick으로 구동.
|
|
76
|
+
|
|
77
|
+
### 타임존 처리
|
|
78
|
+
|
|
79
|
+
- **피크/오피크判定**: 항상 **북경 시간(UTC+8)** 사용 (`BILLING_TIMEZONE = 'Asia/Shanghai'`). DeepSeek 공식 과금 기준. `timezone` 설정으로 변경 불가 (하드코딩);
|
|
80
|
+
- **주말判定**: 사용자 설정 `timezone` (예: `Asia/Tokyo`, `Asia/Seoul`) 사용. "주말"은 로컬 개념이므로;
|
|
81
|
+
- `Intl.DateTimeFormat`으로 타임존 투영. 잘못된 IANA 타임존 이름은 `RangeError`로 fail-open하여 `Asia/Shanghai`로 폴백;
|
|
82
|
+
- 피크 윈도우는 **좌폐우개** `[start, end)`. 자정 횡단 윈도우 (예: `22:00–06:00`) 지원.
|
|
83
|
+
|
|
84
|
+
### 상태 배지 (프론트엔드 표시)
|
|
85
|
+
|
|
86
|
+
컴포저 입력 영역 오른쪽에 **읽기 전용** 상태 배지 표시:
|
|
87
|
+
|
|
88
|
+
| 단계 | 라벨 | CSS 클래스 | 의미 |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| `peak` | 高峰 | `sg-peak` | 평일 피크 시간대, 세션 자동 일시정지 중 |
|
|
91
|
+
| `off-peak` | 谷时 | `sg-off` | 오피크 시간대, 세션 정상 실행 |
|
|
92
|
+
| `weekend` | 週末 | `sg-weekend` | 주말 (주말 모드 활성화 시), 피크/오피크 무시 |
|
|
93
|
+
|
|
94
|
+
- 15초마다 `GET /session-guard/status` 폴링;
|
|
95
|
+
- fail-open: 라우트 도달 불가·네트워크 오류·`enabled` OFF → 배지 숨김;
|
|
96
|
+
- **input-traffic에 의존하지 않음**: session-guard 클라이언트 코드가 단독으로 렌더링. input-traffic는 동결 버튼만 담당;
|
|
97
|
+
|
|
98
|
+
### input-traffic와의 협업
|
|
99
|
+
|
|
100
|
+
- input-traffic의 **동결 버튼**은 `sessionGuard.stopNextTurn` (RPC, 세션별) 경유 서버사이드에 전달;
|
|
101
|
+
- input-traffic는 **동결 강화만** (큐 동결/해제 + composer 차단), 재시도는 본 플러그인 백엔드가 처리;
|
|
102
|
+
- 둘 다 "세션 격리" 시맨틱 공유: input-traffic 동결 큐는 sessionId로 격리, session-guard RPC도 sessionId로 격리.
|
|
103
|
+
|
|
104
|
+
## 라이선스
|
|
105
|
+
|
|
106
|
+
MIT — [LICENSE](LICENSE) 참조.
|