@heybox/hb-sdk 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -490,7 +490,7 @@ hb-sdk remote deploy --env test --service-tag other-tag --release-note "灰度"
490
490
 
491
491
  `--env <name>` 会读取项目根下的 `.env.<name>`,`--env-file <path>` 显式指定路径且优先级高于 `--env`;两者也可通过 `HB_SDK_ENV=<name>` 触发。加载遵循 dotenv 惯例:不覆盖进程已有的同名变量,因此 CI 或命令行显式设置的值优先。使用 `--env <name>` 或 `HB_SDK_ENV=<name>` 执行 `remote deploy` 时,CLI 还会把同一个 `name` 作为 `--mode <name>` 传给项目 build,使 CLI 后端环境与 Vite mode 保持一致。文件仅支持 `KEY=VALUE`、空行和 `#` 注释,不做变量插值;文件不存在时静默跳过。`--verbose` 会打印生效的文件路径和被跳过的 key。
492
492
 
493
- `--api-base-url` 优先于 `HB_SDK_API_BASE_URL`,影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`--login-base-url` 优先于 `HB_SDK_LOGIN_BASE_URL`,用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。`--service-tag <tag>` 优先于 `HB_SDK_SERVICE_TAG`,给 Heybox 后台请求附加 `x-rylai-service-tag` header,并复用命中的 tag 追加 `special_tag` 请求参数,用于开发环境路由或灰度验证。deploy 子构建会继承 `.env.<name>` 中的 `HB_SDK_SERVICE_TAG`,Vite 最低 SDK 版本门禁请求也会同时携带该 header 和 query;仓库内开发也可继续在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置 path-prefix 级 `special_tag`。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。`hb-sdk doctor`、npm latest 检查、mock host 的 `network.request()` 不受这些配置影响。
493
+ `--api-base-url` 优先于 `HB_SDK_API_BASE_URL`,影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`--login-base-url` 优先于 `HB_SDK_LOGIN_BASE_URL`,用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。`--service-tag <tag>` 优先于 `HB_SDK_SERVICE_TAG`,给 Heybox 后台请求附加 `x-rylai-service-tag` header,并复用命中的 tag 追加 `special_tag` 请求参数,用于开发环境路由或灰度验证。手动 Vite build 的最低 SDK 版本门禁请求会同时携带该 header 和 query;`remote deploy` 的子构建不执行客户端最低版本门禁。仓库内开发也可继续在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置 path-prefix 级 `special_tag`。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。`hb-sdk doctor`、npm latest 检查、mock host 的 `network.request()` 不受这些配置影响。
494
494
 
495
495
  ## hb-sdk remote 命令参考
496
496
 
@@ -548,7 +548,7 @@ CLI 登录态只供 CLI 命令访问黑盒接口时复用,不会注入 iframe
548
548
  ```json
549
549
  {
550
550
  "version": "1.2.3",
551
- "sdkVersion": "0.6.0"
551
+ "sdkVersion": "0.6.1"
552
552
  }
553
553
  ```
554
554
 
@@ -570,7 +570,7 @@ export default defineConfig({
570
570
 
571
571
  插件只接受单页应用:输出目录只能存在入口 `index.html`。build 会用结构化 HTML parser 校验入口,并把平台 CSP 插入 `<head>` 首位;已有 CSP 会原样保留,两份策略按浏览器交集生效。正式策略禁止 `fetch`、XHR、WebSocket、EventSource、Beacon、Worker、iframe、表单和对象加载等浏览器原生出口;业务网络请求应使用 `network.request()`。dev 使用相同策略,只额外放行当前 Vite 的精确 HMR WebSocket 地址。
572
572
 
573
- meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev`、build deploy 会读取 `/user_miniprogram/public/sdk_config` 的 `minimumSdkVersion`;最新请求失败时只回退当前 Remote Environment 下 24 小时内的有效缓存,无缓存则默认阻断并提示升级 `@heybox/hb-sdk@latest`。
573
+ meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev` 和手动 Vite build 会读取 `/user_miniprogram/public/sdk_config` 的 `minimumSdkVersion`;最新请求失败时只回退当前 Remote Environment 下 24 小时内的有效缓存,无缓存则默认阻断并提示升级 `@heybox/hb-sdk@latest`。`hb-sdk remote deploy`(包括 `--from-version`)不执行客户端最低版本查询或比较,但仍校验 Manifest 结构并经过服务端 precheck / submit-audit 策略。
574
574
 
575
575
  失败与警告语义:
576
576
 
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var session = require('./session-DIcRjyDY.cjs');
3
+ var session = require('./session-0XuUaVOO.cjs');
4
+ var index = require('./index-BnCDW-BB.cjs');
4
5
  var fs$1 = require('node:fs');
5
6
  var fs = require('node:fs/promises');
6
7
  var path = require('node:path');
7
- var index = require('./index-CCeHouBU.cjs');
8
8
 
9
9
  const APIUserMiniprogramPublicSdkConfigPath = '/user_miniprogram/public/sdk_config';
10
10
  function createUserMiniprogramPublicSdkConfigRequest(serviceTag) {
@@ -3214,91 +3214,6 @@ function isTruthyEnvFlag(value) {
3214
3214
  .toLowerCase());
3215
3215
  }
3216
3216
 
3217
- const CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1_000;
3218
- const CACHE_FILE_NAME = 'minimum-sdk-versions.json';
3219
- async function resolveMinimumSdkVersion(options) {
3220
- const now = options.now ?? Date.now();
3221
- const cachePath = path.join(options.cacheDir, CACHE_FILE_NAME);
3222
- const cache = await readCache(cachePath);
3223
- let minimumSdkVersion;
3224
- try {
3225
- minimumSdkVersion = validateStableSdkVersion(await options.fetchMinimumSdkVersion(), 'minimumSdkVersion');
3226
- }
3227
- catch {
3228
- const cached = cache.environments[options.environment];
3229
- const cacheAge = cached ? now - cached.fetchedAt : Number.NaN;
3230
- if (cached && Number.isFinite(cached.fetchedAt) && cacheAge >= 0 && cacheAge <= CACHE_MAX_AGE_MS) {
3231
- try {
3232
- return validateStableSdkVersion(cached.minimumSdkVersion, 'cached minimumSdkVersion');
3233
- }
3234
- catch {
3235
- // 非法缓存按不存在处理。
3236
- }
3237
- }
3238
- throw new Error('MINIMUM_SDK_VERSION_UNAVAILABLE:无法获取最低 SDK 版本,且没有 24 小时内的有效缓存');
3239
- }
3240
- cache.environments[options.environment] = { fetchedAt: now, minimumSdkVersion };
3241
- try {
3242
- await writeCache(cachePath, cache);
3243
- }
3244
- catch {
3245
- // 已校验的远端策略仍然可信;缓存只是离线回退优化。
3246
- }
3247
- return minimumSdkVersion;
3248
- }
3249
- function validateCurrentSdkVersion(currentSdkVersion, minimumSdkVersion, options) {
3250
- const current = validateSdkVersion(currentSdkVersion, '当前 SDK 版本');
3251
- const minimum = validateStableSdkVersion(minimumSdkVersion, 'minimumSdkVersion');
3252
- if (!options.allowPrerelease && semverExports.prerelease(current) !== null) {
3253
- throw new Error('正式发布不允许使用预发布 SDK,请运行 pnpm add @heybox/hb-sdk@latest 后重新构建');
3254
- }
3255
- if (!semverExports.satisfies(current, `>=${minimum}`, { includePrerelease: options.allowPrerelease })) {
3256
- throw new Error(`SDK_VERSION_TOO_LOW:当前 @heybox/hb-sdk@${current} 低于最低版本 ${minimum},请运行 pnpm add @heybox/hb-sdk@latest`);
3257
- }
3258
- return current;
3259
- }
3260
- function validateSdkVersion(value, label) {
3261
- const normalized = String(value).trim();
3262
- const parsed = semverExports.parse(normalized);
3263
- if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
3264
- throw new Error(`${label} 必须是合法 SemVer:${normalized}`);
3265
- }
3266
- return normalized;
3267
- }
3268
- function validateStableSdkVersion(value, label) {
3269
- const normalized = validateSdkVersion(value, label);
3270
- if (semverExports.prerelease(normalized) !== null)
3271
- throw new Error(`${label} 必须是稳定 SemVer:${normalized}`);
3272
- return normalized;
3273
- }
3274
- async function readCache(cachePath) {
3275
- try {
3276
- const parsed = JSON.parse(await fs.readFile(cachePath, 'utf8'));
3277
- if (parsed && typeof parsed === 'object' && parsed.environments && typeof parsed.environments === 'object')
3278
- return parsed;
3279
- }
3280
- catch {
3281
- // 缓存缺失或损坏时继续请求最新配置。
3282
- }
3283
- return { environments: {} };
3284
- }
3285
- async function writeCache(cachePath, cache) {
3286
- await fs.mkdir(path.dirname(cachePath), { recursive: true });
3287
- const temporaryPath = `${cachePath}.${process.pid}.tmp`;
3288
- await fs.writeFile(temporaryPath, `${JSON.stringify(cache, null, 2)}\n`, { mode: 0o600 });
3289
- await fs.rename(temporaryPath, cachePath);
3290
- }
3291
-
3292
- const paths = index.envPaths('hb-sdk');
3293
- async function enforceRemoteSdkVersion(options) {
3294
- const minimumSdkVersion = await resolveMinimumSdkVersion({
3295
- cacheDir: options.cacheDir ?? paths.cache,
3296
- environment: options.environment,
3297
- fetchMinimumSdkVersion: async () => (await getPublicSdkConfig({ baseUrl: options.environment, fetchImpl: options.fetchImpl })).minimum_sdk_version,
3298
- });
3299
- return validateCurrentSdkVersion(options.sdkVersion, minimumSdkVersion, { allowPrerelease: options.allowPrerelease });
3300
- }
3301
-
3302
3217
  exports.ACTIVITY_UPLOAD_KEY_MAX_LENGTH = ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
3303
3218
  exports.MINIAPP_UPLOAD_BATCH_SIZE = MINIAPP_UPLOAD_BATCH_SIZE;
3304
3219
  exports.MINIAPP_UPLOAD_SCOPE = MINIAPP_UPLOAD_SCOPE;
@@ -3306,9 +3221,9 @@ exports.MiniProgramProjectBindingError = MiniProgramProjectBindingError;
3306
3221
  exports.PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH = PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH;
3307
3222
  exports.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH = SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH;
3308
3223
  exports.createRemoteApiClientForEnvironment = createRemoteApiClientForEnvironment;
3309
- exports.enforceRemoteSdkVersion = enforceRemoteSdkVersion;
3310
3224
  exports.getBoundMiniProgram = getBoundMiniProgram;
3311
3225
  exports.getMiniappUploadKey = getMiniappUploadKey;
3226
+ exports.getPublicSdkConfig = getPublicSdkConfig;
3312
3227
  exports.normalizeRelativePath = normalizeRelativePath;
3313
3228
  exports.readBoundMiniProgramId = readBoundMiniProgramId;
3314
3229
  exports.readBoundMiniProgramIdFromPackageJson = readBoundMiniProgramIdFromPackageJson;
@@ -5,7 +5,7 @@ var fs = require('node:fs/promises');
5
5
  var path = require('node:path');
6
6
  var require$$0 = require('fs');
7
7
  var require$$1 = require('path');
8
- var index = require('./index-CCeHouBU.cjs');
8
+ var index = require('./index-BnCDW-BB.cjs');
9
9
  require('node:module');
10
10
  require('os');
11
11
  require('readline');
@@ -9,9 +9,9 @@ var node_url = require('node:url');
9
9
  var net = require('node:net');
10
10
  var node_http = require('node:http');
11
11
  var browser = require('./browser-RAy8e8cV.cjs');
12
- var index = require('./index-CCeHouBU.cjs');
13
- var sdkVersionPolicy = require('./sdk-version-policy-B1CFC1Dk.cjs');
14
- var session = require('./session-DIcRjyDY.cjs');
12
+ var index = require('./index-BnCDW-BB.cjs');
13
+ var context = require('./context-D0BowvGu.cjs');
14
+ var session = require('./session-0XuUaVOO.cjs');
15
15
  require('node:process');
16
16
  require('node:buffer');
17
17
  require('node:util');
@@ -666,10 +666,95 @@ function createHeyboxProtocol(payload) {
666
666
  return `heybox://${encodeURIComponent(JSON.stringify(payload))}`;
667
667
  }
668
668
 
669
+ const CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1_000;
670
+ const CACHE_FILE_NAME = 'minimum-sdk-versions.json';
671
+ async function resolveMinimumSdkVersion(options) {
672
+ const now = options.now ?? Date.now();
673
+ const cachePath = path.join(options.cacheDir, CACHE_FILE_NAME);
674
+ const cache = await readCache(cachePath);
675
+ let minimumSdkVersion;
676
+ try {
677
+ minimumSdkVersion = validateStableSdkVersion(await options.fetchMinimumSdkVersion(), 'minimumSdkVersion');
678
+ }
679
+ catch {
680
+ const cached = cache.environments[options.environment];
681
+ const cacheAge = cached ? now - cached.fetchedAt : Number.NaN;
682
+ if (cached && Number.isFinite(cached.fetchedAt) && cacheAge >= 0 && cacheAge <= CACHE_MAX_AGE_MS) {
683
+ try {
684
+ return validateStableSdkVersion(cached.minimumSdkVersion, 'cached minimumSdkVersion');
685
+ }
686
+ catch {
687
+ // 非法缓存按不存在处理。
688
+ }
689
+ }
690
+ throw new Error('MINIMUM_SDK_VERSION_UNAVAILABLE:无法获取最低 SDK 版本,且没有 24 小时内的有效缓存');
691
+ }
692
+ cache.environments[options.environment] = { fetchedAt: now, minimumSdkVersion };
693
+ try {
694
+ await writeCache(cachePath, cache);
695
+ }
696
+ catch {
697
+ // 已校验的远端策略仍然可信;缓存只是离线回退优化。
698
+ }
699
+ return minimumSdkVersion;
700
+ }
701
+ function validateCurrentSdkVersion(currentSdkVersion, minimumSdkVersion, options) {
702
+ const current = validateSdkVersion(currentSdkVersion, '当前 SDK 版本');
703
+ const minimum = validateStableSdkVersion(minimumSdkVersion, 'minimumSdkVersion');
704
+ if (!options.allowPrerelease && context.semverExports.prerelease(current) !== null) {
705
+ throw new Error('正式发布不允许使用预发布 SDK,请运行 pnpm add @heybox/hb-sdk@latest 后重新构建');
706
+ }
707
+ if (!context.semverExports.satisfies(current, `>=${minimum}`, { includePrerelease: options.allowPrerelease })) {
708
+ throw new Error(`SDK_VERSION_TOO_LOW:当前 @heybox/hb-sdk@${current} 低于最低版本 ${minimum},请运行 pnpm add @heybox/hb-sdk@latest`);
709
+ }
710
+ return current;
711
+ }
712
+ function validateSdkVersion(value, label) {
713
+ const normalized = String(value).trim();
714
+ const parsed = context.semverExports.parse(normalized);
715
+ if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
716
+ throw new Error(`${label} 必须是合法 SemVer:${normalized}`);
717
+ }
718
+ return normalized;
719
+ }
720
+ function validateStableSdkVersion(value, label) {
721
+ const normalized = validateSdkVersion(value, label);
722
+ if (context.semverExports.prerelease(normalized) !== null)
723
+ throw new Error(`${label} 必须是稳定 SemVer:${normalized}`);
724
+ return normalized;
725
+ }
726
+ async function readCache(cachePath) {
727
+ try {
728
+ const parsed = JSON.parse(await fs$1.readFile(cachePath, 'utf8'));
729
+ if (parsed && typeof parsed === 'object' && parsed.environments && typeof parsed.environments === 'object')
730
+ return parsed;
731
+ }
732
+ catch {
733
+ // 缓存缺失或损坏时继续请求最新配置。
734
+ }
735
+ return { environments: {} };
736
+ }
737
+ async function writeCache(cachePath, cache) {
738
+ await fs$1.mkdir(path.dirname(cachePath), { recursive: true });
739
+ const temporaryPath = `${cachePath}.${process.pid}.tmp`;
740
+ await fs$1.writeFile(temporaryPath, `${JSON.stringify(cache, null, 2)}\n`, { mode: 0o600 });
741
+ await fs$1.rename(temporaryPath, cachePath);
742
+ }
743
+
744
+ const paths = index.envPaths('hb-sdk');
745
+ async function enforceRemoteSdkVersion(options) {
746
+ const minimumSdkVersion = await resolveMinimumSdkVersion({
747
+ cacheDir: options.cacheDir ?? paths.cache,
748
+ environment: options.environment,
749
+ fetchMinimumSdkVersion: async () => (await context.getPublicSdkConfig({ baseUrl: options.environment, fetchImpl: options.fetchImpl })).minimum_sdk_version,
750
+ });
751
+ return validateCurrentSdkVersion(options.sdkVersion, minimumSdkVersion, { allowPrerelease: options.allowPrerelease });
752
+ }
753
+
669
754
  /** 构建时替换为当前发布包的实际版本。 */
670
755
  const HB_SDK_VERSION = typeof undefined === 'string'
671
756
  ? undefined
672
- : '0.6.0';
757
+ : '0.6.1';
673
758
 
674
759
  const DEFAULT_APP_PORT = 5173;
675
760
  const DEFAULT_MOCK_PORT = 5174;
@@ -682,7 +767,7 @@ async function runDevCommand(options, runtime = {}) {
682
767
  const logger = runtime.logger ?? index.createCliLogger();
683
768
  const fetchImpl = runtime.fetchImpl ?? fetch;
684
769
  const environment = session.resolveHeyboxApiBaseUrl({ env: runtime.env });
685
- await (runtime.enforceRemoteSdkVersion ?? sdkVersionPolicy.enforceRemoteSdkVersion)({
770
+ await (runtime.enforceRemoteSdkVersion ?? enforceRemoteSdkVersion)({
686
771
  sdkVersion: HB_SDK_VERSION,
687
772
  environment,
688
773
  fetchImpl,
@@ -771,14 +856,14 @@ async function runDevCommand(options, runtime = {}) {
771
856
  installShutdownHandlers(closers, runtime.process ?? process);
772
857
  }
773
858
  async function loadDevLaunchContext(options) {
774
- const miniProgramId = await sdkVersionPolicy.readBoundMiniProgramId(options.projectRoot);
859
+ const miniProgramId = await context.readBoundMiniProgramId(options.projectRoot);
775
860
  if (!miniProgramId) {
776
861
  const nativeAppLaunchUnavailableReason = '当前项目未绑定小程序。请先运行 hb-sdk remote create 或 hb-sdk remote bind <mini-program-id>。';
777
862
  options.logger.warn(`未读取到远端 Runtime 权限,Mock runtime 将默认拒绝受管能力:${nativeAppLaunchUnavailableReason}`);
778
863
  return { nativeAppLaunchUnavailableReason };
779
864
  }
780
865
  try {
781
- const { detail, miniProgramId: verifiedMiniProgramId } = await options.logger.task('正在读取远端小程序权限', () => sdkVersionPolicy.getBoundMiniProgram({
866
+ const { detail, miniProgramId: verifiedMiniProgramId } = await options.logger.task('正在读取远端小程序权限', () => context.getBoundMiniProgram({
782
867
  cwd: options.projectRoot,
783
868
  env: options.env,
784
869
  fetchImpl: options.fetchImpl,
@@ -796,7 +881,7 @@ async function loadDevLaunchContext(options) {
796
881
  }
797
882
  }
798
883
  function canFallbackToDefaultRuntimePermissions(error) {
799
- if (error instanceof sdkVersionPolicy.MiniProgramProjectBindingError) {
884
+ if (error instanceof context.MiniProgramProjectBindingError) {
800
885
  return error.code === 'MINI_PROGRAM_UNBOUND';
801
886
  }
802
887
  if (error instanceof TypeError && error.message === 'fetch failed') {
@@ -4,7 +4,7 @@ var fs$1 = require('node:fs');
4
4
  var fs = require('node:fs/promises');
5
5
  var os = require('node:os');
6
6
  var path = require('node:path');
7
- var index = require('./index-CCeHouBU.cjs');
7
+ var index = require('./index-BnCDW-BB.cjs');
8
8
  require('node:module');
9
9
  require('path');
10
10
  require('os');
@@ -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-CCeHouBU.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-BnCDW-BB.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-CCeHouBU.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-BnCDW-BB.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-CCeHouBU.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-BnCDW-BB.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-CCeHouBU.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-BnCDW-BB.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-CCeHouBU.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-BnCDW-BB.cjs', document.baseURI).href)));
250
250
  function __require() { return require$1("node:process"); }
251
251
 
252
252
  var help = {};
@@ -13323,7 +13323,7 @@ function getPathname(pathWithQuery) {
13323
13323
  }
13324
13324
 
13325
13325
  const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
13326
- const BUILT_CLI_VERSION = '0.6.0';
13326
+ const BUILT_CLI_VERSION = '0.6.1';
13327
13327
  const PACKAGE_JSON_CANDIDATES = [
13328
13328
  path.resolve(__dirname, '..', '..', 'package.json'),
13329
13329
  path.resolve(__dirname, '..', 'package.json'),
@@ -13644,31 +13644,31 @@ function createCommandLoggerResolver(options) {
13644
13644
  };
13645
13645
  }
13646
13646
  const defaultClearLoginStatus = async (...args) => {
13647
- const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13647
+ const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-BsyENL1d.cjs'); });
13648
13648
  return clearLoginStatus(...args);
13649
13649
  };
13650
13650
  const defaultLoginToHeybox = async (...args) => {
13651
- const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13651
+ const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-BsyENL1d.cjs'); });
13652
13652
  return loginToHeybox(...args);
13653
13653
  };
13654
13654
  const defaultPrintLoginStatus = async (...args) => {
13655
- const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-DtXHSm8R.cjs'); });
13655
+ const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-BsyENL1d.cjs'); });
13656
13656
  return printLoginStatus(...args);
13657
13657
  };
13658
13658
  const defaultRunCreateCommand = async (...args) => {
13659
- const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-DYb53EQ-.cjs'); });
13659
+ const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-C0afRvs9.cjs'); });
13660
13660
  return runCreateCommand(...args);
13661
13661
  };
13662
13662
  const defaultRunDevCommand = async (...args) => {
13663
- const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-CPKTuA6q.cjs'); });
13663
+ const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-CN307p_G.cjs'); });
13664
13664
  return runDevCommand(...args);
13665
13665
  };
13666
13666
  const defaultRunDoctorCommand = async (...args) => {
13667
- const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-TshFvqHC.cjs'); });
13667
+ const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-VW0nKg5q.cjs'); });
13668
13668
  return runDoctorCommand(...args);
13669
13669
  };
13670
13670
  const defaultRunRemoteCommand = async (...args) => {
13671
- const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-BWfn7qIN.cjs'); });
13671
+ const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-BSvvxvVv.cjs'); });
13672
13672
  return runRemoteCommand(...args);
13673
13673
  };
13674
13674
  function resolveStandaloneLogger(options, verbose) {
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var index$2 = require('./index-CCeHouBU.cjs');
3
+ var index$2 = require('./index-BnCDW-BB.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 sdkVersionPolicy = require('./sdk-version-policy-B1CFC1Dk.cjs');
10
+ var context$1 = require('./context-D0BowvGu.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 = sdkVersionPolicy.requireSemver();
13710
+ const semver = context$1.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-DIcRjyDY.cjs');
6
+ var session = require('./session-0XuUaVOO.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
- var index = require('./index-CCeHouBU.cjs');
8
+ var index = require('./index-BnCDW-BB.cjs');
9
9
  require('node:path');
10
10
  require('fs');
11
11
  require('constants');
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var promises = require('node:readline/promises');
4
- var index = require('./index-CCeHouBU.cjs');
5
- var session = require('./session-DIcRjyDY.cjs');
4
+ var index = require('./index-BnCDW-BB.cjs');
5
+ var session = require('./session-0XuUaVOO.cjs');
6
6
  var childProcess = require('node:child_process');
7
7
  var fs = require('node:fs');
8
8
  var fs$1 = require('node:fs/promises');
9
9
  var path = require('node:path');
10
- var sdkVersionPolicy = require('./sdk-version-policy-B1CFC1Dk.cjs');
10
+ var context = require('./context-D0BowvGu.cjs');
11
11
  require('node:module');
12
12
  require('path');
13
13
  require('os');
@@ -61,7 +61,7 @@ function validateSdkVersion(version, sourceLabel = 'sdkVersion') {
61
61
  throw new Error(`${sourceLabel} 必须是合法 SemVer:${String(version)}`);
62
62
  }
63
63
  const normalized = version.trim();
64
- const parsed = sdkVersionPolicy.semverExports.parse(normalized);
64
+ const parsed = context.semverExports.parse(normalized);
65
65
  if (!parsed || parsed.version !== normalized || parsed.build.length > 0) {
66
66
  throw new Error(`${sourceLabel} 必须是合法 SemVer:${normalized}`);
67
67
  }
@@ -75,7 +75,7 @@ function getMiniappManifestVersionError(version) {
75
75
  return `必须是合法 SemVer:${String(version)}`;
76
76
  }
77
77
  const normalized = version.trim();
78
- const parsed = sdkVersionPolicy.semverExports.parse(normalized);
78
+ const parsed = context.semverExports.parse(normalized);
79
79
  if (!parsed) {
80
80
  return `必须是合法 SemVer:${normalized}`;
81
81
  }
@@ -142,7 +142,7 @@ async function runUpload(options, runtime = {}) {
142
142
  const postCDNUploadCallback$1 = runtime.postCDNUploadCallback ?? postCDNUploadCallback;
143
143
  const createReadStream = runtime.createReadStream ?? fs.createReadStream;
144
144
  const orderedFiles = [...options.files].sort((a, b) => a.relativePath.localeCompare(b.relativePath));
145
- const batches = chunkUploadFiles(orderedFiles, sdkVersionPolicy.MINIAPP_UPLOAD_BATCH_SIZE);
145
+ const batches = chunkUploadFiles(orderedFiles, context.MINIAPP_UPLOAD_BATCH_SIZE);
146
146
  await logger.task(`正在上传 ${orderedFiles.length} 个文件`, async (taskContext) => {
147
147
  logger.debug(`上传并发数: ${concurrency}`);
148
148
  logger.debug(`上传批次数: ${batches.length}`);
@@ -152,7 +152,7 @@ async function runUpload(options, runtime = {}) {
152
152
  logger.debug(`正在处理上传批次 ${batchIndex + 1}/${batches.length},文件数: ${batch.length}`);
153
153
  logger.debug('正在获取 CDN 上传信息');
154
154
  const fileInfos = createUploadFileInfos(batch, options);
155
- const uploadInfo = await getCDNUploadInfo$1({ session: options.session, scope: sdkVersionPolicy.MINIAPP_UPLOAD_SCOPE, fileInfos, needCache: false }, { baseUrl: runtime.baseUrl, fetchImpl });
155
+ const uploadInfo = await getCDNUploadInfo$1({ session: options.session, scope: context.MINIAPP_UPLOAD_SCOPE, fileInfos, needCache: false }, { baseUrl: runtime.baseUrl, fetchImpl });
156
156
  logger.debug(`CDN bucket: ${uploadInfo.bucket}`);
157
157
  logger.debug(`CDN region: ${uploadInfo.region}`);
158
158
  validateUploadInfoKeys(batch, uploadInfo.keys, options);
@@ -213,7 +213,7 @@ function createUploadFileInfos(files, options) {
213
213
  name: file.relativePath.split('/').pop() ?? file.relativePath,
214
214
  mimetype: file.mimeType,
215
215
  fsize: file.size,
216
- path: sdkVersionPolicy.getMiniappUploadKey({
216
+ path: context.getMiniappUploadKey({
217
217
  miniProgramId: options.miniProgramId,
218
218
  version: options.version,
219
219
  relativePath: file.relativePath,
@@ -225,7 +225,7 @@ function validateUploadInfoKeys(files, keys, options) {
225
225
  throw new index.CliError(`CDN 上传接口返回 key 数量异常:期望 ${files.length},实际 ${keys.length}`);
226
226
  }
227
227
  for (let index$1 = 0; index$1 < files.length; index$1 += 1) {
228
- const expectedKey = sdkVersionPolicy.getMiniappUploadKey({
228
+ const expectedKey = context.getMiniappUploadKey({
229
229
  miniProgramId: options.miniProgramId,
230
230
  version: options.version,
231
231
  relativePath: files[index$1].relativePath,
@@ -264,7 +264,7 @@ async function createDefaultCosClient(uploadToken) {
264
264
  };
265
265
  }
266
266
  async function loadCosConstructor() {
267
- const cosModule = await Promise.resolve().then(function () { return require('./index-NOO3q8_C.cjs'); }).then(function (n) { return n.index; });
267
+ const cosModule = await Promise.resolve().then(function () { return require('./index-DcZLSI_y.cjs'); }).then(function (n) { return n.index; });
268
268
  return cosModule.default;
269
269
  }
270
270
  function formatSize(bytes) {
@@ -308,7 +308,7 @@ function isRecord(value) {
308
308
  }
309
309
 
310
310
  async function precheckUserMiniprogramVersion(options, runtime = {}) {
311
- return postUserMiniprogramVersionForm(sdkVersionPolicy.PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, options, {
311
+ return postUserMiniprogramVersionForm(context.PRECHECK_USER_MINIPROGRAM_VERSION_API_PATH, options, {
312
312
  name: options.name,
313
313
  icon_url: options.iconUrl,
314
314
  cover_image_urls: options.coverImageUrls.join(','),
@@ -319,7 +319,7 @@ async function precheckUserMiniprogramVersion(options, runtime = {}) {
319
319
  }, runtime);
320
320
  }
321
321
  async function submitUserMiniprogramAudit(options, runtime = {}) {
322
- return postUserMiniprogramVersionForm(sdkVersionPolicy.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, options, {
322
+ return postUserMiniprogramVersionForm(context.SUBMIT_USER_MINIPROGRAM_AUDIT_API_PATH, options, {
323
323
  name: options.name,
324
324
  icon_url: options.iconUrl,
325
325
  cover_image_urls: options.coverImageUrls.join(','),
@@ -8691,12 +8691,6 @@ async function runDeployCommand(options, runtime = {}) {
8691
8691
  if (!sourceSdkVersion) {
8692
8692
  throw new Error('历史产物缺少 sdkVersion,无法复用,请重新构建并上传新版本');
8693
8693
  }
8694
- await (runtime.enforceRemoteSdkVersion ?? sdkVersionPolicy.enforceRemoteSdkVersion)({
8695
- sdkVersion: sourceSdkVersion,
8696
- environment: apiBaseUrl,
8697
- fetchImpl: runtime.fetchImpl,
8698
- allowPrerelease: false,
8699
- });
8700
8694
  precheckVersion = precheck.version || precheck.version_normalized || fromVersion;
8701
8695
  }
8702
8696
  else {
@@ -8716,6 +8710,7 @@ async function runDeployCommand(options, runtime = {}) {
8716
8710
  const buildMode = env.HB_SDK_ENV?.trim();
8717
8711
  logger.info(`开始构建: ${pm} ${createBuildArgs(pm, buildMode).join(' ')}`);
8718
8712
  await runBuildScript(pm, projectRoot, runtime.spawn ?? childProcess.spawn, {
8713
+ env,
8719
8714
  mode: buildMode,
8720
8715
  outputMode: options.buildOutputMode ?? 'inherit',
8721
8716
  stderr: runtime.stderr,
@@ -8729,27 +8724,21 @@ async function runDeployCommand(options, runtime = {}) {
8729
8724
  const distDir = path.join(projectRoot, 'dist');
8730
8725
  parsedManifest ??= await readDeployManifest(projectRoot, logger);
8731
8726
  ({ manifest, version } = parsedManifest);
8732
- await (runtime.enforceRemoteSdkVersion ?? sdkVersionPolicy.enforceRemoteSdkVersion)({
8733
- sdkVersion: parsedManifest.sdkVersion,
8734
- environment: apiBaseUrl,
8735
- fetchImpl: runtime.fetchImpl,
8736
- allowPrerelease: false,
8737
- });
8738
8727
  if (version !== precheckVersion) {
8739
8728
  throw new Error(`dist/manifest.json.version (${version}) 与预检版本 (${precheckVersion}) 不一致,请重新 build 后再 deploy`);
8740
8729
  }
8741
8730
  const uploadFiles = await logger.task('正在校验 dist 上传文件', async () => {
8742
8731
  const allFiles = await walkDistFiles(distDir);
8743
- const blocked = allFiles.find((entry) => sdkVersionPolicy.relativePathContainsNodeModulesSegment(entry.relativePath));
8732
+ const blocked = allFiles.find((entry) => context.relativePathContainsNodeModulesSegment(entry.relativePath));
8744
8733
  if (blocked) {
8745
8734
  throw new Error(`dist 目录含 node_modules:${blocked.relativePath}`);
8746
8735
  }
8747
- const files = allFiles.filter((entry) => sdkVersionPolicy.shouldUploadDistFile(entry.relativePath));
8748
- const pathError = sdkVersionPolicy.validateUploadPaths(files, { miniProgramId, version, maxLength: sdkVersionPolicy.ACTIVITY_UPLOAD_KEY_MAX_LENGTH });
8736
+ const files = allFiles.filter((entry) => context.shouldUploadDistFile(entry.relativePath));
8737
+ const pathError = context.validateUploadPaths(files, { miniProgramId, version, maxLength: context.ACTIVITY_UPLOAD_KEY_MAX_LENGTH });
8749
8738
  if (pathError) {
8750
8739
  throw new Error(pathError);
8751
8740
  }
8752
- const sizeError = sdkVersionPolicy.validateUploadTotalSize(files);
8741
+ const sizeError = context.validateUploadTotalSize(files);
8753
8742
  if (sizeError) {
8754
8743
  throw new Error(sizeError);
8755
8744
  }
@@ -8950,6 +8939,7 @@ async function runBuildScript(pm, cwd, spawnImpl, options) {
8950
8939
  const buildArgs = createBuildArgs(pm, options.mode);
8951
8940
  const child = spawnImpl(pm, buildArgs, {
8952
8941
  cwd,
8942
+ env: { ...process.env, ...options.env, HB_SDK_DEPLOY_BUILD: '1' },
8953
8943
  stdio: pipeStdoutToStderr ? ['inherit', 'pipe', 'inherit'] : 'inherit',
8954
8944
  });
8955
8945
  if (pipeStdoutToStderr) {
@@ -8993,7 +8983,7 @@ async function walkDistFiles(distDir) {
8993
8983
  }
8994
8984
  const fileStat = await fs$1.stat(absPath);
8995
8985
  results.push({
8996
- relativePath: sdkVersionPolicy.normalizeRelativePath(relPath),
8986
+ relativePath: context.normalizeRelativePath(relPath),
8997
8987
  absolutePath: absPath,
8998
8988
  size: fileStat.size,
8999
8989
  mimeType: inferMimeType(entry.name),
@@ -9152,7 +9142,7 @@ async function runRemoteDeployCommand(options, runtime) {
9152
9142
  async function createRemoteCommandContext(options, runtime) {
9153
9143
  index.applyServiceTagIfNeeded(options.serviceTag);
9154
9144
  const logger = resolveRemoteLogger(options, runtime);
9155
- const environment = await sdkVersionPolicy.resolveRemoteEnvironment({
9145
+ const environment = await context.resolveRemoteEnvironment({
9156
9146
  allowUnsafeApiBaseUrl: options.allowUnsafeApiBaseUrl,
9157
9147
  apiBaseUrl: options.apiBaseUrl,
9158
9148
  env: options.env,
@@ -9162,10 +9152,10 @@ async function createRemoteCommandContext(options, runtime) {
9162
9152
  fetchImpl: runtime.fetchImpl,
9163
9153
  requireAuthSession: runtime.requireAuthSession,
9164
9154
  });
9165
- const packageJson = await sdkVersionPolicy.readMiniProgramProjectPackage(runtime.cwd ?? process.cwd());
9166
- const binding = sdkVersionPolicy.readBoundMiniProgramIdFromPackageJson(packageJson.packageJson);
9155
+ const packageJson = await context.readMiniProgramProjectPackage(runtime.cwd ?? process.cwd());
9156
+ const binding = context.readBoundMiniProgramIdFromPackageJson(packageJson.packageJson);
9167
9157
  const api = {
9168
- ...adaptRemoteApiClient(sdkVersionPolicy.createRemoteApiClientForEnvironment(environment)),
9158
+ ...adaptRemoteApiClient(context.createRemoteApiClientForEnvironment(environment)),
9169
9159
  ...runtime.api,
9170
9160
  };
9171
9161
  logger.debug(`Heybox API: ${environment.apiBaseUrl}`);
@@ -9306,39 +9296,39 @@ async function remoteList(options, context, runtime) {
9306
9296
  }
9307
9297
  return finishRemoteCommand(options, runtime, output);
9308
9298
  }
9309
- async function remoteCreate(options, context, runtime) {
9310
- if (context.binding && !options.forceBind) {
9311
- throw new Error(`当前项目已绑定 ${context.binding};如需覆盖,请使用 --force-bind`);
9299
+ async function remoteCreate(options, context$1, runtime) {
9300
+ if (context$1.binding && !options.forceBind) {
9301
+ throw new Error(`当前项目已绑定 ${context$1.binding};如需覆盖,请使用 --force-bind`);
9312
9302
  }
9313
- const access = await context.api.accessStatus();
9303
+ const access = await context$1.api.accessStatus();
9314
9304
  if (access.status !== 'approved') {
9315
9305
  throw new Error(`当前 CLI 用户没有创建工坊小程序权限:${String(access.status ?? 'unknown')}`);
9316
9306
  }
9317
- await confirmCreateWithCurrentEntity(options, context, runtime);
9318
- const result = await context.api.createMiniProgram();
9307
+ await confirmCreateWithCurrentEntity(options, context$1, runtime);
9308
+ const result = await context$1.api.createMiniProgram();
9319
9309
  const miniProgramId = requireMiniProgramId(result);
9320
- await sdkVersionPolicy.writeBoundMiniProgramId(context.packageJson.projectRoot, miniProgramId, { force: options.forceBind });
9310
+ await context.writeBoundMiniProgramId(context$1.packageJson.projectRoot, miniProgramId, { force: options.forceBind });
9321
9311
  const output = { changed: true, miniProgramId, remote: toCamelCaseDeep(result) };
9322
9312
  if (!options.json) {
9323
- context.logger.success(`创建并绑定成功:${miniProgramId}`);
9313
+ context$1.logger.success(`创建并绑定成功:${miniProgramId}`);
9324
9314
  }
9325
9315
  return finishRemoteCommand(options, runtime, output);
9326
9316
  }
9327
- async function remoteBind(options, context, runtime) {
9317
+ async function remoteBind(options, context$1, runtime) {
9328
9318
  const miniProgramId = requireNonEmpty(options.miniProgramId, 'remote bind 必须传 <mini-program-id>');
9329
- if (context.binding && context.binding !== miniProgramId && !options.force) {
9330
- throw new Error(`当前项目已绑定 ${context.binding};如需覆盖本地绑定,请使用 --force`);
9319
+ if (context$1.binding && context$1.binding !== miniProgramId && !options.force) {
9320
+ throw new Error(`当前项目已绑定 ${context$1.binding};如需覆盖本地绑定,请使用 --force`);
9331
9321
  }
9332
- const detail = await context.api.getMiniProgramDetail(miniProgramId);
9322
+ const detail = await context$1.api.getMiniProgramDetail(miniProgramId);
9333
9323
  const verifiedId = requireMiniProgramId(detail);
9334
- await assertMiniProgramEntityMatchesCurrent(context, detail);
9335
- const changed = context.binding !== verifiedId;
9324
+ await assertMiniProgramEntityMatchesCurrent(context$1, detail);
9325
+ const changed = context$1.binding !== verifiedId;
9336
9326
  if (changed) {
9337
- await sdkVersionPolicy.writeBoundMiniProgramId(context.packageJson.projectRoot, verifiedId, { force: options.force });
9327
+ await context.writeBoundMiniProgramId(context$1.packageJson.projectRoot, verifiedId, { force: options.force });
9338
9328
  }
9339
9329
  const output = { changed, miniProgramId: verifiedId, remote: toCamelCaseDeep(detail) };
9340
9330
  if (!options.json) {
9341
- context.logger.success(changed ? `绑定成功:${verifiedId}` : `已绑定:${verifiedId}`);
9331
+ context$1.logger.success(changed ? `绑定成功:${verifiedId}` : `已绑定:${verifiedId}`);
9342
9332
  }
9343
9333
  return finishRemoteCommand(options, runtime, output);
9344
9334
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CCeHouBU.cjs');
3
+ var index = require('./index-BnCDW-BB.cjs');
4
4
  var node_crypto = require('node:crypto');
5
5
  var path = require('node:path');
6
6
  var require$$0$2 = require('fs');
package/dist/cli.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./cli-chunks/index-CCeHouBU.cjs');
3
+ var index = require('./cli-chunks/index-BnCDW-BB.cjs');
4
4
  require('node:module');
5
5
  require('node:fs');
6
6
  require('node:fs/promises');
package/dist/index.cjs.js CHANGED
@@ -325,7 +325,7 @@ function createMessageId() {
325
325
  /** 构建时替换为当前发布包的实际版本。 */
326
326
  const HB_SDK_VERSION = typeof undefined === 'string'
327
327
  ? undefined
328
- : '0.6.0';
328
+ : '0.6.1';
329
329
 
330
330
  /**
331
331
  * 判断未知数据是否符合小程序 bridge 消息信封。
package/dist/index.esm.js CHANGED
@@ -321,7 +321,7 @@ function createMessageId() {
321
321
  /** 构建时替换为当前发布包的实际版本。 */
322
322
  const HB_SDK_VERSION = typeof undefined === 'string'
323
323
  ? undefined
324
- : '0.6.0';
324
+ : '0.6.1';
325
325
 
326
326
  /**
327
327
  * 判断未知数据是否符合小程序 bridge 消息信封。
package/dist/vite.cjs.js CHANGED
@@ -10,7 +10,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
10
10
  /** 构建时替换为当前发布包的实际版本。 */
11
11
  const HB_SDK_VERSION = typeof undefined === 'string'
12
12
  ? undefined
13
- : '0.6.0';
13
+ : '0.6.1';
14
14
 
15
15
  function getDefaultExportFromCjs (x) {
16
16
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -11933,7 +11933,7 @@ function miniappManifest(options = {}) {
11933
11933
  hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
11934
11934
  },
11935
11935
  async buildStart() {
11936
- if (command !== 'build')
11936
+ if (command !== 'build' || process.env.HB_SDK_DEPLOY_BUILD === '1')
11937
11937
  return;
11938
11938
  try {
11939
11939
  await (options.enforceSdkVersion ?? enforceViteSdkVersion)({
@@ -11966,10 +11966,10 @@ function miniappManifest(options = {}) {
11966
11966
  const sdkVersion = resolveSdkVersion();
11967
11967
  const outputRoot = path.resolve(root, outDir);
11968
11968
  const htmlFiles = collectHtmlFiles(outputRoot);
11969
- const unexpectedHtmlFiles = htmlFiles.filter(file => path.relative(outputRoot, file) !== 'index.html');
11969
+ const unexpectedHtmlFiles = htmlFiles.filter((file) => path.relative(outputRoot, file) !== 'index.html');
11970
11970
  if (unexpectedHtmlFiles.length > 0) {
11971
11971
  throw new Error(`工坊小程序只支持单页应用,构建产物不允许额外 HTML:${unexpectedHtmlFiles
11972
- .map(file => path.relative(outputRoot, file).split(path.sep).join('/'))
11972
+ .map((file) => path.relative(outputRoot, file).split(path.sep).join('/'))
11973
11973
  .join(', ')}`);
11974
11974
  }
11975
11975
  const indexHtmlPath = path.join(outputRoot, 'index.html');
package/dist/vite.esm.js CHANGED
@@ -7,7 +7,7 @@ import { readFile, mkdir, writeFile, rename } from 'node:fs/promises';
7
7
  /** 构建时替换为当前发布包的实际版本。 */
8
8
  const HB_SDK_VERSION = typeof undefined === 'string'
9
9
  ? undefined
10
- : '0.6.0';
10
+ : '0.6.1';
11
11
 
12
12
  function getDefaultExportFromCjs (x) {
13
13
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -11930,7 +11930,7 @@ function miniappManifest(options = {}) {
11930
11930
  hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
11931
11931
  },
11932
11932
  async buildStart() {
11933
- if (command !== 'build')
11933
+ if (command !== 'build' || process.env.HB_SDK_DEPLOY_BUILD === '1')
11934
11934
  return;
11935
11935
  try {
11936
11936
  await (options.enforceSdkVersion ?? enforceViteSdkVersion)({
@@ -11963,10 +11963,10 @@ function miniappManifest(options = {}) {
11963
11963
  const sdkVersion = resolveSdkVersion();
11964
11964
  const outputRoot = path.resolve(root, outDir);
11965
11965
  const htmlFiles = collectHtmlFiles(outputRoot);
11966
- const unexpectedHtmlFiles = htmlFiles.filter(file => path.relative(outputRoot, file) !== 'index.html');
11966
+ const unexpectedHtmlFiles = htmlFiles.filter((file) => path.relative(outputRoot, file) !== 'index.html');
11967
11967
  if (unexpectedHtmlFiles.length > 0) {
11968
11968
  throw new Error(`工坊小程序只支持单页应用,构建产物不允许额外 HTML:${unexpectedHtmlFiles
11969
- .map(file => path.relative(outputRoot, file).split(path.sep).join('/'))
11969
+ .map((file) => path.relative(outputRoot, file).split(path.sep).join('/'))
11970
11970
  .join(', ')}`);
11971
11971
  }
11972
11972
  const indexHtmlPath = path.join(outputRoot, 'index.html');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "sideEffects": [
5
5
  "./src/index.ts",
6
6
  "./src/core/singleton.ts",
@@ -92,7 +92,7 @@
92
92
  "vue": "^2.7.16",
93
93
  "vite": "^8.0.12",
94
94
  "vitest": "^3.2.4",
95
- "@heybox/hb-api": "~1.25.0"
95
+ "@heybox/hb-api": "~1.25.1"
96
96
  },
97
97
  "publishConfig": {
98
98
  "registry": "https://registry.npmjs.org/",
package/skill/SKILL.md CHANGED
@@ -54,12 +54,12 @@ Apply these instructions when writing, reviewing, or debugging code that consume
54
54
  4. Use `hb-sdk remote entity list`, `hb-sdk remote entity current`, and `hb-sdk remote entity switch <entity-id>` to inspect or change the developer platform server-side current entity before remote management commands.
55
55
  5. Use `hb-sdk remote create` to create a remote mini-program under the server-side current entity and bind the returned id into `package.json.heybox.miniProgramId`; use `hb-sdk remote bind <mini-program-id>` to bind an existing remote mini-program after current-entity manageability is verified. Mini-program name, icon, and cover images belong in `package.json.heybox.miniProgramProfile` and are submitted with version audit.
56
56
  6. Use `hb-sdk remote info`, `hb-sdk remote list`, `hb-sdk remote access`, `hb-sdk remote versions`, `hb-sdk remote preview <version>`, and `hb-sdk remote allowlist ...` for read/basic/preview management workflows. Mini-program name and image changes must go through version audit, so the CLI must not expose a basic-info update command.
57
- 7. Use `hb-sdk remote deploy --release-note <text>` to build, upload, and submit the current project for audit. It reads `package.json.heybox.miniProgramId`, validates that the bound mini-program belongs to the server-side current entity before precheck/build/upload, prechecks `package.json.version` before build, runs the project's `build` script via the package manager auto-detected by lockfile, uploads `dist/` to CDN (skipping `manifest.json`, `.DS_Store`, `.map`), then calls the submit-audit API. When `--env <name>` or `HB_SDK_ENV=<name>` selects an environment preset, deploy also passes the same name to the project build as its Vite mode. The deploy upload pipeline rejects actual upload artifacts over 100MiB before any upload request, processes CDN upload metadata and callback confirmation at 50 files per batch, keeps 4-way upload concurrency within each batch, and validates CDN-returned keys exactly against the local expected upload keys.
57
+ 7. Use `hb-sdk remote deploy --release-note <text>` to build, upload, and submit the current project for audit. It reads `package.json.heybox.miniProgramId`, validates that the bound mini-program belongs to the server-side current entity before precheck/build/upload, prechecks `package.json.version` before build, runs the project's `build` script via the package manager auto-detected by lockfile, uploads `dist/` to CDN (skipping `manifest.json`, `.DS_Store`, `.map`), then calls the submit-audit API. Deploy and `--from-version` do not fetch or compare the client-side `minimumSdkVersion`; Manifest validation and server-side precheck / submit-audit policy still apply. When `--env <name>` or `HB_SDK_ENV=<name>` selects an environment preset, deploy also passes the same name to the project build as its Vite mode. The deploy upload pipeline rejects actual upload artifacts over 100MiB before any upload request, processes CDN upload metadata and callback confirmation at 50 files per batch, keeps 4-way upload concurrency within each batch, and validates CDN-returned keys exactly against the local expected upload keys.
58
58
  8. Use `hb-sdk remote deploy --from-version <version> --release-note <text>` to reuse a previously uploaded remote version artifact and submit a new audit version without reading local `dist`, building, or uploading.
59
59
  9. Always provide a concise release note before deploy. Non-interactive environments must pass `--release-note`; interactive terminals may prompt for it. The default is manual release after approval with `hb-sdk remote release <version>`; use `--auto-publish` when the audited version should automatically release after approval.
60
60
  10. Use `hb-sdk remote release <version>`, `hb-sdk remote withdraw <version>`, `hb-sdk remote take-down`, and `hb-sdk remote reopen` for dangerous remote changes. Interactive terminals should confirm after showing enough context; non-interactive environments must pass `--yes`.
61
61
  11. For internal test/staging backend operations, use origin-only custom URLs: `HB_SDK_API_BASE_URL` or `hb-sdk remote ... --api-base-url <url>` for remote platform APIs, and `HB_SDK_LOGIN_BASE_URL` or `hb-sdk login --login-base-url <url>` for browser login. CLI flags override env vars. API base URLs must be Heybox trusted HTTPS origins by default; use `--allow-unsafe-api-base-url` or `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` only for local backend debugging. Do not include path, query, or hash in these URLs.
62
- 12. For development routing or gray validation, use `HB_SDK_SERVICE_TAG` to attach `x-rylai-service-tag` and the matching `special_tag` query parameter to CLI backend requests and the Vite minimum-SDK-version gate. Repository-local path-specific routing can still be configured in `packages/hb-sdk/src/cli/config.ts` with `@heybox/hb-types` `RylaiServiceTagConfig` (`default_tag` / path-specific `special_tag`).
62
+ 12. For development routing or gray validation, use `HB_SDK_SERVICE_TAG` to attach `x-rylai-service-tag` and the matching `special_tag` query parameter to CLI backend requests and the Vite minimum-SDK-version gate used by manual builds. Deploy builds skip that client-side version gate. Repository-local path-specific routing can still be configured in `packages/hb-sdk/src/cli/config.ts` with `@heybox/hb-types` `RylaiServiceTagConfig` (`default_tag` / path-specific `special_tag`).
63
63
  13. If a remote command targets a custom login environment, pass the same `--login-base-url` or `HB_SDK_LOGIN_BASE_URL` used for `hb-sdk login`; remote commands reject cached CLI login state from a different login origin.
64
64
  14. Add `--verbose` / `-v` only when diagnosing failures; default CLI errors are intentionally concise, while verbose output includes backend envelope, HTTP status, trace fields, raw body, or original submit-audit failure details.
65
65
  15. Use `--json` for script consumption of `hb-sdk remote` commands. With `--json`, stdout must contain exactly one JSON object; progress, warnings, update reminders, and verbose diagnostics must not pollute stdout.
@@ -19,7 +19,7 @@
19
19
  ## Package metadata
20
20
 
21
21
  - Package: `@heybox/hb-sdk`
22
- - Version at generation time: `0.6.0`
22
+ - Version at generation time: `0.6.1`
23
23
  - Public root export: `@heybox/hb-sdk`
24
24
  - Protocol export: `@heybox/hb-sdk/protocol`
25
25
  - Vite plugin export: `@heybox/hb-sdk/vite`
@@ -200,10 +200,7 @@ Use `@heybox/hb-sdk/vite` only in `vite.config.ts`. Do not import it from iframe
200
200
  import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
201
201
  import path from 'node:path';
202
202
  import { HB_SDK_VERSION } from '../core/version';
203
- import {
204
- renderMiniappManifest,
205
- validateMiniappPackageVersionForBuild,
206
- } from '../miniapp-manifest/schema';
203
+ import { renderMiniappManifest, validateMiniappPackageVersionForBuild } from '../miniapp-manifest/schema';
207
204
  import { readMiniappVersionFromPackageJson } from '../miniapp-manifest/node';
208
205
  import { enforceMiniappHtmlPolicy } from './html-policy';
209
206
  import { enforceViteSdkVersion as defaultEnforceRemoteSdkVersion } from './sdk-version-gate';
@@ -243,12 +240,14 @@ interface MiniappManifestResolvedConfig {
243
240
  server: {
244
241
  host?: string | boolean;
245
242
  port?: number;
246
- hmr?: boolean | {
247
- clientPort?: number;
248
- host?: string;
249
- port?: number;
250
- protocol?: 'ws' | 'wss';
251
- };
243
+ hmr?:
244
+ | boolean
245
+ | {
246
+ clientPort?: number;
247
+ host?: string;
248
+ port?: number;
249
+ protocol?: 'ws' | 'wss';
250
+ };
252
251
  };
253
252
  }
254
253
 
@@ -281,7 +280,7 @@ export function miniappManifest(options: MiniappManifestOptions = {}): MiniappMa
281
280
  hmrWebSocketUrl = resolveHmrWebSocketUrl(resolved);
282
281
  },
283
282
  async buildStart() {
284
- if (command !== 'build') return;
283
+ if (command !== 'build' || process.env.HB_SDK_DEPLOY_BUILD === '1') return;
285
284
  try {
286
285
  await (options.enforceSdkVersion ?? defaultEnforceRemoteSdkVersion)({
287
286
  sdkVersion: resolveSdkVersion(),
@@ -313,11 +312,11 @@ export function miniappManifest(options: MiniappManifestOptions = {}): MiniappMa
313
312
  const sdkVersion = resolveSdkVersion();
314
313
  const outputRoot = path.resolve(root, outDir);
315
314
  const htmlFiles = collectHtmlFiles(outputRoot);
316
- const unexpectedHtmlFiles = htmlFiles.filter(file => path.relative(outputRoot, file) !== 'index.html');
315
+ const unexpectedHtmlFiles = htmlFiles.filter((file) => path.relative(outputRoot, file) !== 'index.html');
317
316
  if (unexpectedHtmlFiles.length > 0) {
318
317
  throw new Error(
319
318
  `工坊小程序只支持单页应用,构建产物不允许额外 HTML:${unexpectedHtmlFiles
320
- .map(file => path.relative(outputRoot, file).split(path.sep).join('/'))
319
+ .map((file) => path.relative(outputRoot, file).split(path.sep).join('/'))
321
320
  .join(', ')}`,
322
321
  );
323
322
  }
@@ -383,7 +382,7 @@ function resolveHmrWebSocketUrl(resolved: MiniappManifestResolvedConfig) {
383
382
  ```json
384
383
  {
385
384
  "version": "1.2.3",
386
- "sdkVersion": "0.6.0"
385
+ "sdkVersion": "0.6.1"
387
386
  }
388
387
  ```
389
388
 
@@ -405,7 +404,7 @@ export default defineConfig({
405
404
 
406
405
  插件只接受单页应用:输出目录只能存在入口 `index.html`。build 会用结构化 HTML parser 校验入口,并把平台 CSP 插入 `<head>` 首位;已有 CSP 会原样保留,两份策略按浏览器交集生效。正式策略禁止 `fetch`、XHR、WebSocket、EventSource、Beacon、Worker、iframe、表单和对象加载等浏览器原生出口;业务网络请求应使用 `network.request()`。dev 使用相同策略,只额外放行当前 Vite 的精确 HMR WebSocket 地址。
407
406
 
408
- meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev`、build deploy 会读取 `/user_miniprogram/public/sdk_config` 的 `minimumSdkVersion`;最新请求失败时只回退当前 Remote Environment 下 24 小时内的有效缓存,无缓存则默认阻断并提示升级 `@heybox/hb-sdk@latest`。
407
+ meta refresh、外部 anchor、`dns-prefetch`、`preconnect`、`prerender`、外部资源 URL 和额外 HTML 会使 build 失败。内联 script/style 允许,但 `unsafe-eval` 不允许。`dev` 和手动 Vite build 会读取 `/user_miniprogram/public/sdk_config` 的 `minimumSdkVersion`;最新请求失败时只回退当前 Remote Environment 下 24 小时内的有效缓存,无缓存则默认阻断并提示升级 `@heybox/hb-sdk@latest`。`hb-sdk remote deploy`(包括 `--from-version`)不执行客户端最低版本查询或比较,但仍校验 Manifest 结构并经过服务端 precheck / submit-audit 策略。
409
408
 
410
409
  失败与警告语义:
411
410
 
@@ -165,9 +165,11 @@ HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1 hb-sdk remote deploy --api-base-url http://12
165
165
 
166
166
  `manifest.json` 仅作为提交审核接口的 `manifest` 字段提交,不会上传到 CDN。Vite 项目通过 `miniappManifest()` 插件生成;CLI 不会自动注入插件,请在 `vite.config.ts` 中显式挂载。小程序构建产物需要使用相对资源路径;`hb-sdk create` 模板会显式配置 `base: './'`,未配置 `base` 的项目也会由 `miniappManifest()` 在 build 时默认补成 `./`。构建产物只能在兼容的小黑盒 Runtime 中启动,普通浏览器直接打开时不会执行标准业务脚本。
167
167
 
168
+ `remote deploy` 的本地构建和 `--from-version` 路径都不执行客户端 `minimumSdkVersion` 查询或比较;Manifest 结构校验、版本 precheck 和服务端 submit-audit 策略仍然生效。开发者手动执行 Vite build 时仍会运行最低 SDK 版本门禁。
169
+
168
170
  默认发布策略是 `auto_publish=false`:运营审核通过后使用 `hb-sdk remote versions` 查看版本状态,再用 `hb-sdk remote release <version>` 发布。需要审核通过后自动发布并下架旧线上版本时,使用 `--auto-publish`。如需让指定用户预览未发布候选版本,使用 `hb-sdk remote allowlist add <heybox_id>` 管理预览白名单。
169
171
 
170
- 内部测试或预发环境可通过 `HB_SDK_API_BASE_URL` / `HB_SDK_LOGIN_BASE_URL` 设置默认后台环境,也可以用 `--api-base-url` / `--login-base-url` 覆盖单次命令。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。`apiBaseUrl` 影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`loginBaseUrl` 用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。开发环境如需给后台请求带 `x-rylai-service-tag` 和 `special_tag`,优先用 `--service-tag <tag>` 或 `HB_SDK_SERVICE_TAG`;deploy 子构建会继承 `.env.<name>` 中的 `HB_SDK_SERVICE_TAG`,Vite 最低 SDK 版本门禁请求也会同时携带该 header 和 querypath-prefix 级 `special_tag` 仍可在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。
172
+ 内部测试或预发环境可通过 `HB_SDK_API_BASE_URL` / `HB_SDK_LOGIN_BASE_URL` 设置默认后台环境,也可以用 `--api-base-url` / `--login-base-url` 覆盖单次命令。自定义地址只接受 origin,不允许包含 path、query 或 hash;API origin 默认还必须是 Heybox 受信 HTTPS 域名,只有本地联调等场景可显式使用 `--allow-unsafe-api-base-url` 或 `HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1` 放开。`apiBaseUrl` 影响 `hb-sdk remote` 里的远端平台后台 API,包括预检、CDN 上传凭证/回调、提交审核、版本、发布、撤回、下架、重新上架、详情和白名单等调用;`loginBaseUrl` 用于 `hb-sdk login` 的登录入口,以及 remote 命令前校验当前 CLI 登录态是否属于同一个登录环境。开发环境如需给后台请求带 `x-rylai-service-tag` 和 `special_tag`,优先用 `--service-tag <tag>` 或 `HB_SDK_SERVICE_TAG`;手动 Vite build 的最低 SDK 版本门禁请求会同时携带该 header 和 query,deploy 子构建不执行该门禁。path-prefix 级 `special_tag` 仍可在 `packages/hb-sdk/src/cli/config.ts` 里按 `@heybox/hb-types` 的 `RylaiServiceTagConfig` 配置。日志只输出 origin,不输出带身份和签名参数的完整请求 URL。
171
173
 
172
174
  `hb-sdk doctor`、npm latest 检查、mock host 的 `network.request()` 不受这些配置影响。
173
175
 
package/skill/skill.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.6.0+skill.451f74e19672",
3
+ "skillVersion": "0.6.1+skill.31b72826f59b",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.6.0",
7
- "compatibility": "0.6.0"
6
+ "version": "0.6.1",
7
+ "compatibility": "0.6.1"
8
8
  },
9
9
  "source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
10
- "integrity": "sha256-451f74e19672cca0953ebb9d47d6f2632c9341ba2c4f9bcf4a861d5344285673"
10
+ "integrity": "sha256-31b72826f59beadd927f3f2cafcba36bbf9e035915a7734d0b990767fc34d926"
11
11
  }