@heybox/hb-sdk 0.7.4-alpha.5 → 0.7.4

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 (33) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +2 -0
  3. package/dist/cli-chunks/{build-C-ufarA6.cjs → build-CVPqGQY3.cjs} +2 -2
  4. package/dist/cli-chunks/{context-C839--TH.cjs → context-C1nTGr-R.cjs} +26 -1
  5. package/dist/cli-chunks/{create-CNcII_CB.cjs → create-C5qrLLvv.cjs} +1 -1
  6. package/dist/cli-chunks/dev-U5BlN4ei.cjs +15682 -0
  7. package/dist/cli-chunks/{doctor-bhfQwyYU.cjs → doctor-DxqHMTbm.cjs} +1 -1
  8. package/dist/cli-chunks/{index-B_qJzSFo.cjs → index-BfR6OZeU.cjs} +83 -83
  9. package/dist/cli-chunks/{index-CT94XzyO.cjs → index-DLrcC_ij.cjs} +31 -32
  10. package/dist/cli-chunks/index.esm-DbbyeU1z.cjs +5212 -0
  11. package/dist/cli-chunks/{login-hYrDJ3dR.cjs → login-DQkArK14.cjs} +2 -2
  12. package/dist/cli-chunks/{project-vite-zaw68V1G.cjs → project-vite-c13CKUUl.cjs} +1 -1
  13. package/dist/cli-chunks/{remote-DQZRAAHh.cjs → remote-816SyJyA.cjs} +4 -4
  14. package/dist/cli-chunks/{session-D692TU5N.cjs → session-ySUU0fVq.cjs} +2 -1
  15. package/dist/cli.cjs +1 -1
  16. package/dist/devtools/browser-dev-host/index.html +128 -151
  17. package/dist/devtools/browser-dev-host/main.js +1553 -339
  18. package/dist/index.cjs.js +1 -1
  19. package/dist/index.esm.js +1 -1
  20. package/dist/vite.cjs.js +1 -1
  21. package/dist/vite.esm.js +1 -1
  22. package/package.json +14 -7
  23. package/skill/SKILL.md +6 -6
  24. package/skill/references/api-protocol.md +1 -1
  25. package/skill/references/api-root.md +1 -1
  26. package/skill/references/cli.md +16 -20
  27. package/skill/references/examples.md +2 -2
  28. package/skill/references/safety-boundaries.md +1 -1
  29. package/skill/references/smoke-evaluation.md +1 -1
  30. package/skill/scripts/sync-references.mjs +6 -6
  31. package/skill/skill.json +4 -4
  32. package/types/protocol/dev-session.d.ts +13 -0
  33. package/dist/cli-chunks/dev-MpESCaMm.cjs +0 -2769
package/dist/index.cjs.js CHANGED
@@ -672,7 +672,7 @@ function createMessageId() {
672
672
  /** 构建时替换为当前发布包的实际版本。 */
673
673
  const HB_SDK_VERSION = typeof undefined === 'string'
674
674
  ? undefined
675
- : '0.7.4-alpha.5';
675
+ : '0.7.4';
676
676
 
677
677
  const DEFAULT_TIMEOUT = 10000;
678
678
  const HANDSHAKE_RETRY_INTERVAL = 250;
package/dist/index.esm.js CHANGED
@@ -668,7 +668,7 @@ function createMessageId() {
668
668
  /** 构建时替换为当前发布包的实际版本。 */
669
669
  const HB_SDK_VERSION = typeof undefined === 'string'
670
670
  ? undefined
671
- : '0.7.4-alpha.5';
671
+ : '0.7.4';
672
672
 
673
673
  const DEFAULT_TIMEOUT = 10000;
674
674
  const HANDSHAKE_RETRY_INTERVAL = 250;
package/dist/vite.cjs.js CHANGED
@@ -8,7 +8,7 @@ var _documentCurrentScript = typeof document !== 'undefined' ? document.currentS
8
8
  /** 构建时替换为当前发布包的实际版本。 */
9
9
  const HB_SDK_VERSION = typeof undefined === 'string'
10
10
  ? undefined
11
- : '0.7.4-alpha.5';
11
+ : '0.7.4';
12
12
 
13
13
  var re = {exports: {}};
14
14
 
package/dist/vite.esm.js CHANGED
@@ -5,7 +5,7 @@ import { AsyncLocalStorage } from 'node:async_hooks';
5
5
  /** 构建时替换为当前发布包的实际版本。 */
6
6
  const HB_SDK_VERSION = typeof undefined === 'string'
7
7
  ? undefined
8
- : '0.7.4-alpha.5';
8
+ : '0.7.4';
9
9
 
10
10
  var re = {exports: {}};
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heybox/hb-sdk",
3
- "version": "0.7.4-alpha.5",
3
+ "version": "0.7.4",
4
4
  "sideEffects": [
5
5
  "./src/index.ts",
6
6
  "./src/core/singleton.ts",
@@ -56,7 +56,8 @@
56
56
  "@msgpack/msgpack": "^3.1.3",
57
57
  "parse5": "^7.3.0",
58
58
  "undici": "^7.28.0",
59
- "@heybox/hb-sdk-protocol": "0.7.4-alpha.5"
59
+ "ws": "^8.18.0",
60
+ "@heybox/hb-sdk-protocol": "0.7.4"
60
61
  },
61
62
  "peerDependencies": {
62
63
  "vite": ">=5"
@@ -71,6 +72,7 @@
71
72
  "@rollup/plugin-json": "^6.1.0",
72
73
  "@rollup/plugin-node-resolve": "^16.0.1",
73
74
  "@heybox/hb-types": "^1.0.1",
75
+ "@playwright/test": "^1.55.1",
74
76
  "@vitejs/plugin-vue2": "^2.3.3",
75
77
  "@rollup/plugin-typescript": "^11.1.6",
76
78
  "@types/ejs": "^3.1.5",
@@ -78,6 +80,7 @@
78
80
  "@types/node": "24.10.1",
79
81
  "@types/qrcode": "^1.5.6",
80
82
  "@types/semver": "^7.7.1",
83
+ "@types/ws": "^8.5.13",
81
84
  "@vitest/coverage-v8": "^3.2.4",
82
85
  "commander": "^12.1.0",
83
86
  "cos-nodejs-sdk-v5": "2.15.4",
@@ -98,7 +101,10 @@
98
101
  "vite": "^8.0.12",
99
102
  "vitest": "^3.2.4",
100
103
  "@heybox/hb-api": "~1.25.20",
101
- "@heybox/hb-sdk-runtime": "~0.7.4-alpha.5"
104
+ "@heybox/hb-sdk-runtime": "~0.7.4",
105
+ "@heybox/runtime-transport-fetch": "~0.2.0",
106
+ "@heybox/runtime-policy": "~0.2.0",
107
+ "@heybox/runtime": "~0.2.0"
102
108
  },
103
109
  "publishConfig": {
104
110
  "registry": "https://registry.npmjs.org/",
@@ -129,13 +135,14 @@
129
135
  ]
130
136
  },
131
137
  "scripts": {
132
- "dev": "vite",
138
+ "dev": "vite --config vite.browser-dev-host.config.ts",
133
139
  "build:package": "nx exec -- sh -c \"pnpm run clean && pnpm run build:lib:bundle && pnpm run build:cli:bundle && pnpm run build:templates && pnpm run build:types\"",
134
140
  "build:watch": "pnpm run build:lib -w & pnpm run build:types -w",
135
141
  "build:hb-api-contract": "pnpm --dir ../hb-api run build:lib",
136
- "build:lib": "pnpm run build:hb-api-contract && pnpm run build:lib:bundle",
142
+ "build:hb-sdk-protocol": "pnpm --filter @heybox/hb-sdk-protocol run build:package",
143
+ "build:lib": "pnpm run build:hb-sdk-protocol && pnpm run build:hb-api-contract && pnpm run build:lib:bundle",
137
144
  "build:lib:bundle": "rollup -c rollup.config.ts --configPlugin 'typescript={\"tsconfig\":\"tsconfig.build.json\"}'",
138
- "build:cli": "pnpm run build:hb-api-contract && pnpm run build:cli:bundle",
145
+ "build:cli": "pnpm run build:hb-sdk-protocol && pnpm run build:hb-api-contract && pnpm run build:cli:bundle",
139
146
  "build:cli:bundle": "rollup -c rollup.config.ts --environment HB_SDK_BUILD:cli --configPlugin 'typescript={\"tsconfig\":\"tsconfig.build.json\"}' && pnpm run build:browser-dev-host",
140
147
  "build:browser-dev-host": "node scripts/copy-browser-dev-host.cjs",
141
148
  "build:templates": "node scripts/copy-cli-templates.cjs",
@@ -149,7 +156,7 @@
149
156
  "test:types": "pnpm run test:types:characterization && pnpm run test:types:browser-dev-host",
150
157
  "test:e2e:browser-dev-host": "pnpm run build:browser-dev-host && NODE_OPTIONS='--conditions=heybox' vitest run --config vitest.browser-dev-host-e2e.config.ts",
151
158
  "test:unit:coverage": "NODE_OPTIONS='--conditions=heybox' vitest run --coverage",
152
- "test:vite": "pnpm run build:hb-api-contract && vitest run --config vitest.vite.config.ts",
159
+ "test:vite": "pnpm run build:hb-sdk-protocol && pnpm run build:hb-api-contract && vitest run --config vitest.vite.config.ts",
153
160
  "test:watch": "NODE_OPTIONS='--conditions=heybox' vitest",
154
161
  "changelog:draft": "node scripts/changelog-draft.cjs",
155
162
  "check:changelog": "node scripts/check-changelog.cjs",
package/skill/SKILL.md CHANGED
@@ -10,7 +10,7 @@ Apply these instructions when writing, reviewing, or debugging code that consume
10
10
  ## Step 1: Classify the task
11
11
 
12
12
  1. If the task is workshop mini-program business code, use the root package import path `@heybox/hb-sdk`.
13
- 2. If the task is new protocol or `@heybox/hb-sdk-runtime` graph maintenance, import wire contracts directly from `@heybox/hb-sdk-protocol`. Existing released Host consumers continue to use the compatibility entry `@heybox/hb-sdk/protocol` until the synchronized hard cut is published.
13
+ 2. If the task is new protocol or `@heybox/hb-sdk-runtime` graph maintenance, import wire contracts directly from `@heybox/hb-sdk-protocol`. Existing released Host consumers continue to use the compatibility entry `@heybox/hb-sdk/protocol` until they are explicitly migrated.
14
14
  3. If the task is project scaffolding, local startup, production build, browser Mock, device debugging, CLI login, Agent Skill diagnosis, or CLI troubleshooting, use the `hb-sdk` CLI workflow.
15
15
  4. If the task is reviewing a mini-program for submission, listing, audit, publishing, content compliance, data/privacy compliance, runtime quality, or icon/cover design requirements, use the online publishing rules workflow.
16
16
  5. If the task asks for direct login-state extraction, cookies, tokens, raw Heybox client protocols, or internal hb-sdk package paths, refuse that approach and use the public SDK or CLI boundary instead.
@@ -55,13 +55,13 @@ Apply these instructions when writing, reviewing, or debugging code that consume
55
55
  ## Step 5: Use CLI workflows
56
56
 
57
57
  1. Use `hb-sdk create <project-name>` to scaffold a workshop mini-program.
58
- 2. Use `hb-sdk dev` for browser, Mac App, or mobile App debugging. These entries remain available without CLI login or project binding, but managed capabilities are denied by default.
59
- 3. Use `--port`, `--browser-dev-host-port`, and `--no-open` when the default local ports or browser opening behavior need to be controlled.
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
60
  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
61
  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
62
  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
63
  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` only for development and publishing commands. This login does not change `auth.login()`, `user.getInfo()`, or the mini-program user's authorization state.
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.
65
65
  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
66
  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
67
  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.
@@ -90,7 +90,7 @@ For workshop mini-program business code:
90
90
  For CLI and local development:
91
91
 
92
92
  1. Do not print, persist in templates, or pass through pkey, cookies, tokens, or private credentials.
93
- 2. Do not use `hb-sdk login` as a workaround for `auth.login()` or mini-program user authorization.
93
+ 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
94
  3. Use the built-in local debugging page instead of creating another browser Mock.
95
95
  4. Keep the Vite `miniappManifest()` plugin enabled.
96
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.
@@ -98,7 +98,7 @@ For CLI and local development:
98
98
 
99
99
  For host/runtime/protocol-maintenance code:
100
100
 
101
- 1. Treat `@heybox/hb-sdk-protocol` as the wire contract owner; existing consumers continue to use the public compatibility entry `@heybox/hb-sdk/protocol` until the synchronized hard cut is released.
101
+ 1. Use `@heybox/hb-sdk-protocol` as the direct wire-contract owner for new Host/Runtime/protocol work. Preserve `@heybox/hb-sdk/protocol` only for existing compatibility consumers until they are explicitly migrated.
102
102
  2. Keep raw protocol details inside the host/runtime boundary; do not leak them into app-facing SDK examples or workshop mini-program business code.
103
103
  3. Preserve compatibility with existing SDK clients.
104
104
 
@@ -14,7 +14,7 @@
14
14
  - [Generated reference index](#generated-reference-index)
15
15
  ## Host/runtime-only warning
16
16
 
17
- Use `@heybox/hb-sdk/protocol` only for parent-container runtime, bridge-server, protocol-contract, or `@heybox/hb-sdk-runtime` integration tasks. Iframe mini-program business code must use root SDK APIs and must not construct bridge envelopes, nonce handling, or raw `postMessage` flows.
17
+ New parent-container Host, `@heybox/hb-sdk-runtime`, bridge-server, and protocol-contract maintenance must import wire contracts directly from `@heybox/hb-sdk-protocol`. Use `@heybox/hb-sdk/protocol` only for explicitly retained existing compatibility consumers. Iframe mini-program business code must use root SDK APIs and must not construct bridge envelopes, nonce handling, or raw `postMessage` flows.
18
18
 
19
19
  ## Public protocol entrypoint
20
20
 
@@ -24,7 +24,7 @@
24
24
  ## Package metadata
25
25
 
26
26
  - Package: `@heybox/hb-sdk`
27
- - Version at generation time: `0.7.4-alpha.5`
27
+ - Version at generation time: `0.7.4`
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`
@@ -104,9 +104,11 @@ CLI 会启动页面服务并自动打开本地调试页。调试页会展示小
104
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
106
 
107
- 未登录或未绑定小程序时,浏览器、Mac 和手机调试入口仍然可用,但受管能力会默认拒绝。登录并绑定后,调试页才能根据当前小程序的线上配置提示差异。
107
+ `hb-sdk dev` 不支持匿名调试。启动前必须先运行 `hb-sdk login`,并通过 `hb-sdk remote create` 或 `hb-sdk remote bind <mini-program-id>` 绑定当前项目;未登录、未绑定或远端 Dev Context 不可用时,CLI 会在启动 Vite 和调试服务前终止。
108
108
 
109
- `hb-sdk dev` 会在启动 Vite 前读取远端权限。只有远端权限快照有效且 `network.request.status=enabled` 时才跳过平台 CSP;`useOfficialDomain` 不参与该判定。未登录、未绑定、读取失败、非法快照或仅在 Dev Context 中开启本地权限覆盖时都继续注入 CSP
109
+ `hb-sdk dev` 会在启动 Vite 前读取远端权限。只有远端权限快照有效且 `network.request.status=enabled` 时才跳过平台 CSP;`useOfficialDomain` 不参与该判定。本地 Dev Context 权限覆盖不会改变 CSP 决策。
110
+
111
+ 当前调试链路不要求升级 Android、iOS 或 Mac 客户端。Browser Mock 会自动在实时与兼容链路间切换;Mobile 使用 `open_inapp`/`openWindow` 包裹的 LAN 短链接二维码(先开普通 H5 跳转页,再进入小程序并关闭中间页);PC/Mac 行为保持不变。
110
112
 
111
113
  ### 2. 先用浏览器 Mock 验收
112
114
 
@@ -116,18 +118,13 @@ CLI 会启动页面服务并自动打开本地调试页。调试页会展示小
116
118
  - SDK 初始化与用户身份授权流程
117
119
  - 生命周期、Storage 和排行榜等能力
118
120
 
119
- Dev Context 中调整的权限只影响当前本地调试,不会修改线上配置。调试页会区分线上基线与本地覆盖;恢复初始权限后重新按远端配置验收。
120
-
121
- 切换权限后 Mobile App 二维码会自动重生成;旧二维码失效时按调试页提示重新扫码。工坊小程序默认不能进行网络请求,网络权限暂未开放申请;不要把本地调试结果当成线上能力。
121
+ 调试页中调整的权限只影响当前本地调试,不会修改线上配置;切换权限后 Mobile App 会重生成二维码。Debug/Ad-Hoc 的本地增强不可用、过期或读取失败时继续使用原生 Host。恢复初始权限后重新按远端配置验收;工坊小程序默认不能进行网络请求,网络权限暂未开放申请,不要把本地结果当成线上能力。
122
122
 
123
123
  ### 3. 再用 Mac 或手机真机验收
124
124
 
125
- 需要确认真实客户端表现时,从调试页选择一种方式:
126
-
127
- - 点击「在 Mac 版 APP 中启动」。
128
- - 在「Mobile App」区域选择局域网网卡,再用手机小黑盒 APP 扫码。
125
+ 需要确认真实客户端表现时,可以使用调试页提供的 Mac 启动入口;手机验收则在「Mobile App」区域选择局域网网卡,再用手机小黑盒 APP 扫码。
129
126
 
130
- 手机与电脑需要处于同一局域网。二维码默认使用 HTTPS `open_inapp` 包装链接;需要二维码直接编码裸 `heybox://` 协议时,以 `hb-sdk dev --raw-protocol` 启动。二维码无法访问时,先确认选择了正确的 **Network** 网卡。发布前至少完成一次真实客户端验收。
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**。发布前至少完成一次真实客户端验收。
131
128
 
132
129
  ### 浏览器 Mock 的边界
133
130
 
@@ -135,17 +132,16 @@ Dev Context 中调整的权限只影响当前本地调试,不会修改线上
135
132
 
136
133
  ### 常用参数
137
134
 
138
- | 参数 | 用途 |
139
- | -------------------- | ----------------------------------------- |
140
- | `--port <port>` | 指定页面开发服务端口。 |
141
- | `--browser-dev-host-port <port>` | 指定 Browser Dev Host 端口。 |
142
- | `--raw-protocol` | 让手机二维码直接编码裸 `heybox://` 协议。 |
143
- | `--no-open` | 启动后不自动打开浏览器。 |
144
- | `--verbose` | 出现问题时输出更详细的诊断信息。 |
135
+ | 参数 | 用途 |
136
+ | -------------------------------- | ------------------------------------------------------------- |
137
+ | `--port <port>` | 指定页面开发服务端口。 |
138
+ | `--browser-dev-host-port <port>` | 指定 Browser Dev Host 端口。 |
139
+ | `--no-open` | 启动后不自动打开浏览器。 |
140
+ | `--verbose` | 出现问题时输出更详细的诊断信息。 |
145
141
 
146
- 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.
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
143
 
148
- The default CLI does not configure the external one-time-code/PKCE service required for Browser Dev Host user login. In that state the page disables login and reports the missing prerequisite while other local debugging entries remain available. Never substitute CLI login state, cross-site cookies, mock identity, or credential-bearing URLs for this service.
144
+ 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.
149
145
 
150
146
  ## Production build
151
147
 
@@ -252,7 +248,7 @@ Agent rules:
252
248
 
253
249
  ## CLI 登录态
254
250
 
255
- CLI 登录态只用于开发工具和远端管理,不等同于小程序内的用户登录态,也不会改变 `auth.login()`、`user.getInfo()` 或开发者服务端会话。
251
+ CLI 登录态用于开发工具、远端管理,以及 Browser Dev Host 代发 `heybox-session` 请求。这份 CLI 登录态不会改变 `auth.login()` 的授权码流程;调试页只弹出授权确认。不要把 pkey、Cookie 或 token 写进页面、URL 或日志。
256
252
 
257
253
  ```bash
258
254
  hb-sdk login status
@@ -108,9 +108,9 @@ try {
108
108
  ### Host/runtime protocol import
109
109
 
110
110
  ```ts
111
- import { NETWORK_REQUEST_METHOD, type NetworkRequestPayload } from '@heybox/hb-sdk/protocol';
111
+ import { NETWORK_REQUEST_METHOD, type NetworkRequestPayload } from '@heybox/hb-sdk-protocol';
112
112
 
113
- // Host/runtime integration only. Do not use this in iframe business code.
113
+ // New Host/runtime integration only. Existing released consumers may retain @heybox/hb-sdk/protocol until explicitly migrated.
114
114
  export function canHandleNetwork(method: string): method is typeof NETWORK_REQUEST_METHOD {
115
115
  return method === NETWORK_REQUEST_METHOD;
116
116
  }
@@ -36,4 +36,4 @@
36
36
  - Do not build raw `postMessage` bridge flows in iframe business code.
37
37
  - Do not fetch deployed `dist/manifest.json` from business code; it is a build artifact for the release pipeline, not a CDN runtime asset.
38
38
  - Do not import from internal hb-sdk implementation paths; only use documented package entrypoints.
39
- - Browser Dev Host user login must stay fail-closed when its external one-time-code/PKCE service is unavailable. Never reuse CLI login state or expose credentials to browser JavaScript, URLs, logs, or serializable errors.
39
+ - Browser Dev Host may use the Node `hb-sdk login` session to send Host `heybox-session` requests. Never expose pkey, cookies, tokens, or credential-bearing URLs to browser JavaScript, page UI, or logs. Mini-program code must still call `auth.login()`.
@@ -9,7 +9,7 @@ Use this template when evaluating whether an agent followed the hb-sdk skill.
9
9
  ## Expected evidence
10
10
 
11
11
  - [ ] Uses `@heybox/hb-sdk` root imports for iframe business code.
12
- - [ ] Uses `@heybox/hb-sdk/protocol` only for host/runtime/protocol tasks.
12
+ - [ ] Uses `@heybox/hb-sdk-protocol` directly for new host/runtime/protocol work and reserves `@heybox/hb-sdk/protocol` for existing compatibility consumers.
13
13
  - [ ] Uses `hb-sdk create`, `hb-sdk dev`, or `hb-sdk login` correctly for CLI tasks.
14
14
  - [ ] Uses `getHandshakeState()` plus `onHandshakeStateChange()` for gesture-gated control state, enables only on `status === 'ready'`, and cleans up the subscription.
15
15
  - [ ] Treats the non-replayed `ready` lifecycle event as an edge notification that may repeat after a duplicate handshake, never as current state.
@@ -345,7 +345,7 @@ files.set(
345
345
  ['Generated reference index', 'generated-reference-index'],
346
346
  ])}## Host/runtime-only warning
347
347
 
348
- Use \`@heybox/hb-sdk/protocol\` only for parent-container runtime, bridge-server, protocol-contract, or \`@heybox/hb-sdk-runtime\` integration tasks. Iframe mini-program business code must use root SDK APIs and must not construct bridge envelopes, nonce handling, or raw \`postMessage\` flows.
348
+ New parent-container Host, \`@heybox/hb-sdk-runtime\`, bridge-server, and protocol-contract maintenance must import wire contracts directly from \`@heybox/hb-sdk-protocol\`. Use \`@heybox/hb-sdk/protocol\` only for explicitly retained existing compatibility consumers. Iframe mini-program business code must use root SDK APIs and must not construct bridge envelopes, nonce handling, or raw \`postMessage\` flows.
349
349
 
350
350
  ## Public protocol entrypoint
351
351
 
@@ -406,9 +406,9 @@ Agent rules:
406
406
 
407
407
  ${cliDevSection}
408
408
 
409
- 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.
409
+ 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.
410
410
 
411
- The default CLI does not configure the external one-time-code/PKCE service required for Browser Dev Host user login. In that state the page disables login and reports the missing prerequisite while other local debugging entries remain available. Never substitute CLI login state, cross-site cookies, mock identity, or credential-bearing URLs for this service.
411
+ 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.
412
412
 
413
413
  ## Production build
414
414
 
@@ -556,7 +556,7 @@ ${capabilityBoundaries}
556
556
  - Do not build raw \`postMessage\` bridge flows in iframe business code.
557
557
  - Do not fetch deployed \`dist/manifest.json\` from business code; it is a build artifact for the release pipeline, not a CDN runtime asset.
558
558
  - Do not import from internal hb-sdk implementation paths; only use documented package entrypoints.
559
- - Browser Dev Host user login must stay fail-closed when its external one-time-code/PKCE service is unavailable. Never reuse CLI login state or expose credentials to browser JavaScript, URLs, logs, or serializable errors.
559
+ - Browser Dev Host may use the Node \`hb-sdk login\` session to send Host \`heybox-session\` requests. Never expose pkey, cookies, tokens, or credential-bearing URLs to browser JavaScript, page UI, or logs. Mini-program code must still call \`auth.login()\`.
560
560
  `,
561
561
  );
562
562
 
@@ -696,9 +696,9 @@ try {
696
696
 
697
697
  ${fenced(
698
698
  'ts',
699
- `import { NETWORK_REQUEST_METHOD, type NetworkRequestPayload } from '@heybox/hb-sdk/protocol';
699
+ `import { NETWORK_REQUEST_METHOD, type NetworkRequestPayload } from '@heybox/hb-sdk-protocol';
700
700
 
701
- // Host/runtime integration only. Do not use this in iframe business code.
701
+ // New Host/runtime integration only. Existing released consumers may retain @heybox/hb-sdk/protocol until explicitly migrated.
702
702
  export function canHandleNetwork(method: string): method is typeof NETWORK_REQUEST_METHOD {
703
703
  return method === NETWORK_REQUEST_METHOD;
704
704
  }`,
package/skill/skill.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "hb-sdk",
3
- "skillVersion": "0.7.4-alpha.5+skill.6ae0dd3c4740",
3
+ "skillVersion": "0.7.4+skill.f8dd939f4173",
4
4
  "sdk": {
5
5
  "package": "@heybox/hb-sdk",
6
- "version": "0.7.4-alpha.5",
7
- "compatibility": "0.7.4-alpha.5"
6
+ "version": "0.7.4",
7
+ "compatibility": "0.7.4"
8
8
  },
9
9
  "source": "https://open.xiaoheihe.cn/agent-skills/hb-sdk",
10
- "integrity": "sha256-6ae0dd3c47408c7102d70dd1e6dfecf78e8466055dec3ab259fc800fb3ec9b59"
10
+ "integrity": "sha256-f8dd939f4173d20846ae7d62fbf6bc44227f8d9e186fc6a50e818a971a39213b"
11
11
  }
@@ -3,8 +3,12 @@ import type { MiniProgramRuntimePermissionsSnapshot } from './runtime-permission
3
3
  export declare const MINI_PROGRAM_DEV_CONTEXT_QUERY_PARAM = "dev_context_url";
4
4
  /** Browser Dev Host 创建和读取 Dev Session 的固定路径。 */
5
5
  export declare const MINI_PROGRAM_DEV_CONTEXT_PATH = "/__hb_sdk__/dev-context";
6
+ /** 详情 H5 从 `mini_url` origin 发现其余启动参数的固定路径。 */
7
+ export declare const MINI_PROGRAM_DEV_LAUNCH_PATH = "/__hb_sdk__/launch.json";
6
8
  /** Dev Session 当前使用的 schema 版本。 */
7
9
  export declare const MINI_PROGRAM_DEV_SESSION_SCHEMA_VERSION: 1;
10
+ /** `launch.json` 当前使用的 schema 版本。 */
11
+ export declare const MINI_PROGRAM_DEV_LAUNCH_SCHEMA_VERSION: 1;
8
12
  /** Browser Dev Host 创建 Dev Session 时接收的请求。 */
9
13
  export interface MiniProgramDevSessionCreatePayload {
10
14
  mini_url_origin: string;
@@ -23,3 +27,12 @@ export interface MiniProgramDevSessionSnapshot {
23
27
  mini_url_origin: string;
24
28
  runtime_permissions: MiniProgramRuntimePermissionsSnapshot;
25
29
  }
30
+ /** 详情 H5 在只带 `mini_url` 启动后拉取的其余调试参数。 */
31
+ export interface MiniProgramDevLaunchSnapshot {
32
+ schema_version: typeof MINI_PROGRAM_DEV_LAUNCH_SCHEMA_VERSION;
33
+ sdk_version?: string;
34
+ mini_program_id?: string;
35
+ local_dev_launch_token?: string;
36
+ dev_context_url?: string;
37
+ runtime_permissions?: MiniProgramRuntimePermissionsSnapshot;
38
+ }