@agentunion/fastaun-browser 0.4.2 → 0.4.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 (61) hide show
  1. package/CHANGELOG.md +190 -164
  2. package/_packed_docs/0.4.0_/345/267/256/345/274/202/346/240/270/345/256/236/345/206/263/347/255/226/350/256/260/345/275/225.md +302 -0
  3. package/_packed_docs/AUN_SDK_0.4.0_/350/256/276/350/256/241/345/257/271/346/257/224/345/210/206/346/236/220.md +194 -0
  4. package/_packed_docs/AUN_SDK_/351/207/215/346/236/204/345/256/236/346/226/275/350/256/241/345/210/222.md +596 -596
  5. package/_packed_docs/AUN_SDK_/351/207/215/346/236/204/350/256/276/350/256/241/346/226/271/346/241/210_v3.md +1698 -1697
  6. package/_packed_docs/CHANGELOG.md +190 -164
  7. package/_packed_docs/INDEX.md +17 -17
  8. package/_packed_docs/KITE_DOCS_GUIDE.md +11 -11
  9. package/_packed_docs/agent.md/SCHEMA.md +49 -49
  10. package/_packed_docs/agent.md/examples/signed-openclaw-lobster.md +22 -22
  11. package/_packed_docs/agent.md//350/277/234/347/250/213agent.md/347/274/223/345/255/230/344/270/216etag/351/200/217/344/274/240/346/226/271/346/241/210.md +327 -327
  12. package/_packed_docs/cli/AUN-CLI/350/256/276/350/256/241/346/226/207/346/241/243.md +686 -686
  13. package/_packed_docs/design/2026-05-22-aun-rpc-trace-enhancement.md +542 -542
  14. package/_packed_docs/design/E2EE_V2/347/256/200/345/214/226/344/270/2721DH/345/212/240Per-AID_Wrap/346/226/271/346/241/210.md +124 -124
  15. package/_packed_docs/design//350/267/250/350/257/255/350/250/200/345/256/271/345/231/250E2E/346/265/213/350/257/225/346/226/271/346/241/210.md +665 -665
  16. package/_packed_docs/protocol/01-/350/272/253/344/273/275/344/270/216/345/207/255/350/257/201/345/215/217/350/256/256-auth.md +2 -2
  17. package/_packed_docs/protocol/14-/344/272/244/344/272/222/346/234/272/345/210/266-/345/223/215/345/272/224/346/250/241/345/274/217/344/270/216/350/207/252/344/270/273/346/250/241/345/274/217.md +170 -170
  18. package/_packed_docs/protocol/15-/347/246/273/347/272/277/346/216/250/351/200/201/351/200/232/347/237/245/345/215/217/350/256/256.md +419 -419
  19. package/_packed_docs/protocol/README.md +1 -1
  20. package/_packed_docs/protocol/aun-docs-guide.md +1 -1
  21. package/_packed_docs/protocol//351/231/204/345/275/225A-/346/234/257/350/257/255/350/241/250.md +15 -15
  22. package/_packed_docs/protocol//351/231/204/345/275/225B-/346/211/251/345/261/225/346/200/247/346/214/207/345/215/227.md +4 -4
  23. package/_packed_docs/protocol//351/231/204/345/275/225J-/345/256/242/346/210/267/347/253/257/346/216/245/345/205/245/347/244/272/344/276/213.md +98 -98
  24. package/_packed_docs/protocol//351/231/204/345/275/225M-JWT/350/256/244/350/257/201/345/256/236/347/216/260/346/214/207/345/215/227.md +46 -46
  25. package/_packed_docs/protocol//351/231/204/345/275/225N-/345/210/206/345/270/203/345/274/217Trace/345/215/217/350/256/256.md +257 -257
  26. package/_packed_docs/python-sdk-v2-only-changelog.md +189 -189
  27. package/_packed_docs/sdk/01-/345/277/253/351/200/237/345/274/200/345/247/213.md +7 -3
  28. package/_packed_docs/sdk/03-/346/240/270/345/277/203/346/246/202/345/277/265.md +1 -1
  29. package/_packed_docs/sdk/04-/350/277/236/346/216/245/344/270/216/350/256/244/350/257/201.md +3 -1
  30. package/_packed_docs/sdk/05-E2EE/345/212/240/345/257/206/351/200/232/344/277/241.md +1 -1
  31. package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +63 -15
  32. package/_packed_docs/sdk/09-payload-reference.md +13 -13
  33. package/_packed_docs/sdk/E2EE_V2/346/266/210/346/201/257/351/200/232/344/277/241/346/227/266/345/272/217/345/233/276.md +171 -171
  34. package/_packed_docs/sdk/README.md +5 -5
  35. package/dist/aid-store.d.ts.map +1 -1
  36. package/dist/aid-store.js +5 -6
  37. package/dist/aid-store.js.map +1 -1
  38. package/dist/aid.d.ts +2 -1
  39. package/dist/aid.d.ts.map +1 -1
  40. package/dist/aid.js +7 -6
  41. package/dist/aid.js.map +1 -1
  42. package/dist/auth.d.ts.map +1 -1
  43. package/dist/auth.js +4 -0
  44. package/dist/auth.js.map +1 -1
  45. package/dist/bundle.js +292 -188
  46. package/dist/client.d.ts +13 -17
  47. package/dist/client.d.ts.map +1 -1
  48. package/dist/client.js +275 -190
  49. package/dist/client.js.map +1 -1
  50. package/dist/config.d.ts +4 -7
  51. package/dist/config.d.ts.map +1 -1
  52. package/dist/config.js +18 -1
  53. package/dist/config.js.map +1 -1
  54. package/dist/index.d.ts +1 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js.map +1 -1
  57. package/dist/keystore/indexeddb.js +5 -5
  58. package/dist/keystore/indexeddb.js.map +1 -1
  59. package/dist/version.d.ts +1 -1
  60. package/dist/version.js +1 -1
  61. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,164 +1,190 @@
1
- # Changelog
2
-
3
- 本文件记录 `@agentunion/fastaun-browser` SDK 的版本变更。最新版本在最前面。
4
-
5
- 格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循 [SemVer](https://semver.org/lang/zh-CN/)。
6
-
7
- ---
8
-
9
- ## 0.4.2 — 2026-05-30
10
-
11
- ### Added
12
- - **`AIDStore` 新增具名返回类型**:`ResolveResult`、`FetchAgentMdResult`、`HeadAgentMdResult`、`CheckAgentMdResult`、`DiagnoseResult`、`RenewCertResult`、`RekeyResult`、`ChangeSeedResult`、`ListResult`,替代原来的 `Record<string, unknown>`。
13
-
14
- ### Changed
15
- - **移除 `discoveryPort`**:`AIDStore` 构造选项删除 `discoveryPort`,gateway URL 改为纯自动发现。
16
- - **`fetchAgentMd` 新增 `timeoutMs` 参数**(默认 30000ms),`resolve` 内部调用时透传 `opts.timeout`。
17
- - **返回字段精简**:`fetchAgentMd` / `headAgentMd` / `checkAgentMd` / `diagnose` 移除冗余的 camelCase 别名字段,统一使用 snake_case。
18
- - **`resolve` 返回 `source` 字段精简**:移除 `certFromCache` / `agentMdFetched` camelCase 别名,只保留 `cert_from_cache` / `agent_md_fetched`。
19
-
20
- ---
21
-
22
- ## 0.4.0 — 2026-05-30
23
-
24
- > **破坏性重构版本。** 与 Python SDK 0.4.0 对齐:身份管理剥离为 `AID` / `AIDStore`;删除 `auth` / `custody` / `meta` 公开命名空间;引入 `Result` 与字符串错误码;连接状态机扩展为 9 态。浏览器环境下 `AID` 创建和签名/验证均为异步。
25
-
26
- ### Breaking Changes
27
- - **删除公开命名空间**:移除 `client.auth` / `client.custody` / `client.meta`。身份相关功能迁移到 `AIDStore` 与 `AID`,其余 RPC 走 `client.call()`。
28
- - **`AID` 创建改为异步**:使用 `await AID.create(...)` 工厂方法(浏览器 Web Crypto API 限制);`sign` / `verify` / `signAgentMd` / `verifyAgentMd` 均为 `async`。
29
- - **目录约定变更**:`{aun_path}/AgentMDs/` `{aun_path}/AIDs/`(IndexedDB key 前缀同步变更)。
30
-
31
- ### Added
32
- - **`AID` 类**(异步):`AID.create()` 工厂方法;`sign` / `verify` / `signAgentMd` / `verifyAgentMd` 均返回 Promise;`isCertValid` / `isPrivateKeyValid` 同步。
33
- - **`AIDStore` 类**:离线 `load` / `list` / `exists`,联网 `register` / `resolve` / `fetchAgentMd` / `checkAgentMd` / `diagnose` / `renewCert` / `rekey` / `changeSeed`;存储后端为 IndexedDB。
34
- - **`Result<T>` 类型**:统一结果类型(`{ ok: true; data: T }` 或 `{ ok: false; error: ErrorInfo }`)。
35
- - **新增错误类**:`NotFoundError` / `IdentityConflictError` / `E2EEGroupSecretMissingError` / `E2EEGroupEpochMismatchError`。
36
- - **`ConnectionState` 枚举**:9 态(`NO_IDENTITY` / `STANDBY` / `CONNECTING` / `READY` / `RETRY_BACKOFF` / `RECONNECTING` / `CONNECTION_FAILED` / `CLOSED`)。
37
- - **实例级 `protected_headers`**:`setProtectedHeaders()` 自动合并到 `message.send` / `group.send` / `*.thought.put`。
38
- - **重连状态可观测**:`nextRetryAt` / `retryAttempt` / `retryMaxAttempts` / `lastError` / `lastErrorCode` 属性。
39
- - **导出**:`__version__` 常量、`STATE_TO_PUBLIC` 映射表、`ROOT_CA_PEM` 根证书。
40
-
41
- ### Removed
42
- - 删除 `js/src/namespaces/auth.ts`、`js/src/namespaces/custody.ts`、`js/src/namespaces/meta.ts`。
43
-
44
- ---
45
-
46
- ## 0.3.6 — 2026-05-28
47
-
48
- ### Added
49
- - **Encrypted push 解密管线**:收到加密推送时即时尝试 V2 解密,成功则发 `message.received` / `group.message_created`(含明文 payload + e2ee 元数据),失败则发 `message.undecryptable` / `group.message_undecryptable`(含诊断字段 `_decrypt_error` / `_decrypt_stage` / `_envelope_type`)
50
- - **`auth.fetchPeerCert(gatewayUrl, aid)`**:公开 API 实现落地(v0.3.5 声明,v0.3.6 实现独立方法体)
51
- - **`storage.get_limits` RPC**:查询上传限制和配额使用情况
52
- - **`storage.check_upload` RPC**:上传预检(秒传检测 + 超限检测)
53
-
54
- ### Fixed
55
- - **Identity cache 自愈**:V2 session init 时检测 `private_key_pem` 缺失,自动从 keystore 重新加载并清理脏 instance_state
56
- - **`loadIdentity` 字段白名单**:只合并 `_INSTANCE_STATE_FIELDS` 定义的字段,防止 instance_state 表中的脏数据覆盖核心字段
57
-
58
- ---
59
-
60
- ## 0.3.5 2026-05-28
61
-
62
- ### Breaking Changes
63
- - **`createAid()` `registerAid()`**:客户端 API 重命名,旧方法已移除
64
- - **注册与认证分离**:`authenticate()` 不再隐式注册;身份不完整时抛 `StateError`
65
-
66
- ### Added
67
- - **`IdentityConflictError`**:新增错误类型(继承 `AuthError`),AID 注册冲突时抛出
68
- - **`auth.loadIdentity()` / `auth.loadIdentityOrNull()`**:公开 API,只读加载本地已注册身份(密钥对 + 证书 + 实例状态),无副作用
69
- - **`auth.fetchPeerCert()`**:公开 API,获取对端 AID 证书 PEM(本地缓存优先,未命中走 PKI HTTP + 链验证)
70
- - **Pull Gate**:per-key 序列化 pull 操作,防止同一 namespace 并发 pull
71
- - **RPC Inflight 限制**:transport 层全局最大 16 个并发 RPC + 后台 RPC 独立限制 8 个,排队超时抛 `TimeoutError`
72
- - **`_assertCertMatchesLocalKeypair`**:authenticate 前显式校验 cert 公钥与本地 keypair 一致
73
- - **`_downloadRegisteredCert`**:注册前查服务端证书的辅助方法
74
-
75
- ### Changed
76
- - **`registerAid` 半成品恢复**:本地有 keypair cert 时,查服务端恢复;服务端无记录则用现有 keypair 注册
77
- - **agent.md 元数据存储**:从全局 `list.json` key 改为 per-AID `{aid}/agentmd.json` key(IndexedDB)
78
- - **agent.md 下载**:改为无条件 GET;302 显式跟随;304 时本地有缓存直接用,无缓存重试
79
- - **`_loadIdentityOrRaise`**:增加 keypair 完整性检查
80
- - **`ChangeSeed` API**:`IndexedDBKeyStore.changeSeed()` 支持更换 seed(重加密私钥)
81
-
82
- ### Removed
83
- - **`_ensureLocalIdentity` / `_ensureIdentity`**:已移除,注册路径不再隐式生成密钥
84
- - **`createAid` 方法**:已移除
85
-
86
- ---
87
-
88
- ## 0.3.3 — 2026-05-25
89
-
90
- ### Added
91
- - **V2 Thought 加解密**:`group.thought.get` / `message.thought.get` 返回值自动解密;发送端自动加密;`attachV2EnvelopeMetadata` 附加 E2EE 元数据
92
- - **V2 Sender IK 延迟解密**:`_v2SenderIKPending` / `_v2SenderIKFetching` 机制,对端 IK 未缓存时挂起消息、异步拉取后重试解密
93
- - **agent.md 本地缓存体系(浏览器版本)**:`publishAgentMd(content?)` / `fetchAgentMd(aid?)`;基于 IndexedDB/localStorage 的 list + 按 AID 存储 + etag 比对 + 自动拉取缺失
94
- - **V2 辅助函数**:`getV2DeviceId` / `_v2B64ToBytesStrict` / `_v2BytesEqual` / `_v2ConcatBytes` / `_v2LengthPrefixedTextKey` / `_v2LengthPrefixedBytes`
95
- - **V2 envelope 元数据**:`attachV2EnvelopeMetadata` / `attachV2EnvelopeMetadataFromSource` / `extractV2EnvelopeFromSource` / `metadataWithoutAuth`
96
-
97
- ### Changed
98
- - **V2 消息处理路径重构**:统一 P2P/Group 解密入口,支持 sender IK pending 延迟模式
99
- - **V2 SPK rotation**:thought 解密失败时触发 group SPK rotation / registration after peer fallback
100
-
101
- ### Fixed
102
- - **service-plane envelope 解包**:修复 Kernel trace 字段传递丢失
103
- - **trace 树状展示**:enter/exit 配对 + 嵌套缩进
104
-
105
- ---
106
-
107
- ## 0.3.1 — 2026-05-22
108
-
109
- ### Added
110
- - **`auth.checkAid` handler**:本地证书自检 + 远端注册状态查询(与 Node 版对齐)
111
- - **RPC trace 增强(浏览器版本)**:`RPCTransport` 增加 `setTraceMode()` / `setTraceObserver()`;`sortTraceSpansForDisplay` / `formatTraceTree` / `traceDisplay` 树状展示
112
- - **V2 群组 SPK 生命周期**:`V2KeyStore.saveGroupSPK` / `loadGroupSPK` / `loadCurrentGroupSPK` 基于 IndexedDB 持久化;`V2Session.ensureGroupSPK` / `ensureGroupRegistered` / `rotateGroupSPK` / `getGroupDecryptKeys`;`DESTROY_DELAY_MS = 7d`
113
- - **V2 P2P push 解密**:`AUNClient` 增加 push payload 就地解密路径,失败回退到 pull
114
-
115
- ### Changed
116
- - **`SeqTracker.forceContiguousSeq`**:原 `contiguousSeq = minSeq` 跳过空洞(会丢消息),改为 `contiguousSeq = minSeq - 1` 由连续前缀自然推进
117
-
118
- ### Fixed
119
- - short RPC 请求增加 `debug` 完整报文日志,便于跨语言诊断
120
-
121
- ---
122
-
123
- ## 0.3.0 — 2026-05-21 ⚠️ BREAKING CHANGE
124
-
125
- > **V2-only 版本**:移除全部 V1 E2EE(含群组加密),新增 V2 加密原语,API 不向后兼容。
126
-
127
- ### BREAKING
128
- - **移除 V1 E2EE 全部实现**:`e2ee-group.ts`、V1 epoch key 逻辑全部删除
129
- - **移除 V1 群组加密测试**:`e2ee.spec.ts`、`epoch-key-server.spec.ts`、`group-e2ee.spec.ts`、`group-join-key-recovery.spec.ts`
130
- - **E2EE 接口简化**:`e2ee.ts` 仅保留 V2 路径,V1 加解密方法不再可用
131
- - **配置变更**:`config.ts` 移除 V1 相关配置项
132
-
133
- ### Added
134
- - **agent.md 主 API(浏览器版本)**:`AUNClient.publishAgentMd(content)` / `AUNClient.fetchAgentMd(aid?)`
135
- - **V2 加密原语**(跨语言 golden vector 一致性):ECDH P-256、HKDF-SHA256、AES-256-GCM、ECDSA-SHA256 RAW、1DH/3DH wrap_key、Recipients Sort + Merkle Digest、State Commitment
136
- - **V2 Session**:SPK 生命周期 + 对端 IK 缓存 + PFS 三重销毁
137
- - **V2 KeyStore**:IndexedDB 持久化 SPK/IK 异步实现
138
-
139
- ### Removed
140
- - `AUNClient.setLocalAgentMdContent()` / `getLocalAgentMdEtag()` / `getRemoteAgentMdEtag()` — 由主 API 自动维护
141
-
142
- ### Deprecated
143
- - `client.auth.signAgentMd` / `verifyAgentMd` / `uploadAgentMd` / `downloadAgentMd` — 建议迁移到 `client.publishAgentMd` / `client.fetchAgentMd`
144
-
145
- ---
146
-
147
- ## 0.2.20 — 2026-05-18
148
-
149
- ### Added
150
- - **agent.md 版本一致性 API(浏览器版本)**:
151
- - `AUNClient.setLocalAgentMdContent(content: string): Promise<string>`:浏览器无法读本地文件,改为接收 markdown 文本字符串,用 `crypto.subtle.digest('SHA-256', ...)` 计算 etag。业务侧可用 `<input type=file>` 读出文本传入。
152
- - `AUNClient.getLocalAgentMdEtag(): string` / `getRemoteAgentMdEtag(): string`。
153
- - SDK 自动从 RPC envelope `_meta.agent_md_etag` 提取服务端 etag,应用层订阅 `message.received` / `group.message_created` 等事件时 payload 多 `_agent_md.{local_etag, remote_etag}` 字段供版本比对。
154
- - **`downloadAgentMd` 条件请求缓存**:内部维护 ETag/Last-Modified,未变化时返回上次缓存内容;外部 API 形态不变。
155
- - **transport meta observer**:`RPCTransport.setMetaObserver(fn)` 透传 envelope `_meta`,observer 抛错被吞,不影响 RPC result。
156
-
157
- ### Changed
158
- - **RPC call 默认超时 10s → 35s**:与服务端 30s handler timeout 对齐,留 5s buffer。
159
- - **multi-device 架构**:对端无 prekey 时 `_sendEncrypted` 直接抛错(`no registered device prekeys for ...`),不再降级到 `long_term_key`。
160
-
161
- ### Docs
162
- - 仓库根 `docs/`(agent.md 规范、protocol、SDK 手册)随 npm tarball 打包到 `_packed_docs/`,安装后可读。`.gitignore` 排除项(如内部测试指南)不进包。
163
-
164
- ---
1
+ # Changelog
2
+
3
+ 本文件记录 `@agentunion/fastaun-browser` SDK 的版本变更。最新版本在最前面。
4
+
5
+ 格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循 [SemVer](https://semver.org/lang/zh-CN/)。
6
+
7
+ ---
8
+
9
+ ## 0.4.4 — 2026-05-31
10
+
11
+ ### Added
12
+ - **`AID` 新增 `privateKeyPem` 只读字段**:`AIDStore.load()` 加载时注入明文私钥,`AUNClient` 直接从 `AID` 读取,无需再经 keystore 解密。
13
+
14
+ ### Changed
15
+ - **`AUNClient` 剥离私钥读写**:V2 session 初始化、`_signClientOperation`、propose_state 签名均改从 `_currentAid.privateKeyPem` 读取,删除 keystore fallback 重解密路径。
16
+ - **`auth._persistIdentity` 不再写私钥**:写入前剥离 `private_key_pem` / `public_key_der_b64` / `curve`,AUNClient 的 keystore 只持久化 token / cert / instance_state。
17
+ - **`AUNClient` keystore 构造不再传 `encryptionSeed`**:seed 作用域收窄至 AIDStore,不外漏。
18
+
19
+ ---
20
+
21
+ ## 0.4.3 — 2026-05-31
22
+
23
+ ### Added
24
+ - **`normalizeSlotId` / `slotIsolationKey`**:新增 slot_id 校验与隔离键提取工具函数,支持 `/` `:` 空格作为分隔符(首字符不允许)。
25
+ - **`ConnectOptions` 新增字段**:`connection_kind`、`short_ttl_ms`、`delivery_mode`、`extra_info`、`background_sync`,与 Python / Go / TS SDK 对齐。
26
+
27
+ ### Changed
28
+ - **`AUNClient` 构造**:传入 `aid` 参数时增加类型守卫(检查 `aunPath` 字段与 `isPrivateKeyValid` 方法),避免误传非 AID 对象。
29
+ - **slot_id 隔离逻辑**:`connect` 时若目标 slot_id 隔离键与当前不同,自动拒绝跨 slot 连接。
30
+ - **`background_sync` 触发时机**:连接成功后仅在 `sessionOptions.background_sync !== false` 时触发 P2P gap fill。
31
+ - **`verify_ssl=false` 浏览器警告**:浏览器环境不支持关闭 SSL 校验,传入时输出 warn 并强制保持启用。
32
+
33
+ ---
34
+
35
+ ## 0.4.2 2026-05-30
36
+
37
+ ### Added
38
+ - **`AIDStore` 新增具名返回类型**:`ResolveResult`、`FetchAgentMdResult`、`HeadAgentMdResult`、`CheckAgentMdResult`、`DiagnoseResult`、`RenewCertResult`、`RekeyResult`、`ChangeSeedResult`、`ListResult`,替代原来的 `Record<string, unknown>`。
39
+
40
+ ### Changed
41
+ - **移除 `discoveryPort`**:`AIDStore` 构造选项删除 `discoveryPort`,gateway URL 改为纯自动发现。
42
+ - **`fetchAgentMd` 新增 `timeoutMs` 参数**(默认 30000ms),`resolve` 内部调用时透传 `opts.timeout`。
43
+ - **返回字段精简**:`fetchAgentMd` / `headAgentMd` / `checkAgentMd` / `diagnose` 移除冗余的 camelCase 别名字段,统一使用 snake_case。
44
+ - **`resolve` 返回 `source` 字段精简**:移除 `certFromCache` / `agentMdFetched` camelCase 别名,只保留 `cert_from_cache` / `agent_md_fetched`。
45
+
46
+ ---
47
+
48
+ ## 0.4.0 — 2026-05-30
49
+
50
+ > **破坏性重构版本。** Python SDK 0.4.0 对齐:身份管理剥离为 `AID` / `AIDStore`;删除 `auth` / `custody` / `meta` 公开命名空间;引入 `Result` 与字符串错误码;连接状态机扩展为 9 态。浏览器环境下 `AID` 创建和签名/验证均为异步。
51
+
52
+ ### Breaking Changes
53
+ - **删除公开命名空间**:移除 `client.auth` / `client.custody` / `client.meta`。身份相关功能迁移到 `AIDStore` 与 `AID`,其余 RPC 走 `client.call()`。
54
+ - **`AID` 创建改为异步**:使用 `await AID.create(...)` 工厂方法(浏览器 Web Crypto API 限制);`sign` / `verify` / `signAgentMd` / `verifyAgentMd` 均为 `async`。
55
+ - **目录约定变更**:`{aun_path}/AgentMDs/` `{aun_path}/AIDs/`(IndexedDB key 前缀同步变更)。
56
+
57
+ ### Added
58
+ - **`AID` 类**(异步):`AID.create()` 工厂方法;`sign` / `verify` / `signAgentMd` / `verifyAgentMd` 均返回 Promise;`isCertValid` / `isPrivateKeyValid` 同步。
59
+ - **`AIDStore` 类**:离线 `load` / `list` / `exists`,联网 `register` / `resolve` / `fetchAgentMd` / `checkAgentMd` / `diagnose` / `renewCert` / `rekey` / `changeSeed`;存储后端为 IndexedDB。
60
+ - **`Result<T>` 类型**:统一结果类型(`{ ok: true; data: T }` 或 `{ ok: false; error: ErrorInfo }`)。
61
+ - **新增错误类**:`NotFoundError` / `IdentityConflictError` / `E2EEGroupSecretMissingError` / `E2EEGroupEpochMismatchError`。
62
+ - **`ConnectionState` 枚举**:9 态(`NO_IDENTITY` / `STANDBY` / `CONNECTING` / `READY` / `RETRY_BACKOFF` / `RECONNECTING` / `CONNECTION_FAILED` / `CLOSED`)。
63
+ - **实例级 `protected_headers`**:`setProtectedHeaders()` 自动合并到 `message.send` / `group.send` / `*.thought.put`。
64
+ - **重连状态可观测**:`nextRetryAt` / `retryAttempt` / `retryMaxAttempts` / `lastError` / `lastErrorCode` 属性。
65
+ - **导出**:`__version__` 常量、`STATE_TO_PUBLIC` 映射表、`ROOT_CA_PEM` 根证书。
66
+
67
+ ### Removed
68
+ - 删除 `js/src/namespaces/auth.ts`、`js/src/namespaces/custody.ts`、`js/src/namespaces/meta.ts`。
69
+
70
+ ---
71
+
72
+ ## 0.3.6 2026-05-28
73
+
74
+ ### Added
75
+ - **Encrypted push 解密管线**:收到加密推送时即时尝试 V2 解密,成功则发 `message.received` / `group.message_created`(含明文 payload + e2ee 元数据),失败则发 `message.undecryptable` / `group.message_undecryptable`(含诊断字段 `_decrypt_error` / `_decrypt_stage` / `_envelope_type`)
76
+ - **`auth.fetchPeerCert(gatewayUrl, aid)`**:公开 API 实现落地(v0.3.5 声明,v0.3.6 实现独立方法体)
77
+ - **`storage.get_limits` RPC**:查询上传限制和配额使用情况
78
+ - **`storage.check_upload` RPC**:上传预检(秒传检测 + 超限检测)
79
+
80
+ ### Fixed
81
+ - **Identity cache 自愈**:V2 session init 时检测 `private_key_pem` 缺失,自动从 keystore 重新加载并清理脏 instance_state
82
+ - **`loadIdentity` 字段白名单**:只合并 `_INSTANCE_STATE_FIELDS` 定义的字段,防止 instance_state 表中的脏数据覆盖核心字段
83
+
84
+ ---
85
+
86
+ ## 0.3.5 — 2026-05-28
87
+
88
+ ### Breaking Changes
89
+ - **`createAid()` → `registerAid()`**:客户端 API 重命名,旧方法已移除
90
+ - **注册与认证分离**:`authenticate()` 不再隐式注册;身份不完整时抛 `StateError`
91
+
92
+ ### Added
93
+ - **`IdentityConflictError`**:新增错误类型(继承 `AuthError`),AID 注册冲突时抛出
94
+ - **`auth.loadIdentity()` / `auth.loadIdentityOrNull()`**:公开 API,只读加载本地已注册身份(密钥对 + 证书 + 实例状态),无副作用
95
+ - **`auth.fetchPeerCert()`**:公开 API,获取对端 AID 证书 PEM(本地缓存优先,未命中走 PKI HTTP + 链验证)
96
+ - **Pull Gate**:per-key 序列化 pull 操作,防止同一 namespace 并发 pull
97
+ - **RPC Inflight 限制**:transport 层全局最大 16 个并发 RPC + 后台 RPC 独立限制 8 个,排队超时抛 `TimeoutError`
98
+ - **`_assertCertMatchesLocalKeypair`**:authenticate 前显式校验 cert 公钥与本地 keypair 一致
99
+ - **`_downloadRegisteredCert`**:注册前查服务端证书的辅助方法
100
+
101
+ ### Changed
102
+ - **`registerAid` 半成品恢复**:本地有 keypair cert 时,查服务端恢复;服务端无记录则用现有 keypair 注册
103
+ - **agent.md 元数据存储**:从全局 `list.json` key 改为 per-AID `{aid}/agentmd.json` key(IndexedDB)
104
+ - **agent.md 下载**:改为无条件 GET;302 显式跟随;304 时本地有缓存直接用,无缓存重试
105
+ - **`_loadIdentityOrRaise`**:增加 keypair 完整性检查
106
+ - **`ChangeSeed` API**:`IndexedDBKeyStore.changeSeed()` 支持更换 seed(重加密私钥)
107
+
108
+ ### Removed
109
+ - **`_ensureLocalIdentity` / `_ensureIdentity`**:已移除,注册路径不再隐式生成密钥
110
+ - **`createAid` 方法**:已移除
111
+
112
+ ---
113
+
114
+ ## 0.3.3 — 2026-05-25
115
+
116
+ ### Added
117
+ - **V2 Thought 加解密**:`group.thought.get` / `message.thought.get` 返回值自动解密;发送端自动加密;`attachV2EnvelopeMetadata` 附加 E2EE 元数据
118
+ - **V2 Sender IK 延迟解密**:`_v2SenderIKPending` / `_v2SenderIKFetching` 机制,对端 IK 未缓存时挂起消息、异步拉取后重试解密
119
+ - **agent.md 本地缓存体系(浏览器版本)**:`publishAgentMd(content?)` / `fetchAgentMd(aid?)`;基于 IndexedDB/localStorage 的 list + 按 AID 存储 + etag 比对 + 自动拉取缺失
120
+ - **V2 辅助函数**:`getV2DeviceId` / `_v2B64ToBytesStrict` / `_v2BytesEqual` / `_v2ConcatBytes` / `_v2LengthPrefixedTextKey` / `_v2LengthPrefixedBytes`
121
+ - **V2 envelope 元数据**:`attachV2EnvelopeMetadata` / `attachV2EnvelopeMetadataFromSource` / `extractV2EnvelopeFromSource` / `metadataWithoutAuth`
122
+
123
+ ### Changed
124
+ - **V2 消息处理路径重构**:统一 P2P/Group 解密入口,支持 sender IK pending 延迟模式
125
+ - **V2 SPK rotation**:thought 解密失败时触发 group SPK rotation / registration after peer fallback
126
+
127
+ ### Fixed
128
+ - **service-plane envelope 解包**:修复 Kernel trace 字段传递丢失
129
+ - **trace 树状展示**:enter/exit 配对 + 嵌套缩进
130
+
131
+ ---
132
+
133
+ ## 0.3.1 — 2026-05-22
134
+
135
+ ### Added
136
+ - **`auth.checkAid` handler**:本地证书自检 + 远端注册状态查询(与 Node 版对齐)
137
+ - **RPC trace 增强(浏览器版本)**:`RPCTransport` 增加 `setTraceMode()` / `setTraceObserver()`;`sortTraceSpansForDisplay` / `formatTraceTree` / `traceDisplay` 树状展示
138
+ - **V2 群组 SPK 生命周期**:`V2KeyStore.saveGroupSPK` / `loadGroupSPK` / `loadCurrentGroupSPK` 基于 IndexedDB 持久化;`V2Session.ensureGroupSPK` / `ensureGroupRegistered` / `rotateGroupSPK` / `getGroupDecryptKeys`;`DESTROY_DELAY_MS = 7d`
139
+ - **V2 P2P push 解密**:`AUNClient` 增加 push payload 就地解密路径,失败回退到 pull
140
+
141
+ ### Changed
142
+ - **`SeqTracker.forceContiguousSeq`**:原 `contiguousSeq = minSeq` 跳过空洞(会丢消息),改为 `contiguousSeq = minSeq - 1` 由连续前缀自然推进
143
+
144
+ ### Fixed
145
+ - short RPC 请求增加 `debug` 完整报文日志,便于跨语言诊断
146
+
147
+ ---
148
+
149
+ ## 0.3.0 — 2026-05-21 ⚠️ BREAKING CHANGE
150
+
151
+ > **V2-only 版本**:移除全部 V1 E2EE(含群组加密),新增 V2 加密原语,API 不向后兼容。
152
+
153
+ ### BREAKING
154
+ - **移除 V1 E2EE 全部实现**:`e2ee-group.ts`、V1 epoch key 逻辑全部删除
155
+ - **移除 V1 群组加密测试**:`e2ee.spec.ts`、`epoch-key-server.spec.ts`、`group-e2ee.spec.ts`、`group-join-key-recovery.spec.ts`
156
+ - **E2EE 接口简化**:`e2ee.ts` 仅保留 V2 路径,V1 加解密方法不再可用
157
+ - **配置变更**:`config.ts` 移除 V1 相关配置项
158
+
159
+ ### Added
160
+ - **agent.md 主 API(浏览器版本)**:`AUNClient.publishAgentMd(content)` / `AUNClient.fetchAgentMd(aid?)`
161
+ - **V2 加密原语**(跨语言 golden vector 一致性):ECDH P-256、HKDF-SHA256、AES-256-GCM、ECDSA-SHA256 RAW、1DH/3DH wrap_key、Recipients Sort + Merkle Digest、State Commitment
162
+ - **V2 Session**:SPK 生命周期 + 对端 IK 缓存 + PFS 三重销毁
163
+ - **V2 KeyStore**:IndexedDB 持久化 SPK/IK 异步实现
164
+
165
+ ### Removed
166
+ - `AUNClient.setLocalAgentMdContent()` / `getLocalAgentMdEtag()` / `getRemoteAgentMdEtag()` — 由主 API 自动维护
167
+
168
+ ### Deprecated
169
+ - `client.auth.signAgentMd` / `verifyAgentMd` / `uploadAgentMd` / `downloadAgentMd` — 建议迁移到 `client.publishAgentMd` / `client.fetchAgentMd`
170
+
171
+ ---
172
+
173
+ ## 0.2.20 — 2026-05-18
174
+
175
+ ### Added
176
+ - **agent.md 版本一致性 API(浏览器版本)**:
177
+ - `AUNClient.setLocalAgentMdContent(content: string): Promise<string>`:浏览器无法读本地文件,改为接收 markdown 文本字符串,用 `crypto.subtle.digest('SHA-256', ...)` 计算 etag。业务侧可用 `<input type=file>` 读出文本传入。
178
+ - `AUNClient.getLocalAgentMdEtag(): string` / `getRemoteAgentMdEtag(): string`。
179
+ - SDK 自动从 RPC envelope `_meta.agent_md_etag` 提取服务端 etag,应用层订阅 `message.received` / `group.message_created` 等事件时 payload 多 `_agent_md.{local_etag, remote_etag}` 字段供版本比对。
180
+ - **`downloadAgentMd` 条件请求缓存**:内部维护 ETag/Last-Modified,未变化时返回上次缓存内容;外部 API 形态不变。
181
+ - **transport meta observer**:`RPCTransport.setMetaObserver(fn)` 透传 envelope `_meta`,observer 抛错被吞,不影响 RPC result。
182
+
183
+ ### Changed
184
+ - **RPC call 默认超时 10s → 35s**:与服务端 30s handler timeout 对齐,留 5s buffer。
185
+ - **multi-device 架构**:对端无 prekey 时 `_sendEncrypted` 直接抛错(`no registered device prekeys for ...`),不再降级到 `long_term_key`。
186
+
187
+ ### Docs
188
+ - 仓库根 `docs/`(agent.md 规范、protocol、SDK 手册)随 npm tarball 打包到 `_packed_docs/`,安装后可读。`.gitignore` 排除项(如内部测试指南)不进包。
189
+
190
+ ---