@hcmai/cli 0.15.9 → 0.15.10

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/dist/index.js CHANGED
@@ -864,7 +864,11 @@ var StreamPresenter_exports = {};
864
864
  __export(StreamPresenter_exports, {
865
865
  StreamPresenter: () => StreamPresenter
866
866
  });
867
- import { createV4Reducer, truncateDisplay } from "@hcmai/sdk";
867
+ import {
868
+ CliErrorCode as CliErrorCode16,
869
+ createV4Reducer,
870
+ truncateDisplay
871
+ } from "@hcmai/sdk";
868
872
  var debug, StreamPresenter;
869
873
  var init_StreamPresenter = __esm({
870
874
  "src/streaming/StreamPresenter.ts"() {
@@ -1014,7 +1018,7 @@ var init_StreamPresenter = __esm({
1014
1018
  process.stdout.write(JSON.stringify(ev) + "\n");
1015
1019
  if (ev.type === "response.completed") return this.result("completed");
1016
1020
  if (ev.type === "response.interrupted") return this.result("interrupted");
1017
- if (ev.type === "response.failed") throw this.toError(ev);
1021
+ if (ev.type === "response.failed") throw await this.toError(ev);
1018
1022
  if (ev.type === "message.stop" && !ev.payload?.parentToolUseId) {
1019
1023
  this.sawRootStop = true;
1020
1024
  }
@@ -1028,7 +1032,7 @@ var init_StreamPresenter = __esm({
1028
1032
  }
1029
1033
  if (ev.type === "response.failed") {
1030
1034
  this.renderer.stopSpinner();
1031
- throw this.toError(ev);
1035
+ throw await this.toError(ev);
1032
1036
  }
1033
1037
  if (ev.type === "response.interrupted") {
1034
1038
  this.renderer.showInterrupted(ev.payload?.reason ?? "UNKNOWN");
@@ -1037,7 +1041,7 @@ var init_StreamPresenter = __esm({
1037
1041
  if (ev.type === "message.stop" && !ev.payload?.parentToolUseId) {
1038
1042
  this.reducer.handle(ev.type, ev.payload ?? {});
1039
1043
  const reason = ev.payload?.stopReason;
1040
- if (reason === "error") throw this.toError(ev);
1044
+ if (reason === "error") throw await this.toError(ev);
1041
1045
  if (reason === "interrupted") {
1042
1046
  this.renderer.showInterrupted("INTERRUPTED");
1043
1047
  return this.result("interrupted");
@@ -1086,9 +1090,12 @@ var init_StreamPresenter = __esm({
1086
1090
  return { status, traceId: this.traceId, streamId: this.streamId };
1087
1091
  }
1088
1092
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1089
- toError(ev) {
1090
- const err = new Error(ev.payload?.message ?? "stream failed");
1091
- err.code = ev.payload?.errorCode ?? ev.payload?.code;
1093
+ async toError(ev) {
1094
+ const fromConn = await this.opts.serverError?.() ?? null;
1095
+ const code = ev.payload?.errorCode ?? ev.payload?.code ?? fromConn?.code;
1096
+ const message = ev.payload?.message ?? fromConn?.message;
1097
+ const err = new Error(message ?? "stream failed");
1098
+ err.code = code ?? CliErrorCode16.STREAM_FAILED_NO_SERVER_CODE;
1092
1099
  err.traceId = ev.traceId;
1093
1100
  return err;
1094
1101
  }
@@ -2095,12 +2102,6 @@ async function runInkRepl(args) {
2095
2102
  const ctx = await getActiveAuthContextFromCli(args);
2096
2103
  assertDangerWrite(ctx.environmentSafety, "\u542F\u52A8\u4EA4\u4E92\u4F1A\u8BDD\uFF08\u53EF\u80FD\u6267\u884C\u4E1A\u52A1\u5199\u5165\uFF09");
2097
2104
  const client3 = HcmClient10.fromAuthContext(ctx);
2098
- const ws = new WsClient({
2099
- endpoint: conversationWebSocketEndpoint(ctx.endpoint),
2100
- getAccessToken: () => client3.getAccessToken(),
2101
- onTokenExpiring: () => client3.handleRefresh()
2102
- });
2103
- await ws.connect();
2104
2105
  let initialConversationId;
2105
2106
  if (args.resume && args.conversation) {
2106
2107
  throw new Error("--resume \u548C --conversation \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\uFF1B\u65B0\u547D\u4EE4\u8BF7\u7528 --resume <conversationId>");
@@ -2113,6 +2114,13 @@ async function runInkRepl(args) {
2113
2114
  } else if (args.conversation && args.conversation !== "NEW") {
2114
2115
  initialConversationId = args.conversation;
2115
2116
  }
2117
+ const ws = new WsClient({
2118
+ endpoint: conversationWebSocketEndpoint(ctx.endpoint),
2119
+ getAccessToken: () => client3.getAccessToken(),
2120
+ onTokenExpiring: () => client3.handleRefresh(),
2121
+ conversationId: initialConversationId
2122
+ });
2123
+ await ws.connect();
2116
2124
  const { waitUntilExit } = render(
2117
2125
  React3.createElement(ReplApp, {
2118
2126
  ws,
@@ -4570,6 +4578,15 @@ async function describeCommand(model, args) {
4570
4578
  exitWithError(e);
4571
4579
  }
4572
4580
  }
4581
+ function formatEnumValues(enums) {
4582
+ if (!enums?.length) return "";
4583
+ const items = enums.map((e) => {
4584
+ const raw = e.value ?? e.key;
4585
+ const shown = raw === void 0 || raw === null ? "?" : String(raw);
4586
+ return e.label && e.label !== shown ? `${shown}=${e.label}` : shown;
4587
+ });
4588
+ return `[${items.join("|")}]`;
4589
+ }
4573
4590
  function formatDescriptionTable(desc, verbose = false) {
4574
4591
  const lines = [`=== ${desc.model} ===`];
4575
4592
  if (desc.labels.zh_CN) lines.push(`zh_CN: ${desc.labels.zh_CN}`);
@@ -4577,7 +4594,8 @@ function formatDescriptionTable(desc, verbose = false) {
4577
4594
  lines.push(`fields (${desc.fields.length}):`);
4578
4595
  for (const f of desc.fields) {
4579
4596
  const req = f.required ? " required" : " ";
4580
- const lbl = verbose ? ` ${f.label ?? ""} ${f.description ?? ""}` : ` ${f.label ?? ""}`;
4597
+ const extras = verbose ? [f.label, f.description, formatEnumValues(f.enums)] : [f.label];
4598
+ const lbl = extras.filter((s) => s && s.length > 0).map((s) => ` ${s}`).join("");
4581
4599
  const type = f.i18n ? `${f.type} (i18n)` : f.type;
4582
4600
  const objectRef = f.object ? ` \u2192 ${f.object}` : "";
4583
4601
  lines.push(` ${f.name.padEnd(20)} ${type.padEnd(14)} ${req}${lbl}${objectRef}`);
@@ -4614,9 +4632,6 @@ function formatDescriptionTable(desc, verbose = false) {
4614
4632
  }
4615
4633
 
4616
4634
  // src/commands/chat.ts
4617
- init_exit();
4618
- init_impersonation_lifecycle();
4619
- init_auth_guard();
4620
4635
  import {
4621
4636
  HcmClient as HcmClient11,
4622
4637
  WsClient as WsClient2,
@@ -4635,7 +4650,7 @@ import {
4635
4650
  findLastAssistantTarget,
4636
4651
  SUPERSEDED_STATUS,
4637
4652
  CliError as CliError16,
4638
- CliErrorCode as CliErrorCode15,
4653
+ CliErrorCode as CliErrorCode17,
4639
4654
  parseInteractionRequest as parseInteractionRequest2,
4640
4655
  parseInteractionResolved as parseInteractionResolved2,
4641
4656
  buildConfirm as buildConfirm2,
@@ -4646,10 +4661,29 @@ import {
4646
4661
  } from "@hcmai/sdk";
4647
4662
  import chalk2 from "chalk";
4648
4663
  import * as fs5 from "fs/promises";
4664
+
4665
+ // src/streaming/streamFailureCode.ts
4666
+ import { CliErrorCode as CliErrorCode15 } from "@hcmai/sdk";
4667
+ var CLI_CODES = new Set(Object.values(CliErrorCode15));
4668
+ function cliCodeForStreamFailure(raw) {
4669
+ if (raw === void 0 || raw === null || raw === "") return CliErrorCode15.STREAM_FAILED_NO_SERVER_CODE;
4670
+ if (typeof raw === "string" && CLI_CODES.has(raw)) return raw;
4671
+ return CliErrorCode15.BUSINESS_RULE_VIOLATION;
4672
+ }
4673
+ function serverCodeOf(raw) {
4674
+ if (raw === void 0 || raw === null || raw === "") return void 0;
4675
+ if (typeof raw === "string" && CLI_CODES.has(raw)) return void 0;
4676
+ return String(raw);
4677
+ }
4678
+
4679
+ // src/commands/chat.ts
4680
+ init_exit();
4681
+ init_impersonation_lifecycle();
4682
+ init_auth_guard();
4649
4683
  function parseInjectOn(s) {
4650
4684
  const fail8 = (detail) => {
4651
4685
  throw new CliError16({
4652
- code: CliErrorCode15.INVALID_ARGUMENT,
4686
+ code: CliErrorCode17.INVALID_ARGUMENT,
4653
4687
  message: `--inject-on \u683C\u5F0F <eventType>:<action>[:<arg>]\uFF0Caction \u2208 {interrupt, steer}\uFF08steer \u5FC5\u987B\u5E26 content\uFF09\uFF1B${detail}\uFF0C\u6536\u5230 "${s}"`
4654
4688
  });
4655
4689
  };
@@ -4676,20 +4710,20 @@ function parseOnConfirm(s) {
4676
4710
  if (s === "reject") return { decision: "reject" };
4677
4711
  if (s.startsWith("reject:")) return { decision: "reject", reason: s.slice("reject:".length) };
4678
4712
  throw new CliError16({
4679
- code: CliErrorCode15.INVALID_ARGUMENT,
4713
+ code: CliErrorCode17.INVALID_ARGUMENT,
4680
4714
  message: `--on-confirm \u53D6\u503C approve | reject | reject:<reason>\uFF0C\u6536\u5230 "${s}"`
4681
4715
  });
4682
4716
  }
4683
4717
  function resolveResumeConversation(args) {
4684
4718
  if (args.resume && args.conversation) {
4685
4719
  throw new CliError16({
4686
- code: CliErrorCode15.INVALID_ARGUMENT,
4720
+ code: CliErrorCode17.INVALID_ARGUMENT,
4687
4721
  message: "--resume \u548C --conversation \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\uFF1B\u65B0\u547D\u4EE4\u8BF7\u7528 --resume <conversationId>"
4688
4722
  });
4689
4723
  }
4690
4724
  if (args.resume === "NEW") {
4691
4725
  throw new CliError16({
4692
- code: CliErrorCode15.INVALID_ARGUMENT,
4726
+ code: CliErrorCode17.INVALID_ARGUMENT,
4693
4727
  message: "--resume \u9700\u8981\u65E2\u5B58 conversationId\uFF1B\u65B0\u4F1A\u8BDD\u8BF7\u76F4\u63A5\u7701\u7565 --resume"
4694
4728
  });
4695
4729
  }
@@ -4701,7 +4735,7 @@ function parsePositiveInt(value, fallback, flag) {
4701
4735
  const n = Number(value ?? fallback);
4702
4736
  if (!Number.isInteger(n) || n <= 0) {
4703
4737
  throw new CliError16({
4704
- code: CliErrorCode15.INVALID_ARGUMENT,
4738
+ code: CliErrorCode17.INVALID_ARGUMENT,
4705
4739
  message: `${flag} \u9700\u8981\u6B63\u6574\u6570\uFF0C\u6536\u5230 "${value}"`
4706
4740
  });
4707
4741
  }
@@ -4725,20 +4759,20 @@ function resolveEventsConversation(args) {
4725
4759
  const eventConversationId = typeof args.events === "string" ? args.events.trim() : void 0;
4726
4760
  if (eventConversationId === "NEW") {
4727
4761
  throw new CliError16({
4728
- code: CliErrorCode15.INVALID_ARGUMENT,
4762
+ code: CliErrorCode17.INVALID_ARGUMENT,
4729
4763
  message: "--events \u9700\u8981\u65E2\u5B58 conversationId\uFF1B\u65B0\u4F1A\u8BDD\u6CA1\u6709\u53EF\u67E5\u8BE2\u7684\u4E8B\u4EF6\u6D41"
4730
4764
  });
4731
4765
  }
4732
4766
  if (eventConversationId && resumeConversationId && eventConversationId !== resumeConversationId) {
4733
4767
  throw new CliError16({
4734
- code: CliErrorCode15.INVALID_ARGUMENT,
4768
+ code: CliErrorCode17.INVALID_ARGUMENT,
4735
4769
  message: "--events <conversationId> \u4E0E --resume/--conversation \u6307\u5411\u4E0D\u540C\u4F1A\u8BDD\uFF1B\u8BF7\u53EA\u4FDD\u7559\u4E00\u4E2A id"
4736
4770
  });
4737
4771
  }
4738
4772
  const id = eventConversationId || resumeConversationId;
4739
4773
  if (!id) {
4740
4774
  throw new CliError16({
4741
- code: CliErrorCode15.INVALID_ARGUMENT,
4775
+ code: CliErrorCode17.INVALID_ARGUMENT,
4742
4776
  message: "\u67E5\u8BE2\u4E8B\u4EF6\u6D41\u8BF7\u4F20 `hcm chat --events <conversationId>`\uFF0C\u6216 `hcm chat --resume <conversationId> --events`"
4743
4777
  });
4744
4778
  }
@@ -4880,7 +4914,7 @@ async function printConversationEvents(conversationId, args) {
4880
4914
  async function printConversationList(args) {
4881
4915
  if (args.events || args.resume || args.conversation || args.regenerateFrom || args.promptFile) {
4882
4916
  throw new CliError16({
4883
- code: CliErrorCode15.INVALID_ARGUMENT,
4917
+ code: CliErrorCode17.INVALID_ARGUMENT,
4884
4918
  message: "--list \u53EA\u7528\u4E8E\u5217\u4F1A\u8BDD\uFF1B\u4E0D\u8981\u540C\u65F6\u4F20 --events/--resume/--conversation/--regenerate-from/--prompt-file"
4885
4919
  });
4886
4920
  }
@@ -4911,7 +4945,7 @@ async function chatCommand(prompt, args) {
4911
4945
  if (args.list) {
4912
4946
  if (prompt) {
4913
4947
  throw new CliError16({
4914
- code: CliErrorCode15.INVALID_ARGUMENT,
4948
+ code: CliErrorCode17.INVALID_ARGUMENT,
4915
4949
  message: "--list \u4E0D\u63A5\u53D7 prompt\uFF1B\u7528 `hcm chat --list` \u67E5\u770B\u6700\u8FD1\u4F1A\u8BDD"
4916
4950
  });
4917
4951
  }
@@ -4923,7 +4957,7 @@ async function chatCommand(prompt, args) {
4923
4957
  if (eventsConversationId) {
4924
4958
  if (prompt || args.promptFile || args.regenerateFrom || args.attach?.length) {
4925
4959
  throw new CliError16({
4926
- code: CliErrorCode15.INVALID_ARGUMENT,
4960
+ code: CliErrorCode17.INVALID_ARGUMENT,
4927
4961
  message: "--events \u662F\u53EA\u8BFB\u67E5\u8BE2\uFF1B\u4E0D\u8981\u540C\u65F6\u4F20 prompt/--prompt-file/--regenerate-from/--attach"
4928
4962
  });
4929
4963
  }
@@ -4942,14 +4976,14 @@ async function chatCommand(prompt, args) {
4942
4976
  regenerateFromSeq = Number(args.regenerateFrom);
4943
4977
  if (!Number.isInteger(regenerateFromSeq) || regenerateFromSeq <= 0) {
4944
4978
  throw new CliError16({
4945
- code: CliErrorCode15.INVALID_ARGUMENT,
4979
+ code: CliErrorCode17.INVALID_ARGUMENT,
4946
4980
  message: `--regenerate-from \u9700\u8981\u6B63\u6574\u6570 journal seq \u6216 last-assistant\uFF0C\u6536\u5230 "${args.regenerateFrom}"`
4947
4981
  });
4948
4982
  }
4949
4983
  }
4950
4984
  if (!requestedConversationId) {
4951
4985
  throw new CliError16({
4952
- code: CliErrorCode15.INVALID_ARGUMENT,
4986
+ code: CliErrorCode17.INVALID_ARGUMENT,
4953
4987
  message: "--regenerate-from \u5FC5\u987B\u914D\u5408 --resume <\u65E2\u5B58\u4F1A\u8BDD id>\uFF08\u91CD\u8DD1\u65E2\u5B58\u6BB5\uFF0C\u65E0\u65B0 prompt\uFF09"
4954
4988
  });
4955
4989
  }
@@ -4964,7 +4998,7 @@ async function chatCommand(prompt, args) {
4964
4998
  }
4965
4999
  if (prompt === void 0 || !prompt && !regenerateMode) {
4966
5000
  throw new CliError16({
4967
- code: CliErrorCode15.INVALID_ARGUMENT,
5001
+ code: CliErrorCode17.INVALID_ARGUMENT,
4968
5002
  message: "prompt is required (positional or --prompt-file)"
4969
5003
  });
4970
5004
  }
@@ -4987,7 +5021,7 @@ async function chatCommand(prompt, args) {
4987
5021
  const target = findLastAssistantTarget(items);
4988
5022
  if (target.seq == null) {
4989
5023
  throw new CliError16({
4990
- code: CliErrorCode15.BUSINESS_RULE_VIOLATION,
5024
+ code: CliErrorCode17.BUSINESS_RULE_VIOLATION,
4991
5025
  message: `--regenerate-from last-assistant \u627E\u4E0D\u5230\u53EF\u91CD\u8DD1\u7684 chat-text seq: conversation=${resumeConversationId}\uFF08${lastAssistantMissDetail(target)}\uFF09`
4992
5026
  });
4993
5027
  }
@@ -4996,7 +5030,11 @@ async function chatCommand(prompt, args) {
4996
5030
  const ws = new WsClient2({
4997
5031
  endpoint: wsUrl,
4998
5032
  getAccessToken: () => client3.getAccessToken(),
4999
- onTokenExpiring: () => client3.handleRefresh()
5033
+ onTokenExpiring: () => client3.handleRefresh(),
5034
+ // issue #257:握手带上会话 id,后端才会绑控制通道并重投上次留下的未决暂停。
5035
+ // 会话 id 在上面几十行就定下来了(--resume 或刚 createConversation 出来的),
5036
+ // 建连时它一定已经就位。
5037
+ conversationId: resumeConversationId
5000
5038
  });
5001
5039
  await ws.connect();
5002
5040
  const fmt = args.output ?? "text";
@@ -5017,7 +5055,13 @@ async function chatCommand(prompt, args) {
5017
5055
  });
5018
5056
  const presenter = new StreamPresenter2(renderer, {
5019
5057
  showToolCalls: args.showToolCalls !== false,
5020
- output: fmt
5058
+ output: fmt,
5059
+ // issue #255:真因走的是连接层帧 `{type:'error',code,message}`,不在 v4 事件里——
5060
+ // `MessageStopPayload` 这个 record 只有 (stopReason, parentToolUseId, *Tokens),
5061
+ // 没有 errorCode 也没有 message。handle 在下面才建(同一个 async 函数体内),但这个闭包只在
5062
+ // `presenter.consume(handle.events)` 里被调到,那时它早就有了。
5063
+ serverError: () => handle.serverError()
5064
+ // 可等待:真因晚一个 tick 才到(issue #255)
5021
5065
  });
5022
5066
  if (resumedExisting && isTty && fmt === "text" && !args.raw) {
5023
5067
  const { fetchConversationTimeline: fetchConversationTimeline3, buildResumeSummary: buildResumeSummary2 } = await import("@hcmai/sdk");
@@ -5208,10 +5252,12 @@ async function chatCommand(prompt, args) {
5208
5252
  } catch (e) {
5209
5253
  process.removeListener("SIGINT", sigintHandler);
5210
5254
  await ws.close();
5255
+ const serverCode = serverCodeOf(e.code);
5211
5256
  throw new CliError16({
5212
- code: e.code ?? CliErrorCode15.BUSINESS_RULE_VIOLATION,
5257
+ code: cliCodeForStreamFailure(e.code),
5213
5258
  message: e.message,
5214
- traceId: e.traceId ?? void 0
5259
+ traceId: e.traceId ?? void 0,
5260
+ ...serverCode ? { context: { responseCode: serverCode } } : {}
5215
5261
  });
5216
5262
  }
5217
5263
  }
@@ -5271,15 +5317,210 @@ async function chatCommand(prompt, args) {
5271
5317
  }
5272
5318
  }
5273
5319
 
5320
+ // src/commands/interactions.ts
5321
+ init_exit();
5322
+ init_auth_guard();
5323
+ import {
5324
+ CliError as CliError17,
5325
+ CliErrorCode as CliErrorCode18,
5326
+ DEFAULT_AGENT_ID as DEFAULT_AGENT_ID4,
5327
+ HcmClient as HcmClient12,
5328
+ WsClient as WsClient3,
5329
+ conversationWebSocketEndpoint as conversationWebSocketEndpoint3,
5330
+ assertDangerWrite as assertDangerWrite3,
5331
+ formatObject as formatObject10,
5332
+ formatRows as formatRows4,
5333
+ listPendingInteractions,
5334
+ loadConversationState,
5335
+ respondToInteraction
5336
+ } from "@hcmai/sdk";
5337
+ function resolveConversation(explicit, state) {
5338
+ const given = explicit?.trim();
5339
+ if (given) return { conversationId: given, source: "flag" };
5340
+ const last = state?.lastConversationId?.trim();
5341
+ if (last) return { conversationId: last, source: "state" };
5342
+ throw new CliError17({
5343
+ code: CliErrorCode18.INVALID_ARGUMENT,
5344
+ message: "\u4E0D\u77E5\u9053\u8BE5\u770B\u54EA\u4E2A\u4F1A\u8BDD\uFF1A\u6CA1\u6709\u4F20 --conversation\uFF0C\u672C env \u4E5F\u6CA1\u6709\u4E0A\u4E00\u6B21\u4F1A\u8BDD\u7684\u8BB0\u5F55",
5345
+ context: {
5346
+ nextStep: "\u7528 `hcm chat --list` \u627E\u5230\u4F1A\u8BDD id\uFF0C\u518D `hcm interactions list --conversation <id>`"
5347
+ }
5348
+ });
5349
+ }
5350
+ function decisionFor(action, args) {
5351
+ if (action === "approve") return { kind: "confirm" };
5352
+ if (action === "reject") return { kind: "reject", reason: args.reason?.trim() || void 0 };
5353
+ const answer = args.answer?.trim();
5354
+ if (!answer) {
5355
+ throw new CliError17({
5356
+ code: CliErrorCode18.INVALID_ARGUMENT,
5357
+ message: 'answer \u9700\u8981\u7B54\u6848\u6587\u672C\uFF1A--answer "<\u4F60\u7684\u56DE\u7B54>"',
5358
+ context: {
5359
+ nextStep: "\u9009\u9879\u578B\u8FFD\u95EE\u4E5F\u8981\u628A\u9009\u4E2D\u7684\u90A3\u9879\u539F\u6587\u5199\u8FDB --answer\uFF1B--choice \u53EA\u662F\u8865\u5145\uFF0C\u5355\u72EC\u7ED9\u4F1A\u88AB\u4E0B\u6E38\u5F53\u6210\u672A\u56DE\u7B54"
5360
+ }
5361
+ });
5362
+ }
5363
+ let choiceIndex;
5364
+ if (args.choice !== void 0 && String(args.choice).trim() !== "") {
5365
+ choiceIndex = Number(args.choice);
5366
+ if (!Number.isInteger(choiceIndex)) {
5367
+ throw new CliError17({
5368
+ code: CliErrorCode18.INVALID_ARGUMENT,
5369
+ message: `--choice \u8981\u6574\u6570\u4E0B\u6807\uFF0C\u6536\u5230\uFF1A${args.choice}`,
5370
+ context: { nextStep: "\u4E0B\u6807\u6765\u81EA ASK \u4E8B\u4EF6 choices \u6570\u7EC4\u7684\u4F4D\u7F6E\uFF08\u4ECE 0 \u8D77\uFF09" }
5371
+ });
5372
+ }
5373
+ }
5374
+ return { kind: "answer", answer, choiceIndex };
5375
+ }
5376
+ function renderPendingTable(rows2, conversationId) {
5377
+ if (!rows2.length) {
5378
+ return `\u4F1A\u8BDD ${conversationId} \u4E0A\u6CA1\u6709\u672A\u51B3\u7684\u6682\u505C\u3002
5379
+ \uFF08\u8FD9\u4E0E\u300C\u770B\u9519\u4F1A\u8BDD\u4E86\u300D\u662F\u540C\u4E00\u4E2A\u753B\u9762\uFF1A\u7528 \`hcm chat --list\` \u6838\u4E00\u4E0B id\uFF1B\u6682\u505C\u9ED8\u8BA4 5 \u5206\u949F\u8FC7\u671F\uFF0C\u8FC7\u671F\u7684\u4E0D\u4F1A\u51FA\u73B0\u5728\u8FD9\u91CC\u3002\uFF09`;
5380
+ }
5381
+ const table = formatRows4(
5382
+ rows2.map((r) => ({
5383
+ ID: r.interactionId,
5384
+ TYPE: r.type,
5385
+ TOOL: r.executorName || "-",
5386
+ RISK: r.riskLevel || "-",
5387
+ SUMMARY: r.operationSummary || "(\u65E0\u64CD\u4F5C\u6458\u8981)",
5388
+ EXPIRES: r.expired ? `${r.expiresAt || "-"} \u5DF2\u8FC7\u671F` : r.expiresAt || "-"
5389
+ })),
5390
+ { format: "table" }
5391
+ );
5392
+ const live = rows2.filter((r) => !r.expired);
5393
+ const kinds = new Set(live.map((r) => r.type));
5394
+ const verbs = [];
5395
+ if (kinds.has("CONFIRM")) {
5396
+ verbs.push(`hcm interactions approve <ID> --conversation ${conversationId}`, "\uFF08\u62D2\u7EDD\u6362 reject\uFF09");
5397
+ }
5398
+ if (kinds.has("ASK")) {
5399
+ verbs.push(`hcm interactions answer <ID> --answer "<\u4F60\u7684\u56DE\u7B54>" --conversation ${conversationId}`);
5400
+ }
5401
+ if (live.length && !verbs.length) {
5402
+ verbs.push(
5403
+ `\u672A\u8BC6\u522B\u7684\u6682\u505C\u7C7B\u578B ${[...kinds].join(" / ")}\uFF1A\u672C\u7248 CLI \u53EA\u5904\u7406 CONFIRM / ASK\uFF0C\u8BF7\u5728\u524D\u7AEF\u90A3\u5F20\u5361\u4E0A\u5904\u7406\uFF0C\u6216\u5347\u7EA7 CLI\uFF08hcm upgrade\uFF09`
5404
+ );
5405
+ }
5406
+ const hint = live.length ? `
5407
+ \u4E0B\u4E00\u6B65\uFF1A${verbs.join("\n ")}` : "\n\u5168\u90E8\u5DF2\u8FC7\u671F\uFF1A\u8FC7\u671F\u7684\u6682\u505C\u70B9\u4E0D\u52A8\u4E86\uFF0C\u91CD\u53D1\u539F\u59CB\u6307\u4EE4\u5373\u53EF\u3002";
5408
+ return `${table}
5409
+ \u5171 ${rows2.length} \u6761\uFF0C\u5176\u4E2D ${live.length} \u6761\u4ECD\u53EF\u5904\u7406\u3002${hint}`;
5410
+ }
5411
+ function renderOutcome(o) {
5412
+ const head = `${o.interactionId} \xB7 decision=${o.decision ?? "-"} status=${o.status ?? "-"}`;
5413
+ if (o.status === "SUPERSEDED") {
5414
+ return `${head}
5415
+ \u8FD9\u6761\u6682\u505C\u88AB\u65B0\u7684\u6682\u505C\u63A5\u7BA1\u4E86\uFF08\u7EED\u8DD1\u9014\u4E2D\u53C8\u5F39\u4E86\u4E00\u4E2A\uFF09\u2014\u2014\u4F60\u8981\u529E\u7684\u4E8B\u8FD8\u6CA1\u529E\u5B8C\u3002
5416
+ \u4E0B\u4E00\u6B65\uFF1A\u518D \`hcm interactions list\` \u4E00\u6B21\uFF0C\u5904\u7406\u65B0\u51FA\u73B0\u7684\u90A3\u6761\u3002`;
5417
+ }
5418
+ if (o.status === "FAILED") {
5419
+ return `${head}
5420
+ ${o.text ?? "(\u540E\u7AEF\u6CA1\u6709\u7ED9\u6536\u5C3E\u6B63\u6587)"}
5421
+ \u7EED\u8DD1\u5931\u8D25\uFF1A\u51B3\u5B9A\u5DF2\u7ECF\u53D7\u7406\uFF0C\u4F46\u6267\u884C\u6CA1\u6210\u529F\u3002`;
5422
+ }
5423
+ return `${head}
5424
+ ${o.text ?? "(\u540E\u7AEF\u6CA1\u6709\u7ED9\u6536\u5C3E\u6B63\u6587)"}`;
5425
+ }
5426
+ async function loadState(env2) {
5427
+ try {
5428
+ return await loadConversationState(env2);
5429
+ } catch {
5430
+ return null;
5431
+ }
5432
+ }
5433
+ function announceSource(source, conversationId, json) {
5434
+ if (source === "state" && !json) {
5435
+ process.stderr.write(`\u21BB \u672A\u6307\u5B9A --conversation\uFF0C\u7528\u672C env \u4E0A\u4E00\u6B21\u7684\u4F1A\u8BDD\uFF1A${conversationId}
5436
+ `);
5437
+ }
5438
+ }
5439
+ async function interactionsListCommand(args) {
5440
+ try {
5441
+ const ctx = await getActiveAuthContextFromCli(args);
5442
+ const { conversationId, source } = resolveConversation(
5443
+ args.conversation,
5444
+ await loadState(ctx.env)
5445
+ );
5446
+ const json = args.output === "json";
5447
+ announceSource(source, conversationId, json);
5448
+ const client3 = HcmClient12.fromAuthContext(ctx);
5449
+ const agentId = args.agent ?? DEFAULT_AGENT_ID4;
5450
+ const rows2 = await listPendingInteractions(client3.raw(), agentId, conversationId);
5451
+ if (json) {
5452
+ process.stdout.write(
5453
+ formatObject10(
5454
+ { conversationId, conversationIdSource: source, count: rows2.length, interactions: rows2 },
5455
+ { format: "json" }
5456
+ ) + "\n"
5457
+ );
5458
+ } else {
5459
+ process.stdout.write(renderPendingTable(rows2, conversationId) + "\n");
5460
+ }
5461
+ process.exitCode = 0;
5462
+ } catch (e) {
5463
+ exitWithError(e);
5464
+ }
5465
+ }
5466
+ async function interactionsRespondCommand(action, interactionId, args) {
5467
+ let ws;
5468
+ try {
5469
+ const decision = decisionFor(action, args);
5470
+ const ctx = await getActiveAuthContextFromCli(args);
5471
+ const { conversationId, source } = resolveConversation(
5472
+ args.conversation,
5473
+ await loadState(ctx.env)
5474
+ );
5475
+ const json = args.output === "json";
5476
+ announceSource(source, conversationId, json);
5477
+ assertDangerWrite3(ctx.environmentSafety, "\u56DE\u5E94\u6682\u505C\uFF08\u6279\u51C6\u4F1A\u771F\u7684\u6267\u884C\u90A3\u4E2A\u5199\u64CD\u4F5C\uFF09");
5478
+ const client3 = HcmClient12.fromAuthContext(ctx);
5479
+ ws = new WsClient3({
5480
+ endpoint: conversationWebSocketEndpoint3(ctx.endpoint),
5481
+ getAccessToken: () => client3.getAccessToken(),
5482
+ onTokenExpiring: () => client3.handleRefresh(),
5483
+ conversationId
5484
+ });
5485
+ await ws.connect();
5486
+ const timeoutMs = args.timeout ? Number(args.timeout) * 1e3 : void 0;
5487
+ if (timeoutMs !== void 0 && !Number.isFinite(timeoutMs)) {
5488
+ throw new CliError17({
5489
+ code: CliErrorCode18.INVALID_ARGUMENT,
5490
+ message: `--timeout \u8981\u79D2\u6570\uFF0C\u6536\u5230\uFF1A${args.timeout}`
5491
+ });
5492
+ }
5493
+ const outcome = await respondToInteraction(ws, {
5494
+ conversationId,
5495
+ interactionId,
5496
+ decision,
5497
+ timeoutMs,
5498
+ onAccepted: () => {
5499
+ if (!json) process.stderr.write("\xB7 \u5DF2\u53D7\u7406\uFF0C\u7EED\u8DD1\u4E2D\u2026\n");
5500
+ }
5501
+ });
5502
+ if (json) {
5503
+ process.stdout.write(formatObject10(outcome, { format: "json" }) + "\n");
5504
+ } else {
5505
+ process.stdout.write(renderOutcome(outcome) + "\n");
5506
+ }
5507
+ process.exitCode = outcome.status === "COMPLETED" ? 0 : 1;
5508
+ } catch (e) {
5509
+ exitWithError(e);
5510
+ } finally {
5511
+ await ws?.close();
5512
+ }
5513
+ }
5514
+
5274
5515
  // src/commands/download.ts
5275
5516
  init_auth_guard();
5276
5517
  init_exit();
5277
5518
  import { downloadDocument } from "@hcmai/sdk";
5278
- import { HcmClient as HcmClient12 } from "@hcmai/sdk";
5519
+ import { HcmClient as HcmClient13 } from "@hcmai/sdk";
5279
5520
  async function downloadCommand(documentId, args) {
5280
5521
  try {
5281
5522
  const ctx = await getActiveAuthContextFromCli(args);
5282
- const client3 = HcmClient12.fromAuthContext(ctx);
5523
+ const client3 = HcmClient13.fromAuthContext(ctx);
5283
5524
  const saved = await downloadDocument(client3.raw(), { documentId }, args.output);
5284
5525
  process.stdout.write(saved + "\n");
5285
5526
  process.exitCode = 0;
@@ -5301,15 +5542,15 @@ init_auth_guard();
5301
5542
  init_exit();
5302
5543
  import {
5303
5544
  deleteDocument,
5304
- HcmClient as HcmClient13,
5545
+ HcmClient as HcmClient14,
5305
5546
  fromAxiosError as fromAxiosError11,
5306
- formatObject as formatObject10
5547
+ formatObject as formatObject11
5307
5548
  } from "@hcmai/sdk";
5308
5549
  async function documentDeleteCommand(documentId, args) {
5309
5550
  try {
5310
- const client3 = HcmClient13.fromAuthContext(await getActiveAuthContextFromCli(args));
5551
+ const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
5311
5552
  await deleteDocument(client3.raw(), documentId);
5312
- process.stdout.write(formatObject10({ success: true, documentId }, { format: args.output ?? "json" }) + "\n");
5553
+ process.stdout.write(formatObject11({ success: true, documentId }, { format: args.output ?? "json" }) + "\n");
5313
5554
  process.exitCode = 0;
5314
5555
  } catch (e) {
5315
5556
  const err = e;
@@ -5321,7 +5562,7 @@ async function documentDeleteCommand(documentId, args) {
5321
5562
  // src/commands/trace.ts
5322
5563
  init_exit();
5323
5564
  init_auth_guard();
5324
- import { HcmClient as HcmClient14, formatObject as formatObject11, formatRows as formatRows4, fromAxiosError as fromAxiosError12 } from "@hcmai/sdk";
5565
+ import { HcmClient as HcmClient15, formatObject as formatObject12, formatRows as formatRows5, fromAxiosError as fromAxiosError12 } from "@hcmai/sdk";
5325
5566
  function parsePositiveInt2(value, fallback, flag) {
5326
5567
  const n = Number(value ?? fallback);
5327
5568
  if (!Number.isInteger(n) || n <= 0) {
@@ -5374,7 +5615,7 @@ function printRecent(data, limit) {
5374
5615
  OPERATION: short(t.rootOperation, 36),
5375
5616
  TRACE: t.traceId ?? "-"
5376
5617
  }));
5377
- process.stdout.write(formatRows4(rows2, { format: "table" }) + "\n");
5618
+ process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5378
5619
  process.stdout.write(`Showing ${rows2.length} trace${rows2.length === 1 ? "" : "s"}.
5379
5620
  `);
5380
5621
  process.stdout.write("next: hcm trace <traceId> | hcm trace <traceId> --events | hcm trace <traceId> --raw\n");
@@ -5405,7 +5646,7 @@ function printTraceDetail(traceId, agg) {
5405
5646
  OPERATION: short(sp.operation, 48)
5406
5647
  }));
5407
5648
  process.stdout.write("\nTempo spans:\n");
5408
- process.stdout.write(formatRows4(rows2, { format: "table" }) + "\n");
5649
+ process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5409
5650
  if (spans.length > rows2.length) process.stdout.write(`... ${spans.length - rows2.length} more spans
5410
5651
  `);
5411
5652
  } else if (tempo?.reason) {
@@ -5420,7 +5661,7 @@ Tempo: ${tempo.reason}
5420
5661
  MESSAGE: short(log.msg ?? log.exception, 90)
5421
5662
  }));
5422
5663
  process.stdout.write("\nLoki logs:\n");
5423
- process.stdout.write(formatRows4(rows2, { format: "table" }) + "\n");
5664
+ process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5424
5665
  if (logs.length > rows2.length) process.stdout.write(`... ${logs.length - rows2.length} more logs
5425
5666
  `);
5426
5667
  } else if (loki?.reason) {
@@ -5458,7 +5699,7 @@ function printTraceEvents(traceId, agg) {
5458
5699
  }));
5459
5700
  process.stdout.write(`trace events: ${traceId}
5460
5701
  `);
5461
- process.stdout.write(formatRows4(rows2, { format: "table" }) + "\n");
5702
+ process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5462
5703
  }
5463
5704
  async function listRecentTraces(client3, limit) {
5464
5705
  const http = client3.raw();
@@ -5506,7 +5747,7 @@ async function listRecentConversationsPg(client3, limit) {
5506
5747
  TOKENS: c.totalTokens ?? "-",
5507
5748
  CONV: c.id ?? "-"
5508
5749
  }));
5509
- process.stdout.write(formatRows4(table, { format: "table" }) + "\n");
5750
+ process.stdout.write(formatRows5(table, { format: "table" }) + "\n");
5510
5751
  process.stdout.write(`Showing ${rows2.length} conversation${rows2.length === 1 ? "" : "s"}\uFF08PG \u89C6\u56FE\uFF09\u3002
5511
5752
  `);
5512
5753
  process.stdout.write("next: hcm trace --conv <CONV>\uFF08\u770B\u8BE5\u4F1A\u8BDD LLM \u9010\u8C03\u7528\uFF0C\u542B\u59D4\u6D3E\u5B50\u4F1A\u8BDD\uFF09\n");
@@ -5589,7 +5830,7 @@ ${" ".repeat(node.depth)}\u2514\u2500 \u59D4\u6D3E \u2192 ${node.label} \xB7 ${
5589
5830
 
5590
5831
  `);
5591
5832
  if (table.length) {
5592
- process.stdout.write(formatRows4(table, { format: "table" }) + "\n");
5833
+ process.stdout.write(formatRows5(table, { format: "table" }) + "\n");
5593
5834
  } else {
5594
5835
  const why = envelopeReason(node.envelope);
5595
5836
  process.stdout.write(`\uFF08\u65E0 LLM \u8C03\u7528${why ? ` \xB7 ${short(why, 60)}` : ""}\uFF09
@@ -5716,14 +5957,14 @@ async function gatherLlmTraceTree(http, rootConvId, maxDepth = 3) {
5716
5957
  }
5717
5958
  async function traceCommand(traceId, args) {
5718
5959
  try {
5719
- const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
5960
+ const client3 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
5720
5961
  const http = client3.raw();
5721
5962
  const convId = args.conv ?? (args.llmCalls ? traceId ?? void 0 : void 0);
5722
5963
  if (convId) {
5723
5964
  if (args.raw || args.output === "json" || args.output === "yaml") {
5724
5965
  const body = await fetchLlmTrace(http, convId);
5725
5966
  const fmt = args.raw ? "json" : args.output;
5726
- process.stdout.write(formatObject11(body.rows, { format: fmt }) + "\n");
5967
+ process.stdout.write(formatObject12(body.rows, { format: fmt }) + "\n");
5727
5968
  if (!body.rows.length) {
5728
5969
  for (const line of describeLlmTraceEmpty(convId, body.envelope)) {
5729
5970
  process.stderr.write(line + "\n");
@@ -5748,12 +5989,12 @@ async function traceCommand(traceId, args) {
5748
5989
  const resp = await http.get(`/api/trace/${traceId}`);
5749
5990
  const agg = resp.data ?? {};
5750
5991
  if (args.raw) {
5751
- process.stdout.write(formatObject11(agg, { format: "json" }) + "\n");
5992
+ process.stdout.write(formatObject12(agg, { format: "json" }) + "\n");
5752
5993
  process.exitCode = 0;
5753
5994
  return;
5754
5995
  }
5755
5996
  if (args.output === "json" || args.output === "yaml") {
5756
- process.stdout.write(formatObject11(agg, { format: args.output }) + "\n");
5997
+ process.stdout.write(formatObject12(agg, { format: args.output }) + "\n");
5757
5998
  process.exitCode = 0;
5758
5999
  return;
5759
6000
  }
@@ -5764,7 +6005,7 @@ async function traceCommand(traceId, args) {
5764
6005
  exitWithError(`Span #${args.span} \u8D8A\u754C\uFF08\u5171 ${spans.length} \u6761 Tempo span\uFF09`);
5765
6006
  return;
5766
6007
  }
5767
- process.stdout.write(formatObject11(spans[idx], { format: "yaml" }) + "\n");
6008
+ process.stdout.write(formatObject12(spans[idx], { format: "yaml" }) + "\n");
5768
6009
  process.exitCode = 0;
5769
6010
  return;
5770
6011
  }
@@ -5788,21 +6029,21 @@ async function traceCommand(traceId, args) {
5788
6029
  init_exit();
5789
6030
  init_auth_guard();
5790
6031
  import {
5791
- HcmClient as HcmClient15,
5792
- formatObject as formatObject12,
6032
+ HcmClient as HcmClient16,
6033
+ formatObject as formatObject13,
5793
6034
  fromAxiosError as fromAxiosError13,
5794
6035
  getCacheStats,
5795
6036
  clearModelCache,
5796
6037
  clearMetaCache
5797
6038
  } from "@hcmai/sdk";
5798
6039
  async function withClient(args, fn) {
5799
- const client3 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
6040
+ const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
5800
6041
  return fn(client3);
5801
6042
  }
5802
6043
  function emit(result, args, human) {
5803
6044
  const fmt = args.output ?? "json";
5804
6045
  if (fmt !== "json") process.stdout.write(human + "\n");
5805
- process.stdout.write(formatObject12(result, { format: fmt }) + "\n");
6046
+ process.stdout.write(formatObject13(result, { format: fmt }) + "\n");
5806
6047
  process.exitCode = 0;
5807
6048
  return;
5808
6049
  }
@@ -5846,8 +6087,8 @@ init_exit();
5846
6087
  init_auth_guard();
5847
6088
  import { readFileSync as readFileSync3 } from "fs";
5848
6089
  import {
5849
- HcmClient as HcmClient16,
5850
- formatObject as formatObject13,
6090
+ HcmClient as HcmClient17,
6091
+ formatObject as formatObject14,
5851
6092
  fromAxiosError as fromAxiosError14,
5852
6093
  scriptDryRun,
5853
6094
  validateScriptManifest,
@@ -5855,13 +6096,13 @@ import {
5855
6096
  getScriptTask
5856
6097
  } from "@hcmai/sdk";
5857
6098
  async function withClient2(args, fn) {
5858
- const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6099
+ const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
5859
6100
  return fn(client3);
5860
6101
  }
5861
6102
  function emit2(result, args, human) {
5862
6103
  const fmt = args.output ?? "json";
5863
6104
  if (fmt !== "json") process.stdout.write(human + "\n");
5864
- process.stdout.write(formatObject13(result, { format: fmt }) + "\n");
6105
+ process.stdout.write(formatObject14(result, { format: fmt }) + "\n");
5865
6106
  process.exitCode = 0;
5866
6107
  return;
5867
6108
  }
@@ -5957,8 +6198,8 @@ async function scriptTaskCommand(taskId, args) {
5957
6198
  init_exit();
5958
6199
  init_auth_guard();
5959
6200
  import {
5960
- HcmClient as HcmClient17,
5961
- formatObject as formatObject14,
6201
+ HcmClient as HcmClient18,
6202
+ formatObject as formatObject15,
5962
6203
  fromAxiosError as fromAxiosError15,
5963
6204
  uploadDocument as uploadDocument2
5964
6205
  } from "@hcmai/sdk";
@@ -5966,7 +6207,7 @@ var DEFAULT_UPLOAD_CATEGORY = "attachment";
5966
6207
  async function uploadCommand(filePath, args) {
5967
6208
  try {
5968
6209
  const ctx = await getActiveAuthContextFromCli(args);
5969
- const client3 = HcmClient17.fromAuthContext(ctx);
6210
+ const client3 = HcmClient18.fromAuthContext(ctx);
5970
6211
  const meta2 = await uploadDocument2(
5971
6212
  client3.raw(),
5972
6213
  filePath,
@@ -5979,7 +6220,7 @@ async function uploadCommand(filePath, args) {
5979
6220
  `
5980
6221
  );
5981
6222
  }
5982
- process.stdout.write(formatObject14(meta2, { format: fmt }) + "\n");
6223
+ process.stdout.write(formatObject15(meta2, { format: fmt }) + "\n");
5983
6224
  process.exitCode = 0;
5984
6225
  return;
5985
6226
  } catch (e) {
@@ -6001,8 +6242,8 @@ async function uploadCommand(filePath, args) {
6001
6242
  init_exit();
6002
6243
  init_auth_guard();
6003
6244
  import {
6004
- HcmClient as HcmClient18,
6005
- formatObject as formatObject15,
6245
+ HcmClient as HcmClient19,
6246
+ formatObject as formatObject16,
6006
6247
  fromAxiosError as fromAxiosError16,
6007
6248
  packDataPackage,
6008
6249
  installDataPackageArtifactAsync,
@@ -6028,7 +6269,7 @@ async function datapackagePackCommand(packageDir, args) {
6028
6269
  `
6029
6270
  );
6030
6271
  }
6031
- process.stdout.write(formatObject15(result, { format: fmt }) + "\n");
6272
+ process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
6032
6273
  process.exitCode = 0;
6033
6274
  return;
6034
6275
  } catch (e) {
@@ -6038,7 +6279,7 @@ async function datapackagePackCommand(packageDir, args) {
6038
6279
  async function datapackageInstallCommand(artifactPath, args) {
6039
6280
  try {
6040
6281
  const ctx = await getActiveAuthContextFromCli(args);
6041
- const client3 = HcmClient18.fromAuthContext(ctx);
6282
+ const client3 = HcmClient19.fromAuthContext(ctx);
6042
6283
  const fmt = args.output ?? "json";
6043
6284
  const human = fmt !== "json";
6044
6285
  const accepted = await installDataPackageArtifactAsync(client3, artifactPath, {
@@ -6115,7 +6356,7 @@ async function datapackageInstallCommand(artifactPath, args) {
6115
6356
  async function datapackageStatusCommand(runId, args) {
6116
6357
  try {
6117
6358
  const ctx = await getActiveAuthContextFromCli(args);
6118
- const client3 = HcmClient18.fromAuthContext(ctx);
6359
+ const client3 = HcmClient19.fromAuthContext(ctx);
6119
6360
  const run3 = await fetchInstallRun(client3, runId);
6120
6361
  const fmt = args.output ?? "json";
6121
6362
  if (!run3) {
@@ -6155,7 +6396,7 @@ function truncateTail(text, max) {
6155
6396
  return text.length <= max ? text : "\u2026" + text.slice(text.length - max + 1);
6156
6397
  }
6157
6398
  function emit3(payload, fmt) {
6158
- process.stdout.write(formatObject15(payload, { format: fmt }) + "\n");
6399
+ process.stdout.write(formatObject16(payload, { format: fmt }) + "\n");
6159
6400
  }
6160
6401
 
6161
6402
  // src/commands/skills.ts
@@ -6179,18 +6420,18 @@ import {
6179
6420
  resolveAllSkillsInstallOrder,
6180
6421
  matchSkills,
6181
6422
  filterByStage,
6182
- formatObject as formatObject18,
6423
+ formatObject as formatObject19,
6183
6424
  fromAxiosError as fromAxiosError17,
6184
6425
  loadGlobalConfig as loadGlobalConfig6,
6185
6426
  discoverProjectEnv as discoverProjectEnv3,
6186
6427
  resolveEnvContext as resolveEnvContext5,
6187
6428
  printResolvedEnvironment as printResolvedEnvironment4,
6188
- CliError as CliError20,
6189
- CliErrorCode as CliErrorCode19
6429
+ CliError as CliError21,
6430
+ CliErrorCode as CliErrorCode22
6190
6431
  } from "@hcmai/sdk";
6191
6432
 
6192
6433
  // src/commands/skills-catalog.ts
6193
- import { flattenSkills, CliError as CliError17, CliErrorCode as CliErrorCode16 } from "@hcmai/sdk";
6434
+ import { flattenSkills, CliError as CliError18, CliErrorCode as CliErrorCode19 } from "@hcmai/sdk";
6194
6435
  var CLI_CATEGORY_KEY = "cli-operations";
6195
6436
  var CLI_CATEGORY_NAME = "CLI \u64CD\u4F5C";
6196
6437
  function chironEntry(skill) {
@@ -6235,8 +6476,8 @@ var SOURCE_FILTERS = ["cli", "chiron", "all"];
6235
6476
  function parseSourceFilter(raw) {
6236
6477
  if (raw === void 0) return "all";
6237
6478
  if (SOURCE_FILTERS.includes(raw)) return raw;
6238
- throw new CliError17({
6239
- code: CliErrorCode16.INVALID_ARGUMENT,
6479
+ throw new CliError18({
6480
+ code: CliErrorCode19.INVALID_ARGUMENT,
6240
6481
  message: `--source \u53EA\u8BA4 ${SOURCE_FILTERS.join(" / ")}\uFF0C\u6536\u5230 "${raw}"\u3002\uFF08\`local\` \u4E0D\u662F\u53D6\u503C\uFF1A\u6CA1\u6709\u54EA\u4E00\u8D9F\u4F1A\u53BB\u300C\u626B local \u6765\u6E90\u300D\uFF0Cinstall --from \u88C5\u7684\u90A3\u4E9B\u5728\u4EFB\u4F55 --source \u4E0B\u90FD\u5355\u5217\u3001\u90FD\u4E0D\u53C2\u4E0E\u5347\u7EA7\u3002\uFF09`
6241
6482
  });
6242
6483
  }
@@ -6388,11 +6629,11 @@ import { execFileSync } from "child_process";
6388
6629
  import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync as readFileSync4, rmSync, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
6389
6630
  import os2 from "os";
6390
6631
  import path4 from "path";
6391
- import { CASES_REPO_SLUG, CASES_REPO_URL, CNB_ORIGIN, CliError as CliError18, CliErrorCode as CliErrorCode17, formatObject as formatObject16 } from "@hcmai/sdk";
6632
+ import { CASES_REPO_SLUG, CASES_REPO_URL, CNB_ORIGIN, CliError as CliError19, CliErrorCode as CliErrorCode20, formatObject as formatObject17 } from "@hcmai/sdk";
6392
6633
  var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() || path4.join(os2.homedir(), ".cache", "hcm", "chiron-cases");
6393
6634
  var INDEX_CACHE = () => path4.join(casesCacheDir(), "index.json");
6394
6635
  var INDEX_TTL_MS = 60 * 60 * 1e3;
6395
- var fail5 = (message, nextStep) => new CliError18({ code: CliErrorCode17.INVALID_ARGUMENT, message, context: { nextStep } });
6636
+ var fail5 = (message, nextStep) => new CliError19({ code: CliErrorCode20.INVALID_ARGUMENT, message, context: { nextStep } });
6396
6637
  var run = (cmd, args, opts = {}) => execFileSync(cmd, args, { encoding: "utf8", maxBuffer: 1 << 26, ...opts });
6397
6638
  function parseCnbEnvelope(raw, what) {
6398
6639
  const trimmed = raw.trim();
@@ -6487,7 +6728,7 @@ function matchTag(c, fp) {
6487
6728
  }
6488
6729
  function emit4(args, data, text) {
6489
6730
  if (args.output === "json" || args.output === "yaml") {
6490
- process.stdout.write(formatObject16(data, { format: args.output }) + "\n");
6731
+ process.stdout.write(formatObject17(data, { format: args.output }) + "\n");
6491
6732
  } else {
6492
6733
  process.stdout.write(text() + "\n");
6493
6734
  }
@@ -6761,14 +7002,14 @@ async function inspectJira() {
6761
7002
  // src/commands/skills-bundled.ts
6762
7003
  import { promises as fsp } from "fs";
6763
7004
  import * as path7 from "path";
6764
- import { CliError as CliError19, CliErrorCode as CliErrorCode18, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
7005
+ import { CliError as CliError20, CliErrorCode as CliErrorCode21, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
6765
7006
 
6766
7007
  // src/commands/skills-manifest.ts
6767
7008
  import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as statSync4, existsSync as existsSync2 } from "fs";
6768
7009
  import { createHash as createHash3 } from "crypto";
6769
7010
  import * as path6 from "path";
6770
7011
  import { fileURLToPath } from "url";
6771
- import { formatObject as formatObject17, parseSkillFrontmatter } from "@hcmai/sdk";
7012
+ import { formatObject as formatObject18, parseSkillFrontmatter } from "@hcmai/sdk";
6772
7013
  function collectCommandSurface(root) {
6773
7014
  const out = [];
6774
7015
  const walk = (cmd, prefix) => {
@@ -6844,7 +7085,7 @@ function buildManifest(root, skillsDir = bundledSkillsDir()) {
6844
7085
  }
6845
7086
  function skillsManifestCommand(root, args) {
6846
7087
  const manifest2 = buildManifest(root);
6847
- process.stdout.write(formatObject17(manifest2, { format: args.output ?? "json" }) + "\n");
7088
+ process.stdout.write(formatObject18(manifest2, { format: args.output ?? "json" }) + "\n");
6848
7089
  }
6849
7090
  function str(v) {
6850
7091
  return typeof v === "string" && v ? v : void 0;
@@ -6858,8 +7099,8 @@ function listBundledSkills(dir = bundledSkillsDir()) {
6858
7099
  return collectBundledSkills(dir);
6859
7100
  }
6860
7101
  function unreachable(id, detail) {
6861
- return new CliError19({
6862
- code: CliErrorCode18.SKILL_SOURCE_UNREACHABLE,
7102
+ return new CliError20({
7103
+ code: CliErrorCode21.SKILL_SOURCE_UNREACHABLE,
6863
7104
  message: `\u88C5\u5728\u8FD9\u4EFD CLI \u91CC\u7684\u6280\u80FD\u8D44\u6E90\u8BFB\u4E0D\u5230\uFF08${detail}\uFF09\uFF0C\u91CD\u88C5 @hcmai/cli\u3002
6864
7105
  \u6280\u80FD id\uFF1A${id}\uFF1B\u627E\u7684\u4F4D\u7F6E\uFF1A${bundledSkillsDir()}`
6865
7106
  });
@@ -6916,8 +7157,8 @@ async function resolveBundledClosure(targetId, dir = bundledSkillsDir()) {
6916
7157
  const visit = async (id) => {
6917
7158
  if (state.get(id) === "done") return;
6918
7159
  if (state.get(id) === "visiting") {
6919
- throw new CliError19({
6920
- code: CliErrorCode18.INVALID_ARGUMENT,
7160
+ throw new CliError20({
7161
+ code: CliErrorCode21.INVALID_ARGUMENT,
6921
7162
  message: `\u81EA\u5E26\u6280\u80FD\u4F9D\u8D56\u6210\u73AF\uFF1A${[...stack, id].join(" \u2192 ")}`
6922
7163
  });
6923
7164
  }
@@ -6974,7 +7215,7 @@ async function resolveEndpoint(args) {
6974
7215
  const env2 = resolved.config;
6975
7216
  if (env2?.endpoint) return env2.endpoint.replace(/\/+$/, "");
6976
7217
  } catch (e) {
6977
- if (e?.code !== CliErrorCode19.ENV_NOT_FOUND) throw e;
7218
+ if (e?.code !== CliErrorCode22.ENV_NOT_FOUND) throw e;
6978
7219
  const project = await discoverProjectEnv3();
6979
7220
  const name = args.env ?? project?.config.default;
6980
7221
  const fromProject = name ? project?.config.environments[name] : void 0;
@@ -6987,8 +7228,8 @@ async function resolveEndpoint(args) {
6987
7228
  }
6988
7229
  throw e;
6989
7230
  }
6990
- throw new CliError20({
6991
- code: CliErrorCode19.MISSING_FLAG,
7231
+ throw new CliError21({
7232
+ code: CliErrorCode22.MISSING_FLAG,
6992
7233
  message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\uFF08\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u5148 login\uFF09"
6993
7234
  });
6994
7235
  }
@@ -7005,8 +7246,8 @@ function decideTrackedEndpoint(options) {
7005
7246
  }
7006
7247
  if (!recorded) {
7007
7248
  if (!current) {
7008
- throw new CliError20({
7009
- code: CliErrorCode19.MISSING_FLAG,
7249
+ throw new CliError21({
7250
+ code: CliErrorCode22.MISSING_FLAG,
7010
7251
  message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002\uFF08\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u4E0D\u9700\u8981\u5148 login\uFF09"
7011
7252
  });
7012
7253
  }
@@ -7088,8 +7329,8 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
7088
7329
  const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
7089
7330
  const conflicts = detectIdConflicts(catalog);
7090
7331
  if (conflicts.ids.length > 0) {
7091
- throw new CliError20({
7092
- code: CliErrorCode19.SKILL_ID_CONFLICT,
7332
+ throw new CliError21({
7333
+ code: CliErrorCode22.SKILL_ID_CONFLICT,
7093
7334
  message: conflictMessage(conflicts.ids, endpoint ?? "(\u672A\u77E5\u73AF\u5883)")
7094
7335
  });
7095
7336
  }
@@ -7120,7 +7361,7 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
7120
7361
  }
7121
7362
  if (fmt === "json" || fmt === "yaml") {
7122
7363
  process.stdout.write(
7123
- formatObject18(
7364
+ formatObject19(
7124
7365
  {
7125
7366
  ...manifest2 ?? {},
7126
7367
  categories: cats,
@@ -7209,7 +7450,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
7209
7450
  const legacy = await detectLegacyFlatLayout(layout);
7210
7451
  const legacyState = legacy ? await readSkillsState(legacy) : void 0;
7211
7452
  if (fmt === "json" || fmt === "yaml") {
7212
- process.stdout.write(formatObject18({
7453
+ process.stdout.write(formatObject19({
7213
7454
  baseDir: layout.baseDir,
7214
7455
  target: layout.target,
7215
7456
  all: false,
@@ -7268,7 +7509,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
7268
7509
  const shown = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
7269
7510
  const groupOf = (kind) => kind === "cli" ? "CLI \u81EA\u5E26" : kind === "local" ? "\u672C\u9879\u76EE\u81EA\u5DF1\u7684\uFF08hcm-skills/local/\uFF09" : "\u777F\u620E\u6280\u80FD\u5E93";
7270
7511
  if (fmt === "json" || fmt === "yaml") {
7271
- process.stdout.write(formatObject18({
7512
+ process.stdout.write(formatObject19({
7272
7513
  baseDir: layout.baseDir,
7273
7514
  target: layout.target,
7274
7515
  endpoint: state?.endpoint,
@@ -7379,7 +7620,7 @@ async function skillsInstallCommand(id, args) {
7379
7620
  const tracked = decideTrackedEndpoint({
7380
7621
  explicit: Boolean(args.endpoint || args.env),
7381
7622
  current: await resolveEndpoint(args).catch((error) => {
7382
- if (error instanceof CliError20 && error.code === CliErrorCode19.NO_ACTIVE_ENV) return void 0;
7623
+ if (error instanceof CliError21 && error.code === CliErrorCode22.NO_ACTIVE_ENV) return void 0;
7383
7624
  throw error;
7384
7625
  }),
7385
7626
  recorded: (await readSkillsState(layout.baseDir))?.endpoint
@@ -7393,8 +7634,8 @@ async function skillsInstallCommand(id, args) {
7393
7634
  const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
7394
7635
  const conflicts = detectIdConflicts(catalog);
7395
7636
  if (conflicts.ids.length > 0) {
7396
- throw new CliError20({
7397
- code: CliErrorCode19.SKILL_ID_CONFLICT,
7637
+ throw new CliError21({
7638
+ code: CliErrorCode22.SKILL_ID_CONFLICT,
7398
7639
  message: conflictMessage(conflicts.ids, endpoint ?? "(\u672A\u77E5\u73AF\u5883)")
7399
7640
  });
7400
7641
  }
@@ -7475,7 +7716,7 @@ async function skillsInstallCommand(id, args) {
7475
7716
  const legacyState = await readSkillsState(legacyForCheck);
7476
7717
  const count = Object.keys(legacyState?.skills ?? {}).length;
7477
7718
  if (fmtCheck === "json" || fmtCheck === "yaml") {
7478
- process.stdout.write(formatObject18({
7719
+ process.stdout.write(formatObject19({
7479
7720
  dryRun: true,
7480
7721
  legacyFlatLayout: { dir: legacyForCheck, skills: count },
7481
7722
  wouldMigrate: true,
@@ -7493,7 +7734,7 @@ async function skillsInstallCommand(id, args) {
7493
7734
  }
7494
7735
  const would = documents.map((d) => d.id).sort();
7495
7736
  if (fmtCheck === "json" || fmtCheck === "yaml") {
7496
- process.stdout.write(formatObject18({
7737
+ process.stdout.write(formatObject19({
7497
7738
  dryRun: true,
7498
7739
  baseDir: layout.baseDir,
7499
7740
  target: layout.target,
@@ -7528,7 +7769,7 @@ async function skillsInstallCommand(id, args) {
7528
7769
  const agents = agentIndexes[0]?.status;
7529
7770
  const fmt = args.output ?? "table";
7530
7771
  if (fmt === "json" || fmt === "yaml") {
7531
- process.stdout.write(formatObject18({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, agentIndexes, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
7772
+ process.stdout.write(formatObject19({ ...result, all, target_agent: layout.target, agentsFile: layout.agentsFile, agents, agentIndexes, conflictCheck: conflictNote ? { checked: false, note: conflictNote } : { checked: true } }, { format: fmt }) + "\n");
7532
7773
  } else {
7533
7774
  const headline = all ? `\u2705 \u5168\u90E8 ${requestedIds.length} \u4E2A\u6280\u80FD \u2192 ${result.baseDir}` : `\u2705 ${id} \u2192 ${path8.join(result.baseDir, id, "SKILL.md")}`;
7534
7775
  process.stdout.write(`${headline}
@@ -7673,8 +7914,8 @@ async function resolveSkillPath(layout, id) {
7673
7914
  ...layout.localDir ? [`${layout.localDir}/${id}/SKILL.md`] : [],
7674
7915
  `${layout.baseDir}/${id}/SKILL.md`
7675
7916
  ];
7676
- throw new CliError20({
7677
- code: CliErrorCode19.INVALID_ARGUMENT,
7917
+ throw new CliError21({
7918
+ code: CliErrorCode22.INVALID_ARGUMENT,
7678
7919
  message: `\u8FD9\u4E2A\u9879\u76EE\u91CC\u6CA1\u6709\u6280\u80FD ${id}\u3002\u627E\u8FC7\uFF1A
7679
7920
  ${looked.join("\n ")}
7680
7921
  \u770B\u6709\u54EA\u4E9B\uFF1Ahcm skills list --installed\uFF1B\u6CA1\u88C5\u5C31\u5148 hcm chiron skills sync\u3002`
@@ -7686,7 +7927,7 @@ async function skillsPathCommand(id, args) {
7686
7927
  const resolved = await resolveSkillPath(layout, id);
7687
7928
  const fmt = args.output ?? "table";
7688
7929
  if (fmt === "json" || fmt === "yaml") {
7689
- process.stdout.write(formatObject18(resolved, { format: fmt }) + "\n");
7930
+ process.stdout.write(formatObject19(resolved, { format: fmt }) + "\n");
7690
7931
  process.exitCode = 0;
7691
7932
  return;
7692
7933
  }
@@ -8107,15 +8348,15 @@ function parsePruneMax(raw) {
8107
8348
  const text = typeof raw === "number" ? void 0 : raw.trim();
8108
8349
  const n = text === void 0 ? raw : text === "" ? Number.NaN : Number(text);
8109
8350
  if (!Number.isInteger(n) || n < 0) {
8110
- throw new CliError20({
8111
- code: CliErrorCode19.INVALID_ARGUMENT,
8351
+ throw new CliError21({
8352
+ code: CliErrorCode22.INVALID_ARGUMENT,
8112
8353
  message: `--prune-max \u8981\u4E00\u4E2A\u975E\u8D1F\u6574\u6570\uFF0C\u6536\u5230 ${JSON.stringify(raw)}\u30020 = \u8FD9\u4E00\u8D9F\u4E00\u4EFD\u90FD\u522B\u6E05\uFF1B\u4E0D\u7ED9\u8FD9\u4E2A\u53C2\u6570\u65F6\u4E0A\u9650\u662F\u300C${PRUNE_DEFAULT_MAX} \u4E0E\u5728\u518C\u4EFD\u6570\u4E00\u534A\u53D6\u5C0F\u300D\u3002`
8113
8354
  });
8114
8355
  }
8115
8356
  return n;
8116
8357
  }
8117
8358
  function invalid(message) {
8118
- return new CliError20({ code: CliErrorCode19.INVALID_ARGUMENT, message });
8359
+ return new CliError21({ code: CliErrorCode22.INVALID_ARGUMENT, message });
8119
8360
  }
8120
8361
  var PRUNE_DEFAULT_MAX = 5;
8121
8362
  var PRUNE_MAX_SHARE = 0.5;
@@ -8343,8 +8584,8 @@ async function skillsUpdateCommand(args) {
8343
8584
  const layout = await resolveInstallLayout(args);
8344
8585
  const state = await readSkillsState(layout.baseDir);
8345
8586
  if (!state || Object.keys(state.skills).length === 0) {
8346
- throw new CliError20({
8347
- code: CliErrorCode19.INVALID_ARGUMENT,
8587
+ throw new CliError21({
8588
+ code: CliErrorCode22.INVALID_ARGUMENT,
8348
8589
  message: `${path8.join(layout.baseDir, SKILLS_STATE_FILE)} \u4E0D\u5B58\u5728\u6216\u4E3A\u7A7A \u2014\u2014 \u8FD9\u4E2A\u76EE\u5F55\u4E0B\u8FD8\u6CA1\u6709\u7528\u672C CLI \u88C5\u8FC7\u6280\u80FD\u3002\u5148\u8DD1 \`hcm chiron skills sync\`\uFF1B\u5982\u679C\u6280\u80FD\u662F\u624B\u5DE5\u62F7\u8FDB\u6765\u7684\uFF0C\u540C\u6B65\u4E00\u6B21\u5373\u53EF\u63A5\u7BA1\u5347\u7EA7\u3002`
8349
8590
  });
8350
8591
  }
@@ -8352,7 +8593,7 @@ async function skillsUpdateCommand(args) {
8352
8593
  const endpoint = decideTrackedEndpoint({
8353
8594
  explicit: Boolean(args.endpoint || args.env),
8354
8595
  current: await resolveEndpoint(args).catch((error) => {
8355
- if (error instanceof CliError20 && error.code === CliErrorCode19.NO_ACTIVE_ENV) return void 0;
8596
+ if (error instanceof CliError21 && error.code === CliErrorCode22.NO_ACTIVE_ENV) return void 0;
8356
8597
  throw error;
8357
8598
  }),
8358
8599
  recorded: state.endpoint
@@ -8400,7 +8641,7 @@ async function skillsUpdateCommand(args) {
8400
8641
  const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
8401
8642
  const fmt = args.output ?? "table";
8402
8643
  if (fmt === "json" || fmt === "yaml") {
8403
- process.stdout.write(formatObject18({
8644
+ process.stdout.write(formatObject19({
8404
8645
  endpoint,
8405
8646
  baseDir: layout.baseDir,
8406
8647
  target: layout.target,
@@ -8627,19 +8868,19 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
8627
8868
  import {
8628
8869
  bootstrapTenant,
8629
8870
  resetTenant,
8630
- HcmClient as HcmClient19,
8871
+ HcmClient as HcmClient20,
8631
8872
  readSessionPrincipal as readSessionPrincipal2,
8632
8873
  discoverProjectEnv as discoverProjectEnv4,
8633
- assertDangerWrite as assertDangerWrite3,
8874
+ assertDangerWrite as assertDangerWrite4,
8634
8875
  normalizeOrigin as normalizeOrigin4,
8635
8876
  createHttpClient as createHttpClient3,
8636
- formatObject as formatObject19,
8877
+ formatObject as formatObject20,
8637
8878
  fromAxiosError as fromAxiosError18,
8638
8879
  loadGlobalConfig as loadGlobalConfig7,
8639
8880
  resolveEnvContext as resolveEnvContext6,
8640
8881
  printResolvedEnvironment as printResolvedEnvironment5,
8641
- CliError as CliError21,
8642
- CliErrorCode as CliErrorCode20
8882
+ CliError as CliError22,
8883
+ CliErrorCode as CliErrorCode23
8643
8884
  } from "@hcmai/sdk";
8644
8885
  init_exit();
8645
8886
  init_auth_guard();
@@ -8647,27 +8888,27 @@ async function tenantResetCommand(args) {
8647
8888
  let attempted = false;
8648
8889
  try {
8649
8890
  const fmt = args.output ?? "json";
8650
- if (!["table", "json", "yaml"].includes(fmt)) throw new CliError21({
8651
- code: CliErrorCode20.INVALID_ARGUMENT,
8891
+ if (!["table", "json", "yaml"].includes(fmt)) throw new CliError22({
8892
+ code: CliErrorCode23.INVALID_ARGUMENT,
8652
8893
  message: "--output \u53D6\u503C table | json | yaml"
8653
8894
  });
8654
8895
  const ctx = await getActiveAuthContextFromCli(args);
8655
- if (ctx.impersonation) throw new CliError21({
8656
- code: CliErrorCode20.SCOPE_FORBIDDEN,
8896
+ if (ctx.impersonation) throw new CliError22({
8897
+ code: CliErrorCode23.SCOPE_FORBIDDEN,
8657
8898
  message: "\u79DF\u6237\u91CD\u7F6E\u4E0D\u63A5\u53D7\u4EE3\u7406\u4F1A\u8BDD\uFF0C\u8BF7\u7528\u5185\u7F6E admin \u7684\u76F4\u63A5\u767B\u5F55\u8EAB\u4EFD\u3002"
8658
8899
  });
8659
8900
  const { endpoint, tenantId, env: env2 } = ctx;
8660
8901
  const safety = ctx.environmentSafety ? { ...ctx.environmentSafety } : void 0;
8661
- assertDangerWrite3(safety, "\u91CD\u7F6E\u79DF\u6237 PostgreSQL \u6570\u636E");
8662
- const accessToken = await HcmClient19.fromAuthContext(ctx).getAccessToken();
8663
- if (!accessToken) throw new CliError21({ code: CliErrorCode20.AUTH_FAILED, message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
8664
- const client3 = new HcmClient19({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
8902
+ assertDangerWrite4(safety, "\u91CD\u7F6E\u79DF\u6237 PostgreSQL \u6570\u636E");
8903
+ const accessToken = await HcmClient20.fromAuthContext(ctx).getAccessToken();
8904
+ if (!accessToken) throw new CliError22({ code: CliErrorCode23.AUTH_FAILED, message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
8905
+ const client3 = new HcmClient20({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
8665
8906
  client3.raw().defaults.maxRedirects = 0;
8666
8907
  client3.raw().defaults.__skipRetry = true;
8667
8908
  const principal = await readSessionPrincipal2(client3.raw());
8668
8909
  if (principal.tenantId !== tenantId || principal.username !== "admin" || !principal.roles?.includes("admin.system") || principal.impersonated || principal.actSub != null) {
8669
- throw new CliError21({
8670
- code: CliErrorCode20.SCOPE_FORBIDDEN,
8910
+ throw new CliError22({
8911
+ code: CliErrorCode23.SCOPE_FORBIDDEN,
8671
8912
  message: `\u5B9E\u9645\u8EAB\u4EFD ${principal.username} / \u79DF\u6237 ${principal.tenantId} \u4E0D\u662F\u76EE\u6807 ${tenantId} \u7684\u76F4\u63A5\u5185\u7F6E\u7BA1\u7406\u5458\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002`,
8672
8913
  context: { nextStep: `hcm login --env ${env2} \u767B\u5F55\u76EE\u6807\u79DF\u6237\u7684\u5185\u7F6E admin \u540E\u91CD\u8BD5\u3002` }
8673
8914
  });
@@ -8676,13 +8917,13 @@ async function tenantResetCommand(args) {
8676
8917
  \u5C06\u4E0D\u53EF\u9006\u5730\u5220\u9664 PostgreSQL \u4E1A\u52A1\u6570\u636E\u5E76\u6062\u590D\u51FA\u5382\u57FA\u7EBF\uFF1BMongo\u3001\u6587\u6863\u5BF9\u8C61\u4E0E\u5916\u90E8\u5411\u91CF\u4E0D\u5904\u7406\u3001\u4E0D\u6838\u9A8C\u3002
8677
8918
  `);
8678
8919
  if (!args.yes) {
8679
- if (!process.stdin.isTTY) throw new CliError21({
8680
- code: CliErrorCode20.INVALID_ARGUMENT,
8920
+ if (!process.stdin.isTTY) throw new CliError22({
8921
+ code: CliErrorCode23.INVALID_ARGUMENT,
8681
8922
  message: "\u975E\u4EA4\u4E92\u8F93\u5165\u672A\u786E\u8BA4\u79DF\u6237\u91CD\u7F6E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002",
8682
8923
  context: { nextStep: "\u6838\u5BF9\u4E0A\u8FF0\u76EE\u6807\u4E0E\u5F71\u54CD\u540E\u663E\u5F0F\u52A0 --yes\uFF1B\u5371\u9669\u73AF\u5883\u8FD8\u9700\u8981 --allow-danger\u3002" }
8683
8924
  });
8684
8925
  const answer = await promptText("\u786E\u8BA4\u91CD\u7F6E\u8FD9\u4E2A\u79DF\u6237\uFF1F\u8F93\u5165 yes \u7EE7\u7EED\uFF1A", process.stderr);
8685
- if (!/^y(es)?$/i.test(answer)) throw new CliError21({ code: CliErrorCode20.INVALID_ARGUMENT, message: "\u5DF2\u53D6\u6D88\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
8926
+ if (!/^y(es)?$/i.test(answer)) throw new CliError22({ code: CliErrorCode23.INVALID_ARGUMENT, message: "\u5DF2\u53D6\u6D88\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
8686
8927
  }
8687
8928
  attempted = true;
8688
8929
  const receipt = await resetTenant(client3.raw(), tenantId);
@@ -8694,7 +8935,7 @@ PostgreSQL \u6838\u9A8C=${receipt.pgVerified}\uFF1B\u6574\u4F53\u6838\u9A8C=${re
8694
8935
  \u4E0B\u4E00\u6B65\uFF1A${receipt.nonPgSurface.nextStep}
8695
8936
  `
8696
8937
  );
8697
- process.stdout.write(formatObject19(receipt, { format: fmt }) + "\n");
8938
+ process.stdout.write(formatObject20(receipt, { format: fmt }) + "\n");
8698
8939
  const quote = (value) => "'" + value.replace(/'/g, "'\\''") + "'";
8699
8940
  process.stderr.write(`\u91CD\u7F6E\u5DF2\u6E05\u7406\u5F53\u524D\u4F1A\u8BDD\uFF1B\u8BF7 hcm login --env ${quote(env2)} --endpoint ${quote(endpoint)} --tenant ${quote(tenantId)} \u91CD\u65B0\u767B\u5F55\uFF0C\u518D\u67E5\u8BE2\u6216\u88C5\u5305\u3002
8700
8941
  `);
@@ -8712,8 +8953,8 @@ async function resolveBootstrapKey(args, stdinTaken) {
8712
8953
  if (fromEnv) return fromEnv;
8713
8954
  if (args.bootstrapKeyStdin) {
8714
8955
  if (stdinTaken) {
8715
- throw new CliError21({
8716
- code: CliErrorCode20.INVALID_ARGUMENT,
8956
+ throw new CliError22({
8957
+ code: CliErrorCode23.INVALID_ARGUMENT,
8717
8958
  message: "--bootstrap-key-stdin \u4E0E --admin-password-stdin \u4E0D\u80FD\u540C\u65F6\u7528\uFF08stdin \u53EA\u6709\u4E00\u8DEF\uFF09\uFF1B\u628A\u5176\u4E2D\u4E00\u4E2A\u6539\u8D70 HCM_BOOTSTRAP_KEY \u73AF\u5883\u53D8\u91CF\u6216\u4EA4\u4E92\u8F93\u5165"
8718
8959
  });
8719
8960
  }
@@ -8744,8 +8985,8 @@ async function resolveEndpoint2(args) {
8744
8985
  printResolvedEnvironment5(resolved);
8745
8986
  const env2 = resolved.config;
8746
8987
  if (!env2?.endpoint) {
8747
- throw new CliError21({
8748
- code: CliErrorCode20.MISSING_FLAG,
8988
+ throw new CliError22({
8989
+ code: CliErrorCode23.MISSING_FLAG,
8749
8990
  message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`"
8750
8991
  });
8751
8992
  }
@@ -8754,15 +8995,15 @@ async function resolveEndpoint2(args) {
8754
8995
  async function tenantBootstrapCommand(args) {
8755
8996
  try {
8756
8997
  if (!args.tenantId || !args.adminUsername) {
8757
- throw new CliError21({
8758
- code: CliErrorCode20.MISSING_FLAG,
8998
+ throw new CliError22({
8999
+ code: CliErrorCode23.MISSING_FLAG,
8759
9000
  message: "--tenant-id \u4E0E --admin-username \u5FC5\u586B"
8760
9001
  });
8761
9002
  }
8762
9003
  const endpoint = await resolveEndpoint2(args);
8763
9004
  const project = await discoverProjectEnv4();
8764
9005
  const protectedNames = project ? Object.entries(project.config.environments).filter(([, candidate]) => candidate.danger && candidate.endpoint === normalizeOrigin4(endpoint)).map(([name]) => name) : [];
8765
- assertDangerWrite3({ name: protectedNames.join(", "), danger: protectedNames.length > 0, allowDanger: args.allowDanger }, "\u5F00\u901A\u79DF\u6237");
9006
+ assertDangerWrite4({ name: protectedNames.join(", "), danger: protectedNames.length > 0, allowDanger: args.allowDanger }, "\u5F00\u901A\u79DF\u6237");
8766
9007
  if (args.endpoint) process.stderr.write(`\u2192 ${endpoint} \xB7 \u79DF\u6237 ${args.tenantId} \xB7 \u8EAB\u4EFD bootstrap key\uFF08\u6765\u81EA --endpoint\uFF09
8767
9008
  `);
8768
9009
  const { pwd, stdinTaken } = await resolveAdminPassword(args);
@@ -8796,7 +9037,7 @@ async function tenantBootstrapCommand(args) {
8796
9037
  `
8797
9038
  );
8798
9039
  }
8799
- process.stdout.write(formatObject19(result, { format: fmt }) + "\n");
9040
+ process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
8800
9041
  process.exitCode = 0;
8801
9042
  return;
8802
9043
  } catch (e) {
@@ -8816,8 +9057,8 @@ import { promises as fsp3 } from "fs";
8816
9057
  import os4 from "os";
8817
9058
  import nodePath from "path";
8818
9059
  import {
8819
- HcmClient as HcmClient20,
8820
- formatObject as formatObject20,
9060
+ HcmClient as HcmClient21,
9061
+ formatObject as formatObject21,
8821
9062
  fromAxiosError as fromAxiosError19,
8822
9063
  listTenantMeta,
8823
9064
  getTenantMeta,
@@ -8828,14 +9069,14 @@ import {
8828
9069
  formatMetaIssues,
8829
9070
  explainJacksonError,
8830
9071
  META_SCHEMA_SOURCE_COMMIT,
8831
- CliError as CliError22,
8832
- CliErrorCode as CliErrorCode21
9072
+ CliError as CliError23,
9073
+ CliErrorCode as CliErrorCode24
8833
9074
  } from "@hcmai/sdk";
8834
9075
  init_exit();
8835
9076
  init_impersonation_lifecycle();
8836
9077
  init_auth_guard();
8837
9078
  async function client2(args) {
8838
- return HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
9079
+ return HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
8839
9080
  }
8840
9081
  function formatMetaForbiddenMessage(mode = "write") {
8841
9082
  if (mode === "read") {
@@ -8866,7 +9107,7 @@ async function metaListCommand(args) {
8866
9107
  const fmt = args.output ?? "json";
8867
9108
  if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
8868
9109
  `);
8869
- process.stdout.write(formatObject20(items, { format: fmt }) + "\n");
9110
+ process.stdout.write(formatObject21(items, { format: fmt }) + "\n");
8870
9111
  process.exitCode = 0;
8871
9112
  return;
8872
9113
  } catch (e) {
@@ -8954,8 +9195,8 @@ async function verifyAfterWrite(c, path19) {
8954
9195
  async function metaSetCommand(path19, args) {
8955
9196
  try {
8956
9197
  if (!args.file) {
8957
- throw new CliError22({
8958
- code: CliErrorCode21.MISSING_FLAG,
9198
+ throw new CliError23({
9199
+ code: CliErrorCode24.MISSING_FLAG,
8959
9200
  message: "--file <path> \u5FC5\u586B\uFF08\u4ECE\u6587\u4EF6\u8BFB\u53D6 meta \u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
8960
9201
  });
8961
9202
  }
@@ -8987,7 +9228,7 @@ async function metaSetCommand(path19, args) {
8987
9228
  const dryFmt = args.output;
8988
9229
  if (dryFmt === "json" || dryFmt === "yaml") {
8989
9230
  process.stdout.write(
8990
- formatObject20(
9231
+ formatObject21(
8991
9232
  { dryRun: true, path: path19, bytes: Buffer.byteLength(content), content },
8992
9233
  { format: dryFmt }
8993
9234
  ) + "\n"
@@ -9070,7 +9311,7 @@ ${content}
9070
9311
  process.stdout.write(" \u5DF2\u6E05\u5143\u6570\u636E\u7F13\u5B58\uFF0C\u5E76\u771F\u8BFB\u4E86\u4E00\u904D\uFF1A\u670D\u52A1\u7AEF\u8BFB\u5F97\u52A8 \u2714\n");
9071
9312
  }
9072
9313
  }
9073
- process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
9314
+ process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
9074
9315
  process.exitCode = 0;
9075
9316
  return;
9076
9317
  } catch (e) {
@@ -9092,7 +9333,7 @@ async function metaDeleteCommand(path19, args) {
9092
9333
  const fmt = args.output ?? "json";
9093
9334
  if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path19}
9094
9335
  `);
9095
- process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
9336
+ process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
9096
9337
  process.exitCode = 0;
9097
9338
  return;
9098
9339
  } catch (e) {
@@ -9102,8 +9343,8 @@ async function metaDeleteCommand(path19, args) {
9102
9343
  async function metaValidateCommand(path19, args) {
9103
9344
  try {
9104
9345
  if (!args.file) {
9105
- throw new CliError22({
9106
- code: CliErrorCode21.MISSING_FLAG,
9346
+ throw new CliError23({
9347
+ code: CliErrorCode24.MISSING_FLAG,
9107
9348
  message: "--file <path> \u5FC5\u586B\uFF08\u8981\u9A8C\u7684\u90A3\u4EFD\u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
9108
9349
  });
9109
9350
  }
@@ -9118,7 +9359,7 @@ async function metaValidateCommand(path19, args) {
9118
9359
  const fmt = args.output ?? "table";
9119
9360
  if (fmt === "json" || fmt === "yaml") {
9120
9361
  process.stdout.write(
9121
- formatObject20(
9362
+ formatObject21(
9122
9363
  {
9123
9364
  path: path19,
9124
9365
  kind: result.kind,
@@ -9159,10 +9400,10 @@ import {
9159
9400
  createWorkspaceFile,
9160
9401
  deleteWorkspaceFile,
9161
9402
  formatMiniVerifyReport,
9162
- formatObject as formatObject21,
9163
- formatRows as formatRows5,
9403
+ formatObject as formatObject22,
9404
+ formatRows as formatRows6,
9164
9405
  getMiniStatus,
9165
- HcmClient as HcmClient21,
9406
+ HcmClient as HcmClient22,
9166
9407
  initMiniAppProject,
9167
9408
  inferMiniWritableTemplateOptionsFromModel,
9168
9409
  listWorkspaceFiles,
@@ -9219,7 +9460,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
9219
9460
  var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
9220
9461
  async function workspaceListCommand(args) {
9221
9462
  try {
9222
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
9463
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
9223
9464
  const limit = parsePositiveInt3(args.limit, 50, "--limit");
9224
9465
  const result = await client3.query("TenantExtensionWorkspace", {
9225
9466
  keyword: args.keyword,
@@ -9252,7 +9493,7 @@ async function workspaceActiveCommand(args) {
9252
9493
  const ctx = await getActiveAuthContextFromCli(args, {
9253
9494
  fallbackEnv: localContext?.profile
9254
9495
  });
9255
- const client3 = HcmClient21.fromAuthContext(ctx);
9496
+ const client3 = HcmClient22.fromAuthContext(ctx);
9256
9497
  const result = await client3.query("TenantExtensionWorkspace", {
9257
9498
  filter: { devModeEnabled: true },
9258
9499
  fields: ["workspaceKey", "devModeEnabled"],
@@ -9310,7 +9551,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
9310
9551
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
9311
9552
  );
9312
9553
  }
9313
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
9554
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
9314
9555
  const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
9315
9556
  const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
9316
9557
  workspaceKey: normalizedWorkspaceKey,
@@ -9358,7 +9599,7 @@ async function workspacePullCommand(args) {
9358
9599
  `workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
9359
9600
  );
9360
9601
  }
9361
- const client3 = HcmClient21.fromAuthContext(
9602
+ const client3 = HcmClient22.fromAuthContext(
9362
9603
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
9363
9604
  );
9364
9605
  const context = buildWorkspaceContext({
@@ -9512,7 +9753,7 @@ async function workspaceRmCommand(relativePath, args) {
9512
9753
  if (!stat) {
9513
9754
  if (manifestEntry) {
9514
9755
  process.stdout.write(
9515
- formatObject21(
9756
+ formatObject22(
9516
9757
  {
9517
9758
  workspaceKey: context.workspaceKey,
9518
9759
  file: normalized,
@@ -9537,7 +9778,7 @@ async function workspaceRmCommand(relativePath, args) {
9537
9778
  next: `hcm workspace push --dir ${args.dir ?? "."}`
9538
9779
  };
9539
9780
  if (args.output === "json" || args.output === "yaml") {
9540
- process.stdout.write(formatObject21(result, { format: args.output }) + "\n");
9781
+ process.stdout.write(formatObject22(result, { format: args.output }) + "\n");
9541
9782
  } else {
9542
9783
  process.stdout.write(`workspace file staged for deletion: ${normalized}
9543
9784
  `);
@@ -9584,10 +9825,10 @@ async function workspaceStatusCommand(args) {
9584
9825
  }
9585
9826
  if (args.output === "json" || args.output === "yaml") {
9586
9827
  process.stdout.write(
9587
- formatObject21({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
9828
+ formatObject22({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
9588
9829
  );
9589
9830
  } else {
9590
- process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
9831
+ process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
9591
9832
  }
9592
9833
  process.exitCode = 0;
9593
9834
  return;
@@ -9618,7 +9859,7 @@ async function workspacePushCommand(args) {
9618
9859
  const rootDir = resolveRootDir(args.dir);
9619
9860
  const context = await requireWorkspaceContext(rootDir);
9620
9861
  const miniApps = await discoverMiniApps(rootDir);
9621
- const client3 = HcmClient21.fromAuthContext(
9862
+ const client3 = HcmClient22.fromAuthContext(
9622
9863
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
9623
9864
  );
9624
9865
  const activeWorkspaceKey = args.dryRun ? null : await probeActiveWorkspaceKey(client3);
@@ -9689,9 +9930,9 @@ async function workspacePreviewCommand(args) {
9689
9930
  );
9690
9931
  }
9691
9932
  if (args.output === "json" || args.output === "yaml") {
9692
- process.stdout.write(formatObject21(rows2, { format: args.output }) + "\n");
9933
+ process.stdout.write(formatObject22(rows2, { format: args.output }) + "\n");
9693
9934
  } else {
9694
- process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
9935
+ process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
9695
9936
  }
9696
9937
  process.exitCode = 0;
9697
9938
  return;
@@ -10166,7 +10407,7 @@ async function readMiniStatusSafely(app) {
10166
10407
  async function loadProfileClient(args) {
10167
10408
  try {
10168
10409
  const ctx = await getActiveAuthContextFromCli(args);
10169
- return HcmClient21.fromAuthContext(ctx);
10410
+ return HcmClient22.fromAuthContext(ctx);
10170
10411
  } catch (e) {
10171
10412
  if (args.env || args.profile) throw e;
10172
10413
  return null;
@@ -10333,10 +10574,10 @@ function optionalText(value) {
10333
10574
  }
10334
10575
  function writeWorkspaceListResult(rows2, format, total) {
10335
10576
  if (format !== "table") {
10336
- process.stdout.write(formatObject21({ rows: rows2, total }, { format }) + "\n");
10577
+ process.stdout.write(formatObject22({ rows: rows2, total }, { format }) + "\n");
10337
10578
  return;
10338
10579
  }
10339
- process.stdout.write(formatRows5(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
10580
+ process.stdout.write(formatRows6(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
10340
10581
  if (total !== void 0) {
10341
10582
  process.stdout.write(`Showing ${rows2.length} of ${total} workspaces.
10342
10583
  `);
@@ -10344,7 +10585,7 @@ function writeWorkspaceListResult(rows2, format, total) {
10344
10585
  }
10345
10586
  function writeWorkspaceActiveResult(view, format) {
10346
10587
  if (format !== "table") {
10347
- process.stdout.write(formatObject21(view, { format }) + "\n");
10588
+ process.stdout.write(formatObject22(view, { format }) + "\n");
10348
10589
  return;
10349
10590
  }
10350
10591
  const rows2 = [
@@ -10358,7 +10599,7 @@ function writeWorkspaceActiveResult(view, format) {
10358
10599
  dir: view.rootDir
10359
10600
  }
10360
10601
  ];
10361
- process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
10602
+ process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
10362
10603
  if (view.nextCommand) {
10363
10604
  process.stdout.write(`\u4E0B\u4E00\u6B65\uFF1A${view.nextCommand}
10364
10605
  `);
@@ -10366,7 +10607,7 @@ function writeWorkspaceActiveResult(view, format) {
10366
10607
  }
10367
10608
  function writeWorkspaceBindResult(context, rootDir, format) {
10368
10609
  if (format !== "table") {
10369
- process.stdout.write(formatObject21({ ...context, rootDir }, { format }) + "\n");
10610
+ process.stdout.write(formatObject22({ ...context, rootDir }, { format }) + "\n");
10370
10611
  return;
10371
10612
  }
10372
10613
  process.stdout.write(
@@ -10380,7 +10621,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
10380
10621
  }
10381
10622
  function writeWorkspaceCreateResult(result, format) {
10382
10623
  if (format !== "table") {
10383
- process.stdout.write(formatObject21(result, { format }) + "\n");
10624
+ process.stdout.write(formatObject22(result, { format }) + "\n");
10384
10625
  return;
10385
10626
  }
10386
10627
  process.stdout.write(
@@ -10396,7 +10637,7 @@ function writeWorkspaceCreateResult(result, format) {
10396
10637
  }
10397
10638
  function writeWorkspacePullResult(result, format) {
10398
10639
  if (format !== "table") {
10399
- process.stdout.write(formatObject21(result, { format }) + "\n");
10640
+ process.stdout.write(formatObject22(result, { format }) + "\n");
10400
10641
  return;
10401
10642
  }
10402
10643
  const lines = [
@@ -10414,7 +10655,7 @@ function writeWorkspacePullResult(result, format) {
10414
10655
  }
10415
10656
  function writeWorkspaceAddMiniResult(result, rootDir, format) {
10416
10657
  if (format !== "table") {
10417
- process.stdout.write(formatObject21({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
10658
+ process.stdout.write(formatObject22({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
10418
10659
  return;
10419
10660
  }
10420
10661
  process.stdout.write(
@@ -10430,7 +10671,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
10430
10671
  function writeWorkspaceValidateResult(results, format) {
10431
10672
  if (format !== "table") {
10432
10673
  process.stdout.write(
10433
- formatObject21(
10674
+ formatObject22(
10434
10675
  results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result })),
10435
10676
  { format }
10436
10677
  ) + "\n"
@@ -10443,7 +10684,7 @@ function writeWorkspaceValidateResult(results, format) {
10443
10684
  errors: item.result.errors.length,
10444
10685
  warnings: item.result.warnings.length
10445
10686
  }));
10446
- process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
10687
+ process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
10447
10688
  for (const item of results) {
10448
10689
  if (!item.result.errors.length && !item.result.warnings.length) continue;
10449
10690
  process.stdout.write(`
@@ -10458,7 +10699,7 @@ mini:${item.app.appCode}
10458
10699
  function writeWorkspacePushResult(rawResult, results, format) {
10459
10700
  if (format !== "table") {
10460
10701
  process.stdout.write(
10461
- formatObject21(
10702
+ formatObject22(
10462
10703
  {
10463
10704
  workspaceFiles: { artifact: "workspace", ...rawResult },
10464
10705
  miniApps: results.map((item) => ({
@@ -10487,7 +10728,7 @@ function writeWorkspacePushResult(rawResult, results, format) {
10487
10728
  );
10488
10729
  const conflicts = [...rawConflicts, ...miniConflicts];
10489
10730
  if (conflicts.length) {
10490
- process.stdout.write("conflicts:\n" + formatRows5(conflicts, { format: "table" }) + "\n");
10731
+ process.stdout.write("conflicts:\n" + formatRows6(conflicts, { format: "table" }) + "\n");
10491
10732
  return;
10492
10733
  }
10493
10734
  const rawOperations = rawResult.operations.map((operation) => ({
@@ -10507,7 +10748,7 @@ function writeWorkspacePushResult(rawResult, results, format) {
10507
10748
  }))
10508
10749
  );
10509
10750
  const operations = [...rawOperations, ...miniOperations];
10510
- process.stdout.write(formatRows5(operations, { format: "table" }) + "\n");
10751
+ process.stdout.write(formatRows6(operations, { format: "table" }) + "\n");
10511
10752
  if (rawResult.dryRun || results.some((item) => item.result.dryRun)) {
10512
10753
  process.stdout.write("dry-run: no remote changes were written\n");
10513
10754
  }
@@ -10517,7 +10758,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
10517
10758
  const ok = rawOk && reports.every((item) => item.report.ok);
10518
10759
  if (format === "json") {
10519
10760
  process.stdout.write(
10520
- formatObject21(
10761
+ formatObject22(
10521
10762
  {
10522
10763
  ok,
10523
10764
  workspaceKey: context.workspaceKey,
@@ -10544,7 +10785,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
10544
10785
  }
10545
10786
  if (format !== "table") {
10546
10787
  process.stdout.write(
10547
- formatObject21(
10788
+ formatObject22(
10548
10789
  {
10549
10790
  ok,
10550
10791
  workspaceKey: context.workspaceKey,
@@ -10653,7 +10894,7 @@ async function requestWorkspaceDeactivation(client3) {
10653
10894
  }
10654
10895
  async function workspaceActivateCommand(workspaceKey, args) {
10655
10896
  try {
10656
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
10897
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
10657
10898
  const key2 = normalizeWorkspaceKey(workspaceKey);
10658
10899
  await setDevModeBinding(client3, key2);
10659
10900
  const fmt = args.output ?? "table";
@@ -10663,7 +10904,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
10663
10904
  process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
10664
10905
  } else {
10665
10906
  process.stdout.write(
10666
- formatObject21({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
10907
+ formatObject22({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
10667
10908
  );
10668
10909
  }
10669
10910
  process.exitCode = 0;
@@ -10674,7 +10915,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
10674
10915
  }
10675
10916
  async function workspaceDeactivateCommand(args) {
10676
10917
  try {
10677
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
10918
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
10678
10919
  const binding = await requestWorkspaceDeactivation(client3);
10679
10920
  const result = { ...binding, deactivated: true };
10680
10921
  const fmt = args.output ?? "table";
@@ -10682,7 +10923,7 @@ async function workspaceDeactivateCommand(args) {
10682
10923
  process.stdout.write("workspace deactivated\n");
10683
10924
  process.stdout.write("\u5F53\u524D\u8EAB\u4EFD\u5DF2\u9000\u51FA\u5F00\u53D1\u8005\u6A21\u5F0F\uFF1B\u5F00\u53D1\u7A7A\u95F4\u3001\u672C\u5730\u6587\u4EF6\u4E0E\u5DF2\u53D1\u5E03\u8D44\u4EA7\u5747\u672A\u5220\u9664\u3002\n");
10684
10925
  } else {
10685
- process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
10926
+ process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
10686
10927
  }
10687
10928
  process.exitCode = 0;
10688
10929
  return;
@@ -10696,10 +10937,10 @@ init_exit();
10696
10937
  import axios4 from "axios";
10697
10938
  import {
10698
10939
  AUTH_INFO_PATH,
10699
- CliError as CliError23,
10700
- CliErrorCode as CliErrorCode22,
10701
- formatObject as formatObject22,
10702
- formatRows as formatRows6,
10940
+ CliError as CliError24,
10941
+ CliErrorCode as CliErrorCode25,
10942
+ formatObject as formatObject23,
10943
+ formatRows as formatRows7,
10703
10944
  fromAxiosError as fromAxiosError21,
10704
10945
  loadEnv as loadEnv4,
10705
10946
  saveEnv as saveEnv3,
@@ -10724,8 +10965,8 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
10724
10965
  const env2 = await loadEnv4(meta2.env);
10725
10966
  const accessToken = await TokenStore4.forIdentity(name).getStoredAccessToken();
10726
10967
  if (!accessToken) {
10727
- throw new CliError23({
10728
- code: CliErrorCode22.AUTH_FAILED,
10968
+ throw new CliError24({
10969
+ code: CliErrorCode25.AUTH_FAILED,
10729
10970
  message: `identity '${name}' \u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u6301\u4E45\u5316 token`,
10730
10971
  context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
10731
10972
  });
@@ -10753,7 +10994,7 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
10753
10994
  async function identityShow(name, args) {
10754
10995
  try {
10755
10996
  const details = await inspectIdentity(name);
10756
- return exitOk(formatObject22(details, { format: args.output ?? "json" }));
10997
+ return exitOk(formatObject23(details, { format: args.output ?? "json" }));
10757
10998
  } catch (e) {
10758
10999
  exitWithError(axios4.isAxiosError(e) ? fromAxiosError21(e, name) : e);
10759
11000
  }
@@ -10765,7 +11006,7 @@ async function identityList(args) {
10765
11006
  const names = await listIdentities4(filter);
10766
11007
  const fmt = args.output ?? "table";
10767
11008
  if (names.length === 0) {
10768
- return exitOk(fmt === "table" ? "(no identities)" : formatObject22([], { format: fmt }));
11009
+ return exitOk(fmt === "table" ? "(no identities)" : formatObject23([], { format: fmt }));
10769
11010
  }
10770
11011
  const rows2 = [];
10771
11012
  for (const n of names) {
@@ -10779,7 +11020,7 @@ async function identityList(args) {
10779
11020
  isDefault: env2?.defaultIdentity === n
10780
11021
  });
10781
11022
  }
10782
- return exitOk(fmt === "table" ? formatRows6(rows2, { format: fmt }) : formatObject22(rows2, { format: fmt }));
11023
+ return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject23(rows2, { format: fmt }));
10783
11024
  } catch (e) {
10784
11025
  exitWithError(e);
10785
11026
  }
@@ -10788,8 +11029,8 @@ async function identityUse(name) {
10788
11029
  try {
10789
11030
  const meta2 = await loadIdentity4(name);
10790
11031
  const env2 = await loadEnv4(meta2.env).catch(() => {
10791
- throw new CliError23({
10792
- code: CliErrorCode22.IDENTITY_NOT_IN_ENV,
11032
+ throw new CliError24({
11033
+ code: CliErrorCode25.IDENTITY_NOT_IN_ENV,
10793
11034
  message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
10794
11035
  });
10795
11036
  });
@@ -10829,11 +11070,11 @@ init_exit();
10829
11070
  import { promises as fs9 } from "fs";
10830
11071
  import path10 from "path";
10831
11072
  import {
10832
- CliError as CliError24,
10833
- CliErrorCode as CliErrorCode23,
10834
- HcmClient as HcmClient22,
11073
+ CliError as CliError25,
11074
+ CliErrorCode as CliErrorCode26,
11075
+ HcmClient as HcmClient23,
10835
11076
  fetchReconIdentity,
10836
- formatObject as formatObject23,
11077
+ formatObject as formatObject24,
10837
11078
  httpProbe,
10838
11079
  isTempEnv as isTempEnv3,
10839
11080
  listIdentities as listIdentities5,
@@ -10845,7 +11086,7 @@ import {
10845
11086
  } from "@hcmai/sdk";
10846
11087
  async function probeTokenTenant(envName, requested) {
10847
11088
  const ctx = await getActiveAuthContextFromCli({ env: envName });
10848
- const client3 = HcmClient22.fromAuthContext(ctx);
11089
+ const client3 = HcmClient23.fromAuthContext(ctx);
10849
11090
  const identity2 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
10850
11091
  return identity2?.tenantId ? String(identity2.tenantId) : void 0;
10851
11092
  }
@@ -10893,8 +11134,8 @@ async function resolveInitEnv(root, args, deps) {
10893
11134
  if (existing && path10.dirname(existing.path) === path10.resolve(root)) {
10894
11135
  const name2 = args.env ?? existing.config.default;
10895
11136
  const env2 = existing.config.environments[name2];
10896
- if (!env2) throw new CliError24({
10897
- code: CliErrorCode23.INVALID_ARGUMENT,
11137
+ if (!env2) throw new CliError25({
11138
+ code: CliErrorCode26.INVALID_ARGUMENT,
10898
11139
  message: `${existing.path} \u91CC\u6CA1\u6709\u73AF\u5883 '${name2}'\uFF0C\u53EA\u6709\uFF1A${Object.keys(existing.config.environments).join("\u3001")}`,
10899
11140
  context: { nextStep: `hcm chiron env add ${name2} --endpoint <\u540E\u7AEF\u5730\u5740>` }
10900
11141
  });
@@ -10903,8 +11144,8 @@ async function resolveInitEnv(root, args, deps) {
10903
11144
  }
10904
11145
  if (args.env) {
10905
11146
  const config3 = await loadEnv5(args.env).catch(() => null);
10906
- if (!config3?.endpoint) throw new CliError24({
10907
- code: CliErrorCode23.ENV_NOT_FOUND,
11147
+ if (!config3?.endpoint) throw new CliError25({
11148
+ code: CliErrorCode26.ENV_NOT_FOUND,
10908
11149
  message: `\u672C\u673A\u6CA1\u6709\u540D\u53EB '${args.env}' \u7684\u73AF\u5883\u3002`,
10909
11150
  context: { nextStep: "`hcm env list` \u770B\u6709\u54EA\u4E9B\uFF1B\u6216\u5B8C\u5168\u663E\u5F0F\u5730\u5EFA\uFF1A`hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>`" }
10910
11151
  });
@@ -10914,14 +11155,14 @@ async function resolveInitEnv(root, args, deps) {
10914
11155
  const name = g.activeEnv;
10915
11156
  const config2 = name ? await loadEnv5(name).catch(() => null) : null;
10916
11157
  const explicitPaths = " hcm chiron init --env <\u672C\u673A\u73AF\u5883\u540D>\uFF08hcm env list \u770B\u6709\u54EA\u4E9B\uFF09\n hcm chiron init --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>\uFF08\u5B8C\u5168\u663E\u5F0F\uFF0C\u4E0D\u9700\u8981\u5148\u767B\u5F55\uFF09";
10917
- if (!config2?.endpoint) throw new CliError24({
10918
- code: CliErrorCode23.ENV_NOT_FOUND,
11158
+ if (!config2?.endpoint) throw new CliError25({
11159
+ code: CliErrorCode26.ENV_NOT_FOUND,
10919
11160
  message: "\u6CA1\u8BF4\u8FD9\u4E2A\u9879\u76EE\u5BF9\u7740\u54EA\u4E2A\u73AF\u5883\uFF0C\u672C\u673A\u4E5F\u6CA1\u6709\u53EF\u7528\u7684\u6D3B\u52A8\u73AF\u5883\u3002",
10920
11161
  context: { nextStep: `\u4E8C\u9009\u4E00\uFF1A
10921
11162
  ${explicitPaths}` }
10922
11163
  });
10923
- if (isTempEnv3(name)) throw new CliError24({
10924
- code: CliErrorCode23.INVALID_ARGUMENT,
11164
+ if (isTempEnv3(name)) throw new CliError25({
11165
+ code: CliErrorCode26.INVALID_ARGUMENT,
10925
11166
  message: `\u672C\u673A\u6D3B\u52A8\u73AF\u5883\u662F\u4E34\u65F6\u7684\uFF08${config2.endpoint}\uFF09\uFF0C\u8FD8\u6CA1\u6709\u540D\u5B57\u3002\u9879\u76EE\u8981\u7ED1\u4E00\u4E2A\u7A33\u5B9A\u7684\u73AF\u5883\uFF0C\u5426\u5219\u4E0B\u4E00\u6B21 hcm login --code \u8986\u76D6\u5B83\u4E4B\u540E\uFF0C\u4ED3\u91CC\u8BB0\u7684\u5C31\u5BF9\u4E0D\u4E0A\u4E86\u3002`,
10926
11167
  context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF1B\u6216\u76F4\u63A5\u663E\u5F0F\u5EFA\uFF1A
10927
11168
  ${explicitPaths}` }
@@ -10929,8 +11170,8 @@ ${explicitPaths}` }
10929
11170
  const summary = `${name} \xB7 ${config2.endpoint} \xB7 \u79DF\u6237 ${config2.tenantId ?? "1"}`;
10930
11171
  if (!args.yes) {
10931
11172
  const ok = deps.isTty() && deps.confirm ? await deps.confirm(`\u6CA1\u6307\u5B9A\u73AF\u5883\uFF0C\u7528\u672C\u673A\u5F53\u524D\u6D3B\u52A8\u7684 ${summary} \u5417\uFF1F[y/N] `) : false;
10932
- if (!ok) throw new CliError24({
10933
- code: CliErrorCode23.INVALID_ARGUMENT,
11173
+ if (!ok) throw new CliError25({
11174
+ code: CliErrorCode26.INVALID_ARGUMENT,
10934
11175
  message: `\u6CA1\u786E\u8BA4\u8981\u7528\u672C\u673A\u6D3B\u52A8\u73AF\u5883\uFF08${summary}\uFF09\u3002\u9879\u76EE\u73AF\u5883\u4F1A\u63D0\u4EA4\u8FDB\u4ED3\u3001\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u4E0D\u9760\u4E0A\u4E00\u6761\u547D\u4EE4\u7684\u526F\u4F5C\u7528\u51B3\u5B9A\u3002`,
10935
11176
  context: { nextStep: `\u786E\u8BA4\u5C31\u52A0 --yes\uFF1B\u6216\u660E\u8BF4\uFF1A
10936
11177
  ${explicitPaths}` }
@@ -10946,16 +11187,16 @@ async function scaffoldChironProject(root, env2, envName) {
10946
11187
  const document2 = parseEnvYaml(existing);
10947
11188
  const recorded = Object.values(document2.environments).find((candidate) => candidate.endpoint === env2.endpoint && candidate.tenant === env2.tenant) ?? document2.environments[document2.default];
10948
11189
  if (recorded.endpoint !== env2.endpoint) {
10949
- throw new CliError24({
10950
- code: CliErrorCode23.INVALID_ARGUMENT,
11190
+ throw new CliError25({
11191
+ code: CliErrorCode26.INVALID_ARGUMENT,
10951
11192
  message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
10952
11193
  \u8981\u7528\u8FD9\u4E2A\u9879\u76EE\u7684\u73AF\u5883\uFF1Ahcm login ${recorded.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init
10953
11194
  \u8981\u628A\u9879\u76EE\u6539\u5230\u4F60\u767B\u5F55\u7684\u73AF\u5883\uFF1A\u5220\u6389 ${ENV_FILE} \u540E\u91CD\u8DD1\uFF08\u8FD9\u4F1A\u5F71\u54CD\u6240\u6709\u534F\u4F5C\u8005\uFF0C\u5148\u8DDF\u8D1F\u8D23\u4EBA\u786E\u8BA4\uFF09`
10954
11195
  });
10955
11196
  }
10956
11197
  if (recorded.tenant !== env2.tenant) {
10957
- throw new CliError24({
10958
- code: CliErrorCode23.INVALID_ARGUMENT,
11198
+ throw new CliError25({
11199
+ code: CliErrorCode26.INVALID_ARGUMENT,
10959
11200
  message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
10960
11201
  \u7528\u9879\u76EE\u79DF\u6237\u7684\u914D\u5BF9\u7801\u91CD\u65B0\u767B\u5F55\uFF1Ahcm login ${env2.endpoint} --code <\u914D\u5BF9\u7801>\uFF0C\u518D\u91CD\u8DD1 hcm chiron init`
10961
11202
  });
@@ -11030,7 +11271,7 @@ async function chironInitCommand(args, deps) {
11030
11271
  const result = await runChironInit(args, deps);
11031
11272
  const fmt = args.output ?? "table";
11032
11273
  if (fmt === "json" || fmt === "yaml") {
11033
- process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
11274
+ process.stdout.write(formatObject24(result, { format: fmt }) + "\n");
11034
11275
  } else {
11035
11276
  const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
11036
11277
  process.stdout.write(
@@ -11052,9 +11293,9 @@ async function chironInitCommand(args, deps) {
11052
11293
  // src/commands/gap.ts
11053
11294
  import { readFileSync as readFileSync6 } from "fs";
11054
11295
  import {
11055
- CliErrorCode as CliErrorCode25,
11296
+ CliErrorCode as CliErrorCode28,
11056
11297
  createHttpClient as createHttpClient4,
11057
- formatObject as formatObject24,
11298
+ formatObject as formatObject25,
11058
11299
  loadGlobalConfig as loadGlobalConfig10,
11059
11300
  resolveEnvContext as resolveEnvContext7,
11060
11301
  printResolvedEnvironment as printResolvedEnvironment7
@@ -11449,7 +11690,7 @@ async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug =
11449
11690
  }
11450
11691
 
11451
11692
  // src/jira/gap-verify.ts
11452
- import { CASES_REPO_SLUG as CASES_REPO_SLUG3, CliError as CliError25, CliErrorCode as CliErrorCode24, JiraHttpError, firstLine as firstLine2, parseRef as parseRef2 } from "@hcmai/sdk";
11693
+ import { CASES_REPO_SLUG as CASES_REPO_SLUG3, CliError as CliError26, CliErrorCode as CliErrorCode27, JiraHttpError, firstLine as firstLine2, parseRef as parseRef2 } from "@hcmai/sdk";
11453
11694
  var VERIFY_RESULTS = ["pass", "fail", "partial"];
11454
11695
  var WRITTEN_TAG = { no: "\u3010\u672A\u5199\u5165\u3011", yes: "\u3010\u5DF2\u5199\u5165\u3011", unknown: "\u3010\u5199\u6CA1\u5199\u4E0D\u786E\u5B9A\u3011" };
11455
11696
  var FIXED_STATUS = "\u5DF2\u4FEE\u590D";
@@ -11463,14 +11704,14 @@ var VERIFY_PLAN = {
11463
11704
  function parseVerifyResult(raw) {
11464
11705
  const v = String(raw ?? "").trim().toLowerCase();
11465
11706
  if (VERIFY_RESULTS.includes(v)) return v;
11466
- throw new CliError25({
11467
- code: raw === void 0 ? CliErrorCode24.MISSING_FLAG : CliErrorCode24.INVALID_ARGUMENT,
11707
+ throw new CliError26({
11708
+ code: raw === void 0 ? CliErrorCode27.MISSING_FLAG : CliErrorCode27.INVALID_ARGUMENT,
11468
11709
  message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
11469
11710
  context: { nextStep: "pass = \u539F\u6545\u969C\u5728\u76EE\u6807\u73AF\u5883\u4E0D\u518D\u51FA\u73B0\uFF1Bfail = \u4ECD\u7136\u590D\u73B0\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF1Bpartial = \u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09\u3002" }
11470
11711
  });
11471
11712
  }
11472
11713
  function verifyFailure(reasonCode, code, written, message, nextStep, extra = {}, cause) {
11473
- return new CliError25({ code, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
11714
+ return new CliError26({ code, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
11474
11715
  }
11475
11716
  function who(u) {
11476
11717
  if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
@@ -11546,7 +11787,7 @@ function unconfirmedWhy(e) {
11546
11787
  }
11547
11788
  function writeFailure(e, key2, what) {
11548
11789
  if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
11549
- return verifyFailure("write-rejected", CliErrorCode24.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
11790
+ return verifyFailure("write-rejected", CliErrorCode27.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
11550
11791
  key: key2,
11551
11792
  status: e.status,
11552
11793
  details: e.message
@@ -11554,7 +11795,7 @@ function writeFailure(e, key2, what) {
11554
11795
  }
11555
11796
  return verifyFailure(
11556
11797
  "write-unconfirmed",
11557
- CliErrorCode24.NETWORK_ERROR,
11798
+ CliErrorCode27.NETWORK_ERROR,
11558
11799
  "unknown",
11559
11800
  `${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
11560
11801
  `\u5148\u7528 \`hcm chiron gap status ${key2}\` \u4E0E \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\u5199\u8FDB\u53BB\u6CA1\u6709\uFF0C\u518D\u51B3\u5B9A\u8981\u4E0D\u8981\u91CD\u8DD1\u2014\u2014partial \u91CD\u8DD1\u4F1A\u591A\u4E00\u6761\u8BC4\u8BBA\u3002`,
@@ -11577,7 +11818,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11577
11818
  if (!parsed || parsed.kind !== "jira") {
11578
11819
  throw verifyFailure(
11579
11820
  "not-jira-key",
11580
- CliErrorCode24.INVALID_ARGUMENT,
11821
+ CliErrorCode27.INVALID_ARGUMENT,
11581
11822
  "no",
11582
11823
  parsed && parsed.kind === "repo" ? `${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u9A8C\u6536\u8981\u843D\u5728 Jira \u5355\u4E0A` : `\u770B\u4E0D\u61C2 ${ref}`,
11583
11824
  "\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u2014\u2014\u5C31\u662F `hcm chiron gap submit` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\u7F16\u53F7\u3002"
@@ -11587,7 +11828,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11587
11828
  const inProject = (k) => k.startsWith(`${client3.project}-`);
11588
11829
  const wrongProject = (k) => verifyFailure(
11589
11830
  "wrong-project",
11590
- CliErrorCode24.INVALID_ARGUMENT,
11831
+ CliErrorCode27.INVALID_ARGUMENT,
11591
11832
  "no",
11592
11833
  `${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
11593
11834
  `\u7ED9 ${client3.project} \u7684\u5355\u53F7\uFF08\`hcm chiron gap submit\` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\uFF09\u3002\u522B\u7684\u9879\u76EE\u7684\u5355\u8FD9\u6761\u547D\u4EE4\u4E0D\u78B0\u2014\u2014\u90A3\u91CC\u7684\u72B6\u6001\u540D\u4E0E\u6D41\u8F6C\u540D\u548C ${client3.project} \u540C\u5F62\uFF0C\u5199\u9519\u4E86\u4F1A\u628A\u522B\u5904\u7684\u5355\u5173\u6389\u3002`,
@@ -11598,7 +11839,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11598
11839
  if (evidence.length < EVIDENCE_MIN) {
11599
11840
  throw verifyFailure(
11600
11841
  "evidence-too-short",
11601
- CliErrorCode24.INVALID_ARGUMENT,
11842
+ CliErrorCode27.INVALID_ARGUMENT,
11602
11843
  "no",
11603
11844
  `\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
11604
11845
  "\u5199\u6E05\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\uFF08`hcm version`\uFF09\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\uFF1B\u8BC1\u636E\u6587\u4EF6\u653E\u5728 evidence/ \u4E0B\u5E76\u5199\u4E0A\u8DEF\u5F84\u3002",
@@ -11624,7 +11865,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11624
11865
  if (!sameUser(reporter, me)) {
11625
11866
  throw verifyFailure(
11626
11867
  "not-reporter",
11627
- CliErrorCode24.BUSINESS_RULE_VIOLATION,
11868
+ CliErrorCode27.BUSINESS_RULE_VIOLATION,
11628
11869
  "no",
11629
11870
  `\u53EA\u6709\u63D0\u5355\u4EBA\u80FD\u9A8C\u6536 ${key2}\uFF1A\u63D0\u5355\u4EBA\u662F ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD\u662F ${who(me)}`,
11630
11871
  "\u8BF7\u63D0\u5355\u4EBA\u590D\u9A8C\u540E\u81EA\u5DF1\u8DD1\u8FD9\u6761\u547D\u4EE4\u3002\u4F60\u624B\u4E0A\u7684\u65B0\u73B0\u573A\u7528 `hcm chiron gap submit` \u8FFD\u52A0\uFF1B\u7ECF\u529E\u4EBA\u3001\u641C\u7D22\u547D\u4E2D\u3001\u5728\u522B\u4EBA\u7684\u5355\u4E0B\u8FFD\u52A0\u8FC7\u73B0\u573A\u90FD\u4E0D\u6784\u6210\u9A8C\u6536\u8D44\u683C\u3002",
@@ -11638,7 +11879,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11638
11879
  if (status !== FIXED_STATUS) {
11639
11880
  throw verifyFailure(
11640
11881
  "status-not-fixed",
11641
- CliErrorCode24.BUSINESS_RULE_VIOLATION,
11882
+ CliErrorCode27.BUSINESS_RULE_VIOLATION,
11642
11883
  "no",
11643
11884
  `${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
11644
11885
  notFixedNextStep(key2, status, o.result),
@@ -11657,7 +11898,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11657
11898
  const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
11658
11899
  throw verifyFailure(
11659
11900
  "transition-unavailable",
11660
- CliErrorCode24.BUSINESS_RULE_VIOLATION,
11901
+ CliErrorCode27.BUSINESS_RULE_VIOLATION,
11661
11902
  "no",
11662
11903
  `${key2} \u4E0A\u670D\u52A1\u7AEF\u6B64\u523B\u4E0D\u7ED9\u300C${want.name}\u2192${want.to}\u300D\u8FD9\u6761\u6D41\u8F6C\uFF08\u53EF\u7528\uFF1A${available.join(" / ") || "\uFF08\u65E0\uFF09"}\uFF09`,
11663
11904
  "\u591A\u534A\u662F\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF0C\u6216\u4F60\u7684\u8D26\u53F7\u5728\u8FD9\u4E2A\u9879\u76EE\u4E0A\u6CA1\u6709\u8FD9\u6761\u6D41\u8F6C\u7684\u6743\u9650\u3002\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u81EA\u5DF1\u62FC HTTP\uFF0C\u4E5F\u522B\u6539\u95EE\u9898\u7C7B\u578B\u7ED5\u8FC7\u3002",
@@ -11669,7 +11910,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11669
11910
  else if (req.missing.length) {
11670
11911
  throw verifyFailure(
11671
11912
  "required-fields-missing",
11672
- CliErrorCode24.BUSINESS_RULE_VIOLATION,
11913
+ CliErrorCode27.BUSINESS_RULE_VIOLATION,
11673
11914
  "no",
11674
11915
  `\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
11675
11916
  "\u8FD9\u4E9B\u5B57\u6BB5\u7531\u4EA7\u54C1\u4FA7\u7EF4\u62A4\uFF0C\u8BF7\u5206\u8BCA\u4EBA\u8865\u9F50\u540E\u518D\u8DD1\uFF1BCLI \u4E0D\u4EE3\u586B\uFF0C\u4E5F\u522B\u628A\u7ECF\u529E\u4EBA\u6216\u4FEE\u590D\u4EBA\u731C\u6210 Bug\u5F15\u5165\u4EBA\u3002",
@@ -11710,7 +11951,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11710
11951
  } catch (e) {
11711
11952
  throw verifyFailure(
11712
11953
  "readback-failed",
11713
- CliErrorCode24.NETWORK_ERROR,
11954
+ CliErrorCode27.NETWORK_ERROR,
11714
11955
  "yes",
11715
11956
  `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
11716
11957
  `\u7528 \`hcm chiron gap status ${key2}\` \u770B\u7ED3\u679C\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\u8BC4\u8BBA\uFF09\u3002`,
@@ -11724,7 +11965,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11724
11965
  const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
11725
11966
  throw verifyFailure(
11726
11967
  "readback-mismatch",
11727
- CliErrorCode24.SERVER_ERROR,
11968
+ CliErrorCode27.SERVER_ERROR,
11728
11969
  "yes",
11729
11970
  after2.status !== expected ? `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u72B6\u6001\u662F\u300C${after2.status ?? "?"}\u300D\uFF0C\u9884\u671F\u300C${expected}\u300D` : `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C${key2} \u56DE\u5230\u4E86\u300C${expected}\u300D\uFF0C\u4F46 resolution \u8FD8\u662F\u300C${after2.resolution}\u300D\u2014\u2014\u5B83\u4F1A\u4ECE\u300C\u672A\u89E3\u51B3\u300D\u7684\u67E5\u8BE2\u91CC\u6D88\u5931`,
11730
11971
  after2.status !== expected ? `\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\uFF0C\u522B\u5F53\u6210\u5DF2\u7ECF${did}\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002` : "\u8BF7\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u6E05\u6389\u8FD9\u5355\u7684 resolution\uFF08\u300C\u672A\u89E3\u51B3\u300D\u8FD9\u6761\u6D41\u8F6C\u672C\u6765\u4F1A\u6E05\uFF0C\u6CA1\u6E05\u8BF4\u660E\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF09\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4ED6\u3002",
@@ -11755,7 +11996,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11755
11996
  } catch (e) {
11756
11997
  throw verifyFailure(
11757
11998
  "readback-failed",
11758
- CliErrorCode24.NETWORK_ERROR,
11999
+ CliErrorCode27.NETWORK_ERROR,
11759
12000
  "yes",
11760
12001
  `\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
11761
12002
  `\u7528 \`hcm chiron gap comments ${key2}\` \u770B\u5B83\u5728\u4E0D\u5728\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\uFF09\u3002`,
@@ -11769,7 +12010,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11769
12010
  } else if (!listed.some((c) => c.id === written.id)) {
11770
12011
  throw verifyFailure(
11771
12012
  "readback-mismatch",
11772
- CliErrorCode24.SERVER_ERROR,
12013
+ CliErrorCode27.SERVER_ERROR,
11773
12014
  "yes",
11774
12015
  `Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
11775
12016
  `\u7528 \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002`,
@@ -11805,7 +12046,7 @@ async function gapDeps(deps) {
11805
12046
  return { client: await deps.client() };
11806
12047
  }
11807
12048
  function emit5(fmt, data, text) {
11808
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject24(data, { format: fmt }) + "\n");
12049
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject25(data, { format: fmt }) + "\n");
11809
12050
  else process.stdout.write(text() + "\n");
11810
12051
  }
11811
12052
  async function run2(fn) {
@@ -11908,7 +12149,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
11908
12149
  if (opts.file !== void 0 && opts.body !== void 0) {
11909
12150
  throw verifyFailure(
11910
12151
  "evidence-ambiguous",
11911
- CliErrorCode25.INVALID_ARGUMENT,
12152
+ CliErrorCode28.INVALID_ARGUMENT,
11912
12153
  "no",
11913
12154
  "--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
11914
12155
  "\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
@@ -11920,7 +12161,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
11920
12161
  } catch (e) {
11921
12162
  throw verifyFailure(
11922
12163
  "evidence-unreadable",
11923
- CliErrorCode25.INVALID_ARGUMENT,
12164
+ CliErrorCode28.INVALID_ARGUMENT,
11924
12165
  "no",
11925
12166
  `\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
11926
12167
  "\u6838\u5BF9\u8DEF\u5F84\u4E0E\u6743\u9650\uFF1B\u8BC1\u636E\u6587\u4EF6\u4E00\u822C\u653E\u5728\u9879\u76EE\u4ED3\u7684 evidence/ \u4E0B\u3002",
@@ -11933,7 +12174,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
11933
12174
  if (stdinIsTTY) {
11934
12175
  throw verifyFailure(
11935
12176
  "evidence-missing",
11936
- CliErrorCode25.INVALID_ARGUMENT,
12177
+ CliErrorCode28.INVALID_ARGUMENT,
11937
12178
  "no",
11938
12179
  "\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
11939
12180
  "\u7528 --body <\u6587\u672C> \u6216 --file <\u6587\u4EF6> \u7ED9\u51FA\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\u3002"
@@ -11991,26 +12232,26 @@ init_exit();
11991
12232
  import { promises as fs10 } from "fs";
11992
12233
  import path11 from "path";
11993
12234
  import {
11994
- HcmClient as HcmClient23,
11995
- CliError as CliError26,
11996
- CliErrorCode as CliErrorCode26,
12235
+ HcmClient as HcmClient24,
12236
+ CliError as CliError27,
12237
+ CliErrorCode as CliErrorCode29,
11997
12238
  loadGlobalConfig as loadGlobalConfig11,
11998
12239
  resolveEnvContext as resolveEnvContext8,
11999
12240
  fetchReconIdentity as fetchReconIdentity2,
12000
- formatObject as formatObject25,
12241
+ formatObject as formatObject26,
12001
12242
  httpProbe as httpProbe2,
12002
- conversationWebSocketEndpoint as conversationWebSocketEndpoint3,
12243
+ conversationWebSocketEndpoint as conversationWebSocketEndpoint4,
12003
12244
  probeConversationHandshake,
12004
12245
  runDoctor
12005
12246
  } from "@hcmai/sdk";
12006
12247
  var defaultDeps2 = {
12007
12248
  anchors: async (envName, tenant2, as, project) => {
12008
12249
  const ctx = await getActiveAuthContextFromCli({ env: envName, as }, { cwd: project });
12009
- const client3 = HcmClient23.fromAuthContext(ctx);
12250
+ const client3 = HcmClient24.fromAuthContext(ctx);
12010
12251
  const probe = httpProbe2(client3.raw(), "default");
12011
12252
  const identity2 = await fetchReconIdentity2(probe, tenant2);
12012
12253
  const report = await runDoctor(probe, identity2, () => probeConversationHandshake({
12013
- endpoint: conversationWebSocketEndpoint3(ctx.endpoint),
12254
+ endpoint: conversationWebSocketEndpoint4(ctx.endpoint),
12014
12255
  getAccessToken: () => client3.getAccessToken()
12015
12256
  }));
12016
12257
  return { report, tokenTenant: identity2?.tenantId ? String(identity2.tenantId) : void 0 };
@@ -12044,8 +12285,8 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12044
12285
  if (args.env !== void 0 && !Object.hasOwn(file.environments, args.env)) {
12045
12286
  try {
12046
12287
  explicitSlot = await resolveEnvContext8({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig11());
12047
- if (!explicitSlot.project) throw new CliError26({
12048
- code: CliErrorCode26.INVALID_ARGUMENT,
12288
+ if (!explicitSlot.project) throw new CliError27({
12289
+ code: CliErrorCode29.INVALID_ARGUMENT,
12049
12290
  message: `\u672C\u673A\u69FD '${args.env}' \u7684\u5730\u5740\u6216\u79DF\u6237\u4E0D\u5339\u914D\u672C\u9879\u76EE\uFF1B\u672C\u9879\u76EE\u6709\uFF1A${names.join(", ")}`
12050
12291
  });
12051
12292
  selectedName = explicitSlot.project.name;
@@ -12099,7 +12340,7 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12099
12340
  });
12100
12341
  }
12101
12342
  } catch (e) {
12102
- const msg = e instanceof CliError26 ? e.message : e.message;
12343
+ const msg = e instanceof CliError27 ? e.message : e.message;
12103
12344
  report.lines.push({ item: "\u767B\u5F55", verdict: severity(), detail: `${label} \xB7 \u672C\u673A\u69FD ${found.name} \xB7 ${env3.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
12104
12345
  }
12105
12346
  }
@@ -12175,7 +12416,7 @@ async function chironDoctorCommand(args, deps) {
12175
12416
  try {
12176
12417
  const report = await runChironDoctor(args, deps);
12177
12418
  const fmt = args.output ?? "table";
12178
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject25(report, { format: fmt }) + "\n");
12419
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject26(report, { format: fmt }) + "\n");
12179
12420
  else process.stdout.write(renderChironDoctor(report) + "\n");
12180
12421
  process.exitCode = report.ok ? 0 : 1;
12181
12422
  } catch (e) {
@@ -12190,12 +12431,12 @@ import path12 from "path";
12190
12431
  import yaml from "js-yaml";
12191
12432
  import {
12192
12433
  AUTH_INFO_PATH as AUTH_INFO_PATH2,
12193
- CliError as CliError27,
12194
- CliErrorCode as CliErrorCode27,
12434
+ CliError as CliError28,
12435
+ CliErrorCode as CliErrorCode30,
12195
12436
  discoverProjectEnv as discoverProjectEnv6,
12196
12437
  ENV_FILE as ENV_FILE2,
12197
12438
  findEnvByEndpoint as findEnvByEndpoint5,
12198
- formatObject as formatObject26,
12439
+ formatObject as formatObject27,
12199
12440
  listIdentities as listIdentities6,
12200
12441
  parseEnvYaml as parseEnvYaml2,
12201
12442
  renderEnvYaml as renderEnvYaml2,
@@ -12214,7 +12455,7 @@ function summarizeReasons(reasons) {
12214
12455
  return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
12215
12456
  }
12216
12457
  function invalid2(message, nextStep) {
12217
- throw new CliError27({ code: CliErrorCode27.INVALID_ARGUMENT, message, context: { nextStep } });
12458
+ throw new CliError28({ code: CliErrorCode30.INVALID_ARGUMENT, message, context: { nextStep } });
12218
12459
  }
12219
12460
  function required(value, label) {
12220
12461
  if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
@@ -12397,7 +12638,7 @@ async function runChironEnv(action, args = {}) {
12397
12638
  return report;
12398
12639
  }
12399
12640
  function formatChironEnvReport(report, output = "table") {
12400
- if (output !== "table") return formatObject26(report, { format: output });
12641
+ if (output !== "table") return formatObject27(report, { format: output });
12401
12642
  const lines = [
12402
12643
  report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
12403
12644
  formatTable(report.environments.map((env2) => ({
@@ -12432,11 +12673,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
12432
12673
  import fs12 from "fs/promises";
12433
12674
  import os5 from "os";
12434
12675
  import path14 from "path";
12435
- import { CliError as CliError30, CliErrorCode as CliErrorCode30, formatObject as formatObject27, HcmClient as HcmClient24, loadEnv as loadEnv6 } from "@hcmai/sdk";
12676
+ import { CliError as CliError31, CliErrorCode as CliErrorCode33, formatObject as formatObject28, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
12436
12677
  import { createRequire } from "module";
12437
12678
 
12438
12679
  // src/commands/chiron-page-cdp.ts
12439
- import { CliError as CliError28, CliErrorCode as CliErrorCode28 } from "@hcmai/sdk";
12680
+ import { CliError as CliError29, CliErrorCode as CliErrorCode31 } from "@hcmai/sdk";
12440
12681
 
12441
12682
  // src/commands/chiron-page-shared.ts
12442
12683
  function redactTicket(text) {
@@ -12472,14 +12713,14 @@ function normalizeCdpEndpoint(raw) {
12472
12713
  try {
12473
12714
  url = new URL(candidate);
12474
12715
  } catch {
12475
- throw new CliError28({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12716
+ throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12476
12717
  }
12477
12718
  const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
12478
12719
  if (protocol !== "http:" && protocol !== "https:") {
12479
- throw new CliError28({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12720
+ throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12480
12721
  }
12481
12722
  if (!url.port) {
12482
- throw new CliError28({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12723
+ throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12483
12724
  }
12484
12725
  return `${protocol}//${url.hostname}:${url.port}`;
12485
12726
  }
@@ -12576,8 +12817,8 @@ async function captureViaCdp(input, io) {
12576
12817
  const browser = version?.Browser ? String(version.Browser) : `attached ${input.endpoint}`;
12577
12818
  const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
12578
12819
  if (!target?.id || !target.webSocketDebuggerUrl) {
12579
- throw new CliError28({
12580
- code: CliErrorCode28.SERVER_ERROR,
12820
+ throw new CliError29({
12821
+ code: CliErrorCode31.SERVER_ERROR,
12581
12822
  message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
12582
12823
  context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
12583
12824
  });
@@ -12607,7 +12848,7 @@ async function captureViaCdp(input, io) {
12607
12848
  });
12608
12849
  if (r.exceptionDetails) {
12609
12850
  const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
12610
- throw new CliError28({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
12851
+ throw new CliError29({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
12611
12852
  }
12612
12853
  evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
12613
12854
  }
@@ -12618,7 +12859,7 @@ async function captureViaCdp(input, io) {
12618
12859
  const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
12619
12860
  const shot = await session.send("Page.captureScreenshot", { format: "png" });
12620
12861
  if (!shot.data) {
12621
- throw new CliError28({ code: CliErrorCode28.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
12862
+ throw new CliError29({ code: CliErrorCode31.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
12622
12863
  }
12623
12864
  await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
12624
12865
  return { dom, browser, evalResult, navigated, minted };
@@ -12640,7 +12881,7 @@ var defaultCdpIo = {
12640
12881
  openSocket: (wsUrl) => new Promise((resolve3, reject) => {
12641
12882
  const Ctor = globalThis.WebSocket;
12642
12883
  if (!Ctor) {
12643
- reject(new CliError28({ code: CliErrorCode28.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
12884
+ reject(new CliError29({ code: CliErrorCode31.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
12644
12885
  return;
12645
12886
  }
12646
12887
  const ws = new Ctor(wsUrl);
@@ -12663,7 +12904,7 @@ var defaultCdpIo = {
12663
12904
 
12664
12905
  // src/commands/chiron-page-playwright.ts
12665
12906
  import path13 from "path";
12666
- import { CliError as CliError29, CliErrorCode as CliErrorCode29 } from "@hcmai/sdk";
12907
+ import { CliError as CliError30, CliErrorCode as CliErrorCode32 } from "@hcmai/sdk";
12667
12908
  function playwrightCacheRoot(probe) {
12668
12909
  const override = probe.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
12669
12910
  if (override === "0" && probe.packageRoot) return path13.join(probe.packageRoot, ".local-browsers");
@@ -12706,8 +12947,8 @@ function discoverPlaywrightBrowser(probe) {
12706
12947
  const explicit = probe.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
12707
12948
  if (explicit) {
12708
12949
  if (probe.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
12709
- throw new CliError29({
12710
- code: CliErrorCode29.INVALID_ARGUMENT,
12950
+ throw new CliError30({
12951
+ code: CliErrorCode32.INVALID_ARGUMENT,
12711
12952
  message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
12712
12953
  context: { nextStep: "\u6307\u5230 Playwright \u88C5\u7684 chrome-headless-shell / chrome \u4E8C\u8FDB\u5236\uFF0C\u6216\u53BB\u6389\u8FD9\u4E2A\u53D8\u91CF\u8BA9 CLI \u81EA\u5DF1\u627E" }
12713
12954
  });
@@ -12749,8 +12990,8 @@ async function captureViaPlaywright(input) {
12749
12990
  }
12750
12991
  }
12751
12992
  if (!browser) {
12752
- throw new CliError29({
12753
- code: CliErrorCode29.SERVER_ERROR,
12993
+ throw new CliError30({
12994
+ code: CliErrorCode32.SERVER_ERROR,
12754
12995
  message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
12755
12996
  context: {
12756
12997
  nextStep: "\u88C5\u4E00\u4EFD Playwright \u7684 Chromium\uFF1Anpx playwright install chromium-headless-shell\uFF08\u6216 chromium\uFF09\uFF1B\u5DF2\u7ECF\u88C5\u4E86\u4F46\u4E0D\u5728\u7F3A\u7701\u7F13\u5B58\u76EE\u5F55\u5C31 export PLAYWRIGHT_BROWSERS_PATH=<\u76EE\u5F55> \u6216 HCM_PLAYWRIGHT_EXECUTABLE=<\u4E8C\u8FDB\u5236>\uFF1B\u6C99\u7BB1\u8FDE headless shell \u90FD\u8D77\u4E0D\u4E86\u65F6\uFF0C\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u5E76\u7528 --cdp \u8FDE"
@@ -12770,7 +13011,7 @@ async function captureViaPlaywright(input) {
12770
13011
  evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
12771
13012
  } catch (e) {
12772
13013
  const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
12773
- throw new CliError29({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
13014
+ throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
12774
13015
  }
12775
13016
  }
12776
13017
  const dom = await page.content();
@@ -12794,13 +13035,13 @@ function judgePageContent(input) {
12794
13035
  function parseViewport(size) {
12795
13036
  const m = /^(\d+)x(\d+)$/.exec(size.trim());
12796
13037
  if (!m) {
12797
- throw new CliError30({ code: CliErrorCode30.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
13038
+ throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
12798
13039
  }
12799
13040
  const width = Number(m[1]);
12800
13041
  const height = Number(m[2]);
12801
13042
  if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
12802
- throw new CliError30({
12803
- code: CliErrorCode30.INVALID_ARGUMENT,
13043
+ throw new CliError31({
13044
+ code: CliErrorCode33.INVALID_ARGUMENT,
12804
13045
  message: `--size \u8D85\u51FA\u8303\u56F4\uFF1A\u5BBD ${VIEWPORT_MIN.width}..${VIEWPORT_MAX.width}\u3001\u9AD8 ${VIEWPORT_MIN.height}..${VIEWPORT_MAX.height}\uFF0C\u6536\u5230\u7684\u662F ${size}`
12805
13046
  });
12806
13047
  }
@@ -12810,23 +13051,23 @@ function parseWaitMs(raw) {
12810
13051
  if (raw === void 0) return 1e4;
12811
13052
  const value = typeof raw === "number" ? raw : Number(raw);
12812
13053
  if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
12813
- throw new CliError30({ code: CliErrorCode30.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
13054
+ throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
12814
13055
  }
12815
13056
  return value;
12816
13057
  }
12817
13058
  function resolveEvidenceTarget(projectRoot, out) {
12818
13059
  if (!out?.trim()) {
12819
- throw new CliError30({ code: CliErrorCode30.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
13060
+ throw new CliError31({ code: CliErrorCode33.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
12820
13061
  }
12821
13062
  if (!out.endsWith(".png")) {
12822
- throw new CliError30({ code: CliErrorCode30.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
13063
+ throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
12823
13064
  }
12824
13065
  const root = path14.resolve(projectRoot);
12825
13066
  const evidenceRoot = path14.join(root, EVIDENCE_DIR);
12826
13067
  const absolute = path14.resolve(root, out);
12827
13068
  if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path14.sep)) {
12828
- throw new CliError30({
12829
- code: CliErrorCode30.INVALID_ARGUMENT,
13069
+ throw new CliError31({
13070
+ code: CliErrorCode33.INVALID_ARGUMENT,
12830
13071
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
12831
13072
  });
12832
13073
  }
@@ -12874,8 +13115,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
12874
13115
  const canonicalParent = await deps.realpath(path14.dirname(absolute));
12875
13116
  if (canonicalRoot === null || canonicalParent === null) return;
12876
13117
  if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path14.sep)) {
12877
- throw new CliError30({
12878
- code: CliErrorCode30.INVALID_ARGUMENT,
13118
+ throw new CliError31({
13119
+ code: CliErrorCode33.INVALID_ARGUMENT,
12879
13120
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
12880
13121
  });
12881
13122
  }
@@ -12884,8 +13125,8 @@ async function runChironPage(target, args, deps) {
12884
13125
  const sitePath = normalizeTarget(target);
12885
13126
  const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
12886
13127
  if (expect.length === 0) {
12887
- throw new CliError30({
12888
- code: CliErrorCode30.MISSING_FLAG,
13128
+ throw new CliError31({
13129
+ code: CliErrorCode33.MISSING_FLAG,
12889
13130
  message: "\u81F3\u5C11\u8981\u4F20\u4E00\u6761 --expect-text\uFF08\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF09\u3002\u53EA\u5224\u300C\u622A\u51FA\u56FE\u4E86\u300D\u4E0D\u7B97\u9A8C\u6536\uFF1A\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\u3001\u767D\u5C4F\u90FD\u80FD\u622A\u51FA\u56FE\u3002"
12890
13131
  });
12891
13132
  }
@@ -12895,8 +13136,8 @@ async function runChironPage(target, args, deps) {
12895
13136
  const root = path14.resolve(args.project ?? ".");
12896
13137
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
12897
13138
  if (await deps.present(absolute)) {
12898
- throw new CliError30({
12899
- code: CliErrorCode30.INVALID_ARGUMENT,
13139
+ throw new CliError31({
13140
+ code: CliErrorCode33.INVALID_ARGUMENT,
12900
13141
  message: `\u622A\u56FE\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8986\u76D6\uFF1A${absolute}\u3002\u6362\u4E2A --out\uFF0C\u6216\u5148\u628A\u65E7\u8BC1\u636E\u632A\u8D70\u3002`
12901
13142
  });
12902
13143
  }
@@ -12908,8 +13149,8 @@ async function runChironPage(target, args, deps) {
12908
13149
  const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
12909
13150
  const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
12910
13151
  if (evalJs && !endpoint && !usePlaywright) {
12911
- throw new CliError30({
12912
- code: CliErrorCode30.INVALID_ARGUMENT,
13152
+ throw new CliError31({
13153
+ code: CliErrorCode33.INVALID_ARGUMENT,
12913
13154
  message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
12914
13155
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
12915
13156
  });
@@ -12927,10 +13168,10 @@ async function runChironPage(target, args, deps) {
12927
13168
  try {
12928
13169
  captured = endpoint ? await deps.captureAttached({ endpoint, viewport, waitMs, evalJs, screenshot: absolute, mintUrl: mint }) : await deps.capturePlaywright({ viewport, waitMs, evalJs, screenshot: absolute, browser: playwrightBrowser, mintUrl: mint });
12929
13170
  } catch (e) {
12930
- if (e instanceof CliError30) throw new CliError30({ code: e.code, message: redactTicket(e.message), context: e.context });
13171
+ if (e instanceof CliError31) throw new CliError31({ code: e.code, message: redactTicket(e.message), context: e.context });
12931
13172
  const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
12932
- throw new CliError30({
12933
- code: CliErrorCode30.SERVER_ERROR,
13173
+ throw new CliError31({
13174
+ code: CliErrorCode33.SERVER_ERROR,
12934
13175
  message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
12935
13176
  context: {
12936
13177
  nextStep: endpoint ? `\u6838\u4E00\u773C ${endpoint}/json/version \u80FD\u4E0D\u80FD\u6253\u5F00\uFF1BChrome \u8981\u5E26 --remote-debugging-port \u8D77\uFF0C\u4E14\u6C99\u7BB1\u653E\u884C\u4E86\u8FD9\u4E2A\u7AEF\u53E3` : "npx playwright install chromium-headless-shell \u540E\u91CD\u8DD1\uFF1B\u6216 HCM_CHIRON_PAGE_DRIVER=spawn \u8D70\u8001\u8DEF\u5F84\u5BF9\u7167"
@@ -12946,8 +13187,8 @@ async function runChironPage(target, args, deps) {
12946
13187
  mode = "spawn";
12947
13188
  const browser = deps.findBrowser();
12948
13189
  if (!browser) {
12949
- throw new CliError30({
12950
- code: CliErrorCode30.INVALID_ARGUMENT,
13190
+ throw new CliError31({
13191
+ code: CliErrorCode33.INVALID_ARGUMENT,
12951
13192
  message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
12952
13193
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF08\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\uFF1B\u6216\u88C5\u4E00\u4E2A Chrome / HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84\uFF1B\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
12953
13194
  });
@@ -12955,8 +13196,8 @@ async function runChironPage(target, args, deps) {
12955
13196
  minted = await mint();
12956
13197
  const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
12957
13198
  if (!result.ok) {
12958
- throw new CliError30({
12959
- code: CliErrorCode30.SERVER_ERROR,
13199
+ throw new CliError31({
13200
+ code: CliErrorCode33.SERVER_ERROR,
12960
13201
  message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
12961
13202
  context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
12962
13203
  });
@@ -12966,7 +13207,7 @@ async function runChironPage(target, args, deps) {
12966
13207
  }
12967
13208
  const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
12968
13209
  if (bytes === 0) {
12969
- throw new CliError30({ code: CliErrorCode30.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
13210
+ throw new CliError31({ code: CliErrorCode33.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
12970
13211
  }
12971
13212
  const verdict = judgePageContent({ dom, expect, reject });
12972
13213
  return {
@@ -13029,13 +13270,13 @@ var defaultChironPageDeps = {
13029
13270
  const envCfg = await loadEnv6(ctx.env);
13030
13271
  const frontend = ctx.frontend ?? envCfg.frontend;
13031
13272
  if (!frontend?.trim()) {
13032
- throw new CliError30({
13033
- code: CliErrorCode30.INVALID_ARGUMENT,
13273
+ throw new CliError31({
13274
+ code: CliErrorCode33.INVALID_ARGUMENT,
13034
13275
  message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
13035
13276
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
13036
13277
  });
13037
13278
  }
13038
- const client3 = HcmClient24.fromAuthContext(ctx);
13279
+ const client3 = HcmClient25.fromAuthContext(ctx);
13039
13280
  const { ticket } = await mintBrowserTicket(client3, ctx.env)();
13040
13281
  return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
13041
13282
  },
@@ -13097,7 +13338,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
13097
13338
  try {
13098
13339
  const receipt = await runChironPage(target, args, deps);
13099
13340
  const fmt = args.output ?? "table";
13100
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(receipt, { format: fmt }) + "\n");
13341
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject28(receipt, { format: fmt }) + "\n");
13101
13342
  else process.stdout.write(renderChironPage(receipt) + "\n");
13102
13343
  process.exitCode = receipt.ok ? 0 : 3;
13103
13344
  } catch (e) {
@@ -13112,11 +13353,11 @@ import { randomUUID } from "crypto";
13112
13353
  import { promises as fs13 } from "fs";
13113
13354
  import path15 from "path";
13114
13355
  import yaml2 from "js-yaml";
13115
- import { formatObject as formatObject28 } from "@hcmai/sdk";
13356
+ import { formatObject as formatObject29 } from "@hcmai/sdk";
13116
13357
 
13117
13358
  // src/commands/delivery-action-policy.ts
13118
13359
  init_auth_guard();
13119
- import { HcmClient as HcmClient25, classifyEffect } from "@hcmai/sdk";
13360
+ import { HcmClient as HcmClient26, classifyEffect } from "@hcmai/sdk";
13120
13361
 
13121
13362
  // src/commands/delivery.ts
13122
13363
  import { createHash as createHash6 } from "crypto";
@@ -13436,6 +13677,12 @@ function classify(argv, actionResolution) {
13436
13677
  if (name === "chat") {
13437
13678
  return forbidden("agent-autonomy", "\u987E\u95EE\u63D2\u4EF6\u4E0D\u901A\u8FC7\u5D4C\u5957\u6570\u5B57\u5458\u5DE5\u5BF9\u8BDD\u6269\u5927\u81EA\u6CBB\u6267\u884C\u9762\u3002");
13438
13679
  }
13680
+ if (name === "interactions") {
13681
+ return forbidden(
13682
+ "agent-autonomy",
13683
+ "\u987E\u95EE\u63D2\u4EF6\u4E0D\u4EE3\u66FF\u7528\u6237\u6279\u51C6\u6570\u5B57\u5458\u5DE5\u7684\u6682\u505C\uFF1A\u90A3\u662F\u5728\u66FF\u5B83\u653E\u884C\u4E00\u6B21\u5199\u5165\u3002"
13684
+ );
13685
+ }
13439
13686
  return forbidden(
13440
13687
  "unknown-command",
13441
13688
  `\u672A\u77E5\u547D\u4EE4\u6309\u6700\u9AD8\u98CE\u9669\u5173\u95ED\uFF1A\u89E3\u6790\u5230\u7684\u547D\u4EE4\u662F ${name || "(\u7A7A)"}` + (subcommand ? ` ${subcommand}` : "") + "\u3002next_step=\u7528 `hcm --help` \u6838\u5BF9\u547D\u4EE4\u540D\uFF1B\u82E5\u4F60\u786E\u4FE1\u8FD9\u6761\u547D\u4EE4\u5B58\u5728\uFF0C\u5148\u8DD1 `hcm upgrade` \u770B CLI \u662F\u4E0D\u662F\u65E7\u7248\uFF08\u98CE\u63A7\u8868\u968F CLI \u53D1\u5E03\u66F4\u65B0\uFF09"
@@ -13631,7 +13878,7 @@ async function resolveCoreAction(request) {
13631
13878
  as: request.identity,
13632
13879
  profile: request.profile
13633
13880
  });
13634
- const description = await HcmClient25.fromAuthContext(auth).describe(request.model);
13881
+ const description = await HcmClient26.fromAuthContext(auth).describe(request.model);
13635
13882
  const named = description.actions.filter((action) => action.name === request.action);
13636
13883
  if (named.length === 0) {
13637
13884
  const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
@@ -14073,7 +14320,7 @@ async function chironTestCommand(target, args, deps) {
14073
14320
  }
14074
14321
  const fmt = args.output ?? "table";
14075
14322
  if (fmt === "json" || fmt === "yaml") {
14076
- process.stdout.write(formatObject28({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
14323
+ process.stdout.write(formatObject29({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
14077
14324
  } else {
14078
14325
  for (const c of report) {
14079
14326
  process.stdout.write(`
@@ -14102,11 +14349,11 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
14102
14349
  init_auth_guard();
14103
14350
  init_exit();
14104
14351
  import {
14105
- HcmClient as HcmClient26,
14352
+ HcmClient as HcmClient27,
14106
14353
  ReconLayout,
14107
14354
  ROUND_EXIT_CODES,
14108
14355
  computeReconSourceKey,
14109
- formatObject as formatObject29,
14356
+ formatObject as formatObject30,
14110
14357
  fromAxiosError as fromAxiosError22,
14111
14358
  httpProbe as httpProbe3,
14112
14359
  inspectRound,
@@ -14117,7 +14364,7 @@ var DEFAULT_CAPABILITIES = "default";
14117
14364
  async function deliveryReconCommand(args) {
14118
14365
  try {
14119
14366
  const ctx = await getActiveAuthContextFromCli(args);
14120
- const client3 = HcmClient26.fromAuthContext(ctx);
14367
+ const client3 = HcmClient27.fromAuthContext(ctx);
14121
14368
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
14122
14369
  const sourceKey = await computeReconSourceKey(probe);
14123
14370
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -14126,7 +14373,7 @@ async function deliveryReconCommand(args) {
14126
14373
  onlyModel: args.model ?? null,
14127
14374
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
14128
14375
  });
14129
- process.stdout.write(formatObject29(summary, { format: args.output ?? "json" }) + "\n");
14376
+ process.stdout.write(formatObject30(summary, { format: args.output ?? "json" }) + "\n");
14130
14377
  } catch (e) {
14131
14378
  const err = e;
14132
14379
  if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
@@ -14140,7 +14387,7 @@ async function deliveryReconRoundCommand(args) {
14140
14387
  const result = inspectRound(args.dir ?? ".");
14141
14388
  const fmt = args.output ?? "json";
14142
14389
  if (fmt !== "json") process.stdout.write(renderRound(result));
14143
- process.stdout.write(formatObject29(result, { format: fmt }) + "\n");
14390
+ process.stdout.write(formatObject30(result, { format: fmt }) + "\n");
14144
14391
  code = ROUND_EXIT_CODES[result.state];
14145
14392
  } catch (e) {
14146
14393
  exitWithError(e);
@@ -14160,7 +14407,7 @@ import {
14160
14407
  DRY_RUN_TAIL,
14161
14408
  DriftDetected,
14162
14409
  FORCE_STALE_FLAG,
14163
- HcmClient as HcmClient27,
14410
+ HcmClient as HcmClient28,
14164
14411
  fetchReconIdentity as fetchReconIdentity3,
14165
14412
  INIT_EXIT_CODES,
14166
14413
  JOURNAL_STOP_KINDS,
@@ -14300,7 +14547,7 @@ async function authOrSignpost(args, cmd) {
14300
14547
  }
14301
14548
  async function deliverySeedPlanCommand(args) {
14302
14549
  const ctx = await authOrSignpost(args, "plan");
14303
- const client3 = HcmClient27.fromAuthContext(ctx);
14550
+ const client3 = HcmClient28.fromAuthContext(ctx);
14304
14551
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
14305
14552
  }
14306
14553
  function seedClient(client3, ctx) {
@@ -14474,7 +14721,7 @@ async function runSeedApply(args, client3) {
14474
14721
  }
14475
14722
  async function deliverySeedApplyCommand(args) {
14476
14723
  const ctx = await authOrSignpost(args, "apply");
14477
- const client3 = HcmClient27.fromAuthContext(ctx);
14724
+ const client3 = HcmClient28.fromAuthContext(ctx);
14478
14725
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
14479
14726
  }
14480
14727
  async function runSeedVerify(args, client3) {
@@ -14498,7 +14745,7 @@ async function deliverySeedVerifyCommand(args) {
14498
14745
  return;
14499
14746
  }
14500
14747
  const ctx = await authOrSignpost(args, "verify");
14501
- const client3 = HcmClient27.fromAuthContext(ctx);
14748
+ const client3 = HcmClient28.fromAuthContext(ctx);
14502
14749
  process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
14503
14750
  }
14504
14751
 
@@ -14613,7 +14860,7 @@ import {
14613
14860
  CHANGE_STATES,
14614
14861
  CHANGE_UNKNOWN,
14615
14862
  CODE_WORDS,
14616
- HcmClient as HcmClient28,
14863
+ HcmClient as HcmClient29,
14617
14864
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
14618
14865
  META_WRITE_STEPS,
14619
14866
  META_VERIFY_STEPS,
@@ -14841,7 +15088,7 @@ function lowerCaseHeaders2(headers) {
14841
15088
  }
14842
15089
  async function deliveryMetaCommand(args) {
14843
15090
  const ctx = await getActiveAuthContextFromCli(args);
14844
- const client3 = HcmClient28.fromAuthContext(ctx);
15091
+ const client3 = HcmClient29.fromAuthContext(ctx);
14845
15092
  process.exitCode = await runDeliveryMeta(
14846
15093
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
14847
15094
  metaClient(client3, ctx)
@@ -14853,7 +15100,7 @@ init_auth_guard();
14853
15100
  init_exit();
14854
15101
  import {
14855
15102
  computeReconSourceKey as computeReconSourceKey2,
14856
- HcmClient as HcmClient29,
15103
+ HcmClient as HcmClient30,
14857
15104
  httpProbe as httpProbe4,
14858
15105
  ReconLayout as ReconLayout2,
14859
15106
  runTriageRound
@@ -14909,7 +15156,7 @@ async function runTriage(args) {
14909
15156
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
14910
15157
  }
14911
15158
  const ctx = await getActiveAuthContextFromCli(args);
14912
- const client3 = HcmClient29.fromAuthContext(ctx);
15159
+ const client3 = HcmClient30.fromAuthContext(ctx);
14913
15160
  const probe = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
14914
15161
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
14915
15162
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -14938,25 +15185,25 @@ async function deliveryTriageCommand(args) {
14938
15185
  init_auth_guard();
14939
15186
  init_exit();
14940
15187
  import {
14941
- HcmClient as HcmClient30,
15188
+ HcmClient as HcmClient31,
14942
15189
  adminResetPassword,
14943
- formatObject as formatObject30,
15190
+ formatObject as formatObject31,
14944
15191
  fromAxiosError as fromAxiosError23,
14945
- CliError as CliError31,
14946
- CliErrorCode as CliErrorCode31
15192
+ CliError as CliError32,
15193
+ CliErrorCode as CliErrorCode34
14947
15194
  } from "@hcmai/sdk";
14948
15195
  function buildAdminResetPasswordRequest(args, password) {
14949
15196
  const hasId = Boolean(args.id);
14950
15197
  const hasUsername = Boolean(args.username);
14951
15198
  if (hasId === hasUsername) {
14952
- throw new CliError31({
14953
- code: CliErrorCode31.INVALID_ARGUMENT,
15199
+ throw new CliError32({
15200
+ code: CliErrorCode34.INVALID_ARGUMENT,
14954
15201
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
14955
15202
  });
14956
15203
  }
14957
15204
  if (!password) {
14958
- throw new CliError31({
14959
- code: CliErrorCode31.INVALID_ARGUMENT,
15205
+ throw new CliError32({
15206
+ code: CliErrorCode34.INVALID_ARGUMENT,
14960
15207
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
14961
15208
  });
14962
15209
  }
@@ -14972,9 +15219,9 @@ async function userResetPasswordCommand(args) {
14972
15219
  try {
14973
15220
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
14974
15221
  const request = buildAdminResetPasswordRequest(args, password);
14975
- const client3 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
15222
+ const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
14976
15223
  const result = await adminResetPassword(client3.raw(), request);
14977
- process.stdout.write(formatObject30(result, { format: args.output ?? "json" }) + "\n");
15224
+ process.stdout.write(formatObject31(result, { format: args.output ?? "json" }) + "\n");
14978
15225
  } catch (cause) {
14979
15226
  const err = cause;
14980
15227
  if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
@@ -14985,8 +15232,8 @@ async function promptPasswordTwice() {
14985
15232
  const password = await promptSecret("\u65B0\u5BC6\u7801: ");
14986
15233
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
14987
15234
  if (password !== confirmation) {
14988
- throw new CliError31({
14989
- code: CliErrorCode31.INVALID_ARGUMENT,
15235
+ throw new CliError32({
15236
+ code: CliErrorCode34.INVALID_ARGUMENT,
14990
15237
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
14991
15238
  });
14992
15239
  }
@@ -14997,19 +15244,19 @@ async function promptPasswordTwice() {
14997
15244
  init_exit();
14998
15245
  init_auth_guard();
14999
15246
  import {
15000
- HcmClient as HcmClient31,
15001
- formatObject as formatObject31,
15247
+ HcmClient as HcmClient32,
15248
+ formatObject as formatObject32,
15002
15249
  fromAxiosError as fromAxiosError24
15003
15250
  } from "@hcmai/sdk";
15004
15251
  async function modelsCommand(keyword, args) {
15005
15252
  try {
15006
- const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
15253
+ const client3 = HcmClient32.fromAuthContext(await getActiveAuthContextFromCli(args));
15007
15254
  const all = await client3.listModels();
15008
15255
  const needle = keyword?.trim().toLowerCase();
15009
15256
  const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
15010
15257
  const fmt = args.output ?? "table";
15011
15258
  if (fmt !== "table") {
15012
- process.stdout.write(formatObject31({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
15259
+ process.stdout.write(formatObject32({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
15013
15260
  process.exitCode = 0;
15014
15261
  return;
15015
15262
  }
@@ -15222,7 +15469,24 @@ program.command("create <Model>").description("\u521B\u5EFA\u4E00\u6761 Model \u
15222
15469
  program.command("delete <Model>").description("\u5220\u9664\u4E00\u6761 Model \u8BB0\u5F55\uFF08\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF1B\u90E8\u5206 Model \u4F1A\u6267\u884C\u4E1A\u52A1\u64A4\u9500\uFF09").option("--id <id>", "\u76EE\u6807\u5B9E\u4F53 ID\uFF08\u5FC5\u586B\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((m, opts) => deleteCommand(m, opts));
15223
15470
  program.command("import <path>").description("\u6CE8\u5165 DataPackage YAML \u6570\u636E\u96C6\uFF08\u76EE\u5F55\u6216\u5355\u6587\u4EF6\uFF0C\u8D70\u540E\u7AEF\u5B8C\u6574\u6821\u9A8C\uFF09").option("--dry-run", "\u53EA\u8DD1\u5BA2\u6237\u7AEF\u9759\u6001\u6821\u9A8C\uFF0C\u4E0D\u843D\u5E93\uFF08\u89C1 spec \xA78 \u9650\u5236\uFF09").option("--update-only", "\u5DF2\u5B58\u5728\uFF08\u6309 key_field\uFF09\u5219 PUT \u66F4\u65B0\uFF0C\u5426\u5219 create").option("--on-error <mode>", "stop | continue\uFF08\u9ED8\u8BA4 continue\uFF09", "continue").option("--report <path>", "\u5199 JSON \u6CE8\u5165\u62A5\u544A\uFF08\u9010\u884C\u7ED3\u679C + key\u2192id \u6620\u5C04\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((p, opts) => importCommand(p, opts));
15224
15471
  program.command("models [keyword]").description("\u5217\u51FA\u76EE\u6807\u73AF\u5883\u6709\u54EA\u4E9B Model\uFF08describe \u7684\u4E0A\u4E00\u6B65\uFF09\uFF1B\u53EF\u5E26\u5173\u952E\u5B57\u8FC7\u6EE4").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((keyword, opts) => modelsCommand(keyword, opts));
15225
- program.command("describe <Model>").description("\u67E5\u770B Model \u5143\u6570\u636E\uFF08\u5B57\u6BB5\u3001\u5173\u7CFB\u3001Action \u5217\u8868\uFF09").option("-v, --verbose", "\u663E\u793A\u5B57\u6BB5\u63CF\u8FF0\u4E0E enum \u53D6\u503C").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => describeCommand(m, opts));
15472
+ program.command("describe <Model>").description("\u67E5\u770B Model \u5143\u6570\u636E\uFF08\u5B57\u6BB5\u3001\u5173\u7CFB\u3001Action \u5217\u8868\uFF09").option("-v, --verbose", "\u663E\u793A enum \u53D6\u503C\u57DF\uFF0C\u4EE5\u53CA\u81EA\u5B9A\u4E49\u5B57\u6BB5\u7684\u63CF\u8FF0").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => describeCommand(m, opts));
15473
+ var interactions = program.command("interactions").description("\u770B\u89C1\u5E76\u5904\u7406\u4F1A\u8BDD\u91CC\u672A\u51B3\u7684\u6682\u505C\uFF08\u786E\u8BA4 / \u8FFD\u95EE\uFF09\u2014\u2014\u4E0D\u53D1\u65B0\u6D88\u606F\uFF0C\u76F4\u63A5\u56DE\u5230\u90A3\u4E00\u6761");
15474
+ var withInteractionCommonOpts = (cmd) => {
15475
+ cmd.option("--conversation <id>", "\u76EE\u6807\u4F1A\u8BDD\uFF1B\u4E0D\u4F20\u5219\u7528\u672C env \u4E0A\u4E00\u6B21\u804A\u7684\u90A3\u4E2A").option("--agent <uuid>", "\u6307\u5B9A agent UUID\uFF08\u9ED8\u8BA4\u5185\u7F6E analyst\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atext | json", "text");
15476
+ return cmd;
15477
+ };
15478
+ withInteractionCommonOpts(
15479
+ interactions.command("list").description("\u5217\u51FA\u8BE5\u4F1A\u8BDD\u4E0A\u4ECD\u672A\u51B3\u7684\u6682\u505C")
15480
+ ).action((opts) => interactionsListCommand(opts));
15481
+ withInteractionCommonOpts(
15482
+ interactions.command("approve <interactionId>").description("\u6279\u51C6\u4E00\u6761\u5199\u786E\u8BA4\u2014\u2014\u5DE5\u5177\u4F1A\u771F\u7684\u518D\u6267\u884C\u4E00\u6B21").option("--timeout <sec>", "\u7B49\u7EC8\u6001\u7684\u79D2\u6570\uFF08\u7EED\u8DD1\u662F\u4E00\u6B21\u5B8C\u6574 LLM \u8F6E\u6B21\uFF09", "180")
15483
+ ).action((id, opts) => interactionsRespondCommand("approve", id, opts));
15484
+ withInteractionCommonOpts(
15485
+ interactions.command("reject <interactionId>").description("\u62D2\u7EDD\u4E00\u6761\u5199\u786E\u8BA4").option("--reason <text>", "\u62D2\u7EDD\u7406\u7531\uFF08\u4F1A\u6CE8\u5165\u7EED\u8DD1\u4E0A\u4E0B\u6587\uFF09").option("--timeout <sec>", "\u7B49\u7EC8\u6001\u7684\u79D2\u6570", "180")
15486
+ ).action((id, opts) => interactionsRespondCommand("reject", id, opts));
15487
+ withInteractionCommonOpts(
15488
+ interactions.command("answer <interactionId>").description("\u56DE\u7B54\u4E00\u6761\u8FFD\u95EE\uFF08ASK\uFF09").option("--answer <text>", "\u7B54\u6848\u6587\u672C\uFF08\u5FC5\u586B\uFF09").option("--choice <index>", "\u9009\u9879\u4E0B\u6807\uFF0C\u4ECE 0 \u8D77\uFF1B\u53EA\u4F5C\u8865\u5145\uFF0C\u4E0D\u80FD\u66FF\u4EE3 --answer").option("--timeout <sec>", "\u7B49\u7EC8\u6001\u7684\u79D2\u6570", "180")
15489
+ ).action((id, opts) => interactionsRespondCommand("answer", id, opts));
15226
15490
  program.command("chat [prompt]").description("\u4E0E\u6570\u5B57\u5458\u5DE5 Moirai \u5BF9\u8BDD\uFF1B\u6709 prompt \u5355\u53D1\u540E\u9000\u51FA\uFF0C\u4E0D\u5E26 prompt \u8FDB\u5165 REPL").option("--agent <key>", "\u6307\u5B9A agent UUID\uFF08\u9ED8\u8BA4\u4F7F\u7528 analyst \u5185\u7F6E agent\uFF09").option("--resume <id>", "\u7EED\u63A5\u6307\u5B9A conversation\uFF1B\u4E0D\u4F20\u5219\u9ED8\u8BA4\u5F00\u65B0\u4F1A\u8BDD").option("--conversation <id>", "[deprecated] \u7528 --resume \u66FF\u4EE3\uFF1B\u4F20 NEW \u7B49\u4EF7\u9ED8\u8BA4\u65B0\u4F1A\u8BDD").option("--list", "\u5217\u51FA\u6700\u8FD1\u4F1A\u8BDD\uFF0C\u4E0D\u8FDB\u5165\u804A\u5929").option(
15227
15491
  "--events [conversationId]",
15228
15492
  "\u53EA\u8BFB\u67E5\u770B\u6307\u5B9A conversation \u7684 timeline/event \u6D41\uFF1B\u4E5F\u53EF\u914D --resume <id>"