@heybox/hb-sdk 0.6.7-alpha.2 → 0.6.7

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.
@@ -3,10 +3,10 @@
3
3
  var fs$1 = require('node:fs');
4
4
  var fs = require('node:fs/promises');
5
5
  var path = require('node:path');
6
- var index$1 = require('./index-BQm5XmMC.cjs');
7
- var runtimeGate = require('./runtime-gate-B2MQf1vc.cjs');
8
- var index = require('./index-CQnkS0Z8.cjs');
9
- var projectVite = require('./project-vite-D9_v57vp.cjs');
6
+ var index$1 = require('./index-v4-6fbXX.cjs');
7
+ var runtimeGate = require('./runtime-gate-DfMJQGH9.cjs');
8
+ var index = require('./index-B1w-Jpba.cjs');
9
+ var projectVite = require('./project-vite-J4lrUja0.cjs');
10
10
  require('node:module');
11
11
  require('path');
12
12
  require('os');
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var session = require('./session-BjtjhtPg.cjs');
4
- var index = require('./index-BQm5XmMC.cjs');
3
+ var session = require('./session-5ryBp2wZ.cjs');
4
+ var index = require('./index-v4-6fbXX.cjs');
5
5
  var fs$1 = require('node:fs');
6
6
  var fs = require('node:fs/promises');
7
7
  var path = require('node:path');
@@ -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-CQnkS0Z8.cjs');
8
+ var index = require('./index-B1w-Jpba.cjs');
9
9
  require('node:module');
10
10
  require('os');
11
11
  require('readline');
@@ -9,9 +9,9 @@ var node_http = require('node:http');
9
9
  var node_crypto = require('node:crypto');
10
10
  var undici = require('undici');
11
11
  var browser = require('./browser-RAy8e8cV.cjs');
12
- var index = require('./index-CQnkS0Z8.cjs');
13
- var projectVite = require('./project-vite-D9_v57vp.cjs');
14
- var context = require('./context-ChkYWwH_.cjs');
12
+ var index = require('./index-B1w-Jpba.cjs');
13
+ var projectVite = require('./project-vite-J4lrUja0.cjs');
14
+ var context = require('./context-cQXupHub.cjs');
15
15
  var fs$1 = require('node:fs/promises');
16
16
  require('node:process');
17
17
  require('node:buffer');
@@ -28,10 +28,10 @@ require('events');
28
28
  require('stream');
29
29
  require('buffer');
30
30
  require('util');
31
- require('./session-BjtjhtPg.cjs');
31
+ require('./session-5ryBp2wZ.cjs');
32
32
  require('fs');
33
33
  require('constants');
34
- require('./index-BQm5XmMC.cjs');
34
+ require('./index-v4-6fbXX.cjs');
35
35
 
36
36
  class Locked extends Error {
37
37
  constructor(port) {
@@ -1259,7 +1259,7 @@ function cloneDefaultPermissionState() {
1259
1259
  /** 构建时替换为当前发布包的实际版本。 */
1260
1260
  const HB_SDK_VERSION = typeof undefined === 'string'
1261
1261
  ? undefined
1262
- : '0.6.7-alpha.2';
1262
+ : '0.6.7';
1263
1263
 
1264
1264
  class DevPermissionOverrideStoreError extends Error {
1265
1265
  code;
@@ -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-CQnkS0Z8.cjs');
7
+ var index = require('./index-B1w-Jpba.cjs');
8
8
  require('node:module');
9
9
  require('path');
10
10
  require('os');
@@ -33,7 +33,7 @@ async function runDoctorCommand(runtime = {}) {
33
33
  }
34
34
  async function getDoctorResult(runtime = {}) {
35
35
  const currentSdkVersion = await readCurrentSdkVersion(runtime.packageJsonFiles);
36
- const localSkillJsonPath = resolveLocalSkillJsonPath(runtime);
36
+ const localSkillJsonPath = await resolveLocalSkillJsonPath(runtime);
37
37
  let remoteSkill;
38
38
  try {
39
39
  remoteSkill = await fetchRemoteSkill(runtime);
@@ -165,13 +165,31 @@ async function readCurrentSdkVersion(packageJsonCandidates = PACKAGE_JSON_CANDID
165
165
  }
166
166
  throw new Error('未能读取 @heybox/hb-sdk 当前版本号');
167
167
  }
168
- function resolveLocalSkillJsonPath(runtime) {
168
+ async function resolveLocalSkillJsonPath(runtime) {
169
169
  if (runtime.localSkillJsonPath) {
170
170
  return runtime.localSkillJsonPath;
171
171
  }
172
+ const projectSkillJsonPath = await findProjectSkillJsonPath(runtime.cwd ?? process.cwd());
173
+ if (projectSkillJsonPath) {
174
+ return projectSkillJsonPath;
175
+ }
172
176
  const codexHome = runtime.codexHome ?? runtime.env?.CODEX_HOME ?? process.env.CODEX_HOME ?? path.join(os.homedir(), '.codex');
173
177
  return path.join(codexHome, 'skills', index.HB_SDK_SKILL_NAME, 'skill.json');
174
178
  }
179
+ async function findProjectSkillJsonPath(startDir) {
180
+ let current = path.resolve(startDir);
181
+ while (true) {
182
+ const skillJsonPath = path.join(current, '.agents', 'skills', index.HB_SDK_SKILL_NAME, 'skill.json');
183
+ if ((await pathExists(path.join(current, 'package.json'))) && (await pathExists(skillJsonPath))) {
184
+ return skillJsonPath;
185
+ }
186
+ const parent = path.dirname(current);
187
+ if (parent === current) {
188
+ return undefined;
189
+ }
190
+ current = parent;
191
+ }
192
+ }
175
193
  async function pathExists(filePath) {
176
194
  try {
177
195
  await fs.access(filePath, fs$1.constants.F_OK);
@@ -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-CQnkS0Z8.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-B1w-Jpba.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-CQnkS0Z8.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-B1w-Jpba.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-CQnkS0Z8.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-B1w-Jpba.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-CQnkS0Z8.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-B1w-Jpba.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-CQnkS0Z8.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-B1w-Jpba.cjs', document.baseURI).href)));
250
250
  function __require() { return require$1("node:process"); }
251
251
 
252
252
  var help = {};
@@ -13347,7 +13347,7 @@ function getPathname(pathWithQuery) {
13347
13347
  }
13348
13348
 
13349
13349
  const CLI_VERSION_PLACEHOLDER = ['__HB', 'SDK', 'CLI', 'VERSION__'].join('_');
13350
- const BUILT_CLI_VERSION = '0.6.7-alpha.2';
13350
+ const BUILT_CLI_VERSION = '0.6.7';
13351
13351
  const PACKAGE_JSON_CANDIDATES = [
13352
13352
  path.resolve(__dirname, '..', '..', 'package.json'),
13353
13353
  path.resolve(__dirname, '..', 'package.json'),
@@ -13680,35 +13680,35 @@ function createCommandLoggerResolver(options) {
13680
13680
  };
13681
13681
  }
13682
13682
  const defaultClearLoginStatus = async (...args) => {
13683
- const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-BmisXAdp.cjs'); });
13683
+ const { clearLoginStatus } = await Promise.resolve().then(function () { return require('./login-D-ZK-n1E.cjs'); });
13684
13684
  return clearLoginStatus(...args);
13685
13685
  };
13686
13686
  const defaultLoginToHeybox = async (...args) => {
13687
- const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-BmisXAdp.cjs'); });
13687
+ const { loginToHeybox } = await Promise.resolve().then(function () { return require('./login-D-ZK-n1E.cjs'); });
13688
13688
  return loginToHeybox(...args);
13689
13689
  };
13690
13690
  const defaultPrintLoginStatus = async (...args) => {
13691
- const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-BmisXAdp.cjs'); });
13691
+ const { printLoginStatus } = await Promise.resolve().then(function () { return require('./login-D-ZK-n1E.cjs'); });
13692
13692
  return printLoginStatus(...args);
13693
13693
  };
13694
13694
  const defaultRunBuildCommand = async (...args) => {
13695
- const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-CQmYxfxm.cjs'); });
13695
+ const { runBuildCommand } = await Promise.resolve().then(function () { return require('./build-DaHCCSLH.cjs'); });
13696
13696
  return runBuildCommand(...args);
13697
13697
  };
13698
13698
  const defaultRunCreateCommand = async (...args) => {
13699
- const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-CC5r_8bL.cjs'); });
13699
+ const { runCreateCommand } = await Promise.resolve().then(function () { return require('./create-D2dSw7bl.cjs'); });
13700
13700
  return runCreateCommand(...args);
13701
13701
  };
13702
13702
  const defaultRunDevCommand = async (...args) => {
13703
- const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-CD-38TgO.cjs'); });
13703
+ const { runDevCommand } = await Promise.resolve().then(function () { return require('./dev-D6WhI3cC.cjs'); });
13704
13704
  return runDevCommand(...args);
13705
13705
  };
13706
13706
  const defaultRunDoctorCommand = async (...args) => {
13707
- const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-43yEfVr0.cjs'); });
13707
+ const { runDoctorCommand } = await Promise.resolve().then(function () { return require('./doctor-CtNS5Tt2.cjs'); });
13708
13708
  return runDoctorCommand(...args);
13709
13709
  };
13710
13710
  const defaultRunRemoteCommand = async (...args) => {
13711
- const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-BXtT6M2f.cjs'); });
13711
+ const { runRemoteCommand } = await Promise.resolve().then(function () { return require('./remote-BZNHAL5_.cjs'); });
13712
13712
  return runRemoteCommand(...args);
13713
13713
  };
13714
13714
  function resolveStandaloneLogger(options, verbose) {
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var index$2 = require('./index-CQnkS0Z8.cjs');
3
+ var index$2 = require('./index-B1w-Jpba.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 index$3 = require('./index-BQm5XmMC.cjs');
10
+ var index$3 = require('./index-v4-6fbXX.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');
@@ -2839,18 +2839,45 @@ function getMiniappUploadKey(input) {
2839
2839
  }
2840
2840
  function validateUploadPaths(items, options) {
2841
2841
  const limit = options.maxLength;
2842
+ const uploadKeys = new Set();
2842
2843
  for (const item of items) {
2844
+ const relativePath = String(item.relativePath ?? '');
2845
+ const normalizedRelativePath = normalizeRelativePath(relativePath);
2846
+ const invalidReason = getInvalidUploadPathReason(normalizedRelativePath);
2847
+ if (invalidReason) {
2848
+ return `构建产物文件路径不合法(${invalidReason}):${JSON.stringify(relativePath)}`;
2849
+ }
2843
2850
  const key = getMiniappUploadKey({
2844
2851
  miniProgramId: options.miniProgramId,
2845
2852
  version: options.version,
2846
- relativePath: item.relativePath,
2853
+ relativePath: normalizedRelativePath,
2847
2854
  });
2855
+ if (uploadKeys.has(key)) {
2856
+ return `构建产物文件路径重复,无法上传到同一位置:${JSON.stringify(relativePath)}`;
2857
+ }
2858
+ uploadKeys.add(key);
2848
2859
  if (key.length > limit) {
2849
- return `文件路径过长,请缩短构建产物文件名或目录层级:${item.relativePath}`;
2860
+ return `文件路径过长,请缩短构建产物文件名或目录层级:${relativePath}`;
2850
2861
  }
2851
2862
  }
2852
2863
  return undefined;
2853
2864
  }
2865
+ function getInvalidUploadPathReason(relativePath) {
2866
+ const segments = relativePath.replace(/\\/g, '/').split('/');
2867
+ if (segments.some((segment) => !segment)) {
2868
+ return '包含空路径段';
2869
+ }
2870
+ if (segments.some((segment) => segment === '.')) {
2871
+ return '包含当前目录';
2872
+ }
2873
+ if (segments.some((segment) => segment === '..')) {
2874
+ return '包含上级目录';
2875
+ }
2876
+ if (/[\u0000-\u001F\u007F]/.test(relativePath)) {
2877
+ return '包含控制字符';
2878
+ }
2879
+ return undefined;
2880
+ }
2854
2881
  function validateUploadTotalSize(items, options = {}) {
2855
2882
  const limit = options.limitBytes ?? MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES;
2856
2883
  const total = items.reduce((sum, item) => {
@@ -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-BjtjhtPg.cjs');
6
+ var session = require('./session-5ryBp2wZ.cjs');
7
7
  var browser = require('./browser-RAy8e8cV.cjs');
8
- var index = require('./index-CQnkS0Z8.cjs');
8
+ var index = require('./index-B1w-Jpba.cjs');
9
9
  require('node:path');
10
10
  require('fs');
11
11
  require('constants');
@@ -5,7 +5,7 @@ var fs$1 = require('node:fs/promises');
5
5
  var node_module = require('node:module');
6
6
  var path = require('node:path');
7
7
  var node_url = require('node:url');
8
- var index = require('./index-CQnkS0Z8.cjs');
8
+ var index = require('./index-B1w-Jpba.cjs');
9
9
 
10
10
  function findProjectRoot(startDir) {
11
11
  let current = path.resolve(startDir);
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var promises = require('node:readline/promises');
4
- var index = require('./index-CQnkS0Z8.cjs');
5
- var session = require('./session-BjtjhtPg.cjs');
4
+ var index = require('./index-B1w-Jpba.cjs');
5
+ var session = require('./session-5ryBp2wZ.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 index$1 = require('./index-BQm5XmMC.cjs');
11
- var runtimeGate = require('./runtime-gate-B2MQf1vc.cjs');
12
- var context = require('./context-ChkYWwH_.cjs');
10
+ var index$1 = require('./index-v4-6fbXX.cjs');
11
+ var runtimeGate = require('./runtime-gate-DfMJQGH9.cjs');
12
+ var context = require('./context-cQXupHub.cjs');
13
13
  require('node:module');
14
14
  require('path');
15
15
  require('os');
@@ -191,7 +191,7 @@ async function createDefaultCosClient(uploadToken) {
191
191
  };
192
192
  }
193
193
  async function loadCosConstructor() {
194
- const cosModule = await Promise.resolve().then(function () { return require('./index-BM6oH2Hs.cjs'); }).then(function (n) { return n.index; });
194
+ const cosModule = await Promise.resolve().then(function () { return require('./index-C4y2G95g.cjs'); }).then(function (n) { return n.index; });
195
195
  return cosModule.default;
196
196
  }
197
197
  function formatSize(bytes) {
@@ -342,12 +342,14 @@ async function runDeployCommand(options, runtime = {}) {
342
342
  autoPublish,
343
343
  }, runtime, apiBaseUrl, projectRoot, logger);
344
344
  const pm = detectPackageManager(projectRoot);
345
- const buildMode = env.HB_SDK_ENV?.trim();
345
+ const platform = runtime.platform ?? process.platform;
346
+ const buildMode = validateBuildMode(env.HB_SDK_ENV?.trim(), platform);
346
347
  logger.info(`开始构建: ${pm} ${createBuildArgs(pm, buildMode).join(' ')}`);
347
348
  await runBuildScript(pm, projectRoot, runtime.spawn ?? childProcess.spawn, {
348
349
  env,
349
350
  mode: buildMode,
350
351
  outputMode: options.buildOutputMode ?? 'inherit',
352
+ platform,
351
353
  stderr: runtime.stderr,
352
354
  });
353
355
  logger.success('构建完成');
@@ -536,9 +538,14 @@ async function runBuildScript(pm, cwd, spawnImpl, options) {
536
538
  await new Promise((resolve, reject) => {
537
539
  const pipeStdoutToStderr = options.outputMode === 'stderr';
538
540
  const buildArgs = createBuildArgs(pm, options.mode);
539
- const child = spawnImpl(pm, buildArgs, {
541
+ const isWindows = options.platform === 'win32';
542
+ const [executable, args] = isWindows
543
+ ? createWindowsBuildCommand(pm, buildArgs)
544
+ : [pm, buildArgs];
545
+ const child = spawnImpl(executable, args, {
540
546
  cwd,
541
547
  env: { ...process.env, ...options.env },
548
+ ...(isWindows ? { shell: false, windowsVerbatimArguments: true } : {}),
542
549
  stdio: pipeStdoutToStderr ? ['inherit', 'pipe', 'inherit'] : 'inherit',
543
550
  });
544
551
  if (pipeStdoutToStderr) {
@@ -557,6 +564,19 @@ async function runBuildScript(pm, cwd, spawnImpl, options) {
557
564
  });
558
565
  });
559
566
  }
567
+ function createWindowsBuildCommand(pm, buildArgs) {
568
+ const command = `${pm}.cmd ${buildArgs.map(escapeWindowsCommandArgument).join(' ')}`;
569
+ return ['cmd.exe', ['/d', '/s', '/c', `"${command}"`]];
570
+ }
571
+ function validateBuildMode(mode, platform) {
572
+ if (platform === 'win32' && mode && !/^[A-Za-z0-9._-]+$/.test(mode)) {
573
+ throw new Error('Windows 下 HB_SDK_ENV 仅支持字母、数字、点、下划线和连字符');
574
+ }
575
+ return mode;
576
+ }
577
+ function escapeWindowsCommandArgument(argument) {
578
+ return `"${argument}"`;
579
+ }
560
580
  function createBuildArgs(pm, mode) {
561
581
  return ['run', 'build', ...(mode ? [...(pm === 'npm' ? ['--'] : []), '--mode', mode] : [])];
562
582
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BQm5XmMC.cjs');
3
+ var index = require('./index-v4-6fbXX.cjs');
4
4
 
5
5
  function isValidMiniappManifestVersion(version) {
6
6
  return getMiniappManifestVersionError(version) === undefined;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-CQnkS0Z8.cjs');
3
+ var index = require('./index-B1w-Jpba.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-CQnkS0Z8.cjs');
3
+ var index = require('./cli-chunks/index-B1w-Jpba.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.7-alpha.2';
328
+ : '0.6.7';
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.7-alpha.2';
324
+ : '0.6.7';
325
325
 
326
326
  /**
327
327
  * 判断未知数据是否符合小程序 bridge 消息信封。
@@ -2863,18 +2863,45 @@ function getMiniappUploadKey(input) {
2863
2863
  }
2864
2864
  function validateUploadPaths(items, options) {
2865
2865
  const limit = options.maxLength ?? ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
2866
+ const uploadKeys = new Set();
2866
2867
  for (const item of items) {
2868
+ const relativePath = String(item.relativePath ?? '');
2869
+ const normalizedRelativePath = normalizeRelativePath(relativePath);
2870
+ const invalidReason = getInvalidUploadPathReason(normalizedRelativePath);
2871
+ if (invalidReason) {
2872
+ return `构建产物文件路径不合法(${invalidReason}):${JSON.stringify(relativePath)}`;
2873
+ }
2867
2874
  const key = getMiniappUploadKey({
2868
2875
  miniProgramId: options.miniProgramId,
2869
2876
  version: options.version,
2870
- relativePath: item.relativePath,
2877
+ relativePath: normalizedRelativePath,
2871
2878
  });
2879
+ if (uploadKeys.has(key)) {
2880
+ return `构建产物文件路径重复,无法上传到同一位置:${JSON.stringify(relativePath)}`;
2881
+ }
2882
+ uploadKeys.add(key);
2872
2883
  if (key.length > limit) {
2873
- return `文件路径过长,请缩短构建产物文件名或目录层级:${item.relativePath}`;
2884
+ return `文件路径过长,请缩短构建产物文件名或目录层级:${relativePath}`;
2874
2885
  }
2875
2886
  }
2876
2887
  return undefined;
2877
2888
  }
2889
+ function getInvalidUploadPathReason(relativePath) {
2890
+ const segments = relativePath.replace(/\\/g, '/').split('/');
2891
+ if (segments.some((segment) => !segment)) {
2892
+ return '包含空路径段';
2893
+ }
2894
+ if (segments.some((segment) => segment === '.')) {
2895
+ return '包含当前目录';
2896
+ }
2897
+ if (segments.some((segment) => segment === '..')) {
2898
+ return '包含上级目录';
2899
+ }
2900
+ if (/[\u0000-\u001F\u007F]/.test(relativePath)) {
2901
+ return '包含控制字符';
2902
+ }
2903
+ return undefined;
2904
+ }
2878
2905
  function validateUploadTotalSize(items, options = {}) {
2879
2906
  const limit = options.limitBytes ?? MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES;
2880
2907
  const total = items.reduce((sum, item) => {
@@ -2861,18 +2861,45 @@ function getMiniappUploadKey(input) {
2861
2861
  }
2862
2862
  function validateUploadPaths(items, options) {
2863
2863
  const limit = options.maxLength ?? ACTIVITY_UPLOAD_KEY_MAX_LENGTH;
2864
+ const uploadKeys = new Set();
2864
2865
  for (const item of items) {
2866
+ const relativePath = String(item.relativePath ?? '');
2867
+ const normalizedRelativePath = normalizeRelativePath(relativePath);
2868
+ const invalidReason = getInvalidUploadPathReason(normalizedRelativePath);
2869
+ if (invalidReason) {
2870
+ return `构建产物文件路径不合法(${invalidReason}):${JSON.stringify(relativePath)}`;
2871
+ }
2865
2872
  const key = getMiniappUploadKey({
2866
2873
  miniProgramId: options.miniProgramId,
2867
2874
  version: options.version,
2868
- relativePath: item.relativePath,
2875
+ relativePath: normalizedRelativePath,
2869
2876
  });
2877
+ if (uploadKeys.has(key)) {
2878
+ return `构建产物文件路径重复,无法上传到同一位置:${JSON.stringify(relativePath)}`;
2879
+ }
2880
+ uploadKeys.add(key);
2870
2881
  if (key.length > limit) {
2871
- return `文件路径过长,请缩短构建产物文件名或目录层级:${item.relativePath}`;
2882
+ return `文件路径过长,请缩短构建产物文件名或目录层级:${relativePath}`;
2872
2883
  }
2873
2884
  }
2874
2885
  return undefined;
2875
2886
  }
2887
+ function getInvalidUploadPathReason(relativePath) {
2888
+ const segments = relativePath.replace(/\\/g, '/').split('/');
2889
+ if (segments.some((segment) => !segment)) {
2890
+ return '包含空路径段';
2891
+ }
2892
+ if (segments.some((segment) => segment === '.')) {
2893
+ return '包含当前目录';
2894
+ }
2895
+ if (segments.some((segment) => segment === '..')) {
2896
+ return '包含上级目录';
2897
+ }
2898
+ if (/[\u0000-\u001F\u007F]/.test(relativePath)) {
2899
+ return '包含控制字符';
2900
+ }
2901
+ return undefined;
2902
+ }
2876
2903
  function validateUploadTotalSize(items, options = {}) {
2877
2904
  const limit = options.limitBytes ?? MINIAPP_UPLOAD_TOTAL_SIZE_LIMIT_BYTES;
2878
2905
  const total = items.reduce((sum, item) => {
package/dist/vite.cjs.js CHANGED
@@ -7,7 +7,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
7
7
  /** 构建时替换为当前发布包的实际版本。 */
8
8
  const HB_SDK_VERSION = typeof undefined === 'string'
9
9
  ? undefined
10
- : '0.6.7-alpha.2';
10
+ : '0.6.7';
11
11
 
12
12
  var re = {exports: {}};
13
13
 
package/dist/vite.esm.js CHANGED
@@ -4,7 +4,7 @@ import path from 'node:path';
4
4
  /** 构建时替换为当前发布包的实际版本。 */
5
5
  const HB_SDK_VERSION = typeof undefined === 'string'
6
6
  ? undefined
7
- : '0.6.7-alpha.2';
7
+ : '0.6.7';
8
8
 
9
9
  var re = {exports: {}};
10
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.6.7-alpha.2",
3
+ "version": "0.6.7",
4
4
  "sideEffects": [
5
5
  "./src/index.ts",
6
6
  "./src/core/singleton.ts",
@@ -19,7 +19,7 @@
19
19
  ## Package metadata
20
20
 
21
21
  - Package: `@heybox/hb-sdk`
22
- - Version at generation time: `0.6.7-alpha.2`
22
+ - Version at generation time: `0.6.7`
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`
package/skill/skill.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.6.7-alpha.2+skill.ed2b204ea04c",
3
+ "skillVersion": "0.6.7+skill.41468f88775d",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.6.7-alpha.2",
7
- "compatibility": "0.6.7-alpha.2"
6
+ "version": "0.6.7",
7
+ "compatibility": "0.6.7"
8
8
  },
9
9
  "source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
10
- "integrity": "sha256-ed2b204ea04c904a30c99cfc1c4a60833dde694b9a5974bbc885f2b751224e68"
10
+ "integrity": "sha256-41468f88775da671af5db2433db8eec09da54da48adc37acb8f568caa20455d9"
11
11
  }