@hcmai/cli 0.34.0 → 0.34.1

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
@@ -6656,10 +6656,10 @@ async function loginCommand(args) {
6656
6656
  }
6657
6657
  const err = e;
6658
6658
  if (err.isAxiosError) {
6659
- const { fromAxiosError: fromAxiosError36 } = await import("@hcmai/sdk");
6659
+ const { fromAxiosError: fromAxiosError37 } = await import("@hcmai/sdk");
6660
6660
  exitWithError(
6661
6661
  withTenantHostMismatchStep(
6662
- fromAxiosError36(
6662
+ fromAxiosError37(
6663
6663
  e,
6664
6664
  envName
6665
6665
  ),
@@ -10091,19 +10091,72 @@ async function traceCommand(traceId, args) {
10091
10091
  }
10092
10092
  }
10093
10093
 
10094
+ // src/commands/subscription-migration.ts
10095
+ init_auth_guard();
10096
+ init_exit();
10097
+ import { readFile as readFile5 } from "fs/promises";
10098
+ import { HcmClient as HcmClient18, fromAxiosError as fromAxiosError18 } from "@hcmai/sdk";
10099
+ var FAILED_TASK_STATUSES = /* @__PURE__ */ new Set(["FAILED", "CANCELLED", "TIMEOUT", "DEAD_LETTERED"]);
10100
+ async function subscriptionMigrationCommand(operation, args) {
10101
+ try {
10102
+ if (args.output && args.output !== "json") throw new Error("\u8FC1\u79FB\u547D\u4EE4\u53EA\u652F\u6301 --output json\uFF0C\u5B8C\u6574\u4FDD\u7559\u672A\u77E5\u8BA1\u6570\u4E0E\u539F\u56E0");
10103
+ let body = {};
10104
+ if (args.data) {
10105
+ const text2 = args.data.startsWith("@") ? await readFile5(args.data.slice(1), "utf8") : args.data;
10106
+ const parsed = JSON.parse(text2);
10107
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error("--data \u5FC5\u987B\u662F JSON \u5BF9\u8C61\u6216 @\u6587\u4EF6");
10108
+ body = parsed;
10109
+ }
10110
+ if (args.dryRunTaskId) body.dryRunTaskId = args.dryRunTaskId;
10111
+ if (args.taskId) body.taskId = args.taskId;
10112
+ if (args.recordIds !== void 0) {
10113
+ const ids = args.recordIds.split(",").map((id) => id.trim());
10114
+ if (ids.some((id) => id === "")) throw new Error("--record-ids \u542B\u7A7A id\uFF1B\u5199\u6210\u9017\u53F7\u5206\u9694\u7684\u7269\u7406\u8BB0\u5F55 UUID\uFF0C\u4F8B\u5982 --record-ids <id1>,<id2>");
10115
+ body.recordIds = ids;
10116
+ }
10117
+ if (operation === "apply" && !body.dryRunTaskId) throw new Error("apply \u5FC5\u987B\u4F20 --dry-run-task-id <id>\uFF0C\u5148 dry-run \u5E76\u67E5\u770B\u5B8C\u6574\u62A5\u544A");
10118
+ if (operation === "restore" && Boolean(body.taskId) === Boolean(body.recordIds)) throw new Error("restore \u5FC5\u987B\u4F20 --task-id \u6216 --record-ids\uFF0C\u4E8C\u9009\u4E00");
10119
+ if (operation === "status" && !args.taskId) throw new Error("status \u5FC5\u987B\u4F20\u4EFB\u52A1 id");
10120
+ const client4 = HcmClient18.fromAuthContext(await getActiveAuthContextFromCli(args));
10121
+ const base = "/api/subscription-migration";
10122
+ const response = operation === "status" ? await client4.raw().get(`${base}/tasks/${encodeURIComponent(args.taskId)}`) : await client4.raw().post(`${base}/${operation}`, body);
10123
+ const payload = response.data;
10124
+ process.stdout.write(JSON.stringify(payload, null, 2) + "\n");
10125
+ const result = payload?.data ?? payload;
10126
+ if (operation !== "status" && result?.taskId) {
10127
+ process.stderr.write(`\u4E0B\u4E00\u6B65\uFF1Ahcm subscription-migration status ${result.taskId}${args.env ? ` --env ${args.env}` : ""}
10128
+ `);
10129
+ } else if (result?.nextStep) {
10130
+ process.stderr.write(`\u4E0B\u4E00\u6B65\uFF1A${result.nextStep}
10131
+ `);
10132
+ }
10133
+ const failed2 = operation === "status" && FAILED_TASK_STATUSES.has(String(result?.status));
10134
+ if (failed2) {
10135
+ process.stderr.write(`\u4EFB\u52A1 ${args.taskId} \u72B6\u6001\u4E3A ${result.status}\uFF1A${result?.errorMessage ?? result?.reason ?? "\u672A\u7ED9\u51FA\u539F\u56E0"}\uFF1B\u5DF2\u5199\u6761\u76EE\u89C1 report.details / report.writtenByBackups
10136
+ `);
10137
+ }
10138
+ process.exitCode = failed2 ? 1 : 0;
10139
+ } catch (error) {
10140
+ if (error && typeof error === "object" && "isAxiosError" in error) {
10141
+ exitWithError(fromAxiosError18(error, args.env));
10142
+ }
10143
+ exitWithError(error);
10144
+ }
10145
+ }
10146
+
10094
10147
  // src/commands/cache.ts
10095
10148
  init_exit();
10096
10149
  init_auth_guard();
10097
10150
  import {
10098
- HcmClient as HcmClient18,
10151
+ HcmClient as HcmClient19,
10099
10152
  formatObject as formatObject15,
10100
- fromAxiosError as fromAxiosError18,
10153
+ fromAxiosError as fromAxiosError19,
10101
10154
  getCacheStats,
10102
10155
  clearModelCache,
10103
10156
  clearMetaCache
10104
10157
  } from "@hcmai/sdk";
10105
10158
  async function withClient(args, fn) {
10106
- const client4 = HcmClient18.fromAuthContext(await getActiveAuthContextFromCli(args));
10159
+ const client4 = HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
10107
10160
  return fn(client4);
10108
10161
  }
10109
10162
  function emit(result, args, human) {
@@ -10115,7 +10168,7 @@ function emit(result, args, human) {
10115
10168
  }
10116
10169
  function fail3(e, args) {
10117
10170
  const err = e;
10118
- if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
10171
+ if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
10119
10172
  exitWithError(e);
10120
10173
  process.exit(1);
10121
10174
  }
@@ -10153,16 +10206,16 @@ init_exit();
10153
10206
  init_auth_guard();
10154
10207
  import { readFileSync as readFileSync4 } from "fs";
10155
10208
  import {
10156
- HcmClient as HcmClient19,
10209
+ HcmClient as HcmClient20,
10157
10210
  formatObject as formatObject16,
10158
- fromAxiosError as fromAxiosError19,
10211
+ fromAxiosError as fromAxiosError20,
10159
10212
  scriptDryRun,
10160
10213
  validateScriptManifest,
10161
10214
  queryScriptLogs,
10162
10215
  getScriptTask
10163
10216
  } from "@hcmai/sdk";
10164
10217
  async function withClient2(args, fn) {
10165
- const client4 = HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
10218
+ const client4 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
10166
10219
  return fn(client4);
10167
10220
  }
10168
10221
  function emit2(result, args, human) {
@@ -10174,7 +10227,7 @@ function emit2(result, args, human) {
10174
10227
  }
10175
10228
  function fail4(e, args) {
10176
10229
  const err = e;
10177
- if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
10230
+ if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
10178
10231
  exitWithError(e);
10179
10232
  process.exit(1);
10180
10233
  }
@@ -10264,16 +10317,16 @@ async function scriptTaskCommand(taskId, args) {
10264
10317
  init_exit();
10265
10318
  init_auth_guard();
10266
10319
  import {
10267
- HcmClient as HcmClient20,
10320
+ HcmClient as HcmClient21,
10268
10321
  formatObject as formatObject17,
10269
- fromAxiosError as fromAxiosError20,
10322
+ fromAxiosError as fromAxiosError21,
10270
10323
  uploadDocument as uploadDocument2
10271
10324
  } from "@hcmai/sdk";
10272
10325
  var DEFAULT_UPLOAD_CATEGORY = "attachment";
10273
10326
  async function uploadCommand(filePath2, args) {
10274
10327
  try {
10275
10328
  const ctx = await getActiveAuthContextFromCli(args);
10276
- const client4 = HcmClient20.fromAuthContext(ctx);
10329
+ const client4 = HcmClient21.fromAuthContext(ctx);
10277
10330
  const meta2 = await uploadDocument2(
10278
10331
  client4.raw(),
10279
10332
  filePath2,
@@ -10307,7 +10360,7 @@ async function uploadCommand(filePath2, args) {
10307
10360
  } else if (status === 413) {
10308
10361
  exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
10309
10362
  } else if (err?.isAxiosError) {
10310
- exitWithError(fromAxiosError20(err, args.env));
10363
+ exitWithError(fromAxiosError21(err, args.env));
10311
10364
  } else {
10312
10365
  exitWithError(e);
10313
10366
  }
@@ -10318,11 +10371,11 @@ async function uploadCommand(filePath2, args) {
10318
10371
  init_exit();
10319
10372
  init_auth_guard();
10320
10373
  import {
10321
- HcmClient as HcmClient21,
10374
+ HcmClient as HcmClient22,
10322
10375
  CliError as CliError22,
10323
10376
  CliErrorCode as CliErrorCode22,
10324
10377
  formatObject as formatObject18,
10325
- fromAxiosError as fromAxiosError21,
10378
+ fromAxiosError as fromAxiosError22,
10326
10379
  packDataPackage,
10327
10380
  installDataPackageArtifactAsync,
10328
10381
  waitForInstallRun,
@@ -10390,7 +10443,7 @@ function parseRetries(raw) {
10390
10443
  async function datapackageInstallCommand(artifactPath, args) {
10391
10444
  try {
10392
10445
  const ctx = await getActiveAuthContextFromCli(args);
10393
- const client4 = HcmClient21.fromAuthContext(ctx);
10446
+ const client4 = HcmClient22.fromAuthContext(ctx);
10394
10447
  const fmt = args.output ?? "json";
10395
10448
  const human = fmt !== "json";
10396
10449
  const confirmations = {
@@ -10506,7 +10559,7 @@ async function datapackageInstallCommand(artifactPath, args) {
10506
10559
  if (err?.code === "ENOENT") {
10507
10560
  exitWithError(new Error(`\u5236\u54C1\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${artifactPath}`));
10508
10561
  } else if (err?.isAxiosError) {
10509
- exitWithError(fromAxiosError21(err, args.env));
10562
+ exitWithError(fromAxiosError22(err, args.env));
10510
10563
  } else {
10511
10564
  exitWithError(e);
10512
10565
  }
@@ -10515,7 +10568,7 @@ async function datapackageInstallCommand(artifactPath, args) {
10515
10568
  async function datapackageStatusCommand(runId, args) {
10516
10569
  try {
10517
10570
  const ctx = await getActiveAuthContextFromCli(args);
10518
- const client4 = HcmClient21.fromAuthContext(ctx);
10571
+ const client4 = HcmClient22.fromAuthContext(ctx);
10519
10572
  const run3 = await fetchInstallRun(client4, runId);
10520
10573
  const fmt = args.output ?? "json";
10521
10574
  if (!run3) {
@@ -10544,7 +10597,7 @@ async function datapackageStatusCommand(runId, args) {
10544
10597
  return;
10545
10598
  } catch (e) {
10546
10599
  const err = e;
10547
- if (err?.isAxiosError) exitWithError(fromAxiosError21(err, args.env));
10600
+ if (err?.isAxiosError) exitWithError(fromAxiosError22(err, args.env));
10548
10601
  else exitWithError(e);
10549
10602
  }
10550
10603
  }
@@ -10570,7 +10623,7 @@ init_auth_guard();
10570
10623
  import { promises as fs7 } from "fs";
10571
10624
  import * as path7 from "path";
10572
10625
  import yaml from "js-yaml";
10573
- import { HcmClient as HcmClient22, fromAxiosError as fromAxiosError22, CliError as CliError23, CliErrorCode as CliErrorCode23, stripDefinitionIds, columnSlotsToFlex, redactDescriptiveUuids, removeActionsUsingScripts, stripUnknownFieldKeysForPath } from "@hcmai/sdk";
10626
+ import { HcmClient as HcmClient23, fromAxiosError as fromAxiosError23, CliError as CliError23, CliErrorCode as CliErrorCode23, stripDefinitionIds, columnSlotsToFlex, redactDescriptiveUuids, removeActionsUsingScripts, stripUnknownFieldKeysForPath } from "@hcmai/sdk";
10574
10627
 
10575
10628
  // src/commands/env-lane-api.ts
10576
10629
  function createLaneApi(http2) {
@@ -11603,7 +11656,7 @@ async function envExportConfigCommand(args) {
11603
11656
  throw new CliError23({ code: CliErrorCode23.INVALID_ARGUMENT, message: `\u8F93\u51FA\u76EE\u5F55\u975E\u7A7A\uFF1A${outDir}`, context: { nextStep: "\u6362\u4E00\u4E2A\u7A7A\u76EE\u5F55\uFF0C\u6216\u52A0 --force \u8986\u76D6\uFF08\u4F1A\u5148\u6E05\u7A7A data/ \u4E0E extensions/\uFF09" } });
11604
11657
  }
11605
11658
  const ctx = await getActiveAuthContextFromCli(args);
11606
- const client4 = HcmClient22.fromAuthContext(ctx);
11659
+ const client4 = HcmClient23.fromAuthContext(ctx);
11607
11660
  const result = await runExportConfig(createLaneApi(client4.raw()), {
11608
11661
  endpoint: ctx.endpoint,
11609
11662
  tenantId: ctx.tenantId,
@@ -11651,7 +11704,7 @@ async function envExportConfigCommand(args) {
11651
11704
  process.stderr.write(renderNextSteps(outDir, r));
11652
11705
  process.exitCode = r.status === "DEGRADED" ? 3 : 0;
11653
11706
  } catch (e) {
11654
- if (e?.isAxiosError) exitWithError(fromAxiosError22(e, args.env));
11707
+ if (e?.isAxiosError) exitWithError(fromAxiosError23(e, args.env));
11655
11708
  exitWithError(e);
11656
11709
  }
11657
11710
  }
@@ -11702,7 +11755,7 @@ init_auth_guard();
11702
11755
  import { promises as fs8 } from "fs";
11703
11756
  import * as path8 from "path";
11704
11757
  import yaml2 from "js-yaml";
11705
- import { HcmClient as HcmClient23, fromAxiosError as fromAxiosError23, CliError as CliError24, CliErrorCode as CliErrorCode24 } from "@hcmai/sdk";
11758
+ import { HcmClient as HcmClient24, fromAxiosError as fromAxiosError24, CliError as CliError24, CliErrorCode as CliErrorCode24 } from "@hcmai/sdk";
11706
11759
  var FINGERPRINT_MODELS = ["Employee", "OrgUnit", "Position", "Assignment"];
11707
11760
  var RED_LINE_FIELD_RE = /^(name|shortName|code|fullName|realName|userName|username|idNumber|idNo|certNo|archiveNumber)$|(name|idnumber|idcard|phone|mobile|tel|email|address|contact|remark|description|comment|memo|note|reason|text)$|(creator|updator|updater|operator|modifier|handler|approver|reviewer|auditor)(id|code|no)?$/i;
11708
11761
  var OTHER_BUCKET = "_other";
@@ -12364,7 +12417,7 @@ async function envFingerprintCommand(args) {
12364
12417
  });
12365
12418
  }
12366
12419
  const ctx = await getActiveAuthContextFromCli(args);
12367
- const api2 = createLaneApi(HcmClient23.fromAuthContext(ctx).raw());
12420
+ const api2 = createLaneApi(HcmClient24.fromAuthContext(ctx).raw());
12368
12421
  const fieldMetas = /* @__PURE__ */ new Map();
12369
12422
  const fp = await collectFingerprint(api2, { tenantId: ctx.tenantId, minBucket, fieldMetas, log: (l) => process.stderr.write(`${l}
12370
12423
  `) });
@@ -12417,12 +12470,13 @@ async function envFingerprintCommand(args) {
12417
12470
  `);
12418
12471
  process.exitCode = exit;
12419
12472
  } catch (e) {
12420
- if (e?.isAxiosError) exitWithError(fromAxiosError23(e, args.env));
12473
+ if (e?.isAxiosError) exitWithError(fromAxiosError24(e, args.env));
12421
12474
  exitWithError(e);
12422
12475
  }
12423
12476
  }
12424
12477
 
12425
12478
  // src/commands/skills.ts
12479
+ init_auth_guard();
12426
12480
  init_exit();
12427
12481
  import { promises as fsp4 } from "fs";
12428
12482
  import os3 from "os";
@@ -12431,6 +12485,7 @@ import { createHash as createHash4 } from "crypto";
12431
12485
  import axios4 from "axios";
12432
12486
  import {
12433
12487
  createHttpClient as createHttpClient2,
12488
+ TokenStore as TokenStore4,
12434
12489
  fetchSkillCatalog,
12435
12490
  fetchSkillMarkdown,
12436
12491
  fetchSkillReference,
@@ -12445,7 +12500,7 @@ import {
12445
12500
  matchSkills,
12446
12501
  filterByStage,
12447
12502
  formatObject as formatObject21,
12448
- fromAxiosError as fromAxiosError24,
12503
+ fromAxiosError as fromAxiosError25,
12449
12504
  loadGlobalConfig as loadGlobalConfig6,
12450
12505
  discoverProjectEnv as discoverProjectEnv3,
12451
12506
  resolveEnvContext as resolveEnvContext5,
@@ -12991,7 +13046,7 @@ function sha2562(text2) {
12991
13046
  }
12992
13047
  async function resolveEndpoint(args) {
12993
13048
  if (args.endpoint) {
12994
- process.stderr.write(`\u2192 ${args.endpoint} \xB7 \u8EAB\u4EFD \u672A\u8BA4\u8BC1\uFF08\u6765\u81EA --endpoint\uFF09
13049
+ process.stderr.write(`\u2192 ${args.endpoint}\uFF08\u6765\u81EA --endpoint\uFF09
12995
13050
  `);
12996
13051
  return args.endpoint.replace(/\/+$/, "");
12997
13052
  }
@@ -13008,7 +13063,7 @@ async function resolveEndpoint(args) {
13008
13063
  const fromProject = name ? project2?.config.environments[name] : void 0;
13009
13064
  if (fromProject?.endpoint) {
13010
13065
  process.stderr.write(
13011
- `\u2192 ${fromProject.endpoint} \xB7 \u79DF\u6237 ${fromProject.tenant} \xB7 \u8EAB\u4EFD \u672A\u767B\u5F55\uFF08\u6765\u81EA ${project2.path} \u7684 '${name}'\uFF1B\u672C\u673A\u6CA1\u6709\u5339\u914D\u7684\u69FD\uFF0C\u4F46\u6280\u80FD\u5E93\u514D\u8BA4\u8BC1\uFF0C\u53D6\u76EE\u5F55\u4E0D\u9700\u8981\u5B83\uFF09
13066
+ `\u2192 ${fromProject.endpoint} \xB7 \u79DF\u6237 ${fromProject.tenant} \xB7 \u8EAB\u4EFD \u672A\u767B\u5F55\uFF08\u6765\u81EA ${project2.path} \u7684 '${name}'\uFF1B\u672C\u673A\u6CA1\u6709\u5339\u914D\u7684\u69FD\uFF09
13012
13067
  `
13013
13068
  );
13014
13069
  return fromProject.endpoint.replace(/\/+$/, "");
@@ -13017,7 +13072,7 @@ async function resolveEndpoint(args) {
13017
13072
  }
13018
13073
  throw new CliError31({
13019
13074
  code: CliErrorCode31.MISSING_FLAG,
13020
- 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"
13075
+ message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002 \u8BBF\u95EE\u53D7\u4FDD\u62A4\u7684\u6280\u80FD\u5E93\u9700\u767B\u8BB0\u6709\u6743\u9650\u7684\u51ED\u636E\u3002"
13021
13076
  });
13022
13077
  }
13023
13078
  function normalizeEndpoint(endpoint) {
@@ -13035,7 +13090,7 @@ function decideTrackedEndpoint(options) {
13035
13090
  if (!current) {
13036
13091
  throw new CliError31({
13037
13092
  code: CliErrorCode31.MISSING_FLAG,
13038
- 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"
13093
+ message: "\u672A\u89E3\u6790\u5230 endpoint \u2014\u2014 \u4F20 --endpoint <url>\uFF0C\u6216\u5148 `hcm env add <name> --endpoint <url>`\u3002 \u8BBF\u95EE\u53D7\u4FDD\u62A4\u7684\u6280\u80FD\u5E93\u9700\u767B\u8BB0\u6709\u6743\u9650\u7684\u51ED\u636E\u3002"
13039
13094
  });
13040
13095
  }
13041
13096
  return current;
@@ -13111,15 +13166,42 @@ async function resolveInstallLayout(args, cwd = process.cwd(), forWrite = false)
13111
13166
  baseDir: explicitDir ?? (args.global ? path16.join(os3.homedir(), ".claude", "skills") : path16.join(cwd, ".claude", "skills"))
13112
13167
  };
13113
13168
  }
13169
+ async function createChironHttpClient(endpoint, args, timeoutMs) {
13170
+ const target = normalizeEndpoint(endpoint);
13171
+ let accessToken = null;
13172
+ const explicitToken = process.env.HCM_PAT || process.env.HCM_ACCESS_TOKEN;
13173
+ const project2 = await discoverProjectEnv3(args.cwd);
13174
+ if (explicitToken && args.endpoint && !project2 && normalizeEndpoint(args.endpoint) === target) {
13175
+ accessToken = explicitToken;
13176
+ } else {
13177
+ try {
13178
+ const resolved = await resolveEnvContext5({ envFlag: args.env, cwd: args.cwd }, process.env, await loadGlobalConfig6());
13179
+ if (normalizeEndpoint(resolved.config.endpoint) === target) {
13180
+ const context = await getActiveAuthContextFromCli(
13181
+ { env: args.env ?? resolved.project?.name ?? resolved.name },
13182
+ { cwd: args.cwd }
13183
+ );
13184
+ if (normalizeEndpoint(context.endpoint) !== target) {
13185
+ throw new CliError31({
13186
+ code: CliErrorCode31.IDENTITY_NOT_IN_ENV,
13187
+ message: "\u6280\u80FD\u5E93\u76EE\u6807\u4E0E\u5F53\u524D\u8EAB\u4EFD\u5730\u5740\u4E0D\u4E00\u81F4",
13188
+ context: { nextStep: "\u6838\u5BF9\u76EE\u6807\u73AF\u5883\u7684 endpoint\uFF0C\u91CD\u65B0\u9009\u62E9\u8BE5\u73AF\u5883\u540E\u518D\u540C\u6B65\u3002" }
13189
+ });
13190
+ }
13191
+ accessToken = context.ephemeralAccessToken ?? await TokenStore4.forIdentity(context.identity).getStoredAccessToken();
13192
+ }
13193
+ } catch (error) {
13194
+ if (!(error instanceof CliError31 && (error.code === CliErrorCode31.NO_ACTIVE_ENV || error.code === CliErrorCode31.ENV_NOT_FOUND || error.code === CliErrorCode31.IDENTITY_NOT_FOUND))) throw error;
13195
+ }
13196
+ }
13197
+ const http2 = createHttpClient2({ endpoint: target, getAccessToken: async () => accessToken, onRefresh: async () => {
13198
+ }, timeoutMs });
13199
+ if (accessToken) http2.defaults.maxRedirects = 0;
13200
+ return http2;
13201
+ }
13114
13202
  async function chironClient(args, options = {}) {
13115
13203
  const endpoint = options.endpoint ?? await resolveEndpoint(args);
13116
- const http2 = createHttpClient2({
13117
- endpoint,
13118
- getAccessToken: async () => null,
13119
- onRefresh: async () => {
13120
- },
13121
- timeoutMs: options.timeoutMs
13122
- });
13204
+ const http2 = await createChironHttpClient(endpoint, args, options.timeoutMs);
13123
13205
  if (options.signal) http2.defaults.signal = options.signal;
13124
13206
  if (options.onNoResponse) {
13125
13207
  const observe = options.onNoResponse;
@@ -13152,13 +13234,13 @@ function fail6(e, args) {
13152
13234
  if (err.config?.url) requestPath = new URL(axios4.getUri(err.config), "https://request-path.invalid").pathname;
13153
13235
  } catch {
13154
13236
  }
13155
- const traceId = fromAxiosError24(err, args.env).traceId;
13237
+ const traceId = fromAxiosError25(err, args.env).traceId;
13156
13238
  exitWithError(new Error(
13157
13239
  `\u6280\u80FD\u8D44\u6E90\u8BF7\u6C42\u8FD4\u56DE HTTP 404${requestPath ? `\uFF1A${requestPath}` : "\uFF08\u8BF7\u6C42\u8DEF\u5F84\u672A\u77E5\uFF09"}${traceId ? ` [traceId: ${traceId}]` : ""}\u3002
13158
13240
  \u4E0B\u4E00\u6B65: \u8FD0\u884C hcm skills list \u6838\u5BF9\u5F53\u524D\u76EE\u5F55\uFF1B\u82E5\u76EE\u5F55\u4ECD\u58F0\u660E\u8BE5\u8D44\u6E90\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u7AEF\u8D44\u6E90\u548C\u5B9E\u4F8B\u7248\u672C\uFF0C\u518D\u91CD\u8BD5\u3002`
13159
13241
  ));
13160
13242
  }
13161
- if (err?.isAxiosError) exitWithError(fromAxiosError24(err, args.env));
13243
+ if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.env));
13162
13244
  exitWithError(e);
13163
13245
  process.exit(1);
13164
13246
  }
@@ -13417,7 +13499,7 @@ var SHOW_CHECK_REQUEST_TIMEOUT_MS = 5e3;
13417
13499
  var SHOW_CHECK_TOTAL_MS = 8e3;
13418
13500
  function uncheckedReason(error, args) {
13419
13501
  const err = error;
13420
- const resolved = err?.isAxiosError ? fromAxiosError24(err, args.env) : error;
13502
+ const resolved = err?.isAxiosError ? fromAxiosError25(err, args.env) : error;
13421
13503
  const first = (resolved instanceof Error ? resolved.message : String(resolved)).split("\n")[0].trim();
13422
13504
  if (!(resolved instanceof CliError31)) return first || String(resolved);
13423
13505
  const reason = typeof resolved.context?.reason === "string" ? `\uFF1A${resolved.context.reason}` : "";
@@ -13529,11 +13611,11 @@ async function skillsInstallCommand(id, args) {
13529
13611
  }),
13530
13612
  recorded: (await readSkillsState(layout.baseDir))?.endpoint
13531
13613
  });
13532
- const client4 = await beforeAnyWrite(chironClient({ ...args, endpoint: tracked }));
13614
+ const client4 = await beforeAnyWrite(chironClient(args, { endpoint: tracked }));
13533
13615
  endpoint = client4.endpoint;
13534
13616
  base = client4.base;
13535
13617
  http2 = client4.http;
13536
- manifest2 = await beforeAnyWrite(fetchSkillCatalog(http2, base));
13618
+ manifest2 = await beforeAnyWrite(fetchSkillCatalog(http2, base, { requireInstallMetadata: true }));
13537
13619
  }
13538
13620
  const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
13539
13621
  const conflicts = detectIdConflicts(catalog);
@@ -15018,10 +15100,10 @@ async function skillsUpdateCommand(args) {
15018
15100
  let base;
15019
15101
  let http2;
15020
15102
  if (source !== "cli") {
15021
- const client4 = await beforeAnyWrite(chironClient({ ...args, endpoint }));
15103
+ const client4 = await beforeAnyWrite(chironClient(args, { endpoint }));
15022
15104
  http2 = client4.http;
15023
15105
  base = client4.base;
15024
- manifest2 = await beforeAnyWrite(fetchSkillCatalog(http2, base));
15106
+ manifest2 = await beforeAnyWrite(fetchSkillCatalog(http2, base, { requireInstallMetadata: true }));
15025
15107
  }
15026
15108
  const bundled = source === "chiron" ? void 0 : listBundledSkills();
15027
15109
  const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
@@ -15324,14 +15406,14 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
15324
15406
  import {
15325
15407
  bootstrapTenant,
15326
15408
  resetTenant,
15327
- HcmClient as HcmClient24,
15409
+ HcmClient as HcmClient25,
15328
15410
  readSessionPrincipal as readSessionPrincipal2,
15329
15411
  discoverProjectEnv as discoverProjectEnv4,
15330
15412
  assertDangerWrite as assertDangerWrite4,
15331
15413
  normalizeOrigin as normalizeOrigin4,
15332
15414
  createHttpClient as createHttpClient3,
15333
15415
  formatObject as formatObject22,
15334
- fromAxiosError as fromAxiosError25,
15416
+ fromAxiosError as fromAxiosError26,
15335
15417
  loadGlobalConfig as loadGlobalConfig7,
15336
15418
  resolveEnvContext as resolveEnvContext6,
15337
15419
  printResolvedEnvironment as printResolvedEnvironment5,
@@ -15356,9 +15438,9 @@ async function tenantResetCommand(args) {
15356
15438
  const { endpoint, tenantId, env: env2 } = ctx;
15357
15439
  const safety = ctx.environmentSafety ? { ...ctx.environmentSafety } : void 0;
15358
15440
  assertDangerWrite4(safety, "\u91CD\u7F6E\u79DF\u6237 PostgreSQL \u6570\u636E");
15359
- const accessToken = await HcmClient24.fromAuthContext(ctx).getAccessToken();
15441
+ const accessToken = await HcmClient25.fromAuthContext(ctx).getAccessToken();
15360
15442
  if (!accessToken) throw new CliError32({ code: CliErrorCode32.AUTH_FAILED, message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
15361
- const client4 = new HcmClient24({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
15443
+ const client4 = new HcmClient25({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
15362
15444
  client4.raw().defaults.maxRedirects = 0;
15363
15445
  client4.raw().defaults.__skipRetry = true;
15364
15446
  const principal = await readSessionPrincipal2(client4.raw());
@@ -15401,7 +15483,7 @@ PostgreSQL \u6838\u9A8C=${receipt.pgVerified}\uFF1B\u6574\u4F53\u6838\u9A8C=${re
15401
15483
  process.exitCode = receipt.pgVerified ? 0 : 4;
15402
15484
  } catch (error) {
15403
15485
  const e = error;
15404
- const cliError = e?.isAxiosError ? fromAxiosError25(error, args.env) : error;
15486
+ const cliError = e?.isAxiosError ? fromAxiosError26(error, args.env) : error;
15405
15487
  if (attempted) {
15406
15488
  process.stderr.write(rejectedBeforeExecution(cliError) ? "TENANT_RESET_REJECTED_BEFORE_EXECUTION\uFF1A\u670D\u52A1\u7AEF\u5728\u6267\u884C\u524D\u62D2\u7EDD\u4E86\u672C\u6B21\u8BF7\u6C42\uFF0C\u672A\u53D1\u751F\u91CD\u7F6E\u3001\u6CA1\u6709\u91CD\u7F6E\u6D41\u6C34\uFF1B\u6309\u4E0B\u9762\u7684\u670D\u52A1\u7AEF\u8BF4\u660E\u5904\u7406\u540E\u518D\u91CD\u8BD5\u3002\n" : "TENANT_RESET_RESULT_UNKNOWN\uFF1A\u672C\u6B21\u5DF2\u5C1D\u8BD5\u4E00\u6B21\u91CD\u7F6E\uFF0C\u7ED3\u679C\u672A\u786E\u8BA4\uFF1B\u672A\u81EA\u52A8\u91CD\u8BD5\u3002\u4E0D\u8981\u76F2\u76EE\u91CD\u8DD1\uFF0C\u8BF7\u6838\u67E5\u670D\u52A1\u7AEF\u6D41\u6C34\u4E0E\u5F53\u524D\u79DF\u6237\u72B6\u6001\u3002\n");
15407
15489
  }
@@ -15574,7 +15656,7 @@ async function tenantBootstrapCommand(args) {
15574
15656
  if (err?.response?.status === 403) {
15575
15657
  exitWithError(new Error("bootstrap key \u65E0\u6548\uFF08403\uFF09\u2014\u2014 \u6838\u5BF9\u90E8\u7F72\u65B9\u63D0\u4F9B\u7684 key\uFF0C\u52FF\u590D\u7528\u5176\u4ED6\u73AF\u5883\u7684"));
15576
15658
  } else if (err?.isAxiosError) {
15577
- exitWithError(fromAxiosError25(err, args.env));
15659
+ exitWithError(fromAxiosError26(err, args.env));
15578
15660
  } else {
15579
15661
  exitWithError(e);
15580
15662
  }
@@ -15584,14 +15666,14 @@ async function tenantBootstrapCommand(args) {
15584
15666
  // src/commands/tenant-reconcile.ts
15585
15667
  init_auth_guard();
15586
15668
  import {
15587
- HcmClient as HcmClient25,
15669
+ HcmClient as HcmClient26,
15588
15670
  readSessionPrincipal as readSessionPrincipal3,
15589
15671
  reconcileTenant,
15590
15672
  assertDangerWrite as assertDangerWrite5,
15591
15673
  formatObject as formatObject23,
15592
15674
  CliError as CliError33,
15593
15675
  CliErrorCode as CliErrorCode33,
15594
- fromAxiosError as fromAxiosError26
15676
+ fromAxiosError as fromAxiosError27
15595
15677
  } from "@hcmai/sdk";
15596
15678
  import axios5 from "axios";
15597
15679
  init_exit();
@@ -15630,12 +15712,12 @@ async function tenantReconcileCommand(args) {
15630
15712
  const { endpoint, tenantId, env: env2 } = ctx;
15631
15713
  const safety = ctx.environmentSafety ? { ...ctx.environmentSafety } : void 0;
15632
15714
  assertDangerWrite5(safety, "\u8865\u8DD1\u5F53\u524D\u79DF\u6237\u521D\u59CB\u5316");
15633
- const accessToken = await HcmClient25.fromAuthContext(ctx).getAccessToken();
15715
+ const accessToken = await HcmClient26.fromAuthContext(ctx).getAccessToken();
15634
15716
  if (!accessToken) throw new CliError33({
15635
15717
  code: CliErrorCode33.AUTH_FAILED,
15636
15718
  message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u8865\u8DD1\u3002"
15637
15719
  });
15638
- const client4 = new HcmClient25({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
15720
+ const client4 = new HcmClient26({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
15639
15721
  client4.raw().defaults.maxRedirects = 0;
15640
15722
  client4.raw().defaults.__skipRetry = true;
15641
15723
  const principal = await readSessionPrincipal3(client4.raw());
@@ -15680,7 +15762,7 @@ async function tenantReconcileCommand(args) {
15680
15762
  ...!passed ? { reason: "\u521D\u59CB\u5316\u590D\u9A8C\u672A\u8BC1\u660E\u5F53\u524D\u79DF\u6237\u5168\u90E8\u7EC4\u4EF6\u901A\u8FC7\uFF1B\u8BF7\u8BFB\u53D6\u539F\u59CB report\uFF0C\u4E0D\u80FD\u5BA3\u79F0\u5B8C\u6210\u3002" } : {}
15681
15763
  };
15682
15764
  } catch (error) {
15683
- const translated = axios5.isAxiosError(error) ? fromAxiosError26(error, env2) : error;
15765
+ const translated = axios5.isAxiosError(error) ? fromAxiosError27(error, env2) : error;
15684
15766
  verification = { status: "UNDETERMINED", reason: translated instanceof Error ? translated.message : "\u521D\u59CB\u5316\u590D\u9A8C\u5931\u8D25\uFF0C\u539F\u56E0\u672A\u77E5" };
15685
15767
  }
15686
15768
  }
@@ -15701,7 +15783,7 @@ async function tenantReconcileCommand(args) {
15701
15783
  process.exitCode = verification.status === "PASS" ? 0 : 3;
15702
15784
  } catch (error) {
15703
15785
  if (attempted) process.stderr.write("TENANT_RECONCILE_RESULT_UNKNOWN\uFF1A\u5DF2\u5C1D\u8BD5\u4E00\u6B21\u8865\u8DD1\uFF0C\u7ED3\u679C\u672A\u786E\u8BA4\uFF0C\u672A\u81EA\u52A8\u91CD\u53D1\uFF1B\u5148\u53EA\u8BFB\u68C0\u67E5 tenant.bootstrap \u4E0E\u670D\u52A1\u7AEF\u65E5\u5FD7\uFF0C\u4E0D\u8981\u76F2\u76EE\u91CD\u8DD1\u3002\n");
15704
- exitWithError(axios5.isAxiosError(error) ? fromAxiosError26(error, args.env) : error);
15786
+ exitWithError(axios5.isAxiosError(error) ? fromAxiosError27(error, args.env) : error);
15705
15787
  }
15706
15788
  }
15707
15789
 
@@ -15710,9 +15792,9 @@ import { promises as fsp5 } from "fs";
15710
15792
  import os4 from "os";
15711
15793
  import nodePath from "path";
15712
15794
  import {
15713
- HcmClient as HcmClient26,
15795
+ HcmClient as HcmClient27,
15714
15796
  formatObject as formatObject24,
15715
- fromAxiosError as fromAxiosError27,
15797
+ fromAxiosError as fromAxiosError28,
15716
15798
  listTenantMeta,
15717
15799
  getTenantMeta,
15718
15800
  saveTenantMeta,
@@ -15729,7 +15811,7 @@ init_exit();
15729
15811
  init_impersonation_lifecycle();
15730
15812
  init_auth_guard();
15731
15813
  async function client2(args) {
15732
- return HcmClient26.fromAuthContext(await getActiveAuthContextFromCli(args));
15814
+ return HcmClient27.fromAuthContext(await getActiveAuthContextFromCli(args));
15733
15815
  }
15734
15816
  function formatMetaForbiddenMessage(mode = "write") {
15735
15817
  if (mode === "read") {
@@ -15744,7 +15826,7 @@ function fail7(e, args, mode = "write") {
15744
15826
  new Error(formatMetaForbiddenMessage(mode))
15745
15827
  );
15746
15828
  }
15747
- if (err?.isAxiosError) exitWithError(fromAxiosError27(err, args.env));
15829
+ if (err?.isAxiosError) exitWithError(fromAxiosError28(err, args.env));
15748
15830
  exitWithError(e);
15749
15831
  process.exit(1);
15750
15832
  }
@@ -16050,7 +16132,7 @@ init_exit();
16050
16132
  init_error_output();
16051
16133
  init_auth_guard();
16052
16134
  import {
16053
- HcmClient as HcmClient27,
16135
+ HcmClient as HcmClient28,
16054
16136
  CliError as CliError35,
16055
16137
  CliErrorCode as CliErrorCode35,
16056
16138
  formatObject as formatObject25,
@@ -16082,7 +16164,7 @@ function flagsOf(args) {
16082
16164
  return connFlags(args) + (args.workspace ? ` --workspace ${args.workspace}` : "");
16083
16165
  }
16084
16166
  function client3(args) {
16085
- return getActiveAuthContextFromCli(args).then((ctx) => HcmClient27.fromAuthContext(ctx));
16167
+ return getActiveAuthContextFromCli(args).then((ctx) => HcmClient28.fromAuthContext(ctx));
16086
16168
  }
16087
16169
  function formatOf(args) {
16088
16170
  return args.output === "json" || args.output === "yaml" ? args.output : "table";
@@ -16281,7 +16363,7 @@ async function metaColumnSlotSqlCommand(model, field, args) {
16281
16363
  init_exit();
16282
16364
  init_auth_guard();
16283
16365
  import {
16284
- HcmClient as HcmClient28,
16366
+ HcmClient as HcmClient29,
16285
16367
  CliError as CliError36,
16286
16368
  CliErrorCode as CliErrorCode36,
16287
16369
  formatObject as formatObject26,
@@ -16377,7 +16459,7 @@ function writeNotes2(view, args, fmt) {
16377
16459
  async function metaStorageSlotsCommand(args) {
16378
16460
  try {
16379
16461
  const family = requestedFamily(args);
16380
- const client4 = HcmClient28.fromAuthContext(await getActiveAuthContextFromCli(args));
16462
+ const client4 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
16381
16463
  const full = await getStorageSlots(client4.raw());
16382
16464
  const view = family ? pickFamily(full, family) : full;
16383
16465
  const fmt = formatOf2(args);
@@ -16405,7 +16487,7 @@ import {
16405
16487
  formatObject as formatObject28,
16406
16488
  formatRows as formatRows6,
16407
16489
  getMiniStatus,
16408
- HcmClient as HcmClient29,
16490
+ HcmClient as HcmClient30,
16409
16491
  initMiniAppProject,
16410
16492
  inferMiniWritableTemplateOptionsFromModel,
16411
16493
  listWorkspaceFiles,
@@ -16422,14 +16504,14 @@ import {
16422
16504
  validateMiniProject,
16423
16505
  validateMetaContent as validateMetaContent2,
16424
16506
  validateWorkspaceFiles,
16425
- fromAxiosError as fromAxiosError29,
16507
+ fromAxiosError as fromAxiosError30,
16426
16508
  CliError as CliError38,
16427
16509
  CliErrorCode as CliErrorCode38
16428
16510
  } from "@hcmai/sdk";
16429
16511
 
16430
16512
  // src/commands/workspace-push-progress.ts
16431
16513
  import { isAxiosError as isAxiosError2 } from "axios";
16432
- import { CliError as CliError37, CliErrorCode as CliErrorCode37, fromAxiosError as fromAxiosError28 } from "@hcmai/sdk";
16514
+ import { CliError as CliError37, CliErrorCode as CliErrorCode37, fromAxiosError as fromAxiosError29 } from "@hcmai/sdk";
16433
16515
  var PUSH_DEADLINE_MS = 3e5;
16434
16516
  var HEARTBEAT_MS = 1e4;
16435
16517
  async function withWorkspacePushProgress(run3, profile) {
@@ -16500,7 +16582,7 @@ async function withWorkspacePushProgress(run3, profile) {
16500
16582
  return await Promise.race([operation, deadline]);
16501
16583
  } catch (error) {
16502
16584
  if (!isAxiosError2(error)) throw error;
16503
- const translated = fromAxiosError28(error, profile);
16585
+ const translated = fromAxiosError29(error, profile);
16504
16586
  throw new CliError37({
16505
16587
  code: translated.code,
16506
16588
  message: translated.message,
@@ -16881,7 +16963,7 @@ function isProtectedWorkspacePath(relativePath) {
16881
16963
  }
16882
16964
  async function workspaceListCommand(args) {
16883
16965
  try {
16884
- const client4 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
16966
+ const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
16885
16967
  const limit = parsePositiveInt3(args.limit, 50, "--limit");
16886
16968
  const result = await client4.query("TenantExtensionWorkspace", {
16887
16969
  keyword: args.keyword,
@@ -16914,7 +16996,7 @@ async function workspaceActiveCommand(args) {
16914
16996
  const ctx = await getActiveAuthContextFromCli(args, {
16915
16997
  fallbackEnv: localContext?.profile
16916
16998
  });
16917
- const client4 = HcmClient29.fromAuthContext(ctx);
16999
+ const client4 = HcmClient30.fromAuthContext(ctx);
16918
17000
  const binding = await readWorkspaceDevModeBinding(client4);
16919
17001
  const activeWorkspaceKey = binding.enabled ? optionalText(binding.workspaceKey) : null;
16920
17002
  const bindingUpdatedAt = typeof binding.updatedAt === "number" && Number.isFinite(binding.updatedAt) && binding.updatedAt > 0 && binding.updatedAt <= 864e13 ? binding.updatedAt : null;
@@ -16972,7 +17054,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
16972
17054
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
16973
17055
  );
16974
17056
  }
16975
- const client4 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
17057
+ const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
16976
17058
  const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
16977
17059
  const resp = await client4.raw().post("/api/models/TenantExtensionWorkspace", {
16978
17060
  workspaceKey: normalizedWorkspaceKey,
@@ -17014,7 +17096,7 @@ async function workspaceRebaseCommand(args) {
17014
17096
  try {
17015
17097
  const existing = await readWorkspaceContext(resolveRootDir(args.dir));
17016
17098
  const workspaceKey = normalizeWorkspaceKey(args.workspace ?? existing?.workspaceKey ?? "");
17017
- await runWorkspaceRebase(workspaceKey, args, async () => HcmClient29.fromAuthContext(
17099
+ await runWorkspaceRebase(workspaceKey, args, async () => HcmClient30.fromAuthContext(
17018
17100
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
17019
17101
  ));
17020
17102
  process.exitCode = 0;
@@ -17032,7 +17114,7 @@ async function workspacePullCommand(args) {
17032
17114
  `workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
17033
17115
  );
17034
17116
  }
17035
- const client4 = HcmClient29.fromAuthContext(
17117
+ const client4 = HcmClient30.fromAuthContext(
17036
17118
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
17037
17119
  );
17038
17120
  const context = buildWorkspaceContext({
@@ -17199,7 +17281,7 @@ async function workspaceRmCommand(relativePath, args) {
17199
17281
  const manifest2 = await readWorkspaceRawManifest(rootDir, context);
17200
17282
  let manifestEntry = workspaceRawBaselineByPath(manifest2).get(normalized);
17201
17283
  if (!manifestEntry) {
17202
- const client4 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(
17284
+ const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(
17203
17285
  args,
17204
17286
  { fallbackEnv: context.profile }
17205
17287
  ));
@@ -17363,7 +17445,7 @@ async function workspacePushCommand(args) {
17363
17445
  });
17364
17446
  }
17365
17447
  }
17366
- const client4 = HcmClient29.fromAuthContext(
17448
+ const client4 = HcmClient30.fromAuthContext(
17367
17449
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
17368
17450
  );
17369
17451
  profile = client4.profile ?? profile;
@@ -17971,7 +18053,7 @@ ${formatReleaseIssues(result.preflight.releaseIssues, " ")}` : ""),
17971
18053
  checkpointSaved
17972
18054
  });
17973
18055
  } catch (error) {
17974
- const translated = error?.isAxiosError ? fromAxiosError29(error, args.profile ?? args.context.profile) : error;
18056
+ const translated = error?.isAxiosError ? fromAxiosError30(error, args.profile ?? args.context.profile) : error;
17975
18057
  const details = translated instanceof CliError38 ? translated.context?.details : void 0;
17976
18058
  const commitDetails = details && typeof details === "object" && !Array.isArray(details) ? details : void 0;
17977
18059
  const serverCommitted = error?.isAxiosError === true && commitDetails?.workspaceKey === args.context.workspaceKey && commitDetails.relativePath === operation.remotePath && commitDetails.commitState === "COMMITTED";
@@ -18062,7 +18144,7 @@ async function preflightWorkspacePlan(http2, workspaceKey, operations, localFile
18062
18144
  }
18063
18145
  function preflightCallFailure(error, sent, profile) {
18064
18146
  const status = error?.response?.status;
18065
- const translated = error?.isAxiosError ? fromAxiosError29(error, profile) : error;
18147
+ const translated = error?.isAxiosError ? fromAxiosError30(error, profile) : error;
18066
18148
  const detail = translated instanceof Error ? translated.message : String(translated);
18067
18149
  return {
18068
18150
  status: "unavailable",
@@ -18435,7 +18517,7 @@ async function readMiniStatusSafely(app) {
18435
18517
  async function loadProfileClient(args) {
18436
18518
  try {
18437
18519
  const ctx = await getActiveAuthContextFromCli(args);
18438
- return HcmClient29.fromAuthContext(ctx);
18520
+ return HcmClient30.fromAuthContext(ctx);
18439
18521
  } catch (e) {
18440
18522
  if (args.env || args.profile) throw e;
18441
18523
  return null;
@@ -18893,7 +18975,7 @@ function exitWorkspaceError(err, profile, operation, format) {
18893
18975
  return exitWithError(failure2);
18894
18976
  };
18895
18977
  const maybeAxios = err;
18896
- const translated = maybeAxios?.isAxiosError ? fromAxiosError29(err, profile) : err;
18978
+ const translated = maybeAxios?.isAxiosError ? fromAxiosError30(err, profile) : err;
18897
18979
  if (translated instanceof CliError38 && operation && translated.context?.status === 409 && ["WORKSPACE_REVISION_CONFLICT", "DEPLOY_IN_PROGRESS"].includes(String(translated.context.responseCode))) {
18898
18980
  const scope = `${profile ? ` --env ${quoteWorkspaceArg(profile)}` : ""}${operation.as ? ` --as ${quoteWorkspaceArg(operation.as)}` : ""}`;
18899
18981
  const active = "hcm workspace active" + scope + (operation.dir ? ` --dir ${quoteWorkspaceArg(operation.dir)}` : "");
@@ -18980,7 +19062,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
18980
19062
  let recovery2;
18981
19063
  let profile = args.env ?? args.profile;
18982
19064
  try {
18983
- const client4 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
19065
+ const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
18984
19066
  profile = client4.profile ?? profile;
18985
19067
  const key2 = normalizeWorkspaceKey(workspaceKey);
18986
19068
  recovery2 = { command: "activate", workspaceKey: key2, as: args.as };
@@ -19003,7 +19085,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
19003
19085
  }
19004
19086
  async function workspaceDeactivateCommand(args) {
19005
19087
  try {
19006
- const client4 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
19088
+ const client4 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
19007
19089
  const binding = await requestWorkspaceDeactivation(client4);
19008
19090
  const result = { ...binding, deactivated: true };
19009
19091
  const fmt = args.output ?? "table";
@@ -19029,7 +19111,7 @@ import {
19029
19111
  CliErrorCode as CliErrorCode39,
19030
19112
  formatObject as formatObject29,
19031
19113
  formatRows as formatRows7,
19032
- fromAxiosError as fromAxiosError30,
19114
+ fromAxiosError as fromAxiosError31,
19033
19115
  loadEnv as loadEnv4,
19034
19116
  saveEnv as saveEnv3,
19035
19117
  loadIdentity as loadIdentity4,
@@ -19038,7 +19120,7 @@ import {
19038
19120
  loadGlobalConfig as loadGlobalConfig8,
19039
19121
  resolveActiveEnv,
19040
19122
  printResolvedEnvironment as printResolvedEnvironment6,
19041
- TokenStore as TokenStore4,
19123
+ TokenStore as TokenStore5,
19042
19124
  toPrincipal
19043
19125
  } from "@hcmai/sdk";
19044
19126
  var fetchAuthInfo = async (endpoint, accessToken) => {
@@ -19051,7 +19133,7 @@ var fetchAuthInfo = async (endpoint, accessToken) => {
19051
19133
  async function inspectIdentity(name, fetcher = fetchAuthInfo) {
19052
19134
  const meta2 = await loadIdentity4(name);
19053
19135
  const env2 = await loadEnv4(meta2.env);
19054
- const accessToken = await TokenStore4.forIdentity(name).getStoredAccessToken();
19136
+ const accessToken = await TokenStore5.forIdentity(name).getStoredAccessToken();
19055
19137
  if (!accessToken) {
19056
19138
  throw new CliError39({
19057
19139
  code: CliErrorCode39.AUTH_FAILED,
@@ -19084,7 +19166,7 @@ async function identityShow(name, args) {
19084
19166
  const details = await inspectIdentity(name);
19085
19167
  return exitOk(formatObject29(details, { format: args.output ?? "json" }));
19086
19168
  } catch (e) {
19087
- exitWithError(axios6.isAxiosError(e) ? fromAxiosError30(e, name) : e);
19169
+ exitWithError(axios6.isAxiosError(e) ? fromAxiosError31(e, name) : e);
19088
19170
  }
19089
19171
  }
19090
19172
  async function identityList(args) {
@@ -19133,7 +19215,7 @@ async function identityRemove(name) {
19133
19215
  try {
19134
19216
  const meta2 = await loadIdentity4(name);
19135
19217
  try {
19136
- await TokenStore4.forIdentity(name).clear();
19218
+ await TokenStore5.forIdentity(name).clear();
19137
19219
  } catch (err) {
19138
19220
  process.stderr.write(
19139
19221
  `[hcm] event=identity_cleanup_failed identity=${name} reason=${JSON.stringify(String(err.message))}
@@ -19160,7 +19242,7 @@ import path19 from "path";
19160
19242
  import {
19161
19243
  CliError as CliError40,
19162
19244
  CliErrorCode as CliErrorCode40,
19163
- HcmClient as HcmClient30,
19245
+ HcmClient as HcmClient31,
19164
19246
  fetchReconIdentity,
19165
19247
  formatObject as formatObject30,
19166
19248
  httpProbe,
@@ -19175,7 +19257,7 @@ import {
19175
19257
  } from "@hcmai/sdk";
19176
19258
  async function probeTokenTenant(envName, requested) {
19177
19259
  const ctx = await getActiveAuthContextFromCli({ env: envName });
19178
- const client4 = HcmClient30.fromAuthContext(ctx);
19260
+ const client4 = HcmClient31.fromAuthContext(ctx);
19179
19261
  const identity3 = await fetchReconIdentity(httpProbe(client4.raw(), "default"), requested);
19180
19262
  return identity3?.tenantId ? String(identity3.tenantId) : void 0;
19181
19263
  }
@@ -19449,7 +19531,7 @@ import {
19449
19531
  listIdentities as listIdentities6,
19450
19532
  parseEnvYaml as parseEnvYaml2,
19451
19533
  renderEnvYaml as renderEnvYaml2,
19452
- TokenStore as TokenStore5,
19534
+ TokenStore as TokenStore6,
19453
19535
  toPrincipal as toPrincipal2,
19454
19536
  validateCliAuthorizationUrl as validateCliAuthorizationUrl2
19455
19537
  } from "@hcmai/sdk";
@@ -19500,7 +19582,7 @@ async function tokenTenant(endpoint, token) {
19500
19582
  return typeof tenant2 === "string" || typeof tenant2 === "number" && Number.isSafeInteger(tenant2) ? toPrincipal2(raw)?.tenantId : void 0;
19501
19583
  }
19502
19584
  function readStoredIdentityToken(name) {
19503
- return TokenStore5.forIdentity(name).getStoredAccessToken();
19585
+ return TokenStore6.forIdentity(name).getStoredAccessToken();
19504
19586
  }
19505
19587
  async function inspectEnvironment(env2) {
19506
19588
  try {
@@ -19693,7 +19775,6 @@ import {
19693
19775
  METHOD_REPO_DISPLAY,
19694
19776
  METHOD_REPO_URL,
19695
19777
  assertSafeSkillId as assertSafeSkillId2,
19696
- createHttpClient as createHttpClient5,
19697
19778
  discoverProjectEnv as discoverProjectEnv7,
19698
19779
  fetchSkillCatalog as fetchSkillCatalog2,
19699
19780
  flattenSkills as flattenSkills2,
@@ -19840,9 +19921,8 @@ function defaultMethodDeps() {
19840
19921
  repoDisplay: METHOD_REPO_DISPLAY,
19841
19922
  git: makeGitRunner(METHOD_REPO_DISPLAY),
19842
19923
  listBundled: () => ({ ids: listBundledSkills().map((s) => s.id), version: CLI_VERSION, dir: bundledSkillsDir() }),
19843
- fetchOnlineCatalog: async (endpoint) => {
19844
- const http2 = createHttpClient5({ endpoint, getAccessToken: async () => null, onRefresh: async () => {
19845
- }, timeoutMs: 15e3 });
19924
+ fetchOnlineCatalog: async (endpoint, projectRoot, envName) => {
19925
+ const http2 = await createChironHttpClient(endpoint, { cwd: projectRoot, env: envName }, 15e3);
19846
19926
  const base = await resolveChironBase2(http2);
19847
19927
  return flattenSkills2(await fetchSkillCatalog2(http2, base)).map((s) => s.id);
19848
19928
  },
@@ -20200,7 +20280,7 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
20200
20280
  b.note = online.reason ?? "\u6CA1\u6709\u53EF\u6BD4\u5BF9\u7684\u73AF\u5883";
20201
20281
  } else {
20202
20282
  try {
20203
- const ids = await deps.fetchOnlineCatalog(online.endpoint);
20283
+ const ids = await deps.fetchOnlineCatalog(online.endpoint, root, online.envName);
20204
20284
  if (ids.length === 0) {
20205
20285
  b.note = `${online.endpoint} \u7684\u5728\u7EBF\u76EE\u5F55\u662F\u7A7A\u7684\uFF0C\u7A7A\u96C6\u5408\u4E0A\u6BD4\u4E0D\u51FA\u300C\u65E0\u540C\u540D\u300D\uFF0C\u5728\u7EBF\u76EE\u5F55\u672A\u6BD4\u5BF9`;
20206
20286
  } else {
@@ -21152,23 +21232,29 @@ var installed = async (ctx) => {
21152
21232
  }
21153
21233
  };
21154
21234
  var fresh = async (ctx, _env, execution) => {
21155
- return ctx.services.skillsFresh(ctx.skills, ctx.environments.find((e) => e.report.target).config.endpoint, execution.signal);
21235
+ const target = ctx.environments.find((e) => e.report.target);
21236
+ const states = ctx.skills;
21237
+ if (!hasProductSkills(states)) return ctx.services.skillsFresh(states, target.config.endpoint, execution.signal);
21238
+ const credential2 = await target.credential();
21239
+ const token = credential2.resolved && normalizeEndpoint(credential2.resolved.config.endpoint) === normalizeEndpoint(target.config.endpoint) ? credential2.token ?? void 0 : void 0;
21240
+ return ctx.services.skillsFresh(states, target.config.endpoint, execution.signal, token);
21156
21241
  };
21157
21242
  var NO_PRODUCT_SKILLS = "\u6CA1\u6709\u4EA7\u54C1\u6280\u80FD\u8981\u548C\u76EE\u5F55\u5BF9\u8D26\uFF1A\u672C\u9879\u76EE\u7684\u6280\u80FD\u90FD\u6765\u81EA local/\uFF0Csync \u4E0D\u7BA1\u5B83\u4EEC";
21158
21243
  function hasProductSkills(states) {
21159
21244
  return states.some(({ state }) => Boolean(state.all) || Object.values(state.skills).some((r) => (r.sourceKind ?? "chiron") !== "local"));
21160
21245
  }
21161
- async function inspectSkillsFresh(states, endpoint, signal) {
21246
+ async function inspectSkillsFresh(states, endpoint, signal, token) {
21162
21247
  if (!hasProductSkills(states)) return { level: "NOT_APPLICABLE", summary: NO_PRODUCT_SKILLS, note: "\u672A\u8BF7\u6C42\u6280\u80FD\u76EE\u5F55" };
21163
21248
  const http2 = axios7.create({
21164
21249
  baseURL: endpoint,
21165
21250
  timeout: 5e3,
21166
21251
  maxRedirects: 0,
21252
+ headers: token ? { Authorization: `Bearer ${token}` } : void 0,
21167
21253
  signal: AbortSignal.any([signal, AbortSignal.timeout(8e3)])
21168
21254
  });
21169
21255
  try {
21170
21256
  const base = await resolveChironBase3(http2);
21171
- const manifest2 = await fetchSkillCatalog3(http2, base);
21257
+ const manifest2 = await fetchSkillCatalog3(http2, base, { requireInstallMetadata: true });
21172
21258
  const catalog = buildUnifiedCatalog({ source: "all", chironManifest: manifest2, bundled: listBundledSkills(), cliVersion: "doctor" });
21173
21259
  const conflicts = detectIdConflicts(catalog);
21174
21260
  if (conflicts.ids.length > 0) {
@@ -21202,13 +21288,14 @@ async function inspectSkillsFresh(states, endpoint, signal) {
21202
21288
  } catch (error) {
21203
21289
  if (error instanceof CliError46 && error.code === CliErrorCode46.SKILL_CATALOG_UNAVAILABLE) {
21204
21290
  const reason = typeof error.context?.reason === "string" ? `\uFF1A${error.context.reason}` : "";
21205
- const next = typeof error.context?.nextStep === "string" ? error.context.nextStep : void 0;
21206
- return unknown("SKILLS_CATALOG_UNAVAILABLE", `\u670D\u52A1\u7AEF\u6280\u80FD\u76EE\u5F55\u4E0D\u53EF\u7528\uFF08${error.message}${reason}\uFF09\uFF0C\u672C\u8F6E\u6CA1\u6CD5\u5BF9\u8D26`, next ? { note: next } : {});
21291
+ const next2 = typeof error.context?.nextStep === "string" ? error.context.nextStep : void 0;
21292
+ return unknown("SKILLS_CATALOG_UNAVAILABLE", `\u670D\u52A1\u7AEF\u6280\u80FD\u76EE\u5F55\u4E0D\u53EF\u7528\uFF08${error.message}${reason}\uFF09\uFF0C\u672C\u8F6E\u6CA1\u6CD5\u5BF9\u8D26`, next2 ? { note: next2 } : {});
21207
21293
  }
21208
21294
  if (error instanceof CliError46 && error.code === CliErrorCode46.SKILL_SOURCE_UNREACHABLE) {
21209
21295
  return unknown("SKILLS_BUNDLED_UNREACHABLE", void 0, { note: safeError(error) });
21210
21296
  }
21211
- return unknown("SKILLS_CATALOG_UNCHECKED", void 0, { note: safeError(error) });
21297
+ const next = error instanceof CliError46 ? error.context?.nextStep : void 0;
21298
+ return unknown("SKILLS_CATALOG_UNCHECKED", void 0, { note: [safeError(error), next].filter(Boolean).join("\uFF1B") });
21212
21299
  }
21213
21300
  }
21214
21301
  function classifySkillFreshness(stateCount, entries, mismatched) {
@@ -23411,7 +23498,7 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
23411
23498
  import fs17 from "fs/promises";
23412
23499
  import os6 from "os";
23413
23500
  import path27 from "path";
23414
- import { CliError as CliError52, CliErrorCode as CliErrorCode51, formatObject as formatObject35, HcmClient as HcmClient31, loadEnv as loadEnv6 } from "@hcmai/sdk";
23501
+ import { CliError as CliError52, CliErrorCode as CliErrorCode51, formatObject as formatObject35, HcmClient as HcmClient32, loadEnv as loadEnv6 } from "@hcmai/sdk";
23415
23502
  import { createRequire } from "module";
23416
23503
 
23417
23504
  // src/commands/chiron-page-cdp.ts
@@ -24023,7 +24110,7 @@ var defaultChironPageDeps = {
24023
24110
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
24024
24111
  });
24025
24112
  }
24026
- const client4 = HcmClient31.fromAuthContext(ctx);
24113
+ const client4 = HcmClient32.fromAuthContext(ctx);
24027
24114
  const { ticket } = await mintBrowserTicket(client4, ctx.env)();
24028
24115
  return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
24029
24116
  },
@@ -24111,7 +24198,7 @@ import { formatObject as formatObject36 } from "@hcmai/sdk";
24111
24198
 
24112
24199
  // src/commands/delivery-action-policy.ts
24113
24200
  init_auth_guard();
24114
- import { HcmClient as HcmClient32, classifyEffect } from "@hcmai/sdk";
24201
+ import { HcmClient as HcmClient33, classifyEffect } from "@hcmai/sdk";
24115
24202
 
24116
24203
  // src/commands/delivery.ts
24117
24204
  import { createHash as createHash9 } from "crypto";
@@ -24131,6 +24218,7 @@ var GUARDED_EXECUTOR_REASON_CODES = /* @__PURE__ */ new Set([
24131
24218
  "record-create",
24132
24219
  "record-update",
24133
24220
  "cache-mutation",
24221
+ "subscription-migration-write",
24134
24222
  "setting-write",
24135
24223
  "credential-reset",
24136
24224
  "action-write",
@@ -24420,6 +24508,10 @@ function classify(argv, actionResolution) {
24420
24508
  return direct("R1", "remote-read", "business-read");
24421
24509
  }
24422
24510
  if (name === "preset-origin") return direct("R1", "remote-read", "preset-origin-read");
24511
+ if (name === "subscription-migration") {
24512
+ if (subcommand === "dry-run" || subcommand === "status") return direct("R1", "remote-read", "subscription-migration-read");
24513
+ if (subcommand === "apply" || subcommand === "restore") return guarded("tenant-config-write", "subscription-migration-write");
24514
+ }
24423
24515
  if (name === "cache") {
24424
24516
  if (subcommand === "stats") return direct("R1", "remote-read", "cache-read");
24425
24517
  if (subcommand === "clear" || subcommand === "clear-meta") {
@@ -24727,7 +24819,7 @@ async function resolveCoreAction(request) {
24727
24819
  as: request.identity,
24728
24820
  profile: request.profile
24729
24821
  });
24730
- const description = await HcmClient32.fromAuthContext(auth2).describe(request.model);
24822
+ const description = await HcmClient33.fromAuthContext(auth2).describe(request.model);
24731
24823
  const named = description.actions.filter((action) => action.name === request.action);
24732
24824
  if (named.length === 0) {
24733
24825
  const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
@@ -25198,12 +25290,12 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
25198
25290
  init_auth_guard();
25199
25291
  init_exit();
25200
25292
  import {
25201
- HcmClient as HcmClient33,
25293
+ HcmClient as HcmClient34,
25202
25294
  ReconLayout,
25203
25295
  ROUND_EXIT_CODES,
25204
25296
  computeReconSourceKey,
25205
25297
  formatObject as formatObject37,
25206
- fromAxiosError as fromAxiosError31,
25298
+ fromAxiosError as fromAxiosError32,
25207
25299
  httpProbe as httpProbe3,
25208
25300
  inspectRound,
25209
25301
  renderRound,
@@ -25213,7 +25305,7 @@ var DEFAULT_CAPABILITIES = "default";
25213
25305
  async function deliveryReconCommand(args) {
25214
25306
  try {
25215
25307
  const ctx = await getActiveAuthContextFromCli(args);
25216
- const client4 = HcmClient33.fromAuthContext(ctx);
25308
+ const client4 = HcmClient34.fromAuthContext(ctx);
25217
25309
  const probe3 = httpProbe3(client4.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
25218
25310
  const sourceKey = await computeReconSourceKey(probe3);
25219
25311
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -25225,7 +25317,7 @@ async function deliveryReconCommand(args) {
25225
25317
  process.stdout.write(formatObject37(summary, { format: args.output ?? "json" }) + "\n");
25226
25318
  } catch (e) {
25227
25319
  const err = e;
25228
- if (err?.isAxiosError) exitWithError(fromAxiosError31(err, args.env));
25320
+ if (err?.isAxiosError) exitWithError(fromAxiosError32(err, args.env));
25229
25321
  exitWithError(e);
25230
25322
  process.exit(1);
25231
25323
  }
@@ -25256,7 +25348,7 @@ import {
25256
25348
  DRY_RUN_TAIL,
25257
25349
  DriftDetected,
25258
25350
  FORCE_STALE_FLAG,
25259
- HcmClient as HcmClient34,
25351
+ HcmClient as HcmClient35,
25260
25352
  fetchReconIdentity as fetchReconIdentity2,
25261
25353
  INIT_EXIT_CODES,
25262
25354
  JOURNAL_STOP_KINDS,
@@ -25396,7 +25488,7 @@ async function authOrSignpost(args, cmd) {
25396
25488
  }
25397
25489
  async function deliverySeedPlanCommand(args) {
25398
25490
  const ctx = await authOrSignpost(args, "plan");
25399
- const client4 = HcmClient34.fromAuthContext(ctx);
25491
+ const client4 = HcmClient35.fromAuthContext(ctx);
25400
25492
  process.exitCode = await runSeedPlan(args, seedClient(client4, ctx));
25401
25493
  }
25402
25494
  function seedClient(client4, ctx) {
@@ -25570,7 +25662,7 @@ async function runSeedApply(args, client4) {
25570
25662
  }
25571
25663
  async function deliverySeedApplyCommand(args) {
25572
25664
  const ctx = await authOrSignpost(args, "apply");
25573
- const client4 = HcmClient34.fromAuthContext(ctx);
25665
+ const client4 = HcmClient35.fromAuthContext(ctx);
25574
25666
  process.exitCode = await runSeedApply(args, seedClient(client4, ctx));
25575
25667
  }
25576
25668
  async function runSeedVerify(args, client4) {
@@ -25594,7 +25686,7 @@ async function deliverySeedVerifyCommand(args) {
25594
25686
  return;
25595
25687
  }
25596
25688
  const ctx = await authOrSignpost(args, "verify");
25597
- const client4 = HcmClient34.fromAuthContext(ctx);
25689
+ const client4 = HcmClient35.fromAuthContext(ctx);
25598
25690
  process.exitCode = await runSeedVerify(args, await seedVerifyClient(client4, ctx));
25599
25691
  }
25600
25692
 
@@ -25709,7 +25801,7 @@ import {
25709
25801
  CHANGE_STATES,
25710
25802
  CHANGE_UNKNOWN,
25711
25803
  CODE_WORDS,
25712
- HcmClient as HcmClient35,
25804
+ HcmClient as HcmClient36,
25713
25805
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
25714
25806
  META_WRITE_STEPS,
25715
25807
  META_VERIFY_STEPS,
@@ -25937,7 +26029,7 @@ function lowerCaseHeaders2(headers) {
25937
26029
  }
25938
26030
  async function deliveryMetaCommand(args) {
25939
26031
  const ctx = await getActiveAuthContextFromCli(args);
25940
- const client4 = HcmClient35.fromAuthContext(ctx);
26032
+ const client4 = HcmClient36.fromAuthContext(ctx);
25941
26033
  process.exitCode = await runDeliveryMeta(
25942
26034
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
25943
26035
  metaClient(client4, ctx)
@@ -25949,7 +26041,7 @@ init_auth_guard();
25949
26041
  init_exit();
25950
26042
  import {
25951
26043
  computeReconSourceKey as computeReconSourceKey2,
25952
- HcmClient as HcmClient36,
26044
+ HcmClient as HcmClient37,
25953
26045
  httpProbe as httpProbe4,
25954
26046
  ReconLayout as ReconLayout2,
25955
26047
  runTriageRound
@@ -26005,7 +26097,7 @@ async function runTriage(args) {
26005
26097
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
26006
26098
  }
26007
26099
  const ctx = await getActiveAuthContextFromCli(args);
26008
- const client4 = HcmClient36.fromAuthContext(ctx);
26100
+ const client4 = HcmClient37.fromAuthContext(ctx);
26009
26101
  const probe3 = httpProbe4(client4.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
26010
26102
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe3)).dir;
26011
26103
  const result = await runTriageRound(probe3, artifactsDir, entriesIn);
@@ -26034,10 +26126,10 @@ async function deliveryTriageCommand(args) {
26034
26126
  init_auth_guard();
26035
26127
  init_exit();
26036
26128
  import {
26037
- HcmClient as HcmClient37,
26129
+ HcmClient as HcmClient38,
26038
26130
  adminResetPassword,
26039
26131
  formatObject as formatObject38,
26040
- fromAxiosError as fromAxiosError32,
26132
+ fromAxiosError as fromAxiosError33,
26041
26133
  CliError as CliError53,
26042
26134
  CliErrorCode as CliErrorCode52
26043
26135
  } from "@hcmai/sdk";
@@ -26068,12 +26160,12 @@ async function userResetPasswordCommand(args) {
26068
26160
  try {
26069
26161
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
26070
26162
  const request = buildAdminResetPasswordRequest(args, password);
26071
- const client4 = HcmClient37.fromAuthContext(await getActiveAuthContextFromCli(args));
26163
+ const client4 = HcmClient38.fromAuthContext(await getActiveAuthContextFromCli(args));
26072
26164
  const result = await adminResetPassword(client4.raw(), request);
26073
26165
  process.stdout.write(formatObject38(result, { format: args.output ?? "json" }) + "\n");
26074
26166
  } catch (cause) {
26075
26167
  const err = cause;
26076
- if (err?.isAxiosError) exitWithError(fromAxiosError32(err, args.env));
26168
+ if (err?.isAxiosError) exitWithError(fromAxiosError33(err, args.env));
26077
26169
  exitWithError(cause);
26078
26170
  }
26079
26171
  }
@@ -26095,9 +26187,9 @@ init_auth_guard();
26095
26187
  import {
26096
26188
  CliError as CliError55,
26097
26189
  CliErrorCode as CliErrorCode54,
26098
- HcmClient as HcmClient38,
26190
+ HcmClient as HcmClient39,
26099
26191
  formatObject as formatObject40,
26100
- fromAxiosError as fromAxiosError33
26192
+ fromAxiosError as fromAxiosError34
26101
26193
  } from "@hcmai/sdk";
26102
26194
 
26103
26195
  // src/commands/models-search.ts
@@ -26267,7 +26359,7 @@ async function modelsCommand(keyword, args) {
26267
26359
  });
26268
26360
  }
26269
26361
  const parsedSearch = args.search ? parseSearchArgs(keyword, args) : void 0;
26270
- const client4 = HcmClient38.fromAuthContext(await getActiveAuthContextFromCli(args));
26362
+ const client4 = HcmClient39.fromAuthContext(await getActiveAuthContextFromCli(args));
26271
26363
  if (parsedSearch) {
26272
26364
  await modelsSearch(client4, parsedSearch, args);
26273
26365
  return;
@@ -26304,7 +26396,7 @@ async function modelsCommand(keyword, args) {
26304
26396
  return;
26305
26397
  } catch (e) {
26306
26398
  const err = e;
26307
- if (err?.isAxiosError) exitWithError(fromAxiosError33(err, args.env ?? args.profile));
26399
+ if (err?.isAxiosError) exitWithError(fromAxiosError34(err, args.env ?? args.profile));
26308
26400
  exitWithError(e);
26309
26401
  }
26310
26402
  }
@@ -26316,7 +26408,7 @@ function key(m) {
26316
26408
  init_exit();
26317
26409
  init_auth_guard();
26318
26410
  import {
26319
- HcmClient as HcmClient39,
26411
+ HcmClient as HcmClient40,
26320
26412
  CliError as CliError56,
26321
26413
  CliErrorCode as CliErrorCode55,
26322
26414
  INTROSPECTION_ENVELOPE_KEYS,
@@ -26324,7 +26416,7 @@ import {
26324
26416
  classifyEndpointFailure as classifyEndpointFailure2,
26325
26417
  fetchIntrospection,
26326
26418
  formatObject as formatObject41,
26327
- fromAxiosError as fromAxiosError34,
26419
+ fromAxiosError as fromAxiosError35,
26328
26420
  missingKeys as missingKeys3
26329
26421
  } from "@hcmai/sdk";
26330
26422
  function parseLimit2(raw) {
@@ -26452,7 +26544,7 @@ function handleError(e, args, capability) {
26452
26544
  context: { nextStep: NOT_PROVIDED_NEXT_STEP2 }
26453
26545
  }));
26454
26546
  }
26455
- const ce = fromAxiosError34(err, args.env);
26547
+ const ce = fromAxiosError35(err, args.env);
26456
26548
  const body = err.response?.data?.error;
26457
26549
  if (capability !== void 0 && body?.code === "INTROSPECTION_PATH_NOT_FOUND") {
26458
26550
  const available = body?.details?.availablePaths;
@@ -26481,7 +26573,7 @@ async function introspectCommand(capability, args) {
26481
26573
  if (capability !== void 0 && (args.detail || limit !== void 0)) {
26482
26574
  process.stderr.write("\u2139\uFE0F \u7ED9\u4E86 capability \u65F6\u53EA\u53D6\u90A3\u4E00\u683C\uFF08\u672C\u6765\u5C31\u662F\u660E\u7EC6\u5F62\u6001\uFF09\uFF0C--detail / --limit \u4E0D\u751F\u6548\n");
26483
26575
  }
26484
- const client4 = HcmClient39.fromAuthContext(await getActiveAuthContextFromCli(args));
26576
+ const client4 = HcmClient40.fromAuthContext(await getActiveAuthContextFromCli(args));
26485
26577
  const view = await fetchIntrospection(client4.raw(), {
26486
26578
  ...capability !== void 0 ? { path: capability } : {},
26487
26579
  ...args.detail ? { detail: true } : {},
@@ -26507,14 +26599,14 @@ async function introspectCommand(capability, args) {
26507
26599
  init_exit();
26508
26600
  init_auth_guard();
26509
26601
  import {
26510
- HcmClient as HcmClient40,
26602
+ HcmClient as HcmClient41,
26511
26603
  CliError as CliError57,
26512
26604
  CliErrorCode as CliErrorCode56,
26513
26605
  PRESET_ORIGIN_PATH,
26514
26606
  classifyEndpointFailure as classifyEndpointFailure3,
26515
26607
  fetchPresetOrigin,
26516
26608
  formatObject as formatObject42,
26517
- fromAxiosError as fromAxiosError35,
26609
+ fromAxiosError as fromAxiosError36,
26518
26610
  isUuid
26519
26611
  } from "@hcmai/sdk";
26520
26612
  var ORIGIN_MEANING = {
@@ -26620,7 +26712,7 @@ async function presetOriginCommand(model, args) {
26620
26712
  if (args.id !== void 0 && args.includeTenantIds) {
26621
26713
  process.stderr.write("\u2139\uFE0F \u540C\u65F6\u7ED9\u4E86 --id \u4E0E --include-tenant-ids\uFF1A\u4E24\u6837\u90FD\u95EE\uFF0C\u8F93\u51FA\u91CC\u4E24\u6BB5\u90FD\u6709\n");
26622
26714
  }
26623
- const client4 = HcmClient40.fromAuthContext(await getActiveAuthContextFromCli(args));
26715
+ const client4 = HcmClient41.fromAuthContext(await getActiveAuthContextFromCli(args));
26624
26716
  const view = await fetchPresetOrigin(client4.raw(), model, {
26625
26717
  ...args.id !== void 0 ? { id: args.id.trim() } : {},
26626
26718
  ...args.includeTenantIds ? { includeTenantIds: true } : {}
@@ -26645,7 +26737,7 @@ async function presetOriginCommand(model, args) {
26645
26737
  context: { nextStep: NOT_PROVIDED_NEXT_STEP3 }
26646
26738
  }));
26647
26739
  }
26648
- exitWithError(fromAxiosError35(err, args.env));
26740
+ exitWithError(fromAxiosError36(err, args.env));
26649
26741
  }
26650
26742
  }
26651
26743
 
@@ -30380,6 +30472,11 @@ script.command("dry-run").description("\u53EA\u8BFB\u8BD5\u8FD0\u884C\u4E91\u51F
30380
30472
  script.command("manifest-validate").description("\u6821\u9A8C\u6269\u5C55\u5305 manifest.yml").requiredOption("--file <path>", "manifest.yml \u8DEF\u5F84").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptManifestValidateCommand(opts));
30381
30473
  script.command("logs").description("\u67E5\u540C\u6B65\u6267\u884C\u65E5\u5FD7\uFF08\u5206\u9875\uFF09").option("--script-key <key>", "\u53EA\u770B\u67D0\u4E2A\u811A\u672C").option("--status <status>", "\u6309\u72B6\u6001\u8FC7\u6EE4").option("--mode <mode>", "\u6309 sync/async \u8FC7\u6EE4").option("--dry-run", "\u53EA\u770B dry-run \u8BB0\u5F55").option("--from <iso>", "\u8D77\u59CB\u65F6\u95F4\uFF08ISO 8601\uFF09").option("--to <iso>", "\u7ED3\u675F\u65F6\u95F4\uFF08ISO 8601\uFF09").option("--page <n>", "\u9875\u7801\uFF0C\u4ECE 0 \u5F00\u59CB").option("--size <n>", "\u6BCF\u9875\u6761\u6570").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => scriptLogsCommand(opts));
30382
30474
  script.command("task <taskId>").description("\u67E5\u5F02\u6B65\u4EFB\u52A1\uFF1A\u72B6\u6001\u3001\u91CD\u8BD5\u6B21\u6570\u3001\u6700\u7EC8\u7ED3\u679C\u4E0E\u9519\u8BEF").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((taskId, opts) => scriptTaskCommand(taskId, opts));
30475
+ var subscriptionMigration = program.command("subscription-migration").description("\u8BA2\u9605\u8FC1\u79FB\uFF1A\u5148\u5E72\u8DD1\u51BB\u7ED3\u8BA1\u5212\uFF0C\u518D\u663E\u5F0F\u5199\u56DE\uFF1B\u5907\u4EFD\u539F\u6587\u53EF\u6309\u8BB0\u5F55\u6062\u590D");
30476
+ for (const operation of ["dry-run", "apply", "restore"]) {
30477
+ subscriptionMigration.command(operation).description({ "dry-run": "\u53EA\u8BFB\u626B\u63CF\uFF0C\u53EF\u7528 --data @\u6587\u4EF6\u63D0\u4EA4 revisions \u4EBA\u5DE5\u7A3F", apply: "\u6309\u5B8C\u6574\u51BB\u7ED3\u8BA1\u5212\u5907\u4EFD\u540E\u5199\u56DE", restore: "\u8FD8\u539F\u5907\u4EFD\uFF0C\u62D2\u7EDD\u8986\u76D6\u540E\u7EED\u4FEE\u6539" }[operation]).option("--env <name>", "\u672C\u5730\u90E8\u7F72\u670D\u52A1\u7684\u73AF\u5883\u540D").option("--as <identity>", "\u5F53\u524D\u79DF\u6237\u7CFB\u7EDF\u7BA1\u7406\u5458\u8EAB\u4EFD").option("--data <json>", "JSON \u8BF7\u6C42\u5BF9\u8C61\u6216 @\u6587\u4EF6").option("--dry-run-task-id <id>", "apply \u4F7F\u7528\u7684 dry-run \u4EFB\u52A1 ID").option("--task-id <id>", "restore \u4F7F\u7528\u7684\u5199\u56DE\u4EFB\u52A1 ID").option("--record-ids <ids>", "\u9017\u53F7\u5206\u9694\u7684\u7269\u7406\u8BB0\u5F55 ID").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Ajson", "json").action((opts) => subscriptionMigrationCommand(operation, opts));
30478
+ }
30479
+ subscriptionMigration.command("status <taskId>").description("\u67E5\u770B\u540E\u53F0\u4EFB\u52A1\u4E0E\u5B8C\u6574\u8FC1\u79FB\u62A5\u544A\uFF0C\u672A\u77E5\u8BA1\u6570\u4FDD\u7559 null \u4E0E\u539F\u56E0").option("--env <name>", "\u672C\u5730\u90E8\u7F72\u670D\u52A1\u7684\u73AF\u5883\u540D").option("--as <identity>", "\u5F53\u524D\u79DF\u6237\u7CFB\u7EDF\u7BA1\u7406\u5458\u8EAB\u4EFD").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Ajson", "json").action((taskId, opts) => subscriptionMigrationCommand("status", { ...opts, taskId }));
30383
30480
  var cache = program.command("cache").description("\u6A21\u578B\u7F13\u5B58\u8FD0\u7EF4\uFF08Caffeine \u672C\u5730 + Redis \u8FDC\u7A0B\uFF0C\u987B\u8D70 API\uFF09");
30384
30481
  cache.command("stats <Model>").description("\u67E5\u770B\u6A21\u578B\u7F13\u5B58\u7EDF\u8BA1").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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((model, opts) => cacheStatsCommand(model, opts));
30385
30482
  cache.command("clear <Model>").description("\u6E05\u6A21\u578B\u5B9E\u4F53\u7F13\u5B58\uFF08\u5E42\u7B49\uFF0C\u4E0D\u7834\u574F\u6570\u636E\uFF09").option("--id <id>", "\u53EA\u6E05\u5355\u6761\uFF08\u9ED8\u8BA4\u6E05\u5168\u90E8\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").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((model, opts) => cacheClearCommand(model, opts));