@tencent-ai/agent-sdk 0.3.237-dev.cd99b52.202608040127 → 0.3.237-dev.fc41ac4.202608061734

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.
Files changed (75) hide show
  1. package/cli/dist/codebuddy-headless.js +393 -417
  2. package/cli/package.json +4 -4
  3. package/cli/product.cloudhosted.json +6 -7
  4. package/cli/product.internal.json +6 -7
  5. package/cli/product.ioa.json +6 -7
  6. package/cli/product.json +10 -10
  7. package/cli/product.selfhosted.json +4 -5
  8. package/lib/_internal/query-controller.d.ts +2 -55
  9. package/lib/_internal/query-controller.d.ts.map +1 -1
  10. package/lib/_internal/query-controller.js +2 -478
  11. package/lib/_internal/query-controller.js.map +1 -1
  12. package/lib/index.d.ts +1 -17
  13. package/lib/index.d.ts.map +1 -1
  14. package/lib/index.js +1 -18
  15. package/lib/index.js.map +1 -1
  16. package/lib/mcp/index.d.ts +0 -4
  17. package/lib/mcp/index.d.ts.map +1 -1
  18. package/lib/mcp/index.js +1 -8
  19. package/lib/mcp/index.js.map +1 -1
  20. package/lib/query.d.ts +1 -14
  21. package/lib/query.d.ts.map +1 -1
  22. package/lib/query.js +28 -335
  23. package/lib/query.js.map +1 -1
  24. package/lib/session.d.ts +1 -8
  25. package/lib/session.d.ts.map +1 -1
  26. package/lib/session.js +11 -147
  27. package/lib/session.js.map +1 -1
  28. package/lib/transport/index.d.ts +3 -59
  29. package/lib/transport/index.d.ts.map +1 -1
  30. package/lib/transport/index.js.map +1 -1
  31. package/lib/transport/process-transport.d.ts +4 -81
  32. package/lib/transport/process-transport.d.ts.map +1 -1
  33. package/lib/transport/process-transport.js +15 -304
  34. package/lib/transport/process-transport.js.map +1 -1
  35. package/lib/types.d.ts +6 -805
  36. package/lib/types.d.ts.map +1 -1
  37. package/lib/types.js +1 -16
  38. package/lib/types.js.map +1 -1
  39. package/package.json +1 -1
  40. package/lib/_internal/boundary-invariants.d.ts +0 -24
  41. package/lib/_internal/boundary-invariants.d.ts.map +0 -1
  42. package/lib/_internal/boundary-invariants.js +0 -39
  43. package/lib/_internal/boundary-invariants.js.map +0 -1
  44. package/lib/_internal/remote-extensions-options.d.ts +0 -3
  45. package/lib/_internal/remote-extensions-options.d.ts.map +0 -1
  46. package/lib/_internal/remote-extensions-options.js +0 -37
  47. package/lib/_internal/remote-extensions-options.js.map +0 -1
  48. package/lib/_internal/session-mirror.d.ts +0 -53
  49. package/lib/_internal/session-mirror.d.ts.map +0 -1
  50. package/lib/_internal/session-mirror.js +0 -156
  51. package/lib/_internal/session-mirror.js.map +0 -1
  52. package/lib/_internal/session-store-runtime.d.ts +0 -52
  53. package/lib/_internal/session-store-runtime.d.ts.map +0 -1
  54. package/lib/_internal/session-store-runtime.js +0 -283
  55. package/lib/_internal/session-store-runtime.js.map +0 -1
  56. package/lib/in-memory-session-store.d.ts +0 -31
  57. package/lib/in-memory-session-store.d.ts.map +0 -1
  58. package/lib/in-memory-session-store.js +0 -127
  59. package/lib/in-memory-session-store.js.map +0 -1
  60. package/lib/mcp/delegated-redaction.d.ts +0 -47
  61. package/lib/mcp/delegated-redaction.d.ts.map +0 -1
  62. package/lib/mcp/delegated-redaction.js +0 -362
  63. package/lib/mcp/delegated-redaction.js.map +0 -1
  64. package/lib/mcp/managed-remote-mcp-bridge.d.ts +0 -49
  65. package/lib/mcp/managed-remote-mcp-bridge.d.ts.map +0 -1
  66. package/lib/mcp/managed-remote-mcp-bridge.js +0 -303
  67. package/lib/mcp/managed-remote-mcp-bridge.js.map +0 -1
  68. package/lib/remote-error-codes.d.ts +0 -8
  69. package/lib/remote-error-codes.d.ts.map +0 -1
  70. package/lib/remote-error-codes.js +0 -23
  71. package/lib/remote-error-codes.js.map +0 -1
  72. package/lib/session-store-protocol.d.ts +0 -19
  73. package/lib/session-store-protocol.d.ts.map +0 -1
  74. package/lib/session-store-protocol.js +0 -125
  75. package/lib/session-store-protocol.js.map +0 -1
package/lib/types.d.ts CHANGED
@@ -135,7 +135,7 @@ export interface HookCallbackMatcher {
135
135
  }
136
136
  export interface BaseHookInput {
137
137
  session_id: string;
138
- transcript_path?: string;
138
+ transcript_path: string;
139
139
  cwd: string;
140
140
  permission_mode?: string;
141
141
  }
@@ -191,7 +191,7 @@ export type SubagentStopHookInput = BaseHookInput & {
191
191
  hook_event_name: 'SubagentStop';
192
192
  stop_hook_active: boolean;
193
193
  agent_id: string;
194
- agent_transcript_path?: string;
194
+ agent_transcript_path: string;
195
195
  };
196
196
  export type PreCompactHookInput = BaseHookInput & {
197
197
  hook_event_name: 'PreCompact';
@@ -489,11 +489,6 @@ export interface SystemMessage {
489
489
  subtype: 'init';
490
490
  uuid: string;
491
491
  session_id: string;
492
- /**
493
- * 当前帧所属的 run 标识。由 CLI 侧写入并透传给下游消费者,用于按 run 归类每一帧。
494
- * resume 或 replay 阶段 runId 尚未分配时可能缺失。
495
- */
496
- run_id?: string;
497
492
  apiKeySource?: string;
498
493
  cwd?: string;
499
494
  tools: string[];
@@ -512,14 +507,10 @@ export interface SystemMessage {
512
507
  path: string;
513
508
  }>;
514
509
  }
515
- export interface RemoteOperationContext {
516
- contextId: string;
517
- }
518
510
  export interface UserMessage {
519
511
  type: 'user';
520
512
  uuid?: string;
521
513
  session_id: string;
522
- run_id?: string;
523
514
  message: {
524
515
  role: 'user';
525
516
  content: string | ContentBlock[];
@@ -534,7 +525,6 @@ export interface AssistantMessage {
534
525
  type: 'assistant';
535
526
  uuid: string;
536
527
  session_id: string;
537
- run_id?: string;
538
528
  message: {
539
529
  id: string;
540
530
  type: 'message';
@@ -554,14 +544,12 @@ export interface PartialAssistantMessage {
554
544
  parent_tool_use_id: string | null;
555
545
  uuid: string;
556
546
  session_id: string;
557
- run_id?: string;
558
547
  }
559
548
  export type ResultMessage = {
560
549
  type: 'result';
561
550
  subtype: 'success';
562
551
  uuid: string;
563
552
  session_id: string;
564
- run_id?: string;
565
553
  duration_ms: number;
566
554
  duration_api_ms: number;
567
555
  is_error: boolean;
@@ -576,7 +564,6 @@ export type ResultMessage = {
576
564
  subtype: 'error_during_execution' | 'error_max_turns' | 'error_max_budget_usd';
577
565
  uuid: string;
578
566
  session_id: string;
579
- run_id?: string;
580
567
  duration_ms: number;
581
568
  duration_api_ms: number;
582
569
  is_error: boolean;
@@ -591,7 +578,6 @@ export interface CompactBoundaryMessage {
591
578
  subtype: 'compact_boundary';
592
579
  uuid: string;
593
580
  session_id: string;
594
- run_id?: string;
595
581
  compact_metadata: {
596
582
  trigger: 'manual' | 'auto';
597
583
  pre_tokens: number;
@@ -603,44 +589,6 @@ export interface StatusMessage {
603
589
  status: 'compacting' | null;
604
590
  uuid: string;
605
591
  session_id: string;
606
- run_id?: string;
607
- }
608
- /**
609
- * Run 生命周期帧:一次 run 开始时由 CLI 发送一次。
610
- *
611
- * 作为独立 subtype 加入 Message union,而非拓展 SystemMessage.subtype,
612
- * 以保持 init 字面量类型的精确性。CLI 侧通过 --emit-run-lifecycle 显式启用;
613
- * 不启用时消费方永远不会收到该帧。
614
- */
615
- export interface RunStartedMessage {
616
- type: 'system';
617
- subtype: 'run_started';
618
- uuid: string;
619
- session_id: string;
620
- /** 归属 run 的标识(本帧必填)。 */
621
- run_id: string;
622
- /** run 开始时的时间戳(毫秒)。 */
623
- run_started_at: number;
624
- }
625
- /**
626
- * 会话镜像写入失败帧(对齐 Claude 的 {type:'system', subtype:'mirror_error'})。
627
- *
628
- * 双写语义下本地已持久化,镜像失败不中断查询——重试耗尽后丢弃该批,
629
- * flush 超时则远端结果未知;两者都会合成本帧进结果迭代器。
630
- * 作为独立 subtype 加入 Message union(同 RunStartedMessage 的做法),
631
- * 保持 SystemMessage.subtype 'init' 字面量类型的精确性。
632
- */
633
- export interface MirrorErrorMessage {
634
- type: 'system';
635
- subtype: 'mirror_error';
636
- uuid: string;
637
- session_id: string;
638
- /** 失败批次的目标 key(含 subpath 时为子代理记录) */
639
- session_store_key: SessionKey;
640
- /** 失败原因描述 */
641
- error: string;
642
- /** 受影响的条目数;flush 超时时不表示远端一定未提交 */
643
- dropped_entries: number;
644
592
  }
645
593
  /**
646
594
  * Emitted when a background task starts.
@@ -739,20 +687,11 @@ export interface ToolProgressMessage {
739
687
  elapsed_time_seconds: number;
740
688
  uuid: string;
741
689
  session_id: string;
742
- run_id?: string;
743
690
  }
744
- /**
745
- * 错误帧。有两个来源:
746
- * 1. CLI 主动输出的 error 帧;
747
- * 2. ProcessTransport 在 CLI 异常退出(未输出 result 就结束)时合成的补偿帧。
748
- * 合成路径会尽量填充 run_id 与 uuid,便于下游将失败归属到具体的 run。
749
- */
750
691
  export interface ErrorMessage {
751
692
  type: 'error';
752
693
  error: string;
753
694
  session_id?: string;
754
- run_id?: string;
755
- uuid?: string;
756
695
  }
757
696
  /**
758
697
  * Topic message for session title/topic updates.
@@ -762,7 +701,6 @@ export interface TopicMessage {
762
701
  type: 'topic';
763
702
  topic: string;
764
703
  session_id: string;
765
- run_id?: string;
766
704
  }
767
705
  /**
768
706
  * AI-generated session title update.
@@ -771,7 +709,6 @@ export interface AiTitleMessage {
771
709
  type: 'ai-title';
772
710
  aiTitle: string;
773
711
  session_id: string;
774
- run_id?: string;
775
712
  }
776
713
  /**
777
714
  * File history snapshot message.
@@ -791,12 +728,11 @@ export interface FileHistorySnapshotMessage {
791
728
  };
792
729
  id?: string;
793
730
  parentId?: string;
794
- run_id?: string;
795
731
  }
796
732
  /**
797
733
  * @experimental _requestId is an experimental field that may change in future versions.
798
734
  */
799
- export type Message = (SystemMessage | UserMessage | AssistantMessage | PartialAssistantMessage | ResultMessage | CompactBoundaryMessage | StatusMessage | TaskStartedMessage | TaskProgressMessage | TaskUpdatedMessage | TaskNotificationMessage | RunStartedMessage | MirrorErrorMessage | ToolProgressMessage | ErrorMessage | TopicMessage | AiTitleMessage | FileHistorySnapshotMessage) & {
735
+ export type Message = (SystemMessage | UserMessage | AssistantMessage | PartialAssistantMessage | ResultMessage | CompactBoundaryMessage | StatusMessage | TaskStartedMessage | TaskProgressMessage | TaskUpdatedMessage | TaskNotificationMessage | ToolProgressMessage | ErrorMessage | TopicMessage | AiTitleMessage | FileHistorySnapshotMessage) & {
800
736
  /** @experimental */
801
737
  _requestId?: string;
802
738
  };
@@ -871,490 +807,6 @@ export interface Query extends AsyncGenerator<Message, void> {
871
807
  streamInput(stream: AsyncIterable<UserMessage>): Promise<void>;
872
808
  }
873
809
  export type SettingSource = 'user' | 'project' | 'local';
874
- export type FileSystemModuleName = 'tools' | 'memory' | 'settings' | 'skills';
875
- export interface FileSystemHandlerOptions {
876
- module?: FileSystemModuleName;
877
- contextId?: string;
878
- signal?: AbortSignal;
879
- }
880
- /**
881
- * 路径上下文:cbc 本地绝对路径 + workspace 根(cwd) + 配置根(homedir)。
882
- * handler 可据此把 workspace 路径映射到远端;homedir 只作为上下文保留,
883
- * 不代表远端存在对应的 home/assets 镜像。
884
- */
885
- export interface FsPathInfo {
886
- absolutePath: string;
887
- cwd: string;
888
- homedir: string;
889
- }
890
- export interface FileSystemVersionedContent {
891
- exists: boolean;
892
- content: string;
893
- revision: string;
894
- }
895
- export type FileSystemMutation = {
896
- op: 'write';
897
- path: FsPathInfo;
898
- content: string;
899
- } | {
900
- op: 'writeBytes';
901
- path: FsPathInfo;
902
- base64: string;
903
- } | {
904
- op: 'rm';
905
- path: FsPathInfo;
906
- recursive: boolean;
907
- force: boolean;
908
- };
909
- export interface FileSystemConditionalBatchResult {
910
- revision: string;
911
- }
912
- export interface FileSystemConflictError extends Error {
913
- code: 'FILE_SYSTEM_CONFLICT';
914
- currentRevision?: string;
915
- }
916
- /**
917
- * 用户提供的 FileSystem 替换实现;可落到本地、远程沙箱或测试 fake。
918
- *
919
- * 每个 op 接收可选 `signal`:query 取消(query.interrupt() 或 abortController.abort())
920
- * 时 SDK 会触发该 signal,handler 应把信号透传到远端请求或长耗时 IO。v1 handler
921
- * 可忽略 signal(cbc 侧已有 per-op 30s 超时兜底),但接口必须现在就暴露,避免后续
922
- * 加 signal 变成 breaking change。
923
- *
924
- * 错误约定:handler 抛 `Error & { code?: string }`,SDK 会把 `error.code`
925
- * (如 'ENOENT' / 'EACCES' / 'ENOSPC')回包给 cbc,cbc 侧 tool 依此还原与本地
926
- * 一致的报错文案。
927
- */
928
- export interface FileSystemHandler {
929
- /** 文本读:返回 UTF-8 解码后的字符串。非 UTF-8 文件应用 readBytes。 */
930
- read(path: FsPathInfo, options?: FileSystemHandlerOptions): Promise<string>;
931
- /** 字节读:返回 base64 编码的字符串(cbc 侧负责 Buffer.from(base64, 'base64'))。 */
932
- readBytes(path: FsPathInfo, options?: FileSystemHandlerOptions): Promise<string>;
933
- /** 文本写:content 是 UTF-8 字符串;append=true 追加,否则覆盖。 */
934
- write(path: FsPathInfo, content: string, append: boolean, options?: FileSystemHandlerOptions): Promise<void>;
935
- /** 字节写:base64 是 base64 编码的字节流(cbc 已对 Buffer.toString('base64') 后传入)。 */
936
- writeBytes(path: FsPathInfo, base64: string, append: boolean, options?: FileSystemHandlerOptions): Promise<void>;
937
- /** mtime 单位毫秒(与 fs.Stats.mtimeMs 对齐)。 */
938
- stat(path: FsPathInfo, options?: FileSystemHandlerOptions): Promise<{
939
- isFile: boolean;
940
- isDirectory: boolean;
941
- size: number;
942
- mtime: number;
943
- }>;
944
- exists(path: FsPathInfo, options?: FileSystemHandlerOptions): Promise<boolean>;
945
- mkdir(path: FsPathInfo, recursive: boolean, options?: FileSystemHandlerOptions): Promise<void>;
946
- readdir(path: FsPathInfo, options?: FileSystemHandlerOptions): Promise<{
947
- name: string;
948
- type: 'file' | 'directory' | 'symlink';
949
- }[]>;
950
- rm(path: FsPathInfo, recursive: boolean, force: boolean, options?: FileSystemHandlerOptions): Promise<void>;
951
- /** 原子读取文件内容及其不透明 revision;文件不存在时仍返回可用于条件创建的 revision。 */
952
- readVersioned?(path: FsPathInfo, options?: FileSystemHandlerOptions): Promise<FileSystemVersionedContent>;
953
- /** 返回文件或目录 scope 的不透明 revision。 */
954
- revision?(path: FsPathInfo, options?: FileSystemHandlerOptions): Promise<string>;
955
- /** 全部 mutation 原子提交;revision 不匹配时抛 FileSystemConflictError,禁止部分写入。 */
956
- conditionalBatch?(scope: FsPathInfo, expectedRevision: string, mutations: readonly FileSystemMutation[], options?: FileSystemHandlerOptions): Promise<FileSystemConditionalBatchResult>;
957
- }
958
- export interface FileSystemOptions {
959
- /** 'all' 替换全部已接入 module;数组只替换指定 module,且不能为空。 */
960
- modules: 'all' | FileSystemModuleName[];
961
- /** 必填:fs 替换实现,由调用方提供(SDK 不内置默认)。 */
962
- handler: FileSystemHandler;
963
- }
964
- export type SearchGrepOutputMode = 'content' | 'files_with_matches' | 'count';
965
- export interface SearchPathInfo {
966
- absolutePath: string;
967
- cwd: string;
968
- homedir: string;
969
- }
970
- export interface SearchLimits {
971
- maxResults?: number;
972
- offset?: number;
973
- maxBytes: number;
974
- timeoutMs: number;
975
- }
976
- export interface SearchGlobRequest {
977
- pattern: string;
978
- path: SearchPathInfo;
979
- limits: SearchLimits;
980
- contextId?: string;
981
- }
982
- export interface SearchGlobResult {
983
- matches: Array<{
984
- path: string;
985
- modifiedAt?: number;
986
- }>;
987
- totalCount: number;
988
- }
989
- export interface SearchGrepRequest {
990
- query: string;
991
- path: SearchPathInfo;
992
- include?: string;
993
- fileType?: string;
994
- outputMode: SearchGrepOutputMode;
995
- caseInsensitive?: boolean;
996
- multiline?: boolean;
997
- lineNumbers?: boolean;
998
- context?: {
999
- before?: number;
1000
- after?: number;
1001
- };
1002
- limits: SearchLimits;
1003
- contextId?: string;
1004
- }
1005
- export interface SearchGrepMatch {
1006
- path: string;
1007
- line?: number;
1008
- text?: string;
1009
- count?: number;
1010
- kind?: 'match' | 'context';
1011
- }
1012
- export interface SearchGrepResult {
1013
- matches: SearchGrepMatch[];
1014
- totalCount: number;
1015
- }
1016
- export interface SearchHandler {
1017
- glob(request: SearchGlobRequest, options: {
1018
- signal: AbortSignal;
1019
- }): Promise<SearchGlobResult>;
1020
- grep(request: SearchGrepRequest, options: {
1021
- signal: AbortSignal;
1022
- }): Promise<SearchGrepResult>;
1023
- }
1024
- export interface SearchOptions {
1025
- handler: SearchHandler;
1026
- }
1027
- export interface EnvironmentSnapshot {
1028
- cwd: string;
1029
- homeDir: string;
1030
- configRoot: string;
1031
- platform: string;
1032
- platformVersion: string;
1033
- arch: string;
1034
- shell: string;
1035
- isWsl?: boolean;
1036
- locale?: string;
1037
- timezone?: string;
1038
- toolVersions?: Record<string, string>;
1039
- version?: string;
1040
- }
1041
- export interface EnvironmentSnapshotHandler {
1042
- getSnapshot(options: {
1043
- signal: AbortSignal;
1044
- contextId?: string;
1045
- }): Promise<EnvironmentSnapshot>;
1046
- }
1047
- export interface EnvironmentSnapshotOptions {
1048
- handler: EnvironmentSnapshotHandler;
1049
- }
1050
- export type AgentStateScope = 'session' | 'workspace' | 'user';
1051
- export interface AgentStateKey {
1052
- namespace: string;
1053
- scope: AgentStateScope;
1054
- scopeId: string;
1055
- key: string;
1056
- }
1057
- export interface AgentStateEntry {
1058
- key: AgentStateKey;
1059
- value: JsonValue;
1060
- etag: string;
1061
- expiresAt?: number;
1062
- }
1063
- export type AgentStateMutation = {
1064
- op: 'put';
1065
- key: AgentStateKey;
1066
- value: JsonValue;
1067
- expectedEtag?: string;
1068
- ifAbsent?: boolean;
1069
- ttlMs?: number;
1070
- } | {
1071
- op: 'delete';
1072
- key: AgentStateKey;
1073
- expectedEtag?: string;
1074
- };
1075
- export interface AgentStateStoreHandlerOptions {
1076
- signal: AbortSignal;
1077
- contextId?: string;
1078
- }
1079
- export interface AgentStateStoreHandler {
1080
- get(key: AgentStateKey, options: AgentStateStoreHandlerOptions): Promise<AgentStateEntry | undefined>;
1081
- put(key: AgentStateKey, value: JsonValue, write: {
1082
- expectedEtag?: string;
1083
- ifAbsent?: boolean;
1084
- ttlMs?: number;
1085
- }, options: AgentStateStoreHandlerOptions): Promise<AgentStateEntry>;
1086
- delete(key: AgentStateKey, expectedEtag: string | undefined, options: AgentStateStoreHandlerOptions): Promise<boolean>;
1087
- list(scope: Omit<AgentStateKey, 'key'>, prefix: string | undefined, options: AgentStateStoreHandlerOptions): Promise<AgentStateEntry[]>;
1088
- batch(mutations: AgentStateMutation[], options: AgentStateStoreHandlerOptions): Promise<AgentStateEntry[]>;
1089
- }
1090
- export interface AgentStateStoreOptions {
1091
- handler: AgentStateStoreHandler;
1092
- }
1093
- /** 会在控制面本地 spawn 子进程的执行消费者类别(fail-closed 的作用对象)。 */
1094
- export declare const LOCAL_EXECUTION_MODULE_NAMES: readonly ['mcpStdio', 'lsp', 'bash', 'search', 'hook', 'detachedProcess'];
1095
- export type LocalExecutionModuleName = typeof LOCAL_EXECUTION_MODULE_NAMES[number];
1096
- /**
1097
- * 控制面本地执行拒绝清单。'all' = 拒绝全部消费者(含未来新增,fail-safe);
1098
- * 数组 = 只拒绝列出者;未传 / [] = 不拒绝。用显式 'all' 而非「空 = 全部」,
1099
- * 避免安全开关读反导致 fail-open。
1100
- */
1101
- export type LocalExecutionDeny = 'all' | LocalExecutionModuleName[];
1102
- export interface RemoteMcpOptions {
1103
- /** 开启后,远程 MCP 必须走 host 委托;不能在 CLI 进程里本地直连。 */
1104
- managed?: true;
1105
- /** 限制 host 可代转的远程 transport;不传时表示三种都支持。 */
1106
- remoteTransports?: Array<'http' | 'sse' | 'remote'>;
1107
- }
1108
- /**
1109
- * channel open 配置:描述要拉起的远端 channel 类型与启动参数。
1110
- * type 目前由服务端侧解读(如 'mcp_stdio'),SDK 仅原样透传给 handler。
1111
- */
1112
- export interface ChannelOpenConfig {
1113
- type: string;
1114
- serverName: string;
1115
- command: string;
1116
- args?: string[];
1117
- cwd?: string;
1118
- env?: Record<string, string>;
1119
- workspaceRoot?: string;
1120
- idleTimeoutMs?: number;
1121
- }
1122
- /**
1123
- * 服务端 → SDK 推送的 channel 事件。jsonrpc 用于 mcp_stdio 类型的双向消息;
1124
- * stderr/exit/error 用于进程生命周期通知;cursor 留作长任务进度游标。
1125
- */
1126
- export interface ChannelEvent {
1127
- type: 'response' | 'notification' | 'progress' | 'stderr' | 'exit' | 'error';
1128
- jsonrpc?: unknown;
1129
- message?: string;
1130
- exitCode?: number;
1131
- cursor?: string;
1132
- }
1133
- /**
1134
- * 用户提供的 Channel 处理器;SDK 把 cbc 下发的 channel control-request
1135
- * 按 op 派发到对应方法,handler 在远端(如 AL)拉起/写入/收口 channel。
1136
- * onEvent 由 handler 内部在收到服务端推送时调用,SDK 负责转发给 CLI。
1137
- */
1138
- export interface ChannelHandler {
1139
- open(config: ChannelOpenConfig, options?: {
1140
- signal?: AbortSignal;
1141
- }): Promise<{
1142
- channelId: string;
1143
- type: string;
1144
- }>;
1145
- write(channelId: string, message: unknown, options?: {
1146
- signal?: AbortSignal;
1147
- }): Promise<void>;
1148
- heartbeat(channelId: string, options?: {
1149
- signal?: AbortSignal;
1150
- }): Promise<void>;
1151
- stop(channelId: string, options?: {
1152
- signal?: AbortSignal;
1153
- }): Promise<void>;
1154
- /** SDK handler 接到服务端的 channel events 后调此回调推给 CLI */
1155
- onEvent?: (channelId: string, event: ChannelEvent) => void;
1156
- }
1157
- export interface ChannelOptions {
1158
- handler: ChannelHandler;
1159
- }
1160
- export interface ExecPathInfo {
1161
- workspaceRoot: string;
1162
- homedir: string;
1163
- }
1164
- export interface ExecRequestContext {
1165
- userId: string;
1166
- sessionId: string;
1167
- runId: string;
1168
- requestId: string;
1169
- v: number;
1170
- toolCallId?: string;
1171
- conversationRequestId?: string;
1172
- capabilityId?: string;
1173
- contextId?: string;
1174
- remoteExecutionContextId?: string;
1175
- }
1176
- export interface ExecRunArgs {
1177
- cmd: string;
1178
- cwd?: string;
1179
- env?: Record<string, string>;
1180
- timeoutMs?: number;
1181
- maxOutputBytes?: number;
1182
- }
1183
- export type ExecExitReason = 'exited' | 'signaled' | 'timeout' | 'sandbox_denied' | 'permission_denied' | 'unsupported';
1184
- export type ExecErrorCode = 'EXEC_TIMEOUT' | 'EXEC_UNSUPPORTED' | 'EXEC_NO_HANDLER' | 'EXEC_INVALID_REQUEST' | 'EXEC_SANDBOX_DENIED' | 'EXEC_PERMISSION_DENIED' | 'EXEC_HANDLER_ERROR';
1185
- export type ExecUnsupportedFeature = 'pty' | 'interactive' | 'background' | 'persistent_stdin' | 'signal' | 'resize' | 'other';
1186
- export interface ExecRunResult {
1187
- exitCode: number | null;
1188
- stdout: string;
1189
- stderr: string;
1190
- exitReason: ExecExitReason;
1191
- signal?: number;
1192
- timedOut?: boolean;
1193
- unsupported?: boolean;
1194
- unsupportedFeature?: ExecUnsupportedFeature;
1195
- unsupportedReason?: string;
1196
- stdoutTruncated?: boolean;
1197
- stderrTruncated?: boolean;
1198
- sandboxDenied?: boolean;
1199
- sandboxBlockedPaths?: string[];
1200
- errorCode?: ExecErrorCode;
1201
- error?: string;
1202
- }
1203
- export type ExecRunHandlerRequest = ExecRunArgs & {
1204
- path: ExecPathInfo;
1205
- context: ExecRequestContext;
1206
- };
1207
- export interface ExecRunHandler {
1208
- run(request: ExecRunHandlerRequest, options: {
1209
- signal: AbortSignal;
1210
- }): Promise<ExecRunResult>;
1211
- }
1212
- export interface ExecOptions {
1213
- handler: ExecRunHandler;
1214
- maxOutputBytes?: number;
1215
- capabilityId?: string;
1216
- remoteExecutionContextId?: string;
1217
- }
1218
- export type RemoteExtensionScope = 'user' | 'project' | 'connector' | 'plugin';
1219
- export type RemoteExtensionErrorCode = 'EXTENSION_NOT_FOUND' | 'EXTENSION_INVALID' | 'EXTENSION_UNSUPPORTED' | 'EXTENSION_TOO_LARGE' | 'EXTENSION_UNAVAILABLE';
1220
- export declare const REMOTE_EXTENSION_HOOK_EVENTS: readonly ['PreToolUse', 'PostToolUse', 'PostToolUseFailure', 'UserPromptSubmit', 'SessionStart', 'SessionEnd', 'Stop', 'SubagentStart', 'SubagentStop', 'PreCompact', 'PermissionRequest'];
1221
- export type RemoteHookEvent = typeof REMOTE_EXTENSION_HOOK_EVENTS[number];
1222
- export type JsonValue = null | boolean | number | string | JsonValue[] | {
1223
- [key: string]: JsonValue;
1224
- };
1225
- export interface RemoteResourceMetadata {
1226
- path: string;
1227
- kind?: 'text' | 'binary' | 'script' | 'asset';
1228
- size?: number;
1229
- digest?: string;
1230
- }
1231
- export interface RemoteHookMetadata {
1232
- hookRef: string;
1233
- event: RemoteHookEvent;
1234
- type: 'command' | 'prompt' | 'agent' | 'http';
1235
- matcher?: string;
1236
- if?: string;
1237
- once?: boolean;
1238
- timeout?: number;
1239
- scope?: string;
1240
- async?: false;
1241
- asyncRewake?: false;
1242
- }
1243
- interface RemoteExtensionComponentMetadataBase {
1244
- ref: string;
1245
- name: string;
1246
- description: string;
1247
- scope: RemoteExtensionScope;
1248
- /**
1249
- * Host-controlled absolute directory for resources materialized before the
1250
- * CLI starts. The CLI does not scan this directory for discovery.
1251
- */
1252
- baseDirectory?: string;
1253
- plugin?: string;
1254
- hooks?: RemoteHookMetadata[];
1255
- resources?: RemoteResourceMetadata[];
1256
- }
1257
- export interface RemoteSkillMetadata extends RemoteExtensionComponentMetadataBase {
1258
- kind: 'skill';
1259
- disableModelInvocation?: boolean;
1260
- userInvocable?: boolean;
1261
- }
1262
- export interface RemoteCommandMetadata extends RemoteExtensionComponentMetadataBase {
1263
- kind: 'command';
1264
- argumentHint?: string;
1265
- disableModelInvocation?: boolean;
1266
- }
1267
- export interface RemoteAgentMetadata extends RemoteExtensionComponentMetadataBase {
1268
- kind: 'agent';
1269
- }
1270
- export interface RemoteOutputStyleMetadata extends RemoteExtensionComponentMetadataBase {
1271
- kind: 'output_style';
1272
- keepCodingInstructions?: boolean;
1273
- }
1274
- export type RemoteExtensionComponentMetadata = RemoteSkillMetadata | RemoteCommandMetadata | RemoteAgentMetadata | RemoteOutputStyleMetadata;
1275
- export interface RemotePluginMetadata {
1276
- kind: 'plugin';
1277
- ref: string;
1278
- name: string;
1279
- description?: string;
1280
- scope: Exclude<RemoteExtensionScope, 'plugin'>;
1281
- components: RemoteExtensionComponentMetadata[];
1282
- hooks?: RemoteHookMetadata[];
1283
- options?: Record<string, JsonValue>;
1284
- settings?: {
1285
- agent?: string;
1286
- };
1287
- }
1288
- export type RemoteExtensionMetadata = RemoteSkillMetadata | RemoteCommandMetadata | RemoteAgentMetadata | RemotePluginMetadata;
1289
- export type RemoteExtensionContent = {
1290
- kind: 'skill';
1291
- ref: string;
1292
- instructions: string;
1293
- allowedTools?: string[];
1294
- context?: 'fork';
1295
- agent?: string;
1296
- model?: string;
1297
- disableModelInvocation?: boolean;
1298
- userInvocable?: boolean;
1299
- } | {
1300
- kind: 'command';
1301
- ref: string;
1302
- prompt: string;
1303
- allowedTools?: string[];
1304
- argumentHint?: string;
1305
- model?: string;
1306
- disableModelInvocation?: boolean;
1307
- } | {
1308
- kind: 'agent';
1309
- ref: string;
1310
- instructions: string;
1311
- tools?: string[];
1312
- model?: string;
1313
- permissionMode?: string;
1314
- skills?: string[];
1315
- color?: string;
1316
- } | {
1317
- kind: 'output_style';
1318
- ref: string;
1319
- content: string;
1320
- keepCodingInstructions?: boolean;
1321
- } | {
1322
- kind: 'hook_prompt';
1323
- ref: string;
1324
- prompt: string;
1325
- model?: string;
1326
- continueOnBlock?: boolean;
1327
- };
1328
- export interface ExtensionResourceContent {
1329
- encoding: 'utf8' | 'base64';
1330
- content: string;
1331
- }
1332
- export interface RemoteHookInput {
1333
- event: RemoteHookEvent;
1334
- payload: Record<string, JsonValue>;
1335
- }
1336
- export type RemoteHookRawResult = {
1337
- kind: 'command';
1338
- result: ExecRunResult;
1339
- } | {
1340
- kind: 'http';
1341
- status: number;
1342
- body: string;
1343
- } | {
1344
- kind: 'http';
1345
- status: null;
1346
- failure: 'network' | 'timeout' | 'denied';
1347
- errorMessage?: string;
1348
- };
1349
- export interface RemoteExtensionHandler {
1350
- load(ref: string, signal: AbortSignal): Promise<RemoteExtensionContent>;
1351
- readResource(ref: string, path: string, signal: AbortSignal): Promise<ExtensionResourceContent>;
1352
- executeHook(hookRef: string, input: RemoteHookInput, signal: AbortSignal): Promise<RemoteHookRawResult>;
1353
- }
1354
- export interface RemoteExtensionsOptions {
1355
- metadata: RemoteExtensionMetadata[];
1356
- handler: RemoteExtensionHandler;
1357
- }
1358
810
  export interface Options {
1359
811
  /** Controller for cancelling the query */
1360
812
  abortController?: AbortController;
@@ -1439,8 +891,6 @@ export interface Options {
1439
891
  pathToCodebuddyCode?: string;
1440
892
  /** Request timeout for control requests (milliseconds) */
1441
893
  requestTimeoutMs?: number;
1442
- /** Opaque per-query context used by managed remote operation protocols. */
1443
- remoteContext?: RemoteOperationContext;
1444
894
  /** Permission mode */
1445
895
  permissionMode?: PermissionMode;
1446
896
  /** Require explicit flag for bypassPermissions */
@@ -1451,17 +901,6 @@ export interface Options {
1451
901
  resume?: string;
1452
902
  /** Custom session ID for creating new sessions */
1453
903
  sessionId?: string;
1454
- /**
1455
- * 会话存储后端。默认由 CLI 以 mirror 模式运行:本地 JSONL 是真源,
1456
- * 每批条目异步转发到 append();persistSession:false 选择 remote 模式,
1457
- * CLI 不读写本地 history JSONL。mirror 写失败重试耗尽或收尾 flush 超时后合成
1458
- * {type:'system', subtype:'mirror_error'} 帧,查询继续;超时表示远端结果未知。
1459
- * 与 enableFileCheckpointing:true 互斥,因为 file-history 备份 blob 不在
1460
- * SessionStore 协议内。
1461
- */
1462
- sessionStore?: SessionStore;
1463
- /** remote 模式下由宿主绑定的稳定逻辑项目 key。 */
1464
- sessionStoreProjectKey?: string;
1465
904
  /** Resume at specific message ID */
1466
905
  resumeSessionAt?: string;
1467
906
  /** Sandbox settings */
@@ -1492,63 +931,6 @@ export interface Options {
1492
931
  traceId?: string;
1493
932
  /** Parent span ID from upstream caller, used to link CLI trace as child of upstream span. */
1494
933
  parentSpanId?: string;
1495
- /** FileSystem 替换实现:modules='all' 时替换全部已接入 module。 */
1496
- fileSystem?: FileSystemOptions;
1497
- /** Search 替换实现:Glob/Grep 由 SDK host 在权威 workspace 上执行。 */
1498
- search?: SearchOptions;
1499
- /** Host 权威运行环境快照;系统提示词不得再读取控制面进程环境。 */
1500
- environmentSnapshot?: EnvironmentSnapshotOptions;
1501
- /** todo/task 等可变 Agent 状态的 host 权威存储。 */
1502
- agentStateStore?: AgentStateStoreOptions;
1503
- /** Channel 处理器:cbc 下发 channel control-request 时由 SDK 路由到此。 */
1504
- channel?: ChannelOptions;
1505
- /** Exec 替换实现:cbc 下发 exec.run control-request 时由 SDK 路由到此。 */
1506
- exec?: ExecOptions;
1507
- /** Query 级远端扩展清单与按需处理器。处理器留在 SDK 宿主进程。 */
1508
- remoteExtensions?: RemoteExtensionsOptions;
1509
- /**
1510
- * 控制面本地执行拒绝清单。传入即开启:拒绝会在控制面本地 spawn 子进程的
1511
- * 执行消费者(当前 mcpStdio / lsp)。'all' = 全部(含未来新增);数组 = 仅列出者;
1512
- * 未传 / [] = 不拒绝(本地 agent 现状)。用于控制面可能执行在远端的场景。
1513
- */
1514
- localExecutionDeny?: LocalExecutionDeny;
1515
- /**
1516
- * 远程 MCP 委托开关。开启后,cbc 仍负责发现/选择 MCP tool,
1517
- * 但真实 HTTP/SSE 请求由 SDK host 侧的 `mcpTransportFactory` 代发。
1518
- */
1519
- remoteMcp?: RemoteMcpOptions;
1520
- /**
1521
- * 暴露给 cbc 的远程 MCP server 清单。这里故意只放可给模型看的描述信息:
1522
- * serverName / transport / capabilityId / tools 等。
1523
- *
1524
- * 不要在这里放 url、headers、token 或 OAuth refresh 信息。真实 endpoint 和
1525
- * 凭证应由 host 侧按 tenant/user/session/run 维度解析,并在 `mcpTransportFactory`
1526
- * 中创建真实 MCP transport。
1527
- */
1528
- delegatedMcpServers?: McpMessageDelegatedServerDescriptor[];
1529
- /**
1530
- * host 侧提供的委托 transport 工厂。SDK 在 cbc 发起 `mcp_message` 时调用它:
1531
- *
1532
- * - `scopedKey`:由 controlConnectionId / tenantId / userId / sessionId / runId / serverName
1533
- * 拼出,用来索引本次会话可用的 endpoint 和凭证。
1534
- * - `descriptor`:来自 `delegatedMcpServers` 的非敏感描述。
1535
- *
1536
- * agent-sdk-js 不读取 `.env.local`,也不内置 OAuth 或 secret store;AL / Gateway /
1537
- * 业务 host 应在这里完成 endpoint 查找、OAuth token 刷新、secret 注入和审计。
1538
- */
1539
- mcpTransportFactory?: (scopedKey: string, descriptor: {
1540
- transport: 'http' | 'sse' | 'remote';
1541
- capabilityId?: string;
1542
- }) => Promise<import('./mcp/managed-remote-mcp-bridge').RealMcpTransport>;
1543
- /**
1544
- * scoped key 维度:control connection / tenant / user / run。
1545
- * 与 sessionId 一道拼成 `ManagedRemoteMcpBridge` 的 scoped key,避免多 tenant / 多 session /
1546
- * 多 run 之间串 endpoint / token / pending。任一缺失即退化(仍优于裸 serverName)。
1547
- */
1548
- controlConnectionId?: string;
1549
- tenantId?: string;
1550
- userId?: string;
1551
- runId?: string;
1552
934
  }
1553
935
  export interface SessionOptions {
1554
936
  /** Custom session ID for the conversation */
@@ -1571,10 +953,6 @@ export interface SessionOptions {
1571
953
  env?: Record<string, string | undefined>;
1572
954
  /** Request timeout for control requests (milliseconds) */
1573
955
  requestTimeoutMs?: number;
1574
- /** Enable file checkpointing. */
1575
- enableFileCheckpointing?: boolean;
1576
- /** Opaque connection context shared by all remote operations in this Session. */
1577
- remoteContext?: RemoteOperationContext;
1578
956
  /** MCP server configurations (object or file path string) */
1579
957
  mcpServers?: Record<string, McpServerConfig> | string;
1580
958
  /** Strict MCP config validation */
@@ -1662,42 +1040,6 @@ export interface SessionOptions {
1662
1040
  thinking?: ThinkingConfig;
1663
1041
  /** Effort level for model reasoning. */
1664
1042
  effort?: Effort;
1665
- /** 会话存储后端;persistSession:false 选择 remote,否则为 mirror。 */
1666
- sessionStore?: SessionStore;
1667
- /** 是否保留 CLI 本地 Session;与 sessionStore 组合决定 mirror/remote。 */
1668
- persistSession?: boolean;
1669
- /** remote 模式下由宿主绑定的稳定逻辑项目 key。 */
1670
- sessionStoreProjectKey?: string;
1671
- /** FileSystem 替换实现:modules='all' 时替换全部已接入 module。 */
1672
- fileSystem?: FileSystemOptions;
1673
- /** Search 替换实现:同 Options.search。 */
1674
- search?: SearchOptions;
1675
- /** Host 权威运行环境快照:同 Options.environmentSnapshot。 */
1676
- environmentSnapshot?: EnvironmentSnapshotOptions;
1677
- /** Agent 可变状态存储:同 Options.agentStateStore。 */
1678
- agentStateStore?: AgentStateStoreOptions;
1679
- /** Channel 处理器:同 Options.channel,cbc 下发 channel control-request 时由 SDK 路由到此。 */
1680
- channel?: ChannelOptions;
1681
- /** Exec 替换实现:同 Options.exec,cbc 下发 exec.run control-request 时由 SDK 路由到此。 */
1682
- exec?: ExecOptions;
1683
- /** Session 级远端扩展清单与按需处理器。处理器留在 SDK 宿主进程。 */
1684
- remoteExtensions?: RemoteExtensionsOptions;
1685
- /** 控制面本地执行拒绝清单,语义同 Options.localExecutionDeny。 */
1686
- localExecutionDeny?: LocalExecutionDeny;
1687
- /** 同 Options.remoteMcp。 */
1688
- remoteMcp?: RemoteMcpOptions;
1689
- /** 同 Options.delegatedMcpServers;host 声明的委托远程 MCP server 描述符。 */
1690
- delegatedMcpServers?: McpMessageDelegatedServerDescriptor[];
1691
- /** 同 Options.mcpTransportFactory;受管层提供的委托 transport 工厂。 */
1692
- mcpTransportFactory?: (scopedKey: string, descriptor: {
1693
- transport: 'http' | 'sse' | 'remote';
1694
- capabilityId?: string;
1695
- }) => Promise<import('./mcp/managed-remote-mcp-bridge').RealMcpTransport>;
1696
- /** 同 Options 的 scoped key 维度字段。 */
1697
- controlConnectionId?: string;
1698
- tenantId?: string;
1699
- userId?: string;
1700
- runId?: string;
1701
1043
  }
1702
1044
  export interface Session {
1703
1045
  readonly sessionId: string;
@@ -1706,7 +1048,7 @@ export interface Session {
1706
1048
  send(message: string | UserMessage): Promise<void>;
1707
1049
  /** Stream messages from the agent */
1708
1050
  stream(): AsyncGenerator<Message, void>;
1709
- close(): Promise<void>;
1051
+ close(): void;
1710
1052
  [Symbol.asyncDispose](): Promise<void>;
1711
1053
  /**
1712
1054
  * Set the permission mode for the session.
@@ -1827,40 +1169,15 @@ export interface SdkCapabilities {
1827
1169
  elicitation?: {
1828
1170
  form?: boolean;
1829
1171
  };
1830
- /** host 声明的远程 MCP 委托能力。 */
1831
- mcp?: {
1832
- remoteMcpManaged?: true;
1833
- remoteTransports?: Array<'http' | 'sse' | 'remote'>;
1834
- };
1835
- }
1836
- /**
1837
- * host 声明的远程 MCP server 描述符。
1838
- * 不含 url / headers / token / urlRef —— 真实 endpoint/token 只存在于
1839
- * Gateway registry,按 scoped key 索引。
1840
- */
1841
- export interface McpMessageDelegatedServerDescriptor {
1842
- serverName: string;
1843
- transport: 'http' | 'sse' | 'remote';
1844
- description?: string;
1845
- scope?: string;
1846
- capabilityId?: string;
1847
- tools?: Record<string, unknown>;
1848
- builtin_tools?: string[];
1849
- transparent_proxy?: boolean;
1850
1172
  }
1851
1173
  export interface ControlInitializeRequest {
1852
1174
  subtype: 'initialize';
1853
- remoteContext?: RemoteOperationContext;
1854
- remoteExtensions?: {
1855
- metadata: RemoteExtensionMetadata[];
1856
- };
1857
1175
  hooks?: Partial<Record<HookEvent, Array<{
1858
1176
  matcher?: string;
1859
1177
  hookCallbackIds: string[];
1860
1178
  timeout?: number;
1861
1179
  }>>>;
1862
1180
  sdkMcpServers?: string[];
1863
- delegatedMcpServers?: McpMessageDelegatedServerDescriptor[];
1864
1181
  jsonSchema?: Record<string, unknown>;
1865
1182
  systemPrompt?: string;
1866
1183
  appendSystemPrompt?: string;
@@ -1874,17 +1191,9 @@ export interface ControlInitializeRequest {
1874
1191
  /** Whether a prompt will be sent after initialization (used for resume history decision) */
1875
1192
  hasPrompt?: boolean;
1876
1193
  }
1877
- export interface ControlShutdownRequest {
1878
- subtype: 'shutdown';
1879
- session_id?: string;
1880
- reason: 'prompt_input_exit' | 'other';
1881
- }
1882
1194
  export interface ControlInitializeResponse {
1883
1195
  /** The current model ID resolved by CLI */
1884
1196
  currentModelId?: string;
1885
- commands?: SlashCommand[];
1886
- models?: ModelInfo[];
1887
- account?: AccountInfo;
1888
1197
  }
1889
1198
  export interface ControlInterruptRequest {
1890
1199
  subtype: 'interrupt';
@@ -2077,7 +1386,7 @@ export interface ControlLogoutRequest {
2077
1386
  /**
2078
1387
  * Supported subscription channels.
2079
1388
  */
2080
- export type SubscriptionChannel = 'commands' | 'elicitation' | 'session_store';
1389
+ export type SubscriptionChannel = 'commands' | 'elicitation';
2081
1390
  /**
2082
1391
  * Subscribe request - subscribe to a channel for push notifications.
2083
1392
  */
@@ -2099,16 +1408,6 @@ export interface ControlUnsubscribeRequest {
2099
1408
  subtype: 'unsubscribe';
2100
1409
  channel: SubscriptionChannel;
2101
1410
  }
2102
- /**
2103
- * Channel event push: SDK handler receives events from server SSE and pushes them
2104
- * back to cbc via this control-request. cbc's ChannelEventSubtypeHandler forwards
2105
- * them to ChannelEventReceiver subscribers (e.g. RemoteChannelMcpTransport).
2106
- */
2107
- export interface ControlChannelEventRequest {
2108
- subtype: 'channel_event';
2109
- channelId: string;
2110
- event: ChannelEvent;
2111
- }
2112
1411
  /**
2113
1412
  * Unsubscribe response.
2114
1413
  */
@@ -2149,103 +1448,7 @@ export interface CommandsNotificationData {
2149
1448
  }>;
2150
1449
  timestamp: number;
2151
1450
  }
2152
- /**
2153
- * 会话记录的寻址 key(形状对齐 Claude Agent SDK SessionKey)。
2154
- */
2155
- export interface SessionKey {
2156
- /**
2157
- * 工作目录的稳定文件系统安全编码,等于 CLI 的项目目录名
2158
- * (PathUtils.compressPath 产物,如 'Users-me-my-project')。
2159
- */
2160
- projectKey: string;
2161
- /** 主会话 UUID */
2162
- sessionId: string;
2163
- /**
2164
- * 子代理记录时设置,格式 `subagents/agent-<id>`,视为不透明 key 后缀;
2165
- * undefined 指主记录。
2166
- */
2167
- subpath?: string;
2168
- }
2169
- /** JSON wire-safe history item;业务 id 不承担持久化幂等语义。 */
2170
- export interface SessionStoreEntry {
2171
- type: string;
2172
- id?: string;
2173
- [key: string]: unknown;
2174
- }
2175
- export interface SessionStoreEvent {
2176
- eventId: string;
2177
- item: SessionStoreEntry;
2178
- }
2179
- export type SessionStoreMode = 'mirror' | 'remote';
2180
- export type SessionStoreCapability = 'immutable_event_identity' | 'atomic_batch_append' | 'payload_conflict_detection' | 'canonical_payload_v1' | 'subsession_addressing' | 'list_sessions' | 'list_subkeys' | 'delete' | 'deleted_key_fencing';
2181
- export interface ControlSessionStoreRequest {
2182
- subtype: 'session_store';
2183
- op: 'initialize' | 'append' | 'load' | 'listSessions' | 'listSubkeys' | 'delete';
2184
- mode?: 'mirror' | 'remote';
2185
- protocolVersion?: 1;
2186
- requiredCapabilities?: SessionStoreCapability[];
2187
- key?: SessionKey;
2188
- events?: SessionStoreEvent[];
2189
- contextId?: string;
2190
- }
2191
- export type ControlRemoteExtensionRequest = {
2192
- subtype: 'remote_extension';
2193
- op: 'load';
2194
- contextId?: string;
2195
- ref: string;
2196
- } | {
2197
- subtype: 'remote_extension';
2198
- op: 'read_resource';
2199
- contextId?: string;
2200
- ref: string;
2201
- path: string;
2202
- } | {
2203
- subtype: 'remote_extension';
2204
- op: 'execute_hook';
2205
- contextId?: string;
2206
- hookRef: string;
2207
- input: RemoteHookInput;
2208
- };
2209
- export interface SessionStoreInitializeResult {
2210
- protocolVersion: 1;
2211
- capabilities: SessionStoreCapability[];
2212
- projectKey?: string;
2213
- }
2214
- /**
2215
- * 会话存储后端(形状对齐 Claude Agent SDK SessionStore)。
2216
- *
2217
- * mirror 模式下本接口是本地真源的副本;remote 模式下本接口是真源。
2218
- * retention 是适配器的责任。
2219
- */
2220
- export interface SessionStore {
2221
- /** 按完整 key 原子追加,按 eventId 做不可变幂等。 */
2222
- append(key: SessionKey, events: SessionStoreEvent[]): Promise<void>;
2223
- /**
2224
- * CLI 恢复会话时调用;会话未知返回 null。
2225
- * 返回条目须与追加时深度相等(不要求字节相等的序列化)。
2226
- */
2227
- load(key: SessionKey): Promise<SessionStoreEvent[] | null>;
2228
- /** 按 projectKey 列举主会话。 */
2229
- listSessions(projectKey: string): Promise<Array<{
2230
- sessionId: string;
2231
- mtime: number;
2232
- }>>;
2233
- /** 删主 key 必须级联删除子 key,并阻止迟到 append 复活。 */
2234
- delete(key: SessionKey): Promise<void>;
2235
- /** 枚举主会话下的子代理 subpath。 */
2236
- listSubkeys(key: {
2237
- projectKey: string;
2238
- sessionId: string;
2239
- }): Promise<string[]>;
2240
- }
2241
- /**
2242
- * session_store channel 的通知负载:CLI 每批历史落盘成功后 fire-and-forget 下发。
2243
- */
2244
- export interface SessionStoreMirrorNotificationData {
2245
- key: SessionKey;
2246
- events: SessionStoreEvent[];
2247
- }
2248
- export type ControlRequestPayload = ControlInitializeRequest | ControlShutdownRequest | ControlInterruptRequest | ControlSetPermissionModeRequest | ControlSetModelRequest | ControlSetConfigRequest | ControlGetAvailableModesRequest | ControlGetAvailableModelsRequest | ControlSetMaxThinkingTokensRequest | ControlHookCallbackRequest | ControlPermissionRequest | ControlElicitationCreateRequest | ControlMcpMessageRequest | ControlLogoutRequest | ControlSubscribeRequest | ControlUnsubscribeRequest | ControlChannelEventRequest | ControlSessionStoreRequest | ControlRemoteExtensionRequest;
1451
+ export type ControlRequestPayload = ControlInitializeRequest | ControlInterruptRequest | ControlSetPermissionModeRequest | ControlSetModelRequest | ControlSetConfigRequest | ControlGetAvailableModesRequest | ControlGetAvailableModelsRequest | ControlSetMaxThinkingTokensRequest | ControlHookCallbackRequest | ControlPermissionRequest | ControlElicitationCreateRequest | ControlMcpMessageRequest | ControlLogoutRequest | ControlSubscribeRequest | ControlUnsubscribeRequest;
2249
1452
  export interface ControlRequest {
2250
1453
  type: 'control_request';
2251
1454
  request_id: string;
@@ -2260,12 +1463,10 @@ export interface ControlErrorResponse {
2260
1463
  subtype: 'error';
2261
1464
  request_id: string;
2262
1465
  error: string;
2263
- code?: string;
2264
1466
  }
2265
1467
  export interface ControlResponseMessage {
2266
1468
  type: 'control_response';
2267
1469
  response: ControlResponse | ControlErrorResponse;
2268
1470
  }
2269
1471
  export type ControlSignalMessage = ControlRequest | ControlResponseMessage;
2270
- export {};
2271
1472
  //# sourceMappingURL=types.d.ts.map