@anycon/protocol 0.4.6 → 0.4.8

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.
@@ -21,7 +21,7 @@ export type ConfigEditable = "any" | "tighten_only" | "no";
21
21
  /**
22
22
  * 配置值的类型,客户端据此选控件。
23
23
  */
24
- export type ConfigValueKind = "bool" | "int" | "duration" | "enum" | "text";
24
+ export type ConfigValueKind = "bool" | "int" | "duration" | "enum" | "text" | "list";
25
25
  /**
26
26
  * 控制消息集合。方向见注释:D = 设备,H = hub。
27
27
  */
@@ -219,6 +219,16 @@ export type ErrorCode = ("exists" | "not_found" | "internal") | "invalid" | "inv
219
219
  * 会话事件。adapter 把各 agent 的原生事件翻译成这个集合(docs/spec/daemon.md § 8)。
220
220
  */
221
221
  export type Event = {
222
+ message_count: number;
223
+ message_id: string;
224
+ scope: RewindScope;
225
+ to_seq: number;
226
+ /**
227
+ * 非用户事件从开轮的序号算起,缺省沿用旧事件的 `to_seq`。
228
+ */
229
+ turn_seq?: number | null;
230
+ type: "rewind";
231
+ } | {
222
232
  attachments?: AttachmentRef[];
223
233
  by_device: string;
224
234
  content: string;
@@ -425,7 +435,10 @@ export type Event = {
425
435
  message_id: string;
426
436
  state: MessageDeliveryState;
427
437
  type: "message_delivery";
438
+ } | {
439
+ type: "unknown";
428
440
  };
441
+ export type RewindScope = "conversation" | "files" | "both" | "unknown";
429
442
  export type ToolCategory = "shell" | "file_edit" | "file_read" | "search" | "web" | "subagent" | "mcp" | "other";
430
443
  export type EditKind = "edit" | "write" | "delete" | "move";
431
444
  export type FileChangeKind = "created" | "modified" | "deleted";
@@ -476,12 +489,23 @@ export type MessageDeliveryState = "uncertain";
476
489
  */
477
490
  export type FsReadEncoding = "text" | "base64";
478
491
  /**
479
- * 信封种类。hub 对每种的处理见 docs/protocol.md § 3。
492
+ * `anthropic` 格式后端的思考深度(`effort`)。
480
493
  */
481
- export type Kind = "handshake" | "data" | "notify" | "control";
494
+ export type JudgeEffort = "low" | "medium" | "high" | "xhigh" | "max";
482
495
  export type JudgeApiFormat = "anthropic" | "openai" | "unknown";
483
496
  export type JudgeBackendKind = "api" | "agent" | "unknown";
484
497
  export type JudgeProblem = "no_key" | "agent_missing" | "agent_unsupported" | "unknown";
498
+ /**
499
+ * 信封种类。hub 对每种的处理见 docs/protocol.md § 3。
500
+ */
501
+ export type Kind = "handshake" | "data" | "notify" | "control";
502
+ /**
503
+ * 主人确认(节点口令)现在能不能用。
504
+ */
505
+ export type OwnerConfirmStatus = "ready" | "unset" | "untrusted";
506
+ export type UpdateReason = "remote_disabled" | "no_update" | "busy" | "already_rolled_back" | "unsupported_installation" | "check_failed" | "download_failed" | "provenance_failed" | "invalid_archive" | "version_probe_failed" | "install_failed" | "interrupted" | "startup_failed" | "health_timeout" | "snapshot_failed" | "restore_failed" | "unknown";
507
+ export type UpdateManagedBy = "installer" | "homebrew" | "cargo" | "dev" | "readonly" | "unmanaged" | "root" | "unsupported" | "unknown";
508
+ export type UpdatePhase = "idle" | "downloading" | "verifying" | "waiting_for_idle" | "installing" | "rolling_back" | "updated" | "rolled_back" | "failed" | "unknown";
485
509
  /**
486
510
  * 节点配置 `worktree.default` 的取值,也是 `SessionWorkspace` 的两种模式。
487
511
  */
@@ -864,11 +888,14 @@ export interface ProtocolSchema {
864
888
  job_done: JobDone;
865
889
  job_progress: JobProgress;
866
890
  job_started: JobStarted;
891
+ judge_effort: JudgeEffort;
892
+ judge_info: JudgeInfo;
867
893
  kind: Kind;
868
894
  link_block: LinkBlock;
869
895
  node_audit_params: NodeAuditParams;
870
896
  node_audit_result: NodeAuditResult;
871
897
  node_config_result: NodeConfigResult;
898
+ node_delete_judge_backend_params: NodeDeleteJudgeBackendParams;
872
899
  node_devices_result: NodeDevicesResult;
873
900
  node_doctor_result: NodeDoctorResult;
874
901
  node_enroll_approve_params: NodeEnrollApproveParams;
@@ -878,6 +905,7 @@ export interface ProtocolSchema {
878
905
  node_enroll_list_result: NodeEnrollListResult;
879
906
  node_enroll_resolved: NodeEnrollResolved;
880
907
  node_enroll_status_result: NodeEnrollStatusResult;
908
+ node_get_config_params: NodeGetConfigParams;
881
909
  node_info: NodeInfo;
882
910
  node_log_level: NodeLogLevel;
883
911
  node_logs_params: NodeLogsParams;
@@ -890,17 +918,23 @@ export interface ProtocolSchema {
890
918
  node_set_config_params: NodeSetConfigParams;
891
919
  node_set_enroll_enabled_params: NodeSetEnrollEnabledParams;
892
920
  node_set_enroll_password_params: NodeSetEnrollPasswordParams;
921
+ node_set_judge_backend_params: NodeSetJudgeBackendParams;
893
922
  node_stats: NodeStats;
894
923
  node_twin_link_code_result: NodeTwinLinkCodeResult;
924
+ node_update_changed: NodeUpdateChanged;
925
+ node_update_status: NodeUpdateStatus;
895
926
  node_worktree_settings: NodeWorktreeSettings;
896
927
  notify_body: NotifyBody;
897
928
  notify_detail: NotifyDetail;
929
+ owner_confirm: OwnerConfirm;
930
+ owner_confirm_status: OwnerConfirmStatus;
898
931
  pair_ack: PairAck;
899
932
  permission_list_params: PermissionListParams;
900
933
  permission_list_result: PermissionListResult;
901
934
  permission_request: PermissionRequest;
902
935
  permission_resolved: PermissionResolved;
903
936
  permission_respond_params: PermissionRespondParams;
937
+ preview_blocked_port: PreviewBlockedPort;
904
938
  preview_body_encoding: PreviewBodyEncoding;
905
939
  preview_close_params: PreviewCloseParams;
906
940
  preview_detection: PreviewDetection;
@@ -921,6 +955,8 @@ export interface ProtocolSchema {
921
955
  preview_reset: PreviewReset;
922
956
  preview_reset_code: PreviewResetCode;
923
957
  preview_response_head: PreviewResponseHead;
958
+ preview_set_port_allowed_params: PreviewSetPortAllowedParams;
959
+ preview_set_port_allowed_result: PreviewSetPortAllowedResult;
924
960
  project: Project;
925
961
  project_kind: ProjectKind;
926
962
  prompt_segment: PromptSegment;
@@ -975,16 +1011,25 @@ export interface ProtocolSchema {
975
1011
  session_diff_params: SessionDiffParams;
976
1012
  session_diff_result: SessionDiffResult;
977
1013
  session_event: SessionEvent;
1014
+ session_fork_params: SessionForkParams;
978
1015
  session_git_status: SessionGitStatus;
979
1016
  session_git_status_params: SessionGitStatusParams;
980
1017
  session_history_params: SessionHistoryParams;
981
1018
  session_history_result: SessionHistoryResult;
982
1019
  session_id_params: SessionIdParams;
1020
+ session_import_list_params: SessionImportListParams;
1021
+ session_import_list_result: SessionImportListResult;
1022
+ session_import_params: SessionImportParams;
983
1023
  session_list_params: SessionListParams;
984
1024
  session_list_result: SessionListResult;
985
1025
  session_mark_read_params: SessionMarkReadParams;
986
1026
  session_promote_params: SessionPromoteParams;
1027
+ session_read_file_params: SessionReadFileParams;
987
1028
  session_rename_params: SessionRenameParams;
1029
+ session_rewind_check_params: SessionRewindCheckParams;
1030
+ session_rewind_check_result: SessionRewindCheckResult;
1031
+ session_rewind_params: SessionRewindParams;
1032
+ session_rewind_result: SessionRewindResult;
988
1033
  session_search_params: SessionSearchParams;
989
1034
  session_search_result: SessionSearchResult;
990
1035
  session_send_params: SessionSendParams;
@@ -996,6 +1041,7 @@ export interface ProtocolSchema {
996
1041
  session_summary: SessionSummary;
997
1042
  session_sync_base_params: SessionSyncBaseParams;
998
1043
  session_sync_base_result: SessionSyncBaseResult;
1044
+ session_watch_params: SessionWatchParams;
999
1045
  session_workspace: SessionWorkspace;
1000
1046
  session_workspace_mode: SessionWorkspaceMode;
1001
1047
  session_worktree: SessionWorktree;
@@ -1125,6 +1171,14 @@ export interface AgentCapabilities {
1125
1171
  * 支持每会话 env。
1126
1172
  */
1127
1173
  env: boolean;
1174
+ /**
1175
+ * 支持以已有 agent 会话为起点分叉。
1176
+ */
1177
+ fork?: boolean;
1178
+ /**
1179
+ * 可以发现本机原生会话并续接。
1180
+ */
1181
+ import?: boolean;
1128
1182
  /**
1129
1183
  * turn 进行中能否插话。
1130
1184
  */
@@ -1139,7 +1193,14 @@ export interface AgentCapabilities {
1139
1193
  * 进程退出后能否续接。
1140
1194
  */
1141
1195
  resume: boolean;
1196
+ /**
1197
+ * 支持回退原生对话。
1198
+ */
1142
1199
  rewind: boolean;
1200
+ /**
1201
+ * 支持恢复原生文件检查点。
1202
+ */
1203
+ rewind_files?: boolean;
1143
1204
  structured_output: boolean;
1144
1205
  /**
1145
1206
  * 会话的 `system_prompt_append` 真的会交给 agent(docs/spec/daemon.md § 6.3)。为 false(通用 ACP agent、旧 daemon)时,
@@ -1394,7 +1455,7 @@ export interface ConfigItem {
1394
1455
  key: string;
1395
1456
  kind: ConfigValueKind;
1396
1457
  /**
1397
- * 取值上限:`int` 是数值,`duration` 是毫秒,`text` 是字符数。
1458
+ * 取值上限:`int` 是数值,`duration` 是毫秒,`text` 是字符数,`list` 是条目数。
1398
1459
  */
1399
1460
  max?: number | null;
1400
1461
  /**
@@ -1494,6 +1555,11 @@ export interface EnrollPasswordStatus {
1494
1555
  */
1495
1556
  set_by?: string | null;
1496
1557
  state: EnrollPasswordState;
1558
+ /**
1559
+ * 口令是在节点本机设的(`anycon passwd`),所以可以当主人确认(`node.set_config` 的放宽类改动)。
1560
+ * 远程设的口令是 `false`;没有口令、旧 daemon 也读作 `false`。
1561
+ */
1562
+ trusted?: boolean;
1497
1563
  }
1498
1564
  /**
1499
1565
  * 按 category 归一化的渲染字段。全部可选;`input` 仍原样保留。
@@ -1800,6 +1866,38 @@ export interface JobProgress {
1800
1866
  export interface JobStarted {
1801
1867
  job_id: string;
1802
1868
  }
1869
+ export interface JudgeInfo {
1870
+ advisor?: string | null;
1871
+ backends: JudgeBackendInfo[];
1872
+ daily_calls: number;
1873
+ extract?: string | null;
1874
+ triage?: string | null;
1875
+ }
1876
+ export interface JudgeBackendInfo {
1877
+ agent?: string | null;
1878
+ /**
1879
+ * 生效的思考深度;只有 `anthropic` 格式且设了才给。
1880
+ */
1881
+ effort?: JudgeEffort | null;
1882
+ format?: JudgeApiFormat | null;
1883
+ kind: JudgeBackendKind;
1884
+ /**
1885
+ * 生效的输出 token 上限;只有 `api` 后端给。
1886
+ */
1887
+ max_output_tokens?: number | null;
1888
+ model?: string | null;
1889
+ name: string;
1890
+ problem?: JudgeProblem | null;
1891
+ /**
1892
+ * 可以用 `node.set_judge_backend` / `node.delete_judge_backend` 远程改 / 删。用环境变量里的密钥(`api_key_env`)
1893
+ * 或回环 `http` 地址的后端是在机器上定义的,只能在机器上改,这里是 `false`。旧 daemon 不给,读作 `false`。
1894
+ */
1895
+ remote_editable?: boolean;
1896
+ /**
1897
+ * 生效的单次调用时限(毫秒),含缺省值。旧 daemon 不给。
1898
+ */
1899
+ timeout_ms?: number | null;
1900
+ }
1803
1901
  export interface NodeAuditParams {
1804
1902
  device_id?: string | null;
1805
1903
  limit?: number | null;
@@ -1821,6 +1919,26 @@ export interface AuditEntry {
1821
1919
  */
1822
1920
  export interface NodeConfigResult {
1823
1921
  items: ConfigItem[];
1922
+ /**
1923
+ * 主人确认的状态;旧 daemon 不给 = 不支持(放宽类的改动只能在机器上做)。
1924
+ */
1925
+ owner_confirm?: OwnerConfirm | null;
1926
+ }
1927
+ /**
1928
+ * 节点的主人确认状态(`node.get_config` / `node.set_config` 的结果里)。旧 daemon 没有这个字段 = 不支持主人确认。
1929
+ */
1930
+ export interface OwnerConfirm {
1931
+ /**
1932
+ * `status = ready` 且连续输错太多次时:还要等多久才接受下一次确认。
1933
+ */
1934
+ retry_after_ms?: number | null;
1935
+ status: OwnerConfirmStatus;
1936
+ }
1937
+ /**
1938
+ * `node.delete_judge_backend` 参数。名字不存在 → `not_found`;是在机器上定义的后端 → `forbidden`(`data.reason = "local_backend"`)。
1939
+ */
1940
+ export interface NodeDeleteJudgeBackendParams {
1941
+ name: string;
1824
1942
  }
1825
1943
  export interface NodeDevicesResult {
1826
1944
  devices: PeerDevice[];
@@ -1906,6 +2024,16 @@ export interface NodeEnrollStatusResult {
1906
2024
  approval: boolean;
1907
2025
  password: EnrollPasswordStatus;
1908
2026
  }
2027
+ /**
2028
+ * `node.get_config` 参数。整个参数对象可以省略(等于全部缺省)。
2029
+ */
2030
+ export interface NodeGetConfigParams {
2031
+ /**
2032
+ * 返回全部项。缺省 `false`:只返回已发布的客户端认识的项,也就是去掉 `kind = list` 的项和非开关(`kind` 不是 `bool`)的
2033
+ * `tighten_only` 项——旧客户端不认识 `list`,并且把 `tighten_only` 一律当成「只能关掉的开关」。
2034
+ */
2035
+ extended?: boolean;
2036
+ }
1909
2037
  /**
1910
2038
  * `node.info` 结果。
1911
2039
  */
@@ -1932,6 +2060,10 @@ export interface NodeInfo {
1932
2060
  * `[twin] accept_links`:这个节点现在接受别的节点的 Twin 连接(docs/spec/daemon.md § 27.2)。旧 daemon 没有这个字段,读作 `false`。
1933
2061
  */
1934
2062
  twin_accept_links?: boolean;
2063
+ /**
2064
+ * 当前机器的更新开关、安装方式和最近一次安装的状态。
2065
+ */
2066
+ update?: NodeUpdateStatus | null;
1935
2067
  /**
1936
2068
  * 更新检查(ADR-57)知道有比这个 daemon 更新的正式版本时给出;没有更新的版本、检查关着、还没检查成功过,
1937
2069
  * 以及旧 daemon,都不给。
@@ -1977,6 +2109,11 @@ export interface NodeCapabilities {
1977
2109
  */
1978
2110
  file_attachments?: boolean;
1979
2111
  fs: boolean;
2112
+ /**
2113
+ * 支持 `node.set_judge_backend` / `node.delete_judge_backend`,`node.info.judge.backends[]` 带 `remote_editable`。
2114
+ * 旧 daemon 没有这个字段,读作 false。
2115
+ */
2116
+ judge_backends?: boolean;
1980
2117
  /**
1981
2118
  * 支持 dev server 预览(`preview.*`,ADR-39),且节点配置 `preview.enabled = true`。
1982
2119
  */
@@ -1985,6 +2122,10 @@ export interface NodeCapabilities {
1985
2122
  * 支持目录预览(`preview.open { dir }`,ADR-62),且节点开着预览。旧 daemon 没有这个字段,读作 false。
1986
2123
  */
1987
2124
  preview_dir?: boolean;
2125
+ /**
2126
+ * 支持 `preview.set_port_allowed`,`preview.ports` 认 `include_blocked`。旧 daemon 没有这个字段,读作 false。
2127
+ */
2128
+ preview_ports_admin?: boolean;
1988
2129
  /**
1989
2130
  * 支持规则提炼 RPC;没有该字段时按不支持处理。
1990
2131
  */
@@ -1994,6 +2135,22 @@ export interface NodeCapabilities {
1994
2135
  */
1995
2136
  rules?: boolean;
1996
2137
  search: boolean;
2138
+ /**
2139
+ * 支持 `session.fork`。
2140
+ */
2141
+ session_fork?: boolean;
2142
+ /**
2143
+ * 支持 `session.import_list` 和 `session.import`。
2144
+ */
2145
+ session_import?: boolean;
2146
+ /**
2147
+ * 支持 `session.read_file`(读会话里「读文件」调用读的图片 / 文本,docs/protocol.md § 5.4)。旧 daemon 没有这个字段,读作 false。
2148
+ */
2149
+ session_read_file?: boolean;
2150
+ /**
2151
+ * 支持 session.rewind 和 session.rewind_check。
2152
+ */
2153
+ session_rewind?: boolean;
1997
2154
  /**
1998
2155
  * 支持清单(`todo.*`,docs/spec/daemon.md § 21)。旧 daemon 没有这个字段,读作 false。
1999
2156
  */
@@ -2021,6 +2178,10 @@ export interface NodeCapabilities {
2021
2178
  * (docs/spec/daemon.md § 26.8)。旧 daemon 没有这个字段,读作 false。
2022
2179
  */
2023
2180
  twin_stats?: boolean;
2181
+ /**
2182
+ * 支持更新状态和 `node.update`。安装方式和机器级开关见 `node.info.update`。
2183
+ */
2184
+ update?: boolean;
2024
2185
  /**
2025
2186
  * 有 workspace(文件夹即项目)。SDK 节点可能没有。
2026
2187
  */
@@ -2030,20 +2191,18 @@ export interface NodeCapabilities {
2030
2191
  */
2031
2192
  worktree?: boolean;
2032
2193
  }
2033
- export interface JudgeInfo {
2034
- advisor?: string | null;
2035
- backends: JudgeBackendInfo[];
2036
- daily_calls: number;
2037
- extract?: string | null;
2038
- triage?: string | null;
2194
+ export interface NodeUpdateStatus {
2195
+ auto: boolean;
2196
+ last_rollback?: UpdateRollback | null;
2197
+ managed_by: UpdateManagedBy;
2198
+ phase: UpdatePhase;
2199
+ reason?: UpdateReason | null;
2200
+ remote: boolean;
2201
+ version?: string | null;
2039
2202
  }
2040
- export interface JudgeBackendInfo {
2041
- agent?: string | null;
2042
- format?: JudgeApiFormat | null;
2043
- kind: JudgeBackendKind;
2044
- model?: string | null;
2045
- name: string;
2046
- problem?: JudgeProblem | null;
2203
+ export interface UpdateRollback {
2204
+ reason: UpdateReason;
2205
+ version: string;
2047
2206
  }
2048
2207
  /**
2049
2208
  * 有更新的版本(`node.info.update_available`)。daemon 只在 `latest` 是严格的 `X.Y.Z` 且比自己的版本新时给出;
@@ -2184,11 +2343,23 @@ export interface NodeSetAgentDefaultsParams {
2184
2343
  /**
2185
2344
  * `node.set_config` 参数。所有改动先校验,任何一项不合法就一项都不写。
2186
2345
  *
2187
- * 错误:键不在白名单、被环境变量覆盖、想放宽只能收紧的键 → `forbidden`(`data.field` 是键,`data.reason` 是
2188
- * `not_editable` / `env_override` / `tighten_only`);值的类型或取值不合法、键重复、`changes` 为空 → `invalid`(`data.field` 是键)。
2346
+ * 错误:
2347
+ * - 键不在白名单、被环境变量覆盖 → `forbidden`(`data.field` 是键,`data.reason` 是 `not_editable` / `env_override`);
2348
+ * - 值的类型或取值不合法、键重复、`changes` 为空 → `invalid`(`data.field` 是键);
2349
+ * - 有放宽类的改动(`TightenOnly` 的键往宽松方向改)而主人确认没通过 → `forbidden`,`data.field` 是第一个放宽的键,
2350
+ * `data.reason` 是 `owner_required`(没带 `password`)/ `owner_password_unset`(节点没有口令)/ `owner_password_untrusted`
2351
+ * (口令是远程设的)/ `owner_backoff`(连续输错太多次,`data.retry_after_ms` 是还要等多久)/ `owner_wrong_password`。
2189
2352
  */
2190
2353
  export interface NodeSetConfigParams {
2191
2354
  changes: ConfigChange[];
2355
+ /**
2356
+ * 返回的 `items` 是否包含全部项(同 [`NodeGetConfigParams::extended`])。写白名单里的键不受这个标志限制。
2357
+ */
2358
+ extended?: boolean;
2359
+ /**
2360
+ * 节点口令,主人确认用。只有放宽类的改动才会校验;没有放宽类的改动时忽略。
2361
+ */
2362
+ password?: string | null;
2192
2363
  }
2193
2364
  /**
2194
2365
  * `node.set_enroll_enabled` 参数:写 `[enroll]` 配置。`password: true` 同时解除锁定、失败计数清零。
@@ -2199,9 +2370,70 @@ export interface NodeSetEnrollEnabledParams {
2199
2370
  }
2200
2371
  /**
2201
2372
  * `node.set_enroll_password` 参数。`password` 省略 = 清除。至少 8 个字符(按 Unicode 字符计,NFC 之后)。
2373
+ *
2374
+ * 经 hub 来的设备(远程):节点已经有口令时,改 / 清除要带 `current_password`,缺 → `forbidden`
2375
+ * (`data.reason = "current_password_required"`),错 → `forbidden`(`owner_wrong_password`),连续错太多次 → `forbidden`
2376
+ * (`owner_backoff`,`data.retry_after_ms`)。节点还没有口令时远程可以直接设(设出来的口令 `trusted = false`)。
2377
+ * 本机 socket 上的调用方(`anycon passwd`)不需要 `current_password`,设出来的口令 `trusted = true`。
2202
2378
  */
2203
2379
  export interface NodeSetEnrollPasswordParams {
2380
+ /**
2381
+ * 现在的节点口令(远程改 / 清除时必填)。
2382
+ */
2383
+ current_password?: string | null;
2384
+ password?: string | null;
2385
+ }
2386
+ /**
2387
+ * `node.set_judge_backend` 参数:新建或整体替换 `[judge.backends.<name>]`,字段和 `config.toml` 里的一一对应。
2388
+ * 刻意没有 `api_key_env`:远程调用方可以把 `base_url` 指向自己的服务器、再指定本机任意环境变量,daemon 就会把它发出去。
2389
+ *
2390
+ * - `kind = agent`:`agent` 必填(本节点配置里有的 agent id),`model` / `timeout` 可选;带了 api 专用的字段 → `invalid`。不需要主人确认。
2391
+ * - `kind = api`:`format`、`model` 必填;`base_url` 可选(缺省按格式),必须是 `https`;`max_output_tokens` / `effort` / `timeout` 可选。
2392
+ * `api_key` 新建时必填;替换已有的 api 后端时可以省略以沿用已存的密钥,但只有 `format` 和生效的 `base_url` 都没变才行,
2393
+ * 否则 `invalid`(`data.field = "api_key"`,`data.reason = "key_required"`)。必须带 `password` 做主人确认。
2394
+ *
2395
+ * 错误:
2396
+ * - `invalid`:参数不合法(`data.field` 是字段名);`name` 不合法、后端已满 20 个;
2397
+ * - `forbidden`:`data.reason = "local_backend"`(已有的同名后端是在机器上定义的)、`env_override`(`judge.backends` 被 `ANYCON_*` 覆盖);
2398
+ * 主人确认没通过时 `data.field = "password"`,`data.reason` 同 `node.set_config`(`owner_required` / `owner_password_unset` /
2399
+ * `owner_password_untrusted` / `owner_backoff`(带 `data.retry_after_ms`)/ `owner_wrong_password`)。
2400
+ */
2401
+ export interface NodeSetJudgeBackendParams {
2402
+ /**
2403
+ * `kind = agent`:agent id。
2404
+ */
2405
+ agent?: string | null;
2406
+ /**
2407
+ * `kind = api`:密钥。只写不读:任何结果、日志、审计、错误里都没有它。
2408
+ */
2409
+ api_key?: string | null;
2410
+ /**
2411
+ * `kind = api`:服务地址,必须是 `https`;缺省按格式。
2412
+ */
2413
+ base_url?: string | null;
2414
+ /**
2415
+ * 只有 `format = anthropic` 能设。
2416
+ */
2417
+ effort?: JudgeEffort | null;
2418
+ /**
2419
+ * `kind = api`:回应格式。
2420
+ */
2421
+ format?: JudgeApiFormat | null;
2422
+ kind: JudgeBackendKind;
2423
+ max_output_tokens?: number | null;
2424
+ model?: string | null;
2425
+ /**
2426
+ * 1–40 个字符,`[A-Za-z0-9_-]`。
2427
+ */
2428
+ name: string;
2429
+ /**
2430
+ * 节点口令,`kind = api` 时的主人确认。
2431
+ */
2204
2432
  password?: string | null;
2433
+ /**
2434
+ * 时限,如 `"2m"`(10s–60m)。
2435
+ */
2436
+ timeout?: string | null;
2205
2437
  }
2206
2438
  export interface NodeStats {
2207
2439
  agent_processes: number;
@@ -2233,6 +2465,13 @@ export interface NodeTwinLinkCodeResult {
2233
2465
  */
2234
2466
  expires_ms: number;
2235
2467
  }
2468
+ /**
2469
+ * 更新状态变化时发送。字段缺省表示对应的 `node.info` 中也没有已知更新。
2470
+ */
2471
+ export interface NodeUpdateChanged {
2472
+ update: NodeUpdateStatus;
2473
+ update_available?: NodeUpdateAvailable | null;
2474
+ }
2236
2475
  /**
2237
2476
  * `kind = notify` 的 body(msgpack)。`category` 是外层唯一有语义的明文字段。
2238
2477
  */
@@ -2314,6 +2553,17 @@ export interface PermissionRespondParams {
2314
2553
  option_id?: string | null;
2315
2554
  request_id: string;
2316
2555
  }
2556
+ /**
2557
+ * `preview.ports.blocked` 的一项。
2558
+ */
2559
+ export interface PreviewBlockedPort {
2560
+ pid?: number | null;
2561
+ port: number;
2562
+ /**
2563
+ * 进程名(可执行文件名,不含参数)。
2564
+ */
2565
+ process?: string | null;
2566
+ }
2317
2567
  /**
2318
2568
  * `preview.close` 参数:作废这个 label 的全部票据,断开它的全部隧道。
2319
2569
  */
@@ -2473,9 +2723,19 @@ export interface PreviewPort {
2473
2723
  * `preview.ports` 参数。带 `session_id` 只列这个会话的端口(外加配置里允许的端口)。
2474
2724
  */
2475
2725
  export interface PreviewPortsParams {
2726
+ /**
2727
+ * 同时列出现在不能预览的本机监听端口(结果的 `blocked`)。带 `session_id` 时忽略。
2728
+ */
2729
+ include_blocked?: boolean;
2476
2730
  session_id?: string | null;
2477
2731
  }
2478
2732
  export interface PreviewPortsResult {
2733
+ /**
2734
+ * 请求带了 `include_blocked` 时给出:绑在回环 / 通配地址上、按端口策略现在不能预览的监听端口(含混合归属的端口),
2735
+ * 按端口排序,最多 200 个;探测不可用时是空数组。不带 `include_blocked` 时没有这个字段。
2736
+ * 用 `preview.set_port_allowed` 把其中的端口加进 `preview.allow_ports`。
2737
+ */
2738
+ blocked?: PreviewBlockedPort[] | null;
2479
2739
  detection: PreviewDetection;
2480
2740
  ports: PreviewPort[];
2481
2741
  }
@@ -2514,6 +2774,25 @@ export interface PreviewResponseHead {
2514
2774
  headers: [string, string][];
2515
2775
  status: number;
2516
2776
  }
2777
+ /**
2778
+ * `preview.set_port_allowed` 参数:把 `port` 加进(`allowed = true`)/ 移出 `preview.allow_ports`。
2779
+ * 端口不在 1–65535、是本机 hub 的端口、加进去会超过 64 个 → `invalid`(`data.field = "port"`);
2780
+ * `preview.allow_ports` 被 `ANYCON_*` 环境变量覆盖 → `forbidden`(`data.reason = "env_override"`)。
2781
+ * 已经在 / 本来就不在名单里是成功的空操作(不写文件、不进审计)。
2782
+ */
2783
+ export interface PreviewSetPortAllowedParams {
2784
+ allowed: boolean;
2785
+ /**
2786
+ * 用 32 位整数收:超出范围的值回 `invalid` 而不是解析失败。
2787
+ */
2788
+ port: number;
2789
+ }
2790
+ /**
2791
+ * `preview.set_port_allowed` 结果:写入之后 `preview.allow_ports` 的内容,升序。
2792
+ */
2793
+ export interface PreviewSetPortAllowedResult {
2794
+ allow_ports: number[];
2795
+ }
2517
2796
  /**
2518
2797
  * 一个项目 = 某个 workspace 根目录下的一个一级子文件夹,或一个关联的本机目录(`kind = linked`)。
2519
2798
  * 元数据全部推导;只有「关联了哪些目录」存在 daemon 的库里。
@@ -2766,8 +3045,20 @@ export interface RpcErrorData {
2766
3045
  */
2767
3046
  field?: string | null;
2768
3047
  limit?: number | null;
3048
+ /**
3049
+ * 文件恢复失败后,工作目录可能已部分恢复。
3050
+ */
3051
+ partial?: boolean | null;
2769
3052
  reason?: string | null;
2770
3053
  retry_after_ms?: number | null;
3054
+ /**
3055
+ * 文件已完整恢复,但对话回退失败时,记录成功执行的范围。
3056
+ */
3057
+ rewind_result?: SessionRewindResult | null;
3058
+ /**
3059
+ * `session.import` 接管被拒(`already_imported`)时,当前占用原生会话的会话 id。
3060
+ */
3061
+ session_id?: string | null;
2771
3062
  /**
2772
3063
  * 指向另一项清单项:`todo.repeat_now` 被拒(`reason = "previous_open"`)时,还没关闭的那一份复制出来的项的 id。
2773
3064
  */
@@ -2781,6 +3072,12 @@ export interface RpcErrorData {
2781
3072
  */
2782
3073
  used?: number | null;
2783
3074
  }
3075
+ export interface SessionRewindResult {
3076
+ conversation: boolean;
3077
+ files: boolean;
3078
+ seq: number;
3079
+ to_seq: number;
3080
+ }
2784
3081
  export interface RpcRequest {
2785
3082
  id: RpcId;
2786
3083
  jsonrpc: string;
@@ -3118,6 +3415,12 @@ export interface SessionCreateParams {
3118
3415
  * 第一条消息的客户端 id(幂等),有 `prompt` 或 `attachments` 时必填。
3119
3416
  */
3120
3417
  message_id?: string | null;
3418
+ /**
3419
+ * 发起这次创建的会话:agent 在自己的会话里建新会话时带上(`anycon new` 和 MCP `create_session` 读 `ANYCON_SESSION_ID`)。
3420
+ * 本节点有这个会话时记在新会话上(`SessionSummary::origin_session`),没有就丢掉这个字段、照常创建。
3421
+ * 只是调用方自报的归属标注,不影响新会话的行为和权限。
3422
+ */
3423
+ origin_session?: string | null;
3121
3424
  /**
3122
3425
  * 空 = scratch。
3123
3426
  */
@@ -3175,6 +3478,27 @@ export interface SessionEvent {
3175
3478
  ts_ms: number;
3176
3479
  turn_id?: number | null;
3177
3480
  }
3481
+ export interface SessionForkParams {
3482
+ attachments?: AttachmentRef[];
3483
+ /**
3484
+ * 在合并后清除指定设置,规则同 `session.set_settings`。
3485
+ */
3486
+ clear?: ClearableSetting[];
3487
+ message_id?: string | null;
3488
+ /**
3489
+ * 可选的第一条消息,语义和 `session.create` 一样。
3490
+ */
3491
+ prompt?: string | null;
3492
+ session_id: string;
3493
+ /**
3494
+ * 相对源会话设置的增量覆盖。
3495
+ */
3496
+ settings?: SessionSettings | null;
3497
+ /**
3498
+ * 缺省沿用源会话的工作位置类型。
3499
+ */
3500
+ workspace?: SessionWorkspace | null;
3501
+ }
3178
3502
  /**
3179
3503
  * 会话工作目录的 git 状态。worktree 会话相对 base;在项目目录里工作的会话没有 base 相关字段。
3180
3504
  */
@@ -3249,6 +3573,7 @@ export interface SessionHistoryParams {
3249
3573
  * 默认 200,上限 1000。
3250
3574
  */
3251
3575
  limit?: number | null;
3576
+ rewind_events?: boolean;
3252
3577
  session_id: string;
3253
3578
  }
3254
3579
  export interface SessionHistoryResult {
@@ -3258,6 +3583,37 @@ export interface SessionHistoryResult {
3258
3583
  export interface SessionIdParams {
3259
3584
  session_id: string;
3260
3585
  }
3586
+ export interface SessionImportListParams {
3587
+ agent: string;
3588
+ cursor?: string | null;
3589
+ limit?: number | null;
3590
+ project: string;
3591
+ }
3592
+ export interface SessionImportListResult {
3593
+ next_cursor?: string | null;
3594
+ sessions: NativeSession[];
3595
+ }
3596
+ export interface NativeSession {
3597
+ agent_session_id: string;
3598
+ created_ms?: number | null;
3599
+ imported_session_id?: string | null;
3600
+ preview?: string | null;
3601
+ title?: string | null;
3602
+ /**
3603
+ * 原生记录没有更新时间时为 0。
3604
+ */
3605
+ updated_ms: number;
3606
+ }
3607
+ export interface SessionImportParams {
3608
+ agent: string;
3609
+ agent_session_id: string;
3610
+ /**
3611
+ * 缺省为接管。副本在第一次发送时分叉。
3612
+ */
3613
+ copy?: boolean;
3614
+ project: string;
3615
+ settings?: SessionSettings | null;
3616
+ }
3261
3617
  export interface SessionListParams {
3262
3618
  include_archived?: boolean;
3263
3619
  limit?: number | null;
@@ -3284,11 +3640,24 @@ export interface SessionSummary {
3284
3640
  * 改它不动 `updated_at_ms`。
3285
3641
  */
3286
3642
  follow_up?: boolean;
3643
+ /**
3644
+ * 分叉时的源会话和事件水位;源会话删除后仍保留。
3645
+ */
3646
+ forked_from?: SessionForkSource | null;
3287
3647
  id: string;
3648
+ /**
3649
+ * 原生会话导入的来源;不代表当前的续接句柄。
3650
+ */
3651
+ imported_from?: SessionImportSource | null;
3288
3652
  /**
3289
3653
  * 最后一个事件的 seq;客户端据此决定要不要拉增量。
3290
3654
  */
3291
3655
  last_seq: number;
3656
+ /**
3657
+ * 创建它的会话(`SessionCreateParams::origin_session` 被记下时给出)。只在创建时写,之后不变;那个会话被删除后原样留着,
3658
+ * 客户端按没有父会话处理。分叉出来的会话不继承。
3659
+ */
3660
+ origin_session?: string | null;
3292
3661
  pending_permissions: number;
3293
3662
  /**
3294
3663
  * 最后一条消息摘要(列表展示)。
@@ -3321,6 +3690,21 @@ export interface SessionSummary {
3321
3690
  */
3322
3691
  worktree?: SessionWorktree | null;
3323
3692
  }
3693
+ /**
3694
+ * 分叉时源会话的历史边界(含 seq)。
3695
+ */
3696
+ export interface SessionForkSource {
3697
+ seq: number;
3698
+ session_id: string;
3699
+ }
3700
+ /**
3701
+ * 原生会话导入时的来源。
3702
+ */
3703
+ export interface SessionImportSource {
3704
+ agent_session_id: string;
3705
+ at_ms: number;
3706
+ copy: boolean;
3707
+ }
3324
3708
  export interface UsageTotals {
3325
3709
  cache_read_tokens: number;
3326
3710
  cache_write_tokens: number;
@@ -3343,10 +3727,52 @@ export interface SessionPromoteParams {
3343
3727
  name: string;
3344
3728
  session_id: string;
3345
3729
  }
3730
+ /**
3731
+ * `session.read_file`:读会话里一次「读文件」调用(`tool_call.category = file_read`)读的那个文件,给 Web 在调用那一行下面显示。
3732
+ * 客户端只给调用的 id,路径由 daemon 从自己存的事件里取;只认已经成功结束的调用,只回图片和文本
3733
+ * (docs/spec/daemon.md § 16)。结果是 [`crate::FsReadResult`],两种 `encoding` 的语义和 `fs.read` 一样。
3734
+ */
3735
+ export interface SessionReadFileParams {
3736
+ /**
3737
+ * 缺省 `text`。`base64` 只给图片(PNG / JPEG / GIF / WebP,按文件头判断),别的文件是 `invalid`(`data.reason = "unsupported_type"`)。
3738
+ */
3739
+ encoding?: FsReadEncoding & string;
3740
+ /**
3741
+ * 同 `FsReadParams.max_bytes`。
3742
+ */
3743
+ max_bytes?: number | null;
3744
+ /**
3745
+ * 同 `FsReadParams.offset`:只有 `encoding = base64` 能用。
3746
+ */
3747
+ offset?: number;
3748
+ session_id: string;
3749
+ /**
3750
+ * `tool_call.id`。
3751
+ */
3752
+ tool_call_id: string;
3753
+ }
3346
3754
  export interface SessionRenameParams {
3347
3755
  session_id: string;
3348
3756
  title: string;
3349
3757
  }
3758
+ export interface SessionRewindCheckParams {
3759
+ message_id: string;
3760
+ session_id: string;
3761
+ }
3762
+ export interface SessionRewindCheckResult {
3763
+ conversation: RewindAvailability;
3764
+ files: RewindAvailability;
3765
+ target: RewindAvailability;
3766
+ }
3767
+ export interface RewindAvailability {
3768
+ available: boolean;
3769
+ reason?: string | null;
3770
+ }
3771
+ export interface SessionRewindParams {
3772
+ message_id: string;
3773
+ scope: RewindScope;
3774
+ session_id: string;
3775
+ }
3350
3776
  export interface SessionSearchParams {
3351
3777
  /**
3352
3778
  * 最多返回几条命中,默认 20,上限 200。
@@ -3455,6 +3881,10 @@ export interface SessionSyncBaseResult {
3455
3881
  conflicts?: string[];
3456
3882
  outcome: SyncOutcome;
3457
3883
  }
3884
+ export interface SessionWatchParams {
3885
+ rewind_events?: boolean;
3886
+ session_id: string;
3887
+ }
3458
3888
  export interface Todo {
3459
3889
  /**
3460
3890
  * 派出的会话现在的情况,daemon 每次返回这一项时按会话此刻的状态算出来(docs/spec/daemon.md § 22.3):不存储、不动