@hcmai/cli 0.21.7 → 0.21.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
@@ -3403,9 +3403,9 @@ async function loginCommand(args) {
3403
3403
  }
3404
3404
  const err = e;
3405
3405
  if (err.isAxiosError) {
3406
- const { fromAxiosError: fromAxiosError26 } = await import("@hcmai/sdk");
3406
+ const { fromAxiosError: fromAxiosError27 } = await import("@hcmai/sdk");
3407
3407
  exitWithError(
3408
- fromAxiosError26(
3408
+ fromAxiosError27(
3409
3409
  e,
3410
3410
  envName
3411
3411
  )
@@ -5698,7 +5698,7 @@ async function interactionsRespondCommand(action, interactionId, args) {
5698
5698
  // src/commands/download.ts
5699
5699
  init_auth_guard();
5700
5700
  init_exit();
5701
- import { downloadDocument } from "@hcmai/sdk";
5701
+ import { downloadDocument, fromAxiosError as fromAxiosError11 } from "@hcmai/sdk";
5702
5702
  import { HcmClient as HcmClient13 } from "@hcmai/sdk";
5703
5703
  async function downloadCommand(documentId, args) {
5704
5704
  try {
@@ -5710,8 +5710,12 @@ async function downloadCommand(documentId, args) {
5710
5710
  return;
5711
5711
  } catch (e) {
5712
5712
  const status = e?.response?.status;
5713
- if (status === 401 || status === 403) {
5713
+ if (status === 401) {
5714
5714
  exitWithError(new Error(`\u4E0B\u8F7D\u672A\u6388\u6743\uFF08${status}\uFF09\u2014\u2014\u8BF7 hcm login \u540E\u91CD\u8BD5`));
5715
+ } else if (status === 403) {
5716
+ const denied = fromAxiosError11(e, args.env);
5717
+ denied.message += "\uFF1B\u8BF7\u6838\u5BF9\u9644\u4EF6\u7684\u4E1A\u52A1\u5F52\u5C5E\u3001\u5B57\u6BB5\u6743\u9650\u548C\u7EC4\u7EC7\u8303\u56F4\uFF0C\u6743\u9650\u62D2\u7EDD\u65E0\u9700\u91CD\u590D\u767B\u5F55\u3002";
5718
+ exitWithError(denied);
5715
5719
  } else if (status === 404) {
5716
5720
  exitWithError(new Error("\u6587\u6863\u4E0D\u5B58\u5728\u6216\u5DF2\u6E05\u7406\uFF08404\uFF09\u2014\u2014\u6838\u5BF9 documentId"));
5717
5721
  } else {
@@ -5726,7 +5730,7 @@ init_exit();
5726
5730
  import {
5727
5731
  deleteDocument,
5728
5732
  HcmClient as HcmClient14,
5729
- fromAxiosError as fromAxiosError11,
5733
+ fromAxiosError as fromAxiosError12,
5730
5734
  formatObject as formatObject11
5731
5735
  } from "@hcmai/sdk";
5732
5736
  async function documentDeleteCommand(documentId, args) {
@@ -5737,7 +5741,7 @@ async function documentDeleteCommand(documentId, args) {
5737
5741
  process.exitCode = 0;
5738
5742
  } catch (e) {
5739
5743
  const err = e;
5740
- if (err?.isAxiosError) exitWithError(fromAxiosError11(err, args.env));
5744
+ if (err?.isAxiosError) exitWithError(fromAxiosError12(err, args.env));
5741
5745
  exitWithError(e);
5742
5746
  }
5743
5747
  }
@@ -5745,7 +5749,7 @@ async function documentDeleteCommand(documentId, args) {
5745
5749
  // src/commands/trace.ts
5746
5750
  init_exit();
5747
5751
  init_auth_guard();
5748
- import { HcmClient as HcmClient15, formatObject as formatObject12, formatRows as formatRows5, fromAxiosError as fromAxiosError12 } from "@hcmai/sdk";
5752
+ import { HcmClient as HcmClient15, formatObject as formatObject12, formatRows as formatRows5, fromAxiosError as fromAxiosError13 } from "@hcmai/sdk";
5749
5753
  function parsePositiveInt2(value, fallback, flag) {
5750
5754
  const n = Number(value ?? fallback);
5751
5755
  if (!Number.isInteger(n) || n <= 0) {
@@ -6202,7 +6206,7 @@ async function traceCommand(traceId, args) {
6202
6206
  } catch (e) {
6203
6207
  const err = e;
6204
6208
  if (err?.isAxiosError) {
6205
- exitWithError(fromAxiosError12(err, args.profile));
6209
+ exitWithError(fromAxiosError13(err, args.profile));
6206
6210
  }
6207
6211
  exitWithError(e);
6208
6212
  }
@@ -6214,7 +6218,7 @@ init_auth_guard();
6214
6218
  import {
6215
6219
  HcmClient as HcmClient16,
6216
6220
  formatObject as formatObject13,
6217
- fromAxiosError as fromAxiosError13,
6221
+ fromAxiosError as fromAxiosError14,
6218
6222
  getCacheStats,
6219
6223
  clearModelCache,
6220
6224
  clearMetaCache
@@ -6232,7 +6236,7 @@ function emit(result, args, human) {
6232
6236
  }
6233
6237
  function fail3(e, args) {
6234
6238
  const err = e;
6235
- if (err?.isAxiosError) exitWithError(fromAxiosError13(err, args.env));
6239
+ if (err?.isAxiosError) exitWithError(fromAxiosError14(err, args.env));
6236
6240
  exitWithError(e);
6237
6241
  process.exit(1);
6238
6242
  }
@@ -6272,7 +6276,7 @@ import { readFileSync as readFileSync3 } from "fs";
6272
6276
  import {
6273
6277
  HcmClient as HcmClient17,
6274
6278
  formatObject as formatObject14,
6275
- fromAxiosError as fromAxiosError14,
6279
+ fromAxiosError as fromAxiosError15,
6276
6280
  scriptDryRun,
6277
6281
  validateScriptManifest,
6278
6282
  queryScriptLogs,
@@ -6291,7 +6295,7 @@ function emit2(result, args, human) {
6291
6295
  }
6292
6296
  function fail4(e, args) {
6293
6297
  const err = e;
6294
- if (err?.isAxiosError) exitWithError(fromAxiosError14(err, args.env));
6298
+ if (err?.isAxiosError) exitWithError(fromAxiosError15(err, args.env));
6295
6299
  exitWithError(e);
6296
6300
  process.exit(1);
6297
6301
  }
@@ -6383,7 +6387,7 @@ init_auth_guard();
6383
6387
  import {
6384
6388
  HcmClient as HcmClient18,
6385
6389
  formatObject as formatObject15,
6386
- fromAxiosError as fromAxiosError15,
6390
+ fromAxiosError as fromAxiosError16,
6387
6391
  uploadDocument as uploadDocument2
6388
6392
  } from "@hcmai/sdk";
6389
6393
  var DEFAULT_UPLOAD_CATEGORY = "attachment";
@@ -6394,8 +6398,18 @@ async function uploadCommand(filePath, args) {
6394
6398
  const meta2 = await uploadDocument2(
6395
6399
  client3.raw(),
6396
6400
  filePath,
6397
- args.category ?? DEFAULT_UPLOAD_CATEGORY
6401
+ args.category ?? DEFAULT_UPLOAD_CATEGORY,
6402
+ args.model || args.originId || args.field ? { model: args.model ?? "", originId: args.originId ?? "", field: args.field ?? "", state: args.state } : void 0
6398
6403
  );
6404
+ if (meta2.bindingStatus === "PENDING_REFERENCE") {
6405
+ process.stderr.write("\u9644\u4EF6\u5DF2\u4E0A\u4F20\uFF0C\u5F52\u5C5E\u5F85\u4FDD\u5B58\uFF1A\u8BF7\u5C06 documentId \u4FDD\u5B58\u5230\u6307\u5B9A\u4E1A\u52A1\u5B57\u6BB5\uFF0C\u518D\u56DE\u8BFB Document.getByDocumentId \u786E\u8BA4 originId/field\u3002\u5DF2\u6709\u5B57\u6BB5\u5F15\u7528\u53EF\u8C03\u7528 Document.bindToField \u5E76\u63D0\u4F9B reason\u3002\n");
6406
+ }
6407
+ if (meta2.bindingStatus === "CREATOR_ONLY_MODEL_POLICY_UNDECLARED") {
6408
+ process.stderr.write("\u9644\u4EF6\u4ECD\u4EC5\u4E0A\u4F20\u4EBA\u53EF\u8BFB\uFF1A\u8BE5\u6A21\u578B\u672A\u58F0\u660E\u4E1A\u52A1\u9644\u4EF6\u6388\u6743\uFF0C\u8BF7\u4F7F\u7528\u4E1A\u52A1\u4E13\u7528\u4E0A\u4F20/\u5F52\u5C5E\u5165\u53E3\u3002\n");
6409
+ }
6410
+ if (meta2.bindingStatus === "UNBOUND_BACKEND_CONTRACT_UNAVAILABLE") {
6411
+ process.stderr.write("\u9644\u4EF6\u5DF2\u4E0A\u4F20\uFF0C\u4F46\u670D\u52A1\u7AEF\u672A\u786E\u8BA4\u4E1A\u52A1\u5F52\u5C5E\uFF1A\u8BF7\u66F4\u65B0\u540E\u7AEF\u540E\u56DE\u8BFB\u5F52\u5C5E\uFF0C\u4E0D\u80FD\u628A\u4E0A\u4F20\u6210\u529F\u89C6\u4E3A\u7ED1\u5B9A\u6210\u529F\u3002\n");
6412
+ }
6399
6413
  const fmt = args.output ?? "json";
6400
6414
  if (fmt !== "json") {
6401
6415
  process.stdout.write(
@@ -6414,7 +6428,7 @@ async function uploadCommand(filePath, args) {
6414
6428
  } else if (status === 413) {
6415
6429
  exitWithError(new Error("\u6587\u4EF6\u8D85\u51FA\u670D\u52A1\u7AEF\u5927\u5C0F\u4E0A\u9650\uFF08413\uFF09"));
6416
6430
  } else if (err?.isAxiosError) {
6417
- exitWithError(fromAxiosError15(err, args.env));
6431
+ exitWithError(fromAxiosError16(err, args.env));
6418
6432
  } else {
6419
6433
  exitWithError(e);
6420
6434
  }
@@ -6427,7 +6441,7 @@ init_auth_guard();
6427
6441
  import {
6428
6442
  HcmClient as HcmClient19,
6429
6443
  formatObject as formatObject16,
6430
- fromAxiosError as fromAxiosError16,
6444
+ fromAxiosError as fromAxiosError17,
6431
6445
  packDataPackage,
6432
6446
  installDataPackageArtifactAsync,
6433
6447
  waitForInstallRun,
@@ -6530,7 +6544,7 @@ async function datapackageInstallCommand(artifactPath, args) {
6530
6544
  if (err?.code === "ENOENT") {
6531
6545
  exitWithError(new Error(`\u5236\u54C1\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${artifactPath}`));
6532
6546
  } else if (err?.isAxiosError) {
6533
- exitWithError(fromAxiosError16(err, args.env));
6547
+ exitWithError(fromAxiosError17(err, args.env));
6534
6548
  } else {
6535
6549
  exitWithError(e);
6536
6550
  }
@@ -6562,7 +6576,7 @@ async function datapackageStatusCommand(runId, args) {
6562
6576
  return;
6563
6577
  } catch (e) {
6564
6578
  const err = e;
6565
- if (err?.isAxiosError) exitWithError(fromAxiosError16(err, args.env));
6579
+ if (err?.isAxiosError) exitWithError(fromAxiosError17(err, args.env));
6566
6580
  else exitWithError(e);
6567
6581
  }
6568
6582
  }
@@ -6604,7 +6618,7 @@ import {
6604
6618
  matchSkills,
6605
6619
  filterByStage,
6606
6620
  formatObject as formatObject19,
6607
- fromAxiosError as fromAxiosError17,
6621
+ fromAxiosError as fromAxiosError18,
6608
6622
  loadGlobalConfig as loadGlobalConfig6,
6609
6623
  discoverProjectEnv as discoverProjectEnv3,
6610
6624
  resolveEnvContext as resolveEnvContext5,
@@ -7580,7 +7594,7 @@ function fail6(e, args) {
7580
7594
  if (err?.response?.status === 404) {
7581
7595
  exitWithError(new Error("\u8BE5\u73AF\u5883\u6CA1\u6709\u8FD9\u4E2A\u6280\u80FD \u2014\u2014 \u8DD1 `hcm skills list` \u770B\u76EE\u5F55\uFF08\u6280\u80FD\u968F\u4EA7\u54C1\u7248\u672C\u8D70\uFF09"));
7582
7596
  }
7583
- if (err?.isAxiosError) exitWithError(fromAxiosError17(err, args.env));
7597
+ if (err?.isAxiosError) exitWithError(fromAxiosError18(err, args.env));
7584
7598
  exitWithError(e);
7585
7599
  process.exit(1);
7586
7600
  }
@@ -9220,7 +9234,7 @@ import {
9220
9234
  normalizeOrigin as normalizeOrigin4,
9221
9235
  createHttpClient as createHttpClient3,
9222
9236
  formatObject as formatObject20,
9223
- fromAxiosError as fromAxiosError18,
9237
+ fromAxiosError as fromAxiosError19,
9224
9238
  loadGlobalConfig as loadGlobalConfig7,
9225
9239
  resolveEnvContext as resolveEnvContext6,
9226
9240
  printResolvedEnvironment as printResolvedEnvironment5,
@@ -9290,7 +9304,7 @@ PostgreSQL \u6838\u9A8C=${receipt.pgVerified}\uFF1B\u6574\u4F53\u6838\u9A8C=${re
9290
9304
  } catch (error) {
9291
9305
  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");
9292
9306
  const e = error;
9293
- exitWithError(e?.isAxiosError ? fromAxiosError18(error, args.env) : error);
9307
+ exitWithError(e?.isAxiosError ? fromAxiosError19(error, args.env) : error);
9294
9308
  }
9295
9309
  }
9296
9310
  async function resolveBootstrapKey(args, stdinTaken) {
@@ -9420,7 +9434,7 @@ async function tenantBootstrapCommand(args) {
9420
9434
  if (err?.response?.status === 403) {
9421
9435
  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"));
9422
9436
  } else if (err?.isAxiosError) {
9423
- exitWithError(fromAxiosError18(err, args.env));
9437
+ exitWithError(fromAxiosError19(err, args.env));
9424
9438
  } else {
9425
9439
  exitWithError(e);
9426
9440
  }
@@ -9434,7 +9448,7 @@ import nodePath from "path";
9434
9448
  import {
9435
9449
  HcmClient as HcmClient21,
9436
9450
  formatObject as formatObject21,
9437
- fromAxiosError as fromAxiosError19,
9451
+ fromAxiosError as fromAxiosError20,
9438
9452
  listTenantMeta,
9439
9453
  getTenantMeta,
9440
9454
  saveTenantMeta,
@@ -9466,7 +9480,7 @@ function fail7(e, args, mode = "write") {
9466
9480
  new Error(formatMetaForbiddenMessage(mode))
9467
9481
  );
9468
9482
  }
9469
- if (err?.isAxiosError) exitWithError(fromAxiosError19(err, args.env));
9483
+ if (err?.isAxiosError) exitWithError(fromAxiosError20(err, args.env));
9470
9484
  exitWithError(e);
9471
9485
  process.exit(1);
9472
9486
  }
@@ -9790,14 +9804,14 @@ import {
9790
9804
  runMiniSmokeChecks,
9791
9805
  saveWorkspaceFileContent,
9792
9806
  validateMiniProject,
9793
- fromAxiosError as fromAxiosError21,
9807
+ fromAxiosError as fromAxiosError22,
9794
9808
  CliError as CliError25,
9795
9809
  CliErrorCode as CliErrorCode26
9796
9810
  } from "@hcmai/sdk";
9797
9811
 
9798
9812
  // src/commands/workspace-push-progress.ts
9799
9813
  import { isAxiosError } from "axios";
9800
- import { CliError as CliError24, CliErrorCode as CliErrorCode25, fromAxiosError as fromAxiosError20 } from "@hcmai/sdk";
9814
+ import { CliError as CliError24, CliErrorCode as CliErrorCode25, fromAxiosError as fromAxiosError21 } from "@hcmai/sdk";
9801
9815
  var PUSH_DEADLINE_MS = 3e5;
9802
9816
  var HEARTBEAT_MS = 1e4;
9803
9817
  async function withWorkspacePushProgress(run3, profile) {
@@ -9867,7 +9881,7 @@ async function withWorkspacePushProgress(run3, profile) {
9867
9881
  return await Promise.race([operation, deadline]);
9868
9882
  } catch (error) {
9869
9883
  if (!isAxiosError(error)) throw error;
9870
- const translated = fromAxiosError20(error, profile);
9884
+ const translated = fromAxiosError21(error, profile);
9871
9885
  throw new CliError24({
9872
9886
  code: translated.code,
9873
9887
  message: translated.message,
@@ -9974,14 +9988,7 @@ async function workspaceActiveCommand(args) {
9974
9988
  fallbackEnv: localContext?.profile
9975
9989
  });
9976
9990
  const client3 = HcmClient22.fromAuthContext(ctx);
9977
- const response = await client3.raw().get("/api/tenant-extension/dev-mode");
9978
- if (response.data?.success === false) {
9979
- throw new Error("\u5F00\u53D1\u6001\u72B6\u6001\u67E5\u8BE2\u5931\u8D25\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
9980
- }
9981
- const binding = unwrapWorkspaceActionPayload(response.data);
9982
- if (!binding || typeof binding.enabled !== "boolean" || binding.enabled && !optionalText(binding.workspaceKey)) {
9983
- throw new Error("\u5F00\u53D1\u6001\u67E5\u8BE2\u8FD4\u56DE\u65E0\u6548\u6570\u636E\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
9984
- }
9991
+ const binding = await readWorkspaceDevModeBinding(client3);
9985
9992
  const activeWorkspaceKey = binding.enabled ? optionalText(binding.workspaceKey) : null;
9986
9993
  const bindingUpdatedAt = typeof binding.updatedAt === "number" && Number.isFinite(binding.updatedAt) && binding.updatedAt > 0 && binding.updatedAt <= 864e13 ? binding.updatedAt : null;
9987
9994
  const view = {
@@ -10338,9 +10345,6 @@ async function workspaceValidateCommand(args) {
10338
10345
  exitWorkspaceError(e);
10339
10346
  }
10340
10347
  }
10341
- function isScriptPath(relativePath) {
10342
- return relativePath.startsWith("scripts/");
10343
- }
10344
10348
  async function workspacePushCommand(args) {
10345
10349
  try {
10346
10350
  await withWorkspacePushProgress(async (bindHttp, assertRunning) => {
@@ -10361,25 +10365,8 @@ async function workspacePushCommand(args) {
10361
10365
  await getActiveAuthContextFromCli(args, { fallbackEnv: context.profile })
10362
10366
  );
10363
10367
  bindHttp(client3.raw());
10364
- const activeWorkspaceKey = args.dryRun ? null : await probeActiveWorkspaceKey(client3);
10365
- if (!args.dryRun && context.workspaceKey && activeWorkspaceKey !== context.workspaceKey) {
10366
- const plan = await pushWorkspaceRawFiles({
10367
- http: client3.raw(),
10368
- rootDir,
10369
- context,
10370
- dryRun: true
10371
- });
10372
- const scriptOps = plan.operations.filter(
10373
- (op) => isScriptPath(op.remotePath ?? op.localPath)
10374
- );
10375
- if (scriptOps.length > 0) {
10376
- throw new Error(
10377
- `\u672C\u6B21\u4F1A\u5199 ${scriptOps.length} \u4E2A\u811A\u672C\uFF0C\u4F46\u5F53\u524D\u6FC0\u6D3B\u7684\u5F00\u53D1\u7A7A\u95F4\u662F ${activeWorkspaceKey ? `"${activeWorkspaceKey}"` : "\uFF08\u672A\u6FC0\u6D3B\uFF09"}\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${context.workspaceKey}"\u3002
10378
- \u670D\u52A1\u7AEF\u4F1A\u62D2\u7EDD\u5199\u811A\u672C\uFF0C\u800C\u975E\u811A\u672C\u6587\u4EF6\u5DF2\u7ECF\u5199\u8FDB\u53BB\u4E86 \u2014\u2014 \u90A3\u4F1A\u7559\u4E0B\u534A\u63A8\u9001\u72B6\u6001\u3002
10379
- \u4E0B\u4E00\u6B65\uFF1Ahcm workspace activate ${context.workspaceKey}
10380
- \u6D89\u53CA\u811A\u672C\uFF1A${scriptOps.map((op) => op.remotePath ?? op.localPath).join(", ")}`
10381
- );
10382
- }
10368
+ if (!args.dryRun) {
10369
+ requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey);
10383
10370
  }
10384
10371
  const rawResult = await pushWorkspaceRawFiles({
10385
10372
  http: client3.raw(),
@@ -10396,15 +10383,11 @@ async function workspacePushCommand(args) {
10396
10383
  });
10397
10384
  results.push({ app, result });
10398
10385
  }
10399
- const hint = activationHint(
10400
- activeWorkspaceKey ?? await probeActiveWorkspaceKey(client3),
10401
- context.workspaceKey ?? null
10402
- );
10403
10386
  assertRunning();
10404
10387
  writeWorkspacePushResult(rawResult, results, args.output ?? "table");
10405
- if (hint) process.stderr.write(`
10406
- ${hint}
10407
- `);
10388
+ if (!args.dryRun) {
10389
+ requireWorkspaceActivation(await probeActiveWorkspaceKey(client3), context.workspaceKey, true);
10390
+ }
10408
10391
  process.exitCode = rawResult.conflicts.length || results.some((item) => item.result.conflicts.length) ? 3 : 0;
10409
10392
  }, args.env ?? args.profile);
10410
10393
  return;
@@ -11378,7 +11361,7 @@ function formatStatusSummary(summary) {
11378
11361
  }
11379
11362
  function exitWorkspaceError(err, profile) {
11380
11363
  const maybeAxios = err;
11381
- const translated = maybeAxios?.isAxiosError ? fromAxiosError21(err, profile) : err;
11364
+ const translated = maybeAxios?.isAxiosError ? fromAxiosError22(err, profile) : err;
11382
11365
  if (translated instanceof CliError25 && translated.code === CliErrorCode26.AUTH_FAILED) {
11383
11366
  exitWithError(new CliError25({
11384
11367
  code: translated.code,
@@ -11391,28 +11374,28 @@ function exitWorkspaceError(err, profile) {
11391
11374
  }
11392
11375
  exitWithError(translated);
11393
11376
  }
11394
- async function probeActiveWorkspaceKey(client3) {
11395
- try {
11396
- const result = await client3.query("TenantExtensionWorkspace", {
11397
- filter: { devModeEnabled: true },
11398
- fields: ["workspaceKey", "devModeEnabled"],
11399
- limit: 1
11400
- });
11401
- return optionalText(result.rows[0]?.workspaceKey) ?? null;
11402
- } catch {
11403
- return null;
11404
- }
11405
- }
11406
- function activationHint(activeKey, localKey) {
11407
- if (localKey && activeKey === localKey) {
11408
- return null;
11377
+ async function readWorkspaceDevModeBinding(client3) {
11378
+ const response = await client3.raw().get("/api/tenant-extension/dev-mode");
11379
+ if (response.data?.success === false) {
11380
+ throw new Error("\u5F00\u53D1\u6001\u72B6\u6001\u67E5\u8BE2\u5931\u8D25\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
11409
11381
  }
11410
- if (!activeKey) {
11411
- return localKey ? `\u26A0\uFE0F \u5F53\u524D\u8EAB\u4EFD\u672A\u5F00\u542F\u5F00\u53D1\u7A7A\u95F4\u2014\u2014\u672C\u7A7A\u95F4\u7684\u5185\u5BB9\u5C1A\u672A\u751F\u6548\u3002
11412
- \u4E0B\u4E00\u6B65\uFF1Ahcm workspace activate ${localKey}` : "\u26A0\uFE0F \u5F53\u524D\u8EAB\u4EFD\u672A\u5F00\u542F\u5F00\u53D1\u7A7A\u95F4\u2014\u2014\u5F00\u53D1\u7A7A\u95F4\u91CC\u7684\u5185\u5BB9\u5C1A\u672A\u751F\u6548\u3002";
11382
+ const binding = unwrapWorkspaceActionPayload(response.data);
11383
+ if (!binding || typeof binding.enabled !== "boolean" || binding.enabled && !optionalText(binding.workspaceKey)) {
11384
+ throw new Error("\u5F00\u53D1\u6001\u67E5\u8BE2\u8FD4\u56DE\u65E0\u6548\u6570\u636E\uFF0C\u4E0D\u80FD\u5224\u65AD\u662F\u5426\u5DF2\u6FC0\u6D3B\uFF1B\u8BF7\u68C0\u67E5 /api/tenant-extension/dev-mode \u54CD\u5E94\u3002");
11413
11385
  }
11414
- return localKey ? `\u26A0\uFE0F \u5F53\u524D\u8EAB\u4EFD\u6FC0\u6D3B\u7684\u662F "${activeKey}"\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${localKey}"\u2014\u2014\u672C\u7A7A\u95F4\u7684\u5185\u5BB9\u5C1A\u672A\u751F\u6548\u3002
11415
- \u4E0B\u4E00\u6B65\uFF1Ahcm workspace activate ${localKey}` : `\u26A0\uFE0F \u5F53\u524D\u8EAB\u4EFD\u6FC0\u6D3B\u7684\u662F "${activeKey}"\u3002`;
11386
+ return binding;
11387
+ }
11388
+ async function probeActiveWorkspaceKey(client3) {
11389
+ const binding = await readWorkspaceDevModeBinding(client3);
11390
+ return binding.enabled ? optionalText(binding.workspaceKey) : null;
11391
+ }
11392
+ function requireWorkspaceActivation(activeKey, workspaceKey, afterPush = false) {
11393
+ if (activeKey === workspaceKey) return;
11394
+ throw new CliError25({
11395
+ code: CliErrorCode26.INVALID_ARGUMENT,
11396
+ message: (afterPush ? "\u63A8\u9001\u540E\u7ED1\u5B9A\u5DF2\u53D8\u5316\uFF0C\u6587\u4EF6\u53EF\u80FD\u5DF2\u4FDD\u5B58\u4E3A\u8349\u7A3F\uFF1B" : "") + (activeKey ? `\u5F53\u524D\u8EAB\u4EFD\u6FC0\u6D3B\u7684\u662F "${activeKey}"\uFF0C\u4E0D\u662F\u672C\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002` : `\u5F53\u524D\u8EAB\u4EFD\u672A\u6FC0\u6D3B\u5F00\u53D1\u7A7A\u95F4 "${workspaceKey}"\uFF1B\u672C\u7A7A\u95F4\u5185\u5BB9\u5C1A\u672A\u7528\u4E8E\u5F00\u53D1\u9884\u89C8\u3002`),
11397
+ context: { workspaceKey, activeWorkspaceKey: activeKey, nextStep: `hcm workspace activate ${workspaceKey}` }
11398
+ });
11416
11399
  }
11417
11400
  async function setDevModeBinding(client3, workspaceKey) {
11418
11401
  await client3.raw().put("/api/tenant-extension/dev-mode", {
@@ -11491,7 +11474,7 @@ import {
11491
11474
  CliErrorCode as CliErrorCode27,
11492
11475
  formatObject as formatObject23,
11493
11476
  formatRows as formatRows7,
11494
- fromAxiosError as fromAxiosError22,
11477
+ fromAxiosError as fromAxiosError23,
11495
11478
  loadEnv as loadEnv4,
11496
11479
  saveEnv as saveEnv3,
11497
11480
  loadIdentity as loadIdentity4,
@@ -11546,7 +11529,7 @@ async function identityShow(name, args) {
11546
11529
  const details = await inspectIdentity(name);
11547
11530
  return exitOk(formatObject23(details, { format: args.output ?? "json" }));
11548
11531
  } catch (e) {
11549
- exitWithError(axios4.isAxiosError(e) ? fromAxiosError22(e, name) : e);
11532
+ exitWithError(axios4.isAxiosError(e) ? fromAxiosError23(e, name) : e);
11550
11533
  }
11551
11534
  }
11552
11535
  async function identityList(args) {
@@ -18191,7 +18174,7 @@ import {
18191
18174
  ROUND_EXIT_CODES,
18192
18175
  computeReconSourceKey,
18193
18176
  formatObject as formatObject31,
18194
- fromAxiosError as fromAxiosError23,
18177
+ fromAxiosError as fromAxiosError24,
18195
18178
  httpProbe as httpProbe3,
18196
18179
  inspectRound,
18197
18180
  renderRound,
@@ -18213,7 +18196,7 @@ async function deliveryReconCommand(args) {
18213
18196
  process.stdout.write(formatObject31(summary, { format: args.output ?? "json" }) + "\n");
18214
18197
  } catch (e) {
18215
18198
  const err = e;
18216
- if (err?.isAxiosError) exitWithError(fromAxiosError23(err, args.env));
18199
+ if (err?.isAxiosError) exitWithError(fromAxiosError24(err, args.env));
18217
18200
  exitWithError(e);
18218
18201
  process.exit(1);
18219
18202
  }
@@ -19025,7 +19008,7 @@ import {
19025
19008
  HcmClient as HcmClient30,
19026
19009
  adminResetPassword,
19027
19010
  formatObject as formatObject32,
19028
- fromAxiosError as fromAxiosError24,
19011
+ fromAxiosError as fromAxiosError25,
19029
19012
  CliError as CliError37,
19030
19013
  CliErrorCode as CliErrorCode38
19031
19014
  } from "@hcmai/sdk";
@@ -19061,7 +19044,7 @@ async function userResetPasswordCommand(args) {
19061
19044
  process.stdout.write(formatObject32(result, { format: args.output ?? "json" }) + "\n");
19062
19045
  } catch (cause) {
19063
19046
  const err = cause;
19064
- if (err?.isAxiosError) exitWithError(fromAxiosError24(err, args.env));
19047
+ if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.env));
19065
19048
  exitWithError(cause);
19066
19049
  }
19067
19050
  }
@@ -19083,7 +19066,7 @@ init_auth_guard();
19083
19066
  import {
19084
19067
  HcmClient as HcmClient31,
19085
19068
  formatObject as formatObject33,
19086
- fromAxiosError as fromAxiosError25
19069
+ fromAxiosError as fromAxiosError26
19087
19070
  } from "@hcmai/sdk";
19088
19071
  async function modelsCommand(keyword, args) {
19089
19072
  try {
@@ -19120,7 +19103,7 @@ async function modelsCommand(keyword, args) {
19120
19103
  return;
19121
19104
  } catch (e) {
19122
19105
  const err = e;
19123
- if (err?.isAxiosError) exitWithError(fromAxiosError25(err, args.profile));
19106
+ if (err?.isAxiosError) exitWithError(fromAxiosError26(err, args.profile));
19124
19107
  exitWithError(e);
19125
19108
  }
19126
19109
  }
@@ -19388,7 +19371,7 @@ var cache = program.command("cache").description("\u6A21\u578B\u7F13\u5B58\u8FD0
19388
19371
  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));
19389
19372
  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));
19390
19373
  cache.command("clear-meta <Model>").description("\u6E05\u5143\u6570\u636E\u7F13\u5B58\uFF08Code \u7EA7 YAML + Action \u5B9A\u4E49\uFF09\u2014\u2014\u6539 meta YAML \u540E\u5FC5\u8DD1").option("--type <type>", "\u5143\u6570\u636E\u7C7B\u578B\uFF1Alist | info | view | filter | page\u2026\uFF08\u9ED8\u8BA4\u5168\u6E05\uFF09").option("--state <state>", "\u72B6\u6001\u53D8\u4F53\uFF08\u5982 self\uFF09\uFF0C\u914D\u5408 --type").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) => cacheClearMetaCommand(model, opts));
19391
- program.command("upload <file>").description("\u4E0A\u4F20\u672C\u5730\u6587\u4EF6\u5230 HCM \u6587\u6863\u670D\u52A1\uFF0C\u8FD4\u56DE documentId").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").option(
19374
+ program.command("upload <file>").description("\u4E0A\u4F20\u672C\u5730\u6587\u4EF6\u5230 HCM \u6587\u6863\u670D\u52A1\uFF0C\u8FD4\u56DE documentId").option("--model <name>", "\u4E1A\u52A1\u9644\u4EF6\u5F52\u5C5E\u6A21\u578B\uFF0C\u987B\u4E0E --origin-id/--field \u540C\u65F6\u63D0\u4F9B").option("--origin-id <uuid>", "\u771F\u5B9E\u4E1A\u52A1\u8BB0\u5F55 ID\uFF08\u5F52\u5C5E\u5728\u8BE5\u8BB0\u5F55\u5B57\u6BB5\u4FDD\u5B58\u5F15\u7528\u540E\u786E\u8BA4\uFF09").option("--field <key>", "\u670D\u52A1\u7AEF\u58F0\u660E\u7684\u9644\u4EF6\u5B57\u6BB5").option("--state <name>", "\u9644\u4EF6\u5B57\u6BB5\u6240\u5728\u4FE1\u606F\u9875\u72B6\u6001\uFF08\u7F3A\u7701 default\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").option(
19392
19375
  "--category <name>",
19393
19376
  "\u5B58\u50A8\u5206\u7C7B\uFF08\u987B\u662F\u76EE\u6807\u73AF\u5883\u91CC\u771F\u5B9E\u5B58\u5728\u7684\u5206\u7C7B\uFF0C\u5982 flex-report / template / attachment\uFF09",
19394
19377
  "attachment"