@hcmai/cli 0.34.0 → 0.34.2

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