@hcmai/cli 0.15.9 → 0.15.11

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
@@ -133,6 +133,7 @@ import {
133
133
  resolveEnvContext,
134
134
  printResolvedEnvironment,
135
135
  resolveActiveIdentity,
136
+ identityMetaFile,
136
137
  listIdentities,
137
138
  TokenStore,
138
139
  readSessionPrincipal,
@@ -164,6 +165,19 @@ async function ensureActiveAuth(args) {
164
165
  envName
165
166
  );
166
167
  let idMeta = await loadIdentity(identityName);
168
+ if (!idMeta.env) {
169
+ throw new CliError2({
170
+ code: CliErrorCode.IDENTITY_META_INCOMPLETE,
171
+ message: `identity '${identityName}' \u7684\u5143\u6570\u636E\u4E0D\u5B8C\u6574\uFF1A\u7F3A env\u3002\u8FD9\u662F\u4E00\u6B21**\u4E2D\u65AD\u7684\u767B\u5F55\u8FC1\u79FB**\u7559\u4E0B\u7684\u534A\u6210\u54C1\uFF0C\u4E0D\u662F\u300C\u8FD9\u6761\u8EAB\u4EFD\u5C5E\u4E8E\u522B\u7684\u73AF\u5883\u300D\u3002\u6587\u4EF6\uFF1A${identityMetaFile(identityName)}`,
172
+ context: {
173
+ // 🔴 这条出口是走过的,不是写着好看:本仓 PR #273 之后,重登会把这份元数据
174
+ // 整个写成完整形状(`saveIdentity` 一次性写出带 env/username/tenantId 的那份),
175
+ // 并由 identity-meta-incomplete.test.ts 里「报错自陈的那条出口必须真的走得通」
176
+ // 那条用例真跑一遍钉住(点名不点位置:用例一换顺序,按序号写的注释会静默变假)。
177
+ nextStep: `hcm login --env ${envName} \u91CD\u767B\u5373\u53EF\u4FEE\u590D\uFF1B\u82E5\u4ECD\u5931\u8D25\uFF0C\u5220\u6389\u4E0A\u9762\u90A3\u4E2A\u6587\u4EF6\u540E\u518D\u767B`
178
+ }
179
+ });
180
+ }
167
181
  if (idMeta.env !== envName) {
168
182
  throw new CliError2({
169
183
  code: CliErrorCode.IDENTITY_NOT_IN_ENV,
@@ -864,7 +878,11 @@ var StreamPresenter_exports = {};
864
878
  __export(StreamPresenter_exports, {
865
879
  StreamPresenter: () => StreamPresenter
866
880
  });
867
- import { createV4Reducer, truncateDisplay } from "@hcmai/sdk";
881
+ import {
882
+ CliErrorCode as CliErrorCode16,
883
+ createV4Reducer,
884
+ truncateDisplay
885
+ } from "@hcmai/sdk";
868
886
  var debug, StreamPresenter;
869
887
  var init_StreamPresenter = __esm({
870
888
  "src/streaming/StreamPresenter.ts"() {
@@ -1014,7 +1032,7 @@ var init_StreamPresenter = __esm({
1014
1032
  process.stdout.write(JSON.stringify(ev) + "\n");
1015
1033
  if (ev.type === "response.completed") return this.result("completed");
1016
1034
  if (ev.type === "response.interrupted") return this.result("interrupted");
1017
- if (ev.type === "response.failed") throw this.toError(ev);
1035
+ if (ev.type === "response.failed") throw await this.toError(ev);
1018
1036
  if (ev.type === "message.stop" && !ev.payload?.parentToolUseId) {
1019
1037
  this.sawRootStop = true;
1020
1038
  }
@@ -1028,7 +1046,7 @@ var init_StreamPresenter = __esm({
1028
1046
  }
1029
1047
  if (ev.type === "response.failed") {
1030
1048
  this.renderer.stopSpinner();
1031
- throw this.toError(ev);
1049
+ throw await this.toError(ev);
1032
1050
  }
1033
1051
  if (ev.type === "response.interrupted") {
1034
1052
  this.renderer.showInterrupted(ev.payload?.reason ?? "UNKNOWN");
@@ -1037,7 +1055,7 @@ var init_StreamPresenter = __esm({
1037
1055
  if (ev.type === "message.stop" && !ev.payload?.parentToolUseId) {
1038
1056
  this.reducer.handle(ev.type, ev.payload ?? {});
1039
1057
  const reason = ev.payload?.stopReason;
1040
- if (reason === "error") throw this.toError(ev);
1058
+ if (reason === "error") throw await this.toError(ev);
1041
1059
  if (reason === "interrupted") {
1042
1060
  this.renderer.showInterrupted("INTERRUPTED");
1043
1061
  return this.result("interrupted");
@@ -1086,9 +1104,12 @@ var init_StreamPresenter = __esm({
1086
1104
  return { status, traceId: this.traceId, streamId: this.streamId };
1087
1105
  }
1088
1106
  // 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;
1107
+ async toError(ev) {
1108
+ const fromConn = await this.opts.serverError?.() ?? null;
1109
+ const code = ev.payload?.errorCode ?? ev.payload?.code ?? fromConn?.code;
1110
+ const message = ev.payload?.message ?? fromConn?.message;
1111
+ const err = new Error(message ?? "stream failed");
1112
+ err.code = code ?? CliErrorCode16.STREAM_FAILED_NO_SERVER_CODE;
1092
1113
  err.traceId = ev.traceId;
1093
1114
  return err;
1094
1115
  }
@@ -2095,12 +2116,6 @@ async function runInkRepl(args) {
2095
2116
  const ctx = await getActiveAuthContextFromCli(args);
2096
2117
  assertDangerWrite(ctx.environmentSafety, "\u542F\u52A8\u4EA4\u4E92\u4F1A\u8BDD\uFF08\u53EF\u80FD\u6267\u884C\u4E1A\u52A1\u5199\u5165\uFF09");
2097
2118
  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
2119
  let initialConversationId;
2105
2120
  if (args.resume && args.conversation) {
2106
2121
  throw new Error("--resume \u548C --conversation \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\uFF1B\u65B0\u547D\u4EE4\u8BF7\u7528 --resume <conversationId>");
@@ -2113,6 +2128,13 @@ async function runInkRepl(args) {
2113
2128
  } else if (args.conversation && args.conversation !== "NEW") {
2114
2129
  initialConversationId = args.conversation;
2115
2130
  }
2131
+ const ws = new WsClient({
2132
+ endpoint: conversationWebSocketEndpoint(ctx.endpoint),
2133
+ getAccessToken: () => client3.getAccessToken(),
2134
+ onTokenExpiring: () => client3.handleRefresh(),
2135
+ conversationId: initialConversationId
2136
+ });
2137
+ await ws.connect();
2116
2138
  const { waitUntilExit } = render(
2117
2139
  React3.createElement(ReplApp, {
2118
2140
  ws,
@@ -2332,6 +2354,7 @@ import {
2332
2354
  validateCliAuthorizationUrl,
2333
2355
  CLI_VERIFICATION_PATH,
2334
2356
  cliAuthorizationExpired,
2357
+ watchBrowserAuthorization,
2335
2358
  CliError as CliError4,
2336
2359
  CliErrorCode as CliErrorCode3
2337
2360
  } from "@hcmai/sdk";
@@ -2485,6 +2508,17 @@ function cancellation() {
2485
2508
  function verificationUrl(frontend) {
2486
2509
  return `${frontend.replace(/\/+$/, "")}${CLI_VERIFICATION_PATH}`;
2487
2510
  }
2511
+ var rejectionMessages = {
2512
+ tenant_mismatch: "\u6709\u4EBA\u6253\u5F00\u4E86\u6388\u6743\u94FE\u63A5\uFF0C\u4F46\u4ED6\u767B\u5F55\u7684\u79DF\u6237\u4E0D\u662F\u672C\u6B21\u767B\u5F55\u8981\u7528\u7684\u90A3\u4E2A\uFF1B\u8BF7\u6539\u7528\u672C\u6B21\u79DF\u6237\u7684\u8D26\u53F7\u6253\u5F00\u94FE\u63A5\u3002",
2513
+ account_not_usable: "\u6709\u4EBA\u6253\u5F00\u4E86\u6388\u6743\u94FE\u63A5\uFF0C\u4F46\u90A3\u4E2A\u8D26\u53F7\u5F53\u524D\u4E0D\u80FD\u767B\u5F55\uFF08\u9501\u5B9A / \u5F85\u6539\u5BC6 / \u5BC6\u7801\u8FC7\u671F\uFF09\uFF1B\u8BF7\u5148\u5728\u7F51\u9875\u89E3\u9501\u6216\u6539\u5BC6\u3002",
2514
+ tenant_inactive: "\u6709\u4EBA\u6253\u5F00\u4E86\u6388\u6743\u94FE\u63A5\uFF0C\u4F46\u8BE5\u79DF\u6237\u5F53\u524D\u4E0D\u53EF\u7528\uFF1B\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\u3002",
2515
+ credential_changed: "\u6709\u4EBA\u6253\u5F00\u4E86\u6388\u6743\u94FE\u63A5\uFF0C\u4F46\u8BE5\u8D26\u53F7\u7684\u767B\u5F55\u51ED\u636E\u521A\u53D8\u8FC7\uFF1B\u8BF7\u91CD\u65B0\u767B\u5F55\u7F51\u9875\u540E\u518D\u6253\u5F00\u94FE\u63A5\u3002",
2516
+ preview_user_mismatch: "\u6388\u6743\u9875\u4E0A\u786E\u8BA4\u65F6\u7684\u8D26\u53F7\u4E0E\u9884\u89C8\u65F6\u7684\u4E0D\u4E00\u81F4\uFF1B\u8BF7\u5728\u7F51\u9875\u91CD\u65B0\u9884\u89C8\u540E\u518D\u786E\u8BA4\u3002"
2517
+ };
2518
+ function rejectionLine(reason) {
2519
+ const known = rejectionMessages[reason];
2520
+ return known ? `${known} (${reason})` : `\u6709\u4EBA\u6253\u5F00\u4E86\u6388\u6743\u94FE\u63A5\u4F46\u88AB\u6321\u4E0B\uFF0C\u539F\u56E0\u7801\u672C\u7248 CLI \u8FD8\u4E0D\u8BA4\u8BC6 (unknown:${reason})\uFF1B\u5347\u7EA7 hcm CLI \u53EF\u770B\u5230\u5BF9\u75C7\u8BF4\u660E\u3002`;
2521
+ }
2488
2522
  async function beginDeviceLogin(input) {
2489
2523
  const cancel = cancellation();
2490
2524
  let session;
@@ -2510,7 +2544,14 @@ async function beginDeviceLogin(input) {
2510
2544
  ...input,
2511
2545
  authorization,
2512
2546
  signal: cancel.controller.signal,
2513
- onTimeout: () => process.stderr.write("\u6388\u6743\u8F6E\u8BE2\u8BF7\u6C42\u8D85\u65F6\uFF1B\u4ECD\u5728\u539F\u6388\u6743\u671F\u9650\u5185\u7B49\u5F85\uFF0C\u4E0D\u4F1A\u53D1\u8D77\u65B0\u6388\u6743\u3002\n")
2547
+ onTimeout: () => process.stderr.write("\u6388\u6743\u8F6E\u8BE2\u8BF7\u6C42\u8D85\u65F6\uFF1B\u4ECD\u5728\u539F\u6388\u6743\u671F\u9650\u5185\u7B49\u5F85\uFF0C\u4E0D\u4F1A\u53D1\u8D77\u65B0\u6388\u6743\u3002\n"),
2548
+ // 🔴 印出来但**不结束等待**:授权链接里带着 requestId,谁拿到链接谁都能打开并触发一次拒绝,
2549
+ // 在这里失败等于让任何链接持有人都能取消别人的登录。停不停由用户按 Ctrl-C 决定。
2550
+ onRejection: (rejection) => process.stderr.write(
2551
+ `${rejectionLine(rejection.reason)}
2552
+ \u4ECD\u5728\u7B49\u5F85\u672C\u6B21\u6388\u6743\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u53D6\u6D88\uFF1B\u8981\u653E\u5F03\u8BF7\u6309 Ctrl-C\u3002
2553
+ `
2554
+ )
2514
2555
  });
2515
2556
  return { session, complete: async () => {
2516
2557
  if (cancel.controller.signal.aborted) throw cancel.error(new Error("\u767B\u5F55\u5DF2\u53D6\u6D88"));
@@ -2543,6 +2584,7 @@ async function beginBrowserLogin(input) {
2543
2584
  let session;
2544
2585
  let timeout;
2545
2586
  let closing;
2587
+ let watch;
2546
2588
  let resolve3;
2547
2589
  let reject;
2548
2590
  const result = new Promise((yes, no) => {
@@ -2612,6 +2654,7 @@ async function beginBrowserLogin(input) {
2612
2654
  const close = () => {
2613
2655
  closing ??= (async () => {
2614
2656
  clearTimeout(timeout);
2657
+ watch?.stop();
2615
2658
  verifier = "";
2616
2659
  cancel.dispose();
2617
2660
  cancel.controller.abort();
@@ -2659,7 +2702,24 @@ async function beginBrowserLogin(input) {
2659
2702
  signal: cancel.controller.signal
2660
2703
  });
2661
2704
  deadline = authorization.deadline;
2662
- timeout = setTimeout(() => reject(cliAuthorizationExpired()), Math.max(1, deadline - Date.now()));
2705
+ timeout = setTimeout(
2706
+ () => reject(cliAuthorizationExpired(watch?.lastRejection(), watch?.probe())),
2707
+ Math.max(1, deadline - Date.now())
2708
+ );
2709
+ watch = watchBrowserAuthorization({
2710
+ ...input,
2711
+ requestId: authorization.requestId,
2712
+ state,
2713
+ deadline,
2714
+ signal: cancel.controller.signal,
2715
+ // 🔴 印出来但**不结束等待**:授权链接里带着 requestId,谁拿到链接谁都能打开并触发一次
2716
+ // 拒绝,在这里失败等于让任何链接持有人都能取消别人的登录。停不停由用户按 Ctrl-C 决定。
2717
+ onRejection: (rejection) => process.stderr.write(
2718
+ `${rejectionLine(rejection.reason)}
2719
+ \u4ECD\u5728\u7B49\u5F85\u672C\u6B21\u6388\u6743\uFF0C\u4E0D\u4F1A\u81EA\u52A8\u53D6\u6D88\uFF1B\u8981\u653E\u5F03\u8BF7\u6309 Ctrl-C\u3002
2720
+ `
2721
+ )
2722
+ });
2663
2723
  const url = `${verificationUrl(input.frontend)}#${new URLSearchParams({ requestId: authorization.requestId })}`;
2664
2724
  process.stderr.write(`\u8BF7\u5728\u672C\u673A\u6D4F\u89C8\u5668\u786E\u8BA4 CLI \u767B\u5F55\uFF1A${url}
2665
2725
  \u6388\u6743\u622A\u6B62\uFF1A${authorization.expiresAt}
@@ -2814,28 +2874,20 @@ async function migrateProfileTokenToIdentity(envName, identityName) {
2814
2874
  const rawAccess = await oldStore.getAccessToken();
2815
2875
  const rawRefresh = await oldStore.getRefreshToken();
2816
2876
  const newStore = TokenStore2.forIdentity(identityName);
2817
- await newStore.writeMeta(oldMeta);
2877
+ const record = { ...oldMeta };
2878
+ if (rawAccess) record.accessTokenRef = await newStore.setAccessToken(rawAccess);
2879
+ if (rawRefresh) record.refreshTokenRef = await newStore.setRefreshToken(rawRefresh);
2818
2880
  try {
2819
- if (rawAccess) {
2820
- const ref = await newStore.setAccessToken(rawAccess);
2821
- const cur = await newStore.readMeta() ?? oldMeta;
2822
- cur.accessTokenRef = ref;
2823
- await newStore.writeMeta(cur);
2824
- }
2825
- if (rawRefresh) {
2826
- const ref = await newStore.setRefreshToken(rawRefresh);
2827
- const cur = await newStore.readMeta() ?? oldMeta;
2828
- cur.refreshTokenRef = ref;
2829
- await newStore.writeMeta(cur);
2830
- }
2831
2881
  await oldStore.clear();
2832
2882
  } catch (err) {
2833
2883
  process.stderr.write(
2834
- `[hcm] event=migration_partial_failure direction=profile-to-identity identity=${identityName} reason=${JSON.stringify(String(err.message))} hint="re-run hcm login --env ${envName}"
2884
+ `[hcm] event=legacy_store_cleanup_failed direction=profile-to-identity env=${envName} identity=${identityName} reason=${JSON.stringify(String(err.message))}
2885
+ [hcm] WARNING: \u767B\u5F55\u5DF2\u5B8C\u6210\u3001\u8FD9\u4E2A\u8EAB\u4EFD\u53EF\u4EE5\u6B63\u5E38\u4F7F\u7528\uFF1B\u4F46**\u65E7\u7684 profile \u7EA7\u51ED\u636E\u6CA1\u80FD\u6E05\u7406\u6389**\uFF0C\u4E0A\u9762 reason \u91CC\u90A3\u4E2A\u6587\u4EF6\u4ECD\u7559\u5728\u78C1\u76D8\u4E0A\uFF0C\u91CC\u9762\u662F\u4E00\u679A\u4ECD\u7136\u53EF\u7528\u7684 token\u3002
2886
+ [hcm] \u4E0B\u4E00\u6B65\uFF1A\u786E\u8BA4\u6CA1\u6709\u7A0B\u5E8F\u5360\u7528\u3001\u5E76\u89E3\u51B3\u5B83\u7684\u6743\u9650/\u5C5E\u6027\u9650\u5236\u540E\u624B\u5DE5\u5220\u9664\u8BE5\u6587\u4EF6\uFF08\u91CD\u65B0\u767B\u5F55\u4E0D\u4F1A\u6E05\u6389\u5B83\u2014\u2014\u4E0B\u6B21\u767B\u5F55\u4F1A\u8D70\u5230\u540C\u4E00\u5904\u5E76\u518D\u6B21\u5931\u8D25\uFF09\u3002
2835
2887
  `
2836
2888
  );
2837
- throw err;
2838
2889
  }
2890
+ return record;
2839
2891
  }
2840
2892
  async function discardTempEnvSessions() {
2841
2893
  const ids = await listIdentities2(TEMP_ENV_NAME).catch(() => []);
@@ -3173,8 +3225,7 @@ async function loginCommand(args) {
3173
3225
  scopes
3174
3226
  };
3175
3227
  } else {
3176
- await migrateProfileTokenToIdentity(envName, idName);
3177
- newMeta = await newStore.readMeta();
3228
+ newMeta = await migrateProfileTokenToIdentity(envName, idName);
3178
3229
  }
3179
3230
  const identityMeta = {
3180
3231
  env: envName,
@@ -3379,7 +3430,8 @@ import {
3379
3430
  TokenStore as TokenStore3,
3380
3431
  CliError as CliError6,
3381
3432
  CliErrorCode as CliErrorCode5,
3382
- toYaml
3433
+ toYaml,
3434
+ normalizeAndAssertEndpoint
3383
3435
  } from "@hcmai/sdk";
3384
3436
 
3385
3437
  // src/utils/table.ts
@@ -3554,9 +3606,19 @@ async function envAdd(name, args) {
3554
3606
  message: `env '${name}' already exists. Use --force to overwrite.`
3555
3607
  });
3556
3608
  }
3609
+ const ep = normalizeAndAssertEndpoint(args.endpoint, "endpoint");
3610
+ const fe = args.frontend !== void 0 ? normalizeAndAssertEndpoint(args.frontend, "frontend") : void 0;
3611
+ for (const [field, n] of [["endpoint", ep], ["frontend", fe]]) {
3612
+ if (n?.changed) {
3613
+ process.stderr.write(
3614
+ `[hcm] event=endpoint_normalized field=${field} from=${n.raw} to=${n.normalized} reason=\u5C3E\u659C\u6760\u4F1A\u8BA9\u767B\u5F55\u7C7B\u8BF7\u6C42\u62FC\u51FA'//api/\u2026'\u88AB\u5BB9\u5668\u5728\u8DEF\u7531\u524D\u62D2\u7EDD
3615
+ `
3616
+ );
3617
+ }
3618
+ }
3557
3619
  await saveEnv2(name, {
3558
- endpoint: args.endpoint,
3559
- frontend: args.frontend,
3620
+ endpoint: ep.normalized,
3621
+ frontend: fe?.normalized,
3560
3622
  tenantId: args.tenant ?? "1"
3561
3623
  });
3562
3624
  const allEnvs = await listEnvs();
@@ -3578,15 +3640,17 @@ async function envUse(name, args) {
3578
3640
  g.activeEnv = name;
3579
3641
  await saveGlobalConfig2(g);
3580
3642
  const shouldPing = args.ping !== false;
3643
+ let pingFailure;
3581
3644
  if (shouldPing && !process.env.CI) {
3582
3645
  try {
3583
3646
  await axios3.get(`${cfg.endpoint}/api/version/backend`, { timeout: 2e3 });
3584
3647
  } catch (e) {
3585
- const reason = String(e.message).slice(0, 60).replace(/\s+/g, "-");
3586
- process.stderr.write(
3587
- `[hcm] event=env_ping_failed env=${name} reason=${reason} hint=token-may-need-re-login
3588
- `
3589
- );
3648
+ const err = e;
3649
+ const reason = String(err.message ?? "unknown").slice(0, 60).replace(/\s+/g, "-");
3650
+ const hint = err.response?.status ? `backend-responded-${err.response.status}; \u591A\u534A\u662F\u51ED\u636E\u6216\u6743\u9650: hcm login --env ${name}` : `backend-not-reachable; \u5148\u6838\u5730\u5740: hcm env show ${name}`;
3651
+ pingFailure = `${reason}\uFF08${hint}\uFF09`;
3652
+ process.stderr.write(`[hcm] event=env_ping_failed env=${name} reason=${reason} hint=${hint}
3653
+ `);
3590
3654
  }
3591
3655
  }
3592
3656
  if (cfg.defaultIdentity) {
@@ -3598,6 +3662,7 @@ async function envUse(name, args) {
3598
3662
  );
3599
3663
  }
3600
3664
  }
3665
+ if (pingFailure) return exitOk(`\u26A0 active env: ${name}\uFF08\u540E\u7AEF\u672A\u63A2\u901A: ${pingFailure}\uFF09`);
3601
3666
  return exitOk(`\u2705 active env: ${name}`);
3602
3667
  } catch (e) {
3603
3668
  exitWithError(e);
@@ -3672,9 +3737,20 @@ async function envEdit(field, value, args) {
3672
3737
  if (field === "defaultIdentity") {
3673
3738
  await loadIdentity3(value);
3674
3739
  }
3675
- cfg[field] = value;
3740
+ let stored = value;
3741
+ if (field === "endpoint" || field === "frontend") {
3742
+ const n = normalizeAndAssertEndpoint(value, field);
3743
+ stored = n.normalized;
3744
+ if (n.changed) {
3745
+ process.stderr.write(
3746
+ `[hcm] event=endpoint_normalized field=${field} from=${n.raw} to=${n.normalized} reason=\u5C3E\u659C\u6760\u4F1A\u8BA9\u767B\u5F55\u7C7B\u8BF7\u6C42\u62FC\u51FA'//api/\u2026'\u88AB\u5BB9\u5668\u5728\u8DEF\u7531\u524D\u62D2\u7EDD
3747
+ `
3748
+ );
3749
+ }
3750
+ }
3751
+ cfg[field] = stored;
3676
3752
  await saveEnv2(name, cfg);
3677
- return exitOk(`\u2705 ${name}.${field} = ${value}`);
3753
+ return exitOk(`\u2705 ${name}.${field} = ${stored}`);
3678
3754
  } catch (e) {
3679
3755
  exitWithError(e);
3680
3756
  }
@@ -4570,6 +4646,15 @@ async function describeCommand(model, args) {
4570
4646
  exitWithError(e);
4571
4647
  }
4572
4648
  }
4649
+ function formatEnumValues(enums) {
4650
+ if (!enums?.length) return "";
4651
+ const items = enums.map((e) => {
4652
+ const raw = e.value ?? e.key;
4653
+ const shown = raw === void 0 || raw === null ? "?" : String(raw);
4654
+ return e.label && e.label !== shown ? `${shown}=${e.label}` : shown;
4655
+ });
4656
+ return `[${items.join("|")}]`;
4657
+ }
4573
4658
  function formatDescriptionTable(desc, verbose = false) {
4574
4659
  const lines = [`=== ${desc.model} ===`];
4575
4660
  if (desc.labels.zh_CN) lines.push(`zh_CN: ${desc.labels.zh_CN}`);
@@ -4577,7 +4662,8 @@ function formatDescriptionTable(desc, verbose = false) {
4577
4662
  lines.push(`fields (${desc.fields.length}):`);
4578
4663
  for (const f of desc.fields) {
4579
4664
  const req = f.required ? " required" : " ";
4580
- const lbl = verbose ? ` ${f.label ?? ""} ${f.description ?? ""}` : ` ${f.label ?? ""}`;
4665
+ const extras = verbose ? [f.label, f.description, formatEnumValues(f.enums)] : [f.label];
4666
+ const lbl = extras.filter((s) => s && s.length > 0).map((s) => ` ${s}`).join("");
4581
4667
  const type = f.i18n ? `${f.type} (i18n)` : f.type;
4582
4668
  const objectRef = f.object ? ` \u2192 ${f.object}` : "";
4583
4669
  lines.push(` ${f.name.padEnd(20)} ${type.padEnd(14)} ${req}${lbl}${objectRef}`);
@@ -4614,9 +4700,6 @@ function formatDescriptionTable(desc, verbose = false) {
4614
4700
  }
4615
4701
 
4616
4702
  // src/commands/chat.ts
4617
- init_exit();
4618
- init_impersonation_lifecycle();
4619
- init_auth_guard();
4620
4703
  import {
4621
4704
  HcmClient as HcmClient11,
4622
4705
  WsClient as WsClient2,
@@ -4635,7 +4718,7 @@ import {
4635
4718
  findLastAssistantTarget,
4636
4719
  SUPERSEDED_STATUS,
4637
4720
  CliError as CliError16,
4638
- CliErrorCode as CliErrorCode15,
4721
+ CliErrorCode as CliErrorCode17,
4639
4722
  parseInteractionRequest as parseInteractionRequest2,
4640
4723
  parseInteractionResolved as parseInteractionResolved2,
4641
4724
  buildConfirm as buildConfirm2,
@@ -4646,10 +4729,29 @@ import {
4646
4729
  } from "@hcmai/sdk";
4647
4730
  import chalk2 from "chalk";
4648
4731
  import * as fs5 from "fs/promises";
4732
+
4733
+ // src/streaming/streamFailureCode.ts
4734
+ import { CliErrorCode as CliErrorCode15 } from "@hcmai/sdk";
4735
+ var CLI_CODES = new Set(Object.values(CliErrorCode15));
4736
+ function cliCodeForStreamFailure(raw) {
4737
+ if (raw === void 0 || raw === null || raw === "") return CliErrorCode15.STREAM_FAILED_NO_SERVER_CODE;
4738
+ if (typeof raw === "string" && CLI_CODES.has(raw)) return raw;
4739
+ return CliErrorCode15.BUSINESS_RULE_VIOLATION;
4740
+ }
4741
+ function serverCodeOf(raw) {
4742
+ if (raw === void 0 || raw === null || raw === "") return void 0;
4743
+ if (typeof raw === "string" && CLI_CODES.has(raw)) return void 0;
4744
+ return String(raw);
4745
+ }
4746
+
4747
+ // src/commands/chat.ts
4748
+ init_exit();
4749
+ init_impersonation_lifecycle();
4750
+ init_auth_guard();
4649
4751
  function parseInjectOn(s) {
4650
4752
  const fail8 = (detail) => {
4651
4753
  throw new CliError16({
4652
- code: CliErrorCode15.INVALID_ARGUMENT,
4754
+ code: CliErrorCode17.INVALID_ARGUMENT,
4653
4755
  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
4756
  });
4655
4757
  };
@@ -4676,20 +4778,20 @@ function parseOnConfirm(s) {
4676
4778
  if (s === "reject") return { decision: "reject" };
4677
4779
  if (s.startsWith("reject:")) return { decision: "reject", reason: s.slice("reject:".length) };
4678
4780
  throw new CliError16({
4679
- code: CliErrorCode15.INVALID_ARGUMENT,
4781
+ code: CliErrorCode17.INVALID_ARGUMENT,
4680
4782
  message: `--on-confirm \u53D6\u503C approve | reject | reject:<reason>\uFF0C\u6536\u5230 "${s}"`
4681
4783
  });
4682
4784
  }
4683
4785
  function resolveResumeConversation(args) {
4684
4786
  if (args.resume && args.conversation) {
4685
4787
  throw new CliError16({
4686
- code: CliErrorCode15.INVALID_ARGUMENT,
4788
+ code: CliErrorCode17.INVALID_ARGUMENT,
4687
4789
  message: "--resume \u548C --conversation \u4E0D\u80FD\u540C\u65F6\u4F7F\u7528\uFF1B\u65B0\u547D\u4EE4\u8BF7\u7528 --resume <conversationId>"
4688
4790
  });
4689
4791
  }
4690
4792
  if (args.resume === "NEW") {
4691
4793
  throw new CliError16({
4692
- code: CliErrorCode15.INVALID_ARGUMENT,
4794
+ code: CliErrorCode17.INVALID_ARGUMENT,
4693
4795
  message: "--resume \u9700\u8981\u65E2\u5B58 conversationId\uFF1B\u65B0\u4F1A\u8BDD\u8BF7\u76F4\u63A5\u7701\u7565 --resume"
4694
4796
  });
4695
4797
  }
@@ -4701,7 +4803,7 @@ function parsePositiveInt(value, fallback, flag) {
4701
4803
  const n = Number(value ?? fallback);
4702
4804
  if (!Number.isInteger(n) || n <= 0) {
4703
4805
  throw new CliError16({
4704
- code: CliErrorCode15.INVALID_ARGUMENT,
4806
+ code: CliErrorCode17.INVALID_ARGUMENT,
4705
4807
  message: `${flag} \u9700\u8981\u6B63\u6574\u6570\uFF0C\u6536\u5230 "${value}"`
4706
4808
  });
4707
4809
  }
@@ -4725,20 +4827,20 @@ function resolveEventsConversation(args) {
4725
4827
  const eventConversationId = typeof args.events === "string" ? args.events.trim() : void 0;
4726
4828
  if (eventConversationId === "NEW") {
4727
4829
  throw new CliError16({
4728
- code: CliErrorCode15.INVALID_ARGUMENT,
4830
+ code: CliErrorCode17.INVALID_ARGUMENT,
4729
4831
  message: "--events \u9700\u8981\u65E2\u5B58 conversationId\uFF1B\u65B0\u4F1A\u8BDD\u6CA1\u6709\u53EF\u67E5\u8BE2\u7684\u4E8B\u4EF6\u6D41"
4730
4832
  });
4731
4833
  }
4732
4834
  if (eventConversationId && resumeConversationId && eventConversationId !== resumeConversationId) {
4733
4835
  throw new CliError16({
4734
- code: CliErrorCode15.INVALID_ARGUMENT,
4836
+ code: CliErrorCode17.INVALID_ARGUMENT,
4735
4837
  message: "--events <conversationId> \u4E0E --resume/--conversation \u6307\u5411\u4E0D\u540C\u4F1A\u8BDD\uFF1B\u8BF7\u53EA\u4FDD\u7559\u4E00\u4E2A id"
4736
4838
  });
4737
4839
  }
4738
4840
  const id = eventConversationId || resumeConversationId;
4739
4841
  if (!id) {
4740
4842
  throw new CliError16({
4741
- code: CliErrorCode15.INVALID_ARGUMENT,
4843
+ code: CliErrorCode17.INVALID_ARGUMENT,
4742
4844
  message: "\u67E5\u8BE2\u4E8B\u4EF6\u6D41\u8BF7\u4F20 `hcm chat --events <conversationId>`\uFF0C\u6216 `hcm chat --resume <conversationId> --events`"
4743
4845
  });
4744
4846
  }
@@ -4880,7 +4982,7 @@ async function printConversationEvents(conversationId, args) {
4880
4982
  async function printConversationList(args) {
4881
4983
  if (args.events || args.resume || args.conversation || args.regenerateFrom || args.promptFile) {
4882
4984
  throw new CliError16({
4883
- code: CliErrorCode15.INVALID_ARGUMENT,
4985
+ code: CliErrorCode17.INVALID_ARGUMENT,
4884
4986
  message: "--list \u53EA\u7528\u4E8E\u5217\u4F1A\u8BDD\uFF1B\u4E0D\u8981\u540C\u65F6\u4F20 --events/--resume/--conversation/--regenerate-from/--prompt-file"
4885
4987
  });
4886
4988
  }
@@ -4911,7 +5013,7 @@ async function chatCommand(prompt, args) {
4911
5013
  if (args.list) {
4912
5014
  if (prompt) {
4913
5015
  throw new CliError16({
4914
- code: CliErrorCode15.INVALID_ARGUMENT,
5016
+ code: CliErrorCode17.INVALID_ARGUMENT,
4915
5017
  message: "--list \u4E0D\u63A5\u53D7 prompt\uFF1B\u7528 `hcm chat --list` \u67E5\u770B\u6700\u8FD1\u4F1A\u8BDD"
4916
5018
  });
4917
5019
  }
@@ -4923,7 +5025,7 @@ async function chatCommand(prompt, args) {
4923
5025
  if (eventsConversationId) {
4924
5026
  if (prompt || args.promptFile || args.regenerateFrom || args.attach?.length) {
4925
5027
  throw new CliError16({
4926
- code: CliErrorCode15.INVALID_ARGUMENT,
5028
+ code: CliErrorCode17.INVALID_ARGUMENT,
4927
5029
  message: "--events \u662F\u53EA\u8BFB\u67E5\u8BE2\uFF1B\u4E0D\u8981\u540C\u65F6\u4F20 prompt/--prompt-file/--regenerate-from/--attach"
4928
5030
  });
4929
5031
  }
@@ -4942,14 +5044,14 @@ async function chatCommand(prompt, args) {
4942
5044
  regenerateFromSeq = Number(args.regenerateFrom);
4943
5045
  if (!Number.isInteger(regenerateFromSeq) || regenerateFromSeq <= 0) {
4944
5046
  throw new CliError16({
4945
- code: CliErrorCode15.INVALID_ARGUMENT,
5047
+ code: CliErrorCode17.INVALID_ARGUMENT,
4946
5048
  message: `--regenerate-from \u9700\u8981\u6B63\u6574\u6570 journal seq \u6216 last-assistant\uFF0C\u6536\u5230 "${args.regenerateFrom}"`
4947
5049
  });
4948
5050
  }
4949
5051
  }
4950
5052
  if (!requestedConversationId) {
4951
5053
  throw new CliError16({
4952
- code: CliErrorCode15.INVALID_ARGUMENT,
5054
+ code: CliErrorCode17.INVALID_ARGUMENT,
4953
5055
  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
5056
  });
4955
5057
  }
@@ -4964,7 +5066,7 @@ async function chatCommand(prompt, args) {
4964
5066
  }
4965
5067
  if (prompt === void 0 || !prompt && !regenerateMode) {
4966
5068
  throw new CliError16({
4967
- code: CliErrorCode15.INVALID_ARGUMENT,
5069
+ code: CliErrorCode17.INVALID_ARGUMENT,
4968
5070
  message: "prompt is required (positional or --prompt-file)"
4969
5071
  });
4970
5072
  }
@@ -4987,7 +5089,7 @@ async function chatCommand(prompt, args) {
4987
5089
  const target = findLastAssistantTarget(items);
4988
5090
  if (target.seq == null) {
4989
5091
  throw new CliError16({
4990
- code: CliErrorCode15.BUSINESS_RULE_VIOLATION,
5092
+ code: CliErrorCode17.BUSINESS_RULE_VIOLATION,
4991
5093
  message: `--regenerate-from last-assistant \u627E\u4E0D\u5230\u53EF\u91CD\u8DD1\u7684 chat-text seq: conversation=${resumeConversationId}\uFF08${lastAssistantMissDetail(target)}\uFF09`
4992
5094
  });
4993
5095
  }
@@ -4996,7 +5098,11 @@ async function chatCommand(prompt, args) {
4996
5098
  const ws = new WsClient2({
4997
5099
  endpoint: wsUrl,
4998
5100
  getAccessToken: () => client3.getAccessToken(),
4999
- onTokenExpiring: () => client3.handleRefresh()
5101
+ onTokenExpiring: () => client3.handleRefresh(),
5102
+ // issue #257:握手带上会话 id,后端才会绑控制通道并重投上次留下的未决暂停。
5103
+ // 会话 id 在上面几十行就定下来了(--resume 或刚 createConversation 出来的),
5104
+ // 建连时它一定已经就位。
5105
+ conversationId: resumeConversationId
5000
5106
  });
5001
5107
  await ws.connect();
5002
5108
  const fmt = args.output ?? "text";
@@ -5017,7 +5123,13 @@ async function chatCommand(prompt, args) {
5017
5123
  });
5018
5124
  const presenter = new StreamPresenter2(renderer, {
5019
5125
  showToolCalls: args.showToolCalls !== false,
5020
- output: fmt
5126
+ output: fmt,
5127
+ // issue #255:真因走的是连接层帧 `{type:'error',code,message}`,不在 v4 事件里——
5128
+ // `MessageStopPayload` 这个 record 只有 (stopReason, parentToolUseId, *Tokens),
5129
+ // 没有 errorCode 也没有 message。handle 在下面才建(同一个 async 函数体内),但这个闭包只在
5130
+ // `presenter.consume(handle.events)` 里被调到,那时它早就有了。
5131
+ serverError: () => handle.serverError()
5132
+ // 可等待:真因晚一个 tick 才到(issue #255)
5021
5133
  });
5022
5134
  if (resumedExisting && isTty && fmt === "text" && !args.raw) {
5023
5135
  const { fetchConversationTimeline: fetchConversationTimeline3, buildResumeSummary: buildResumeSummary2 } = await import("@hcmai/sdk");
@@ -5208,10 +5320,12 @@ async function chatCommand(prompt, args) {
5208
5320
  } catch (e) {
5209
5321
  process.removeListener("SIGINT", sigintHandler);
5210
5322
  await ws.close();
5323
+ const serverCode = serverCodeOf(e.code);
5211
5324
  throw new CliError16({
5212
- code: e.code ?? CliErrorCode15.BUSINESS_RULE_VIOLATION,
5325
+ code: cliCodeForStreamFailure(e.code),
5213
5326
  message: e.message,
5214
- traceId: e.traceId ?? void 0
5327
+ traceId: e.traceId ?? void 0,
5328
+ ...serverCode ? { context: { responseCode: serverCode } } : {}
5215
5329
  });
5216
5330
  }
5217
5331
  }
@@ -5271,15 +5385,210 @@ async function chatCommand(prompt, args) {
5271
5385
  }
5272
5386
  }
5273
5387
 
5388
+ // src/commands/interactions.ts
5389
+ init_exit();
5390
+ init_auth_guard();
5391
+ import {
5392
+ CliError as CliError17,
5393
+ CliErrorCode as CliErrorCode18,
5394
+ DEFAULT_AGENT_ID as DEFAULT_AGENT_ID4,
5395
+ HcmClient as HcmClient12,
5396
+ WsClient as WsClient3,
5397
+ conversationWebSocketEndpoint as conversationWebSocketEndpoint3,
5398
+ assertDangerWrite as assertDangerWrite3,
5399
+ formatObject as formatObject10,
5400
+ formatRows as formatRows4,
5401
+ listPendingInteractions,
5402
+ loadConversationState,
5403
+ respondToInteraction
5404
+ } from "@hcmai/sdk";
5405
+ function resolveConversation(explicit, state) {
5406
+ const given = explicit?.trim();
5407
+ if (given) return { conversationId: given, source: "flag" };
5408
+ const last = state?.lastConversationId?.trim();
5409
+ if (last) return { conversationId: last, source: "state" };
5410
+ throw new CliError17({
5411
+ code: CliErrorCode18.INVALID_ARGUMENT,
5412
+ 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",
5413
+ context: {
5414
+ nextStep: "\u7528 `hcm chat --list` \u627E\u5230\u4F1A\u8BDD id\uFF0C\u518D `hcm interactions list --conversation <id>`"
5415
+ }
5416
+ });
5417
+ }
5418
+ function decisionFor(action, args) {
5419
+ if (action === "approve") return { kind: "confirm" };
5420
+ if (action === "reject") return { kind: "reject", reason: args.reason?.trim() || void 0 };
5421
+ const answer = args.answer?.trim();
5422
+ if (!answer) {
5423
+ throw new CliError17({
5424
+ code: CliErrorCode18.INVALID_ARGUMENT,
5425
+ message: 'answer \u9700\u8981\u7B54\u6848\u6587\u672C\uFF1A--answer "<\u4F60\u7684\u56DE\u7B54>"',
5426
+ context: {
5427
+ 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"
5428
+ }
5429
+ });
5430
+ }
5431
+ let choiceIndex;
5432
+ if (args.choice !== void 0 && String(args.choice).trim() !== "") {
5433
+ choiceIndex = Number(args.choice);
5434
+ if (!Number.isInteger(choiceIndex)) {
5435
+ throw new CliError17({
5436
+ code: CliErrorCode18.INVALID_ARGUMENT,
5437
+ message: `--choice \u8981\u6574\u6570\u4E0B\u6807\uFF0C\u6536\u5230\uFF1A${args.choice}`,
5438
+ context: { nextStep: "\u4E0B\u6807\u6765\u81EA ASK \u4E8B\u4EF6 choices \u6570\u7EC4\u7684\u4F4D\u7F6E\uFF08\u4ECE 0 \u8D77\uFF09" }
5439
+ });
5440
+ }
5441
+ }
5442
+ return { kind: "answer", answer, choiceIndex };
5443
+ }
5444
+ function renderPendingTable(rows2, conversationId) {
5445
+ if (!rows2.length) {
5446
+ return `\u4F1A\u8BDD ${conversationId} \u4E0A\u6CA1\u6709\u672A\u51B3\u7684\u6682\u505C\u3002
5447
+ \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`;
5448
+ }
5449
+ const table = formatRows4(
5450
+ rows2.map((r) => ({
5451
+ ID: r.interactionId,
5452
+ TYPE: r.type,
5453
+ TOOL: r.executorName || "-",
5454
+ RISK: r.riskLevel || "-",
5455
+ SUMMARY: r.operationSummary || "(\u65E0\u64CD\u4F5C\u6458\u8981)",
5456
+ EXPIRES: r.expired ? `${r.expiresAt || "-"} \u5DF2\u8FC7\u671F` : r.expiresAt || "-"
5457
+ })),
5458
+ { format: "table" }
5459
+ );
5460
+ const live = rows2.filter((r) => !r.expired);
5461
+ const kinds = new Set(live.map((r) => r.type));
5462
+ const verbs = [];
5463
+ if (kinds.has("CONFIRM")) {
5464
+ verbs.push(`hcm interactions approve <ID> --conversation ${conversationId}`, "\uFF08\u62D2\u7EDD\u6362 reject\uFF09");
5465
+ }
5466
+ if (kinds.has("ASK")) {
5467
+ verbs.push(`hcm interactions answer <ID> --answer "<\u4F60\u7684\u56DE\u7B54>" --conversation ${conversationId}`);
5468
+ }
5469
+ if (live.length && !verbs.length) {
5470
+ verbs.push(
5471
+ `\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`
5472
+ );
5473
+ }
5474
+ const hint = live.length ? `
5475
+ \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";
5476
+ return `${table}
5477
+ \u5171 ${rows2.length} \u6761\uFF0C\u5176\u4E2D ${live.length} \u6761\u4ECD\u53EF\u5904\u7406\u3002${hint}`;
5478
+ }
5479
+ function renderOutcome(o) {
5480
+ const head = `${o.interactionId} \xB7 decision=${o.decision ?? "-"} status=${o.status ?? "-"}`;
5481
+ if (o.status === "SUPERSEDED") {
5482
+ return `${head}
5483
+ \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
5484
+ \u4E0B\u4E00\u6B65\uFF1A\u518D \`hcm interactions list\` \u4E00\u6B21\uFF0C\u5904\u7406\u65B0\u51FA\u73B0\u7684\u90A3\u6761\u3002`;
5485
+ }
5486
+ if (o.status === "FAILED") {
5487
+ return `${head}
5488
+ ${o.text ?? "(\u540E\u7AEF\u6CA1\u6709\u7ED9\u6536\u5C3E\u6B63\u6587)"}
5489
+ \u7EED\u8DD1\u5931\u8D25\uFF1A\u51B3\u5B9A\u5DF2\u7ECF\u53D7\u7406\uFF0C\u4F46\u6267\u884C\u6CA1\u6210\u529F\u3002`;
5490
+ }
5491
+ return `${head}
5492
+ ${o.text ?? "(\u540E\u7AEF\u6CA1\u6709\u7ED9\u6536\u5C3E\u6B63\u6587)"}`;
5493
+ }
5494
+ async function loadState(env2) {
5495
+ try {
5496
+ return await loadConversationState(env2);
5497
+ } catch {
5498
+ return null;
5499
+ }
5500
+ }
5501
+ function announceSource(source, conversationId, json) {
5502
+ if (source === "state" && !json) {
5503
+ process.stderr.write(`\u21BB \u672A\u6307\u5B9A --conversation\uFF0C\u7528\u672C env \u4E0A\u4E00\u6B21\u7684\u4F1A\u8BDD\uFF1A${conversationId}
5504
+ `);
5505
+ }
5506
+ }
5507
+ async function interactionsListCommand(args) {
5508
+ try {
5509
+ const ctx = await getActiveAuthContextFromCli(args);
5510
+ const { conversationId, source } = resolveConversation(
5511
+ args.conversation,
5512
+ await loadState(ctx.env)
5513
+ );
5514
+ const json = args.output === "json";
5515
+ announceSource(source, conversationId, json);
5516
+ const client3 = HcmClient12.fromAuthContext(ctx);
5517
+ const agentId = args.agent ?? DEFAULT_AGENT_ID4;
5518
+ const rows2 = await listPendingInteractions(client3.raw(), agentId, conversationId);
5519
+ if (json) {
5520
+ process.stdout.write(
5521
+ formatObject10(
5522
+ { conversationId, conversationIdSource: source, count: rows2.length, interactions: rows2 },
5523
+ { format: "json" }
5524
+ ) + "\n"
5525
+ );
5526
+ } else {
5527
+ process.stdout.write(renderPendingTable(rows2, conversationId) + "\n");
5528
+ }
5529
+ process.exitCode = 0;
5530
+ } catch (e) {
5531
+ exitWithError(e);
5532
+ }
5533
+ }
5534
+ async function interactionsRespondCommand(action, interactionId, args) {
5535
+ let ws;
5536
+ try {
5537
+ const decision = decisionFor(action, args);
5538
+ const ctx = await getActiveAuthContextFromCli(args);
5539
+ const { conversationId, source } = resolveConversation(
5540
+ args.conversation,
5541
+ await loadState(ctx.env)
5542
+ );
5543
+ const json = args.output === "json";
5544
+ announceSource(source, conversationId, json);
5545
+ assertDangerWrite3(ctx.environmentSafety, "\u56DE\u5E94\u6682\u505C\uFF08\u6279\u51C6\u4F1A\u771F\u7684\u6267\u884C\u90A3\u4E2A\u5199\u64CD\u4F5C\uFF09");
5546
+ const client3 = HcmClient12.fromAuthContext(ctx);
5547
+ ws = new WsClient3({
5548
+ endpoint: conversationWebSocketEndpoint3(ctx.endpoint),
5549
+ getAccessToken: () => client3.getAccessToken(),
5550
+ onTokenExpiring: () => client3.handleRefresh(),
5551
+ conversationId
5552
+ });
5553
+ await ws.connect();
5554
+ const timeoutMs = args.timeout ? Number(args.timeout) * 1e3 : void 0;
5555
+ if (timeoutMs !== void 0 && !Number.isFinite(timeoutMs)) {
5556
+ throw new CliError17({
5557
+ code: CliErrorCode18.INVALID_ARGUMENT,
5558
+ message: `--timeout \u8981\u79D2\u6570\uFF0C\u6536\u5230\uFF1A${args.timeout}`
5559
+ });
5560
+ }
5561
+ const outcome = await respondToInteraction(ws, {
5562
+ conversationId,
5563
+ interactionId,
5564
+ decision,
5565
+ timeoutMs,
5566
+ onAccepted: () => {
5567
+ if (!json) process.stderr.write("\xB7 \u5DF2\u53D7\u7406\uFF0C\u7EED\u8DD1\u4E2D\u2026\n");
5568
+ }
5569
+ });
5570
+ if (json) {
5571
+ process.stdout.write(formatObject10(outcome, { format: "json" }) + "\n");
5572
+ } else {
5573
+ process.stdout.write(renderOutcome(outcome) + "\n");
5574
+ }
5575
+ process.exitCode = outcome.status === "COMPLETED" ? 0 : 1;
5576
+ } catch (e) {
5577
+ exitWithError(e);
5578
+ } finally {
5579
+ await ws?.close();
5580
+ }
5581
+ }
5582
+
5274
5583
  // src/commands/download.ts
5275
5584
  init_auth_guard();
5276
5585
  init_exit();
5277
5586
  import { downloadDocument } from "@hcmai/sdk";
5278
- import { HcmClient as HcmClient12 } from "@hcmai/sdk";
5587
+ import { HcmClient as HcmClient13 } from "@hcmai/sdk";
5279
5588
  async function downloadCommand(documentId, args) {
5280
5589
  try {
5281
5590
  const ctx = await getActiveAuthContextFromCli(args);
5282
- const client3 = HcmClient12.fromAuthContext(ctx);
5591
+ const client3 = HcmClient13.fromAuthContext(ctx);
5283
5592
  const saved = await downloadDocument(client3.raw(), { documentId }, args.output);
5284
5593
  process.stdout.write(saved + "\n");
5285
5594
  process.exitCode = 0;
@@ -5301,15 +5610,15 @@ init_auth_guard();
5301
5610
  init_exit();
5302
5611
  import {
5303
5612
  deleteDocument,
5304
- HcmClient as HcmClient13,
5613
+ HcmClient as HcmClient14,
5305
5614
  fromAxiosError as fromAxiosError11,
5306
- formatObject as formatObject10
5615
+ formatObject as formatObject11
5307
5616
  } from "@hcmai/sdk";
5308
5617
  async function documentDeleteCommand(documentId, args) {
5309
5618
  try {
5310
- const client3 = HcmClient13.fromAuthContext(await getActiveAuthContextFromCli(args));
5619
+ const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
5311
5620
  await deleteDocument(client3.raw(), documentId);
5312
- process.stdout.write(formatObject10({ success: true, documentId }, { format: args.output ?? "json" }) + "\n");
5621
+ process.stdout.write(formatObject11({ success: true, documentId }, { format: args.output ?? "json" }) + "\n");
5313
5622
  process.exitCode = 0;
5314
5623
  } catch (e) {
5315
5624
  const err = e;
@@ -5321,7 +5630,7 @@ async function documentDeleteCommand(documentId, args) {
5321
5630
  // src/commands/trace.ts
5322
5631
  init_exit();
5323
5632
  init_auth_guard();
5324
- import { HcmClient as HcmClient14, formatObject as formatObject11, formatRows as formatRows4, fromAxiosError as fromAxiosError12 } from "@hcmai/sdk";
5633
+ import { HcmClient as HcmClient15, formatObject as formatObject12, formatRows as formatRows5, fromAxiosError as fromAxiosError12 } from "@hcmai/sdk";
5325
5634
  function parsePositiveInt2(value, fallback, flag) {
5326
5635
  const n = Number(value ?? fallback);
5327
5636
  if (!Number.isInteger(n) || n <= 0) {
@@ -5374,7 +5683,7 @@ function printRecent(data, limit) {
5374
5683
  OPERATION: short(t.rootOperation, 36),
5375
5684
  TRACE: t.traceId ?? "-"
5376
5685
  }));
5377
- process.stdout.write(formatRows4(rows2, { format: "table" }) + "\n");
5686
+ process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5378
5687
  process.stdout.write(`Showing ${rows2.length} trace${rows2.length === 1 ? "" : "s"}.
5379
5688
  `);
5380
5689
  process.stdout.write("next: hcm trace <traceId> | hcm trace <traceId> --events | hcm trace <traceId> --raw\n");
@@ -5405,7 +5714,7 @@ function printTraceDetail(traceId, agg) {
5405
5714
  OPERATION: short(sp.operation, 48)
5406
5715
  }));
5407
5716
  process.stdout.write("\nTempo spans:\n");
5408
- process.stdout.write(formatRows4(rows2, { format: "table" }) + "\n");
5717
+ process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5409
5718
  if (spans.length > rows2.length) process.stdout.write(`... ${spans.length - rows2.length} more spans
5410
5719
  `);
5411
5720
  } else if (tempo?.reason) {
@@ -5420,7 +5729,7 @@ Tempo: ${tempo.reason}
5420
5729
  MESSAGE: short(log.msg ?? log.exception, 90)
5421
5730
  }));
5422
5731
  process.stdout.write("\nLoki logs:\n");
5423
- process.stdout.write(formatRows4(rows2, { format: "table" }) + "\n");
5732
+ process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5424
5733
  if (logs.length > rows2.length) process.stdout.write(`... ${logs.length - rows2.length} more logs
5425
5734
  `);
5426
5735
  } else if (loki?.reason) {
@@ -5458,7 +5767,7 @@ function printTraceEvents(traceId, agg) {
5458
5767
  }));
5459
5768
  process.stdout.write(`trace events: ${traceId}
5460
5769
  `);
5461
- process.stdout.write(formatRows4(rows2, { format: "table" }) + "\n");
5770
+ process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
5462
5771
  }
5463
5772
  async function listRecentTraces(client3, limit) {
5464
5773
  const http = client3.raw();
@@ -5506,7 +5815,7 @@ async function listRecentConversationsPg(client3, limit) {
5506
5815
  TOKENS: c.totalTokens ?? "-",
5507
5816
  CONV: c.id ?? "-"
5508
5817
  }));
5509
- process.stdout.write(formatRows4(table, { format: "table" }) + "\n");
5818
+ process.stdout.write(formatRows5(table, { format: "table" }) + "\n");
5510
5819
  process.stdout.write(`Showing ${rows2.length} conversation${rows2.length === 1 ? "" : "s"}\uFF08PG \u89C6\u56FE\uFF09\u3002
5511
5820
  `);
5512
5821
  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 +5898,7 @@ ${" ".repeat(node.depth)}\u2514\u2500 \u59D4\u6D3E \u2192 ${node.label} \xB7 ${
5589
5898
 
5590
5899
  `);
5591
5900
  if (table.length) {
5592
- process.stdout.write(formatRows4(table, { format: "table" }) + "\n");
5901
+ process.stdout.write(formatRows5(table, { format: "table" }) + "\n");
5593
5902
  } else {
5594
5903
  const why = envelopeReason(node.envelope);
5595
5904
  process.stdout.write(`\uFF08\u65E0 LLM \u8C03\u7528${why ? ` \xB7 ${short(why, 60)}` : ""}\uFF09
@@ -5716,14 +6025,14 @@ async function gatherLlmTraceTree(http, rootConvId, maxDepth = 3) {
5716
6025
  }
5717
6026
  async function traceCommand(traceId, args) {
5718
6027
  try {
5719
- const client3 = HcmClient14.fromAuthContext(await getActiveAuthContextFromCli(args));
6028
+ const client3 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
5720
6029
  const http = client3.raw();
5721
6030
  const convId = args.conv ?? (args.llmCalls ? traceId ?? void 0 : void 0);
5722
6031
  if (convId) {
5723
6032
  if (args.raw || args.output === "json" || args.output === "yaml") {
5724
6033
  const body = await fetchLlmTrace(http, convId);
5725
6034
  const fmt = args.raw ? "json" : args.output;
5726
- process.stdout.write(formatObject11(body.rows, { format: fmt }) + "\n");
6035
+ process.stdout.write(formatObject12(body.rows, { format: fmt }) + "\n");
5727
6036
  if (!body.rows.length) {
5728
6037
  for (const line of describeLlmTraceEmpty(convId, body.envelope)) {
5729
6038
  process.stderr.write(line + "\n");
@@ -5748,12 +6057,12 @@ async function traceCommand(traceId, args) {
5748
6057
  const resp = await http.get(`/api/trace/${traceId}`);
5749
6058
  const agg = resp.data ?? {};
5750
6059
  if (args.raw) {
5751
- process.stdout.write(formatObject11(agg, { format: "json" }) + "\n");
6060
+ process.stdout.write(formatObject12(agg, { format: "json" }) + "\n");
5752
6061
  process.exitCode = 0;
5753
6062
  return;
5754
6063
  }
5755
6064
  if (args.output === "json" || args.output === "yaml") {
5756
- process.stdout.write(formatObject11(agg, { format: args.output }) + "\n");
6065
+ process.stdout.write(formatObject12(agg, { format: args.output }) + "\n");
5757
6066
  process.exitCode = 0;
5758
6067
  return;
5759
6068
  }
@@ -5764,7 +6073,7 @@ async function traceCommand(traceId, args) {
5764
6073
  exitWithError(`Span #${args.span} \u8D8A\u754C\uFF08\u5171 ${spans.length} \u6761 Tempo span\uFF09`);
5765
6074
  return;
5766
6075
  }
5767
- process.stdout.write(formatObject11(spans[idx], { format: "yaml" }) + "\n");
6076
+ process.stdout.write(formatObject12(spans[idx], { format: "yaml" }) + "\n");
5768
6077
  process.exitCode = 0;
5769
6078
  return;
5770
6079
  }
@@ -5788,21 +6097,21 @@ async function traceCommand(traceId, args) {
5788
6097
  init_exit();
5789
6098
  init_auth_guard();
5790
6099
  import {
5791
- HcmClient as HcmClient15,
5792
- formatObject as formatObject12,
6100
+ HcmClient as HcmClient16,
6101
+ formatObject as formatObject13,
5793
6102
  fromAxiosError as fromAxiosError13,
5794
6103
  getCacheStats,
5795
6104
  clearModelCache,
5796
6105
  clearMetaCache
5797
6106
  } from "@hcmai/sdk";
5798
6107
  async function withClient(args, fn) {
5799
- const client3 = HcmClient15.fromAuthContext(await getActiveAuthContextFromCli(args));
6108
+ const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
5800
6109
  return fn(client3);
5801
6110
  }
5802
6111
  function emit(result, args, human) {
5803
6112
  const fmt = args.output ?? "json";
5804
6113
  if (fmt !== "json") process.stdout.write(human + "\n");
5805
- process.stdout.write(formatObject12(result, { format: fmt }) + "\n");
6114
+ process.stdout.write(formatObject13(result, { format: fmt }) + "\n");
5806
6115
  process.exitCode = 0;
5807
6116
  return;
5808
6117
  }
@@ -5846,8 +6155,8 @@ init_exit();
5846
6155
  init_auth_guard();
5847
6156
  import { readFileSync as readFileSync3 } from "fs";
5848
6157
  import {
5849
- HcmClient as HcmClient16,
5850
- formatObject as formatObject13,
6158
+ HcmClient as HcmClient17,
6159
+ formatObject as formatObject14,
5851
6160
  fromAxiosError as fromAxiosError14,
5852
6161
  scriptDryRun,
5853
6162
  validateScriptManifest,
@@ -5855,13 +6164,13 @@ import {
5855
6164
  getScriptTask
5856
6165
  } from "@hcmai/sdk";
5857
6166
  async function withClient2(args, fn) {
5858
- const client3 = HcmClient16.fromAuthContext(await getActiveAuthContextFromCli(args));
6167
+ const client3 = HcmClient17.fromAuthContext(await getActiveAuthContextFromCli(args));
5859
6168
  return fn(client3);
5860
6169
  }
5861
6170
  function emit2(result, args, human) {
5862
6171
  const fmt = args.output ?? "json";
5863
6172
  if (fmt !== "json") process.stdout.write(human + "\n");
5864
- process.stdout.write(formatObject13(result, { format: fmt }) + "\n");
6173
+ process.stdout.write(formatObject14(result, { format: fmt }) + "\n");
5865
6174
  process.exitCode = 0;
5866
6175
  return;
5867
6176
  }
@@ -5957,8 +6266,8 @@ async function scriptTaskCommand(taskId, args) {
5957
6266
  init_exit();
5958
6267
  init_auth_guard();
5959
6268
  import {
5960
- HcmClient as HcmClient17,
5961
- formatObject as formatObject14,
6269
+ HcmClient as HcmClient18,
6270
+ formatObject as formatObject15,
5962
6271
  fromAxiosError as fromAxiosError15,
5963
6272
  uploadDocument as uploadDocument2
5964
6273
  } from "@hcmai/sdk";
@@ -5966,7 +6275,7 @@ var DEFAULT_UPLOAD_CATEGORY = "attachment";
5966
6275
  async function uploadCommand(filePath, args) {
5967
6276
  try {
5968
6277
  const ctx = await getActiveAuthContextFromCli(args);
5969
- const client3 = HcmClient17.fromAuthContext(ctx);
6278
+ const client3 = HcmClient18.fromAuthContext(ctx);
5970
6279
  const meta2 = await uploadDocument2(
5971
6280
  client3.raw(),
5972
6281
  filePath,
@@ -5979,7 +6288,7 @@ async function uploadCommand(filePath, args) {
5979
6288
  `
5980
6289
  );
5981
6290
  }
5982
- process.stdout.write(formatObject14(meta2, { format: fmt }) + "\n");
6291
+ process.stdout.write(formatObject15(meta2, { format: fmt }) + "\n");
5983
6292
  process.exitCode = 0;
5984
6293
  return;
5985
6294
  } catch (e) {
@@ -6001,8 +6310,8 @@ async function uploadCommand(filePath, args) {
6001
6310
  init_exit();
6002
6311
  init_auth_guard();
6003
6312
  import {
6004
- HcmClient as HcmClient18,
6005
- formatObject as formatObject15,
6313
+ HcmClient as HcmClient19,
6314
+ formatObject as formatObject16,
6006
6315
  fromAxiosError as fromAxiosError16,
6007
6316
  packDataPackage,
6008
6317
  installDataPackageArtifactAsync,
@@ -6028,7 +6337,7 @@ async function datapackagePackCommand(packageDir, args) {
6028
6337
  `
6029
6338
  );
6030
6339
  }
6031
- process.stdout.write(formatObject15(result, { format: fmt }) + "\n");
6340
+ process.stdout.write(formatObject16(result, { format: fmt }) + "\n");
6032
6341
  process.exitCode = 0;
6033
6342
  return;
6034
6343
  } catch (e) {
@@ -6038,7 +6347,7 @@ async function datapackagePackCommand(packageDir, args) {
6038
6347
  async function datapackageInstallCommand(artifactPath, args) {
6039
6348
  try {
6040
6349
  const ctx = await getActiveAuthContextFromCli(args);
6041
- const client3 = HcmClient18.fromAuthContext(ctx);
6350
+ const client3 = HcmClient19.fromAuthContext(ctx);
6042
6351
  const fmt = args.output ?? "json";
6043
6352
  const human = fmt !== "json";
6044
6353
  const accepted = await installDataPackageArtifactAsync(client3, artifactPath, {
@@ -6115,7 +6424,7 @@ async function datapackageInstallCommand(artifactPath, args) {
6115
6424
  async function datapackageStatusCommand(runId, args) {
6116
6425
  try {
6117
6426
  const ctx = await getActiveAuthContextFromCli(args);
6118
- const client3 = HcmClient18.fromAuthContext(ctx);
6427
+ const client3 = HcmClient19.fromAuthContext(ctx);
6119
6428
  const run3 = await fetchInstallRun(client3, runId);
6120
6429
  const fmt = args.output ?? "json";
6121
6430
  if (!run3) {
@@ -6155,7 +6464,7 @@ function truncateTail(text, max) {
6155
6464
  return text.length <= max ? text : "\u2026" + text.slice(text.length - max + 1);
6156
6465
  }
6157
6466
  function emit3(payload, fmt) {
6158
- process.stdout.write(formatObject15(payload, { format: fmt }) + "\n");
6467
+ process.stdout.write(formatObject16(payload, { format: fmt }) + "\n");
6159
6468
  }
6160
6469
 
6161
6470
  // src/commands/skills.ts
@@ -6179,18 +6488,18 @@ import {
6179
6488
  resolveAllSkillsInstallOrder,
6180
6489
  matchSkills,
6181
6490
  filterByStage,
6182
- formatObject as formatObject18,
6491
+ formatObject as formatObject19,
6183
6492
  fromAxiosError as fromAxiosError17,
6184
6493
  loadGlobalConfig as loadGlobalConfig6,
6185
6494
  discoverProjectEnv as discoverProjectEnv3,
6186
6495
  resolveEnvContext as resolveEnvContext5,
6187
6496
  printResolvedEnvironment as printResolvedEnvironment4,
6188
- CliError as CliError20,
6189
- CliErrorCode as CliErrorCode19
6497
+ CliError as CliError21,
6498
+ CliErrorCode as CliErrorCode22
6190
6499
  } from "@hcmai/sdk";
6191
6500
 
6192
6501
  // src/commands/skills-catalog.ts
6193
- import { flattenSkills, CliError as CliError17, CliErrorCode as CliErrorCode16 } from "@hcmai/sdk";
6502
+ import { flattenSkills, CliError as CliError18, CliErrorCode as CliErrorCode19 } from "@hcmai/sdk";
6194
6503
  var CLI_CATEGORY_KEY = "cli-operations";
6195
6504
  var CLI_CATEGORY_NAME = "CLI \u64CD\u4F5C";
6196
6505
  function chironEntry(skill) {
@@ -6235,8 +6544,8 @@ var SOURCE_FILTERS = ["cli", "chiron", "all"];
6235
6544
  function parseSourceFilter(raw) {
6236
6545
  if (raw === void 0) return "all";
6237
6546
  if (SOURCE_FILTERS.includes(raw)) return raw;
6238
- throw new CliError17({
6239
- code: CliErrorCode16.INVALID_ARGUMENT,
6547
+ throw new CliError18({
6548
+ code: CliErrorCode19.INVALID_ARGUMENT,
6240
6549
  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
6550
  });
6242
6551
  }
@@ -6351,22 +6660,10 @@ function upsertBlock(existing, begin, end, block) {
6351
6660
  `;
6352
6661
  }
6353
6662
 
6663
+ // src/commands/generated/agent-boundary.ts
6664
+ var BUILTIN_BOUNDARY = '# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C\n\n- \u53EA\u4F7F\u7528\u672C\u9879\u76EE `hcm-skills/` \u91CC\u7684\u6280\u80FD\u4E0E\u5DF2\u53D1\u5E03\u7684 `hcm` CLI\uFF1B\u4E0D\u8BFB\u53D6\u4EA7\u54C1\u6E90\u7801\uFF0C\u4E0D\u76F4\u8FDE\u6570\u636E\u5E93\uFF0C\u4E0D\u7528 `curl` \u7ED5\u8FC7 CLI\u3002\n- \u6280\u80FD\u76EE\u5F55\u5206\u4E24\u534A\uFF1A`hcm-skills/sync/` \u662F\u4EA7\u54C1\u7684\uFF08\u540C\u6B65\u7EF4\u62A4\uFF0C\u522B\u624B\u6539\uFF09\uFF0C`hcm-skills/local/` \u662F\u8FD9\u4E2A\u9879\u76EE\u81EA\u5DF1\u7684\uFF08\u540C\u6B65\u4E0D\u78B0\uFF09\u3002\u8981\u6539\u4E00\u4EFD\u4EA7\u54C1\u6280\u80FD\uFF0C\u590D\u5236\u5230 `local/` \u6539\u2014\u2014\u540C\u540D\u65F6\u5B83\u906E\u853D\u4EA7\u54C1\u90A3\u4EFD\uFF0C\u800C\u4EA7\u54C1\u90A3\u4EFD\u7EE7\u7EED\u8DDF\u7740\u66F4\u65B0\u3002\n- **\u63A5\u5230\u9700\u6C42\u5148\u505A\u4E00\u8F6E\u53EA\u8BFB\u6838\u5BF9**\uFF08\u8FB9\u754C\u3001\u6280\u80FD\u6E05\u5355\u3001CLI \u7248\u672C\u3001\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF09\uFF0C\u7ED9\u51FA READY / READY WITH RISKS / BLOCKED \u518D\u52A8\u624B\u3002\u987E\u95EE\u4E0D\u9700\u8981\u7C98\u4EFB\u4F55\u5F00\u573A\u767D\uFF0C\u8FD9\u6761\u5C31\u662F\u5F00\u573A\u767D\u3002\n- \u9700\u6C42\u8BF4\u5F97\u542B\u7CCA\u5C31\u8FFD\u95EE\uFF0C\u4E0D\u8981\u66FF\u5BA2\u6237\u731C\u53E3\u5F84\uFF1B\u53E3\u5F84\u4E0E\u8303\u56F4\u5199\u8FDB `requirements/`\uFF0C\u5BA2\u6237\u62CD\u677F\u7684\u5199\u8FDB `decisions/`\u3002\n- \u9879\u76EE\u5BF9\u7740\u7684\u73AF\u5883\u5728 `env.yaml`\uFF08default / environments\uFF0C\u5404\u73AF\u5883\u542B endpoint / frontend / tenant / roles\uFF09\uFF0C\u8EAB\u4EFD\u5728\u672C\u673A `hcm login`\u3002\u6BCF\u6B21\u5F00\u5DE5\u5148\u8DD1 `hcm chiron doctor`\uFF1B\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002\n- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002\n- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002\n- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002\n- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\uFF0C\u8981\u770B\u90A3\u5355\u7684\u5168\u90E8\u8BC4\u8BBA\u7528 `hcm chiron gap comments`\u3002\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u7528 `hcm chiron gap verify <\u5355\u53F7> --result pass|fail|partial --body <\u8BC1\u636E>` \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1B\u53EA\u9A8C `gaps/` \u53F0\u8D26\u91CC\u8BB0\u7740 `outcome=created`\u3001\u81EA\u5DF1\u63D0\u7684\u5355\uFF0C\u56DE\u5199\u524D\u8981\u9879\u76EE\u8D1F\u8D23\u4EBA\u672C\u6B21\u660E\u786E\u540C\u610F\u3002\n- \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `hcm chiron page </\u8DEF\u5F84> --expect-text <\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> --out evidence/\u2026.png`\uFF1B\u53EA\u622A\u5230\u56FE\u4E0D\u7B97\u901A\u8FC7\u3002\u8981\u70B9\u6309\u94AE / \u8FFD\u95EE / \u5207\u8303\u56F4\u518D\u622A\uFF0C\u7528 `--eval "<\u51FD\u6570\u4F53\uFF0C\u53EF await>"`\uFF080.15.7 \u8D77\uFF0C\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\u3002\n- \u4EFB\u4F55\u51ED\u636E\u3001\u914D\u5BF9\u7801\u3001\u4EE4\u724C\u3001\u5BA2\u6237\u5BC6\u7801\u90FD\u4E0D\u5F97\u5199\u5165\u4ED3\u5E93\u3001\u547D\u4EE4\u53C2\u6570\u6216\u4EA4\u4ED8\u6587\u6863\u3002';
6665
+
6354
6666
  // src/commands/chiron-agent-boundary.ts
6355
- var BUILTIN_BOUNDARY = [
6356
- "# HCM \u987E\u95EE\u9879\u76EE\u8FB9\u754C",
6357
- "",
6358
- "- \u53EA\u4F7F\u7528\u672C\u9879\u76EE `hcm-skills/` \u91CC\u7684\u6280\u80FD\u4E0E\u5DF2\u53D1\u5E03\u7684 `hcm` CLI\uFF1B\u4E0D\u8BFB\u53D6\u4EA7\u54C1\u6E90\u7801\uFF0C\u4E0D\u76F4\u8FDE\u6570\u636E\u5E93\uFF0C\u4E0D\u7528 `curl` \u7ED5\u8FC7 CLI\u3002",
6359
- "- \u6280\u80FD\u76EE\u5F55\u5206\u4E24\u534A\uFF1A`hcm-skills/sync/` \u662F\u4EA7\u54C1\u7684\uFF08\u540C\u6B65\u7EF4\u62A4\uFF0C\u522B\u624B\u6539\uFF09\uFF0C`hcm-skills/local/` \u662F\u8FD9\u4E2A\u9879\u76EE\u81EA\u5DF1\u7684\uFF08\u540C\u6B65\u4E0D\u78B0\uFF09\u3002\u8981\u6539\u4E00\u4EFD\u4EA7\u54C1\u6280\u80FD\uFF0C\u590D\u5236\u5230 `local/` \u6539\u2014\u2014\u540C\u540D\u65F6\u5B83\u906E\u853D\u4EA7\u54C1\u90A3\u4EFD\uFF0C\u800C\u4EA7\u54C1\u90A3\u4EFD\u7EE7\u7EED\u8DDF\u7740\u66F4\u65B0\u3002",
6360
- "- **\u63A5\u5230\u9700\u6C42\u5148\u505A\u4E00\u8F6E\u53EA\u8BFB\u6838\u5BF9**\uFF08\u8FB9\u754C\u3001\u6280\u80FD\u6E05\u5355\u3001CLI \u7248\u672C\u3001\u73AF\u5883\u4E0E\u8EAB\u4EFD\uFF09\uFF0C\u7ED9\u51FA READY / READY WITH RISKS / BLOCKED \u518D\u52A8\u624B\u3002\u987E\u95EE\u4E0D\u9700\u8981\u7C98\u4EFB\u4F55\u5F00\u573A\u767D\uFF0C\u8FD9\u6761\u5C31\u662F\u5F00\u573A\u767D\u3002",
6361
- "- \u9700\u6C42\u8BF4\u5F97\u542B\u7CCA\u5C31\u8FFD\u95EE\uFF0C\u4E0D\u8981\u66FF\u5BA2\u6237\u731C\u53E3\u5F84\uFF1B\u53E3\u5F84\u4E0E\u8303\u56F4\u5199\u8FDB `requirements/`\uFF0C\u5BA2\u6237\u62CD\u677F\u7684\u5199\u8FDB `decisions/`\u3002",
6362
- "- \u9879\u76EE\u5BF9\u7740\u7684\u73AF\u5883\u5728 `env.yaml`\uFF08default / environments\uFF0C\u5404\u73AF\u5883\u542B endpoint / frontend / tenant / roles\uFF09\uFF0C\u8EAB\u4EFD\u5728\u672C\u673A `hcm login`\u3002\u6BCF\u6B21\u5F00\u5DE5\u5148\u8DD1 `hcm chiron doctor`\uFF1B\u73AF\u5883\u4E8B\u5B9E\u5FC5\u987B\u73B0\u67E5\uFF0C\u4E0D\u51ED\u8BB0\u5FC6\u586B\u5199\u3002",
6363
- "- \u5199\u6388\u6743\u53EA\u8BA4\u9879\u76EE\u8D1F\u8D23\u4EBA\u5728**\u672C\u6B21\u5BF9\u8BDD\u6216\u4EFB\u52A1\u4E66**\u91CC\u7684\u660E\u786E\u6279\u51C6\uFF1B\u5BA2\u6237\u53E3\u5934\u8981\u6C42\u6216\u7FA4\u6D88\u606F\u4E0D\u662F\u6267\u884C\u6388\u6743\u3002",
6364
- "- \u5199\u524D\u5FC5\u987B\u8BF4\u660E\u5BF9\u8C61\u3001\u8303\u56F4\u3001\u5F71\u54CD\u4E0E\u56DE\u9000\u5E76\u53D6\u5F97\u672C\u6B21\u660E\u786E\u786E\u8BA4\u3002\u975E\u4EA4\u4E92\u8FD0\u884C\u62FF\u4E0D\u5230\u786E\u8BA4\u65F6**\u505C\u5728\u8BA1\u5212\u3001\u4E0D\u8981\u5199**\uFF0C\u7ED3\u8BBA\u5FC5\u987B\u4E3A `BLOCKED` \u5E76\u9644\u8BA1\u5212\u3002",
6365
- "- \u76EE\u5F55\u7EA6\u5B9A\uFF1A`requirements/` \u5BA2\u6237\u9700\u6C42 \xB7 `deliverables/` \u4EA4\u4ED8\u7269 \xB7 `evidence/` \u622A\u56FE\u4E0E\u6536\u636E \xB7 `cases/` \u6C89\u6DC0\u7684\u6848\u4F8B \xB7 `gaps/` \u4EA7\u54C1\u505A\u4E0D\u5230\u7684\u53F0\u8D26 \xB7 `decisions/` \u51B3\u7B56 \xB7 `customer-docs/` \u5BA2\u6237\u8D44\u6599 \xB7 `work/` \u53D8\u66F4\u4E0E\u56DE\u6EDA\u8BF4\u660E\u3002",
6366
- "- \u649E\u5230\u4EA7\u54C1\u505A\u4E0D\u5230\uFF1A\u5148\u5199 `gaps/` \u53F0\u8D26\u5E76\u7B54\u6E05\u4E09\u95EE\uFF0C\u7528 `hcm chiron gap search` \u67E5\u91CD\uFF0C\u7ECF\u987E\u95EE\u786E\u8BA4\u540E `hcm chiron gap submit` \u63D0\u5230 Jira\uFF08\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\uFF09\uFF0C\u62A5\u544A\u5199 `BLOCKED \xB7 \u5DF2\u63D0 <\u5355\u53F7> \xB7 \u66FF\u4EE3\u6CD5`\uFF1B\u4E4B\u540E\u7528 `hcm chiron gap status` \u67E5\u8FDB\u5EA6\uFF08\u5B83\u53EA\u7ED9\u6BCF\u6761\u8BC4\u8BBA\u7684\u9996\u884C\uFF0C\u90E8\u7F72 / \u9A8C\u6536\u7ED3\u8BBA\u7684\u5168\u6587\u7528 `hcm chiron gap comments` \u770B\uFF09\u3002\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u7528 `hcm chiron gap verify <\u5355\u53F7> --result pass|fail|partial --body <\u8BC1\u636E>` \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1B\u53EA\u9A8C\u672C\u6B21 `created` \u56DE\u6267\u91CC\u81EA\u5DF1\u63D0\u7684\u5355\uFF0C\u9A8C\u6536\u5173\u5355\u8981\u9879\u76EE\u8D1F\u8D23\u4EBA\u672C\u6B21\u540C\u610F\u3002",
6367
- "- \u9875\u9762\u9A8C\u6536\u7EDF\u4E00\u7528 `hcm chiron page </\u8DEF\u5F84> --expect-text <\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C> --out evidence/\u2026.png`\uFF1B\u53EA\u622A\u5230\u56FE\u4E0D\u7B97\u901A\u8FC7\u3002",
6368
- "- \u4EFB\u4F55\u51ED\u636E\u3001\u914D\u5BF9\u7801\u3001\u4EE4\u724C\u3001\u5BA2\u6237\u5BC6\u7801\u90FD\u4E0D\u5F97\u5199\u5165\u4ED3\u5E93\u3001\u547D\u4EE4\u53C2\u6570\u6216\u4EA4\u4ED8\u6587\u6863\u3002"
6369
- ].join("\n");
6370
6667
  var FALLBACK_NOTICE = "> \u26A0\uFE0F \u672C\u6BB5\u6765\u81EA CLI \u5185\u7F6E\u526F\u672C\uFF0C**\u672A\u4E0E\u4EA7\u54C1\u7248\u672C\u6838\u5BF9**\uFF08\u8FD9\u4E2A\u73AF\u5883\u7684 `/chiron.json` \u6CA1\u5E26 `agentBoundary`\uFF0C\u591A\u534A\u662F\u540E\u7AEF\u8FD8\u6CA1\u5347\u5230\u542B\u4F5C\u8005\u6E90\u7684\u7248\u672C\uFF09\u3002\u8054\u7F51\u5E76\u5347\u7EA7\u540E\u7AEF\u540E\u8DD1\u4E00\u6B21 `hcm chiron skills sync` \u5C31\u4F1A\u6362\u6210\u4EA7\u54C1\u90A3\u4E00\u7248\u3002";
6371
6668
  function renderBoundaryBlock(fromProduct) {
6372
6669
  const trimmed = fromProduct?.trim();
@@ -6388,11 +6685,11 @@ import { execFileSync } from "child_process";
6388
6685
  import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync as readFileSync4, rmSync, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
6389
6686
  import os2 from "os";
6390
6687
  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";
6688
+ import { CASES_REPO_SLUG, CASES_REPO_URL, CNB_ORIGIN, CliError as CliError19, CliErrorCode as CliErrorCode20, formatObject as formatObject17 } from "@hcmai/sdk";
6392
6689
  var casesCacheDir = () => process.env.HCM_CASES_CACHE?.trim() || path4.join(os2.homedir(), ".cache", "hcm", "chiron-cases");
6393
6690
  var INDEX_CACHE = () => path4.join(casesCacheDir(), "index.json");
6394
6691
  var INDEX_TTL_MS = 60 * 60 * 1e3;
6395
- var fail5 = (message, nextStep) => new CliError18({ code: CliErrorCode17.INVALID_ARGUMENT, message, context: { nextStep } });
6692
+ var fail5 = (message, nextStep) => new CliError19({ code: CliErrorCode20.INVALID_ARGUMENT, message, context: { nextStep } });
6396
6693
  var run = (cmd, args, opts = {}) => execFileSync(cmd, args, { encoding: "utf8", maxBuffer: 1 << 26, ...opts });
6397
6694
  function parseCnbEnvelope(raw, what) {
6398
6695
  const trimmed = raw.trim();
@@ -6487,7 +6784,7 @@ function matchTag(c, fp) {
6487
6784
  }
6488
6785
  function emit4(args, data, text) {
6489
6786
  if (args.output === "json" || args.output === "yaml") {
6490
- process.stdout.write(formatObject16(data, { format: args.output }) + "\n");
6787
+ process.stdout.write(formatObject17(data, { format: args.output }) + "\n");
6491
6788
  } else {
6492
6789
  process.stdout.write(text() + "\n");
6493
6790
  }
@@ -6761,14 +7058,14 @@ async function inspectJira() {
6761
7058
  // src/commands/skills-bundled.ts
6762
7059
  import { promises as fsp } from "fs";
6763
7060
  import * as path7 from "path";
6764
- import { CliError as CliError19, CliErrorCode as CliErrorCode18, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
7061
+ import { CliError as CliError20, CliErrorCode as CliErrorCode21, assertSafeReferencePath, parseSkillRequirements } from "@hcmai/sdk";
6765
7062
 
6766
7063
  // src/commands/skills-manifest.ts
6767
7064
  import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as statSync4, existsSync as existsSync2 } from "fs";
6768
7065
  import { createHash as createHash3 } from "crypto";
6769
7066
  import * as path6 from "path";
6770
7067
  import { fileURLToPath } from "url";
6771
- import { formatObject as formatObject17, parseSkillFrontmatter } from "@hcmai/sdk";
7068
+ import { formatObject as formatObject18, parseSkillFrontmatter } from "@hcmai/sdk";
6772
7069
  function collectCommandSurface(root) {
6773
7070
  const out = [];
6774
7071
  const walk = (cmd, prefix) => {
@@ -6844,7 +7141,7 @@ function buildManifest(root, skillsDir = bundledSkillsDir()) {
6844
7141
  }
6845
7142
  function skillsManifestCommand(root, args) {
6846
7143
  const manifest2 = buildManifest(root);
6847
- process.stdout.write(formatObject17(manifest2, { format: args.output ?? "json" }) + "\n");
7144
+ process.stdout.write(formatObject18(manifest2, { format: args.output ?? "json" }) + "\n");
6848
7145
  }
6849
7146
  function str(v) {
6850
7147
  return typeof v === "string" && v ? v : void 0;
@@ -6858,8 +7155,8 @@ function listBundledSkills(dir = bundledSkillsDir()) {
6858
7155
  return collectBundledSkills(dir);
6859
7156
  }
6860
7157
  function unreachable(id, detail) {
6861
- return new CliError19({
6862
- code: CliErrorCode18.SKILL_SOURCE_UNREACHABLE,
7158
+ return new CliError20({
7159
+ code: CliErrorCode21.SKILL_SOURCE_UNREACHABLE,
6863
7160
  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
7161
  \u6280\u80FD id\uFF1A${id}\uFF1B\u627E\u7684\u4F4D\u7F6E\uFF1A${bundledSkillsDir()}`
6865
7162
  });
@@ -6916,8 +7213,8 @@ async function resolveBundledClosure(targetId, dir = bundledSkillsDir()) {
6916
7213
  const visit = async (id) => {
6917
7214
  if (state.get(id) === "done") return;
6918
7215
  if (state.get(id) === "visiting") {
6919
- throw new CliError19({
6920
- code: CliErrorCode18.INVALID_ARGUMENT,
7216
+ throw new CliError20({
7217
+ code: CliErrorCode21.INVALID_ARGUMENT,
6921
7218
  message: `\u81EA\u5E26\u6280\u80FD\u4F9D\u8D56\u6210\u73AF\uFF1A${[...stack, id].join(" \u2192 ")}`
6922
7219
  });
6923
7220
  }
@@ -6974,7 +7271,7 @@ async function resolveEndpoint(args) {
6974
7271
  const env2 = resolved.config;
6975
7272
  if (env2?.endpoint) return env2.endpoint.replace(/\/+$/, "");
6976
7273
  } catch (e) {
6977
- if (e?.code !== CliErrorCode19.ENV_NOT_FOUND) throw e;
7274
+ if (e?.code !== CliErrorCode22.ENV_NOT_FOUND) throw e;
6978
7275
  const project = await discoverProjectEnv3();
6979
7276
  const name = args.env ?? project?.config.default;
6980
7277
  const fromProject = name ? project?.config.environments[name] : void 0;
@@ -6987,8 +7284,8 @@ async function resolveEndpoint(args) {
6987
7284
  }
6988
7285
  throw e;
6989
7286
  }
6990
- throw new CliError20({
6991
- code: CliErrorCode19.MISSING_FLAG,
7287
+ throw new CliError21({
7288
+ code: CliErrorCode22.MISSING_FLAG,
6992
7289
  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
7290
  });
6994
7291
  }
@@ -7005,8 +7302,8 @@ function decideTrackedEndpoint(options) {
7005
7302
  }
7006
7303
  if (!recorded) {
7007
7304
  if (!current) {
7008
- throw new CliError20({
7009
- code: CliErrorCode19.MISSING_FLAG,
7305
+ throw new CliError21({
7306
+ code: CliErrorCode22.MISSING_FLAG,
7010
7307
  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
7308
  });
7012
7309
  }
@@ -7088,8 +7385,8 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
7088
7385
  const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
7089
7386
  const conflicts = detectIdConflicts(catalog);
7090
7387
  if (conflicts.ids.length > 0) {
7091
- throw new CliError20({
7092
- code: CliErrorCode19.SKILL_ID_CONFLICT,
7388
+ throw new CliError21({
7389
+ code: CliErrorCode22.SKILL_ID_CONFLICT,
7093
7390
  message: conflictMessage(conflicts.ids, endpoint ?? "(\u672A\u77E5\u73AF\u5883)")
7094
7391
  });
7095
7392
  }
@@ -7120,7 +7417,7 @@ async function skillsListCommand(keyword, args, cwd = process.cwd()) {
7120
7417
  }
7121
7418
  if (fmt === "json" || fmt === "yaml") {
7122
7419
  process.stdout.write(
7123
- formatObject18(
7420
+ formatObject19(
7124
7421
  {
7125
7422
  ...manifest2 ?? {},
7126
7423
  categories: cats,
@@ -7209,7 +7506,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
7209
7506
  const legacy = await detectLegacyFlatLayout(layout);
7210
7507
  const legacyState = legacy ? await readSkillsState(legacy) : void 0;
7211
7508
  if (fmt === "json" || fmt === "yaml") {
7212
- process.stdout.write(formatObject18({
7509
+ process.stdout.write(formatObject19({
7213
7510
  baseDir: layout.baseDir,
7214
7511
  target: layout.target,
7215
7512
  all: false,
@@ -7268,7 +7565,7 @@ async function listInstalledSkills(keyword, args, cwd = process.cwd()) {
7268
7565
  const shown = sourceFilter === "all" ? byKeyword : byKeyword.filter((row) => row.sourceKind === sourceFilter);
7269
7566
  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
7567
  if (fmt === "json" || fmt === "yaml") {
7271
- process.stdout.write(formatObject18({
7568
+ process.stdout.write(formatObject19({
7272
7569
  baseDir: layout.baseDir,
7273
7570
  target: layout.target,
7274
7571
  endpoint: state?.endpoint,
@@ -7379,7 +7676,7 @@ async function skillsInstallCommand(id, args) {
7379
7676
  const tracked = decideTrackedEndpoint({
7380
7677
  explicit: Boolean(args.endpoint || args.env),
7381
7678
  current: await resolveEndpoint(args).catch((error) => {
7382
- if (error instanceof CliError20 && error.code === CliErrorCode19.NO_ACTIVE_ENV) return void 0;
7679
+ if (error instanceof CliError21 && error.code === CliErrorCode22.NO_ACTIVE_ENV) return void 0;
7383
7680
  throw error;
7384
7681
  }),
7385
7682
  recorded: (await readSkillsState(layout.baseDir))?.endpoint
@@ -7393,8 +7690,8 @@ async function skillsInstallCommand(id, args) {
7393
7690
  const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
7394
7691
  const conflicts = detectIdConflicts(catalog);
7395
7692
  if (conflicts.ids.length > 0) {
7396
- throw new CliError20({
7397
- code: CliErrorCode19.SKILL_ID_CONFLICT,
7693
+ throw new CliError21({
7694
+ code: CliErrorCode22.SKILL_ID_CONFLICT,
7398
7695
  message: conflictMessage(conflicts.ids, endpoint ?? "(\u672A\u77E5\u73AF\u5883)")
7399
7696
  });
7400
7697
  }
@@ -7475,7 +7772,7 @@ async function skillsInstallCommand(id, args) {
7475
7772
  const legacyState = await readSkillsState(legacyForCheck);
7476
7773
  const count = Object.keys(legacyState?.skills ?? {}).length;
7477
7774
  if (fmtCheck === "json" || fmtCheck === "yaml") {
7478
- process.stdout.write(formatObject18({
7775
+ process.stdout.write(formatObject19({
7479
7776
  dryRun: true,
7480
7777
  legacyFlatLayout: { dir: legacyForCheck, skills: count },
7481
7778
  wouldMigrate: true,
@@ -7493,7 +7790,7 @@ async function skillsInstallCommand(id, args) {
7493
7790
  }
7494
7791
  const would = documents.map((d) => d.id).sort();
7495
7792
  if (fmtCheck === "json" || fmtCheck === "yaml") {
7496
- process.stdout.write(formatObject18({
7793
+ process.stdout.write(formatObject19({
7497
7794
  dryRun: true,
7498
7795
  baseDir: layout.baseDir,
7499
7796
  target: layout.target,
@@ -7528,7 +7825,7 @@ async function skillsInstallCommand(id, args) {
7528
7825
  const agents = agentIndexes[0]?.status;
7529
7826
  const fmt = args.output ?? "table";
7530
7827
  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");
7828
+ 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
7829
  } else {
7533
7830
  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
7831
  process.stdout.write(`${headline}
@@ -7673,8 +7970,8 @@ async function resolveSkillPath(layout, id) {
7673
7970
  ...layout.localDir ? [`${layout.localDir}/${id}/SKILL.md`] : [],
7674
7971
  `${layout.baseDir}/${id}/SKILL.md`
7675
7972
  ];
7676
- throw new CliError20({
7677
- code: CliErrorCode19.INVALID_ARGUMENT,
7973
+ throw new CliError21({
7974
+ code: CliErrorCode22.INVALID_ARGUMENT,
7678
7975
  message: `\u8FD9\u4E2A\u9879\u76EE\u91CC\u6CA1\u6709\u6280\u80FD ${id}\u3002\u627E\u8FC7\uFF1A
7679
7976
  ${looked.join("\n ")}
7680
7977
  \u770B\u6709\u54EA\u4E9B\uFF1Ahcm skills list --installed\uFF1B\u6CA1\u88C5\u5C31\u5148 hcm chiron skills sync\u3002`
@@ -7686,7 +7983,7 @@ async function skillsPathCommand(id, args) {
7686
7983
  const resolved = await resolveSkillPath(layout, id);
7687
7984
  const fmt = args.output ?? "table";
7688
7985
  if (fmt === "json" || fmt === "yaml") {
7689
- process.stdout.write(formatObject18(resolved, { format: fmt }) + "\n");
7986
+ process.stdout.write(formatObject19(resolved, { format: fmt }) + "\n");
7690
7987
  process.exitCode = 0;
7691
7988
  return;
7692
7989
  }
@@ -8107,15 +8404,15 @@ function parsePruneMax(raw) {
8107
8404
  const text = typeof raw === "number" ? void 0 : raw.trim();
8108
8405
  const n = text === void 0 ? raw : text === "" ? Number.NaN : Number(text);
8109
8406
  if (!Number.isInteger(n) || n < 0) {
8110
- throw new CliError20({
8111
- code: CliErrorCode19.INVALID_ARGUMENT,
8407
+ throw new CliError21({
8408
+ code: CliErrorCode22.INVALID_ARGUMENT,
8112
8409
  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
8410
  });
8114
8411
  }
8115
8412
  return n;
8116
8413
  }
8117
8414
  function invalid(message) {
8118
- return new CliError20({ code: CliErrorCode19.INVALID_ARGUMENT, message });
8415
+ return new CliError21({ code: CliErrorCode22.INVALID_ARGUMENT, message });
8119
8416
  }
8120
8417
  var PRUNE_DEFAULT_MAX = 5;
8121
8418
  var PRUNE_MAX_SHARE = 0.5;
@@ -8343,8 +8640,8 @@ async function skillsUpdateCommand(args) {
8343
8640
  const layout = await resolveInstallLayout(args);
8344
8641
  const state = await readSkillsState(layout.baseDir);
8345
8642
  if (!state || Object.keys(state.skills).length === 0) {
8346
- throw new CliError20({
8347
- code: CliErrorCode19.INVALID_ARGUMENT,
8643
+ throw new CliError21({
8644
+ code: CliErrorCode22.INVALID_ARGUMENT,
8348
8645
  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
8646
  });
8350
8647
  }
@@ -8352,7 +8649,7 @@ async function skillsUpdateCommand(args) {
8352
8649
  const endpoint = decideTrackedEndpoint({
8353
8650
  explicit: Boolean(args.endpoint || args.env),
8354
8651
  current: await resolveEndpoint(args).catch((error) => {
8355
- if (error instanceof CliError20 && error.code === CliErrorCode19.NO_ACTIVE_ENV) return void 0;
8652
+ if (error instanceof CliError21 && error.code === CliErrorCode22.NO_ACTIVE_ENV) return void 0;
8356
8653
  throw error;
8357
8654
  }),
8358
8655
  recorded: state.endpoint
@@ -8400,7 +8697,7 @@ async function skillsUpdateCommand(args) {
8400
8697
  const changed = plan.entries.filter((e) => e.status === "updated" || e.status === "added");
8401
8698
  const fmt = args.output ?? "table";
8402
8699
  if (fmt === "json" || fmt === "yaml") {
8403
- process.stdout.write(formatObject18({
8700
+ process.stdout.write(formatObject19({
8404
8701
  endpoint,
8405
8702
  baseDir: layout.baseDir,
8406
8703
  target: layout.target,
@@ -8627,19 +8924,19 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
8627
8924
  import {
8628
8925
  bootstrapTenant,
8629
8926
  resetTenant,
8630
- HcmClient as HcmClient19,
8927
+ HcmClient as HcmClient20,
8631
8928
  readSessionPrincipal as readSessionPrincipal2,
8632
8929
  discoverProjectEnv as discoverProjectEnv4,
8633
- assertDangerWrite as assertDangerWrite3,
8930
+ assertDangerWrite as assertDangerWrite4,
8634
8931
  normalizeOrigin as normalizeOrigin4,
8635
8932
  createHttpClient as createHttpClient3,
8636
- formatObject as formatObject19,
8933
+ formatObject as formatObject20,
8637
8934
  fromAxiosError as fromAxiosError18,
8638
8935
  loadGlobalConfig as loadGlobalConfig7,
8639
8936
  resolveEnvContext as resolveEnvContext6,
8640
8937
  printResolvedEnvironment as printResolvedEnvironment5,
8641
- CliError as CliError21,
8642
- CliErrorCode as CliErrorCode20
8938
+ CliError as CliError22,
8939
+ CliErrorCode as CliErrorCode23
8643
8940
  } from "@hcmai/sdk";
8644
8941
  init_exit();
8645
8942
  init_auth_guard();
@@ -8647,27 +8944,27 @@ async function tenantResetCommand(args) {
8647
8944
  let attempted = false;
8648
8945
  try {
8649
8946
  const fmt = args.output ?? "json";
8650
- if (!["table", "json", "yaml"].includes(fmt)) throw new CliError21({
8651
- code: CliErrorCode20.INVALID_ARGUMENT,
8947
+ if (!["table", "json", "yaml"].includes(fmt)) throw new CliError22({
8948
+ code: CliErrorCode23.INVALID_ARGUMENT,
8652
8949
  message: "--output \u53D6\u503C table | json | yaml"
8653
8950
  });
8654
8951
  const ctx = await getActiveAuthContextFromCli(args);
8655
- if (ctx.impersonation) throw new CliError21({
8656
- code: CliErrorCode20.SCOPE_FORBIDDEN,
8952
+ if (ctx.impersonation) throw new CliError22({
8953
+ code: CliErrorCode23.SCOPE_FORBIDDEN,
8657
8954
  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
8955
  });
8659
8956
  const { endpoint, tenantId, env: env2 } = ctx;
8660
8957
  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 });
8958
+ assertDangerWrite4(safety, "\u91CD\u7F6E\u79DF\u6237 PostgreSQL \u6570\u636E");
8959
+ const accessToken = await HcmClient20.fromAuthContext(ctx).getAccessToken();
8960
+ 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" });
8961
+ const client3 = new HcmClient20({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
8665
8962
  client3.raw().defaults.maxRedirects = 0;
8666
8963
  client3.raw().defaults.__skipRetry = true;
8667
8964
  const principal = await readSessionPrincipal2(client3.raw());
8668
8965
  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,
8966
+ throw new CliError22({
8967
+ code: CliErrorCode23.SCOPE_FORBIDDEN,
8671
8968
  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
8969
  context: { nextStep: `hcm login --env ${env2} \u767B\u5F55\u76EE\u6807\u79DF\u6237\u7684\u5185\u7F6E admin \u540E\u91CD\u8BD5\u3002` }
8673
8970
  });
@@ -8676,13 +8973,13 @@ async function tenantResetCommand(args) {
8676
8973
  \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
8974
  `);
8678
8975
  if (!args.yes) {
8679
- if (!process.stdin.isTTY) throw new CliError21({
8680
- code: CliErrorCode20.INVALID_ARGUMENT,
8976
+ if (!process.stdin.isTTY) throw new CliError22({
8977
+ code: CliErrorCode23.INVALID_ARGUMENT,
8681
8978
  message: "\u975E\u4EA4\u4E92\u8F93\u5165\u672A\u786E\u8BA4\u79DF\u6237\u91CD\u7F6E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002",
8682
8979
  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
8980
  });
8684
8981
  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" });
8982
+ 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
8983
  }
8687
8984
  attempted = true;
8688
8985
  const receipt = await resetTenant(client3.raw(), tenantId);
@@ -8694,7 +8991,7 @@ PostgreSQL \u6838\u9A8C=${receipt.pgVerified}\uFF1B\u6574\u4F53\u6838\u9A8C=${re
8694
8991
  \u4E0B\u4E00\u6B65\uFF1A${receipt.nonPgSurface.nextStep}
8695
8992
  `
8696
8993
  );
8697
- process.stdout.write(formatObject19(receipt, { format: fmt }) + "\n");
8994
+ process.stdout.write(formatObject20(receipt, { format: fmt }) + "\n");
8698
8995
  const quote = (value) => "'" + value.replace(/'/g, "'\\''") + "'";
8699
8996
  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
8997
  `);
@@ -8712,8 +9009,8 @@ async function resolveBootstrapKey(args, stdinTaken) {
8712
9009
  if (fromEnv) return fromEnv;
8713
9010
  if (args.bootstrapKeyStdin) {
8714
9011
  if (stdinTaken) {
8715
- throw new CliError21({
8716
- code: CliErrorCode20.INVALID_ARGUMENT,
9012
+ throw new CliError22({
9013
+ code: CliErrorCode23.INVALID_ARGUMENT,
8717
9014
  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
9015
  });
8719
9016
  }
@@ -8744,8 +9041,8 @@ async function resolveEndpoint2(args) {
8744
9041
  printResolvedEnvironment5(resolved);
8745
9042
  const env2 = resolved.config;
8746
9043
  if (!env2?.endpoint) {
8747
- throw new CliError21({
8748
- code: CliErrorCode20.MISSING_FLAG,
9044
+ throw new CliError22({
9045
+ code: CliErrorCode23.MISSING_FLAG,
8749
9046
  message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`"
8750
9047
  });
8751
9048
  }
@@ -8754,15 +9051,15 @@ async function resolveEndpoint2(args) {
8754
9051
  async function tenantBootstrapCommand(args) {
8755
9052
  try {
8756
9053
  if (!args.tenantId || !args.adminUsername) {
8757
- throw new CliError21({
8758
- code: CliErrorCode20.MISSING_FLAG,
9054
+ throw new CliError22({
9055
+ code: CliErrorCode23.MISSING_FLAG,
8759
9056
  message: "--tenant-id \u4E0E --admin-username \u5FC5\u586B"
8760
9057
  });
8761
9058
  }
8762
9059
  const endpoint = await resolveEndpoint2(args);
8763
9060
  const project = await discoverProjectEnv4();
8764
9061
  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");
9062
+ assertDangerWrite4({ name: protectedNames.join(", "), danger: protectedNames.length > 0, allowDanger: args.allowDanger }, "\u5F00\u901A\u79DF\u6237");
8766
9063
  if (args.endpoint) process.stderr.write(`\u2192 ${endpoint} \xB7 \u79DF\u6237 ${args.tenantId} \xB7 \u8EAB\u4EFD bootstrap key\uFF08\u6765\u81EA --endpoint\uFF09
8767
9064
  `);
8768
9065
  const { pwd, stdinTaken } = await resolveAdminPassword(args);
@@ -8796,7 +9093,7 @@ async function tenantBootstrapCommand(args) {
8796
9093
  `
8797
9094
  );
8798
9095
  }
8799
- process.stdout.write(formatObject19(result, { format: fmt }) + "\n");
9096
+ process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
8800
9097
  process.exitCode = 0;
8801
9098
  return;
8802
9099
  } catch (e) {
@@ -8816,8 +9113,8 @@ import { promises as fsp3 } from "fs";
8816
9113
  import os4 from "os";
8817
9114
  import nodePath from "path";
8818
9115
  import {
8819
- HcmClient as HcmClient20,
8820
- formatObject as formatObject20,
9116
+ HcmClient as HcmClient21,
9117
+ formatObject as formatObject21,
8821
9118
  fromAxiosError as fromAxiosError19,
8822
9119
  listTenantMeta,
8823
9120
  getTenantMeta,
@@ -8828,14 +9125,14 @@ import {
8828
9125
  formatMetaIssues,
8829
9126
  explainJacksonError,
8830
9127
  META_SCHEMA_SOURCE_COMMIT,
8831
- CliError as CliError22,
8832
- CliErrorCode as CliErrorCode21
9128
+ CliError as CliError23,
9129
+ CliErrorCode as CliErrorCode24
8833
9130
  } from "@hcmai/sdk";
8834
9131
  init_exit();
8835
9132
  init_impersonation_lifecycle();
8836
9133
  init_auth_guard();
8837
9134
  async function client2(args) {
8838
- return HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
9135
+ return HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
8839
9136
  }
8840
9137
  function formatMetaForbiddenMessage(mode = "write") {
8841
9138
  if (mode === "read") {
@@ -8866,7 +9163,7 @@ async function metaListCommand(args) {
8866
9163
  const fmt = args.output ?? "json";
8867
9164
  if (fmt !== "json") process.stdout.write(`\u{1F4C4} ${items.length} \u4EFD${total ? ` / \u5171 ${total}` : ""}
8868
9165
  `);
8869
- process.stdout.write(formatObject20(items, { format: fmt }) + "\n");
9166
+ process.stdout.write(formatObject21(items, { format: fmt }) + "\n");
8870
9167
  process.exitCode = 0;
8871
9168
  return;
8872
9169
  } catch (e) {
@@ -8954,8 +9251,8 @@ async function verifyAfterWrite(c, path19) {
8954
9251
  async function metaSetCommand(path19, args) {
8955
9252
  try {
8956
9253
  if (!args.file) {
8957
- throw new CliError22({
8958
- code: CliErrorCode21.MISSING_FLAG,
9254
+ throw new CliError23({
9255
+ code: CliErrorCode24.MISSING_FLAG,
8959
9256
  message: "--file <path> \u5FC5\u586B\uFF08\u4ECE\u6587\u4EF6\u8BFB\u53D6 meta \u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
8960
9257
  });
8961
9258
  }
@@ -8987,7 +9284,7 @@ async function metaSetCommand(path19, args) {
8987
9284
  const dryFmt = args.output;
8988
9285
  if (dryFmt === "json" || dryFmt === "yaml") {
8989
9286
  process.stdout.write(
8990
- formatObject20(
9287
+ formatObject21(
8991
9288
  { dryRun: true, path: path19, bytes: Buffer.byteLength(content), content },
8992
9289
  { format: dryFmt }
8993
9290
  ) + "\n"
@@ -9070,7 +9367,7 @@ ${content}
9070
9367
  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
9368
  }
9072
9369
  }
9073
- process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
9370
+ process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
9074
9371
  process.exitCode = 0;
9075
9372
  return;
9076
9373
  } catch (e) {
@@ -9092,7 +9389,7 @@ async function metaDeleteCommand(path19, args) {
9092
9389
  const fmt = args.output ?? "json";
9093
9390
  if (fmt !== "json") process.stdout.write(`\u{1F5D1}\uFE0F \u5DF2\u5220\u9664 ${path19}
9094
9391
  `);
9095
- process.stdout.write(formatObject20(result, { format: fmt }) + "\n");
9392
+ process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
9096
9393
  process.exitCode = 0;
9097
9394
  return;
9098
9395
  } catch (e) {
@@ -9102,8 +9399,8 @@ async function metaDeleteCommand(path19, args) {
9102
9399
  async function metaValidateCommand(path19, args) {
9103
9400
  try {
9104
9401
  if (!args.file) {
9105
- throw new CliError22({
9106
- code: CliErrorCode21.MISSING_FLAG,
9402
+ throw new CliError23({
9403
+ code: CliErrorCode24.MISSING_FLAG,
9107
9404
  message: "--file <path> \u5FC5\u586B\uFF08\u8981\u9A8C\u7684\u90A3\u4EFD\u539F\u6587\uFF1B\u7528 - \u8868\u793A stdin\uFF09"
9108
9405
  });
9109
9406
  }
@@ -9118,7 +9415,7 @@ async function metaValidateCommand(path19, args) {
9118
9415
  const fmt = args.output ?? "table";
9119
9416
  if (fmt === "json" || fmt === "yaml") {
9120
9417
  process.stdout.write(
9121
- formatObject20(
9418
+ formatObject21(
9122
9419
  {
9123
9420
  path: path19,
9124
9421
  kind: result.kind,
@@ -9159,10 +9456,10 @@ import {
9159
9456
  createWorkspaceFile,
9160
9457
  deleteWorkspaceFile,
9161
9458
  formatMiniVerifyReport,
9162
- formatObject as formatObject21,
9163
- formatRows as formatRows5,
9459
+ formatObject as formatObject22,
9460
+ formatRows as formatRows6,
9164
9461
  getMiniStatus,
9165
- HcmClient as HcmClient21,
9462
+ HcmClient as HcmClient22,
9166
9463
  initMiniAppProject,
9167
9464
  inferMiniWritableTemplateOptionsFromModel,
9168
9465
  listWorkspaceFiles,
@@ -9219,7 +9516,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
9219
9516
  var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
9220
9517
  async function workspaceListCommand(args) {
9221
9518
  try {
9222
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
9519
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
9223
9520
  const limit = parsePositiveInt3(args.limit, 50, "--limit");
9224
9521
  const result = await client3.query("TenantExtensionWorkspace", {
9225
9522
  keyword: args.keyword,
@@ -9252,7 +9549,7 @@ async function workspaceActiveCommand(args) {
9252
9549
  const ctx = await getActiveAuthContextFromCli(args, {
9253
9550
  fallbackEnv: localContext?.profile
9254
9551
  });
9255
- const client3 = HcmClient21.fromAuthContext(ctx);
9552
+ const client3 = HcmClient22.fromAuthContext(ctx);
9256
9553
  const result = await client3.query("TenantExtensionWorkspace", {
9257
9554
  filter: { devModeEnabled: true },
9258
9555
  fields: ["workspaceKey", "devModeEnabled"],
@@ -9310,7 +9607,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
9310
9607
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
9311
9608
  );
9312
9609
  }
9313
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
9610
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
9314
9611
  const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
9315
9612
  const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
9316
9613
  workspaceKey: normalizedWorkspaceKey,
@@ -9358,7 +9655,7 @@ async function workspacePullCommand(args) {
9358
9655
  `workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
9359
9656
  );
9360
9657
  }
9361
- const client3 = HcmClient21.fromAuthContext(
9658
+ const client3 = HcmClient22.fromAuthContext(
9362
9659
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
9363
9660
  );
9364
9661
  const context = buildWorkspaceContext({
@@ -9512,7 +9809,7 @@ async function workspaceRmCommand(relativePath, args) {
9512
9809
  if (!stat) {
9513
9810
  if (manifestEntry) {
9514
9811
  process.stdout.write(
9515
- formatObject21(
9812
+ formatObject22(
9516
9813
  {
9517
9814
  workspaceKey: context.workspaceKey,
9518
9815
  file: normalized,
@@ -9537,7 +9834,7 @@ async function workspaceRmCommand(relativePath, args) {
9537
9834
  next: `hcm workspace push --dir ${args.dir ?? "."}`
9538
9835
  };
9539
9836
  if (args.output === "json" || args.output === "yaml") {
9540
- process.stdout.write(formatObject21(result, { format: args.output }) + "\n");
9837
+ process.stdout.write(formatObject22(result, { format: args.output }) + "\n");
9541
9838
  } else {
9542
9839
  process.stdout.write(`workspace file staged for deletion: ${normalized}
9543
9840
  `);
@@ -9584,10 +9881,10 @@ async function workspaceStatusCommand(args) {
9584
9881
  }
9585
9882
  if (args.output === "json" || args.output === "yaml") {
9586
9883
  process.stdout.write(
9587
- formatObject21({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
9884
+ formatObject22({ rootDir, miniApps: rows2 }, { format: args.output }) + "\n"
9588
9885
  );
9589
9886
  } else {
9590
- process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
9887
+ process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
9591
9888
  }
9592
9889
  process.exitCode = 0;
9593
9890
  return;
@@ -9618,7 +9915,7 @@ async function workspacePushCommand(args) {
9618
9915
  const rootDir = resolveRootDir(args.dir);
9619
9916
  const context = await requireWorkspaceContext(rootDir);
9620
9917
  const miniApps = await discoverMiniApps(rootDir);
9621
- const client3 = HcmClient21.fromAuthContext(
9918
+ const client3 = HcmClient22.fromAuthContext(
9622
9919
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
9623
9920
  );
9624
9921
  const activeWorkspaceKey = args.dryRun ? null : await probeActiveWorkspaceKey(client3);
@@ -9689,9 +9986,9 @@ async function workspacePreviewCommand(args) {
9689
9986
  );
9690
9987
  }
9691
9988
  if (args.output === "json" || args.output === "yaml") {
9692
- process.stdout.write(formatObject21(rows2, { format: args.output }) + "\n");
9989
+ process.stdout.write(formatObject22(rows2, { format: args.output }) + "\n");
9693
9990
  } else {
9694
- process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
9991
+ process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
9695
9992
  }
9696
9993
  process.exitCode = 0;
9697
9994
  return;
@@ -10166,7 +10463,7 @@ async function readMiniStatusSafely(app) {
10166
10463
  async function loadProfileClient(args) {
10167
10464
  try {
10168
10465
  const ctx = await getActiveAuthContextFromCli(args);
10169
- return HcmClient21.fromAuthContext(ctx);
10466
+ return HcmClient22.fromAuthContext(ctx);
10170
10467
  } catch (e) {
10171
10468
  if (args.env || args.profile) throw e;
10172
10469
  return null;
@@ -10333,10 +10630,10 @@ function optionalText(value) {
10333
10630
  }
10334
10631
  function writeWorkspaceListResult(rows2, format, total) {
10335
10632
  if (format !== "table") {
10336
- process.stdout.write(formatObject21({ rows: rows2, total }, { format }) + "\n");
10633
+ process.stdout.write(formatObject22({ rows: rows2, total }, { format }) + "\n");
10337
10634
  return;
10338
10635
  }
10339
- process.stdout.write(formatRows5(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
10636
+ process.stdout.write(formatRows6(toWorkspaceListRows(rows2), { format: "table" }) + "\n");
10340
10637
  if (total !== void 0) {
10341
10638
  process.stdout.write(`Showing ${rows2.length} of ${total} workspaces.
10342
10639
  `);
@@ -10344,7 +10641,7 @@ function writeWorkspaceListResult(rows2, format, total) {
10344
10641
  }
10345
10642
  function writeWorkspaceActiveResult(view, format) {
10346
10643
  if (format !== "table") {
10347
- process.stdout.write(formatObject21(view, { format }) + "\n");
10644
+ process.stdout.write(formatObject22(view, { format }) + "\n");
10348
10645
  return;
10349
10646
  }
10350
10647
  const rows2 = [
@@ -10358,7 +10655,7 @@ function writeWorkspaceActiveResult(view, format) {
10358
10655
  dir: view.rootDir
10359
10656
  }
10360
10657
  ];
10361
- process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
10658
+ process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
10362
10659
  if (view.nextCommand) {
10363
10660
  process.stdout.write(`\u4E0B\u4E00\u6B65\uFF1A${view.nextCommand}
10364
10661
  `);
@@ -10366,7 +10663,7 @@ function writeWorkspaceActiveResult(view, format) {
10366
10663
  }
10367
10664
  function writeWorkspaceBindResult(context, rootDir, format) {
10368
10665
  if (format !== "table") {
10369
- process.stdout.write(formatObject21({ ...context, rootDir }, { format }) + "\n");
10666
+ process.stdout.write(formatObject22({ ...context, rootDir }, { format }) + "\n");
10370
10667
  return;
10371
10668
  }
10372
10669
  process.stdout.write(
@@ -10380,7 +10677,7 @@ function writeWorkspaceBindResult(context, rootDir, format) {
10380
10677
  }
10381
10678
  function writeWorkspaceCreateResult(result, format) {
10382
10679
  if (format !== "table") {
10383
- process.stdout.write(formatObject21(result, { format }) + "\n");
10680
+ process.stdout.write(formatObject22(result, { format }) + "\n");
10384
10681
  return;
10385
10682
  }
10386
10683
  process.stdout.write(
@@ -10396,7 +10693,7 @@ function writeWorkspaceCreateResult(result, format) {
10396
10693
  }
10397
10694
  function writeWorkspacePullResult(result, format) {
10398
10695
  if (format !== "table") {
10399
- process.stdout.write(formatObject21(result, { format }) + "\n");
10696
+ process.stdout.write(formatObject22(result, { format }) + "\n");
10400
10697
  return;
10401
10698
  }
10402
10699
  const lines = [
@@ -10414,7 +10711,7 @@ function writeWorkspacePullResult(result, format) {
10414
10711
  }
10415
10712
  function writeWorkspaceAddMiniResult(result, rootDir, format) {
10416
10713
  if (format !== "table") {
10417
- process.stdout.write(formatObject21({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
10714
+ process.stdout.write(formatObject22({ ...result, workspaceRoot: rootDir }, { format }) + "\n");
10418
10715
  return;
10419
10716
  }
10420
10717
  process.stdout.write(
@@ -10430,7 +10727,7 @@ function writeWorkspaceAddMiniResult(result, rootDir, format) {
10430
10727
  function writeWorkspaceValidateResult(results, format) {
10431
10728
  if (format !== "table") {
10432
10729
  process.stdout.write(
10433
- formatObject21(
10730
+ formatObject22(
10434
10731
  results.map((item) => ({ artifact: `mini:${item.app.appCode}`, ...item.result })),
10435
10732
  { format }
10436
10733
  ) + "\n"
@@ -10443,7 +10740,7 @@ function writeWorkspaceValidateResult(results, format) {
10443
10740
  errors: item.result.errors.length,
10444
10741
  warnings: item.result.warnings.length
10445
10742
  }));
10446
- process.stdout.write(formatRows5(rows2, { format: "table" }) + "\n");
10743
+ process.stdout.write(formatRows6(rows2, { format: "table" }) + "\n");
10447
10744
  for (const item of results) {
10448
10745
  if (!item.result.errors.length && !item.result.warnings.length) continue;
10449
10746
  process.stdout.write(`
@@ -10458,7 +10755,7 @@ mini:${item.app.appCode}
10458
10755
  function writeWorkspacePushResult(rawResult, results, format) {
10459
10756
  if (format !== "table") {
10460
10757
  process.stdout.write(
10461
- formatObject21(
10758
+ formatObject22(
10462
10759
  {
10463
10760
  workspaceFiles: { artifact: "workspace", ...rawResult },
10464
10761
  miniApps: results.map((item) => ({
@@ -10487,7 +10784,7 @@ function writeWorkspacePushResult(rawResult, results, format) {
10487
10784
  );
10488
10785
  const conflicts = [...rawConflicts, ...miniConflicts];
10489
10786
  if (conflicts.length) {
10490
- process.stdout.write("conflicts:\n" + formatRows5(conflicts, { format: "table" }) + "\n");
10787
+ process.stdout.write("conflicts:\n" + formatRows6(conflicts, { format: "table" }) + "\n");
10491
10788
  return;
10492
10789
  }
10493
10790
  const rawOperations = rawResult.operations.map((operation) => ({
@@ -10507,7 +10804,7 @@ function writeWorkspacePushResult(rawResult, results, format) {
10507
10804
  }))
10508
10805
  );
10509
10806
  const operations = [...rawOperations, ...miniOperations];
10510
- process.stdout.write(formatRows5(operations, { format: "table" }) + "\n");
10807
+ process.stdout.write(formatRows6(operations, { format: "table" }) + "\n");
10511
10808
  if (rawResult.dryRun || results.some((item) => item.result.dryRun)) {
10512
10809
  process.stdout.write("dry-run: no remote changes were written\n");
10513
10810
  }
@@ -10517,7 +10814,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
10517
10814
  const ok = rawOk && reports.every((item) => item.report.ok);
10518
10815
  if (format === "json") {
10519
10816
  process.stdout.write(
10520
- formatObject21(
10817
+ formatObject22(
10521
10818
  {
10522
10819
  ok,
10523
10820
  workspaceKey: context.workspaceKey,
@@ -10544,7 +10841,7 @@ function writeWorkspaceVerifyResult(context, rootDir, raw, reports, format) {
10544
10841
  }
10545
10842
  if (format !== "table") {
10546
10843
  process.stdout.write(
10547
- formatObject21(
10844
+ formatObject22(
10548
10845
  {
10549
10846
  ok,
10550
10847
  workspaceKey: context.workspaceKey,
@@ -10653,7 +10950,7 @@ async function requestWorkspaceDeactivation(client3) {
10653
10950
  }
10654
10951
  async function workspaceActivateCommand(workspaceKey, args) {
10655
10952
  try {
10656
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
10953
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
10657
10954
  const key2 = normalizeWorkspaceKey(workspaceKey);
10658
10955
  await setDevModeBinding(client3, key2);
10659
10956
  const fmt = args.output ?? "table";
@@ -10663,7 +10960,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
10663
10960
  process.stdout.write("\u8BE5\u7A7A\u95F4\u7684 metas / scripts / menus / mini_apps \u73B0\u5DF2\u5728\u5F53\u524D\u79DF\u6237\u751F\u6548\u3002\n");
10664
10961
  } else {
10665
10962
  process.stdout.write(
10666
- formatObject21({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
10963
+ formatObject22({ workspaceKey: key2, activated: true }, { format: fmt }) + "\n"
10667
10964
  );
10668
10965
  }
10669
10966
  process.exitCode = 0;
@@ -10674,7 +10971,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
10674
10971
  }
10675
10972
  async function workspaceDeactivateCommand(args) {
10676
10973
  try {
10677
- const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
10974
+ const client3 = HcmClient22.fromAuthContext(await getActiveAuthContextFromCli(args));
10678
10975
  const binding = await requestWorkspaceDeactivation(client3);
10679
10976
  const result = { ...binding, deactivated: true };
10680
10977
  const fmt = args.output ?? "table";
@@ -10682,7 +10979,7 @@ async function workspaceDeactivateCommand(args) {
10682
10979
  process.stdout.write("workspace deactivated\n");
10683
10980
  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
10981
  } else {
10685
- process.stdout.write(formatObject21(result, { format: fmt }) + "\n");
10982
+ process.stdout.write(formatObject22(result, { format: fmt }) + "\n");
10686
10983
  }
10687
10984
  process.exitCode = 0;
10688
10985
  return;
@@ -10696,10 +10993,10 @@ init_exit();
10696
10993
  import axios4 from "axios";
10697
10994
  import {
10698
10995
  AUTH_INFO_PATH,
10699
- CliError as CliError23,
10700
- CliErrorCode as CliErrorCode22,
10701
- formatObject as formatObject22,
10702
- formatRows as formatRows6,
10996
+ CliError as CliError24,
10997
+ CliErrorCode as CliErrorCode25,
10998
+ formatObject as formatObject23,
10999
+ formatRows as formatRows7,
10703
11000
  fromAxiosError as fromAxiosError21,
10704
11001
  loadEnv as loadEnv4,
10705
11002
  saveEnv as saveEnv3,
@@ -10724,8 +11021,8 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
10724
11021
  const env2 = await loadEnv4(meta2.env);
10725
11022
  const accessToken = await TokenStore4.forIdentity(name).getStoredAccessToken();
10726
11023
  if (!accessToken) {
10727
- throw new CliError23({
10728
- code: CliErrorCode22.AUTH_FAILED,
11024
+ throw new CliError24({
11025
+ code: CliErrorCode25.AUTH_FAILED,
10729
11026
  message: `identity '${name}' \u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u6301\u4E45\u5316 token`,
10730
11027
  context: { nextStep: `\u91CD\u65B0\u767B\u5F55\u8BE5\u8EAB\u4EFD\uFF1Ahcm login --env ${meta2.env} --name ${name}` }
10731
11028
  });
@@ -10753,7 +11050,7 @@ async function inspectIdentity(name, fetcher = fetchAuthInfo) {
10753
11050
  async function identityShow(name, args) {
10754
11051
  try {
10755
11052
  const details = await inspectIdentity(name);
10756
- return exitOk(formatObject22(details, { format: args.output ?? "json" }));
11053
+ return exitOk(formatObject23(details, { format: args.output ?? "json" }));
10757
11054
  } catch (e) {
10758
11055
  exitWithError(axios4.isAxiosError(e) ? fromAxiosError21(e, name) : e);
10759
11056
  }
@@ -10765,7 +11062,7 @@ async function identityList(args) {
10765
11062
  const names = await listIdentities4(filter);
10766
11063
  const fmt = args.output ?? "table";
10767
11064
  if (names.length === 0) {
10768
- return exitOk(fmt === "table" ? "(no identities)" : formatObject22([], { format: fmt }));
11065
+ return exitOk(fmt === "table" ? "(no identities)" : formatObject23([], { format: fmt }));
10769
11066
  }
10770
11067
  const rows2 = [];
10771
11068
  for (const n of names) {
@@ -10779,7 +11076,7 @@ async function identityList(args) {
10779
11076
  isDefault: env2?.defaultIdentity === n
10780
11077
  });
10781
11078
  }
10782
- return exitOk(fmt === "table" ? formatRows6(rows2, { format: fmt }) : formatObject22(rows2, { format: fmt }));
11079
+ return exitOk(fmt === "table" ? formatRows7(rows2, { format: fmt }) : formatObject23(rows2, { format: fmt }));
10783
11080
  } catch (e) {
10784
11081
  exitWithError(e);
10785
11082
  }
@@ -10788,8 +11085,8 @@ async function identityUse(name) {
10788
11085
  try {
10789
11086
  const meta2 = await loadIdentity4(name);
10790
11087
  const env2 = await loadEnv4(meta2.env).catch(() => {
10791
- throw new CliError23({
10792
- code: CliErrorCode22.IDENTITY_NOT_IN_ENV,
11088
+ throw new CliError24({
11089
+ code: CliErrorCode25.IDENTITY_NOT_IN_ENV,
10793
11090
  message: `identity '${name}' references env '${meta2.env}' which no longer exists. Re-create the env, or remove this orphan: hcm identity remove ${name}`
10794
11091
  });
10795
11092
  });
@@ -10829,11 +11126,11 @@ init_exit();
10829
11126
  import { promises as fs9 } from "fs";
10830
11127
  import path10 from "path";
10831
11128
  import {
10832
- CliError as CliError24,
10833
- CliErrorCode as CliErrorCode23,
10834
- HcmClient as HcmClient22,
11129
+ CliError as CliError25,
11130
+ CliErrorCode as CliErrorCode26,
11131
+ HcmClient as HcmClient23,
10835
11132
  fetchReconIdentity,
10836
- formatObject as formatObject23,
11133
+ formatObject as formatObject24,
10837
11134
  httpProbe,
10838
11135
  isTempEnv as isTempEnv3,
10839
11136
  listIdentities as listIdentities5,
@@ -10845,7 +11142,7 @@ import {
10845
11142
  } from "@hcmai/sdk";
10846
11143
  async function probeTokenTenant(envName, requested) {
10847
11144
  const ctx = await getActiveAuthContextFromCli({ env: envName });
10848
- const client3 = HcmClient22.fromAuthContext(ctx);
11145
+ const client3 = HcmClient23.fromAuthContext(ctx);
10849
11146
  const identity2 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
10850
11147
  return identity2?.tenantId ? String(identity2.tenantId) : void 0;
10851
11148
  }
@@ -10893,8 +11190,8 @@ async function resolveInitEnv(root, args, deps) {
10893
11190
  if (existing && path10.dirname(existing.path) === path10.resolve(root)) {
10894
11191
  const name2 = args.env ?? existing.config.default;
10895
11192
  const env2 = existing.config.environments[name2];
10896
- if (!env2) throw new CliError24({
10897
- code: CliErrorCode23.INVALID_ARGUMENT,
11193
+ if (!env2) throw new CliError25({
11194
+ code: CliErrorCode26.INVALID_ARGUMENT,
10898
11195
  message: `${existing.path} \u91CC\u6CA1\u6709\u73AF\u5883 '${name2}'\uFF0C\u53EA\u6709\uFF1A${Object.keys(existing.config.environments).join("\u3001")}`,
10899
11196
  context: { nextStep: `hcm chiron env add ${name2} --endpoint <\u540E\u7AEF\u5730\u5740>` }
10900
11197
  });
@@ -10903,8 +11200,8 @@ async function resolveInitEnv(root, args, deps) {
10903
11200
  }
10904
11201
  if (args.env) {
10905
11202
  const config3 = await loadEnv5(args.env).catch(() => null);
10906
- if (!config3?.endpoint) throw new CliError24({
10907
- code: CliErrorCode23.ENV_NOT_FOUND,
11203
+ if (!config3?.endpoint) throw new CliError25({
11204
+ code: CliErrorCode26.ENV_NOT_FOUND,
10908
11205
  message: `\u672C\u673A\u6CA1\u6709\u540D\u53EB '${args.env}' \u7684\u73AF\u5883\u3002`,
10909
11206
  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
11207
  });
@@ -10914,14 +11211,14 @@ async function resolveInitEnv(root, args, deps) {
10914
11211
  const name = g.activeEnv;
10915
11212
  const config2 = name ? await loadEnv5(name).catch(() => null) : null;
10916
11213
  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,
11214
+ if (!config2?.endpoint) throw new CliError25({
11215
+ code: CliErrorCode26.ENV_NOT_FOUND,
10919
11216
  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
11217
  context: { nextStep: `\u4E8C\u9009\u4E00\uFF1A
10921
11218
  ${explicitPaths}` }
10922
11219
  });
10923
- if (isTempEnv3(name)) throw new CliError24({
10924
- code: CliErrorCode23.INVALID_ARGUMENT,
11220
+ if (isTempEnv3(name)) throw new CliError25({
11221
+ code: CliErrorCode26.INVALID_ARGUMENT,
10925
11222
  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
11223
  context: { nextStep: `\u5148\u7ED9\u5B83\u8D77\u4E2A\u540D\u5B57\uFF1Ahcm env save <name>\uFF1B\u6216\u76F4\u63A5\u663E\u5F0F\u5EFA\uFF1A
10927
11224
  ${explicitPaths}` }
@@ -10929,8 +11226,8 @@ ${explicitPaths}` }
10929
11226
  const summary = `${name} \xB7 ${config2.endpoint} \xB7 \u79DF\u6237 ${config2.tenantId ?? "1"}`;
10930
11227
  if (!args.yes) {
10931
11228
  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,
11229
+ if (!ok) throw new CliError25({
11230
+ code: CliErrorCode26.INVALID_ARGUMENT,
10934
11231
  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
11232
  context: { nextStep: `\u786E\u8BA4\u5C31\u52A0 --yes\uFF1B\u6216\u660E\u8BF4\uFF1A
10936
11233
  ${explicitPaths}` }
@@ -10946,16 +11243,16 @@ async function scaffoldChironProject(root, env2, envName) {
10946
11243
  const document2 = parseEnvYaml(existing);
10947
11244
  const recorded = Object.values(document2.environments).find((candidate) => candidate.endpoint === env2.endpoint && candidate.tenant === env2.tenant) ?? document2.environments[document2.default];
10948
11245
  if (recorded.endpoint !== env2.endpoint) {
10949
- throw new CliError24({
10950
- code: CliErrorCode23.INVALID_ARGUMENT,
11246
+ throw new CliError25({
11247
+ code: CliErrorCode26.INVALID_ARGUMENT,
10951
11248
  message: `${ENV_FILE} \u6307\u5411 ${recorded.endpoint}\uFF0C\u800C\u4F60\u5F53\u524D\u767B\u5F55\u7684\u662F ${env2.endpoint}\uFF08env '${envName}'\uFF09\u3002
10952
11249
  \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
11250
  \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
11251
  });
10955
11252
  }
10956
11253
  if (recorded.tenant !== env2.tenant) {
10957
- throw new CliError24({
10958
- code: CliErrorCode23.INVALID_ARGUMENT,
11254
+ throw new CliError25({
11255
+ code: CliErrorCode26.INVALID_ARGUMENT,
10959
11256
  message: `${ENV_FILE} \u662F\u79DF\u6237 ${recorded.tenant}\uFF0C\u800C\u4F60\u767B\u5F55\u7684\u8EAB\u4EFD\u5C5E\u4E8E\u79DF\u6237 ${env2.tenant}\u3002
10960
11257
  \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
11258
  });
@@ -11030,7 +11327,7 @@ async function chironInitCommand(args, deps) {
11030
11327
  const result = await runChironInit(args, deps);
11031
11328
  const fmt = args.output ?? "table";
11032
11329
  if (fmt === "json" || fmt === "yaml") {
11033
- process.stdout.write(formatObject23(result, { format: fmt }) + "\n");
11330
+ process.stdout.write(formatObject24(result, { format: fmt }) + "\n");
11034
11331
  } else {
11035
11332
  const mark = { verified: "\u2705", mismatch: "\u274C", unreachable: "\u26A0\uFE0F", skipped: "\xB7" }[result.tenantCheck.status];
11036
11333
  process.stdout.write(
@@ -11052,9 +11349,9 @@ async function chironInitCommand(args, deps) {
11052
11349
  // src/commands/gap.ts
11053
11350
  import { readFileSync as readFileSync6 } from "fs";
11054
11351
  import {
11055
- CliErrorCode as CliErrorCode25,
11352
+ CliErrorCode as CliErrorCode28,
11056
11353
  createHttpClient as createHttpClient4,
11057
- formatObject as formatObject24,
11354
+ formatObject as formatObject25,
11058
11355
  loadGlobalConfig as loadGlobalConfig10,
11059
11356
  resolveEnvContext as resolveEnvContext7,
11060
11357
  printResolvedEnvironment as printResolvedEnvironment7
@@ -11449,7 +11746,7 @@ async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug =
11449
11746
  }
11450
11747
 
11451
11748
  // 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";
11749
+ 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
11750
  var VERIFY_RESULTS = ["pass", "fail", "partial"];
11454
11751
  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
11752
  var FIXED_STATUS = "\u5DF2\u4FEE\u590D";
@@ -11463,14 +11760,14 @@ var VERIFY_PLAN = {
11463
11760
  function parseVerifyResult(raw) {
11464
11761
  const v = String(raw ?? "").trim().toLowerCase();
11465
11762
  if (VERIFY_RESULTS.includes(v)) return v;
11466
- throw new CliError25({
11467
- code: raw === void 0 ? CliErrorCode24.MISSING_FLAG : CliErrorCode24.INVALID_ARGUMENT,
11763
+ throw new CliError26({
11764
+ code: raw === void 0 ? CliErrorCode27.MISSING_FLAG : CliErrorCode27.INVALID_ARGUMENT,
11468
11765
  message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
11469
11766
  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
11767
  });
11471
11768
  }
11472
11769
  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 });
11770
+ return new CliError26({ code, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
11474
11771
  }
11475
11772
  function who(u) {
11476
11773
  if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
@@ -11546,7 +11843,7 @@ function unconfirmedWhy(e) {
11546
11843
  }
11547
11844
  function writeFailure(e, key2, what) {
11548
11845
  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), {
11846
+ return verifyFailure("write-rejected", CliErrorCode27.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
11550
11847
  key: key2,
11551
11848
  status: e.status,
11552
11849
  details: e.message
@@ -11554,7 +11851,7 @@ function writeFailure(e, key2, what) {
11554
11851
  }
11555
11852
  return verifyFailure(
11556
11853
  "write-unconfirmed",
11557
- CliErrorCode24.NETWORK_ERROR,
11854
+ CliErrorCode27.NETWORK_ERROR,
11558
11855
  "unknown",
11559
11856
  `${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
11560
11857
  `\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 +11874,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11577
11874
  if (!parsed || parsed.kind !== "jira") {
11578
11875
  throw verifyFailure(
11579
11876
  "not-jira-key",
11580
- CliErrorCode24.INVALID_ARGUMENT,
11877
+ CliErrorCode27.INVALID_ARGUMENT,
11581
11878
  "no",
11582
11879
  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
11880
  "\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 +11884,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11587
11884
  const inProject = (k) => k.startsWith(`${client3.project}-`);
11588
11885
  const wrongProject = (k) => verifyFailure(
11589
11886
  "wrong-project",
11590
- CliErrorCode24.INVALID_ARGUMENT,
11887
+ CliErrorCode27.INVALID_ARGUMENT,
11591
11888
  "no",
11592
11889
  `${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
11593
11890
  `\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 +11895,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11598
11895
  if (evidence.length < EVIDENCE_MIN) {
11599
11896
  throw verifyFailure(
11600
11897
  "evidence-too-short",
11601
- CliErrorCode24.INVALID_ARGUMENT,
11898
+ CliErrorCode27.INVALID_ARGUMENT,
11602
11899
  "no",
11603
11900
  `\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
11604
11901
  "\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 +11921,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11624
11921
  if (!sameUser(reporter, me)) {
11625
11922
  throw verifyFailure(
11626
11923
  "not-reporter",
11627
- CliErrorCode24.BUSINESS_RULE_VIOLATION,
11924
+ CliErrorCode27.BUSINESS_RULE_VIOLATION,
11628
11925
  "no",
11629
11926
  `\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
11927
  "\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 +11935,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11638
11935
  if (status !== FIXED_STATUS) {
11639
11936
  throw verifyFailure(
11640
11937
  "status-not-fixed",
11641
- CliErrorCode24.BUSINESS_RULE_VIOLATION,
11938
+ CliErrorCode27.BUSINESS_RULE_VIOLATION,
11642
11939
  "no",
11643
11940
  `${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
11644
11941
  notFixedNextStep(key2, status, o.result),
@@ -11657,7 +11954,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11657
11954
  const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
11658
11955
  throw verifyFailure(
11659
11956
  "transition-unavailable",
11660
- CliErrorCode24.BUSINESS_RULE_VIOLATION,
11957
+ CliErrorCode27.BUSINESS_RULE_VIOLATION,
11661
11958
  "no",
11662
11959
  `${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
11960
  "\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 +11966,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11669
11966
  else if (req.missing.length) {
11670
11967
  throw verifyFailure(
11671
11968
  "required-fields-missing",
11672
- CliErrorCode24.BUSINESS_RULE_VIOLATION,
11969
+ CliErrorCode27.BUSINESS_RULE_VIOLATION,
11673
11970
  "no",
11674
11971
  `\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
11675
11972
  "\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 +12007,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11710
12007
  } catch (e) {
11711
12008
  throw verifyFailure(
11712
12009
  "readback-failed",
11713
- CliErrorCode24.NETWORK_ERROR,
12010
+ CliErrorCode27.NETWORK_ERROR,
11714
12011
  "yes",
11715
12012
  `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
11716
12013
  `\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 +12021,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11724
12021
  const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
11725
12022
  throw verifyFailure(
11726
12023
  "readback-mismatch",
11727
- CliErrorCode24.SERVER_ERROR,
12024
+ CliErrorCode27.SERVER_ERROR,
11728
12025
  "yes",
11729
12026
  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
12027
  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 +12052,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11755
12052
  } catch (e) {
11756
12053
  throw verifyFailure(
11757
12054
  "readback-failed",
11758
- CliErrorCode24.NETWORK_ERROR,
12055
+ CliErrorCode27.NETWORK_ERROR,
11759
12056
  "yes",
11760
12057
  `\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
11761
12058
  `\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 +12066,7 @@ async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLU
11769
12066
  } else if (!listed.some((c) => c.id === written.id)) {
11770
12067
  throw verifyFailure(
11771
12068
  "readback-mismatch",
11772
- CliErrorCode24.SERVER_ERROR,
12069
+ CliErrorCode27.SERVER_ERROR,
11773
12070
  "yes",
11774
12071
  `Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
11775
12072
  `\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 +12102,7 @@ async function gapDeps(deps) {
11805
12102
  return { client: await deps.client() };
11806
12103
  }
11807
12104
  function emit5(fmt, data, text) {
11808
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject24(data, { format: fmt }) + "\n");
12105
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject25(data, { format: fmt }) + "\n");
11809
12106
  else process.stdout.write(text() + "\n");
11810
12107
  }
11811
12108
  async function run2(fn) {
@@ -11908,7 +12205,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
11908
12205
  if (opts.file !== void 0 && opts.body !== void 0) {
11909
12206
  throw verifyFailure(
11910
12207
  "evidence-ambiguous",
11911
- CliErrorCode25.INVALID_ARGUMENT,
12208
+ CliErrorCode28.INVALID_ARGUMENT,
11912
12209
  "no",
11913
12210
  "--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
11914
12211
  "\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
@@ -11920,7 +12217,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
11920
12217
  } catch (e) {
11921
12218
  throw verifyFailure(
11922
12219
  "evidence-unreadable",
11923
- CliErrorCode25.INVALID_ARGUMENT,
12220
+ CliErrorCode28.INVALID_ARGUMENT,
11924
12221
  "no",
11925
12222
  `\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
11926
12223
  "\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 +12230,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
11933
12230
  if (stdinIsTTY) {
11934
12231
  throw verifyFailure(
11935
12232
  "evidence-missing",
11936
- CliErrorCode25.INVALID_ARGUMENT,
12233
+ CliErrorCode28.INVALID_ARGUMENT,
11937
12234
  "no",
11938
12235
  "\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
11939
12236
  "\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 +12288,26 @@ init_exit();
11991
12288
  import { promises as fs10 } from "fs";
11992
12289
  import path11 from "path";
11993
12290
  import {
11994
- HcmClient as HcmClient23,
11995
- CliError as CliError26,
11996
- CliErrorCode as CliErrorCode26,
12291
+ HcmClient as HcmClient24,
12292
+ CliError as CliError27,
12293
+ CliErrorCode as CliErrorCode29,
11997
12294
  loadGlobalConfig as loadGlobalConfig11,
11998
12295
  resolveEnvContext as resolveEnvContext8,
11999
12296
  fetchReconIdentity as fetchReconIdentity2,
12000
- formatObject as formatObject25,
12297
+ formatObject as formatObject26,
12001
12298
  httpProbe as httpProbe2,
12002
- conversationWebSocketEndpoint as conversationWebSocketEndpoint3,
12299
+ conversationWebSocketEndpoint as conversationWebSocketEndpoint4,
12003
12300
  probeConversationHandshake,
12004
12301
  runDoctor
12005
12302
  } from "@hcmai/sdk";
12006
12303
  var defaultDeps2 = {
12007
12304
  anchors: async (envName, tenant2, as, project) => {
12008
12305
  const ctx = await getActiveAuthContextFromCli({ env: envName, as }, { cwd: project });
12009
- const client3 = HcmClient23.fromAuthContext(ctx);
12306
+ const client3 = HcmClient24.fromAuthContext(ctx);
12010
12307
  const probe = httpProbe2(client3.raw(), "default");
12011
12308
  const identity2 = await fetchReconIdentity2(probe, tenant2);
12012
12309
  const report = await runDoctor(probe, identity2, () => probeConversationHandshake({
12013
- endpoint: conversationWebSocketEndpoint3(ctx.endpoint),
12310
+ endpoint: conversationWebSocketEndpoint4(ctx.endpoint),
12014
12311
  getAccessToken: () => client3.getAccessToken()
12015
12312
  }));
12016
12313
  return { report, tokenTenant: identity2?.tenantId ? String(identity2.tenantId) : void 0 };
@@ -12044,8 +12341,8 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12044
12341
  if (args.env !== void 0 && !Object.hasOwn(file.environments, args.env)) {
12045
12342
  try {
12046
12343
  explicitSlot = await resolveEnvContext8({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig11());
12047
- if (!explicitSlot.project) throw new CliError26({
12048
- code: CliErrorCode26.INVALID_ARGUMENT,
12344
+ if (!explicitSlot.project) throw new CliError27({
12345
+ code: CliErrorCode29.INVALID_ARGUMENT,
12049
12346
  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
12347
  });
12051
12348
  selectedName = explicitSlot.project.name;
@@ -12099,7 +12396,7 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12099
12396
  });
12100
12397
  }
12101
12398
  } catch (e) {
12102
- const msg = e instanceof CliError26 ? e.message : e.message;
12399
+ const msg = e instanceof CliError27 ? e.message : e.message;
12103
12400
  report.lines.push({ item: "\u767B\u5F55", verdict: severity(), detail: `${label} \xB7 \u672C\u673A\u69FD ${found.name} \xB7 ${env3.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
12104
12401
  }
12105
12402
  }
@@ -12175,7 +12472,7 @@ async function chironDoctorCommand(args, deps) {
12175
12472
  try {
12176
12473
  const report = await runChironDoctor(args, deps);
12177
12474
  const fmt = args.output ?? "table";
12178
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject25(report, { format: fmt }) + "\n");
12475
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject26(report, { format: fmt }) + "\n");
12179
12476
  else process.stdout.write(renderChironDoctor(report) + "\n");
12180
12477
  process.exitCode = report.ok ? 0 : 1;
12181
12478
  } catch (e) {
@@ -12190,12 +12487,12 @@ import path12 from "path";
12190
12487
  import yaml from "js-yaml";
12191
12488
  import {
12192
12489
  AUTH_INFO_PATH as AUTH_INFO_PATH2,
12193
- CliError as CliError27,
12194
- CliErrorCode as CliErrorCode27,
12490
+ CliError as CliError28,
12491
+ CliErrorCode as CliErrorCode30,
12195
12492
  discoverProjectEnv as discoverProjectEnv6,
12196
12493
  ENV_FILE as ENV_FILE2,
12197
12494
  findEnvByEndpoint as findEnvByEndpoint5,
12198
- formatObject as formatObject26,
12495
+ formatObject as formatObject27,
12199
12496
  listIdentities as listIdentities6,
12200
12497
  parseEnvYaml as parseEnvYaml2,
12201
12498
  renderEnvYaml as renderEnvYaml2,
@@ -12214,7 +12511,7 @@ function summarizeReasons(reasons) {
12214
12511
  return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
12215
12512
  }
12216
12513
  function invalid2(message, nextStep) {
12217
- throw new CliError27({ code: CliErrorCode27.INVALID_ARGUMENT, message, context: { nextStep } });
12514
+ throw new CliError28({ code: CliErrorCode30.INVALID_ARGUMENT, message, context: { nextStep } });
12218
12515
  }
12219
12516
  function required(value, label) {
12220
12517
  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 +12694,7 @@ async function runChironEnv(action, args = {}) {
12397
12694
  return report;
12398
12695
  }
12399
12696
  function formatChironEnvReport(report, output = "table") {
12400
- if (output !== "table") return formatObject26(report, { format: output });
12697
+ if (output !== "table") return formatObject27(report, { format: output });
12401
12698
  const lines = [
12402
12699
  report.action === "list" ? `\u9879\u76EE\u73AF\u5883\uFF1A${report.path}` : `\u5DF2\u5199\u5165\uFF1A${report.path}`,
12403
12700
  formatTable(report.environments.map((env2) => ({
@@ -12432,11 +12729,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
12432
12729
  import fs12 from "fs/promises";
12433
12730
  import os5 from "os";
12434
12731
  import path14 from "path";
12435
- import { CliError as CliError30, CliErrorCode as CliErrorCode30, formatObject as formatObject27, HcmClient as HcmClient24, loadEnv as loadEnv6 } from "@hcmai/sdk";
12732
+ import { CliError as CliError31, CliErrorCode as CliErrorCode33, formatObject as formatObject28, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
12436
12733
  import { createRequire } from "module";
12437
12734
 
12438
12735
  // src/commands/chiron-page-cdp.ts
12439
- import { CliError as CliError28, CliErrorCode as CliErrorCode28 } from "@hcmai/sdk";
12736
+ import { CliError as CliError29, CliErrorCode as CliErrorCode31 } from "@hcmai/sdk";
12440
12737
 
12441
12738
  // src/commands/chiron-page-shared.ts
12442
12739
  function redactTicket(text) {
@@ -12472,14 +12769,14 @@ function normalizeCdpEndpoint(raw) {
12472
12769
  try {
12473
12770
  url = new URL(candidate);
12474
12771
  } 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}` });
12772
+ 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
12773
  }
12477
12774
  const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
12478
12775
  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}` });
12776
+ 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
12777
  }
12481
12778
  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}` });
12779
+ 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
12780
  }
12484
12781
  return `${protocol}//${url.hostname}:${url.port}`;
12485
12782
  }
@@ -12576,8 +12873,8 @@ async function captureViaCdp(input, io) {
12576
12873
  const browser = version?.Browser ? String(version.Browser) : `attached ${input.endpoint}`;
12577
12874
  const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
12578
12875
  if (!target?.id || !target.webSocketDebuggerUrl) {
12579
- throw new CliError28({
12580
- code: CliErrorCode28.SERVER_ERROR,
12876
+ throw new CliError29({
12877
+ code: CliErrorCode31.SERVER_ERROR,
12581
12878
  message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
12582
12879
  context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
12583
12880
  });
@@ -12607,7 +12904,7 @@ async function captureViaCdp(input, io) {
12607
12904
  });
12608
12905
  if (r.exceptionDetails) {
12609
12906
  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)}` });
12907
+ 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
12908
  }
12612
12909
  evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
12613
12910
  }
@@ -12618,7 +12915,7 @@ async function captureViaCdp(input, io) {
12618
12915
  const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
12619
12916
  const shot = await session.send("Page.captureScreenshot", { format: "png" });
12620
12917
  if (!shot.data) {
12621
- throw new CliError28({ code: CliErrorCode28.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
12918
+ throw new CliError29({ code: CliErrorCode31.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
12622
12919
  }
12623
12920
  await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
12624
12921
  return { dom, browser, evalResult, navigated, minted };
@@ -12640,7 +12937,7 @@ var defaultCdpIo = {
12640
12937
  openSocket: (wsUrl) => new Promise((resolve3, reject) => {
12641
12938
  const Ctor = globalThis.WebSocket;
12642
12939
  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" }));
12940
+ 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
12941
  return;
12645
12942
  }
12646
12943
  const ws = new Ctor(wsUrl);
@@ -12663,7 +12960,7 @@ var defaultCdpIo = {
12663
12960
 
12664
12961
  // src/commands/chiron-page-playwright.ts
12665
12962
  import path13 from "path";
12666
- import { CliError as CliError29, CliErrorCode as CliErrorCode29 } from "@hcmai/sdk";
12963
+ import { CliError as CliError30, CliErrorCode as CliErrorCode32 } from "@hcmai/sdk";
12667
12964
  function playwrightCacheRoot(probe) {
12668
12965
  const override = probe.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
12669
12966
  if (override === "0" && probe.packageRoot) return path13.join(probe.packageRoot, ".local-browsers");
@@ -12706,8 +13003,8 @@ function discoverPlaywrightBrowser(probe) {
12706
13003
  const explicit = probe.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
12707
13004
  if (explicit) {
12708
13005
  if (probe.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
12709
- throw new CliError29({
12710
- code: CliErrorCode29.INVALID_ARGUMENT,
13006
+ throw new CliError30({
13007
+ code: CliErrorCode32.INVALID_ARGUMENT,
12711
13008
  message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
12712
13009
  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
13010
  });
@@ -12749,8 +13046,8 @@ async function captureViaPlaywright(input) {
12749
13046
  }
12750
13047
  }
12751
13048
  if (!browser) {
12752
- throw new CliError29({
12753
- code: CliErrorCode29.SERVER_ERROR,
13049
+ throw new CliError30({
13050
+ code: CliErrorCode32.SERVER_ERROR,
12754
13051
  message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
12755
13052
  context: {
12756
13053
  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 +13067,7 @@ async function captureViaPlaywright(input) {
12770
13067
  evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
12771
13068
  } catch (e) {
12772
13069
  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)}` });
13070
+ throw new CliError30({ code: CliErrorCode32.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
12774
13071
  }
12775
13072
  }
12776
13073
  const dom = await page.content();
@@ -12794,13 +13091,13 @@ function judgePageContent(input) {
12794
13091
  function parseViewport(size) {
12795
13092
  const m = /^(\d+)x(\d+)$/.exec(size.trim());
12796
13093
  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}` });
13094
+ 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
13095
  }
12799
13096
  const width = Number(m[1]);
12800
13097
  const height = Number(m[2]);
12801
13098
  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,
13099
+ throw new CliError31({
13100
+ code: CliErrorCode33.INVALID_ARGUMENT,
12804
13101
  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
13102
  });
12806
13103
  }
@@ -12810,23 +13107,23 @@ function parseWaitMs(raw) {
12810
13107
  if (raw === void 0) return 1e4;
12811
13108
  const value = typeof raw === "number" ? raw : Number(raw);
12812
13109
  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}` });
13110
+ 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
13111
  }
12815
13112
  return value;
12816
13113
  }
12817
13114
  function resolveEvidenceTarget(projectRoot, out) {
12818
13115
  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` });
13116
+ 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
13117
  }
12821
13118
  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}` });
13119
+ throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
12823
13120
  }
12824
13121
  const root = path14.resolve(projectRoot);
12825
13122
  const evidenceRoot = path14.join(root, EVIDENCE_DIR);
12826
13123
  const absolute = path14.resolve(root, out);
12827
13124
  if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path14.sep)) {
12828
- throw new CliError30({
12829
- code: CliErrorCode30.INVALID_ARGUMENT,
13125
+ throw new CliError31({
13126
+ code: CliErrorCode33.INVALID_ARGUMENT,
12830
13127
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
12831
13128
  });
12832
13129
  }
@@ -12874,8 +13171,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
12874
13171
  const canonicalParent = await deps.realpath(path14.dirname(absolute));
12875
13172
  if (canonicalRoot === null || canonicalParent === null) return;
12876
13173
  if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path14.sep)) {
12877
- throw new CliError30({
12878
- code: CliErrorCode30.INVALID_ARGUMENT,
13174
+ throw new CliError31({
13175
+ code: CliErrorCode33.INVALID_ARGUMENT,
12879
13176
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
12880
13177
  });
12881
13178
  }
@@ -12884,8 +13181,8 @@ async function runChironPage(target, args, deps) {
12884
13181
  const sitePath = normalizeTarget(target);
12885
13182
  const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
12886
13183
  if (expect.length === 0) {
12887
- throw new CliError30({
12888
- code: CliErrorCode30.MISSING_FLAG,
13184
+ throw new CliError31({
13185
+ code: CliErrorCode33.MISSING_FLAG,
12889
13186
  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
13187
  });
12891
13188
  }
@@ -12895,8 +13192,8 @@ async function runChironPage(target, args, deps) {
12895
13192
  const root = path14.resolve(args.project ?? ".");
12896
13193
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
12897
13194
  if (await deps.present(absolute)) {
12898
- throw new CliError30({
12899
- code: CliErrorCode30.INVALID_ARGUMENT,
13195
+ throw new CliError31({
13196
+ code: CliErrorCode33.INVALID_ARGUMENT,
12900
13197
  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
13198
  });
12902
13199
  }
@@ -12908,8 +13205,8 @@ async function runChironPage(target, args, deps) {
12908
13205
  const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
12909
13206
  const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
12910
13207
  if (evalJs && !endpoint && !usePlaywright) {
12911
- throw new CliError30({
12912
- code: CliErrorCode30.INVALID_ARGUMENT,
13208
+ throw new CliError31({
13209
+ code: CliErrorCode33.INVALID_ARGUMENT,
12913
13210
  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
13211
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
12915
13212
  });
@@ -12927,10 +13224,10 @@ async function runChironPage(target, args, deps) {
12927
13224
  try {
12928
13225
  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
13226
  } catch (e) {
12930
- if (e instanceof CliError30) throw new CliError30({ code: e.code, message: redactTicket(e.message), context: e.context });
13227
+ if (e instanceof CliError31) throw new CliError31({ code: e.code, message: redactTicket(e.message), context: e.context });
12931
13228
  const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
12932
- throw new CliError30({
12933
- code: CliErrorCode30.SERVER_ERROR,
13229
+ throw new CliError31({
13230
+ code: CliErrorCode33.SERVER_ERROR,
12934
13231
  message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
12935
13232
  context: {
12936
13233
  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 +13243,8 @@ async function runChironPage(target, args, deps) {
12946
13243
  mode = "spawn";
12947
13244
  const browser = deps.findBrowser();
12948
13245
  if (!browser) {
12949
- throw new CliError30({
12950
- code: CliErrorCode30.INVALID_ARGUMENT,
13246
+ throw new CliError31({
13247
+ code: CliErrorCode33.INVALID_ARGUMENT,
12951
13248
  message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
12952
13249
  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
13250
  });
@@ -12955,8 +13252,8 @@ async function runChironPage(target, args, deps) {
12955
13252
  minted = await mint();
12956
13253
  const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
12957
13254
  if (!result.ok) {
12958
- throw new CliError30({
12959
- code: CliErrorCode30.SERVER_ERROR,
13255
+ throw new CliError31({
13256
+ code: CliErrorCode33.SERVER_ERROR,
12960
13257
  message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
12961
13258
  context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
12962
13259
  });
@@ -12966,7 +13263,7 @@ async function runChironPage(target, args, deps) {
12966
13263
  }
12967
13264
  const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
12968
13265
  if (bytes === 0) {
12969
- throw new CliError30({ code: CliErrorCode30.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
13266
+ throw new CliError31({ code: CliErrorCode33.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
12970
13267
  }
12971
13268
  const verdict = judgePageContent({ dom, expect, reject });
12972
13269
  return {
@@ -13029,13 +13326,13 @@ var defaultChironPageDeps = {
13029
13326
  const envCfg = await loadEnv6(ctx.env);
13030
13327
  const frontend = ctx.frontend ?? envCfg.frontend;
13031
13328
  if (!frontend?.trim()) {
13032
- throw new CliError30({
13033
- code: CliErrorCode30.INVALID_ARGUMENT,
13329
+ throw new CliError31({
13330
+ code: CliErrorCode33.INVALID_ARGUMENT,
13034
13331
  message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
13035
13332
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
13036
13333
  });
13037
13334
  }
13038
- const client3 = HcmClient24.fromAuthContext(ctx);
13335
+ const client3 = HcmClient25.fromAuthContext(ctx);
13039
13336
  const { ticket } = await mintBrowserTicket(client3, ctx.env)();
13040
13337
  return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
13041
13338
  },
@@ -13097,7 +13394,7 @@ async function chironPageCommand(target, args, deps = defaultChironPageDeps) {
13097
13394
  try {
13098
13395
  const receipt = await runChironPage(target, args, deps);
13099
13396
  const fmt = args.output ?? "table";
13100
- if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject27(receipt, { format: fmt }) + "\n");
13397
+ if (fmt === "json" || fmt === "yaml") process.stdout.write(formatObject28(receipt, { format: fmt }) + "\n");
13101
13398
  else process.stdout.write(renderChironPage(receipt) + "\n");
13102
13399
  process.exitCode = receipt.ok ? 0 : 3;
13103
13400
  } catch (e) {
@@ -13112,11 +13409,11 @@ import { randomUUID } from "crypto";
13112
13409
  import { promises as fs13 } from "fs";
13113
13410
  import path15 from "path";
13114
13411
  import yaml2 from "js-yaml";
13115
- import { formatObject as formatObject28 } from "@hcmai/sdk";
13412
+ import { formatObject as formatObject29 } from "@hcmai/sdk";
13116
13413
 
13117
13414
  // src/commands/delivery-action-policy.ts
13118
13415
  init_auth_guard();
13119
- import { HcmClient as HcmClient25, classifyEffect } from "@hcmai/sdk";
13416
+ import { HcmClient as HcmClient26, classifyEffect } from "@hcmai/sdk";
13120
13417
 
13121
13418
  // src/commands/delivery.ts
13122
13419
  import { createHash as createHash6 } from "crypto";
@@ -13436,6 +13733,12 @@ function classify(argv, actionResolution) {
13436
13733
  if (name === "chat") {
13437
13734
  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
13735
  }
13736
+ if (name === "interactions") {
13737
+ return forbidden(
13738
+ "agent-autonomy",
13739
+ "\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"
13740
+ );
13741
+ }
13439
13742
  return forbidden(
13440
13743
  "unknown-command",
13441
13744
  `\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 +13934,7 @@ async function resolveCoreAction(request) {
13631
13934
  as: request.identity,
13632
13935
  profile: request.profile
13633
13936
  });
13634
- const description = await HcmClient25.fromAuthContext(auth).describe(request.model);
13937
+ const description = await HcmClient26.fromAuthContext(auth).describe(request.model);
13635
13938
  const named = description.actions.filter((action) => action.name === request.action);
13636
13939
  if (named.length === 0) {
13637
13940
  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 +14376,7 @@ async function chironTestCommand(target, args, deps) {
14073
14376
  }
14074
14377
  const fmt = args.output ?? "table";
14075
14378
  if (fmt === "json" || fmt === "yaml") {
14076
- process.stdout.write(formatObject28({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
14379
+ process.stdout.write(formatObject29({ ok: failed2 === 0, failed: failed2, cases: report }, { format: fmt }) + "\n");
14077
14380
  } else {
14078
14381
  for (const c of report) {
14079
14382
  process.stdout.write(`
@@ -14102,11 +14405,11 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
14102
14405
  init_auth_guard();
14103
14406
  init_exit();
14104
14407
  import {
14105
- HcmClient as HcmClient26,
14408
+ HcmClient as HcmClient27,
14106
14409
  ReconLayout,
14107
14410
  ROUND_EXIT_CODES,
14108
14411
  computeReconSourceKey,
14109
- formatObject as formatObject29,
14412
+ formatObject as formatObject30,
14110
14413
  fromAxiosError as fromAxiosError22,
14111
14414
  httpProbe as httpProbe3,
14112
14415
  inspectRound,
@@ -14117,7 +14420,7 @@ var DEFAULT_CAPABILITIES = "default";
14117
14420
  async function deliveryReconCommand(args) {
14118
14421
  try {
14119
14422
  const ctx = await getActiveAuthContextFromCli(args);
14120
- const client3 = HcmClient26.fromAuthContext(ctx);
14423
+ const client3 = HcmClient27.fromAuthContext(ctx);
14121
14424
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
14122
14425
  const sourceKey = await computeReconSourceKey(probe);
14123
14426
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -14126,7 +14429,7 @@ async function deliveryReconCommand(args) {
14126
14429
  onlyModel: args.model ?? null,
14127
14430
  identity: ctx.tenantId ? { requestedTenantId: ctx.tenantId } : null
14128
14431
  });
14129
- process.stdout.write(formatObject29(summary, { format: args.output ?? "json" }) + "\n");
14432
+ process.stdout.write(formatObject30(summary, { format: args.output ?? "json" }) + "\n");
14130
14433
  } catch (e) {
14131
14434
  const err = e;
14132
14435
  if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
@@ -14140,7 +14443,7 @@ async function deliveryReconRoundCommand(args) {
14140
14443
  const result = inspectRound(args.dir ?? ".");
14141
14444
  const fmt = args.output ?? "json";
14142
14445
  if (fmt !== "json") process.stdout.write(renderRound(result));
14143
- process.stdout.write(formatObject29(result, { format: fmt }) + "\n");
14446
+ process.stdout.write(formatObject30(result, { format: fmt }) + "\n");
14144
14447
  code = ROUND_EXIT_CODES[result.state];
14145
14448
  } catch (e) {
14146
14449
  exitWithError(e);
@@ -14160,7 +14463,7 @@ import {
14160
14463
  DRY_RUN_TAIL,
14161
14464
  DriftDetected,
14162
14465
  FORCE_STALE_FLAG,
14163
- HcmClient as HcmClient27,
14466
+ HcmClient as HcmClient28,
14164
14467
  fetchReconIdentity as fetchReconIdentity3,
14165
14468
  INIT_EXIT_CODES,
14166
14469
  JOURNAL_STOP_KINDS,
@@ -14300,7 +14603,7 @@ async function authOrSignpost(args, cmd) {
14300
14603
  }
14301
14604
  async function deliverySeedPlanCommand(args) {
14302
14605
  const ctx = await authOrSignpost(args, "plan");
14303
- const client3 = HcmClient27.fromAuthContext(ctx);
14606
+ const client3 = HcmClient28.fromAuthContext(ctx);
14304
14607
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
14305
14608
  }
14306
14609
  function seedClient(client3, ctx) {
@@ -14474,7 +14777,7 @@ async function runSeedApply(args, client3) {
14474
14777
  }
14475
14778
  async function deliverySeedApplyCommand(args) {
14476
14779
  const ctx = await authOrSignpost(args, "apply");
14477
- const client3 = HcmClient27.fromAuthContext(ctx);
14780
+ const client3 = HcmClient28.fromAuthContext(ctx);
14478
14781
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
14479
14782
  }
14480
14783
  async function runSeedVerify(args, client3) {
@@ -14498,7 +14801,7 @@ async function deliverySeedVerifyCommand(args) {
14498
14801
  return;
14499
14802
  }
14500
14803
  const ctx = await authOrSignpost(args, "verify");
14501
- const client3 = HcmClient27.fromAuthContext(ctx);
14804
+ const client3 = HcmClient28.fromAuthContext(ctx);
14502
14805
  process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
14503
14806
  }
14504
14807
 
@@ -14613,7 +14916,7 @@ import {
14613
14916
  CHANGE_STATES,
14614
14917
  CHANGE_UNKNOWN,
14615
14918
  CODE_WORDS,
14616
- HcmClient as HcmClient28,
14919
+ HcmClient as HcmClient29,
14617
14920
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
14618
14921
  META_WRITE_STEPS,
14619
14922
  META_VERIFY_STEPS,
@@ -14841,7 +15144,7 @@ function lowerCaseHeaders2(headers) {
14841
15144
  }
14842
15145
  async function deliveryMetaCommand(args) {
14843
15146
  const ctx = await getActiveAuthContextFromCli(args);
14844
- const client3 = HcmClient28.fromAuthContext(ctx);
15147
+ const client3 = HcmClient29.fromAuthContext(ctx);
14845
15148
  process.exitCode = await runDeliveryMeta(
14846
15149
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
14847
15150
  metaClient(client3, ctx)
@@ -14853,7 +15156,7 @@ init_auth_guard();
14853
15156
  init_exit();
14854
15157
  import {
14855
15158
  computeReconSourceKey as computeReconSourceKey2,
14856
- HcmClient as HcmClient29,
15159
+ HcmClient as HcmClient30,
14857
15160
  httpProbe as httpProbe4,
14858
15161
  ReconLayout as ReconLayout2,
14859
15162
  runTriageRound
@@ -14909,7 +15212,7 @@ async function runTriage(args) {
14909
15212
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
14910
15213
  }
14911
15214
  const ctx = await getActiveAuthContextFromCli(args);
14912
- const client3 = HcmClient29.fromAuthContext(ctx);
15215
+ const client3 = HcmClient30.fromAuthContext(ctx);
14913
15216
  const probe = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
14914
15217
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
14915
15218
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -14938,25 +15241,25 @@ async function deliveryTriageCommand(args) {
14938
15241
  init_auth_guard();
14939
15242
  init_exit();
14940
15243
  import {
14941
- HcmClient as HcmClient30,
15244
+ HcmClient as HcmClient31,
14942
15245
  adminResetPassword,
14943
- formatObject as formatObject30,
15246
+ formatObject as formatObject31,
14944
15247
  fromAxiosError as fromAxiosError23,
14945
- CliError as CliError31,
14946
- CliErrorCode as CliErrorCode31
15248
+ CliError as CliError32,
15249
+ CliErrorCode as CliErrorCode34
14947
15250
  } from "@hcmai/sdk";
14948
15251
  function buildAdminResetPasswordRequest(args, password) {
14949
15252
  const hasId = Boolean(args.id);
14950
15253
  const hasUsername = Boolean(args.username);
14951
15254
  if (hasId === hasUsername) {
14952
- throw new CliError31({
14953
- code: CliErrorCode31.INVALID_ARGUMENT,
15255
+ throw new CliError32({
15256
+ code: CliErrorCode34.INVALID_ARGUMENT,
14954
15257
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
14955
15258
  });
14956
15259
  }
14957
15260
  if (!password) {
14958
- throw new CliError31({
14959
- code: CliErrorCode31.INVALID_ARGUMENT,
15261
+ throw new CliError32({
15262
+ code: CliErrorCode34.INVALID_ARGUMENT,
14960
15263
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
14961
15264
  });
14962
15265
  }
@@ -14972,9 +15275,9 @@ async function userResetPasswordCommand(args) {
14972
15275
  try {
14973
15276
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
14974
15277
  const request = buildAdminResetPasswordRequest(args, password);
14975
- const client3 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
15278
+ const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
14976
15279
  const result = await adminResetPassword(client3.raw(), request);
14977
- process.stdout.write(formatObject30(result, { format: args.output ?? "json" }) + "\n");
15280
+ process.stdout.write(formatObject31(result, { format: args.output ?? "json" }) + "\n");
14978
15281
  } catch (cause) {
14979
15282
  const err = cause;
14980
15283
  if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
@@ -14985,8 +15288,8 @@ async function promptPasswordTwice() {
14985
15288
  const password = await promptSecret("\u65B0\u5BC6\u7801: ");
14986
15289
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
14987
15290
  if (password !== confirmation) {
14988
- throw new CliError31({
14989
- code: CliErrorCode31.INVALID_ARGUMENT,
15291
+ throw new CliError32({
15292
+ code: CliErrorCode34.INVALID_ARGUMENT,
14990
15293
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
14991
15294
  });
14992
15295
  }
@@ -14997,19 +15300,19 @@ async function promptPasswordTwice() {
14997
15300
  init_exit();
14998
15301
  init_auth_guard();
14999
15302
  import {
15000
- HcmClient as HcmClient31,
15001
- formatObject as formatObject31,
15303
+ HcmClient as HcmClient32,
15304
+ formatObject as formatObject32,
15002
15305
  fromAxiosError as fromAxiosError24
15003
15306
  } from "@hcmai/sdk";
15004
15307
  async function modelsCommand(keyword, args) {
15005
15308
  try {
15006
- const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
15309
+ const client3 = HcmClient32.fromAuthContext(await getActiveAuthContextFromCli(args));
15007
15310
  const all = await client3.listModels();
15008
15311
  const needle = keyword?.trim().toLowerCase();
15009
15312
  const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
15010
15313
  const fmt = args.output ?? "table";
15011
15314
  if (fmt !== "table") {
15012
- process.stdout.write(formatObject31({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
15315
+ process.stdout.write(formatObject32({ total: rows2.length, models: rows2 }, { format: fmt }) + "\n");
15013
15316
  process.exitCode = 0;
15014
15317
  return;
15015
15318
  }
@@ -15099,7 +15402,7 @@ config.command("get <key>").description("\u8BFB\u53D6\u5168\u5C40 defaults").act
15099
15402
  var env = program.command("env").description("\u7BA1\u7406 HCM \u73AF\u5883\uFF08\u591A\u540E\u7AEF\u8FDE\u63A5\u914D\u7F6E\uFF09");
15100
15403
  env.command("list").description("\u5217\u51FA\u5168\u90E8 env").option("--all", "\u9879\u76EE\u76EE\u5F55\u91CC\u4E5F\u5217\u51FA\u4E0E\u672C\u9879\u76EE\u65E0\u5173\u7684\u672C\u673A\u69FD").action((opts) => envList(opts));
15101
15404
  env.command("current").description("\u663E\u793A\u5F53\u524D\u6FC0\u6D3B\u7684 env").action((opts) => envCurrent(opts));
15102
- env.command("add <name>").description("\u65B0\u589E env").option("--endpoint <url>", "HCM \u540E\u7AEF URL\uFF08\u5FC5\u586B\uFF09").option("--tenant <id>", "\u9ED8\u8BA4 tenant id", "1").option("--frontend <url>", "\u5BF9\u5E94\u524D\u7AEF URL\uFF0C\u4F8B\u5982 http://127.0.0.1:5176").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D env").action((name, opts) => envAdd(name, opts));
15405
+ env.command("add <name>").description("\u65B0\u589E env").option("--endpoint <url>", "HCM \u540E\u7AEF URL\uFF08\u5FC5\u586B\uFF09\uFF0C\u4F8B\u5982 https://hcm.example.com\uFF1B\u672B\u5C3E\u4E0D\u8981\u5E26 /\uFF08\u5E26\u4E86\u4F1A\u81EA\u52A8\u53BB\u6389\u5E76\u63D0\u793A\uFF09\uFF0C\u53EF\u5E26\u90E8\u7F72\u524D\u7F00\u5982 https://host/hcm").option("--tenant <id>", "\u9ED8\u8BA4 tenant id", "1").option("--frontend <url>", "\u5BF9\u5E94\u524D\u7AEF URL\uFF0C\u4F8B\u5982 http://127.0.0.1:5176\uFF1B\u540C\u6837\u4E0D\u8981\u5E26\u672B\u5C3E /").option("--force", "\u8986\u76D6\u5DF2\u5B58\u5728\u7684\u540C\u540D env").action((name, opts) => envAdd(name, opts));
15103
15406
  env.command("use <name>").description("\u5207\u5230\u6307\u5B9A env").option("--no-ping", "\u8DF3\u8FC7 endpoint \u5065\u5EB7\u68C0\u67E5").action((name, opts) => envUse(name, opts));
15104
15407
  env.command("save <name>").description("\u628A\u5F53\u524D\u4E34\u65F6\u73AF\u5883\uFF08login --code \u4EA7\u751F\u7684\uFF09\u5B58\u6210\u5177\u540D env").option("--force", "\u76EE\u6807 env \u5DF2\u5B58\u5728\u65F6\u8986\u76D6\u5B83\u7684\u914D\u7F6E").action((name, opts) => envSave(name, opts));
15105
15408
  env.command("remove <name>").description("\u5220\u9664 env\uFF08\u7EA7\u8054\u6E05\u9664\u8BE5 env \u7684\u5168\u90E8 identity \u548C token\uFF09").option("--force", "\u8DF3\u8FC7\u786E\u8BA4\u63D0\u793A").action((name, opts) => envRemove(name, opts));
@@ -15222,7 +15525,24 @@ program.command("create <Model>").description("\u521B\u5EFA\u4E00\u6761 Model \u
15222
15525
  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
15526
  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
15527
  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));
15528
+ 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));
15529
+ 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");
15530
+ var withInteractionCommonOpts = (cmd) => {
15531
+ 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");
15532
+ return cmd;
15533
+ };
15534
+ withInteractionCommonOpts(
15535
+ interactions.command("list").description("\u5217\u51FA\u8BE5\u4F1A\u8BDD\u4E0A\u4ECD\u672A\u51B3\u7684\u6682\u505C")
15536
+ ).action((opts) => interactionsListCommand(opts));
15537
+ withInteractionCommonOpts(
15538
+ 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")
15539
+ ).action((id, opts) => interactionsRespondCommand("approve", id, opts));
15540
+ withInteractionCommonOpts(
15541
+ 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")
15542
+ ).action((id, opts) => interactionsRespondCommand("reject", id, opts));
15543
+ withInteractionCommonOpts(
15544
+ 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")
15545
+ ).action((id, opts) => interactionsRespondCommand("answer", id, opts));
15226
15546
  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
15547
  "--events [conversationId]",
15228
15548
  "\u53EA\u8BFB\u67E5\u770B\u6307\u5B9A conversation \u7684 timeline/event \u6D41\uFF1B\u4E5F\u53EF\u914D --resume <id>"