@anycon/protocol 0.3.1 → 0.4.2
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 +75 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +80 -0
- package/dist/constants.js.map +1 -1
- package/dist/envelope.d.ts.map +1 -1
- package/dist/envelope.js +3 -1
- package/dist/envelope.js.map +1 -1
- package/dist/generated.d.ts +1756 -59
- package/dist/generated.d.ts.map +1 -1
- package/dist/method-types.d.ts +174 -1
- package/dist/method-types.d.ts.map +1 -1
- package/dist/preview.d.ts +9 -1
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +30 -2
- package/dist/preview.js.map +1 -1
- package/dist/rpc.d.ts +6 -0
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +18 -0
- package/dist/rpc.js.map +1 -1
- package/package.json +3 -3
- package/src/constants.ts +83 -0
- package/src/envelope.ts +3 -1
- package/src/generated.ts +1806 -54
- package/src/method-types.ts +111 -0
- package/src/preview.ts +28 -2
- package/src/rpc.ts +15 -0
- package/wasm/THIRD-PARTY-LICENSES.txt +3 -3
- package/wasm/anycon_crypto_bg.wasm +0 -0
package/dist/generated.d.ts
CHANGED
|
@@ -5,7 +5,15 @@ export type AgentStatus = ("ready" | "disabled" | "not_installed" | "not_authent
|
|
|
5
5
|
* 一个目录为什么不能关联为项目(ADR-33 修订,daemon.md § 10)。
|
|
6
6
|
*/
|
|
7
7
|
export type LinkBlock = "hidden" | "sensitive" | "workspace" | "data_dir" | "filesystem_root";
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* `rule.update` 的 `clear` 可以清空的可选字段。
|
|
10
|
+
*/
|
|
11
|
+
export type ClearableRuleField = "project";
|
|
12
|
+
/**
|
|
13
|
+
* `todo.update` 的 `clear` 可以清空的可选字段。
|
|
14
|
+
*/
|
|
15
|
+
export type ClearableTodoField = "project" | "due_ms" | "repeat";
|
|
16
|
+
export type DeviceKind = ("daemon" | "web" | "cli" | "sdk") | "twin" | "unknown";
|
|
9
17
|
/**
|
|
10
18
|
* 一项配置能不能被远程客户端改(ADR-43)。
|
|
11
19
|
*/
|
|
@@ -189,7 +197,7 @@ export type EnrollMethod = "scan" | "code" | "password";
|
|
|
189
197
|
/**
|
|
190
198
|
* `EnrollReply.reason`(`status = rejected` 时)。
|
|
191
199
|
*/
|
|
192
|
-
export type EnrollRejectReason = "method_disabled" | "password_not_set" | "backoff" | "locked" | "no_code" | "busy" | "denied" | "wrong_secret" | "expired" | "invalid";
|
|
200
|
+
export type EnrollRejectReason = "method_disabled" | "password_not_set" | "backoff" | "locked" | "no_code" | "busy" | "denied" | "wrong_secret" | "expired" | "invalid" | "twin_not_allowed" | "unknown";
|
|
193
201
|
/**
|
|
194
202
|
* `EnrollReply.status`。
|
|
195
203
|
*/
|
|
@@ -471,6 +479,9 @@ export type FsReadEncoding = "text" | "base64";
|
|
|
471
479
|
* 信封种类。hub 对每种的处理见 docs/protocol.md § 3。
|
|
472
480
|
*/
|
|
473
481
|
export type Kind = "handshake" | "data" | "notify" | "control";
|
|
482
|
+
export type JudgeApiFormat = "anthropic" | "openai" | "unknown";
|
|
483
|
+
export type JudgeBackendKind = "api" | "agent" | "unknown";
|
|
484
|
+
export type JudgeProblem = "no_key" | "agent_missing" | "agent_unsupported" | "unknown";
|
|
474
485
|
/**
|
|
475
486
|
* 节点配置 `worktree.default` 的取值,也是 `SessionWorkspace` 的两种模式。
|
|
476
487
|
*/
|
|
@@ -482,8 +493,8 @@ export type NodeLogLevel = "trace" | "debug" | "info" | "warn" | "error";
|
|
|
482
493
|
/**
|
|
483
494
|
* `node.security_event.kind`。
|
|
484
495
|
*/
|
|
485
|
-
export type SecurityEventKind = "device_enrolled" | "password_failures" | "password_locked" | "password_changed" | "settings_changed";
|
|
486
|
-
export type NotifyCategory = ("permission_requested" | "turn_finished" | "error" | "session_idle") | "enroll_requested" | "security";
|
|
496
|
+
export type SecurityEventKind = "device_enrolled" | "password_failures" | "password_locked" | "password_changed" | "settings_changed" | "twin_linked" | "twin_unlinked" | "unknown";
|
|
497
|
+
export type NotifyCategory = ("permission_requested" | "turn_finished" | "error" | "session_idle") | "follow_up" | "twin_question" | "enroll_requested" | "security";
|
|
487
498
|
/**
|
|
488
499
|
* 隧道里响应体的编码。`gzip`:`DATA` 帧拼起来是 gzip 流,预览页要先解压;`headers` 里已经去掉
|
|
489
500
|
* `content-encoding` / `content-length`。
|
|
@@ -507,12 +518,44 @@ export type PreviewResetCode = "internal" | "refused" | "timeout" | "too_large"
|
|
|
507
518
|
* 项目从哪来。
|
|
508
519
|
*/
|
|
509
520
|
export type ProjectKind = "folder" | "linked";
|
|
521
|
+
/**
|
|
522
|
+
* 第一条消息里的一段是从哪里来的(`PromptSegment.kind`)。`title` / `body` 是人写的(或照抄模板的),其余是 daemon 加的,
|
|
523
|
+
* 只有 `earlier_reports` 和 `twin_note` 里是 agent / Twin 写的内容。
|
|
524
|
+
*/
|
|
525
|
+
export type PromptSegmentKind = "title" | "body" | "earlier_reports" | "state_usage" | "closing_report" | "no_push" | "twin_note" | "unknown";
|
|
510
526
|
export type PullRequestState = "open" | "draft" | "merged" | "closed";
|
|
511
527
|
/**
|
|
512
528
|
* 一条内层消息。解码时按字段判别:有 `method` 且有 `id` 是请求,有 `method` 无 `id` 是通知,否则是响应。
|
|
513
529
|
*/
|
|
514
530
|
export type RpcMessage = RpcRequest | RpcNotification | RpcResponse;
|
|
515
531
|
export type RpcId = number | string;
|
|
532
|
+
/**
|
|
533
|
+
* 规则是怎么来的。
|
|
534
|
+
*/
|
|
535
|
+
export type RuleSourceKind = "manual" | "answer" | "extracted" | "agent" | "unknown";
|
|
536
|
+
/**
|
|
537
|
+
* 规则的状态。
|
|
538
|
+
*/
|
|
539
|
+
export type RuleStatus = "pending" | "active" | "disabled" | "rejected" | "unknown";
|
|
540
|
+
/**
|
|
541
|
+
* 规则在节点之间的同步范围,由客户端同步(docs/spec/daemon.md § 23.8)。
|
|
542
|
+
*/
|
|
543
|
+
export type RuleSync = "node" | "group" | "unknown";
|
|
544
|
+
/**
|
|
545
|
+
* `rule.add` 的调用方可以声明的来源种类(`extracted` 只有 daemon 自己提炼时才有,`agent` 由 `agent: true` 决定)。
|
|
546
|
+
*/
|
|
547
|
+
export type RuleAddSourceKind = "manual" | "answer";
|
|
548
|
+
/**
|
|
549
|
+
* `rule.add` 可以直接给的状态。
|
|
550
|
+
*/
|
|
551
|
+
export type RuleAddStatus = "active" | "pending" | "disabled" | "rejected";
|
|
552
|
+
export type JudgeErrorCode = "timeout" | "network" | "http" | "auth" | "rate_limited" | "bad_output" | "agent_failed" | "cancelled" | "internal" | "unknown";
|
|
553
|
+
export type ExtractRunStatus = "running" | "done" | "failed" | "unknown";
|
|
554
|
+
export type ExtractTrigger = "manual" | "auto" | "unknown";
|
|
555
|
+
/**
|
|
556
|
+
* 派发时生效的规则没有注入的原因(`TodoEventData::Dispatched.rules_skipped`)。
|
|
557
|
+
*/
|
|
558
|
+
export type RulesSkipped = "unsupported" | "unknown";
|
|
516
559
|
/**
|
|
517
560
|
* 归档 / 删除会话时怎么处理它的 worktree。
|
|
518
561
|
*/
|
|
@@ -548,6 +591,227 @@ export type SessionWorkspace = {
|
|
|
548
591
|
*/
|
|
549
592
|
export type ClearableSetting = ("thinking" | "mode" | "system_prompt_append" | "max_turns" | "max_budget_usd") | "model" | "env";
|
|
550
593
|
export type SyncOutcome = "up_to_date" | "merged" | "conflicts" | "aborted";
|
|
594
|
+
/**
|
|
595
|
+
* 清单项派出的会话现在的情况(算出来的,不存;`Todo.activity`)。
|
|
596
|
+
*/
|
|
597
|
+
export type TodoActivity = "working" | "waiting" | "review" | "unknown";
|
|
598
|
+
/**
|
|
599
|
+
* 清单项的处理人;旧节点没有这个字段时由人处理。
|
|
600
|
+
*/
|
|
601
|
+
export type TodoHandler = "me" | "twin" | "unknown";
|
|
602
|
+
/**
|
|
603
|
+
* `kind = interval` 的规则在哪些日子里生效(`TodoRepeat.days`)。
|
|
604
|
+
*/
|
|
605
|
+
export type TodoRepeatDays = "daily" | "weekdays" | "weekly" | "unknown";
|
|
606
|
+
/**
|
|
607
|
+
* 周期项的重复方式(`TodoRepeat.kind`)。
|
|
608
|
+
*/
|
|
609
|
+
export type TodoRepeatKind = "daily" | "weekdays" | "weekly" | "interval" | "unknown";
|
|
610
|
+
/**
|
|
611
|
+
* 一项是谁记的。
|
|
612
|
+
*/
|
|
613
|
+
export type TodoSourceKind = "device" | "local" | "agent" | "twin" | "repeat" | "unknown";
|
|
614
|
+
/**
|
|
615
|
+
* 清单项的状态。这一步 daemon 不限制状态之间怎么转。
|
|
616
|
+
*/
|
|
617
|
+
export type TodoState = "open" | "working" | "waiting" | "review" | "done" | "dropped";
|
|
618
|
+
/**
|
|
619
|
+
* 「经过」里的一条:只追加,没有修改、删除一条的方法;删除这一项时一起删。
|
|
620
|
+
*/
|
|
621
|
+
export type TodoEvent = {
|
|
622
|
+
/**
|
|
623
|
+
* 这一项内从 1 递增。
|
|
624
|
+
*/
|
|
625
|
+
seq: number;
|
|
626
|
+
ts_ms: number;
|
|
627
|
+
} & TodoEvent1;
|
|
628
|
+
export type TodoEvent1 = {
|
|
629
|
+
agent: string;
|
|
630
|
+
by: TodoActor;
|
|
631
|
+
kind: "dispatched";
|
|
632
|
+
no_push: boolean;
|
|
633
|
+
/**
|
|
634
|
+
* 注入这个会话的系统提示的规则(`rule.*`,docs/spec/daemon.md § 23.5),按在文字里的顺序。没有注入时缺省(旧 daemon 的记录也没有)。
|
|
635
|
+
*/
|
|
636
|
+
rules?: string[];
|
|
637
|
+
/**
|
|
638
|
+
* 有生效的规则、但没有注入的原因。
|
|
639
|
+
*/
|
|
640
|
+
rules_skipped?: RulesSkipped | null;
|
|
641
|
+
session_id: string;
|
|
642
|
+
workspace_mode: SessionWorkspaceMode;
|
|
643
|
+
} | {
|
|
644
|
+
kind: "result";
|
|
645
|
+
session_id: string;
|
|
646
|
+
text: string;
|
|
647
|
+
truncated: boolean;
|
|
648
|
+
turn: number;
|
|
649
|
+
} | {
|
|
650
|
+
by: TodoActor;
|
|
651
|
+
from: TodoState;
|
|
652
|
+
kind: "state";
|
|
653
|
+
to: TodoState;
|
|
654
|
+
} | {
|
|
655
|
+
done?: boolean;
|
|
656
|
+
kind: "handed_back";
|
|
657
|
+
reason: string;
|
|
658
|
+
run_id?: string | null;
|
|
659
|
+
} | {
|
|
660
|
+
by: TodoActor;
|
|
661
|
+
kind: "taken_over";
|
|
662
|
+
node_id?: string | null;
|
|
663
|
+
} | {
|
|
664
|
+
action: TwinAction;
|
|
665
|
+
kind: "twin_decision";
|
|
666
|
+
reason: string;
|
|
667
|
+
run_id: string;
|
|
668
|
+
} | {
|
|
669
|
+
kind: "twin_question";
|
|
670
|
+
question_id: string;
|
|
671
|
+
} | {
|
|
672
|
+
by: TodoActor;
|
|
673
|
+
from: TodoHandler;
|
|
674
|
+
kind: "handler";
|
|
675
|
+
to: TodoHandler;
|
|
676
|
+
} | {
|
|
677
|
+
at_ms: number;
|
|
678
|
+
kind: "repeat_created";
|
|
679
|
+
manual?: boolean;
|
|
680
|
+
todo_id: string;
|
|
681
|
+
} | {
|
|
682
|
+
at_ms: number;
|
|
683
|
+
kind: "repeat_skipped";
|
|
684
|
+
} | {
|
|
685
|
+
kind: "remote_dispatched";
|
|
686
|
+
node_id: string;
|
|
687
|
+
session_id: string;
|
|
688
|
+
todo_id: string;
|
|
689
|
+
} | {
|
|
690
|
+
kind: "remote_result";
|
|
691
|
+
node_id: string;
|
|
692
|
+
session_id: string;
|
|
693
|
+
text: string;
|
|
694
|
+
} | {
|
|
695
|
+
event: PrEventKind;
|
|
696
|
+
kind: "pr_event";
|
|
697
|
+
session_id: string;
|
|
698
|
+
url?: string | null;
|
|
699
|
+
} | {
|
|
700
|
+
kind: "state_usage";
|
|
701
|
+
/**
|
|
702
|
+
* `todo.state_get` / `state_list` / `state_unseen` 的次数。
|
|
703
|
+
*/
|
|
704
|
+
reads: number;
|
|
705
|
+
session_id: string;
|
|
706
|
+
turn: number;
|
|
707
|
+
/**
|
|
708
|
+
* `todo.state_set` / `state_delete` 的次数。
|
|
709
|
+
*/
|
|
710
|
+
writes: number;
|
|
711
|
+
} | {
|
|
712
|
+
kind: "unknown";
|
|
713
|
+
};
|
|
714
|
+
export type TwinAction = "dispatch" | "ask_user" | "ask_advisor" | "wait" | "hand_back" | "done" | "unknown";
|
|
715
|
+
/**
|
|
716
|
+
* [`TodoEventData::PrEvent`] 的种类。
|
|
717
|
+
*/
|
|
718
|
+
export type PrEventKind = "merged" | "checks_failed" | "closed" | "reviewed" | "unknown";
|
|
719
|
+
/**
|
|
720
|
+
* 「经过」里的一条的内容;`kind` 是线路上的标签。
|
|
721
|
+
*/
|
|
722
|
+
export type TodoEventData = {
|
|
723
|
+
agent: string;
|
|
724
|
+
by: TodoActor;
|
|
725
|
+
kind: "dispatched";
|
|
726
|
+
no_push: boolean;
|
|
727
|
+
/**
|
|
728
|
+
* 注入这个会话的系统提示的规则(`rule.*`,docs/spec/daemon.md § 23.5),按在文字里的顺序。没有注入时缺省(旧 daemon 的记录也没有)。
|
|
729
|
+
*/
|
|
730
|
+
rules?: string[];
|
|
731
|
+
/**
|
|
732
|
+
* 有生效的规则、但没有注入的原因。
|
|
733
|
+
*/
|
|
734
|
+
rules_skipped?: RulesSkipped | null;
|
|
735
|
+
session_id: string;
|
|
736
|
+
workspace_mode: SessionWorkspaceMode;
|
|
737
|
+
} | {
|
|
738
|
+
kind: "result";
|
|
739
|
+
session_id: string;
|
|
740
|
+
text: string;
|
|
741
|
+
truncated: boolean;
|
|
742
|
+
turn: number;
|
|
743
|
+
} | {
|
|
744
|
+
by: TodoActor;
|
|
745
|
+
from: TodoState;
|
|
746
|
+
kind: "state";
|
|
747
|
+
to: TodoState;
|
|
748
|
+
} | {
|
|
749
|
+
done?: boolean;
|
|
750
|
+
kind: "handed_back";
|
|
751
|
+
reason: string;
|
|
752
|
+
run_id?: string | null;
|
|
753
|
+
} | {
|
|
754
|
+
by: TodoActor;
|
|
755
|
+
kind: "taken_over";
|
|
756
|
+
node_id?: string | null;
|
|
757
|
+
} | {
|
|
758
|
+
action: TwinAction;
|
|
759
|
+
kind: "twin_decision";
|
|
760
|
+
reason: string;
|
|
761
|
+
run_id: string;
|
|
762
|
+
} | {
|
|
763
|
+
kind: "twin_question";
|
|
764
|
+
question_id: string;
|
|
765
|
+
} | {
|
|
766
|
+
by: TodoActor;
|
|
767
|
+
from: TodoHandler;
|
|
768
|
+
kind: "handler";
|
|
769
|
+
to: TodoHandler;
|
|
770
|
+
} | {
|
|
771
|
+
at_ms: number;
|
|
772
|
+
kind: "repeat_created";
|
|
773
|
+
manual?: boolean;
|
|
774
|
+
todo_id: string;
|
|
775
|
+
} | {
|
|
776
|
+
at_ms: number;
|
|
777
|
+
kind: "repeat_skipped";
|
|
778
|
+
} | {
|
|
779
|
+
kind: "remote_dispatched";
|
|
780
|
+
node_id: string;
|
|
781
|
+
session_id: string;
|
|
782
|
+
todo_id: string;
|
|
783
|
+
} | {
|
|
784
|
+
kind: "remote_result";
|
|
785
|
+
node_id: string;
|
|
786
|
+
session_id: string;
|
|
787
|
+
text: string;
|
|
788
|
+
} | {
|
|
789
|
+
event: PrEventKind;
|
|
790
|
+
kind: "pr_event";
|
|
791
|
+
session_id: string;
|
|
792
|
+
url?: string | null;
|
|
793
|
+
} | {
|
|
794
|
+
kind: "state_usage";
|
|
795
|
+
/**
|
|
796
|
+
* `todo.state_get` / `state_list` / `state_unseen` 的次数。
|
|
797
|
+
*/
|
|
798
|
+
reads: number;
|
|
799
|
+
session_id: string;
|
|
800
|
+
turn: number;
|
|
801
|
+
/**
|
|
802
|
+
* `todo.state_set` / `state_delete` 的次数。
|
|
803
|
+
*/
|
|
804
|
+
writes: number;
|
|
805
|
+
} | {
|
|
806
|
+
kind: "unknown";
|
|
807
|
+
};
|
|
808
|
+
export type TwinDecisionOutcome = "executed" | "skipped" | "unknown";
|
|
809
|
+
export type TwinSkipReason = ("invalid" | "out_of_scope" | "no_capacity" | "budget" | "unknown") | "remote_unavailable" | "remote_refused";
|
|
810
|
+
export type TwinRunResult = "done" | "idle" | "budget" | "failed" | "cancelled" | "unknown";
|
|
811
|
+
export type TwinTrigger = ("todo" | "session" | "answer" | "tick" | "manual" | "unknown") | "pr";
|
|
812
|
+
export type TwinState = "running" | "idle" | "paused" | "disabled" | "not_configured" | "budget" | "unknown";
|
|
813
|
+
export type TwinQuestionStatus = "open" | "answered" | "void" | "unknown";
|
|
814
|
+
export type ClearableTwinField = "agent" | "model" | "mode" | "unknown";
|
|
551
815
|
/**
|
|
552
816
|
* 仅用于导出 schema,不在线上传输。字段名即 TS / Python 的类型名。
|
|
553
817
|
*/
|
|
@@ -565,6 +829,8 @@ export interface ProtocolSchema {
|
|
|
565
829
|
blob_put_begin_result: BlobPutBeginResult;
|
|
566
830
|
blob_put_chunk_params: BlobPutChunkParams;
|
|
567
831
|
browse_entry: BrowseEntry;
|
|
832
|
+
clearable_rule_field: ClearableRuleField;
|
|
833
|
+
clearable_todo_field: ClearableTodoField;
|
|
568
834
|
client_info: ClientInfo;
|
|
569
835
|
config_change: ConfigChange;
|
|
570
836
|
config_editable: ConfigEditable;
|
|
@@ -625,6 +891,7 @@ export interface ProtocolSchema {
|
|
|
625
891
|
node_set_enroll_enabled_params: NodeSetEnrollEnabledParams;
|
|
626
892
|
node_set_enroll_password_params: NodeSetEnrollPasswordParams;
|
|
627
893
|
node_stats: NodeStats;
|
|
894
|
+
node_twin_link_code_result: NodeTwinLinkCodeResult;
|
|
628
895
|
node_worktree_settings: NodeWorktreeSettings;
|
|
629
896
|
notify_body: NotifyBody;
|
|
630
897
|
notify_detail: NotifyDetail;
|
|
@@ -656,11 +923,50 @@ export interface ProtocolSchema {
|
|
|
656
923
|
preview_response_head: PreviewResponseHead;
|
|
657
924
|
project: Project;
|
|
658
925
|
project_kind: ProjectKind;
|
|
926
|
+
prompt_segment: PromptSegment;
|
|
927
|
+
prompt_segment_kind: PromptSegmentKind;
|
|
659
928
|
pull_request_info: PullRequestInfo;
|
|
660
929
|
pull_request_state: PullRequestState;
|
|
661
930
|
quota: Quota;
|
|
931
|
+
repeat_state_changed: RepeatStateChanged;
|
|
932
|
+
repeat_state_clear_params: RepeatStateClearParams;
|
|
933
|
+
repeat_state_clear_result: RepeatStateClearResult;
|
|
934
|
+
repeat_state_delete_params: RepeatStateDeleteParams;
|
|
935
|
+
repeat_state_delete_result: RepeatStateDeleteResult;
|
|
936
|
+
repeat_state_entry: RepeatStateEntry;
|
|
937
|
+
repeat_state_get_params: RepeatStateGetParams;
|
|
938
|
+
repeat_state_get_result: RepeatStateGetResult;
|
|
939
|
+
repeat_state_list_params: RepeatStateListParams;
|
|
940
|
+
repeat_state_list_result: RepeatStateListResult;
|
|
941
|
+
repeat_state_set_params: RepeatStateSetParams;
|
|
942
|
+
repeat_state_set_result: RepeatStateSetResult;
|
|
943
|
+
repeat_state_unseen_params: RepeatStateUnseenParams;
|
|
944
|
+
repeat_state_unseen_result: RepeatStateUnseenResult;
|
|
662
945
|
rpc_error: RpcError;
|
|
663
946
|
rpc_message: RpcMessage;
|
|
947
|
+
rule: Rule;
|
|
948
|
+
rule_add_params: RuleAddParams;
|
|
949
|
+
rule_add_source: RuleAddSource;
|
|
950
|
+
rule_add_source_kind: RuleAddSourceKind;
|
|
951
|
+
rule_add_status: RuleAddStatus;
|
|
952
|
+
rule_budget: RuleBudget;
|
|
953
|
+
rule_changed: RuleChanged;
|
|
954
|
+
rule_delete_params: RuleDeleteParams;
|
|
955
|
+
rule_extract_done: RuleExtractDone;
|
|
956
|
+
rule_extract_params: RuleExtractParams;
|
|
957
|
+
rule_extract_result: RuleExtractResult;
|
|
958
|
+
rule_extract_runs_params: RuleExtractRunsParams;
|
|
959
|
+
rule_extract_runs_result: RuleExtractRunsResult;
|
|
960
|
+
rule_list_params: RuleListParams;
|
|
961
|
+
rule_list_result: RuleListResult;
|
|
962
|
+
rule_preview_params: RulePreviewParams;
|
|
963
|
+
rule_preview_result: RulePreviewResult;
|
|
964
|
+
rule_source: RuleSource;
|
|
965
|
+
rule_source_kind: RuleSourceKind;
|
|
966
|
+
rule_status: RuleStatus;
|
|
967
|
+
rule_sync: RuleSync;
|
|
968
|
+
rule_update_params: RuleUpdateParams;
|
|
969
|
+
rules_skipped: RulesSkipped;
|
|
664
970
|
security_event_kind: SecurityEventKind;
|
|
665
971
|
session_archive_params: SessionArchiveParams;
|
|
666
972
|
session_changed: SessionChanged;
|
|
@@ -676,12 +982,14 @@ export interface ProtocolSchema {
|
|
|
676
982
|
session_id_params: SessionIdParams;
|
|
677
983
|
session_list_params: SessionListParams;
|
|
678
984
|
session_list_result: SessionListResult;
|
|
985
|
+
session_mark_read_params: SessionMarkReadParams;
|
|
679
986
|
session_promote_params: SessionPromoteParams;
|
|
680
987
|
session_rename_params: SessionRenameParams;
|
|
681
988
|
session_search_params: SessionSearchParams;
|
|
682
989
|
session_search_result: SessionSearchResult;
|
|
683
990
|
session_send_params: SessionSendParams;
|
|
684
991
|
session_send_result: SessionSendResult;
|
|
992
|
+
session_set_marks_params: SessionSetMarksParams;
|
|
685
993
|
session_set_settings_params: SessionSetSettingsParams;
|
|
686
994
|
session_set_settings_result: SessionSetSettingsResult;
|
|
687
995
|
session_settings: SessionSettings;
|
|
@@ -692,7 +1000,60 @@ export interface ProtocolSchema {
|
|
|
692
1000
|
session_workspace_mode: SessionWorkspaceMode;
|
|
693
1001
|
session_worktree: SessionWorktree;
|
|
694
1002
|
sync_outcome: SyncOutcome;
|
|
1003
|
+
todo: Todo;
|
|
1004
|
+
todo_activity: TodoActivity;
|
|
1005
|
+
todo_actor: TodoActor;
|
|
1006
|
+
todo_add_params: TodoAddParams;
|
|
1007
|
+
todo_changed: TodoChanged;
|
|
1008
|
+
todo_cursor: TodoCursor;
|
|
1009
|
+
todo_delete_params: TodoDeleteParams;
|
|
1010
|
+
todo_dispatch_params: TodoDispatchParams;
|
|
1011
|
+
todo_dispatch_preview_params: TodoDispatchPreviewParams;
|
|
1012
|
+
todo_dispatch_preview_result: TodoDispatchPreviewResult;
|
|
1013
|
+
todo_dispatch_result: TodoDispatchResult;
|
|
1014
|
+
todo_event: TodoEvent;
|
|
1015
|
+
todo_event_data: TodoEventData;
|
|
1016
|
+
todo_event_notice: TodoEventNotice;
|
|
1017
|
+
todo_history_params: TodoHistoryParams;
|
|
1018
|
+
todo_history_result: TodoHistoryResult;
|
|
1019
|
+
todo_id_params: TodoIdParams;
|
|
1020
|
+
todo_list_params: TodoListParams;
|
|
1021
|
+
todo_list_result: TodoListResult;
|
|
1022
|
+
todo_remote: TodoRemote;
|
|
1023
|
+
todo_repeat_preview_params: TodoRepeatPreviewParams;
|
|
1024
|
+
todo_repeat_preview_result: TodoRepeatPreviewResult;
|
|
1025
|
+
todo_source: TodoSource;
|
|
1026
|
+
todo_source_kind: TodoSourceKind;
|
|
1027
|
+
todo_state: TodoState;
|
|
1028
|
+
todo_update_params: TodoUpdateParams;
|
|
695
1029
|
trash_entry: TrashEntry;
|
|
1030
|
+
twin_answer_params: TwinAnswerParams;
|
|
1031
|
+
twin_changed: TwinChanged;
|
|
1032
|
+
twin_day_stats: TwinDayStats;
|
|
1033
|
+
twin_decision: TwinDecision;
|
|
1034
|
+
twin_dry_run_result: TwinDryRunResult;
|
|
1035
|
+
twin_get_params: TwinGetParams;
|
|
1036
|
+
twin_get_result: TwinGetResult;
|
|
1037
|
+
twin_link: TwinLink;
|
|
1038
|
+
twin_link_params: TwinLinkParams;
|
|
1039
|
+
twin_links_result: TwinLinksResult;
|
|
1040
|
+
twin_peer_agent: TwinPeerAgent;
|
|
1041
|
+
twin_peer_status: TwinPeerStatus;
|
|
1042
|
+
twin_question: TwinQuestion;
|
|
1043
|
+
twin_question_notice: TwinQuestionNotice;
|
|
1044
|
+
twin_questions_params: TwinQuestionsParams;
|
|
1045
|
+
twin_questions_result: TwinQuestionsResult;
|
|
1046
|
+
twin_run: TwinRun;
|
|
1047
|
+
twin_run_brief: TwinRunBrief;
|
|
1048
|
+
twin_runs_params: TwinRunsParams;
|
|
1049
|
+
twin_runs_result: TwinRunsResult;
|
|
1050
|
+
twin_scope: TwinScope;
|
|
1051
|
+
twin_set_params: TwinSetParams;
|
|
1052
|
+
twin_state: TwinState;
|
|
1053
|
+
twin_stats_params: TwinStatsParams;
|
|
1054
|
+
twin_stats_result: TwinStatsResult;
|
|
1055
|
+
twin_today: TwinToday;
|
|
1056
|
+
twin_unlink_params: TwinUnlinkParams;
|
|
696
1057
|
workspace_branches_params: WorkspaceBranchesParams;
|
|
697
1058
|
workspace_branches_result: WorkspaceBranchesResult;
|
|
698
1059
|
workspace_browse_params: WorkspaceBrowseParams;
|
|
@@ -769,12 +1130,22 @@ export interface AgentCapabilities {
|
|
|
769
1130
|
*/
|
|
770
1131
|
interject: boolean;
|
|
771
1132
|
interrupt: boolean;
|
|
1133
|
+
/**
|
|
1134
|
+
* 能做一次性调用:不开会话、没有工具,给 `kind = "agent"` 的判断后端用(docs/spec/daemon.md § 25.1)。
|
|
1135
|
+
* 旧 daemon 没有这个字段,按 false。
|
|
1136
|
+
*/
|
|
1137
|
+
oneshot?: boolean;
|
|
772
1138
|
/**
|
|
773
1139
|
* 进程退出后能否续接。
|
|
774
1140
|
*/
|
|
775
1141
|
resume: boolean;
|
|
776
1142
|
rewind: boolean;
|
|
777
1143
|
structured_output: boolean;
|
|
1144
|
+
/**
|
|
1145
|
+
* 会话的 `system_prompt_append` 真的会交给 agent(docs/spec/daemon.md § 6.3)。为 false(ACP agent、旧 daemon)时,
|
|
1146
|
+
* 决策档案里的规则注入不到它的会话里(§ 23.5)。
|
|
1147
|
+
*/
|
|
1148
|
+
system_prompt?: boolean;
|
|
778
1149
|
/**
|
|
779
1150
|
* 会不会发 `thinking_delta`。
|
|
780
1151
|
*/
|
|
@@ -830,6 +1201,10 @@ export interface ModeInfo {
|
|
|
830
1201
|
id: string;
|
|
831
1202
|
label: string;
|
|
832
1203
|
risk: ModeRisk;
|
|
1204
|
+
/**
|
|
1205
|
+
* 无人值守时可以使用;由 agent 自己处理自动审批。
|
|
1206
|
+
*/
|
|
1207
|
+
unattended?: boolean;
|
|
833
1208
|
}
|
|
834
1209
|
/**
|
|
835
1210
|
* agent 特定的其他选项(Codex fast mode、ACP 自定义 configOptions…)。客户端用通用控件渲染。
|
|
@@ -1540,11 +1915,28 @@ export interface NodeInfo {
|
|
|
1540
1915
|
*/
|
|
1541
1916
|
attachment_limits?: NodeAttachmentLimits | null;
|
|
1542
1917
|
capabilities: NodeCapabilities;
|
|
1918
|
+
/**
|
|
1919
|
+
* 分组名(`[hub] group`):名字相同的节点客户端合并显示;是标签,不是访问控制。为空或旧 daemon 时不给。
|
|
1920
|
+
*/
|
|
1921
|
+
group?: string | null;
|
|
1922
|
+
/**
|
|
1923
|
+
* 判断后端的脱敏状态。
|
|
1924
|
+
*/
|
|
1925
|
+
judge?: JudgeInfo | null;
|
|
1543
1926
|
name: string;
|
|
1544
1927
|
node_id: string;
|
|
1545
1928
|
platform: string;
|
|
1546
1929
|
protocol_version: number;
|
|
1547
1930
|
started_at_ms: number;
|
|
1931
|
+
/**
|
|
1932
|
+
* `[twin] accept_links`:这个节点现在接受别的节点的 Twin 连接(docs/spec/daemon.md § 27.2)。旧 daemon 没有这个字段,读作 `false`。
|
|
1933
|
+
*/
|
|
1934
|
+
twin_accept_links?: boolean;
|
|
1935
|
+
/**
|
|
1936
|
+
* 更新检查(ADR-57)知道有比这个 daemon 更新的正式版本时给出;没有更新的版本、检查关着、还没检查成功过,
|
|
1937
|
+
* 以及旧 daemon,都不给。
|
|
1938
|
+
*/
|
|
1939
|
+
update_available?: NodeUpdateAvailable | null;
|
|
1548
1940
|
version: string;
|
|
1549
1941
|
/**
|
|
1550
1942
|
* 主根。多个根时看 `workspace_roots`。
|
|
@@ -1589,7 +1981,46 @@ export interface NodeCapabilities {
|
|
|
1589
1981
|
* 支持 dev server 预览(`preview.*`,ADR-39),且节点配置 `preview.enabled = true`。
|
|
1590
1982
|
*/
|
|
1591
1983
|
preview?: boolean;
|
|
1984
|
+
/**
|
|
1985
|
+
* 支持目录预览(`preview.open { dir }`,ADR-62),且节点开着预览。旧 daemon 没有这个字段,读作 false。
|
|
1986
|
+
*/
|
|
1987
|
+
preview_dir?: boolean;
|
|
1988
|
+
/**
|
|
1989
|
+
* 支持规则提炼 RPC;没有该字段时按不支持处理。
|
|
1990
|
+
*/
|
|
1991
|
+
rule_extract?: boolean;
|
|
1992
|
+
/**
|
|
1993
|
+
* 支持决策档案(`rule.*`,docs/spec/daemon.md § 23)。旧 daemon 没有这个字段,读作 false。
|
|
1994
|
+
*/
|
|
1995
|
+
rules?: boolean;
|
|
1592
1996
|
search: boolean;
|
|
1997
|
+
/**
|
|
1998
|
+
* 支持清单(`todo.*`,docs/spec/daemon.md § 21)。旧 daemon 没有这个字段,读作 false。
|
|
1999
|
+
*/
|
|
2000
|
+
todo?: boolean;
|
|
2001
|
+
/**
|
|
2002
|
+
* 支持周期项(`Todo.repeat`,docs/spec/daemon.md § 26.9)。旧 daemon 没有这个字段,读作 false。
|
|
2003
|
+
*/
|
|
2004
|
+
todo_repeat?: boolean;
|
|
2005
|
+
/**
|
|
2006
|
+
* 周期项支持 `kind = interval`、`auto_close`、`todo.repeat_now` 和 `repeat_created.manual`(docs/spec/daemon.md § 26.9)。
|
|
2007
|
+
* 旧 daemon 没有这个字段,读作 false。
|
|
2008
|
+
*/
|
|
2009
|
+
todo_repeat_interval?: boolean;
|
|
2010
|
+
/**
|
|
2011
|
+
* 周期项支持跨次状态:`repeat.keep_state` / `state_hint_off`、`todo.state_*`、`todo.state_changed`、`todo.repeat_preview`、
|
|
2012
|
+
* 「经过」的 `state_usage` 和预览的 `segments`(docs/spec/daemon.md § 26.11)。旧 daemon 没有这个字段,读作 false。
|
|
2013
|
+
*/
|
|
2014
|
+
todo_repeat_state?: boolean;
|
|
2015
|
+
/**
|
|
2016
|
+
* 支持 Twin 的调度和 RPC。
|
|
2017
|
+
*/
|
|
2018
|
+
twin?: boolean;
|
|
2019
|
+
/**
|
|
2020
|
+
* daemon 提供 `twin.stats`,`twin.get` 带 `last_run` / `next_wake_ms` / `queued` / `deferred`,`TwinRun` 带 `usage`
|
|
2021
|
+
* (docs/spec/daemon.md § 26.8)。旧 daemon 没有这个字段,读作 false。
|
|
2022
|
+
*/
|
|
2023
|
+
twin_stats?: boolean;
|
|
1593
2024
|
/**
|
|
1594
2025
|
* 有 workspace(文件夹即项目)。SDK 节点可能没有。
|
|
1595
2026
|
*/
|
|
@@ -1599,6 +2030,39 @@ export interface NodeCapabilities {
|
|
|
1599
2030
|
*/
|
|
1600
2031
|
worktree?: boolean;
|
|
1601
2032
|
}
|
|
2033
|
+
export interface JudgeInfo {
|
|
2034
|
+
advisor?: string | null;
|
|
2035
|
+
backends: JudgeBackendInfo[];
|
|
2036
|
+
daily_calls: number;
|
|
2037
|
+
extract?: string | null;
|
|
2038
|
+
triage?: string | null;
|
|
2039
|
+
}
|
|
2040
|
+
export interface JudgeBackendInfo {
|
|
2041
|
+
agent?: string | null;
|
|
2042
|
+
format?: JudgeApiFormat | null;
|
|
2043
|
+
kind: JudgeBackendKind;
|
|
2044
|
+
model?: string | null;
|
|
2045
|
+
name: string;
|
|
2046
|
+
problem?: JudgeProblem | null;
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* 有更新的版本(`node.info.update_available`)。daemon 只在 `latest` 是严格的 `X.Y.Z` 且比自己的版本新时给出;
|
|
2050
|
+
* `url` 由 daemon 用版本号拼出来,不取 anycon.ai 回应里的链接。
|
|
2051
|
+
*/
|
|
2052
|
+
export interface NodeUpdateAvailable {
|
|
2053
|
+
/**
|
|
2054
|
+
* 得到这个结果的那次检查的时间。
|
|
2055
|
+
*/
|
|
2056
|
+
checked_at_ms: number;
|
|
2057
|
+
/**
|
|
2058
|
+
* 最新的正式版本,`X.Y.Z`,不带 `v`。
|
|
2059
|
+
*/
|
|
2060
|
+
latest: string;
|
|
2061
|
+
/**
|
|
2062
|
+
* 这个版本的发布页:总是 `https://github.com/anycon-ai/anycon/releases/tag/v<latest>`。
|
|
2063
|
+
*/
|
|
2064
|
+
url: string;
|
|
2065
|
+
}
|
|
1602
2066
|
/**
|
|
1603
2067
|
* 一个 workspace 根(ADR-45)。每个根下的一级子文件夹都是项目。
|
|
1604
2068
|
*/
|
|
@@ -1756,6 +2220,19 @@ export interface SessionCounts {
|
|
|
1756
2220
|
running: number;
|
|
1757
2221
|
waiting_permission: number;
|
|
1758
2222
|
}
|
|
2223
|
+
/**
|
|
2224
|
+
* `node.twin_link_code` 的结果:B 开了一次只接受 Twin 设备的短码配对。
|
|
2225
|
+
*/
|
|
2226
|
+
export interface NodeTwinLinkCodeResult {
|
|
2227
|
+
/**
|
|
2228
|
+
* 16 位短码(`XXXX-XXXX-XXXX-XXXX`)。
|
|
2229
|
+
*/
|
|
2230
|
+
code: string;
|
|
2231
|
+
/**
|
|
2232
|
+
* 过期时间(10 分钟后)。
|
|
2233
|
+
*/
|
|
2234
|
+
expires_ms: number;
|
|
2235
|
+
}
|
|
1759
2236
|
/**
|
|
1760
2237
|
* `kind = notify` 的 body(msgpack)。`category` 是外层唯一有语义的明文字段。
|
|
1761
2238
|
*/
|
|
@@ -1854,8 +2331,15 @@ export interface PreviewGoaway {
|
|
|
1854
2331
|
* 隧道握手第二条消息(daemon → 预览页)的 payload,JSON。到这一条预览页才确认对端持有票据、是钉住的 daemon。
|
|
1855
2332
|
*/
|
|
1856
2333
|
export interface PreviewHello {
|
|
2334
|
+
/**
|
|
2335
|
+
* 目录票据的目录。
|
|
2336
|
+
*/
|
|
2337
|
+
dir?: string | null;
|
|
1857
2338
|
expires_at_ms: number;
|
|
1858
|
-
|
|
2339
|
+
/**
|
|
2340
|
+
* 票据的目标,和 [`PreviewLaunch`] 里的一致才算连对了:端口票据给 `port`,目录票据给 `dir`。
|
|
2341
|
+
*/
|
|
2342
|
+
port?: number | null;
|
|
1859
2343
|
session_id?: string | null;
|
|
1860
2344
|
}
|
|
1861
2345
|
/**
|
|
@@ -1868,9 +2352,16 @@ export interface PreviewInfo {
|
|
|
1868
2352
|
*/
|
|
1869
2353
|
created_by: string;
|
|
1870
2354
|
created_by_name: string;
|
|
2355
|
+
/**
|
|
2356
|
+
* 目录票据的目录。
|
|
2357
|
+
*/
|
|
2358
|
+
dir?: string | null;
|
|
1871
2359
|
expires_at_ms: number;
|
|
1872
2360
|
label: string;
|
|
1873
|
-
|
|
2361
|
+
/**
|
|
2362
|
+
* 端口票据的端口。和 `dir` 正好有一个。
|
|
2363
|
+
*/
|
|
2364
|
+
port?: number | null;
|
|
1874
2365
|
session_id?: string | null;
|
|
1875
2366
|
ticket_id: string;
|
|
1876
2367
|
/**
|
|
@@ -1884,6 +2375,10 @@ export interface PreviewInfo {
|
|
|
1884
2375
|
* IndexedDB,立即从地址栏抹掉。
|
|
1885
2376
|
*/
|
|
1886
2377
|
export interface PreviewLaunch {
|
|
2378
|
+
/**
|
|
2379
|
+
* 目录票据的目录。
|
|
2380
|
+
*/
|
|
2381
|
+
dir?: string | null;
|
|
1887
2382
|
/**
|
|
1888
2383
|
* 票据和令牌里较早的那个过期时间。
|
|
1889
2384
|
*/
|
|
@@ -1901,7 +2396,10 @@ export interface PreviewLaunch {
|
|
|
1901
2396
|
* 打开后先导航到的路径(以 `/` 开头,可带查询串)。
|
|
1902
2397
|
*/
|
|
1903
2398
|
path: string;
|
|
1904
|
-
|
|
2399
|
+
/**
|
|
2400
|
+
* 票据的目标:端口或目录,正好有一个(取自 `preview.open` 的结果)。
|
|
2401
|
+
*/
|
|
2402
|
+
port?: number | null;
|
|
1905
2403
|
psk: string;
|
|
1906
2404
|
ticket_id: string;
|
|
1907
2405
|
/**
|
|
@@ -1917,10 +2415,18 @@ export interface PreviewListResult {
|
|
|
1917
2415
|
previews: PreviewInfo[];
|
|
1918
2416
|
}
|
|
1919
2417
|
/**
|
|
1920
|
-
* `preview.open`
|
|
2418
|
+
* `preview.open` 参数:为本机端口 `port` 或目录 `dir` 签发一张预览票据,两者正好给一个。
|
|
1921
2419
|
*/
|
|
1922
2420
|
export interface PreviewOpenParams {
|
|
1923
|
-
|
|
2421
|
+
/**
|
|
2422
|
+
* 目录预览(ADR-62,spec/daemon.md § 19.6):项目名(`fs.list` 路径的第一段,关联项目也是它的名字),
|
|
2423
|
+
* 或 `.scratch`(全部 scratch 会话的工作目录)。要 `capabilities.preview_dir`。
|
|
2424
|
+
*/
|
|
2425
|
+
dir?: string | null;
|
|
2426
|
+
/**
|
|
2427
|
+
* 本机端口(dev server)。
|
|
2428
|
+
*/
|
|
2429
|
+
port?: number | null;
|
|
1924
2430
|
/**
|
|
1925
2431
|
* 从哪个会话发起(只用于界面展示和审计;端口是否允许不看它,见 spec/daemon.md § 19.3)。
|
|
1926
2432
|
*/
|
|
@@ -1930,12 +2436,19 @@ export interface PreviewOpenParams {
|
|
|
1930
2436
|
* `preview.open` 结果。`psk` 是票据的密钥,只交给预览页(放进 [`PreviewLaunch`]),不要写日志、不要发给 hub。
|
|
1931
2437
|
*/
|
|
1932
2438
|
export interface PreviewOpenResult {
|
|
2439
|
+
/**
|
|
2440
|
+
* 目录票据的目录(daemon 规整过的写法,预览页的启动参数用这个值)。
|
|
2441
|
+
*/
|
|
2442
|
+
dir?: string | null;
|
|
1933
2443
|
expires_at_ms: number;
|
|
1934
2444
|
/**
|
|
1935
|
-
*
|
|
2445
|
+
* 这个端口 / 目录固定的预览 label(26 位小写 base32),预览 origin 是 `<label>.<预览域名>`。
|
|
1936
2446
|
*/
|
|
1937
2447
|
label: string;
|
|
1938
|
-
|
|
2448
|
+
/**
|
|
2449
|
+
* 端口票据的端口。和 `dir` 正好有一个。
|
|
2450
|
+
*/
|
|
2451
|
+
port?: number | null;
|
|
1939
2452
|
/**
|
|
1940
2453
|
* 票据密钥,64 个小写 hex(32 字节),Noise PSK。
|
|
1941
2454
|
*/
|
|
@@ -2047,6 +2560,13 @@ export interface GitMeta {
|
|
|
2047
2560
|
*/
|
|
2048
2561
|
worktree_ready?: boolean;
|
|
2049
2562
|
}
|
|
2563
|
+
/**
|
|
2564
|
+
* 第一条消息的一段。整条消息是各段的 `text` 按顺序用一个空行(`"\n\n"`)连起来。
|
|
2565
|
+
*/
|
|
2566
|
+
export interface PromptSegment {
|
|
2567
|
+
kind: PromptSegmentKind;
|
|
2568
|
+
text: string;
|
|
2569
|
+
}
|
|
2050
2570
|
/**
|
|
2051
2571
|
* `gh pr view` 的摘要。
|
|
2052
2572
|
*/
|
|
@@ -2066,72 +2586,504 @@ export interface PullRequestInfo {
|
|
|
2066
2586
|
title: string;
|
|
2067
2587
|
url: string;
|
|
2068
2588
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
export interface RpcErrorData {
|
|
2075
|
-
code: ErrorCode;
|
|
2589
|
+
/**
|
|
2590
|
+
* `todo.state_changed` 通知:一个模板的状态被写、删或清空了。只有模板 id 和条数,不带键和值;客户端要看内容就 `todo.state_list`。
|
|
2591
|
+
*/
|
|
2592
|
+
export interface RepeatStateChanged {
|
|
2593
|
+
count: number;
|
|
2076
2594
|
/**
|
|
2077
|
-
*
|
|
2595
|
+
* 模板的 id。
|
|
2078
2596
|
*/
|
|
2079
|
-
|
|
2080
|
-
reason?: string | null;
|
|
2081
|
-
retry_after_ms?: number | null;
|
|
2082
|
-
}
|
|
2083
|
-
export interface RpcRequest {
|
|
2084
|
-
id: RpcId;
|
|
2085
|
-
jsonrpc: string;
|
|
2086
|
-
method: string;
|
|
2087
|
-
params?: unknown;
|
|
2597
|
+
id: string;
|
|
2088
2598
|
}
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2599
|
+
/**
|
|
2600
|
+
* `todo.state_clear`:清空这个模板的全部状态。只由人调用。
|
|
2601
|
+
*/
|
|
2602
|
+
export interface RepeatStateClearParams {
|
|
2603
|
+
/**
|
|
2604
|
+
* 带了 `true` → `forbidden`(同自报 `mcp` 的连接)。
|
|
2605
|
+
*/
|
|
2606
|
+
agent?: boolean | null;
|
|
2607
|
+
id: string;
|
|
2093
2608
|
}
|
|
2094
|
-
export interface
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
jsonrpc: string;
|
|
2098
|
-
result?: unknown;
|
|
2609
|
+
export interface RepeatStateClearResult {
|
|
2610
|
+
removed: number;
|
|
2611
|
+
template_id: string;
|
|
2099
2612
|
}
|
|
2100
2613
|
/**
|
|
2101
|
-
* `
|
|
2614
|
+
* `todo.state_delete`:删一个键;没存着也不是错。
|
|
2102
2615
|
*/
|
|
2103
|
-
export interface
|
|
2104
|
-
|
|
2105
|
-
|
|
2616
|
+
export interface RepeatStateDeleteParams {
|
|
2617
|
+
agent?: boolean | null;
|
|
2618
|
+
id: string;
|
|
2619
|
+
key: string;
|
|
2620
|
+
origin_session?: string | null;
|
|
2621
|
+
}
|
|
2622
|
+
export interface RepeatStateDeleteResult {
|
|
2623
|
+
count: number;
|
|
2624
|
+
/**
|
|
2625
|
+
* 这个键原来存着。
|
|
2626
|
+
*/
|
|
2627
|
+
deleted: boolean;
|
|
2628
|
+
template_id: string;
|
|
2106
2629
|
}
|
|
2107
2630
|
/**
|
|
2108
|
-
*
|
|
2631
|
+
* 状态里的一条。
|
|
2109
2632
|
*/
|
|
2110
|
-
export interface
|
|
2111
|
-
archived?: boolean;
|
|
2633
|
+
export interface RepeatStateEntry {
|
|
2112
2634
|
/**
|
|
2113
|
-
*
|
|
2635
|
+
* 非空,≤ 200 字节,不含控制字符和 U+2028 / U+2029。
|
|
2114
2636
|
*/
|
|
2115
|
-
|
|
2637
|
+
key: string;
|
|
2116
2638
|
/**
|
|
2117
|
-
*
|
|
2639
|
+
* ≤ 1 KiB,可以是空串。
|
|
2118
2640
|
*/
|
|
2119
|
-
|
|
2120
|
-
last_seq: number;
|
|
2121
|
-
pending_permissions: number;
|
|
2122
|
-
session_id: string;
|
|
2123
|
-
status: SessionStatus;
|
|
2124
|
-
title: string;
|
|
2125
|
-
updated_at_ms: number;
|
|
2641
|
+
value: string;
|
|
2126
2642
|
/**
|
|
2127
|
-
*
|
|
2643
|
+
* 最近一次写这个键的时间。
|
|
2128
2644
|
*/
|
|
2129
|
-
|
|
2645
|
+
written_ms: number;
|
|
2130
2646
|
}
|
|
2131
2647
|
/**
|
|
2132
|
-
*
|
|
2648
|
+
* `todo.state_get`。
|
|
2133
2649
|
*/
|
|
2134
|
-
export interface
|
|
2650
|
+
export interface RepeatStateGetParams {
|
|
2651
|
+
/**
|
|
2652
|
+
* 调用方自报「这是 agent」(同 `todo.add`)。
|
|
2653
|
+
*/
|
|
2654
|
+
agent?: boolean | null;
|
|
2655
|
+
/**
|
|
2656
|
+
* 模板或它复制出来的某一项。
|
|
2657
|
+
*/
|
|
2658
|
+
id: string;
|
|
2659
|
+
key: string;
|
|
2660
|
+
/**
|
|
2661
|
+
* 调用来自哪个会话(CLI 读 `ANYCON_SESSION_ID`)。这个会话存在时,daemon 核对它是从这个模板的某次复制派出的,不是 → `forbidden`。
|
|
2662
|
+
*/
|
|
2663
|
+
origin_session?: string | null;
|
|
2664
|
+
}
|
|
2665
|
+
export interface RepeatStateGetResult {
|
|
2666
|
+
/**
|
|
2667
|
+
* 没存着这个键时没有。
|
|
2668
|
+
*/
|
|
2669
|
+
entry?: RepeatStateEntry | null;
|
|
2670
|
+
/**
|
|
2671
|
+
* 状态所属的模板。
|
|
2672
|
+
*/
|
|
2673
|
+
template_id: string;
|
|
2674
|
+
}
|
|
2675
|
+
/**
|
|
2676
|
+
* `todo.state_list`:按键(按字节)从小到大翻页。
|
|
2677
|
+
*/
|
|
2678
|
+
export interface RepeatStateListParams {
|
|
2679
|
+
/**
|
|
2680
|
+
* 只列排在这个键后面的(翻页:上一页最后一条的 `key`)。
|
|
2681
|
+
*/
|
|
2682
|
+
after?: string | null;
|
|
2683
|
+
agent?: boolean | null;
|
|
2684
|
+
id: string;
|
|
2685
|
+
/**
|
|
2686
|
+
* 缺省 200,上限 1000(0 按 1)。
|
|
2687
|
+
*/
|
|
2688
|
+
limit?: number | null;
|
|
2689
|
+
origin_session?: string | null;
|
|
2690
|
+
/**
|
|
2691
|
+
* 只列以它开头的键。
|
|
2692
|
+
*/
|
|
2693
|
+
prefix?: string | null;
|
|
2694
|
+
}
|
|
2695
|
+
export interface RepeatStateListResult {
|
|
2696
|
+
entries: RepeatStateEntry[];
|
|
2697
|
+
has_more: boolean;
|
|
2698
|
+
/**
|
|
2699
|
+
* 匹配 `prefix` 的条数(没给 `prefix` 时等于 `total`)。
|
|
2700
|
+
*/
|
|
2701
|
+
matched: number;
|
|
2702
|
+
template_id: string;
|
|
2703
|
+
/**
|
|
2704
|
+
* 这个模板的总条数(不看 `prefix`)。
|
|
2705
|
+
*/
|
|
2706
|
+
total: number;
|
|
2707
|
+
}
|
|
2708
|
+
/**
|
|
2709
|
+
* `todo.state_set`:写一个键(已有就覆盖)。满 2 000 条时淘汰最久没被写过的。
|
|
2710
|
+
*/
|
|
2711
|
+
export interface RepeatStateSetParams {
|
|
2712
|
+
agent?: boolean | null;
|
|
2713
|
+
id: string;
|
|
2714
|
+
key: string;
|
|
2715
|
+
origin_session?: string | null;
|
|
2716
|
+
/**
|
|
2717
|
+
* 缺省空串。
|
|
2718
|
+
*/
|
|
2719
|
+
value?: string;
|
|
2720
|
+
}
|
|
2721
|
+
export interface RepeatStateSetResult {
|
|
2722
|
+
/**
|
|
2723
|
+
* 写完之后的条数。
|
|
2724
|
+
*/
|
|
2725
|
+
count: number;
|
|
2726
|
+
/**
|
|
2727
|
+
* 为了不超过上限淘汰了几条(最久没被写过的)。
|
|
2728
|
+
*/
|
|
2729
|
+
evicted?: number;
|
|
2730
|
+
template_id: string;
|
|
2731
|
+
}
|
|
2732
|
+
/**
|
|
2733
|
+
* `todo.state_unseen`:给一组键,返回其中没存着的。
|
|
2734
|
+
*/
|
|
2735
|
+
export interface RepeatStateUnseenParams {
|
|
2736
|
+
agent?: boolean | null;
|
|
2737
|
+
id: string;
|
|
2738
|
+
/**
|
|
2739
|
+
* 最多 2 000 个;每个的校验同 `key`。
|
|
2740
|
+
*/
|
|
2741
|
+
keys: string[];
|
|
2742
|
+
origin_session?: string | null;
|
|
2743
|
+
}
|
|
2744
|
+
export interface RepeatStateUnseenResult {
|
|
2745
|
+
template_id: string;
|
|
2746
|
+
/**
|
|
2747
|
+
* 按请求里的顺序,去重。
|
|
2748
|
+
*/
|
|
2749
|
+
unseen: string[];
|
|
2750
|
+
}
|
|
2751
|
+
export interface RpcError {
|
|
2752
|
+
code: number;
|
|
2753
|
+
data?: RpcErrorData | null;
|
|
2754
|
+
message: string;
|
|
2755
|
+
}
|
|
2756
|
+
export interface RpcErrorData {
|
|
2757
|
+
/**
|
|
2758
|
+
* 规则超出注入的字数上限(`rule.add` / `rule.update` 的 `invalid`,`reason = "over_budget"`)时,这次改动之后一个会话拿到的
|
|
2759
|
+
* 规则文字的字节数,和上限(`cap`)。
|
|
2760
|
+
*/
|
|
2761
|
+
bytes?: number | null;
|
|
2762
|
+
cap?: number | null;
|
|
2763
|
+
code: ErrorCode;
|
|
2764
|
+
/**
|
|
2765
|
+
* `invalid_settings` 时的字段名等补充信息。
|
|
2766
|
+
*/
|
|
2767
|
+
field?: string | null;
|
|
2768
|
+
limit?: number | null;
|
|
2769
|
+
reason?: string | null;
|
|
2770
|
+
retry_after_ms?: number | null;
|
|
2771
|
+
/**
|
|
2772
|
+
* 指向另一项清单项:`todo.repeat_now` 被拒(`reason = "previous_open"`)时,还没关闭的那一份复制出来的项的 id。
|
|
2773
|
+
*/
|
|
2774
|
+
todo_id?: string | null;
|
|
2775
|
+
/**
|
|
2776
|
+
* 带条件的写被拒(`todo.delete` 的 `if_updated_ms` 对不上,`reason = "changed"`)时,那一项现在的 `updated_ms`。
|
|
2777
|
+
*/
|
|
2778
|
+
updated_ms?: number | null;
|
|
2779
|
+
/**
|
|
2780
|
+
* 判断后端当天已经使用的次数与每日上限(reason = budget)。
|
|
2781
|
+
*/
|
|
2782
|
+
used?: number | null;
|
|
2783
|
+
}
|
|
2784
|
+
export interface RpcRequest {
|
|
2785
|
+
id: RpcId;
|
|
2786
|
+
jsonrpc: string;
|
|
2787
|
+
method: string;
|
|
2788
|
+
params?: unknown;
|
|
2789
|
+
}
|
|
2790
|
+
export interface RpcNotification {
|
|
2791
|
+
jsonrpc: string;
|
|
2792
|
+
method: string;
|
|
2793
|
+
params?: unknown;
|
|
2794
|
+
}
|
|
2795
|
+
export interface RpcResponse {
|
|
2796
|
+
error?: RpcError | null;
|
|
2797
|
+
id: RpcId;
|
|
2798
|
+
jsonrpc: string;
|
|
2799
|
+
result?: unknown;
|
|
2800
|
+
}
|
|
2801
|
+
export interface Rule {
|
|
2802
|
+
created_ms: number;
|
|
2803
|
+
/**
|
|
2804
|
+
* 客户端生成的小写带连字符的 UUID;`rule.add` 按它幂等。
|
|
2805
|
+
*/
|
|
2806
|
+
id: string;
|
|
2807
|
+
/**
|
|
2808
|
+
* 最近一次被注入某个会话;改它不动 `updated_ms`,也不发 `rule.changed`。
|
|
2809
|
+
*/
|
|
2810
|
+
last_injected_ms?: number | null;
|
|
2811
|
+
/**
|
|
2812
|
+
* 最近一次被分拣的决定引用、并且这个决定被执行;改它不动 `updated_ms`,也不发 `rule.changed`(§ 26.10)。
|
|
2813
|
+
*/
|
|
2814
|
+
last_referenced_ms?: number | null;
|
|
2815
|
+
/**
|
|
2816
|
+
* 只进这个项目的会话;缺省 = 这个节点上所有项目的会话。
|
|
2817
|
+
*/
|
|
2818
|
+
project?: string | null;
|
|
2819
|
+
source: RuleSource;
|
|
2820
|
+
/**
|
|
2821
|
+
* 过期:生效的规则 60 天里没被注入也没被引用,daemon 标上它。过期的规则仍是 `active`,但不注入、不计字数预算;
|
|
2822
|
+
* 只有人能用 `rule.update { stale: false }` 恢复(docs/spec/daemon.md § 23.2、§ 26.10)。缺省 `false`。
|
|
2823
|
+
*/
|
|
2824
|
+
stale?: boolean;
|
|
2825
|
+
status: RuleStatus;
|
|
2826
|
+
sync: RuleSync;
|
|
2827
|
+
/**
|
|
2828
|
+
* 1–600 个 Unicode 码点,可以多行;除换行外不含控制字符,不含 U+2028 / U+2029。
|
|
2829
|
+
*/
|
|
2830
|
+
text: string;
|
|
2831
|
+
/**
|
|
2832
|
+
* 每次真正的修改严格递增,也是版本号(`if_updated_ms`)。
|
|
2833
|
+
*/
|
|
2834
|
+
updated_ms: number;
|
|
2835
|
+
}
|
|
2836
|
+
export interface RuleSource {
|
|
2837
|
+
/**
|
|
2838
|
+
* 经 hub 来的调用带上发起设备的 id(daemon 填)。
|
|
2839
|
+
*/
|
|
2840
|
+
device_id?: string | null;
|
|
2841
|
+
kind: RuleSourceKind;
|
|
2842
|
+
/**
|
|
2843
|
+
* `answer`:出自哪个权限请求或提问。
|
|
2844
|
+
*/
|
|
2845
|
+
request_id?: string | null;
|
|
2846
|
+
/**
|
|
2847
|
+
* `extracted`:出自会话的哪个事件。
|
|
2848
|
+
*/
|
|
2849
|
+
seq?: number | null;
|
|
2850
|
+
/**
|
|
2851
|
+
* `answer` / `extracted`:规则出自哪个会话。
|
|
2852
|
+
*/
|
|
2853
|
+
session_id?: string | null;
|
|
2854
|
+
}
|
|
2855
|
+
export interface RuleAddParams {
|
|
2856
|
+
/**
|
|
2857
|
+
* 调用方自报「这是 agent 写的」:状态强制为 `pending`,来源强制为 `agent`。只会让这条规则更不被信任,所以不需要校验。
|
|
2858
|
+
*/
|
|
2859
|
+
agent?: boolean | null;
|
|
2860
|
+
/**
|
|
2861
|
+
* UUID。已经存在时原样返回已有的那一条(幂等)。
|
|
2862
|
+
*/
|
|
2863
|
+
id: string;
|
|
2864
|
+
/**
|
|
2865
|
+
* 这条规则是哪个会话里的 agent 提的;只在这条规则记成 agent 写的、并且这个会话存在时才记(同 `todo.add` 的 `origin_session`)。
|
|
2866
|
+
*/
|
|
2867
|
+
origin_session?: string | null;
|
|
2868
|
+
project?: string | null;
|
|
2869
|
+
/**
|
|
2870
|
+
* 缺省 `{ kind: manual }`。
|
|
2871
|
+
*/
|
|
2872
|
+
source?: RuleAddSource | null;
|
|
2873
|
+
/**
|
|
2874
|
+
* 缺省 `active`。
|
|
2875
|
+
*/
|
|
2876
|
+
status?: RuleAddStatus | null;
|
|
2877
|
+
/**
|
|
2878
|
+
* 缺省 `node`;agent 写入强制为 `node`。
|
|
2879
|
+
*/
|
|
2880
|
+
sync?: RuleSync | null;
|
|
2881
|
+
text: string;
|
|
2882
|
+
}
|
|
2883
|
+
export interface RuleAddSource {
|
|
2884
|
+
kind: RuleAddSourceKind;
|
|
2885
|
+
request_id?: string | null;
|
|
2886
|
+
session_id?: string | null;
|
|
2887
|
+
}
|
|
2888
|
+
/**
|
|
2889
|
+
* 注入的字数预算(docs/spec/daemon.md § 23.4):字节数按**生效**的规则算,不受 `rule.list` 的过滤条件影响。
|
|
2890
|
+
*/
|
|
2891
|
+
export interface RuleBudget {
|
|
2892
|
+
/**
|
|
2893
|
+
* 一个会话拿到的规则文字(含模板)的字节上限。
|
|
2894
|
+
*/
|
|
2895
|
+
cap: number;
|
|
2896
|
+
/**
|
|
2897
|
+
* 模板的开头加上全节点生效规则的字节数;一条生效的规则都没有时是 0。一个会话拿到的文字是它加上这个会话的项目的 `projects[项目]`
|
|
2898
|
+
* (没有项目规则的会话就是它自己)。只有项目规则生效时,它只是模板的开头。
|
|
2899
|
+
*/
|
|
2900
|
+
node_bytes: number;
|
|
2901
|
+
/**
|
|
2902
|
+
* 每个项目的生效规则的字节数(不含 `node_bytes`),键是项目名。一个这个项目的会话拿到的文字是 `node_bytes + projects[项目]`。
|
|
2903
|
+
*/
|
|
2904
|
+
projects: {
|
|
2905
|
+
[k: string]: number;
|
|
2906
|
+
};
|
|
2907
|
+
}
|
|
2908
|
+
/**
|
|
2909
|
+
* `rule.changed` 通知:新建、修改、删除后发给所有在线客户端(包括发起的那一台)。`last_injected_ms` 的变化不通知。
|
|
2910
|
+
*/
|
|
2911
|
+
export interface RuleChanged {
|
|
2912
|
+
deleted?: boolean;
|
|
2913
|
+
id: string;
|
|
2914
|
+
/**
|
|
2915
|
+
* `deleted = true` 时没有。
|
|
2916
|
+
*/
|
|
2917
|
+
rule?: Rule | null;
|
|
2918
|
+
}
|
|
2919
|
+
/**
|
|
2920
|
+
* `rule.delete`:`if_updated_ms` 的语义同 `rule.update`。
|
|
2921
|
+
*/
|
|
2922
|
+
export interface RuleDeleteParams {
|
|
2923
|
+
id: string;
|
|
2924
|
+
if_updated_ms?: number | null;
|
|
2925
|
+
}
|
|
2926
|
+
export interface RuleExtractDone {
|
|
2927
|
+
run: ExtractRun;
|
|
2928
|
+
}
|
|
2929
|
+
export interface ExtractRun {
|
|
2930
|
+
added: string[];
|
|
2931
|
+
backend: string;
|
|
2932
|
+
device_id?: string | null;
|
|
2933
|
+
dropped: ExtractDropped;
|
|
2934
|
+
error?: JudgeError | null;
|
|
2935
|
+
finished_ms?: number | null;
|
|
2936
|
+
from_seq: number;
|
|
2937
|
+
id: string;
|
|
2938
|
+
points: number;
|
|
2939
|
+
session_id: string;
|
|
2940
|
+
started_ms: number;
|
|
2941
|
+
status: ExtractRunStatus;
|
|
2942
|
+
to_seq: number;
|
|
2943
|
+
trigger: ExtractTrigger;
|
|
2944
|
+
usage?: JudgeUsage | null;
|
|
2945
|
+
}
|
|
2946
|
+
export interface ExtractDropped {
|
|
2947
|
+
duplicate: number;
|
|
2948
|
+
full: number;
|
|
2949
|
+
invalid: number;
|
|
2950
|
+
}
|
|
2951
|
+
export interface JudgeError {
|
|
2952
|
+
code: JudgeErrorCode;
|
|
2953
|
+
status?: number | null;
|
|
2954
|
+
}
|
|
2955
|
+
export interface JudgeUsage {
|
|
2956
|
+
cost_usd?: number | null;
|
|
2957
|
+
input_tokens?: number | null;
|
|
2958
|
+
output_tokens?: number | null;
|
|
2959
|
+
}
|
|
2960
|
+
export interface RuleExtractParams {
|
|
2961
|
+
session_id: string;
|
|
2962
|
+
}
|
|
2963
|
+
export interface RuleExtractResult {
|
|
2964
|
+
points: number;
|
|
2965
|
+
run?: ExtractRun | null;
|
|
2966
|
+
}
|
|
2967
|
+
export interface RuleExtractRunsParams {
|
|
2968
|
+
limit?: number | null;
|
|
2969
|
+
session_id?: string | null;
|
|
2970
|
+
}
|
|
2971
|
+
export interface RuleExtractRunsResult {
|
|
2972
|
+
daily_calls: number;
|
|
2973
|
+
runs: ExtractRun[];
|
|
2974
|
+
used_today: number;
|
|
2975
|
+
}
|
|
2976
|
+
export interface RuleListParams {
|
|
2977
|
+
/**
|
|
2978
|
+
* 只给 `project` 等于它的规则(去掉首尾空白后比较;不含全节点规则)。
|
|
2979
|
+
*/
|
|
2980
|
+
project?: string | null;
|
|
2981
|
+
/**
|
|
2982
|
+
* 只给这个状态的规则。
|
|
2983
|
+
*/
|
|
2984
|
+
status?: RuleStatus | null;
|
|
2985
|
+
}
|
|
2986
|
+
export interface RuleListResult {
|
|
2987
|
+
budget: RuleBudget;
|
|
2988
|
+
/**
|
|
2989
|
+
* 按 `created_ms` 从早到晚(同一毫秒的按写入先后)。
|
|
2990
|
+
*/
|
|
2991
|
+
rules: Rule[];
|
|
2992
|
+
}
|
|
2993
|
+
export interface RulePreviewParams {
|
|
2994
|
+
/**
|
|
2995
|
+
* 缺省:不属于任何项目的会话(只有全节点规则)。
|
|
2996
|
+
*/
|
|
2997
|
+
project?: string | null;
|
|
2998
|
+
}
|
|
2999
|
+
/**
|
|
3000
|
+
* `rule.preview`:现在开一个这个项目的会话会注入的那段文字,和它用到的规则。只读。
|
|
3001
|
+
*/
|
|
3002
|
+
export interface RulePreviewResult {
|
|
3003
|
+
/**
|
|
3004
|
+
* `text` 的 UTF-8 字节数。
|
|
3005
|
+
*/
|
|
3006
|
+
bytes: number;
|
|
3007
|
+
/**
|
|
3008
|
+
* 写进 `text` 的规则,按它们在 `text` 里的顺序。
|
|
3009
|
+
*/
|
|
3010
|
+
rule_ids: string[];
|
|
3011
|
+
/**
|
|
3012
|
+
* 没有生效的规则时为空串。
|
|
3013
|
+
*/
|
|
3014
|
+
text: string;
|
|
3015
|
+
}
|
|
3016
|
+
export interface RuleUpdateParams {
|
|
3017
|
+
/**
|
|
3018
|
+
* 要清空的可选字段,在合并之后生效。
|
|
3019
|
+
*/
|
|
3020
|
+
clear?: ClearableRuleField[];
|
|
3021
|
+
id: string;
|
|
3022
|
+
/**
|
|
3023
|
+
* 给了而和这条规则现在的 `updated_ms` 不同:什么都不改,`invalid`(`data.reason = "changed"`,`data.updated_ms` 是现在的值)。
|
|
3024
|
+
*/
|
|
3025
|
+
if_updated_ms?: number | null;
|
|
3026
|
+
project?: string | null;
|
|
3027
|
+
/**
|
|
3028
|
+
* 只能给 `false`:恢复一条过期的规则(和「变成生效」一样过字数检查)。给 `true` → `invalid`(`data.field = "stale"`)。
|
|
3029
|
+
*/
|
|
3030
|
+
stale?: boolean | null;
|
|
3031
|
+
status?: RuleStatus | null;
|
|
3032
|
+
/**
|
|
3033
|
+
* 同组范围仅接受全节点、非待确认的规则。
|
|
3034
|
+
*/
|
|
3035
|
+
sync?: RuleSync | null;
|
|
3036
|
+
text?: string | null;
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* `session.archive`。没有 worktree 的会话只看 `session_id`。
|
|
3040
|
+
*/
|
|
3041
|
+
export interface SessionArchiveParams {
|
|
3042
|
+
session_id: string;
|
|
3043
|
+
worktree?: WorktreeDisposal & string;
|
|
3044
|
+
}
|
|
3045
|
+
/**
|
|
3046
|
+
* `session.changed` 通知:列表级变化,发给所有在线客户端。
|
|
3047
|
+
*/
|
|
3048
|
+
export interface SessionChanged {
|
|
3049
|
+
archived?: boolean;
|
|
3050
|
+
/**
|
|
3051
|
+
* 同 [`SessionSummary::background_tasks`]。
|
|
3052
|
+
*/
|
|
3053
|
+
background_tasks?: number;
|
|
3054
|
+
/**
|
|
3055
|
+
* 会话被删除。
|
|
3056
|
+
*/
|
|
3057
|
+
deleted?: boolean;
|
|
3058
|
+
/**
|
|
3059
|
+
* 同 [`SessionSummary::follow_up`]。
|
|
3060
|
+
*/
|
|
3061
|
+
follow_up?: boolean;
|
|
3062
|
+
/**
|
|
3063
|
+
* 这条 `session.changed` 是 daemon 因为发了 `follow_up` 通知、消费了 `follow_up` 标记而发的:
|
|
3064
|
+
* 会话刚完成,标记已清成 false。只有这一种情况为 true(出错清标记、`session.set_marks` 都不带);
|
|
3065
|
+
* 它是一次性的事件信号,客户端不存进会话摘要。
|
|
3066
|
+
*/
|
|
3067
|
+
follow_up_fired?: boolean;
|
|
3068
|
+
last_seq: number;
|
|
3069
|
+
pending_permissions: number;
|
|
3070
|
+
/**
|
|
3071
|
+
* 同 [`SessionSummary::read_seq`]。
|
|
3072
|
+
*/
|
|
3073
|
+
read_seq?: number;
|
|
3074
|
+
session_id: string;
|
|
3075
|
+
status: SessionStatus;
|
|
3076
|
+
title: string;
|
|
3077
|
+
updated_at_ms: number;
|
|
3078
|
+
/**
|
|
3079
|
+
* worktree 的当前状态(会话有 worktree 时)。
|
|
3080
|
+
*/
|
|
3081
|
+
worktree?: SessionWorktree | null;
|
|
3082
|
+
}
|
|
3083
|
+
/**
|
|
3084
|
+
* 会话所在的 worktree。
|
|
3085
|
+
*/
|
|
3086
|
+
export interface SessionWorktree {
|
|
2135
3087
|
/**
|
|
2136
3088
|
* base 的展示名:分支 / 远端跟踪分支 / 标签写法是短名字(`main`、`origin/main`、`v1.0`),
|
|
2137
3089
|
* 其他写法(`HEAD`、`HEAD~1`…)是解析出的提交的前 12 位。daemon 内部按规范化的引用名或完整 SHA 计算。
|
|
@@ -2327,6 +3279,11 @@ export interface SessionSummary {
|
|
|
2327
3279
|
*/
|
|
2328
3280
|
background_tasks?: number;
|
|
2329
3281
|
created_at_ms: number;
|
|
3282
|
+
/**
|
|
3283
|
+
* 用户标了「待处理」(docs/spec/web.md § 4.6.1)。纯标注,不影响会话的行为;只能由 `session.set_marks` 改,
|
|
3284
|
+
* 改它不动 `updated_at_ms`。
|
|
3285
|
+
*/
|
|
3286
|
+
follow_up?: boolean;
|
|
2330
3287
|
id: string;
|
|
2331
3288
|
/**
|
|
2332
3289
|
* 最后一个事件的 seq;客户端据此决定要不要拉增量。
|
|
@@ -2345,9 +3302,18 @@ export interface SessionSummary {
|
|
|
2345
3302
|
* 排队位置(status = queued 时)。
|
|
2346
3303
|
*/
|
|
2347
3304
|
queue_position?: number | null;
|
|
2348
|
-
|
|
3305
|
+
/**
|
|
3306
|
+
* 已读水位:用户已经看到的最大 seq(取最大值,只增不减;`session.mark_read` 改)。会话不在运行、且 `last_seq` 大于它时
|
|
3307
|
+
* 客户端显示未读。改它不动 `updated_at_ms`。
|
|
3308
|
+
*/
|
|
3309
|
+
read_seq?: number;
|
|
3310
|
+
settings: SessionSettings;
|
|
2349
3311
|
status: SessionStatus;
|
|
2350
3312
|
title: string;
|
|
3313
|
+
/**
|
|
3314
|
+
* 会话从哪一项派出(`todo.dispatch`,docs/spec/daemon.md § 22.3)。这一项被删除后原样留着,客户端按「来源已删除」显示。
|
|
3315
|
+
*/
|
|
3316
|
+
todo_id?: string | null;
|
|
2351
3317
|
updated_at_ms: number;
|
|
2352
3318
|
usage?: UsageTotals;
|
|
2353
3319
|
/**
|
|
@@ -2363,6 +3329,13 @@ export interface UsageTotals {
|
|
|
2363
3329
|
output_tokens: number;
|
|
2364
3330
|
turns: number;
|
|
2365
3331
|
}
|
|
3332
|
+
/**
|
|
3333
|
+
* `session.mark_read`:客户端已经把会话显示到 `seq`。daemon 取 `max(现有水位, min(seq, last_seq))`,所以重复、乱序都无害。
|
|
3334
|
+
*/
|
|
3335
|
+
export interface SessionMarkReadParams {
|
|
3336
|
+
seq: number;
|
|
3337
|
+
session_id: string;
|
|
3338
|
+
}
|
|
2366
3339
|
export interface SessionPromoteParams {
|
|
2367
3340
|
/**
|
|
2368
3341
|
* 新项目名。
|
|
@@ -2437,6 +3410,13 @@ export interface SessionSendResult {
|
|
|
2437
3410
|
*/
|
|
2438
3411
|
turn_id?: number | null;
|
|
2439
3412
|
}
|
|
3413
|
+
/**
|
|
3414
|
+
* `session.set_marks`:局部更新会话上的用户标注,只改传了的字段。归档不在这里(它有自己的行为约束,见 `session.archive`)。
|
|
3415
|
+
*/
|
|
3416
|
+
export interface SessionSetMarksParams {
|
|
3417
|
+
follow_up?: boolean | null;
|
|
3418
|
+
session_id: string;
|
|
3419
|
+
}
|
|
2440
3420
|
export interface SessionSetSettingsParams {
|
|
2441
3421
|
/**
|
|
2442
3422
|
* 要清除(恢复为未设置)的字段,在 `settings` 合并之后生效;两边都出现时以 `clear` 为准。
|
|
@@ -2475,6 +3455,384 @@ export interface SessionSyncBaseResult {
|
|
|
2475
3455
|
conflicts?: string[];
|
|
2476
3456
|
outcome: SyncOutcome;
|
|
2477
3457
|
}
|
|
3458
|
+
export interface Todo {
|
|
3459
|
+
/**
|
|
3460
|
+
* 派出的会话现在的情况,daemon 每次返回这一项时按会话此刻的状态算出来(docs/spec/daemon.md § 22.3):不存储、不动
|
|
3461
|
+
* `updated_ms`、不进审计。已关闭(`done` / `dropped`)或者没有派发过的项没有这个字段。`state` 只由人设置。
|
|
3462
|
+
*/
|
|
3463
|
+
activity?: TodoActivity | null;
|
|
3464
|
+
/**
|
|
3465
|
+
* Markdown,≤ 16 KiB,可以是空串。
|
|
3466
|
+
*/
|
|
3467
|
+
body: string;
|
|
3468
|
+
/**
|
|
3469
|
+
* 进入 `done` / `dropped` 的时间;重新打开时清掉。
|
|
3470
|
+
*/
|
|
3471
|
+
closed_ms?: number | null;
|
|
3472
|
+
created_ms: number;
|
|
3473
|
+
/**
|
|
3474
|
+
* 想在什么时候之前处理;只用于显示和排序。
|
|
3475
|
+
*/
|
|
3476
|
+
due_ms?: number | null;
|
|
3477
|
+
handler?: TodoHandler & string;
|
|
3478
|
+
/**
|
|
3479
|
+
* 客户端生成的 UUID;`todo.add` 按它幂等。
|
|
3480
|
+
*/
|
|
3481
|
+
id: string;
|
|
3482
|
+
/**
|
|
3483
|
+
* 项目名;不校验项目存在,项目改名 / 删除后原样保留。
|
|
3484
|
+
*/
|
|
3485
|
+
project?: string | null;
|
|
3486
|
+
/**
|
|
3487
|
+
* 这一项派到别的节点的远程项(docs/spec/daemon.md § 27.4),只追加;没有时缺省为空。由 Twin 连接的 A 侧写。
|
|
3488
|
+
*/
|
|
3489
|
+
remote?: TodoRemote[];
|
|
3490
|
+
/**
|
|
3491
|
+
* 周期规则。带它的项是模板:不进分拣、不能派发,到点由 daemon 复制出新的一项(`source.kind = repeat`);只由人设置。
|
|
3492
|
+
*/
|
|
3493
|
+
repeat?: TodoRepeat | null;
|
|
3494
|
+
/**
|
|
3495
|
+
* 这一项派出的会话(`todo.dispatch`,docs/spec/daemon.md § 22.3),按派发的先后,最多 20 个。会话被删除后关联留着。
|
|
3496
|
+
*/
|
|
3497
|
+
sessions?: string[];
|
|
3498
|
+
source: TodoSource;
|
|
3499
|
+
state: TodoState;
|
|
3500
|
+
/**
|
|
3501
|
+
* 单行,1–200 字符(去掉首尾空白之后)。
|
|
3502
|
+
*/
|
|
3503
|
+
title: string;
|
|
3504
|
+
/**
|
|
3505
|
+
* agent 记的、还没有人收下的项。
|
|
3506
|
+
*/
|
|
3507
|
+
unreviewed: boolean;
|
|
3508
|
+
updated_ms: number;
|
|
3509
|
+
}
|
|
3510
|
+
/**
|
|
3511
|
+
* 这一项在另一个节点上对应的项(`Todo.remote`)。
|
|
3512
|
+
*/
|
|
3513
|
+
export interface TodoRemote {
|
|
3514
|
+
/**
|
|
3515
|
+
* 那个节点的 id。
|
|
3516
|
+
*/
|
|
3517
|
+
node_id: string;
|
|
3518
|
+
/**
|
|
3519
|
+
* 那个节点上的项 id。
|
|
3520
|
+
*/
|
|
3521
|
+
todo_id: string;
|
|
3522
|
+
}
|
|
3523
|
+
/**
|
|
3524
|
+
* 周期项的规则:按节点的本地时区,每次到点复制出一项新的(docs/spec/daemon.md § 26.9)。
|
|
3525
|
+
*/
|
|
3526
|
+
export interface TodoRepeat {
|
|
3527
|
+
/**
|
|
3528
|
+
* `HH:MM`,`00:00`–`23:59`,本地时间。
|
|
3529
|
+
*/
|
|
3530
|
+
at: string;
|
|
3531
|
+
/**
|
|
3532
|
+
* Twin 对这个模板复制出来的项执行 `done` 时,daemon 直接把那一项关闭(docs/spec/daemon.md § 26.9);缺省 false,false 时不出现。
|
|
3533
|
+
* 任何一种规则都能带。
|
|
3534
|
+
*/
|
|
3535
|
+
auto_close?: boolean;
|
|
3536
|
+
/**
|
|
3537
|
+
* `kind = interval` 时必填(别的种类不能带):在哪些日子里生效。
|
|
3538
|
+
*/
|
|
3539
|
+
days?: TodoRepeatDays | null;
|
|
3540
|
+
/**
|
|
3541
|
+
* `kind = interval` 时必填(别的种类不能带):两次之间隔多少分钟,15–720。
|
|
3542
|
+
*/
|
|
3543
|
+
every_min?: number | null;
|
|
3544
|
+
/**
|
|
3545
|
+
* 给这个模板一张跨次保留的「键 → 值」小表,由它复制出来的各次会话里的 agent 用 `anycon todo state` 读写
|
|
3546
|
+
* (`todo.state_*`,docs/spec/daemon.md § 26.11)。缺省 false,false 时不出现;只由人设置。关掉不删已有的条目。
|
|
3547
|
+
*/
|
|
3548
|
+
keep_state?: boolean;
|
|
3549
|
+
kind: TodoRepeatKind;
|
|
3550
|
+
/**
|
|
3551
|
+
* 下一次复制的时间(节点此刻算出来的,不存;请求里带了也忽略)。模板已关闭时没有。算在 daemon 上,是因为规则按节点的时区。
|
|
3552
|
+
*/
|
|
3553
|
+
next_ms?: number | null;
|
|
3554
|
+
/**
|
|
3555
|
+
* `keep_state` 开着时,派发复制出来的项的第一条消息缺省带 daemon 的一段用法说明;这一项为 true 表示不带(用户自己在正文里写)。
|
|
3556
|
+
* 缺省 false,false 时不出现:所以「带说明」是不出现这个字段的那一种,旧客户端没见过它也照常是带说明。只能和 `keep_state` 一起为
|
|
3557
|
+
* true(否则 `invalid`,`data.reason = "state_hint_off"`);只由人设置。
|
|
3558
|
+
*/
|
|
3559
|
+
state_hint_off?: boolean;
|
|
3560
|
+
/**
|
|
3561
|
+
* `kind = interval` 时必填(别的种类不能带):当天最后一个时间点不晚于它,`HH:MM`,同一天内严格晚于 `at`。
|
|
3562
|
+
*/
|
|
3563
|
+
until?: string | null;
|
|
3564
|
+
/**
|
|
3565
|
+
* 1–7,周一 = 1(ISO);`kind = weekly`、或 `kind = interval` 且 `days = weekly` 时必填,别的情况不能带。
|
|
3566
|
+
*/
|
|
3567
|
+
weekday?: number | null;
|
|
3568
|
+
}
|
|
3569
|
+
export interface TodoSource {
|
|
3570
|
+
/**
|
|
3571
|
+
* 经 hub 来的调用带上发起设备的 id;`kind = twin` 时是那台 Twin 设备(另一个节点的 Twin,docs/spec/daemon.md § 27.3)的设备 id。
|
|
3572
|
+
*/
|
|
3573
|
+
device_id?: string | null;
|
|
3574
|
+
kind: TodoSourceKind;
|
|
3575
|
+
/**
|
|
3576
|
+
* 这一项是从哪个会话里来的(只有 `kind = agent` 才可能有;会话之后被删,这个字段原样留着)。
|
|
3577
|
+
*/
|
|
3578
|
+
session_id?: string | null;
|
|
3579
|
+
/**
|
|
3580
|
+
* `kind = repeat` 时是复制出这一项的周期项(模板)的 id;模板被删后原样留着。
|
|
3581
|
+
*/
|
|
3582
|
+
todo_id?: string | null;
|
|
3583
|
+
}
|
|
3584
|
+
/**
|
|
3585
|
+
* 谁做了这件事(审计里的「发起者」,不含会话内容)。
|
|
3586
|
+
*/
|
|
3587
|
+
export interface TodoActor {
|
|
3588
|
+
device_id?: string | null;
|
|
3589
|
+
/**
|
|
3590
|
+
* Twin 动作的请求方(local 或设备 id)。
|
|
3591
|
+
*/
|
|
3592
|
+
id?: string | null;
|
|
3593
|
+
kind: TodoSourceKind;
|
|
3594
|
+
}
|
|
3595
|
+
export interface TodoAddParams {
|
|
3596
|
+
/**
|
|
3597
|
+
* 调用方自报「这是 agent 加的」。只会让这一项更不被信任,所以不需要校验。
|
|
3598
|
+
*/
|
|
3599
|
+
agent?: boolean | null;
|
|
3600
|
+
body?: string | null;
|
|
3601
|
+
due_ms?: number | null;
|
|
3602
|
+
handler?: TodoHandler | null;
|
|
3603
|
+
/**
|
|
3604
|
+
* UUID。已经存在时原样返回已有的那一项(幂等)。
|
|
3605
|
+
*/
|
|
3606
|
+
id: string;
|
|
3607
|
+
/**
|
|
3608
|
+
* 这一项从哪个会话里来;daemon 只在这一项记成 `kind = agent`、且这个会话存在时才记。
|
|
3609
|
+
*/
|
|
3610
|
+
origin_session?: string | null;
|
|
3611
|
+
project?: string | null;
|
|
3612
|
+
/**
|
|
3613
|
+
* 周期规则(只由人设置:自报 `mcp` 的连接或 `agent: true` → `forbidden`)。
|
|
3614
|
+
*/
|
|
3615
|
+
repeat?: TodoRepeat | null;
|
|
3616
|
+
title: string;
|
|
3617
|
+
}
|
|
3618
|
+
/**
|
|
3619
|
+
* `todo.changed` 通知:新建、修改、删除后发给所有在线客户端(包括发起的那一台)。
|
|
3620
|
+
*/
|
|
3621
|
+
export interface TodoChanged {
|
|
3622
|
+
deleted?: boolean;
|
|
3623
|
+
id: string;
|
|
3624
|
+
/**
|
|
3625
|
+
* `deleted = true` 时没有。
|
|
3626
|
+
*/
|
|
3627
|
+
todo?: Todo | null;
|
|
3628
|
+
}
|
|
3629
|
+
/**
|
|
3630
|
+
* `todo.list` 的翻页游标:上一页最后一项的这两个值。
|
|
3631
|
+
*/
|
|
3632
|
+
export interface TodoCursor {
|
|
3633
|
+
id: string;
|
|
3634
|
+
updated_ms: number;
|
|
3635
|
+
}
|
|
3636
|
+
/**
|
|
3637
|
+
* `todo.delete`:`if_updated_ms` 给了、而这一项现在的 `updated_ms` 不是它,就拒绝(`invalid`,`data.reason = "changed"`,
|
|
3638
|
+
* `data.updated_ms` 是现在的值),什么都不删。
|
|
3639
|
+
*/
|
|
3640
|
+
export interface TodoDeleteParams {
|
|
3641
|
+
id: string;
|
|
3642
|
+
if_updated_ms?: number | null;
|
|
3643
|
+
}
|
|
3644
|
+
/**
|
|
3645
|
+
* `todo.dispatch`:从一项开一个会话,把会话和这一项关联。
|
|
3646
|
+
*/
|
|
3647
|
+
export interface TodoDispatchParams {
|
|
3648
|
+
/**
|
|
3649
|
+
* 同 `session.create`。
|
|
3650
|
+
*/
|
|
3651
|
+
agent: string;
|
|
3652
|
+
id: string;
|
|
3653
|
+
/**
|
|
3654
|
+
* 幂等:和 `session.create` 的 `message_id` 一样。同一个值重试(比如回执丢了)返回第一次的结果,不再开第二个会话、
|
|
3655
|
+
* 不多记关联和「经过」;它同时是会话第一条消息的 id。缺省由 daemon 生成(那样就没有幂等)。
|
|
3656
|
+
*/
|
|
3657
|
+
message_id?: string | null;
|
|
3658
|
+
/**
|
|
3659
|
+
* 「不 push、不开 PR」(agent 的 `no_push` 选项)。缺省 `true`;所选 agent 没有声明这个选项而它为 `true` → `unsupported`。
|
|
3660
|
+
*/
|
|
3661
|
+
no_push?: boolean | null;
|
|
3662
|
+
/**
|
|
3663
|
+
* Twin 的说明(≤ 2048 字节),接在第一条消息后面,不改这一项的正文(docs/spec/daemon.md § 26.4、§ 27.4)。
|
|
3664
|
+
* 只有 Twin 设备(另一个节点的 Twin)能带;别的调用方带了 → `invalid`(`data.field = "note"`,`data.reason = "not_allowed"`)。
|
|
3665
|
+
*/
|
|
3666
|
+
note?: string | null;
|
|
3667
|
+
/**
|
|
3668
|
+
* 缺省用这一项的 `project`;两者都没有 → `invalid`(`data.field = "project"`)。给了而且和这一项的不同,派发成功时写回这一项。
|
|
3669
|
+
*/
|
|
3670
|
+
project?: string | null;
|
|
3671
|
+
/**
|
|
3672
|
+
* 同 `session.create`。
|
|
3673
|
+
*/
|
|
3674
|
+
settings?: SessionSettings;
|
|
3675
|
+
/**
|
|
3676
|
+
* 同 `session.create`。缺省:项目能开 worktree 就用新的 worktree,否则在项目目录里(不看 `worktree.default`)。
|
|
3677
|
+
*/
|
|
3678
|
+
workspace?: SessionWorkspace | null;
|
|
3679
|
+
}
|
|
3680
|
+
/**
|
|
3681
|
+
* `todo.dispatch_preview`:这一项现在派发的话,第一条消息会是什么。不改这一项、不开会话;唯一的副作用是先把排着的结果记进「经过」(§ 22.2)。
|
|
3682
|
+
*/
|
|
3683
|
+
export interface TodoDispatchPreviewParams {
|
|
3684
|
+
id: string;
|
|
3685
|
+
/**
|
|
3686
|
+
* 同 `todo.dispatch` 的 `no_push`,缺省 `true`(决定第一条消息里有没有「不 push、不开 PR」那一行)。
|
|
3687
|
+
*/
|
|
3688
|
+
no_push?: boolean | null;
|
|
3689
|
+
/**
|
|
3690
|
+
* 同 `todo.dispatch` 的 `project`:只影响 `rules_text`(派发会选另一个项目时,那个项目的规则);缺省用这一项自己的项目。
|
|
3691
|
+
*/
|
|
3692
|
+
project?: string | null;
|
|
3693
|
+
}
|
|
3694
|
+
export interface TodoDispatchPreviewResult {
|
|
3695
|
+
/**
|
|
3696
|
+
* 此刻派发会发出的第一条消息,一字不差(同一个组装函数、同一套「之前的结果」的选法)。
|
|
3697
|
+
*/
|
|
3698
|
+
first_message: string;
|
|
3699
|
+
/**
|
|
3700
|
+
* 此刻开一个这一项的项目的会话会注入的规则文字(docs/spec/daemon.md § 23.5,和 `rule.preview` 同一个函数);这一项没有项目时
|
|
3701
|
+
* 只有全节点规则;没有生效的规则时为空串。不看所选的 agent:它收不收得到由 `AgentInfo.capabilities.system_prompt` 说了算。
|
|
3702
|
+
*/
|
|
3703
|
+
rules_text?: string;
|
|
3704
|
+
/**
|
|
3705
|
+
* 同一条消息按来源分段(`first_message` = 各段用 `"\n\n"` 连起来)。旧 daemon 没有,读作空。
|
|
3706
|
+
*/
|
|
3707
|
+
segments?: PromptSegment[];
|
|
3708
|
+
}
|
|
3709
|
+
export interface TodoDispatchResult {
|
|
3710
|
+
session: SessionSummary;
|
|
3711
|
+
todo: Todo;
|
|
3712
|
+
}
|
|
3713
|
+
/**
|
|
3714
|
+
* `todo.event` 通知:这一项的「经过」多了一条,发给所有在线客户端。
|
|
3715
|
+
*/
|
|
3716
|
+
export interface TodoEventNotice {
|
|
3717
|
+
event: TodoEvent;
|
|
3718
|
+
todo_id: string;
|
|
3719
|
+
}
|
|
3720
|
+
/**
|
|
3721
|
+
* `todo.history` 的参数。
|
|
3722
|
+
*/
|
|
3723
|
+
export interface TodoHistoryParams {
|
|
3724
|
+
/**
|
|
3725
|
+
* 只给 `seq` 小于它的事件(翻页用:上一页最后一条的 `seq`)。
|
|
3726
|
+
*/
|
|
3727
|
+
before_seq?: number | null;
|
|
3728
|
+
id: string;
|
|
3729
|
+
/**
|
|
3730
|
+
* 缺省 50,上限 200。
|
|
3731
|
+
*/
|
|
3732
|
+
limit?: number | null;
|
|
3733
|
+
}
|
|
3734
|
+
export interface TodoHistoryResult {
|
|
3735
|
+
/**
|
|
3736
|
+
* 按 `seq` 从新到旧。
|
|
3737
|
+
*/
|
|
3738
|
+
events: TodoEvent[];
|
|
3739
|
+
has_more: boolean;
|
|
3740
|
+
}
|
|
3741
|
+
export interface TodoIdParams {
|
|
3742
|
+
id: string;
|
|
3743
|
+
}
|
|
3744
|
+
export interface TodoListParams {
|
|
3745
|
+
/**
|
|
3746
|
+
* 返回排在这个游标后面的项(按 `(updated_ms, id)` 从新到旧)。
|
|
3747
|
+
*/
|
|
3748
|
+
before?: TodoCursor | null;
|
|
3749
|
+
/**
|
|
3750
|
+
* 缺省只给没关闭的;`true` 时也给 `done` / `dropped`。
|
|
3751
|
+
*/
|
|
3752
|
+
include_closed?: boolean | null;
|
|
3753
|
+
/**
|
|
3754
|
+
* 缺省 200,上限 1000。
|
|
3755
|
+
*/
|
|
3756
|
+
limit?: number | null;
|
|
3757
|
+
project?: string | null;
|
|
3758
|
+
}
|
|
3759
|
+
export interface TodoListResult {
|
|
3760
|
+
/**
|
|
3761
|
+
* 后面还有没给出的项(一页另有 1 MiB 的字节预算,可能少于 `limit`)。
|
|
3762
|
+
*/
|
|
3763
|
+
has_more: boolean;
|
|
3764
|
+
todos: Todo[];
|
|
3765
|
+
}
|
|
3766
|
+
/**
|
|
3767
|
+
* `todo.repeat_preview`:一个周期项(模板)复制出来的下一项交给 Twin 时会发出的第一条消息,分段标明来源。
|
|
3768
|
+
* 给了的字段代替存着的值(表单里还没保存的内容)。`id` 还不在库里时,给了 `title` 就按一个还没保存的模板处理
|
|
3769
|
+
* (条数为 0,用法说明里用这个 id:清单项的 id 由客户端生成)。
|
|
3770
|
+
*/
|
|
3771
|
+
export interface TodoRepeatPreviewParams {
|
|
3772
|
+
/**
|
|
3773
|
+
* 表单里的正文;校验同 `todo.add`。
|
|
3774
|
+
*/
|
|
3775
|
+
body?: string | null;
|
|
3776
|
+
id: string;
|
|
3777
|
+
keep_state?: boolean | null;
|
|
3778
|
+
/**
|
|
3779
|
+
* 缺省 `true`(Twin 派发总是带「不 push、不开 PR」;人手动派发也缺省带)。
|
|
3780
|
+
*/
|
|
3781
|
+
no_push?: boolean | null;
|
|
3782
|
+
/**
|
|
3783
|
+
* 表单里的项目,只影响 `rules_text`;空白表示没有项目。
|
|
3784
|
+
*/
|
|
3785
|
+
project?: string | null;
|
|
3786
|
+
state_hint_off?: boolean | null;
|
|
3787
|
+
/**
|
|
3788
|
+
* 表单里的标题;校验同 `todo.add`。
|
|
3789
|
+
*/
|
|
3790
|
+
title?: string | null;
|
|
3791
|
+
}
|
|
3792
|
+
export interface TodoRepeatPreviewResult {
|
|
3793
|
+
/**
|
|
3794
|
+
* 和真正派发同一个组装函数得到的全文;新复制出来的项还没有之前的报告,所以没有那一段。
|
|
3795
|
+
*/
|
|
3796
|
+
first_message: string;
|
|
3797
|
+
/**
|
|
3798
|
+
* 此刻开一个模板所在项目的会话会注入的规则文字(同 `todo.dispatch_preview`)。
|
|
3799
|
+
*/
|
|
3800
|
+
rules_text?: string;
|
|
3801
|
+
segments: PromptSegment[];
|
|
3802
|
+
/**
|
|
3803
|
+
* 这个模板现在存着的条数(开关关着时也照实给)。
|
|
3804
|
+
*/
|
|
3805
|
+
state_count: number;
|
|
3806
|
+
/**
|
|
3807
|
+
* 状态用法说明的「抄进正文」版本:命令里用模板的 id(对之后每一次复制都有效),不带条数那一行。
|
|
3808
|
+
*/
|
|
3809
|
+
state_usage_text: string;
|
|
3810
|
+
}
|
|
3811
|
+
export interface TodoUpdateParams {
|
|
3812
|
+
/**
|
|
3813
|
+
* 调用方自报是 agent;不能把处理人设成 Twin,也不算人收下了这一项。
|
|
3814
|
+
*/
|
|
3815
|
+
agent?: boolean | null;
|
|
3816
|
+
body?: string | null;
|
|
3817
|
+
/**
|
|
3818
|
+
* 要清空的可选字段,在合并之后生效。
|
|
3819
|
+
*/
|
|
3820
|
+
clear?: ClearableTodoField[];
|
|
3821
|
+
due_ms?: number | null;
|
|
3822
|
+
handler?: TodoHandler | null;
|
|
3823
|
+
id: string;
|
|
3824
|
+
project?: string | null;
|
|
3825
|
+
/**
|
|
3826
|
+
* 设置或替换周期规则(规则变了就从现在起重新算下一次);清掉用 `clear: ["repeat"]`。同 `todo.add`,只由人设置。
|
|
3827
|
+
*/
|
|
3828
|
+
repeat?: TodoRepeat | null;
|
|
3829
|
+
/**
|
|
3830
|
+
* `true`:把 `unreviewed` 清掉(`false` 或对已经收下的项会被忽略)。
|
|
3831
|
+
*/
|
|
3832
|
+
reviewed?: boolean | null;
|
|
3833
|
+
state?: TodoState | null;
|
|
3834
|
+
title?: string | null;
|
|
3835
|
+
}
|
|
2478
3836
|
export interface TrashEntry {
|
|
2479
3837
|
bytes: number;
|
|
2480
3838
|
/**
|
|
@@ -2488,6 +3846,345 @@ export interface TrashEntry {
|
|
|
2488
3846
|
root?: string | null;
|
|
2489
3847
|
trashed_at_ms: number;
|
|
2490
3848
|
}
|
|
3849
|
+
export interface TwinAnswerParams {
|
|
3850
|
+
answer: string;
|
|
3851
|
+
id: string;
|
|
3852
|
+
}
|
|
3853
|
+
export interface TwinChanged {
|
|
3854
|
+
run?: TwinRun | null;
|
|
3855
|
+
state: TwinState;
|
|
3856
|
+
}
|
|
3857
|
+
export interface TwinRun {
|
|
3858
|
+
decisions: TwinDecision[];
|
|
3859
|
+
dry_run: boolean;
|
|
3860
|
+
error?: JudgeError | null;
|
|
3861
|
+
finished_ms?: number | null;
|
|
3862
|
+
id: string;
|
|
3863
|
+
items: string[];
|
|
3864
|
+
judge_calls: string[];
|
|
3865
|
+
/**
|
|
3866
|
+
* 本机为 local;Twin 连接以设备 id 作请求方。
|
|
3867
|
+
*/
|
|
3868
|
+
requester: string;
|
|
3869
|
+
result: TwinRunResult;
|
|
3870
|
+
started_ms: number;
|
|
3871
|
+
triggers: TwinTrigger[];
|
|
3872
|
+
/**
|
|
3873
|
+
* 这次运行所有判断调用的用量之和;调用都没报告的成员缺省。
|
|
3874
|
+
*/
|
|
3875
|
+
usage?: JudgeUsage | null;
|
|
3876
|
+
}
|
|
3877
|
+
export interface TwinDecision {
|
|
3878
|
+
action: TwinAction;
|
|
3879
|
+
/**
|
|
3880
|
+
* 派发到哪个节点(节点表里的 id);缺省 = 本机。只用于显示。
|
|
3881
|
+
*/
|
|
3882
|
+
node?: string | null;
|
|
3883
|
+
/**
|
|
3884
|
+
* 解析后的动作参数;试跑据此展示计划,不保存原始模型输出。
|
|
3885
|
+
*/
|
|
3886
|
+
note?: string | null;
|
|
3887
|
+
options?: string[];
|
|
3888
|
+
outcome: TwinDecisionOutcome;
|
|
3889
|
+
project?: string | null;
|
|
3890
|
+
question?: string | null;
|
|
3891
|
+
question_id?: string | null;
|
|
3892
|
+
reason: string;
|
|
3893
|
+
rules: string[];
|
|
3894
|
+
session_id?: string | null;
|
|
3895
|
+
skip_reason?: TwinSkipReason | null;
|
|
3896
|
+
todo_id: string;
|
|
3897
|
+
}
|
|
3898
|
+
/**
|
|
3899
|
+
* 一个本地日的 Twin 统计。数据来自节点保留的运行记录(90 天)和待办的经过(已删除待办的经过没了),所以旧日子的数字可能变小。
|
|
3900
|
+
*/
|
|
3901
|
+
export interface TwinDayStats {
|
|
3902
|
+
/**
|
|
3903
|
+
* 这天由未关闭(非 `done` / `dropped`)变为 `done` 的 `state` 事件数,且本机 Twin 在事件时间或之前派发过这一项。
|
|
3904
|
+
* 已关闭项在 `done` 和 `dropped` 之间改来改去不算;重新打开后再关闭算新的一次。
|
|
3905
|
+
*/
|
|
3906
|
+
accepted?: number;
|
|
3907
|
+
/**
|
|
3908
|
+
* 节点本地时间的 `YYYY-MM-DD`。
|
|
3909
|
+
*/
|
|
3910
|
+
date: string;
|
|
3911
|
+
decisions?: TwinDecisionCounts;
|
|
3912
|
+
/**
|
|
3913
|
+
* 同 `accepted`,但是变为 `dropped`。
|
|
3914
|
+
*/
|
|
3915
|
+
dropped?: number;
|
|
3916
|
+
dry_runs?: number;
|
|
3917
|
+
/**
|
|
3918
|
+
* 这天待办经过里的 `handed_back` 事件数:Twin 没做完就交回给人的次数(`hand_back` 判断、连续 3 次失败、2 小时卡住)。
|
|
3919
|
+
* 不含 `done` 判断(Twin 认为做完了,请人确认)写的那一条。
|
|
3920
|
+
*/
|
|
3921
|
+
handed_back?: number;
|
|
3922
|
+
/**
|
|
3923
|
+
* 这天开始的所有运行(含试跑,它们也占预算)发起的判断调用次数。
|
|
3924
|
+
*/
|
|
3925
|
+
judge_calls?: number;
|
|
3926
|
+
/**
|
|
3927
|
+
* 这天开始的非试跑运行,按 `result`。
|
|
3928
|
+
*/
|
|
3929
|
+
runs?: TwinRunCounts;
|
|
3930
|
+
/**
|
|
3931
|
+
* 非试跑运行里 `outcome = skipped` 的决定数。
|
|
3932
|
+
*/
|
|
3933
|
+
skipped?: number;
|
|
3934
|
+
/**
|
|
3935
|
+
* 这一天开始的本地零点。
|
|
3936
|
+
*/
|
|
3937
|
+
start_ms: number;
|
|
3938
|
+
/**
|
|
3939
|
+
* 这天的 `taken_over` 事件数,只算本机 Twin 派发过(不晚于事件)的项;Twin 设备派来的会话里的接手不算。
|
|
3940
|
+
*/
|
|
3941
|
+
taken_over?: number;
|
|
3942
|
+
/**
|
|
3943
|
+
* 这天每个 `accepted` 事件的(事件时间 - 该项在事件时间或之前最近一次被本机 Twin 派发的时间)之和;平均 = `turnaround_ms / accepted`。
|
|
3944
|
+
*/
|
|
3945
|
+
turnaround_ms?: number;
|
|
3946
|
+
/**
|
|
3947
|
+
* 这些调用的用量之和。
|
|
3948
|
+
*/
|
|
3949
|
+
usage?: JudgeUsage | null;
|
|
3950
|
+
}
|
|
3951
|
+
/**
|
|
3952
|
+
* 非试跑运行里 `outcome = executed` 的决定按动作的计数。
|
|
3953
|
+
*/
|
|
3954
|
+
export interface TwinDecisionCounts {
|
|
3955
|
+
ask_advisor?: number;
|
|
3956
|
+
ask_user?: number;
|
|
3957
|
+
dispatch?: number;
|
|
3958
|
+
done?: number;
|
|
3959
|
+
hand_back?: number;
|
|
3960
|
+
wait?: number;
|
|
3961
|
+
}
|
|
3962
|
+
/**
|
|
3963
|
+
* 非试跑运行按 `result` 的计数。
|
|
3964
|
+
*/
|
|
3965
|
+
export interface TwinRunCounts {
|
|
3966
|
+
budget?: number;
|
|
3967
|
+
cancelled?: number;
|
|
3968
|
+
done?: number;
|
|
3969
|
+
failed?: number;
|
|
3970
|
+
idle?: number;
|
|
3971
|
+
}
|
|
3972
|
+
export interface TwinDryRunResult {
|
|
3973
|
+
run: TwinRun;
|
|
3974
|
+
}
|
|
3975
|
+
/**
|
|
3976
|
+
* `twin.get` 的参数。
|
|
3977
|
+
*/
|
|
3978
|
+
export interface TwinGetParams {
|
|
3979
|
+
/**
|
|
3980
|
+
* 读谁的范围:缺省 `local`(本机 Twin);也可以是一个已配对的 Twin 设备(`DeviceKind::Twin`)的设备 id,读 B 给这条 Twin 连接
|
|
3981
|
+
* 的设置(docs/spec/daemon.md § 27.3)。不是已存在的 Twin 设备 → `not_found`。
|
|
3982
|
+
*/
|
|
3983
|
+
requester?: string | null;
|
|
3984
|
+
}
|
|
3985
|
+
export interface TwinGetResult {
|
|
3986
|
+
configured: boolean;
|
|
3987
|
+
/**
|
|
3988
|
+
* 仍在范围内、但上一次判断放不进输入(§ 26.4 的大小上限)的待办 id。只在内存里,重启后为空。
|
|
3989
|
+
*/
|
|
3990
|
+
deferred?: string[];
|
|
3991
|
+
enabled: boolean;
|
|
3992
|
+
/**
|
|
3993
|
+
* 最近一次真实唤醒(不含试跑),按 `started_ms`;可能还在运行(没有 `finished_ms`)。
|
|
3994
|
+
*/
|
|
3995
|
+
last_run?: TwinRunBrief | null;
|
|
3996
|
+
/**
|
|
3997
|
+
* 已配置、本机启用且未暂停时:待处理触发的合并截止时间(运行中没有)和下一次兜底 tick 里较早的那个;都没有则缺省。
|
|
3998
|
+
* 读取时的快照,变化时不发通知。
|
|
3999
|
+
*/
|
|
4000
|
+
next_wake_ms?: number | null;
|
|
4001
|
+
/**
|
|
4002
|
+
* 在 Twin 范围内(§ 26.1),但既不在 `working` 里也没有未回答的问题的待办 id。
|
|
4003
|
+
*/
|
|
4004
|
+
queued?: string[];
|
|
4005
|
+
scope: TwinScope;
|
|
4006
|
+
state: TwinState;
|
|
4007
|
+
today: TwinToday;
|
|
4008
|
+
waiting: string[];
|
|
4009
|
+
working: string[];
|
|
4010
|
+
}
|
|
4011
|
+
/**
|
|
4012
|
+
* 一次运行的摘要(`TwinGetResult.last_run`):不含每项的决定,要看细节用 `twin.runs`。
|
|
4013
|
+
*/
|
|
4014
|
+
export interface TwinRunBrief {
|
|
4015
|
+
error?: JudgeError | null;
|
|
4016
|
+
/**
|
|
4017
|
+
* 缺省 = 还在运行。
|
|
4018
|
+
*/
|
|
4019
|
+
finished_ms?: number | null;
|
|
4020
|
+
id: string;
|
|
4021
|
+
result: TwinRunResult;
|
|
4022
|
+
started_ms: number;
|
|
4023
|
+
triggers: TwinTrigger[];
|
|
4024
|
+
}
|
|
4025
|
+
export interface TwinScope {
|
|
4026
|
+
agent?: string | null;
|
|
4027
|
+
daily_dispatches: number;
|
|
4028
|
+
max_sessions: number;
|
|
4029
|
+
mode?: string | null;
|
|
4030
|
+
model?: string | null;
|
|
4031
|
+
paused: boolean;
|
|
4032
|
+
projects: string[];
|
|
4033
|
+
}
|
|
4034
|
+
export interface TwinToday {
|
|
4035
|
+
dispatches: number;
|
|
4036
|
+
judge_calls: number;
|
|
4037
|
+
}
|
|
4038
|
+
/**
|
|
4039
|
+
* 一条 Twin 连接(A 记下的,表 `twin_links`)。
|
|
4040
|
+
*/
|
|
4041
|
+
export interface TwinLink {
|
|
4042
|
+
/**
|
|
4043
|
+
* B 的静态公钥指纹。
|
|
4044
|
+
*/
|
|
4045
|
+
fingerprint: string;
|
|
4046
|
+
group?: string | null;
|
|
4047
|
+
name: string;
|
|
4048
|
+
/**
|
|
4049
|
+
* B 的节点 id。
|
|
4050
|
+
*/
|
|
4051
|
+
node_id: string;
|
|
4052
|
+
/**
|
|
4053
|
+
* 这条连接现在在线。
|
|
4054
|
+
*/
|
|
4055
|
+
online?: boolean;
|
|
4056
|
+
paired_ms: number;
|
|
4057
|
+
/**
|
|
4058
|
+
* 上一次的 `twin.peer_status`;还没取到过为空。
|
|
4059
|
+
*/
|
|
4060
|
+
status?: TwinPeerStatus | null;
|
|
4061
|
+
}
|
|
4062
|
+
/**
|
|
4063
|
+
* B 对这条 Twin 连接开放了什么、还剩多少(`twin.peer_status` 的结果,只给这条连接自己的)。
|
|
4064
|
+
*/
|
|
4065
|
+
export interface TwinPeerStatus {
|
|
4066
|
+
/**
|
|
4067
|
+
* B 现在接受 Twin 连接(`[twin] accept_links`)。
|
|
4068
|
+
*/
|
|
4069
|
+
accept_links: boolean;
|
|
4070
|
+
agents: TwinPeerAgent[];
|
|
4071
|
+
/**
|
|
4072
|
+
* B 的分组名。
|
|
4073
|
+
*/
|
|
4074
|
+
group?: string | null;
|
|
4075
|
+
/**
|
|
4076
|
+
* B 的节点名。
|
|
4077
|
+
*/
|
|
4078
|
+
name: string;
|
|
4079
|
+
/**
|
|
4080
|
+
* 这条连接被 B 暂停了。
|
|
4081
|
+
*/
|
|
4082
|
+
paused: boolean;
|
|
4083
|
+
/**
|
|
4084
|
+
* 对这条连接开放的项目;空 = 什么都没开放。
|
|
4085
|
+
*/
|
|
4086
|
+
projects: string[];
|
|
4087
|
+
/**
|
|
4088
|
+
* 这个本地日还能派发几次。
|
|
4089
|
+
*/
|
|
4090
|
+
remaining_dispatches: number;
|
|
4091
|
+
/**
|
|
4092
|
+
* 这条连接还能同时派出几个会话:它的上限和给人留的名额里更紧的那个,减去已在处理中的。
|
|
4093
|
+
*/
|
|
4094
|
+
remaining_sessions: number;
|
|
4095
|
+
}
|
|
4096
|
+
export interface TwinPeerAgent {
|
|
4097
|
+
id: string;
|
|
4098
|
+
label: string;
|
|
4099
|
+
/**
|
|
4100
|
+
* agent 现在可用(已安装、已登录)。
|
|
4101
|
+
*/
|
|
4102
|
+
ready: boolean;
|
|
4103
|
+
}
|
|
4104
|
+
/**
|
|
4105
|
+
* `twin.link` 的参数:A 的 daemon 用 B 发的短码以 Twin 设备的身份和 B 配对。
|
|
4106
|
+
*/
|
|
4107
|
+
export interface TwinLinkParams {
|
|
4108
|
+
/**
|
|
4109
|
+
* B 的 `node.twin_link_code` 发出的短码。
|
|
4110
|
+
*/
|
|
4111
|
+
code: string;
|
|
4112
|
+
/**
|
|
4113
|
+
* B 的节点 id:配对完成后核对,对不上就失败并丢掉这次配对。
|
|
4114
|
+
*/
|
|
4115
|
+
node_id: string;
|
|
4116
|
+
}
|
|
4117
|
+
export interface TwinLinksResult {
|
|
4118
|
+
links: TwinLink[];
|
|
4119
|
+
}
|
|
4120
|
+
export interface TwinQuestion {
|
|
4121
|
+
answer?: string | null;
|
|
4122
|
+
answered_by?: TodoActor | null;
|
|
4123
|
+
answered_ms?: number | null;
|
|
4124
|
+
created_ms: number;
|
|
4125
|
+
id: string;
|
|
4126
|
+
options?: string[];
|
|
4127
|
+
question: string;
|
|
4128
|
+
status: TwinQuestionStatus;
|
|
4129
|
+
todo_id: string;
|
|
4130
|
+
}
|
|
4131
|
+
export interface TwinQuestionNotice {
|
|
4132
|
+
question: TwinQuestion;
|
|
4133
|
+
}
|
|
4134
|
+
export interface TwinQuestionsParams {
|
|
4135
|
+
open_only?: boolean | null;
|
|
4136
|
+
}
|
|
4137
|
+
export interface TwinQuestionsResult {
|
|
4138
|
+
questions: TwinQuestion[];
|
|
4139
|
+
}
|
|
4140
|
+
export interface TwinRunsParams {
|
|
4141
|
+
before_ms?: number | null;
|
|
4142
|
+
limit?: number | null;
|
|
4143
|
+
}
|
|
4144
|
+
export interface TwinRunsResult {
|
|
4145
|
+
runs: TwinRun[];
|
|
4146
|
+
}
|
|
4147
|
+
export interface TwinSetParams {
|
|
4148
|
+
agent?: string | null;
|
|
4149
|
+
/**
|
|
4150
|
+
* 合并字段之后清空;恢复 agent / model / mode 的缺省选择。
|
|
4151
|
+
*/
|
|
4152
|
+
clear?: ClearableTwinField[];
|
|
4153
|
+
daily_dispatches?: number | null;
|
|
4154
|
+
max_sessions?: number | null;
|
|
4155
|
+
mode?: string | null;
|
|
4156
|
+
model?: string | null;
|
|
4157
|
+
paused?: boolean | null;
|
|
4158
|
+
projects?: string[] | null;
|
|
4159
|
+
/**
|
|
4160
|
+
* 改谁的范围,同 [`TwinGetParams::requester`]。
|
|
4161
|
+
*/
|
|
4162
|
+
requester?: string | null;
|
|
4163
|
+
}
|
|
4164
|
+
/**
|
|
4165
|
+
* `twin.stats` 的参数。只统计本机 Twin。
|
|
4166
|
+
*/
|
|
4167
|
+
export interface TwinStatsParams {
|
|
4168
|
+
/**
|
|
4169
|
+
* 统计最近几个本地日(含今天),1..=90,缺省 7;越界 → `invalid`,`data.field = "days"`。
|
|
4170
|
+
*/
|
|
4171
|
+
days?: number | null;
|
|
4172
|
+
}
|
|
4173
|
+
/**
|
|
4174
|
+
* `twin.stats` 的结果。
|
|
4175
|
+
*/
|
|
4176
|
+
export interface TwinStatsResult {
|
|
4177
|
+
/**
|
|
4178
|
+
* 节点本地时区的每一天,按日期升序,最后一项是今天;没有活动的日子也在,数字为 0。
|
|
4179
|
+
*/
|
|
4180
|
+
days: TwinDayStats[];
|
|
4181
|
+
}
|
|
4182
|
+
/**
|
|
4183
|
+
* `twin.unlink` 的参数:A 忘掉这一条连接(关掉传输、删记录)。B 上的设备记录要在 B 上吊销。
|
|
4184
|
+
*/
|
|
4185
|
+
export interface TwinUnlinkParams {
|
|
4186
|
+
node_id: string;
|
|
4187
|
+
}
|
|
2491
4188
|
/**
|
|
2492
4189
|
* `workspace.branches`:给新建会话的「基于哪个分支」下拉框列分支。
|
|
2493
4190
|
*/
|