@anycon/protocol 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +14 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +15 -0
- package/dist/constants.js.map +1 -1
- package/dist/crypto.d.ts +10 -1
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +1 -0
- package/dist/crypto.js.map +1 -1
- package/dist/envelope.d.ts.map +1 -1
- package/dist/envelope.js +5 -3
- package/dist/envelope.js.map +1 -1
- package/dist/generated.d.ts +658 -13
- package/dist/generated.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/method-types.d.ts +29 -1
- package/dist/method-types.d.ts.map +1 -1
- package/dist/preview.d.ts +173 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +554 -0
- package/dist/preview.js.map +1 -0
- package/package.json +2 -2
- package/src/constants.ts +16 -0
- package/src/crypto.ts +16 -4
- package/src/envelope.ts +5 -3
- package/src/generated.ts +664 -13
- package/src/index.ts +2 -0
- package/src/method-types.ts +17 -0
- package/src/preview.ts +625 -0
- package/wasm/THIRD-PARTY-LICENSES.txt +4 -3
- package/wasm/anycon_crypto.d.ts +6 -0
- package/wasm/anycon_crypto.js +29 -0
- package/wasm/anycon_crypto_bg.wasm +0 -0
- package/wasm/anycon_crypto_bg.wasm.d.ts +1 -0
package/src/generated.ts
CHANGED
|
@@ -10,6 +10,14 @@ export type AgentStatus =
|
|
|
10
10
|
*/
|
|
11
11
|
export type LinkBlock = "hidden" | "sensitive" | "workspace" | "data_dir" | "filesystem_root";
|
|
12
12
|
export type DeviceKind = "daemon" | "web" | "cli" | "sdk";
|
|
13
|
+
/**
|
|
14
|
+
* 一项配置能不能被远程客户端改(ADR-43)。
|
|
15
|
+
*/
|
|
16
|
+
export type ConfigEditable = "any" | "tighten_only" | "no";
|
|
17
|
+
/**
|
|
18
|
+
* 配置值的类型,客户端据此选控件。
|
|
19
|
+
*/
|
|
20
|
+
export type ConfigValueKind = "bool" | "int" | "duration" | "enum" | "text";
|
|
13
21
|
/**
|
|
14
22
|
* 控制消息集合。方向见注释:D = 设备,H = hub。
|
|
15
23
|
*/
|
|
@@ -17,6 +25,7 @@ export type Control =
|
|
|
17
25
|
| {
|
|
18
26
|
client: ClientInfo;
|
|
19
27
|
device_token?: string | null;
|
|
28
|
+
preview_token?: string | null;
|
|
20
29
|
protocol_version: number;
|
|
21
30
|
type: "auth";
|
|
22
31
|
}
|
|
@@ -102,6 +111,11 @@ export type Control =
|
|
|
102
111
|
device: string;
|
|
103
112
|
type: "peer_offline";
|
|
104
113
|
}
|
|
114
|
+
| {
|
|
115
|
+
label: string;
|
|
116
|
+
peer: string;
|
|
117
|
+
type: "preview_peer";
|
|
118
|
+
}
|
|
105
119
|
| {
|
|
106
120
|
seq: number;
|
|
107
121
|
to: string;
|
|
@@ -128,6 +142,7 @@ export type Control =
|
|
|
128
142
|
}
|
|
129
143
|
| {
|
|
130
144
|
retry_after_ms: number;
|
|
145
|
+
to?: string | null;
|
|
131
146
|
type: "rate_limited";
|
|
132
147
|
}
|
|
133
148
|
| {
|
|
@@ -286,6 +301,11 @@ export type Event =
|
|
|
286
301
|
id: string;
|
|
287
302
|
input?: unknown;
|
|
288
303
|
name: string;
|
|
304
|
+
/**
|
|
305
|
+
* 子 agent 内部的调用:启动这个子 agent 的那次调用(`category = subagent`)的 `id`。
|
|
306
|
+
* 子 agent 再启动子 agent 时一层层指上去;主 agent 自己的调用不带。
|
|
307
|
+
*/
|
|
308
|
+
parent_id?: string | null;
|
|
289
309
|
title: string;
|
|
290
310
|
type: "tool_call";
|
|
291
311
|
}
|
|
@@ -320,7 +340,18 @@ export type Event =
|
|
|
320
340
|
type: "permission";
|
|
321
341
|
}
|
|
322
342
|
| {
|
|
343
|
+
/**
|
|
344
|
+
* 设备答复时带的 `answers`(kind = question:`{ [question_id]: 字符串或字符串数组 }`),原样记下,
|
|
345
|
+
* 客户端据此在历史里显示问题和回答。daemon 自己答复的(超时、取消、自动拒绝)没有。
|
|
346
|
+
*/
|
|
347
|
+
answers?: {
|
|
348
|
+
[k: string]: unknown;
|
|
349
|
+
} | null;
|
|
323
350
|
by_device: string;
|
|
351
|
+
/**
|
|
352
|
+
* 设备答复时附的话(拒绝的理由、跳过问题时的说明)。daemon 自己答复的没有。
|
|
353
|
+
*/
|
|
354
|
+
message?: string | null;
|
|
324
355
|
option_id?: string | null;
|
|
325
356
|
request_id: string;
|
|
326
357
|
type: "permission_resolved";
|
|
@@ -375,6 +406,82 @@ export type Event =
|
|
|
375
406
|
message: string;
|
|
376
407
|
recoverable: boolean;
|
|
377
408
|
type: "error";
|
|
409
|
+
}
|
|
410
|
+
| {
|
|
411
|
+
/**
|
|
412
|
+
* workflow 里的各个 agent,按 `index` 升序;非 workflow 为空。
|
|
413
|
+
*/
|
|
414
|
+
agents?: TaskAgent[];
|
|
415
|
+
/**
|
|
416
|
+
* agent 给任务的 id(Claude Code 的 `task_id`;Codex 子 agent 的 thread id)。会话内唯一。
|
|
417
|
+
*/
|
|
418
|
+
id: string;
|
|
419
|
+
kind: TaskKind;
|
|
420
|
+
/**
|
|
421
|
+
* 任务最近一次调用的工具名。
|
|
422
|
+
*/
|
|
423
|
+
last_tool?: string | null;
|
|
424
|
+
/**
|
|
425
|
+
* workflow 的阶段,按 `index` 升序;非 workflow 为空。
|
|
426
|
+
*/
|
|
427
|
+
phases?: TaskPhase[];
|
|
428
|
+
status: TaskStatus;
|
|
429
|
+
/**
|
|
430
|
+
* agent 给的进度 / 结果摘要。
|
|
431
|
+
*/
|
|
432
|
+
summary?: string | null;
|
|
433
|
+
/**
|
|
434
|
+
* workflow 的名字 / 任务描述。
|
|
435
|
+
*/
|
|
436
|
+
title: string;
|
|
437
|
+
/**
|
|
438
|
+
* 启动这个任务的 `tool_call` 的 `id`(Claude Code 的 `tool_use_id`;Codex 的 collab agent 调用 item id)。
|
|
439
|
+
* 客户端据此把进度挂在那个工具块上;对不上时单独成块。
|
|
440
|
+
*/
|
|
441
|
+
tool_id?: string | null;
|
|
442
|
+
type: "task";
|
|
443
|
+
usage?: TaskUsage | null;
|
|
444
|
+
}
|
|
445
|
+
| {
|
|
446
|
+
code: string;
|
|
447
|
+
level: NoticeLevel;
|
|
448
|
+
/**
|
|
449
|
+
* agent 给的原文(通常是英文),可能是空串。`command_output` 里是本地命令的输出,可能多行。
|
|
450
|
+
*/
|
|
451
|
+
message: string;
|
|
452
|
+
/**
|
|
453
|
+
* `code = model_fallback`:原来的模型。
|
|
454
|
+
*/
|
|
455
|
+
model_from?: string | null;
|
|
456
|
+
/**
|
|
457
|
+
* `code = model_fallback`:实际使用的模型。
|
|
458
|
+
*/
|
|
459
|
+
model_to?: string | null;
|
|
460
|
+
/**
|
|
461
|
+
* `code = rate_limit`:限额恢复的时间。
|
|
462
|
+
*/
|
|
463
|
+
resets_at_ms?: number | null;
|
|
464
|
+
type: "notice";
|
|
465
|
+
}
|
|
466
|
+
| {
|
|
467
|
+
/**
|
|
468
|
+
* `retrying`:这是第几次重试(从 1 开始)。
|
|
469
|
+
*/
|
|
470
|
+
attempt?: number | null;
|
|
471
|
+
/**
|
|
472
|
+
* `retrying`:距下一次重试的毫秒数。
|
|
473
|
+
*/
|
|
474
|
+
delay_ms?: number | null;
|
|
475
|
+
/**
|
|
476
|
+
* `retrying`:最多重试几次。
|
|
477
|
+
*/
|
|
478
|
+
max_attempts?: number | null;
|
|
479
|
+
/**
|
|
480
|
+
* `retrying`:触发重试的错误摘要,如 `529 overloaded_error`。
|
|
481
|
+
*/
|
|
482
|
+
reason?: string | null;
|
|
483
|
+
state: ActivityState;
|
|
484
|
+
type: "activity";
|
|
378
485
|
};
|
|
379
486
|
export type ToolCategory = "shell" | "file_edit" | "file_read" | "search" | "web" | "subagent" | "mcp" | "other";
|
|
380
487
|
export type EditKind = "edit" | "write" | "delete" | "move";
|
|
@@ -399,6 +506,32 @@ export type GitAction =
|
|
|
399
506
|
| "worktree_kept"
|
|
400
507
|
| "worktree_restored"
|
|
401
508
|
| "worktree_missing";
|
|
509
|
+
/**
|
|
510
|
+
* workflow 里一个 agent 的状态。
|
|
511
|
+
*/
|
|
512
|
+
export type TaskAgentState = ("running" | "done" | "failed") | "queued" | "skipped";
|
|
513
|
+
/**
|
|
514
|
+
* `Event::Task` 的任务种类。
|
|
515
|
+
*/
|
|
516
|
+
export type TaskKind = "other" | "workflow" | "subagent" | "shell";
|
|
517
|
+
/**
|
|
518
|
+
* `Event::Task` 的任务状态。`Running` 以外的三个是收尾状态(终态):Claude Code 的任务进入终态后不会再变;
|
|
519
|
+
* Codex 的子 agent 是一个可以再收到输入的 thread,`Completed` 之后收到新输入、开始新 turn 就会回到 `Running`。
|
|
520
|
+
* 所以终态只说明「这一刻不在跑」,不保证同一个 `id` 以后不会再有快照;客户端始终以最新的一条为准。
|
|
521
|
+
*/
|
|
522
|
+
export type TaskStatus = ("running" | "completed" | "failed") | "cancelled";
|
|
523
|
+
/**
|
|
524
|
+
* `Event::Notice` 的级别。
|
|
525
|
+
*/
|
|
526
|
+
export type NoticeLevel = "info" | "warning";
|
|
527
|
+
/**
|
|
528
|
+
* `Event::Activity` 的状态。
|
|
529
|
+
*/
|
|
530
|
+
export type ActivityState = "none" | "retrying" | "compacting";
|
|
531
|
+
/**
|
|
532
|
+
* `fs.read` 返回内容的方式。
|
|
533
|
+
*/
|
|
534
|
+
export type FsReadEncoding = "text" | "base64";
|
|
402
535
|
/**
|
|
403
536
|
* 信封种类。hub 对每种的处理见 docs/protocol.md § 3。
|
|
404
537
|
*/
|
|
@@ -407,6 +540,10 @@ export type Kind = "handshake" | "data" | "notify" | "control";
|
|
|
407
540
|
* 节点配置 `worktree.default` 的取值,也是 `SessionWorkspace` 的两种模式。
|
|
408
541
|
*/
|
|
409
542
|
export type SessionWorkspaceMode = "local" | "worktree";
|
|
543
|
+
/**
|
|
544
|
+
* 日志级别,`node.logs` 的最低级别过滤。
|
|
545
|
+
*/
|
|
546
|
+
export type NodeLogLevel = "trace" | "debug" | "info" | "warn" | "error";
|
|
410
547
|
/**
|
|
411
548
|
* `node.security_event.kind`。
|
|
412
549
|
*/
|
|
@@ -414,6 +551,27 @@ export type SecurityEventKind =
|
|
|
414
551
|
"device_enrolled" | "password_failures" | "password_locked" | "password_changed" | "settings_changed";
|
|
415
552
|
export type NotifyCategory =
|
|
416
553
|
("permission_requested" | "turn_finished" | "error" | "session_idle") | "enroll_requested" | "security";
|
|
554
|
+
/**
|
|
555
|
+
* 隧道里响应体的编码。`gzip`:`DATA` 帧拼起来是 gzip 流,预览页要先解压;`headers` 里已经去掉
|
|
556
|
+
* `content-encoding` / `content-length`。
|
|
557
|
+
*/
|
|
558
|
+
export type PreviewBodyEncoding = "identity" | "gzip";
|
|
559
|
+
/**
|
|
560
|
+
* 端口探测是否可用。`unavailable`:这台机器上没有可用的探测手段(如没有 `lsof`),只能预览配置里允许的端口。
|
|
561
|
+
*/
|
|
562
|
+
export type PreviewDetection = "ok" | "unavailable";
|
|
563
|
+
export type PreviewGoawayCode = "expired" | "closed" | "revoked" | "disabled" | "port_not_allowed" | "shutdown";
|
|
564
|
+
/**
|
|
565
|
+
* 这个端口为什么允许预览(spec/daemon.md § 19.3)。
|
|
566
|
+
*/
|
|
567
|
+
export type PreviewPortSource = "session" | "workspace" | "config";
|
|
568
|
+
/**
|
|
569
|
+
* daemon 拒绝隧道握手的原因(握手回复 `0x01` 后面的 UTF-8 串)。这一条不受 Noise 保护,只能当提示用。
|
|
570
|
+
*/
|
|
571
|
+
export type PreviewRejectReason =
|
|
572
|
+
("expired" | "port_not_allowed" | "disabled" | "malformed") | "unknown_ticket" | "label_mismatch" | "busy";
|
|
573
|
+
export type PreviewResetCode =
|
|
574
|
+
"internal" | "refused" | "timeout" | "too_large" | "cancelled" | "flow_control" | "protocol" | "limit";
|
|
417
575
|
/**
|
|
418
576
|
* 项目从哪来。
|
|
419
577
|
*/
|
|
@@ -481,6 +639,10 @@ export interface ProtocolSchema {
|
|
|
481
639
|
blob_put_chunk_params: BlobPutChunkParams;
|
|
482
640
|
browse_entry: BrowseEntry;
|
|
483
641
|
client_info: ClientInfo;
|
|
642
|
+
config_change: ConfigChange;
|
|
643
|
+
config_editable: ConfigEditable;
|
|
644
|
+
config_item: ConfigItem;
|
|
645
|
+
config_value_kind: ConfigValueKind;
|
|
484
646
|
control: Control;
|
|
485
647
|
diff_against: DiffAgainst;
|
|
486
648
|
diff_file: DiffFile;
|
|
@@ -501,6 +663,7 @@ export interface ProtocolSchema {
|
|
|
501
663
|
event: Event;
|
|
502
664
|
fs_list_params: FsListParams;
|
|
503
665
|
fs_list_result: FsListResult;
|
|
666
|
+
fs_read_encoding: FsReadEncoding;
|
|
504
667
|
fs_read_params: FsReadParams;
|
|
505
668
|
fs_read_result: FsReadResult;
|
|
506
669
|
git_action: GitAction;
|
|
@@ -512,6 +675,7 @@ export interface ProtocolSchema {
|
|
|
512
675
|
link_block: LinkBlock;
|
|
513
676
|
node_audit_params: NodeAuditParams;
|
|
514
677
|
node_audit_result: NodeAuditResult;
|
|
678
|
+
node_config_result: NodeConfigResult;
|
|
515
679
|
node_devices_result: NodeDevicesResult;
|
|
516
680
|
node_doctor_result: NodeDoctorResult;
|
|
517
681
|
node_enroll_approve_params: NodeEnrollApproveParams;
|
|
@@ -522,11 +686,15 @@ export interface ProtocolSchema {
|
|
|
522
686
|
node_enroll_resolved: NodeEnrollResolved;
|
|
523
687
|
node_enroll_status_result: NodeEnrollStatusResult;
|
|
524
688
|
node_info: NodeInfo;
|
|
689
|
+
node_log_level: NodeLogLevel;
|
|
690
|
+
node_logs_params: NodeLogsParams;
|
|
691
|
+
node_logs_result: NodeLogsResult;
|
|
525
692
|
node_pair_begin_params: NodePairBeginParams;
|
|
526
693
|
node_pair_begin_result: NodePairBeginResult;
|
|
527
694
|
node_revoke_device_params: NodeRevokeDeviceParams;
|
|
528
695
|
node_security_event: NodeSecurityEvent;
|
|
529
696
|
node_set_agent_defaults_params: NodeSetAgentDefaultsParams;
|
|
697
|
+
node_set_config_params: NodeSetConfigParams;
|
|
530
698
|
node_set_enroll_enabled_params: NodeSetEnrollEnabledParams;
|
|
531
699
|
node_set_enroll_password_params: NodeSetEnrollPasswordParams;
|
|
532
700
|
node_stats: NodeStats;
|
|
@@ -539,6 +707,26 @@ export interface ProtocolSchema {
|
|
|
539
707
|
permission_request: PermissionRequest;
|
|
540
708
|
permission_resolved: PermissionResolved;
|
|
541
709
|
permission_respond_params: PermissionRespondParams;
|
|
710
|
+
preview_body_encoding: PreviewBodyEncoding;
|
|
711
|
+
preview_close_params: PreviewCloseParams;
|
|
712
|
+
preview_detection: PreviewDetection;
|
|
713
|
+
preview_goaway: PreviewGoaway;
|
|
714
|
+
preview_goaway_code: PreviewGoawayCode;
|
|
715
|
+
preview_hello: PreviewHello;
|
|
716
|
+
preview_info: PreviewInfo;
|
|
717
|
+
preview_launch: PreviewLaunch;
|
|
718
|
+
preview_list_result: PreviewListResult;
|
|
719
|
+
preview_open_params: PreviewOpenParams;
|
|
720
|
+
preview_open_result: PreviewOpenResult;
|
|
721
|
+
preview_port: PreviewPort;
|
|
722
|
+
preview_port_source: PreviewPortSource;
|
|
723
|
+
preview_ports_params: PreviewPortsParams;
|
|
724
|
+
preview_ports_result: PreviewPortsResult;
|
|
725
|
+
preview_reject_reason: PreviewRejectReason;
|
|
726
|
+
preview_request_head: PreviewRequestHead;
|
|
727
|
+
preview_reset: PreviewReset;
|
|
728
|
+
preview_reset_code: PreviewResetCode;
|
|
729
|
+
preview_response_head: PreviewResponseHead;
|
|
542
730
|
project: Project;
|
|
543
731
|
project_kind: ProjectKind;
|
|
544
732
|
pull_request_info: PullRequestInfo;
|
|
@@ -590,6 +778,7 @@ export interface ProtocolSchema {
|
|
|
590
778
|
workspace_name_params: WorkspaceNameParams;
|
|
591
779
|
workspace_remove_worktree_params: WorkspaceRemoveWorktreeParams;
|
|
592
780
|
workspace_rename_params: WorkspaceRenameParams;
|
|
781
|
+
workspace_root_info: WorkspaceRootInfo;
|
|
593
782
|
workspace_trash_id_params: WorkspaceTrashIdParams;
|
|
594
783
|
workspace_trash_list_result: WorkspaceTrashListResult;
|
|
595
784
|
workspace_worktrees_params: WorkspaceWorktreesParams;
|
|
@@ -640,7 +829,8 @@ export interface AgentInfo {
|
|
|
640
829
|
}
|
|
641
830
|
export interface AgentCapabilities {
|
|
642
831
|
/**
|
|
643
|
-
*
|
|
832
|
+
* agent **原生**收的附件 mime,如 `image/png`。其它附件(非图片、这里没列出的图片格式)不受它限制:daemon 把它们落到
|
|
833
|
+
* 会话工作目录并在文字里附上路径(ADR-44)。
|
|
644
834
|
*/
|
|
645
835
|
attachments?: string[];
|
|
646
836
|
/**
|
|
@@ -741,7 +931,7 @@ export interface AgentListResult {
|
|
|
741
931
|
not_modified?: boolean;
|
|
742
932
|
}
|
|
743
933
|
/**
|
|
744
|
-
* 消息里的一个附件(ADR-35):指向 daemon 上已经传完的 blob
|
|
934
|
+
* 消息里的一个附件(ADR-35、ADR-44):指向 daemon 上已经传完的 blob(图片或任意文件)。客户端从 `blob.put_end` 拿到它、原样放进
|
|
745
935
|
* `session.send` / `session.create`;daemon 以自己记录的元数据为准写进 `user_message` 事件。
|
|
746
936
|
*/
|
|
747
937
|
export interface AttachmentRef {
|
|
@@ -751,7 +941,7 @@ export interface AttachmentRef {
|
|
|
751
941
|
mime: string;
|
|
752
942
|
name: string;
|
|
753
943
|
/**
|
|
754
|
-
* 图片像素宽高(daemon
|
|
944
|
+
* 图片像素宽高(daemon 读文件头得出;读不出来、不是图片时省略)。客户端用来在下载前占好位置。
|
|
755
945
|
*/
|
|
756
946
|
width?: number | null;
|
|
757
947
|
}
|
|
@@ -789,11 +979,13 @@ export interface BlobIdParams {
|
|
|
789
979
|
*/
|
|
790
980
|
export interface BlobPutBeginParams {
|
|
791
981
|
/**
|
|
792
|
-
*
|
|
982
|
+
* 任意 `type/subtype`:不合法或空的按 `application/octet-stream` 记录(不报错),大小写和 `;` 之后的参数规整掉。
|
|
983
|
+
* 声明为 `image/png` `image/jpeg` `image/gif` `image/webp` 的才校验文件头、读宽高。
|
|
793
984
|
*/
|
|
794
985
|
mime: string;
|
|
795
986
|
/**
|
|
796
|
-
* 展示用的文件名(1–255 字节,不能含 `/` `\`
|
|
987
|
+
* 展示用的文件名(1–255 字节,不能含 `/` `\` 和控制字符)。非图片的存储扩展名取自它(清洗过),落到工作目录时也用它
|
|
988
|
+
* 作文件名;daemon 不用它拼出别的路径。
|
|
797
989
|
*/
|
|
798
990
|
name: string;
|
|
799
991
|
/**
|
|
@@ -875,6 +1067,47 @@ export interface ClientInfo {
|
|
|
875
1067
|
*/
|
|
876
1068
|
version: string;
|
|
877
1069
|
}
|
|
1070
|
+
/**
|
|
1071
|
+
* `node.set_config` 的一项改动。
|
|
1072
|
+
*/
|
|
1073
|
+
export interface ConfigChange {
|
|
1074
|
+
key: string;
|
|
1075
|
+
/**
|
|
1076
|
+
* 新值,JSON 类型要和该键的 `kind` 一致(布尔、整数、字符串)。
|
|
1077
|
+
*/
|
|
1078
|
+
value: unknown;
|
|
1079
|
+
}
|
|
1080
|
+
/**
|
|
1081
|
+
* `node.get_config` 的一项:一个可以远程查看的配置键。
|
|
1082
|
+
*/
|
|
1083
|
+
export interface ConfigItem {
|
|
1084
|
+
editable: ConfigEditable;
|
|
1085
|
+
/**
|
|
1086
|
+
* 被 `ANYCON_*` 环境变量覆盖(`log.level` 还包括 `ANYCON_LOG` / `RUST_LOG`)。为真时 `editable` 一定是 `no`。
|
|
1087
|
+
*/
|
|
1088
|
+
env_override?: boolean;
|
|
1089
|
+
/**
|
|
1090
|
+
* 点分隔的键,和 `config.toml` 一致(`sessions.max_concurrent`)。
|
|
1091
|
+
*/
|
|
1092
|
+
key: string;
|
|
1093
|
+
kind: ConfigValueKind;
|
|
1094
|
+
/**
|
|
1095
|
+
* 取值上限:`int` 是数值,`duration` 是毫秒,`text` 是字符数。
|
|
1096
|
+
*/
|
|
1097
|
+
max?: number | null;
|
|
1098
|
+
/**
|
|
1099
|
+
* 取值下限:`int` 是数值,`duration` 是毫秒,`text` 不用。
|
|
1100
|
+
*/
|
|
1101
|
+
min?: number | null;
|
|
1102
|
+
/**
|
|
1103
|
+
* `kind = enum` 时允许的取值。
|
|
1104
|
+
*/
|
|
1105
|
+
options?: string[];
|
|
1106
|
+
/**
|
|
1107
|
+
* 当前生效的值(默认值 → 文件 → 环境变量合并后的结果):布尔、整数或字符串,类型见 `kind`。
|
|
1108
|
+
*/
|
|
1109
|
+
value: unknown;
|
|
1110
|
+
}
|
|
878
1111
|
export interface Quota {
|
|
879
1112
|
connections: number;
|
|
880
1113
|
connections_max?: number | null;
|
|
@@ -974,6 +1207,11 @@ export interface ToolCallDetail {
|
|
|
974
1207
|
url?: string | null;
|
|
975
1208
|
}
|
|
976
1209
|
export interface ToolResultDetail {
|
|
1210
|
+
/**
|
|
1211
|
+
* 调用已经返回,但它启动的工作还在后台跑(后台子 agent)。结束时同一个 `id` 会再来一条
|
|
1212
|
+
* `tool_result`(不带这个标记),取代这一条。
|
|
1213
|
+
*/
|
|
1214
|
+
background?: boolean | null;
|
|
977
1215
|
exit_code?: number | null;
|
|
978
1216
|
/**
|
|
979
1217
|
* 这次调用的流式 `tool_output_delta` 累计超过上限、后续 delta 没有转发;最终 `output` 仍是
|
|
@@ -985,6 +1223,11 @@ export interface ToolResultDetail {
|
|
|
985
1223
|
* daemon 对 `output` 做头尾截断时丢掉的字节数(spec/daemon.md § 12);没截断就缺省。
|
|
986
1224
|
*/
|
|
987
1225
|
output_truncated_bytes?: number | null;
|
|
1226
|
+
/**
|
|
1227
|
+
* 子 agent 结束时 agent 报的它一共用掉的 token(`category = subagent`;agent 不报就缺省)。
|
|
1228
|
+
* 主 agent 的 `turn_done.usage` 不含这部分。
|
|
1229
|
+
*/
|
|
1230
|
+
total_tokens?: number | null;
|
|
988
1231
|
unified_diff?: string | null;
|
|
989
1232
|
}
|
|
990
1233
|
export interface PlanEntry {
|
|
@@ -1008,12 +1251,22 @@ export interface PermissionDetail {
|
|
|
1008
1251
|
* kind = tool
|
|
1009
1252
|
*/
|
|
1010
1253
|
tool?: ToolPermissionDetail | null;
|
|
1254
|
+
/**
|
|
1255
|
+
* kind = other:要用户在浏览器里打开的链接(MCP server 的 URL 模式 elicitation)。只会是 `http` / `https`;
|
|
1256
|
+
* 客户端只对这两种协议提供「打开」入口,并且显示完整 URL。
|
|
1257
|
+
*/
|
|
1258
|
+
url?: string | null;
|
|
1011
1259
|
}
|
|
1012
1260
|
export interface Question {
|
|
1013
1261
|
choices?: QuestionChoice[];
|
|
1014
1262
|
free_text?: boolean;
|
|
1015
1263
|
id: string;
|
|
1016
1264
|
multi?: boolean;
|
|
1265
|
+
/**
|
|
1266
|
+
* 可以不答:客户端允许留空提交,答复里就没有这一题的答案。默认 `false`(必答),
|
|
1267
|
+
* 所以 AskUserQuestion 这类每题都要答的行为不变;MCP elicitation 表单里 schema 没列进 `required` 的字段是 `true`。
|
|
1268
|
+
*/
|
|
1269
|
+
optional?: boolean;
|
|
1017
1270
|
text: string;
|
|
1018
1271
|
}
|
|
1019
1272
|
export interface QuestionChoice {
|
|
@@ -1045,6 +1298,15 @@ export interface PermissionOption {
|
|
|
1045
1298
|
export interface Usage {
|
|
1046
1299
|
cache_read_tokens?: number | null;
|
|
1047
1300
|
cache_write_tokens?: number | null;
|
|
1301
|
+
/**
|
|
1302
|
+
* turn 结束时上下文已经占用的 token:最近一次模型请求的输入 + 缓存读写。和 `input_tokens` 等
|
|
1303
|
+
* 累计用量不同,它是「此刻窗口里有多少」,客户端拿它和 `context_window` 算占用比例。agent 不报就缺省。
|
|
1304
|
+
*/
|
|
1305
|
+
context_tokens?: number | null;
|
|
1306
|
+
/**
|
|
1307
|
+
* 模型的上下文窗口大小(token)。agent 不报就缺省。
|
|
1308
|
+
*/
|
|
1309
|
+
context_window?: number | null;
|
|
1048
1310
|
cost_usd?: number | null;
|
|
1049
1311
|
duration_ms: number;
|
|
1050
1312
|
input_tokens?: number | null;
|
|
@@ -1077,6 +1339,56 @@ export interface SessionSettings {
|
|
|
1077
1339
|
*/
|
|
1078
1340
|
thinking?: string | null;
|
|
1079
1341
|
}
|
|
1342
|
+
/**
|
|
1343
|
+
* workflow 里的一个 agent。
|
|
1344
|
+
*/
|
|
1345
|
+
export interface TaskAgent {
|
|
1346
|
+
/**
|
|
1347
|
+
* 第几次尝试(重试过才有)。
|
|
1348
|
+
*/
|
|
1349
|
+
attempt?: number | null;
|
|
1350
|
+
/**
|
|
1351
|
+
* 结果来自缓存,没有真的运行。
|
|
1352
|
+
*/
|
|
1353
|
+
cached?: boolean | null;
|
|
1354
|
+
duration_ms?: number | null;
|
|
1355
|
+
/**
|
|
1356
|
+
* `state = failed` 时的错误信息。
|
|
1357
|
+
*/
|
|
1358
|
+
error?: string | null;
|
|
1359
|
+
/**
|
|
1360
|
+
* 在 workflow 里的序号,同一个任务内唯一。
|
|
1361
|
+
*/
|
|
1362
|
+
index: number;
|
|
1363
|
+
label: string;
|
|
1364
|
+
/**
|
|
1365
|
+
* 最近一次调用的工具名。
|
|
1366
|
+
*/
|
|
1367
|
+
last_tool?: string | null;
|
|
1368
|
+
model?: string | null;
|
|
1369
|
+
/**
|
|
1370
|
+
* 所属阶段的 `TaskPhase.index`。
|
|
1371
|
+
*/
|
|
1372
|
+
phase_index?: number | null;
|
|
1373
|
+
state: TaskAgentState;
|
|
1374
|
+
tokens?: number | null;
|
|
1375
|
+
tool_calls?: number | null;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* workflow 的一个阶段。
|
|
1379
|
+
*/
|
|
1380
|
+
export interface TaskPhase {
|
|
1381
|
+
index: number;
|
|
1382
|
+
title: string;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* 任务的用量。每个字段 agent 不报就缺省。
|
|
1386
|
+
*/
|
|
1387
|
+
export interface TaskUsage {
|
|
1388
|
+
duration_ms?: number | null;
|
|
1389
|
+
tool_calls?: number | null;
|
|
1390
|
+
total_tokens?: number | null;
|
|
1391
|
+
}
|
|
1080
1392
|
export interface FsListParams {
|
|
1081
1393
|
/**
|
|
1082
1394
|
* `<项目名>/<项目内的相对路径>`,如 `my-app/src`。第一段是关联项目的名字时,其余部分相对那个目录解析,
|
|
@@ -1095,21 +1407,50 @@ export interface FsEntry {
|
|
|
1095
1407
|
}
|
|
1096
1408
|
export interface FsReadParams {
|
|
1097
1409
|
/**
|
|
1098
|
-
*
|
|
1410
|
+
* 缺省 `text`。
|
|
1411
|
+
*/
|
|
1412
|
+
encoding?: FsReadEncoding & string;
|
|
1413
|
+
/**
|
|
1414
|
+
* 读多少**原始字节**。`encoding = text`:默认 1 MiB,上限 10 MiB。`encoding = base64`:一次最多一块(512 KiB,和
|
|
1415
|
+
* `blob.get` 一样),缺省就是一块,超过的按一块算(不报错);`0` 只回大小、不带数据。
|
|
1099
1416
|
*/
|
|
1100
1417
|
max_bytes?: number | null;
|
|
1418
|
+
/**
|
|
1419
|
+
* 从文件的第几个字节读起,缺省 0。只有 `encoding = base64` 能用:大文件按块一块一块读,一个响应不会长时间占住设备到 daemon
|
|
1420
|
+
* 那条有序的传输。`text` 模式下 `offset > 0` 是 `invalid`。
|
|
1421
|
+
*/
|
|
1422
|
+
offset?: number;
|
|
1101
1423
|
/**
|
|
1102
1424
|
* 解析规则同 `FsListParams.path`。
|
|
1103
1425
|
*/
|
|
1104
1426
|
path: string;
|
|
1105
1427
|
}
|
|
1106
1428
|
export interface FsReadResult {
|
|
1429
|
+
/**
|
|
1430
|
+
* `text` 模式:文件是二进制(不返回内容)。`base64` 模式:按**这一块**的内容判断(前 8 KiB 里有 NUL、或不是合法的
|
|
1431
|
+
* UTF-8),只有 `offset = 0` 的那一块说明整个文件;从中间读起的块可能从半个字符开始,客户端不要依赖它。
|
|
1432
|
+
*/
|
|
1107
1433
|
binary: boolean;
|
|
1434
|
+
/**
|
|
1435
|
+
* 文件的总字节数(不是读到的)。分块读的时候每一块都带着它:总数变了说明文件在读的过程中被改写过。
|
|
1436
|
+
*/
|
|
1108
1437
|
bytes: number;
|
|
1109
1438
|
/**
|
|
1110
|
-
*
|
|
1439
|
+
* `encoding = base64` 时读到的字节(至多一块;`offset` 在文件末尾或之后时为空串);`text` 模式没有这个字段。
|
|
1440
|
+
*/
|
|
1441
|
+
data_base64?: string | null;
|
|
1442
|
+
/**
|
|
1443
|
+
* `encoding = base64` 时 `data_base64` 从文件的第几个字节开始(原样回显请求的 `offset`);`text` 模式没有这个字段。
|
|
1444
|
+
* 不认识 `offset` 的旧 daemon 不会带它,客户端据此知道分块读不能用。
|
|
1445
|
+
*/
|
|
1446
|
+
offset?: number | null;
|
|
1447
|
+
/**
|
|
1448
|
+
* UTF-8 文本;二进制文件 `text` 为空且 `binary = true`。`encoding = base64` 时恒为空。
|
|
1111
1449
|
*/
|
|
1112
1450
|
text: string;
|
|
1451
|
+
/**
|
|
1452
|
+
* 文件在读到的这一段**之后**还有内容(`offset + 读到的字节数 < bytes`)。
|
|
1453
|
+
*/
|
|
1113
1454
|
truncated: boolean;
|
|
1114
1455
|
}
|
|
1115
1456
|
export interface JobCancelParams {
|
|
@@ -1145,6 +1486,12 @@ export interface AuditEntry {
|
|
|
1145
1486
|
target?: string | null;
|
|
1146
1487
|
ts_ms: number;
|
|
1147
1488
|
}
|
|
1489
|
+
/**
|
|
1490
|
+
* `node.get_config` / `node.set_config` 的结果:白名单里的全部配置项(顺序固定,按段分组)。
|
|
1491
|
+
*/
|
|
1492
|
+
export interface NodeConfigResult {
|
|
1493
|
+
items: ConfigItem[];
|
|
1494
|
+
}
|
|
1148
1495
|
export interface NodeDevicesResult {
|
|
1149
1496
|
devices: PeerDevice[];
|
|
1150
1497
|
}
|
|
@@ -1233,6 +1580,10 @@ export interface NodeEnrollStatusResult {
|
|
|
1233
1580
|
* `node.info` 结果。
|
|
1234
1581
|
*/
|
|
1235
1582
|
export interface NodeInfo {
|
|
1583
|
+
/**
|
|
1584
|
+
* `capabilities.blobs` 为 true 时给出。
|
|
1585
|
+
*/
|
|
1586
|
+
attachment_limits?: NodeAttachmentLimits | null;
|
|
1236
1587
|
capabilities: NodeCapabilities;
|
|
1237
1588
|
name: string;
|
|
1238
1589
|
node_id: string;
|
|
@@ -1240,16 +1591,49 @@ export interface NodeInfo {
|
|
|
1240
1591
|
protocol_version: number;
|
|
1241
1592
|
started_at_ms: number;
|
|
1242
1593
|
version: string;
|
|
1594
|
+
/**
|
|
1595
|
+
* 主根。多个根时看 `workspace_roots`。
|
|
1596
|
+
*/
|
|
1243
1597
|
workspace_root?: string | null;
|
|
1598
|
+
/**
|
|
1599
|
+
* 所有 workspace 根,主根在最前,额外根按配置顺序。老版本的 daemon 不给,客户端当作只有 `workspace_root` 一个。
|
|
1600
|
+
*/
|
|
1601
|
+
workspace_roots?: WorkspaceRootInfo[];
|
|
1244
1602
|
/**
|
|
1245
1603
|
* `capabilities.worktree` 为 true 时给出。
|
|
1246
1604
|
*/
|
|
1247
1605
|
worktree?: NodeWorktreeSettings | null;
|
|
1248
1606
|
}
|
|
1607
|
+
/**
|
|
1608
|
+
* 附件的上限(`node.info`),客户端据此在上传之前就拒绝明显超限的文件。
|
|
1609
|
+
*/
|
|
1610
|
+
export interface NodeAttachmentLimits {
|
|
1611
|
+
/**
|
|
1612
|
+
* 单个附件的字节上限(`sessions.max_attachment_bytes`,热加载;这里是 `node.info` 被调用那一刻的值)。
|
|
1613
|
+
*/
|
|
1614
|
+
max_bytes: number;
|
|
1615
|
+
/**
|
|
1616
|
+
* 一条消息的附件字节合计上限。
|
|
1617
|
+
*/
|
|
1618
|
+
max_message_bytes: number;
|
|
1619
|
+
/**
|
|
1620
|
+
* 一条消息至多带几个附件。
|
|
1621
|
+
*/
|
|
1622
|
+
max_per_message: number;
|
|
1623
|
+
}
|
|
1249
1624
|
export interface NodeCapabilities {
|
|
1250
1625
|
audit: boolean;
|
|
1251
1626
|
blobs: boolean;
|
|
1627
|
+
/**
|
|
1628
|
+
* daemon 能把任意类型的文件交给任何会话的 agent(非图片、agent 不原生收的图片落到会话工作目录,ADR-44)。
|
|
1629
|
+
* 为 false(旧 daemon)时客户端只能上传图片。
|
|
1630
|
+
*/
|
|
1631
|
+
file_attachments?: boolean;
|
|
1252
1632
|
fs: boolean;
|
|
1633
|
+
/**
|
|
1634
|
+
* 支持 dev server 预览(`preview.*`,ADR-39),且节点配置 `preview.enabled = true`。
|
|
1635
|
+
*/
|
|
1636
|
+
preview?: boolean;
|
|
1253
1637
|
search: boolean;
|
|
1254
1638
|
/**
|
|
1255
1639
|
* 有 workspace(文件夹即项目)。SDK 节点可能没有。
|
|
@@ -1260,6 +1644,24 @@ export interface NodeCapabilities {
|
|
|
1260
1644
|
*/
|
|
1261
1645
|
worktree?: boolean;
|
|
1262
1646
|
}
|
|
1647
|
+
/**
|
|
1648
|
+
* 一个 workspace 根(ADR-45)。每个根下的一级子文件夹都是项目。
|
|
1649
|
+
*/
|
|
1650
|
+
export interface WorkspaceRootInfo {
|
|
1651
|
+
/**
|
|
1652
|
+
* 现在能用:daemon 启动时它是一个存在的目录,并且现在还在。不可用的根下的项目不出现在列表里,也不能在上面新建 / 克隆;
|
|
1653
|
+
* 配置只在启动时读,修好(挂上外接盘)之后要重启 daemon。
|
|
1654
|
+
*/
|
|
1655
|
+
available: boolean;
|
|
1656
|
+
/**
|
|
1657
|
+
* canonical 绝对路径(根不可用时是展开后的配置值)。`workspace.create` / `clone` 的 `root` 取这里的值。
|
|
1658
|
+
*/
|
|
1659
|
+
path: string;
|
|
1660
|
+
/**
|
|
1661
|
+
* 主根:放 `.scratch/`,不指定 `root` 时新项目建在这里。恰好有一个。
|
|
1662
|
+
*/
|
|
1663
|
+
primary: boolean;
|
|
1664
|
+
}
|
|
1263
1665
|
/**
|
|
1264
1666
|
* 节点的 worktree 配置(`config.toml` 的 `[worktree]`),客户端据此决定新建会话的初始选择和分支名预览。
|
|
1265
1667
|
*/
|
|
@@ -1273,6 +1675,32 @@ export interface NodeWorktreeSettings {
|
|
|
1273
1675
|
*/
|
|
1274
1676
|
default_mode: SessionWorkspaceMode;
|
|
1275
1677
|
}
|
|
1678
|
+
/**
|
|
1679
|
+
* `node.logs` 参数。
|
|
1680
|
+
*/
|
|
1681
|
+
export interface NodeLogsParams {
|
|
1682
|
+
/**
|
|
1683
|
+
* 最低级别:只返回这个级别及更高级别的行。缺省 = 不过滤。
|
|
1684
|
+
*/
|
|
1685
|
+
level?: NodeLogLevel | null;
|
|
1686
|
+
/**
|
|
1687
|
+
* 最多返回多少行,缺省 200,最大 1000(超出按 1000)。
|
|
1688
|
+
*/
|
|
1689
|
+
lines?: number | null;
|
|
1690
|
+
}
|
|
1691
|
+
/**
|
|
1692
|
+
* `node.logs` 结果。
|
|
1693
|
+
*/
|
|
1694
|
+
export interface NodeLogsResult {
|
|
1695
|
+
/**
|
|
1696
|
+
* 日志行,旧的在前、新的在后;每行最多 2 KiB(超出的截断,行尾加 `…`)。
|
|
1697
|
+
*/
|
|
1698
|
+
lines: string[];
|
|
1699
|
+
/**
|
|
1700
|
+
* 还有更早的行没有返回(行数到了上限,或扫描的日志量到了上限)。
|
|
1701
|
+
*/
|
|
1702
|
+
truncated: boolean;
|
|
1703
|
+
}
|
|
1276
1704
|
export interface NodePairBeginParams {
|
|
1277
1705
|
/**
|
|
1278
1706
|
* `true`(缺省)= 16 位短码(约 79 bit;链接、二维码、默认都是它);`false` = 8 位(约 40 bit),
|
|
@@ -1334,6 +1762,15 @@ export interface NodeSetAgentDefaultsParams {
|
|
|
1334
1762
|
} | null;
|
|
1335
1763
|
thinking?: string | null;
|
|
1336
1764
|
}
|
|
1765
|
+
/**
|
|
1766
|
+
* `node.set_config` 参数。所有改动先校验,任何一项不合法就一项都不写。
|
|
1767
|
+
*
|
|
1768
|
+
* 错误:键不在白名单、被环境变量覆盖、想放宽只能收紧的键 → `forbidden`(`data.field` 是键,`data.reason` 是
|
|
1769
|
+
* `not_editable` / `env_override` / `tighten_only`);值的类型或取值不合法、键重复、`changes` 为空 → `invalid`(`data.field` 是键)。
|
|
1770
|
+
*/
|
|
1771
|
+
export interface NodeSetConfigParams {
|
|
1772
|
+
changes: ConfigChange[];
|
|
1773
|
+
}
|
|
1337
1774
|
/**
|
|
1338
1775
|
* `node.set_enroll_enabled` 参数:写 `[enroll]` 配置。`password: true` 同时解除锁定、失败计数清零。
|
|
1339
1776
|
*/
|
|
@@ -1446,7 +1883,171 @@ export interface PermissionRespondParams {
|
|
|
1446
1883
|
request_id: string;
|
|
1447
1884
|
}
|
|
1448
1885
|
/**
|
|
1449
|
-
*
|
|
1886
|
+
* `preview.close` 参数:作废这个 label 的全部票据,断开它的全部隧道。
|
|
1887
|
+
*/
|
|
1888
|
+
export interface PreviewCloseParams {
|
|
1889
|
+
label: string;
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* 隧道 `GOAWAY` 帧的载荷(msgpack,只有 daemon 发,stream 0):daemon 要关掉这条隧道,之后不再处理它的帧。
|
|
1893
|
+
*/
|
|
1894
|
+
export interface PreviewGoaway {
|
|
1895
|
+
code: PreviewGoawayCode;
|
|
1896
|
+
message?: string | null;
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* 隧道握手第二条消息(daemon → 预览页)的 payload,JSON。到这一条预览页才确认对端持有票据、是钉住的 daemon。
|
|
1900
|
+
*/
|
|
1901
|
+
export interface PreviewHello {
|
|
1902
|
+
expires_at_ms: number;
|
|
1903
|
+
port: number;
|
|
1904
|
+
session_id?: string | null;
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* `preview.list` 的一项:一张未过期的票据。
|
|
1908
|
+
*/
|
|
1909
|
+
export interface PreviewInfo {
|
|
1910
|
+
created_at_ms: number;
|
|
1911
|
+
/**
|
|
1912
|
+
* 签发这张票据的设备。
|
|
1913
|
+
*/
|
|
1914
|
+
created_by: string;
|
|
1915
|
+
created_by_name: string;
|
|
1916
|
+
expires_at_ms: number;
|
|
1917
|
+
label: string;
|
|
1918
|
+
port: number;
|
|
1919
|
+
session_id?: string | null;
|
|
1920
|
+
ticket_id: string;
|
|
1921
|
+
/**
|
|
1922
|
+
* 此刻用这张票据建立的隧道数。
|
|
1923
|
+
*/
|
|
1924
|
+
tunnels: number;
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* 预览页的启动参数。Web UI 把它序列化成 JSON、再 base64url(无填充),放进
|
|
1928
|
+
* `<预览 origin>/__anycon/enter#<…>` 的 fragment(浏览器不会把 fragment 发给 hub)。引导页读出后存进预览 origin 的
|
|
1929
|
+
* IndexedDB,立即从地址栏抹掉。
|
|
1930
|
+
*/
|
|
1931
|
+
export interface PreviewLaunch {
|
|
1932
|
+
/**
|
|
1933
|
+
* 票据和令牌里较早的那个过期时间。
|
|
1934
|
+
*/
|
|
1935
|
+
expires_at_ms: number;
|
|
1936
|
+
label: string;
|
|
1937
|
+
/**
|
|
1938
|
+
* daemon 的设备 id。
|
|
1939
|
+
*/
|
|
1940
|
+
node: string;
|
|
1941
|
+
/**
|
|
1942
|
+
* daemon 的 Noise 静态公钥,64 个小写 hex。预览页用它做 NK 握手(钉住 daemon)。
|
|
1943
|
+
*/
|
|
1944
|
+
node_public: string;
|
|
1945
|
+
/**
|
|
1946
|
+
* 打开后先导航到的路径(以 `/` 开头,可带查询串)。
|
|
1947
|
+
*/
|
|
1948
|
+
path: string;
|
|
1949
|
+
port: number;
|
|
1950
|
+
psk: string;
|
|
1951
|
+
ticket_id: string;
|
|
1952
|
+
/**
|
|
1953
|
+
* hub 签发的预览令牌(`POST /api/preview/tokens`),预览连接凭它向 hub 认证。
|
|
1954
|
+
*/
|
|
1955
|
+
token: string;
|
|
1956
|
+
/**
|
|
1957
|
+
* 格式版本,目前是 1。
|
|
1958
|
+
*/
|
|
1959
|
+
v: number;
|
|
1960
|
+
}
|
|
1961
|
+
export interface PreviewListResult {
|
|
1962
|
+
previews: PreviewInfo[];
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* `preview.open` 参数:为本机 `port` 签发一张预览票据。
|
|
1966
|
+
*/
|
|
1967
|
+
export interface PreviewOpenParams {
|
|
1968
|
+
port: number;
|
|
1969
|
+
/**
|
|
1970
|
+
* 从哪个会话发起(只用于界面展示和审计;端口是否允许不看它,见 spec/daemon.md § 19.3)。
|
|
1971
|
+
*/
|
|
1972
|
+
session_id?: string | null;
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* `preview.open` 结果。`psk` 是票据的密钥,只交给预览页(放进 [`PreviewLaunch`]),不要写日志、不要发给 hub。
|
|
1976
|
+
*/
|
|
1977
|
+
export interface PreviewOpenResult {
|
|
1978
|
+
expires_at_ms: number;
|
|
1979
|
+
/**
|
|
1980
|
+
* 这个端口固定的预览 label(26 位小写 base32),预览 origin 是 `<label>.<预览域名>`。
|
|
1981
|
+
*/
|
|
1982
|
+
label: string;
|
|
1983
|
+
port: number;
|
|
1984
|
+
/**
|
|
1985
|
+
* 票据密钥,64 个小写 hex(32 字节),Noise PSK。
|
|
1986
|
+
*/
|
|
1987
|
+
psk: string;
|
|
1988
|
+
session_id?: string | null;
|
|
1989
|
+
/**
|
|
1990
|
+
* 票据 id,32 个小写 hex(16 字节)。
|
|
1991
|
+
*/
|
|
1992
|
+
ticket_id: string;
|
|
1993
|
+
}
|
|
1994
|
+
export interface PreviewPort {
|
|
1995
|
+
pid?: number | null;
|
|
1996
|
+
port: number;
|
|
1997
|
+
/**
|
|
1998
|
+
* 进程名(可执行文件名,不含参数)。
|
|
1999
|
+
*/
|
|
2000
|
+
process?: string | null;
|
|
2001
|
+
session_id?: string | null;
|
|
2002
|
+
source: PreviewPortSource;
|
|
2003
|
+
}
|
|
2004
|
+
/**
|
|
2005
|
+
* `preview.ports` 参数。带 `session_id` 只列这个会话的端口(外加配置里允许的端口)。
|
|
2006
|
+
*/
|
|
2007
|
+
export interface PreviewPortsParams {
|
|
2008
|
+
session_id?: string | null;
|
|
2009
|
+
}
|
|
2010
|
+
export interface PreviewPortsResult {
|
|
2011
|
+
detection: PreviewDetection;
|
|
2012
|
+
ports: PreviewPort[];
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* 隧道 `REQUEST` 帧的载荷(msgpack,字段名为键)。
|
|
2016
|
+
*/
|
|
2017
|
+
export interface PreviewRequestHead {
|
|
2018
|
+
/**
|
|
2019
|
+
* 请求头,按原顺序,名字小写。`cookie` 来自预览页自己的 cookie jar;daemon 转发前改写哪些头见
|
|
2020
|
+
* spec/daemon.md § 19.5。
|
|
2021
|
+
*/
|
|
2022
|
+
headers: [string, string][];
|
|
2023
|
+
method: string;
|
|
2024
|
+
/**
|
|
2025
|
+
* 以 `/` 开头,可带查询串;不含 scheme 和主机。
|
|
2026
|
+
*/
|
|
2027
|
+
path: string;
|
|
2028
|
+
/**
|
|
2029
|
+
* `true`:这是一个 WebSocket 升级请求(`method` 为 `GET`,子协议在 `sec-websocket-protocol` 头里)。
|
|
2030
|
+
*/
|
|
2031
|
+
websocket?: boolean;
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* 隧道 `RESET` 帧的载荷(msgpack):终止这个 stream 的两个方向。
|
|
2035
|
+
*/
|
|
2036
|
+
export interface PreviewReset {
|
|
2037
|
+
code: PreviewResetCode;
|
|
2038
|
+
message?: string | null;
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* 隧道 `RESPONSE` 帧的载荷(msgpack)。WebSocket 流里 `status = 101` 表示升级成功,其他状态码表示被拒,
|
|
2042
|
+
* 后面跟普通响应体。
|
|
2043
|
+
*/
|
|
2044
|
+
export interface PreviewResponseHead {
|
|
2045
|
+
encoding?: PreviewBodyEncoding & string;
|
|
2046
|
+
headers: [string, string][];
|
|
2047
|
+
status: number;
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* 一个项目 = 某个 workspace 根目录下的一个一级子文件夹,或一个关联的本机目录(`kind = linked`)。
|
|
1450
2051
|
* 元数据全部推导;只有「关联了哪些目录」存在 daemon 的库里。
|
|
1451
2052
|
*/
|
|
1452
2053
|
export interface Project {
|
|
@@ -1468,13 +2069,18 @@ export interface Project {
|
|
|
1468
2069
|
missing?: boolean;
|
|
1469
2070
|
modified_at_ms: number;
|
|
1470
2071
|
/**
|
|
1471
|
-
*
|
|
2072
|
+
* 项目名。所有 workspace 根下的项目和关联的项目共用一个命名空间,客户端的所有操作都用它。
|
|
1472
2073
|
*/
|
|
1473
2074
|
name: string;
|
|
1474
2075
|
/**
|
|
1475
2076
|
* 绝对路径,仅展示用。
|
|
1476
2077
|
*/
|
|
1477
2078
|
path: string;
|
|
2079
|
+
/**
|
|
2080
|
+
* 文件夹项目所在的 workspace 根(canonical 绝对路径,等于 `node.info.workspace_roots` 里的某一项的 `path`);
|
|
2081
|
+
* 关联项目没有。老版本的 daemon 不给,客户端当作主根。
|
|
2082
|
+
*/
|
|
2083
|
+
root?: string | null;
|
|
1478
2084
|
}
|
|
1479
2085
|
export interface GitMeta {
|
|
1480
2086
|
branch?: string | null;
|
|
@@ -1548,6 +2154,10 @@ export interface SessionArchiveParams {
|
|
|
1548
2154
|
*/
|
|
1549
2155
|
export interface SessionChanged {
|
|
1550
2156
|
archived?: boolean;
|
|
2157
|
+
/**
|
|
2158
|
+
* 同 [`SessionSummary::background_tasks`]。
|
|
2159
|
+
*/
|
|
2160
|
+
background_tasks?: number;
|
|
1551
2161
|
/**
|
|
1552
2162
|
* 会话被删除。
|
|
1553
2163
|
*/
|
|
@@ -1593,7 +2203,8 @@ export interface SessionWorktree {
|
|
|
1593
2203
|
export interface SessionCreateParams {
|
|
1594
2204
|
agent: string;
|
|
1595
2205
|
/**
|
|
1596
|
-
* 第一条消息的附件(`blob.put_end` 的结果)。agent
|
|
2206
|
+
* 第一条消息的附件(`blob.put_end` 的结果)。agent 原生收的 mime(`capabilities.attachments`)交给 adapter,
|
|
2207
|
+
* 其余落到会话工作目录、路径写在交给 agent 的文字里(ADR-44)。
|
|
1597
2208
|
*/
|
|
1598
2209
|
attachments?: AttachmentRef[];
|
|
1599
2210
|
/**
|
|
@@ -1755,6 +2366,11 @@ export interface SessionSummary {
|
|
|
1755
2366
|
*/
|
|
1756
2367
|
agent_session_id?: string | null;
|
|
1757
2368
|
archived?: boolean;
|
|
2369
|
+
/**
|
|
2370
|
+
* agent 进程里还在跑的后台任务数(Claude Code 的后台 subagent、后台命令)。主 turn 结束后它们可能还在干活,
|
|
2371
|
+
* 期间 daemon 不按 `idle_timeout` 回收进程(docs/spec/daemon.md § 7.3)。只反映 daemon 内存里的当前状态,不进事件流。
|
|
2372
|
+
*/
|
|
2373
|
+
background_tasks?: number;
|
|
1758
2374
|
created_at_ms: number;
|
|
1759
2375
|
id: string;
|
|
1760
2376
|
/**
|
|
@@ -1804,26 +2420,45 @@ export interface SessionRenameParams {
|
|
|
1804
2420
|
title: string;
|
|
1805
2421
|
}
|
|
1806
2422
|
export interface SessionSearchParams {
|
|
2423
|
+
/**
|
|
2424
|
+
* 最多返回几条命中,默认 20,上限 200。
|
|
2425
|
+
*/
|
|
1807
2426
|
limit?: number | null;
|
|
2427
|
+
/**
|
|
2428
|
+
* 只搜这个项目里的会话。
|
|
2429
|
+
*/
|
|
1808
2430
|
project?: string | null;
|
|
2431
|
+
/**
|
|
2432
|
+
* 空白分隔的若干个词,每个词按前缀匹配、都要出现在同一段文字里;不能为空(`invalid`)。
|
|
2433
|
+
*/
|
|
1809
2434
|
query: string;
|
|
1810
2435
|
}
|
|
1811
2436
|
export interface SessionSearchResult {
|
|
1812
2437
|
hits: SearchHit[];
|
|
1813
2438
|
}
|
|
1814
2439
|
export interface SearchHit {
|
|
2440
|
+
/**
|
|
2441
|
+
* 命中的那段文字开始处的事件 seq:用户消息就是 `user_message` 的 seq;assistant 文字是那一段第一个 `text_delta` 的 seq
|
|
2442
|
+
* (长文字每 32 KiB 切一段索引,所以同一条回复可以有几个不同的 seq)。
|
|
2443
|
+
*/
|
|
1815
2444
|
seq: number;
|
|
1816
2445
|
session_id: string;
|
|
1817
2446
|
/**
|
|
1818
|
-
*
|
|
2447
|
+
* 命中处的片段。除了包住命中词的字面 `<mark>` / `</mark>`,里面没有 HTML:会话文字里原有的
|
|
2448
|
+
* `<` `>` `&` 已转义成 `<` `>` `&`,客户端按 `<mark>` 切开后把这三个实体还原成字符、
|
|
2449
|
+
* 当纯文本显示即可,不要当 HTML 解析。
|
|
1819
2450
|
*/
|
|
1820
2451
|
snippet: string;
|
|
2452
|
+
/**
|
|
2453
|
+
* 会话当前的标题。
|
|
2454
|
+
*/
|
|
1821
2455
|
title: string;
|
|
1822
2456
|
ts_ms: number;
|
|
1823
2457
|
}
|
|
1824
2458
|
export interface SessionSendParams {
|
|
1825
2459
|
/**
|
|
1826
|
-
* `blob.put_end` 的结果,每条至多 20 个。agent
|
|
2460
|
+
* `blob.put_end` 的结果,每条至多 20 个。agent 原生收的 mime(`capabilities.attachments`)交给 adapter,
|
|
2461
|
+
* 其余落到会话工作目录、路径写在交给 agent 的文字里(ADR-44)。
|
|
1827
2462
|
*/
|
|
1828
2463
|
attachments?: AttachmentRef[];
|
|
1829
2464
|
/**
|
|
@@ -1888,10 +2523,14 @@ export interface SessionSyncBaseResult {
|
|
|
1888
2523
|
export interface TrashEntry {
|
|
1889
2524
|
bytes: number;
|
|
1890
2525
|
/**
|
|
1891
|
-
* `.trash/` 下的目录名,如 `my-app-20261011T120000Z
|
|
2526
|
+
* `.trash/` 下的目录名,如 `my-app-20261011T120000Z`。每个根有自己的 `.trash/`,id 在所有根之间唯一。
|
|
1892
2527
|
*/
|
|
1893
2528
|
id: string;
|
|
1894
2529
|
original_name: string;
|
|
2530
|
+
/**
|
|
2531
|
+
* 条目所在(也是 `restore` 还原到)的 workspace 根。老版本的 daemon 不给,客户端当作主根。
|
|
2532
|
+
*/
|
|
2533
|
+
root?: string | null;
|
|
1895
2534
|
trashed_at_ms: number;
|
|
1896
2535
|
}
|
|
1897
2536
|
/**
|
|
@@ -1988,6 +2627,10 @@ export interface RenamedProject {
|
|
|
1988
2627
|
}
|
|
1989
2628
|
export interface WorkspaceCloneParams {
|
|
1990
2629
|
name?: string | null;
|
|
2630
|
+
/**
|
|
2631
|
+
* 克隆到哪个 workspace 根下,规则同 `WorkspaceCreateParams.root`。
|
|
2632
|
+
*/
|
|
2633
|
+
root?: string | null;
|
|
1991
2634
|
/**
|
|
1992
2635
|
* 只允许 `https://`、`ssh://`、`git@host:path` 三种形式。
|
|
1993
2636
|
*/
|
|
@@ -1996,6 +2639,11 @@ export interface WorkspaceCloneParams {
|
|
|
1996
2639
|
export interface WorkspaceCreateParams {
|
|
1997
2640
|
git_init?: boolean;
|
|
1998
2641
|
name: string;
|
|
2642
|
+
/**
|
|
2643
|
+
* 在哪个 workspace 根下新建。必须是 `node.info.workspace_roots` 里的某一项的 `path`;缺省 = 主根;
|
|
2644
|
+
* 不在列表里 → `invalid`,在列表里但现在不可用(`available = false`)→ `not_found`。
|
|
2645
|
+
*/
|
|
2646
|
+
root?: string | null;
|
|
1999
2647
|
}
|
|
2000
2648
|
/**
|
|
2001
2649
|
* `workspace.link`:把本机一个已有目录关联为项目。
|
|
@@ -2013,6 +2661,9 @@ export interface WorkspaceLinkParams {
|
|
|
2013
2661
|
}
|
|
2014
2662
|
export interface WorkspaceListResult {
|
|
2015
2663
|
projects: Project[];
|
|
2664
|
+
/**
|
|
2665
|
+
* 主根(`node.info.workspace_roots` 里 `primary` 的那一项)。其余根下的项目看 `Project.root`。
|
|
2666
|
+
*/
|
|
2016
2667
|
root: string;
|
|
2017
2668
|
}
|
|
2018
2669
|
export interface WorkspaceNameParams {
|