@chentyit/dsh-chatbot-panel 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +174 -2
- package/client.js +516 -0
- package/cordis.patch.yml +24 -0
- package/icon.svg +15 -0
- package/index.js +718 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +59 -4
- package/pure.js +466 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 chentyit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,175 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ChatBot capability panel
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A **DeepSeek Harness** bundle that turns the composer's web capabilities into an explicit,
|
|
4
|
+
per-session choice, and keeps the usage honest.
|
|
5
|
+
|
|
6
|
+
It adds a small **ChatBot** chip right of the composer's permission chip («Workspace Write»).
|
|
7
|
+
Clicking the chip opens an upward panel; enabling a capability there starts it for the current
|
|
8
|
+
session. While a capability is off, its tools are not "politely denied" — they leave the model's
|
|
9
|
+
tool catalog entirely.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **Per-session capability switch.** Click the chip to open/close the panel. The chip itself never
|
|
14
|
+
toggles a capability; enabling anything in the panel marks it active (tinted bot icon).
|
|
15
|
+
- **Web search** — exposes the built-in `web_search` / `web_fetch` tools only while enabled.
|
|
16
|
+
- **Image search** — adds `chatbot_image_search` while web search is on. When the user's message
|
|
17
|
+
carries an image, the tool reads that image from the current turn and asks DeepSeek's native
|
|
18
|
+
`deepseek_web_search` server tool to search by it, returning an identification, source pages and
|
|
19
|
+
the matched `image_url`s. An explicit workspace path, `http(s)` URL or base64 data URI also works.
|
|
20
|
+
- **Deep thinking search** — adds `chatbot_deep_search`, which runs DeepSeek's server-side
|
|
21
|
+
`deepseek_web_search` tool with thinking enabled: the search model plans several queries,
|
|
22
|
+
searches, opens and reads relevant pages over multiple steps, then answers with sources. Pass
|
|
23
|
+
`image: "auto"` to combine it with the current message's image.
|
|
24
|
+
- **Default off.** A fresh session starts with no web tools declared; turning a capability off
|
|
25
|
+
restores that state.
|
|
26
|
+
- **Durable state.** The switch is stored in the session log through the `/chatbot` command
|
|
27
|
+
lifecycle and read back from a session projection, so it survives page reloads, resume and forks.
|
|
28
|
+
- **Usage and estimated cost.** The panel footer shows billed searches / sources, fetch calls,
|
|
29
|
+
image searches / images sent / billed requests, deep-search calls and tool calls, deep-search
|
|
30
|
+
tokens and failures, per-category fees and the estimated total, with a link to the DeepSeek
|
|
31
|
+
platform usage page. Image and deep fees are split into tool and auxiliary-token fees.
|
|
32
|
+
- **Theme-native, borderless.** The chip uses the host theme tokens and matches the permission
|
|
33
|
+
chip's 28 px text-chip look; no border, no fill, hover tints the whole chip.
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
Requires DeepSeek Harness `0.2.2-rc.3` or another compatible `0.2.x` runtime (`engines.dsh`).
|
|
38
|
+
|
|
39
|
+
After the package is published to a registry:
|
|
40
|
+
|
|
41
|
+
1. **Settings → Plugins → install** and enter `@chentyit/dsh-chatbot-panel@0.2.0`, or
|
|
42
|
+
2. use the plugin manager tool: `install_bundle` with target `@chentyit/dsh-chatbot-panel@0.2.0`.
|
|
43
|
+
|
|
44
|
+
From a local checkout (development):
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# a local directory is linked into the profile; edits need a bundle toggle or restart
|
|
48
|
+
plugin_manager install_bundle target=/path/to/dsh-chatbot-panel
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The Web page reloads the client half after activation; if the Plugins page asks for a restart,
|
|
52
|
+
restart the app. Uninstall from Settings → Plugins (or remove the bundle).
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
1. Open a session. The **ChatBot** chip sits right of the permission chip.
|
|
57
|
+
2. Click it; the panel opens upward. Tick **Web search** (and optionally **Deep thinking search**).
|
|
58
|
+
3. Ask the model a question that needs current information — it now has the matching tools.
|
|
59
|
+
4. Attach an image and ask what it is, where it comes from, or to find similar images. With web
|
|
60
|
+
search on, the model calls `chatbot_image_search`; with deep search on it can also add
|
|
61
|
+
`image: "auto"` to `chatbot_deep_search` for a slower, multi-step image search.
|
|
62
|
+
5. Untick everything, and the tools disappear from the model's catalog again.
|
|
63
|
+
6. The panel footer reports this session's usage and estimated cost.
|
|
64
|
+
|
|
65
|
+
You can also drive the same state with the slash command:
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
/chatbot web on | web off
|
|
69
|
+
/chatbot deep on | deep off
|
|
70
|
+
/chatbot reset
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Usage and billing
|
|
74
|
+
|
|
75
|
+
The official price list bills web search, image search and page fetch separately from model tokens:
|
|
76
|
+
**CNY 5 per 1,000 successful requests** (≈ ¥0.005 per call; failed or empty results are not
|
|
77
|
+
billed).
|
|
78
|
+
|
|
79
|
+
| Row in the panel | What is counted |
|
|
80
|
+
|---|---|
|
|
81
|
+
| Search | one successful `web_search` tool call fans out one request per query, so a successful call counts `queries.length` billed searches |
|
|
82
|
+
| Fetch | successful `web_fetch` calls; anonymous HTTP fetch is free, so no fee is added unless the fetch provider is the DeepSeek Fetch API (`countFetchCost: true`) |
|
|
83
|
+
| Image | `chatbot_image_search` calls, images sent, and the billed request count (`tool_search` + `tool_fetch` + `tool_image_search`); the fee is split into tool and auxiliary-token fees |
|
|
84
|
+
| Deep | deep-search tool calls plus the billed `tool_search` / `tool_fetch` / `tool_image_search` counters from the provider and the auxiliary model's input/output tokens |
|
|
85
|
+
| Failed | calls that ended in an error; a failed multi-query search may already have billed some requests |
|
|
86
|
+
|
|
87
|
+
The displayed amount is an **estimate**: the API returns counts, not money, so the panel multiplies
|
|
88
|
+
counts by the configured unit prices. The DeepSeek platform usage page remains authoritative, and
|
|
89
|
+
the panel links to it.
|
|
90
|
+
|
|
91
|
+
## Configuration
|
|
92
|
+
|
|
93
|
+
Override the row's `config` in the profile patch (`~/.dsh/profiles/<profile>/cordis.patch.yml`):
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
- id: chatbot-panel
|
|
97
|
+
name: '@chentyit/dsh-chatbot-panel'
|
|
98
|
+
config:
|
|
99
|
+
manageBuiltinWebTools: true # false = the panel no longer hides/enables built-in web tools
|
|
100
|
+
pricePerThousand: 5 # CNY per 1,000 successful web-tool requests (estimate only)
|
|
101
|
+
countFetchCost: false # true only when the fetch provider is the DeepSeek Fetch API
|
|
102
|
+
deepSearch:
|
|
103
|
+
baseURL: https://api.deepseek.com/anthropic/v1
|
|
104
|
+
apiKeyEnv: DEEPSEEK_API_KEY
|
|
105
|
+
model: deepseek-flash
|
|
106
|
+
maxTokens: 4096
|
|
107
|
+
timeoutMs: 180000
|
|
108
|
+
tokenPrice: # auxiliary search turn, deepseek-flash idle prices
|
|
109
|
+
inputPerMillion: 1
|
|
110
|
+
outputPerMillion: 4
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Image search uses the same `deepSearch` endpoint, model and credential as deep search. It
|
|
114
|
+
authenticates with the signed-in DeepSeek account when the session runs on the account route
|
|
115
|
+
(`x-dsh-auth-token`), otherwise with a stored API key or the key named by
|
|
116
|
+
`deepSearch.apiKeyEnv` (`$DSH_HOME/.env`, the credential service, or the process environment).
|
|
117
|
+
Without either it fails with a clear message.
|
|
118
|
+
|
|
119
|
+
## Limitations
|
|
120
|
+
|
|
121
|
+
- Deep search and image search need a DeepSeek account sign-in or an API key.
|
|
122
|
+
- Image search reads the images attached to the **current turn's** user message. In a later turn,
|
|
123
|
+
attach the image again or pass an explicit workspace path, `http(s)` URL or data URI.
|
|
124
|
+
- One image search accepts up to four images; each must be PNG, JPEG, WebP or GIF, up to 8 MB
|
|
125
|
+
(attached images are resized toward the DeepSeek vision budget first).
|
|
126
|
+
- Searching by image uploads that image to DeepSeek's Messages API. The result's `image_url` is for
|
|
127
|
+
display only and is not guaranteed to be reachable.
|
|
128
|
+
- Toggling a capability changes the request's tool catalog, so that session's DeepSeek prompt
|
|
129
|
+
cache is invalidated once.
|
|
130
|
+
- With plan mode active, the plan chip sits between the permission chip and this chip (official
|
|
131
|
+
single-slot order).
|
|
132
|
+
- Usage is folded from the session log; billing counts from failed multi-query searches are not
|
|
133
|
+
recoverable, so they are reported as failures only.
|
|
134
|
+
- Requires a DeepSeek model route that serves the official Messages API; other providers keep
|
|
135
|
+
their own web tools untouched.
|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
The package is plain JavaScript — no build step, no runtime dependencies:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npm run check # syntax + metadata validation + node:test suites
|
|
143
|
+
npm pack --dry-run # inspect the published file list
|
|
144
|
+
npm publish --access public
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The Host half is `index.js`; `pure.js` holds the testable capability, usage and response helpers;
|
|
148
|
+
`client.js` is the browser half. `test/` covers the pure helpers and the two auxiliary tools with a
|
|
149
|
+
mocked Cordis context and Messages response.
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
MIT. Copyright (c) 2026 chentyit.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 中文说明
|
|
158
|
+
|
|
159
|
+
**DeepSeek Harness 插件(bundle)**:把 composer 里的联网能力变成按会话的显式开关,并如实记录用量。
|
|
160
|
+
|
|
161
|
+
在输入框「工作区内修改」权限按钮右侧加一个 **ChatBot** 小按钮(无边框、无底色,与权限 chip 同款视觉)。
|
|
162
|
+
点击按钮展开向上弹出的能力面板;在面板里勾选能力,才对本会话生效。**关闭时不是"拒绝调用",而是把对应工具从模型的工具目录里彻底移除。**
|
|
163
|
+
|
|
164
|
+
- **联网搜索**:仅在开启时向模型暴露内置 `web_search` / `web_fetch`。
|
|
165
|
+
- **以图搜图**:联网搜索开启时额外提供 `chatbot_image_search`。用户消息带图时,工具读取本轮的图片,交给 DeepSeek 服务端 `deepseek_web_search` 按图搜索,返回识别结论、来源页面和匹配到的 `image_url`;也支持工作区路径、`http(s)` URL 或 base64 data URI。
|
|
166
|
+
- **深度思考搜索**:额外提供 `chatbot_deep_search`,走 DeepSeek 服务端 `deepseek_web_search`(thinking 开启)多步搜索、打开网页后带来源作答;传 `image: "auto"` 可结合本轮图片做深度以图搜图。
|
|
167
|
+
- **默认关闭**;开关按会话写入会话日志,刷新、恢复、分叉后仍有效。
|
|
168
|
+
- **用量与费用**:面板底部按官方口径记录搜索、抓取、搜图、深搜的次数与估算费用,并链接开放平台用量页。
|
|
169
|
+
- **图片限制**:只读取本条消息里的图片;一次最多 4 张,支持 PNG/JPEG/WebP/GIF,单张 ≤ 8MB;搜索时图片会上传给 DeepSeek,搜图与深搜需 DeepSeek 账号或 API key。
|
|
170
|
+
|
|
171
|
+
安装:`Settings → Plugins` 输入 `@chentyit/dsh-chatbot-panel@0.2.0`,或用 `plugin_manager` 的 `install_bundle`。
|
|
172
|
+
|
|
173
|
+
计费口径:联网搜索/抓取/图片搜索官方价 **5 元 / 1000 次成功请求**(失败或零结果不计费);一次 `web_search` 按查询词数拆成多次请求;图片搜索每张图片计 1 次,模型框选图片中的区域时每个区域另计 1 次。面板金额是**估算**(API 只返回次数),以平台账单为准。
|
|
174
|
+
|
|
175
|
+
配置项与限制见上方英文段落(`manageBuiltinWebTools` / `pricePerThousand` / `countFetchCost` / `deepSearch` / `tokenPrice`)。
|