dsh-scnet-connect 0.0.0-stage → 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-scnet-connect contributors
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,259 @@
1
- # Temporary Holding Version
1
+ # SCNet Connect
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/dsh-scnet-connect)](https://www.npmjs.com/package/dsh-scnet-connect)
4
+ [![license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
5
+
6
+ 把 **SCNet 模型**接入 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)。
7
+ 可**免客户端登录**,使用免费模型(`SCNet-Max`,基座为 DeepSeek Flash 系列 —— 实测与 `DeepSeek-V4.1-Flash-1017` 行为一致,证据见 [基座认定](#基座认定scnet-max-与-deepseek-v41-flash-1017-的行为比对))。
8
+
9
+ - **零客户端**:不装 SCNet 桌面客户端,用手机短信登录即可使用
10
+ - **零配置**:装了客户端的话,自动读凭据、自动发现免费模型
11
+ - **设置页管理**:账号、登录、模型开关都在 DSH 设置里
12
+
13
+ ![设置页](.github/assets/settings.png)
14
+
15
+ ---
16
+
17
+ ## 基座认定:SCNet-Max 与 DeepSeek-V4.1-Flash-1017 的行为比对
18
+
19
+ `SCNet-Max` 在平台目录里的 `description` 只有四个字(`SCNet-Max`),没有任何基座标注。下面是一组可复现的实测,用来判断它的基座。
20
+
21
+ 对比对象为 `DeepSeek-V4.1-Flash-1017`。
22
+
23
+
24
+ ### 证据一:分词器与对话模板完全一致
25
+
26
+ 同一字符串在两侧算出的 `prompt_tokens` 逐项相同(22 个探针,22 个一致):
27
+
28
+ | 探针 | 两侧 `prompt_tokens` |
29
+ | --- | --- |
30
+ | `"Hi"`(模板开销) | 31 |
31
+ | 中文 | 36 |
32
+ | 阿拉伯语 | 40 |
33
+ | 印地语 | 47 |
34
+ | 泰语 | 43 |
35
+ | 韩语 | 41 |
36
+ | 家庭 emoji(ZWJ) | 52 |
37
+ | 旗帜 emoji | 46 |
38
+ | 4 字节 CJK(`𠀋𠀌𠀍`) | 43 |
39
+ | 零宽字符 + 组合音标 | 39 |
40
+ | 代码块 | 44 |
41
+ | base64 | 66 |
42
+ | JSON | 41 |
43
+ | 400 个 ASCII | 80 |
44
+ | 200 个「中」 | 230 |
45
+
46
+ 基准串 `"Hi"` 在两侧都是 **31** token,说明 chat template 也一致。
47
+
48
+ ### 证据二:`temperature=0` 下逐字输出
49
+
50
+ 8 道确定性短题,其中 7 道字节级完全相同(sha256 前 8 位):
51
+
52
+ | 题目 | 输出 | sha256[:8] |
53
+ | --- | --- | --- |
54
+ | 输出 JSON `{"ok":true}` | `{"ok":true}` | `4062edaf75` |
55
+ | 列出 1 到 5 | `1, 2, 3, 4, 5` | `43f0c4c6d1` |
56
+ | `"hello world"` 转大写 | `HELLO WORLD` | `787ec76dca` |
57
+ | 斐波那契第 10 项 | `55` | `02d20bbd7e` |
58
+ | 3 的 5 次方 | `243` | `72440a20f5` |
59
+ | `"abc"` 反转 | `cba` | `6d970874d0` |
60
+ | 2024 是否闰年 | `是` | `b5141d3d19` |
61
+
62
+ 唯一不同的是自由论述题(「用一句话解释哈希表」)。该题在 `temperature=0.7` 复测时,两侧各采样出**完全相同的一整句**:
63
+
64
+ ```text
65
+ 哈希表是一种通过哈希函数把键映射到存储位置,从而以平均常数时间实现键值查找、插入和删除的数据结构。
66
+ ```
67
+
68
+ 跨两个不同网关各自采样,能撞出整句相同的汉语,基本排除「不同模型」的可能。
69
+
70
+ ### 证据三:知识边界重合
71
+
72
+ | 事实 | 两侧答案 |
73
+ | --- | --- |
74
+ | Gemini 3 发布 | 2025-11-18 |
75
+ | GPT-5 发布 | 2025-08-07 |
76
+ | Claude 4 发布 | 2025-05-22 |
77
+ | 2026 春节 | 2026-02-17 |
78
+ | 2025 诺贝尔文学奖 | 拉斯洛·克拉斯纳霍尔凯(László Krasznahorkai) |
79
+ | DeepSeek V4 | 均否认已发布(「截至 2026-04 / 2026-05」) |
80
+ | DeepSeek-V4.1-Flash-1017 | 均不认识 |
81
+
82
+ 两侧都不认识自己的发布名——模型对自身 release 无知属正常现象,不构成反证。
83
+
84
+ ### 证据四:网关实现不同(证明这是两个独立部署)
85
+
86
+ | 字段 | SCNet-Max | 对比侧 |
87
+ | --- | --- | --- |
88
+ | `prompt_cache_hit_tokens` / `prompt_cache_miss_tokens` | 无 | 有(DeepSeek 原生 schema) |
89
+ | `service_tier` | 有 | 无 |
90
+ | `system_fingerprint` | 字段缺失 | `""` |
91
+
92
+ ### 结论与残留不确定性
93
+
94
+ **可以确定**:`SCNet-Max` 与 `DeepSeek-V4.1-Flash-1017` 在 tokenizer、chat template、知识边界、确定性输出上全部一致,属**同一模型**。
95
+
96
+ **不能确定**:SCNet-Max 究竟是 `1017`,还是更早的 `DeepSeek-V4.1-Flash-0910`。DeepSeek 历代模型共用同一 tokenizer。
97
+
98
+
99
+ ## 安装
100
+
101
+ 三种方式,任选其一。
102
+
103
+ ### 方式一:DSH 插件页直接安装(最简单)
104
+
105
+ 打开 DSH 的 **插件** 页,在搜索/安装框里输入包名:
106
+
107
+ ```text
108
+ dsh-scnet-connect
109
+ ```
110
+
111
+ 点安装即可。装完重启 DSH,或改一下 profile 的 `cordis.patch.yml` 触发热重载。
112
+
113
+ ### 方式二:命令行安装(npm)
114
+
115
+ ```bash
116
+ dsh plugin --profile desktop add dsh-scnet-connect
117
+ ```
118
+
119
+ ### 方式三:从源码安装
120
+
121
+ ```bash
122
+ git clone https://github.com/Phoeky/dsh-scnet-connect.git
123
+ cd dsh-scnet-connect
124
+ dsh plugin --profile desktop add link:.
125
+ ```
126
+
127
+ > 装完如果没生效,改一下 profile 的 `cordis.patch.yml`(加一行注释再保存)触发热重载,或重启 DSH。
128
+
129
+ ---
130
+
131
+ ## 快速开始
132
+ ### 方式一:免客户端登录(推荐)
133
+
134
+ 打开 **设置 → SCNet Connect**:
135
+
136
+ 1. 填手机号 → 点「获取验证码」→ 输入图形验证码
137
+ 2. 点「发送短信验证码」→ 填收到的 6 位验证码
138
+ 3. 点「登录」
139
+
140
+ 登录成功后插件会自动换取模型 Key,无需其他操作。
141
+
142
+ ### 方式二:用本机 SCNet 客户端
143
+
144
+ 先装好 SCNet 客户端并登录,正常发起一次对话(让客户端把凭据落到本地)。
145
+ 插件会自动读取凭据,客户端之后可以关掉。
146
+
147
+ ---
148
+
149
+ ## 使用
150
+
151
+ 在 DSH 的模型选择器里选 **SCNet Connect → SCNet-Max**。
152
+
153
+ 设置页可以:
154
+
155
+ | 功能 | 说明 |
156
+ | --- | --- |
157
+ | 查看账号 | 用户名、ID、脱敏手机号、登录态剩余天数 |
158
+ | 登录 / 退出 | 短信登录;退出后插件停止供 Key,可随时「恢复使用」 |
159
+ | 只显示免费模型 | 默认开启。关闭后会把目录里所有模型都注册出来(可能产生费用) |
160
+ | 刷新模型 | 重新读模型目录并用网关校验可用性 |
161
+
162
+ ![模型开关](.github/assets/settings-models.png)
163
+
164
+ ---
165
+
166
+ ## 配置
167
+
168
+ 全部有默认值,一般不用改。需要时在 profile 的 `cordis.patch.yml` 里给 entry 加 `config`:
169
+
170
+ ```yaml
171
+ - id: scnet-connect
172
+ name: dsh-scnet-connect
173
+ config:
174
+ freeOnly: true # 只注册免费模型(默认开)
175
+ credentialSource: auto # auto | client | login
176
+ modelIds: '' # 逗号分隔;留空 = 自动发现
177
+ contextWindow: 0 # 0 = 跟随目录/默认
178
+ maxTokens: 0 # 0 = 跟随目录/默认
179
+ ```
180
+
181
+ <details>
182
+ <summary>全部字段</summary>
183
+
184
+ | 字段 | 默认 | 说明 |
185
+ | --- | --- | --- |
186
+ | `credentialSource` | `auto` | `auto` 先客户端再登录;`client` 只用客户端;`login` 只用设置页登录 |
187
+ | `freeOnly` | `true` | 只注册 `priceLabel=free` 的模型 |
188
+ | `credentialDir` | 空 | 默认 `~/.sclaw/agent/scnet-credentials` |
189
+ | `apiKey` | 空 | 直接指定 Key(会明文存在配置文件里) |
190
+ | `baseUrl` | `https://api.scnet.cn/api/llm/v1` | 网关地址 |
191
+ | `modelIds` | 空 | 指定模型 id,逗号分隔 |
192
+ | `modelName` | 空 | 自定义显示名(仅单模型时生效) |
193
+ | `contextWindow` / `maxTokens` | `0` | 覆盖上下文/输出上限 |
194
+ | `inputImages` | `true` | 是否声明接受图片 |
195
+ | `reasoning` | `true` | 是否声明支持思考等级 |
196
+ | `verifyWithGateway` | `true` | 刷新时用 `GET /models` 校验 |
197
+
198
+ </details>
199
+
200
+ ---
201
+
202
+ ## 故障排查
203
+
204
+ | 现象 | 处理 |
205
+ | --- | --- |
206
+ | 模型选择器里没有 SCNet Connect | 确认插件已装、profile 的 `dsh.profile.bundles` 里有 `dsh-scnet-connect`,然后触发热重载或重启 DSH |
207
+ | 设置页没有 SCNet Connect | 需要 DSH `0.2.2` 及以上(`settings.section` slot) |
208
+ | 没有可用模型 | 点「刷新模型」;免客户端模式下登录成功后会自动刷新 |
209
+ | 报 `No API key for provider: scnet` | 没有可用凭据:去设置页登录,或装客户端并登录一次 |
210
+ | 提示「平台会话已过期」 | 在设置页重新登录一次 |
211
+ | 短信收不到 | 确认手机号正确、图形验证码没填错;平台有 60 秒与每小时次数限制 |
212
+ | 上游 429 | 插件不屏蔽限流,降低并发或稍等重试 |
213
+
214
+ ---
215
+
216
+ ## 安全
217
+
218
+ - **不接收账号密码**:只走短信验证码,密码从不经过插件。
219
+ - 登录会话存于 `$DSH_HOME/scnet-session.json`(权限 `0600`),退出登录即删除。
220
+ - **这两样东西等价于你的账号权限**:不要复制给他人,不要提交进仓库。
221
+ - 插件只在本机回环地址上暴露设置页路由,且**不返回** Key / Cookie / 验证码明文。
222
+ - 若用 `apiKey` 配置项,它以明文存在 profile 的 `cordis.patch.yml` 里,请自行控制权限。
223
+
224
+ > `sk-` Key 是账号级凭据、与 SCNet 客户端共用,平台没有吊销接口。
225
+ > 所以「退出登录」的语义是**停止使用**,不是让 Key 在平台失效;要作废请到 SCNet 平台重置账号凭据。
226
+
227
+ ---
228
+
229
+ ## 已知限制
230
+
231
+ - 免费模型取决于平台:目前只有 `SCNet-Max` 标记为 `free`。
232
+ - 「免费」是平台侧的**限时**政策,不是永久免费;本插件不提供额度,也不绕过计费。
233
+ - 插件内**不提供微信扫码**(平台二维码接口对非微信客户端恒返回 402)。
234
+ - 用的是未公开的客户端内部接口,SCNet 客户端升级后可能变化。
235
+
236
+ ---
237
+
238
+ ## 开发
239
+
240
+ ```bash
241
+ git clone https://github.com/Phoeky/dsh-scnet-connect.git && cd dsh-scnet-connect
242
+ node tools/check.mjs # 自检:凭据、模型目录、账号
243
+ node tools/check.mjs --live # 额外请求一次 /models
244
+ ```
245
+
246
+ ```text
247
+ lib/index.js 插件入口:注册 provider、设置页路由
248
+ lib/client.js 浏览器侧:设置页卡片
249
+ lib/scnet-login.js 免客户端登录状态机
250
+ lib/scnet-platform.js 平台接口封装
251
+ lib/scnet-web-login.js 短信登录与验证码
252
+ lib/scnet-catalog.js 模型目录发现与过滤
253
+ lib/scnet-credential.js 客户端凭据读取
254
+ lib/scnet-models.js 模型描述符
255
+ ```
256
+
257
+ ## License
258
+
259
+ [MIT](LICENSE)
@@ -0,0 +1,29 @@
1
+ # dsh-scnet-connect(SCNet Connect)bundle patch
2
+ #
3
+ # 把插件本体装进 profile:
4
+ # id = loader entry id
5
+ # name = npm 包名(loader 用它 import 入口模块)
6
+ #
7
+ # provider(路由 `scnet`)由 lib/index.js 在 apply() 里动态注册,
8
+ # 不在这里写 provider 配置,避免覆盖用户现有的 llm-pi-ai.providers。
9
+ #
10
+ # 零配置即可用:默认读取本机 SCNet 客户端凭据,自动注册客户端目录里
11
+ # 所有 priceLabel=free 的模型(当前是 SCNet-Max)。
12
+ # 没装客户端也能用:在设置页用手机短信登录。
13
+ - insert:
14
+ - id: scnet-connect
15
+ name: dsh-scnet-connect
16
+ config: {}
17
+ # 全部字段有默认值;需要覆盖时取消对应注释。
18
+ # credentialDir: '' # 默认 ~/.sclaw/agent/scnet-credentials
19
+ # apiKey: '' # 留空 = 自动读客户端凭据(填了会明文存在本文件里)
20
+ # baseUrl: 'https://api.scnet.cn/api/llm/v1'
21
+ # modelIds: '' # 逗号分隔;留空 = 自动注册所有免费模型
22
+ # modelName: '' # 仅在只注册一个模型时生效
23
+ # contextWindow: 0 # 0 = 跟随客户端目录 / 内置默认
24
+ # maxTokens: 0 # 0 = 跟随客户端目录 / 内置默认
25
+ # inputImages: true
26
+ # reasoning: true
27
+ # verifyWithGateway: true # 刷新模型时用 GET /models 校验可用性
28
+ # freeOnly: true # 只注册免费模型(默认开)
29
+ # credentialSource: auto # auto | client | login