@hcmai/cli 0.15.7 → 0.15.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -142,7 +142,7 @@ import {
142
142
  } from "@hcmai/sdk";
143
143
  async function ensureActiveAuth(args) {
144
144
  const g = await loadGlobalConfig();
145
- const resolved = await resolveEnvContext({ envFlag: args.envFlag, fallbackEnv: args.fallbackEnv }, process.env, g);
145
+ const resolved = await resolveEnvContext({ envFlag: args.envFlag, fallbackEnv: args.fallbackEnv, cwd: args.cwd }, process.env, g);
146
146
  if (resolved.project && (process.env.HCM_PAT || process.env.HCM_ACCESS_TOKEN)) throw new CliError2({
147
147
  code: CliErrorCode.INVALID_ARGUMENT,
148
148
  message: "\u9879\u76EE\u73AF\u5883\u4E0D\u63A5\u53D7 HCM_PAT / HCM_ACCESS_TOKEN \u8986\u76D6\u5DF2\u9009\u62E9\u8EAB\u4EFD\u7684\u51ED\u636E\uFF1B\u672A\u53D1\u9001\u4E1A\u52A1\u8BF7\u6C42\u3002",
@@ -326,7 +326,7 @@ async function getActiveAuthContextFromCli(args, opts) {
326
326
  );
327
327
  envFlag = args.profile;
328
328
  }
329
- const ctx = await ensureActiveAuth({ envFlag, asFlag: args.as, fallbackEnv: opts?.fallbackEnv, allowDanger: args.allowDanger });
329
+ const ctx = await ensureActiveAuth({ envFlag, asFlag: args.as, fallbackEnv: opts?.fallbackEnv, cwd: opts?.cwd, allowDanger: args.allowDanger });
330
330
  return ctx;
331
331
  }
332
332
  async function deadlockHint(envName) {
@@ -3413,7 +3413,7 @@ function renderEnvListing(listing) {
3413
3413
  const out = [];
3414
3414
  const effectiveRow = rows2.find((r) => r.name === effective);
3415
3415
  out.push(
3416
- effective ? `\u2192 \u8FD9\u4E2A\u76EE\u5F55\u7528 ${effective}\uFF08\u6765\u81EA ${source === "env.yaml" ? `${file} \u7684 default` : source}\uFF09${effectiveRow?.slot ? `\uFF0C\u51ED\u636E\u53D6\u672C\u673A\u69FD ${effectiveRow.slot}` : "\uFF0C\u4F46\u5B83\u8FD8\u6CA1\u5728\u672C\u673A\u767B\u5F55\u8FC7"}` : `\u2192 \u8FD9\u4E2A\u76EE\u5F55\u6709 ${file}\uFF0C\u4F46\u751F\u6548\u7684\u662F\u672C\u673A\u69FD ${listing.activeEnv}\uFF08${source ?? "activeEnv"} \u6307\u7684\u540D\u5B57\u4E0D\u5728 ${file} \u91CC\uFF09`
3416
+ listing.resolutionError ? `\u2192 \u73AF\u5883\u9009\u62E9\u5931\u8D25\uFF1A${listing.resolutionError}` : effective ? `\u2192 \u8FD9\u4E2A\u76EE\u5F55\u7528 ${effective}\uFF08\u6765\u81EA ${source === "env.yaml" ? `${file} \u7684 default` : source}\uFF09${effectiveRow?.slot ? `\uFF0C\u51ED\u636E\u53D6\u672C\u673A\u69FD ${effectiveRow.slot}` : "\uFF0C\u4F46\u5B83\u8FD8\u6CA1\u5728\u672C\u673A\u767B\u5F55\u8FC7"}` : `\u2192 \u8FD9\u4E2A\u76EE\u5F55\u6709 ${file}\uFF0C\u4F46\u751F\u6548\u7684\u662F\u672C\u673A\u69FD ${listing.effectiveSlot ?? listing.activeEnv}\uFF08\u6765\u81EA ${source ?? "activeEnv"}\uFF1B\u5730\u5740\u6216\u79DF\u6237\u4E0D\u5339\u914D\u9879\u76EE\u58F0\u660E\uFF09`
3417
3417
  );
3418
3418
  out.push("");
3419
3419
  out.push(`\u9879\u76EE\u73AF\u5883\uFF08${file}\uFF09`);
@@ -3465,15 +3465,35 @@ async function collectEnvListing(args = {}) {
3465
3465
  const listing = { slots, activeEnv: g.activeEnv };
3466
3466
  const discovered = await discoverProjectEnv2();
3467
3467
  if (!discovered) return listing;
3468
- const selected = await resolveProjectEnvironment2({}, process.env);
3468
+ let selected = await resolveProjectEnvironment2({}, process.env);
3469
+ let resolved;
3470
+ if (!selected) {
3471
+ try {
3472
+ resolved = await resolveEnvContext3({}, process.env, g);
3473
+ } catch (e) {
3474
+ if (!(e instanceof CliError6) || e.code !== CliErrorCode5.ENV_NOT_FOUND && e.code !== CliErrorCode5.INVALID_ARGUMENT) throw e;
3475
+ listing.resolutionError = e.message;
3476
+ }
3477
+ }
3478
+ if (resolved) {
3479
+ selected = resolved.project ?? null;
3480
+ listing.effectiveSlot = resolved.name;
3481
+ }
3469
3482
  const rows2 = await Promise.all(
3470
3483
  Object.entries(discovered.config.environments).map(async ([name, env2]) => {
3471
3484
  const found = await findEnvByEndpoint2(env2.endpoint, env2.tenant, { strictTenant: true, activeEnv: g.activeEnv });
3472
- return { name, endpoint: env2.endpoint, tenant: env2.tenant, danger: env2.danger === true, slot: found?.name ?? null };
3485
+ return {
3486
+ name,
3487
+ endpoint: env2.endpoint,
3488
+ tenant: env2.tenant,
3489
+ danger: env2.danger === true,
3490
+ slot: resolved?.project?.name === name ? resolved.name : found?.name ?? null
3491
+ };
3473
3492
  })
3474
3493
  );
3475
3494
  if (!args.all) {
3476
3495
  const relevant = new Set(rows2.map((r) => r.slot).filter((n) => n !== null));
3496
+ if (resolved) relevant.add(resolved.name);
3477
3497
  const kept = slots.filter((s) => relevant.has(s.name));
3478
3498
  listing.hiddenSlots = slots.length - kept.length;
3479
3499
  listing.slots = kept;
@@ -3483,7 +3503,7 @@ async function collectEnvListing(args = {}) {
3483
3503
  file: relative2.startsWith(".") ? relative2 : `./${relative2}`,
3484
3504
  rows: rows2,
3485
3505
  effective: selected?.name ?? null,
3486
- source: selected?.source ?? null
3506
+ source: selected?.source ?? resolved?.source ?? null
3487
3507
  };
3488
3508
  return listing;
3489
3509
  }
@@ -3822,15 +3842,7 @@ import {
3822
3842
  } from "@hcmai/sdk";
3823
3843
  async function queryCommand(model, args) {
3824
3844
  try {
3825
- const dsl = {};
3826
- if (args.filter) dsl.filter = parseJsonOrThrow(args.filter, "--filter");
3827
- if (args.sort) dsl.sort = parseJsonOrThrow(args.sort, "--sort");
3828
- if (args.additions) dsl.additions = parseAdditionsOrThrow(args.additions);
3829
- if (args.fields) dsl.fields = args.fields.split(",").map((s) => s.trim());
3830
- if (args.keyword) dsl.keyword = args.keyword;
3831
- if (args.limit) dsl.limit = Number(args.limit);
3832
- if (args.offset) dsl.offset = Number(args.offset);
3833
- if (!dsl.limit) dsl.limit = 20;
3845
+ const dsl = buildQueryDsl(args);
3834
3846
  const client3 = HcmClient2.fromAuthContext(await getActiveAuthContextFromCli(args));
3835
3847
  const result = await client3.query(model, dsl);
3836
3848
  const fmt = args.output ?? "table";
@@ -3843,6 +3855,19 @@ async function queryCommand(model, args) {
3843
3855
  exitWithError(e);
3844
3856
  }
3845
3857
  }
3858
+ function buildQueryDsl(args) {
3859
+ const dsl = {};
3860
+ if (args.plugin) dsl.plugin = args.plugin;
3861
+ if (args.filter) dsl.filter = parseJsonOrThrow(args.filter, "--filter");
3862
+ if (args.sort) dsl.sort = parseJsonOrThrow(args.sort, "--sort");
3863
+ if (args.additions) dsl.additions = parseAdditionsOrThrow(args.additions);
3864
+ if (args.fields) dsl.fields = args.fields.split(",").map((s) => s.trim());
3865
+ if (args.keyword) dsl.keyword = args.keyword;
3866
+ if (args.limit) dsl.limit = Number(args.limit);
3867
+ if (args.offset) dsl.offset = Number(args.offset);
3868
+ if (!dsl.limit) dsl.limit = 20;
3869
+ return dsl;
3870
+ }
3846
3871
  function printQueryResult(result, fmt) {
3847
3872
  const out = formatRows(result.rows, { format: fmt });
3848
3873
  process.stdout.write(out + "\n");
@@ -8601,6 +8626,9 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
8601
8626
  // src/commands/tenant.ts
8602
8627
  import {
8603
8628
  bootstrapTenant,
8629
+ resetTenant,
8630
+ HcmClient as HcmClient19,
8631
+ readSessionPrincipal as readSessionPrincipal2,
8604
8632
  discoverProjectEnv as discoverProjectEnv4,
8605
8633
  assertDangerWrite as assertDangerWrite3,
8606
8634
  normalizeOrigin as normalizeOrigin4,
@@ -8614,6 +8642,71 @@ import {
8614
8642
  CliErrorCode as CliErrorCode20
8615
8643
  } from "@hcmai/sdk";
8616
8644
  init_exit();
8645
+ init_auth_guard();
8646
+ async function tenantResetCommand(args) {
8647
+ let attempted = false;
8648
+ try {
8649
+ const fmt = args.output ?? "json";
8650
+ if (!["table", "json", "yaml"].includes(fmt)) throw new CliError21({
8651
+ code: CliErrorCode20.INVALID_ARGUMENT,
8652
+ message: "--output \u53D6\u503C table | json | yaml"
8653
+ });
8654
+ const ctx = await getActiveAuthContextFromCli(args);
8655
+ if (ctx.impersonation) throw new CliError21({
8656
+ code: CliErrorCode20.SCOPE_FORBIDDEN,
8657
+ message: "\u79DF\u6237\u91CD\u7F6E\u4E0D\u63A5\u53D7\u4EE3\u7406\u4F1A\u8BDD\uFF0C\u8BF7\u7528\u5185\u7F6E admin \u7684\u76F4\u63A5\u767B\u5F55\u8EAB\u4EFD\u3002"
8658
+ });
8659
+ const { endpoint, tenantId, env: env2 } = ctx;
8660
+ const safety = ctx.environmentSafety ? { ...ctx.environmentSafety } : void 0;
8661
+ assertDangerWrite3(safety, "\u91CD\u7F6E\u79DF\u6237 PostgreSQL \u6570\u636E");
8662
+ const accessToken = await HcmClient19.fromAuthContext(ctx).getAccessToken();
8663
+ if (!accessToken) throw new CliError21({ code: CliErrorCode20.AUTH_FAILED, message: "\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u8BFB\u53D6\u7684\u51ED\u636E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
8664
+ const client3 = new HcmClient19({ endpoint, tenantId, accessToken, profile: env2, environmentSafety: safety });
8665
+ client3.raw().defaults.maxRedirects = 0;
8666
+ client3.raw().defaults.__skipRetry = true;
8667
+ const principal = await readSessionPrincipal2(client3.raw());
8668
+ if (principal.tenantId !== tenantId || principal.username !== "admin" || !principal.roles?.includes("admin.system") || principal.impersonated || principal.actSub != null) {
8669
+ throw new CliError21({
8670
+ code: CliErrorCode20.SCOPE_FORBIDDEN,
8671
+ message: `\u5B9E\u9645\u8EAB\u4EFD ${principal.username} / \u79DF\u6237 ${principal.tenantId} \u4E0D\u662F\u76EE\u6807 ${tenantId} \u7684\u76F4\u63A5\u5185\u7F6E\u7BA1\u7406\u5458\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002`,
8672
+ context: { nextStep: `hcm login --env ${env2} \u767B\u5F55\u76EE\u6807\u79DF\u6237\u7684\u5185\u7F6E admin \u540E\u91CD\u8BD5\u3002` }
8673
+ });
8674
+ }
8675
+ process.stderr.write(`\u2192 \u91CD\u7F6E\u76EE\u6807 ${endpoint} \xB7 \u73AF\u5883 ${env2} \xB7 \u79DF\u6237 ${tenantId} \xB7 \u7528\u6237 ${principal.username}
8676
+ \u5C06\u4E0D\u53EF\u9006\u5730\u5220\u9664 PostgreSQL \u4E1A\u52A1\u6570\u636E\u5E76\u6062\u590D\u51FA\u5382\u57FA\u7EBF\uFF1BMongo\u3001\u6587\u6863\u5BF9\u8C61\u4E0E\u5916\u90E8\u5411\u91CF\u4E0D\u5904\u7406\u3001\u4E0D\u6838\u9A8C\u3002
8677
+ `);
8678
+ if (!args.yes) {
8679
+ if (!process.stdin.isTTY) throw new CliError21({
8680
+ code: CliErrorCode20.INVALID_ARGUMENT,
8681
+ message: "\u975E\u4EA4\u4E92\u8F93\u5165\u672A\u786E\u8BA4\u79DF\u6237\u91CD\u7F6E\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002",
8682
+ context: { nextStep: "\u6838\u5BF9\u4E0A\u8FF0\u76EE\u6807\u4E0E\u5F71\u54CD\u540E\u663E\u5F0F\u52A0 --yes\uFF1B\u5371\u9669\u73AF\u5883\u8FD8\u9700\u8981 --allow-danger\u3002" }
8683
+ });
8684
+ const answer = await promptText("\u786E\u8BA4\u91CD\u7F6E\u8FD9\u4E2A\u79DF\u6237\uFF1F\u8F93\u5165 yes \u7EE7\u7EED\uFF1A", process.stderr);
8685
+ if (!/^y(es)?$/i.test(answer)) throw new CliError21({ code: CliErrorCode20.INVALID_ARGUMENT, message: "\u5DF2\u53D6\u6D88\uFF0C\u672A\u53D1\u9001\u91CD\u7F6E\u3002" });
8686
+ }
8687
+ attempted = true;
8688
+ const receipt = await resetTenant(client3.raw(), tenantId);
8689
+ if (fmt === "table") process.stdout.write(
8690
+ `\u79DF\u6237 ${receipt.tenantId} \xB7 \u6D41\u6C34 ${receipt.runId}
8691
+ \u5220\u9664 ${receipt.deletedRows} \u884C / \u6D89\u53CA ${receipt.touchedTables} \u8868 / \u91CD\u5EFA ${receipt.restoredRows} \u884C
8692
+ PostgreSQL \u6838\u9A8C=${receipt.pgVerified}\uFF1B\u6574\u4F53\u6838\u9A8C=${receipt.overallVerified}\uFF1B\u8BB0\u8D26=${receipt.journalReconciledMarked}
8693
+ \u975E PG ${receipt.nonPgSurface.status}\uFF1A${receipt.nonPgSurface.reason}
8694
+ \u4E0B\u4E00\u6B65\uFF1A${receipt.nonPgSurface.nextStep}
8695
+ `
8696
+ );
8697
+ process.stdout.write(formatObject19(receipt, { format: fmt }) + "\n");
8698
+ const quote = (value) => "'" + value.replace(/'/g, "'\\''") + "'";
8699
+ process.stderr.write(`\u91CD\u7F6E\u5DF2\u6E05\u7406\u5F53\u524D\u4F1A\u8BDD\uFF1B\u8BF7 hcm login --env ${quote(env2)} --endpoint ${quote(endpoint)} --tenant ${quote(tenantId)} \u91CD\u65B0\u767B\u5F55\uFF0C\u518D\u67E5\u8BE2\u6216\u88C5\u5305\u3002
8700
+ `);
8701
+ if (!receipt.journalReconciledMarked) process.stderr.write("\u91CD\u7F6E\u56DE\u6267\u8BB0\u8D26\u672A\u786E\u8BA4\uFF1B\u8BF7\u6309 runId \u6838\u67E5\u670D\u52A1\u7AEF\u6D41\u6C34\uFF0C\u52FF\u56E0\u8BB0\u8D26\u72B6\u6001\u91CD\u8DD1\u91CD\u7F6E\u3002\n");
8702
+ if (!receipt.pgVerified) process.stderr.write("PostgreSQL \u57FA\u7EBF\u672A\u6838\u9A8C\uFF0C\u4E0D\u80FD\u5BA3\u79F0\u91CD\u7F6E\u5B8C\u6210\uFF1B\u8BF7\u6309 runId \u6838\u67E5\u3002\n");
8703
+ process.exitCode = receipt.pgVerified ? 0 : 4;
8704
+ } catch (error) {
8705
+ if (attempted) process.stderr.write("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");
8706
+ const e = error;
8707
+ exitWithError(e?.isAxiosError ? fromAxiosError18(error, args.env) : error);
8708
+ }
8709
+ }
8617
8710
  async function resolveBootstrapKey(args, stdinTaken) {
8618
8711
  const fromEnv = process.env.HCM_BOOTSTRAP_KEY;
8619
8712
  if (fromEnv) return fromEnv;
@@ -8723,7 +8816,7 @@ import { promises as fsp3 } from "fs";
8723
8816
  import os4 from "os";
8724
8817
  import nodePath from "path";
8725
8818
  import {
8726
- HcmClient as HcmClient19,
8819
+ HcmClient as HcmClient20,
8727
8820
  formatObject as formatObject20,
8728
8821
  fromAxiosError as fromAxiosError19,
8729
8822
  listTenantMeta,
@@ -8742,7 +8835,7 @@ init_exit();
8742
8835
  init_impersonation_lifecycle();
8743
8836
  init_auth_guard();
8744
8837
  async function client2(args) {
8745
- return HcmClient19.fromAuthContext(await getActiveAuthContextFromCli(args));
8838
+ return HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
8746
8839
  }
8747
8840
  function formatMetaForbiddenMessage(mode = "write") {
8748
8841
  if (mode === "read") {
@@ -9069,7 +9162,7 @@ import {
9069
9162
  formatObject as formatObject21,
9070
9163
  formatRows as formatRows5,
9071
9164
  getMiniStatus,
9072
- HcmClient as HcmClient20,
9165
+ HcmClient as HcmClient21,
9073
9166
  initMiniAppProject,
9074
9167
  inferMiniWritableTemplateOptionsFromModel,
9075
9168
  listWorkspaceFiles,
@@ -9126,7 +9219,7 @@ var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
9126
9219
  var RAW_WORKSPACE_EXCLUDED_FILES = /* @__PURE__ */ new Set([WORKSPACE_CONTEXT_FILE, ".DS_Store"]);
9127
9220
  async function workspaceListCommand(args) {
9128
9221
  try {
9129
- const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
9222
+ const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
9130
9223
  const limit = parsePositiveInt3(args.limit, 50, "--limit");
9131
9224
  const result = await client3.query("TenantExtensionWorkspace", {
9132
9225
  keyword: args.keyword,
@@ -9159,7 +9252,7 @@ async function workspaceActiveCommand(args) {
9159
9252
  const ctx = await getActiveAuthContextFromCli(args, {
9160
9253
  fallbackEnv: localContext?.profile
9161
9254
  });
9162
- const client3 = HcmClient20.fromAuthContext(ctx);
9255
+ const client3 = HcmClient21.fromAuthContext(ctx);
9163
9256
  const result = await client3.query("TenantExtensionWorkspace", {
9164
9257
  filter: { devModeEnabled: true },
9165
9258
  fields: ["workspaceKey", "devModeEnabled"],
@@ -9217,7 +9310,7 @@ async function workspaceCreateCommand(workspaceKey, args) {
9217
9310
  `${WORKSPACE_CONTEXT_FILE} already binds workspace '${existing.workspaceKey}'; use --force to rebind`
9218
9311
  );
9219
9312
  }
9220
- const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
9313
+ const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
9221
9314
  const normalizedWorkspaceKey = normalizeWorkspaceKey(workspaceKey);
9222
9315
  const resp = await client3.raw().post("/api/models/TenantExtensionWorkspace", {
9223
9316
  workspaceKey: normalizedWorkspaceKey,
@@ -9265,7 +9358,7 @@ async function workspacePullCommand(args) {
9265
9358
  `workspace key is required; pass --workspace <key> or run hcm workspace bind <key> first`
9266
9359
  );
9267
9360
  }
9268
- const client3 = HcmClient20.fromAuthContext(
9361
+ const client3 = HcmClient21.fromAuthContext(
9269
9362
  await getActiveAuthContextFromCli(args, { fallbackEnv: existing?.profile })
9270
9363
  );
9271
9364
  const context = buildWorkspaceContext({
@@ -9525,7 +9618,7 @@ async function workspacePushCommand(args) {
9525
9618
  const rootDir = resolveRootDir(args.dir);
9526
9619
  const context = await requireWorkspaceContext(rootDir);
9527
9620
  const miniApps = await discoverMiniApps(rootDir);
9528
- const client3 = HcmClient20.fromAuthContext(
9621
+ const client3 = HcmClient21.fromAuthContext(
9529
9622
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
9530
9623
  );
9531
9624
  const activeWorkspaceKey = args.dryRun ? null : await probeActiveWorkspaceKey(client3);
@@ -10073,7 +10166,7 @@ async function readMiniStatusSafely(app) {
10073
10166
  async function loadProfileClient(args) {
10074
10167
  try {
10075
10168
  const ctx = await getActiveAuthContextFromCli(args);
10076
- return HcmClient20.fromAuthContext(ctx);
10169
+ return HcmClient21.fromAuthContext(ctx);
10077
10170
  } catch (e) {
10078
10171
  if (args.env || args.profile) throw e;
10079
10172
  return null;
@@ -10560,7 +10653,7 @@ async function requestWorkspaceDeactivation(client3) {
10560
10653
  }
10561
10654
  async function workspaceActivateCommand(workspaceKey, args) {
10562
10655
  try {
10563
- const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
10656
+ const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
10564
10657
  const key2 = normalizeWorkspaceKey(workspaceKey);
10565
10658
  await setDevModeBinding(client3, key2);
10566
10659
  const fmt = args.output ?? "table";
@@ -10581,7 +10674,7 @@ async function workspaceActivateCommand(workspaceKey, args) {
10581
10674
  }
10582
10675
  async function workspaceDeactivateCommand(args) {
10583
10676
  try {
10584
- const client3 = HcmClient20.fromAuthContext(await getActiveAuthContextFromCli(args));
10677
+ const client3 = HcmClient21.fromAuthContext(await getActiveAuthContextFromCli(args));
10585
10678
  const binding = await requestWorkspaceDeactivation(client3);
10586
10679
  const result = { ...binding, deactivated: true };
10587
10680
  const fmt = args.output ?? "table";
@@ -10738,7 +10831,7 @@ import path10 from "path";
10738
10831
  import {
10739
10832
  CliError as CliError24,
10740
10833
  CliErrorCode as CliErrorCode23,
10741
- HcmClient as HcmClient21,
10834
+ HcmClient as HcmClient22,
10742
10835
  fetchReconIdentity,
10743
10836
  formatObject as formatObject23,
10744
10837
  httpProbe,
@@ -10752,7 +10845,7 @@ import {
10752
10845
  } from "@hcmai/sdk";
10753
10846
  async function probeTokenTenant(envName, requested) {
10754
10847
  const ctx = await getActiveAuthContextFromCli({ env: envName });
10755
- const client3 = HcmClient21.fromAuthContext(ctx);
10848
+ const client3 = HcmClient22.fromAuthContext(ctx);
10756
10849
  const identity2 = await fetchReconIdentity(httpProbe(client3.raw(), "default"), requested);
10757
10850
  return identity2?.tenantId ? String(identity2.tenantId) : void 0;
10758
10851
  }
@@ -11898,8 +11991,11 @@ init_exit();
11898
11991
  import { promises as fs10 } from "fs";
11899
11992
  import path11 from "path";
11900
11993
  import {
11901
- HcmClient as HcmClient22,
11994
+ HcmClient as HcmClient23,
11902
11995
  CliError as CliError26,
11996
+ CliErrorCode as CliErrorCode26,
11997
+ loadGlobalConfig as loadGlobalConfig11,
11998
+ resolveEnvContext as resolveEnvContext8,
11903
11999
  fetchReconIdentity as fetchReconIdentity2,
11904
12000
  formatObject as formatObject25,
11905
12001
  httpProbe as httpProbe2,
@@ -11908,9 +12004,9 @@ import {
11908
12004
  runDoctor
11909
12005
  } from "@hcmai/sdk";
11910
12006
  var defaultDeps2 = {
11911
- anchors: async (envName, tenant2, as) => {
11912
- const ctx = await getActiveAuthContextFromCli({ env: envName, as });
11913
- const client3 = HcmClient22.fromAuthContext(ctx);
12007
+ anchors: async (envName, tenant2, as, project) => {
12008
+ const ctx = await getActiveAuthContextFromCli({ env: envName, as }, { cwd: project });
12009
+ const client3 = HcmClient23.fromAuthContext(ctx);
11914
12010
  const probe = httpProbe2(client3.raw(), "default");
11915
12011
  const identity2 = await fetchReconIdentity2(probe, tenant2);
11916
12012
  const report = await runDoctor(probe, identity2, () => probeConversationHandshake({
@@ -11943,17 +12039,28 @@ async function runChironDoctor(args, deps = defaultDeps2) {
11943
12039
  return finish(report);
11944
12040
  }
11945
12041
  const names = Object.keys(file.environments);
12042
+ let selectedName = args.env;
12043
+ let explicitSlot;
11946
12044
  if (args.env !== void 0 && !Object.hasOwn(file.environments, args.env)) {
11947
- report.lines.push({
11948
- item: "\u767B\u5F55",
11949
- verdict: "fail",
11950
- detail: `${ENV_FILE} \u91CC\u6CA1\u6709\u73AF\u5883 '${args.env}'\uFF1B\u672C\u9879\u76EE\u6709\uFF1A${names.join(", ")}`,
11951
- nextStep: `\u53BB\u6389 --env \u6838\u5168\u90E8\uFF0C\u6216\u6362\u6210\u4E0A\u9762\u5217\u51FA\u7684\u540D\u5B57`
11952
- });
11953
- return finish(report);
12045
+ try {
12046
+ explicitSlot = await resolveEnvContext8({ envFlag: args.env, cwd: root }, process.env, await loadGlobalConfig11());
12047
+ if (!explicitSlot.project) throw new CliError26({
12048
+ code: CliErrorCode26.INVALID_ARGUMENT,
12049
+ message: `\u672C\u673A\u69FD '${args.env}' \u7684\u5730\u5740\u6216\u79DF\u6237\u4E0D\u5339\u914D\u672C\u9879\u76EE\uFF1B\u672C\u9879\u76EE\u6709\uFF1A${names.join(", ")}`
12050
+ });
12051
+ selectedName = explicitSlot.project.name;
12052
+ } catch (e) {
12053
+ report.lines.push({
12054
+ item: "\u767B\u5F55",
12055
+ verdict: "fail",
12056
+ detail: e.message,
12057
+ nextStep: `\u53BB\u6389 --env \u6838\u5168\u90E8\uFF0C\u6216\u7528 --env <\u9879\u76EE\u73AF\u5883\u540D> \u9009\u62E9\uFF1A${names.join(", ")}`
12058
+ });
12059
+ return finish(report);
12060
+ }
11954
12061
  }
11955
- const targets = args.env !== void 0 ? [args.env] : names;
11956
- const env2 = file.environments[file.default] ?? file.environments[targets[0]];
12062
+ const targets = selectedName !== void 0 ? [selectedName] : names;
12063
+ const env2 = file.environments[selectedName ?? file.default];
11957
12064
  report.env = env2;
11958
12065
  report.environments = names;
11959
12066
  report.defaultEnv = file.default;
@@ -11963,16 +12070,16 @@ async function runChironDoctor(args, deps = defaultDeps2) {
11963
12070
  const selected = isDefault || args.env !== void 0;
11964
12071
  const severity = () => selected ? "fail" : "warn";
11965
12072
  const label = `${name}${isDefault ? "\uFF08default\uFF09" : ""}${env3.danger ? " \xB7 danger" : ""}`;
11966
- const found = await findEnvByEndpoint3(env3.endpoint, env3.tenant);
11967
- const loginCmd = names.length > 1 ? `hcm login --env ${name}` : `hcm login ${env3.endpoint}`;
12073
+ const found = explicitSlot ?? await findEnvByEndpoint3(env3.endpoint, env3.tenant);
12074
+ const loginCmd = args.env !== void 0 ? `hcm login --env ${args.env}` : isDefault && process.env.HCM_ENV === void 0 && process.env.HCM_PROFILE === void 0 ? "hcm login" : `hcm login --env ${name}`;
11968
12075
  if (!found) {
11969
12076
  report.lines.push({ item: "\u767B\u5F55", verdict: severity(), detail: `${label} \xB7 \u672C\u673A\u6CA1\u6709\u767B\u5F55\u8FC7 ${env3.endpoint}`, nextStep: loginCmd });
11970
12077
  continue;
11971
12078
  }
11972
12079
  if (selected) report.envName = found.name;
11973
12080
  try {
11974
- const targetEnv = name;
11975
- const { report: anchors, tokenTenant: tokenTenant2 } = await deps.anchors(targetEnv, env3.tenant, args.as);
12081
+ const targetEnv = explicitSlot?.name ?? name;
12082
+ const { report: anchors, tokenTenant: tokenTenant2 } = await deps.anchors(targetEnv, env3.tenant, args.as, root);
11976
12083
  if (selected) report.anchors = anchors;
11977
12084
  (report.environmentAnchors ??= {})[name] = anchors;
11978
12085
  const tenantMismatch = tokenTenant2 && tokenTenant2 !== env3.tenant;
@@ -11996,6 +12103,8 @@ async function runChironDoctor(args, deps = defaultDeps2) {
11996
12103
  report.lines.push({ item: "\u767B\u5F55", verdict: severity(), detail: `${label} \xB7 \u672C\u673A\u69FD ${found.name} \xB7 ${env3.endpoint}\uFF1A${msg}`, nextStep: loginCmd });
11997
12104
  }
11998
12105
  }
12106
+ const skillsEnv = args.env ?? (process.env.HCM_ENV !== void 0 || process.env.HCM_PROFILE !== void 0 ? file.default : void 0);
12107
+ const skillsEnvOption = skillsEnv === void 0 ? "" : `--env ${skillsEnv}`;
11999
12108
  const skillsLine = async () => {
12000
12109
  const state = await readSkillsState(skillsSyncDir(root));
12001
12110
  if (!state) {
@@ -12005,22 +12114,22 @@ async function runChironDoctor(args, deps = defaultDeps2) {
12005
12114
  item: "\u6280\u80FD",
12006
12115
  verdict: "warn",
12007
12116
  detail: `${Object.keys(legacy.skills).length} \u4E2A\uFF0C\u4F46\u8FD8\u662F 0.14.0 \u4E4B\u524D\u7684\u6241\u5E73\u5E03\u5C40\uFF08\u6E05\u5355\u5728 ${SKILLS_DIR}/\uFF0C\u4EA7\u54C1\u90A3\u4E00\u534A\u5E94\u8BE5\u5728 ${SKILLS_DIR}/${SKILLS_SYNC_SUBDIR}/\uFF09`,
12008
- nextStep: "hcm chiron skills sync \u5C31\u5730\u5206\u6210\u4E24\u534A\uFF08\u5E42\u7B49\uFF0C\u4E0D\u4F1A\u91CD\u88C5\uFF09"
12117
+ nextStep: `hcm chiron skills sync ${skillsEnvOption} \u5C31\u5730\u5206\u6210\u4E24\u534A\uFF08\u5E42\u7B49\uFF0C\u4E0D\u4F1A\u91CD\u88C5\uFF09`
12009
12118
  };
12010
12119
  }
12011
12120
  return {
12012
12121
  item: "\u6280\u80FD",
12013
12122
  verdict: "fail",
12014
12123
  detail: `${SKILLS_DIR}/${SKILLS_SYNC_SUBDIR}/ \u91CC\u6CA1\u6709\u5B89\u88C5\u6E05\u5355`,
12015
- nextStep: "hcm chiron skills sync"
12124
+ nextStep: `hcm chiron skills sync ${skillsEnvOption}`.trimEnd()
12016
12125
  };
12017
12126
  }
12018
12127
  const count = Object.keys(state.skills).length;
12019
12128
  if (state.endpoint && normalizeOrigin3(state.endpoint) !== env2.endpoint) {
12020
- return { item: "\u6280\u80FD", verdict: "fail", detail: `${count} \u4E2A\uFF0C\u4F46\u88C5\u81EA ${state.endpoint}\uFF0C\u4E0D\u662F\u9879\u76EE\u73AF\u5883 ${env2.endpoint}`, nextStep: "hcm chiron skills sync \u91CD\u88C5\uFF08\u5B83\u4F1A\u6309\u9879\u76EE\u73AF\u5883\u91CD\u65B0\u5BF9\u8D26\uFF09" };
12129
+ return { item: "\u6280\u80FD", verdict: "fail", detail: `${count} \u4E2A\uFF0C\u4F46\u88C5\u81EA ${state.endpoint}\uFF0C\u4E0D\u662F\u9879\u76EE\u73AF\u5883 ${env2.endpoint}`, nextStep: `hcm chiron skills sync ${skillsEnvOption} \u91CD\u88C5\uFF08\u5B83\u4F1A\u6309\u9879\u76EE\u73AF\u5883\u91CD\u65B0\u5BF9\u8D26\uFF09` };
12021
12130
  }
12022
12131
  if (state.target !== "codex") {
12023
- return { item: "\u6280\u80FD", verdict: "warn", detail: `${count} \u4E2A\uFF0C\u5E03\u5C40\u662F ${state.target}\uFF08Codex \u8981\u8BFB AGENTS.md \u7D22\u5F15\uFF09`, nextStep: "hcm chiron skills sync --target codex" };
12132
+ return { item: "\u6280\u80FD", verdict: "warn", detail: `${count} \u4E2A\uFF0C\u5E03\u5C40\u662F ${state.target}\uFF08Codex \u8981\u8BFB AGENTS.md \u7D22\u5F15\uFF09`, nextStep: `hcm chiron skills sync ${skillsEnvOption} --target codex` };
12024
12133
  }
12025
12134
  return { item: "\u6280\u80FD", verdict: "ok", detail: `${count} \u4E2A\uFF0C\u6765\u81EA ${state.endpoint ?? "\u672C\u5730"}${state.all ? "\uFF0C\u8DDF\u968F\u5168\u96C6" : ""}` };
12026
12135
  };
@@ -12046,7 +12155,7 @@ function finish(report) {
12046
12155
  }
12047
12156
  function renderChironDoctor(report) {
12048
12157
  const mark = { ok: "\u2705", warn: "\u26A0\uFE0F", fail: "\u274C" };
12049
- const out = [];
12158
+ const out = [`\u9879\u76EE\u76EE\u5F55\uFF1A${report.project}\uFF08\u4E0B\u4E00\u6B65\u547D\u4EE4\u5728\u6B64\u76EE\u5F55\u6267\u884C\uFF09`];
12050
12159
  for (const l of report.lines) {
12051
12160
  out.push(`${mark[l.verdict]} ${l.item.padEnd(3, "\u3000")} ${l.detail}`);
12052
12161
  if (l.nextStep && l.verdict !== "ok") out.push(` \u2192 ${l.nextStep}`);
@@ -12082,7 +12191,7 @@ import yaml from "js-yaml";
12082
12191
  import {
12083
12192
  AUTH_INFO_PATH as AUTH_INFO_PATH2,
12084
12193
  CliError as CliError27,
12085
- CliErrorCode as CliErrorCode26,
12194
+ CliErrorCode as CliErrorCode27,
12086
12195
  discoverProjectEnv as discoverProjectEnv6,
12087
12196
  ENV_FILE as ENV_FILE2,
12088
12197
  findEnvByEndpoint as findEnvByEndpoint5,
@@ -12105,7 +12214,7 @@ function summarizeReasons(reasons) {
12105
12214
  return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
12106
12215
  }
12107
12216
  function invalid2(message, nextStep) {
12108
- throw new CliError27({ code: CliErrorCode26.INVALID_ARGUMENT, message, context: { nextStep } });
12217
+ throw new CliError27({ code: CliErrorCode27.INVALID_ARGUMENT, message, context: { nextStep } });
12109
12218
  }
12110
12219
  function required(value, label) {
12111
12220
  if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
@@ -12323,11 +12432,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
12323
12432
  import fs12 from "fs/promises";
12324
12433
  import os5 from "os";
12325
12434
  import path14 from "path";
12326
- import { CliError as CliError30, CliErrorCode as CliErrorCode29, formatObject as formatObject27, HcmClient as HcmClient23, loadEnv as loadEnv6 } from "@hcmai/sdk";
12435
+ import { CliError as CliError30, CliErrorCode as CliErrorCode30, formatObject as formatObject27, HcmClient as HcmClient24, loadEnv as loadEnv6 } from "@hcmai/sdk";
12327
12436
  import { createRequire } from "module";
12328
12437
 
12329
12438
  // src/commands/chiron-page-cdp.ts
12330
- import { CliError as CliError28, CliErrorCode as CliErrorCode27 } from "@hcmai/sdk";
12439
+ import { CliError as CliError28, CliErrorCode as CliErrorCode28 } from "@hcmai/sdk";
12331
12440
 
12332
12441
  // src/commands/chiron-page-shared.ts
12333
12442
  function redactTicket(text) {
@@ -12363,14 +12472,14 @@ function normalizeCdpEndpoint(raw) {
12363
12472
  try {
12364
12473
  url = new URL(candidate);
12365
12474
  } catch {
12366
- throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12475
+ throw new CliError28({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12367
12476
  }
12368
12477
  const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
12369
12478
  if (protocol !== "http:" && protocol !== "https:") {
12370
- throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12479
+ throw new CliError28({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12371
12480
  }
12372
12481
  if (!url.port) {
12373
- throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12482
+ throw new CliError28({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
12374
12483
  }
12375
12484
  return `${protocol}//${url.hostname}:${url.port}`;
12376
12485
  }
@@ -12468,7 +12577,7 @@ async function captureViaCdp(input, io) {
12468
12577
  const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
12469
12578
  if (!target?.id || !target.webSocketDebuggerUrl) {
12470
12579
  throw new CliError28({
12471
- code: CliErrorCode27.SERVER_ERROR,
12580
+ code: CliErrorCode28.SERVER_ERROR,
12472
12581
  message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
12473
12582
  context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
12474
12583
  });
@@ -12498,7 +12607,7 @@ async function captureViaCdp(input, io) {
12498
12607
  });
12499
12608
  if (r.exceptionDetails) {
12500
12609
  const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
12501
- throw new CliError28({ code: CliErrorCode27.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
12610
+ throw new CliError28({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
12502
12611
  }
12503
12612
  evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
12504
12613
  }
@@ -12509,7 +12618,7 @@ async function captureViaCdp(input, io) {
12509
12618
  const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
12510
12619
  const shot = await session.send("Page.captureScreenshot", { format: "png" });
12511
12620
  if (!shot.data) {
12512
- throw new CliError28({ code: CliErrorCode27.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
12621
+ throw new CliError28({ code: CliErrorCode28.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
12513
12622
  }
12514
12623
  await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
12515
12624
  return { dom, browser, evalResult, navigated, minted };
@@ -12531,7 +12640,7 @@ var defaultCdpIo = {
12531
12640
  openSocket: (wsUrl) => new Promise((resolve3, reject) => {
12532
12641
  const Ctor = globalThis.WebSocket;
12533
12642
  if (!Ctor) {
12534
- reject(new CliError28({ code: CliErrorCode27.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
12643
+ reject(new CliError28({ code: CliErrorCode28.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
12535
12644
  return;
12536
12645
  }
12537
12646
  const ws = new Ctor(wsUrl);
@@ -12554,7 +12663,7 @@ var defaultCdpIo = {
12554
12663
 
12555
12664
  // src/commands/chiron-page-playwright.ts
12556
12665
  import path13 from "path";
12557
- import { CliError as CliError29, CliErrorCode as CliErrorCode28 } from "@hcmai/sdk";
12666
+ import { CliError as CliError29, CliErrorCode as CliErrorCode29 } from "@hcmai/sdk";
12558
12667
  function playwrightCacheRoot(probe) {
12559
12668
  const override = probe.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
12560
12669
  if (override === "0" && probe.packageRoot) return path13.join(probe.packageRoot, ".local-browsers");
@@ -12598,7 +12707,7 @@ function discoverPlaywrightBrowser(probe) {
12598
12707
  if (explicit) {
12599
12708
  if (probe.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
12600
12709
  throw new CliError29({
12601
- code: CliErrorCode28.INVALID_ARGUMENT,
12710
+ code: CliErrorCode29.INVALID_ARGUMENT,
12602
12711
  message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
12603
12712
  context: { nextStep: "\u6307\u5230 Playwright \u88C5\u7684 chrome-headless-shell / chrome \u4E8C\u8FDB\u5236\uFF0C\u6216\u53BB\u6389\u8FD9\u4E2A\u53D8\u91CF\u8BA9 CLI \u81EA\u5DF1\u627E" }
12604
12713
  });
@@ -12641,7 +12750,7 @@ async function captureViaPlaywright(input) {
12641
12750
  }
12642
12751
  if (!browser) {
12643
12752
  throw new CliError29({
12644
- code: CliErrorCode28.SERVER_ERROR,
12753
+ code: CliErrorCode29.SERVER_ERROR,
12645
12754
  message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
12646
12755
  context: {
12647
12756
  nextStep: "\u88C5\u4E00\u4EFD Playwright \u7684 Chromium\uFF1Anpx playwright install chromium-headless-shell\uFF08\u6216 chromium\uFF09\uFF1B\u5DF2\u7ECF\u88C5\u4E86\u4F46\u4E0D\u5728\u7F3A\u7701\u7F13\u5B58\u76EE\u5F55\u5C31 export PLAYWRIGHT_BROWSERS_PATH=<\u76EE\u5F55> \u6216 HCM_PLAYWRIGHT_EXECUTABLE=<\u4E8C\u8FDB\u5236>\uFF1B\u6C99\u7BB1\u8FDE headless shell \u90FD\u8D77\u4E0D\u4E86\u65F6\uFF0C\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u5E76\u7528 --cdp \u8FDE"
@@ -12661,7 +12770,7 @@ async function captureViaPlaywright(input) {
12661
12770
  evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
12662
12771
  } catch (e) {
12663
12772
  const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
12664
- throw new CliError29({ code: CliErrorCode28.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
12773
+ throw new CliError29({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
12665
12774
  }
12666
12775
  }
12667
12776
  const dom = await page.content();
@@ -12685,13 +12794,13 @@ function judgePageContent(input) {
12685
12794
  function parseViewport(size) {
12686
12795
  const m = /^(\d+)x(\d+)$/.exec(size.trim());
12687
12796
  if (!m) {
12688
- throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
12797
+ throw new CliError30({ code: CliErrorCode30.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
12689
12798
  }
12690
12799
  const width = Number(m[1]);
12691
12800
  const height = Number(m[2]);
12692
12801
  if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
12693
12802
  throw new CliError30({
12694
- code: CliErrorCode29.INVALID_ARGUMENT,
12803
+ code: CliErrorCode30.INVALID_ARGUMENT,
12695
12804
  message: `--size \u8D85\u51FA\u8303\u56F4\uFF1A\u5BBD ${VIEWPORT_MIN.width}..${VIEWPORT_MAX.width}\u3001\u9AD8 ${VIEWPORT_MIN.height}..${VIEWPORT_MAX.height}\uFF0C\u6536\u5230\u7684\u662F ${size}`
12696
12805
  });
12697
12806
  }
@@ -12701,23 +12810,23 @@ function parseWaitMs(raw) {
12701
12810
  if (raw === void 0) return 1e4;
12702
12811
  const value = typeof raw === "number" ? raw : Number(raw);
12703
12812
  if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
12704
- throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
12813
+ throw new CliError30({ code: CliErrorCode30.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
12705
12814
  }
12706
12815
  return value;
12707
12816
  }
12708
12817
  function resolveEvidenceTarget(projectRoot, out) {
12709
12818
  if (!out?.trim()) {
12710
- throw new CliError30({ code: CliErrorCode29.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
12819
+ throw new CliError30({ code: CliErrorCode30.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
12711
12820
  }
12712
12821
  if (!out.endsWith(".png")) {
12713
- throw new CliError30({ code: CliErrorCode29.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
12822
+ throw new CliError30({ code: CliErrorCode30.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
12714
12823
  }
12715
12824
  const root = path14.resolve(projectRoot);
12716
12825
  const evidenceRoot = path14.join(root, EVIDENCE_DIR);
12717
12826
  const absolute = path14.resolve(root, out);
12718
12827
  if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path14.sep)) {
12719
12828
  throw new CliError30({
12720
- code: CliErrorCode29.INVALID_ARGUMENT,
12829
+ code: CliErrorCode30.INVALID_ARGUMENT,
12721
12830
  message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
12722
12831
  });
12723
12832
  }
@@ -12766,7 +12875,7 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
12766
12875
  if (canonicalRoot === null || canonicalParent === null) return;
12767
12876
  if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path14.sep)) {
12768
12877
  throw new CliError30({
12769
- code: CliErrorCode29.INVALID_ARGUMENT,
12878
+ code: CliErrorCode30.INVALID_ARGUMENT,
12770
12879
  message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
12771
12880
  });
12772
12881
  }
@@ -12776,7 +12885,7 @@ async function runChironPage(target, args, deps) {
12776
12885
  const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
12777
12886
  if (expect.length === 0) {
12778
12887
  throw new CliError30({
12779
- code: CliErrorCode29.MISSING_FLAG,
12888
+ code: CliErrorCode30.MISSING_FLAG,
12780
12889
  message: "\u81F3\u5C11\u8981\u4F20\u4E00\u6761 --expect-text\uFF08\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF09\u3002\u53EA\u5224\u300C\u622A\u51FA\u56FE\u4E86\u300D\u4E0D\u7B97\u9A8C\u6536\uFF1A\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\u3001\u767D\u5C4F\u90FD\u80FD\u622A\u51FA\u56FE\u3002"
12781
12890
  });
12782
12891
  }
@@ -12787,7 +12896,7 @@ async function runChironPage(target, args, deps) {
12787
12896
  const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
12788
12897
  if (await deps.present(absolute)) {
12789
12898
  throw new CliError30({
12790
- code: CliErrorCode29.INVALID_ARGUMENT,
12899
+ code: CliErrorCode30.INVALID_ARGUMENT,
12791
12900
  message: `\u622A\u56FE\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8986\u76D6\uFF1A${absolute}\u3002\u6362\u4E2A --out\uFF0C\u6216\u5148\u628A\u65E7\u8BC1\u636E\u632A\u8D70\u3002`
12792
12901
  });
12793
12902
  }
@@ -12800,7 +12909,7 @@ async function runChironPage(target, args, deps) {
12800
12909
  const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
12801
12910
  if (evalJs && !endpoint && !usePlaywright) {
12802
12911
  throw new CliError30({
12803
- code: CliErrorCode29.INVALID_ARGUMENT,
12912
+ code: CliErrorCode30.INVALID_ARGUMENT,
12804
12913
  message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
12805
12914
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
12806
12915
  });
@@ -12821,7 +12930,7 @@ async function runChironPage(target, args, deps) {
12821
12930
  if (e instanceof CliError30) throw new CliError30({ code: e.code, message: redactTicket(e.message), context: e.context });
12822
12931
  const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
12823
12932
  throw new CliError30({
12824
- code: CliErrorCode29.SERVER_ERROR,
12933
+ code: CliErrorCode30.SERVER_ERROR,
12825
12934
  message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
12826
12935
  context: {
12827
12936
  nextStep: endpoint ? `\u6838\u4E00\u773C ${endpoint}/json/version \u80FD\u4E0D\u80FD\u6253\u5F00\uFF1BChrome \u8981\u5E26 --remote-debugging-port \u8D77\uFF0C\u4E14\u6C99\u7BB1\u653E\u884C\u4E86\u8FD9\u4E2A\u7AEF\u53E3` : "npx playwright install chromium-headless-shell \u540E\u91CD\u8DD1\uFF1B\u6216 HCM_CHIRON_PAGE_DRIVER=spawn \u8D70\u8001\u8DEF\u5F84\u5BF9\u7167"
@@ -12838,7 +12947,7 @@ async function runChironPage(target, args, deps) {
12838
12947
  const browser = deps.findBrowser();
12839
12948
  if (!browser) {
12840
12949
  throw new CliError30({
12841
- code: CliErrorCode29.INVALID_ARGUMENT,
12950
+ code: CliErrorCode30.INVALID_ARGUMENT,
12842
12951
  message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
12843
12952
  context: { nextStep: "npx playwright install chromium-headless-shell\uFF08\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\uFF1B\u6216\u88C5\u4E00\u4E2A Chrome / HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84\uFF1B\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
12844
12953
  });
@@ -12847,7 +12956,7 @@ async function runChironPage(target, args, deps) {
12847
12956
  const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
12848
12957
  if (!result.ok) {
12849
12958
  throw new CliError30({
12850
- code: CliErrorCode29.SERVER_ERROR,
12959
+ code: CliErrorCode30.SERVER_ERROR,
12851
12960
  message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
12852
12961
  context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
12853
12962
  });
@@ -12857,7 +12966,7 @@ async function runChironPage(target, args, deps) {
12857
12966
  }
12858
12967
  const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
12859
12968
  if (bytes === 0) {
12860
- throw new CliError30({ code: CliErrorCode29.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
12969
+ throw new CliError30({ code: CliErrorCode30.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
12861
12970
  }
12862
12971
  const verdict = judgePageContent({ dom, expect, reject });
12863
12972
  return {
@@ -12921,12 +13030,12 @@ var defaultChironPageDeps = {
12921
13030
  const frontend = ctx.frontend ?? envCfg.frontend;
12922
13031
  if (!frontend?.trim()) {
12923
13032
  throw new CliError30({
12924
- code: CliErrorCode29.INVALID_ARGUMENT,
13033
+ code: CliErrorCode30.INVALID_ARGUMENT,
12925
13034
  message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
12926
13035
  context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
12927
13036
  });
12928
13037
  }
12929
- const client3 = HcmClient23.fromAuthContext(ctx);
13038
+ const client3 = HcmClient24.fromAuthContext(ctx);
12930
13039
  const { ticket } = await mintBrowserTicket(client3, ctx.env)();
12931
13040
  return { url: buildBrowserLoginUrl(frontend, ticket, sitePath), environment: ctx.env, identity: ctx.identity ?? null };
12932
13041
  },
@@ -13007,7 +13116,7 @@ import { formatObject as formatObject28 } from "@hcmai/sdk";
13007
13116
 
13008
13117
  // src/commands/delivery-action-policy.ts
13009
13118
  init_auth_guard();
13010
- import { HcmClient as HcmClient24, classifyEffect } from "@hcmai/sdk";
13119
+ import { HcmClient as HcmClient25, classifyEffect } from "@hcmai/sdk";
13011
13120
 
13012
13121
  // src/commands/delivery.ts
13013
13122
  import { createHash as createHash6 } from "crypto";
@@ -13522,7 +13631,7 @@ async function resolveCoreAction(request) {
13522
13631
  as: request.identity,
13523
13632
  profile: request.profile
13524
13633
  });
13525
- const description = await HcmClient24.fromAuthContext(auth).describe(request.model);
13634
+ const description = await HcmClient25.fromAuthContext(auth).describe(request.model);
13526
13635
  const named = description.actions.filter((action) => action.name === request.action);
13527
13636
  if (named.length === 0) {
13528
13637
  const degraded = description.effectiveActionsAvailable ? "" : `\u26A0\uFE0F \u672C\u6B21\u6BD4\u5BF9\u4E0D\u542B\u811A\u672C Action\u2014\u2014${description.effectiveActionsNote ?? "\u539F\u56E0\u672A\u77E5"}\u3002`;
@@ -13993,7 +14102,7 @@ ${failed2} \u6761\u6CA1\u8FC7\u2014\u2014\u4E0A\u9762\u6BCF\u6761\u90FD\u5199\u4
13993
14102
  init_auth_guard();
13994
14103
  init_exit();
13995
14104
  import {
13996
- HcmClient as HcmClient25,
14105
+ HcmClient as HcmClient26,
13997
14106
  ReconLayout,
13998
14107
  ROUND_EXIT_CODES,
13999
14108
  computeReconSourceKey,
@@ -14008,7 +14117,7 @@ var DEFAULT_CAPABILITIES = "default";
14008
14117
  async function deliveryReconCommand(args) {
14009
14118
  try {
14010
14119
  const ctx = await getActiveAuthContextFromCli(args);
14011
- const client3 = HcmClient25.fromAuthContext(ctx);
14120
+ const client3 = HcmClient26.fromAuthContext(ctx);
14012
14121
  const probe = httpProbe3(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES);
14013
14122
  const sourceKey = await computeReconSourceKey(probe);
14014
14123
  const layout = new ReconLayout(args.out ?? ".", ctx.tenantId, sourceKey);
@@ -14051,7 +14160,7 @@ import {
14051
14160
  DRY_RUN_TAIL,
14052
14161
  DriftDetected,
14053
14162
  FORCE_STALE_FLAG,
14054
- HcmClient as HcmClient26,
14163
+ HcmClient as HcmClient27,
14055
14164
  fetchReconIdentity as fetchReconIdentity3,
14056
14165
  INIT_EXIT_CODES,
14057
14166
  JOURNAL_STOP_KINDS,
@@ -14191,7 +14300,7 @@ async function authOrSignpost(args, cmd) {
14191
14300
  }
14192
14301
  async function deliverySeedPlanCommand(args) {
14193
14302
  const ctx = await authOrSignpost(args, "plan");
14194
- const client3 = HcmClient26.fromAuthContext(ctx);
14303
+ const client3 = HcmClient27.fromAuthContext(ctx);
14195
14304
  process.exitCode = await runSeedPlan(args, seedClient(client3, ctx));
14196
14305
  }
14197
14306
  function seedClient(client3, ctx) {
@@ -14365,7 +14474,7 @@ async function runSeedApply(args, client3) {
14365
14474
  }
14366
14475
  async function deliverySeedApplyCommand(args) {
14367
14476
  const ctx = await authOrSignpost(args, "apply");
14368
- const client3 = HcmClient26.fromAuthContext(ctx);
14477
+ const client3 = HcmClient27.fromAuthContext(ctx);
14369
14478
  process.exitCode = await runSeedApply(args, seedClient(client3, ctx));
14370
14479
  }
14371
14480
  async function runSeedVerify(args, client3) {
@@ -14389,7 +14498,7 @@ async function deliverySeedVerifyCommand(args) {
14389
14498
  return;
14390
14499
  }
14391
14500
  const ctx = await authOrSignpost(args, "verify");
14392
- const client3 = HcmClient26.fromAuthContext(ctx);
14501
+ const client3 = HcmClient27.fromAuthContext(ctx);
14393
14502
  process.exitCode = await runSeedVerify(args, await seedVerifyClient(client3, ctx));
14394
14503
  }
14395
14504
 
@@ -14504,7 +14613,7 @@ import {
14504
14613
  CHANGE_STATES,
14505
14614
  CHANGE_UNKNOWN,
14506
14615
  CODE_WORDS,
14507
- HcmClient as HcmClient27,
14616
+ HcmClient as HcmClient28,
14508
14617
  INIT_EXIT_CODES as INIT_EXIT_CODES3,
14509
14618
  META_WRITE_STEPS,
14510
14619
  META_VERIFY_STEPS,
@@ -14732,7 +14841,7 @@ function lowerCaseHeaders2(headers) {
14732
14841
  }
14733
14842
  async function deliveryMetaCommand(args) {
14734
14843
  const ctx = await getActiveAuthContextFromCli(args);
14735
- const client3 = HcmClient27.fromAuthContext(ctx);
14844
+ const client3 = HcmClient28.fromAuthContext(ctx);
14736
14845
  process.exitCode = await runDeliveryMeta(
14737
14846
  { ...args, tenant: args.tenant ?? String(ctx.tenantId ?? "") },
14738
14847
  metaClient(client3, ctx)
@@ -14744,7 +14853,7 @@ init_auth_guard();
14744
14853
  init_exit();
14745
14854
  import {
14746
14855
  computeReconSourceKey as computeReconSourceKey2,
14747
- HcmClient as HcmClient28,
14856
+ HcmClient as HcmClient29,
14748
14857
  httpProbe as httpProbe4,
14749
14858
  ReconLayout as ReconLayout2,
14750
14859
  runTriageRound
@@ -14800,7 +14909,7 @@ async function runTriage(args) {
14800
14909
  return premise4(e instanceof Error ? e.message : String(e), REQUESTS_SHAPE);
14801
14910
  }
14802
14911
  const ctx = await getActiveAuthContextFromCli(args);
14803
- const client3 = HcmClient28.fromAuthContext(ctx);
14912
+ const client3 = HcmClient29.fromAuthContext(ctx);
14804
14913
  const probe = httpProbe4(client3.raw(), args.capabilities ?? DEFAULT_CAPABILITIES3);
14805
14914
  const artifactsDir = args.recon ?? new ReconLayout2(args.out ?? ".", ctx.tenantId, await computeReconSourceKey2(probe)).dir;
14806
14915
  const result = await runTriageRound(probe, artifactsDir, entriesIn);
@@ -14829,25 +14938,25 @@ async function deliveryTriageCommand(args) {
14829
14938
  init_auth_guard();
14830
14939
  init_exit();
14831
14940
  import {
14832
- HcmClient as HcmClient29,
14941
+ HcmClient as HcmClient30,
14833
14942
  adminResetPassword,
14834
14943
  formatObject as formatObject30,
14835
14944
  fromAxiosError as fromAxiosError23,
14836
14945
  CliError as CliError31,
14837
- CliErrorCode as CliErrorCode30
14946
+ CliErrorCode as CliErrorCode31
14838
14947
  } from "@hcmai/sdk";
14839
14948
  function buildAdminResetPasswordRequest(args, password) {
14840
14949
  const hasId = Boolean(args.id);
14841
14950
  const hasUsername = Boolean(args.username);
14842
14951
  if (hasId === hasUsername) {
14843
14952
  throw new CliError31({
14844
- code: CliErrorCode30.INVALID_ARGUMENT,
14953
+ code: CliErrorCode31.INVALID_ARGUMENT,
14845
14954
  message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
14846
14955
  });
14847
14956
  }
14848
14957
  if (!password) {
14849
14958
  throw new CliError31({
14850
- code: CliErrorCode30.INVALID_ARGUMENT,
14959
+ code: CliErrorCode31.INVALID_ARGUMENT,
14851
14960
  message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
14852
14961
  });
14853
14962
  }
@@ -14863,7 +14972,7 @@ async function userResetPasswordCommand(args) {
14863
14972
  try {
14864
14973
  const password = args.passwordStdin ? await readSecretFromStdin() : await promptPasswordTwice();
14865
14974
  const request = buildAdminResetPasswordRequest(args, password);
14866
- const client3 = HcmClient29.fromAuthContext(await getActiveAuthContextFromCli(args));
14975
+ const client3 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
14867
14976
  const result = await adminResetPassword(client3.raw(), request);
14868
14977
  process.stdout.write(formatObject30(result, { format: args.output ?? "json" }) + "\n");
14869
14978
  } catch (cause) {
@@ -14877,7 +14986,7 @@ async function promptPasswordTwice() {
14877
14986
  const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
14878
14987
  if (password !== confirmation) {
14879
14988
  throw new CliError31({
14880
- code: CliErrorCode30.INVALID_ARGUMENT,
14989
+ code: CliErrorCode31.INVALID_ARGUMENT,
14881
14990
  message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
14882
14991
  });
14883
14992
  }
@@ -14888,13 +14997,13 @@ async function promptPasswordTwice() {
14888
14997
  init_exit();
14889
14998
  init_auth_guard();
14890
14999
  import {
14891
- HcmClient as HcmClient30,
15000
+ HcmClient as HcmClient31,
14892
15001
  formatObject as formatObject31,
14893
15002
  fromAxiosError as fromAxiosError24
14894
15003
  } from "@hcmai/sdk";
14895
15004
  async function modelsCommand(keyword, args) {
14896
15005
  try {
14897
- const client3 = HcmClient30.fromAuthContext(await getActiveAuthContextFromCli(args));
15006
+ const client3 = HcmClient31.fromAuthContext(await getActiveAuthContextFromCli(args));
14898
15007
  const all = await client3.listModels();
14899
15008
  const needle = keyword?.trim().toLowerCase();
14900
15009
  const rows2 = (needle ? all.filter((m) => JSON.stringify(m).toLowerCase().includes(needle)) : all).sort((a, b) => key(a).localeCompare(key(b)));
@@ -15098,7 +15207,7 @@ program.command("query <Model>").description("\u67E5\u8BE2 Model \u5217\u8868\u6
15098
15207
  ).option("--sort <JSON>", `\u6392\u5E8F\u6761\u4EF6 JSON\uFF0C\u4F8B\u5982 '[{"field":"hireDate","direction":"desc"}]'`).option(
15099
15208
  "--additions <JSON>",
15100
15209
  `\u8DE8\u5173\u7CFB JOIN \u7684\u5BF9\u8C61\u6570\u7EC4 JSON\uFF0C\u4F8B\u5982 '[{"key":"employee","model":"Employee"}]'`
15101
- ).option("--fields <list>", "\u8FD4\u56DE\u5B57\u6BB5\u5217\u8868\uFF08\u9017\u53F7\u5206\u9694\uFF09\uFF0C\u4F8B\u5982 name,code,email").option("--keyword <text>", "\u5168\u6587\u68C0\u7D22\u5173\u952E\u5B57").option("--limit <n>", "\u6BCF\u9875\u5927\u5C0F", "20").option("--offset <n>", "\u504F\u79FB\u91CF\uFF08\u6309 limit \u81EA\u52A8\u6362\u7B97 page\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => queryCommand(m, opts));
15210
+ ).option("--fields <list>", "\u8FD4\u56DE\u5B57\u6BB5\u5217\u8868\uFF08\u9017\u53F7\u5206\u9694\uFF09\uFF0C\u4F8B\u5982 name,code,email").option("--plugin <activation>", "\u5143\u6570\u636E\u63D2\u4EF6\u6FC0\u6D3B\u4E32\uFF0C\u4F8B\u5982 salaryByAssist:assistId=<uuid>").option("--keyword <text>", "\u5168\u6587\u68C0\u7D22\u5173\u952E\u5B57").option("--limit <n>", "\u6BCF\u9875\u5927\u5C0F", "20").option("--offset <n>", "\u504F\u79FB\u91CF\uFF08\u6309 limit \u81EA\u52A8\u6362\u7B97 page\uFF09").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD\uFF08\u8986\u76D6 env defaultIdentity\uFF0C\u672C\u6B21\u547D\u4EE4\uFF09").option("--profile <name>", "[deprecated] \u7528 --env \u66FF\u4EE3").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((m, opts) => queryCommand(m, opts));
15102
15211
  program.command("action <Model.Action>").description("\u8C03\u7528 Model \u4E0A\u7684 Action\uFF08\u4E1A\u52A1\u65B9\u6CD5\uFF09\uFF0C\u4F8B\u5982 Employee.regularize").option("--id <id>", "\u76EE\u6807\u5B9E\u4F53 ID\uFF08object Action \u5FC5\u586B\uFF09").option("--ids <csv>", "\u6279\u91CF ID\uFF08\u9017\u53F7\u5206\u9694\uFF0Cbulk Action \u7528\uFF09").option("--method <method>", "HTTP \u65B9\u6CD5\uFF1AGET | POST | PUT | DELETE\uFF08\u9ED8\u8BA4\u6309 Core \u5143\u6570\u636E\u81EA\u52A8\u5224\u5B9A\uFF09").option(
15103
15212
  "--scope <scope>",
15104
15213
  "\u5F3A\u5236 Action scope\uFF1Aclass | object\uFF08\u9ED8\u8BA4\uFF1A\u6709 --id \u4E3A object\uFF0C\u5426\u5219 class\uFF09"
@@ -15184,6 +15293,7 @@ datapackage.command("pack <packageDir>").description("\u628A\u5305\u76EE\u5F55\u
15184
15293
  datapackage.command("install <artifact>").description("\u4E0A\u4F20 .hcmpkg \u5236\u54C1\u5E76\u7ECF\u670D\u52A1\u7AEF\u5F02\u6B65\u5B89\u88C5\u5668\u5B89\u88C5\uFF0C\u5B9E\u65F6\u663E\u793A\u8FDB\u5EA6\uFF08admin.system\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("--category <name>", "\u5236\u54C1\u4E0A\u4F20\u7684\u5B58\u50A8\u5206\u7C7B\uFF08\u670D\u52A1\u7AEF\u6570\u636E\u975E\u679A\u4E3E\uFF09", "attachment").option("--no-wait", "\u53EA\u53D7\u7406\u4E0D\u7B49\u5F85\uFF0C\u7ACB\u523B\u8FD4\u56DE runId").option("--timeout <sec>", "\u7B49\u5F85\u4E0A\u9650\uFF08\u79D2\uFF09\uFF1B\u7B49\u4E0D\u5230\u4E0D\u662F\u5931\u8D25\uFF0C\u88C5\u8F7D\u5728\u670D\u52A1\u7AEF\u7EE7\u7EED", "900").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((artifact, opts) => datapackageInstallCommand(artifact, opts));
15185
15294
  datapackage.command("status <runId>").description("\u67E5\u770B\u88C5\u8F7D\u6D41\u6C34\u8FDB\u5EA6/\u7EC8\u6001\uFF08\u914D\u5408 install --no-wait \u6216\u7B49\u5F85\u8D85\u65F6\u540E\u4F7F\u7528\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((runId, opts) => datapackageStatusCommand(runId, opts));
15186
15295
  var tenant = program.command("tenant").description("\u79DF\u6237\u5F00\u901A\u4E0E\u751F\u547D\u5468\u671F");
15296
+ tenant.command("reset").description("\u4EE5\u5F53\u524D\u79DF\u6237\u5185\u7F6E admin \u91CD\u7F6E PostgreSQL \u5230\u51FA\u5382\u57FA\u7EBF\uFF1B\u4E0D\u53EF\u9006\uFF0C\u975E PG \u672A\u5904\u7406\u672A\u6838\u9A8C").option("--env <name>", "\u672C\u6B21\u4F7F\u7528\u7684\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4F7F\u7528\u8BE5\u73AF\u5883\u7684\u76F4\u63A5\u767B\u5F55\u8EAB\u4EFD\uFF0C\u4E0D\u63A5\u53D7\u4EE3\u7406").option("-y, --yes", "\u786E\u8BA4\u91CD\u7F6E\u5DF2\u6838\u9A8C\u7684\u5F53\u524D\u79DF\u6237\uFF0C\u8DF3\u8FC7\u4EA4\u4E92").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "json").action((opts) => tenantResetCommand(opts));
15187
15297
  tenant.command("bootstrap").description("\u5F00\u901A\u65B0\u79DF\u6237\uFF08\u5EFA\u79DF\u6237 + admin \u7528\u6237 + \u7ED3\u6784 reconcile\uFF09\u2014\u2014\u4E0D\u53EF\u9006\uFF0C\u9ED8\u8BA4\u8FC7\u786E\u8BA4\u95F8").requiredOption("--tenant-id <id>", "\u79DF\u6237 ID").requiredOption("--admin-username <user>", "\u7BA1\u7406\u5458\u7528\u6237\u540D").option(
15188
15298
  "--admin-password <pwd>",
15189
15299
  "\u7BA1\u7406\u5458\u5BC6\u7801\uFF08\u4F1A\u6CC4\u6F0F\u5230 history/ps\uFF0C\u5EFA\u8BAE --admin-password-stdin\uFF09"