@heybox/hb-sdk 0.8.0-alpha → 0.8.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +44 -1
  2. package/README.md +87 -14
  3. package/THIRD_PARTY_NOTICES.md +1755 -0
  4. package/dist/cli-chunks/{build-DJWFSM1B.cjs → build-qWzAbpS7.cjs} +2 -2
  5. package/dist/cli-chunks/{context-DV2UK1Nz.cjs → context-CtS2Thp0.cjs} +1 -26
  6. package/dist/cli-chunks/{create-2HfoB48V.cjs → create-PV5ua977.cjs} +1 -1
  7. package/dist/cli-chunks/{dev-Dgt2zS9k.cjs → dev-CwKbAm_H.cjs} +337 -522
  8. package/dist/cli-chunks/doctor-tJUGOYrm.cjs +65 -0
  9. package/dist/cli-chunks/{index-BjoSXl8C.cjs → index-DVuD75Hr.cjs} +1 -1
  10. package/dist/cli-chunks/{index-D62ANeBv.cjs → index-De687C6-.cjs} +33 -24
  11. package/dist/cli-chunks/{index.esm-CigcxJ2B.cjs → index.esm-B-4yrLNm.cjs} +6 -5
  12. package/dist/cli-chunks/{login-Cumknwdx.cjs → login-DolpqD8K.cjs} +2 -2
  13. package/dist/cli-chunks/{project-vite-CcE-HMmd.cjs → project-vite-1rvkK-M8.cjs} +1 -1
  14. package/dist/cli-chunks/{remote-DDdP3xcE.cjs → remote-rIAQE_G2.cjs} +4 -4
  15. package/dist/cli-chunks/{session-BDi_AZSv.cjs → session-CzaM2Cq3.cjs} +1 -1
  16. package/dist/cli-chunks/skill-CM40_9WH.cjs +83 -0
  17. package/dist/cli-chunks/version-Bz-AfXQU.cjs +8 -0
  18. package/dist/cli.cjs +1 -1
  19. package/dist/devtools/browser-dev-host/assets/browser-dev-host-uq-Wac6k.js +97 -0
  20. package/dist/devtools/browser-dev-host/assets/heybox-logo-CogNENsk.svg +6 -0
  21. package/dist/devtools/browser-dev-host/assets/index-CeP6SLB3.js +567 -0
  22. package/dist/devtools/browser-dev-host/assets/index-KD2f3Jdz.css +1 -0
  23. package/dist/devtools/browser-dev-host/assets/workbench-state-D-1U0JRq.js +5 -0
  24. package/dist/devtools/browser-dev-host/index.html +6 -435
  25. package/dist/index.cjs.js +924 -28
  26. package/dist/index.esm.js +924 -29
  27. package/dist/protocol.cjs.js +208 -6
  28. package/dist/protocol.esm.js +182 -7
  29. package/dist/vite.cjs.js +1 -1
  30. package/dist/vite.esm.js +1 -1
  31. package/package.json +29 -10
  32. package/skill/SKILL.md +16 -13
  33. package/skill/references/api-protocol.md +100 -4
  34. package/skill/references/api-root.md +142 -15
  35. package/skill/references/cli.md +27 -22
  36. package/skill/references/examples.md +30 -1
  37. package/skill/references/llms-index.md +1 -1
  38. package/skill/references/recipes.md +106 -2
  39. package/skill/references/safety-boundaries.md +12 -1
  40. package/skill/skill.json +10 -5
  41. package/types/core/client.d.ts +17 -1
  42. package/types/core/sdk.d.ts +3 -0
  43. package/types/core/singleton.d.ts +3 -0
  44. package/types/index.d.ts +4 -2
  45. package/types/modules/files/index.d.ts +5 -0
  46. package/types/modules/files/registry.d.ts +35 -0
  47. package/types/modules/files/types.d.ts +159 -0
  48. package/types/modules/network/index.d.ts +50 -3
  49. package/types/protocol/capabilities.d.ts +2 -2
  50. package/types/protocol/constants.d.ts +1 -1
  51. package/types/protocol/guards.d.ts +1 -1
  52. package/types/protocol/types.d.ts +1 -1
  53. package/types/protocol.d.ts +4 -3
  54. package/types/skill-metadata.d.ts +0 -4
  55. package/dist/cli-chunks/doctor-C95gIao_.cjs +0 -204
  56. package/dist/devtools/browser-dev-host/main.js +0 -12263
  57. package/skill/scripts/check-references.mjs +0 -14
  58. package/skill/scripts/markdown-sections.mjs +0 -36
  59. package/skill/scripts/package-skill.mjs +0 -60
  60. package/skill/scripts/package-skill.sh +0 -6
  61. package/skill/scripts/skill-metadata.mjs +0 -77
  62. package/skill/scripts/sync-agent-skills-payload.mjs +0 -359
  63. package/skill/scripts/sync-references.mjs +0 -794
  64. package/skill/scripts/validate-skill.mjs +0 -263
package/skill/SKILL.md CHANGED
@@ -51,17 +51,19 @@ Apply these instructions when writing, reviewing, or debugging code that consume
51
51
  11. `user.getSteamGameList()` is available only to network-disabled mini-programs. In a network-enabled mini-program it returns `SERVER_API_REQUIRED`, and there is no Steam library authorization scope or OpenAPI resource. Treat `user.getInfo()` returning `SERVER_API_REQUIRED` as a server-boundary signal, not as logged-out state.
52
52
  12. Use `share.showShareMenu({ post })` or `share.screenshot({ post })` to preset editable community destinations and topics. Pass partition IDs through `topicIds` and topic text without surrounding `#` through `topics`; do not construct the underlying client post protocol.
53
53
  13. Use `share.showShareMenu({ extra })` to open the share menu or `share.copyLink({ extra })` to copy and return the default mini-program share link. Read the JSON-compatible page state synchronously with `share.getExtra()` after launch, validate the developer-defined fields, and fall back to the default page when it returns `undefined`.
54
+ 14. Treat `files` and `network.download()` as a retained public contract that is not yet enabled by a current Host. The legacy PC adapter was dropped because the new PC will implement the Host ports directly. Until then, legacy PC, Mobile, Web, and Browser Dev Host return `METHOD_FORBIDDEN` and provide no memory/Blob fallback. Once a supporting Host is available, call `files.pickFiles()` / `pickDirectory()` / `saveFile()` only from trusted user actions; `saveFile()` accepts only `suggestedName`, `remove()` only deletes sandbox objects, and non-empty directories require `remove({ recursive: true })`.
55
+ 15. Use `network.download()` only with an SDK-created File/Directory target. It is GET-only, does not follow redirects, and exposes local `AbortSignal` / progress callbacks without sending functions over the bridge. Abort is a cancellation intent; a Host commit that already won still resolves successfully.
54
56
 
55
57
  ## Step 5: Use CLI workflows
56
58
 
57
59
  1. Use `hb-sdk create <project-name>` to scaffold a workshop mini-program.
58
- 2. Use `hb-sdk dev` for Browser Mock, Mac App, or Mobile App debugging. It requires an active CLI login, a bound Mini-program, and an available remote Dev Context; it must stop before starting Vite or any debugging service when a prerequisite is missing. Mobile uses the `open_inapp` and `heybox://` `openWindow` wrapper with a LAN short URL, then opens `heybox-mini-dev://sandbox` with the complete launch context.
59
- 3. Treat debugging-page permission overrides as local development behavior; overrides do not change remote permissions. Use `--port`, `--browser-dev-host-port`, and `--no-open` to control local endpoints and browser opening. Select a Mobile network interface the device can reach. `launch.json` is a LAN discovery document, not authentication, encryption, signing, or HMAC protection.
60
+ 2. Use `hb-sdk dev` for Browser Mock and Mobile App debugging. Browser debugging can start without CLI login, project binding, or a remote Dev Context; capabilities that need those inputs fail explicitly. Mobile uses the single QR entry with the `open_inapp` and `heybox://` `openWindow` wrapper around a LAN short URL, then opens `heybox-mini-dev://sandbox` with the complete launch context.
61
+ 3. The debugging page does not edit permissions. Treat the validated remote permission snapshot as canonical Runtime input. Use `--port`, `--browser-dev-host-port`, and `--no-open` to control local endpoints and browser opening. Select a Mobile network interface the device can reach. `launch.json` is a LAN discovery document, not authentication, encryption, signing, or HMAC protection.
60
62
  4. Use `hb-sdk build [--env <name>] [--verbose]` as the recommended production build entry. It directly owns the Vite build, always cleans and writes `dist/`, and works without CLI login, project binding, or network access.
61
63
  5. Keep `miniappManifest()` explicitly enabled in `vite.config.ts`; `hb-sdk build` must fail when the required Manifest or Runtime gate output is missing.
62
64
  6. Keep project typechecking in `scripts.build`, for example `vue-tsc --noEmit && hb-sdk build`; `hb-sdk build` does not run typechecking or invoke `scripts.build` itself.
63
65
  7. Existing projects may continue to use `vite build`; do not auto-migrate them. Do not invent `--mode`, `--json`, config, or output-directory flags for `hb-sdk build`.
64
- 8. Use `hb-sdk login`, `hb-sdk login status`, and `hb-sdk login clear` for development, publishing, and Browser Mock Host `heybox-session` requests. Mini-program code must still call `auth.login()`; the debug page only confirms authorization. Do not paste CLI credentials into page JavaScript. Phone debugging continues to use the App login.
66
+ 8. Use `hb-sdk login`, `hb-sdk login status`, and `hb-sdk login clear` for remote management, publishing, Mobile debugging, and optional Browser Mock Host `heybox-session` requests. Browser debugging itself can start without CLI login. Mini-program code must still call `auth.login()`; the debug page only confirms authorization. Do not paste CLI credentials into page JavaScript. Phone debugging continues to use the App login.
65
67
  9. Use `hb-sdk remote entity current` to confirm the current developer account and `hb-sdk remote entity switch <entity-id>` to change it before remote operations.
66
68
  10. Use `hb-sdk remote create` to create and bind a mini-program; use `hb-sdk remote bind <mini-program-id>` to bind an existing manageable mini-program.
67
69
  11. 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 remote inspection and preview management.
@@ -81,11 +83,12 @@ For workshop mini-program business code:
81
83
  1. Do not read or request tokens, cookies, phone numbers, or private credentials from the SDK.
82
84
  2. Do not expose raw share protocol fields, JS callbacks, activity reporting, custom buttons, direct post publishing, or upload-only flows. Public `share.*({ post })` options only preset an editable client post flow and never publish automatically.
83
85
  3. Do not use unsupported storage operations such as delete, clear, info listing, or global client storage access.
84
- 4. Use only the public `network.request` configuration.
86
+ 4. Use only the public `network.request` / `network.download` configurations.
85
87
  5. Do not use private package paths or client protocols.
86
88
  6. Build artifacts may include `dist/manifest.json`; business code should not fetch a deployed manifest directly because it is not a CDN asset.
87
89
  7. Do not use `network.request()` to reach platform-reserved runtime auth or OpenAPI internal paths.
88
90
  8. Do not expose credentials or describe internal Host authorization state machines and routes in app-facing guidance.
91
+ 9. Do not invent string paths, File System Access API handles, Blob downloads, uploads, Range/resume, external deletion, move, append, or persistent external grants. Public file operations use only SDK-created handles; deletion is limited to SDK sandbox handles.
89
92
 
90
93
  For CLI and local development:
91
94
 
@@ -93,8 +96,9 @@ For CLI and local development:
93
96
  2. Do not skip `auth.login()` in mini-program code. Browser Mock may reuse the Node `hb-sdk login` session for Host network requests, but the page must still call `auth.login()` and handle the authorization dialog. Never paste CLI credentials into page JavaScript.
94
97
  3. Use the built-in local debugging page instead of creating another browser Mock.
95
98
  4. Keep the Vite `miniappManifest()` plugin enabled.
96
- 5. Treat permission changes made in the `hb-sdk dev` debugging page as local debugging overrides, not online configuration changes. Use the page's reset action to return to the remote baseline.
99
+ 5. Do not suggest changing or resetting permissions in the `hb-sdk dev` debugging page; that UI does not exist. Diagnose permission behavior from the remote snapshot and capability result.
97
100
  6. Treat browser Mock results as development feedback only. Validate permissions, identity flows, and user interactions again in a real Heybox client before publishing.
101
+ 7. The Browser Dev Host offers iPhone 16 Pro Max (`440 x 956`) and Pixel 9 Pro (`410 x 914`) presets. Switching a preset must preserve the iframe, Runtime session, and page state. Authorization/action dialogs, Toast, Loading, and vibration feedback render inside the preview. Use the upper-right QR popover as the only Mobile QR entry.
98
102
 
99
103
  For host/runtime/protocol-maintenance code:
100
104
 
@@ -110,17 +114,16 @@ For host/runtime/protocol-maintenance code:
110
114
  - `cat packages/hb-sdk/DOC_SYNC_CHECKLIST.md`
111
115
  3. When preparing a package release, run `pnpm --filter @heybox/hb-sdk run release:prepare -- --bump patch` or `pnpm --filter @heybox/hb-sdk run release:prepare -- --version <x.y.z>`. The release assistant updates the Protocol/Runtime/SDK family versions, inserts `packages/hb-sdk/CHANGELOG.md`, and runs `check:changelog`. Use `--ai-command "<command>"` or `HB_SDK_CHANGELOG_AI_COMMAND` when an AI writer should rewrite the Conventional Commit draft. Review the entry for Mini-program developers and Host/Runtime integration maintainers, and do not expose Runtime internal adapter, state-machine, or security-policy details.
112
116
  4. When modifying this repo's source skill at `packages/hb-sdk/skill` and preparing distributable artifacts, also run:
113
- - `node packages/hb-sdk/skill/scripts/package-skill.mjs`
117
+ - `node packages/hb-sdk/scripts/skill/sync-references.mjs`
118
+ - `node packages/hb-sdk/scripts/skill/validate-skill.mjs`
114
119
  5. When modifying CLI, local debugging, package exports, or package dependency direction, also run:
115
120
  - `pnpm --filter @heybox/hb-sdk run check:boundary`
116
121
  - `pnpm --filter @heybox/hb-sdk run test:unit`
117
- 6. Inspect the generated zip before distribution:
118
- - `unzip -l packages/hb-sdk/hb-sdk.zip | sed -n '1,120p'`
119
- 7. When adding or modifying the deploy command or its upload pipeline, also run:
122
+ 6. When adding or modifying the deploy command or its upload pipeline, also run:
120
123
  - `pnpm --filter @heybox/hb-sdk run check:boundary`
121
124
  - `pnpm --filter @heybox/hb-sdk run test:unit`
122
125
  - Verify `dist/cli.cjs` does not have any `require('cos-nodejs-sdk-v5')` left after `build:cli`; the boundary check enforces this automatically.
123
- 8. Verify the canonical payload before publishing:
124
- - `pnpm exec hbexec hb-sdk sync`
125
- - `pnpm exec hbexec hb-sdk check`
126
- - For a release artifact, run `pnpm exec hbexec hb-sdk sync --out-dir <payload-dir>` and then `pnpm exec hbexec hb-sdk check-artifact --artifact-dir <payload-dir>`.
126
+ 7. Verify the canonical payload before publishing:
127
+ - `node packages/hb-sdk/scripts/skill/sync-references.mjs`
128
+ - `node packages/hb-sdk/scripts/skill/validate-skill.mjs`
129
+ - For a release artifact, run `npm pack --dry-run` and `node packages/hb-sdk/scripts/skill/verify-tarball-install.mjs`.
@@ -1,6 +1,6 @@
1
1
  # Protocol API reference
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -26,16 +26,33 @@ export {
26
26
  CLOUD_LEADERBOARD_GET_INFO_METHOD,
27
27
  CLOUD_LEADERBOARD_GET_LIST_METHOD,
28
28
  CLOUD_LEADERBOARD_SUBMIT_METHOD,
29
+ DIRECTORY_CREATE_METHOD,
30
+ DIRECTORY_EXISTS_METHOD,
31
+ DIRECTORY_LIST_METHOD,
32
+ DIRECTORY_REMOVE_METHOD,
29
33
  DEVICE_SET_CLIPBOARD_METHOD,
30
34
  DEVICE_VIBRATE_METHOD,
35
+ FILES_PICK_DIRECTORY_METHOD,
36
+ FILES_PICK_FILES_METHOD,
37
+ FILES_SAVE_FILE_METHOD,
38
+ FILE_CREATE_METHOD,
39
+ FILE_EXISTS_METHOD,
40
+ FILE_READ_BYTES_METHOD,
41
+ FILE_READ_TEXT_METHOD,
42
+ FILE_REMOVE_METHOD,
43
+ FILE_STAT_METHOD,
44
+ FILE_WRITE_BYTES_METHOD,
45
+ FILE_WRITE_TEXT_METHOD,
31
46
  MINI_PROGRAM_BRIDGE_NONCE_PARAM,
32
47
  MINI_PROGRAM_MESSAGE_NAMESPACE,
33
48
  MINI_PROGRAM_MESSAGE_VERSION,
49
+ MINI_PROGRAM_OPERATION_PROGRESS_METHOD,
34
50
  MINI_PROGRAM_PROTOCOL_CAPABILITIES,
35
51
  NAVIGATION_CLOSE_METHOD,
36
52
  NAVIGATION_OPEN_APP_PAGE_METHOD,
37
53
  NAVIGATION_RELOAD_METHOD,
38
54
  NETWORK_REQUEST_METHOD,
55
+ NETWORK_DOWNLOAD_METHOD,
39
56
  SDK_HANDSHAKE_METHOD,
40
57
  SHARE_COPY_LINK_METHOD,
41
58
  SHARE_SCREENSHOT_METHOD,
@@ -52,7 +69,17 @@ export {
52
69
  VIEWPORT_GET_WINDOW_INFO_METHOD,
53
70
  VIEWPORT_SET_NAVIGATION_BAR_STYLE_METHOD,
54
71
  isManagedMiniProgramRuntimePermissionKey,
72
+ isMiniProgramByteArray,
55
73
  isMiniProgramBridgeMessage,
74
+ isMiniProgramDirectoryDescriptor,
75
+ isMiniProgramDirectoryRef,
76
+ isMiniProgramDownloadProgressPayload,
77
+ isMiniProgramFileDescriptor,
78
+ isMiniProgramFileRef,
79
+ isMiniProgramFileStat,
80
+ isMiniProgramFileSystemEntityDescriptor,
81
+ isMiniProgramPathRootRef,
82
+ isMiniProgramRelativePath,
56
83
  parseMiniProgramRuntimePermissions,
57
84
  } from '@heybox/hb-sdk-protocol';
58
85
 
@@ -62,6 +89,14 @@ export type {
62
89
  CloseResult,
63
90
  CopyLinkPayload,
64
91
  CopyLinkResult,
92
+ DirectoryCreatePayload,
93
+ DirectoryCreateResult,
94
+ DirectoryExistsPayload,
95
+ DirectoryExistsResult,
96
+ DirectoryListPayload,
97
+ DirectoryListResult,
98
+ DirectoryRemovePayload,
99
+ DirectoryRemoveResult,
65
100
  DeleteCurrentUserLeaderboardEntryPayload,
66
101
  DeleteCurrentUserLeaderboardEntryResult,
67
102
  GetCurrentUserLeaderboardEntryPayload,
@@ -78,8 +113,25 @@ export type {
78
113
  GetUserInfoResult,
79
114
  GetWindowInfoPayload,
80
115
  GetWindowInfoResult,
116
+ DownloadProgressPayload,
81
117
  HideLoadingPayload,
82
118
  HideLoadingResult,
119
+ FileCreatePayload,
120
+ FileCreateResult,
121
+ FileExistsPayload,
122
+ FileExistsResult,
123
+ FileReadBytesPayload,
124
+ FileReadBytesResult,
125
+ FileReadTextPayload,
126
+ FileReadTextResult,
127
+ FileRemovePayload,
128
+ FileRemoveResult,
129
+ FileStatPayload,
130
+ FileStatResult,
131
+ FileWriteBytesPayload,
132
+ FileWriteBytesResult,
133
+ FileWriteTextPayload,
134
+ FileWriteTextResult,
83
135
  LeaderboardEntry,
84
136
  LeaderboardOrder,
85
137
  LoginPayload,
@@ -87,8 +139,10 @@ export type {
87
139
  LoginScope,
88
140
  MiniProgramAuthMethod,
89
141
  MiniProgramBridgeError,
142
+ MiniProgramBridgeCancelMessage,
90
143
  MiniProgramBridgeMessage,
91
144
  MiniProgramBridgeMessageType,
145
+ MiniProgramBridgeProgressMessage,
92
146
  MiniProgramBridgeMethod,
93
147
  MiniProgramCapabilityDefinition,
94
148
  MiniProgramCapabilityModule,
@@ -99,8 +153,23 @@ export type {
99
153
  MiniProgramCapabilityRisk,
100
154
  MiniProgramCloudMethod,
101
155
  MiniProgramDeviceMethod,
156
+ MiniProgramDirectoryDescriptor,
157
+ MiniProgramDirectoryMethod,
158
+ MiniProgramDirectoryRef,
159
+ MiniProgramDirectDirectoryRef,
160
+ MiniProgramDirectFileRef,
102
161
  MiniProgramEventName,
103
162
  MiniProgramEventPayloadMap,
163
+ MiniProgramFileDescriptor,
164
+ MiniProgramFileMode,
165
+ MiniProgramFileMethod,
166
+ MiniProgramFileRef,
167
+ MiniProgramFilesMethod,
168
+ MiniProgramFileStat,
169
+ MiniProgramFileSystemEntityDescriptor,
170
+ MiniProgramFileSystemEntityRef,
171
+ MiniProgramPathRootRef,
172
+ MiniProgramSandboxRootRef,
104
173
  MiniProgramNavigationBarForegroundStyle,
105
174
  MiniProgramNavigationMethod,
106
175
  MiniProgramNetworkHeaders,
@@ -125,11 +194,17 @@ export type {
125
194
  MiniProgramWindowInfoResult,
126
195
  NetworkRequestPayload,
127
196
  NetworkResponsePayload,
197
+ NetworkDownloadPayload,
198
+ NetworkDownloadResult,
128
199
  OpenAppPagePayload,
129
200
  OpenAppPageResult,
130
201
  OpenGameDetailAppPagePayload,
131
202
  OpenPostDetailAppPagePayload,
132
203
  OpenUserDetailAppPagePayload,
204
+ PickDirectoryPayload,
205
+ PickDirectoryResult,
206
+ PickFilesPayload,
207
+ PickFilesResult,
133
208
  ParsedMiniProgramRuntimePermissions,
134
209
  ReloadPayload,
135
210
  ReloadResult,
@@ -137,6 +212,8 @@ export type {
137
212
  RevokeAuthorizationResult,
138
213
  ScreenshotPayload,
139
214
  ScreenshotResult,
215
+ SaveFilePayload,
216
+ SaveFileResult,
140
217
  SDKHandshakePayload,
141
218
  SetClipboardPayload,
142
219
  SetClipboardResult,
@@ -167,10 +244,29 @@ export type { LoginOptions } from './modules/auth';
167
244
  export type { GetSteamGameListOptions } from './modules/user';
168
245
  export type { MiniProgramEventHandler } from './protocol/types';
169
246
  export type {
247
+ DownloadBaseOptions,
248
+ DownloadOptions,
249
+ DownloadProgress,
170
250
  MiniProgramNetworkRequestConfig,
171
251
  MiniProgramNetworkResponse,
172
252
  MiniProgramNetworkValidateStatus,
173
253
  } from './modules/network';
254
+ export type {
255
+ CreateOptions,
256
+ DirectoryHandle,
257
+ FileHandle,
258
+ FileMode,
259
+ FileStat,
260
+ FileSystem,
261
+ FileSystemEntity,
262
+ FilesModule,
263
+ ListOptions,
264
+ PathRoot,
265
+ PickDirectoryOptions,
266
+ PickFilesOptions,
267
+ RemoveOptions,
268
+ SaveFileOptions,
269
+ } from './modules/files';
174
270
  export type { MiniProgramScreenshotOptions, MiniProgramShowShareMenuOptions } from './modules/share';
175
271
  export type { MiniProgramSetNavigationBarStyleOptions } from './modules/viewport';
176
272
  ```
@@ -201,12 +297,12 @@ Reference 由 `@heybox/hb-sdk` 的公开导出与源码注释自动生成,不
201
297
 
202
298
  | 导出面 | Classes | Functions | Interfaces | Types | Constants |
203
299
  | --- | ---: | ---: | ---: | ---: | ---: |
204
- | Root API | 2 | 4 | 51 | 57 | 1 |
205
- | Protocol API | 0 | 3 | 34 | 62 | 30 |
300
+ | Root API | 2 | 4 | 65 | 60 | 1 |
301
+ | Protocol API | 0 | 13 | 56 | 90 | 47 |
206
302
  | Miniapp Publish API | 0 | 5 | 2 | 0 | 0 |
207
303
  | Vite API | 0 | 1 | 5 | 1 | 1 |
208
304
 
209
- <!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=2; fingerprint=d54639a086217e53edf8a85d2e11e0f0263aa0fd3dc88183fe2b3f3f07b4f4a1 -->
305
+ <!-- Generated by apps/docs/hb-sdk/scripts/generate-api-docs.ts; schemaVersion=2; fingerprint=cb985ad876f7066639ee3b72d545185f251ed6ad597b8276425e02615bb608ba -->
210
306
 
211
307
  ## SDK API
212
308
 
@@ -1,6 +1,6 @@
1
1
  # Root API reference
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -24,7 +24,7 @@
24
24
  ## Package metadata
25
25
 
26
26
  - Package: `@heybox/hb-sdk`
27
- - Version at generation time: `0.8.0-alpha`
27
+ - Version at generation time: `0.8.0-alpha.3`
28
28
  - Public root export: `@heybox/hb-sdk`
29
29
  - Protocol export: `@heybox/hb-sdk/protocol`
30
30
  - Vite plugin export: `@heybox/hb-sdk/vite`
@@ -43,6 +43,7 @@ export {
43
43
  share,
44
44
  viewport,
45
45
  storage,
46
+ files,
46
47
  network,
47
48
  ui,
48
49
  device,
@@ -117,6 +118,9 @@ export type {
117
118
  } from './modules/viewport';
118
119
  export type { GetStoragePayload, GetStorageResult, MiniProgramStorageModule, SetStoragePayload } from './modules/storage';
119
120
  export type {
121
+ DownloadBaseOptions,
122
+ DownloadOptions,
123
+ DownloadProgress,
120
124
  MiniProgramNetworkHeaders,
121
125
  MiniProgramNetworkModule,
122
126
  MiniProgramNetworkParams,
@@ -127,6 +131,22 @@ export type {
127
131
  NetworkRequestPayload,
128
132
  NetworkResponsePayload,
129
133
  } from './modules/network';
134
+ export type {
135
+ CreateOptions,
136
+ DirectoryHandle,
137
+ FileHandle,
138
+ FileMode,
139
+ FileStat,
140
+ FileSystem,
141
+ FileSystemEntity,
142
+ FilesModule,
143
+ ListOptions,
144
+ PathRoot,
145
+ PickDirectoryOptions,
146
+ PickFilesOptions,
147
+ RemoveOptions,
148
+ SaveFileOptions,
149
+ } from './modules/files';
130
150
  export type {
131
151
  HideLoadingPayload,
132
152
  HideLoadingResult,
@@ -177,6 +197,7 @@ import {
177
197
  onHandshakeStateChange,
178
198
  share,
179
199
  storage,
200
+ files,
180
201
  ui,
181
202
  viewport,
182
203
  user,
@@ -192,6 +213,7 @@ const hbSDK = {
192
213
  share,
193
214
  viewport,
194
215
  storage,
216
+ files,
195
217
  network,
196
218
  ui,
197
219
  device,
@@ -428,7 +450,7 @@ import hbSDK, { type MiniProgramSDKHandshakeState } from '@heybox/hb-sdk'
428
450
  import { computed, onUnmounted, ref } from 'vue'
429
451
 
430
452
  const handshakeState = ref<MiniProgramSDKHandshakeState>(hbSDK.getHandshakeState())
431
- const stopHandshakeState = hbSDK.onHandshakeStateChange((state) => {
453
+ const stopHandshakeState = hbSDK.onHandshakeStateChange(state => {
432
454
  handshakeState.value = state
433
455
  })
434
456
  const sdkReady = computed(() => handshakeState.value.status === 'ready')
@@ -484,6 +506,102 @@ async function loginFromUserAction() {
484
506
 
485
507
  返回值与边界以[用户身份与登录](https://docs.xiaoheihe.cn/hb_sdk/guide/auth)为准。页面只把 `code` 提交给自己的服务端。不要在页面初始化阶段自动调用 `auth.login()`。
486
508
 
509
+ ## 文件与下载
510
+
511
+ `files.sandbox` 是当前小程序隔离的逻辑根。`file()` / `directory()` 只创建 lazy proxy,不执行
512
+ I/O;第一次真实 I/O 仍由 Runtime 和 Host 校验当前 session、授权、mode、kind 和路径。
513
+
514
+ ```ts
515
+ import hbSDK, { HbMiniProgramSDKError } from '@heybox/hb-sdk'
516
+
517
+ const exportDirectory = hbSDK.files.sandbox.directory('exports')
518
+ await exportDirectory.create({ recursive: true })
519
+
520
+ const controller = new AbortController()
521
+
522
+ try {
523
+ const file = await hbSDK.network.download({
524
+ url: 'https://cdn.example.com/report.json',
525
+ to: exportDirectory,
526
+ suggestedName: 'report.json',
527
+ overwrite: true,
528
+ maxBytes: 8 * 1024 * 1024,
529
+ signal: controller.signal,
530
+ onProgress({ loaded, total, lengthComputable }) {
531
+ console.log(lengthComputable ? `${loaded}/${total}` : loaded)
532
+ },
533
+ })
534
+
535
+ console.log(await file.readText())
536
+ } catch (error) {
537
+ if (error instanceof HbMiniProgramSDKError && error.code === 'METHOD_FORBIDDEN') {
538
+ // 当前 Host 不支持 V1 文件能力。
539
+ return
540
+ }
541
+ throw error
542
+ }
543
+ ```
544
+
545
+ 当前平台状态如下:
546
+
547
+ | Host | `files.sandbox` | 外部 picker | `network.download()` |
548
+ | ---------------- | --------------- | ----------- | -------------------- |
549
+ | 旧版 PC | 不支持 | 不支持 | 不支持 |
550
+ | Mobile | 不支持 | 不支持 | 不支持 |
551
+ | Web | 不支持 | 不支持 | 不支持 |
552
+ | Browser Dev Host | 不支持 | 不支持 | 不支持 |
553
+
554
+ 当前 Runtime 认识但 Host 未实现时返回 `METHOD_FORBIDDEN`;旧 Runtime 收到新 method 时返回
555
+ `METHOD_NOT_FOUND`。此前曾实现面向旧版小黑盒 PC 的 Host 适配;由于新版 PC 即将启用,该适配
556
+ 不再发布。文件/下载 API、协议和 Runtime 体系保持不变,后续直接按照新版 PC Host 架构接入。
557
+ 当前任何 Host 都不提供 Blob 或内存假下载。
558
+
559
+ ### 路径与创建
560
+
561
+ - 逻辑相对路径统一使用 `/`。拒绝空字符串、绝对路径、空 segment、`.`、`..`、反斜杠、尾分隔符、NUL 和控制字符。
562
+ - `create()` 的 `recursive` 与 `exclusive` 默认均为 `false`。默认行为是不截断内容的 ensure-exists;`exclusive: true` 在同名实体已存在时失败。
563
+ - `writeText()` / `writeBytes()` 可以在父目录存在时隐式创建目标,但不会自动创建父目录。
564
+ - `exists()` 在祖先/目标缺失或 kind mismatch 时返回 `false`;授权撤销、quota 与 I/O 错误仍抛出。
565
+ - `file.remove()` 与 `directory.remove()` 只删除 sandbox 对象;外部 picker/saveFile 授权调用删除时抛出 `FILE_ACCESS_DENIED`。
566
+ - 非空目录默认不能删除并抛出 `DIRECTORY_NOT_EMPTY`;确认删除整个目录树后显式调用 `directory.remove({ recursive: true })`。
567
+ - `directory.list()` 默认最多返回 1000 项,显式 `limit` 也不能超过 1000;超限抛出 `DIRECTORY_LIST_LIMIT_EXCEEDED`。
568
+ - Host 文件错误只暴露稳定 code 与 canonical 安全文案;原始 message、data、native path 和 credential 不会进入小程序。
569
+ - `FileStat.size` 是字节数;`modifiedAt` / `createdAt` 若存在,单位为 Unix epoch milliseconds。
570
+
571
+ ### 外部授权与保存
572
+
573
+ `pickFiles()`、`pickDirectory()` 和 `saveFile()` 必须直接从按钮点击等可信用户操作调用。picker
574
+ 取消会抛 `FILE_PICKER_CANCELLED`,不会返回空数组或 `undefined`。
575
+
576
+ ```ts
577
+ async function saveFromUserAction(text: string) {
578
+ const file = await hbSDK.files.saveFile({ suggestedName: 'report.json' })
579
+ await file.writeText(text)
580
+ }
581
+ ```
582
+
583
+ `saveFile()` 打开系统保存对话框并返回精确 File 授权,不会同时创建或保留 Directory
584
+ 授权。V1 不接受 `accept`;扩展名过滤只属于 `pickFiles({ accept: ['.json'] })`。外部授权仅在当前
585
+ Runtime session 有效。
586
+
587
+ `pickFiles()` / `pickDirectory()` 默认返回 `mode: 'read'` 的授权;只有显式传入
588
+ `multiple: true` 时,`pickFiles()` 才允许 Host 返回多个文件。需要修改文件、在所选目录中创建
589
+ 文件,或把外部授权用作下载目标时,必须在 picker options 中显式请求 `mode: 'readwrite'`。
590
+
591
+ 单个 Runtime session 最多保留 1024 个 picker/saveFile direct handle;整批选择超过剩余额度时抛出 `FILE_QUOTA_EXCEEDED`,不会保留部分授权。Sandbox 派生项与目录枚举结果使用逻辑引用,不持续占用该额度。
592
+
593
+ ### 下载边界
594
+
595
+ - 下载固定使用 GET,不接受 method、body、上传或 Range 字段。
596
+ - File target 必须已存在且为 `readwrite`,成功后返回同一个 File proxy;Directory target 必须存在且为 `readwrite`,成功后返回新的子 File proxy。
597
+ - Directory 默认不覆盖同名文件;只有显式 `overwrite: true` 才允许原子替换。
598
+ - Directory target 的子文件名按安全的 `Content-Disposition filename*` / `filename`、`suggestedName`、URL basename、`download.bin` 依次选择。
599
+ - `timeout` 是网络空闲超时,不是整个下载总时长。取消或失败不会改动原目标。
600
+ - `AbortSignal` 只发出取消意图并等待 Host 终态;如果 Host 已先完成原子提交,Promise 仍以成功结果 resolve,否则抛出 `DOWNLOAD_CANCELLED`。
601
+ - 公开 request 与 download 都不跟随重定向;3xx 或 partial representation 会失败。
602
+ - 进度从 `loaded: 0` 开始并单调不减;原子提交后、Promise resolve 前会再发送一次 final progress,因此空文件或 Host 已报告最终值时允许相邻值相同。只有无歧义、identity-encoded 的 `Content-Length` 才使 `lengthComputable=true`;压缩、chunked 或重复长度都视为未知 total,可信长度必须在提交前与实际字节数一致。
603
+ - `onProgress` 在本地同步执行;回调异常不会中断下载。成功时最后一次回调发生在文件提交后、Promise resolve 前。
604
+
487
605
  ## 默认单例
488
606
 
489
607
  大多数小程序页面都应该使用默认实例。0.6 起不再对业务代码提供独立实例工厂。
@@ -523,6 +641,10 @@ try {
523
641
  - `USER_GESTURE_REQUIRED` 表示潜在授权 UI 缺少可信用户手势,应让用户点击按钮后重试。
524
642
  - `AUTHORIZATION_CANCELLED` 表示用户取消、拒绝或关闭授权页面,应正常结束当前操作。
525
643
  - `SERVER_API_REQUIRED` 表示当前用户数据必须经开发者服务端 OpenAPI 获取,不应在页面重试对应 Host API。
644
+ - `METHOD_FORBIDDEN` 表示当前 Host 未实现或关闭对应能力。V1 files/download 在 Mobile、Web 和 Browser Dev Host 都会得到该错误。
645
+ - `FILE_PICKER_CANCELLED` 表示用户取消了外部文件或目录选择,应正常结束当前操作。
646
+ - `DOWNLOAD_CANCELLED` 表示取消意图先于 Host 提交生效;Host 已完成提交时仍返回成功。`DOWNLOAD_TIMEOUT` 表示网络空闲超时,失败不会改动原目标。
647
+ - `DOWNLOAD_HTTP_STATUS` 的 `data` 只包含脱敏后的 `status`、可选 `statusText` 和安全响应头。
526
648
  - 超时或运行环境不可用时,允许用户重试或退出当前流程。
527
649
  - 上报 `code`、`message` 和必要的业务上下文,不要上报用户凭据或敏感数据。
528
650
 
@@ -571,24 +693,29 @@ function reportSDKError(errorCode: string, message: string, data?: unknown) {
571
693
 
572
694
  授权码在取得后立即交给开发者服务端交换,不要写入页面状态、DOM、日志或持久化存储。UI 只处理服务端会话是否建立成功。
573
695
 
696
+ 文件与下载仍使用 `HbMiniProgramSDKError`,不会新增第三种错误类。业务根据 `error.code` 处理
697
+ picker 取消、授权撤销、文件缺失、quota、下载状态或取消,不依赖 `message` 文案,也不要记录
698
+ 真实路径、内部 handle 或响应凭据头。
699
+
574
700
  ## Public modules
575
701
 
576
702
  ## 能力概览
577
703
 
578
704
  SDK 还提供 `getHandshakeState()` / `onHandshakeStateChange()` 管理持久握手状态,并通过 `on()` / `off()` 处理前后台、登录态等生命周期事件。
579
705
 
580
- | 模块 | 用途 |
581
- | ------------ | ------------------------------------------ |
582
- | `auth` | 获取交给开发者服务端交换的短期授权码 |
583
- | `user` | 读取 Host 当前用户资料、隔离身份或撤销授权 |
584
- | `share` | 打开分享、复制链接或截图分享流程 |
585
- | `ui` | 展示 Toast 和 Loading |
586
- | `device` | 调用振动和剪贴板能力 |
587
- | `navigation` | 关闭、刷新页面或打开小黑盒页面 |
588
- | `viewport` | 读取窗口信息和设置导航栏样式 |
589
- | `storage` | 读写当前小程序的隔离存储 |
590
- | `cloud` | 使用小程序云端排行榜 |
591
- | `network` | 发起经过平台授权的网络请求 |
706
+ | 模块 | 用途 |
707
+ | ------------ | ----------------------------------------------- |
708
+ | `auth` | 获取交给开发者服务端交换的短期授权码 |
709
+ | `user` | 读取 Host 当前用户资料、隔离身份或撤销授权 |
710
+ | `share` | 打开分享、复制链接或截图分享流程 |
711
+ | `ui` | 展示 Toast 和 Loading |
712
+ | `device` | 调用振动和剪贴板能力 |
713
+ | `navigation` | 关闭、刷新页面或打开小黑盒页面 |
714
+ | `viewport` | 读取窗口信息和设置导航栏样式 |
715
+ | `storage` | 读写当前小程序的隔离存储 |
716
+ | `files` | 声明受控 sandbox 与用户选择授权的文件、目录操作 |
717
+ | `cloud` | 使用小程序云端排行榜 |
718
+ | `network` | 发起经过平台授权的网络请求,并声明受控流式下载 |
592
719
 
593
720
  具体方法、参数和返回值以 [API Reference](https://docs.xiaoheihe.cn/hb_sdk/reference/) 为准,常见组合写法见 [Recipes](https://docs.xiaoheihe.cn/hb_sdk/recipes/)。
594
721
 
@@ -1,6 +1,6 @@
1
1
  # CLI reference
2
2
 
3
- > Generated by `node packages/hb-sdk/skill/scripts/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
3
+ > Generated by `node packages/hb-sdk/scripts/skill/sync-references.mjs` from the public hb-sdk source/docs. Do not edit by hand; update sources or this generator instead.
4
4
 
5
5
  ## Sources
6
6
 
@@ -27,7 +27,7 @@
27
27
  - [Update reminders](#update-reminders)
28
28
  ## When to use the CLI
29
29
 
30
- 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.
30
+ Use the bundled `hb-sdk` CLI to create a workshop mini-program, open the local Browser debugging workbench, test in the Heybox mobile App, or manage and publish a remote mini-program.
31
31
 
32
32
  `hb-sdk login` is for development and publishing commands only. It does not authorize mini-program users and does not change `auth.login()`, `user.getInfo()`, or `network.request()` inside a mini-program.
33
33
 
@@ -40,7 +40,8 @@ hb-sdk build [--env <name>] [--verbose]
40
40
  hb-sdk login
41
41
  hb-sdk login status
42
42
  hb-sdk login clear
43
- hb-sdk doctor
43
+ hb-sdk skill install [--global] [--agent <agent>] [--all-agents] [--force]
44
+ hb-sdk doctor [--agent <agent>] [--all-agents] [--json]
44
45
  hb-sdk remote access
45
46
  hb-sdk remote entity list
46
47
  hb-sdk remote entity current
@@ -100,15 +101,15 @@ Agent rules:
100
101
  hb-sdk dev
101
102
  ```
102
103
 
103
- CLI 会启动页面服务并自动打开本地调试页。调试页会展示小程序、浏览器 Mock、Mac 启动入口和手机二维码。
104
+ CLI 会启动页面服务并自动打开 Vue 3 本地调试台。左侧集中放置调用日志、Storage 和问题三个诊断页签,右侧保持稳定的小程序内容与设备预览。
104
105
 
105
- <img src="https://static.max-c.com/static/heybox/webapp/heybox-docs/docs-hb_sdk/assets/local-preview-debug-page.png" alt="hb-sdk 本地调试页、浏览器 Mock 和真机调试入口" style="width: 100%; max-width: 860px;" />
106
+ <img src="/assets/browser-dev-host-workbench.png" alt="小程序工坊 Vue 3 调试台" style="width: 100%; max-width: 1120px;" />
106
107
 
107
- `hb-sdk dev` 不支持匿名调试。启动前必须先运行 `hb-sdk login`,并通过 `hb-sdk remote create` 或 `hb-sdk remote bind <mini-program-id>` 绑定当前项目;未登录、未绑定或远端 Dev Context 不可用时,CLI 会在启动 Vite 和调试服务前终止。
108
+ 浏览器调试入口不要求 CLI 登录或项目绑定。没有账号、绑定小程序或远端 Dev Context 时,页面和基础 Browser Mock 仍可启动;依赖这些上下文的能力会返回明确失败。远端管理、部署和发布仍要求完成登录与绑定。
108
109
 
109
- `hb-sdk dev` 会在启动 Vite 前读取远端权限。只有远端权限快照有效且 `network.request.status=enabled` 时才跳过平台 CSP;`useOfficialDomain` 不参与该判定。本地 Dev Context 权限覆盖不会改变 CSP 决策。
110
+ `hb-sdk dev` 在远端权限快照可用时读取它。只有快照有效且 `network.request.status=enabled` 时才跳过平台 CSP;`useOfficialDomain` 不参与该判定。调试台不提供权限修改入口,远端权限快照始终是 Runtime 的规范输入;快照缺失或无效时保留平台 CSP
110
111
 
111
- 当前调试链路不要求升级 Android、iOS 或 Mac 客户端。Browser Mock 会自动在实时与兼容链路间切换;Mobile 使用 `open_inapp`/`openWindow` 包裹的 LAN 短链接二维码(先开普通 H5 跳转页,再进入小程序并关闭中间页);PC/Mac 行为保持不变。
112
+ Browser Mock 会自动在实时与兼容链路间切换。手机调试使用 `open_inapp`/`openWindow` 包裹的 LAN 短链接二维码(先开普通 H5 跳转页,再进入小程序并关闭中间页)。
112
113
 
113
114
  ### 2. 先用浏览器 Mock 验收
114
115
 
@@ -118,13 +119,15 @@ CLI 会启动页面服务并自动打开本地调试页。调试页会展示小
118
119
  - SDK 初始化与用户身份授权流程
119
120
  - 生命周期、Storage 和排行榜等能力
120
121
 
121
- 调试页中调整的权限只影响当前本地调试,不会修改线上配置;切换权限后 Mobile App 会重生成二维码。Debug/Ad-Hoc 的本地增强不可用、过期或读取失败时继续使用原生 Host。恢复初始权限后重新按远端配置验收;工坊小程序默认不能进行网络请求,网络权限暂未开放申请,不要把本地结果当成线上能力。
122
+ 调试台提供紧凑的调用日志、当前小程序隔离作用域内的 Storage 只读快照和问题聚合。日志与网络记录只保留脱敏的诊断字段,不展示 payload、结果、查询参数、凭据或原始错误信息。工坊小程序默认不能进行网络请求,网络权限暂未开放申请,不要把本地结果当成线上能力。
122
123
 
123
- ### 3. 再用 Mac 或手机真机验收
124
+ 右侧可切换 iPhone 16 Pro Max(`387 x 821`)与 Pixel 9 Pro(`322 x 716`)两个设备预设。尺寸对应固定上游设备外框的真实屏幕 opening;预设同时决定外框、状态栏、安全区和 viewport。切换设备不会重新加载小程序或重启 Runtime,页面状态和调试会话保持不变。授权与操作弹窗、Toast、Loading 和振动反馈均显示在设备预览内部,不会覆盖整个调试台。
124
125
 
125
- 需要确认真实客户端表现时,可以使用调试页提供的 Mac 启动入口;手机验收则在「Mobile App」区域选择局域网网卡,再用手机小黑盒 APP 扫码。
126
+ ### 3. 再用手机真机验收
126
127
 
127
- 手机与电脑需要处于同一局域网。二维码走 HTTPS `open_inapp` `heybox://` `openWindow`,其中 `webview.url` 是局域网短链 `http://<lan-ip>:<browser-dev-host-port>/l/<token>`。短链返回跳转页:先打开带 `mini_url`、小程序身份、启动票、SDK 版本和局域网 Dev Context 的完整 `heybox-mini-dev://sandbox` 协议,约 500ms 后再发 `closeWindow` 关掉中间页。权限、网卡或启动票变化时调试页会刷新二维码并轮换 Dev Session。多网卡时选择手机实际可达的 **Network**。发布前至少完成一次真实客户端验收。
128
+ 需要确认真实客户端表现时,从调试台右上角唯一的二维码入口打开浮层,选择局域网网卡,再用手机小黑盒 APP 扫码。页面不再提供 Browser/Mobile 切换页签或其他二维码入口。
129
+
130
+ 手机与电脑需要处于同一局域网。二维码走 HTTPS `open_inapp` 与 `heybox://` `openWindow`,其中 `webview.url` 是局域网短链 `http://<lan-ip>:<browser-dev-host-port>/l/<token>`。短链返回跳转页:先打开带 `mini_url`、小程序身份、启动票、SDK 版本和局域网 Dev Context 的完整 `heybox-mini-dev://sandbox` 协议,约 500ms 后再发 `closeWindow` 关掉中间页。网卡或启动票变化时调试台会刷新二维码并轮换 Dev Session。多网卡时选择手机实际可达的 **Network**。发布前至少完成一次真实客户端验收。
128
131
 
129
132
  ### 浏览器 Mock 的边界
130
133
 
@@ -132,14 +135,16 @@ CLI 会启动页面服务并自动打开本地调试页。调试页会展示小
132
135
 
133
136
  ### 常用参数
134
137
 
135
- | 参数 | 用途 |
136
- | -------------------------------- | ------------------------------------------------------------- |
137
- | `--port <port>` | 指定页面开发服务端口。 |
138
- | `--browser-dev-host-port <port>` | 指定 Browser Dev Host 端口。 |
139
- | `--no-open` | 启动后不自动打开浏览器。 |
140
- | `--verbose` | 出现问题时输出更详细的诊断信息。 |
138
+ | 参数 | 用途 |
139
+ | -------------------------------- | -------------------------------- |
140
+ | `--port <port>` | 指定页面开发服务端口。 |
141
+ | `--browser-dev-host-port <port>` | 指定 Browser Dev Host 端口。 |
142
+ | `--no-open` | 启动后不自动打开浏览器。 |
143
+ | `--verbose` | 出现问题时输出更详细的诊断信息。 |
144
+
145
+ Use `hb-sdk dev` to open the local Vue 3 debugging workbench. Browser debugging can start without CLI login, project binding, or a remote Dev Context; capabilities that need them fail explicitly. The upper-right QR popover is the only Mobile entry and requires selecting a LAN interface the phone can reach.
141
146
 
142
- Use `hb-sdk dev` to open the local debugging page after CLI login and project binding are complete. Missing login, binding, or remote Dev Context stops before Vite and the debugging services start. The "Mobile App" QR code opens it in the phone App after a LAN interface is selected. The phone and computer must be on the same LAN.
147
+ The workbench offers iPhone 16 Pro Max (`440 x 956`) and Pixel 9 Pro (`410 x 914`) presets. Switching presets preserves the iframe, Runtime session, and page state. Authorization/action dialogs, Toast, Loading, and vibration feedback render inside the preview. Do not suggest a debugging-page permission editor; it does not exist, and the validated remote permission snapshot remains canonical.
143
148
 
144
149
  Browser Mock uses the Node `hb-sdk login` session to send Host `heybox-session` requests. Mini-program code must still call `auth.login()`; the debug page only shows an authorization dialog. Never copy pkey, cookies, tokens, or credential-bearing URLs into page JavaScript or logs. Phone debugging continues to use the App login, not the CLI session.
145
150
 
@@ -268,8 +273,8 @@ Agent rules:
268
273
 
269
274
  Agent rules:
270
275
 
271
- - Use `hb-sdk doctor` for read-only diagnosis of local SDK, remote latest skill metadata, and local skill metadata.
272
- - 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`.
273
- - If doctor reports `SDK_MISMATCH`, tell the user to upgrade `@heybox/hb-sdk@latest` before reinstalling the skill.
276
+ - Use `hb-sdk doctor [--agent <agent>] [--all-agents] [--json]` for read-only diagnosis of the locally installed SDK and its bundled Skill.
277
+ - Use `hb-sdk skill install` to install or refresh the Skill bundled with the matching npm package. Add `--global` for user scope, `--agent <agent>` for one Agent, or `--all-agents` for every supported Agent.
278
+ - If doctor reports `SDK_MISMATCH`, upgrade the project dependency to the matching @heybox/hb-sdk version before reinstalling the skill.
274
279
 
275
280
  ## Update reminders