dsh-connect-workbuddy-gateway 1.4.2 → 1.4.3
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 +1 -1
- package/package.json +1 -1
- package/src/pairing.js +7 -3
- package/src/routes.js +11 -1
package/README.md
CHANGED
|
@@ -558,7 +558,7 @@ hy4flash-free@#9 ← 昵称含中文/emoji,退化成序号
|
|
|
558
558
|
node tests/harness.mjs
|
|
559
559
|
```
|
|
560
560
|
|
|
561
|
-
覆盖
|
|
561
|
+
覆盖 292 项:首次建 key 与惰性补选、鉴权、模型勾选与清单投影、重名后缀(区域 / 昵称 /
|
|
562
562
|
非 ASCII 序号)、跨区同名、按名字路由、推理档透传、**固定监听端口与占用提示**、**局域网分享与接入**、**两种角色模式**、
|
|
563
563
|
并行工具调用按 index 分组、
|
|
564
564
|
Responses 流的规范校验(`sequence_number`、part 一致性、terminal 的 output 顺序)、
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-connect-workbuddy-gateway",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "把 dsh-connect-workbuddy 的 WorkBuddy 模型开放成 HTTP API:OpenAI Chat / Responses、Anthropic Messages、Gemini 四协议共用一个固定 base URL,模型按 API key 逐个勾选。也可切换成接收方,接入局域网内另一台设备分享的模型。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh-plugin",
|
package/src/pairing.js
CHANGED
|
@@ -57,13 +57,17 @@ export function createPairingRegistry({ logger, now = () => Date.now() } = {}) {
|
|
|
57
57
|
/**
|
|
58
58
|
* 接收方发起配对请求。
|
|
59
59
|
*
|
|
60
|
-
*
|
|
60
|
+
* `deviceName` **不是必填**:它只是给对方看的「谁在申请」,缺了给个中性占位
|
|
61
|
+
* 就行,不该让一次配对因为一个显示名而失败。之前这里返回 400,结果手动填地址
|
|
62
|
+
* 那条路径(不带设备名)直接报 `deviceName is required` —— 用户什么都没做错。
|
|
63
|
+
*
|
|
64
|
+
* @param input `{ deviceName?, nonce? }`
|
|
61
65
|
* @returns `{ nonce, expiresAt }` 或 `{ error }`
|
|
62
66
|
*/
|
|
63
67
|
function request(input) {
|
|
64
68
|
sweep()
|
|
65
|
-
const
|
|
66
|
-
|
|
69
|
+
const raw = typeof input?.deviceName === 'string' ? input.deviceName.trim() : ''
|
|
70
|
+
const deviceName = raw === '' ? 'a device' : raw.slice(0, 64)
|
|
67
71
|
|
|
68
72
|
if (pending.size >= MAX_PENDING) {
|
|
69
73
|
/* 满了就不收新的:拒绝比静默丢更诚实,接收方知道要等人处理。 */
|
package/src/routes.js
CHANGED
|
@@ -686,7 +686,17 @@ async function dispatchAdmin(req, res, ctx, env) {
|
|
|
686
686
|
sendJson(res, 400, { error: 'baseUrl must look like http://192.168.31.107:8790' })
|
|
687
687
|
return
|
|
688
688
|
}
|
|
689
|
-
|
|
689
|
+
/*
|
|
690
|
+
* `deviceName` 允许缺省,也允许是空串 —— 那是「用户没填名字」,不是错误。
|
|
691
|
+
*
|
|
692
|
+
* **不能用 `??`**:它只在 null/undefined 时兜底,而手动填地址那条路径传的
|
|
693
|
+
* 是空字符串,`??` 会放过它,于是 '' 一路走到 pairing.request 被拒成
|
|
694
|
+
* 「deviceName is required」。用户什么都没做错,却看到一个字段名报错。
|
|
695
|
+
*/
|
|
696
|
+
const deviceName = typeof body?.deviceName === 'string' && body.deviceName.trim() !== ''
|
|
697
|
+
? body.deviceName.trim()
|
|
698
|
+
: defaultDeviceName()
|
|
699
|
+
const result = await requestPairing(baseUrl, deviceName)
|
|
690
700
|
if (result.error !== undefined) {
|
|
691
701
|
sendJson(res, 400, { error: result.error })
|
|
692
702
|
return
|