@alexpeng/dsh-custom-plugin 0.1.0 → 0.1.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/LICENSE +1 -1
- package/README.i18n.yaml +2 -2
- package/README.md +11 -2
- package/README.zh.md +11 -2
- package/cordis.patch.yml +2 -2
- package/lib/client.js +21 -16
- package/lib/client.js.map +1 -1
- package/lib/index.js +46 -4977
- package/lib/types/client/api.d.ts +2 -2
- package/lib/types/client/index.d.ts +2 -1
- package/lib/types/host-service.d.ts +5 -6
- package/lib/types/protocol.d.ts +0 -5
- package/lib/types/usage.d.ts +4 -4
- package/package.json +84 -79
package/LICENSE
CHANGED
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2026 AlexPeng
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.i18n.yaml
CHANGED
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
# after editing either side, bring the other along and re-record the hashes:
|
|
4
4
|
# git hash-object --path README.md README.md
|
|
5
5
|
# git hash-object --path README.zh.md README.zh.md
|
|
6
|
-
README.md:
|
|
7
|
-
README.zh.md:
|
|
6
|
+
README.md: 66867ca059a673323ef9086acca0c2f44670affa
|
|
7
|
+
README.zh.md: 92ca89e338374c829a87a3b4f691a62617e9aacf
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ English | [中文](README.zh.md)
|
|
|
4
4
|
|
|
5
5
|
Custom convenience suite for the DeepSeek Harness (DSH) Web GUI: personalization, weather FX, glass effects, a per-user-message timeline rail, project folders, prompts, conversation export, Mermaid rendering, quote reply, and DeepSeek balance / daily token usage.
|
|
6
6
|
|
|
7
|
-
The plugin is dual-face: the host half (`src/`) owns the state document, registers the `/api/custom-plugin` routes and the `custom_plugin_status` agent tool; the browser half (`src/client/`) injects its UI through
|
|
7
|
+
The plugin is dual-face: the host half (`src/`) owns the state document, registers the `/api/custom-plugin` routes and the `custom_plugin_status` agent tool; the browser half (`src/client/`) injects its UI through eight injections into seven official slots and talks to the host over same-origin fetch. Mounted through the official profile mechanism — no DSH source changes.
|
|
8
8
|
|
|
9
9
|
## What it does
|
|
10
10
|
|
|
@@ -59,7 +59,7 @@ When a message contains a ```mermaid block, a render chip appears under it; the
|
|
|
59
59
|
A balance badge sits in the session header (clickable to pin); the balance panel provides:
|
|
60
60
|
|
|
61
61
|
- **Balance**: the official `https://api.deepseek.com/user/balance` endpoint, CNY preferred, granted and topped-up balances listed separately, with the account availability flag.
|
|
62
|
-
- **Key resolution order**: pasted in the panel (stored only in the local state file) → environment variables `DEEPSEEK_API_KEY` / `DEEPSEEK_KEY` / `DEEPSEEK_TOKEN` → the DSH credentials file `$DSH_HOME/.credentials.yaml` (reuses the DeepSeek key already configured in DSH — no duplicate setup).
|
|
62
|
+
- **Key resolution order**: pasted in the panel (stored only in the local state file) → environment variables `DEEPSEEK_API_KEY` / `DEEPSEEK_KEY` / `DEEPSEEK_TOKEN` (values must start with `sk-`) → the DSH credentials file `$DSH_HOME/.credentials.yaml` (reuses the DeepSeek key already configured in DSH — no duplicate setup).
|
|
63
63
|
- **Today's usage**: per-model input / output / cache token counters and call counts, folded live from `session/event` records.
|
|
64
64
|
- **Cost estimate**: DeepSeek's official peak/off-peak table (effective 2026-08-17) — peak hours (Beijing 09:00–12:00 / 14:00–18:00) at full price, off-peak at half: `deepseek-v4-flash` ¥3 / ¥9, `deepseek-v4-pro` ¥9 / ¥27 (CNY per 1M tokens in / out, cache writes ¥0.1 / ¥0.3; the retired `deepseek-chat` / `deepseek-reasoner` price as v4-flash). Indicative only.
|
|
65
65
|
- **Scan**: "scan today's session logs" replays every session and buckets usage events by their own timestamp (cross-midnight sessions keep contributing today's usage), reporting how many active sessions were scanned.
|
|
@@ -85,6 +85,15 @@ dsh plugin --profile web add @alexpeng/dsh-custom-plugin
|
|
|
85
85
|
|
|
86
86
|
The registry tarball ships prebuilt output — no source build on the installing machine.
|
|
87
87
|
|
|
88
|
+
### From GitHub (source install)
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
dsh plugin --profile web add github:AlexPeng07/dsh-custom-plugin
|
|
92
|
+
# restart dsh web
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Git installs pull sources; the `prepare` script builds `lib/` on the installing machine. pnpm ≥10 asks you to approve that build once — copy the exact package key it prints into the profile's `pnpm-workspace.yaml` under `allowBuilds`, then re-run the add. The npm route above skips the build-approval step.
|
|
96
|
+
|
|
88
97
|
### Local link (development)
|
|
89
98
|
|
|
90
99
|
```sh
|
package/README.zh.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天气特效、玻璃效果、按用户消息的时间线导航、项目文件夹、提示词库、会话导出、Mermaid 渲染、引用回复,以及 DeepSeek 额度与今日 token 用量。
|
|
6
6
|
|
|
7
|
-
插件为双半区架构:宿主半区(`src/`)持有状态文档、注册 `/api/custom-plugin` 路由与 `custom_plugin_status` 智能体工具;浏览器半区(`src/client/`)通过
|
|
7
|
+
插件为双半区架构:宿主半区(`src/`)持有状态文档、注册 `/api/custom-plugin` 路由与 `custom_plugin_status` 智能体工具;浏览器半区(`src/client/`)通过 7 个官方 slot 的 8 处注入挂载 UI,以同源 fetch 与宿主通信。经官方 profile 机制挂载,不改 DSH 源码。
|
|
8
8
|
|
|
9
9
|
## 功能
|
|
10
10
|
|
|
@@ -59,7 +59,7 @@ DeepSeek Harness(DSH)Web GUI 的 Custom 便利套件:个性化外观、天
|
|
|
59
59
|
会话头部常驻额度徽标(可点击固定),额度面板提供:
|
|
60
60
|
|
|
61
61
|
- **余额**:调用官方 `https://api.deepseek.com/user/balance` 接口,优先显示 CNY,赠送与充值余额分列,并显示账户可用状态。
|
|
62
|
-
- **Key 解析顺序**:面板粘贴(仅存本机状态文件)→ 环境变量 `DEEPSEEK_API_KEY` / `DEEPSEEK_KEY` / `DEEPSEEK_TOKEN`
|
|
62
|
+
- **Key 解析顺序**:面板粘贴(仅存本机状态文件)→ 环境变量 `DEEPSEEK_API_KEY` / `DEEPSEEK_KEY` / `DEEPSEEK_TOKEN`(取值需以 `sk-` 开头)→ DSH 凭据文件 `$DSH_HOME/.credentials.yaml`(自动复用 DSH 已配置的 DeepSeek key,无需重复填写)。
|
|
63
63
|
- **今日用量**:按模型统计输入 / 输出 / 缓存 token 与调用次数,实时折叠自 `session/event` 事件。
|
|
64
64
|
- **费用估算**:按 DeepSeek 官方峰谷价目(2026-08-17 生效)估算——高峰时段(北京时间 9–12 / 14–18 时)全价,空闲时段半价:`deepseek-v4-flash` ¥3 / ¥9,`deepseek-v4-pro` ¥9 / ¥27(每百万 tokens 输入 / 输出,缓存写入 ¥0.1 / ¥0.3;已停用的 `deepseek-chat` / `deepseek-reasoner` 按 v4-flash 计),仅供参考。
|
|
65
65
|
- **扫描**:「扫描今日会话日志」重放全部会话、按事件自身时间戳归入今日(跨午夜会话不丢量),完成后显示扫描到的活跃会话数。
|
|
@@ -85,6 +85,15 @@ dsh plugin --profile web add @alexpeng/dsh-custom-plugin
|
|
|
85
85
|
|
|
86
86
|
registry 上是预构建产物,安装端无需从源码构建。
|
|
87
87
|
|
|
88
|
+
### 从 GitHub 安装(源码安装)
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
dsh plugin --profile web add github:AlexPeng07/dsh-custom-plugin
|
|
92
|
+
# 重启 dsh web
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
git 安装拉取的是源码,`prepare` 脚本会在安装端构建 `lib/`。pnpm ≥10 需要一次性授权该构建——把 pnpm 提示的确切包键复制进 profile 的 `pnpm-workspace.yaml` 的 `allowBuilds` 下,再重新执行 add。走上方 npm 路线可免去构建授权。
|
|
96
|
+
|
|
88
97
|
### 本地链接(开发)
|
|
89
98
|
|
|
90
99
|
```sh
|
package/cordis.patch.yml
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# dsh-custom-plugin bundle patch: inserts the dual-face plugin row into the web
|
|
2
2
|
# profile roster. Applied as a profile bundle layer (the `dsh.bundle.patch`
|
|
3
3
|
# manifest field) over dsh-base; activate with
|
|
4
|
-
# `dsh plugin --profile <name> add
|
|
4
|
+
# `dsh plugin --profile <name> add github:AlexPeng07/dsh-custom-plugin`.
|
|
5
5
|
#
|
|
6
6
|
# The row is a bare plugin by package name: the node half (exports ".") runs
|
|
7
7
|
# in the host process (state store, /api/custom-plugin routes, the
|
|
8
8
|
# custom_plugin_status agent tool), and the `dsh.client` declaration in
|
|
9
9
|
# package.json makes the browser half (exports "./client", served at
|
|
10
|
-
# /plugins/custom-plugin/client.js) load in the web GUI.
|
|
10
|
+
# /plugins/@alexpeng/dsh-custom-plugin/client.js) load in the web GUI.
|
|
11
11
|
- insert:
|
|
12
12
|
- id: custom-plugin
|
|
13
13
|
name: '@alexpeng/dsh-custom-plugin'
|
package/lib/client.js
CHANGED
|
@@ -94,9 +94,9 @@ window.__ModuleLoader__.load({
|
|
|
94
94
|
async function apiStateSave(edit) {
|
|
95
95
|
return await postJson("/state", edit);
|
|
96
96
|
}
|
|
97
|
-
/** Timeline nodes for one session. */
|
|
98
|
-
async function apiTimelineGet(sessionId
|
|
99
|
-
return await request(`/timeline?sessionId=${encodeURIComponent(sessionId)}
|
|
97
|
+
/** Timeline nodes for one session (tail-capped by the host). */
|
|
98
|
+
async function apiTimelineGet(sessionId) {
|
|
99
|
+
return await request(`/timeline?sessionId=${encodeURIComponent(sessionId)}`, { cache: "no-store" });
|
|
100
100
|
}
|
|
101
101
|
/** Export one session in the given format. */
|
|
102
102
|
async function apiExportRun(sessionId, format) {
|
|
@@ -1239,8 +1239,6 @@ window.__ModuleLoader__.load({
|
|
|
1239
1239
|
balance: null,
|
|
1240
1240
|
exporting: false,
|
|
1241
1241
|
insertDraft: null,
|
|
1242
|
-
quoteSetDraft: null,
|
|
1243
|
-
suppressUntil: 0,
|
|
1244
1242
|
greeted: false
|
|
1245
1243
|
};
|
|
1246
1244
|
let listeners = [];
|
|
@@ -2427,7 +2425,6 @@ window.__ModuleLoader__.load({
|
|
|
2427
2425
|
toast("该消息尚未渲染,请稍后重试", "error");
|
|
2428
2426
|
return;
|
|
2429
2427
|
}
|
|
2430
|
-
S.suppressUntil = Date.now() + 400;
|
|
2431
2428
|
const scroller = S.scrollerEl;
|
|
2432
2429
|
let done = false;
|
|
2433
2430
|
if (scroller !== null && scroller.isConnected) try {
|
|
@@ -2618,7 +2615,7 @@ window.__ModuleLoader__.load({
|
|
|
2618
2615
|
mermaid.initialize({
|
|
2619
2616
|
startOnLoad: false,
|
|
2620
2617
|
theme: "default",
|
|
2621
|
-
securityLevel: "
|
|
2618
|
+
securityLevel: "strict"
|
|
2622
2619
|
});
|
|
2623
2620
|
const id = "vx-mmd-" + Date.now() + Math.floor(Math.random() * 9999);
|
|
2624
2621
|
const out = await mermaid.render(id, code);
|
|
@@ -2690,7 +2687,15 @@ window.__ModuleLoader__.load({
|
|
|
2690
2687
|
try {
|
|
2691
2688
|
const result = await apiBalanceGet();
|
|
2692
2689
|
S.balance = result;
|
|
2693
|
-
|
|
2690
|
+
const usageToday = result.usageToday;
|
|
2691
|
+
if (usageToday !== void 0 && usageToday !== null && typeof usageToday === "object") {
|
|
2692
|
+
S.usage = { ...S.usage };
|
|
2693
|
+
S.usage[dayKey()] = usageToday;
|
|
2694
|
+
setS({
|
|
2695
|
+
balance: S.balance,
|
|
2696
|
+
usage: S.usage
|
|
2697
|
+
});
|
|
2698
|
+
} else setS({ balance: S.balance });
|
|
2694
2699
|
} catch (error) {
|
|
2695
2700
|
S.balance = {
|
|
2696
2701
|
ok: false,
|
|
@@ -2885,7 +2890,13 @@ window.__ModuleLoader__.load({
|
|
|
2885
2890
|
const [hover, setHover] = react.useState(false);
|
|
2886
2891
|
const [pinned, setPinned] = react.useState(false);
|
|
2887
2892
|
react.useEffect(() => {
|
|
2888
|
-
if (
|
|
2893
|
+
if (S.balance === null) refreshBalance();
|
|
2894
|
+
const timer = setInterval(() => {
|
|
2895
|
+
refreshBalance();
|
|
2896
|
+
}, 6e4);
|
|
2897
|
+
return () => {
|
|
2898
|
+
clearInterval(timer);
|
|
2899
|
+
};
|
|
2889
2900
|
}, []);
|
|
2890
2901
|
const usageToday = s.usage[dayKey()] ?? {};
|
|
2891
2902
|
const calls = Object.keys(usageToday).reduce((n, k) => n + (usageToday[k].calls ?? 0), 0);
|
|
@@ -2984,10 +2995,8 @@ window.__ModuleLoader__.load({
|
|
|
2984
2995
|
return false;
|
|
2985
2996
|
}
|
|
2986
2997
|
};
|
|
2987
|
-
S.quoteSetDraft = (text) => S.insertDraft !== null ? S.insertDraft(text, false) : false;
|
|
2988
2998
|
return () => {
|
|
2989
2999
|
S.insertDraft = null;
|
|
2990
|
-
S.quoteSetDraft = null;
|
|
2991
3000
|
};
|
|
2992
3001
|
}, []);
|
|
2993
3002
|
react.useEffect(() => {
|
|
@@ -3372,7 +3381,6 @@ window.__ModuleLoader__.load({
|
|
|
3372
3381
|
function FolderNode(props) {
|
|
3373
3382
|
const s = useS();
|
|
3374
3383
|
const node = props.node;
|
|
3375
|
-
const depth = props.depth ?? 0;
|
|
3376
3384
|
const [open, setOpen] = react.useState(true);
|
|
3377
3385
|
const sessions = useSessionsSafe(props);
|
|
3378
3386
|
const byId = sessions !== null ? sessions.byId : {};
|
|
@@ -3551,7 +3559,6 @@ window.__ModuleLoader__.load({
|
|
|
3551
3559
|
}))), open ? react.createElement("div", { className: "vx-folder-body" }, children.map((c) => react.createElement(FolderNode, {
|
|
3552
3560
|
key: c.id,
|
|
3553
3561
|
node: c,
|
|
3554
|
-
depth: depth + 1,
|
|
3555
3562
|
useSessions: props.useSessions,
|
|
3556
3563
|
useWorkspaces: props.useWorkspaces
|
|
3557
3564
|
})), wsIds.map((wid) => {
|
|
@@ -3673,7 +3680,6 @@ window.__ModuleLoader__.load({
|
|
|
3673
3680
|
return react.createElement("div", { className: "vx-col" }, react.createElement("div", { className: "vx-muted" }, "跨工作区共享的会话与工作区收藏夹,支持多级嵌套与拖拽排序;数据保存在本机状态文件。"), S.folders.length === 0 ? react.createElement("div", { className: "vx-muted vx-pad-sm" }, "暂无文件夹,点击下方按钮创建。") : null, S.folders.map((f) => react.createElement(FolderNode, {
|
|
3674
3681
|
key: f.id,
|
|
3675
3682
|
node: f,
|
|
3676
|
-
depth: 0,
|
|
3677
3683
|
useSessions: props.useSessions,
|
|
3678
3684
|
useWorkspaces: props.useWorkspaces
|
|
3679
3685
|
})), react.createElement("div", { className: "vx-row vx-pad-sm" }, react.createElement("button", {
|
|
@@ -4267,7 +4273,6 @@ window.__ModuleLoader__.load({
|
|
|
4267
4273
|
}))), react.createElement("div", { className: "vx-folders-body" }, S.folders.length === 0 ? react.createElement("div", { className: "vx-muted vx-pad-sm" }, "暂无文件夹。在个性化中心可管理,或点击右上角新建。") : null, S.folders.map((f) => react.createElement(FolderNode, {
|
|
4268
4274
|
key: f.id,
|
|
4269
4275
|
node: f,
|
|
4270
|
-
depth: 0,
|
|
4271
4276
|
useSessions: props.useSessions,
|
|
4272
4277
|
useWorkspaces: props.useWorkspaces
|
|
4273
4278
|
}))));
|
|
@@ -4526,7 +4531,7 @@ window.__ModuleLoader__.load({
|
|
|
4526
4531
|
order: -5,
|
|
4527
4532
|
label: "额度"
|
|
4528
4533
|
}, HeaderBalance);
|
|
4529
|
-
|
|
4534
|
+
reportDiag("client registered: 8 injections / 7 slots");
|
|
4530
4535
|
return () => {
|
|
4531
4536
|
for (const unregister of unregisterAll.splice(0)) try {
|
|
4532
4537
|
unregister();
|