@downcity/agent 1.1.200 → 1.1.202

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 (228) hide show
  1. package/bin/agent/local/Agent.d.ts +3 -7
  2. package/bin/agent/local/Agent.d.ts.map +1 -1
  3. package/bin/agent/local/Agent.js +14 -19
  4. package/bin/agent/local/Agent.js.map +1 -1
  5. package/bin/agent/local/services/{AgentSessionManager.d.ts → AgentSessions.d.ts} +12 -17
  6. package/bin/agent/local/services/AgentSessions.d.ts.map +1 -0
  7. package/bin/agent/local/services/{AgentSessionManager.js → AgentSessions.js} +11 -26
  8. package/bin/agent/local/services/AgentSessions.js.map +1 -0
  9. package/bin/agent/remote/RemoteAgent.d.ts +2 -9
  10. package/bin/agent/remote/RemoteAgent.d.ts.map +1 -1
  11. package/bin/agent/remote/RemoteAgent.js +40 -22
  12. package/bin/agent/remote/RemoteAgent.js.map +1 -1
  13. package/bin/agent/remote/RemoteSession.d.ts +5 -5
  14. package/bin/agent/remote/RemoteSession.d.ts.map +1 -1
  15. package/bin/agent/remote/RemoteSession.js +5 -3
  16. package/bin/agent/remote/RemoteSession.js.map +1 -1
  17. package/bin/agent/remote/RemoteTransport.d.ts +2 -2
  18. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +2 -2
  19. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +5 -5
  20. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +2 -2
  21. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +2 -2
  22. package/bin/executor/Executor.d.ts +5 -5
  23. package/bin/executor/Executor.d.ts.map +1 -1
  24. package/bin/executor/Executor.js +22 -13
  25. package/bin/executor/Executor.js.map +1 -1
  26. package/bin/executor/SessionRunScope.d.ts +1 -1
  27. package/bin/executor/SessionRunScope.d.ts.map +1 -1
  28. package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts +3 -3
  29. package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts.map +1 -1
  30. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts +4 -5
  31. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
  32. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +56 -16
  33. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
  34. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts +27 -0
  35. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts.map +1 -0
  36. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js +181 -0
  37. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js.map +1 -0
  38. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts +45 -0
  39. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts.map +1 -0
  40. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js +144 -0
  41. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js.map +1 -0
  42. package/bin/executor/composer/context/LocalSessionContextComposer.d.ts +3 -3
  43. package/bin/executor/composer/context/LocalSessionContextComposer.d.ts.map +1 -1
  44. package/bin/executor/composer/context/SessionContextComposer.d.ts +3 -3
  45. package/bin/executor/composer/context/SessionContextComposer.d.ts.map +1 -1
  46. package/bin/executor/composer/history/SessionHistoryComposer.d.ts +2 -2
  47. package/bin/executor/composer/history/SessionHistoryComposer.d.ts.map +1 -1
  48. package/bin/executor/composer/history/SessionHistoryWriter.d.ts +5 -5
  49. package/bin/executor/composer/history/SessionHistoryWriter.d.ts.map +1 -1
  50. package/bin/executor/composer/history/SessionHistoryWriter.js +6 -6
  51. package/bin/executor/composer/history/SessionHistoryWriter.js.map +1 -1
  52. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts +2 -2
  53. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts.map +1 -1
  54. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js +5 -5
  55. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js.map +1 -1
  56. package/bin/executor/core-engine/CoreEngineMessageState.d.ts +5 -5
  57. package/bin/executor/core-engine/CoreEngineMessageState.d.ts.map +1 -1
  58. package/bin/executor/core-engine/CoreEngineMessageState.js.map +1 -1
  59. package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
  60. package/bin/executor/core-engine/CoreEngineSignals.d.ts +4 -4
  61. package/bin/executor/core-engine/CoreEngineSignals.d.ts.map +1 -1
  62. package/bin/executor/core-engine/CoreEngineSignals.js.map +1 -1
  63. package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts +3 -3
  64. package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts.map +1 -1
  65. package/bin/executor/core-engine/CoreEngineUiStreamCollector.js.map +1 -1
  66. package/bin/executor/messages/AssistantResultPersistence.d.ts +5 -5
  67. package/bin/executor/messages/AssistantResultPersistence.d.ts.map +1 -1
  68. package/bin/executor/messages/AssistantResultPersistence.js +1 -1
  69. package/bin/executor/messages/AssistantResultPersistence.js.map +1 -1
  70. package/bin/executor/messages/SessionAttachmentMapper.d.ts +3 -3
  71. package/bin/executor/messages/SessionAttachmentMapper.d.ts.map +1 -1
  72. package/bin/executor/messages/SessionAttachmentMapper.js.map +1 -1
  73. package/bin/executor/messages/SessionMessageCodec.d.ts +4 -4
  74. package/bin/executor/messages/SessionMessageCodec.d.ts.map +1 -1
  75. package/bin/executor/messages/SessionMessageCodec.js +5 -5
  76. package/bin/executor/messages/SessionMessageCodec.js.map +1 -1
  77. package/bin/executor/messages/SessionMessageLog.d.ts +3 -3
  78. package/bin/executor/messages/SessionMessageLog.d.ts.map +1 -1
  79. package/bin/executor/messages/SessionMessageLog.js.map +1 -1
  80. package/bin/executor/messages/SessionStepEventMapper.d.ts +2 -2
  81. package/bin/executor/messages/SessionStepEventMapper.d.ts.map +1 -1
  82. package/bin/executor/messages/SessionStepEventMapper.js.map +1 -1
  83. package/bin/executor/messages/UserVisibleText.d.ts +3 -3
  84. package/bin/executor/messages/UserVisibleText.d.ts.map +1 -1
  85. package/bin/executor/messages/UserVisibleText.js +3 -3
  86. package/bin/executor/messages/UserVisibleText.js.map +1 -1
  87. package/bin/executor/services/ExecutorInflightService.d.ts +2 -2
  88. package/bin/executor/services/ExecutorInflightService.d.ts.map +1 -1
  89. package/bin/executor/services/ExecutorInflightService.js +4 -4
  90. package/bin/executor/services/ExecutorInflightService.js.map +1 -1
  91. package/bin/executor/store/history/SessionHistoryStore.d.ts +24 -21
  92. package/bin/executor/store/history/SessionHistoryStore.d.ts.map +1 -1
  93. package/bin/executor/store/history/SessionHistoryStore.js +3 -3
  94. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +18 -19
  95. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
  96. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +33 -36
  97. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
  98. package/bin/executor/tools/plugin/PluginToolDefinition.d.ts +1 -7
  99. package/bin/executor/tools/plugin/PluginToolDefinition.d.ts.map +1 -1
  100. package/bin/executor/tools/plugin/PluginToolSchemas.d.ts +4 -6
  101. package/bin/executor/tools/plugin/PluginToolSchemas.d.ts.map +1 -1
  102. package/bin/executor/tools/plugin/PluginToolSchemas.js +24 -10
  103. package/bin/executor/tools/plugin/PluginToolSchemas.js.map +1 -1
  104. package/bin/executor/types/{SessionMessages.d.ts → SessionRecords.d.ts} +53 -28
  105. package/bin/executor/types/SessionRecords.d.ts.map +1 -0
  106. package/bin/executor/types/SessionRecords.js +52 -0
  107. package/bin/executor/types/SessionRecords.js.map +1 -0
  108. package/bin/executor/types/SessionRun.d.ts +3 -3
  109. package/bin/executor/types/SessionRun.d.ts.map +1 -1
  110. package/bin/index.d.ts +1 -1
  111. package/bin/index.d.ts.map +1 -1
  112. package/bin/rpc/Client.d.ts +5 -5
  113. package/bin/rpc/Client.js +4 -4
  114. package/bin/session/Session.d.ts +6 -6
  115. package/bin/session/Session.d.ts.map +1 -1
  116. package/bin/session/Session.js +8 -8
  117. package/bin/session/Session.js.map +1 -1
  118. package/bin/session/SessionTitle.d.ts +2 -2
  119. package/bin/session/SessionTitle.d.ts.map +1 -1
  120. package/bin/session/SessionTitle.js +3 -3
  121. package/bin/session/SessionTitle.js.map +1 -1
  122. package/bin/session/browse/Browse.d.ts +12 -12
  123. package/bin/session/browse/Browse.d.ts.map +1 -1
  124. package/bin/session/browse/Browse.js +9 -9
  125. package/bin/session/browse/Browse.js.map +1 -1
  126. package/bin/session/index.d.ts +1 -1
  127. package/bin/session/index.js +1 -1
  128. package/bin/session/runtime/SessionPromptRuntime.d.ts +3 -3
  129. package/bin/session/runtime/SessionPromptRuntime.d.ts.map +1 -1
  130. package/bin/session/services/SessionStateService.d.ts +7 -8
  131. package/bin/session/services/SessionStateService.d.ts.map +1 -1
  132. package/bin/session/services/SessionStateService.js +15 -31
  133. package/bin/session/services/SessionStateService.js.map +1 -1
  134. package/bin/session/services/SessionViewService.d.ts +4 -4
  135. package/bin/session/services/SessionViewService.js +12 -12
  136. package/bin/session/services/SessionViewService.js.map +1 -1
  137. package/bin/session/storage/Persistence.d.ts +4 -4
  138. package/bin/session/storage/Persistence.d.ts.map +1 -1
  139. package/bin/session/storage/RuntimeSessionPort.d.ts +2 -2
  140. package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
  141. package/bin/session/storage/RuntimeSessionPort.js +4 -4
  142. package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
  143. package/bin/types/agent/AgentTypes.d.ts +2 -2
  144. package/bin/types/agent/AgentTypes.d.ts.map +1 -1
  145. package/bin/types/agent/SessionActor.d.ts +11 -11
  146. package/bin/types/agent/SessionActor.d.ts.map +1 -1
  147. package/bin/types/agent/SessionTypes.d.ts +12 -12
  148. package/bin/types/agent/SessionTypes.d.ts.map +1 -1
  149. package/bin/types/executor/SessionRunContext.d.ts +2 -2
  150. package/bin/types/executor/SessionRunContext.d.ts.map +1 -1
  151. package/bin/types/rpc/RpcProtocol.d.ts +6 -6
  152. package/bin/types/runtime/agent/AgentContext.d.ts +7 -7
  153. package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
  154. package/bin/types/sdk/AgentSessionAction.d.ts +8 -49
  155. package/bin/types/sdk/AgentSessionAction.d.ts.map +1 -1
  156. package/bin/types/sdk/AgentSessionAction.js +4 -4
  157. package/bin/types/sdk/AgentSessionTurn.d.ts +2 -2
  158. package/bin/types/sdk/AgentSessionTurn.d.ts.map +1 -1
  159. package/package.json +3 -3
  160. package/scripts/agent-ready.test.mjs +1 -1
  161. package/scripts/city-model-tool-loop.test.mjs +36 -4
  162. package/scripts/plugin-tool-bridge.test.mjs +13 -0
  163. package/scripts/session-action-message.test.mjs +25 -25
  164. package/scripts/session-compaction-prompts.test.mjs +97 -0
  165. package/scripts/session-history-archive.test.mjs +8 -8
  166. package/scripts/session-history-inflight.test.mjs +10 -10
  167. package/scripts/session-list-title.test.mjs +9 -9
  168. package/scripts/session-title-event.test.mjs +12 -10
  169. package/src/agent/local/Agent.ts +16 -22
  170. package/src/agent/local/services/{AgentSessionManager.ts → AgentSessions.ts} +16 -32
  171. package/src/agent/remote/RemoteAgent.ts +58 -23
  172. package/src/agent/remote/RemoteSession.ts +10 -8
  173. package/src/agent/remote/RemoteTransport.ts +5 -5
  174. package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +10 -10
  175. package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +6 -6
  176. package/src/executor/Executor.ts +30 -19
  177. package/src/executor/SessionRunScope.ts +1 -1
  178. package/src/executor/composer/compaction/SessionCompactionComposer.ts +3 -3
  179. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +73 -29
  180. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.ts +197 -0
  181. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.ts +162 -0
  182. package/src/executor/composer/context/LocalSessionContextComposer.ts +5 -5
  183. package/src/executor/composer/context/SessionContextComposer.ts +5 -5
  184. package/src/executor/composer/history/SessionHistoryComposer.ts +2 -2
  185. package/src/executor/composer/history/SessionHistoryWriter.ts +10 -10
  186. package/src/executor/composer/history/jsonl/JsonlSessionHistoryComposer.ts +13 -13
  187. package/src/executor/core-engine/CoreEngineMessageState.ts +8 -8
  188. package/src/executor/core-engine/CoreEngineRunner.ts +7 -7
  189. package/src/executor/core-engine/CoreEngineSignals.ts +7 -7
  190. package/src/executor/core-engine/CoreEngineUiStreamCollector.ts +5 -5
  191. package/src/executor/messages/AssistantResultPersistence.ts +8 -8
  192. package/src/executor/messages/SessionAttachmentMapper.ts +11 -11
  193. package/src/executor/messages/SessionMessageCodec.ts +10 -10
  194. package/src/executor/messages/SessionMessageLog.ts +3 -3
  195. package/src/executor/messages/SessionStepEventMapper.ts +5 -5
  196. package/src/executor/messages/UserVisibleText.ts +9 -9
  197. package/src/executor/services/ExecutorInflightService.ts +7 -7
  198. package/src/executor/store/history/SessionHistoryStore.ts +26 -23
  199. package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +58 -62
  200. package/src/executor/tools/plugin/PluginToolSchemas.ts +24 -10
  201. package/src/executor/types/{SessionMessages.ts → SessionRecords.ts} +71 -40
  202. package/src/executor/types/SessionRun.ts +5 -5
  203. package/src/index.ts +4 -4
  204. package/src/rpc/Client.ts +9 -9
  205. package/src/session/Session.ts +10 -10
  206. package/src/session/SessionTitle.ts +7 -7
  207. package/src/session/browse/Browse.ts +38 -38
  208. package/src/session/index.ts +1 -1
  209. package/src/session/runtime/SessionPromptRuntime.ts +6 -6
  210. package/src/session/services/SessionStateService.ts +29 -44
  211. package/src/session/services/SessionTurnService.ts +4 -4
  212. package/src/session/services/SessionViewService.ts +21 -21
  213. package/src/session/storage/Persistence.ts +6 -6
  214. package/src/session/storage/RuntimeSessionPort.ts +6 -6
  215. package/src/types/agent/AgentTypes.ts +4 -4
  216. package/src/types/agent/SessionActor.ts +12 -12
  217. package/src/types/agent/SessionTypes.ts +12 -12
  218. package/src/types/executor/SessionRunContext.ts +2 -2
  219. package/src/types/rpc/RpcProtocol.ts +6 -6
  220. package/src/types/runtime/agent/AgentContext.ts +8 -8
  221. package/src/types/sdk/AgentSessionAction.ts +12 -56
  222. package/src/types/sdk/AgentSessionTurn.ts +2 -2
  223. package/tsconfig.tsbuildinfo +1 -1
  224. package/bin/agent/local/services/AgentSessionManager.d.ts.map +0 -1
  225. package/bin/agent/local/services/AgentSessionManager.js.map +0 -1
  226. package/bin/executor/types/SessionMessages.d.ts.map +0 -1
  227. package/bin/executor/types/SessionMessages.js +0 -46
  228. package/bin/executor/types/SessionMessages.js.map +0 -1
@@ -9,9 +9,9 @@
9
9
  import { extractTextFromUiMessage } from "@/executor/messages/UIMessageTransformer.js";
10
10
  import type { SessionHistoryMetaV1 } from "@/executor/types/SessionHistoryMeta.js";
11
11
  import type {
12
- SessionMessageV1,
13
- SessionModelMessageV1,
14
- } from "@/executor/types/SessionMessages.js";
12
+ SessionRecordV1,
13
+ SessionMessageRecordV1,
14
+ } from "@/executor/types/SessionRecords.js";
15
15
  import { persistAssistantResult } from "@/executor/messages/AssistantResultPersistence.js";
16
16
  import type { AgentSessionConfigSnapshot } from "@/types/agent/AgentTypes.js";
17
17
  import {
@@ -50,11 +50,11 @@ export interface PersistSdkAssistantResultParams
50
50
  * 追加 assistant 消息的底层执行编排器。
51
51
  */
52
52
  executor: {
53
- appendAssistantMessage(params: {
53
+ append_assistant_message(params: {
54
54
  /**
55
55
  * 已构造好的完整消息。
56
56
  */
57
- message?: SessionMessageV1 | null;
57
+ message?: SessionRecordV1 | null;
58
58
  /**
59
59
  * 兜底文本内容。
60
60
  */
@@ -68,7 +68,7 @@ export interface PersistSdkAssistantResultParams
68
68
  * - stop/abort 且没有 assistant 内容时允许为空。
69
69
  * - 为空时仅刷新 metadata,不写入伪造 assistant 正文。
70
70
  */
71
- assistantMessage?: SessionModelMessageV1 | null;
71
+ assistantMessage?: SessionMessageRecordV1 | null;
72
72
  }
73
73
 
74
74
  /**
@@ -58,11 +58,11 @@ export interface CreateRuntimeSessionPortParams {
58
58
  /**
59
59
  * 追加 user 消息到底层历史。
60
60
  */
61
- appendUserMessage: SessionPort["appendUserMessage"];
61
+ append_user_message: SessionPort["append_user_message"];
62
62
  /**
63
63
  * 追加 assistant 消息到底层历史。
64
64
  */
65
- appendAssistantMessage: SessionPort["appendAssistantMessage"];
65
+ append_assistant_message: SessionPort["append_assistant_message"];
66
66
  /**
67
67
  * 返回当前 session 是否正在执行。
68
68
  */
@@ -111,12 +111,12 @@ export function createRuntimeSessionPort(
111
111
  afterSessionUpdatedAsync: async () => {
112
112
  await params.afterSessionUpdatedAsync();
113
113
  },
114
- appendUserMessage: async (messageParams) => {
115
- await params.appendUserMessage(messageParams);
114
+ append_user_message: async (messageParams) => {
115
+ await params.append_user_message(messageParams);
116
116
  await params.touchMetadata();
117
117
  },
118
- appendAssistantMessage: async (messageParams) => {
119
- await params.appendAssistantMessage(messageParams);
118
+ append_assistant_message: async (messageParams) => {
119
+ await params.append_assistant_message(messageParams);
120
120
  await params.touchMetadata();
121
121
  },
122
122
  isExecuting: () => params.isExecuting(),
@@ -36,9 +36,9 @@ export type {
36
36
  AgentListSessionsInput,
37
37
  AgentSessionConfigSnapshot,
38
38
  AgentSessionForkInput,
39
- AgentSessionHistoryInput,
40
- AgentSessionHistoryPage,
41
- AgentSessionHistoryView,
39
+ AgentSessionRecordsInput,
40
+ AgentSessionRecordsPage,
41
+ AgentSessionRecordsView,
42
42
  AgentSessionInfo,
43
43
  AgentSessionSetInput,
44
44
  AgentSessionSummary,
@@ -53,6 +53,6 @@ export type { AgentSessionStopResult } from "@/types/sdk/AgentSessionStop.js";
53
53
  export type {
54
54
  AgentSession,
55
55
  AgentSessionActor,
56
- AgentSessionCollection,
56
+ AgentSessions,
57
57
  RemoteAgentSession,
58
58
  } from "@/types/agent/SessionActor.js";
@@ -16,8 +16,8 @@ import type {
16
16
  AgentListSessionsInput,
17
17
  AgentSessionConfigSnapshot,
18
18
  AgentSessionForkInput,
19
- AgentSessionHistoryInput,
20
- AgentSessionHistoryPage,
19
+ AgentSessionRecordsInput,
20
+ AgentSessionRecordsPage,
21
21
  AgentSessionInfo,
22
22
  AgentSessionSetInput,
23
23
  AgentSessionSummaryPage,
@@ -32,23 +32,23 @@ import type { AgentSessionStopResult } from "@/types/sdk/AgentSessionStop.js";
32
32
  import type { AgentSessionTurnHandle } from "@/types/sdk/AgentSessionTurn.js";
33
33
 
34
34
  /**
35
- * SDK Session 集合绑定。
35
+ * SDK Session 集合入口。
36
36
  */
37
- export interface AgentSessionCollection {
37
+ export interface AgentSessions<TSession extends AgentSessionActor = AgentSession> {
38
38
  /** 新建一个 session。 */
39
- create_session(input?: AgentCreateSessionInput): Promise<AgentSession>;
39
+ create(input?: AgentCreateSessionInput): Promise<TSession>;
40
40
 
41
41
  /** 获取一个已存在的 session。 */
42
- get_session(sessionId: string): Promise<AgentSession>;
42
+ get(session_id: string): Promise<TSession>;
43
43
 
44
44
  /** 列出当前 agent 的 session 摘要页。 */
45
- list_sessions(input?: AgentListSessionsInput): Promise<AgentSessionSummaryPage>;
45
+ list(input?: AgentListSessionsInput): Promise<AgentSessionSummaryPage>;
46
46
 
47
47
  /** 归档单个 session。 */
48
- archive_session(input: AgentArchiveSessionInput): Promise<AgentArchiveSessionResult>;
48
+ archive(input: AgentArchiveSessionInput): Promise<AgentArchiveSessionResult>;
49
49
 
50
50
  /** 列出已归档的 session 摘要页。 */
51
- archive_sessions(input?: AgentArchiveSessionsInput): Promise<AgentArchiveSessionsResult>;
51
+ archived(input?: AgentArchiveSessionsInput): Promise<AgentArchiveSessionsResult>;
52
52
 
53
53
  /** 永久清空已归档 session。 */
54
54
  clean_archive(): Promise<AgentCleanArchiveResult>;
@@ -62,7 +62,7 @@ export interface AgentSessionActor {
62
62
  readonly id: string;
63
63
 
64
64
  /** 读取当前 session 详情。 */
65
- getInfo(): Promise<AgentSessionInfo>;
65
+ get_info(): Promise<AgentSessionInfo>;
66
66
 
67
67
  /** 追加一条新的 prompt。 */
68
68
  prompt(input: AgentSessionPromptInput): Promise<AgentSessionTurnHandle>;
@@ -73,8 +73,8 @@ export interface AgentSessionActor {
73
73
  /** 订阅当前 session 的未来事件。 */
74
74
  subscribe(subscriber: AgentSessionSubscriber): AgentSessionUnsubscribe;
75
75
 
76
- /** 读取当前 session 历史分页。 */
77
- history(input?: AgentSessionHistoryInput): Promise<AgentSessionHistoryPage>;
76
+ /** 读取当前 session records 分页。 */
77
+ records(input?: AgentSessionRecordsInput): Promise<AgentSessionRecordsPage>;
78
78
 
79
79
  /** 读取当前 session 生效的 system 快照。 */
80
80
  system(): Promise<AgentSessionSystemSnapshot>;
@@ -8,7 +8,7 @@
8
8
 
9
9
  import type { LanguageModel } from "ai";
10
10
  import type { AgentModel } from "@/model/CityModelAdapter.js";
11
- import type { SessionMessageV1 } from "@/executor/types/SessionMessages.js";
11
+ import type { SessionRecordV1 } from "@/executor/types/SessionRecords.js";
12
12
 
13
13
  /**
14
14
  * 新建 session 的输入参数。
@@ -83,9 +83,9 @@ export interface AgentSessionConfigSnapshot {
83
83
  }
84
84
 
85
85
  /**
86
- * Session 历史视图类型。
86
+ * Session records视图类型。
87
87
  */
88
- export type AgentSessionHistoryView = "message" | "timeline";
88
+ export type AgentSessionRecordsView = "message" | "timeline";
89
89
 
90
90
  /**
91
91
  * Session 时间线事件。
@@ -286,9 +286,9 @@ export interface AgentSessionSummaryPage {
286
286
  }
287
287
 
288
288
  /**
289
- * Session 历史读取输入。
289
+ * Session records 读取输入。
290
290
  */
291
- export interface AgentSessionHistoryInput {
291
+ export interface AgentSessionRecordsInput {
292
292
  /** 当前页返回上限。 */
293
293
  limit?: number;
294
294
  /** 分页游标。 */
@@ -316,25 +316,25 @@ export interface AgentSessionHistoryInput {
316
316
  * - `message`:原始 session 消息
317
317
  * - `timeline`:适合直接渲染 UI 的平铺事件
318
318
  */
319
- view?: AgentSessionHistoryView;
319
+ view?: AgentSessionRecordsView;
320
320
  }
321
321
 
322
322
  /**
323
- * Session 历史分页结果。
323
+ * Session records 分页结果。
324
324
  */
325
- export interface AgentSessionHistoryPage {
325
+ export interface AgentSessionRecordsPage {
326
326
  /** 当前读取所对应的 session 信息。 */
327
327
  session: AgentSessionInfo;
328
328
  /** 当前页实际返回视图。 */
329
- view: AgentSessionHistoryView;
329
+ view: AgentSessionRecordsView;
330
330
  /**
331
331
  * 当前页数据列表。
332
332
  *
333
333
  * 说明(中文)
334
- * - `view=message` 时返回 `SessionMessageV1[]`
334
+ * - `view=message` 时返回 `SessionRecordV1[]`
335
335
  * - `view=timeline` 时返回 `AgentSessionTimelineEvent[]`
336
336
  */
337
- items: SessionMessageV1[] | AgentSessionTimelineEvent[];
337
+ items: SessionRecordV1[] | AgentSessionTimelineEvent[];
338
338
  /**
339
339
  * 过滤前后的总条数。
340
340
  *
@@ -360,7 +360,7 @@ export interface AgentSessionHistoryPage {
360
360
  *
361
361
  * 关键点(中文)
362
362
  * - compact summary 不会出现在 `items` 中。
363
- * - 若当前层包含 compact summary,则这里暴露其 archive ID,供调用方继续 `session.history({ archive_id })`。
363
+ * - 若当前层包含 compact summary,则这里暴露其 archive ID,供调用方继续 `session.records({ archive_id })`。
364
364
  */
365
365
  previous_archive_id?: string;
366
366
  }
@@ -16,7 +16,7 @@ import type {
16
16
  SessionAssistantStepCallback,
17
17
  SessionUiMessageChunkCallback,
18
18
  } from "@/executor/types/SessionRun.js";
19
- import type { SessionUserMessageV1 } from "@/executor/types/SessionMessages.js";
19
+ import type { SessionUserMessageV1 } from "@/executor/types/SessionRecords.js";
20
20
  import type { FileUIPart } from "ai";
21
21
 
22
22
  /**
@@ -75,7 +75,7 @@ export interface SessionRunContext {
75
75
  * action 发布回调。
76
76
  *
77
77
  * 关键点(中文)
78
- * - 用于把 compaction 等辅助动作转成 session event 与 action message
78
+ * - 用于把 compaction 等辅助动作转成 session event 与 action record
79
79
  * - action 不代表 assistant 正文,也不会进入 LLM 输入。
80
80
  */
81
81
  onActionCallback?: AgentSessionActionCallback;
@@ -15,7 +15,7 @@ import type {
15
15
  AgentArchiveSessionResult,
16
16
  AgentArchiveSessionsResult,
17
17
  AgentCleanArchiveResult,
18
- AgentSessionHistoryInput,
18
+ AgentSessionRecordsInput,
19
19
  AgentSessionStopResult,
20
20
  AgentSessionSystemSnapshot,
21
21
  } from "@/types/agent/AgentTypes.js";
@@ -112,14 +112,14 @@ export type RpcRequest =
112
112
  | {
113
113
  /** 请求 id,用于匹配响应。 */
114
114
  id: string;
115
- /** 读取 session history。 */
116
- method: "sdk.sessions.history";
117
- /** history 查询参数。 */
115
+ /** 读取 session records。 */
116
+ method: "sdk.sessions.records";
117
+ /** records 查询参数。 */
118
118
  params: {
119
119
  /** 目标 session id。 */
120
120
  sessionId: string;
121
- /** history 分页与视图参数。 */
122
- input?: AgentSessionHistoryInput;
121
+ /** records 分页与视图参数。 */
122
+ input?: AgentSessionRecordsInput;
123
123
  };
124
124
  }
125
125
  | {
@@ -19,8 +19,8 @@ import type { AgentPlugins } from "@/plugin/types/Plugin.js";
19
19
  import type { Plugin } from "@/types/plugin/PluginDefinition.js";
20
20
  import type {
21
21
  SessionMetadataV1,
22
- SessionMessageV1,
23
- } from "@/executor/types/SessionMessages.js";
22
+ SessionRecordV1,
23
+ } from "@/executor/types/SessionRecords.js";
24
24
  import type {
25
25
  SessionRunInput,
26
26
  SessionRunResult,
@@ -133,7 +133,7 @@ export interface SessionPort {
133
133
  *
134
134
  * 关键点(中文)
135
135
  * - 只广播订阅之后产生的事件。
136
- * - 历史消息仍通过 `getHistoryStore()` / SDK `history()` 读取。
136
+ * - session records 仍通过 `getHistoryStore()` / SDK `records()` 读取。
137
137
  */
138
138
  subscribe(subscriber: AgentSessionSubscriber): AgentSessionUnsubscribe;
139
139
  /**
@@ -141,7 +141,7 @@ export interface SessionPort {
141
141
  *
142
142
  * 关键点(中文)
143
143
  * - plugin runtime 用它把审批、外部进度等非模型 chunk 事件推送给订阅方。
144
- * - 历史消息持久化仍由 appendUserMessage / appendAssistantMessage 负责。
144
+ * - 历史消息持久化仍由 append_user_message / append_assistant_message 负责。
145
145
  */
146
146
  publishEvent(event: AgentSessionEvent): void;
147
147
  /**
@@ -155,11 +155,11 @@ export interface SessionPort {
155
155
  /**
156
156
  * 追加一条 user 消息。
157
157
  */
158
- appendUserMessage(params: {
158
+ append_user_message(params: {
159
159
  /**
160
160
  * 已构造好的完整消息。
161
161
  */
162
- message?: SessionMessageV1 | null;
162
+ message?: SessionRecordV1 | null;
163
163
  /**
164
164
  * 兜底文本内容。
165
165
  */
@@ -172,11 +172,11 @@ export interface SessionPort {
172
172
  /**
173
173
  * 追加一条 assistant 消息。
174
174
  */
175
- appendAssistantMessage(params: {
175
+ append_assistant_message(params: {
176
176
  /**
177
177
  * 已构造好的完整消息。
178
178
  */
179
- message?: SessionMessageV1 | null;
179
+ message?: SessionRecordV1 | null;
180
180
  /**
181
181
  * 兜底文本内容。
182
182
  */
@@ -1,75 +1,31 @@
1
1
  /**
2
- * Agent Session action 类型定义。
2
+ * Agent Session action 公开类型。
3
3
  *
4
4
  * 关键点(中文)
5
- * - action 描述 session 内部正在发生的辅助动作,不代表 assistant 正文。
6
- * - action 同时用于 `session.subscribe()` 实时事件与 JSONL history item。
7
- * - action 只服务前端状态展示与历史回放,不进入 LLM 输入。
5
+ * - action session records 中的 `type: "action"` 记录。
6
+ * - 同一份结构同时用于 JSONL 持久化与 `session.subscribe()` 实时事件。
7
+ * - action 不进入 LLM 输入;组装模型消息前必须过滤。
8
8
  */
9
9
 
10
+ import type {
11
+ SessionActionRecordV1,
12
+ SessionActionStateV1,
13
+ } from "@/executor/types/SessionRecords.js";
14
+
10
15
  /**
11
16
  * Session action 当前状态。
12
17
  */
13
- export type AgentSessionActionState = "running" | "completed" | "failed";
18
+ export type AgentSessionActionState = SessionActionStateV1;
14
19
 
15
20
  /**
16
21
  * Session action 记录。
17
22
  */
18
- export interface AgentSessionActionRecord {
19
- /**
20
- * 同一个 action 生命周期内稳定复用的 ID。
21
- *
22
- * 说明(中文)
23
- * - 这是 history item envelope 字段,用于把同一个动作更新为一条记录。
24
- * - 前端展示语义只依赖 `type/title/description/state`。
25
- */
26
- id: string;
27
-
28
- /**
29
- * 当前 action 标题。
30
- */
31
- title: string;
32
-
33
- /**
34
- * 当前 action 描述。
35
- */
36
- description?: string;
37
-
38
- /**
39
- * 当前 action 状态。
40
- */
41
- state: AgentSessionActionState;
42
-
43
- /**
44
- * 当前 action 关联的 turn 标识。
45
- */
46
- turnId?: string;
47
-
48
- /**
49
- * 是否建议前端展示。
50
- *
51
- * 说明(中文)
52
- * - 默认视为 `true`。
53
- * - 调试或审计类辅助事件可显式写入 `false`。
54
- */
55
- visible?: boolean;
56
- }
23
+ export type AgentSessionActionRecord = SessionActionRecordV1;
57
24
 
58
25
  /**
59
26
  * Session action 订阅事件。
60
27
  */
61
- export interface AgentSessionActionEvent
62
- extends Omit<AgentSessionActionRecord, "visible"> {
63
- /**
64
- * 当前事件类型。
65
- */
66
- type: "action";
67
-
68
- /**
69
- * 当前 session 唯一标识。
70
- */
71
- sessionId: string;
72
- }
28
+ export type AgentSessionActionEvent = SessionActionRecordV1;
73
29
 
74
30
  /**
75
31
  * Session action 发布回调。
@@ -7,7 +7,7 @@
7
7
  * - 增量过程继续通过 `session.subscribe()` 观察;turn handle 只负责等待最终完成结果。
8
8
  */
9
9
 
10
- import type { SessionModelMessageV1 } from "@/executor/types/SessionMessages.js";
10
+ import type { SessionMessageRecordV1 } from "@/executor/types/SessionRecords.js";
11
11
 
12
12
  /**
13
13
  * 单个 Session turn 的最终结果。
@@ -35,7 +35,7 @@ export interface AgentSessionTurnResult {
35
35
  * - `turn.finished` 返回的结果以这条消息作为最终事实源。
36
36
  * - transport / runtime service 若需要读取最终结构化输出,应优先消费这里。
37
37
  */
38
- assistantMessage?: SessionModelMessageV1;
38
+ assistantMessage?: SessionMessageRecordV1;
39
39
 
40
40
  /**
41
41
  * 当前 turn 失败时的错误文本。