@authinex/dsh-plugin 0.3.7 → 0.3.8

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/cordis.patch.yml CHANGED
@@ -1,4 +1,10 @@
1
1
  # 组合包只插入一行。地址和密钥都由用户在插件配置页自己填,这里不带任何默认值。
2
+ #
3
+ # id 是这一行在插件树里的身份,也会出现在插件页「包含的组件」里。早先它叫
4
+ # `authinex-ds-plugin`,和包名只差一个连字符,读起来像「包里又装了同一个包」;
5
+ # 改成 `authinex-host`,标明这是插件在 Host 上跑的那一半(工具、命令、提示词)。
6
+ # 改这里必须同步 `src/view.ts` 的 ROW_ID:`plugins.row.config` 的键是
7
+ # `<包名>#<行 id>`,两边不一致时行配置页会空白。
2
8
  - insert:
3
- - id: authinex-ds-plugin
9
+ - id: authinex-host
4
10
  name: '@authinex/dsh-plugin'
package/lib/client.js CHANGED
@@ -32,6 +32,59 @@ module.exports = __toCommonJS(client_exports);
32
32
  var import_react3 = require("react");
33
33
  var import_dsh_client_ui_primitives3 = require("@deepseek-ai/dsh-client-ui-primitives");
34
34
 
35
+ // src/account-wire.ts
36
+ function textOf(data, fallback) {
37
+ const message = typeof data.message === "string" ? data.message.trim() : "";
38
+ if (message) return message;
39
+ const detail = typeof data.detail === "string" ? data.detail.trim() : "";
40
+ if (detail) return detail;
41
+ return fallback;
42
+ }
43
+
44
+ // src/account-options.ts
45
+ var CURRENT_PREFIX = "当前值 ";
46
+ function withCurrent(rows, value, items, label = "") {
47
+ if (value && !items.some((item) => item.uuid === value)) {
48
+ const named = label.trim();
49
+ rows.push({ uuid: value, name: named && !named.startsWith(CURRENT_PREFIX) ? named : `${CURRENT_PREFIX}${value}` });
50
+ }
51
+ return rows;
52
+ }
53
+ function optionLabel(items, uuid) {
54
+ if (!uuid) return "";
55
+ const row = items.find((item) => item.uuid === uuid);
56
+ if (!row || row.name.startsWith(CURRENT_PREFIX)) return "";
57
+ return row.name;
58
+ }
59
+ function pickedName(items, uuid, previousId, previousName) {
60
+ return optionLabel(items, uuid) || (uuid && uuid === previousId ? previousName : "");
61
+ }
62
+ function onesSelectRows(input) {
63
+ const { field, draft, projects, types, busy } = input;
64
+ const value = draft[field.name] ?? "";
65
+ const project = draft.defaultProjectUuid ?? "";
66
+ const label = field.name === "defaultIssueTypeId" ? draft.defaultIssueTypeName ?? "" : draft.defaultProjectName ?? "";
67
+ if (field.name !== "defaultIssueTypeId") {
68
+ const rows2 = [{
69
+ uuid: "",
70
+ name: busy === "projects" ? "正在拉取项目…" : "— 请选择项目 —"
71
+ }];
72
+ for (const item of projects.items) rows2.push(item);
73
+ return { disabled: busy === "projects", rows: withCurrent(rows2, value, projects.items, label) };
74
+ }
75
+ if (!project) return { disabled: true, rows: [{ uuid: "", name: "先选择默认项目" }] };
76
+ if (busy === "types" || types.forProject !== project) {
77
+ return { disabled: true, rows: [{ uuid: "", name: "正在拉取工单类型…" }] };
78
+ }
79
+ if (types.message) {
80
+ const rows2 = [{ uuid: "", name: types.message }];
81
+ return { disabled: false, rows: withCurrent(rows2, value, types.items, label) };
82
+ }
83
+ const rows = [{ uuid: "", name: "— 请选择工单类型 —" }];
84
+ for (const item of types.items) rows.push(item);
85
+ return { disabled: false, rows: withCurrent(rows, value, types.items, label) };
86
+ }
87
+
35
88
  // src/endpoint.ts
36
89
  function checkEndpoint(raw) {
37
90
  const text = String(raw || "").trim();
@@ -246,10 +299,27 @@ function labelOf(kind) {
246
299
  const found = PRODUCT_KINDS.find((item) => item.id === kind);
247
300
  return found ? found.label : kind;
248
301
  }
302
+ function parseReceiptText(text) {
303
+ const lines = String(text || "").split("\n").map((line) => line.trim()).filter(Boolean);
304
+ const first = lines[0] || "";
305
+ const matched = /^(?:已设置|当前工作上下文):(.+)$/.exec(first);
306
+ if (!matched) return null;
307
+ const fields = [];
308
+ for (const part of matched[1].split(" / ")) {
309
+ const at = part.indexOf(" ");
310
+ if (at <= 0) return null;
311
+ const label = part.slice(0, at);
312
+ const value = part.slice(at + 1);
313
+ if (!label || !value) return null;
314
+ fields.push({ label, value });
315
+ }
316
+ if (!fields.length) return null;
317
+ return { fields, note: lines.slice(1).join("\n") };
318
+ }
249
319
 
250
320
  // src/view.ts
251
321
  var PACKAGE_NAME = "@authinex/dsh-plugin";
252
- var ROW_ID = "authinex-ds-plugin";
322
+ var ROW_ID = "authinex-host";
253
323
  var ROW_KEY = `${PACKAGE_NAME}#${ROW_ID}`;
254
324
  var SKILL_HOT_MIN = 5;
255
325
  function skillUseCount(row) {
@@ -265,6 +335,25 @@ function skillUseText(row) {
265
335
  const n = skillUseCount(row);
266
336
  return n ? `${n} 次` : "未使用";
267
337
  }
338
+ var HAS_TZ = /(?:Z|[+-]\d{2}:?\d{2})$/i;
339
+ function formatUpdatedAt(value) {
340
+ const text = (value || "").trim();
341
+ if (!text) return "—";
342
+ const date = new Date(HAS_TZ.test(text) ? text : `${text}Z`);
343
+ if (Number.isNaN(date.getTime())) return "—";
344
+ const parts = new Intl.DateTimeFormat("en-CA", {
345
+ timeZone: "Asia/Shanghai",
346
+ year: "numeric",
347
+ month: "2-digit",
348
+ day: "2-digit",
349
+ hour: "2-digit",
350
+ minute: "2-digit",
351
+ hourCycle: "h23"
352
+ }).formatToParts(date);
353
+ const pick = (type) => parts.find((part) => part.type === type)?.value || "";
354
+ const hour = pick("hour") === "24" ? "00" : pick("hour");
355
+ return `${pick("year")}-${pick("month")}-${pick("day")} ${hour}:${pick("minute")}`;
356
+ }
268
357
  var ACCOUNT_FIELDS = {
269
358
  gitlab: [
270
359
  { name: "username", title: "账号" },
@@ -371,7 +460,11 @@ function viewModel(state) {
371
460
  username: row.state === "unconfigured" ? "" : maskAccount(String(row.username || "")),
372
461
  enabled: row.enabled !== false,
373
462
  hasToken: Boolean(row.hasToken),
374
- fields: accountFields(id, row)
463
+ fields: accountFields(id, row),
464
+ extras: id === "ones" ? {
465
+ defaultProjectName: fieldValue(row, "defaultProjectName"),
466
+ defaultIssueTypeName: fieldValue(row, "defaultIssueTypeName")
467
+ } : {}
375
468
  };
376
469
  }) : [];
377
470
  const toolNames = showIdentity && !state?.upgradeRequired ? state?.tools || [] : [];
@@ -659,7 +752,7 @@ function WorkContextCard(props) {
659
752
  ] })
660
753
  ] }),
661
754
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "axds-actions", children: [
662
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "axds-muted", children: "也可以在对话里用 /ax-context" }),
755
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "axds-muted", children: "也可以在对话里用 /ax-context 云枢 8.7 某客户 要问的问题" }),
663
756
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives2.Button, { size: "sm", variant: "ghost", disabled: props.disabled, onClick: props.onClear, children: "清空" }),
664
757
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
665
758
  import_dsh_client_ui_primitives2.Button,
@@ -704,7 +797,7 @@ function tagTone(state) {
704
797
  return "outline";
705
798
  }
706
799
  function draftOf(account) {
707
- const draft = {};
800
+ const draft = { ...account.extras };
708
801
  for (const field of account.fields) draft[field.name] = field.value;
709
802
  return draft;
710
803
  }
@@ -751,6 +844,12 @@ function AuthinexPanel() {
751
844
  const [skillBusy, setSkillBusy] = (0, import_react3.useState)("");
752
845
  const [skillNotice, setSkillNotice] = (0, import_react3.useState)("");
753
846
  const [skillFeedback, setSkillFeedback] = (0, import_react3.useState)("");
847
+ const [accountMsg, setAccountMsg] = (0, import_react3.useState)({});
848
+ const [onesProjects, setOnesProjects] = (0, import_react3.useState)({ items: [], message: "", loaded: false });
849
+ const [onesTypes, setOnesTypes] = (0, import_react3.useState)({ items: [], message: "", forProject: "" });
850
+ const [optionsBusy, setOptionsBusy] = (0, import_react3.useState)("");
851
+ const projectTicket = (0, import_react3.useRef)(0);
852
+ const typeTicket = (0, import_react3.useRef)(0);
754
853
  const model = (0, import_react3.useMemo)(() => viewModel(state || void 0), [state]);
755
854
  const applyState = (0, import_react3.useCallback)((next) => {
756
855
  setState(next);
@@ -788,6 +887,62 @@ function AuthinexPanel() {
788
887
  setBusy("");
789
888
  }
790
889
  }, []);
890
+ const loadOnesProjects = (0, import_react3.useCallback)(async (form) => {
891
+ const ticket = ++projectTicket.current;
892
+ setOnesProjects((prev) => ({ ...prev, message: "" }));
893
+ setOptionsBusy("projects");
894
+ try {
895
+ const body = await api("/authinex-ds/accounts/options", {
896
+ method: "POST",
897
+ body: { provider: "ones", kind: "projects", form }
898
+ });
899
+ if (ticket !== projectTicket.current) return;
900
+ const ok = body.ok === true;
901
+ const items = Array.isArray(body.projects) ? body.projects : [];
902
+ const reason = textOf(body, "");
903
+ setOnesProjects({
904
+ items,
905
+ message: ok ? items.length ? "" : reason || "这个账号下没有可选项目" : reason || "没有拉到项目",
906
+ loaded: true
907
+ });
908
+ } catch {
909
+ if (ticket !== projectTicket.current) return;
910
+ setOnesProjects({ items: [], message: "没有拉到项目", loaded: true });
911
+ } finally {
912
+ if (ticket === projectTicket.current) setOptionsBusy((prev) => prev === "projects" ? "" : prev);
913
+ }
914
+ }, []);
915
+ const loadOnesTypes = (0, import_react3.useCallback)(async (project, form) => {
916
+ if (!project) {
917
+ typeTicket.current += 1;
918
+ setOnesTypes({ items: [], message: "", forProject: "" });
919
+ setOptionsBusy((prev) => prev === "types" ? "" : prev);
920
+ return;
921
+ }
922
+ const ticket = ++typeTicket.current;
923
+ setOnesTypes({ items: [], message: "", forProject: "" });
924
+ setOptionsBusy("types");
925
+ try {
926
+ const body = await api("/authinex-ds/accounts/options", {
927
+ method: "POST",
928
+ body: { provider: "ones", kind: "issueTypes", project, form }
929
+ });
930
+ if (ticket !== typeTicket.current) return;
931
+ const ok = body.ok === true;
932
+ const items = Array.isArray(body.issueTypes) ? body.issueTypes : [];
933
+ const reason = textOf(body, "");
934
+ setOnesTypes({
935
+ items,
936
+ message: ok ? items.length ? "" : reason || "这个项目下没有工单类型" : reason || "没有拉到工单类型",
937
+ forProject: project
938
+ });
939
+ } catch {
940
+ if (ticket !== typeTicket.current) return;
941
+ setOnesTypes({ items: [], message: "没有拉到工单类型", forProject: project });
942
+ } finally {
943
+ if (ticket === typeTicket.current) setOptionsBusy((prev) => prev === "types" ? "" : prev);
944
+ }
945
+ }, []);
791
946
  const onBind = (event) => {
792
947
  event.preventDefault();
793
948
  const url = endpoint.trim();
@@ -836,6 +991,9 @@ function AuthinexPanel() {
836
991
  setDrafts({});
837
992
  setEndpoint("");
838
993
  setSkillView(SKILL_EMPTY);
994
+ setAccountMsg({});
995
+ setOnesProjects({ items: [], message: "", loaded: false });
996
+ setOnesTypes({ items: [], message: "", forProject: "" });
839
997
  setNotice("已解除绑定,地址和密钥都清掉了");
840
998
  });
841
999
  };
@@ -846,6 +1004,14 @@ function AuthinexPanel() {
846
1004
  }
847
1005
  setOpen(account.id);
848
1006
  setDrafts((prev) => prev[account.id] ? prev : { ...prev, [account.id]: draftOf(account) });
1007
+ if (account.id === "ones") {
1008
+ setOnesTypes({ items: [], message: "", forProject: "" });
1009
+ const form = drafts.ones || draftOf(account);
1010
+ void (async () => {
1011
+ await loadOnesProjects(form);
1012
+ if (form.defaultProjectUuid) await loadOnesTypes(form.defaultProjectUuid, form);
1013
+ })();
1014
+ }
849
1015
  };
850
1016
  const setField = (account, name, value) => {
851
1017
  setDrafts((prev) => ({
@@ -853,6 +1019,35 @@ function AuthinexPanel() {
853
1019
  [account.id]: { ...prev[account.id] || draftOf(account), [name]: value }
854
1020
  }));
855
1021
  };
1022
+ const onOnesSelect = (account, name, value) => {
1023
+ const base = { ...drafts[account.id] || draftOf(account) };
1024
+ if (name === "defaultProjectUuid") {
1025
+ const previousId = base.defaultProjectUuid || "";
1026
+ const previousName = base.defaultProjectName || "";
1027
+ base.defaultProjectUuid = value;
1028
+ base.defaultProjectName = pickedName(onesProjects.items, value, previousId, previousName);
1029
+ if (value !== previousId) {
1030
+ base.defaultIssueTypeId = "";
1031
+ base.defaultIssueTypeName = "";
1032
+ }
1033
+ } else if (name === "defaultIssueTypeId") {
1034
+ const previousId = base.defaultIssueTypeId || "";
1035
+ const previousName = base.defaultIssueTypeName || "";
1036
+ base.defaultIssueTypeId = value;
1037
+ base.defaultIssueTypeName = pickedName(onesTypes.items, value, previousId, previousName);
1038
+ } else {
1039
+ base[name] = value;
1040
+ }
1041
+ setDrafts((prev) => ({ ...prev, [account.id]: base }));
1042
+ if (name === "defaultProjectUuid") void loadOnesTypes(value, base);
1043
+ };
1044
+ const onFetchOnes = (account) => {
1045
+ const form = drafts[account.id] || draftOf(account);
1046
+ void (async () => {
1047
+ await loadOnesProjects(form);
1048
+ if ((form.defaultProjectUuid || "").trim()) await loadOnesTypes(form.defaultProjectUuid, form);
1049
+ })();
1050
+ };
856
1051
  const onToggleEnabled = (account, next) => {
857
1052
  void run(`enabled:${account.id}`, async () => {
858
1053
  const body = await api("/authinex-ds/accounts/enabled", {
@@ -864,23 +1059,57 @@ function AuthinexPanel() {
864
1059
  });
865
1060
  };
866
1061
  const onTest = (account) => {
1062
+ const form = drafts[account.id] || draftOf(account);
1063
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text: `${account.label}:正在测试连接…`, tone: "pending" } }));
867
1064
  void run(`test:${account.id}`, async () => {
868
- const body = await api("/authinex-ds/accounts/test", {
869
- method: "POST",
870
- body: { provider: account.id, form: drafts[account.id] || draftOf(account) }
871
- });
872
- setNotice(`${account.label}:${String(body.message || (body.ok ? "连接正常" : "连接失败"))}`);
1065
+ let body;
1066
+ try {
1067
+ body = await api("/authinex-ds/accounts/test", {
1068
+ method: "POST",
1069
+ body: { provider: account.id, form }
1070
+ });
1071
+ } catch {
1072
+ const text2 = `${account.label}:没有连上,稍后再试`;
1073
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text: text2, tone: "error" } }));
1074
+ setNotice(text2);
1075
+ setFeedback("error");
1076
+ return;
1077
+ }
1078
+ const ok = Boolean(body.ok);
1079
+ const text = `${account.label}:${String(body.message || (ok ? "连接正常" : "连接失败"))}`;
1080
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text, tone: ok ? "ok" : "error" } }));
1081
+ setNotice(text);
1082
+ setFeedback(ok ? "ok" : "error");
1083
+ if (ok && account.id === "ones") {
1084
+ await loadOnesProjects(form);
1085
+ if ((form.defaultProjectUuid || "").trim()) await loadOnesTypes(form.defaultProjectUuid, form);
1086
+ }
873
1087
  });
874
1088
  };
875
1089
  const onSave = (account) => {
1090
+ const form = drafts[account.id] || draftOf(account);
1091
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text: `${account.label}:正在保存…`, tone: "pending" } }));
876
1092
  void run(`save:${account.id}`, async () => {
877
- const body = await api("/authinex-ds/accounts", {
878
- method: "PATCH",
879
- body: { provider: account.id, form: drafts[account.id] || draftOf(account) }
880
- });
1093
+ let body;
1094
+ try {
1095
+ body = await api("/authinex-ds/accounts", {
1096
+ method: "PATCH",
1097
+ body: { provider: account.id, form }
1098
+ });
1099
+ } catch {
1100
+ const text2 = `${account.label}:没有保存`;
1101
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text: text2, tone: "error" } }));
1102
+ setNotice(text2);
1103
+ setFeedback("error");
1104
+ return;
1105
+ }
881
1106
  if (body.state) applyState(body.state);
882
- setNotice(`${account.label}:${String(body.message || (body.ok ? "已保存" : "没有保存"))}`);
883
- if (body.ok) {
1107
+ const ok = Boolean(body.ok);
1108
+ const text = ok ? `${account.label}:已保存,个人设置和 AuthineX 已是这一份` : `${account.label}:${String(body.message || "没有保存")}`;
1109
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text, tone: ok ? "ok" : "error" } }));
1110
+ setNotice(text);
1111
+ setFeedback(ok ? "ok" : "error");
1112
+ if (ok) {
884
1113
  setDrafts((prev) => {
885
1114
  const next = { ...prev };
886
1115
  delete next[account.id];
@@ -1050,7 +1279,7 @@ function AuthinexPanel() {
1050
1279
  const message = localError || notice || model.message;
1051
1280
  const messageError = localError !== "" || model.phase === "invalid" || model.phase === "revoked" || model.phase === "unreachable";
1052
1281
  const disabled = busy !== "";
1053
- const pending = busy === "refresh" ? "正在刷新…" : busy === "update" ? "正在检查更新…" : "";
1282
+ const pending = busy === "refresh" ? "正在刷新…" : busy === "update" ? "正在检查更新…" : busy.startsWith("test:") ? "正在测试连接…" : busy.startsWith("save:") ? "正在保存…" : "";
1054
1283
  const messageClass = feedback === "ok" ? "axds-ok" : feedback === "warn" ? "axds-notice" : messageError || feedback === "error" ? "axds-error" : "axds-muted";
1055
1284
  const skillPending = skillBusy === "list" ? "正在取技能列表…" : "";
1056
1285
  const installed = model.installedSkills;
@@ -1234,31 +1463,70 @@ function AuthinexPanel() {
1234
1463
  account.hasToken ? " · 已有凭据" : ""
1235
1464
  ] }) : null,
1236
1465
  editing ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1237
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "axds-fields", children: account.fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "axds-field", children: [
1238
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: field.title }),
1239
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1240
- import_dsh_client_ui_primitives3.Input,
1241
- {
1242
- className: "axds-input",
1243
- type: field.type,
1244
- value: draft[field.name] ?? "",
1245
- placeholder: field.placeholder,
1246
- autoComplete: "off",
1247
- spellCheck: false,
1248
- onChange: (event) => {
1249
- setField(account, field.name, event.target.value);
1466
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "axds-fields", children: account.fields.map((field) => {
1467
+ const onesSelect = account.id === "ones" && (field.name === "defaultProjectUuid" || field.name === "defaultIssueTypeId") ? onesSelectRows({
1468
+ field,
1469
+ draft,
1470
+ projects: onesProjects,
1471
+ types: onesTypes,
1472
+ busy: optionsBusy
1473
+ }) : null;
1474
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "axds-field", children: [
1475
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: field.title }),
1476
+ onesSelect ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1477
+ "select",
1478
+ {
1479
+ className: "axds-select",
1480
+ value: draft[field.name] ?? "",
1481
+ disabled: disabled || optionsBusy !== "" || onesSelect.disabled,
1482
+ onChange: (event) => {
1483
+ onOnesSelect(account, field.name, event.target.value);
1484
+ },
1485
+ children: onesSelect.rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: row.uuid, children: row.name }, `${row.uuid}:${row.name}`))
1250
1486
  }
1251
- }
1252
- )
1253
- ] }, field.name)) }),
1487
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1488
+ import_dsh_client_ui_primitives3.Input,
1489
+ {
1490
+ className: "axds-input",
1491
+ type: field.type,
1492
+ value: draft[field.name] ?? "",
1493
+ placeholder: field.placeholder,
1494
+ autoComplete: "off",
1495
+ spellCheck: false,
1496
+ onChange: (event) => {
1497
+ setField(account, field.name, event.target.value);
1498
+ }
1499
+ }
1500
+ )
1501
+ ] }, field.name);
1502
+ }) }),
1503
+ account.id === "ones" && onesProjects.message ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "axds-error", children: [
1504
+ "项目:",
1505
+ onesProjects.message
1506
+ ] }) : null,
1507
+ account.id === "ones" && onesTypes.message ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "axds-error", children: [
1508
+ "工单类型:",
1509
+ onesTypes.message
1510
+ ] }) : null,
1511
+ editing && accountMsg[account.id] ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1512
+ "p",
1513
+ {
1514
+ className: accountMsg[account.id].tone === "ok" ? "axds-ok" : accountMsg[account.id].tone === "error" ? "axds-error" : "axds-notice",
1515
+ role: "status",
1516
+ children: accountMsg[account.id].text
1517
+ }
1518
+ ) : null,
1254
1519
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "axds-actions", children: [
1255
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "axds-muted", children: "保存前会先做一次连接测试" }),
1520
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "axds-muted", children: "保存前会先做一次连接测试,并写入个人设置" }),
1521
+ account.id === "ones" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.Button, { size: "sm", disabled: disabled || optionsBusy !== "", onClick: () => {
1522
+ onFetchOnes(account);
1523
+ }, children: optionsBusy ? "获取中" : "获取类型" }) : null,
1256
1524
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.Button, { size: "sm", disabled, onClick: () => {
1257
1525
  onTest(account);
1258
- }, children: "测试连接" }),
1526
+ }, children: busy === `test:${account.id}` ? "测试中" : "测试连接" }),
1259
1527
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.Button, { size: "sm", variant: "primary", disabled, onClick: () => {
1260
1528
  onSave(account);
1261
- }, children: "保存" })
1529
+ }, children: busy === `save:${account.id}` ? "保存中" : "保存" })
1262
1530
  ] })
1263
1531
  ] }) : null
1264
1532
  ] }, account.id);
@@ -1431,9 +1699,9 @@ function AuthinexPanel() {
1431
1699
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: "适用范围" }),
1432
1700
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { children: skillScopeText(row) })
1433
1701
  ] }),
1434
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
1702
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "axds-kv-when", children: [
1435
1703
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: "更新时间" }),
1436
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { children: row.updatedAt || "—" })
1704
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { children: formatUpdatedAt(row.updatedAt) })
1437
1705
  ] }),
1438
1706
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
1439
1707
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: "来源" }),
@@ -1535,6 +1803,48 @@ function AuthinexPanel() {
1535
1803
  ] });
1536
1804
  }
1537
1805
 
1806
+ // src/command-card.tsx
1807
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1808
+ function AxContextCommandCard(props) {
1809
+ const outcome = props.node?.outcome;
1810
+ if (!outcome) {
1811
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "axds-cmd", "data-state": "running", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd-head", children: [
1812
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-title", children: "工作上下文" }),
1813
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-muted", children: "正在设置…" })
1814
+ ] }) });
1815
+ }
1816
+ if (outcome.kind === "error") {
1817
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd", "data-state": "error", children: [
1818
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd-head", children: [
1819
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-title", children: "工作上下文" }),
1820
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-mark", "data-mark": "bad", children: "没设成" })
1821
+ ] }),
1822
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "axds-cmd-note axds-error", children: outcome.text })
1823
+ ] });
1824
+ }
1825
+ const receipt = parseReceiptText(outcome.text || "");
1826
+ if (!receipt) {
1827
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd", "data-state": "ok", children: [
1828
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd-head", children: [
1829
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-title", children: "工作上下文" }),
1830
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-mark", "data-mark": "ok", children: "已生效" })
1831
+ ] }),
1832
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "axds-cmd-note axds-muted", children: outcome.text })
1833
+ ] });
1834
+ }
1835
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd", "data-state": "ok", children: [
1836
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd-head", children: [
1837
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-title", children: "工作上下文" }),
1838
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-mark", "data-mark": "ok", children: "已生效" })
1839
+ ] }),
1840
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "axds-cmd-fields", children: receipt.fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "axds-cmd-field", children: [
1841
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: field.label }),
1842
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("b", { children: field.value })
1843
+ ] }, `${field.label}:${field.value}`)) }),
1844
+ receipt.note ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "axds-cmd-note axds-muted", children: receipt.note }) : null
1845
+ ] });
1846
+ }
1847
+
1538
1848
  // src/styles.ts
1539
1849
  var CSS = `
1540
1850
  .axds{display:flex;flex-direction:column;gap:12px;color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5}
@@ -1612,13 +1922,32 @@ var CSS = `
1612
1922
  .axds-kv>div{display:flex;gap:6px;min-width:0}
1613
1923
  .axds-kv dt{color:var(--dsw-alias-label-tertiary);flex:none}
1614
1924
  .axds-kv dd{margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1925
+ .axds-kv-when{min-width:220px}
1926
+ .axds-kv-when dd{overflow:visible;text-overflow:clip}
1615
1927
  .axds-pager{display:flex;align-items:center;gap:8px}
1616
1928
  .axds-import{display:flex;flex-direction:column;gap:8px}
1617
1929
  .axds-import-form{display:flex;flex-direction:column;gap:8px}
1618
- .axds-plain,.axds-select,.axds-textarea{width:100%;box-sizing:border-box;border:0.5px solid var(--dsw-alias-border-l1);border-radius:8px;background:transparent;color:inherit;font:inherit;font-size:13px}
1619
- .axds-plain,.axds-select{height:32px;padding:0 8px}
1930
+ .axds-plain,.axds-textarea{width:100%;box-sizing:border-box;border:0.5px solid var(--dsw-alias-border-l1);border-radius:8px;background:transparent;color:inherit;font:inherit;font-size:13px}
1931
+ .axds-plain{height:32px;padding:0 8px}
1932
+ /* 跟 Input 原子同一套:36px、layer-1 底、l4 边。原生 select 默认是系统白底,和旁边输入框对不齐。 */
1933
+ .axds-select{display:block;width:100%;box-sizing:border-box;height:36px;margin:0;padding:0 28px 0 8px;border:0.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background-color:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:34px;appearance:none;-webkit-appearance:none;background-image:linear-gradient(45deg,transparent 50%,var(--dsw-alias-label-tertiary) 50%),linear-gradient(135deg,var(--dsw-alias-label-tertiary) 50%,transparent 50%);background-position:calc(100% - 16px) center,calc(100% - 11px) center;background-size:5px 5px,5px 5px;background-repeat:no-repeat}
1934
+ .axds-select:focus{outline:none;border-color:var(--dsw-alias-state-business-primary)}
1935
+ .axds-select:disabled{opacity:.55}
1936
+ .axds-select option{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary)}
1620
1937
  .axds-textarea{min-height:96px;resize:vertical;padding:8px;line-height:1.5}
1621
1938
  .axds-file{display:none}
1939
+ /* 对话里 /ax-context 的回执卡:比宿主通用命令卡更醒目,成功显字段徽片。 */
1940
+ .axds-cmd{border:0.5px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-settings-card-fill);padding:10px 12px;display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--dsw-alias-label-primary)}
1941
+ .axds-cmd[data-state="error"]{border-color:var(--dsw-alias-state-error-primary)}
1942
+ .axds-cmd-head{display:flex;align-items:center;gap:8px}
1943
+ .axds-cmd-title{font-weight:600}
1944
+ .axds-cmd-mark{font-size:12px;padding:1px 8px;border-radius:999px}
1945
+ .axds-cmd-mark[data-mark="ok"]{color:var(--dsw-alias-state-success-primary);background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 12%,transparent)}
1946
+ .axds-cmd-mark[data-mark="bad"]{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 12%,transparent)}
1947
+ .axds-cmd-fields{display:flex;flex-wrap:wrap;gap:6px}
1948
+ .axds-cmd-field{display:inline-flex;align-items:baseline;gap:6px;border:0.5px solid var(--dsw-alias-border-l1);border-radius:999px;padding:2px 10px;font-size:12px;color:var(--dsw-alias-label-tertiary)}
1949
+ .axds-cmd-field b{font-weight:600;color:var(--dsw-alias-label-primary)}
1950
+ .axds-cmd-note{max-width:72ch}
1622
1951
  `;
1623
1952
  var mounted = 0;
1624
1953
  function installClientStyles() {
@@ -1653,6 +1982,13 @@ function install() {
1653
1982
  };
1654
1983
  contribute("plugins.bundle.config", PACKAGE_NAME);
1655
1984
  contribute("plugins.row.config", ROW_KEY);
1985
+ try {
1986
+ ctx.slots.inject("conversation.chat.commandview", () => ctx.slots.register(
1987
+ { name: "conversation.chat.commandview", key: "ax-context" },
1988
+ AxContextCommandCard
1989
+ ));
1990
+ } catch {
1991
+ }
1656
1992
  }
1657
1993
  };
1658
1994
  }
package/lib/index.js CHANGED
@@ -79,8 +79,8 @@ function attachOptionalHosts(ctx, bridge) {
79
79
  const service = commands;
80
80
  keep(ctx, "authinex-ds: command", () => service.register({
81
81
  name: "ax-context",
82
- description: "设置当前工作上下文(产品线、版本、客户)",
83
- input: { hint: "云枢 8.7 某客户,或「清空」" },
82
+ description: "设置当前工作上下文(产品线、版本、客户),句尾可以直接带要问的问题",
83
+ input: { hint: "云枢 8.7 某客户 要问的问题,或「清空」" },
84
84
  handler: (invocation) => bridge.runContextCommand(invocation.rawInput)
85
85
  }));
86
86
  }
@@ -364,6 +364,57 @@ import { tmpdir } from "node:os";
364
364
  import { join as join2 } from "node:path";
365
365
  import { arch as arch2, hostname as hostname2, platform as platform2 } from "node:os";
366
366
 
367
+ // src/account-wire.ts
368
+ var SETTING_KEYS = [
369
+ "defaultProjectUuid",
370
+ "defaultProjectName",
371
+ "defaultIssueTypeId",
372
+ "defaultIssueTypeName",
373
+ "engineCode",
374
+ "schemaCode",
375
+ "authMode",
376
+ "isTenant"
377
+ ];
378
+ function accountPatch(form) {
379
+ const settings = {};
380
+ for (const key of SETTING_KEYS) {
381
+ if (!Object.prototype.hasOwnProperty.call(form, key)) continue;
382
+ const value = form[key];
383
+ if (typeof value !== "string") continue;
384
+ settings[key] = value.trim();
385
+ }
386
+ const body = { settings };
387
+ for (const key of ["baseUrl", "username", "teamUuid"]) {
388
+ if (typeof form[key] === "string") body[key] = form[key].trim();
389
+ }
390
+ if (typeof form.token === "string" && form.token.trim()) body.token = form.token.trim();
391
+ return body;
392
+ }
393
+ function textOf(data, fallback) {
394
+ const message = typeof data.message === "string" ? data.message.trim() : "";
395
+ if (message) return message;
396
+ const detail = typeof data.detail === "string" ? data.detail.trim() : "";
397
+ if (detail) return detail;
398
+ return fallback;
399
+ }
400
+ async function postJson(fetchImpl, url, headers, body) {
401
+ const response = await fetchImpl(url, {
402
+ method: "POST",
403
+ headers,
404
+ body: JSON.stringify(body),
405
+ timeout: 3e4
406
+ });
407
+ const raw = await response.text();
408
+ let data = {};
409
+ try {
410
+ const parsed = raw ? JSON.parse(raw) : {};
411
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) data = parsed;
412
+ } catch {
413
+ data = {};
414
+ }
415
+ return { ok: response.ok, status: response.status, data };
416
+ }
417
+
367
418
  // src/endpoint.ts
368
419
  function checkEndpoint(raw) {
369
420
  const text2 = String(raw || "").trim();
@@ -826,6 +877,13 @@ function formatWork(work) {
826
877
  if (!parts.length) return "";
827
878
  return `工作上下文:${parts.join(",")}`;
828
879
  }
880
+ function formatWorkFields(work) {
881
+ const parts = [];
882
+ if (work.productKind) parts.push(`产品线 ${labelOf(work.productKind)}`);
883
+ if (work.version) parts.push(`版本 ${work.version}`);
884
+ if (work.customer) parts.push(`客户 ${work.customer}`);
885
+ return parts.join(" / ");
886
+ }
829
887
  var SYSTEMS = [
830
888
  { id: "ones", label: "ONES" },
831
889
  { id: "h3yun", label: "氚云" },
@@ -890,28 +948,45 @@ function contextPatch(input) {
890
948
  }
891
949
  return patch;
892
950
  }
893
- var USAGE = "没看懂。用法:/ax-context 云枢 8.7 某客户,或 /ax-context 清空";
951
+ var USAGE = "没看懂。用法:/ax-context 云枢 8.7 某客户 要问的问题,或 /ax-context 清空";
952
+ var QUESTION_MARKS = ["?", "?", "怎么", "怎样", "如何", "为啥", "为什么", "为何", "哪些", "哪个", "排查", "报错"];
953
+ function questionStartOf(tokens) {
954
+ return tokens.findIndex((token) => QUESTION_MARKS.some((mark) => token.includes(mark)));
955
+ }
894
956
  function interpretCommand(raw, current) {
895
957
  const text2 = raw.trim();
896
958
  if (!text2) {
897
- const line = formatWork(current);
959
+ const line2 = formatWorkFields(current);
898
960
  return {
899
961
  kind: "success",
900
- text: line ? `当前${line}` : "还没有工作上下文。用法:/ax-context 云枢 8.7 某客户,或 /ax-context 清空",
901
- work: current
962
+ text: line2 ? `当前工作上下文:${line2}` : `还没有工作上下文。${USAGE}`,
963
+ work: current,
964
+ question: ""
902
965
  };
903
966
  }
904
- if (text2 === "清空") return { kind: "success", text: "已清空工作上下文", work: EMPTY_WORK };
967
+ if (text2 === "清空") return { kind: "success", text: "已清空工作上下文", work: EMPTY_WORK, question: "" };
905
968
  const tokens = text2.split(/\s+/).filter(Boolean);
906
969
  const kindToken = tokens[0] || "";
907
970
  if (!Object.prototype.hasOwnProperty.call(ALIASES, kindToken) || !ALIASES[kindToken]) {
908
971
  return { kind: "error", text: USAGE };
909
972
  }
910
973
  const version = tokens[1] || "";
911
- const customer = tokens.slice(2).join(" ");
974
+ const rest = tokens.slice(2);
975
+ const questionAt = questionStartOf(rest);
976
+ const customerTokens = questionAt < 0 ? rest : rest.slice(0, questionAt);
977
+ const questionTokens = questionAt < 0 ? [] : rest.slice(questionAt);
978
+ const customer = customerTokens.join(" ");
979
+ const question = questionTokens.join(" ");
912
980
  const parsed = normalizeWork({ productKind: kindToken, version, customer });
913
981
  if (!parsed.ok) return { kind: "error", text: parsed.message };
914
- return { kind: "success", text: `已设置${formatWork(parsed.value)}`, work: parsed.value };
982
+ const line = formatWorkFields(parsed.value);
983
+ let note = "";
984
+ if (question) {
985
+ note = `问题「${question}」这次没有发出去:/ax-context 只设置上下文,把问题直接发出来,就会带着上面的上下文回答。`;
986
+ }
987
+ const text22 = note ? `已设置:${line}
988
+ ${note}` : `已设置:${line}`;
989
+ return { kind: "success", text: text22, work: parsed.value, question };
915
990
  }
916
991
 
917
992
  // src/tool-dispatch.ts
@@ -924,7 +999,7 @@ var CITABLE = /* @__PURE__ */ new Set([
924
999
  "locate_online",
925
1000
  "task_status"
926
1001
  ]);
927
- function textOf(data) {
1002
+ function textOf2(data) {
928
1003
  if (Array.isArray(data?.content)) {
929
1004
  return data.content.map((item) => item?.text || "").join("\n");
930
1005
  }
@@ -1071,7 +1146,7 @@ ${accepted.tools.map((tool) => tool.name).join("\n")}`;
1071
1146
  });
1072
1147
  const status = data.structuredContent?.status;
1073
1148
  const failed = Boolean(data.isError);
1074
- const text2 = failed || CITABLE.has(name2) ? textOf(data) : omitSourceSections(textOf(data));
1149
+ const text2 = failed || CITABLE.has(name2) ? textOf2(data) : omitSourceSections(textOf2(data));
1075
1150
  return {
1076
1151
  text: text2,
1077
1152
  isError: failed,
@@ -1316,12 +1391,12 @@ ${accepted.tools.map((tool) => tool.name).join("\n")}`;
1316
1391
 
1317
1392
  // src/view.ts
1318
1393
  var PACKAGE_NAME = "@authinex/dsh-plugin";
1319
- var ROW_ID = "authinex-ds-plugin";
1394
+ var ROW_ID = "authinex-host";
1320
1395
  var ROW_KEY = `${PACKAGE_NAME}#${ROW_ID}`;
1321
1396
  var SKILL_PAGE_SIZE = 8;
1322
1397
 
1323
1398
  // src/controller.ts
1324
- var VERSION = true ? "0.3.7" : "0.1.0";
1399
+ var VERSION = true ? "0.3.8" : "0.1.0";
1325
1400
  var CREDENTIAL_REF = "AUTHINEX_DS_DEVICE";
1326
1401
  var CONTEXT_CREDENTIAL_REF = "AUTHINEX_DS_CONTEXT";
1327
1402
  var NPM_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
@@ -1895,46 +1970,42 @@ function createController(options) {
1895
1970
  await credentials.unset(CREDENTIAL_REF);
1896
1971
  return { ok: true, state: snapshot() };
1897
1972
  }
1898
- function accountBody(form) {
1899
- const patch = { ...form };
1900
- if (!patch.token) delete patch.token;
1901
- const settings = {};
1902
- for (const key of ["defaultProjectUuid", "defaultIssueTypeId", "engineCode", "schemaCode", "authMode", "isTenant"]) {
1903
- if (patch[key] !== void 0) settings[key] = patch[key];
1904
- }
1973
+ function sessionHeaders() {
1905
1974
  return {
1906
- baseUrl: patch.baseUrl,
1907
- username: patch.username,
1908
- teamUuid: patch.teamUuid,
1909
- projectId: patch.projectId,
1910
- token: patch.token,
1911
- enabled: patch.enabled !== false,
1912
- settings
1975
+ authorization: `Bearer ${memory.token}`,
1976
+ "content-type": "application/json",
1977
+ "x-authinex-ds-version": version
1913
1978
  };
1914
1979
  }
1980
+ async function postPersonal(path, body, replayed = false) {
1981
+ const base = normalizeEndpoint(memory.endpoint);
1982
+ if (!base || !memory.token) return { ok: false, status: 0, data: { message: PHRASES.unreachable } };
1983
+ const res = await postJson(fetchImpl, `${base}${path}`, sessionHeaders(), body);
1984
+ if (res.status === 401 && !replayed && await hasDeviceSecret()) {
1985
+ const back = await signInSaved();
1986
+ if (back) return postPersonal(path, body, true);
1987
+ }
1988
+ return { ok: res.ok, status: res.status, data: res.data };
1989
+ }
1915
1990
  async function testAccount(provider, form) {
1916
1991
  if (memory.busy) return { ok: false, message: BUSY };
1917
1992
  try {
1918
- const tested = await request(`/api/auth/me/accounts/test/${provider}`, {
1919
- body: accountBody(form),
1920
- session: true,
1921
- timeout: 3e4
1922
- });
1923
- return { ok: Boolean(tested.ok), message: String(tested.message || "") };
1993
+ const res = await postPersonal(
1994
+ `/api/auth/me/accounts/test/${encodeURIComponent(provider)}`,
1995
+ accountPatch(form)
1996
+ );
1997
+ const ok = res.ok && Boolean(res.data.ok);
1998
+ return { ok, message: textOf(res.data, ok ? "连接正常" : "连接失败") };
1924
1999
  } catch {
1925
- return { ok: false, message: MISS };
2000
+ return { ok: false, message: "没有连上,稍后再试" };
1926
2001
  }
1927
2002
  }
1928
2003
  async function saveAccount(provider, form) {
1929
2004
  if (memory.busy) return { ok: false, message: BUSY };
1930
- const body = accountBody(form);
2005
+ const body = accountPatch(form);
2006
+ const tested = await testAccount(provider, form);
2007
+ if (!tested.ok) return { ok: false, message: tested.message || "连接测试没通过,没有保存" };
1931
2008
  try {
1932
- const tested = await request(`/api/auth/me/accounts/test/${provider}`, {
1933
- body,
1934
- session: true,
1935
- timeout: 3e4
1936
- });
1937
- if (!tested.ok) return { ok: false, message: tested.message || "连接测试没通过,没有保存" };
1938
2009
  await request("/api/auth/me/accounts", {
1939
2010
  method: "PUT",
1940
2011
  body: { [provider]: body },
@@ -1943,7 +2014,7 @@ function createController(options) {
1943
2014
  await loadAccounts();
1944
2015
  return { ok: true, message: "已保存", state: snapshot() };
1945
2016
  } catch {
1946
- return { ok: false, message: MISS };
2017
+ return { ok: false, message: "连接通过了,但没有写进个人设置" };
1947
2018
  }
1948
2019
  }
1949
2020
  async function setAccountEnabled(provider, enabled) {
@@ -1960,6 +2031,65 @@ function createController(options) {
1960
2031
  return { ok: false, message: MISS, state: snapshot() };
1961
2032
  }
1962
2033
  }
2034
+ function optionRows(rows) {
2035
+ if (!Array.isArray(rows)) return [];
2036
+ return rows.map((row) => ({ uuid: String(row.uuid || ""), name: String(row.name || row.uuid || "") })).filter((row) => row.uuid);
2037
+ }
2038
+ async function legacyOnesOptions(issueTypes, project) {
2039
+ const base = normalizeEndpoint(memory.endpoint);
2040
+ if (!base || !memory.token) return { ok: false, message: PHRASES.unreachable };
2041
+ const path = issueTypes ? `/api/auth/me/accounts/ones/issue-types?projectUuid=${encodeURIComponent(project.trim())}` : "/api/auth/me/accounts/ones/projects";
2042
+ try {
2043
+ const response = await fetchImpl(`${base}${path}`, {
2044
+ method: issueTypes ? "GET" : "POST",
2045
+ headers: {
2046
+ authorization: `Bearer ${memory.token}`,
2047
+ "x-authinex-ds-version": version
2048
+ },
2049
+ timeout: 3e4
2050
+ });
2051
+ const raw = await response.text();
2052
+ let data = {};
2053
+ try {
2054
+ const parsed = raw ? JSON.parse(raw) : {};
2055
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) data = parsed;
2056
+ } catch {
2057
+ data = {};
2058
+ }
2059
+ if (!response.ok) return { ok: false, message: textOf(data, "拉取失败") };
2060
+ if (issueTypes) {
2061
+ const rows2 = optionRows(data.issueTypes ?? data.issue_types);
2062
+ return { ok: true, message: rows2.length ? "" : "这个项目下没有工单类型", issueTypes: rows2 };
2063
+ }
2064
+ const rows = optionRows(data.projects);
2065
+ return { ok: true, message: rows.length ? "" : "这个账号下没有可选项目", projects: rows };
2066
+ } catch {
2067
+ return { ok: false, message: "没有拉到,稍后再试" };
2068
+ }
2069
+ }
2070
+ async function accountOptions(provider, kind, project, form = {}) {
2071
+ if (provider !== "ones") return { ok: false, message: "这一家没有可拉取的下拉数据" };
2072
+ const base = normalizeEndpoint(memory.endpoint);
2073
+ if (!base || !memory.token) return { ok: false, message: PHRASES.unreachable };
2074
+ const issueTypes = kind === "issueTypes";
2075
+ try {
2076
+ const res = await postPersonal("/api/auth/me/accounts/ones/form-options", {
2077
+ ...accountPatch(form),
2078
+ kind: issueTypes ? "issueTypes" : "projects",
2079
+ projectUuid: project.trim()
2080
+ });
2081
+ if (res.status === 404) return legacyOnesOptions(issueTypes, project);
2082
+ if (!res.ok) return { ok: false, message: textOf(res.data, "拉取失败") };
2083
+ if (issueTypes) {
2084
+ const rows2 = optionRows(res.data.issueTypes ?? res.data.issue_types);
2085
+ return { ok: true, message: rows2.length ? "" : textOf(res.data, "这个项目下没有工单类型"), issueTypes: rows2 };
2086
+ }
2087
+ const rows = optionRows(res.data.projects);
2088
+ return { ok: true, message: rows.length ? "" : textOf(res.data, "这个账号下没有可选项目"), projects: rows };
2089
+ } catch {
2090
+ return { ok: false, message: "没有拉到,稍后再试" };
2091
+ }
2092
+ }
1963
2093
  async function fetchManifest() {
1964
2094
  const base = normalizeEndpoint(memory.endpoint);
1965
2095
  if (!base || !memory.token) return null;
@@ -2112,16 +2242,25 @@ function createController(options) {
2112
2242
  }
2113
2243
  if (path === "/authinex-ds/accounts" && method === "PATCH") {
2114
2244
  const result = await saveAccount(String(body?.provider || ""), body?.form || {});
2115
- return { status: result.ok ? 200 : 400, body: result };
2245
+ return { status: 200, body: result };
2116
2246
  }
2117
2247
  if (path === "/authinex-ds/accounts/test" && method === "POST") {
2118
2248
  const result = await testAccount(String(body?.provider || ""), body?.form || {});
2119
- return { status: result.ok ? 200 : 400, body: result };
2249
+ return { status: 200, body: result };
2120
2250
  }
2121
2251
  if (path === "/authinex-ds/accounts/enabled" && method === "POST") {
2122
2252
  const result = await setAccountEnabled(String(body?.provider || ""), Boolean(body?.enabled));
2123
2253
  return { status: result.ok ? 200 : 400, body: result };
2124
2254
  }
2255
+ if (path === "/authinex-ds/accounts/options" && method === "POST") {
2256
+ const result = await accountOptions(
2257
+ String(body?.provider || ""),
2258
+ String(body?.kind || ""),
2259
+ String(body?.project || ""),
2260
+ body?.form || {}
2261
+ );
2262
+ return { status: 200, body: result };
2263
+ }
2125
2264
  if (method === "POST" && path === "/authinex-ds/update/check") {
2126
2265
  const result = await checkUpdate();
2127
2266
  return { status: 200, body: { ...result.state, updateMessage: result.message || "" } };
@@ -2191,6 +2330,7 @@ function createController(options) {
2191
2330
  saveAccount,
2192
2331
  setAccountEnabled,
2193
2332
  testAccount,
2333
+ accountOptions,
2194
2334
  checkUpdate,
2195
2335
  listSkills,
2196
2336
  importSkill,
@@ -2211,6 +2351,7 @@ var PATHS = [
2211
2351
  "/authinex-ds/accounts",
2212
2352
  "/authinex-ds/accounts/test",
2213
2353
  "/authinex-ds/accounts/enabled",
2354
+ "/authinex-ds/accounts/options",
2214
2355
  "/authinex-ds/update/check",
2215
2356
  "/authinex-ds/update/apply",
2216
2357
  "/authinex-ds/update/download",
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "AuthineX Assistant",
4
+ "description": "AuthineX inside DeepSeek: search the knowledge base, look up tickets, search source code, locate root causes read-only, file tickets with your own account, and /ax-context in the chat"
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "AuthineX 助手",
4
+ "description": "DeepSeek 里的 AuthineX 助手:问知识库、查工单、检索源码、只读定位、建单,并提供对话里的 /ax-context"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authinex/dsh-plugin",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "DeepSeek 里的 AuthineX 插件:问知识库、查工单、检索源码、只读定位,并用本人账号建单",
5
5
  "type": "module",
6
6
  "icon": "./icon.svg",
@@ -10,10 +10,12 @@
10
10
  "./client": "./lib/client.js",
11
11
  "./package.json": "./package.json",
12
12
  "./cordis.patch.yml": "./cordis.patch.yml",
13
- "./icon": "./icon.svg"
13
+ "./icon": "./icon.svg",
14
+ "./locale/*.json": "./locale/*.json"
14
15
  },
15
16
  "files": [
16
17
  "icon.svg",
18
+ "locale/*.json",
17
19
  "lib/index.js",
18
20
  "lib/client.js",
19
21
  "cordis.patch.yml"