@authinex/dsh-plugin 0.3.8 → 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/lib/client.js CHANGED
@@ -43,6 +43,11 @@ function textOf(data, fallback) {
43
43
 
44
44
  // src/account-options.ts
45
45
  var CURRENT_PREFIX = "当前值 ";
46
+ var NAME_KEY = {
47
+ defaultProjectUuid: "defaultProjectName",
48
+ defaultIssueTypeId: "defaultIssueTypeName",
49
+ planIssueTypeId: "planIssueTypeName"
50
+ };
46
51
  function withCurrent(rows, value, items, label = "") {
47
52
  if (value && !items.some((item) => item.uuid === value)) {
48
53
  const named = label.trim();
@@ -63,8 +68,8 @@ function onesSelectRows(input) {
63
68
  const { field, draft, projects, types, busy } = input;
64
69
  const value = draft[field.name] ?? "";
65
70
  const project = draft.defaultProjectUuid ?? "";
66
- const label = field.name === "defaultIssueTypeId" ? draft.defaultIssueTypeName ?? "" : draft.defaultProjectName ?? "";
67
- if (field.name !== "defaultIssueTypeId") {
71
+ const label = draft[NAME_KEY[field.name] ?? ""] ?? "";
72
+ if (field.name === "defaultProjectUuid") {
68
73
  const rows2 = [{
69
74
  uuid: "",
70
75
  name: busy === "projects" ? "正在拉取项目…" : "— 请选择项目 —"
@@ -74,7 +79,8 @@ function onesSelectRows(input) {
74
79
  }
75
80
  if (!project) return { disabled: true, rows: [{ uuid: "", name: "先选择默认项目" }] };
76
81
  if (busy === "types" || types.forProject !== project) {
77
- return { disabled: true, rows: [{ uuid: "", name: "正在拉取工单类型…" }] };
82
+ const rows2 = [{ uuid: "", name: "正在拉取工单类型…" }];
83
+ return { disabled: true, rows: withCurrent(rows2, value, [], label) };
78
84
  }
79
85
  if (types.message) {
80
86
  const rows2 = [{ uuid: "", name: types.message }];
@@ -202,10 +208,12 @@ var TOOLS = {
202
208
  title: "查询工单",
203
209
  timeoutMs: 3e4,
204
210
  description: `按单号查 ONES、氚云或 PMO。没有可用账号的那一家不要编造单号。
211
+ 13 位氚云流水号查氚云原单;要查 ONES 上同步过去的缺陷,system 填 ones,或把流水号放进 h3yunSeqNo。不要把它当成 ONES 编号。
205
212
  已知单号才用它;按条件筛用 search_tickets。${DATA_NOT_INSTRUCTION}`,
206
213
  parameters: {
207
- number: { type: "string", description: "工单号" },
214
+ number: { type: "string", description: "工单号。13 位氚云流水号配 system=ones 时查 ONES 同步缺陷。" },
208
215
  system: { type: "string", description: "ones、h3yun 或 pmo" },
216
+ h3yunSeqNo: { type: "string", description: "氚云工单流水号。只查 ONES 上这个字段,不查氚云原单。" },
209
217
  keyword: { type: "string", description: "没有单号时按标题筛" }
210
218
  }
211
219
  },
@@ -276,14 +284,22 @@ var TOOLS = {
276
284
  },
277
285
  create_ticket: {
278
286
  title: "创建工单",
279
- timeoutMs: 6e4,
280
- 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}`,
281
291
  parameters: {
282
292
  system: { type: "string", required: true, description: "ones、h3yun 或 pmo" },
283
293
  title: { type: "string", required: true, description: "标题" },
284
294
  description: { type: "string", required: true, description: "描述" },
285
- version: { type: "string", description: "产品版本" },
286
- 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 用高、中、底。没说留空。" }
287
303
  }
288
304
  }
289
305
  };
@@ -366,7 +382,8 @@ var ACCOUNT_FIELDS = {
366
382
  { name: "baseUrl", title: "地址(可空)" },
367
383
  { name: "token", title: "密码或 API Token", type: "password" },
368
384
  { name: "defaultProjectUuid", title: "默认项目" },
369
- { name: "defaultIssueTypeId", title: "缺陷工单类型" }
385
+ { name: "defaultIssueTypeId", title: "缺陷工单类型" },
386
+ { name: "planIssueTypeId", title: "规划项工单类型" }
370
387
  ],
371
388
  h3yun: [
372
389
  { name: "username", title: "手机号" },
@@ -463,7 +480,8 @@ function viewModel(state) {
463
480
  fields: accountFields(id, row),
464
481
  extras: id === "ones" ? {
465
482
  defaultProjectName: fieldValue(row, "defaultProjectName"),
466
- defaultIssueTypeName: fieldValue(row, "defaultIssueTypeName")
483
+ defaultIssueTypeName: fieldValue(row, "defaultIssueTypeName"),
484
+ planIssueTypeName: fieldValue(row, "planIssueTypeName")
467
485
  } : {}
468
486
  };
469
487
  }) : [];
@@ -1029,12 +1047,15 @@ function AuthinexPanel() {
1029
1047
  if (value !== previousId) {
1030
1048
  base.defaultIssueTypeId = "";
1031
1049
  base.defaultIssueTypeName = "";
1050
+ base.planIssueTypeId = "";
1051
+ base.planIssueTypeName = "";
1032
1052
  }
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);
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);
1038
1059
  } else {
1039
1060
  base[name] = value;
1040
1061
  }
@@ -1358,7 +1379,8 @@ function AuthinexPanel() {
1358
1379
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives3.Button, { size: "sm", variant: "outline", disabled, onClick: () => {
1359
1380
  setConfirmUnbind(true);
1360
1381
  }, children: "解除绑定" })
1361
- ] }) : null
1382
+ ] }) : null,
1383
+ model.phase === "invalid" && model.endpoint ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "axds-muted", children: "升级不会作废这把密钥。把原来的密钥再贴一次,就会接回这台机器。" }) : null
1362
1384
  ] }) : null,
1363
1385
  model.user ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1364
1386
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "axds-row", children: [
@@ -1464,7 +1486,7 @@ function AuthinexPanel() {
1464
1486
  ] }) : null,
1465
1487
  editing ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
1466
1488
  /* @__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({
1489
+ const onesSelect = account.id === "ones" && (field.name === "defaultProjectUuid" || field.name === "defaultIssueTypeId" || field.name === "planIssueTypeId") ? onesSelectRows({
1468
1490
  field,
1469
1491
  draft,
1470
1492
  projects: onesProjects,
package/lib/index.js CHANGED
@@ -86,6 +86,34 @@ function attachOptionalHosts(ctx, bridge) {
86
86
  }
87
87
  }
88
88
 
89
+ // src/device-file.ts
90
+ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
91
+ import { homedir } from "node:os";
92
+ import { dirname, join } from "node:path";
93
+ function deviceFileAt(path2) {
94
+ return {
95
+ async read() {
96
+ try {
97
+ const text2 = await readFile(path2, "utf8");
98
+ return text2.trim() ? text2 : void 0;
99
+ } catch {
100
+ return void 0;
101
+ }
102
+ },
103
+ async write(value) {
104
+ await mkdir(dirname(path2), { recursive: true, mode: 448 });
105
+ await writeFile(path2, value, { mode: 384 });
106
+ await chmod(path2, 384);
107
+ },
108
+ async clear() {
109
+ await rm(path2, { force: true });
110
+ }
111
+ };
112
+ }
113
+ function defaultDeviceFile() {
114
+ return deviceFileAt(join(homedir(), ".dsh", "authinex-ds-device.json"));
115
+ }
116
+
89
117
  // src/phrases.ts
90
118
  var PHRASES = {
91
119
  unbound: "填写访问地址和密钥完成绑定",
@@ -308,9 +336,9 @@ function command(file, args) {
308
336
  stdio: ["ignore", "pipe", "ignore"]
309
337
  });
310
338
  }
311
- function readText(path) {
339
+ function readText(path2) {
312
340
  try {
313
- return readFileSync(path, "utf8").trim();
341
+ return readFileSync(path2, "utf8").trim();
314
342
  } catch {
315
343
  return "";
316
344
  }
@@ -346,6 +374,10 @@ function stableFingerprint(installId, env) {
346
374
  if (!env.machineId || env.machineId.length < 16) throw new Error("machine id unavailable");
347
375
  return sha256([env.platform, env.arch, env.machineId, installId].join("\n"));
348
376
  }
377
+ function machineFingerprint(env) {
378
+ if (!env.machineId || env.machineId.length < 16) throw new Error("machine id unavailable");
379
+ return sha256([env.platform, env.arch, env.machineId].join("\n"));
380
+ }
349
381
  function legacyFingerprint(installId, env) {
350
382
  return sha256([env.platform, env.arch, env.hostname, installId].join("\n"));
351
383
  }
@@ -359,9 +391,9 @@ function currentFingerprints(installId) {
359
391
  }
360
392
 
361
393
  // src/controller.ts
362
- import { mkdtemp, writeFile as writeFile2 } from "node:fs/promises";
394
+ import { mkdtemp, writeFile as writeFile3 } from "node:fs/promises";
363
395
  import { tmpdir } from "node:os";
364
- import { join as join2 } from "node:path";
396
+ import { join as join3 } from "node:path";
365
397
  import { arch as arch2, hostname as hostname2, platform as platform2 } from "node:os";
366
398
 
367
399
  // src/account-wire.ts
@@ -370,6 +402,8 @@ var SETTING_KEYS = [
370
402
  "defaultProjectName",
371
403
  "defaultIssueTypeId",
372
404
  "defaultIssueTypeName",
405
+ "planIssueTypeId",
406
+ "planIssueTypeName",
373
407
  "engineCode",
374
408
  "schemaCode",
375
409
  "authMode",
@@ -482,23 +516,23 @@ function parseKey(raw) {
482
516
  }
483
517
 
484
518
  // src/skills-fs.ts
485
- import { mkdir, readdir, writeFile } from "node:fs/promises";
486
- import { homedir } from "node:os";
487
- import { join } from "node:path";
519
+ import { mkdir as mkdir2, readdir, writeFile as writeFile2 } from "node:fs/promises";
520
+ import { homedir as homedir2 } from "node:os";
521
+ import { join as join2 } from "node:path";
488
522
  var SLUG = /^[a-z0-9][a-z0-9-]{0,63}$/;
489
523
  function skillsRoot(home) {
490
- const root = String(home || "").trim() || String(process.env.DSH_HOME || "").trim() || join(homedir(), ".dsh");
491
- return join(root, "skills");
524
+ const root = String(home || "").trim() || String(process.env.DSH_HOME || "").trim() || join2(homedir2(), ".dsh");
525
+ return join2(root, "skills");
492
526
  }
493
527
  function validSlug(slug) {
494
528
  return SLUG.test(slug);
495
529
  }
496
530
  async function writeSkill(slug, markdown, home) {
497
531
  if (!validSlug(slug)) throw new Error("非法技能目录名");
498
- const dir = join(skillsRoot(home), slug);
499
- await mkdir(dir, { recursive: true });
500
- const file = join(dir, "SKILL.md");
501
- await writeFile(file, markdown, "utf8");
532
+ const dir = join2(skillsRoot(home), slug);
533
+ await mkdir2(dir, { recursive: true });
534
+ const file = join2(dir, "SKILL.md");
535
+ await writeFile2(file, markdown, "utf8");
502
536
  return file;
503
537
  }
504
538
  async function listInstalled(home) {
@@ -510,22 +544,183 @@ async function listInstalled(home) {
510
544
  }
511
545
  }
512
546
 
547
+ // src/ticket-files.ts
548
+ import { readFile as readFile2, realpath, stat } from "node:fs/promises";
549
+ import { homedir as homedir3 } from "node:os";
550
+ import path from "node:path";
551
+ var MAX_FILES = 6;
552
+ var MAX_BYTES = 4 * 1024 * 1024;
553
+ var MIME = {
554
+ ".png": "image/png",
555
+ ".jpg": "image/jpeg",
556
+ ".jpeg": "image/jpeg",
557
+ ".gif": "image/gif",
558
+ ".webp": "image/webp",
559
+ ".bmp": "image/bmp",
560
+ ".txt": "text/plain",
561
+ ".log": "text/plain",
562
+ ".json": "application/json",
563
+ ".har": "application/json",
564
+ ".pdf": "application/pdf",
565
+ ".zip": "application/zip"
566
+ };
567
+ function attachmentRoots(env = process.env, home = homedir3()) {
568
+ const base = env.DSH_HOME || path.join(home, ".dsh");
569
+ return [path.join(base, "attachments"), path.join(base, "cache", "attachments")];
570
+ }
571
+ function piece(pathName, name2 = "", mime = "", data = "") {
572
+ if (!pathName && !data) return null;
573
+ return { path: pathName, name: name2, mime, data };
574
+ }
575
+ function pieceFromText(value) {
576
+ const text2 = value.trim();
577
+ if (!text2) return null;
578
+ if (text2.startsWith("data:")) return piece("", "", "", text2);
579
+ const quoted = text2.match(/["'](\/[^"']+)["']/);
580
+ const candidate = (quoted ? quoted[1] : text2.replace(/^["']|["']$/g, "")).trim();
581
+ if (!path.isAbsolute(candidate)) return null;
582
+ return piece(candidate);
583
+ }
584
+ function pieceFromRow(value) {
585
+ if (typeof value === "string") return pieceFromText(value);
586
+ if (!value || typeof value !== "object") return null;
587
+ const row = value;
588
+ const data = typeof row.data === "string" ? row.data : "";
589
+ const filePath = typeof row.path === "string" ? row.path : typeof row.file === "string" ? row.file : "";
590
+ const name2 = typeof row.name === "string" ? row.name.trim() : "";
591
+ const mime = typeof row.mime === "string" ? row.mime.trim() : "";
592
+ return piece(filePath.trim(), name2, mime, data);
593
+ }
594
+ function parseAttachmentInput(raw) {
595
+ if (Array.isArray(raw)) {
596
+ return raw.flatMap((item) => {
597
+ const parsed = pieceFromRow(item);
598
+ return parsed ? [parsed] : [];
599
+ });
600
+ }
601
+ if (typeof raw !== "string") return [];
602
+ const text2 = raw.trim();
603
+ if (!text2) return [];
604
+ if (text2.startsWith("[") || text2.startsWith("{")) {
605
+ try {
606
+ const parsed = JSON.parse(text2);
607
+ if (Array.isArray(parsed) || parsed && typeof parsed === "object") {
608
+ return parseAttachmentInput(Array.isArray(parsed) ? parsed : [parsed]);
609
+ }
610
+ } catch {
611
+ }
612
+ }
613
+ return text2.split(/\r?\n/).flatMap((line) => {
614
+ const parsed = pieceFromText(line);
615
+ return parsed ? [parsed] : [];
616
+ });
617
+ }
618
+ function attachmentCount(raw) {
619
+ return parseAttachmentInput(raw).length;
620
+ }
621
+ function labelOf(piece2) {
622
+ if (piece2.name) return piece2.name;
623
+ if (piece2.path) return path.basename(piece2.path);
624
+ return "附件";
625
+ }
626
+ function mimeOfData(data) {
627
+ if (!data.startsWith("data:")) return "application/octet-stream";
628
+ const comma = data.indexOf(",");
629
+ const head = (comma >= 0 ? data.slice(5, comma) : data.slice(5)).split(";")[0].trim();
630
+ return head || "application/octet-stream";
631
+ }
632
+ function decodeLength(data) {
633
+ const comma = data.indexOf(",");
634
+ const body = data.startsWith("data:") && comma >= 0 ? data.slice(comma + 1) : data;
635
+ const compact = body.replace(/\s+/g, "");
636
+ return Buffer.from(compact, "base64").length;
637
+ }
638
+ async function allowed(real, roots) {
639
+ for (const root of roots) {
640
+ let base = "";
641
+ try {
642
+ base = await realpath(root);
643
+ } catch {
644
+ continue;
645
+ }
646
+ if (real === base || real.startsWith(base + path.sep)) return true;
647
+ }
648
+ return false;
649
+ }
650
+ async function fileFromPath(item, roots) {
651
+ const real = await realpath(item.path);
652
+ const info = await stat(real);
653
+ if (!info.isFile() || info.size <= 0 || info.size > MAX_BYTES) throw new Error("skip");
654
+ if (!await allowed(real, roots)) throw new Error("skip");
655
+ const body = await readFile2(real);
656
+ const ext = path.extname(real).toLowerCase();
657
+ return {
658
+ name: item.name || path.basename(real),
659
+ mime: item.mime || MIME[ext] || "application/octet-stream",
660
+ data: body.toString("base64"),
661
+ bytes: body.length
662
+ };
663
+ }
664
+ function fileFromData(item) {
665
+ const bytes = decodeLength(item.data);
666
+ if (bytes <= 0 || bytes > MAX_BYTES) throw new Error("skip");
667
+ return {
668
+ name: item.name || "image.png",
669
+ mime: item.mime || mimeOfData(item.data),
670
+ data: item.data,
671
+ bytes
672
+ };
673
+ }
674
+ async function readTicketFiles(raw, roots = attachmentRoots()) {
675
+ const pieces = parseAttachmentInput(raw).slice(0, MAX_FILES + 4);
676
+ if (!pieces.length) return { files: [], note: "" };
677
+ const files = [];
678
+ const skipped = [];
679
+ let total = 0;
680
+ for (const item of pieces) {
681
+ const name2 = labelOf(item);
682
+ if (files.length >= MAX_FILES) {
683
+ skipped.push(name2);
684
+ continue;
685
+ }
686
+ try {
687
+ const file = item.data ? fileFromData(item) : await fileFromPath(item, roots);
688
+ if (total + file.bytes > MAX_BYTES * MAX_FILES) {
689
+ skipped.push(file.name);
690
+ continue;
691
+ }
692
+ total += file.bytes;
693
+ files.push({ name: file.name, mime: file.mime, data: file.data });
694
+ } catch {
695
+ skipped.push(name2);
696
+ }
697
+ }
698
+ const note = skipped.length ? `有 ${skipped.length} 个附件没带上(${skipped.slice(0, 3).join("、")})。只接受对话附件目录里的文件。` : "";
699
+ return { files, note };
700
+ }
701
+
513
702
  // src/confirm-write.ts
514
703
  var EXPERIENCE_CANCELLED = "用户取消了提交经验,不要用同一草稿再提一次。";
515
704
  function oneLine(value, limit) {
516
705
  return value.replace(/\s+/g, " ").slice(0, limit);
517
706
  }
518
- async function confirmCreateTicket(args, ask, askContext, login, cancelled) {
707
+ async function confirmCreateTicket(args, ask, askContext, cancelled) {
708
+ const version = (args.version || "").trim();
709
+ const files = attachmentCount(args.attachments);
710
+ const marker = typeof args.attachments === "string" ? args.attachments : "";
519
711
  const draft = `${args.system}
520
712
  ${args.title}
521
- ${args.description}`;
713
+ ${args.description}
714
+ ${version}
715
+ ${marker.slice(0, 500)}`;
522
716
  if (cancelled.has(draft)) return { proceed: false, result: { text: CANCELLED, isError: false } };
523
717
  const target = ["ones", "h3yun", "pmo"].includes(args.system) ? args.system.toUpperCase() : args.system;
524
718
  const detail = [
525
719
  `系统 ${target}`,
720
+ version ? `发现版本 ${oneLine(version, 60)}` : "",
721
+ files ? `附件 ${files} 个` : "",
526
722
  `标题 ${args.title}`,
527
- `描述 ${oneLine(args.description, 100)}`,
528
- login ? `登录名 ${login}` : ""
723
+ `描述 ${oneLine(args.description, 100)}`
529
724
  ].filter(Boolean).join(" · ");
530
725
  let selected = "";
531
726
  try {
@@ -713,10 +908,12 @@ var TOOLS = {
713
908
  title: "查询工单",
714
909
  timeoutMs: 3e4,
715
910
  description: `按单号查 ONES、氚云或 PMO。没有可用账号的那一家不要编造单号。
911
+ 13 位氚云流水号查氚云原单;要查 ONES 上同步过去的缺陷,system 填 ones,或把流水号放进 h3yunSeqNo。不要把它当成 ONES 编号。
716
912
  已知单号才用它;按条件筛用 search_tickets。${DATA_NOT_INSTRUCTION}`,
717
913
  parameters: {
718
- number: { type: "string", description: "工单号" },
914
+ number: { type: "string", description: "工单号。13 位氚云流水号配 system=ones 时查 ONES 同步缺陷。" },
719
915
  system: { type: "string", description: "ones、h3yun 或 pmo" },
916
+ h3yunSeqNo: { type: "string", description: "氚云工单流水号。只查 ONES 上这个字段,不查氚云原单。" },
720
917
  keyword: { type: "string", description: "没有单号时按标题筛" }
721
918
  }
722
919
  },
@@ -787,14 +984,22 @@ var TOOLS = {
787
984
  },
788
985
  create_ticket: {
789
986
  title: "创建工单",
790
- timeoutMs: 6e4,
791
- description: `起草 ONES、氚云或 PMO 工单。必须先让用户在确认卡上点创建,取消后不要用同一草稿再提。${DATA_NOT_INSTRUCTION}`,
987
+ // 建单本身要跑一串 ONES 往返(登录、字段字典、add3);带附件还要再申请上传、
988
+ // 传完回写 <figure>,60 秒装不下,超时会让单子看起来"没建成",人就会重提。
989
+ timeoutMs: 18e4,
990
+ description: `起草 ONES、氚云或 PMO 工单。提交用的是已经保存的个人账号,不要向用户要邮箱、密码或 Token。用户说了版本就把原话放进 version,ONES 写入「发现版本-云枢」,没说就留空。用户附了图片或文件时,把对话里给出的只读路径放进 attachments,一行一个。必须先让用户在确认卡上点创建,取消后不要用同一草稿再提。${DATA_NOT_INSTRUCTION}`,
792
991
  parameters: {
793
992
  system: { type: "string", required: true, description: "ones、h3yun 或 pmo" },
794
993
  title: { type: "string", required: true, description: "标题" },
795
994
  description: { type: "string", required: true, description: "描述" },
796
- version: { type: "string", description: "产品版本" },
797
- customer: { type: "string", description: "客户" }
995
+ version: { type: "string", description: "ONES「发现版本-云枢」。用户说了才填,按原话,如 AI-Platform-v2.1。没说留空。" },
996
+ attachments: { type: "string", description: "对话里图片或文件的只读路径,一行一个。没有就留空,不要编路径。" },
997
+ customer: { type: "string", description: "客户。PMO 要客户全称。" },
998
+ ticketType: { type: "string", description: "氚云工单类型:需求、缺陷或咨询。没说留空。" },
999
+ serviceType: { type: "string", description: "PMO 服务单类型。没说留空,系统按问题单。" },
1000
+ product: { type: "string", description: "PMO 产品类型,如云枢。没说留空。" },
1001
+ issueType: { type: "string", description: "PMO 问题类型:产品问题、技术问题或其他问题。没说留空。" },
1002
+ priority: { type: "string", description: "优先级。PMO 用高、中、底。没说留空。" }
798
1003
  }
799
1004
  }
800
1005
  };
@@ -833,7 +1038,7 @@ var ALIASES = {
833
1038
  print: "print",
834
1039
  打印: "print"
835
1040
  };
836
- function labelOf(kind) {
1041
+ function labelOf2(kind) {
837
1042
  const found = PRODUCT_KINDS.find((item) => item.id === kind);
838
1043
  return found ? found.label : kind;
839
1044
  }
@@ -871,7 +1076,7 @@ function workIsEmpty(work) {
871
1076
  }
872
1077
  function formatWork(work) {
873
1078
  const parts = [];
874
- if (work.productKind) parts.push(`产品线 ${labelOf(work.productKind)}`);
1079
+ if (work.productKind) parts.push(`产品线 ${labelOf2(work.productKind)}`);
875
1080
  if (work.version) parts.push(`版本 ${work.version}`);
876
1081
  if (work.customer) parts.push(`客户 ${work.customer}`);
877
1082
  if (!parts.length) return "";
@@ -879,7 +1084,7 @@ function formatWork(work) {
879
1084
  }
880
1085
  function formatWorkFields(work) {
881
1086
  const parts = [];
882
- if (work.productKind) parts.push(`产品线 ${labelOf(work.productKind)}`);
1087
+ if (work.productKind) parts.push(`产品线 ${labelOf2(work.productKind)}`);
883
1088
  if (work.version) parts.push(`版本 ${work.version}`);
884
1089
  if (work.customer) parts.push(`客户 ${work.customer}`);
885
1090
  return parts.join(" / ");
@@ -1196,16 +1401,31 @@ ${accepted.tools.map((tool) => tool.name).join("\n")}`;
1196
1401
  }
1197
1402
  async function runTicket(args, ctx, timeout) {
1198
1403
  const decision = await confirmCreateTicket(
1199
- { system: textArg(args, "system"), title: textArg(args, "title"), description: textArg(args, "description") },
1404
+ {
1405
+ system: textArg(args, "system"),
1406
+ title: textArg(args, "title"),
1407
+ description: textArg(args, "description"),
1408
+ version: textArg(args, "version"),
1409
+ attachments: args.attachments
1410
+ },
1200
1411
  ctx.ask,
1201
1412
  askContextOf(ctx),
1202
- state.accounts?.[textArg(args, "system")]?.username || "",
1203
1413
  deps.cancelled
1204
1414
  );
1205
1415
  if (!decision.proceed) return decision.result;
1416
+ const prepared = await readTicketFiles(args.attachments);
1417
+ if (attachmentCount(args.attachments) > 0 && prepared.files.length === 0) {
1418
+ return { text: prepared.note || "附件没读到,工单没有提交。", isError: true };
1419
+ }
1420
+ const outbound = { ...args };
1421
+ if (prepared.files.length) outbound.attachments = prepared.files;
1422
+ else delete outbound.attachments;
1206
1423
  state.busy += 1;
1207
1424
  try {
1208
- return await toolCall("create_ticket", args, timeout);
1425
+ const result = await toolCall("create_ticket", outbound, timeout);
1426
+ if (prepared.note && !result.isError) return { ...result, text: `${result.text}
1427
+ ${prepared.note}` };
1428
+ return result;
1209
1429
  } catch {
1210
1430
  return { text: "结果不清楚。请到「我的工单」核对,不要自动再提交一张。", isError: true };
1211
1431
  } finally {
@@ -1236,7 +1456,7 @@ ${accepted.tools.map((tool) => tool.name).join("\n")}`;
1236
1456
  return { text: "当前没有这个工具。", isError: true };
1237
1457
  }
1238
1458
  const payload = applyContextArgs(name2, args);
1239
- if (name2 === "create_ticket") return runTicket(payload, ctx, entry?.timeoutMs || 6e4);
1459
+ if (name2 === "create_ticket") return runTicket(payload, ctx, entry?.timeoutMs || TOOLS.create_ticket.timeoutMs);
1240
1460
  if (name2 === "submit_experience") return runExperience(payload, ctx, entry?.timeoutMs || 3e4);
1241
1461
  state.busy += 1;
1242
1462
  try {
@@ -1396,7 +1616,7 @@ var ROW_KEY = `${PACKAGE_NAME}#${ROW_ID}`;
1396
1616
  var SKILL_PAGE_SIZE = 8;
1397
1617
 
1398
1618
  // src/controller.ts
1399
- var VERSION = true ? "0.3.8" : "0.1.0";
1619
+ var VERSION = true ? "0.3.9" : "0.1.0";
1400
1620
  var CREDENTIAL_REF = "AUTHINEX_DS_DEVICE";
1401
1621
  var CONTEXT_CREDENTIAL_REF = "AUTHINEX_DS_CONTEXT";
1402
1622
  var NPM_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
@@ -1422,6 +1642,9 @@ var PhaseError = class extends Error {
1422
1642
  function phaseError(error) {
1423
1643
  return error instanceof PhaseError ? error : null;
1424
1644
  }
1645
+ function defaultMachineFingerprint() {
1646
+ return machineFingerprint({ platform: platform2(), arch: arch2(), machineId: readMachineId() });
1647
+ }
1425
1648
  function defaultFingerprint(installId) {
1426
1649
  return currentFingerprints(installId).current;
1427
1650
  }
@@ -1462,15 +1685,30 @@ function createController(options) {
1462
1685
  const clientKind = options.clientKind || detectClientKind();
1463
1686
  const fingerprintOf = options.fingerprint || defaultFingerprint;
1464
1687
  const legacyFingerprintOf = options.legacyFingerprint || defaultLegacyFingerprint;
1688
+ const machineFingerprintOf = options.machineFingerprint || (options.fingerprint ? (() => "") : defaultMachineFingerprint);
1689
+ const deviceFile = options.deviceFile;
1465
1690
  function devicePrints(installId) {
1466
1691
  try {
1467
- return { current: fingerprintOf(installId), legacy: legacyFingerprintOf(installId) };
1692
+ return {
1693
+ current: fingerprintOf(installId),
1694
+ legacy: legacyFingerprintOf(installId),
1695
+ machine: machineFingerprintOf()
1696
+ };
1468
1697
  } catch {
1469
1698
  const error = new PhaseError("machine", "invalid");
1470
1699
  error.detail = "读不到这台机器的硬件标识,无法绑定";
1471
1700
  throw error;
1472
1701
  }
1473
1702
  }
1703
+ function fingerprintFields(installId) {
1704
+ const prints = devicePrints(installId);
1705
+ const fields = {
1706
+ fingerprint: prints.current,
1707
+ legacyFingerprint: prints.legacy
1708
+ };
1709
+ if (prints.machine) fields.machineFingerprint = prints.machine;
1710
+ return fields;
1711
+ }
1474
1712
  const createKey = options.createKey || defaultKeyPair;
1475
1713
  const signPayload = options.sign || defaultSign;
1476
1714
  const installer = options.install;
@@ -1542,9 +1780,8 @@ function createController(options) {
1542
1780
  toolTitles: dispatch.toolTitles()
1543
1781
  };
1544
1782
  }
1545
- async function readSecret() {
1546
- const resolved = await credentials.resolve(CREDENTIAL_REF);
1547
- const value = typeof resolved === "string" ? resolved : resolved?.value;
1783
+ function parseStored(raw) {
1784
+ const value = typeof raw === "string" ? raw : raw && typeof raw === "object" && "value" in raw ? String(raw.value || "") : "";
1548
1785
  if (!value) return null;
1549
1786
  try {
1550
1787
  const data = JSON.parse(value);
@@ -1560,15 +1797,47 @@ function createController(options) {
1560
1797
  return null;
1561
1798
  }
1562
1799
  }
1563
- async function writeSecret(record) {
1564
- const secret = {
1800
+ function secretReady(secret) {
1801
+ return Boolean(secret?.privateJwk && secret.deviceId && secret.installId && secret.endpoint);
1802
+ }
1803
+ function secretText(record) {
1804
+ return JSON.stringify({
1565
1805
  installId: record.installId,
1566
1806
  deviceId: record.deviceId || "",
1567
1807
  endpoint: normalizeEndpoint(record.endpoint),
1568
1808
  privateJwk: record.privateJwk,
1569
1809
  publicJwk: record.publicJwk
1570
- };
1571
- await credentials.set(CREDENTIAL_REF, JSON.stringify(secret));
1810
+ });
1811
+ }
1812
+ async function readSecret() {
1813
+ const fromHost = parseStored(await credentials.resolve(CREDENTIAL_REF));
1814
+ if (secretReady(fromHost)) {
1815
+ if (deviceFile) {
1816
+ try {
1817
+ await deviceFile.write(secretText(fromHost));
1818
+ } catch {
1819
+ }
1820
+ }
1821
+ return fromHost;
1822
+ }
1823
+ if (!deviceFile) return fromHost;
1824
+ const fromFile = parseStored(await deviceFile.read());
1825
+ if (!secretReady(fromFile)) return fromHost;
1826
+ try {
1827
+ await credentials.set(CREDENTIAL_REF, secretText(fromFile));
1828
+ } catch {
1829
+ }
1830
+ return fromFile;
1831
+ }
1832
+ async function writeSecret(record) {
1833
+ const text2 = secretText(record);
1834
+ await credentials.set(CREDENTIAL_REF, text2);
1835
+ if (deviceFile) {
1836
+ try {
1837
+ await deviceFile.write(text2);
1838
+ } catch {
1839
+ }
1840
+ }
1572
1841
  }
1573
1842
  function clearSession() {
1574
1843
  memory.token = "";
@@ -1607,7 +1876,7 @@ function createController(options) {
1607
1876
  }
1608
1877
  return snapshot();
1609
1878
  }
1610
- async function request(path, init = {}) {
1879
+ async function request(path2, init = {}) {
1611
1880
  const method = init.method || "POST";
1612
1881
  const timeout = init.timeout ?? 3e4;
1613
1882
  const session = Boolean(init.session);
@@ -1618,7 +1887,7 @@ function createController(options) {
1618
1887
  "x-authinex-ds-version": version
1619
1888
  };
1620
1889
  if (memory.token) headers.authorization = `Bearer ${memory.token}`;
1621
- const run = () => fetchImpl(`${base}${path}`, {
1890
+ const run = () => fetchImpl(`${base}${path2}`, {
1622
1891
  method,
1623
1892
  headers,
1624
1893
  body: init.body === void 0 ? void 0 : JSON.stringify(init.body),
@@ -1660,7 +1929,7 @@ function createController(options) {
1660
1929
  const known = phaseError(error);
1661
1930
  if (known && !init.replayed && known.phase === "invalid" && await hasDeviceSecret()) {
1662
1931
  const back = await signInSaved();
1663
- if (back) return request(path, { ...init, replayed: true });
1932
+ if (back) return request(path2, { ...init, replayed: true });
1664
1933
  throw new PhaseError("session", "unreachable");
1665
1934
  }
1666
1935
  if (known) throw error;
@@ -1818,9 +2087,9 @@ function createController(options) {
1818
2087
  if (!validSlug(slug)) {
1819
2088
  return { ok: false, message: "技能目录名不合法,已放弃这次安装", path: "", slug: "" };
1820
2089
  }
1821
- const path = await writeSkill2(slug, exported.markdown);
2090
+ const path2 = await writeSkill2(slug, exported.markdown);
1822
2091
  await refreshInstalled();
1823
- return { ok: true, message: "已装到本机技能目录,新会话生效", path, slug };
2092
+ return { ok: true, message: "已装到本机技能目录,新会话生效", path: path2, slug };
1824
2093
  } catch {
1825
2094
  return { ok: false, message: "写到本机技能目录失败", path: "", slug: "" };
1826
2095
  } finally {
@@ -1847,8 +2116,7 @@ function createController(options) {
1847
2116
  const data = await request("/api/auth/ds-plugin/session", {
1848
2117
  body: {
1849
2118
  deviceId: secret.deviceId,
1850
- fingerprint: devicePrints(secret.installId).current,
1851
- legacyFingerprint: devicePrints(secret.installId).legacy,
2119
+ ...fingerprintFields(secret.installId),
1852
2120
  nonce: challenge.nonce,
1853
2121
  signature,
1854
2122
  appVersion: version
@@ -1880,7 +2148,8 @@ function createController(options) {
1880
2148
  signingIn = false;
1881
2149
  }
1882
2150
  }
1883
- async function restore() {
2151
+ let boot = null;
2152
+ async function loadBinding() {
1884
2153
  await dispatch.loadWork();
1885
2154
  const secret = await readSecret();
1886
2155
  if (!secret?.privateJwk || !secret.deviceId || !secret.installId || !secret.endpoint) {
@@ -1892,6 +2161,13 @@ function createController(options) {
1892
2161
  await signInSaved();
1893
2162
  return snapshot();
1894
2163
  }
2164
+ async function restore() {
2165
+ if (boot) return boot;
2166
+ boot = loadBinding().finally(() => {
2167
+ boot = null;
2168
+ });
2169
+ return boot;
2170
+ }
1895
2171
  async function bind(input) {
1896
2172
  if (bindFlight) return bindFlight;
1897
2173
  bindFlight = doBind(input).finally(() => {
@@ -1923,8 +2199,7 @@ function createController(options) {
1923
2199
  keyProtection: "software",
1924
2200
  clientKind,
1925
2201
  installId,
1926
- fingerprint: devicePrints(installId).current,
1927
- legacyFingerprint: devicePrints(installId).legacy,
2202
+ ...fingerprintFields(installId),
1928
2203
  deviceName: hostname2(),
1929
2204
  os: platform2(),
1930
2205
  appVersion: version
@@ -1949,8 +2224,15 @@ function createController(options) {
1949
2224
  const phase = known?.phase || "unreachable";
1950
2225
  fail(phase, known?.detail || "");
1951
2226
  memory.retryAfter = retryAfter;
1952
- const text2 = phrase(phase);
1953
- const message = phase === "unreachable" && memory.endpoint ? `${text2}(${memory.endpoint})` : text2;
2227
+ if (secretReady(existing) && existing.endpoint === endpoint) {
2228
+ const back = await signInSaved();
2229
+ if (back) {
2230
+ return { ok: true, message: "原来的绑定还在,继续用这台机器上的登录", state: snapshot() };
2231
+ }
2232
+ }
2233
+ const shown = String(memory.phase);
2234
+ const text2 = phrase(shown);
2235
+ const message = shown === "unreachable" && memory.endpoint ? `${text2}(${memory.endpoint})` : text2;
1954
2236
  return { ok: false, message, state: snapshot() };
1955
2237
  }
1956
2238
  }
@@ -1968,6 +2250,12 @@ function createController(options) {
1968
2250
  memory.endpoint = "";
1969
2251
  memory.phase = "unbound";
1970
2252
  await credentials.unset(CREDENTIAL_REF);
2253
+ if (deviceFile) {
2254
+ try {
2255
+ await deviceFile.clear();
2256
+ } catch {
2257
+ }
2258
+ }
1971
2259
  return { ok: true, state: snapshot() };
1972
2260
  }
1973
2261
  function sessionHeaders() {
@@ -1977,13 +2265,13 @@ function createController(options) {
1977
2265
  "x-authinex-ds-version": version
1978
2266
  };
1979
2267
  }
1980
- async function postPersonal(path, body, replayed = false) {
2268
+ async function postPersonal(path2, body, replayed = false) {
1981
2269
  const base = normalizeEndpoint(memory.endpoint);
1982
2270
  if (!base || !memory.token) return { ok: false, status: 0, data: { message: PHRASES.unreachable } };
1983
- const res = await postJson(fetchImpl, `${base}${path}`, sessionHeaders(), body);
2271
+ const res = await postJson(fetchImpl, `${base}${path2}`, sessionHeaders(), body);
1984
2272
  if (res.status === 401 && !replayed && await hasDeviceSecret()) {
1985
2273
  const back = await signInSaved();
1986
- if (back) return postPersonal(path, body, true);
2274
+ if (back) return postPersonal(path2, body, true);
1987
2275
  }
1988
2276
  return { ok: res.ok, status: res.status, data: res.data };
1989
2277
  }
@@ -2038,9 +2326,9 @@ function createController(options) {
2038
2326
  async function legacyOnesOptions(issueTypes, project) {
2039
2327
  const base = normalizeEndpoint(memory.endpoint);
2040
2328
  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";
2329
+ const path2 = issueTypes ? `/api/auth/me/accounts/ones/issue-types?projectUuid=${encodeURIComponent(project.trim())}` : "/api/auth/me/accounts/ones/projects";
2042
2330
  try {
2043
- const response = await fetchImpl(`${base}${path}`, {
2331
+ const response = await fetchImpl(`${base}${path2}`, {
2044
2332
  method: issueTypes ? "GET" : "POST",
2045
2333
  headers: {
2046
2334
  authorization: `Bearer ${memory.token}`,
@@ -2206,53 +2494,57 @@ function createController(options) {
2206
2494
  if (found.sha && sha !== found.sha) {
2207
2495
  return { ok: false, message: "校验值不一致,已放弃这次更新" };
2208
2496
  }
2209
- const dir = await mkdtemp(join2(tmpdir(), "authinex-ds-update-"));
2210
- const file = join2(dir, found.artifact);
2211
- await writeFile2(file, buffer);
2497
+ const dir = await mkdtemp(join3(tmpdir(), "authinex-ds-update-"));
2498
+ const file = join3(dir, found.artifact);
2499
+ await writeFile3(file, buffer);
2212
2500
  return { ok: true, message: `已下载 ${found.version}`, path: file, version: found.version, sha };
2213
2501
  } catch {
2214
2502
  return { ok: false, message: "下载更新包失败" };
2215
2503
  }
2216
2504
  }
2217
- async function handle(method, path, body, headers) {
2505
+ async function handle(method, path2, body, headers) {
2218
2506
  if (headers?.["x-authinex-ds"] !== "1") {
2219
2507
  return { status: 403, body: { detail: "forbidden" } };
2220
2508
  }
2221
- if (method === "GET" && path === "/authinex-ds/state") {
2509
+ if (method === "GET" && path2 === "/authinex-ds/state") {
2510
+ if (!memory.token && memory.phase !== "binding") {
2511
+ const saved = await readSecret();
2512
+ if (secretReady(saved)) await restore();
2513
+ }
2222
2514
  await dispatch.refreshStatus();
2223
2515
  return { status: 200, body: snapshot() };
2224
2516
  }
2225
- if (method === "GET" && path === "/authinex-ds/context") {
2517
+ if (method === "GET" && path2 === "/authinex-ds/context") {
2226
2518
  return { status: 200, body: dispatch.contextView() };
2227
2519
  }
2228
- if (method === "POST" && path === "/authinex-ds/context") {
2520
+ if (method === "POST" && path2 === "/authinex-ds/context") {
2229
2521
  const saved = await dispatch.saveContext(body || {});
2230
2522
  return { status: saved.ok ? 200 : 400, body: { ...saved, state: snapshot() } };
2231
2523
  }
2232
- if (method === "POST" && path === "/authinex-ds/bind") {
2524
+ if (method === "POST" && path2 === "/authinex-ds/bind") {
2233
2525
  const result = await bind({ key: String(body?.key || ""), endpoint: body?.endpoint });
2234
2526
  return { status: result.ok ? 200 : 400, body: { ...result.state, message: result.message || "" } };
2235
2527
  }
2236
- if (method === "POST" && path === "/authinex-ds/unbind") {
2528
+ if (method === "POST" && path2 === "/authinex-ds/unbind") {
2237
2529
  const result = await unbind();
2238
2530
  return { status: 200, body: { ...result.state, message: "已解除绑定" } };
2239
2531
  }
2240
- if (path === "/authinex-ds/accounts" && method === "GET") {
2532
+ if (path2 === "/authinex-ds/accounts" && method === "GET") {
2241
2533
  return { status: 200, body: snapshot().accounts };
2242
2534
  }
2243
- if (path === "/authinex-ds/accounts" && method === "PATCH") {
2535
+ if (path2 === "/authinex-ds/accounts" && method === "PATCH") {
2244
2536
  const result = await saveAccount(String(body?.provider || ""), body?.form || {});
2245
2537
  return { status: 200, body: result };
2246
2538
  }
2247
- if (path === "/authinex-ds/accounts/test" && method === "POST") {
2539
+ if (path2 === "/authinex-ds/accounts/test" && method === "POST") {
2248
2540
  const result = await testAccount(String(body?.provider || ""), body?.form || {});
2249
2541
  return { status: 200, body: result };
2250
2542
  }
2251
- if (path === "/authinex-ds/accounts/enabled" && method === "POST") {
2543
+ if (path2 === "/authinex-ds/accounts/enabled" && method === "POST") {
2252
2544
  const result = await setAccountEnabled(String(body?.provider || ""), Boolean(body?.enabled));
2253
2545
  return { status: result.ok ? 200 : 400, body: result };
2254
2546
  }
2255
- if (path === "/authinex-ds/accounts/options" && method === "POST") {
2547
+ if (path2 === "/authinex-ds/accounts/options" && method === "POST") {
2256
2548
  const result = await accountOptions(
2257
2549
  String(body?.provider || ""),
2258
2550
  String(body?.kind || ""),
@@ -2261,19 +2553,19 @@ function createController(options) {
2261
2553
  );
2262
2554
  return { status: 200, body: result };
2263
2555
  }
2264
- if (method === "POST" && path === "/authinex-ds/update/check") {
2556
+ if (method === "POST" && path2 === "/authinex-ds/update/check") {
2265
2557
  const result = await checkUpdate();
2266
2558
  return { status: 200, body: { ...result.state, updateMessage: result.message || "" } };
2267
2559
  }
2268
- if (method === "POST" && path === "/authinex-ds/update/apply") {
2560
+ if (method === "POST" && path2 === "/authinex-ds/update/apply") {
2269
2561
  const result = await applyUpdate();
2270
2562
  return { status: result.ok ? 200 : 400, body: { ...result } };
2271
2563
  }
2272
- if (method === "POST" && path === "/authinex-ds/update/download") {
2564
+ if (method === "POST" && path2 === "/authinex-ds/update/download") {
2273
2565
  const result = await downloadUpdate();
2274
2566
  return { status: result.ok ? 200 : 400, body: { ...result } };
2275
2567
  }
2276
- if (method === "POST" && path === "/authinex-ds/skills") {
2568
+ if (method === "POST" && path2 === "/authinex-ds/skills") {
2277
2569
  const result = await listSkills({
2278
2570
  q: String(body?.q || ""),
2279
2571
  page: Number(body?.page || 1),
@@ -2282,7 +2574,7 @@ function createController(options) {
2282
2574
  });
2283
2575
  return { status: 200, body: result };
2284
2576
  }
2285
- if (method === "POST" && path === "/authinex-ds/skills/import") {
2577
+ if (method === "POST" && path2 === "/authinex-ds/skills/import") {
2286
2578
  const result = await importSkill({
2287
2579
  markdown: String(body?.markdown || ""),
2288
2580
  name: String(body?.name || ""),
@@ -2290,11 +2582,11 @@ function createController(options) {
2290
2582
  });
2291
2583
  return { status: result.ok ? 200 : 400, body: result };
2292
2584
  }
2293
- if (method === "POST" && path === "/authinex-ds/skills/export") {
2585
+ if (method === "POST" && path2 === "/authinex-ds/skills/export") {
2294
2586
  const result = await exportSkill(body?.id);
2295
2587
  return { status: result.ok ? 200 : 400, body: result };
2296
2588
  }
2297
- if (method === "POST" && path === "/authinex-ds/skills/install") {
2589
+ if (method === "POST" && path2 === "/authinex-ds/skills/install") {
2298
2590
  const result = await installSkill(body?.id);
2299
2591
  return { status: result.ok ? 200 : 400, body: { ...result, state: snapshot() } };
2300
2592
  }
@@ -2441,6 +2733,7 @@ function apply(ctx) {
2441
2733
  // 技能只落 DSH 自己的技能目录,不进用户工作区、不碰仓库。
2442
2734
  writeSkill,
2443
2735
  listInstalled,
2736
+ deviceFile: defaultDeviceFile(),
2444
2737
  credentials: {
2445
2738
  resolve: () => ctx.credentials.resolve(ref),
2446
2739
  set: (_ref, value) => ctx.credentials.set(ref, value),
@@ -2494,10 +2787,10 @@ function apply(ctx) {
2494
2787
  disposed = true;
2495
2788
  for (const dispose of disposers.splice(0)) dispose();
2496
2789
  }, "authinex-ds: tools");
2497
- for (const path of PATHS) {
2790
+ for (const path2 of PATHS) {
2498
2791
  ctx.effect(() => ctx.webServer.register({
2499
2792
  kind: "exact",
2500
- path,
2793
+ path: path2,
2501
2794
  handler: async (req, res) => {
2502
2795
  const rejection = ctx.connection?.requestRejection?.(req);
2503
2796
  if (rejection !== void 0) {
@@ -2514,9 +2807,9 @@ function apply(ctx) {
2514
2807
  return;
2515
2808
  }
2516
2809
  }
2517
- const result = await controller.handle(method, path, body, headerMap(req));
2810
+ const result = await controller.handle(method, path2, body, headerMap(req));
2518
2811
  const payload = result.body;
2519
- if (path === "/authinex-ds/bind" || path === "/authinex-ds/unbind" || path === "/authinex-ds/accounts") {
2812
+ if (path2 === "/authinex-ds/bind" || path2 === "/authinex-ds/unbind" || path2 === "/authinex-ds/accounts") {
2520
2813
  try {
2521
2814
  registerTools();
2522
2815
  } catch (error) {
@@ -2531,7 +2824,7 @@ function apply(ctx) {
2531
2824
  }
2532
2825
  send(res, result.status, payload);
2533
2826
  }
2534
- }), `authinex-ds: ${path}`);
2827
+ }), `authinex-ds: ${path2}`);
2535
2828
  }
2536
2829
  void controller.restore().then(() => registerTools());
2537
2830
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authinex/dsh-plugin",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "DeepSeek 里的 AuthineX 插件:问知识库、查工单、检索源码、只读定位,并用本人账号建单",
5
5
  "type": "module",
6
6
  "icon": "./icon.svg",