@authinex/dsh-plugin 0.1.0 → 0.1.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 +74 -31
- package/lib/client.js +85 -17
- package/lib/index.js +46 -10
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,56 +1,99 @@
|
|
|
1
1
|
# AuthineX DS 插件
|
|
2
2
|
|
|
3
|
-
DeepSeek
|
|
3
|
+
在 DeepSeek 里直接问产品、查工单、检索源码、做线上定位,并用你自己的 ONES / 氚云 / PMO 账号建单。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
装好后由你填**访问地址**和**密钥**完成绑定。插件本身不带任何默认地址、公司信息或密钥。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## 功能
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
绑定后,对话里会出现这些工具:
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
| 工具 | 做什么 |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| 咨询问题 | 检索云枢知识库(产品手册、专家经验、源码说明、版本说明)。用完整中文问句,可带版本收窄 |
|
|
14
|
+
| 查询工单 | 按单号查 ONES、氚云或 PMO;没有单号时按标题筛 |
|
|
15
|
+
| 查询相似工单 | 按现象检索历史上修过的相似工单,给出当时的根因和解决办法 |
|
|
16
|
+
| 修复模式 | 按现象检索团队修复模式库:问题模式、根因、修复策略、关键文件 |
|
|
17
|
+
| 代码检索 | 检索云枢代码索引,返回文件路径、行号和代码片段。可指定仓或分支 |
|
|
18
|
+
| 问智能助手 | 把整个问题交给智能助手,返回答案和出处 |
|
|
19
|
+
| 线上源码定位 | 按版本读线上源码做只读定位,返回根因和位置;通常 2–4 分钟 |
|
|
20
|
+
| 查任务进度 | 查上面那条定位任务的进度和结论 |
|
|
21
|
+
| 创建工单 | 起草 ONES、氚云或 PMO 工单,你确认后才提交 |
|
|
12
22
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
23
|
+
配置页里还有:
|
|
24
|
+
|
|
25
|
+
- **工单账号**:ONES、氚云、PMO 三家。与 AuthineX、运营台「个人设置」是同一份数据——已经配过的直接拉下来用,在这里新填的写回 AgentHub。每家可以单独启用或停用,填完先测连接再保存。
|
|
26
|
+
- **更新**:检查到新版本后可以直接在页面里更新,装完重启智能问答生效,绑定和账号都不动。
|
|
27
|
+
- **解除绑定**:二次确认后清掉本机的地址和密钥,服务端作废这台设备。
|
|
28
|
+
|
|
29
|
+
插件只做「看和判断」:不改你本机的文件、不推代码、不收你的 GitLab 凭据。要动本机用桌面端 AuthineX。
|
|
30
|
+
|
|
31
|
+
权限由运营台角色和签发的密钥共同决定,角色不够的工具不会出现在列表里。
|
|
32
|
+
|
|
33
|
+
## 安装
|
|
34
|
+
|
|
35
|
+
包名 `@authinex/dsh-plugin`,已发布到 [npm](https://www.npmjs.com/package/@authinex/dsh-plugin)。
|
|
36
|
+
|
|
37
|
+
**方式一:插件页**
|
|
38
|
+
|
|
39
|
+
左侧「插件」→ 右上「添加插件」→ 输入 `@authinex/dsh-plugin` → 安装。
|
|
40
|
+
|
|
41
|
+
国内网络在对话框的「安装源」里选**中国镜像源**(`registry.npmmirror.com`)。镜像还没同步到时,选「自定义地址」填下面任意一个:
|
|
17
42
|
|
|
18
|
-
|
|
43
|
+
- `https://mirrors.cloud.tencent.com/npm/`
|
|
44
|
+
- `https://mirrors.huaweicloud.com/repository/npm/`
|
|
19
45
|
|
|
20
|
-
|
|
46
|
+
**方式二:命令行**
|
|
21
47
|
|
|
22
48
|
```bash
|
|
23
|
-
|
|
49
|
+
dsh plugin --profile <你的 profile> add @authinex/dsh-plugin
|
|
24
50
|
```
|
|
25
51
|
|
|
26
|
-
|
|
52
|
+
国内网络加 `--registry=https://registry.npmmirror.com/`。
|
|
27
53
|
|
|
28
|
-
|
|
54
|
+
装完**重启智能问答**。插件清单只在 Host 启动那一刻拼出来,不重启看不到。
|
|
29
55
|
|
|
30
|
-
|
|
56
|
+
> 刚发布完可能提示「未找到相关插件」——这是 npm 元数据还没扩散,等几分钟再试。
|
|
31
57
|
|
|
32
|
-
|
|
58
|
+
> 刚发布不到 24 小时的版本会被 pnpm 的供应链策略(`minimumReleaseAge`)暂缓,直接装会拿到上一个版本。要新版本就装精确版本号 `@authinex/dsh-plugin@x.y.z`;插件页会先卸掉当前版本再装。
|
|
33
59
|
|
|
34
|
-
|
|
35
|
-
- **Client**(`lib/client.js`,跑在插件页里)通过 `window.__ModuleLoader__` 注册,同时挂到 DeepSeek 的 `plugins.bundle.config` 和 `plugins.row.config` 两个插槽。页面上只有两个输入框:访问地址和密钥。页面不保存公司、用户和密码。
|
|
60
|
+
## 绑定
|
|
36
61
|
|
|
37
|
-
|
|
62
|
+
左侧「插件」→ 点这一行右侧的「Configure」,页面上有两个输入框:
|
|
38
63
|
|
|
39
|
-
|
|
64
|
+
- **访问地址**:你所在环境的 AgentHub 地址,必须是完整的 `http://` 或 `https://`,不能带账号密码。
|
|
65
|
+
- **密钥**:管理员签发的 `auds-t-…`(测试)或 `auds-p-…`(生产)。
|
|
40
66
|
|
|
41
|
-
|
|
67
|
+
两个都填对才能绑上。几个约定:
|
|
42
68
|
|
|
43
|
-
|
|
69
|
+
- 密钥一次性,兑换成功即作废。
|
|
70
|
+
- 测试密钥只能连测试环境,前缀和服务对不上只显示「密钥无效」。
|
|
71
|
+
- 绑定成功后地址和私钥一起存进本机凭据,重启自动登录,不用重填。
|
|
72
|
+
- 换地址要先「解除绑定」再重填。
|
|
73
|
+
- 验证通过后才会出现使用者、功能列表和账号;没通过之前这些都不显示。
|
|
44
74
|
|
|
45
|
-
|
|
46
|
-
npm login
|
|
47
|
-
npm publish
|
|
48
|
-
```
|
|
75
|
+
## 工单账号
|
|
49
76
|
|
|
50
|
-
|
|
77
|
+
在配置页展开某一家填字段,「测试连接」通过才能保存。
|
|
51
78
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
79
|
+
- 卡片上的账号一律打码:邮箱 `z****@example.com`,手机号 `158****3***`。展开表单才能看到完整值,因为保存时要按原值回写。
|
|
80
|
+
- 密码 / Token 框留空表示不修改原来的。
|
|
81
|
+
- 角色只给了读权限时,那一家显示「已配置,只能查」。
|
|
82
|
+
- 停用某一家后,它不再参与建单和查单。
|
|
83
|
+
|
|
84
|
+
## 更新
|
|
85
|
+
|
|
86
|
+
点「检查更新」先取服务端清单;服务端没配更新源(清单 404)时,退回 npm 的 `latest` 标签比较版本,这时只能发现版本号,安装仍让 DeepSeek 的安装器按 `@authinex/dsh-plugin@x.y.z` 去 npm 取。
|
|
87
|
+
|
|
88
|
+
点「更新到 x.y.z」并确认,插件会调用 DeepSeek 自己的安装器装新版本。装完重启智能问答生效,绑定和账号都不动。
|
|
89
|
+
|
|
90
|
+
## 在对话里用
|
|
91
|
+
|
|
92
|
+
直接说人话就行,模型会自己选工具:
|
|
93
|
+
|
|
94
|
+
- 「云枢 8.7 表单设计器的显示条件为什么不生效」→ 查知识库
|
|
95
|
+
- 「DTS-1234 这个单什么情况」→ 查工单
|
|
96
|
+
- 「登录页白屏,帮我看下大概在哪个文件」→ 线上源码定位,然后用「查任务进度」取结论
|
|
97
|
+
- 「给 ONES 建个单,标题是登录失败」→ 起草,弹出确认卡,你点创建才提交
|
|
55
98
|
|
|
56
|
-
|
|
99
|
+
取消确认卡之后,同一个草稿不会再自动提交。
|
package/lib/client.js
CHANGED
|
@@ -217,6 +217,27 @@ var ACCOUNT_FIELDS = {
|
|
|
217
217
|
]
|
|
218
218
|
};
|
|
219
219
|
var ACCOUNT_LABELS = { ones: "ONES", h3yun: "氚云", pmo: "PMO" };
|
|
220
|
+
function maskMobile(raw) {
|
|
221
|
+
const digits = String(raw || "").replace(/[\s-]/g, "");
|
|
222
|
+
if (!digits) return "";
|
|
223
|
+
if (/^\d{11}$/.test(digits)) return `${digits.slice(0, 3)}****${digits.slice(-4)}`;
|
|
224
|
+
if (digits.length <= 4) return "****";
|
|
225
|
+
return `${digits.slice(0, 3)}****${digits.slice(-2)}`;
|
|
226
|
+
}
|
|
227
|
+
function maskEmail(raw) {
|
|
228
|
+
const text = String(raw || "").trim();
|
|
229
|
+
const at = text.indexOf("@");
|
|
230
|
+
if (at <= 0) return text.length <= 1 ? "****" : `${text.slice(0, 1)}****`;
|
|
231
|
+
return `${text.slice(0, 1)}****@${text.slice(at + 1)}`;
|
|
232
|
+
}
|
|
233
|
+
function maskAccount(raw) {
|
|
234
|
+
const text = String(raw || "").trim();
|
|
235
|
+
if (!text) return "";
|
|
236
|
+
if (/^\d{11}$/.test(text)) return maskMobile(text);
|
|
237
|
+
if (text.indexOf("@") > 0) return maskEmail(text);
|
|
238
|
+
if (text.length <= 4) return `${text.slice(0, 1)}****`;
|
|
239
|
+
return `${text.slice(0, 2)}****${text.slice(-2)}`;
|
|
240
|
+
}
|
|
220
241
|
function verified(state) {
|
|
221
242
|
const phase = state?.phase;
|
|
222
243
|
return phase === "bound" || phase === "caps-missing" || phase === "upgrade";
|
|
@@ -263,7 +284,8 @@ function viewModel(state) {
|
|
|
263
284
|
state: String(row.state || "unconfigured"),
|
|
264
285
|
status: String(row.label || "未配置"),
|
|
265
286
|
hint: String(row.hint || ""),
|
|
266
|
-
|
|
287
|
+
// 卡片上只展示打码后的账号;编辑表单另算,值来自 accountFields。
|
|
288
|
+
username: row.state === "unconfigured" ? "" : maskAccount(String(row.username || "")),
|
|
267
289
|
enabled: row.enabled !== false,
|
|
268
290
|
hasToken: Boolean(row.hasToken),
|
|
269
291
|
fields: accountFields(id, row)
|
|
@@ -306,6 +328,9 @@ async function api(path, init) {
|
|
|
306
328
|
return {};
|
|
307
329
|
}
|
|
308
330
|
}
|
|
331
|
+
function dwell(ms = 450) {
|
|
332
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
333
|
+
}
|
|
309
334
|
function tagTone(state) {
|
|
310
335
|
if (state === "ready") return "success";
|
|
311
336
|
if (state === "read_only") return "info";
|
|
@@ -330,6 +355,7 @@ function AuthinexPanel() {
|
|
|
330
355
|
const [confirmUnbind, setConfirmUnbind] = (0, import_react.useState)(false);
|
|
331
356
|
const [confirmUpdate, setConfirmUpdate] = (0, import_react.useState)(false);
|
|
332
357
|
const [restart, setRestart] = (0, import_react.useState)(false);
|
|
358
|
+
const [feedback, setFeedback] = (0, import_react.useState)("");
|
|
333
359
|
const model = (0, import_react.useMemo)(() => viewModel(state || void 0), [state]);
|
|
334
360
|
const applyState = (0, import_react.useCallback)((next) => {
|
|
335
361
|
setState(next);
|
|
@@ -337,8 +363,10 @@ function AuthinexPanel() {
|
|
|
337
363
|
const read = (0, import_react.useCallback)(async () => {
|
|
338
364
|
try {
|
|
339
365
|
applyState(await api("/authinex-ds/state"));
|
|
366
|
+
return true;
|
|
340
367
|
} catch {
|
|
341
368
|
setState({ phase: "unreachable" });
|
|
369
|
+
return false;
|
|
342
370
|
} finally {
|
|
343
371
|
setLoaded(true);
|
|
344
372
|
}
|
|
@@ -353,10 +381,14 @@ function AuthinexPanel() {
|
|
|
353
381
|
setBusy(label);
|
|
354
382
|
setNotice("");
|
|
355
383
|
setLocalError("");
|
|
384
|
+
setFeedback("");
|
|
356
385
|
try {
|
|
357
386
|
await work();
|
|
358
387
|
} catch {
|
|
359
388
|
setState({ phase: "unreachable" });
|
|
389
|
+
if (label === "refresh") setNotice("没有刷新到");
|
|
390
|
+
if (label === "update") setNotice("没有查到更新");
|
|
391
|
+
if (label === "refresh" || label === "update") setFeedback("error");
|
|
360
392
|
} finally {
|
|
361
393
|
setBusy("");
|
|
362
394
|
}
|
|
@@ -442,11 +474,28 @@ function AuthinexPanel() {
|
|
|
442
474
|
}
|
|
443
475
|
});
|
|
444
476
|
};
|
|
477
|
+
const onRefresh = () => {
|
|
478
|
+
void run("refresh", async () => {
|
|
479
|
+
const [ok] = await Promise.all([read(), dwell()]);
|
|
480
|
+
if (!ok) {
|
|
481
|
+
setFeedback("error");
|
|
482
|
+
setNotice("没有刷新到");
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
setFeedback("ok");
|
|
486
|
+
setNotice("已刷新");
|
|
487
|
+
});
|
|
488
|
+
};
|
|
445
489
|
const onCheckUpdate = () => {
|
|
446
490
|
void run("update", async () => {
|
|
447
|
-
const body = await
|
|
491
|
+
const [body] = await Promise.all([
|
|
492
|
+
api("/authinex-ds/update/check", { method: "POST" }),
|
|
493
|
+
dwell()
|
|
494
|
+
]);
|
|
448
495
|
applyState(body);
|
|
449
|
-
|
|
496
|
+
const text = String(body.updateMessage || "没有查到更新");
|
|
497
|
+
setNotice(text);
|
|
498
|
+
setFeedback(text.includes("没有") ? "warn" : "ok");
|
|
450
499
|
});
|
|
451
500
|
};
|
|
452
501
|
const onApplyUpdate = () => {
|
|
@@ -461,6 +510,8 @@ function AuthinexPanel() {
|
|
|
461
510
|
const message = localError || notice || model.message;
|
|
462
511
|
const messageError = localError !== "" || model.phase === "invalid" || model.phase === "revoked" || model.phase === "unreachable";
|
|
463
512
|
const disabled = busy !== "";
|
|
513
|
+
const pending = busy === "refresh" ? "正在刷新…" : busy === "update" ? "正在检查更新…" : "";
|
|
514
|
+
const messageClass = feedback === "ok" ? "axds-ok" : feedback === "warn" ? "axds-notice" : messageError || feedback === "error" ? "axds-error" : "axds-muted";
|
|
464
515
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "axds", "aria-label": "AuthineX 助手", children: [
|
|
465
516
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "axds-head", children: [
|
|
466
517
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.StateDot, { state: model.tone }),
|
|
@@ -468,9 +519,7 @@ function AuthinexPanel() {
|
|
|
468
519
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "axds-title", children: "AuthineX 助手" }),
|
|
469
520
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "axds-sub", children: loaded ? model.headline : "正在读取状态…" })
|
|
470
521
|
] }),
|
|
471
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "axds-head-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick:
|
|
472
|
-
void read();
|
|
473
|
-
}, children: "刷新" }) })
|
|
522
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "axds-head-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick: onRefresh, children: busy === "refresh" ? "刷新中" : "刷新" }) })
|
|
474
523
|
] }),
|
|
475
524
|
model.retryAfterSec > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "axds-notice", children: [
|
|
476
525
|
"请等待 ",
|
|
@@ -484,7 +533,10 @@ function AuthinexPanel() {
|
|
|
484
533
|
model.minVersion,
|
|
485
534
|
"。请先更新插件。"
|
|
486
535
|
] }) : null,
|
|
487
|
-
|
|
536
|
+
pending ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "axds-pending", role: "status", children: [
|
|
537
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "axds-spin", "aria-hidden": "true" }),
|
|
538
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: pending })
|
|
539
|
+
] }, "pending") : message ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: messageClass, role: "status", children: message }, message) : null,
|
|
488
540
|
showForm ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "axds-card", onSubmit: onBind, children: [
|
|
489
541
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "axds-field", children: [
|
|
490
542
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "访问地址" }),
|
|
@@ -523,7 +575,16 @@ function AuthinexPanel() {
|
|
|
523
575
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-actions", children: [
|
|
524
576
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "axds-muted", children: "地址和密钥都由你填;插件本身不带任何地址或密钥。" }),
|
|
525
577
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { type: "submit", variant: "primary", size: "md", disabled: disabled || key.trim() === "", children: "绑定" })
|
|
526
|
-
] })
|
|
578
|
+
] }),
|
|
579
|
+
model.endpoint ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-actions", children: [
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "axds-muted", children: [
|
|
581
|
+
"本机还记着上次的地址 ",
|
|
582
|
+
model.endpoint
|
|
583
|
+
] }),
|
|
584
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", disabled, onClick: () => {
|
|
585
|
+
setConfirmUnbind(true);
|
|
586
|
+
}, children: "解除绑定" })
|
|
587
|
+
] }) : null
|
|
527
588
|
] }) : null,
|
|
528
589
|
model.user ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
529
590
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-row", children: [
|
|
@@ -641,19 +702,19 @@ function AuthinexPanel() {
|
|
|
641
702
|
] }) : null,
|
|
642
703
|
restart ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "axds-notice", children: "已装好,重启智能问答后新版本才生效。" }) : null,
|
|
643
704
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-row", children: [
|
|
644
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick: onCheckUpdate, children: "检查更新" }),
|
|
705
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick: onCheckUpdate, children: busy === "update" ? "检查中" : "检查更新" }),
|
|
645
706
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", disabled, onClick: () => {
|
|
646
707
|
setConfirmUnbind(true);
|
|
647
708
|
}, children: "解除绑定" }),
|
|
648
709
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "axds-muted", children: "解除后地址和密钥都会清掉,要重新填" })
|
|
649
|
-
] })
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
710
|
+
] })
|
|
711
|
+
] }) : null,
|
|
712
|
+
confirmUnbind ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-confirm", children: [
|
|
713
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "确认解除这台设备的绑定?" }),
|
|
714
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", onClick: () => {
|
|
715
|
+
setConfirmUnbind(false);
|
|
716
|
+
}, children: "取消" }),
|
|
717
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "primary", disabled, onClick: onUnbind, children: "确认解除" })
|
|
657
718
|
] }) : null,
|
|
658
719
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("footer", { className: "axds-foot", children: [
|
|
659
720
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
@@ -683,6 +744,13 @@ var CSS = `
|
|
|
683
744
|
.axds-notice{color:var(--dsw-alias-state-warn-label);font-size:12px}
|
|
684
745
|
.axds-error{color:var(--dsw-alias-state-error-primary);font-size:12px}
|
|
685
746
|
.axds-ok{color:var(--dsw-alias-state-success-primary);font-size:12px}
|
|
747
|
+
/* 状态行换了内容时淡入一下,否则点「刷新」像什么都没发生。 */
|
|
748
|
+
.axds-pending,.axds-ok,.axds-notice,.axds-error{animation:axds-fade .18s ease-out both}
|
|
749
|
+
@keyframes axds-fade{from{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}
|
|
750
|
+
@media (prefers-reduced-motion:reduce){.axds-pending,.axds-ok,.axds-notice,.axds-error{animation:none}}
|
|
751
|
+
.axds-pending{display:flex;align-items:center;gap:8px;color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
752
|
+
.axds-spin{width:14px;height:14px;border-radius:50%;border:2px solid var(--dsw-alias-border-l1);border-top-color:var(--dsw-alias-label-primary);animation:axds-spin .7s linear infinite;flex:none}
|
|
753
|
+
@keyframes axds-spin{to{transform:rotate(360deg)}}
|
|
686
754
|
.axds-bind{display:flex;gap:8px;align-items:center}
|
|
687
755
|
/* Input 原子自带边框、圆角与 focus-within;这里只让它占满一行,别再叠一层。 */
|
|
688
756
|
.axds-input{display:flex;width:100%;box-sizing:border-box;height:36px}
|
package/lib/index.js
CHANGED
|
@@ -215,8 +215,9 @@ var ROW_ID = "authinex-ds-plugin";
|
|
|
215
215
|
var ROW_KEY = `${PACKAGE_NAME}#${ROW_ID}`;
|
|
216
216
|
|
|
217
217
|
// src/controller.ts
|
|
218
|
-
var VERSION = true ? "0.1.
|
|
218
|
+
var VERSION = true ? "0.1.3" : "0.1.0";
|
|
219
219
|
var CREDENTIAL_REF = "AUTHINEX_DS_DEVICE";
|
|
220
|
+
var NPM_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
|
|
220
221
|
var ALLOWED_DETAILS = /* @__PURE__ */ new Set([
|
|
221
222
|
"密钥无效",
|
|
222
223
|
"尝试次数过多,请稍后再试",
|
|
@@ -499,14 +500,16 @@ function createController(options) {
|
|
|
499
500
|
if (!parsed) {
|
|
500
501
|
return { ok: false, message: PHRASES.invalid, state: fail("invalid") };
|
|
501
502
|
}
|
|
502
|
-
memory.endpoint
|
|
503
|
-
if (memory.token && memory.phase === "bound") {
|
|
503
|
+
if (memory.token && memory.phase === "bound" && memory.endpoint === endpoint) {
|
|
504
504
|
return { ok: true, state: snapshot() };
|
|
505
505
|
}
|
|
506
|
+
memory.endpoint = endpoint;
|
|
506
507
|
const existing = await readSecret();
|
|
507
|
-
|
|
508
|
+
const samePlace = Boolean(existing?.endpoint) && existing?.endpoint === endpoint;
|
|
509
|
+
if (samePlace && existing?.privateJwk && existing.deviceId) {
|
|
508
510
|
const restored = await restore();
|
|
509
511
|
if (memory.token) return { ok: true, state: restored };
|
|
512
|
+
memory.endpoint = endpoint;
|
|
510
513
|
}
|
|
511
514
|
memory.phase = "binding";
|
|
512
515
|
memory.detail = "";
|
|
@@ -541,9 +544,12 @@ function createController(options) {
|
|
|
541
544
|
} catch (error) {
|
|
542
545
|
const known = phaseError(error);
|
|
543
546
|
const retryAfter = known?.retryAfter || 0;
|
|
544
|
-
|
|
547
|
+
const phase = known?.phase || "unreachable";
|
|
548
|
+
fail(phase, known?.detail || "");
|
|
545
549
|
memory.retryAfter = retryAfter;
|
|
546
|
-
|
|
550
|
+
const text = phrase(phase);
|
|
551
|
+
const message = phase === "unreachable" && memory.endpoint ? `${text}(${memory.endpoint})` : text;
|
|
552
|
+
return { ok: false, message, state: snapshot() };
|
|
547
553
|
}
|
|
548
554
|
}
|
|
549
555
|
async function unbind() {
|
|
@@ -757,11 +763,34 @@ ${description}`;
|
|
|
757
763
|
return null;
|
|
758
764
|
}
|
|
759
765
|
}
|
|
766
|
+
async function fetchNpmLatest() {
|
|
767
|
+
try {
|
|
768
|
+
const response = await fetchImpl(NPM_LATEST_URL, {
|
|
769
|
+
method: "GET",
|
|
770
|
+
headers: { accept: "application/json" },
|
|
771
|
+
timeout: 1e4
|
|
772
|
+
});
|
|
773
|
+
if (!response.ok) return null;
|
|
774
|
+
const data = JSON.parse(await response.text());
|
|
775
|
+
const found = String(data.version || "").trim();
|
|
776
|
+
if (!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(found)) return null;
|
|
777
|
+
return {
|
|
778
|
+
version: found,
|
|
779
|
+
sha: "",
|
|
780
|
+
notes: "服务端没有更新清单,按 npm 上的最新版本比较",
|
|
781
|
+
artifact: "",
|
|
782
|
+
size: 0,
|
|
783
|
+
available: versionBelow(version, found)
|
|
784
|
+
};
|
|
785
|
+
} catch {
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
760
789
|
async function checkUpdate() {
|
|
761
790
|
if (memory.busy) return { ok: false, message: BUSY, state: snapshot() };
|
|
762
791
|
const base = normalizeEndpoint(memory.endpoint);
|
|
763
|
-
if (!base) return { ok: false, message: PHRASES.unreachable, state: snapshot() };
|
|
764
|
-
const found = await fetchManifest();
|
|
792
|
+
if (!base || !memory.token) return { ok: false, message: PHRASES.unreachable, state: snapshot() };
|
|
793
|
+
const found = await fetchManifest() || await fetchNpmLatest();
|
|
765
794
|
if (!found) {
|
|
766
795
|
memory.update = null;
|
|
767
796
|
return { ok: false, message: "没有查到更新", state: snapshot() };
|
|
@@ -769,9 +798,13 @@ ${description}`;
|
|
|
769
798
|
memory.update = found;
|
|
770
799
|
return { ok: true, message: found.available ? `发现新版本 ${found.version}` : "已经是最新版本", state: snapshot() };
|
|
771
800
|
}
|
|
801
|
+
async function discoverUpdate() {
|
|
802
|
+
if (memory.update?.available) return memory.update;
|
|
803
|
+
return await fetchManifest() || await fetchNpmLatest();
|
|
804
|
+
}
|
|
772
805
|
async function applyUpdate() {
|
|
773
806
|
if (memory.busy) return { ok: false, message: BUSY };
|
|
774
|
-
const found =
|
|
807
|
+
const found = await discoverUpdate();
|
|
775
808
|
if (!found) return { ok: false, message: "没有查到更新" };
|
|
776
809
|
memory.update = found;
|
|
777
810
|
if (!found.available) return { ok: false, message: "已经是最新版本" };
|
|
@@ -792,10 +825,13 @@ ${description}`;
|
|
|
792
825
|
if (memory.busy) return { ok: false, message: BUSY };
|
|
793
826
|
const base = normalizeEndpoint(memory.endpoint);
|
|
794
827
|
if (!base || !memory.token) return { ok: false, message: PHRASES.unreachable };
|
|
795
|
-
const found =
|
|
828
|
+
const found = await discoverUpdate();
|
|
796
829
|
if (!found) return { ok: false, message: "没有查到更新" };
|
|
797
830
|
memory.update = found;
|
|
798
831
|
if (!found.available) return { ok: false, message: "已经是最新版本" };
|
|
832
|
+
if (!found.artifact) {
|
|
833
|
+
return { ok: false, message: "这次只查到 npm 上的版本号,没有可下载的更新包,请到插件页更新" };
|
|
834
|
+
}
|
|
799
835
|
if (!/^authinex-dsh-plugin-[0-9A-Za-z.+-]+\.(tgz|tar\.gz)$/.test(found.artifact)) {
|
|
800
836
|
return { ok: false, message: "更新包名不合法,已放弃这次更新" };
|
|
801
837
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authinex/dsh-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "DeepSeek 里的 AuthineX 插件:问知识库、查工单、检索源码、只读定位,并用本人账号建单",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"typecheck": "tsc --noEmit",
|
|
35
35
|
"test": "tsc --noEmit && node scripts/build.mjs && node --test test/*.test.mjs",
|
|
36
36
|
"prepublishOnly": "npm test",
|
|
37
|
+
"release": "node scripts/publish.mjs",
|
|
37
38
|
"preview": "node scripts/preview.mjs"
|
|
38
39
|
},
|
|
39
40
|
"publishConfig": {
|