dsh-config-manager 0.1.47 → 0.1.49
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 +15 -0
- package/README.zh-CN.md +15 -0
- package/lib/client.d.ts +70 -3
- package/lib/client.js +792 -268
- package/lib/client.js.map +1 -1
- package/lib/core/restore.d.ts +7 -0
- package/lib/core/restore.js +4 -0
- package/lib/core/restore.js.map +1 -1
- package/lib/core/run-registry.d.ts +11 -4
- package/lib/core/run-registry.js +14 -7
- package/lib/core/run-registry.js.map +1 -1
- package/lib/index.d.ts +7 -1
- package/lib/index.js +131 -19
- package/lib/index.js.map +1 -1
- package/lib/ui/backup-schedule.d.ts +49 -0
- package/lib/ui/backup-schedule.js +42 -0
- package/lib/ui/backup-schedule.js.map +1 -0
- package/package.json +1 -1
- package/src/client/api.ts +35 -1
- package/src/client/common/ConfirmDialog.tsx +4 -2
- package/src/client/common/ErrorBanner.tsx +8 -4
- package/src/client/common/ReportView.tsx +10 -3
- package/src/client/common/ui.tsx +9 -2
- package/src/client/config-manager.module.css +22 -0
- package/src/client/export/ExportView.tsx +15 -5
- package/src/client/import/ImportWizardView.tsx +75 -14
- package/src/client/locales.ts +46 -0
- package/src/client/market/MarketPanel.tsx +9 -4
- package/src/client/market/MyConfigsView.tsx +8 -8
- package/src/client/run-store.test.ts +112 -1
- package/src/client/run-store.ts +78 -4
- package/src/client/snapshots/SnapshotsPanel.tsx +261 -7
- package/src/client/sync/SyncHistoryView.tsx +16 -2
- package/src/core/restore.ts +7 -0
- package/src/core/run-registry.test.ts +40 -0
- package/src/core/run-registry.ts +16 -9
- package/src/index.ts +129 -18
- package/src/ui/backup-schedule.test.ts +53 -0
- package/src/ui/backup-schedule.ts +83 -0
package/README.md
CHANGED
|
@@ -81,6 +81,7 @@ Browse the built-in official market for ready-made configurations (model provide
|
|
|
81
81
|
| 🛒 | **Config Marketplace** | Browse & one-click install community configs — supply-chain warnings + per-section approval |
|
|
82
82
|
| 🗂️ | **Profiles** | Save multiple setups (Work / Personal) and switch anytime |
|
|
83
83
|
| 🌐 | **Bilingual UI** | Interface, reports and error details follow the DSH app language (中文 / English) |
|
|
84
|
+
| 🤖 | **Agent tools** | Backup / snapshot / restore / sync right from an agent session |
|
|
84
85
|
|
|
85
86
|
---
|
|
86
87
|
|
|
@@ -326,6 +327,20 @@ Every overwrite/delete is first copied to `<snapshotDir>/pre-restore/` so you ca
|
|
|
326
327
|
|
|
327
328
|
**A typical rescue flow** when DSH won't start: ① `dsh-config-manager reinstall` to bring the launcher back (plus any clean-up), ② `dsh web` to start DSH again, ③ re-add the plugin from the registry, and ④ pull a snapshot from the remote repo (or run `dsh-config-manager restore`) to bring your config back. The CLI works at every step regardless of DSH's health.
|
|
328
329
|
|
|
330
|
+
### 🤖 Agent tools (for AI assistants)
|
|
331
|
+
|
|
332
|
+
The plugin also registers **5 model tools** that an AI agent (a DSH assistant session) can call directly — the same backup / snapshot / sync engines, no GUI needed:
|
|
333
|
+
|
|
334
|
+
| Tool | What it does |
|
|
335
|
+
|---|---|
|
|
336
|
+
| `config_backup` | Full backup of DSH config to the local `exports` dir — **no secrets by default**; pass `password` for an encrypted backup. Returns ZIP name / size / included sections / encryption state |
|
|
337
|
+
| `config_list_snapshots` | List local rollback snapshots (id / created / source / status / entry count) for use with `config_restore` |
|
|
338
|
+
| `config_restore` | Restore to a snapshot. **Default is a zero-write plan preview**; pass `confirm: true` to actually execute (overwrites / deletes `$DSH_HOME` files and uninstalls plugins added during import — destructive, always preview first) |
|
|
339
|
+
| `config_sync_push` | Push config sync to the remote (Git / WebDAV) using the persisted channel config. Writing the remote is an explicit action; encryption / credentials require `password` and the engine forces `encrypt` |
|
|
340
|
+
| `config_sync_pull` | Pull a remote diff **preview** (zero-write: download + analyze only). Landing the diff requires the separate confirm-import pipeline |
|
|
341
|
+
|
|
342
|
+
Once the plugin is installed the tools appear automatically in every agent session (hosts without an agent `tools` service silently skip registration). The agent calls them when the task matches — e.g. "back up my config", "what snapshots do I have", "restore to that snapshot", "sync to my repo" or "show me the remote diff". Safety invariants are built in: `config_restore` is dry-run by default, `config_sync_pull` never writes, `config_sync_push` is an explicit remote write, and secret values never enter tool inputs / outputs / logs.
|
|
343
|
+
|
|
329
344
|
---
|
|
330
345
|
|
|
331
346
|
## 🛡️ Security
|
package/README.zh-CN.md
CHANGED
|
@@ -80,6 +80,7 @@ DSH 是你的 AI 助手工作台,里面存着你的各种设置:模型配置
|
|
|
80
80
|
| ⏰ | **定时全量备份** | 按固定周期(6h / 12h / 24h / 7d)自动全量备份,一劳永逸,密钥永不包含 |
|
|
81
81
|
| 🛒 | **配置市场** | 浏览并一键安装社区分享的配置——供应链警示 + 逐分区批准 |
|
|
82
82
|
| 🗂️ | **配置档案 Profiles** | 保存多套配置(工作 / 个人),随时切换 |
|
|
83
|
+
| 🤖 | **Agent 工具** | Agent 会话内直接备份 / 快照 / 恢复 / 同步 |
|
|
83
84
|
|
|
84
85
|
---
|
|
85
86
|
|
|
@@ -325,6 +326,20 @@ dsh-config-manager restore --id <snapshot-id> # 执行恢复(
|
|
|
325
326
|
|
|
326
327
|
**典型救急流程**(DSH 起不来时):① `dsh-config-manager reinstall` 先把启动器重装回来(必要时顺带清理),② `dsh web` 重新启动 DSH,③ 从仓库装回插件,④ 从远程仓库拉取快照(或执行 `dsh-config-manager restore`)把配置恢复回来。整个流程中 CLI 全程可用,与 DSH 是否健康无关。
|
|
327
328
|
|
|
329
|
+
### 🤖 Agent 可调用的模型工具
|
|
330
|
+
|
|
331
|
+
插件还向宿主注册了 **5 个模型工具**,让 AI agent(DSH 助手会话)能在对话中直接驱动配置运维——与 GUI 共用同一套备份 / 快照 / 同步引擎,无需打开界面:
|
|
332
|
+
|
|
333
|
+
| 工具 | 作用 |
|
|
334
|
+
|---|---|
|
|
335
|
+
| `config_backup` | 全量备份 DSH 配置到本地 `exports` 目录(**默认不含 secret**;传 `password` 可加密导出)。返回 ZIP 文件名 / 大小 / 分区清单 / 加密状态 |
|
|
336
|
+
| `config_list_snapshots` | 列出本地回滚快照(id / 创建时间 / 来源 / 状态 / 条目数),供 `config_restore` 使用 |
|
|
337
|
+
| `config_restore` | 恢复到指定快照。**默认只返回动作计划(零写入)**;传 `confirm: true` 才真实执行(会覆盖 / 删除 `$DSH_HOME` 文件并卸载导入期间新增插件——破坏性操作,务必先预览) |
|
|
338
|
+
| `config_sync_push` | 手动推送配置同步到远端(Git / WebDAV),复用已持久化的通道配置。写远端属主动操作;加密 / 含凭据必须传 `password` 且引擎强制 `encrypt` |
|
|
339
|
+
| `config_sync_pull` | 拉取远端差异**预览**(零写入:只下载 + 分析出差异报告)。要落地差异需另走确认导入管道 |
|
|
340
|
+
|
|
341
|
+
安装插件后,这 5 个工具会自动出现在任意 agent 会话的工具清单里(宿主未组合 agent `tools` 服务时静默跳过注册)。由 agent 在任务相关时自主调用,例如「备份我的配置」「看看有哪些快照」「恢复到那个快照」「同步到我的仓库」「给我看远端差异」。安全不变量内建:`config_restore` 默认 dry-run、`config_sync_pull` 永不写入、`config_sync_push` 是显式远端写操作,且 secret 值永不进入工具入参 / 出参 / 日志。
|
|
342
|
+
|
|
328
343
|
---
|
|
329
344
|
|
|
330
345
|
## 🛡️ 安全
|
package/lib/client.d.ts
CHANGED
|
@@ -281,8 +281,8 @@ interface SnapshotMeta {
|
|
|
281
281
|
}
|
|
282
282
|
//#endregion
|
|
283
283
|
//#region src/core/run-registry.d.ts
|
|
284
|
-
/** run 类型:导出 / 导入 / 自动同步 / 一键同步逐项应用 /
|
|
285
|
-
type RunKind = 'export' | 'import' | 'autosync' | 'sync-apply' | 'backup-schedule';
|
|
284
|
+
/** run 类型:导出 / 导入 / 自动同步 / 一键同步逐项应用 / 定时备份 / 快照恢复。 */
|
|
285
|
+
type RunKind = 'export' | 'import' | 'autosync' | 'sync-apply' | 'backup-schedule' | 'restore';
|
|
286
286
|
/** run 状态:进行中 / 完成 / 失败。 */
|
|
287
287
|
type RunStatus = 'running' | 'done' | 'failed';
|
|
288
288
|
/** 单个 run 的实时状态(/progress 返回体;纯 JSON 可序列化)。 */
|
|
@@ -312,6 +312,40 @@ interface RunState {
|
|
|
312
312
|
updatedAt: number;
|
|
313
313
|
}
|
|
314
314
|
//#endregion
|
|
315
|
+
//#region src/sync/backup-schedule-config.d.ts
|
|
316
|
+
/** 定时备份间隔档位(全量备份无需太频繁;默认 24h) */
|
|
317
|
+
type BackupInterval = '6h' | '12h' | '24h' | '7d';
|
|
318
|
+
/** 最近一次定时备份执行状态 */
|
|
319
|
+
type BackupRunStatus = 'success' | 'skipped' | 'failed';
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/sync/backup-scheduler.d.ts
|
|
322
|
+
interface BackupRunResult {
|
|
323
|
+
status: BackupRunStatus;
|
|
324
|
+
zip?: string;
|
|
325
|
+
sizeBytes?: number;
|
|
326
|
+
sections?: string[];
|
|
327
|
+
skipReason?: string;
|
|
328
|
+
error?: string;
|
|
329
|
+
consecutiveFailures: number;
|
|
330
|
+
}
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region src/ui/backup-schedule.d.ts
|
|
333
|
+
/** 设置草稿(表单编辑态:总开关 + 间隔档位)。 */
|
|
334
|
+
interface BackupScheduleDraft {
|
|
335
|
+
enabled: boolean;
|
|
336
|
+
interval: BackupInterval;
|
|
337
|
+
}
|
|
338
|
+
/** 定时备份配置的浏览器侧视图(与 sync/backup-schedule-config.ts 的持久化面一致;无敏感字段)。 */
|
|
339
|
+
interface BackupScheduleStatus {
|
|
340
|
+
enabled: boolean;
|
|
341
|
+
interval: BackupInterval;
|
|
342
|
+
startupMinIntervalMs: number;
|
|
343
|
+
consecutiveFailures: number;
|
|
344
|
+
lastRunAt?: string;
|
|
345
|
+
lastRunStatus?: BackupRunStatus;
|
|
346
|
+
lastRunMessage?: string;
|
|
347
|
+
}
|
|
348
|
+
//#endregion
|
|
315
349
|
//#region src/ui/i18n.d.ts
|
|
316
350
|
/**
|
|
317
351
|
* 客户端展示层(src/ui/*、src/client/common/*)的渲染文案目录(zh 源语言 / en 镜像)。
|
|
@@ -604,11 +638,13 @@ interface DecryptArchiveResponse {
|
|
|
604
638
|
/** 解密覆盖的凭据 ref 名(非值);UI 据此从补录阶段剔除已恢复项 */
|
|
605
639
|
refs: string[];
|
|
606
640
|
}
|
|
607
|
-
/** restore 端点响应:dryRun=true 返回 plan;执行返回 report(与 CLI
|
|
641
|
+
/** restore 端点响应:dryRun=true 返回 plan;执行返回 report(与 CLI 一致的诚实报告)。
|
|
642
|
+
* runId 仅真实执行时存在(宿主 RunRegistry 登记;/runs + /progress 刷新恢复用)。 */
|
|
608
643
|
interface RestoreResponse {
|
|
609
644
|
dryRun: boolean;
|
|
610
645
|
plan?: RestorePlan;
|
|
611
646
|
report?: RestoreReport;
|
|
647
|
+
runId?: string;
|
|
612
648
|
}
|
|
613
649
|
/** Star 引导弹窗状态(GET /star-prompt;纯偏好,无 secret) */
|
|
614
650
|
interface StarPromptStatus {
|
|
@@ -712,6 +748,15 @@ declare class ConfigManagerApi {
|
|
|
712
748
|
snapshots(): Promise<SnapshotMeta[]>;
|
|
713
749
|
/** 快照恢复:dryRun=true 只取动作计划(零写入);false 执行并返回诚实报告 */
|
|
714
750
|
restoreSnapshot(snapshotId: string, dryRun: boolean): Promise<RestoreResponse>;
|
|
751
|
+
/** 读取定时备份配置(enabled / interval / 上次运行状态;无敏感字段)。 */
|
|
752
|
+
backupSchedule(): Promise<BackupScheduleStatus>;
|
|
753
|
+
/** 保存定时备份设置(enabled + interval);Host 校验后原子写 + 重排调度器。 */
|
|
754
|
+
saveBackupSchedule(draft: BackupScheduleDraft): Promise<BackupScheduleStatus>;
|
|
755
|
+
/** 立即执行一次全量备份(复用调度器 runOnce,防重;返回执行结果 + 最新配置)。 */
|
|
756
|
+
runBackupNow(): Promise<{
|
|
757
|
+
run: BackupRunResult;
|
|
758
|
+
schedule: BackupScheduleStatus;
|
|
759
|
+
}>;
|
|
715
760
|
}
|
|
716
761
|
//#endregion
|
|
717
762
|
//#region src/sync/sync-engine.d.ts
|
|
@@ -1526,6 +1571,7 @@ declare const zh$2: {
|
|
|
1526
1571
|
readonly 'import.importing': "正在导入…(插件安装较多时可能需要几分钟,请勿关闭页面)";
|
|
1527
1572
|
readonly 'import.log.title': "导入日志";
|
|
1528
1573
|
readonly 'import.log.empty': "等待命令输出…";
|
|
1574
|
+
readonly 'import.log.newOutput': "↓ 新输出";
|
|
1529
1575
|
readonly 'import.skipCurrent': "跳过当前插件";
|
|
1530
1576
|
readonly 'import.skipPending': "正在跳过…其余项将继续导入";
|
|
1531
1577
|
readonly 'import.retrySkipped': "重试失败/跳过的项 ({count})";
|
|
@@ -1571,6 +1617,7 @@ declare const zh$2: {
|
|
|
1571
1617
|
readonly 'snapshots.noActions': "该快照无可用恢复动作(或全部跳过)。";
|
|
1572
1618
|
readonly 'snapshots.execute': "执行恢复";
|
|
1573
1619
|
readonly 'snapshots.executing': "恢复执行中…";
|
|
1620
|
+
readonly 'snapshots.confirmTitle': "确认恢复";
|
|
1574
1621
|
readonly 'snapshots.confirmRestore': "确认执行恢复?当前文件会先备份到快照的 pre-restore 目录,插件通过官方 dsh plugin remove 卸载。";
|
|
1575
1622
|
readonly 'snapshots.reportTitle': "恢复报告";
|
|
1576
1623
|
readonly 'snapshots.restored': "已还原";
|
|
@@ -1578,6 +1625,26 @@ declare const zh$2: {
|
|
|
1578
1625
|
readonly 'snapshots.manualHints': "需人工处理";
|
|
1579
1626
|
readonly 'snapshots.failed': "失败";
|
|
1580
1627
|
readonly 'snapshots.skipped': "跳过";
|
|
1628
|
+
readonly 'backupSchedule.title': "定时全量备份";
|
|
1629
|
+
readonly 'backupSchedule.hint': "按固定间隔在后台自动导出全量备份 ZIP(恒不含 secret、不加密;要加密请手动导出)。配置存 sync/backup-schedule.json,随 self 分区备份 / 远程同步迁移。";
|
|
1630
|
+
readonly 'backupSchedule.enabled': "启用定时备份";
|
|
1631
|
+
readonly 'backupSchedule.enabledHint': "开启后 DSH 在后台按间隔自动备份;每次启动时立即执行一次(距上次运行不足 1 小时则跳过启动触发)。";
|
|
1632
|
+
readonly 'backupSchedule.interval': "备份间隔";
|
|
1633
|
+
readonly 'backupSchedule.interval.6h': "每 6 小时";
|
|
1634
|
+
readonly 'backupSchedule.interval.12h': "每 12 小时";
|
|
1635
|
+
readonly 'backupSchedule.interval.24h': "每 24 小时";
|
|
1636
|
+
readonly 'backupSchedule.interval.7d': "每 7 天";
|
|
1637
|
+
readonly 'backupSchedule.save': "保存设置";
|
|
1638
|
+
readonly 'backupSchedule.saved': "设置已保存";
|
|
1639
|
+
readonly 'backupSchedule.runNow': "立即备份";
|
|
1640
|
+
readonly 'backupSchedule.running': "备份中…";
|
|
1641
|
+
readonly 'backupSchedule.lastRun': "上次运行";
|
|
1642
|
+
readonly 'backupSchedule.never': "从未运行";
|
|
1643
|
+
readonly 'backupSchedule.status.success': "成功";
|
|
1644
|
+
readonly 'backupSchedule.status.skipped': "已跳过";
|
|
1645
|
+
readonly 'backupSchedule.status.failed': "失败";
|
|
1646
|
+
readonly 'backupSchedule.loading': "加载定时备份设置…";
|
|
1647
|
+
readonly 'backupSchedule.error': "定时备份设置加载失败";
|
|
1581
1648
|
readonly 'report.export.title': "导出完成";
|
|
1582
1649
|
readonly 'report.import.title': "导入结果";
|
|
1583
1650
|
readonly 'report.rollback.title': "回滚报告";
|