@tansr/sdk 0.13.1 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -48,6 +48,39 @@ P 和 S 同为模型 system 输入,拼接次序不保证冲突指令谁胜出
48
48
 
49
49
  完整三档 SDK、Windows Electron、serve、Android/iOS 示例见[提示词指南](https://docs.tansr.com/sdk/system-prompts/)与仓内 doc/90 §4.12。此能力仍须发布包含 AP-SP 的 API 与 SDK/serve,旧版本不识别保留策略。
50
50
 
51
+ ## 模型、上下文和图文输入
52
+
53
+ 开发中的新接口须使用包含它们的 SDK 构建;旧 npm 包没有这些接口时,宿主应提示升级。
54
+ `session.contextState()` 和 `session.subscribeContext(listener)` 提供可序列化快照:
55
+ `selected` 是下一轮模型,`active` 是运行轮冻结的模型;`lastObserved` 仅在收到模型用量证据后存在。
56
+ `currentModel({ active: true })` 查询执行轮模型,空闲时返回当前选择。fallback 只报告已观测到的提供方变化。
57
+ `budget` 包含物理与有效窗口、输入估算、输出/思考预留、剩余量、压缩阈值及设置来源。
58
+ 未知值为 `null`;本地输入估算与平台累计计费用量分别展示。
59
+
60
+ 大窗口降到小窗口时,在空闲状态 `await session.switchModel(next)`。
61
+ SDK 保留迁移前原文备份,必要时用源模型分段摘要,核验目标预算并落盘后再提交切换;
62
+ 图片、工具配对及其前后顺序保留,无法容纳即拒绝。失败或取消不静默截断历史。
63
+ `modelTransitionBackup()` 可取回最近一次迁移备份;需要跨进程恢复时配置 checkpoint/store。
64
+ 外部压缩管理器需要通过 `switchModel(next, { compaction })` 显式提供与目标匹配的配置。
65
+ 摘要调用可能产生用量;备份不代表摘要语义必然完整,业务关键事实仍应核对。
66
+
67
+ `sendBlocks([{ t: 'image', mime: 'image/png', data: base64 }, { t: 'text', text: '描述图片' }])`
68
+ 提交同一轮图文,返回 `started` 或带原因的 `rejected`。忙时由宿主保留整份草稿,不能自动去图重发。
69
+ 图片需满足格式魔数、单图 3.75 MiB、最多 20 张、总图片 30 MiB 和上下文预算限制;
70
+ 模型与传输通道都需支持图片。Read 产生的像素随工具结果发送到支持视觉的模型,元数据读取成功不等于模型已看见图片。
71
+
72
+ `planSpeechInput(text, { maxCharacters, segment })` 使用授权模型 `maxChars` 规划朗读;
73
+ 汉字按 2、其他 Unicode 码点按 1 估算。超出单次限制须显式允许分段,总上限 32000、最多 32 段。
74
+ 宿主负责逐段执行、取消和保留产物,已成功或结果不明的收费请求不自动重放。
75
+ 应用提示词刷新失败提供 `reason`、`stage`、`retry`,继续中止该轮;由宿主换发开发者凭据并决定重试。
76
+
77
+ The new interfaces above require a build that includes them. `contextState()` separates the next selected
78
+ model, the active turn's frozen model, observed usage, and local context estimates. Unknown values are
79
+ `null`. Await `switchModel()` while idle to prepare and validate a smaller context before committing;
80
+ failure keeps the original history. `sendBlocks()` submits image and text together and rejects busy
81
+ submissions without removing images. Speech planning requires the authorized model's character limit
82
+ and explicit segmentation; completed or uncertain paid requests must not be replayed automatically.
83
+
51
84
  ## 三档 API × 三档模型来源
52
85
 
53
86
  | API | 形态 | 适用 |
@@ -1,8 +1,8 @@
1
1
  {
2
- "revision": 4,
3
- "sha256": "c57ffb63c51fa37f84814857240785a1c1d433839a7d0e6ebcdedc419838597c",
2
+ "revision": 7,
3
+ "sha256": "99d86f2b3ac6b6183bee7ca7717cbc6fa4b3af88fc1c8cf2d683488cde610e94",
4
4
  "errorCodes": 38,
5
- "eventTypes": 54,
5
+ "eventTypes": 55,
6
6
  "eventTypeNames": [
7
7
  "agent.completed",
8
8
  "agent.followup",
@@ -39,6 +39,7 @@
39
39
  "session.created",
40
40
  "session.cwd_changed",
41
41
  "session.ended",
42
+ "session.events_dropped",
42
43
  "session.forked",
43
44
  "session.locale.changed",
44
45
  "session.microcompacted",
@@ -59,8 +60,8 @@
59
60
  "turn.error",
60
61
  "turn.started"
61
62
  ],
62
- "eventSchemaSha256": "ddc7afac50d2ff8980ebeab2d8b3089dd197623dc2a23049e76a0944fa15ef59",
63
+ "eventSchemaSha256": "54b587ade59bf20a3d55647a160c3d857dbf2fa73730d82cf7811b7ee4097501",
63
64
  "contractVersion": "v1",
64
- "sourceCommit": "34a6f37e23036ce8aa7cccd67dbbbd40863d8544",
65
- "generatedAt": "2026-09-10T02:55:26.356Z"
65
+ "sourceCommit": "d346aadf99e1b7ce1db2226b71de03adcc22f3df",
66
+ "generatedAt": "2026-09-12T09:12:29.149Z"
66
67
  }