@anycon/protocol 0.4.7 → 0.4.9

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/src/generated.ts CHANGED
@@ -25,7 +25,7 @@ export type ConfigEditable = "any" | "tighten_only" | "no";
25
25
  /**
26
26
  * 配置值的类型,客户端据此选控件。
27
27
  */
28
- export type ConfigValueKind = "bool" | "int" | "duration" | "enum" | "text";
28
+ export type ConfigValueKind = "bool" | "int" | "duration" | "enum" | "text" | "list";
29
29
  /**
30
30
  * 控制消息集合。方向见注释:D = 设备,H = hub。
31
31
  */
@@ -278,6 +278,17 @@ export type ErrorCode =
278
278
  * 会话事件。adapter 把各 agent 的原生事件翻译成这个集合(docs/spec/daemon.md § 8)。
279
279
  */
280
280
  export type Event =
281
+ | {
282
+ message_count: number;
283
+ message_id: string;
284
+ scope: RewindScope;
285
+ to_seq: number;
286
+ /**
287
+ * 非用户事件从开轮的序号算起,缺省沿用旧事件的 `to_seq`。
288
+ */
289
+ turn_seq?: number | null;
290
+ type: "rewind";
291
+ }
281
292
  | {
282
293
  attachments?: AttachmentRef[];
283
294
  by_device: string;
@@ -507,7 +518,11 @@ export type Event =
507
518
  message_id: string;
508
519
  state: MessageDeliveryState;
509
520
  type: "message_delivery";
521
+ }
522
+ | {
523
+ type: "unknown";
510
524
  };
525
+ export type RewindScope = "conversation" | "files" | "both" | "unknown";
511
526
  export type ToolCategory = "shell" | "file_edit" | "file_read" | "search" | "web" | "subagent" | "mcp" | "other";
512
527
  export type EditKind = "edit" | "write" | "delete" | "move";
513
528
  export type FileChangeKind = "created" | "modified" | "deleted";
@@ -566,12 +581,51 @@ export type MessageDeliveryState = "uncertain";
566
581
  */
567
582
  export type FsReadEncoding = "text" | "base64";
568
583
  /**
569
- * 信封种类。hub 对每种的处理见 docs/protocol.md § 3。
584
+ * `anthropic` 格式后端的思考深度(`effort`)。
570
585
  */
571
- export type Kind = "handshake" | "data" | "notify" | "control";
586
+ export type JudgeEffort = "low" | "medium" | "high" | "xhigh" | "max";
572
587
  export type JudgeApiFormat = "anthropic" | "openai" | "unknown";
573
588
  export type JudgeBackendKind = "api" | "agent" | "unknown";
574
589
  export type JudgeProblem = "no_key" | "agent_missing" | "agent_unsupported" | "unknown";
590
+ /**
591
+ * 信封种类。hub 对每种的处理见 docs/protocol.md § 3。
592
+ */
593
+ export type Kind = "handshake" | "data" | "notify" | "control";
594
+ /**
595
+ * 主人确认(节点口令)现在能不能用。
596
+ */
597
+ export type OwnerConfirmStatus = "ready" | "unset" | "untrusted";
598
+ export type UpdateReason =
599
+ | "remote_disabled"
600
+ | "no_update"
601
+ | "busy"
602
+ | "already_rolled_back"
603
+ | "unsupported_installation"
604
+ | "check_failed"
605
+ | "download_failed"
606
+ | "provenance_failed"
607
+ | "invalid_archive"
608
+ | "version_probe_failed"
609
+ | "install_failed"
610
+ | "interrupted"
611
+ | "startup_failed"
612
+ | "health_timeout"
613
+ | "snapshot_failed"
614
+ | "restore_failed"
615
+ | "unknown";
616
+ export type UpdateManagedBy =
617
+ "installer" | "homebrew" | "cargo" | "dev" | "readonly" | "unmanaged" | "root" | "unsupported" | "unknown";
618
+ export type UpdatePhase =
619
+ | "idle"
620
+ | "downloading"
621
+ | "verifying"
622
+ | "waiting_for_idle"
623
+ | "installing"
624
+ | "rolling_back"
625
+ | "updated"
626
+ | "rolled_back"
627
+ | "failed"
628
+ | "unknown";
575
629
  /**
576
630
  * 节点配置 `worktree.default` 的取值,也是 `SessionWorkspace` 的两种模式。
577
631
  */
@@ -1015,11 +1069,14 @@ export interface ProtocolSchema {
1015
1069
  job_done: JobDone;
1016
1070
  job_progress: JobProgress;
1017
1071
  job_started: JobStarted;
1072
+ judge_effort: JudgeEffort;
1073
+ judge_info: JudgeInfo;
1018
1074
  kind: Kind;
1019
1075
  link_block: LinkBlock;
1020
1076
  node_audit_params: NodeAuditParams;
1021
1077
  node_audit_result: NodeAuditResult;
1022
1078
  node_config_result: NodeConfigResult;
1079
+ node_delete_judge_backend_params: NodeDeleteJudgeBackendParams;
1023
1080
  node_devices_result: NodeDevicesResult;
1024
1081
  node_doctor_result: NodeDoctorResult;
1025
1082
  node_enroll_approve_params: NodeEnrollApproveParams;
@@ -1029,6 +1086,7 @@ export interface ProtocolSchema {
1029
1086
  node_enroll_list_result: NodeEnrollListResult;
1030
1087
  node_enroll_resolved: NodeEnrollResolved;
1031
1088
  node_enroll_status_result: NodeEnrollStatusResult;
1089
+ node_get_config_params: NodeGetConfigParams;
1032
1090
  node_info: NodeInfo;
1033
1091
  node_log_level: NodeLogLevel;
1034
1092
  node_logs_params: NodeLogsParams;
@@ -1041,17 +1099,23 @@ export interface ProtocolSchema {
1041
1099
  node_set_config_params: NodeSetConfigParams;
1042
1100
  node_set_enroll_enabled_params: NodeSetEnrollEnabledParams;
1043
1101
  node_set_enroll_password_params: NodeSetEnrollPasswordParams;
1102
+ node_set_judge_backend_params: NodeSetJudgeBackendParams;
1044
1103
  node_stats: NodeStats;
1045
1104
  node_twin_link_code_result: NodeTwinLinkCodeResult;
1105
+ node_update_changed: NodeUpdateChanged;
1106
+ node_update_status: NodeUpdateStatus;
1046
1107
  node_worktree_settings: NodeWorktreeSettings;
1047
1108
  notify_body: NotifyBody;
1048
1109
  notify_detail: NotifyDetail;
1110
+ owner_confirm: OwnerConfirm;
1111
+ owner_confirm_status: OwnerConfirmStatus;
1049
1112
  pair_ack: PairAck;
1050
1113
  permission_list_params: PermissionListParams;
1051
1114
  permission_list_result: PermissionListResult;
1052
1115
  permission_request: PermissionRequest;
1053
1116
  permission_resolved: PermissionResolved;
1054
1117
  permission_respond_params: PermissionRespondParams;
1118
+ preview_blocked_port: PreviewBlockedPort;
1055
1119
  preview_body_encoding: PreviewBodyEncoding;
1056
1120
  preview_close_params: PreviewCloseParams;
1057
1121
  preview_detection: PreviewDetection;
@@ -1072,6 +1136,8 @@ export interface ProtocolSchema {
1072
1136
  preview_reset: PreviewReset;
1073
1137
  preview_reset_code: PreviewResetCode;
1074
1138
  preview_response_head: PreviewResponseHead;
1139
+ preview_set_port_allowed_params: PreviewSetPortAllowedParams;
1140
+ preview_set_port_allowed_result: PreviewSetPortAllowedResult;
1075
1141
  project: Project;
1076
1142
  project_kind: ProjectKind;
1077
1143
  prompt_segment: PromptSegment;
@@ -1126,17 +1192,25 @@ export interface ProtocolSchema {
1126
1192
  session_diff_params: SessionDiffParams;
1127
1193
  session_diff_result: SessionDiffResult;
1128
1194
  session_event: SessionEvent;
1195
+ session_fork_params: SessionForkParams;
1129
1196
  session_git_status: SessionGitStatus;
1130
1197
  session_git_status_params: SessionGitStatusParams;
1131
1198
  session_history_params: SessionHistoryParams;
1132
1199
  session_history_result: SessionHistoryResult;
1133
1200
  session_id_params: SessionIdParams;
1201
+ session_import_list_params: SessionImportListParams;
1202
+ session_import_list_result: SessionImportListResult;
1203
+ session_import_params: SessionImportParams;
1134
1204
  session_list_params: SessionListParams;
1135
1205
  session_list_result: SessionListResult;
1136
1206
  session_mark_read_params: SessionMarkReadParams;
1137
1207
  session_promote_params: SessionPromoteParams;
1138
1208
  session_read_file_params: SessionReadFileParams;
1139
1209
  session_rename_params: SessionRenameParams;
1210
+ session_rewind_check_params: SessionRewindCheckParams;
1211
+ session_rewind_check_result: SessionRewindCheckResult;
1212
+ session_rewind_params: SessionRewindParams;
1213
+ session_rewind_result: SessionRewindResult;
1140
1214
  session_search_params: SessionSearchParams;
1141
1215
  session_search_result: SessionSearchResult;
1142
1216
  session_send_params: SessionSendParams;
@@ -1148,6 +1222,7 @@ export interface ProtocolSchema {
1148
1222
  session_summary: SessionSummary;
1149
1223
  session_sync_base_params: SessionSyncBaseParams;
1150
1224
  session_sync_base_result: SessionSyncBaseResult;
1225
+ session_watch_params: SessionWatchParams;
1151
1226
  session_workspace: SessionWorkspace;
1152
1227
  session_workspace_mode: SessionWorkspaceMode;
1153
1228
  session_worktree: SessionWorktree;
@@ -1277,6 +1352,14 @@ export interface AgentCapabilities {
1277
1352
  * 支持每会话 env。
1278
1353
  */
1279
1354
  env: boolean;
1355
+ /**
1356
+ * 支持以已有 agent 会话为起点分叉。
1357
+ */
1358
+ fork?: boolean;
1359
+ /**
1360
+ * 可以发现本机原生会话并续接。
1361
+ */
1362
+ import?: boolean;
1280
1363
  /**
1281
1364
  * turn 进行中能否插话。
1282
1365
  */
@@ -1291,7 +1374,14 @@ export interface AgentCapabilities {
1291
1374
  * 进程退出后能否续接。
1292
1375
  */
1293
1376
  resume: boolean;
1377
+ /**
1378
+ * 支持回退原生对话。
1379
+ */
1294
1380
  rewind: boolean;
1381
+ /**
1382
+ * 支持恢复原生文件检查点。
1383
+ */
1384
+ rewind_files?: boolean;
1295
1385
  structured_output: boolean;
1296
1386
  /**
1297
1387
  * 会话的 `system_prompt_append` 真的会交给 agent(docs/spec/daemon.md § 6.3)。为 false(通用 ACP agent、旧 daemon)时,
@@ -1546,7 +1636,7 @@ export interface ConfigItem {
1546
1636
  key: string;
1547
1637
  kind: ConfigValueKind;
1548
1638
  /**
1549
- * 取值上限:`int` 是数值,`duration` 是毫秒,`text` 是字符数。
1639
+ * 取值上限:`int` 是数值,`duration` 是毫秒,`text` 是字符数,`list` 是条目数。
1550
1640
  */
1551
1641
  max?: number | null;
1552
1642
  /**
@@ -1645,6 +1735,11 @@ export interface EnrollPasswordStatus {
1645
1735
  */
1646
1736
  set_by?: string | null;
1647
1737
  state: EnrollPasswordState;
1738
+ /**
1739
+ * 口令是在节点本机设的(`anycon passwd`),所以可以当主人确认(`node.set_config` 的放宽类改动)。
1740
+ * 远程设的口令是 `false`;没有口令、旧 daemon 也读作 `false`。
1741
+ */
1742
+ trusted?: boolean;
1648
1743
  }
1649
1744
  /**
1650
1745
  * 按 category 归一化的渲染字段。全部可选;`input` 仍原样保留。
@@ -1951,6 +2046,38 @@ export interface JobProgress {
1951
2046
  export interface JobStarted {
1952
2047
  job_id: string;
1953
2048
  }
2049
+ export interface JudgeInfo {
2050
+ advisor?: string | null;
2051
+ backends: JudgeBackendInfo[];
2052
+ daily_calls: number;
2053
+ extract?: string | null;
2054
+ triage?: string | null;
2055
+ }
2056
+ export interface JudgeBackendInfo {
2057
+ agent?: string | null;
2058
+ /**
2059
+ * 生效的思考深度;只有 `anthropic` 格式且设了才给。
2060
+ */
2061
+ effort?: JudgeEffort | null;
2062
+ format?: JudgeApiFormat | null;
2063
+ kind: JudgeBackendKind;
2064
+ /**
2065
+ * 生效的输出 token 上限;只有 `api` 后端给。
2066
+ */
2067
+ max_output_tokens?: number | null;
2068
+ model?: string | null;
2069
+ name: string;
2070
+ problem?: JudgeProblem | null;
2071
+ /**
2072
+ * 可以用 `node.set_judge_backend` / `node.delete_judge_backend` 远程改 / 删。用环境变量里的密钥(`api_key_env`)
2073
+ * 或回环 `http` 地址的后端是在机器上定义的,只能在机器上改,这里是 `false`。旧 daemon 不给,读作 `false`。
2074
+ */
2075
+ remote_editable?: boolean;
2076
+ /**
2077
+ * 生效的单次调用时限(毫秒),含缺省值。旧 daemon 不给。
2078
+ */
2079
+ timeout_ms?: number | null;
2080
+ }
1954
2081
  export interface NodeAuditParams {
1955
2082
  device_id?: string | null;
1956
2083
  limit?: number | null;
@@ -1972,6 +2099,26 @@ export interface AuditEntry {
1972
2099
  */
1973
2100
  export interface NodeConfigResult {
1974
2101
  items: ConfigItem[];
2102
+ /**
2103
+ * 主人确认的状态;旧 daemon 不给 = 不支持(放宽类的改动只能在机器上做)。
2104
+ */
2105
+ owner_confirm?: OwnerConfirm | null;
2106
+ }
2107
+ /**
2108
+ * 节点的主人确认状态(`node.get_config` / `node.set_config` 的结果里)。旧 daemon 没有这个字段 = 不支持主人确认。
2109
+ */
2110
+ export interface OwnerConfirm {
2111
+ /**
2112
+ * `status = ready` 且连续输错太多次时:还要等多久才接受下一次确认。
2113
+ */
2114
+ retry_after_ms?: number | null;
2115
+ status: OwnerConfirmStatus;
2116
+ }
2117
+ /**
2118
+ * `node.delete_judge_backend` 参数。名字不存在 → `not_found`;是在机器上定义的后端 → `forbidden`(`data.reason = "local_backend"`)。
2119
+ */
2120
+ export interface NodeDeleteJudgeBackendParams {
2121
+ name: string;
1975
2122
  }
1976
2123
  export interface NodeDevicesResult {
1977
2124
  devices: PeerDevice[];
@@ -2057,6 +2204,16 @@ export interface NodeEnrollStatusResult {
2057
2204
  approval: boolean;
2058
2205
  password: EnrollPasswordStatus;
2059
2206
  }
2207
+ /**
2208
+ * `node.get_config` 参数。整个参数对象可以省略(等于全部缺省)。
2209
+ */
2210
+ export interface NodeGetConfigParams {
2211
+ /**
2212
+ * 返回全部项。缺省 `false`:只返回已发布的客户端认识的项,也就是去掉 `kind = list` 的项和非开关(`kind` 不是 `bool`)的
2213
+ * `tighten_only` 项——旧客户端不认识 `list`,并且把 `tighten_only` 一律当成「只能关掉的开关」。
2214
+ */
2215
+ extended?: boolean;
2216
+ }
2060
2217
  /**
2061
2218
  * `node.info` 结果。
2062
2219
  */
@@ -2083,6 +2240,10 @@ export interface NodeInfo {
2083
2240
  * `[twin] accept_links`:这个节点现在接受别的节点的 Twin 连接(docs/spec/daemon.md § 27.2)。旧 daemon 没有这个字段,读作 `false`。
2084
2241
  */
2085
2242
  twin_accept_links?: boolean;
2243
+ /**
2244
+ * 当前机器的更新开关、安装方式和最近一次安装的状态。
2245
+ */
2246
+ update?: NodeUpdateStatus | null;
2086
2247
  /**
2087
2248
  * 更新检查(ADR-57)知道有比这个 daemon 更新的正式版本时给出;没有更新的版本、检查关着、还没检查成功过,
2088
2249
  * 以及旧 daemon,都不给。
@@ -2128,6 +2289,11 @@ export interface NodeCapabilities {
2128
2289
  */
2129
2290
  file_attachments?: boolean;
2130
2291
  fs: boolean;
2292
+ /**
2293
+ * 支持 `node.set_judge_backend` / `node.delete_judge_backend`,`node.info.judge.backends[]` 带 `remote_editable`。
2294
+ * 旧 daemon 没有这个字段,读作 false。
2295
+ */
2296
+ judge_backends?: boolean;
2131
2297
  /**
2132
2298
  * 支持 dev server 预览(`preview.*`,ADR-39),且节点配置 `preview.enabled = true`。
2133
2299
  */
@@ -2136,6 +2302,10 @@ export interface NodeCapabilities {
2136
2302
  * 支持目录预览(`preview.open { dir }`,ADR-62),且节点开着预览。旧 daemon 没有这个字段,读作 false。
2137
2303
  */
2138
2304
  preview_dir?: boolean;
2305
+ /**
2306
+ * 支持 `preview.set_port_allowed`,`preview.ports` 认 `include_blocked`。旧 daemon 没有这个字段,读作 false。
2307
+ */
2308
+ preview_ports_admin?: boolean;
2139
2309
  /**
2140
2310
  * 支持规则提炼 RPC;没有该字段时按不支持处理。
2141
2311
  */
@@ -2145,10 +2315,22 @@ export interface NodeCapabilities {
2145
2315
  */
2146
2316
  rules?: boolean;
2147
2317
  search: boolean;
2318
+ /**
2319
+ * 支持 `session.fork`。
2320
+ */
2321
+ session_fork?: boolean;
2322
+ /**
2323
+ * 支持 `session.import_list` 和 `session.import`。
2324
+ */
2325
+ session_import?: boolean;
2148
2326
  /**
2149
2327
  * 支持 `session.read_file`(读会话里「读文件」调用读的图片 / 文本,docs/protocol.md § 5.4)。旧 daemon 没有这个字段,读作 false。
2150
2328
  */
2151
2329
  session_read_file?: boolean;
2330
+ /**
2331
+ * 支持 session.rewind 和 session.rewind_check。
2332
+ */
2333
+ session_rewind?: boolean;
2152
2334
  /**
2153
2335
  * 支持清单(`todo.*`,docs/spec/daemon.md § 21)。旧 daemon 没有这个字段,读作 false。
2154
2336
  */
@@ -2176,6 +2358,10 @@ export interface NodeCapabilities {
2176
2358
  * (docs/spec/daemon.md § 26.8)。旧 daemon 没有这个字段,读作 false。
2177
2359
  */
2178
2360
  twin_stats?: boolean;
2361
+ /**
2362
+ * 支持更新状态和 `node.update`。安装方式和机器级开关见 `node.info.update`。
2363
+ */
2364
+ update?: boolean;
2179
2365
  /**
2180
2366
  * 有 workspace(文件夹即项目)。SDK 节点可能没有。
2181
2367
  */
@@ -2185,20 +2371,18 @@ export interface NodeCapabilities {
2185
2371
  */
2186
2372
  worktree?: boolean;
2187
2373
  }
2188
- export interface JudgeInfo {
2189
- advisor?: string | null;
2190
- backends: JudgeBackendInfo[];
2191
- daily_calls: number;
2192
- extract?: string | null;
2193
- triage?: string | null;
2374
+ export interface NodeUpdateStatus {
2375
+ auto: boolean;
2376
+ last_rollback?: UpdateRollback | null;
2377
+ managed_by: UpdateManagedBy;
2378
+ phase: UpdatePhase;
2379
+ reason?: UpdateReason | null;
2380
+ remote: boolean;
2381
+ version?: string | null;
2194
2382
  }
2195
- export interface JudgeBackendInfo {
2196
- agent?: string | null;
2197
- format?: JudgeApiFormat | null;
2198
- kind: JudgeBackendKind;
2199
- model?: string | null;
2200
- name: string;
2201
- problem?: JudgeProblem | null;
2383
+ export interface UpdateRollback {
2384
+ reason: UpdateReason;
2385
+ version: string;
2202
2386
  }
2203
2387
  /**
2204
2388
  * 有更新的版本(`node.info.update_available`)。daemon 只在 `latest` 是严格的 `X.Y.Z` 且比自己的版本新时给出;
@@ -2339,11 +2523,23 @@ export interface NodeSetAgentDefaultsParams {
2339
2523
  /**
2340
2524
  * `node.set_config` 参数。所有改动先校验,任何一项不合法就一项都不写。
2341
2525
  *
2342
- * 错误:键不在白名单、被环境变量覆盖、想放宽只能收紧的键 → `forbidden`(`data.field` 是键,`data.reason` 是
2343
- * `not_editable` / `env_override` / `tighten_only`);值的类型或取值不合法、键重复、`changes` 为空 → `invalid`(`data.field` 是键)。
2526
+ * 错误:
2527
+ * - 键不在白名单、被环境变量覆盖 → `forbidden`(`data.field` 是键,`data.reason` 是 `not_editable` / `env_override`);
2528
+ * - 值的类型或取值不合法、键重复、`changes` 为空 → `invalid`(`data.field` 是键);
2529
+ * - 有放宽类的改动(`TightenOnly` 的键往宽松方向改)而主人确认没通过 → `forbidden`,`data.field` 是第一个放宽的键,
2530
+ * `data.reason` 是 `owner_required`(没带 `password`)/ `owner_password_unset`(节点没有口令)/ `owner_password_untrusted`
2531
+ * (口令是远程设的)/ `owner_backoff`(连续输错太多次,`data.retry_after_ms` 是还要等多久)/ `owner_wrong_password`。
2344
2532
  */
2345
2533
  export interface NodeSetConfigParams {
2346
2534
  changes: ConfigChange[];
2535
+ /**
2536
+ * 返回的 `items` 是否包含全部项(同 [`NodeGetConfigParams::extended`])。写白名单里的键不受这个标志限制。
2537
+ */
2538
+ extended?: boolean;
2539
+ /**
2540
+ * 节点口令,主人确认用。只有放宽类的改动才会校验;没有放宽类的改动时忽略。
2541
+ */
2542
+ password?: string | null;
2347
2543
  }
2348
2544
  /**
2349
2545
  * `node.set_enroll_enabled` 参数:写 `[enroll]` 配置。`password: true` 同时解除锁定、失败计数清零。
@@ -2354,9 +2550,70 @@ export interface NodeSetEnrollEnabledParams {
2354
2550
  }
2355
2551
  /**
2356
2552
  * `node.set_enroll_password` 参数。`password` 省略 = 清除。至少 8 个字符(按 Unicode 字符计,NFC 之后)。
2553
+ *
2554
+ * 经 hub 来的设备(远程):节点已经有口令时,改 / 清除要带 `current_password`,缺 → `forbidden`
2555
+ * (`data.reason = "current_password_required"`),错 → `forbidden`(`owner_wrong_password`),连续错太多次 → `forbidden`
2556
+ * (`owner_backoff`,`data.retry_after_ms`)。节点还没有口令时远程可以直接设(设出来的口令 `trusted = false`)。
2557
+ * 本机 socket 上的调用方(`anycon passwd`)不需要 `current_password`,设出来的口令 `trusted = true`。
2357
2558
  */
2358
2559
  export interface NodeSetEnrollPasswordParams {
2560
+ /**
2561
+ * 现在的节点口令(远程改 / 清除时必填)。
2562
+ */
2563
+ current_password?: string | null;
2564
+ password?: string | null;
2565
+ }
2566
+ /**
2567
+ * `node.set_judge_backend` 参数:新建或整体替换 `[judge.backends.<name>]`,字段和 `config.toml` 里的一一对应。
2568
+ * 刻意没有 `api_key_env`:远程调用方可以把 `base_url` 指向自己的服务器、再指定本机任意环境变量,daemon 就会把它发出去。
2569
+ *
2570
+ * - `kind = agent`:`agent` 必填(本节点配置里有的 agent id),`model` / `timeout` 可选;带了 api 专用的字段 → `invalid`。不需要主人确认。
2571
+ * - `kind = api`:`format`、`model` 必填;`base_url` 可选(缺省按格式),必须是 `https`;`max_output_tokens` / `effort` / `timeout` 可选。
2572
+ * `api_key` 新建时必填;替换已有的 api 后端时可以省略以沿用已存的密钥,但只有 `format` 和生效的 `base_url` 都没变才行,
2573
+ * 否则 `invalid`(`data.field = "api_key"`,`data.reason = "key_required"`)。必须带 `password` 做主人确认。
2574
+ *
2575
+ * 错误:
2576
+ * - `invalid`:参数不合法(`data.field` 是字段名);`name` 不合法、后端已满 20 个;
2577
+ * - `forbidden`:`data.reason = "local_backend"`(已有的同名后端是在机器上定义的)、`env_override`(`judge.backends` 被 `ANYCON_*` 覆盖);
2578
+ * 主人确认没通过时 `data.field = "password"`,`data.reason` 同 `node.set_config`(`owner_required` / `owner_password_unset` /
2579
+ * `owner_password_untrusted` / `owner_backoff`(带 `data.retry_after_ms`)/ `owner_wrong_password`)。
2580
+ */
2581
+ export interface NodeSetJudgeBackendParams {
2582
+ /**
2583
+ * `kind = agent`:agent id。
2584
+ */
2585
+ agent?: string | null;
2586
+ /**
2587
+ * `kind = api`:密钥。只写不读:任何结果、日志、审计、错误里都没有它。
2588
+ */
2589
+ api_key?: string | null;
2590
+ /**
2591
+ * `kind = api`:服务地址,必须是 `https`;缺省按格式。
2592
+ */
2593
+ base_url?: string | null;
2594
+ /**
2595
+ * 只有 `format = anthropic` 能设。
2596
+ */
2597
+ effort?: JudgeEffort | null;
2598
+ /**
2599
+ * `kind = api`:回应格式。
2600
+ */
2601
+ format?: JudgeApiFormat | null;
2602
+ kind: JudgeBackendKind;
2603
+ max_output_tokens?: number | null;
2604
+ model?: string | null;
2605
+ /**
2606
+ * 1–40 个字符,`[A-Za-z0-9_-]`。
2607
+ */
2608
+ name: string;
2609
+ /**
2610
+ * 节点口令,`kind = api` 时的主人确认。
2611
+ */
2359
2612
  password?: string | null;
2613
+ /**
2614
+ * 时限,如 `"2m"`(10s–60m)。
2615
+ */
2616
+ timeout?: string | null;
2360
2617
  }
2361
2618
  export interface NodeStats {
2362
2619
  agent_processes: number;
@@ -2388,6 +2645,13 @@ export interface NodeTwinLinkCodeResult {
2388
2645
  */
2389
2646
  expires_ms: number;
2390
2647
  }
2648
+ /**
2649
+ * 更新状态变化时发送。字段缺省表示对应的 `node.info` 中也没有已知更新。
2650
+ */
2651
+ export interface NodeUpdateChanged {
2652
+ update: NodeUpdateStatus;
2653
+ update_available?: NodeUpdateAvailable | null;
2654
+ }
2391
2655
  /**
2392
2656
  * `kind = notify` 的 body(msgpack)。`category` 是外层唯一有语义的明文字段。
2393
2657
  */
@@ -2469,6 +2733,17 @@ export interface PermissionRespondParams {
2469
2733
  option_id?: string | null;
2470
2734
  request_id: string;
2471
2735
  }
2736
+ /**
2737
+ * `preview.ports.blocked` 的一项。
2738
+ */
2739
+ export interface PreviewBlockedPort {
2740
+ pid?: number | null;
2741
+ port: number;
2742
+ /**
2743
+ * 进程名(可执行文件名,不含参数)。
2744
+ */
2745
+ process?: string | null;
2746
+ }
2472
2747
  /**
2473
2748
  * `preview.close` 参数:作废这个 label 的全部票据,断开它的全部隧道。
2474
2749
  */
@@ -2628,9 +2903,19 @@ export interface PreviewPort {
2628
2903
  * `preview.ports` 参数。带 `session_id` 只列这个会话的端口(外加配置里允许的端口)。
2629
2904
  */
2630
2905
  export interface PreviewPortsParams {
2906
+ /**
2907
+ * 同时列出现在不能预览的本机监听端口(结果的 `blocked`)。带 `session_id` 时忽略。
2908
+ */
2909
+ include_blocked?: boolean;
2631
2910
  session_id?: string | null;
2632
2911
  }
2633
2912
  export interface PreviewPortsResult {
2913
+ /**
2914
+ * 请求带了 `include_blocked` 时给出:绑在回环 / 通配地址上、按端口策略现在不能预览的监听端口(含混合归属的端口),
2915
+ * 按端口排序,最多 200 个;探测不可用时是空数组。不带 `include_blocked` 时没有这个字段。
2916
+ * 用 `preview.set_port_allowed` 把其中的端口加进 `preview.allow_ports`。
2917
+ */
2918
+ blocked?: PreviewBlockedPort[] | null;
2634
2919
  detection: PreviewDetection;
2635
2920
  ports: PreviewPort[];
2636
2921
  }
@@ -2669,6 +2954,25 @@ export interface PreviewResponseHead {
2669
2954
  headers: [string, string][];
2670
2955
  status: number;
2671
2956
  }
2957
+ /**
2958
+ * `preview.set_port_allowed` 参数:把 `port` 加进(`allowed = true`)/ 移出 `preview.allow_ports`。
2959
+ * 端口不在 1–65535、是本机 hub 的端口、加进去会超过 64 个 → `invalid`(`data.field = "port"`);
2960
+ * `preview.allow_ports` 被 `ANYCON_*` 环境变量覆盖 → `forbidden`(`data.reason = "env_override"`)。
2961
+ * 已经在 / 本来就不在名单里是成功的空操作(不写文件、不进审计)。
2962
+ */
2963
+ export interface PreviewSetPortAllowedParams {
2964
+ allowed: boolean;
2965
+ /**
2966
+ * 用 32 位整数收:超出范围的值回 `invalid` 而不是解析失败。
2967
+ */
2968
+ port: number;
2969
+ }
2970
+ /**
2971
+ * `preview.set_port_allowed` 结果:写入之后 `preview.allow_ports` 的内容,升序。
2972
+ */
2973
+ export interface PreviewSetPortAllowedResult {
2974
+ allow_ports: number[];
2975
+ }
2672
2976
  /**
2673
2977
  * 一个项目 = 某个 workspace 根目录下的一个一级子文件夹,或一个关联的本机目录(`kind = linked`)。
2674
2978
  * 元数据全部推导;只有「关联了哪些目录」存在 daemon 的库里。
@@ -2921,8 +3225,20 @@ export interface RpcErrorData {
2921
3225
  */
2922
3226
  field?: string | null;
2923
3227
  limit?: number | null;
3228
+ /**
3229
+ * 文件恢复失败后,工作目录可能已部分恢复。
3230
+ */
3231
+ partial?: boolean | null;
2924
3232
  reason?: string | null;
2925
3233
  retry_after_ms?: number | null;
3234
+ /**
3235
+ * 文件已完整恢复,但对话回退失败时,记录成功执行的范围。
3236
+ */
3237
+ rewind_result?: SessionRewindResult | null;
3238
+ /**
3239
+ * `session.import` 接管被拒(`already_imported`)时,当前占用原生会话的会话 id。
3240
+ */
3241
+ session_id?: string | null;
2926
3242
  /**
2927
3243
  * 指向另一项清单项:`todo.repeat_now` 被拒(`reason = "previous_open"`)时,还没关闭的那一份复制出来的项的 id。
2928
3244
  */
@@ -2936,6 +3252,12 @@ export interface RpcErrorData {
2936
3252
  */
2937
3253
  used?: number | null;
2938
3254
  }
3255
+ export interface SessionRewindResult {
3256
+ conversation: boolean;
3257
+ files: boolean;
3258
+ seq: number;
3259
+ to_seq: number;
3260
+ }
2939
3261
  export interface RpcRequest {
2940
3262
  id: RpcId;
2941
3263
  jsonrpc: string;
@@ -3273,6 +3595,12 @@ export interface SessionCreateParams {
3273
3595
  * 第一条消息的客户端 id(幂等),有 `prompt` 或 `attachments` 时必填。
3274
3596
  */
3275
3597
  message_id?: string | null;
3598
+ /**
3599
+ * 发起这次创建的会话:agent 在自己的会话里建新会话时带上(`anycon new` 和 MCP `create_session` 读 `ANYCON_SESSION_ID`)。
3600
+ * 本节点有这个会话时记在新会话上(`SessionSummary::origin_session`),没有就丢掉这个字段、照常创建。
3601
+ * 只是调用方自报的归属标注,不影响新会话的行为和权限。
3602
+ */
3603
+ origin_session?: string | null;
3276
3604
  /**
3277
3605
  * 空 = scratch。
3278
3606
  */
@@ -3330,6 +3658,27 @@ export interface SessionEvent {
3330
3658
  ts_ms: number;
3331
3659
  turn_id?: number | null;
3332
3660
  }
3661
+ export interface SessionForkParams {
3662
+ attachments?: AttachmentRef[];
3663
+ /**
3664
+ * 在合并后清除指定设置,规则同 `session.set_settings`。
3665
+ */
3666
+ clear?: ClearableSetting[];
3667
+ message_id?: string | null;
3668
+ /**
3669
+ * 可选的第一条消息,语义和 `session.create` 一样。
3670
+ */
3671
+ prompt?: string | null;
3672
+ session_id: string;
3673
+ /**
3674
+ * 相对源会话设置的增量覆盖。
3675
+ */
3676
+ settings?: SessionSettings | null;
3677
+ /**
3678
+ * 缺省沿用源会话的工作位置类型。
3679
+ */
3680
+ workspace?: SessionWorkspace | null;
3681
+ }
3333
3682
  /**
3334
3683
  * 会话工作目录的 git 状态。worktree 会话相对 base;在项目目录里工作的会话没有 base 相关字段。
3335
3684
  */
@@ -3404,6 +3753,7 @@ export interface SessionHistoryParams {
3404
3753
  * 默认 200,上限 1000。
3405
3754
  */
3406
3755
  limit?: number | null;
3756
+ rewind_events?: boolean;
3407
3757
  session_id: string;
3408
3758
  }
3409
3759
  export interface SessionHistoryResult {
@@ -3413,6 +3763,37 @@ export interface SessionHistoryResult {
3413
3763
  export interface SessionIdParams {
3414
3764
  session_id: string;
3415
3765
  }
3766
+ export interface SessionImportListParams {
3767
+ agent: string;
3768
+ cursor?: string | null;
3769
+ limit?: number | null;
3770
+ project: string;
3771
+ }
3772
+ export interface SessionImportListResult {
3773
+ next_cursor?: string | null;
3774
+ sessions: NativeSession[];
3775
+ }
3776
+ export interface NativeSession {
3777
+ agent_session_id: string;
3778
+ created_ms?: number | null;
3779
+ imported_session_id?: string | null;
3780
+ preview?: string | null;
3781
+ title?: string | null;
3782
+ /**
3783
+ * 原生记录没有更新时间时为 0。
3784
+ */
3785
+ updated_ms: number;
3786
+ }
3787
+ export interface SessionImportParams {
3788
+ agent: string;
3789
+ agent_session_id: string;
3790
+ /**
3791
+ * 缺省为接管。副本在第一次发送时分叉。
3792
+ */
3793
+ copy?: boolean;
3794
+ project: string;
3795
+ settings?: SessionSettings | null;
3796
+ }
3416
3797
  export interface SessionListParams {
3417
3798
  include_archived?: boolean;
3418
3799
  limit?: number | null;
@@ -3439,11 +3820,24 @@ export interface SessionSummary {
3439
3820
  * 改它不动 `updated_at_ms`。
3440
3821
  */
3441
3822
  follow_up?: boolean;
3823
+ /**
3824
+ * 分叉时的源会话和事件水位;源会话删除后仍保留。
3825
+ */
3826
+ forked_from?: SessionForkSource | null;
3442
3827
  id: string;
3828
+ /**
3829
+ * 原生会话导入的来源;不代表当前的续接句柄。
3830
+ */
3831
+ imported_from?: SessionImportSource | null;
3443
3832
  /**
3444
3833
  * 最后一个事件的 seq;客户端据此决定要不要拉增量。
3445
3834
  */
3446
3835
  last_seq: number;
3836
+ /**
3837
+ * 创建它的会话(`SessionCreateParams::origin_session` 被记下时给出)。只在创建时写,之后不变;那个会话被删除后原样留着,
3838
+ * 客户端按没有父会话处理。分叉出来的会话不继承。
3839
+ */
3840
+ origin_session?: string | null;
3447
3841
  pending_permissions: number;
3448
3842
  /**
3449
3843
  * 最后一条消息摘要(列表展示)。
@@ -3476,6 +3870,21 @@ export interface SessionSummary {
3476
3870
  */
3477
3871
  worktree?: SessionWorktree | null;
3478
3872
  }
3873
+ /**
3874
+ * 分叉时源会话的历史边界(含 seq)。
3875
+ */
3876
+ export interface SessionForkSource {
3877
+ seq: number;
3878
+ session_id: string;
3879
+ }
3880
+ /**
3881
+ * 原生会话导入时的来源。
3882
+ */
3883
+ export interface SessionImportSource {
3884
+ agent_session_id: string;
3885
+ at_ms: number;
3886
+ copy: boolean;
3887
+ }
3479
3888
  export interface UsageTotals {
3480
3889
  cache_read_tokens: number;
3481
3890
  cache_write_tokens: number;
@@ -3526,6 +3935,24 @@ export interface SessionRenameParams {
3526
3935
  session_id: string;
3527
3936
  title: string;
3528
3937
  }
3938
+ export interface SessionRewindCheckParams {
3939
+ message_id: string;
3940
+ session_id: string;
3941
+ }
3942
+ export interface SessionRewindCheckResult {
3943
+ conversation: RewindAvailability;
3944
+ files: RewindAvailability;
3945
+ target: RewindAvailability;
3946
+ }
3947
+ export interface RewindAvailability {
3948
+ available: boolean;
3949
+ reason?: string | null;
3950
+ }
3951
+ export interface SessionRewindParams {
3952
+ message_id: string;
3953
+ scope: RewindScope;
3954
+ session_id: string;
3955
+ }
3529
3956
  export interface SessionSearchParams {
3530
3957
  /**
3531
3958
  * 最多返回几条命中,默认 20,上限 200。
@@ -3634,6 +4061,10 @@ export interface SessionSyncBaseResult {
3634
4061
  conflicts?: string[];
3635
4062
  outcome: SyncOutcome;
3636
4063
  }
4064
+ export interface SessionWatchParams {
4065
+ rewind_events?: boolean;
4066
+ session_id: string;
4067
+ }
3637
4068
  export interface Todo {
3638
4069
  /**
3639
4070
  * 派出的会话现在的情况,daemon 每次返回这一项时按会话此刻的状态算出来(docs/spec/daemon.md § 22.3):不存储、不动