@heybox/hb-sdk 0.5.17 → 0.6.0

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.
Files changed (48) hide show
  1. package/README.md +46 -25
  2. package/dist/cli-chunks/{create-CPIjDM-n.cjs → create-DYb53EQ-.cjs} +1 -1
  3. package/dist/cli-chunks/{dev-Cr2u9ajy.cjs → dev-CPKTuA6q.cjs} +35 -6
  4. package/dist/cli-chunks/{doctor-mIgvLfLl.cjs → doctor-TshFvqHC.cjs} +1 -1
  5. package/dist/cli-chunks/{index-Dor8wa6R.cjs → index-CCeHouBU.cjs} +269 -17
  6. package/dist/cli-chunks/{index-DHWEoki_.cjs → index-NOO3q8_C.cjs} +3 -3
  7. package/dist/cli-chunks/{login-B63QgKed.cjs → login-DtXHSm8R.cjs} +2 -2
  8. package/dist/cli-chunks/remote-BWfn7qIN.cjs +9915 -0
  9. package/dist/cli-chunks/{context-mav2gs13.cjs → sdk-version-policy-B1CFC1Dk.cjs} +122 -1
  10. package/dist/cli-chunks/{session-BMSThs93.cjs → session-DIcRjyDY.cjs} +4 -54
  11. package/dist/cli.cjs +1 -1
  12. package/dist/devtools/mock-host/index.html +40 -0
  13. package/dist/devtools/mock-host/main.js +85 -0
  14. package/dist/index.cjs.js +232 -4
  15. package/dist/index.esm.js +233 -3
  16. package/dist/miniapp-publish.cjs.js +4 -0
  17. package/dist/miniapp-publish.esm.js +4 -1
  18. package/dist/protocol.cjs.js +9 -0
  19. package/dist/protocol.esm.js +7 -1
  20. package/dist/vite.cjs.js +9159 -22
  21. package/dist/vite.esm.js +9159 -23
  22. package/package.json +19 -7
  23. package/skill/SKILL.md +23 -23
  24. package/skill/references/api-protocol.md +11 -2
  25. package/skill/references/api-root.md +145 -19
  26. package/skill/references/cli.md +29 -14
  27. package/skill/references/recipes.md +12 -44
  28. package/skill/references/safety-boundaries.md +1 -2
  29. package/skill/scripts/sync-references.mjs +2 -2
  30. package/skill/skill.json +4 -4
  31. package/types/cli/auth/base-url.d.ts +20 -0
  32. package/types/cli/config.d.ts +11 -0
  33. package/types/core/client.d.ts +7 -0
  34. package/types/core/csp-violation.d.ts +5 -0
  35. package/types/core/history-observer.d.ts +4 -0
  36. package/types/core/version.d.ts +2 -0
  37. package/types/index.d.ts +0 -2
  38. package/types/miniapp-manifest/schema.d.ts +6 -1
  39. package/types/miniapp-manifest/sdk-version-policy.d.ts +9 -0
  40. package/types/miniapp-publish/index.d.ts +1 -0
  41. package/types/protocol/constants.d.ts +6 -0
  42. package/types/protocol/types.d.ts +45 -0
  43. package/types/protocol.d.ts +2 -2
  44. package/types/vite/html-policy.d.ts +4 -0
  45. package/types/vite/index.d.ts +23 -3
  46. package/types/vite/runtime-gate.d.ts +5 -0
  47. package/types/vite/sdk-version-gate.d.ts +8 -0
  48. package/dist/cli-chunks/remote-Dksa9s5M.cjs +0 -1603
@@ -234,19 +234,19 @@ function requireArgument () {
234
234
 
235
235
  var command = {};
236
236
 
237
- const require$5 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-Dor8wa6R.cjs', document.baseURI).href)));
237
+ const require$5 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
238
238
  function __require$4() { return require$5("node:events"); }
239
239
 
240
- const require$4 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-Dor8wa6R.cjs', document.baseURI).href)));
240
+ const require$4 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
241
241
  function __require$3() { return require$4("node:child_process"); }
242
242
 
243
- const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-Dor8wa6R.cjs', document.baseURI).href)));
243
+ const require$3 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
244
244
  function __require$2() { return require$3("node:path"); }
245
245
 
246
- const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-Dor8wa6R.cjs', document.baseURI).href)));
246
+ const require$2 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
247
247
  function __require$1() { return require$2("node:fs"); }
248
248
 
249
- const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-Dor8wa6R.cjs', document.baseURI).href)));
249
+ const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli-chunks/index-CCeHouBU.cjs', document.baseURI).href)));
250
250
  function __require() { return require$1("node:process"); }
251
251
 
252
252
  var help = {};
@@ -13095,8 +13095,235 @@ function readErrorMessage(error, options = {}) {
13095
13095
  return String(error);
13096
13096
  }
13097
13097
 
13098
+ /**
13099
+ * 极简 .env 文件解析器。
13100
+ *
13101
+ * 只支持 hb-sdk CLI 需要的最小语义:KEY=VALUE、空行、`#` 注释、单/双引号包裹值。
13102
+ * 不做变量插值,不展开 shell 转义,避免引入额外依赖。
13103
+ */
13104
+ /**
13105
+ * 解析 .env 文件内容为 key/value 记录,保持原始出现顺序的 key 列表。
13106
+ */
13107
+ function parseDotenvFile(content) {
13108
+ const entries = {};
13109
+ const keys = [];
13110
+ for (const rawLine of content.split(/\r?\n/)) {
13111
+ const line = stripInlineComment(rawLine).trim();
13112
+ if (!line || line.startsWith('#')) {
13113
+ continue;
13114
+ }
13115
+ const equalsIndex = line.indexOf('=');
13116
+ if (equalsIndex <= 0) {
13117
+ continue;
13118
+ }
13119
+ const key = line.slice(0, equalsIndex).trim();
13120
+ if (!isValidEnvKey(key)) {
13121
+ continue;
13122
+ }
13123
+ const rawValue = line.slice(equalsIndex + 1).trim();
13124
+ const value = unquoteDotenvValue(rawValue);
13125
+ if (!Object.prototype.hasOwnProperty.call(entries, key)) {
13126
+ keys.push(key);
13127
+ }
13128
+ entries[key] = value;
13129
+ }
13130
+ return { entries, keys };
13131
+ }
13132
+ function stripInlineComment(line) {
13133
+ // 仅处理未被引号包裹的行内注释,避免误伤值里的 #。
13134
+ let inSingle = false;
13135
+ let inDouble = false;
13136
+ for (let i = 0; i < line.length; i += 1) {
13137
+ const char = line[i];
13138
+ if (char === "'" && !inDouble) {
13139
+ inSingle = !inSingle;
13140
+ }
13141
+ else if (char === '"' && !inSingle) {
13142
+ inDouble = !inDouble;
13143
+ }
13144
+ else if (char === '#' && !inSingle && !inDouble) {
13145
+ return line.slice(0, i);
13146
+ }
13147
+ }
13148
+ return line;
13149
+ }
13150
+ function unquoteDotenvValue(value) {
13151
+ if (value.length >= 2) {
13152
+ const first = value[0];
13153
+ const last = value[value.length - 1];
13154
+ if (first === '"' && last === '"') {
13155
+ return value.slice(1, -1).replace(/\\(["\\$])/g, '$1');
13156
+ }
13157
+ if (first === "'" && last === "'") {
13158
+ return value.slice(1, -1);
13159
+ }
13160
+ }
13161
+ return value;
13162
+ }
13163
+ function isValidEnvKey(key) {
13164
+ return /^[A-Za-z_][A-Za-z0-9_]*$/.test(key);
13165
+ }
13166
+
13167
+ const DEFAULT_READ_FILE = (path) => fs$1.readFileSync(path, 'utf8');
13168
+ function resolveEnvPresetFilePath(argv, env = process.env, cwd = process.cwd()) {
13169
+ const explicit = readEnvFileArgFromArgv(argv);
13170
+ if (explicit) {
13171
+ return path.resolve(cwd, explicit);
13172
+ }
13173
+ const name = readEnvNameArgFromArgv(argv) ?? env.HB_SDK_ENV;
13174
+ if (name) {
13175
+ return path.resolve(cwd, `.env.${name}`);
13176
+ }
13177
+ return undefined;
13178
+ }
13179
+ function loadEnvPreset(argv, options = {}) {
13180
+ const targetEnv = options.env ?? process.env;
13181
+ const cwd = options.cwd ?? process.cwd();
13182
+ const readFile = options.readFile ?? DEFAULT_READ_FILE;
13183
+ const filePath = resolveEnvPresetFilePath(argv, targetEnv, cwd);
13184
+ if (!filePath) {
13185
+ return { filePath: undefined, appliedKeys: [], skippedKeys: [] };
13186
+ }
13187
+ let content;
13188
+ try {
13189
+ content = readFile(filePath);
13190
+ }
13191
+ catch {
13192
+ // 文件不存在或不可读时静默跳过,与 dotenv 默认行为一致。
13193
+ return { filePath, appliedKeys: [], skippedKeys: [] };
13194
+ }
13195
+ const { entries } = parseDotenvFile(content);
13196
+ const appliedKeys = [];
13197
+ const skippedKeys = [];
13198
+ for (const [key, value] of Object.entries(entries)) {
13199
+ if (targetEnv[key] !== undefined && targetEnv[key] !== '') {
13200
+ skippedKeys.push(key);
13201
+ continue;
13202
+ }
13203
+ targetEnv[key] = value;
13204
+ appliedKeys.push(key);
13205
+ }
13206
+ const explicitName = readEnvNameArgFromArgv(argv);
13207
+ if (explicitName) {
13208
+ targetEnv.HB_SDK_ENV = explicitName;
13209
+ if (!appliedKeys.includes('HB_SDK_ENV')) {
13210
+ appliedKeys.push('HB_SDK_ENV');
13211
+ }
13212
+ }
13213
+ return { filePath, appliedKeys, skippedKeys };
13214
+ }
13215
+ /**
13216
+ * 从 argv 中提取 `--env-file <path>` 的值。
13217
+ * 支持 `--env-file path`、`--env-file=path` 两种写法。
13218
+ */
13219
+ function readEnvFileArgFromArgv(argv) {
13220
+ for (let i = 0; i < argv.length; i += 1) {
13221
+ const arg = argv[i];
13222
+ if (arg === '--env-file') {
13223
+ return argv[i + 1];
13224
+ }
13225
+ if (arg?.startsWith('--env-file=')) {
13226
+ return arg.slice('--env-file='.length);
13227
+ }
13228
+ }
13229
+ return undefined;
13230
+ }
13231
+ /**
13232
+ * 从 argv 中提取 `--env <name>` 的值。
13233
+ * 支持 `--env name`、`--env=name` 两种写法。
13234
+ */
13235
+ function readEnvNameArgFromArgv(argv) {
13236
+ for (let i = 0; i < argv.length; i += 1) {
13237
+ const arg = argv[i];
13238
+ if (arg === '--env') {
13239
+ return argv[i + 1];
13240
+ }
13241
+ if (arg?.startsWith('--env=')) {
13242
+ return arg.slice('--env='.length);
13243
+ }
13244
+ }
13245
+ return undefined;
13246
+ }
13247
+
13248
+ const globalHeyboxCliRequestConfig = {};
13249
+ function configureHeyboxCliRequestConfig(config) {
13250
+ const normalized = normalizeHeyboxRylaiServiceTagConfig(config);
13251
+ if (normalized.default_tag) {
13252
+ globalHeyboxCliRequestConfig.default_tag = normalized.default_tag;
13253
+ }
13254
+ else {
13255
+ delete globalHeyboxCliRequestConfig.default_tag;
13256
+ }
13257
+ if (normalized.special_tag) {
13258
+ globalHeyboxCliRequestConfig.special_tag = normalized.special_tag;
13259
+ }
13260
+ else {
13261
+ delete globalHeyboxCliRequestConfig.special_tag;
13262
+ }
13263
+ }
13264
+ function readHeyboxCliRequestConfig() {
13265
+ return normalizeHeyboxRylaiServiceTagConfig(globalHeyboxCliRequestConfig);
13266
+ }
13267
+ /**
13268
+ * 当 tag 为非空字符串时,把它设为 CLI 全局 default_tag;为空时不改动现有配置,
13269
+ * 避免清掉 env 预设阶段已注入的值。
13270
+ */
13271
+ function applyServiceTagIfNeeded(tag) {
13272
+ const normalized = normalizeHeyboxRylaiServiceTag(tag);
13273
+ if (!normalized) {
13274
+ return;
13275
+ }
13276
+ configureHeyboxCliRequestConfig({ default_tag: normalized });
13277
+ }
13278
+ function resolveHeyboxRylaiServiceTag(pathWithQuery, config = readHeyboxCliRequestConfig()) {
13279
+ const normalized = normalizeHeyboxRylaiServiceTagConfig(config);
13280
+ const pathname = pathWithQuery ? getPathname(pathWithQuery) : '';
13281
+ const specialTag = normalized.special_tag;
13282
+ if (pathname && specialTag?.path_prefix_list.some((prefix) => pathname.startsWith(prefix))) {
13283
+ return specialTag.tag_name;
13284
+ }
13285
+ return normalized.default_tag;
13286
+ }
13287
+ function normalizeHeyboxRylaiServiceTagConfig(config) {
13288
+ const defaultTag = normalizeHeyboxRylaiServiceTag(config.default_tag);
13289
+ const specialTagName = normalizeHeyboxRylaiServiceTag(config.special_tag?.tag_name);
13290
+ const pathPrefixList = config.special_tag?.path_prefix_list?.filter(isValidPathPrefix) || [];
13291
+ return {
13292
+ ...(defaultTag ? { default_tag: defaultTag } : {}),
13293
+ ...(specialTagName && pathPrefixList.length
13294
+ ? {
13295
+ special_tag: {
13296
+ tag_name: specialTagName,
13297
+ path_prefix_list: pathPrefixList,
13298
+ },
13299
+ }
13300
+ : {}),
13301
+ };
13302
+ }
13303
+ function normalizeHeyboxRylaiServiceTag(value) {
13304
+ const tag = String(value ?? '').trim();
13305
+ if (!tag) {
13306
+ return undefined;
13307
+ }
13308
+ if (/[\r\n]/.test(tag)) {
13309
+ throw new Error('x-rylai-service-tag 不允许包含换行符');
13310
+ }
13311
+ return tag;
13312
+ }
13313
+ function isValidPathPrefix(value) {
13314
+ return typeof value === 'string' && value.startsWith('/') && !/[\r\n]/.test(value);
13315
+ }
13316
+ function getPathname(pathWithQuery) {
13317
+ try {
13318
+ return new URL(pathWithQuery, 'https://api.xiaoheihe.cn').pathname;
13319
+ }
13320
+ catch {
13321
+ return '';
13322
+ }
13323
+ }
13324
+
13098
13325
  const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
13099
- const BUILT_CLI_VERSION = '0.5.17';
13326
+ const BUILT_CLI_VERSION = '0.6.0';
13100
13327
  const PACKAGE_JSON_CANDIDATES = [
13101
13328
  path.resolve(__dirname, '..', '..', 'package.json'),
13102
13329
  path.resolve(__dirname, '..', 'package.json'),
@@ -13134,7 +13361,9 @@ async function runCli(options = {}) {
13134
13361
  const processLike = options.process ?? process;
13135
13362
  const argv = options.argv ?? process.argv;
13136
13363
  const verbose = hasVerboseArg(argv);
13364
+ const logger = resolveStandaloneLogger(options, verbose);
13137
13365
  try {
13366
+ preloadCliEnvPreset(argv, { logger });
13138
13367
  await createCliProgram(options).parseAsync(argv);
13139
13368
  }
13140
13369
  catch (error) {
@@ -13143,7 +13372,7 @@ async function runCli(options = {}) {
13143
13372
  return;
13144
13373
  }
13145
13374
  if (!(error instanceof CommanderError)) {
13146
- (options.printError ?? printError)(error, { logger: resolveStandaloneLogger(options, verbose), verbose });
13375
+ (options.printError ?? printError)(error, { logger, verbose });
13147
13376
  }
13148
13377
  processLike.exit(error instanceof CommanderError ? error.exitCode : 1);
13149
13378
  }
@@ -13167,6 +13396,8 @@ function createCliProgram(overrides = {}) {
13167
13396
  .description('hb-sdk developer tools')
13168
13397
  .version(getCliVersion())
13169
13398
  .option('-v, --verbose', '输出详细调试信息')
13399
+ .option('--env <name>', '加载项目根下 .env.<name> 预设,并将 deploy 构建的 Vite mode 设为 name')
13400
+ .option('--env-file <path>', '显式指定 .env 文件路径,优先级高于 --env')
13170
13401
  .showHelpAfterError()
13171
13402
  .exitOverride();
13172
13403
  installVersionUpdateReminder(program, handlers.printUpdateReminder, resolveLogger);
@@ -13222,7 +13453,8 @@ function addRemotePublicOptions(command) {
13222
13453
  .option('--json', '以 JSON 格式输出 remote 命令结果')
13223
13454
  .option('--api-base-url <url>', 'Heybox 后台 API origin,默认读取 HB_SDK_API_BASE_URL 或生产地址')
13224
13455
  .option('--login-base-url <url>', '校验 CLI 登录态使用的登录 origin,默认读取 HB_SDK_LOGIN_BASE_URL 或生产地址')
13225
- .option('--allow-unsafe-api-base-url', '允许向非 Heybox HTTPS API origin 发送登录态,仅限本地调试'));
13456
+ .option('--allow-unsafe-api-base-url', '允许向非 Heybox HTTPS API origin 发送登录态,仅限本地调试')
13457
+ .option('--service-tag <tag>', '给 Heybox 后台请求附加 x-rylai-service-tag,默认读取 HB_SDK_SERVICE_TAG'));
13226
13458
  }
13227
13459
  function installRemoteCommands(program, handlers, resolveLogger) {
13228
13460
  const remote = addRemotePublicOptions(program.command('remote').description('管理当前项目绑定的远程 Heybox 工坊小程序'));
@@ -13301,7 +13533,6 @@ function installRemoteCommands(program, handlers, resolveLogger) {
13301
13533
  addRemotePublicOptions(remote
13302
13534
  .command('deploy')
13303
13535
  .description('构建并提交当前小程序版本审核')
13304
- .option('--skip-build', '跳过 build,直接读 dist 目录上传并提交审核')
13305
13536
  .option('--from-version <version>', '复用指定历史版本产物提交审核')
13306
13537
  .option('--release-note <text>', '发布日志,提交审核必填')
13307
13538
  .option('--auto-publish', '审核通过后自动发布;默认需在 CLI 中手动发布')).action(createRemoteAction(handlers, resolveLogger, 'deploy', (command) => {
@@ -13310,7 +13541,6 @@ function installRemoteCommands(program, handlers, resolveLogger) {
13310
13541
  autoPublish: Boolean(options.autoPublish),
13311
13542
  fromVersion: readStringOption(options.fromVersion),
13312
13543
  releaseNote: readStringOption(options.releaseNote),
13313
- skipBuild: Boolean(options.skipBuild),
13314
13544
  };
13315
13545
  }));
13316
13546
  addRemotePublicOptions(remote.command('versions').description('列出当前绑定小程序的远程版本')).action(createRemoteAction(handlers, resolveLogger, 'versions'));
@@ -13359,6 +13589,7 @@ function readRemoteCommonOptions(command) {
13359
13589
  apiBaseUrl: readStringOption(options.apiBaseUrl),
13360
13590
  json: Boolean(options.json),
13361
13591
  loginBaseUrl: readStringOption(options.loginBaseUrl),
13592
+ serviceTag: readStringOption(options.serviceTag),
13362
13593
  verbose: Boolean(options.verbose),
13363
13594
  };
13364
13595
  }
@@ -13413,31 +13644,31 @@ function createCommandLoggerResolver(options) {
13413
13644
  };
13414
13645
  }
13415
13646
  const defaultClearLoginStatus = async (...args) => {
13416
- const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-B63QgKed.cjs'); });
13647
+ const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13417
13648
  return clearLoginStatus(...args);
13418
13649
  };
13419
13650
  const defaultLoginToHeybox = async (...args) => {
13420
- const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-B63QgKed.cjs'); });
13651
+ const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13421
13652
  return loginToHeybox(...args);
13422
13653
  };
13423
13654
  const defaultPrintLoginStatus = async (...args) => {
13424
- const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-B63QgKed.cjs'); });
13655
+ const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13425
13656
  return printLoginStatus(...args);
13426
13657
  };
13427
13658
  const defaultRunCreateCommand = async (...args) => {
13428
- const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-CPIjDM-n.cjs'); });
13659
+ const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-DYb53EQ-.cjs'); });
13429
13660
  return runCreateCommand(...args);
13430
13661
  };
13431
13662
  const defaultRunDevCommand = async (...args) => {
13432
- const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-Cr2u9ajy.cjs'); });
13663
+ const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-CPKTuA6q.cjs'); });
13433
13664
  return runDevCommand(...args);
13434
13665
  };
13435
13666
  const defaultRunDoctorCommand = async (...args) => {
13436
- const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-mIgvLfLl.cjs'); });
13667
+ const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-TshFvqHC.cjs'); });
13437
13668
  return runDoctorCommand(...args);
13438
13669
  };
13439
13670
  const defaultRunRemoteCommand = async (...args) => {
13440
- const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-Dksa9s5M.cjs'); });
13671
+ const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-BWfn7qIN.cjs'); });
13441
13672
  return runRemoteCommand(...args);
13442
13673
  };
13443
13674
  function resolveStandaloneLogger(options, verbose) {
@@ -13495,6 +13726,25 @@ function readCommandFromActionArgs(args) {
13495
13726
  const lastArg = args[args.length - 1];
13496
13727
  return lastArg instanceof Command ? lastArg : undefined;
13497
13728
  }
13729
+ /**
13730
+ * 在 commander 解析前加载 .env 预设,把其中的 HB_SDK_* 变量注入 process.env(不覆盖已有值),
13731
+ * 并把 HB_SDK_SERVICE_TAG 同步到 CLI 全局请求配置。
13732
+ * 这样后续 resolveHeyboxApiBaseUrl / resolveHeyboxLoginBaseUrl 读 process.env 时即可拿到预设值。
13733
+ */
13734
+ function preloadCliEnvPreset(argv, options = {}) {
13735
+ const result = loadEnvPreset(argv);
13736
+ if (!result.filePath) {
13737
+ return;
13738
+ }
13739
+ options.logger?.debug(`已加载 env 预设: ${result.filePath}`);
13740
+ if (result.appliedKeys.length) {
13741
+ options.logger?.debug(`env 预设生效: ${result.appliedKeys.join(', ')}`);
13742
+ }
13743
+ if (result.skippedKeys.length) {
13744
+ options.logger?.debug(`env 预设跳过(已有值): ${result.skippedKeys.join(', ')}`);
13745
+ }
13746
+ applyServiceTagIfNeeded(process.env.HB_SDK_SERVICE_TAG);
13747
+ }
13498
13748
  function parsePositivePort(value) {
13499
13749
  const parsed = Number(value);
13500
13750
  if (!Number.isInteger(parsed) || parsed <= 0) {
@@ -13516,6 +13766,7 @@ exports.HB_SDK_SKILL_INDEX_URL = HB_SDK_SKILL_INDEX_URL;
13516
13766
  exports.HB_SDK_SKILL_INSTALL_COMMAND = HB_SDK_SKILL_INSTALL_COMMAND;
13517
13767
  exports.HB_SDK_SKILL_NAME = HB_SDK_SKILL_NAME;
13518
13768
  exports.HB_SDK_SKILL_SOURCE = HB_SDK_SKILL_SOURCE;
13769
+ exports.applyServiceTagIfNeeded = applyServiceTagIfNeeded;
13519
13770
  exports.commonjsGlobal = commonjsGlobal;
13520
13771
  exports.createCliLogger = createCliLogger;
13521
13772
  exports.createCliProgram = createCliProgram;
@@ -13525,4 +13776,5 @@ exports.readErrorMessage = readErrorMessage;
13525
13776
  exports.requireEnvPaths = requireEnvPaths;
13526
13777
  exports.requireOnetime = requireOnetime;
13527
13778
  exports.requireSafeBuffer = requireSafeBuffer;
13779
+ exports.resolveHeyboxRylaiServiceTag = resolveHeyboxRylaiServiceTag;
13528
13780
  exports.runCli = runCli;
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var index$2 = require('./index-Dor8wa6R.cjs');
3
+ var index$2 = require('./index-CCeHouBU.cjs');
4
4
  var require$$0$2 = require('fs');
5
5
  var require$$2$1 = require('crypto');
6
6
  var require$$1$2 = require('path');
7
7
  var require$$0$3 = require('assert');
8
8
  var require$$4$2 = require('events');
9
9
  var require$$1$1 = require('util');
10
- var context$1 = require('./context-mav2gs13.cjs');
10
+ var sdkVersionPolicy = require('./sdk-version-policy-B1CFC1Dk.cjs');
11
11
  var require$$0$5 = require('net');
12
12
  var require$$0$4 = require('url');
13
13
  var require$$2$2 = require('http');
@@ -13707,7 +13707,7 @@ function requireSource () {
13707
13707
  const ajv_1 = requireAjv$1();
13708
13708
  const ajv_formats_1 = requireDist();
13709
13709
  const debounceFn = requireDebounceFn();
13710
- const semver = context$1.requireSemver();
13710
+ const semver = sdkVersionPolicy.requireSemver();
13711
13711
  const onetime = index$2.requireOnetime();
13712
13712
  const encryptionAlgorithm = 'aes-256-cbc';
13713
13713
  const createPlainObject = () => {
@@ -3,9 +3,9 @@
3
3
  var promises = require('node:readline/promises');
4
4
  var node_crypto = require('node:crypto');
5
5
  var node_http = require('node:http');
6
- var session = require('./session-BMSThs93.cjs');
6
+ var session = require('./session-DIcRjyDY.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
- var index = require('./index-Dor8wa6R.cjs');
8
+ var index = require('./index-CCeHouBU.cjs');
9
9
  require('node:path');
10
10
  require('fs');
11
11
  require('constants');