@heybox/hb-sdk 0.6.4 → 0.6.6-alpha.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.
@@ -93,7 +93,16 @@ function rewriteBundledRecipeLinks(markdown) {
93
93
  return markdown
94
94
  .replaceAll('(../recipes/custom-instance)', '(#custom-instance-recipe)')
95
95
  .replaceAll('(../reference/protocol/interfaces/MiniProgramEventPayloadMap)', '(api-root.md)')
96
- .replaceAll('(../reference/protocol/types/#miniprogrameventname)', '(api-root.md)');
96
+ .replaceAll('(../reference/protocol/types/#miniprogrameventname)', '(api-root.md)')
97
+ .replaceAll('(../reference/root/classes/HbMiniProgramSDKError)', '(api-root.md)')
98
+ .replaceAll('(../reference/root/classes/HbMiniProgramNetworkError)', '(api-root.md)');
99
+ }
100
+
101
+ function rewriteBundledCliLinks(markdown) {
102
+ return markdown.replaceAll(
103
+ '(./mini-program-publishing-rules)',
104
+ '(https://docs.xiaoheihe.cn/hb_sdk/guide/mini-program-publishing-rules)',
105
+ );
97
106
  }
98
107
 
99
108
  function rewriteBundledProtocolIndexLinks(markdown) {
@@ -191,7 +200,6 @@ const rootEntry = read('packages/hb-sdk/src/index.ts');
191
200
  const protocolEntry = read('packages/hb-sdk/src/protocol.ts');
192
201
  const viteEntry = read('packages/hb-sdk/src/vite/index.ts');
193
202
  const cliEntry = read('packages/hb-sdk/src/cli/index.ts');
194
- const cliTemplateReadme = read('packages/hb-sdk/src/cli/templates/vue3-vite-ts/README.md.ejs');
195
203
  const readme = read('packages/hb-sdk/README.md');
196
204
  const cliGuide = frontmatterless(read('apps/docs/hb-sdk/guide/cli.md'));
197
205
  const quickStart = frontmatterless(read('apps/docs/hb-sdk/guide/quick-start.md'));
@@ -210,20 +218,16 @@ const sdkRuntimeRelation = extractSection(readme, '## SDK 与 Runtime');
210
218
  const capabilityBoundaries = extractSection(readme, '## 能力边界');
211
219
  const manifestSection = extractSection(readme, '## Manifest');
212
220
  const cliSummarySection = extractSection(readme, '## CLI');
213
- const repositoryDevelopment = extractSection(readme, '## 本仓库开发');
214
- const cliCreateSection = extractSection(cliGuide, '## 创建外部小程序模板');
215
- const cliDevSection = [
216
- extractSection(cliGuide, '## 本地开发模式'),
217
- extractSection(cliGuide, '## Mock runtime 边界'),
218
- ].filter(Boolean).join('\n\n');
221
+ const cliCreateSection = extractSection(cliGuide, '## 创建工坊小程序');
222
+ const cliDevSection = extractSection(cliGuide, '## 推荐调试流程');
219
223
  const cliDeploySection = extractSection(cliGuide, '## 部署发布');
220
224
  const cliRemoteSection = extractSection(cliGuide, '## 远端管理命令');
221
225
  const cliLoginSection = extractSection(cliGuide, '## CLI 登录态');
222
226
  const cliDoctorSection = extractSection(cliGuide, '## Agent Skill doctor');
223
227
  const cliUpdateSection = extractSection(cliGuide, '## 版本提醒');
224
228
  const cliCommandSurface = `hb-sdk create <project-name>
225
- hb-sdk dev [--port <port>] [--mock-port <port>] [--runtime-url <url>] [--no-open]
226
- hb-sdk login [--login-base-url <url>] [--no-select-entity]
229
+ hb-sdk dev [--port <port>] [--mock-port <port>] [--no-open]
230
+ hb-sdk login
227
231
  hb-sdk login status
228
232
  hb-sdk login clear
229
233
  hb-sdk doctor
@@ -251,17 +255,15 @@ hb-sdk remote square show
251
255
 
252
256
  Removed: hb-sdk deploy`;
253
257
 
254
- const cliRemoteEntitySection = `Developer entity selection lives under \`hb-sdk remote entity\`:
258
+ const cliRemoteEntitySection = `Developer account selection lives under \`hb-sdk remote entity\`:
255
259
 
256
260
  ${fenced('bash', `hb-sdk remote entity list
257
261
  hb-sdk remote entity current
258
262
  hb-sdk remote entity switch <entity-id>`)}
259
263
 
260
- The authoritative current entity is the developer platform server-side current entity. The CLI auth cache may contain a \`selectedEntity\` value, but that value is only a hint snapshot for \`hb-sdk login status\` display and drift troubleshooting. Do not use \`selectedEntity\` as the source of truth for permissions, ownership, create, bind, deploy, or release decisions.
264
+ Remote management commands use the current developer account. Use \`current\` to confirm it and \`switch\` to change it before creating, binding, or publishing a mini-program.`;
261
265
 
262
- \`hb-sdk login\` tries to make the server-side current entity explicit after browser login. Zero entities leaves login successful and prints a guidance message. One entity is displayed and, when needed, switched to current. Multiple entities in a TTY prompt for a choice; multiple entities in non-interactive mode do not block login but tell the user to run \`hb-sdk remote entity switch <entity-id>\`. Passing \`--no-select-entity\` writes only the login state and does not modify the server-side current entity.`;
263
-
264
- const cliRemoteEntityDeploySection = `Before precheck, build, upload, or submit audit, \`hb-sdk remote deploy\` must verify that the current project's bound mini-program belongs to the server-side current entity. If \`detail.entity_id\` differs from the current entity, the command fails with both entity ids/names and suggests \`hb-sdk remote entity switch <entity-id>\`. It must not auto-switch entities and must not continue into precheck/build/upload/submit on mismatch.`;
266
+ const cliRemoteEntityDeploySection = `Before publishing, \`hb-sdk remote deploy\` verifies that the bound mini-program belongs to the current developer account. If it does not, the command stops and asks the user to switch accounts.`;
265
267
 
266
268
  const files = new Map();
267
269
 
@@ -343,29 +345,23 @@ files.set('cli.md', `${header('CLI reference', [
343
345
  'packages/hb-sdk/src/cli/commands/create.ts',
344
346
  'packages/hb-sdk/src/cli/commands/dev.ts',
345
347
  'packages/hb-sdk/src/cli/commands/login.ts',
346
- 'packages/hb-sdk/src/cli/templates/vue3-vite-ts/README.md.ejs',
347
348
  'apps/docs/hb-sdk/guide/cli.md',
348
- 'packages/hb-sdk/README.md',
349
349
  ])}${contents([
350
350
  ['When to use the CLI', 'when-to-use-the-cli'],
351
351
  ['Command surface', 'command-surface'],
352
352
  ['Create a mini-program template', 'create-a-mini-program-template'],
353
- ['Local dev and mock runtime', 'local-dev-and-mock-runtime'],
354
- ['Deploy and backend operations', 'deploy-and-backend-operations'],
355
- ['Remote entity scope', 'remote-entity-scope'],
353
+ ['Local debugging', 'local-debugging'],
354
+ ['Deploy and publish', 'deploy-and-publish'],
355
+ ['Developer account scope', 'developer-account-scope'],
356
356
  ['Remote management commands', 'remote-management-commands'],
357
- ['CLI login cache', 'cli-login-cache'],
357
+ ['CLI login', 'cli-login'],
358
358
  ['Agent Skill doctor', 'agent-skill-doctor'],
359
359
  ['Update reminders', 'update-reminders'],
360
- ['Repository validation commands', 'repository-validation-commands'],
361
- ['Generated template README', 'generated-template-readme'],
362
360
  ])}## When to use the CLI
363
361
 
364
- Use the bundled \`hb-sdk\` CLI when the task is about creating an external mini-program project, starting local Vite development, debugging SDK calls in a browser mock runtime host, managing the CLI's own Heybox auth cache, or inspecting/switching the developer platform current entity for remote mini-program management.
362
+ Use the bundled \`hb-sdk\` CLI to create a workshop mini-program, open the local debugging page, test in the Heybox Mac or mobile App, or manage and publish a remote mini-program.
365
363
 
366
- Do not use the CLI to replace iframe SDK calls. \`hb-sdk login\` is for CLI commands only and does not change \`auth.login()\`, \`user.getInfo()\`, \`network.request()\`, or mock-host user state.
367
-
368
- The CLI, templates, and mock host are owned by \`${packageJson.name}\`. Do not create a second mock runtime package or move CLI guidance outside this package unless the package boundary changes.
364
+ \`hb-sdk login\` is for development and publishing commands only. It does not change \`auth.login()\`, \`user.getInfo()\`, or \`network.request()\` inside a mini-program.
369
365
 
370
366
  ## Command surface
371
367
 
@@ -379,20 +375,20 @@ ${cliCreateSection}
379
375
 
380
376
  Agent rules:
381
377
 
382
- - Prefer \`hb-sdk create <project-name>\` for a new standalone external mini-program template.
378
+ - Prefer \`hb-sdk create <project-name>\` for a new workshop mini-program.
383
379
  - After creation, the expected next steps are \`npm install\` and \`npm run dev\`.
384
380
  - Do not claim the CLI installs dependencies, initializes git, opens an editor, or overwrites non-empty directories.
385
381
  - Treat \`project-name\` as an unscoped npm package name and project directory.
386
382
 
387
- ## Local dev and mock runtime
383
+ ## Local debugging
388
384
 
389
385
  ${cliDevSection}
390
386
 
391
- Use \`hb-sdk dev\` for local browser SDK debugging. Use the Mock runtime host's "在 Mac 版 APP 中启动" button for Mac App debugging, or the "Mobile App" QR code after selecting a LAN interface for phone App debugging. The phone must be on the same LAN and use a Heybox App version that supports the mini-program dev shell. If the mock host is open inside Codex, VSCode, or another embedded browser, ask the user to open the same debug page in the system browser before retrying because embedded browsers may block the \`heybox://\` protocol handoff.
387
+ Use \`hb-sdk dev\` to open the local debugging page. The "在 Mac 版 APP 中启动" button opens the page in the Mac App; the "Mobile App" QR code opens it in the phone App after a LAN interface is selected. These entries remain available without CLI login or project binding, but managed capabilities are denied by default. The phone and computer must be on the same LAN. If an embedded browser cannot open the App, use the system browser.
392
388
 
393
- ## Deploy and backend operations
389
+ ## Deploy and publish
394
390
 
395
- ${cliDeploySection}
391
+ ${rewriteBundledCliLinks(cliDeploySection)}
396
392
 
397
393
  ${cliRemoteEntityDeploySection}
398
394
 
@@ -400,25 +396,18 @@ Agent rules:
400
396
 
401
397
  - Use \`hb-sdk remote deploy --release-note <text>\` for normal build, upload, and submit-audit flows.
402
398
  - Use \`hb-sdk remote deploy --from-version <version> --release-note <text>\` to reuse a remote history artifact.
403
- - Verify remote deploy guidance says current-entity mismatch fails before precheck/build/upload/submit and never auto-switches the developer entity.
399
+ - If the bound mini-program does not belong to the current developer account, stop and ask the user to switch accounts.
404
400
  - Never recommend top-level \`hb-sdk deploy\`; it has been removed rather than retained as a compatibility alias.
405
401
  - After non-auto deploy succeeds, suggest \`hb-sdk remote versions\` and then \`hb-sdk remote release <version>\` after approval. Do not send the user to Open for manual publish when the CLI command exists.
406
402
  - Use \`hb-sdk remote allowlist add <heybox_id>\` when preview access needs to be granted.
407
- - Use \`--api-base-url <url>\` or \`HB_SDK_API_BASE_URL\` for remote platform backend APIs.
408
- - Use \`--allow-unsafe-api-base-url\` or \`HB_SDK_ALLOW_UNSAFE_API_BASE_URL=1\` only for local backend debugging against non-Heybox or non-HTTPS API origins.
409
- - Use \`--login-base-url <url>\` or \`HB_SDK_LOGIN_BASE_URL\` for CLI browser login and remote command login-environment validation.
410
- - Use \`packages/hb-sdk/src/cli/config.ts\` with \`RylaiServiceTagConfig\` only when Heybox backend API requests need the development-only \`x-rylai-service-tag\` header and matching \`special_tag\` query parameter.
411
- - Custom base URLs must be origin-only; API origins must be Heybox trusted HTTPS unless the unsafe debug switch is explicit. Do not include path, query, or hash.
412
- - Do not expect custom base URLs to affect \`hb-sdk doctor\`, npm latest checks, or mock-host \`network.request()\`.
413
403
 
414
- ## Remote entity scope
404
+ ## Developer account scope
415
405
 
416
406
  ${cliRemoteEntitySection}
417
407
 
418
408
  Agent rules:
419
409
 
420
- - Treat the server-side current entity as the authority for remote create, bind, deploy, list, access, versions, preview, release, withdraw, take-down, reopen, and square-display workflows.
421
- - Treat CLI \`selectedEntity\` as a display/debug snapshot only; it can drift from the server-side current entity and must not be used as a permission source.
410
+ - Treat the current developer account as the scope for remote create, bind, deploy, list, access, versions, preview, release, withdraw, take-down, reopen, and square-display workflows.
422
411
  - Use \`hb-sdk remote entity current\` when a user needs to confirm which entity create/deploy will use.
423
412
  - Use \`hb-sdk remote entity switch <entity-id>\` to change entity scope. Do not recommend \`--entity-id\` or an environment variable as a remote command override.
424
413
  - \`hb-sdk remote list\` lists mini-programs in the current entity scope only; do not promise cross-entity aggregation.
@@ -440,14 +429,13 @@ Agent rules:
440
429
  - Require confirmation or \`--yes\` for \`hb-sdk remote release\`, \`hb-sdk remote withdraw\`, \`hb-sdk remote take-down\`, \`hb-sdk remote reopen\`, and \`hb-sdk remote square hide\`.
441
430
  - Use \`--json\` for script consumption and keep stdout as exactly one JSON object.
442
431
 
443
- ## CLI login cache
432
+ ## CLI login
444
433
 
445
434
  ${cliLoginSection}
446
435
 
447
436
  Agent rules:
448
437
 
449
- - Keep CLI auth cache separate from iframe SDK login state.
450
- - Keep \`selectedEntity\` guidance explicit: it is only a hint snapshot, while every remote command uses the server-side current entity.
438
+ - Keep CLI login separate from the mini-program user login state.
451
439
  - It is correct to say status output is redacted.
452
440
  - Do not expose or template pkey, cookie, token, or private credential values.
453
441
  - Use \`hb-sdk login clear\` only to clear the \`hb-sdk\` CLI namespace.
@@ -461,19 +449,11 @@ Agent rules:
461
449
  - Use \`hb-sdk doctor\` for read-only diagnosis of local SDK, remote latest skill metadata, and local skill metadata.
462
450
  - Do not use \`hb-sdk doctor\` to auto-install skills; when installation or refresh is needed, tell the user to run \`npx skills add https://open.xiaoheihe.cn/agent-skills/hb-sdk\`.
463
451
  - If doctor reports \`SDK_MISMATCH\`, tell the user to upgrade \`${packageJson.name}@latest\` before reinstalling the skill.
464
- - The supported local skill path is \`$CODEX_HOME/skills/hb-sdk/skill.json\`, falling back to \`~/.codex/skills/hb-sdk/skill.json\`.
465
452
 
466
453
  ## Update reminders
467
454
 
468
455
  ${cliUpdateSection}
469
456
 
470
- ## Repository validation commands
471
-
472
- ${repositoryDevelopment}
473
-
474
- ## Generated template README
475
-
476
- ${fenced('md', cliTemplateReadme)}
477
457
  `);
478
458
 
479
459
  files.set('recipes.md', `${header('Recipes', [
package/skill/skill.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.6.4+skill.36b02466ef23",
3
+ "skillVersion": "0.6.6-alpha.0+skill.cfc5c9fb3951",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.6.4",
7
- "compatibility": "0.6.4"
6
+ "version": "0.6.6-alpha.0",
7
+ "compatibility": "0.6.6-alpha.0"
8
8
  },
9
9
  "source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
10
- "integrity": "sha256-36b02466ef23a54c71c1eff6f9610dfa63d25d423529b20a6d8d50c8f1e85eaf"
10
+ "integrity": "sha256-cfc5c9fb39515fb1aa10fa2fc4db030d31ff0034b389062e009c0d6f2195e9e4"
11
11
  }
@@ -0,0 +1,25 @@
1
+ import type { MiniProgramRuntimePermissionsSnapshot } from './runtime-permissions';
2
+ /** Dev Shell 读取局域网 Dev Session endpoint 的 query 参数。 */
3
+ export declare const MINI_PROGRAM_DEV_CONTEXT_QUERY_PARAM = "dev_context_url";
4
+ /** Mock Host 创建和读取 Dev Session 的固定路径。 */
5
+ export declare const MINI_PROGRAM_DEV_CONTEXT_PATH = "/__hb_sdk__/dev-context";
6
+ /** Dev Session 当前使用的 schema 版本。 */
7
+ export declare const MINI_PROGRAM_DEV_SESSION_SCHEMA_VERSION: 1;
8
+ /** Mock Host 创建 Dev Session 时接收的请求。 */
9
+ export interface MiniProgramDevSessionCreatePayload {
10
+ mini_url_origin: string;
11
+ runtime_permissions: MiniProgramRuntimePermissionsSnapshot;
12
+ }
13
+ /** Mock Host 创建 Dev Session 后返回的短期引用。 */
14
+ export interface MiniProgramDevSessionCreateResult {
15
+ expires_at: number;
16
+ token: string;
17
+ }
18
+ /** Runtime Host 通过短期引用读取的不可变 Dev Session 快照。 */
19
+ export interface MiniProgramDevSessionSnapshot {
20
+ schema_version: typeof MINI_PROGRAM_DEV_SESSION_SCHEMA_VERSION;
21
+ revision: number;
22
+ expires_at: number;
23
+ mini_url_origin: string;
24
+ runtime_permissions: MiniProgramRuntimePermissionsSnapshot;
25
+ }