@sema-agent/sdk 30.1.0 → 32.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.
Files changed (72) hide show
  1. package/README.md +156 -0
  2. package/dist/errors.d.ts +59 -5
  3. package/dist/errors.d.ts.map +1 -1
  4. package/dist/errors.js +39 -3
  5. package/dist/errors.js.map +1 -1
  6. package/dist/events.d.ts +106 -26
  7. package/dist/events.d.ts.map +1 -1
  8. package/dist/events.js.map +1 -1
  9. package/dist/health.d.ts +14 -0
  10. package/dist/health.d.ts.map +1 -1
  11. package/dist/health.js.map +1 -1
  12. package/dist/idempotency.d.ts +2 -1
  13. package/dist/idempotency.d.ts.map +1 -1
  14. package/dist/idempotency.js +2 -1
  15. package/dist/idempotency.js.map +1 -1
  16. package/dist/index.d.ts +19 -6
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +10 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/resources/approvals.d.ts +7 -1
  21. package/dist/resources/approvals.d.ts.map +1 -1
  22. package/dist/resources/approvals.js +5 -0
  23. package/dist/resources/approvals.js.map +1 -1
  24. package/dist/resources/attachments.d.ts +7 -1
  25. package/dist/resources/attachments.d.ts.map +1 -1
  26. package/dist/resources/attachments.js +7 -1
  27. package/dist/resources/attachments.js.map +1 -1
  28. package/dist/resources/fleet.d.ts +59 -5
  29. package/dist/resources/fleet.d.ts.map +1 -1
  30. package/dist/resources/fleet.js +25 -0
  31. package/dist/resources/fleet.js.map +1 -1
  32. package/dist/resources/memory.d.ts +10 -3
  33. package/dist/resources/memory.d.ts.map +1 -1
  34. package/dist/resources/memory.js +10 -3
  35. package/dist/resources/memory.js.map +1 -1
  36. package/dist/resources/runs.d.ts +67 -2
  37. package/dist/resources/runs.d.ts.map +1 -1
  38. package/dist/resources/runs.js +35 -1
  39. package/dist/resources/runs.js.map +1 -1
  40. package/dist/resources/session-sync.d.ts +9 -0
  41. package/dist/resources/session-sync.d.ts.map +1 -1
  42. package/dist/resources/session-sync.js +9 -0
  43. package/dist/resources/session-sync.js.map +1 -1
  44. package/dist/resources/sessions.d.ts +32 -5
  45. package/dist/resources/sessions.d.ts.map +1 -1
  46. package/dist/resources/sessions.js +36 -4
  47. package/dist/resources/sessions.js.map +1 -1
  48. package/dist/resources/side-query.d.ts +20 -2
  49. package/dist/resources/side-query.d.ts.map +1 -1
  50. package/dist/resources/side-query.js.map +1 -1
  51. package/dist/resources/tasks.d.ts +13 -7
  52. package/dist/resources/tasks.d.ts.map +1 -1
  53. package/dist/resources/tasks.js +13 -7
  54. package/dist/resources/tasks.js.map +1 -1
  55. package/dist/resources/tool-approvals.d.ts +4 -3
  56. package/dist/resources/tool-approvals.d.ts.map +1 -1
  57. package/dist/resources/tool-approvals.js +4 -3
  58. package/dist/resources/tool-approvals.js.map +1 -1
  59. package/dist/settings.d.ts +44 -9
  60. package/dist/settings.d.ts.map +1 -1
  61. package/dist/settings.js +6 -1
  62. package/dist/settings.js.map +1 -1
  63. package/dist/sse.d.ts +11 -5
  64. package/dist/sse.d.ts.map +1 -1
  65. package/dist/sse.js +8 -3
  66. package/dist/sse.js.map +1 -1
  67. package/dist/types.d.ts +322 -91
  68. package/dist/types.d.ts.map +1 -1
  69. package/dist/types.js +7 -0
  70. package/dist/types.js.map +1 -1
  71. package/openapi.yaml +713 -107
  72. package/package.json +2 -2
package/dist/types.d.ts CHANGED
@@ -310,7 +310,12 @@ export interface TaskRequest {
310
310
  * verified principal,客户端只透传、零铸造权威。形状门在 server authorizer(不合形 ⇒ 422 typed
311
311
  * `invalid_project_id`)。多租户 DB 记忆面下它把派生 scope 从 user 盘切到项目盘(`proj:<tenant>/<projectId>`)
312
312
  * 并以该项目的 `defaultScopes` 作 memory.scopes 种子;单用户部署忽略派生、只有种子生效。随持久化 body
313
- * 骑到 resume 腿上(与 `memoryWrite` 同姿势)。 */
313
+ * 骑到 resume 腿上(与 `memoryWrite` 同姿势)。
314
+ * 🔴 **server ≥7.138.0(引擎 7.58.0)项目身份对账**:这条腿声明的项目(提交体的 `projectId`;不带则取这只会话上一条腿**声明过**的项目 —— 会话行上最后一帧 `workspace_changed` 的 `project.id`,只当 `project.source` 为 `declared`;
315
+ * 引擎从记号判出的项目不续声明)与检出里的 `.sema/project` 记号**必须是同一个**:不等 ⇒ 引擎在开跑前拒整条腿(一个 token 没烧)—— `config.project_identity_mismatch`;**没有记号时声明就是身份**。
316
+ * 记号读不出(内容坏 / 文件系统答不出)而这条腿要用项目身份 ⇒ `config.memory_project_marker`;记号嵌在仓根之下(v1 只认仓根上的一只)⇒ `config.memory_project_marker_nested`。三码都是 409(请求合法、检出状态与之冲突,见 {@link ConflictError}):
317
+ * 同步腿 HTTP 409,异步 / 活流腿 HTTP 2xx、同码落终态 run 行;出路 = 声明记号里的那个 id(提交体带它就胜过会话行)/ 改记号 / 换会话。
318
+ * `config.project_id_invalid`(400)是引擎对「声明的 id 不是 UUID」的拒 —— 本服务请求面铸不出(鉴权口先按同一条形状律答 422 `invalid_project_id`,会话行上的值是引擎自己铸的),这一码只对分诊面完备。 */
314
319
  projectId?: string;
315
320
  /** 🔴 Per-turn MODEL (CC /model picker parity). A configured catalog name, a tier word of the TARGET
316
321
  * deployment, or a model id — the server judges it against its tier-expanded catalog (case-sensitive exact key) and
@@ -448,7 +453,12 @@ export interface TaskRequest {
448
453
  userAttachments?: UserAttachment[];
449
454
  /** D-1(server ≥1.289):预上传附件句柄(`client.attachments.upload()` 的 id)。提交时绑定会话并在
450
455
  * 执行环境工作目录 `attachments/` 物化;objective 尾部追加文件清单告知(内容不进 durable 流)。
451
- * ≤16/task;未知/他人 id → 400。⚠️ 键名 attachmentIds——`attachments` 已被系统提醒配置键占用。 */
456
+ * ≤16/task;未知/他人 id → 400。⚠️ 键名 attachmentIds——`attachments` 已被系统提醒配置键占用。
457
+ * 🔴 **server ≥7.142.0 三只 409**(新提交;都落 {@link import("./errors.js").AttachmentRejectedError},机读位经 `err.extra`,{@link import("./errors.js").AttachmentBindRefusalExtra}):
458
+ * `attachment.bound_elsewhere`(`id`)—— 附件**一经绑定不改绑**:已绑在别的会话上(此前同属主下后绑会把它挪过来)⇒ 每个会话各上传一次;
459
+ * `attachment.bundle_lane_not_isolated`(`id` · `lane`)—— 项目包({@link import("./resources/attachments.js").PROJECT_BUNDLE_MIME})只绑进**隔离**车道的会话;
460
+ * `attachment.bundle_seed_fixed`(`id`)—— 一只会话一只种子:会话已有种子,或同一提交体带第二只项目包。体里任一只被拒 ⇒ 其余一只都不绑。续跑腿重放存量体时不 4xx(该 id 跳过)。
461
+ * 隔离车道上的附件(server ≥7.142.0)由恢复点放进工作区。 */
452
462
  attachmentIds?: string[];
453
463
  /** G3([816]③/[820]③,server ≥1.291):壳供 per-session scratchpad 路径(壳自己的约定路径,如 CC 形
454
464
  * `/tmp/claude-<uid>/<proj>/<sid>/scratchpad`)。接受后 server 让事实(envFacts.scratchpadDir)/写门豁免(exemptDirs)/
@@ -481,7 +491,10 @@ export interface TaskRequest {
481
491
  * · **没变的**:`cascade:true` 不带停驻 opt-in,撞限仍 `failed`,级上停在审批门上仍 `failed` + `unexpected.suspended` + `nestedPause`(见 {@link TaskResult.terminal} 的 failed 臂);验证器自己那一腿撞限仍失败。 */
482
492
  verify?: boolean;
483
493
  verifyRounds?: number;
484
- /** Quality-gate cascade (cheap→strong). Mutually exclusive with verify. Not on `stream`. */
494
+ /** Quality-gate cascade (cheap→strong). Mutually exclusive with verify. Not on `stream`.
495
+ * 🔴 server ≥7.142.0:结果上 `attempts[].diagnostics` 过结果脱敏器、每级的 `gateError` 与 `terminal.message` 同一只脱敏(凭据片段换 `«redacted…»`;键集 / 条数 / 序不变);
496
+ * 每级的失败码 `attempts[].errorCode` 与 `terminal.code` 同一只出口封口折:出了本服务码形的(驱动原生码、长得像凭据的串)读作 `internal.store_error`(原码只进运维线索)。
497
+ * 按 `attempts[].errorCode` 读驱动原生码的端改读同一读法。 */
485
498
  cascade?: boolean;
486
499
  /** §sandbox-image-select(P0.5):送**镜像 profile 意图**(≤128 chars),service 内部按 trusted
487
500
  * principal 用 `latestPublished(profile, viewer)` **fail-closed** 解析 digest + 再准入 → per-pod 起像(复用 select 同 visibility)。
@@ -1335,52 +1348,40 @@ export interface WorkspaceCacheCapability {
1335
1348
  */
1336
1349
  export type ParkedRunStatus = "suspended" | "needs_review";
1337
1350
  /**
1338
- * S-173(K-24;server ≥7.104.0)—— 同步提交撞 park 时叠在结果上的 **poll 回执三键**(修前 park 体的全部内容,值逐字不变;
1339
- * 与 server `http/sync-submit-body.ts` 的同名接口逐键同,测试对拍)。
1351
+ * **run 回执三键**(server 名 `SyncRunReceipt`,`http/sync-submit-body.ts`;与它逐键同,测试对拍)—— 手里**没有**引擎结果时同步体的全部内容:
1352
+ * 去 `GET /v1/runs/:taskId` 读行。{@link SyncReceiptBody} 是它在同步体上的那一臂(多一个可选的 `replay`)。
1340
1353
  */
1341
- export interface SyncParkReceipt {
1342
- /** 同步腿提交时铸的 durable run id —— `GET /v1/runs/:taskId` 的 poll 键(= 结果自带的 `taskId`)。 */
1354
+ export interface SyncRunReceipt {
1355
+ /** 同步腿提交时铸的 durable run id —— `GET /v1/runs/:taskId` 的 poll 键。 */
1343
1356
  taskId: string;
1344
- /** 提交的会话(= 结果自带的 `sessionId`)。 */
1357
+ /** 提交的会话。 */
1345
1358
  sessionId: string;
1359
+ /** 对外词 = `GET /v1/runs/:id` 行上的 `status`。 */
1360
+ status: RunStatus;
1361
+ }
1362
+ /**
1363
+ * S-173(K-24;server ≥7.104.0)—— 同步提交撞 park 时叠在结果上的 **poll 回执三键**(修前 park 体的全部内容,值逐字不变;
1364
+ * 与 server `http/sync-submit-body.ts` 的同名接口逐键同、同继承 {@link SyncRunReceipt},测试对拍):`status` 收窄到 park 两词。
1365
+ */
1366
+ export interface SyncParkReceipt extends SyncRunReceipt {
1346
1367
  /** 对外词 = `GET /v1/runs/:id` 行上的 `status`(park 两词之一)。 */
1347
1368
  status: ParkedRunStatus;
1348
1369
  }
1349
1370
  /**
1350
- * `POST /v1/tasks`(非流式)的 200 体(K-24;server 名 `SyncSubmitBody`,`http/sync-submit-body.ts` `buildSyncSubmitBody` 单点铸)。
1351
- *
1352
- * **一条规则**(server ≥7.104.0,契约 §5.0c):200 体**恒** = 结果本身(出口封口 + 脱敏后的引擎结果,即 {@link TaskResult});run
1353
- * **停在门上**(`terminal.kind === "paused"`)时再叠 {@link SyncParkReceipt} 三键 —— 所以在 7.104.0 上 `status` **只在 park 时在场**,
1354
- * 终局体不带它(不给终局造 `terminal.kind` 之外的第二真源)。同一次 park 在 `/v1/tasks/stream` 的 `done.result` 上除身份键外逐字相同;
1355
- * 恢复凭据从不在体上(`paused.token` 摘掉)。
1356
- *
1357
- * ⚠️ **三代同一个型,如实登记**(本包支持地板 7.52.0 ⇒ 下面三代都还在支持面内或经账本回放可达;与 {@link TaskResult.terminal} 同款:型面按现行代声明,老代的差别写在这里,
1358
- * 不把 `terminal` 做成可选去逼每个现行读点处理一个不存在的缺席分支):
1359
- * · **server ≤7.63**:平面形(见 {@link LegacyPlaneTaskResult})—— `status` 是**终局词**(`completed` / `failed` / `blocked` /
1360
- * park 两词),**没有** `terminal`,码在退役平面键(`r["errorCode"]` 经开集索引读);
1361
- * · **7.64–7.103**:终局体 = 现行 `terminal` 形、无 `status`;**park 体只有**回执三键 `{ taskId, sessionId, status }`(`terminal` /
1362
- * `stats` 运行期缺席);
1363
- * · **≥7.104**:上面那条规则。
1364
- * ⇒ 所以 `status` 的词 = park 两词 ∪ ≤7.63 平面词(`LegacyPlaneTaskResult["status"]`,本包对那一代的既有声明,不另抄一份)。
1365
- * **三代通用读法**(测试 `server-7104-wire` ④bis 三代样例都编译得过、读得对):
1366
- * ```ts
1367
- * const r = await client.tasks.submit(req);
1368
- * if (r.status === "suspended" || r.status === "needs_review") pollLater(r.taskId); // 三代都在 park 时带回执词
1369
- * else if (r.terminal === undefined) legacyFlat(r.status, r["errorCode"]); // ≤7.63 平面形
1370
- * else render(r.terminal); // ≥7.64
1371
- * ```
1372
- * 🔴 判代用 `r.terminal === undefined`,**别用** `"terminal" in r`:`terminal` 在型上是必填,`in` 的假支会被收成 `never`
1373
- * (那一支里 `r.status` 编译不过)。
1371
+ * `POST /v1/tasks`(非流式)200 体的**引擎结果臂**(K-24;server 名 `SyncSubmitBody`,`http/sync-submit-body.ts` `buildSyncSubmitBody` 单点铸)。
1374
1372
  *
1375
- * 🔴 **20.0.0:`tasks.submit` 返回 {@link SyncSubmitOutcome}(本型 ∪ {@link RunReplayRecord})**。server ≥7.125.0 起,同一把 `Idempotency-Key` 已经建过一条 run 行
1376
- * (换了进程 / 副本 / 重启,或原请求已落定;SDK 自动键的断线重发正会撞上)时,200 **不是**上面任何一代的首答 —— 它是 `GET /v1/runs/:id` 的读面 + `replay: true`
1377
- * (`result` 是**嵌套**的 {@link TaskResult},**没有**顶层 `terminal` / `stats`,没有 `wiringManifest` / `notice`)。所以本型**只描述首答**(含上面三代),重放体是联合的另一臂;
1378
- * 判别位 `r.replay`:`true` ⇒ 重放体,缺席 ⇒ 本型。窄化之后,上面「三代通用读法」原样适用。
1379
- * 同进程里同键的**并发**请求被合流到的那一份不是重放:与首答逐字节同体、没有 `replay` 键。
1373
+ * 体 = 结果本身(出口封口 + 脱敏后的引擎结果,即 {@link TaskResult});run **停在门上**(`terminal.kind === "paused"`)时再叠 {@link SyncParkReceipt} 三键(server ≥7.104.0,契约 §5.0c)——
1374
+ * 所以 `status` **只在 park 时在场**、只取 park 两词,终局体不带它(不给终局造 `terminal.kind` 之外的第二真源)。同一次 park 在 `/v1/tasks/stream` 的
1375
+ * `done.result` 上除身份键外逐字相同;恢复凭据从不在体上(`paused.token` 摘掉)。server ≥7.142.0 起,同键重放一条**有结果**的行就是这只信封 + `replay: true`。
1376
+ *
1377
+ * 别的代不在本型上,在 {@link SyncSubmitOutcome} 的另两臂:server ≤7.63 答平面形 {@link LegacyPlaneTaskResult}(没有 `terminal`);7.64.0–7.103.x 的 park 只答
1378
+ * 回执三键({@link SyncReceiptBody},没有 `stats`)。判形读 {@link SyncSubmitOutcome} 的注。
1380
1379
  */
1381
1380
  export interface SyncSubmitResult extends TaskResult {
1382
- /** 回执词 / ≤7.63 平面词(见上):≥7.104 只在 park 时在场(park 两词);7.64–7.103 只在 park 体上;≤7.63 恒在(平面终局词)。 */
1383
- status?: ParkedRunStatus | LegacyPlaneTaskResult["status"];
1381
+ /** park 时的回执词(两词之一);终局体缺席。 */
1382
+ status?: ParkedRunStatus;
1383
+ /** server ≥7.125.0:只在同键重放体上在场,恒 `true`(从不发 `false`)。只说「这是重放」,不说形。 */
1384
+ replay?: true;
1384
1385
  }
1385
1386
  /**
1386
1387
  * `abortCause` 的闭集三词(server ≥7.112.0 / S-947;契约 §5.0d)—— **谁让这条 run 停下来**:server 发起的中止的机读成因。每个词有一个真站点:
@@ -1500,7 +1501,14 @@ export interface TaskResult {
1500
1501
  /** MF-25 — effective model id that ran the task(`done.result.model`,engine main.ts:1339 `model: config.model.id`)。
1501
1502
  * 成本/总览面板据此知"哪个模型跑的"。live 实测引擎真回传(@sema-agent/server 1.3.0+)。 */
1502
1503
  model?: string;
1503
- /** Present when the task was run behind the verify gate. */
1504
+ /** Present when the task was run behind the verify gate.
1505
+ * ⚠️ This type declares only `verdict` / `rounds` / `findings`. The engine's outcome can carry more on the wire
1506
+ * (`unverifiedReason`, and `verifierPause` when the verifier itself paused); they are not typed here yet.
1507
+ * From server 7.141.0 on, `verifierPause` never carries the verifier session's resume credential `checkpointToken`
1508
+ * outward (the exit seal strips it on every outward path, the same seal as the run's own pause token); a ≤7.140.x
1509
+ * server could still send it. Do not read, store or forward a `checkpointToken` found under `verification`.
1510
+ * 🔴 server ≥7.142.0:`findings` 的每一条与 `evidence` 过本服务的结果脱敏器(与 `result` 同一只)—— 认出的凭据片段换成 `«redacted…»` 记号,条数与顺序不变,判词 / 轮数逐字;
1511
+ * 升级前落盘的存量行在读面上同样脱。按条数与判词分支照旧,逐字比对 / 存档原文的要改按记号之外的文本比。 */
1504
1512
  verification?: {
1505
1513
  verdict: "PASS" | "FAIL" | "PARTIAL" | "unverified";
1506
1514
  rounds: number;
@@ -2568,37 +2576,30 @@ export interface RunRecord {
2568
2576
  /** 🔴 K-43(sdk 16.0.0 补型;**server ≥7.73.0 / S-230 P-45 起就在真 `GET /v1/runs/:id` 上**,契约 §5.5 (c),封闭 spec 一直没声明 —— K-41 同病)——
2569
2577
  * **此刻持有**这条 run 的副本(行的 `instance_id`:`createRun` 写、跨副本续跑的 `markResuming` **接管**),答的是「活腿现在在哪」,不是「谁建的行」。
2570
2578
  * server ≥7.73.0 上**恒在场**,**显式 `null`**(不是键缺席)= 没有副本持有;< 7.73.0 缺席。
2571
- * 🔴 契约:`heldBy` 变 `null` **或** run 进终态 = 这条 claim 已释放(两者任一);终态行上的 `heldBy` 读作「哪个副本跑完的」这一历史事实,不是「还占着」。
2572
- * ⚠️ 唯一例外是 **stale 折叠**:`running` 且超过 stale 窗的行,读面把 `status` 折成 `failed`(伴 `error: "run stalled (instance lost?)"`)—— 那是读面的判断,
2573
- * 盘上的行仍是 `running`、claim 要到 reaper 下一拍才释放,`heldBy` 照旧逐字给出那台**失联**副本的 id(排障时唯一有用的坐标)。
2574
- * 部署内的副本标识,**不是**用户可读的位置。 */
2579
+ * 🔴 **一个条件**(server ≥7.141.0):`heldBy === null` ⇔ 这条 run 的 claim 已释放,非空 ⇔ 此刻有副本持有。**终态行**(`completed` / `failed` / `blocked`,
2580
+ * 含 `errorCode` 为 `cancelled` / `run.stalled` / `run.orphaned` / `approval.expired` 的收割落盘)**恒 `null`**;`running` / `suspended` / `needs_review` 给持有副本的 id。
2581
+ * 同一个读面也是 `runs.getByIdempotencyKey` 与提交面同键重放体(`replay: true`)的形,同读。
2582
+ * ⚠️ 读面折叠那一形:久未心跳的 `running` 被读面折成 `failed`(`errorCode: "run.stalled"`)—— 盘上的行仍是 `running`、claim 仍被占着,
2583
+ * `heldBy` 照旧逐字给出那台**失联**副本的 id(排障时唯一有用的坐标);收割落盘之后 ⇒ `null`。
2584
+ * ≤7.140.x 的分界:那一代终态行上仍是跑过它的副本 id(契约写「变 `null` **或**进终态 = 已释放」两读法)—— 对老 server 判「已释放」仍要两者任一;
2585
+ * 「哪个副本跑完的」这一历史事实不在本键上(读部署日志 / 指标)。部署内的副本标识,**不是**用户可读的位置。 */
2575
2586
  heldBy?: string | null;
2576
2587
  /** 🔴 K-43(同上,server ≥7.73.0 / S-230 P-45 起恒在场,契约 §5.5 (c))—— **耐久取消旗**(跨副本;持有副本的心跳拍 poll 它)。
2577
2588
  * ⚠️ 它是**待生效**的取消:已经取消掉的 run 由 `status` + `errorCode:"cancelled"` 说(park 臂的取消**根本不经这面旗**,直接把行终局化);
2578
2589
  * 续跑认领会把旗清零(撞上 suspend 的取消不许在恢复之后再杀一遍)。⇒ **别**把 `cancelRequested` 翻回 `false` 读成「取消完成」—— 等终态 `status` + `errorCode:"cancelled"`。
2579
2590
  * `POST /v1/runs/:id/cancel` 的受理体带同一个键({@link CancelAck.cancelRequested},同一个谓词)。< 7.73.0 缺席。 */
2580
2591
  cancelRequested?: boolean;
2581
- /** 🔴 server ≥7.125.0(additive;契约 §0.7)—— **提交幂等重放体的判别位**:只在 `POST /v1/tasks` 的 200 重放体与 `POST /v1/tasks/stream` 的 `done.result` 重放体上在场(值恒 `true`,见 {@link RunReplayRecord}),
2582
- * `GET /v1/runs/:id` 与 `GET /v1/runs?idempotencyKey=` 上**缺席**(那是读面本身),从不发 `false`。按 `replay === true` 分流;结果读 `result`(嵌套的 {@link TaskResult})。 */
2583
- replay?: true;
2584
2592
  }
2585
2593
  /**
2586
- * **提交幂等的重放体**(server ≥7.125.0;契约 §0.7)= {@link RunRecord}(`GET /v1/runs/:id` 的读面,同一只投影口)+ `replay: true`。
2587
- *
2588
- * 同一把 `Idempotency-Key` 已经建过一条 run 行(换了进程 / 副本 / 重启,或原请求已落定)时,同步提交 `POST /v1/tasks` 不再「当新提交再跑一遍」、
2589
- * 也**不**回首答的形:200 回这一份体;`POST /v1/tasks/stream` 开流同首答(`x-task-id` 头 + `meta` 帧),终帧 `done { result: <同一份体>, replay: true }`。
2590
- *
2591
- * 🔴 **它不是 {@link TaskResult}**:首答是引擎结果(`terminal` / `stats` 在顶层,`result` 是字符串),重放时手里只有行 ⇒ 体是行读面:`result` 是**嵌套**的 {@link TaskResult}(或在 run 还没有结果时缺席),
2592
- * **没有**顶层 `terminal` / `stats`,也**没有** `wiringManifest`(起手接线回执是首帧的活捕获、不落行)与 `notice`。判别位 `replay === true`(两形不会同时匹配)。
2593
- * 在飞合流(同进程里同键的并发请求)到的那一份不是重放:与首答逐字节同体、**没有** `replay` 键。
2594
- *
2595
- * 流式腿的一个窄形:这条腿**已开流之后**才发现命中(建行那一刻撞上另一副本先落的行)时,已发出的 `x-task-id` 头 / `meta` 帧带的是本腿现铸、没建成的那枚 id —— 终帧重放体里的 `taskId` 才是命中的那条 run 的真 id,以终帧为准。
2596
- *
2597
- * 只有**建得出行**的提交才有行可放:要有 run 店,且 `POST /v1/tasks` / `/v1/tasks/stream` 带 `sessionId`(`POST /v1/runs` 恒建行);没有行的提交落定之后同键重试会再跑一遍。
2598
- * 重放体读不到(属主不符 / 键指向别的行)⇒ 409 `conflict.run_exists`({@link import("./errors.js").ConflictError},体里不回显那一行的任何标识)。
2594
+ * 同步体的 **run 回执臂**(手里没有引擎结果 ⇒ 体 = {@link SyncRunReceipt} 三键,去 `GET /v1/runs/:taskId` 读行)。三个生产者:
2595
+ * · 7.64.0–7.103.x 的 park(那一代 park 体只有这三键);
2596
+ * · server ≥7.142.0 的同键重放,行上还**没有**结果(还在跑;或失联 —— 失联行的 `status` 读作 `failed`),带 `replay: true`;
2597
+ * · server 7.125.0–7.141.x 的同键重放:那一代回的是行读面 + `replay: true` —— 三键的超集、没有 `stats`,落在本臂;读法同样是读三键、再去读行
2598
+ * (那一代的读面键这里不声明:本型只承诺三键,别的键在旧字节上可能在,要读就显式按开集读)。
2599
2599
  */
2600
- export interface RunReplayRecord extends RunRecord {
2601
- replay: true;
2600
+ export interface SyncReceiptBody extends SyncRunReceipt {
2601
+ /** server ≥7.125.0:只在同键重放体上在场,恒 `true`。 */
2602
+ replay?: true;
2602
2603
  }
2603
2604
  /**
2604
2605
  * **提交在 SSE 已开流之后被拒**时的 `done.result`(`POST /v1/tasks/stream`)—— 状态行已经发出,拒绝只能编码成终帧的三键 `{ status: "failed", errorCode, errorMessage }`
@@ -2615,37 +2616,44 @@ export interface SubmitRefusalDoneResult {
2615
2616
  errorCode: string;
2616
2617
  errorMessage: string;
2617
2618
  }
2618
- /** 判别位 `replay` 的「非重放」一半:联合里每一条非重放臂都带它,于是 `r.replay === true` 能把联合窄到 {@link RunReplayRecord}(各臂接口本身不声明 `replay`——它们镜像 wire 键,wire 上这些形没有这个键)。 */
2619
+ /** 两只拒绝臂在 wire 上没有 `replay` 键;联合里给它们补上「`replay` 读得出、恒缺席」,于是 `r.replay` 在每一臂上都读得出
2620
+ * (各臂接口本身不声明 `replay`——它们镜像 wire 键)。 */
2619
2621
  type NotReplay = {
2620
2622
  replay?: undefined;
2621
2623
  };
2624
+ /** 平面形({@link LegacyPlaneTaskResult})在同步体上可带的重放标:server ≥7.142.0 同键重放一条**行上存的是平面形结果**的 run(≤7.63 写下的行;
2625
+ * 读盘面原样交回,不改形)⇒ 体 = 那份平面形 + `replay: true`。接口本身不声明 `replay`(它也是 `RunRecord.result` 的读盘形),只在同步体联合里补上。 */
2626
+ type LegacyReplayMark = {
2627
+ replay?: true;
2628
+ };
2622
2629
  /**
2623
- * `POST /v1/tasks`(同步腿)200 体的**可判别联合**(20.0.0;server ≥7.125.0 起重放体可达):
2624
- * · 首答 {@link SyncSubmitResult} —— 引擎结果(`terminal` / `stats` 在顶层);**没有** `replay` 键;
2625
- * · 幂等重放 {@link RunReplayRecord} —— 同键已建过 run 行时的读面 + `replay: true`(结果在嵌套的 `result`,**没有**顶层 `terminal` / `stats`)。
2626
- * 判别位 = `r.replay`:`true` ⇒ 重放体,`undefined` ⇒ 首答。先分流再读引擎字段:
2630
+ * `POST /v1/tasks`(同步腿)200 体的**可判别联合**(32.0.0)—— **一条规则**(server ≥7.142.0):**手里有没有引擎结果**。
2631
+ * · 有(`"stats" in r`)⇒ 引擎结果:{@link SyncSubmitResult}(停在门上再叠回执三键;`"terminal" in r` 不成立 ⇒ server ≤7.63 的平面形 {@link LegacyPlaneTaskResult});
2632
+ * · 没有 ⇒ run 回执三键 {@link SyncReceiptBody}:去 `GET /v1/runs/:taskId` 读行。
2633
+ * 同键重放(server ≥7.125.0)= 首答的信封 + `replay: true`(server ≥7.142.0;行上有结果 ⇒ 引擎结果 —— 行上存的是 ≤7.63 的平面形就是平面形,没有 ⇒ 回执三键)。`replay: true` 只说「这是同键重放」,不说形。
2634
+ * server 7.125.0–7.141.x 的重放体是行读面 + `replay: true`:没有 `stats`,落回执臂 —— 读三键、再读行,正是它该有的读法。
2627
2635
  * ```ts
2628
2636
  * const r = await client.tasks.submit(req);
2629
- * if (r.replay === true) readRow(r.status, r.result); // 行读面:状态 / 嵌套结果 / errorCode …
2630
- * else render(r.terminal); // 首答:引擎结果
2637
+ * if (!("stats" in r)) pollLater(r.taskId, r.status); // run 回执:GET /v1/runs/:taskId
2638
+ * else if (!("terminal" in r)) legacyFlat(r.status); // ≤7.63 平面形
2639
+ * else render(r.terminal); // 引擎结果(park 时 r.status 是 park 词)
2631
2640
  * ```
2641
+ * 同进程里同键的**并发**请求被合流到的那一份不是重放:与首答逐字节同体、没有 `replay` 键。
2632
2642
  */
2633
- export type SyncSubmitOutcome = (SyncSubmitResult & NotReplay) | RunReplayRecord;
2643
+ export type SyncSubmitOutcome = SyncSubmitResult | (LegacyPlaneTaskResult & LegacyReplayMark) | SyncReceiptBody;
2634
2644
  /**
2635
- * 流式提交(`POST /v1/tasks/stream`)终帧 `done.result` 的**可判别联合**(20.0.0;`AgentEvent` 的 `done` 臂读它)——spec `Event_done.result` 的 `oneOf` 同表:
2636
- * · {@link TaskResult} —— 正常终态(引擎结果);
2637
- * · {@link ActiveRunConflictDoneResult} —— 会话已有活跃 run 的拒绝信封(`conflict.session_active_run`,必带 `activeTaskId`);
2638
- * · {@link LegacyPlaneTaskResult} —— 只在 durable 账本回放腿上、跨 7.64.0 升级过的部署:升级前落盘的旧平面形;
2639
- * · {@link RunReplayRecord} —— server ≥7.125.0 同键重放(该 run 已落行):读面 + `replay: true`;
2645
+ * 流式提交(`POST /v1/tasks/stream`)终帧 `done.result` 的**可判别联合**(`AgentEvent` 的 `done` 臂读它)—— spec `Event_done.result` 的 `oneOf` 同表:
2646
+ * · {@link SyncSubmitOutcome} —— 一条 run 的结果,与同步体同三臂(durable 账本回放腿上、跨 7.64.0 升级过的部署可能读到平面形);
2647
+ * · {@link ActiveRunConflictDoneResult} —— 会话已有活跃 run 的拒绝信封(`conflict.session_active_run`,必带 `activeTaskId`);
2640
2648
  * · {@link SubmitRefusalDoneResult} —— 开流后才被拒的 `{status:"failed", errorCode, errorMessage}`。
2641
- * **窄化顺序**(五臂靠不同的键分家):`r.replay === true` ⇒ 重放体;`"stats" in r` ⇒ 引擎结果(再按 `"terminal" in r` 分现行因由形与旧平面形);`"activeTaskId" in r` ⇒ 会话占用冲突;其余 ⇒ 拒绝三键。
2642
- * ⚠️ 帧上的 `replay: true` 与 `result.replay` 不是一回事:同进程在飞合流到的那一份,帧上也带 `replay: true`,但 `result` 是首答 {@link TaskResult} 逐字(无 `result.replay`)。
2649
+ * **窄化顺序**(按键分家,server ≥7.142.0 起同键重放也是首答的信封):`"stats" in r` ⇒ 引擎结果(再按 `"terminal" in r` 分现行因由形与平面形);`"activeTaskId" in r` ⇒ 会话占用冲突;
2650
+ * `"taskId" in r` ⇒ run 回执(去读行);其余 ⇒ 拒绝三键。帧上的 `replay: true` 与 `result.replay` 都只说「这是重放」,不说形。
2643
2651
  * 🔴 **在飞合流的拒绝(server ≥7.125.0 起与首发同形)**:同进程在飞合流的跟随方,若**首请求被拒**(会话占用 409 / `conflict.run_exists` / device 放置拒 / 同步腿零工作拒),`done.result` 与首发那一帧是**同一只投影**
2644
- * (会话占用 ⇒ 冲突臂,其余 ⇒ 拒绝三键),帧上带 `replay: true`、`result` 上没有 —— 都在上面五臂里,按 `errorCode` 判、`errorMessage` 读句子即可。
2645
- * **≤7.124.x** 的跟随方拿到的是首请求的 **JSON 拒绝体原样**(键是 `error` / `errorCode` / …,**没有** `status` / `errorMessage`),不在五臂的形里:带 `activeTaskId` 的会落进冲突臂的窄化却读不到 `errorMessage`。
2652
+ * (会话占用 ⇒ 冲突臂,其余 ⇒ 拒绝三键),帧上带 `replay: true`、`result` 上没有 —— 按 `errorCode` 判、`errorMessage` 读句子即可。
2653
+ * **≤7.124.x** 的跟随方拿到的是首请求的 **JSON 拒绝体原样**(键是 `error` / `errorCode` / …,**没有** `status` / `errorMessage`),不在这些臂的形里:带 `activeTaskId` 的会落进冲突臂的窄化却读不到 `errorMessage`。
2646
2654
  * 老 server 的读法:拒绝类终帧一律先按 `errorCode` 判,`errorMessage` 缺席时回落读 `error` —— 这条回落分支只为 ≤7.124.x,支持底线抬过 7.124.x 之后可删。
2647
2655
  */
2648
- export type DoneFrameResult = (TaskResult & NotReplay) | (ActiveRunConflictDoneResult & NotReplay) | (LegacyPlaneTaskResult & NotReplay) | RunReplayRecord | (SubmitRefusalDoneResult & NotReplay);
2656
+ export type DoneFrameResult = SyncSubmitOutcome | (ActiveRunConflictDoneResult & NotReplay) | (SubmitRefusalDoneResult & NotReplay);
2649
2657
  /** Run list item (`GET /v1/tasks` items) — the live cheap `runSummary` shape (service Drift 1).
2650
2658
  * NOTE wire names: `id` (not taskId), `startedAt` (not createdAt), `costMicroUsd` (micro-USD); no sessionId. */
2651
2659
  export interface TaskSummary {
@@ -3000,6 +3008,28 @@ export type ExtensionRequester = {
3000
3008
  kind: "extension";
3001
3009
  name: string;
3002
3010
  };
3011
+ /**
3012
+ * 一次工具调用的参数被**谁换掉**(`tool_end.rewrite.by` 的一项;core `RewriteAuthor`,server ≥7.138.0 上 wire):
3013
+ * · `{ kind: "extension", name }` —— 这条腿的一张扩展注册(与 {@link ExtensionRequester} **同一个形**:`name` 是注册方的串,UNTRUSTED-for-display);
3014
+ * · `{ kind: "policy" }` —— 限制链的答;
3015
+ * · `{ kind: "approver" }` —— 审批人带改动作答(是谁读 `gate.settlement.who`)。
3016
+ * **闭集三词,带 `default` 臂**(引擎加一类改写者 = 引擎下一版 + 本型同批加员;server 对出了这三形的记录**整只丢** `rewrite`,所以读到的每一项都在这三形里)。
3017
+ */
3018
+ export type RewriteAuthor = ExtensionRequester | {
3019
+ kind: "policy";
3020
+ } | {
3021
+ kind: "approver";
3022
+ };
3023
+ /**
3024
+ * `tool_end.rewrite`(core `ToolInputRewrite`;server ≥7.138.0):门放行时交给工具体的参数、以及谁换的。
3025
+ * · `by` —— **非空**列表,每次改动一项,按**发生序**(一个判官改了两次就点名两次);
3026
+ * · `input` —— 门放行的那份参数(引擎的纯数据冻结投影:不是纯数据的成员读作 `[not recorded: …]` 记号),与 `tool_start.args` 同一只脱敏。
3027
+ * 在场律与缺席成因见 {@link import("./events.js").AgentEvent} `tool_end` 臂的 `rewrite` 注。
3028
+ */
3029
+ export interface ToolInputRewrite {
3030
+ by: RewriteAuthor[];
3031
+ input: unknown;
3032
+ }
3003
3033
  /**
3004
3034
  * 一只问**属于哪一类**(core `ASK_CLASSES`:7.34.0 铸二十词,core 7.39.0 起 `shell_floor` 入册 ⇒ 二十一词,core 7.40.0 起 `unstated` 入册 ⇒ 二十二词,core 7.41.0 起 `requires_user_interaction` 入册 ⇒ 二十三词,core 7.43.0 起 `classifier_no_ruling` 入册 ⇒ 二十四词,core 7.45.0 起 `dangerous_delete` 入册 ⇒ 二十五词,core 7.49.0 起 `unverifiable_shell_text` 入册 ⇒ 二十六词(同版写目标落点读不出那一类改拼 `target_unresolved`,旧拼法见 README 22.0.0 迁移表),**core 7.51.0 / server ≥7.129.0 起 `governance_unavailable` 并入 `rule_unreadable` ⇒ 二十五词**(23.0.0 BREAKING,零别名;7.128.x 停驻的卡 / 行由 server 起服一次性改写),**core 7.54.0 / server ≥7.134.0 起 `cross_boundary` 入册 ⇒ 二十六词**,**core 7.58.0 / server ≥7.138.0 起 `write_protection_on_disk` 入册 ⇒ 二十七词**(29.0.0;引擎序在 `probe` 之后、`write_protection` 之前);模式 × 类仲裁表的列)。K-32 扩项 / server ≥7.106.0 起出现在
3005
3035
  * {@link ModeRelease.askClass} / `.classes` 与 deny 臂的 `askClass` / `classes` 上,以及通告 `permission.ask_released_by_mode` 的 detail 里;
@@ -3229,6 +3259,10 @@ export type GateDisposition = {
3229
3259
  askClass?: GateRecordAskClass;
3230
3260
  /** 与 `mode` 同在:折叠出的整个类集合。 */
3231
3261
  classes?: GateRecordAskClass[];
3262
+ /** server ≥7.138.0(core 7.59.0 不变量 I12):**present-iff** `deniedBy` 是 `hook` 且拒的那只处理器的**扩展注册名**已知 —— 值就是那张注册的名(扩展的 `tool.check` / `classic.PreToolUse` / `tool.call` 答 deny,
3263
+ * 或它抛错 / 超预算 / 答在站点收不了的形 —— 引擎按失败关门),过注册方文本的出口纪律(UNTRUSTED-for-display)。**缺席**的三种成因:别的层拒(祖先腿的筛到后代腿读作 `policy`;继承来的安装的问所裁的拒也不是它)·
3264
+ * 放行(allowed 臂没有这个键)· `hook` 层拒而拒者无名(引擎自己的失败抛 / 取消)。显示与审计用:无论叫什么名,这次调用都被拒了。老 server 缺席 = 不可知。 */
3265
+ extension?: string;
3232
3266
  };
3233
3267
  /**
3234
3268
  * 一只 ask 在等的那次等待**怎么结束的** —— 按 `kind` 判别的联合(core 7.6.0 `SETTLEMENT_KINDS`,闭十二词)。
@@ -3321,12 +3355,13 @@ export type Settlement = {
3321
3355
  * **铸一次,投三面**(门的出口;耐久 park 走 decide 车道)—— `permissionDenied` 观察者的载荷、这次调用的
3322
3356
  * `tool_end` 帧、耐久行的 resolved outcome。三面是同一张对象图,所以讲不出三个故事。
3323
3357
  *
3324
- * 三个成员正交,但被引擎的四条不变量绑住:
3358
+ * 三个成员正交,但被引擎的不变量绑住(这里列读面要用的几条;全表见引擎的 `screenGateOutcome`):
3325
3359
  * · **I1** `settlement` 在场 ⇔ `origin` 在场(它们说的是同一只 ask);
3326
3360
  * · **I2** `deniedBy === "ask_resolution"` ⇒ `settlement` 在场且是拒绝类词;
3327
3361
  * · **I3** `human_allowed` 结算旁边出现 `denied` 处置 ⇒ 那是**人批了之后的复查**否决,`deniedBy` 必是可否决层
3328
3362
  * (`policy` / `hook` / `org` / `write_protection`),而 approver 留在结算上(这不是 approver 的拒);
3329
- * · **I4** `allowed` 处置 ⇒ `settlement` 缺席或恰是一只**决策者的放行词**(`human_allowed`,server ≥7.113.0 起还有 `policy_allowed`)。
3363
+ * · **I4** `allowed` 处置 ⇒ `settlement` 缺席或恰是一只**决策者的放行词**(`human_allowed`,server ≥7.113.0 起还有 `policy_allowed`);
3364
+ * · **I12**(server ≥7.138.0)denied 臂的 `extension` 在场 ⇒ `deniedBy` 是钩子层(`hook`)∧ 它是非空串;别的层词旁 / allowed 臂上带它是记录缺陷 —— 缺陷记录 server 整条不投。
3330
3365
  *
3331
3366
  * 🔴 **没有任何一项从缺席读出来**:普通放行是 `{ disposition: { kind: "allowed" } }`,直接策略拒是
3332
3367
  * `{ disposition: { kind: "denied", deniedBy: "policy" } }`,两者都不带结算 —— 因为两者都没结算过什么。
@@ -3423,7 +3458,23 @@ export type WiringManifestMcpEntry = {
3423
3458
  * 据缺席反推「拨没拨过号」会得出相反的结论。
3424
3459
  */
3425
3460
  liveness?: McpServerLiveness;
3461
+ /** server ≥7.138.0(core 7.59.0):**present-iff** `errorCode` 是 `"unauthorized"` —— 为什么要重新授权,见 {@link McpAuthorization}(只有闭集词 `reason`,地址不出门)。缺席 = 不是授权门,或老 server。 */
3462
+ authorization?: McpAuthorization;
3426
3463
  };
3464
+ /**
3465
+ * {@link McpAuthorization.reason} 的词(core 7.59.0 `MCP_AUTHORIZATION_REASONS`,**三词**;server ≥7.138.0):`rejected` = 端点答 401、授权座的重问也没给出能过的凭据 ·
3466
+ * `scope` = 403 带 `insufficient_scope` 挑战 · `none` = 授权座答「这位用户没有授权」。同 {@link McpFailureKind}:闭集声明、开集读(新引擎可能加词,带 `default` 臂)。
3467
+ */
3468
+ export type McpAuthorizationReason = "rejected" | "scope" | "none";
3469
+ /**
3470
+ * MCP 授权事实(core 7.59.0 `McpAuthorization`;server ≥7.138.0):**一只 MCP 服务器要用户先授权**才肯服务 —— 在 MCP 状态三面上与 `errorCode: "unauthorized"` 同行
3471
+ * (`wiring_manifest.mcp[]` 行〔{@link WiringManifestMcpEntry}〕、重拨回执的 `status`〔{@link McpReconnectServerStatus}〕、`GET /v1/sessions/:id/mcp` 面板的 `servers[]`〔{@link McpServerStatus};面板行不带 `errorCode`,在场律读作「这台服务器未授权」〕)。
3472
+ * 🔴 **只有闭集词 `reason`**:引擎记录里的两只地址(`authorizeUrl` / `resourceMetadataUrl`)**不出门**(前者只来自部署的授权座,本服务今天没有授权座;后者是远端在挑战头里自报的、不可信)——
3473
+ * 用户面的「去授权」由会话通告 `mcp.authorization_required`({@link import("./events.js").McpAuthorizationRequiredDetail})承载。server 对词出闭集 / 非对象的记录**整格缺席**(最弱断言,不铸词)。
3474
+ */
3475
+ export interface McpAuthorization {
3476
+ reason: McpAuthorizationReason | (string & {});
3477
+ }
3427
3478
  /**
3428
3479
  * 一台 MCP 服务器的**一次**活性观察(core 7.24.3 #874 `McpServerLiveness` 镜像;server ≥7.91.2)。
3429
3480
  * 它说的是引擎**最后学到**了什么、**什么时候**学到的 —— 从不是「现在是不是真的」,也**不是心跳**
@@ -4084,6 +4135,13 @@ export interface SkillSpec {
4084
4135
  * 而 `allowedTools` 里同一条目 server ≥7.123.0 起受理 + 通告 —— 同一条理由:读成空的 deny 条目看着像拒、其实什么也不拒,读成空的 allow 条目只是不放行、有通告可看。 */
4085
4136
  disallowedTools?: string[];
4086
4137
  }
4138
+ /**
4139
+ * 本包认识的 MCP 传输种类 —— 请求面 {@link McpServerSpec.transport} 的两个判别词(`stdio` / `http`),也是 server ≥7.141.0 能力位 {@link Capabilities.mcpTransportKinds} 的已知词。
4140
+ * 测试两向锚:== `McpServerSpec["transport"]["kind"]`(编译期)· == server 自铸登记 `mcpTransportKind`(发布字节)。
4141
+ */
4142
+ export declare const MCP_TRANSPORT_KINDS: readonly ["stdio", "http"];
4143
+ /** {@link MCP_TRANSPORT_KINDS} 的成员型。 */
4144
+ export type McpTransportKind = (typeof MCP_TRANSPORT_KINDS)[number];
4087
4145
  /** A per-request MCP server (CC `.mcp.json` parity) — core-native `McpServerSpec` shape (core types.ts:277).
4088
4146
  * `stdio` = a local command the worker spawns (single-user only); `http` = a remote streamable-HTTP server. */
4089
4147
  export interface McpServerSpec {
@@ -4150,6 +4208,13 @@ export interface McpServerSpec {
4150
4208
  * `400 request.field_invalid`(原因句是引擎的);server 7.132.0–7.133.x 照常受理、引擎在拨号时**只拒这一台**(`config.mcp_startup_timeout_invalid`,兄弟照挂)。
4151
4209
  * 老 server(≤7.131.x)对它答 `400 request.body_shape`(`unknownKeys` 点名)。 */
4152
4210
  startupTimeoutMs?: number;
4211
+ /** server ≥7.138.0(受理键;core `McpServerSpec.sessionMetaKey`):声明了它的服务器,引擎在发给它的**每一个 `tools/call` 与 `resources/read`** 的 `_meta[<这个键>]` 里放**这条腿自己的会话 id**(stdio 与 Streamable HTTP 同样),
4212
+ * 让连接器按 (principal, session) 存状态。缺席 ⇒ 什么都不发(会话 id 出进程是一次关联,由部署选择)。**委派子代是另一个会话**:它的调用带它自己的 id,引擎不替你猜根;principal 也不是树键。没有会话的拨号(库入口、无 run 的探测)不带。
4213
+ * 键判官只有引擎一只(`judgeSessionMetaKey`):非空串、≤128 个字符、合 MCP `_meta` 的键名格式(可选的「点分标签 + `/`」前缀 + 名字),且不撞别人的 `_meta` 成员 —— 不是 SDK 自己的 `progressToken`、不在引擎的 `sema/` 命名空间下、
4214
+ * 不在 MCP 保留的前缀下(前缀 = 第一个 `/` 之前的文本,标签是 DNS 标签,第二个标签大小写折叠后比)。坏形 ⇒ 新提交(`POST /v1/tasks*` · `/v1/runs`)与探测口(`probeMcp`)一律 `400 request.field_invalid`,点名 `mcpServers[i].sessionMetaKey`;
4215
+ * 🔴 **server ≥7.139.0 的拒句不回显你写的键**(句子要说到它时写成 `[redacted] (N characters)`,N = 码位数;超长 / 空串 / 非串的拒因只说长度或类型、根本不提键)—— 按码与点名的键路径读,别匹配句子。部署腿(中心下发 / `config.d`)从 server ≥7.139.0 起也承运这把键(此前读配置时被剥并报未知键),同一只判官,坏形整条 server 不挂。
4216
+ * 老 server(<7.138.0)的受理键表里没有它 ⇒ 当词表外的键答 `400 request.body_shape`(`unknownKeys` 点名;按键律推,未对老字节实测)。 */
4217
+ sessionMetaKey?: string;
4153
4218
  }
4154
4219
  /**
4155
4220
  * 一条 **A2A peer**(`TaskRequest.a2aPeers[]` 的一行)—— 本 SDK 镜像的是 server **真受理**的那一面:
@@ -4529,7 +4594,9 @@ export interface Capabilities extends EngineCapabilityBits {
4529
4594
  usage?: boolean;
4530
4595
  /** /v1/policy 面(`routes/capabilities.ts` 的能力对象 硬编码 true)。 */
4531
4596
  policy?: boolean;
4532
- /** 会话内改 permission mode 的写面 —— server 1.214 恒 false(`routes/capabilities.ts` 的能力对象,未上线;mode 走 TaskRequest.permissionMode)。 */
4597
+ /** server ≥7.141.0 · 在飞 run 切权限档的写口 `POST /v1/runs/:id/permission-mode`(`runs.setPermissionMode`,{@link import("./resources/runs.js").RunsResource.setPermissionMode})这台部署接没接上 —— **设施依赖**:
4598
+ * 耐久 run 店(`DB_BACKEND=mysql|pg|local`)∧ checkpoint 店(`DURABLE_APPROVAL`)都在 ⇒ `true`;缺一个 ⇒ `false`,写口答 501(`capability.run_store_required` / `capability.checkpoint_store_required`,按缺的那一个)。
4599
+ * ≤7.140.x 这一位不挂设施、总是 `false`(那一代没有写口;档只能随提交体 {@link TaskRequest.permissionMode} 定)。缺席 = 更老的 server。 */
4533
4600
  permissionModeWrite?: boolean;
4534
4601
  /** per-turn `model` 字段可用(`routes/capabilities.ts` 的能力对象 硬编码 true;TaskRequest.model → CC /model parity)。 */
4535
4602
  modelSelection?: boolean;
@@ -4597,6 +4664,10 @@ export interface Capabilities extends EngineCapabilityBits {
4597
4664
  /** server ≥7.133.0:请求 `settings.hooks[]` 的**组来源**键 `source`(托管 / 非托管车道:`managedPolicy` / `managedPlugin:<name>` 跑在独立托管车道)这台部署受不受理——与 {@link hooks} 同一谓词。
4598
4665
  * 见位才给组标 `source`;位缺席 / `false` = 静默剥掉(托管车道语义不生效,不是拒)。 */
4599
4666
  managedHookGroups?: boolean;
4667
+ /** server ≥7.142.0:请求 {@link import("./settings.js").SemaSettings.allowedHttpHookUrls} / {@link import("./settings.js").SemaSettings.httpHookAllowedEnvVars}(契约包 http hook 两张名单)这台部署读不读、
4668
+ * 在 http 条目**拨出之前**执行不执行 —— 与 {@link hooks} **同一谓词**(单用户真;多租户 `settings.hooks` 整只被忽略 ⇒ 假)。
4669
+ * **见位才发**:位缺席 = 老 server(≤7.141.x),两键是集外键 ⇒ 新提交答 `400 request.body_shape`。 */
4670
+ httpHookAllowlists?: boolean;
4600
4671
  /** server ≥7.133.0:**只收紧座位表**恒受理——请求 `settings.readDenyPatterns` / `settings.writeProtectedExtra` / `settings.complianceAdditionalDenies` / `settings.permissions.neverAuto` 四键
4601
4672
  * (见 {@link SemaSettings} 对应成员):每座 = 部署表 ∪ 请求列表,**只增不减**,空数组 ≡ 没送。恒 `true`;**位缺席 = 老 server —— 对这四键答 400 `request.body_shape`,见位才发**。 */
4602
4673
  tightenOnlySeats?: boolean;
@@ -4606,7 +4677,8 @@ export interface Capabilities extends EngineCapabilityBits {
4606
4677
  approvalFrameFamilies?: boolean;
4607
4678
  [k: string]: unknown;
4608
4679
  };
4609
- /** 🔴 **server ≥7.115.0 起恒在**:`{ permissions: { allowGrant: true } }`;**≥7.117.0 起 `permissions` 多一位 `allowLayer: true`** —— 「请求体 `settings.permissions.allow` 按**哪一种读法**收」的**版本位**(wire additive;两位都是恒真、
4680
+ /** 🔴 **server ≥7.115.0 起恒在**:`{ permissions: { allowGrant: true } }`;**≥7.117.0 起 `permissions` 多一位 `allowLayer: true`**;**≥7.141.0 再多一位 `layers: true`**(`deny` / `ask` 的带层条目,见 `layers` 成员)——
4681
+ * 前两位是「请求体 `settings.permissions.allow` 按**哪一种读法**收」的**版本位**(wire additive;三位都是恒真、
4610
4682
  * 不随部署形变:单用户与 `REQUIRE_PRINCIPAL=true` 两形同值,不挂任何设施)。逐位读,三段读 `settings` → `permissions` → <位>:
4611
4683
  * · `allowGrant === true`(≥7.115.0)= 两代都成立的那句话:**allow 桶按 allow 规则读,不是名单**(名单外的工具不再被拒);键缺席 = 老 server(≤7.114.x,按名单读)—— **别投 allow 桶**(投了只是一份收窄,方向安全,但不是你要的)。
4612
4684
  * · `allowLayer === true`(**≥7.117.0**,core 7.42.0)= 这台 server 把 `allow` **整份原样**交给引擎的 **allow 层**:表里的调用**免问** —— 清「普通问 + 没人表态」两类(内置工具的写门 / shell 普通问也清,与参照实现的 `permissions.allow` 同读);
@@ -4622,6 +4694,10 @@ export interface Capabilities extends EngineCapabilityBits {
4622
4694
  permissions?: {
4623
4695
  allowGrant?: boolean;
4624
4696
  allowLayer?: boolean;
4697
+ /** server ≥7.141.0 · **恒真的版本位**:请求 `settings.permissions.deny` / `ask` 受理带出处层的条目 `{ rule, layer }`({@link import("./settings.js").LayeredPermissionRule};
4698
+ * 层的读法见 {@link import("./settings.js").SettingsPermissions.deny})。不随部署形变(单用户与多租户两形同值)。
4699
+ * **见位才发**:位缺席 = 老 server —— 带层条目新提交 400、续跑 409(响亮拒,不静默读丢),只发纯串。 */
4700
+ layers?: boolean;
4625
4701
  /** server ≥7.133.0:**这位调用方**的信任档(按调用方、按凭据读,**不是**版本位)—— 请求里「不经人答就生效」的规则表(`settings.permissions` 各桶、被按名点用的自带技能的 `allowedTools` / `disallowedTools`)按它准入:
4626
4702
  * `allow` 放宽免问面,要 `global`;`deny` / `ask` 只收紧,任何档都收。取值:`global`(单用户 turnkey;多租户持部署 service 凭据;多租户登录令牌的 scope 角色 ≥ 治理域写角色)/ `project`
4627
4703
  * (其余:低角色 / 无角色令牌 / 直连门 principal 令牌 / 没验过的凭据)。**开集读**:词表属主在契约包(`MinTrust`),不认识的词按 `project` 处置(fail-closed)。
@@ -4698,6 +4774,14 @@ export interface Capabilities extends EngineCapabilityBits {
4698
4774
  * **位缺席 ≈ `false`**(老 server 同样不发送),与 `false` 同处置 —— 别靠这个键里的头去做对端鉴权。
4699
4775
  */
4700
4776
  mcpAssertionHeaderSent?: boolean;
4777
+ /**
4778
+ * server ≥7.141.0 · 请求面读器与引擎今天能拨的 **MCP 传输种类**(串数组,书写序;今天恒 `["stdio", "http"]`,每种部署形都在场、不随部署形变)。
4779
+ * 只回答「语法 / 实现支持哪些种类」:本部署收不收调用方自带的 `mcpServers` 仍读 {@link mcpInjection};「端到端可达」没有位承诺。
4780
+ * 用法:拼 `mcpServers` 之前按它筛 —— 目标传输不在位里的条目只丢那一台、其余照投(提交面没有放宽:不在位里的 `transport.kind` 新提交与探测口照旧整次 400)。
4781
+ * **开集读**:不认识的词按「本包不支持该种类」处理,不让整份能力解析失败(位会随新种类长词);本包认识的词见 {@link MCP_TRANSPORT_KINDS}。
4782
+ * 位缺席 = 老 server:7.135.0–7.140.x 读作 `["stdio", "http"]`;更老的 server 以它自己的受理面为准。
4783
+ */
4784
+ mcpTransportKinds?: Array<McpTransportKind | (string & {})>;
4701
4785
  /** §E23 inbound-MCP elicitation HITL(`routes/capabilities.ts` 的能力对象 `Boolean(elicitation)` = MCP_ELICITATION_ENABLED)。 */
4702
4786
  mcpElicitation?: boolean;
4703
4787
  /** §4④ live AskUserQuestion HITL(`routes/capabilities.ts` 的能力对象 `Boolean(question)` = ASK_QUESTION_ENABLED)。 */
@@ -4853,8 +4937,8 @@ export interface Capabilities extends EngineCapabilityBits {
4853
4937
  * ⚠️ 与上面三位**不同轴**:那三位是**设备侧**接入面(executor 连 WS 要知道的);本位是**壳/管理侧**
4854
4938
  * (谁能列设备、换绑、签发、注册、吊销)。一位为真不蕴含另一位为真。 */
4855
4939
  management?: boolean;
4856
- /** server ≥7.137.0 · **present-iff 运维声明了 `DEVICE_RELAY_URL`**:设备的直达入口 —— 绝对 ws(s) URL(无 userinfo / query / fragment),逐字。🔴 **设备拨号方**:在场就拨它、不再自己拼「引擎地址 + `wsPath`」;
4857
- * 缺席照旧拼(老 server / 运维没声明)。 */
4940
+ /** server ≥7.137.0 · **present-iff 运维把 `DEVICE_RELAY_URL` 声明成 ws(s) URL**:设备的直达入口 —— 绝对 ws(s) URL(无 userinfo / query / fragment),逐字。🔴 **设备拨号方**:在场就拨它、不再自己拼「引擎地址 + `wsPath`」;
4941
+ * 缺席照旧拼。server ≥7.141.0 的 device 车道上这根 env 必填(ws(s) URL 或字面 `none`;`none` = 没有中继 ⇒ 本键缺席);≤7.140.x 上缺席也可能是运维没写;更老的 server 没有本键。 */
4858
4942
  relayUrl?: string;
4859
4943
  [k: string]: unknown;
4860
4944
  };
@@ -4874,9 +4958,11 @@ export interface Capabilities extends EngineCapabilityBits {
4874
4958
  * 🔴 与 {@link memory} / {@link memoryWrite} **不是**一回事:那两位说的是**退役的** MemoryStore HTTP
4875
4959
  * 动词(恒假,且会一直恒假);本位说的是**引擎接线**,它没有 HTTP 动词面 —— 记忆是模型在注入目录上的
4876
4960
  * 文件技能。所以本位为真**不**意味着有记忆读写端点可打(那正是 legacy 两位在否认的东西)。
4877
- * 🔴 `vectorMode: null` = 这条腿**没有档位指示面**(`file` 引擎),**不是**「档位是词面」。 */
4961
+ * 🔴 `vectorMode: null` = 这条腿**没有档位指示面**(`file` 引擎),**不是**「档位是词面」。
4962
+ * 🔴 `backend` 的已知词 = 契约包 `MEMORY_ENGINE_BACKENDS`(`file` / `pg` / `mysql`):server ≥7.141.0 在 MySQL 族部署上答 `mysql`(与 `DB_BACKEND=mysql` 同字),
4963
+ * ≤7.140.x 同一部署答 `tidb`(旧词零别名退役:本型不再列它,老 server 送来的 `tidb` 走开集尾、按未知词处置)。 */
4878
4964
  memoryEngine?: false | {
4879
- backend: "file" | "pg" | "tidb" | (string & {});
4965
+ backend: "file" | "pg" | "mysql" | (string & {});
4880
4966
  vectorMode: "native" | "portable" | "lexical" | null;
4881
4967
  [k: string]: unknown;
4882
4968
  };
@@ -4952,6 +5038,18 @@ export interface Capabilities extends EngineCapabilityBits {
4952
5038
  * ⇒ 四口 501 `capability.memory_optout_grant_required`)。
4953
5039
  * 🔴 位为假时是 **501**(换部署形态),与 {@link memoryConsolidationDriver} 的 404(开旋钮)分家。 */
4954
5040
  memoryOptOutGrant?: boolean;
5041
+ /** 🔴 server ≥7.142.0:会话记忆同步触发口 `POST /v1/sessions/:id/memory/sync`({@link import("./resources/sessions.js").SessionsResource.syncMemory},`sessions.syncMemory`)这台部署有没有 ——
5042
+ * 要三件同时在:本机同步腿(file 记忆引擎 + `MEMORY_SYNC_URL`)、持久 run 店、会话归属面。位为 `false` 时口答 501(缺哪件答哪只码:`feature.memory_sync_disabled` /
5043
+ * `capability.run_store_required` / `capability.session_ownership_required`)。**见位才调**;位缺席 = 老 server(口不存在)。 */
5044
+ sessionMemorySync?: boolean;
5045
+ /** 🔴 server ≥7.142.0:**记忆同步中心**的身份位 —— `{ identity }` ⇔ 这台是 DB 记忆平面(`MEMORY_ENGINE_BACKEND=pg|mysql`)的中心、有同步执行位、且运维声明了同步身份 `MEMORY_SYNC_SERVE_IDENTITY`;
5046
+ * 否则 `false`(不是中心,或没声明身份 —— 后者的同步口答 501 `feature.memory_sync_serve_disabled`)。复合位(server 复合成员表 `memorySyncServe: ["identity"]`),没有 `true` 这个值。
5047
+ * `identity` = 客户端到达本中心同步口用的基址的**规范形**(小写协议与主机、无缺省端口、无尾斜杠、无查询 / 片段 / 凭据),逐字:本机壳把它原样作为 `sessions.syncMemory` 的 `target`
5048
+ * (「会话要去的那台引擎」);中心侧同步口拿入站 `peer` 按串与它比。位缺席 = 老 server。 */
5049
+ memorySyncServe?: false | MemorySyncServeCapability;
5050
+ /** 🔴 server ≥7.142.0:导出读面 `GET /v1/memory/export`({@link import("./resources/memory.js").MemoryResource.exportScope},`memory.exportScope`)在不在(DB 记忆平面才有)。
5051
+ * 位为 `false` ⇒ 口答 501 `capability.memory_store_required`。本版起该 501 读能力事实,不再读后端名。位缺席 = 老 server。 */
5052
+ memoryExport?: boolean;
4955
5053
  /**
4956
5054
  * server ≥7.119.0(`routes/capabilities.ts` 的能力对象,值 = 引擎 `PERMISSION_MODES` **全集**,引擎序)—— 这台 worker 的请求面**收的权限模式词**:今天六词
4957
5055
  * `default` / `acceptEdits` / `plan` / `auto` / `bypassPermissions` / `dontAsk`。顶层 {@link TaskRequest.permissionMode}、`settings.permissions.defaultMode`、
@@ -5525,7 +5623,9 @@ export interface CrashConvergedRow {
5525
5623
  expiresAtMs: number;
5526
5624
  /** 判别常量:这张卡**已不可再决**。 */
5527
5625
  decision: "denied";
5528
- /** 成因(决断口 410 `gone.ask` 体的 `cause` 是同一个词):`crashed_before_park` = 进程崩了;`shutdown_before_park`(server ≥7.108.0)= 腿被有序关停截断。 */
5626
+ /** 成因(决断口 410 `gone.ask` 体的 `cause` 是同一个词):`crashed_before_park` = 进程崩了;`shutdown_before_park`(server ≥7.108.0)= 腿被有序关停截断。
5627
+ * 🔴 server ≥7.142.0(local 车道;键与闭集不变,值变):有序关停截断、收尾结束时仍未结清的**后台 / 委派子代**卡此前在这里读 `crashed_before_park`(审计账的关停记号按腿落、子代卡的腿不在视野里),
5628
+ * 现在读 `shutdown_before_park` —— 有序关停是进程的事实,三个读面一个词;上一版已收敛过的组升级后照新规则重投影(终态问账行不改写,历史问上两处的词可能不同)。两词处置相同。 */
5529
5629
  cause: Extract<import("./errors.js").AskRowEndingCause, "crashed_before_park" | "shutdown_before_park">;
5530
5630
  /** `pending` = 工具零执行可机械证明;`decided` = 人当时已答、可能有半截副作用。 */
5531
5631
  orphanState: "pending" | "decided";
@@ -5710,7 +5810,9 @@ export interface PendingCheckpoint {
5710
5810
  ruleOffersAbsence?: RuleOffersAbsence;
5711
5811
  /** server ≥7.129.0(core 7.51.0 #1688;park 行事实第八位)—— 这张停驻卡**为什么没有**授予绑定摘要(park 行孪生座 `PendingAction.tool_approval.boundGrantAbsence`,
5712
5812
  * 与活卡帧 / inbox 行同一只窄读、同名同值)。读法见 {@link import("./resources/tool-approvals.js").BoundGrantAbsence}。
5713
- * 🔴 本面缺席 = 技能卡(带摘要)/ 7.51.0 之前停驻的行(两者都不说 —— inbox 面对同一张行投 `unreadable`)/ 集外词 / 老 server —— **不是** `not_bindable`。 */
5813
+ * 🔴 server ≥7.141.0:工具审批行**恰带** {@link boundGrantDigest} 与本键之一(与 inbox 行同一条读法)—— 摘要是串 ⇒ 摘要;否则摘要键不在且行上的词是闭集成员 ⇒ 那个词;
5814
+ * 否则 ⇒ `unreadable`(7.51.0 之前停驻、两者都不说的行 · 集外词 · 摘要在却不是串的行,即使另有 `not_bindable`)。
5815
+ * ≤7.140.x 的分界:那一代队列面上这三种行两键都缺席(inbox 面投 `unreadable`)、老 server(≤7.128.x)本键恒缺席 —— 缺席**不是** `not_bindable`。 */
5714
5816
  boundGrantAbsence?: BoundGrantAbsence;
5715
5817
  /** server ≥7.136.0 —— 引擎 `Skill` 工具的停驻卡上的授予绑定摘要,与 inbox 行 / 活卡帧同名位同值({@link InboxRow.boundGrantDigest}):运维从队列决这张卡时看得到批准它放行了什么。
5716
5818
  * 三位({@link boundGrantDigest} / {@link boundGrants} / {@link classifierNoRuling})由**一只投影**投队列行、`/v1/approvals/stream` 的 `pending` 帧与 inbox 行 —— 同一张停驻行三面逐字相等;值是引擎对这一行投的检查点摘要,server 不重算哈希。
@@ -5910,6 +6012,10 @@ export interface SessionSummary {
5910
6012
  * = **一跳 live-tail re-attach 锚**:picker 选中会话 → 直接 `GET /v1/runs/:lastRunId/events?from=seq` 续 live 尾,
5911
6013
  * 免二次查。无 run → null(空会话)。running/suspended run 也会冒出来(noteTaskRun seam),故选中即可续在跑的尾。 */
5912
6014
  lastRunId: string | null;
6015
+ /** 最近一条 run 的**引擎** run id(`TaskResult.runId`)—— 已知才带,**恒不铸 `null`**(缺席 = 这一行没有已知的引擎 run id:空会话、在跑的最近一条〔认领续跑时清空〕或老 server)。
6016
+ * ⚠️ 与 {@link lastRunId}(最近一条 run 的 **task_id**)是两条身份轴,别混读:续 live 尾用 `lastRunId`,对引擎侧账(trace / journal)用本键。
6017
+ * server 侧列表行早已投这个键(全部后端从最近一条 run 的结果里取);sdk 31.0.0 起声明。 */
6018
+ lastTaskRunId?: string;
5913
6019
  /** 🔴 facade 审计(2026-07-24,批次②-11):server security.ts:12-24 权威 `SessionListItem`(handleSessionList
5914
6020
  * 直接透传给 sendJson,零裁剪;类型自述"Mirrors SessionSummary shape so the wire response is unchanged")
5915
6021
  * 真实带这个字段——会话自动摘要(session-titler.ts,首次提交后台起一次廉价模型调用生成,IS NULL 门控幂等,
@@ -5932,8 +6038,97 @@ export interface SessionSummary {
5932
6038
  /** server ≥7.91.0(additive,老 server 缺席):会话活动词,由最近 run 的状态经 server 与 peer 目录**同一张**映射表派生
5933
6039
  * (running → `active`;suspended / needs_review → `blocked`;无非终态 run → `idle`)。壳的会话列表 / peer 行 tempo 同源。 */
5934
6040
  tempo?: "active" | "idle" | "blocked";
6041
+ /** 🔴 server ≥7.142.0(additive;契约 §17.2 订正)—— **这只会话的存档读不出**:present-iff 会话头的叶子读不出,值 {@link SessionUnreadable}(键闭集只有 `errorCode`)。
6042
+ * 只在文件后端(`DB_BACKEND=local`)上出现:会话头坏了 / 整份截在会话头半截 ⇒ `corrupt_session`;权限不对、I/O 故障 ⇒ `internal.error` —— 值 = 读口打开这只会话时答的那个码
6043
+ * (同一只会话的 `GET /v1/sessions/:id` 与 `…/head` 答 500 带同码)。此前这些会话从列表里**消失**;本版起照样列,行上的格出自会话行(属主 / 标题 / 置顶 / 时间 / `rowTag` / run 四位 / `tempo`,与好行同读),
6044
+ * `objectivePreview: null`(`?q=` 搜索不命中它们)。**出路**:按本键在场分支(灰显 / 提示读不出 / 只给删除);`DELETE /v1/sessions/:id` 对属主照常删;从留存副本恢复存档或修好权限后标记随之消失。
6045
+ * SQL 后端的行从不带它(叶子是会话行上一列,一行坏事件照旧在列表里)。缺席 = 读得出,或老 server(≤7.141.x 文件后端上这种会话不在列表里)。 */
6046
+ unreadable?: SessionUnreadable;
5935
6047
  [k: string]: unknown;
5936
6048
  }
6049
+ /** {@link SessionSummary.unreadable} 的值(server ≥7.142.0;server 自铸登记 `sessionsListRowUnreadableKey`,键闭集)。 */
6050
+ export interface SessionUnreadable {
6051
+ /** 读口打开这只会话时答的码:`corrupt_session`(会话头坏 / 截在头里)或 `internal.error`(I/O 级读不出)—— 与全局兜底答码同一张表。按码分支,开集串。 */
6052
+ errorCode: string;
6053
+ }
6054
+ /** {@link Capabilities.memorySyncServe} 在场形(server ≥7.142.0)。 */
6055
+ export interface MemorySyncServeCapability {
6056
+ /** 本中心声明的同步身份(`MEMORY_SYNC_SERVE_IDENTITY`,规范形)—— 逐字作 `sessions.syncMemory` 的 `target`。 */
6057
+ identity: string;
6058
+ }
6059
+ /** `sessions.syncMemory` 的请求体(server ≥7.142.0):**恰一键** `target`(多键 / 少键 ⇒ 400 `request.body_shape`)。 */
6060
+ export interface SessionMemorySyncRequest {
6061
+ /** 会话要去的那台引擎的同步身份 —— 那台 `GET /v1/capabilities` 上 `memorySyncServe.identity`,逐字。不是同步身份规范形 ⇒ 400 `request.field_invalid`(`field: "target"`,`reason` ∈ {@link import("./errors.js").MEMORY_SYNC_IDENTITY_FLAWS})。 */
6062
+ target: string;
6063
+ }
6064
+ /** 一层同步落下的一条改动(引擎 `PatchReport.applied` 的一项)。 */
6065
+ export interface MemorySyncAppliedOp {
6066
+ op: "add" | "update" | "delete";
6067
+ id: string;
6068
+ slug?: string;
6069
+ }
6070
+ /** 一层同步里没对上的一条(服务端报的或本地的;引擎 `MemorySyncClientConflict`)。 */
6071
+ export interface MemorySyncConflict {
6072
+ side: "server" | "local";
6073
+ id: string;
6074
+ reason: string;
6075
+ baseRev?: string;
6076
+ currentRev?: string;
6077
+ }
6078
+ /**
6079
+ * 记忆同步报告的**一层**(一个 scope、一个结局;引擎 `memorySyncReportOf` 铸,server 原样上 wire)。按 `outcome` 判别(闭集四臂):
6080
+ * · `synced` —— 这一层到了(`applied` 的条数不说到没到,`outcome` 说;重放的调用什么都不落也算 `synced`);
6081
+ * · `incomplete` —— 没到全:`why: "conflicts"`(最后一次调用有冲突,`conflicts` 全列)/ `"truncated"`(被截断、还要再跑);`warnings?` = 客户端拒收的服务端答复;
6082
+ * · `refused` —— 发请求之前就拒了:`code` ∈ `config.memory_sync_cursor_mismatch`(游标绑在别的轴上;`detail.axis` / `detail.found`)/ `config.memory_sync_store`;`outs` = 拒句点名的两条出路(都归宿主);
6083
+ * · `failed` —— 这一层的调用抛了(`error` = 消息原文;一层失败只结束这一层,别的层照跑)。
6084
+ */
6085
+ export type MemorySyncLayerReport = {
6086
+ scope: string;
6087
+ /** 这一层所有调用落下的改动,两半,调用序。 */
6088
+ applied: {
6089
+ server: MemorySyncAppliedOp[];
6090
+ local: MemorySyncAppliedOp[];
6091
+ };
6092
+ } & ({
6093
+ outcome: "synced";
6094
+ } | {
6095
+ outcome: "incomplete";
6096
+ why: "conflicts" | "truncated";
6097
+ conflicts: MemorySyncConflict[];
6098
+ warnings?: string[];
6099
+ } | {
6100
+ outcome: "refused";
6101
+ code: "config.memory_sync_cursor_mismatch" | "config.memory_sync_store";
6102
+ detail?: {
6103
+ axis: "scope" | "peer" | "store";
6104
+ found: "absent" | "other";
6105
+ };
6106
+ outs: [string, string];
6107
+ message: string;
6108
+ } | {
6109
+ outcome: "failed";
6110
+ error: string;
6111
+ });
6112
+ /**
6113
+ * `POST /v1/sessions/:id/memory/sync` 的 200 体(server ≥7.142.0;引擎 `MemorySyncRoundReport`,server 原样上 wire)—— 轮级两臂,按 `"refused" in r` 判:
6114
+ * · `layers` —— 逐层结局({@link MemorySyncLayerReport});读集里没有对应层的 scope 没同步(没被本机同步腿覆盖);
6115
+ * · `refused` —— 整轮拒、一层没跑、零请求:`config.memory_sync_target_mismatch`(目标不是本机同步腿到达的那台)/ `session_active`(会话有在飞 run,或读完记忆观测之后又受理了 run / 会话记录前进了 —— 等它静下来再调)。
6116
+ * 公共三键:`target`(你给的)、`sourceRevision`(这次同步对着的会话版本 = 会话头的叶子;fork 时拿它对齐)、`scopes`(会话的读集,序同它)。
6117
+ */
6118
+ export type SessionMemorySyncReport = {
6119
+ target: string;
6120
+ sourceRevision: string;
6121
+ scopes: string[];
6122
+ } & ({
6123
+ layers: MemorySyncLayerReport[];
6124
+ refused?: never;
6125
+ } | {
6126
+ refused: {
6127
+ code: "config.memory_sync_target_mismatch" | "session_active";
6128
+ message: string;
6129
+ };
6130
+ layers?: never;
6131
+ });
5937
6132
  /** `GET /v1/sessions` 的分页信封(service handleSessionList,keyset)。`nextCursor` 缺 = 末页。 */
5938
6133
  export interface SessionListPage {
5939
6134
  sessions: SessionSummary[];
@@ -6001,6 +6196,8 @@ export interface McpServerStatus {
6001
6196
  toolNames?: string[];
6002
6197
  /** 仅 failed 时;service redact + slice(200)。 */
6003
6198
  error?: string;
6199
+ /** server ≥7.138.0(core 7.59.0):**present-iff** 这台服务器未授权(**本面行不带 `errorCode`**,所以在场律读作「这台要用户先授权」)—— 见 {@link McpAuthorization}。缺席 = 不是授权门,或老 server。 */
6200
+ authorization?: McpAuthorization;
6004
6201
  [k: string]: unknown;
6005
6202
  }
6006
6203
  /**
@@ -6142,6 +6339,8 @@ export interface McpReconnectServerStatus {
6142
6339
  httpStatus?: number;
6143
6340
  /** 请求到没到那台服务器 —— 与 {@link errorCode} **合读**。 */
6144
6341
  delivered?: McpDelivered;
6342
+ /** server ≥7.138.0(core 7.59.0):**present-iff** `errorCode` 是 `"unauthorized"` —— 见 {@link McpAuthorization}(只有闭集词 `reason`,地址不出门)。缺席 = 不是授权门,或老 server。 */
6343
+ authorization?: McpAuthorization;
6145
6344
  serverInfo?: {
6146
6345
  name: string;
6147
6346
  version: string;
@@ -6329,7 +6528,33 @@ export interface SessionMemoryStatusResponse extends SessionMemoryStatus {
6329
6528
  * 两处**同源唯一读点**,租户面只有本键。
6330
6529
  */
6331
6530
  autoConsolidationArmed?: boolean;
6531
+ /**
6532
+ * server ≥7.141.0 · **这台部署的记忆同步停驻读数**({@link SessionMemorySync};部署事实:有同步腿 ⇔ 在场;不随会话、不随 `?scope=`)。
6533
+ * `parked: []` = 在同步;每行一层停驻 —— 该层的同步游标被同步引擎在 scope / 对端 / 店任一轴拒,或读不成游标:零请求、文件不动、每一轮照样停,直到删掉它。
6534
+ * 缺席 = 本部署没有同步腿,或老 server(≤7.140.x)。游标的盘路径不上 wire(运维行 `memory_sync_layer_parked` 带它)。
6535
+ */
6536
+ memorySync?: SessionMemorySync;
6537
+ }
6538
+ /** server ≥7.141.0 · `memory-status` 的 {@link SessionMemoryStatusResponse.memorySync} 段。 */
6539
+ export interface SessionMemorySync {
6540
+ /** 停驻的层(空数组 = 在同步)。 */
6541
+ parked: MemorySyncParkedLayer[];
6542
+ }
6543
+ /** 一层停驻的记忆同步。 */
6544
+ export interface MemorySyncParkedLayer {
6545
+ /** 停驻层的 scope(记忆层坐标,逐字)。 */
6546
+ scope: string;
6547
+ /**
6548
+ * 这一层唯一的出路词。今天恒 `delete_cursor`:删掉这一层的游标文件,下一轮从空基线重收敛(拉中心这一层有的、推本店有的、不推删除;两边都改过的条目按冲突报)——
6549
+ * **保守合并**:自上一轮以来一侧删掉的条目会从另一侧回来(不丢条目,删除要重做)。服务端自己不写、不改、不删游标。
6550
+ * **开集读**:已知词 {@link MEMORY_SYNC_WAY_OUTS};不认识的词按「出路未知、别替用户动手」处置。
6551
+ */
6552
+ wayOut: MemorySyncWayOut | (string & {});
6332
6553
  }
6554
+ /** {@link MemorySyncParkedLayer.wayOut} 的已知词(server 自铸登记 `memorySyncWayOut`,测试对已装 server 做相等锚)。 */
6555
+ export declare const MEMORY_SYNC_WAY_OUTS: readonly ["delete_cursor"];
6556
+ /** {@link MEMORY_SYNC_WAY_OUTS} 的成员型。 */
6557
+ export type MemorySyncWayOut = (typeof MEMORY_SYNC_WAY_OUTS)[number];
6333
6558
  /** ONE session-tree entry as it crosses the sync wire — the SDK treats it as an OPAQUE payload (verbatim,
6334
6559
  * cross-backend stable ids/parents). It is core's `SessionTreeEntry`; the SDK only ever reads `.id` (for the
6335
6560
  * §7 id-set classify) and otherwise pipes it through untouched (the cloud re-validates the whole tree). */
@@ -6799,7 +7024,8 @@ export interface InboxRow {
6799
7024
  * 🔴 部署文本:渲染按上下文转义。 */
6800
7025
  boundGrants?: BoundSkillGrants;
6801
7026
  /** server ≥7.129.0(core 7.51.0 #1688)—— 卡**为什么没有** {@link boundGrantDigest}(两者恰一;引擎 `summarizeCheckpoint` 对工具审批行是全函数 ——
6802
- * 7.51.0 之前停驻、两者都不说的行在本面投 `unreadable`)。与活卡帧 / 运维队列行同名同值,读法见 {@link import("./resources/tool-approvals.js").BoundGrantAbsence}。 */
7027
+ * 7.51.0 之前停驻、两者都不说的行在本面投 `unreadable`)。与活卡帧 / 运维队列行同名同值(server ≥7.141.0 起运维队列两面也恰带其一,同一条读法),
7028
+ * 读法见 {@link import("./resources/tool-approvals.js").BoundGrantAbsence}。 */
6803
7029
  boundGrantAbsence?: BoundGrantAbsence;
6804
7030
  /** server ≥7.118.0(core 7.43.0 #1353)—— 只在类 `classifier_no_ruling` 的停驻卡上:分类器为什么没判({@link AutoModeFallbackCause})。 */
6805
7031
  classifierNoRuling?: AutoModeFallbackCause;
@@ -7034,6 +7260,9 @@ export interface WiringManifest {
7034
7260
  reasons?: string[];
7035
7261
  checkpointDurability?: string;
7036
7262
  };
7263
+ /** 主 runner 会话店的耐久读数(引擎的词,开集读):`declared_durable` = 会话店声明了持久介质;`process_local` = 进程内(重启即丢)。
7264
+ * server ≥7.141.0:SQL 两种后端(`DB_BACKEND=mysql` / `pg`)与本机形(`DB_BACKEND=local`)都答 `declared_durable`(7.140.x 上这三种部署都答 `process_local`,真持久的部署也是);
7265
+ * 会话店仍是进程内店的部署(`DB_BACKEND=memory`,或 SQL 而 `SESSION_BACKEND=memory`)与子代 runner 的那一格仍答 `process_local`。 */
7037
7266
  session?: {
7038
7267
  store?: string;
7039
7268
  };
@@ -7052,6 +7281,8 @@ export interface WiringManifest {
7052
7281
  skills?: WiringManifestSkill[];
7053
7282
  /** fleet 面:`backgroundAgentStore` / `hostChildEventSink` 是在场位;🔴 `subagentTranscripts`(**server ≥7.115.0 / S-744**,core 7.32.0 的档位上 wire)= 这台部署的**子代转录档位**,
7054
7283
  * 壳按它如实渲「durable record」文案:`"none"`(没有 agent 行店:子代记录不留)/ `"rows"`(行与终态快照活过重启、**对话不活**:仅本进程 / 会话店 TTL 内可续)/ `"full"`(已结束的子代**跨重启可续**)。
7284
+ * server ≥7.141.0:本服务的装配只产出 `full`(`DB_BACKEND=mysql` / `pg` / `local`)与 `none`(没有后台记录店的 `DB_BACKEND=memory`);`rows` 仍是引擎闭集里的词,只来自调用方自挂的 runner
7285
+ * (7.140.x 的 local 部署答 `rows`)。
7055
7286
  * 🔴 **开集读**:三词是 core 今天的词,**不要穷举**(core 的第四个词会被吞成缺席);**未知词 ⇒ 按「未知档位」处置,不要当 `full`**。缺席(老 server / 老引擎)= 不知道,**绝不读成 `"none"`**;租户帧与 operator 帧同投。 */
7056
7287
  fleet?: {
7057
7288
  backgroundAgentStore?: boolean;