@anycon/protocol 0.1.1 → 0.3.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 +656 -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 +3 -3
- package/src/constants.ts +16 -0
- package/src/crypto.ts +16 -4
- package/src/envelope.ts +5 -3
- package/src/generated.ts +663 -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
|
| {
|
|
@@ -325,7 +340,18 @@ export type Event =
|
|
|
325
340
|
type: "permission";
|
|
326
341
|
}
|
|
327
342
|
| {
|
|
343
|
+
/**
|
|
344
|
+
* 设备答复时带的 `answers`(kind = question:`{ [question_id]: 字符串或字符串数组 }`),原样记下,
|
|
345
|
+
* 客户端据此在历史里显示问题和回答。daemon 自己答复的(超时、取消、自动拒绝)没有。
|
|
346
|
+
*/
|
|
347
|
+
answers?: {
|
|
348
|
+
[k: string]: unknown;
|
|
349
|
+
} | null;
|
|
328
350
|
by_device: string;
|
|
351
|
+
/**
|
|
352
|
+
* 设备答复时附的话(拒绝的理由、跳过问题时的说明)。daemon 自己答复的没有。
|
|
353
|
+
*/
|
|
354
|
+
message?: string | null;
|
|
329
355
|
option_id?: string | null;
|
|
330
356
|
request_id: string;
|
|
331
357
|
type: "permission_resolved";
|
|
@@ -377,9 +403,100 @@ export type Event =
|
|
|
377
403
|
}
|
|
378
404
|
| {
|
|
379
405
|
code: string;
|
|
406
|
+
/**
|
|
407
|
+
* `code = usage_limit`:触到的是账号级的窗口还是特定模型的窗口。只有上游明确给出限额类型时才有;
|
|
408
|
+
* 缺省 = 不知道。
|
|
409
|
+
*/
|
|
410
|
+
limit_scope?: LimitScope | null;
|
|
380
411
|
message: string;
|
|
381
412
|
recoverable: boolean;
|
|
413
|
+
/**
|
|
414
|
+
* 限额类错误(`usage_limit`,有时 `rate_limited`):限额恢复的时间。和 `Notice.resets_at_ms` 同语义;
|
|
415
|
+
* 上游没给就缺省,不估算。
|
|
416
|
+
*/
|
|
417
|
+
resets_at_ms?: number | null;
|
|
382
418
|
type: "error";
|
|
419
|
+
}
|
|
420
|
+
| {
|
|
421
|
+
/**
|
|
422
|
+
* workflow 里的各个 agent,按 `index` 升序;非 workflow 为空。
|
|
423
|
+
*/
|
|
424
|
+
agents?: TaskAgent[];
|
|
425
|
+
/**
|
|
426
|
+
* agent 给任务的 id(Claude Code 的 `task_id`;Codex 子 agent 的 thread id)。会话内唯一。
|
|
427
|
+
*/
|
|
428
|
+
id: string;
|
|
429
|
+
kind: TaskKind;
|
|
430
|
+
/**
|
|
431
|
+
* 任务最近一次调用的工具名。
|
|
432
|
+
*/
|
|
433
|
+
last_tool?: string | null;
|
|
434
|
+
/**
|
|
435
|
+
* workflow 的阶段,按 `index` 升序;非 workflow 为空。
|
|
436
|
+
*/
|
|
437
|
+
phases?: TaskPhase[];
|
|
438
|
+
status: TaskStatus;
|
|
439
|
+
/**
|
|
440
|
+
* agent 给的进度 / 结果摘要。
|
|
441
|
+
*/
|
|
442
|
+
summary?: string | null;
|
|
443
|
+
/**
|
|
444
|
+
* workflow 的名字 / 任务描述。
|
|
445
|
+
*/
|
|
446
|
+
title: string;
|
|
447
|
+
/**
|
|
448
|
+
* 启动这个任务的 `tool_call` 的 `id`(Claude Code 的 `tool_use_id`;Codex 的 collab agent 调用 item id)。
|
|
449
|
+
* 客户端据此把进度挂在那个工具块上;对不上时单独成块。
|
|
450
|
+
*/
|
|
451
|
+
tool_id?: string | null;
|
|
452
|
+
type: "task";
|
|
453
|
+
usage?: TaskUsage | null;
|
|
454
|
+
}
|
|
455
|
+
| {
|
|
456
|
+
code: string;
|
|
457
|
+
level: NoticeLevel;
|
|
458
|
+
/**
|
|
459
|
+
* agent 给的原文(通常是英文),可能是空串。`command_output` 里是本地命令的输出,可能多行。
|
|
460
|
+
*/
|
|
461
|
+
message: string;
|
|
462
|
+
/**
|
|
463
|
+
* `code = model_fallback`:原来的模型。
|
|
464
|
+
*/
|
|
465
|
+
model_from?: string | null;
|
|
466
|
+
/**
|
|
467
|
+
* `code = model_fallback`:实际使用的模型。
|
|
468
|
+
*/
|
|
469
|
+
model_to?: string | null;
|
|
470
|
+
/**
|
|
471
|
+
* `code = rate_limit`:限额恢复的时间。
|
|
472
|
+
*/
|
|
473
|
+
resets_at_ms?: number | null;
|
|
474
|
+
type: "notice";
|
|
475
|
+
}
|
|
476
|
+
| {
|
|
477
|
+
/**
|
|
478
|
+
* `retrying`:这是第几次重试(从 1 开始)。
|
|
479
|
+
*/
|
|
480
|
+
attempt?: number | null;
|
|
481
|
+
/**
|
|
482
|
+
* `retrying`:距下一次重试的毫秒数。
|
|
483
|
+
*/
|
|
484
|
+
delay_ms?: number | null;
|
|
485
|
+
/**
|
|
486
|
+
* `retrying`:最多重试几次。
|
|
487
|
+
*/
|
|
488
|
+
max_attempts?: number | null;
|
|
489
|
+
/**
|
|
490
|
+
* `retrying`:触发重试的错误摘要,如 `529 overloaded_error`。
|
|
491
|
+
*/
|
|
492
|
+
reason?: string | null;
|
|
493
|
+
state: ActivityState;
|
|
494
|
+
type: "activity";
|
|
495
|
+
}
|
|
496
|
+
| {
|
|
497
|
+
message_id: string;
|
|
498
|
+
state: MessageDeliveryState;
|
|
499
|
+
type: "message_delivery";
|
|
383
500
|
};
|
|
384
501
|
export type ToolCategory = "shell" | "file_edit" | "file_read" | "search" | "web" | "subagent" | "mcp" | "other";
|
|
385
502
|
export type EditKind = "edit" | "write" | "delete" | "move";
|
|
@@ -404,6 +521,40 @@ export type GitAction =
|
|
|
404
521
|
| "worktree_kept"
|
|
405
522
|
| "worktree_restored"
|
|
406
523
|
| "worktree_missing";
|
|
524
|
+
/**
|
|
525
|
+
* `Event::Error.limit_scope`:用量限额的范围。
|
|
526
|
+
*/
|
|
527
|
+
export type LimitScope = "account" | "model";
|
|
528
|
+
/**
|
|
529
|
+
* workflow 里一个 agent 的状态。
|
|
530
|
+
*/
|
|
531
|
+
export type TaskAgentState = ("running" | "done" | "failed") | "queued" | "skipped";
|
|
532
|
+
/**
|
|
533
|
+
* `Event::Task` 的任务种类。
|
|
534
|
+
*/
|
|
535
|
+
export type TaskKind = "other" | "workflow" | "subagent" | "shell";
|
|
536
|
+
/**
|
|
537
|
+
* `Event::Task` 的任务状态。`Running` 以外的三个是收尾状态(终态):Claude Code 的任务进入终态后不会再变;
|
|
538
|
+
* Codex 的子 agent 是一个可以再收到输入的 thread,`Completed` 之后收到新输入、开始新 turn 就会回到 `Running`。
|
|
539
|
+
* 所以终态只说明「这一刻不在跑」,不保证同一个 `id` 以后不会再有快照;客户端始终以最新的一条为准。
|
|
540
|
+
*/
|
|
541
|
+
export type TaskStatus = ("running" | "completed" | "failed") | "cancelled";
|
|
542
|
+
/**
|
|
543
|
+
* `Event::Notice` 的级别。
|
|
544
|
+
*/
|
|
545
|
+
export type NoticeLevel = "info" | "warning";
|
|
546
|
+
/**
|
|
547
|
+
* `Event::Activity` 的状态。
|
|
548
|
+
*/
|
|
549
|
+
export type ActivityState = "none" | "retrying" | "compacting";
|
|
550
|
+
/**
|
|
551
|
+
* `Event::MessageDelivery` 的状态。目前只有 `uncertain`;未来如有别的取值,客户端把不认识的当成没有标记。
|
|
552
|
+
*/
|
|
553
|
+
export type MessageDeliveryState = "uncertain";
|
|
554
|
+
/**
|
|
555
|
+
* `fs.read` 返回内容的方式。
|
|
556
|
+
*/
|
|
557
|
+
export type FsReadEncoding = "text" | "base64";
|
|
407
558
|
/**
|
|
408
559
|
* 信封种类。hub 对每种的处理见 docs/protocol.md § 3。
|
|
409
560
|
*/
|
|
@@ -412,6 +563,10 @@ export type Kind = "handshake" | "data" | "notify" | "control";
|
|
|
412
563
|
* 节点配置 `worktree.default` 的取值,也是 `SessionWorkspace` 的两种模式。
|
|
413
564
|
*/
|
|
414
565
|
export type SessionWorkspaceMode = "local" | "worktree";
|
|
566
|
+
/**
|
|
567
|
+
* 日志级别,`node.logs` 的最低级别过滤。
|
|
568
|
+
*/
|
|
569
|
+
export type NodeLogLevel = "trace" | "debug" | "info" | "warn" | "error";
|
|
415
570
|
/**
|
|
416
571
|
* `node.security_event.kind`。
|
|
417
572
|
*/
|
|
@@ -419,6 +574,27 @@ export type SecurityEventKind =
|
|
|
419
574
|
"device_enrolled" | "password_failures" | "password_locked" | "password_changed" | "settings_changed";
|
|
420
575
|
export type NotifyCategory =
|
|
421
576
|
("permission_requested" | "turn_finished" | "error" | "session_idle") | "enroll_requested" | "security";
|
|
577
|
+
/**
|
|
578
|
+
* 隧道里响应体的编码。`gzip`:`DATA` 帧拼起来是 gzip 流,预览页要先解压;`headers` 里已经去掉
|
|
579
|
+
* `content-encoding` / `content-length`。
|
|
580
|
+
*/
|
|
581
|
+
export type PreviewBodyEncoding = "identity" | "gzip";
|
|
582
|
+
/**
|
|
583
|
+
* 端口探测是否可用。`unavailable`:这台机器上没有可用的探测手段(如没有 `lsof`),只能预览配置里允许的端口。
|
|
584
|
+
*/
|
|
585
|
+
export type PreviewDetection = "ok" | "unavailable";
|
|
586
|
+
export type PreviewGoawayCode = "expired" | "closed" | "revoked" | "disabled" | "port_not_allowed" | "shutdown";
|
|
587
|
+
/**
|
|
588
|
+
* 这个端口为什么允许预览(spec/daemon.md § 19.3)。
|
|
589
|
+
*/
|
|
590
|
+
export type PreviewPortSource = "session" | "workspace" | "config";
|
|
591
|
+
/**
|
|
592
|
+
* daemon 拒绝隧道握手的原因(握手回复 `0x01` 后面的 UTF-8 串)。这一条不受 Noise 保护,只能当提示用。
|
|
593
|
+
*/
|
|
594
|
+
export type PreviewRejectReason =
|
|
595
|
+
("expired" | "port_not_allowed" | "disabled" | "malformed") | "unknown_ticket" | "label_mismatch" | "busy";
|
|
596
|
+
export type PreviewResetCode =
|
|
597
|
+
"internal" | "refused" | "timeout" | "too_large" | "cancelled" | "flow_control" | "protocol" | "limit";
|
|
422
598
|
/**
|
|
423
599
|
* 项目从哪来。
|
|
424
600
|
*/
|
|
@@ -486,6 +662,10 @@ export interface ProtocolSchema {
|
|
|
486
662
|
blob_put_chunk_params: BlobPutChunkParams;
|
|
487
663
|
browse_entry: BrowseEntry;
|
|
488
664
|
client_info: ClientInfo;
|
|
665
|
+
config_change: ConfigChange;
|
|
666
|
+
config_editable: ConfigEditable;
|
|
667
|
+
config_item: ConfigItem;
|
|
668
|
+
config_value_kind: ConfigValueKind;
|
|
489
669
|
control: Control;
|
|
490
670
|
diff_against: DiffAgainst;
|
|
491
671
|
diff_file: DiffFile;
|
|
@@ -506,6 +686,7 @@ export interface ProtocolSchema {
|
|
|
506
686
|
event: Event;
|
|
507
687
|
fs_list_params: FsListParams;
|
|
508
688
|
fs_list_result: FsListResult;
|
|
689
|
+
fs_read_encoding: FsReadEncoding;
|
|
509
690
|
fs_read_params: FsReadParams;
|
|
510
691
|
fs_read_result: FsReadResult;
|
|
511
692
|
git_action: GitAction;
|
|
@@ -517,6 +698,7 @@ export interface ProtocolSchema {
|
|
|
517
698
|
link_block: LinkBlock;
|
|
518
699
|
node_audit_params: NodeAuditParams;
|
|
519
700
|
node_audit_result: NodeAuditResult;
|
|
701
|
+
node_config_result: NodeConfigResult;
|
|
520
702
|
node_devices_result: NodeDevicesResult;
|
|
521
703
|
node_doctor_result: NodeDoctorResult;
|
|
522
704
|
node_enroll_approve_params: NodeEnrollApproveParams;
|
|
@@ -527,11 +709,15 @@ export interface ProtocolSchema {
|
|
|
527
709
|
node_enroll_resolved: NodeEnrollResolved;
|
|
528
710
|
node_enroll_status_result: NodeEnrollStatusResult;
|
|
529
711
|
node_info: NodeInfo;
|
|
712
|
+
node_log_level: NodeLogLevel;
|
|
713
|
+
node_logs_params: NodeLogsParams;
|
|
714
|
+
node_logs_result: NodeLogsResult;
|
|
530
715
|
node_pair_begin_params: NodePairBeginParams;
|
|
531
716
|
node_pair_begin_result: NodePairBeginResult;
|
|
532
717
|
node_revoke_device_params: NodeRevokeDeviceParams;
|
|
533
718
|
node_security_event: NodeSecurityEvent;
|
|
534
719
|
node_set_agent_defaults_params: NodeSetAgentDefaultsParams;
|
|
720
|
+
node_set_config_params: NodeSetConfigParams;
|
|
535
721
|
node_set_enroll_enabled_params: NodeSetEnrollEnabledParams;
|
|
536
722
|
node_set_enroll_password_params: NodeSetEnrollPasswordParams;
|
|
537
723
|
node_stats: NodeStats;
|
|
@@ -544,6 +730,26 @@ export interface ProtocolSchema {
|
|
|
544
730
|
permission_request: PermissionRequest;
|
|
545
731
|
permission_resolved: PermissionResolved;
|
|
546
732
|
permission_respond_params: PermissionRespondParams;
|
|
733
|
+
preview_body_encoding: PreviewBodyEncoding;
|
|
734
|
+
preview_close_params: PreviewCloseParams;
|
|
735
|
+
preview_detection: PreviewDetection;
|
|
736
|
+
preview_goaway: PreviewGoaway;
|
|
737
|
+
preview_goaway_code: PreviewGoawayCode;
|
|
738
|
+
preview_hello: PreviewHello;
|
|
739
|
+
preview_info: PreviewInfo;
|
|
740
|
+
preview_launch: PreviewLaunch;
|
|
741
|
+
preview_list_result: PreviewListResult;
|
|
742
|
+
preview_open_params: PreviewOpenParams;
|
|
743
|
+
preview_open_result: PreviewOpenResult;
|
|
744
|
+
preview_port: PreviewPort;
|
|
745
|
+
preview_port_source: PreviewPortSource;
|
|
746
|
+
preview_ports_params: PreviewPortsParams;
|
|
747
|
+
preview_ports_result: PreviewPortsResult;
|
|
748
|
+
preview_reject_reason: PreviewRejectReason;
|
|
749
|
+
preview_request_head: PreviewRequestHead;
|
|
750
|
+
preview_reset: PreviewReset;
|
|
751
|
+
preview_reset_code: PreviewResetCode;
|
|
752
|
+
preview_response_head: PreviewResponseHead;
|
|
547
753
|
project: Project;
|
|
548
754
|
project_kind: ProjectKind;
|
|
549
755
|
pull_request_info: PullRequestInfo;
|
|
@@ -595,6 +801,7 @@ export interface ProtocolSchema {
|
|
|
595
801
|
workspace_name_params: WorkspaceNameParams;
|
|
596
802
|
workspace_remove_worktree_params: WorkspaceRemoveWorktreeParams;
|
|
597
803
|
workspace_rename_params: WorkspaceRenameParams;
|
|
804
|
+
workspace_root_info: WorkspaceRootInfo;
|
|
598
805
|
workspace_trash_id_params: WorkspaceTrashIdParams;
|
|
599
806
|
workspace_trash_list_result: WorkspaceTrashListResult;
|
|
600
807
|
workspace_worktrees_params: WorkspaceWorktreesParams;
|
|
@@ -645,7 +852,8 @@ export interface AgentInfo {
|
|
|
645
852
|
}
|
|
646
853
|
export interface AgentCapabilities {
|
|
647
854
|
/**
|
|
648
|
-
*
|
|
855
|
+
* agent **原生**收的附件 mime,如 `image/png`。其它附件(非图片、这里没列出的图片格式)不受它限制:daemon 把它们落到
|
|
856
|
+
* 会话工作目录并在文字里附上路径(ADR-44)。
|
|
649
857
|
*/
|
|
650
858
|
attachments?: string[];
|
|
651
859
|
/**
|
|
@@ -746,7 +954,7 @@ export interface AgentListResult {
|
|
|
746
954
|
not_modified?: boolean;
|
|
747
955
|
}
|
|
748
956
|
/**
|
|
749
|
-
* 消息里的一个附件(ADR-35):指向 daemon 上已经传完的 blob
|
|
957
|
+
* 消息里的一个附件(ADR-35、ADR-44):指向 daemon 上已经传完的 blob(图片或任意文件)。客户端从 `blob.put_end` 拿到它、原样放进
|
|
750
958
|
* `session.send` / `session.create`;daemon 以自己记录的元数据为准写进 `user_message` 事件。
|
|
751
959
|
*/
|
|
752
960
|
export interface AttachmentRef {
|
|
@@ -756,7 +964,7 @@ export interface AttachmentRef {
|
|
|
756
964
|
mime: string;
|
|
757
965
|
name: string;
|
|
758
966
|
/**
|
|
759
|
-
* 图片像素宽高(daemon
|
|
967
|
+
* 图片像素宽高(daemon 读文件头得出;读不出来、不是图片时省略)。客户端用来在下载前占好位置。
|
|
760
968
|
*/
|
|
761
969
|
width?: number | null;
|
|
762
970
|
}
|
|
@@ -794,11 +1002,13 @@ export interface BlobIdParams {
|
|
|
794
1002
|
*/
|
|
795
1003
|
export interface BlobPutBeginParams {
|
|
796
1004
|
/**
|
|
797
|
-
*
|
|
1005
|
+
* 任意 `type/subtype`:不合法或空的按 `application/octet-stream` 记录(不报错),大小写和 `;` 之后的参数规整掉。
|
|
1006
|
+
* 声明为 `image/png` `image/jpeg` `image/gif` `image/webp` 的才校验文件头、读宽高。
|
|
798
1007
|
*/
|
|
799
1008
|
mime: string;
|
|
800
1009
|
/**
|
|
801
|
-
* 展示用的文件名(1–255 字节,不能含 `/` `\`
|
|
1010
|
+
* 展示用的文件名(1–255 字节,不能含 `/` `\` 和控制字符)。非图片的存储扩展名取自它(清洗过),落到工作目录时也用它
|
|
1011
|
+
* 作文件名;daemon 不用它拼出别的路径。
|
|
802
1012
|
*/
|
|
803
1013
|
name: string;
|
|
804
1014
|
/**
|
|
@@ -880,6 +1090,47 @@ export interface ClientInfo {
|
|
|
880
1090
|
*/
|
|
881
1091
|
version: string;
|
|
882
1092
|
}
|
|
1093
|
+
/**
|
|
1094
|
+
* `node.set_config` 的一项改动。
|
|
1095
|
+
*/
|
|
1096
|
+
export interface ConfigChange {
|
|
1097
|
+
key: string;
|
|
1098
|
+
/**
|
|
1099
|
+
* 新值,JSON 类型要和该键的 `kind` 一致(布尔、整数、字符串)。
|
|
1100
|
+
*/
|
|
1101
|
+
value: unknown;
|
|
1102
|
+
}
|
|
1103
|
+
/**
|
|
1104
|
+
* `node.get_config` 的一项:一个可以远程查看的配置键。
|
|
1105
|
+
*/
|
|
1106
|
+
export interface ConfigItem {
|
|
1107
|
+
editable: ConfigEditable;
|
|
1108
|
+
/**
|
|
1109
|
+
* 被 `ANYCON_*` 环境变量覆盖(`log.level` 还包括 `ANYCON_LOG` / `RUST_LOG`)。为真时 `editable` 一定是 `no`。
|
|
1110
|
+
*/
|
|
1111
|
+
env_override?: boolean;
|
|
1112
|
+
/**
|
|
1113
|
+
* 点分隔的键,和 `config.toml` 一致(`sessions.max_concurrent`)。
|
|
1114
|
+
*/
|
|
1115
|
+
key: string;
|
|
1116
|
+
kind: ConfigValueKind;
|
|
1117
|
+
/**
|
|
1118
|
+
* 取值上限:`int` 是数值,`duration` 是毫秒,`text` 是字符数。
|
|
1119
|
+
*/
|
|
1120
|
+
max?: number | null;
|
|
1121
|
+
/**
|
|
1122
|
+
* 取值下限:`int` 是数值,`duration` 是毫秒,`text` 不用。
|
|
1123
|
+
*/
|
|
1124
|
+
min?: number | null;
|
|
1125
|
+
/**
|
|
1126
|
+
* `kind = enum` 时允许的取值。
|
|
1127
|
+
*/
|
|
1128
|
+
options?: string[];
|
|
1129
|
+
/**
|
|
1130
|
+
* 当前生效的值(默认值 → 文件 → 环境变量合并后的结果):布尔、整数或字符串,类型见 `kind`。
|
|
1131
|
+
*/
|
|
1132
|
+
value: unknown;
|
|
1133
|
+
}
|
|
883
1134
|
export interface Quota {
|
|
884
1135
|
connections: number;
|
|
885
1136
|
connections_max?: number | null;
|
|
@@ -1023,12 +1274,22 @@ export interface PermissionDetail {
|
|
|
1023
1274
|
* kind = tool
|
|
1024
1275
|
*/
|
|
1025
1276
|
tool?: ToolPermissionDetail | null;
|
|
1277
|
+
/**
|
|
1278
|
+
* kind = other:要用户在浏览器里打开的链接(MCP server 的 URL 模式 elicitation)。只会是 `http` / `https`;
|
|
1279
|
+
* 客户端只对这两种协议提供「打开」入口,并且显示完整 URL。
|
|
1280
|
+
*/
|
|
1281
|
+
url?: string | null;
|
|
1026
1282
|
}
|
|
1027
1283
|
export interface Question {
|
|
1028
1284
|
choices?: QuestionChoice[];
|
|
1029
1285
|
free_text?: boolean;
|
|
1030
1286
|
id: string;
|
|
1031
1287
|
multi?: boolean;
|
|
1288
|
+
/**
|
|
1289
|
+
* 可以不答:客户端允许留空提交,答复里就没有这一题的答案。默认 `false`(必答),
|
|
1290
|
+
* 所以 AskUserQuestion 这类每题都要答的行为不变;MCP elicitation 表单里 schema 没列进 `required` 的字段是 `true`。
|
|
1291
|
+
*/
|
|
1292
|
+
optional?: boolean;
|
|
1032
1293
|
text: string;
|
|
1033
1294
|
}
|
|
1034
1295
|
export interface QuestionChoice {
|
|
@@ -1060,6 +1321,15 @@ export interface PermissionOption {
|
|
|
1060
1321
|
export interface Usage {
|
|
1061
1322
|
cache_read_tokens?: number | null;
|
|
1062
1323
|
cache_write_tokens?: number | null;
|
|
1324
|
+
/**
|
|
1325
|
+
* turn 结束时上下文已经占用的 token:最近一次模型请求的输入 + 缓存读写。和 `input_tokens` 等
|
|
1326
|
+
* 累计用量不同,它是「此刻窗口里有多少」,客户端拿它和 `context_window` 算占用比例。agent 不报就缺省。
|
|
1327
|
+
*/
|
|
1328
|
+
context_tokens?: number | null;
|
|
1329
|
+
/**
|
|
1330
|
+
* 模型的上下文窗口大小(token)。agent 不报就缺省。
|
|
1331
|
+
*/
|
|
1332
|
+
context_window?: number | null;
|
|
1063
1333
|
cost_usd?: number | null;
|
|
1064
1334
|
duration_ms: number;
|
|
1065
1335
|
input_tokens?: number | null;
|
|
@@ -1092,6 +1362,56 @@ export interface SessionSettings {
|
|
|
1092
1362
|
*/
|
|
1093
1363
|
thinking?: string | null;
|
|
1094
1364
|
}
|
|
1365
|
+
/**
|
|
1366
|
+
* workflow 里的一个 agent。
|
|
1367
|
+
*/
|
|
1368
|
+
export interface TaskAgent {
|
|
1369
|
+
/**
|
|
1370
|
+
* 第几次尝试(重试过才有)。
|
|
1371
|
+
*/
|
|
1372
|
+
attempt?: number | null;
|
|
1373
|
+
/**
|
|
1374
|
+
* 结果来自缓存,没有真的运行。
|
|
1375
|
+
*/
|
|
1376
|
+
cached?: boolean | null;
|
|
1377
|
+
duration_ms?: number | null;
|
|
1378
|
+
/**
|
|
1379
|
+
* `state = failed` 时的错误信息。
|
|
1380
|
+
*/
|
|
1381
|
+
error?: string | null;
|
|
1382
|
+
/**
|
|
1383
|
+
* 在 workflow 里的序号,同一个任务内唯一。
|
|
1384
|
+
*/
|
|
1385
|
+
index: number;
|
|
1386
|
+
label: string;
|
|
1387
|
+
/**
|
|
1388
|
+
* 最近一次调用的工具名。
|
|
1389
|
+
*/
|
|
1390
|
+
last_tool?: string | null;
|
|
1391
|
+
model?: string | null;
|
|
1392
|
+
/**
|
|
1393
|
+
* 所属阶段的 `TaskPhase.index`。
|
|
1394
|
+
*/
|
|
1395
|
+
phase_index?: number | null;
|
|
1396
|
+
state: TaskAgentState;
|
|
1397
|
+
tokens?: number | null;
|
|
1398
|
+
tool_calls?: number | null;
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* workflow 的一个阶段。
|
|
1402
|
+
*/
|
|
1403
|
+
export interface TaskPhase {
|
|
1404
|
+
index: number;
|
|
1405
|
+
title: string;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* 任务的用量。每个字段 agent 不报就缺省。
|
|
1409
|
+
*/
|
|
1410
|
+
export interface TaskUsage {
|
|
1411
|
+
duration_ms?: number | null;
|
|
1412
|
+
tool_calls?: number | null;
|
|
1413
|
+
total_tokens?: number | null;
|
|
1414
|
+
}
|
|
1095
1415
|
export interface FsListParams {
|
|
1096
1416
|
/**
|
|
1097
1417
|
* `<项目名>/<项目内的相对路径>`,如 `my-app/src`。第一段是关联项目的名字时,其余部分相对那个目录解析,
|
|
@@ -1110,21 +1430,50 @@ export interface FsEntry {
|
|
|
1110
1430
|
}
|
|
1111
1431
|
export interface FsReadParams {
|
|
1112
1432
|
/**
|
|
1113
|
-
*
|
|
1433
|
+
* 缺省 `text`。
|
|
1434
|
+
*/
|
|
1435
|
+
encoding?: FsReadEncoding & string;
|
|
1436
|
+
/**
|
|
1437
|
+
* 读多少**原始字节**。`encoding = text`:默认 1 MiB,上限 10 MiB。`encoding = base64`:一次最多一块(512 KiB,和
|
|
1438
|
+
* `blob.get` 一样),缺省就是一块,超过的按一块算(不报错);`0` 只回大小、不带数据。
|
|
1114
1439
|
*/
|
|
1115
1440
|
max_bytes?: number | null;
|
|
1441
|
+
/**
|
|
1442
|
+
* 从文件的第几个字节读起,缺省 0。只有 `encoding = base64` 能用:大文件按块一块一块读,一个响应不会长时间占住设备到 daemon
|
|
1443
|
+
* 那条有序的传输。`text` 模式下 `offset > 0` 是 `invalid`。
|
|
1444
|
+
*/
|
|
1445
|
+
offset?: number;
|
|
1116
1446
|
/**
|
|
1117
1447
|
* 解析规则同 `FsListParams.path`。
|
|
1118
1448
|
*/
|
|
1119
1449
|
path: string;
|
|
1120
1450
|
}
|
|
1121
1451
|
export interface FsReadResult {
|
|
1452
|
+
/**
|
|
1453
|
+
* `text` 模式:文件是二进制(不返回内容)。`base64` 模式:按**这一块**的内容判断(前 8 KiB 里有 NUL、或不是合法的
|
|
1454
|
+
* UTF-8),只有 `offset = 0` 的那一块说明整个文件;从中间读起的块可能从半个字符开始,客户端不要依赖它。
|
|
1455
|
+
*/
|
|
1122
1456
|
binary: boolean;
|
|
1457
|
+
/**
|
|
1458
|
+
* 文件的总字节数(不是读到的)。分块读的时候每一块都带着它:总数变了说明文件在读的过程中被改写过。
|
|
1459
|
+
*/
|
|
1123
1460
|
bytes: number;
|
|
1124
1461
|
/**
|
|
1125
|
-
*
|
|
1462
|
+
* `encoding = base64` 时读到的字节(至多一块;`offset` 在文件末尾或之后时为空串);`text` 模式没有这个字段。
|
|
1463
|
+
*/
|
|
1464
|
+
data_base64?: string | null;
|
|
1465
|
+
/**
|
|
1466
|
+
* `encoding = base64` 时 `data_base64` 从文件的第几个字节开始(原样回显请求的 `offset`);`text` 模式没有这个字段。
|
|
1467
|
+
* 不认识 `offset` 的旧 daemon 不会带它,客户端据此知道分块读不能用。
|
|
1468
|
+
*/
|
|
1469
|
+
offset?: number | null;
|
|
1470
|
+
/**
|
|
1471
|
+
* UTF-8 文本;二进制文件 `text` 为空且 `binary = true`。`encoding = base64` 时恒为空。
|
|
1126
1472
|
*/
|
|
1127
1473
|
text: string;
|
|
1474
|
+
/**
|
|
1475
|
+
* 文件在读到的这一段**之后**还有内容(`offset + 读到的字节数 < bytes`)。
|
|
1476
|
+
*/
|
|
1128
1477
|
truncated: boolean;
|
|
1129
1478
|
}
|
|
1130
1479
|
export interface JobCancelParams {
|
|
@@ -1160,6 +1509,12 @@ export interface AuditEntry {
|
|
|
1160
1509
|
target?: string | null;
|
|
1161
1510
|
ts_ms: number;
|
|
1162
1511
|
}
|
|
1512
|
+
/**
|
|
1513
|
+
* `node.get_config` / `node.set_config` 的结果:白名单里的全部配置项(顺序固定,按段分组)。
|
|
1514
|
+
*/
|
|
1515
|
+
export interface NodeConfigResult {
|
|
1516
|
+
items: ConfigItem[];
|
|
1517
|
+
}
|
|
1163
1518
|
export interface NodeDevicesResult {
|
|
1164
1519
|
devices: PeerDevice[];
|
|
1165
1520
|
}
|
|
@@ -1248,6 +1603,10 @@ export interface NodeEnrollStatusResult {
|
|
|
1248
1603
|
* `node.info` 结果。
|
|
1249
1604
|
*/
|
|
1250
1605
|
export interface NodeInfo {
|
|
1606
|
+
/**
|
|
1607
|
+
* `capabilities.blobs` 为 true 时给出。
|
|
1608
|
+
*/
|
|
1609
|
+
attachment_limits?: NodeAttachmentLimits | null;
|
|
1251
1610
|
capabilities: NodeCapabilities;
|
|
1252
1611
|
name: string;
|
|
1253
1612
|
node_id: string;
|
|
@@ -1255,16 +1614,49 @@ export interface NodeInfo {
|
|
|
1255
1614
|
protocol_version: number;
|
|
1256
1615
|
started_at_ms: number;
|
|
1257
1616
|
version: string;
|
|
1617
|
+
/**
|
|
1618
|
+
* 主根。多个根时看 `workspace_roots`。
|
|
1619
|
+
*/
|
|
1258
1620
|
workspace_root?: string | null;
|
|
1621
|
+
/**
|
|
1622
|
+
* 所有 workspace 根,主根在最前,额外根按配置顺序。老版本的 daemon 不给,客户端当作只有 `workspace_root` 一个。
|
|
1623
|
+
*/
|
|
1624
|
+
workspace_roots?: WorkspaceRootInfo[];
|
|
1259
1625
|
/**
|
|
1260
1626
|
* `capabilities.worktree` 为 true 时给出。
|
|
1261
1627
|
*/
|
|
1262
1628
|
worktree?: NodeWorktreeSettings | null;
|
|
1263
1629
|
}
|
|
1630
|
+
/**
|
|
1631
|
+
* 附件的上限(`node.info`),客户端据此在上传之前就拒绝明显超限的文件。
|
|
1632
|
+
*/
|
|
1633
|
+
export interface NodeAttachmentLimits {
|
|
1634
|
+
/**
|
|
1635
|
+
* 单个附件的字节上限(`sessions.max_attachment_bytes`,热加载;这里是 `node.info` 被调用那一刻的值)。
|
|
1636
|
+
*/
|
|
1637
|
+
max_bytes: number;
|
|
1638
|
+
/**
|
|
1639
|
+
* 一条消息的附件字节合计上限。
|
|
1640
|
+
*/
|
|
1641
|
+
max_message_bytes: number;
|
|
1642
|
+
/**
|
|
1643
|
+
* 一条消息至多带几个附件。
|
|
1644
|
+
*/
|
|
1645
|
+
max_per_message: number;
|
|
1646
|
+
}
|
|
1264
1647
|
export interface NodeCapabilities {
|
|
1265
1648
|
audit: boolean;
|
|
1266
1649
|
blobs: boolean;
|
|
1650
|
+
/**
|
|
1651
|
+
* daemon 能把任意类型的文件交给任何会话的 agent(非图片、agent 不原生收的图片落到会话工作目录,ADR-44)。
|
|
1652
|
+
* 为 false(旧 daemon)时客户端只能上传图片。
|
|
1653
|
+
*/
|
|
1654
|
+
file_attachments?: boolean;
|
|
1267
1655
|
fs: boolean;
|
|
1656
|
+
/**
|
|
1657
|
+
* 支持 dev server 预览(`preview.*`,ADR-39),且节点配置 `preview.enabled = true`。
|
|
1658
|
+
*/
|
|
1659
|
+
preview?: boolean;
|
|
1268
1660
|
search: boolean;
|
|
1269
1661
|
/**
|
|
1270
1662
|
* 有 workspace(文件夹即项目)。SDK 节点可能没有。
|
|
@@ -1275,6 +1667,24 @@ export interface NodeCapabilities {
|
|
|
1275
1667
|
*/
|
|
1276
1668
|
worktree?: boolean;
|
|
1277
1669
|
}
|
|
1670
|
+
/**
|
|
1671
|
+
* 一个 workspace 根(ADR-45)。每个根下的一级子文件夹都是项目。
|
|
1672
|
+
*/
|
|
1673
|
+
export interface WorkspaceRootInfo {
|
|
1674
|
+
/**
|
|
1675
|
+
* 现在能用:daemon 启动时它是一个存在的目录,并且现在还在。不可用的根下的项目不出现在列表里,也不能在上面新建 / 克隆;
|
|
1676
|
+
* 配置只在启动时读,修好(挂上外接盘)之后要重启 daemon。
|
|
1677
|
+
*/
|
|
1678
|
+
available: boolean;
|
|
1679
|
+
/**
|
|
1680
|
+
* canonical 绝对路径(根不可用时是展开后的配置值)。`workspace.create` / `clone` 的 `root` 取这里的值。
|
|
1681
|
+
*/
|
|
1682
|
+
path: string;
|
|
1683
|
+
/**
|
|
1684
|
+
* 主根:放 `.scratch/`,不指定 `root` 时新项目建在这里。恰好有一个。
|
|
1685
|
+
*/
|
|
1686
|
+
primary: boolean;
|
|
1687
|
+
}
|
|
1278
1688
|
/**
|
|
1279
1689
|
* 节点的 worktree 配置(`config.toml` 的 `[worktree]`),客户端据此决定新建会话的初始选择和分支名预览。
|
|
1280
1690
|
*/
|
|
@@ -1288,6 +1698,32 @@ export interface NodeWorktreeSettings {
|
|
|
1288
1698
|
*/
|
|
1289
1699
|
default_mode: SessionWorkspaceMode;
|
|
1290
1700
|
}
|
|
1701
|
+
/**
|
|
1702
|
+
* `node.logs` 参数。
|
|
1703
|
+
*/
|
|
1704
|
+
export interface NodeLogsParams {
|
|
1705
|
+
/**
|
|
1706
|
+
* 最低级别:只返回这个级别及更高级别的行。缺省 = 不过滤。
|
|
1707
|
+
*/
|
|
1708
|
+
level?: NodeLogLevel | null;
|
|
1709
|
+
/**
|
|
1710
|
+
* 最多返回多少行,缺省 200,最大 1000(超出按 1000)。
|
|
1711
|
+
*/
|
|
1712
|
+
lines?: number | null;
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* `node.logs` 结果。
|
|
1716
|
+
*/
|
|
1717
|
+
export interface NodeLogsResult {
|
|
1718
|
+
/**
|
|
1719
|
+
* 日志行,旧的在前、新的在后;每行最多 2 KiB(超出的截断,行尾加 `…`)。
|
|
1720
|
+
*/
|
|
1721
|
+
lines: string[];
|
|
1722
|
+
/**
|
|
1723
|
+
* 还有更早的行没有返回(行数到了上限,或扫描的日志量到了上限)。
|
|
1724
|
+
*/
|
|
1725
|
+
truncated: boolean;
|
|
1726
|
+
}
|
|
1291
1727
|
export interface NodePairBeginParams {
|
|
1292
1728
|
/**
|
|
1293
1729
|
* `true`(缺省)= 16 位短码(约 79 bit;链接、二维码、默认都是它);`false` = 8 位(约 40 bit),
|
|
@@ -1349,6 +1785,15 @@ export interface NodeSetAgentDefaultsParams {
|
|
|
1349
1785
|
} | null;
|
|
1350
1786
|
thinking?: string | null;
|
|
1351
1787
|
}
|
|
1788
|
+
/**
|
|
1789
|
+
* `node.set_config` 参数。所有改动先校验,任何一项不合法就一项都不写。
|
|
1790
|
+
*
|
|
1791
|
+
* 错误:键不在白名单、被环境变量覆盖、想放宽只能收紧的键 → `forbidden`(`data.field` 是键,`data.reason` 是
|
|
1792
|
+
* `not_editable` / `env_override` / `tighten_only`);值的类型或取值不合法、键重复、`changes` 为空 → `invalid`(`data.field` 是键)。
|
|
1793
|
+
*/
|
|
1794
|
+
export interface NodeSetConfigParams {
|
|
1795
|
+
changes: ConfigChange[];
|
|
1796
|
+
}
|
|
1352
1797
|
/**
|
|
1353
1798
|
* `node.set_enroll_enabled` 参数:写 `[enroll]` 配置。`password: true` 同时解除锁定、失败计数清零。
|
|
1354
1799
|
*/
|
|
@@ -1461,7 +1906,171 @@ export interface PermissionRespondParams {
|
|
|
1461
1906
|
request_id: string;
|
|
1462
1907
|
}
|
|
1463
1908
|
/**
|
|
1464
|
-
*
|
|
1909
|
+
* `preview.close` 参数:作废这个 label 的全部票据,断开它的全部隧道。
|
|
1910
|
+
*/
|
|
1911
|
+
export interface PreviewCloseParams {
|
|
1912
|
+
label: string;
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* 隧道 `GOAWAY` 帧的载荷(msgpack,只有 daemon 发,stream 0):daemon 要关掉这条隧道,之后不再处理它的帧。
|
|
1916
|
+
*/
|
|
1917
|
+
export interface PreviewGoaway {
|
|
1918
|
+
code: PreviewGoawayCode;
|
|
1919
|
+
message?: string | null;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* 隧道握手第二条消息(daemon → 预览页)的 payload,JSON。到这一条预览页才确认对端持有票据、是钉住的 daemon。
|
|
1923
|
+
*/
|
|
1924
|
+
export interface PreviewHello {
|
|
1925
|
+
expires_at_ms: number;
|
|
1926
|
+
port: number;
|
|
1927
|
+
session_id?: string | null;
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* `preview.list` 的一项:一张未过期的票据。
|
|
1931
|
+
*/
|
|
1932
|
+
export interface PreviewInfo {
|
|
1933
|
+
created_at_ms: number;
|
|
1934
|
+
/**
|
|
1935
|
+
* 签发这张票据的设备。
|
|
1936
|
+
*/
|
|
1937
|
+
created_by: string;
|
|
1938
|
+
created_by_name: string;
|
|
1939
|
+
expires_at_ms: number;
|
|
1940
|
+
label: string;
|
|
1941
|
+
port: number;
|
|
1942
|
+
session_id?: string | null;
|
|
1943
|
+
ticket_id: string;
|
|
1944
|
+
/**
|
|
1945
|
+
* 此刻用这张票据建立的隧道数。
|
|
1946
|
+
*/
|
|
1947
|
+
tunnels: number;
|
|
1948
|
+
}
|
|
1949
|
+
/**
|
|
1950
|
+
* 预览页的启动参数。Web UI 把它序列化成 JSON、再 base64url(无填充),放进
|
|
1951
|
+
* `<预览 origin>/__anycon/enter#<…>` 的 fragment(浏览器不会把 fragment 发给 hub)。引导页读出后存进预览 origin 的
|
|
1952
|
+
* IndexedDB,立即从地址栏抹掉。
|
|
1953
|
+
*/
|
|
1954
|
+
export interface PreviewLaunch {
|
|
1955
|
+
/**
|
|
1956
|
+
* 票据和令牌里较早的那个过期时间。
|
|
1957
|
+
*/
|
|
1958
|
+
expires_at_ms: number;
|
|
1959
|
+
label: string;
|
|
1960
|
+
/**
|
|
1961
|
+
* daemon 的设备 id。
|
|
1962
|
+
*/
|
|
1963
|
+
node: string;
|
|
1964
|
+
/**
|
|
1965
|
+
* daemon 的 Noise 静态公钥,64 个小写 hex。预览页用它做 NK 握手(钉住 daemon)。
|
|
1966
|
+
*/
|
|
1967
|
+
node_public: string;
|
|
1968
|
+
/**
|
|
1969
|
+
* 打开后先导航到的路径(以 `/` 开头,可带查询串)。
|
|
1970
|
+
*/
|
|
1971
|
+
path: string;
|
|
1972
|
+
port: number;
|
|
1973
|
+
psk: string;
|
|
1974
|
+
ticket_id: string;
|
|
1975
|
+
/**
|
|
1976
|
+
* hub 签发的预览令牌(`POST /api/preview/tokens`),预览连接凭它向 hub 认证。
|
|
1977
|
+
*/
|
|
1978
|
+
token: string;
|
|
1979
|
+
/**
|
|
1980
|
+
* 格式版本,目前是 1。
|
|
1981
|
+
*/
|
|
1982
|
+
v: number;
|
|
1983
|
+
}
|
|
1984
|
+
export interface PreviewListResult {
|
|
1985
|
+
previews: PreviewInfo[];
|
|
1986
|
+
}
|
|
1987
|
+
/**
|
|
1988
|
+
* `preview.open` 参数:为本机 `port` 签发一张预览票据。
|
|
1989
|
+
*/
|
|
1990
|
+
export interface PreviewOpenParams {
|
|
1991
|
+
port: number;
|
|
1992
|
+
/**
|
|
1993
|
+
* 从哪个会话发起(只用于界面展示和审计;端口是否允许不看它,见 spec/daemon.md § 19.3)。
|
|
1994
|
+
*/
|
|
1995
|
+
session_id?: string | null;
|
|
1996
|
+
}
|
|
1997
|
+
/**
|
|
1998
|
+
* `preview.open` 结果。`psk` 是票据的密钥,只交给预览页(放进 [`PreviewLaunch`]),不要写日志、不要发给 hub。
|
|
1999
|
+
*/
|
|
2000
|
+
export interface PreviewOpenResult {
|
|
2001
|
+
expires_at_ms: number;
|
|
2002
|
+
/**
|
|
2003
|
+
* 这个端口固定的预览 label(26 位小写 base32),预览 origin 是 `<label>.<预览域名>`。
|
|
2004
|
+
*/
|
|
2005
|
+
label: string;
|
|
2006
|
+
port: number;
|
|
2007
|
+
/**
|
|
2008
|
+
* 票据密钥,64 个小写 hex(32 字节),Noise PSK。
|
|
2009
|
+
*/
|
|
2010
|
+
psk: string;
|
|
2011
|
+
session_id?: string | null;
|
|
2012
|
+
/**
|
|
2013
|
+
* 票据 id,32 个小写 hex(16 字节)。
|
|
2014
|
+
*/
|
|
2015
|
+
ticket_id: string;
|
|
2016
|
+
}
|
|
2017
|
+
export interface PreviewPort {
|
|
2018
|
+
pid?: number | null;
|
|
2019
|
+
port: number;
|
|
2020
|
+
/**
|
|
2021
|
+
* 进程名(可执行文件名,不含参数)。
|
|
2022
|
+
*/
|
|
2023
|
+
process?: string | null;
|
|
2024
|
+
session_id?: string | null;
|
|
2025
|
+
source: PreviewPortSource;
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* `preview.ports` 参数。带 `session_id` 只列这个会话的端口(外加配置里允许的端口)。
|
|
2029
|
+
*/
|
|
2030
|
+
export interface PreviewPortsParams {
|
|
2031
|
+
session_id?: string | null;
|
|
2032
|
+
}
|
|
2033
|
+
export interface PreviewPortsResult {
|
|
2034
|
+
detection: PreviewDetection;
|
|
2035
|
+
ports: PreviewPort[];
|
|
2036
|
+
}
|
|
2037
|
+
/**
|
|
2038
|
+
* 隧道 `REQUEST` 帧的载荷(msgpack,字段名为键)。
|
|
2039
|
+
*/
|
|
2040
|
+
export interface PreviewRequestHead {
|
|
2041
|
+
/**
|
|
2042
|
+
* 请求头,按原顺序,名字小写。`cookie` 来自预览页自己的 cookie jar;daemon 转发前改写哪些头见
|
|
2043
|
+
* spec/daemon.md § 19.5。
|
|
2044
|
+
*/
|
|
2045
|
+
headers: [string, string][];
|
|
2046
|
+
method: string;
|
|
2047
|
+
/**
|
|
2048
|
+
* 以 `/` 开头,可带查询串;不含 scheme 和主机。
|
|
2049
|
+
*/
|
|
2050
|
+
path: string;
|
|
2051
|
+
/**
|
|
2052
|
+
* `true`:这是一个 WebSocket 升级请求(`method` 为 `GET`,子协议在 `sec-websocket-protocol` 头里)。
|
|
2053
|
+
*/
|
|
2054
|
+
websocket?: boolean;
|
|
2055
|
+
}
|
|
2056
|
+
/**
|
|
2057
|
+
* 隧道 `RESET` 帧的载荷(msgpack):终止这个 stream 的两个方向。
|
|
2058
|
+
*/
|
|
2059
|
+
export interface PreviewReset {
|
|
2060
|
+
code: PreviewResetCode;
|
|
2061
|
+
message?: string | null;
|
|
2062
|
+
}
|
|
2063
|
+
/**
|
|
2064
|
+
* 隧道 `RESPONSE` 帧的载荷(msgpack)。WebSocket 流里 `status = 101` 表示升级成功,其他状态码表示被拒,
|
|
2065
|
+
* 后面跟普通响应体。
|
|
2066
|
+
*/
|
|
2067
|
+
export interface PreviewResponseHead {
|
|
2068
|
+
encoding?: PreviewBodyEncoding & string;
|
|
2069
|
+
headers: [string, string][];
|
|
2070
|
+
status: number;
|
|
2071
|
+
}
|
|
2072
|
+
/**
|
|
2073
|
+
* 一个项目 = 某个 workspace 根目录下的一个一级子文件夹,或一个关联的本机目录(`kind = linked`)。
|
|
1465
2074
|
* 元数据全部推导;只有「关联了哪些目录」存在 daemon 的库里。
|
|
1466
2075
|
*/
|
|
1467
2076
|
export interface Project {
|
|
@@ -1483,13 +2092,18 @@ export interface Project {
|
|
|
1483
2092
|
missing?: boolean;
|
|
1484
2093
|
modified_at_ms: number;
|
|
1485
2094
|
/**
|
|
1486
|
-
*
|
|
2095
|
+
* 项目名。所有 workspace 根下的项目和关联的项目共用一个命名空间,客户端的所有操作都用它。
|
|
1487
2096
|
*/
|
|
1488
2097
|
name: string;
|
|
1489
2098
|
/**
|
|
1490
2099
|
* 绝对路径,仅展示用。
|
|
1491
2100
|
*/
|
|
1492
2101
|
path: string;
|
|
2102
|
+
/**
|
|
2103
|
+
* 文件夹项目所在的 workspace 根(canonical 绝对路径,等于 `node.info.workspace_roots` 里的某一项的 `path`);
|
|
2104
|
+
* 关联项目没有。老版本的 daemon 不给,客户端当作主根。
|
|
2105
|
+
*/
|
|
2106
|
+
root?: string | null;
|
|
1493
2107
|
}
|
|
1494
2108
|
export interface GitMeta {
|
|
1495
2109
|
branch?: string | null;
|
|
@@ -1612,7 +2226,8 @@ export interface SessionWorktree {
|
|
|
1612
2226
|
export interface SessionCreateParams {
|
|
1613
2227
|
agent: string;
|
|
1614
2228
|
/**
|
|
1615
|
-
* 第一条消息的附件(`blob.put_end` 的结果)。agent
|
|
2229
|
+
* 第一条消息的附件(`blob.put_end` 的结果)。agent 原生收的 mime(`capabilities.attachments`)交给 adapter,
|
|
2230
|
+
* 其余落到会话工作目录、路径写在交给 agent 的文字里(ADR-44)。
|
|
1616
2231
|
*/
|
|
1617
2232
|
attachments?: AttachmentRef[];
|
|
1618
2233
|
/**
|
|
@@ -1828,26 +2443,45 @@ export interface SessionRenameParams {
|
|
|
1828
2443
|
title: string;
|
|
1829
2444
|
}
|
|
1830
2445
|
export interface SessionSearchParams {
|
|
2446
|
+
/**
|
|
2447
|
+
* 最多返回几条命中,默认 20,上限 200。
|
|
2448
|
+
*/
|
|
1831
2449
|
limit?: number | null;
|
|
2450
|
+
/**
|
|
2451
|
+
* 只搜这个项目里的会话。
|
|
2452
|
+
*/
|
|
1832
2453
|
project?: string | null;
|
|
2454
|
+
/**
|
|
2455
|
+
* 空白分隔的若干个词,每个词按前缀匹配、都要出现在同一段文字里;不能为空(`invalid`)。
|
|
2456
|
+
*/
|
|
1833
2457
|
query: string;
|
|
1834
2458
|
}
|
|
1835
2459
|
export interface SessionSearchResult {
|
|
1836
2460
|
hits: SearchHit[];
|
|
1837
2461
|
}
|
|
1838
2462
|
export interface SearchHit {
|
|
2463
|
+
/**
|
|
2464
|
+
* 命中的那段文字开始处的事件 seq:用户消息就是 `user_message` 的 seq;assistant 文字是那一段第一个 `text_delta` 的 seq
|
|
2465
|
+
* (长文字每 32 KiB 切一段索引,所以同一条回复可以有几个不同的 seq)。
|
|
2466
|
+
*/
|
|
1839
2467
|
seq: number;
|
|
1840
2468
|
session_id: string;
|
|
1841
2469
|
/**
|
|
1842
|
-
*
|
|
2470
|
+
* 命中处的片段。除了包住命中词的字面 `<mark>` / `</mark>`,里面没有 HTML:会话文字里原有的
|
|
2471
|
+
* `<` `>` `&` 已转义成 `<` `>` `&`,客户端按 `<mark>` 切开后把这三个实体还原成字符、
|
|
2472
|
+
* 当纯文本显示即可,不要当 HTML 解析。
|
|
1843
2473
|
*/
|
|
1844
2474
|
snippet: string;
|
|
2475
|
+
/**
|
|
2476
|
+
* 会话当前的标题。
|
|
2477
|
+
*/
|
|
1845
2478
|
title: string;
|
|
1846
2479
|
ts_ms: number;
|
|
1847
2480
|
}
|
|
1848
2481
|
export interface SessionSendParams {
|
|
1849
2482
|
/**
|
|
1850
|
-
* `blob.put_end` 的结果,每条至多 20 个。agent
|
|
2483
|
+
* `blob.put_end` 的结果,每条至多 20 个。agent 原生收的 mime(`capabilities.attachments`)交给 adapter,
|
|
2484
|
+
* 其余落到会话工作目录、路径写在交给 agent 的文字里(ADR-44)。
|
|
1851
2485
|
*/
|
|
1852
2486
|
attachments?: AttachmentRef[];
|
|
1853
2487
|
/**
|
|
@@ -1912,10 +2546,14 @@ export interface SessionSyncBaseResult {
|
|
|
1912
2546
|
export interface TrashEntry {
|
|
1913
2547
|
bytes: number;
|
|
1914
2548
|
/**
|
|
1915
|
-
* `.trash/` 下的目录名,如 `my-app-20261011T120000Z
|
|
2549
|
+
* `.trash/` 下的目录名,如 `my-app-20261011T120000Z`。每个根有自己的 `.trash/`,id 在所有根之间唯一。
|
|
1916
2550
|
*/
|
|
1917
2551
|
id: string;
|
|
1918
2552
|
original_name: string;
|
|
2553
|
+
/**
|
|
2554
|
+
* 条目所在(也是 `restore` 还原到)的 workspace 根。老版本的 daemon 不给,客户端当作主根。
|
|
2555
|
+
*/
|
|
2556
|
+
root?: string | null;
|
|
1919
2557
|
trashed_at_ms: number;
|
|
1920
2558
|
}
|
|
1921
2559
|
/**
|
|
@@ -2012,6 +2650,10 @@ export interface RenamedProject {
|
|
|
2012
2650
|
}
|
|
2013
2651
|
export interface WorkspaceCloneParams {
|
|
2014
2652
|
name?: string | null;
|
|
2653
|
+
/**
|
|
2654
|
+
* 克隆到哪个 workspace 根下,规则同 `WorkspaceCreateParams.root`。
|
|
2655
|
+
*/
|
|
2656
|
+
root?: string | null;
|
|
2015
2657
|
/**
|
|
2016
2658
|
* 只允许 `https://`、`ssh://`、`git@host:path` 三种形式。
|
|
2017
2659
|
*/
|
|
@@ -2020,6 +2662,11 @@ export interface WorkspaceCloneParams {
|
|
|
2020
2662
|
export interface WorkspaceCreateParams {
|
|
2021
2663
|
git_init?: boolean;
|
|
2022
2664
|
name: string;
|
|
2665
|
+
/**
|
|
2666
|
+
* 在哪个 workspace 根下新建。必须是 `node.info.workspace_roots` 里的某一项的 `path`;缺省 = 主根;
|
|
2667
|
+
* 不在列表里 → `invalid`,在列表里但现在不可用(`available = false`)→ `not_found`。
|
|
2668
|
+
*/
|
|
2669
|
+
root?: string | null;
|
|
2023
2670
|
}
|
|
2024
2671
|
/**
|
|
2025
2672
|
* `workspace.link`:把本机一个已有目录关联为项目。
|
|
@@ -2037,6 +2684,9 @@ export interface WorkspaceLinkParams {
|
|
|
2037
2684
|
}
|
|
2038
2685
|
export interface WorkspaceListResult {
|
|
2039
2686
|
projects: Project[];
|
|
2687
|
+
/**
|
|
2688
|
+
* 主根(`node.info.workspace_roots` 里 `primary` 的那一项)。其余根下的项目看 `Project.root`。
|
|
2689
|
+
*/
|
|
2040
2690
|
root: string;
|
|
2041
2691
|
}
|
|
2042
2692
|
export interface WorkspaceNameParams {
|