@authinex/dsh-plugin 0.3.7 → 0.3.9

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 CHANGED
@@ -45,6 +45,7 @@
45
45
  **凭据不进页面**
46
46
 
47
47
  - 插件本身不带任何默认地址、公司信息或密钥,装完由你填访问地址和密钥完成绑定。
48
+ - 升级插件不会让已经绑定的密钥失效。本机私钥还在就直接连上;页面如果又问密钥,把原来那把再贴一次,同一台机器会接回原来的绑定。
48
49
  - ONES / 氚云 / PMO / GitLab 的账号只写回 AgentHub,配置页上不留明文。
49
50
  - 权限由运营台角色和签发的密钥共同决定,角色不够的工具不会出现在列表里。
50
51
 
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,65 @@ 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
+ var NAME_KEY = {
47
+ defaultProjectUuid: "defaultProjectName",
48
+ defaultIssueTypeId: "defaultIssueTypeName",
49
+ planIssueTypeId: "planIssueTypeName"
50
+ };
51
+ function withCurrent(rows, value, items, label = "") {
52
+ if (value && !items.some((item) => item.uuid === value)) {
53
+ const named = label.trim();
54
+ rows.push({ uuid: value, name: named && !named.startsWith(CURRENT_PREFIX) ? named : `${CURRENT_PREFIX}${value}` });
55
+ }
56
+ return rows;
57
+ }
58
+ function optionLabel(items, uuid) {
59
+ if (!uuid) return "";
60
+ const row = items.find((item) => item.uuid === uuid);
61
+ if (!row || row.name.startsWith(CURRENT_PREFIX)) return "";
62
+ return row.name;
63
+ }
64
+ function pickedName(items, uuid, previousId, previousName) {
65
+ return optionLabel(items, uuid) || (uuid && uuid === previousId ? previousName : "");
66
+ }
67
+ function onesSelectRows(input) {
68
+ const { field, draft, projects, types, busy } = input;
69
+ const value = draft[field.name] ?? "";
70
+ const project = draft.defaultProjectUuid ?? "";
71
+ const label = draft[NAME_KEY[field.name] ?? ""] ?? "";
72
+ if (field.name === "defaultProjectUuid") {
73
+ const rows2 = [{
74
+ uuid: "",
75
+ name: busy === "projects" ? "正在拉取项目…" : "— 请选择项目 —"
76
+ }];
77
+ for (const item of projects.items) rows2.push(item);
78
+ return { disabled: busy === "projects", rows: withCurrent(rows2, value, projects.items, label) };
79
+ }
80
+ if (!project) return { disabled: true, rows: [{ uuid: "", name: "先选择默认项目" }] };
81
+ if (busy === "types" || types.forProject !== project) {
82
+ const rows2 = [{ uuid: "", name: "正在拉取工单类型…" }];
83
+ return { disabled: true, rows: withCurrent(rows2, value, [], label) };
84
+ }
85
+ if (types.message) {
86
+ const rows2 = [{ uuid: "", name: types.message }];
87
+ return { disabled: false, rows: withCurrent(rows2, value, types.items, label) };
88
+ }
89
+ const rows = [{ uuid: "", name: "— 请选择工单类型 —" }];
90
+ for (const item of types.items) rows.push(item);
91
+ return { disabled: false, rows: withCurrent(rows, value, types.items, label) };
92
+ }
93
+
35
94
  // src/endpoint.ts
36
95
  function checkEndpoint(raw) {
37
96
  const text = String(raw || "").trim();
@@ -149,10 +208,12 @@ var TOOLS = {
149
208
  title: "查询工单",
150
209
  timeoutMs: 3e4,
151
210
  description: `按单号查 ONES、氚云或 PMO。没有可用账号的那一家不要编造单号。
211
+ 13 位氚云流水号查氚云原单;要查 ONES 上同步过去的缺陷,system 填 ones,或把流水号放进 h3yunSeqNo。不要把它当成 ONES 编号。
152
212
  已知单号才用它;按条件筛用 search_tickets。${DATA_NOT_INSTRUCTION}`,
153
213
  parameters: {
154
- number: { type: "string", description: "工单号" },
214
+ number: { type: "string", description: "工单号。13 位氚云流水号配 system=ones 时查 ONES 同步缺陷。" },
155
215
  system: { type: "string", description: "ones、h3yun 或 pmo" },
216
+ h3yunSeqNo: { type: "string", description: "氚云工单流水号。只查 ONES 上这个字段,不查氚云原单。" },
156
217
  keyword: { type: "string", description: "没有单号时按标题筛" }
157
218
  }
158
219
  },
@@ -223,14 +284,22 @@ var TOOLS = {
223
284
  },
224
285
  create_ticket: {
225
286
  title: "创建工单",
226
- timeoutMs: 6e4,
227
- description: `起草 ONES、氚云或 PMO 工单。必须先让用户在确认卡上点创建,取消后不要用同一草稿再提。${DATA_NOT_INSTRUCTION}`,
287
+ // 建单本身要跑一串 ONES 往返(登录、字段字典、add3);带附件还要再申请上传、
288
+ // 传完回写 <figure>,60 秒装不下,超时会让单子看起来"没建成",人就会重提。
289
+ timeoutMs: 18e4,
290
+ description: `起草 ONES、氚云或 PMO 工单。提交用的是已经保存的个人账号,不要向用户要邮箱、密码或 Token。用户说了版本就把原话放进 version,ONES 写入「发现版本-云枢」,没说就留空。用户附了图片或文件时,把对话里给出的只读路径放进 attachments,一行一个。必须先让用户在确认卡上点创建,取消后不要用同一草稿再提。${DATA_NOT_INSTRUCTION}`,
228
291
  parameters: {
229
292
  system: { type: "string", required: true, description: "ones、h3yun 或 pmo" },
230
293
  title: { type: "string", required: true, description: "标题" },
231
294
  description: { type: "string", required: true, description: "描述" },
232
- version: { type: "string", description: "产品版本" },
233
- customer: { type: "string", description: "客户" }
295
+ version: { type: "string", description: "ONES「发现版本-云枢」。用户说了才填,按原话,如 AI-Platform-v2.1。没说留空。" },
296
+ attachments: { type: "string", description: "对话里图片或文件的只读路径,一行一个。没有就留空,不要编路径。" },
297
+ customer: { type: "string", description: "客户。PMO 要客户全称。" },
298
+ ticketType: { type: "string", description: "氚云工单类型:需求、缺陷或咨询。没说留空。" },
299
+ serviceType: { type: "string", description: "PMO 服务单类型。没说留空,系统按问题单。" },
300
+ product: { type: "string", description: "PMO 产品类型,如云枢。没说留空。" },
301
+ issueType: { type: "string", description: "PMO 问题类型:产品问题、技术问题或其他问题。没说留空。" },
302
+ priority: { type: "string", description: "优先级。PMO 用高、中、底。没说留空。" }
234
303
  }
235
304
  }
236
305
  };
@@ -246,10 +315,27 @@ function labelOf(kind) {
246
315
  const found = PRODUCT_KINDS.find((item) => item.id === kind);
247
316
  return found ? found.label : kind;
248
317
  }
318
+ function parseReceiptText(text) {
319
+ const lines = String(text || "").split("\n").map((line) => line.trim()).filter(Boolean);
320
+ const first = lines[0] || "";
321
+ const matched = /^(?:已设置|当前工作上下文):(.+)$/.exec(first);
322
+ if (!matched) return null;
323
+ const fields = [];
324
+ for (const part of matched[1].split(" / ")) {
325
+ const at = part.indexOf(" ");
326
+ if (at <= 0) return null;
327
+ const label = part.slice(0, at);
328
+ const value = part.slice(at + 1);
329
+ if (!label || !value) return null;
330
+ fields.push({ label, value });
331
+ }
332
+ if (!fields.length) return null;
333
+ return { fields, note: lines.slice(1).join("\n") };
334
+ }
249
335
 
250
336
  // src/view.ts
251
337
  var PACKAGE_NAME = "@authinex/dsh-plugin";
252
- var ROW_ID = "authinex-ds-plugin";
338
+ var ROW_ID = "authinex-host";
253
339
  var ROW_KEY = `${PACKAGE_NAME}#${ROW_ID}`;
254
340
  var SKILL_HOT_MIN = 5;
255
341
  function skillUseCount(row) {
@@ -265,6 +351,25 @@ function skillUseText(row) {
265
351
  const n = skillUseCount(row);
266
352
  return n ? `${n} 次` : "未使用";
267
353
  }
354
+ var HAS_TZ = /(?:Z|[+-]\d{2}:?\d{2})$/i;
355
+ function formatUpdatedAt(value) {
356
+ const text = (value || "").trim();
357
+ if (!text) return "—";
358
+ const date = new Date(HAS_TZ.test(text) ? text : `${text}Z`);
359
+ if (Number.isNaN(date.getTime())) return "—";
360
+ const parts = new Intl.DateTimeFormat("en-CA", {
361
+ timeZone: "Asia/Shanghai",
362
+ year: "numeric",
363
+ month: "2-digit",
364
+ day: "2-digit",
365
+ hour: "2-digit",
366
+ minute: "2-digit",
367
+ hourCycle: "h23"
368
+ }).formatToParts(date);
369
+ const pick = (type) => parts.find((part) => part.type === type)?.value || "";
370
+ const hour = pick("hour") === "24" ? "00" : pick("hour");
371
+ return `${pick("year")}-${pick("month")}-${pick("day")} ${hour}:${pick("minute")}`;
372
+ }
268
373
  var ACCOUNT_FIELDS = {
269
374
  gitlab: [
270
375
  { name: "username", title: "账号" },
@@ -277,7 +382,8 @@ var ACCOUNT_FIELDS = {
277
382
  { name: "baseUrl", title: "地址(可空)" },
278
383
  { name: "token", title: "密码或 API Token", type: "password" },
279
384
  { name: "defaultProjectUuid", title: "默认项目" },
280
- { name: "defaultIssueTypeId", title: "缺陷工单类型" }
385
+ { name: "defaultIssueTypeId", title: "缺陷工单类型" },
386
+ { name: "planIssueTypeId", title: "规划项工单类型" }
281
387
  ],
282
388
  h3yun: [
283
389
  { name: "username", title: "手机号" },
@@ -371,7 +477,12 @@ function viewModel(state) {
371
477
  username: row.state === "unconfigured" ? "" : maskAccount(String(row.username || "")),
372
478
  enabled: row.enabled !== false,
373
479
  hasToken: Boolean(row.hasToken),
374
- fields: accountFields(id, row)
480
+ fields: accountFields(id, row),
481
+ extras: id === "ones" ? {
482
+ defaultProjectName: fieldValue(row, "defaultProjectName"),
483
+ defaultIssueTypeName: fieldValue(row, "defaultIssueTypeName"),
484
+ planIssueTypeName: fieldValue(row, "planIssueTypeName")
485
+ } : {}
375
486
  };
376
487
  }) : [];
377
488
  const toolNames = showIdentity && !state?.upgradeRequired ? state?.tools || [] : [];
@@ -659,7 +770,7 @@ function WorkContextCard(props) {
659
770
  ] })
660
771
  ] }),
661
772
  /* @__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" }),
773
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "axds-muted", children: "也可以在对话里用 /ax-context 云枢 8.7 某客户 要问的问题" }),
663
774
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_dsh_client_ui_primitives2.Button, { size: "sm", variant: "ghost", disabled: props.disabled, onClick: props.onClear, children: "清空" }),
664
775
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
665
776
  import_dsh_client_ui_primitives2.Button,
@@ -704,7 +815,7 @@ function tagTone(state) {
704
815
  return "outline";
705
816
  }
706
817
  function draftOf(account) {
707
- const draft = {};
818
+ const draft = { ...account.extras };
708
819
  for (const field of account.fields) draft[field.name] = field.value;
709
820
  return draft;
710
821
  }
@@ -751,6 +862,12 @@ function AuthinexPanel() {
751
862
  const [skillBusy, setSkillBusy] = (0, import_react3.useState)("");
752
863
  const [skillNotice, setSkillNotice] = (0, import_react3.useState)("");
753
864
  const [skillFeedback, setSkillFeedback] = (0, import_react3.useState)("");
865
+ const [accountMsg, setAccountMsg] = (0, import_react3.useState)({});
866
+ const [onesProjects, setOnesProjects] = (0, import_react3.useState)({ items: [], message: "", loaded: false });
867
+ const [onesTypes, setOnesTypes] = (0, import_react3.useState)({ items: [], message: "", forProject: "" });
868
+ const [optionsBusy, setOptionsBusy] = (0, import_react3.useState)("");
869
+ const projectTicket = (0, import_react3.useRef)(0);
870
+ const typeTicket = (0, import_react3.useRef)(0);
754
871
  const model = (0, import_react3.useMemo)(() => viewModel(state || void 0), [state]);
755
872
  const applyState = (0, import_react3.useCallback)((next) => {
756
873
  setState(next);
@@ -788,6 +905,62 @@ function AuthinexPanel() {
788
905
  setBusy("");
789
906
  }
790
907
  }, []);
908
+ const loadOnesProjects = (0, import_react3.useCallback)(async (form) => {
909
+ const ticket = ++projectTicket.current;
910
+ setOnesProjects((prev) => ({ ...prev, message: "" }));
911
+ setOptionsBusy("projects");
912
+ try {
913
+ const body = await api("/authinex-ds/accounts/options", {
914
+ method: "POST",
915
+ body: { provider: "ones", kind: "projects", form }
916
+ });
917
+ if (ticket !== projectTicket.current) return;
918
+ const ok = body.ok === true;
919
+ const items = Array.isArray(body.projects) ? body.projects : [];
920
+ const reason = textOf(body, "");
921
+ setOnesProjects({
922
+ items,
923
+ message: ok ? items.length ? "" : reason || "这个账号下没有可选项目" : reason || "没有拉到项目",
924
+ loaded: true
925
+ });
926
+ } catch {
927
+ if (ticket !== projectTicket.current) return;
928
+ setOnesProjects({ items: [], message: "没有拉到项目", loaded: true });
929
+ } finally {
930
+ if (ticket === projectTicket.current) setOptionsBusy((prev) => prev === "projects" ? "" : prev);
931
+ }
932
+ }, []);
933
+ const loadOnesTypes = (0, import_react3.useCallback)(async (project, form) => {
934
+ if (!project) {
935
+ typeTicket.current += 1;
936
+ setOnesTypes({ items: [], message: "", forProject: "" });
937
+ setOptionsBusy((prev) => prev === "types" ? "" : prev);
938
+ return;
939
+ }
940
+ const ticket = ++typeTicket.current;
941
+ setOnesTypes({ items: [], message: "", forProject: "" });
942
+ setOptionsBusy("types");
943
+ try {
944
+ const body = await api("/authinex-ds/accounts/options", {
945
+ method: "POST",
946
+ body: { provider: "ones", kind: "issueTypes", project, form }
947
+ });
948
+ if (ticket !== typeTicket.current) return;
949
+ const ok = body.ok === true;
950
+ const items = Array.isArray(body.issueTypes) ? body.issueTypes : [];
951
+ const reason = textOf(body, "");
952
+ setOnesTypes({
953
+ items,
954
+ message: ok ? items.length ? "" : reason || "这个项目下没有工单类型" : reason || "没有拉到工单类型",
955
+ forProject: project
956
+ });
957
+ } catch {
958
+ if (ticket !== typeTicket.current) return;
959
+ setOnesTypes({ items: [], message: "没有拉到工单类型", forProject: project });
960
+ } finally {
961
+ if (ticket === typeTicket.current) setOptionsBusy((prev) => prev === "types" ? "" : prev);
962
+ }
963
+ }, []);
791
964
  const onBind = (event) => {
792
965
  event.preventDefault();
793
966
  const url = endpoint.trim();
@@ -836,6 +1009,9 @@ function AuthinexPanel() {
836
1009
  setDrafts({});
837
1010
  setEndpoint("");
838
1011
  setSkillView(SKILL_EMPTY);
1012
+ setAccountMsg({});
1013
+ setOnesProjects({ items: [], message: "", loaded: false });
1014
+ setOnesTypes({ items: [], message: "", forProject: "" });
839
1015
  setNotice("已解除绑定,地址和密钥都清掉了");
840
1016
  });
841
1017
  };
@@ -846,6 +1022,14 @@ function AuthinexPanel() {
846
1022
  }
847
1023
  setOpen(account.id);
848
1024
  setDrafts((prev) => prev[account.id] ? prev : { ...prev, [account.id]: draftOf(account) });
1025
+ if (account.id === "ones") {
1026
+ setOnesTypes({ items: [], message: "", forProject: "" });
1027
+ const form = drafts.ones || draftOf(account);
1028
+ void (async () => {
1029
+ await loadOnesProjects(form);
1030
+ if (form.defaultProjectUuid) await loadOnesTypes(form.defaultProjectUuid, form);
1031
+ })();
1032
+ }
849
1033
  };
850
1034
  const setField = (account, name, value) => {
851
1035
  setDrafts((prev) => ({
@@ -853,6 +1037,38 @@ function AuthinexPanel() {
853
1037
  [account.id]: { ...prev[account.id] || draftOf(account), [name]: value }
854
1038
  }));
855
1039
  };
1040
+ const onOnesSelect = (account, name, value) => {
1041
+ const base = { ...drafts[account.id] || draftOf(account) };
1042
+ if (name === "defaultProjectUuid") {
1043
+ const previousId = base.defaultProjectUuid || "";
1044
+ const previousName = base.defaultProjectName || "";
1045
+ base.defaultProjectUuid = value;
1046
+ base.defaultProjectName = pickedName(onesProjects.items, value, previousId, previousName);
1047
+ if (value !== previousId) {
1048
+ base.defaultIssueTypeId = "";
1049
+ base.defaultIssueTypeName = "";
1050
+ base.planIssueTypeId = "";
1051
+ base.planIssueTypeName = "";
1052
+ }
1053
+ } else if (name === "defaultIssueTypeId" || name === "planIssueTypeId") {
1054
+ const nameKey = name === "planIssueTypeId" ? "planIssueTypeName" : "defaultIssueTypeName";
1055
+ const previousId = base[name] || "";
1056
+ const previousName = base[nameKey] || "";
1057
+ base[name] = value;
1058
+ base[nameKey] = pickedName(onesTypes.items, value, previousId, previousName);
1059
+ } else {
1060
+ base[name] = value;
1061
+ }
1062
+ setDrafts((prev) => ({ ...prev, [account.id]: base }));
1063
+ if (name === "defaultProjectUuid") void loadOnesTypes(value, base);
1064
+ };
1065
+ const onFetchOnes = (account) => {
1066
+ const form = drafts[account.id] || draftOf(account);
1067
+ void (async () => {
1068
+ await loadOnesProjects(form);
1069
+ if ((form.defaultProjectUuid || "").trim()) await loadOnesTypes(form.defaultProjectUuid, form);
1070
+ })();
1071
+ };
856
1072
  const onToggleEnabled = (account, next) => {
857
1073
  void run(`enabled:${account.id}`, async () => {
858
1074
  const body = await api("/authinex-ds/accounts/enabled", {
@@ -864,23 +1080,57 @@ function AuthinexPanel() {
864
1080
  });
865
1081
  };
866
1082
  const onTest = (account) => {
1083
+ const form = drafts[account.id] || draftOf(account);
1084
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text: `${account.label}:正在测试连接…`, tone: "pending" } }));
867
1085
  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 ? "连接正常" : "连接失败"))}`);
1086
+ let body;
1087
+ try {
1088
+ body = await api("/authinex-ds/accounts/test", {
1089
+ method: "POST",
1090
+ body: { provider: account.id, form }
1091
+ });
1092
+ } catch {
1093
+ const text2 = `${account.label}:没有连上,稍后再试`;
1094
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text: text2, tone: "error" } }));
1095
+ setNotice(text2);
1096
+ setFeedback("error");
1097
+ return;
1098
+ }
1099
+ const ok = Boolean(body.ok);
1100
+ const text = `${account.label}:${String(body.message || (ok ? "连接正常" : "连接失败"))}`;
1101
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text, tone: ok ? "ok" : "error" } }));
1102
+ setNotice(text);
1103
+ setFeedback(ok ? "ok" : "error");
1104
+ if (ok && account.id === "ones") {
1105
+ await loadOnesProjects(form);
1106
+ if ((form.defaultProjectUuid || "").trim()) await loadOnesTypes(form.defaultProjectUuid, form);
1107
+ }
873
1108
  });
874
1109
  };
875
1110
  const onSave = (account) => {
1111
+ const form = drafts[account.id] || draftOf(account);
1112
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text: `${account.label}:正在保存…`, tone: "pending" } }));
876
1113
  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
- });
1114
+ let body;
1115
+ try {
1116
+ body = await api("/authinex-ds/accounts", {
1117
+ method: "PATCH",
1118
+ body: { provider: account.id, form }
1119
+ });
1120
+ } catch {
1121
+ const text2 = `${account.label}:没有保存`;
1122
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text: text2, tone: "error" } }));
1123
+ setNotice(text2);
1124
+ setFeedback("error");
1125
+ return;
1126
+ }
881
1127
  if (body.state) applyState(body.state);
882
- setNotice(`${account.label}:${String(body.message || (body.ok ? "已保存" : "没有保存"))}`);
883
- if (body.ok) {
1128
+ const ok = Boolean(body.ok);
1129
+ const text = ok ? `${account.label}:已保存,个人设置和 AuthineX 已是这一份` : `${account.label}:${String(body.message || "没有保存")}`;
1130
+ setAccountMsg((prev) => ({ ...prev, [account.id]: { text, tone: ok ? "ok" : "error" } }));
1131
+ setNotice(text);
1132
+ setFeedback(ok ? "ok" : "error");
1133
+ if (ok) {
884
1134
  setDrafts((prev) => {
885
1135
  const next = { ...prev };
886
1136
  delete next[account.id];
@@ -1050,7 +1300,7 @@ function AuthinexPanel() {
1050
1300
  const message = localError || notice || model.message;
1051
1301
  const messageError = localError !== "" || model.phase === "invalid" || model.phase === "revoked" || model.phase === "unreachable";
1052
1302
  const disabled = busy !== "";
1053
- const pending = busy === "refresh" ? "正在刷新…" : busy === "update" ? "正在检查更新…" : "";
1303
+ const pending = busy === "refresh" ? "正在刷新…" : busy === "update" ? "正在检查更新…" : busy.startsWith("test:") ? "正在测试连接…" : busy.startsWith("save:") ? "正在保存…" : "";
1054
1304
  const messageClass = feedback === "ok" ? "axds-ok" : feedback === "warn" ? "axds-notice" : messageError || feedback === "error" ? "axds-error" : "axds-muted";
1055
1305
  const skillPending = skillBusy === "list" ? "正在取技能列表…" : "";
1056
1306
  const installed = model.installedSkills;
@@ -1129,7 +1379,8 @@ function AuthinexPanel() {
1129
1379
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.Button, { size: "sm", variant: "outline", disabled, onClick: () => {
1130
1380
  setConfirmUnbind(true);
1131
1381
  }, children: "解除绑定" })
1132
- ] }) : null
1382
+ ] }) : null,
1383
+ model.phase === "invalid" && model.endpoint ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "axds-muted", children: "升级不会作废这把密钥。把原来的密钥再贴一次,就会接回这台机器。" }) : null
1133
1384
  ] }) : null,
1134
1385
  model.user ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1135
1386
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "axds-row", children: [
@@ -1234,31 +1485,70 @@ function AuthinexPanel() {
1234
1485
  account.hasToken ? " · 已有凭据" : ""
1235
1486
  ] }) : null,
1236
1487
  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);
1488
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "axds-fields", children: account.fields.map((field) => {
1489
+ const onesSelect = account.id === "ones" && (field.name === "defaultProjectUuid" || field.name === "defaultIssueTypeId" || field.name === "planIssueTypeId") ? onesSelectRows({
1490
+ field,
1491
+ draft,
1492
+ projects: onesProjects,
1493
+ types: onesTypes,
1494
+ busy: optionsBusy
1495
+ }) : null;
1496
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "axds-field", children: [
1497
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: field.title }),
1498
+ onesSelect ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1499
+ "select",
1500
+ {
1501
+ className: "axds-select",
1502
+ value: draft[field.name] ?? "",
1503
+ disabled: disabled || optionsBusy !== "" || onesSelect.disabled,
1504
+ onChange: (event) => {
1505
+ onOnesSelect(account, field.name, event.target.value);
1506
+ },
1507
+ children: onesSelect.rows.map((row) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: row.uuid, children: row.name }, `${row.uuid}:${row.name}`))
1250
1508
  }
1251
- }
1252
- )
1253
- ] }, field.name)) }),
1509
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1510
+ import_dsh_client_ui_primitives3.Input,
1511
+ {
1512
+ className: "axds-input",
1513
+ type: field.type,
1514
+ value: draft[field.name] ?? "",
1515
+ placeholder: field.placeholder,
1516
+ autoComplete: "off",
1517
+ spellCheck: false,
1518
+ onChange: (event) => {
1519
+ setField(account, field.name, event.target.value);
1520
+ }
1521
+ }
1522
+ )
1523
+ ] }, field.name);
1524
+ }) }),
1525
+ account.id === "ones" && onesProjects.message ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "axds-error", children: [
1526
+ "项目:",
1527
+ onesProjects.message
1528
+ ] }) : null,
1529
+ account.id === "ones" && onesTypes.message ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: "axds-error", children: [
1530
+ "工单类型:",
1531
+ onesTypes.message
1532
+ ] }) : null,
1533
+ editing && accountMsg[account.id] ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1534
+ "p",
1535
+ {
1536
+ className: accountMsg[account.id].tone === "ok" ? "axds-ok" : accountMsg[account.id].tone === "error" ? "axds-error" : "axds-notice",
1537
+ role: "status",
1538
+ children: accountMsg[account.id].text
1539
+ }
1540
+ ) : null,
1254
1541
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "axds-actions", children: [
1255
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "axds-muted", children: "保存前会先做一次连接测试" }),
1542
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "axds-muted", children: "保存前会先做一次连接测试,并写入个人设置" }),
1543
+ account.id === "ones" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.Button, { size: "sm", disabled: disabled || optionsBusy !== "", onClick: () => {
1544
+ onFetchOnes(account);
1545
+ }, children: optionsBusy ? "获取中" : "获取类型" }) : null,
1256
1546
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.Button, { size: "sm", disabled, onClick: () => {
1257
1547
  onTest(account);
1258
- }, children: "测试连接" }),
1548
+ }, children: busy === `test:${account.id}` ? "测试中" : "测试连接" }),
1259
1549
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.Button, { size: "sm", variant: "primary", disabled, onClick: () => {
1260
1550
  onSave(account);
1261
- }, children: "保存" })
1551
+ }, children: busy === `save:${account.id}` ? "保存中" : "保存" })
1262
1552
  ] })
1263
1553
  ] }) : null
1264
1554
  ] }, account.id);
@@ -1431,9 +1721,9 @@ function AuthinexPanel() {
1431
1721
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: "适用范围" }),
1432
1722
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { children: skillScopeText(row) })
1433
1723
  ] }),
1434
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
1724
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "axds-kv-when", children: [
1435
1725
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: "更新时间" }),
1436
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { children: row.updatedAt || "—" })
1726
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dd", { children: formatUpdatedAt(row.updatedAt) })
1437
1727
  ] }),
1438
1728
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
1439
1729
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("dt", { children: "来源" }),
@@ -1535,6 +1825,48 @@ function AuthinexPanel() {
1535
1825
  ] });
1536
1826
  }
1537
1827
 
1828
+ // src/command-card.tsx
1829
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1830
+ function AxContextCommandCard(props) {
1831
+ const outcome = props.node?.outcome;
1832
+ if (!outcome) {
1833
+ 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: [
1834
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-title", children: "工作上下文" }),
1835
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-muted", children: "正在设置…" })
1836
+ ] }) });
1837
+ }
1838
+ if (outcome.kind === "error") {
1839
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd", "data-state": "error", children: [
1840
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd-head", children: [
1841
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-title", children: "工作上下文" }),
1842
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-mark", "data-mark": "bad", children: "没设成" })
1843
+ ] }),
1844
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "axds-cmd-note axds-error", children: outcome.text })
1845
+ ] });
1846
+ }
1847
+ const receipt = parseReceiptText(outcome.text || "");
1848
+ if (!receipt) {
1849
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd", "data-state": "ok", children: [
1850
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd-head", children: [
1851
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-title", children: "工作上下文" }),
1852
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-mark", "data-mark": "ok", children: "已生效" })
1853
+ ] }),
1854
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "axds-cmd-note axds-muted", children: outcome.text })
1855
+ ] });
1856
+ }
1857
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd", "data-state": "ok", children: [
1858
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "axds-cmd-head", children: [
1859
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-title", children: "工作上下文" }),
1860
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "axds-cmd-mark", "data-mark": "ok", children: "已生效" })
1861
+ ] }),
1862
+ /* @__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: [
1863
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: field.label }),
1864
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("b", { children: field.value })
1865
+ ] }, `${field.label}:${field.value}`)) }),
1866
+ receipt.note ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "axds-cmd-note axds-muted", children: receipt.note }) : null
1867
+ ] });
1868
+ }
1869
+
1538
1870
  // src/styles.ts
1539
1871
  var CSS = `
1540
1872
  .axds{display:flex;flex-direction:column;gap:12px;color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5}
@@ -1612,13 +1944,32 @@ var CSS = `
1612
1944
  .axds-kv>div{display:flex;gap:6px;min-width:0}
1613
1945
  .axds-kv dt{color:var(--dsw-alias-label-tertiary);flex:none}
1614
1946
  .axds-kv dd{margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1947
+ .axds-kv-when{min-width:220px}
1948
+ .axds-kv-when dd{overflow:visible;text-overflow:clip}
1615
1949
  .axds-pager{display:flex;align-items:center;gap:8px}
1616
1950
  .axds-import{display:flex;flex-direction:column;gap:8px}
1617
1951
  .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}
1952
+ .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}
1953
+ .axds-plain{height:32px;padding:0 8px}
1954
+ /* 跟 Input 原子同一套:36px、layer-1 底、l4 边。原生 select 默认是系统白底,和旁边输入框对不齐。 */
1955
+ .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}
1956
+ .axds-select:focus{outline:none;border-color:var(--dsw-alias-state-business-primary)}
1957
+ .axds-select:disabled{opacity:.55}
1958
+ .axds-select option{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary)}
1620
1959
  .axds-textarea{min-height:96px;resize:vertical;padding:8px;line-height:1.5}
1621
1960
  .axds-file{display:none}
1961
+ /* 对话里 /ax-context 的回执卡:比宿主通用命令卡更醒目,成功显字段徽片。 */
1962
+ .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)}
1963
+ .axds-cmd[data-state="error"]{border-color:var(--dsw-alias-state-error-primary)}
1964
+ .axds-cmd-head{display:flex;align-items:center;gap:8px}
1965
+ .axds-cmd-title{font-weight:600}
1966
+ .axds-cmd-mark{font-size:12px;padding:1px 8px;border-radius:999px}
1967
+ .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)}
1968
+ .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)}
1969
+ .axds-cmd-fields{display:flex;flex-wrap:wrap;gap:6px}
1970
+ .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)}
1971
+ .axds-cmd-field b{font-weight:600;color:var(--dsw-alias-label-primary)}
1972
+ .axds-cmd-note{max-width:72ch}
1622
1973
  `;
1623
1974
  var mounted = 0;
1624
1975
  function installClientStyles() {
@@ -1653,6 +2004,13 @@ function install() {
1653
2004
  };
1654
2005
  contribute("plugins.bundle.config", PACKAGE_NAME);
1655
2006
  contribute("plugins.row.config", ROW_KEY);
2007
+ try {
2008
+ ctx.slots.inject("conversation.chat.commandview", () => ctx.slots.register(
2009
+ { name: "conversation.chat.commandview", key: "ax-context" },
2010
+ AxContextCommandCard
2011
+ ));
2012
+ } catch {
2013
+ }
1656
2014
  }
1657
2015
  };
1658
2016
  }