@sema-agent/sdk 29.0.0 → 30.0.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/dist/types.d.ts CHANGED
@@ -580,7 +580,7 @@ export interface TaskRequest {
580
580
  * 正解 = `GET /v1/runs/<taskId>` 读真相,或等 executor 重连后再试。
581
581
  * · ⚠️ 换绑与提交**不要并发**(§14.6 末段成文残留:换绑的「无活跃 run」门是 check→act);先 rebind
582
582
  * 拿到 200 再提交,或提交后用
583
- * {@link import("./resources/devices.js").DevicesResource.sessionBinding} 回读一次。
583
+ * {@link import("./resources/sessions.js").SessionsResource.executionPlacement} 回读一次。
584
584
  * · 走 device 车道**不会**比 host 车道多问任何一次工具审批(`permissionMode` 读数同构造)。
585
585
  */
586
586
  deviceId?: string;
@@ -600,16 +600,9 @@ export interface TaskRequest {
600
600
  * 全部去掉」那个形。边界由 core 判,server **原样透传**它的拒绝码供壳渲染:
601
601
  * `resume_at.before_target_not_user`(只接受普通 user 消息作目标)、
602
602
  * `resume_at.before_root_unsupported`(不能倒退过会话根 —— 该开新会话了)、
603
- * `rewind_snapshot.unresolvable`(配文件还原 `restoreFiles` 时:目标自己没有文件历史边界 —— `before` 的还原只认目标**自己**的边界、不会越到更早一回合;
604
- * 退役拼法 `rewindFiles` 的还原义是 core 的迁移拒,点名 `restoreFiles`)。
603
+ * `rewind_snapshot.unresolvable`(配文件还原 `restoreFiles` 时:目标自己没有文件历史边界 —— `before` 的还原只认目标**自己**的边界、不会越到更早一回合)。
605
604
  * **只在配 `resumeAt` 时有意义**;单独送 = 400 fail-loud(不是静默 no-op)。 */
606
605
  resumeAtMode?: "at" | "before";
607
- /** ⚰️ **退役拼法**(整树快照纪元;S-15 / design/381,server ≥7.52 起;sdk 11.4.0 注改真,与 {@link rewindFilesTo} 同一类陈旧注 [8437] U3)。
608
- * server `src/http/wire-types.ts` 逐字:仍收在 wire 上 —— 「捕获」义(`true`、不配 `resumeAt`)是被容忍的 no-op + 弃用披露;
609
- * 「恢复」义(`true` + `resumeAt`)是 core 的 **typed 迁移拒**,点名 {@link restoreFiles}(恢复语义真的变了:整树 ⇒ 跟踪集,
610
- * server 从不静默改写)。⇒ 新代码发 `restoreFiles`(先探 `capabilities.restoreFiles`)。本键照**钉版 server 的请求面**声明:
611
- * 它仍收这个拼法(上面两种答法都是它的真行为),sdk 26.0.0 的律「开形面上的退役键以钉版 server 的面为准」⇒ 留到 server 那边删的那一版同版删。 */
612
- rewindFiles?: boolean;
613
606
  /** 🔴 E18 code-only rewind(core 1.166.0 `TaskSpec.rewindFilesTo`;server「R8」)—— 把本会话编辑过的**跟踪集**文件收敛到
614
607
  * 某一条 **user message** 那一刻的历史边界、**不** fork 对话(会话 leaf 不动,只动文件)。= CC Rewind "code"-only 模式
615
608
  * (`resumeAt`+`restoreFiles` = both、`resumeAt` 单独 = conversation、本字段 = code)。
@@ -628,8 +621,9 @@ export interface TaskRequest {
628
621
  /** S-15 纪元请求键(design/381,server ≥7.52 校验布尔并透传 core;codex 复审 R1-[medium] 补齐 ——
629
622
  * capabilities.restoreFiles 教人发本键,而类型面此前写不出它)。配 `resumeAt`:分叉时把**跟踪集**
630
623
  * (本会话编辑过的文件)恢复到该边界 —— S-15 起 restore 语义收窄 whole-tree ⇒ tracked-set,请求键
631
- * 随之从 `rewindFiles` 换拼(旧拼法 `rewindFiles`+`resumeAt` 在 ≥7.52 吃 core 的 typed 迁移拒)。
632
- * 🔴 先探 `capabilities.restoreFiles` 再发:位缺席=老 server(发旧拼法);两拼法别同发。 */
624
+ * 随之从旧拼法 `rewindFiles` 换拼。🔴 **旧拼法 `rewindFiles` 随 sdk 30.0.0 / server 7.139.0 整删**(server MIGRATION 7.139.0 节第 2 条,零别名):新提交带它 ⇒ `400 request.body_shape` + `unknownKeys: ["rewindFiles"]`、不建 run;
625
+ * ≥7.52 且 <7.139.0 的 server 对它的答法是「捕获义被容忍的 no-op / 恢复义 = core 的 typed 迁移拒」,本包不再描述 —— 读到 `restoreFiles` 即可,先探 `capabilities.restoreFiles`;
626
+ * 位缺席 = <7.52 的 server,低于本包支持地板。 */
633
627
  restoreFiles?: boolean;
634
628
  /** S-15 同批键(design/381 DV-15;server ≥7.52 校验布尔并透传 core,语义属主=core 的 restore 合同,
635
629
  * dist types.d.ts 亲读):部分恢复同意位 —— 缺席/false = 收敛中 ≥1 文件被拒/失败时 loud 终局
@@ -644,7 +638,7 @@ export interface TaskRequest {
644
638
  * 不铸回合边界(子代继承);缺席 = 按部署设置(**没有** `"enabled"` 的拼法)。
645
639
  * · 拼写门(fresh / resume 两腿同判):别的任何值 ⇒ 400 `request.field_invalid`,句子以
646
640
  * `fileHistory must be the string 'disabled' when present` 开头;
647
- * · 🔴 与任一还原键**同体**(`restoreFiles` / {@link rewindFilesTo} / 退役 {@link rewindFiles})⇒ **受理时** 400
641
+ * · 🔴 与任一还原键**同体**(`restoreFiles` / {@link rewindFilesTo})⇒ **受理时** 400
648
642
  * `request.field_conflict`(`fileHistory: 'disabled' cannot ride with a file restore …`),会话与文件都不动 —— 要还原就别带它;
649
643
  * · 这条腿的实际结论读 `wiring_manifest.fileHistory`(`"on"` / `"disabled"`);要不要给用户渲「本会话不捕获」开关读
650
644
  * {@link Capabilities.fileHistoryCapture}(`"on-optional"` 才渲;「本会话不捕获」= 这条会话的每个提交都带本键)。
@@ -3347,7 +3341,7 @@ export interface GateOutcome {
3347
3341
  */
3348
3342
  export type McpDelivered = "yes" | "no" | "unknown";
3349
3343
  /**
3350
- * MCP 失败的**类**(core `MCP_FAILURE_KINDS`:7.6.0 闭十词;core 7.58.0 起 `credential_unavailable`、core 7.59.0 起 `unauthorized` ⇒ 十二词,server ≥7.138.0)—— `tool_end.errorCode` 与
3344
+ * MCP 失败的**类**(core `MCP_FAILURE_KINDS`:7.6.0 闭十词;core 7.58.0 起 `credential_unavailable`、core 7.59.0 起 `unauthorized` ⇒ 十二词,server ≥7.138.0;core 7.60.0 起 `host_refused` ⇒ 十三词,server ≥7.139.0)—— `tool_end.errorCode` 与
3351
3345
  * `wiring_manifest.mcp[].errorCode` 上 MCP 那一族的取值。
3352
3346
  * `connect_refused`(连接相 errno:请求**可证**从未离开)/ `connection_failed`(其他 errno:可能跑过了)/
3353
3347
  * `connection_closed`(SDK 报传输已关:在飞时命运不可知,对已知死掉的服务器则从未尝试——两者靠
@@ -3355,12 +3349,13 @@ export type McpDelivered = "yes" | "no" | "unknown";
3355
3349
  * 或凭据席答「这个主体在这里没被授权」;下一步在用户,不是等故障恢复。此前前两形是 `http_status` + `httpStatus`)/ `http_status`(HTTP 端点回了状态而不是 MCP 响应;数字在 `httpStatus`)/
3356
3350
  * `not_mcp_response` / `spawn_failed`(stdio 子进程起不来)/ `timeout` / `protocol`(服务器**答**了一个
3357
3351
  * MCP/JSON-RPC 错:交换发生过)/ `invalid_config`(声明本身拨不出去 —— 要改 spec,不是等它恢复)/ `credential_unavailable`(server ≥7.138.0:
3358
- * 部署的凭据席没给出这次请求 —— 席抛了、没按时答,或答了引擎带不了的东西;这次请求**没发出**,是部署要修的故障,不是服务器挂了)/ `unknown`。
3352
+ * 部署的凭据席没给出这次请求 —— 席抛了、没按时答,或答了引擎带不了的东西;这次请求**没发出**,是部署要修的故障,不是服务器挂了)/ `host_refused`(server ≥7.139.0 / core 7.60.0:
3353
+ * 宿主提供的传输〔core `McpServerSpec` 的 `transport.kind: "host"`〕的**宿主席**没有把这次请求交给对端 —— 请求**没发出**〔`delivered: "no"`〕;server 7.139.0 发布字节里没有任何宿主传输席的装配点,所以部署上读不到它,词表以引擎为准,故收进已知词)/ `unknown`。
3359
3354
  * 🔴 core 7.6.0 起**退役** `MCP_FAILURE_CODES` 那张十词表,`network` 与 `http_<status>` **两种拼法一并作废**
3360
3355
  * (HTTP 状态从此走结构位 `httpStatus`,不再编进码里)。
3361
3356
  * 🔴 `tool_end.errorCode` 整体仍是**开集**(词表属主是工具);本类型只描述其中 MCP 这一族,按开集读。
3362
3357
  */
3363
- export type McpFailureKind = "connect_refused" | "connection_failed" | "connection_closed" | "unauthorized" | "http_status" | "not_mcp_response" | "spawn_failed" | "timeout" | "protocol" | "invalid_config" | "credential_unavailable" | "unknown" | (string & {});
3358
+ export type McpFailureKind = "connect_refused" | "connection_failed" | "connection_closed" | "unauthorized" | "http_status" | "not_mcp_response" | "spawn_failed" | "timeout" | "protocol" | "invalid_config" | "credential_unavailable" | "host_refused" | "unknown" | (string & {});
3364
3359
  /**
3365
3360
  * 一条腿的 **MCP 装配名册**里的**一行**(core ≥7.5.0 #562 / ≥7.6.0 S6-B,server ≥7.60;**租户可见**):
3366
3361
  * 这条腿申报的那台服务器连上了没有、没连上是哪一类、挂上来几只工具。
@@ -4345,12 +4340,12 @@ export interface Capabilities extends EngineCapabilityBits {
4345
4340
  * 仅 env-only/无后端 worker false。 */
4346
4341
  resumeAt?: boolean;
4347
4342
  /** 🔴 E19 rewind-files gate(server ≥7.52 谓词改 `Boolean(fileHistoryStore)`,S-15 换店;≤7.51 为
4348
- * `Boolean(fileSnapshotStore)`)—— `TaskRequest.rewindFiles` 能否生效(分叉时同步回退**跟踪集**文件;
4349
- * S-15 起 restore 语义收窄 whole-tree ⇒ tracked-set,位名不变=wire 兼容)。false/缺 ⇒ rewind 仅回退对话。 */
4343
+ * `Boolean(fileSnapshotStore)`)—— 部署有没有**文件历史店**,即文件还原腿({@link TaskRequest.restoreFiles} / {@link TaskRequest.rewindFilesTo})能不能生效(分叉时同步回退**跟踪集**文件;
4344
+ * S-15 起 restore 语义收窄 whole-tree ⇒ tracked-set,位名不变=wire 兼容)。false/缺 ⇒ rewind 仅回退对话。
4345
+ * ⚠️ **位名是历史拼法**:同名请求键 `TaskRequest.rewindFiles` 随 server 7.139.0 / sdk 30.0.0 退役(新提交 400 `request.body_shape`),位本身 server 仍铸 —— 位与键是两个面,别因键没了就以为位也没了。 */
4350
4346
  rewindFiles?: boolean;
4351
4347
  /** S-15 纪元判别位(server ≥7.52,`Boolean(fileHistoryStore)`)—— 服务端认 **`restoreFiles` 请求键/
4352
- * 跟踪集语义**的显式在场位。🔴 老客户端看见熟悉的 `rewindFiles:true` 会发旧键(`rewindFiles`+`resumeAt`
4353
- * ⇒ core typed 迁移拒),新客户端据**本位**协商发 `restoreFiles`(+`resumeAt`);位缺席=老 server,发旧键。 */
4348
+ * 跟踪集语义**的显式在场位。据**本位**协商发 `restoreFiles`(+`resumeAt`);位缺席 = <7.52 的 server,低于本包支持地板。 */
4354
4349
  restoreFiles?: boolean;
4355
4350
  /** 🔴 K-1c 手动 compact gate(service src/http/routes/capabilities.ts `Boolean(runStore)`,POST /v1/runs/:id/compact → core 1.156
4356
4351
  * `TaskStream.compact()`)—— 手动 `/compact` 命令是否可发。配 `compacted` 事件的 `trigger:"manual"`。false/缺 ⇒ 灰掉
@@ -4786,7 +4781,7 @@ export interface Capabilities extends EngineCapabilityBits {
4786
4781
  * 🔴 K-24 改真(server ≥7.104.0 / S-724):7.97.0–7.103.x 上那一席是**捕获脸**(后端 ∧ 部署旋钮 `FILE_HISTORY_CAPTURE`),关掉捕获的
4787
4782
  * 部署上本位与 `rewindFiles` / `restoreFiles` / `sessionSync` 同为 false;**7.104.0 起旋钮只关捕获**(店照接,已存历史照常
4788
4783
  * 还原 / 同步)⇒ 本位与那三位只看「有没有文件历史店」(= 有没有存储后端),与旋钮无关 —— `fileHistoryCapture: "off"` 不再意味着
4789
- * 没有 rewind。rewind 入口看本位 / `rewindFiles`,**别**看 {@link fileHistoryCapture}。 */
4784
+ * 没有 rewind。rewind 入口看本位 / {@link rewindFiles}(能力位),**别**看 {@link fileHistoryCapture}。 */
4790
4785
  rewindFilesTo?: boolean;
4791
4786
  /** assistant-scheduler 面(`routes/capabilities.ts` 的能力对象 `schedulerEnabled && requirePrincipal!==true && remoteExec==="host"` 三与)。 */
4792
4787
  scheduler?: boolean;
@@ -4825,7 +4820,7 @@ export interface Capabilities extends EngineCapabilityBits {
4825
4820
  protocolVersion: number;
4826
4821
  maxInflightPerDevice: number;
4827
4822
  wsPath: string;
4828
- /** 🔴 **`/v1/devices/*` 管理面六动词在不在**(server ≥7.88.0,契约 §14;`routes/capabilities.ts`
4823
+ /** 🔴 **`/v1/devices/*` 管理面动词在不在**(server ≥7.88.0,契约 §14;`routes/capabilities.ts`
4829
4824
  * 的 `deviceExecutor` 对象;谓词与该族 501 `capability.device_lane_required` 的判据**逐字同源**
4830
4825
  * —— device store + hub + 准入链三件齐,由 `boot/device-lane.ts` 一处建齐)。
4831
4826
  *
@@ -5142,7 +5137,7 @@ export interface Capabilities extends EngineCapabilityBits {
5142
5137
  * `src/file-history-capture.ts` 的 `FILE_HISTORY_CAPTURE_WORD_SET` —— 测试对它做源码腿 / dist 腿的词表对拍)。从**装配结果**派生
5143
5138
  * (店在 ∧ 部署旋钮 `FILE_HISTORY_CAPTURE` 没关),**不是**旋钮字面回声 —— 无后端的部署同样是 `"off"`。穷举读:
5144
5139
  * · `"off"` —— 这台部署**不捕获**任何改动文件的首次快照 ⇒ 不渲「关闭捕获」开关。🔴 7.104.0 起**不再连带 rewind**:
5145
- * 旋钮只关捕获,已存历史照常 `restoreFiles` / `rewindFilesTo` / session-sync —— rewind 入口看 `rewindFiles` / {@link rewindFilesTo},别看本位;
5140
+ * 旋钮只关捕获,已存历史照常 `restoreFiles` / `rewindFilesTo` / session-sync —— rewind 入口看能力位 `rewindFiles` / {@link rewindFilesTo},别看本位;
5146
5141
  * · `"on-optional"` —— 捕获中,且**可以按 run 关掉**:提交体带 {@link TaskRequest.fileHistory} `"disabled"` ⇒ 渲开关
5147
5142
  * (关 = 这条会话的每个提交都带它;续跑腿重放同一个体,照带);
5148
5143
  * · ⚰️ `"on-always"` —— **退役词**(server 7.104.0 起不再发出:请求词接线后「捕获中且关不掉」结构上不可达),7.97.0–7.103.x 的 worker
@@ -5151,7 +5146,7 @@ export interface Capabilities extends EngineCapabilityBits {
5151
5146
  * 判一份合法的 7.103 能力面违约、消费端写不出契约要的那一臂);登记 `_keyset-divergence.ts` `CAPABILITY_RETIRED_WORDS`,
5152
5147
  * 删除条件 = 支持地板抬过 7.104.0。
5153
5148
  * 词表外的词按未知处理(不按前缀猜,不渲开关)。⚠️ 关掉 ≠ 删掉:部署翻成 `"off"` 不做任何批量删除。
5154
- * ⚠️ 缺席 = 老 worker(≤7.96,没有这根旋钮)⇒ 按 `rewindFiles` 兜底:`true` 读作 `"on-always"`、`false` 读作 `"off"`(那时捕获 ⟺
5149
+ * ⚠️ 缺席 = 老 worker(≤7.96,没有这根旋钮)⇒ 按能力位 `rewindFiles` 兜底:`true` 读作 `"on-always"`、`false` 读作 `"off"`(那时捕获 ⟺
5155
5150
  * 历史店在场,逐字等价)。 */
5156
5151
  fileHistoryCapture?: "off" | "on-optional" | "on-always";
5157
5152
  /** **模型钥匙 sealed 形的公钥发现面**(K-24;server ≥7.104.0 / S-737;铸点 int-7104 `routes/capabilities.ts:969` 普通成员
@@ -5906,6 +5901,12 @@ export interface SessionSummary {
5906
5901
  * **缺席 = 老 server(≤7.124.x)**——按「没有置顶」读,别读成错误。排序不变(仍按 `lastActivityAt` 新近序),置顶段由端侧按本位分组;
5907
5902
  * 改名 / 置顶**不动** `lastActivityAt`;服务重启后置顶位仍在(两种后端同读数)。 */
5908
5903
  pinned?: boolean;
5904
+ /** server ≥7.139.0(additive,契约 §20「条件写」):**行标签** —— 不透明串(43 个 `[A-Za-z0-9_-]` 字符),只拿来原样回传给 {@link import("./resources/sessions.js").SessionPatchBody.expectedRowTag}:
5905
+ * 「这一行仍是我读到的那一份,才写」。在**这一行的可写位**(今天 `title` / `pinned`)或**这只会话本身**(删后同 id 重建、同一会话换属主)变了时变;一次新 run、活动时间、预览变化**不**让它变;
5906
+ * 值改走又改回 = 没变(不判值的往返);对没变的值再写一遍(如对没置顶的行写 `pinned: false`)也不让它变 —— **标签是行当前值的函数,不是写计数器**。`GET /v1/sessions` 的每一行、`PATCH` 的 200 行、`409 conflict.session_row_changed` 的 `currentRow`(体键,读法见 {@link import("./errors.js").SessionRowChangedExtra})是**同一只投影**,都带它。
5907
+ * **present-iff** 这一行可被条件写:三种持久会话后端的行都带;没有会话元数据的老形枚举面(内存 run 店聚合)不带。**缺席 = 老 server(≤7.138.x)或那种列表面**,按「没有标签、只能无条件写」读,别读成错误。
5908
+ * 🔴 不要解析它、不要比较大小、不要跨会话用;拿它做条件写时撞 409 就用 `currentRow` 重新决定、再带那一行的 `rowTag` 发 —— **不要原样重发**(只会再得 409)。不加能力位:行上有它即支持。 */
5909
+ rowTag?: string;
5909
5910
  /** server ≥7.91.0(additive,老 server 缺席):会话活动词,由最近 run 的状态经 server 与 peer 目录**同一张**映射表派生
5910
5911
  * (running → `active`;suspended / needs_review → `blocked`;无非终态 run → `idle`)。壳的会话列表 / peer 行 tempo 同源。 */
5911
5912
  tempo?: "active" | "idle" | "blocked";
@@ -6221,6 +6222,9 @@ export interface SessionBackgroundRow {
6221
6222
  /** core 的 retain 谓词(env 声明 / 任务 lane / 行标记任一 ⇒ 留)—— **真才带**,恒不铸 `false`;只可能出现在 shell 行
6222
6223
  * (`background_bash` / `monitor`,core `list()` 行注)。在场 = 退出单上「会继续跑」;缺席 = `includeRetained:false` 的硬收**会**停它。 */
6223
6224
  retained?: true;
6225
+ /** server ≥7.139.0(additive,MIGRATION 7.139.0 节第 7 条):后台 agent 行在**子会话绑定之后**带它 —— 跳到子会话用(那只会话照常过会话面的属主门,读它走 `sessions.get`)。
6226
+ * **缺席 = 没有 / 还没绑定**(含老 server),不是错误;只会出现在 `background_agent` 行。 */
6227
+ sessionId?: string;
6224
6228
  [k: string]: unknown;
6225
6229
  }
6226
6230
  /** `GET /v1/sessions/:id/background` 的 200 体(契约 §16)。空会话 ⇒ `{ rows: [] }`。 */
@@ -6600,24 +6604,12 @@ export interface DeviceSummary {
6600
6604
  export interface DeviceListResult {
6601
6605
  devices: DeviceSummary[];
6602
6606
  }
6603
- /** 一条会话↔设备绑定(server `boundDeviceOf`;冻结键集)。 */
6604
- export interface DeviceBinding {
6605
- deviceId: string;
6606
- /** 前态版本号 —— 换绑动词的 `expectedRev` 要回显的就是它(强制显式前态,两操作员并发换绑不互踩)。 */
6607
- rev: number;
6608
- /** ISO-8601。 */
6609
- boundAt: string;
6610
- }
6611
- /** `GET /v1/devices/sessions/:rootSessionId` 的 200 体(S-4 绑定读面 = 壳换绑 UX 的全部材料)。 */
6612
- export interface DeviceSessionBinding {
6613
- rootSessionId: string;
6614
- boundDevice: DeviceBinding;
6615
- }
6616
- /** `POST /v1/devices/sessions/:rootSessionId/rebind` 的请求体。⚠️ server 7.88.2 对这一口**不做键闭集**(六动词里唯一一个:
6607
+ /** `POST /v1/devices/sessions/:rootSessionId/rebind` 的请求体。⚠️ server 7.88.2 对这一口**不做键闭集**(管理面动词里唯一一个:
6617
6608
  * 多余键被静默丢弃,不像 enroll / revoke 那样 400 `request.body_shape` 点名)—— server 侧已立票补齐;本 SDK 不发多余键。 */
6618
6609
  export interface DeviceRebindRequest {
6619
6610
  toDeviceId: string;
6620
- /** 🔴 **必填** = 从 {@link DeviceBinding.rev} 读到的前态。强制显式前态,两个操作员并发换绑不互踩;
6611
+ /** 🔴 **必填** = 从 {@link import("./resources/sessions.js").ExecutionPlacementDevice.rev} 读到的前态(`sessions.executionPlacement(rootSessionId)` 的 `writer` 臂上的 `device.rev`;
6612
+ * server ≥7.139.0 起绑定读面 `GET /v1/devices/sessions/:id` 已删,旧体的 `boundDevice.rev` 即新体的 `device.rev`)。强制显式前态,两个操作员并发换绑不互踩;
6621
6613
  * 非负整数(否则 400 `request.field_invalid`)。`toDeviceId` **同**但 rev 错**仍然** 409。 */
6622
6614
  expectedRev: number;
6623
6615
  }