@downcity/agent 1.1.199 → 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 (247) 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 +7 -7
  23. package/bin/executor/Executor.d.ts.map +1 -1
  24. package/bin/executor/Executor.js +41 -33
  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 +5 -5
  29. package/bin/executor/composer/compaction/SessionCompactionComposer.d.ts.map +1 -1
  30. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.js +1 -1
  31. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.js.map +1 -1
  32. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts +4 -5
  33. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
  34. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +73 -40
  35. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
  36. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts +27 -0
  37. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.d.ts.map +1 -0
  38. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js +181 -0
  39. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js.map +1 -0
  40. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts +45 -0
  41. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.d.ts.map +1 -0
  42. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js +144 -0
  43. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js.map +1 -0
  44. package/bin/executor/composer/context/LocalSessionContextComposer.d.ts +3 -3
  45. package/bin/executor/composer/context/LocalSessionContextComposer.d.ts.map +1 -1
  46. package/bin/executor/composer/context/SessionContextComposer.d.ts +3 -3
  47. package/bin/executor/composer/context/SessionContextComposer.d.ts.map +1 -1
  48. package/bin/executor/composer/history/SessionHistoryComposer.d.ts +2 -2
  49. package/bin/executor/composer/history/SessionHistoryComposer.d.ts.map +1 -1
  50. package/bin/executor/composer/history/SessionHistoryWriter.d.ts +5 -5
  51. package/bin/executor/composer/history/SessionHistoryWriter.d.ts.map +1 -1
  52. package/bin/executor/composer/history/SessionHistoryWriter.js +6 -6
  53. package/bin/executor/composer/history/SessionHistoryWriter.js.map +1 -1
  54. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts +2 -2
  55. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.d.ts.map +1 -1
  56. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js +5 -4
  57. package/bin/executor/composer/history/jsonl/JsonlSessionHistoryComposer.js.map +1 -1
  58. package/bin/executor/core-engine/CoreEngineMessageState.d.ts +5 -5
  59. package/bin/executor/core-engine/CoreEngineMessageState.d.ts.map +1 -1
  60. package/bin/executor/core-engine/CoreEngineMessageState.js.map +1 -1
  61. package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
  62. package/bin/executor/core-engine/CoreEngineSignals.d.ts +4 -4
  63. package/bin/executor/core-engine/CoreEngineSignals.d.ts.map +1 -1
  64. package/bin/executor/core-engine/CoreEngineSignals.js.map +1 -1
  65. package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts +3 -3
  66. package/bin/executor/core-engine/CoreEngineUiStreamCollector.d.ts.map +1 -1
  67. package/bin/executor/core-engine/CoreEngineUiStreamCollector.js.map +1 -1
  68. package/bin/executor/messages/AssistantResultPersistence.d.ts +5 -5
  69. package/bin/executor/messages/AssistantResultPersistence.d.ts.map +1 -1
  70. package/bin/executor/messages/AssistantResultPersistence.js +1 -1
  71. package/bin/executor/messages/AssistantResultPersistence.js.map +1 -1
  72. package/bin/executor/messages/SessionAttachmentMapper.d.ts +3 -3
  73. package/bin/executor/messages/SessionAttachmentMapper.d.ts.map +1 -1
  74. package/bin/executor/messages/SessionAttachmentMapper.js.map +1 -1
  75. package/bin/executor/messages/SessionMessageCodec.d.ts +4 -4
  76. package/bin/executor/messages/SessionMessageCodec.d.ts.map +1 -1
  77. package/bin/executor/messages/SessionMessageCodec.js +5 -5
  78. package/bin/executor/messages/SessionMessageCodec.js.map +1 -1
  79. package/bin/executor/messages/SessionMessageLog.d.ts +3 -3
  80. package/bin/executor/messages/SessionMessageLog.d.ts.map +1 -1
  81. package/bin/executor/messages/SessionMessageLog.js.map +1 -1
  82. package/bin/executor/messages/SessionStepEventMapper.d.ts +2 -2
  83. package/bin/executor/messages/SessionStepEventMapper.d.ts.map +1 -1
  84. package/bin/executor/messages/SessionStepEventMapper.js.map +1 -1
  85. package/bin/executor/messages/UserVisibleText.d.ts +3 -3
  86. package/bin/executor/messages/UserVisibleText.d.ts.map +1 -1
  87. package/bin/executor/messages/UserVisibleText.js +3 -3
  88. package/bin/executor/messages/UserVisibleText.js.map +1 -1
  89. package/bin/executor/services/ExecutorInflightService.d.ts +2 -2
  90. package/bin/executor/services/ExecutorInflightService.d.ts.map +1 -1
  91. package/bin/executor/services/ExecutorInflightService.js +11 -7
  92. package/bin/executor/services/ExecutorInflightService.js.map +1 -1
  93. package/bin/executor/store/history/SessionHistoryStore.d.ts +30 -27
  94. package/bin/executor/store/history/SessionHistoryStore.d.ts.map +1 -1
  95. package/bin/executor/store/history/SessionHistoryStore.js +3 -3
  96. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +21 -20
  97. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
  98. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +114 -72
  99. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
  100. package/bin/executor/tools/plugin/PluginToolDefinition.d.ts +1 -7
  101. package/bin/executor/tools/plugin/PluginToolDefinition.d.ts.map +1 -1
  102. package/bin/executor/tools/plugin/PluginToolSchemas.d.ts +4 -6
  103. package/bin/executor/tools/plugin/PluginToolSchemas.d.ts.map +1 -1
  104. package/bin/executor/tools/plugin/PluginToolSchemas.js +24 -10
  105. package/bin/executor/tools/plugin/PluginToolSchemas.js.map +1 -1
  106. package/bin/executor/types/SessionRecords.d.ts +162 -0
  107. package/bin/executor/types/SessionRecords.d.ts.map +1 -0
  108. package/bin/executor/types/SessionRecords.js +52 -0
  109. package/bin/executor/types/SessionRecords.js.map +1 -0
  110. package/bin/executor/types/SessionRun.d.ts +3 -3
  111. package/bin/executor/types/SessionRun.d.ts.map +1 -1
  112. package/bin/index.d.ts +2 -2
  113. package/bin/index.d.ts.map +1 -1
  114. package/bin/index.js.map +1 -1
  115. package/bin/rpc/Client.d.ts +5 -5
  116. package/bin/rpc/Client.js +4 -4
  117. package/bin/session/Session.d.ts +6 -6
  118. package/bin/session/Session.d.ts.map +1 -1
  119. package/bin/session/Session.js +8 -8
  120. package/bin/session/Session.js.map +1 -1
  121. package/bin/session/SessionTitle.d.ts +2 -2
  122. package/bin/session/SessionTitle.d.ts.map +1 -1
  123. package/bin/session/SessionTitle.js +5 -0
  124. package/bin/session/SessionTitle.js.map +1 -1
  125. package/bin/session/browse/Browse.d.ts +12 -12
  126. package/bin/session/browse/Browse.d.ts.map +1 -1
  127. package/bin/session/browse/Browse.js +37 -34
  128. package/bin/session/browse/Browse.js.map +1 -1
  129. package/bin/session/index.d.ts +1 -1
  130. package/bin/session/index.js +1 -1
  131. package/bin/session/runtime/SessionPromptRuntime.d.ts +3 -3
  132. package/bin/session/runtime/SessionPromptRuntime.d.ts.map +1 -1
  133. package/bin/session/services/SessionStateService.d.ts +11 -12
  134. package/bin/session/services/SessionStateService.d.ts.map +1 -1
  135. package/bin/session/services/SessionStateService.js +43 -69
  136. package/bin/session/services/SessionStateService.js.map +1 -1
  137. package/bin/session/services/SessionTurnService.js +3 -3
  138. package/bin/session/services/SessionTurnService.js.map +1 -1
  139. package/bin/session/services/SessionViewService.d.ts +4 -4
  140. package/bin/session/services/SessionViewService.d.ts.map +1 -1
  141. package/bin/session/services/SessionViewService.js +26 -36
  142. package/bin/session/services/SessionViewService.js.map +1 -1
  143. package/bin/session/storage/Persistence.d.ts +4 -4
  144. package/bin/session/storage/Persistence.d.ts.map +1 -1
  145. package/bin/session/storage/RuntimeSessionPort.d.ts +2 -2
  146. package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
  147. package/bin/session/storage/RuntimeSessionPort.js +4 -4
  148. package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
  149. package/bin/types/agent/AgentTypes.d.ts +2 -2
  150. package/bin/types/agent/AgentTypes.d.ts.map +1 -1
  151. package/bin/types/agent/SessionActor.d.ts +11 -11
  152. package/bin/types/agent/SessionActor.d.ts.map +1 -1
  153. package/bin/types/agent/SessionTypes.d.ts +22 -22
  154. package/bin/types/agent/SessionTypes.d.ts.map +1 -1
  155. package/bin/types/executor/SessionRunContext.d.ts +7 -7
  156. package/bin/types/executor/SessionRunContext.d.ts.map +1 -1
  157. package/bin/types/rpc/RpcProtocol.d.ts +6 -6
  158. package/bin/types/runtime/agent/AgentContext.d.ts +7 -7
  159. package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
  160. package/bin/types/sdk/AgentSessionAction.d.ts +26 -0
  161. package/bin/types/sdk/AgentSessionAction.d.ts.map +1 -0
  162. package/bin/types/sdk/AgentSessionAction.js +10 -0
  163. package/bin/types/sdk/AgentSessionAction.js.map +1 -0
  164. package/bin/types/sdk/AgentSessionEvent.d.ts +2 -2
  165. package/bin/types/sdk/AgentSessionEvent.d.ts.map +1 -1
  166. package/bin/types/sdk/AgentSessionTurn.d.ts +2 -2
  167. package/bin/types/sdk/AgentSessionTurn.d.ts.map +1 -1
  168. package/package.json +3 -3
  169. package/scripts/agent-ready.test.mjs +1 -1
  170. package/scripts/city-model-tool-loop.test.mjs +36 -4
  171. package/scripts/plugin-tool-bridge.test.mjs +13 -0
  172. package/scripts/session-action-message.test.mjs +199 -0
  173. package/scripts/session-compaction-prompts.test.mjs +97 -0
  174. package/scripts/session-history-archive.test.mjs +8 -8
  175. package/scripts/session-history-inflight.test.mjs +10 -10
  176. package/scripts/session-list-title.test.mjs +9 -9
  177. package/scripts/session-title-event.test.mjs +12 -10
  178. package/src/agent/local/Agent.ts +16 -22
  179. package/src/agent/local/services/{AgentSessionManager.ts → AgentSessions.ts} +16 -32
  180. package/src/agent/remote/RemoteAgent.ts +58 -23
  181. package/src/agent/remote/RemoteSession.ts +10 -8
  182. package/src/agent/remote/RemoteTransport.ts +5 -5
  183. package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +10 -10
  184. package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +6 -6
  185. package/src/executor/Executor.ts +51 -41
  186. package/src/executor/SessionRunScope.ts +1 -1
  187. package/src/executor/composer/compaction/SessionCompactionComposer.ts +5 -5
  188. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionComposer.ts +1 -1
  189. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +91 -52
  190. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.ts +197 -0
  191. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.ts +162 -0
  192. package/src/executor/composer/context/LocalSessionContextComposer.ts +5 -5
  193. package/src/executor/composer/context/SessionContextComposer.ts +5 -5
  194. package/src/executor/composer/history/SessionHistoryComposer.ts +2 -2
  195. package/src/executor/composer/history/SessionHistoryWriter.ts +10 -10
  196. package/src/executor/composer/history/jsonl/JsonlSessionHistoryComposer.ts +13 -10
  197. package/src/executor/core-engine/CoreEngineMessageState.ts +8 -8
  198. package/src/executor/core-engine/CoreEngineRunner.ts +7 -7
  199. package/src/executor/core-engine/CoreEngineSignals.ts +7 -7
  200. package/src/executor/core-engine/CoreEngineUiStreamCollector.ts +5 -5
  201. package/src/executor/messages/AssistantResultPersistence.ts +8 -8
  202. package/src/executor/messages/SessionAttachmentMapper.ts +11 -11
  203. package/src/executor/messages/SessionMessageCodec.ts +10 -10
  204. package/src/executor/messages/SessionMessageLog.ts +3 -3
  205. package/src/executor/messages/SessionStepEventMapper.ts +5 -5
  206. package/src/executor/messages/UserVisibleText.ts +9 -9
  207. package/src/executor/services/ExecutorInflightService.ts +13 -9
  208. package/src/executor/store/history/SessionHistoryStore.ts +32 -28
  209. package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +146 -95
  210. package/src/executor/tools/plugin/PluginToolSchemas.ts +24 -10
  211. package/src/executor/types/SessionRecords.ts +217 -0
  212. package/src/executor/types/SessionRun.ts +5 -5
  213. package/src/index.ts +9 -10
  214. package/src/rpc/Client.ts +9 -9
  215. package/src/session/Session.ts +10 -10
  216. package/src/session/SessionTitle.ts +7 -4
  217. package/src/session/browse/Browse.ts +66 -58
  218. package/src/session/index.ts +1 -1
  219. package/src/session/runtime/SessionPromptRuntime.ts +6 -6
  220. package/src/session/services/SessionStateService.ts +61 -86
  221. package/src/session/services/SessionTurnService.ts +7 -7
  222. package/src/session/services/SessionViewService.ts +35 -45
  223. package/src/session/storage/Persistence.ts +6 -6
  224. package/src/session/storage/RuntimeSessionPort.ts +6 -6
  225. package/src/types/agent/AgentTypes.ts +4 -4
  226. package/src/types/agent/SessionActor.ts +12 -12
  227. package/src/types/agent/SessionTypes.ts +22 -22
  228. package/src/types/executor/SessionRunContext.ts +12 -12
  229. package/src/types/rpc/RpcProtocol.ts +6 -6
  230. package/src/types/runtime/agent/AgentContext.ts +8 -8
  231. package/src/types/sdk/AgentSessionAction.ts +35 -0
  232. package/src/types/sdk/AgentSessionEvent.ts +2 -2
  233. package/src/types/sdk/AgentSessionTurn.ts +2 -2
  234. package/tsconfig.tsbuildinfo +1 -1
  235. package/bin/agent/local/services/AgentSessionManager.d.ts.map +0 -1
  236. package/bin/agent/local/services/AgentSessionManager.js.map +0 -1
  237. package/bin/executor/types/SessionMessages.d.ts +0 -118
  238. package/bin/executor/types/SessionMessages.d.ts.map +0 -1
  239. package/bin/executor/types/SessionMessages.js +0 -28
  240. package/bin/executor/types/SessionMessages.js.map +0 -1
  241. package/bin/types/sdk/AgentSessionOperation.d.ts +0 -99
  242. package/bin/types/sdk/AgentSessionOperation.d.ts.map +0 -1
  243. package/bin/types/sdk/AgentSessionOperation.js +0 -10
  244. package/bin/types/sdk/AgentSessionOperation.js.map +0 -1
  245. package/scripts/session-operation-message.test.mjs +0 -197
  246. package/src/executor/types/SessionMessages.ts +0 -148
  247. package/src/types/sdk/AgentSessionOperation.ts +0 -125
@@ -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 时间线事件。
@@ -99,7 +99,7 @@ export interface AgentSessionTimelineEvent {
99
99
  * 说明(中文)
100
100
  * - `tool-call` / `tool-result` 用于把 assistant 内部工具过程平铺给 UI。
101
101
  */
102
- role: "user" | "assistant" | "tool-call" | "tool-result" | "operation";
102
+ role: "user" | "assistant" | "tool-call" | "tool-result" | "action";
103
103
  /** 事件时间戳(毫秒)。 */
104
104
  ts?: number;
105
105
  /** 事件所属消息种类。 */
@@ -116,26 +116,26 @@ export interface AgentSessionTimelineEvent {
116
116
  */
117
117
  toolName?: string;
118
118
  /**
119
- * 当前 operation ID。
119
+ * 当前 action 标题。
120
120
  *
121
121
  * 说明(中文)
122
- * - 仅 `role=operation` 的事件通常会携带该字段。
122
+ * - 仅 `role=action` 的事件通常会携带该字段。
123
123
  */
124
- operationId?: string;
124
+ actionTitle?: string;
125
125
  /**
126
- * 当前 operation 名称。
126
+ * 当前 action 描述。
127
127
  *
128
128
  * 说明(中文)
129
- * - 仅 `role=operation` 的事件通常会携带该字段。
129
+ * - 仅 `role=action` 的事件通常会携带该字段。
130
130
  */
131
- operationName?: string;
131
+ actionDescription?: string;
132
132
  /**
133
- * 当前 operation 状态。
133
+ * 当前 action 状态。
134
134
  *
135
135
  * 说明(中文)
136
- * - 仅 `role=operation` 的事件通常会携带该字段。
136
+ * - 仅 `role=action` 的事件通常会携带该字段。
137
137
  */
138
- operationStatus?: string;
138
+ actionState?: string;
139
139
  }
140
140
 
141
141
  /**
@@ -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
  }
@@ -8,15 +8,15 @@
8
8
  */
9
9
 
10
10
  import type {
11
- AgentSessionOperationCallback,
12
- AgentSessionOperationEvent,
13
- AgentSessionOperationRecord,
14
- } from "@/types/sdk/AgentSessionOperation.js";
11
+ AgentSessionActionCallback,
12
+ AgentSessionActionEvent,
13
+ AgentSessionActionRecord,
14
+ } from "@/types/sdk/AgentSessionAction.js";
15
15
  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
  /**
@@ -72,13 +72,13 @@ export interface SessionRunContext {
72
72
  onUiMessageChunkCallback?: SessionUiMessageChunkCallback;
73
73
 
74
74
  /**
75
- * operation 发布回调。
75
+ * action 发布回调。
76
76
  *
77
77
  * 关键点(中文)
78
- * - 用于把 compaction 等辅助操作转成 session event 与 operation message
79
- * - operation 不代表 assistant 正文,也不会进入 LLM 输入。
78
+ * - 用于把 compaction 等辅助动作转成 session event 与 action record
79
+ * - action 不代表 assistant 正文,也不会进入 LLM 输入。
80
80
  */
81
- onOperationCallback?: AgentSessionOperationCallback;
81
+ onActionCallback?: AgentSessionActionCallback;
82
82
 
83
83
  /**
84
84
  * 当前 turn 的取消信号。
@@ -117,7 +117,7 @@ export interface SessionRunContext {
117
117
  }
118
118
 
119
119
  export type {
120
- AgentSessionOperationCallback,
121
- AgentSessionOperationEvent,
122
- AgentSessionOperationRecord,
120
+ AgentSessionActionCallback,
121
+ AgentSessionActionEvent,
122
+ AgentSessionActionRecord,
123
123
  };
@@ -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
  */
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Agent Session action 公开类型。
3
+ *
4
+ * 关键点(中文)
5
+ * - action 是 session records 中的 `type: "action"` 记录。
6
+ * - 同一份结构同时用于 JSONL 持久化与 `session.subscribe()` 实时事件。
7
+ * - action 不进入 LLM 输入;组装模型消息前必须过滤。
8
+ */
9
+
10
+ import type {
11
+ SessionActionRecordV1,
12
+ SessionActionStateV1,
13
+ } from "@/executor/types/SessionRecords.js";
14
+
15
+ /**
16
+ * Session action 当前状态。
17
+ */
18
+ export type AgentSessionActionState = SessionActionStateV1;
19
+
20
+ /**
21
+ * Session action 记录。
22
+ */
23
+ export type AgentSessionActionRecord = SessionActionRecordV1;
24
+
25
+ /**
26
+ * Session action 订阅事件。
27
+ */
28
+ export type AgentSessionActionEvent = SessionActionRecordV1;
29
+
30
+ /**
31
+ * Session action 发布回调。
32
+ */
33
+ export type AgentSessionActionCallback = (
34
+ action: AgentSessionActionEvent,
35
+ ) => Promise<void>;
@@ -8,7 +8,7 @@
8
8
 
9
9
  import type { JsonValue } from "@/types/common/Json.js";
10
10
  import type { SessionAssistantStepVisibility } from "@/executor/types/SessionRun.js";
11
- import type { AgentSessionOperationEvent } from "@/types/sdk/AgentSessionOperation.js";
11
+ import type { AgentSessionActionEvent } from "@/types/sdk/AgentSessionAction.js";
12
12
 
13
13
  /**
14
14
  * 单个 turn 开始事件。
@@ -355,7 +355,7 @@ export type AgentSessionEvent =
355
355
  | AgentSessionToolApprovalResultEvent
356
356
  | AgentSessionAssistantStepEvent
357
357
  | AgentSessionTitleEvent
358
- | AgentSessionOperationEvent
358
+ | AgentSessionActionEvent
359
359
  | AgentSessionTurnFinishEvent
360
360
  | AgentSessionErrorEvent;
361
361
 
@@ -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 失败时的错误文本。