@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/dist/generated.d.ts
CHANGED
|
@@ -6,12 +6,21 @@ export type AgentStatus = ("ready" | "disabled" | "not_installed" | "not_authent
|
|
|
6
6
|
*/
|
|
7
7
|
export type LinkBlock = "hidden" | "sensitive" | "workspace" | "data_dir" | "filesystem_root";
|
|
8
8
|
export type DeviceKind = "daemon" | "web" | "cli" | "sdk";
|
|
9
|
+
/**
|
|
10
|
+
* 一项配置能不能被远程客户端改(ADR-43)。
|
|
11
|
+
*/
|
|
12
|
+
export type ConfigEditable = "any" | "tighten_only" | "no";
|
|
13
|
+
/**
|
|
14
|
+
* 配置值的类型,客户端据此选控件。
|
|
15
|
+
*/
|
|
16
|
+
export type ConfigValueKind = "bool" | "int" | "duration" | "enum" | "text";
|
|
9
17
|
/**
|
|
10
18
|
* 控制消息集合。方向见注释:D = 设备,H = hub。
|
|
11
19
|
*/
|
|
12
20
|
export type Control = {
|
|
13
21
|
client: ClientInfo;
|
|
14
22
|
device_token?: string | null;
|
|
23
|
+
preview_token?: string | null;
|
|
15
24
|
protocol_version: number;
|
|
16
25
|
type: "auth";
|
|
17
26
|
} | {
|
|
@@ -79,6 +88,10 @@ export type Control = {
|
|
|
79
88
|
} | {
|
|
80
89
|
device: string;
|
|
81
90
|
type: "peer_offline";
|
|
91
|
+
} | {
|
|
92
|
+
label: string;
|
|
93
|
+
peer: string;
|
|
94
|
+
type: "preview_peer";
|
|
82
95
|
} | {
|
|
83
96
|
seq: number;
|
|
84
97
|
to: string;
|
|
@@ -100,6 +113,7 @@ export type Control = {
|
|
|
100
113
|
type: "dropped";
|
|
101
114
|
} | {
|
|
102
115
|
retry_after_ms: number;
|
|
116
|
+
to?: string | null;
|
|
103
117
|
type: "rate_limited";
|
|
104
118
|
} | {
|
|
105
119
|
quota: Quota;
|
|
@@ -223,6 +237,11 @@ export type Event = {
|
|
|
223
237
|
id: string;
|
|
224
238
|
input?: unknown;
|
|
225
239
|
name: string;
|
|
240
|
+
/**
|
|
241
|
+
* 子 agent 内部的调用:启动这个子 agent 的那次调用(`category = subagent`)的 `id`。
|
|
242
|
+
* 子 agent 再启动子 agent 时一层层指上去;主 agent 自己的调用不带。
|
|
243
|
+
*/
|
|
244
|
+
parent_id?: string | null;
|
|
226
245
|
title: string;
|
|
227
246
|
type: "tool_call";
|
|
228
247
|
} | {
|
|
@@ -251,7 +270,18 @@ export type Event = {
|
|
|
251
270
|
title: string;
|
|
252
271
|
type: "permission";
|
|
253
272
|
} | {
|
|
273
|
+
/**
|
|
274
|
+
* 设备答复时带的 `answers`(kind = question:`{ [question_id]: 字符串或字符串数组 }`),原样记下,
|
|
275
|
+
* 客户端据此在历史里显示问题和回答。daemon 自己答复的(超时、取消、自动拒绝)没有。
|
|
276
|
+
*/
|
|
277
|
+
answers?: {
|
|
278
|
+
[k: string]: unknown;
|
|
279
|
+
} | null;
|
|
254
280
|
by_device: string;
|
|
281
|
+
/**
|
|
282
|
+
* 设备答复时附的话(拒绝的理由、跳过问题时的说明)。daemon 自己答复的没有。
|
|
283
|
+
*/
|
|
284
|
+
message?: string | null;
|
|
255
285
|
option_id?: string | null;
|
|
256
286
|
request_id: string;
|
|
257
287
|
type: "permission_resolved";
|
|
@@ -300,6 +330,79 @@ export type Event = {
|
|
|
300
330
|
message: string;
|
|
301
331
|
recoverable: boolean;
|
|
302
332
|
type: "error";
|
|
333
|
+
} | {
|
|
334
|
+
/**
|
|
335
|
+
* workflow 里的各个 agent,按 `index` 升序;非 workflow 为空。
|
|
336
|
+
*/
|
|
337
|
+
agents?: TaskAgent[];
|
|
338
|
+
/**
|
|
339
|
+
* agent 给任务的 id(Claude Code 的 `task_id`;Codex 子 agent 的 thread id)。会话内唯一。
|
|
340
|
+
*/
|
|
341
|
+
id: string;
|
|
342
|
+
kind: TaskKind;
|
|
343
|
+
/**
|
|
344
|
+
* 任务最近一次调用的工具名。
|
|
345
|
+
*/
|
|
346
|
+
last_tool?: string | null;
|
|
347
|
+
/**
|
|
348
|
+
* workflow 的阶段,按 `index` 升序;非 workflow 为空。
|
|
349
|
+
*/
|
|
350
|
+
phases?: TaskPhase[];
|
|
351
|
+
status: TaskStatus;
|
|
352
|
+
/**
|
|
353
|
+
* agent 给的进度 / 结果摘要。
|
|
354
|
+
*/
|
|
355
|
+
summary?: string | null;
|
|
356
|
+
/**
|
|
357
|
+
* workflow 的名字 / 任务描述。
|
|
358
|
+
*/
|
|
359
|
+
title: string;
|
|
360
|
+
/**
|
|
361
|
+
* 启动这个任务的 `tool_call` 的 `id`(Claude Code 的 `tool_use_id`;Codex 的 collab agent 调用 item id)。
|
|
362
|
+
* 客户端据此把进度挂在那个工具块上;对不上时单独成块。
|
|
363
|
+
*/
|
|
364
|
+
tool_id?: string | null;
|
|
365
|
+
type: "task";
|
|
366
|
+
usage?: TaskUsage | null;
|
|
367
|
+
} | {
|
|
368
|
+
code: string;
|
|
369
|
+
level: NoticeLevel;
|
|
370
|
+
/**
|
|
371
|
+
* agent 给的原文(通常是英文),可能是空串。`command_output` 里是本地命令的输出,可能多行。
|
|
372
|
+
*/
|
|
373
|
+
message: string;
|
|
374
|
+
/**
|
|
375
|
+
* `code = model_fallback`:原来的模型。
|
|
376
|
+
*/
|
|
377
|
+
model_from?: string | null;
|
|
378
|
+
/**
|
|
379
|
+
* `code = model_fallback`:实际使用的模型。
|
|
380
|
+
*/
|
|
381
|
+
model_to?: string | null;
|
|
382
|
+
/**
|
|
383
|
+
* `code = rate_limit`:限额恢复的时间。
|
|
384
|
+
*/
|
|
385
|
+
resets_at_ms?: number | null;
|
|
386
|
+
type: "notice";
|
|
387
|
+
} | {
|
|
388
|
+
/**
|
|
389
|
+
* `retrying`:这是第几次重试(从 1 开始)。
|
|
390
|
+
*/
|
|
391
|
+
attempt?: number | null;
|
|
392
|
+
/**
|
|
393
|
+
* `retrying`:距下一次重试的毫秒数。
|
|
394
|
+
*/
|
|
395
|
+
delay_ms?: number | null;
|
|
396
|
+
/**
|
|
397
|
+
* `retrying`:最多重试几次。
|
|
398
|
+
*/
|
|
399
|
+
max_attempts?: number | null;
|
|
400
|
+
/**
|
|
401
|
+
* `retrying`:触发重试的错误摘要,如 `529 overloaded_error`。
|
|
402
|
+
*/
|
|
403
|
+
reason?: string | null;
|
|
404
|
+
state: ActivityState;
|
|
405
|
+
type: "activity";
|
|
303
406
|
};
|
|
304
407
|
export type ToolCategory = "shell" | "file_edit" | "file_read" | "search" | "web" | "subagent" | "mcp" | "other";
|
|
305
408
|
export type EditKind = "edit" | "write" | "delete" | "move";
|
|
@@ -316,6 +419,32 @@ export type SessionStatus = ("starting" | "running" | "waiting_permission" | "id
|
|
|
316
419
|
* `Event::Git` 的动作。
|
|
317
420
|
*/
|
|
318
421
|
export type GitAction = ("sync_up_to_date" | "sync_merged" | "sync_conflicts" | "sync_aborted") | "worktree_created" | "worktree_failed" | "worktree_removed" | "worktree_kept" | "worktree_restored" | "worktree_missing";
|
|
422
|
+
/**
|
|
423
|
+
* workflow 里一个 agent 的状态。
|
|
424
|
+
*/
|
|
425
|
+
export type TaskAgentState = ("running" | "done" | "failed") | "queued" | "skipped";
|
|
426
|
+
/**
|
|
427
|
+
* `Event::Task` 的任务种类。
|
|
428
|
+
*/
|
|
429
|
+
export type TaskKind = "other" | "workflow" | "subagent" | "shell";
|
|
430
|
+
/**
|
|
431
|
+
* `Event::Task` 的任务状态。`Running` 以外的三个是收尾状态(终态):Claude Code 的任务进入终态后不会再变;
|
|
432
|
+
* Codex 的子 agent 是一个可以再收到输入的 thread,`Completed` 之后收到新输入、开始新 turn 就会回到 `Running`。
|
|
433
|
+
* 所以终态只说明「这一刻不在跑」,不保证同一个 `id` 以后不会再有快照;客户端始终以最新的一条为准。
|
|
434
|
+
*/
|
|
435
|
+
export type TaskStatus = ("running" | "completed" | "failed") | "cancelled";
|
|
436
|
+
/**
|
|
437
|
+
* `Event::Notice` 的级别。
|
|
438
|
+
*/
|
|
439
|
+
export type NoticeLevel = "info" | "warning";
|
|
440
|
+
/**
|
|
441
|
+
* `Event::Activity` 的状态。
|
|
442
|
+
*/
|
|
443
|
+
export type ActivityState = "none" | "retrying" | "compacting";
|
|
444
|
+
/**
|
|
445
|
+
* `fs.read` 返回内容的方式。
|
|
446
|
+
*/
|
|
447
|
+
export type FsReadEncoding = "text" | "base64";
|
|
319
448
|
/**
|
|
320
449
|
* 信封种类。hub 对每种的处理见 docs/protocol.md § 3。
|
|
321
450
|
*/
|
|
@@ -324,11 +453,34 @@ export type Kind = "handshake" | "data" | "notify" | "control";
|
|
|
324
453
|
* 节点配置 `worktree.default` 的取值,也是 `SessionWorkspace` 的两种模式。
|
|
325
454
|
*/
|
|
326
455
|
export type SessionWorkspaceMode = "local" | "worktree";
|
|
456
|
+
/**
|
|
457
|
+
* 日志级别,`node.logs` 的最低级别过滤。
|
|
458
|
+
*/
|
|
459
|
+
export type NodeLogLevel = "trace" | "debug" | "info" | "warn" | "error";
|
|
327
460
|
/**
|
|
328
461
|
* `node.security_event.kind`。
|
|
329
462
|
*/
|
|
330
463
|
export type SecurityEventKind = "device_enrolled" | "password_failures" | "password_locked" | "password_changed" | "settings_changed";
|
|
331
464
|
export type NotifyCategory = ("permission_requested" | "turn_finished" | "error" | "session_idle") | "enroll_requested" | "security";
|
|
465
|
+
/**
|
|
466
|
+
* 隧道里响应体的编码。`gzip`:`DATA` 帧拼起来是 gzip 流,预览页要先解压;`headers` 里已经去掉
|
|
467
|
+
* `content-encoding` / `content-length`。
|
|
468
|
+
*/
|
|
469
|
+
export type PreviewBodyEncoding = "identity" | "gzip";
|
|
470
|
+
/**
|
|
471
|
+
* 端口探测是否可用。`unavailable`:这台机器上没有可用的探测手段(如没有 `lsof`),只能预览配置里允许的端口。
|
|
472
|
+
*/
|
|
473
|
+
export type PreviewDetection = "ok" | "unavailable";
|
|
474
|
+
export type PreviewGoawayCode = "expired" | "closed" | "revoked" | "disabled" | "port_not_allowed" | "shutdown";
|
|
475
|
+
/**
|
|
476
|
+
* 这个端口为什么允许预览(spec/daemon.md § 19.3)。
|
|
477
|
+
*/
|
|
478
|
+
export type PreviewPortSource = "session" | "workspace" | "config";
|
|
479
|
+
/**
|
|
480
|
+
* daemon 拒绝隧道握手的原因(握手回复 `0x01` 后面的 UTF-8 串)。这一条不受 Noise 保护,只能当提示用。
|
|
481
|
+
*/
|
|
482
|
+
export type PreviewRejectReason = ("expired" | "port_not_allowed" | "disabled" | "malformed") | "unknown_ticket" | "label_mismatch" | "busy";
|
|
483
|
+
export type PreviewResetCode = "internal" | "refused" | "timeout" | "too_large" | "cancelled" | "flow_control" | "protocol" | "limit";
|
|
332
484
|
/**
|
|
333
485
|
* 项目从哪来。
|
|
334
486
|
*/
|
|
@@ -392,6 +544,10 @@ export interface ProtocolSchema {
|
|
|
392
544
|
blob_put_chunk_params: BlobPutChunkParams;
|
|
393
545
|
browse_entry: BrowseEntry;
|
|
394
546
|
client_info: ClientInfo;
|
|
547
|
+
config_change: ConfigChange;
|
|
548
|
+
config_editable: ConfigEditable;
|
|
549
|
+
config_item: ConfigItem;
|
|
550
|
+
config_value_kind: ConfigValueKind;
|
|
395
551
|
control: Control;
|
|
396
552
|
diff_against: DiffAgainst;
|
|
397
553
|
diff_file: DiffFile;
|
|
@@ -412,6 +568,7 @@ export interface ProtocolSchema {
|
|
|
412
568
|
event: Event;
|
|
413
569
|
fs_list_params: FsListParams;
|
|
414
570
|
fs_list_result: FsListResult;
|
|
571
|
+
fs_read_encoding: FsReadEncoding;
|
|
415
572
|
fs_read_params: FsReadParams;
|
|
416
573
|
fs_read_result: FsReadResult;
|
|
417
574
|
git_action: GitAction;
|
|
@@ -423,6 +580,7 @@ export interface ProtocolSchema {
|
|
|
423
580
|
link_block: LinkBlock;
|
|
424
581
|
node_audit_params: NodeAuditParams;
|
|
425
582
|
node_audit_result: NodeAuditResult;
|
|
583
|
+
node_config_result: NodeConfigResult;
|
|
426
584
|
node_devices_result: NodeDevicesResult;
|
|
427
585
|
node_doctor_result: NodeDoctorResult;
|
|
428
586
|
node_enroll_approve_params: NodeEnrollApproveParams;
|
|
@@ -433,11 +591,15 @@ export interface ProtocolSchema {
|
|
|
433
591
|
node_enroll_resolved: NodeEnrollResolved;
|
|
434
592
|
node_enroll_status_result: NodeEnrollStatusResult;
|
|
435
593
|
node_info: NodeInfo;
|
|
594
|
+
node_log_level: NodeLogLevel;
|
|
595
|
+
node_logs_params: NodeLogsParams;
|
|
596
|
+
node_logs_result: NodeLogsResult;
|
|
436
597
|
node_pair_begin_params: NodePairBeginParams;
|
|
437
598
|
node_pair_begin_result: NodePairBeginResult;
|
|
438
599
|
node_revoke_device_params: NodeRevokeDeviceParams;
|
|
439
600
|
node_security_event: NodeSecurityEvent;
|
|
440
601
|
node_set_agent_defaults_params: NodeSetAgentDefaultsParams;
|
|
602
|
+
node_set_config_params: NodeSetConfigParams;
|
|
441
603
|
node_set_enroll_enabled_params: NodeSetEnrollEnabledParams;
|
|
442
604
|
node_set_enroll_password_params: NodeSetEnrollPasswordParams;
|
|
443
605
|
node_stats: NodeStats;
|
|
@@ -450,6 +612,26 @@ export interface ProtocolSchema {
|
|
|
450
612
|
permission_request: PermissionRequest;
|
|
451
613
|
permission_resolved: PermissionResolved;
|
|
452
614
|
permission_respond_params: PermissionRespondParams;
|
|
615
|
+
preview_body_encoding: PreviewBodyEncoding;
|
|
616
|
+
preview_close_params: PreviewCloseParams;
|
|
617
|
+
preview_detection: PreviewDetection;
|
|
618
|
+
preview_goaway: PreviewGoaway;
|
|
619
|
+
preview_goaway_code: PreviewGoawayCode;
|
|
620
|
+
preview_hello: PreviewHello;
|
|
621
|
+
preview_info: PreviewInfo;
|
|
622
|
+
preview_launch: PreviewLaunch;
|
|
623
|
+
preview_list_result: PreviewListResult;
|
|
624
|
+
preview_open_params: PreviewOpenParams;
|
|
625
|
+
preview_open_result: PreviewOpenResult;
|
|
626
|
+
preview_port: PreviewPort;
|
|
627
|
+
preview_port_source: PreviewPortSource;
|
|
628
|
+
preview_ports_params: PreviewPortsParams;
|
|
629
|
+
preview_ports_result: PreviewPortsResult;
|
|
630
|
+
preview_reject_reason: PreviewRejectReason;
|
|
631
|
+
preview_request_head: PreviewRequestHead;
|
|
632
|
+
preview_reset: PreviewReset;
|
|
633
|
+
preview_reset_code: PreviewResetCode;
|
|
634
|
+
preview_response_head: PreviewResponseHead;
|
|
453
635
|
project: Project;
|
|
454
636
|
project_kind: ProjectKind;
|
|
455
637
|
pull_request_info: PullRequestInfo;
|
|
@@ -501,6 +683,7 @@ export interface ProtocolSchema {
|
|
|
501
683
|
workspace_name_params: WorkspaceNameParams;
|
|
502
684
|
workspace_remove_worktree_params: WorkspaceRemoveWorktreeParams;
|
|
503
685
|
workspace_rename_params: WorkspaceRenameParams;
|
|
686
|
+
workspace_root_info: WorkspaceRootInfo;
|
|
504
687
|
workspace_trash_id_params: WorkspaceTrashIdParams;
|
|
505
688
|
workspace_trash_list_result: WorkspaceTrashListResult;
|
|
506
689
|
workspace_worktrees_params: WorkspaceWorktreesParams;
|
|
@@ -551,7 +734,8 @@ export interface AgentInfo {
|
|
|
551
734
|
}
|
|
552
735
|
export interface AgentCapabilities {
|
|
553
736
|
/**
|
|
554
|
-
*
|
|
737
|
+
* agent **原生**收的附件 mime,如 `image/png`。其它附件(非图片、这里没列出的图片格式)不受它限制:daemon 把它们落到
|
|
738
|
+
* 会话工作目录并在文字里附上路径(ADR-44)。
|
|
555
739
|
*/
|
|
556
740
|
attachments?: string[];
|
|
557
741
|
/**
|
|
@@ -652,7 +836,7 @@ export interface AgentListResult {
|
|
|
652
836
|
not_modified?: boolean;
|
|
653
837
|
}
|
|
654
838
|
/**
|
|
655
|
-
* 消息里的一个附件(ADR-35):指向 daemon 上已经传完的 blob
|
|
839
|
+
* 消息里的一个附件(ADR-35、ADR-44):指向 daemon 上已经传完的 blob(图片或任意文件)。客户端从 `blob.put_end` 拿到它、原样放进
|
|
656
840
|
* `session.send` / `session.create`;daemon 以自己记录的元数据为准写进 `user_message` 事件。
|
|
657
841
|
*/
|
|
658
842
|
export interface AttachmentRef {
|
|
@@ -662,7 +846,7 @@ export interface AttachmentRef {
|
|
|
662
846
|
mime: string;
|
|
663
847
|
name: string;
|
|
664
848
|
/**
|
|
665
|
-
* 图片像素宽高(daemon
|
|
849
|
+
* 图片像素宽高(daemon 读文件头得出;读不出来、不是图片时省略)。客户端用来在下载前占好位置。
|
|
666
850
|
*/
|
|
667
851
|
width?: number | null;
|
|
668
852
|
}
|
|
@@ -700,11 +884,13 @@ export interface BlobIdParams {
|
|
|
700
884
|
*/
|
|
701
885
|
export interface BlobPutBeginParams {
|
|
702
886
|
/**
|
|
703
|
-
*
|
|
887
|
+
* 任意 `type/subtype`:不合法或空的按 `application/octet-stream` 记录(不报错),大小写和 `;` 之后的参数规整掉。
|
|
888
|
+
* 声明为 `image/png` `image/jpeg` `image/gif` `image/webp` 的才校验文件头、读宽高。
|
|
704
889
|
*/
|
|
705
890
|
mime: string;
|
|
706
891
|
/**
|
|
707
|
-
* 展示用的文件名(1–255 字节,不能含 `/` `\`
|
|
892
|
+
* 展示用的文件名(1–255 字节,不能含 `/` `\` 和控制字符)。非图片的存储扩展名取自它(清洗过),落到工作目录时也用它
|
|
893
|
+
* 作文件名;daemon 不用它拼出别的路径。
|
|
708
894
|
*/
|
|
709
895
|
name: string;
|
|
710
896
|
/**
|
|
@@ -786,6 +972,47 @@ export interface ClientInfo {
|
|
|
786
972
|
*/
|
|
787
973
|
version: string;
|
|
788
974
|
}
|
|
975
|
+
/**
|
|
976
|
+
* `node.set_config` 的一项改动。
|
|
977
|
+
*/
|
|
978
|
+
export interface ConfigChange {
|
|
979
|
+
key: string;
|
|
980
|
+
/**
|
|
981
|
+
* 新值,JSON 类型要和该键的 `kind` 一致(布尔、整数、字符串)。
|
|
982
|
+
*/
|
|
983
|
+
value: unknown;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* `node.get_config` 的一项:一个可以远程查看的配置键。
|
|
987
|
+
*/
|
|
988
|
+
export interface ConfigItem {
|
|
989
|
+
editable: ConfigEditable;
|
|
990
|
+
/**
|
|
991
|
+
* 被 `ANYCON_*` 环境变量覆盖(`log.level` 还包括 `ANYCON_LOG` / `RUST_LOG`)。为真时 `editable` 一定是 `no`。
|
|
992
|
+
*/
|
|
993
|
+
env_override?: boolean;
|
|
994
|
+
/**
|
|
995
|
+
* 点分隔的键,和 `config.toml` 一致(`sessions.max_concurrent`)。
|
|
996
|
+
*/
|
|
997
|
+
key: string;
|
|
998
|
+
kind: ConfigValueKind;
|
|
999
|
+
/**
|
|
1000
|
+
* 取值上限:`int` 是数值,`duration` 是毫秒,`text` 是字符数。
|
|
1001
|
+
*/
|
|
1002
|
+
max?: number | null;
|
|
1003
|
+
/**
|
|
1004
|
+
* 取值下限:`int` 是数值,`duration` 是毫秒,`text` 不用。
|
|
1005
|
+
*/
|
|
1006
|
+
min?: number | null;
|
|
1007
|
+
/**
|
|
1008
|
+
* `kind = enum` 时允许的取值。
|
|
1009
|
+
*/
|
|
1010
|
+
options?: string[];
|
|
1011
|
+
/**
|
|
1012
|
+
* 当前生效的值(默认值 → 文件 → 环境变量合并后的结果):布尔、整数或字符串,类型见 `kind`。
|
|
1013
|
+
*/
|
|
1014
|
+
value: unknown;
|
|
1015
|
+
}
|
|
789
1016
|
export interface Quota {
|
|
790
1017
|
connections: number;
|
|
791
1018
|
connections_max?: number | null;
|
|
@@ -886,6 +1113,11 @@ export interface ToolCallDetail {
|
|
|
886
1113
|
url?: string | null;
|
|
887
1114
|
}
|
|
888
1115
|
export interface ToolResultDetail {
|
|
1116
|
+
/**
|
|
1117
|
+
* 调用已经返回,但它启动的工作还在后台跑(后台子 agent)。结束时同一个 `id` 会再来一条
|
|
1118
|
+
* `tool_result`(不带这个标记),取代这一条。
|
|
1119
|
+
*/
|
|
1120
|
+
background?: boolean | null;
|
|
889
1121
|
exit_code?: number | null;
|
|
890
1122
|
/**
|
|
891
1123
|
* 这次调用的流式 `tool_output_delta` 累计超过上限、后续 delta 没有转发;最终 `output` 仍是
|
|
@@ -897,6 +1129,11 @@ export interface ToolResultDetail {
|
|
|
897
1129
|
* daemon 对 `output` 做头尾截断时丢掉的字节数(spec/daemon.md § 12);没截断就缺省。
|
|
898
1130
|
*/
|
|
899
1131
|
output_truncated_bytes?: number | null;
|
|
1132
|
+
/**
|
|
1133
|
+
* 子 agent 结束时 agent 报的它一共用掉的 token(`category = subagent`;agent 不报就缺省)。
|
|
1134
|
+
* 主 agent 的 `turn_done.usage` 不含这部分。
|
|
1135
|
+
*/
|
|
1136
|
+
total_tokens?: number | null;
|
|
900
1137
|
unified_diff?: string | null;
|
|
901
1138
|
}
|
|
902
1139
|
export interface PlanEntry {
|
|
@@ -920,12 +1157,22 @@ export interface PermissionDetail {
|
|
|
920
1157
|
* kind = tool
|
|
921
1158
|
*/
|
|
922
1159
|
tool?: ToolPermissionDetail | null;
|
|
1160
|
+
/**
|
|
1161
|
+
* kind = other:要用户在浏览器里打开的链接(MCP server 的 URL 模式 elicitation)。只会是 `http` / `https`;
|
|
1162
|
+
* 客户端只对这两种协议提供「打开」入口,并且显示完整 URL。
|
|
1163
|
+
*/
|
|
1164
|
+
url?: string | null;
|
|
923
1165
|
}
|
|
924
1166
|
export interface Question {
|
|
925
1167
|
choices?: QuestionChoice[];
|
|
926
1168
|
free_text?: boolean;
|
|
927
1169
|
id: string;
|
|
928
1170
|
multi?: boolean;
|
|
1171
|
+
/**
|
|
1172
|
+
* 可以不答:客户端允许留空提交,答复里就没有这一题的答案。默认 `false`(必答),
|
|
1173
|
+
* 所以 AskUserQuestion 这类每题都要答的行为不变;MCP elicitation 表单里 schema 没列进 `required` 的字段是 `true`。
|
|
1174
|
+
*/
|
|
1175
|
+
optional?: boolean;
|
|
929
1176
|
text: string;
|
|
930
1177
|
}
|
|
931
1178
|
export interface QuestionChoice {
|
|
@@ -957,6 +1204,15 @@ export interface PermissionOption {
|
|
|
957
1204
|
export interface Usage {
|
|
958
1205
|
cache_read_tokens?: number | null;
|
|
959
1206
|
cache_write_tokens?: number | null;
|
|
1207
|
+
/**
|
|
1208
|
+
* turn 结束时上下文已经占用的 token:最近一次模型请求的输入 + 缓存读写。和 `input_tokens` 等
|
|
1209
|
+
* 累计用量不同,它是「此刻窗口里有多少」,客户端拿它和 `context_window` 算占用比例。agent 不报就缺省。
|
|
1210
|
+
*/
|
|
1211
|
+
context_tokens?: number | null;
|
|
1212
|
+
/**
|
|
1213
|
+
* 模型的上下文窗口大小(token)。agent 不报就缺省。
|
|
1214
|
+
*/
|
|
1215
|
+
context_window?: number | null;
|
|
960
1216
|
cost_usd?: number | null;
|
|
961
1217
|
duration_ms: number;
|
|
962
1218
|
input_tokens?: number | null;
|
|
@@ -989,6 +1245,56 @@ export interface SessionSettings {
|
|
|
989
1245
|
*/
|
|
990
1246
|
thinking?: string | null;
|
|
991
1247
|
}
|
|
1248
|
+
/**
|
|
1249
|
+
* workflow 里的一个 agent。
|
|
1250
|
+
*/
|
|
1251
|
+
export interface TaskAgent {
|
|
1252
|
+
/**
|
|
1253
|
+
* 第几次尝试(重试过才有)。
|
|
1254
|
+
*/
|
|
1255
|
+
attempt?: number | null;
|
|
1256
|
+
/**
|
|
1257
|
+
* 结果来自缓存,没有真的运行。
|
|
1258
|
+
*/
|
|
1259
|
+
cached?: boolean | null;
|
|
1260
|
+
duration_ms?: number | null;
|
|
1261
|
+
/**
|
|
1262
|
+
* `state = failed` 时的错误信息。
|
|
1263
|
+
*/
|
|
1264
|
+
error?: string | null;
|
|
1265
|
+
/**
|
|
1266
|
+
* 在 workflow 里的序号,同一个任务内唯一。
|
|
1267
|
+
*/
|
|
1268
|
+
index: number;
|
|
1269
|
+
label: string;
|
|
1270
|
+
/**
|
|
1271
|
+
* 最近一次调用的工具名。
|
|
1272
|
+
*/
|
|
1273
|
+
last_tool?: string | null;
|
|
1274
|
+
model?: string | null;
|
|
1275
|
+
/**
|
|
1276
|
+
* 所属阶段的 `TaskPhase.index`。
|
|
1277
|
+
*/
|
|
1278
|
+
phase_index?: number | null;
|
|
1279
|
+
state: TaskAgentState;
|
|
1280
|
+
tokens?: number | null;
|
|
1281
|
+
tool_calls?: number | null;
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* workflow 的一个阶段。
|
|
1285
|
+
*/
|
|
1286
|
+
export interface TaskPhase {
|
|
1287
|
+
index: number;
|
|
1288
|
+
title: string;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* 任务的用量。每个字段 agent 不报就缺省。
|
|
1292
|
+
*/
|
|
1293
|
+
export interface TaskUsage {
|
|
1294
|
+
duration_ms?: number | null;
|
|
1295
|
+
tool_calls?: number | null;
|
|
1296
|
+
total_tokens?: number | null;
|
|
1297
|
+
}
|
|
992
1298
|
export interface FsListParams {
|
|
993
1299
|
/**
|
|
994
1300
|
* `<项目名>/<项目内的相对路径>`,如 `my-app/src`。第一段是关联项目的名字时,其余部分相对那个目录解析,
|
|
@@ -1007,21 +1313,50 @@ export interface FsEntry {
|
|
|
1007
1313
|
}
|
|
1008
1314
|
export interface FsReadParams {
|
|
1009
1315
|
/**
|
|
1010
|
-
*
|
|
1316
|
+
* 缺省 `text`。
|
|
1317
|
+
*/
|
|
1318
|
+
encoding?: FsReadEncoding & string;
|
|
1319
|
+
/**
|
|
1320
|
+
* 读多少**原始字节**。`encoding = text`:默认 1 MiB,上限 10 MiB。`encoding = base64`:一次最多一块(512 KiB,和
|
|
1321
|
+
* `blob.get` 一样),缺省就是一块,超过的按一块算(不报错);`0` 只回大小、不带数据。
|
|
1011
1322
|
*/
|
|
1012
1323
|
max_bytes?: number | null;
|
|
1324
|
+
/**
|
|
1325
|
+
* 从文件的第几个字节读起,缺省 0。只有 `encoding = base64` 能用:大文件按块一块一块读,一个响应不会长时间占住设备到 daemon
|
|
1326
|
+
* 那条有序的传输。`text` 模式下 `offset > 0` 是 `invalid`。
|
|
1327
|
+
*/
|
|
1328
|
+
offset?: number;
|
|
1013
1329
|
/**
|
|
1014
1330
|
* 解析规则同 `FsListParams.path`。
|
|
1015
1331
|
*/
|
|
1016
1332
|
path: string;
|
|
1017
1333
|
}
|
|
1018
1334
|
export interface FsReadResult {
|
|
1335
|
+
/**
|
|
1336
|
+
* `text` 模式:文件是二进制(不返回内容)。`base64` 模式:按**这一块**的内容判断(前 8 KiB 里有 NUL、或不是合法的
|
|
1337
|
+
* UTF-8),只有 `offset = 0` 的那一块说明整个文件;从中间读起的块可能从半个字符开始,客户端不要依赖它。
|
|
1338
|
+
*/
|
|
1019
1339
|
binary: boolean;
|
|
1340
|
+
/**
|
|
1341
|
+
* 文件的总字节数(不是读到的)。分块读的时候每一块都带着它:总数变了说明文件在读的过程中被改写过。
|
|
1342
|
+
*/
|
|
1020
1343
|
bytes: number;
|
|
1021
1344
|
/**
|
|
1022
|
-
*
|
|
1345
|
+
* `encoding = base64` 时读到的字节(至多一块;`offset` 在文件末尾或之后时为空串);`text` 模式没有这个字段。
|
|
1346
|
+
*/
|
|
1347
|
+
data_base64?: string | null;
|
|
1348
|
+
/**
|
|
1349
|
+
* `encoding = base64` 时 `data_base64` 从文件的第几个字节开始(原样回显请求的 `offset`);`text` 模式没有这个字段。
|
|
1350
|
+
* 不认识 `offset` 的旧 daemon 不会带它,客户端据此知道分块读不能用。
|
|
1351
|
+
*/
|
|
1352
|
+
offset?: number | null;
|
|
1353
|
+
/**
|
|
1354
|
+
* UTF-8 文本;二进制文件 `text` 为空且 `binary = true`。`encoding = base64` 时恒为空。
|
|
1023
1355
|
*/
|
|
1024
1356
|
text: string;
|
|
1357
|
+
/**
|
|
1358
|
+
* 文件在读到的这一段**之后**还有内容(`offset + 读到的字节数 < bytes`)。
|
|
1359
|
+
*/
|
|
1025
1360
|
truncated: boolean;
|
|
1026
1361
|
}
|
|
1027
1362
|
export interface JobCancelParams {
|
|
@@ -1057,6 +1392,12 @@ export interface AuditEntry {
|
|
|
1057
1392
|
target?: string | null;
|
|
1058
1393
|
ts_ms: number;
|
|
1059
1394
|
}
|
|
1395
|
+
/**
|
|
1396
|
+
* `node.get_config` / `node.set_config` 的结果:白名单里的全部配置项(顺序固定,按段分组)。
|
|
1397
|
+
*/
|
|
1398
|
+
export interface NodeConfigResult {
|
|
1399
|
+
items: ConfigItem[];
|
|
1400
|
+
}
|
|
1060
1401
|
export interface NodeDevicesResult {
|
|
1061
1402
|
devices: PeerDevice[];
|
|
1062
1403
|
}
|
|
@@ -1145,6 +1486,10 @@ export interface NodeEnrollStatusResult {
|
|
|
1145
1486
|
* `node.info` 结果。
|
|
1146
1487
|
*/
|
|
1147
1488
|
export interface NodeInfo {
|
|
1489
|
+
/**
|
|
1490
|
+
* `capabilities.blobs` 为 true 时给出。
|
|
1491
|
+
*/
|
|
1492
|
+
attachment_limits?: NodeAttachmentLimits | null;
|
|
1148
1493
|
capabilities: NodeCapabilities;
|
|
1149
1494
|
name: string;
|
|
1150
1495
|
node_id: string;
|
|
@@ -1152,16 +1497,49 @@ export interface NodeInfo {
|
|
|
1152
1497
|
protocol_version: number;
|
|
1153
1498
|
started_at_ms: number;
|
|
1154
1499
|
version: string;
|
|
1500
|
+
/**
|
|
1501
|
+
* 主根。多个根时看 `workspace_roots`。
|
|
1502
|
+
*/
|
|
1155
1503
|
workspace_root?: string | null;
|
|
1504
|
+
/**
|
|
1505
|
+
* 所有 workspace 根,主根在最前,额外根按配置顺序。老版本的 daemon 不给,客户端当作只有 `workspace_root` 一个。
|
|
1506
|
+
*/
|
|
1507
|
+
workspace_roots?: WorkspaceRootInfo[];
|
|
1156
1508
|
/**
|
|
1157
1509
|
* `capabilities.worktree` 为 true 时给出。
|
|
1158
1510
|
*/
|
|
1159
1511
|
worktree?: NodeWorktreeSettings | null;
|
|
1160
1512
|
}
|
|
1513
|
+
/**
|
|
1514
|
+
* 附件的上限(`node.info`),客户端据此在上传之前就拒绝明显超限的文件。
|
|
1515
|
+
*/
|
|
1516
|
+
export interface NodeAttachmentLimits {
|
|
1517
|
+
/**
|
|
1518
|
+
* 单个附件的字节上限(`sessions.max_attachment_bytes`,热加载;这里是 `node.info` 被调用那一刻的值)。
|
|
1519
|
+
*/
|
|
1520
|
+
max_bytes: number;
|
|
1521
|
+
/**
|
|
1522
|
+
* 一条消息的附件字节合计上限。
|
|
1523
|
+
*/
|
|
1524
|
+
max_message_bytes: number;
|
|
1525
|
+
/**
|
|
1526
|
+
* 一条消息至多带几个附件。
|
|
1527
|
+
*/
|
|
1528
|
+
max_per_message: number;
|
|
1529
|
+
}
|
|
1161
1530
|
export interface NodeCapabilities {
|
|
1162
1531
|
audit: boolean;
|
|
1163
1532
|
blobs: boolean;
|
|
1533
|
+
/**
|
|
1534
|
+
* daemon 能把任意类型的文件交给任何会话的 agent(非图片、agent 不原生收的图片落到会话工作目录,ADR-44)。
|
|
1535
|
+
* 为 false(旧 daemon)时客户端只能上传图片。
|
|
1536
|
+
*/
|
|
1537
|
+
file_attachments?: boolean;
|
|
1164
1538
|
fs: boolean;
|
|
1539
|
+
/**
|
|
1540
|
+
* 支持 dev server 预览(`preview.*`,ADR-39),且节点配置 `preview.enabled = true`。
|
|
1541
|
+
*/
|
|
1542
|
+
preview?: boolean;
|
|
1165
1543
|
search: boolean;
|
|
1166
1544
|
/**
|
|
1167
1545
|
* 有 workspace(文件夹即项目)。SDK 节点可能没有。
|
|
@@ -1172,6 +1550,24 @@ export interface NodeCapabilities {
|
|
|
1172
1550
|
*/
|
|
1173
1551
|
worktree?: boolean;
|
|
1174
1552
|
}
|
|
1553
|
+
/**
|
|
1554
|
+
* 一个 workspace 根(ADR-45)。每个根下的一级子文件夹都是项目。
|
|
1555
|
+
*/
|
|
1556
|
+
export interface WorkspaceRootInfo {
|
|
1557
|
+
/**
|
|
1558
|
+
* 现在能用:daemon 启动时它是一个存在的目录,并且现在还在。不可用的根下的项目不出现在列表里,也不能在上面新建 / 克隆;
|
|
1559
|
+
* 配置只在启动时读,修好(挂上外接盘)之后要重启 daemon。
|
|
1560
|
+
*/
|
|
1561
|
+
available: boolean;
|
|
1562
|
+
/**
|
|
1563
|
+
* canonical 绝对路径(根不可用时是展开后的配置值)。`workspace.create` / `clone` 的 `root` 取这里的值。
|
|
1564
|
+
*/
|
|
1565
|
+
path: string;
|
|
1566
|
+
/**
|
|
1567
|
+
* 主根:放 `.scratch/`,不指定 `root` 时新项目建在这里。恰好有一个。
|
|
1568
|
+
*/
|
|
1569
|
+
primary: boolean;
|
|
1570
|
+
}
|
|
1175
1571
|
/**
|
|
1176
1572
|
* 节点的 worktree 配置(`config.toml` 的 `[worktree]`),客户端据此决定新建会话的初始选择和分支名预览。
|
|
1177
1573
|
*/
|
|
@@ -1185,6 +1581,32 @@ export interface NodeWorktreeSettings {
|
|
|
1185
1581
|
*/
|
|
1186
1582
|
default_mode: SessionWorkspaceMode;
|
|
1187
1583
|
}
|
|
1584
|
+
/**
|
|
1585
|
+
* `node.logs` 参数。
|
|
1586
|
+
*/
|
|
1587
|
+
export interface NodeLogsParams {
|
|
1588
|
+
/**
|
|
1589
|
+
* 最低级别:只返回这个级别及更高级别的行。缺省 = 不过滤。
|
|
1590
|
+
*/
|
|
1591
|
+
level?: NodeLogLevel | null;
|
|
1592
|
+
/**
|
|
1593
|
+
* 最多返回多少行,缺省 200,最大 1000(超出按 1000)。
|
|
1594
|
+
*/
|
|
1595
|
+
lines?: number | null;
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* `node.logs` 结果。
|
|
1599
|
+
*/
|
|
1600
|
+
export interface NodeLogsResult {
|
|
1601
|
+
/**
|
|
1602
|
+
* 日志行,旧的在前、新的在后;每行最多 2 KiB(超出的截断,行尾加 `…`)。
|
|
1603
|
+
*/
|
|
1604
|
+
lines: string[];
|
|
1605
|
+
/**
|
|
1606
|
+
* 还有更早的行没有返回(行数到了上限,或扫描的日志量到了上限)。
|
|
1607
|
+
*/
|
|
1608
|
+
truncated: boolean;
|
|
1609
|
+
}
|
|
1188
1610
|
export interface NodePairBeginParams {
|
|
1189
1611
|
/**
|
|
1190
1612
|
* `true`(缺省)= 16 位短码(约 79 bit;链接、二维码、默认都是它);`false` = 8 位(约 40 bit),
|
|
@@ -1246,6 +1668,15 @@ export interface NodeSetAgentDefaultsParams {
|
|
|
1246
1668
|
} | null;
|
|
1247
1669
|
thinking?: string | null;
|
|
1248
1670
|
}
|
|
1671
|
+
/**
|
|
1672
|
+
* `node.set_config` 参数。所有改动先校验,任何一项不合法就一项都不写。
|
|
1673
|
+
*
|
|
1674
|
+
* 错误:键不在白名单、被环境变量覆盖、想放宽只能收紧的键 → `forbidden`(`data.field` 是键,`data.reason` 是
|
|
1675
|
+
* `not_editable` / `env_override` / `tighten_only`);值的类型或取值不合法、键重复、`changes` 为空 → `invalid`(`data.field` 是键)。
|
|
1676
|
+
*/
|
|
1677
|
+
export interface NodeSetConfigParams {
|
|
1678
|
+
changes: ConfigChange[];
|
|
1679
|
+
}
|
|
1249
1680
|
/**
|
|
1250
1681
|
* `node.set_enroll_enabled` 参数:写 `[enroll]` 配置。`password: true` 同时解除锁定、失败计数清零。
|
|
1251
1682
|
*/
|
|
@@ -1358,7 +1789,171 @@ export interface PermissionRespondParams {
|
|
|
1358
1789
|
request_id: string;
|
|
1359
1790
|
}
|
|
1360
1791
|
/**
|
|
1361
|
-
*
|
|
1792
|
+
* `preview.close` 参数:作废这个 label 的全部票据,断开它的全部隧道。
|
|
1793
|
+
*/
|
|
1794
|
+
export interface PreviewCloseParams {
|
|
1795
|
+
label: string;
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* 隧道 `GOAWAY` 帧的载荷(msgpack,只有 daemon 发,stream 0):daemon 要关掉这条隧道,之后不再处理它的帧。
|
|
1799
|
+
*/
|
|
1800
|
+
export interface PreviewGoaway {
|
|
1801
|
+
code: PreviewGoawayCode;
|
|
1802
|
+
message?: string | null;
|
|
1803
|
+
}
|
|
1804
|
+
/**
|
|
1805
|
+
* 隧道握手第二条消息(daemon → 预览页)的 payload,JSON。到这一条预览页才确认对端持有票据、是钉住的 daemon。
|
|
1806
|
+
*/
|
|
1807
|
+
export interface PreviewHello {
|
|
1808
|
+
expires_at_ms: number;
|
|
1809
|
+
port: number;
|
|
1810
|
+
session_id?: string | null;
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* `preview.list` 的一项:一张未过期的票据。
|
|
1814
|
+
*/
|
|
1815
|
+
export interface PreviewInfo {
|
|
1816
|
+
created_at_ms: number;
|
|
1817
|
+
/**
|
|
1818
|
+
* 签发这张票据的设备。
|
|
1819
|
+
*/
|
|
1820
|
+
created_by: string;
|
|
1821
|
+
created_by_name: string;
|
|
1822
|
+
expires_at_ms: number;
|
|
1823
|
+
label: string;
|
|
1824
|
+
port: number;
|
|
1825
|
+
session_id?: string | null;
|
|
1826
|
+
ticket_id: string;
|
|
1827
|
+
/**
|
|
1828
|
+
* 此刻用这张票据建立的隧道数。
|
|
1829
|
+
*/
|
|
1830
|
+
tunnels: number;
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* 预览页的启动参数。Web UI 把它序列化成 JSON、再 base64url(无填充),放进
|
|
1834
|
+
* `<预览 origin>/__anycon/enter#<…>` 的 fragment(浏览器不会把 fragment 发给 hub)。引导页读出后存进预览 origin 的
|
|
1835
|
+
* IndexedDB,立即从地址栏抹掉。
|
|
1836
|
+
*/
|
|
1837
|
+
export interface PreviewLaunch {
|
|
1838
|
+
/**
|
|
1839
|
+
* 票据和令牌里较早的那个过期时间。
|
|
1840
|
+
*/
|
|
1841
|
+
expires_at_ms: number;
|
|
1842
|
+
label: string;
|
|
1843
|
+
/**
|
|
1844
|
+
* daemon 的设备 id。
|
|
1845
|
+
*/
|
|
1846
|
+
node: string;
|
|
1847
|
+
/**
|
|
1848
|
+
* daemon 的 Noise 静态公钥,64 个小写 hex。预览页用它做 NK 握手(钉住 daemon)。
|
|
1849
|
+
*/
|
|
1850
|
+
node_public: string;
|
|
1851
|
+
/**
|
|
1852
|
+
* 打开后先导航到的路径(以 `/` 开头,可带查询串)。
|
|
1853
|
+
*/
|
|
1854
|
+
path: string;
|
|
1855
|
+
port: number;
|
|
1856
|
+
psk: string;
|
|
1857
|
+
ticket_id: string;
|
|
1858
|
+
/**
|
|
1859
|
+
* hub 签发的预览令牌(`POST /api/preview/tokens`),预览连接凭它向 hub 认证。
|
|
1860
|
+
*/
|
|
1861
|
+
token: string;
|
|
1862
|
+
/**
|
|
1863
|
+
* 格式版本,目前是 1。
|
|
1864
|
+
*/
|
|
1865
|
+
v: number;
|
|
1866
|
+
}
|
|
1867
|
+
export interface PreviewListResult {
|
|
1868
|
+
previews: PreviewInfo[];
|
|
1869
|
+
}
|
|
1870
|
+
/**
|
|
1871
|
+
* `preview.open` 参数:为本机 `port` 签发一张预览票据。
|
|
1872
|
+
*/
|
|
1873
|
+
export interface PreviewOpenParams {
|
|
1874
|
+
port: number;
|
|
1875
|
+
/**
|
|
1876
|
+
* 从哪个会话发起(只用于界面展示和审计;端口是否允许不看它,见 spec/daemon.md § 19.3)。
|
|
1877
|
+
*/
|
|
1878
|
+
session_id?: string | null;
|
|
1879
|
+
}
|
|
1880
|
+
/**
|
|
1881
|
+
* `preview.open` 结果。`psk` 是票据的密钥,只交给预览页(放进 [`PreviewLaunch`]),不要写日志、不要发给 hub。
|
|
1882
|
+
*/
|
|
1883
|
+
export interface PreviewOpenResult {
|
|
1884
|
+
expires_at_ms: number;
|
|
1885
|
+
/**
|
|
1886
|
+
* 这个端口固定的预览 label(26 位小写 base32),预览 origin 是 `<label>.<预览域名>`。
|
|
1887
|
+
*/
|
|
1888
|
+
label: string;
|
|
1889
|
+
port: number;
|
|
1890
|
+
/**
|
|
1891
|
+
* 票据密钥,64 个小写 hex(32 字节),Noise PSK。
|
|
1892
|
+
*/
|
|
1893
|
+
psk: string;
|
|
1894
|
+
session_id?: string | null;
|
|
1895
|
+
/**
|
|
1896
|
+
* 票据 id,32 个小写 hex(16 字节)。
|
|
1897
|
+
*/
|
|
1898
|
+
ticket_id: string;
|
|
1899
|
+
}
|
|
1900
|
+
export interface PreviewPort {
|
|
1901
|
+
pid?: number | null;
|
|
1902
|
+
port: number;
|
|
1903
|
+
/**
|
|
1904
|
+
* 进程名(可执行文件名,不含参数)。
|
|
1905
|
+
*/
|
|
1906
|
+
process?: string | null;
|
|
1907
|
+
session_id?: string | null;
|
|
1908
|
+
source: PreviewPortSource;
|
|
1909
|
+
}
|
|
1910
|
+
/**
|
|
1911
|
+
* `preview.ports` 参数。带 `session_id` 只列这个会话的端口(外加配置里允许的端口)。
|
|
1912
|
+
*/
|
|
1913
|
+
export interface PreviewPortsParams {
|
|
1914
|
+
session_id?: string | null;
|
|
1915
|
+
}
|
|
1916
|
+
export interface PreviewPortsResult {
|
|
1917
|
+
detection: PreviewDetection;
|
|
1918
|
+
ports: PreviewPort[];
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* 隧道 `REQUEST` 帧的载荷(msgpack,字段名为键)。
|
|
1922
|
+
*/
|
|
1923
|
+
export interface PreviewRequestHead {
|
|
1924
|
+
/**
|
|
1925
|
+
* 请求头,按原顺序,名字小写。`cookie` 来自预览页自己的 cookie jar;daemon 转发前改写哪些头见
|
|
1926
|
+
* spec/daemon.md § 19.5。
|
|
1927
|
+
*/
|
|
1928
|
+
headers: [string, string][];
|
|
1929
|
+
method: string;
|
|
1930
|
+
/**
|
|
1931
|
+
* 以 `/` 开头,可带查询串;不含 scheme 和主机。
|
|
1932
|
+
*/
|
|
1933
|
+
path: string;
|
|
1934
|
+
/**
|
|
1935
|
+
* `true`:这是一个 WebSocket 升级请求(`method` 为 `GET`,子协议在 `sec-websocket-protocol` 头里)。
|
|
1936
|
+
*/
|
|
1937
|
+
websocket?: boolean;
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* 隧道 `RESET` 帧的载荷(msgpack):终止这个 stream 的两个方向。
|
|
1941
|
+
*/
|
|
1942
|
+
export interface PreviewReset {
|
|
1943
|
+
code: PreviewResetCode;
|
|
1944
|
+
message?: string | null;
|
|
1945
|
+
}
|
|
1946
|
+
/**
|
|
1947
|
+
* 隧道 `RESPONSE` 帧的载荷(msgpack)。WebSocket 流里 `status = 101` 表示升级成功,其他状态码表示被拒,
|
|
1948
|
+
* 后面跟普通响应体。
|
|
1949
|
+
*/
|
|
1950
|
+
export interface PreviewResponseHead {
|
|
1951
|
+
encoding?: PreviewBodyEncoding & string;
|
|
1952
|
+
headers: [string, string][];
|
|
1953
|
+
status: number;
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* 一个项目 = 某个 workspace 根目录下的一个一级子文件夹,或一个关联的本机目录(`kind = linked`)。
|
|
1362
1957
|
* 元数据全部推导;只有「关联了哪些目录」存在 daemon 的库里。
|
|
1363
1958
|
*/
|
|
1364
1959
|
export interface Project {
|
|
@@ -1380,13 +1975,18 @@ export interface Project {
|
|
|
1380
1975
|
missing?: boolean;
|
|
1381
1976
|
modified_at_ms: number;
|
|
1382
1977
|
/**
|
|
1383
|
-
*
|
|
1978
|
+
* 项目名。所有 workspace 根下的项目和关联的项目共用一个命名空间,客户端的所有操作都用它。
|
|
1384
1979
|
*/
|
|
1385
1980
|
name: string;
|
|
1386
1981
|
/**
|
|
1387
1982
|
* 绝对路径,仅展示用。
|
|
1388
1983
|
*/
|
|
1389
1984
|
path: string;
|
|
1985
|
+
/**
|
|
1986
|
+
* 文件夹项目所在的 workspace 根(canonical 绝对路径,等于 `node.info.workspace_roots` 里的某一项的 `path`);
|
|
1987
|
+
* 关联项目没有。老版本的 daemon 不给,客户端当作主根。
|
|
1988
|
+
*/
|
|
1989
|
+
root?: string | null;
|
|
1390
1990
|
}
|
|
1391
1991
|
export interface GitMeta {
|
|
1392
1992
|
branch?: string | null;
|
|
@@ -1460,6 +2060,10 @@ export interface SessionArchiveParams {
|
|
|
1460
2060
|
*/
|
|
1461
2061
|
export interface SessionChanged {
|
|
1462
2062
|
archived?: boolean;
|
|
2063
|
+
/**
|
|
2064
|
+
* 同 [`SessionSummary::background_tasks`]。
|
|
2065
|
+
*/
|
|
2066
|
+
background_tasks?: number;
|
|
1463
2067
|
/**
|
|
1464
2068
|
* 会话被删除。
|
|
1465
2069
|
*/
|
|
@@ -1505,7 +2109,8 @@ export interface SessionWorktree {
|
|
|
1505
2109
|
export interface SessionCreateParams {
|
|
1506
2110
|
agent: string;
|
|
1507
2111
|
/**
|
|
1508
|
-
* 第一条消息的附件(`blob.put_end` 的结果)。agent
|
|
2112
|
+
* 第一条消息的附件(`blob.put_end` 的结果)。agent 原生收的 mime(`capabilities.attachments`)交给 adapter,
|
|
2113
|
+
* 其余落到会话工作目录、路径写在交给 agent 的文字里(ADR-44)。
|
|
1509
2114
|
*/
|
|
1510
2115
|
attachments?: AttachmentRef[];
|
|
1511
2116
|
/**
|
|
@@ -1667,6 +2272,11 @@ export interface SessionSummary {
|
|
|
1667
2272
|
*/
|
|
1668
2273
|
agent_session_id?: string | null;
|
|
1669
2274
|
archived?: boolean;
|
|
2275
|
+
/**
|
|
2276
|
+
* agent 进程里还在跑的后台任务数(Claude Code 的后台 subagent、后台命令)。主 turn 结束后它们可能还在干活,
|
|
2277
|
+
* 期间 daemon 不按 `idle_timeout` 回收进程(docs/spec/daemon.md § 7.3)。只反映 daemon 内存里的当前状态,不进事件流。
|
|
2278
|
+
*/
|
|
2279
|
+
background_tasks?: number;
|
|
1670
2280
|
created_at_ms: number;
|
|
1671
2281
|
id: string;
|
|
1672
2282
|
/**
|
|
@@ -1716,26 +2326,45 @@ export interface SessionRenameParams {
|
|
|
1716
2326
|
title: string;
|
|
1717
2327
|
}
|
|
1718
2328
|
export interface SessionSearchParams {
|
|
2329
|
+
/**
|
|
2330
|
+
* 最多返回几条命中,默认 20,上限 200。
|
|
2331
|
+
*/
|
|
1719
2332
|
limit?: number | null;
|
|
2333
|
+
/**
|
|
2334
|
+
* 只搜这个项目里的会话。
|
|
2335
|
+
*/
|
|
1720
2336
|
project?: string | null;
|
|
2337
|
+
/**
|
|
2338
|
+
* 空白分隔的若干个词,每个词按前缀匹配、都要出现在同一段文字里;不能为空(`invalid`)。
|
|
2339
|
+
*/
|
|
1721
2340
|
query: string;
|
|
1722
2341
|
}
|
|
1723
2342
|
export interface SessionSearchResult {
|
|
1724
2343
|
hits: SearchHit[];
|
|
1725
2344
|
}
|
|
1726
2345
|
export interface SearchHit {
|
|
2346
|
+
/**
|
|
2347
|
+
* 命中的那段文字开始处的事件 seq:用户消息就是 `user_message` 的 seq;assistant 文字是那一段第一个 `text_delta` 的 seq
|
|
2348
|
+
* (长文字每 32 KiB 切一段索引,所以同一条回复可以有几个不同的 seq)。
|
|
2349
|
+
*/
|
|
1727
2350
|
seq: number;
|
|
1728
2351
|
session_id: string;
|
|
1729
2352
|
/**
|
|
1730
|
-
*
|
|
2353
|
+
* 命中处的片段。除了包住命中词的字面 `<mark>` / `</mark>`,里面没有 HTML:会话文字里原有的
|
|
2354
|
+
* `<` `>` `&` 已转义成 `<` `>` `&`,客户端按 `<mark>` 切开后把这三个实体还原成字符、
|
|
2355
|
+
* 当纯文本显示即可,不要当 HTML 解析。
|
|
1731
2356
|
*/
|
|
1732
2357
|
snippet: string;
|
|
2358
|
+
/**
|
|
2359
|
+
* 会话当前的标题。
|
|
2360
|
+
*/
|
|
1733
2361
|
title: string;
|
|
1734
2362
|
ts_ms: number;
|
|
1735
2363
|
}
|
|
1736
2364
|
export interface SessionSendParams {
|
|
1737
2365
|
/**
|
|
1738
|
-
* `blob.put_end` 的结果,每条至多 20 个。agent
|
|
2366
|
+
* `blob.put_end` 的结果,每条至多 20 个。agent 原生收的 mime(`capabilities.attachments`)交给 adapter,
|
|
2367
|
+
* 其余落到会话工作目录、路径写在交给 agent 的文字里(ADR-44)。
|
|
1739
2368
|
*/
|
|
1740
2369
|
attachments?: AttachmentRef[];
|
|
1741
2370
|
/**
|
|
@@ -1800,10 +2429,14 @@ export interface SessionSyncBaseResult {
|
|
|
1800
2429
|
export interface TrashEntry {
|
|
1801
2430
|
bytes: number;
|
|
1802
2431
|
/**
|
|
1803
|
-
* `.trash/` 下的目录名,如 `my-app-20261011T120000Z
|
|
2432
|
+
* `.trash/` 下的目录名,如 `my-app-20261011T120000Z`。每个根有自己的 `.trash/`,id 在所有根之间唯一。
|
|
1804
2433
|
*/
|
|
1805
2434
|
id: string;
|
|
1806
2435
|
original_name: string;
|
|
2436
|
+
/**
|
|
2437
|
+
* 条目所在(也是 `restore` 还原到)的 workspace 根。老版本的 daemon 不给,客户端当作主根。
|
|
2438
|
+
*/
|
|
2439
|
+
root?: string | null;
|
|
1807
2440
|
trashed_at_ms: number;
|
|
1808
2441
|
}
|
|
1809
2442
|
/**
|
|
@@ -1900,6 +2533,10 @@ export interface RenamedProject {
|
|
|
1900
2533
|
}
|
|
1901
2534
|
export interface WorkspaceCloneParams {
|
|
1902
2535
|
name?: string | null;
|
|
2536
|
+
/**
|
|
2537
|
+
* 克隆到哪个 workspace 根下,规则同 `WorkspaceCreateParams.root`。
|
|
2538
|
+
*/
|
|
2539
|
+
root?: string | null;
|
|
1903
2540
|
/**
|
|
1904
2541
|
* 只允许 `https://`、`ssh://`、`git@host:path` 三种形式。
|
|
1905
2542
|
*/
|
|
@@ -1908,6 +2545,11 @@ export interface WorkspaceCloneParams {
|
|
|
1908
2545
|
export interface WorkspaceCreateParams {
|
|
1909
2546
|
git_init?: boolean;
|
|
1910
2547
|
name: string;
|
|
2548
|
+
/**
|
|
2549
|
+
* 在哪个 workspace 根下新建。必须是 `node.info.workspace_roots` 里的某一项的 `path`;缺省 = 主根;
|
|
2550
|
+
* 不在列表里 → `invalid`,在列表里但现在不可用(`available = false`)→ `not_found`。
|
|
2551
|
+
*/
|
|
2552
|
+
root?: string | null;
|
|
1911
2553
|
}
|
|
1912
2554
|
/**
|
|
1913
2555
|
* `workspace.link`:把本机一个已有目录关联为项目。
|
|
@@ -1925,6 +2567,9 @@ export interface WorkspaceLinkParams {
|
|
|
1925
2567
|
}
|
|
1926
2568
|
export interface WorkspaceListResult {
|
|
1927
2569
|
projects: Project[];
|
|
2570
|
+
/**
|
|
2571
|
+
* 主根(`node.info.workspace_roots` 里 `primary` 的那一项)。其余根下的项目看 `Project.root`。
|
|
2572
|
+
*/
|
|
1928
2573
|
root: string;
|
|
1929
2574
|
}
|
|
1930
2575
|
export interface WorkspaceNameParams {
|