@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
@@ -6,7 +6,7 @@
6
6
  * - Client 与 Server 共享同一份 request/frame 类型,避免协议两边漂移。
7
7
  * - 字段名保持现有协议格式,兼容已发布的 downcity 托管 runtime 调用。
8
8
  */
9
- import type { AgentCreateSessionInput, AgentListSessionsInput, AgentArchiveSessionsInput, AgentSessionHistoryInput, AgentSessionSystemSnapshot } from "../../types/agent/AgentTypes.js";
9
+ import type { AgentCreateSessionInput, AgentListSessionsInput, AgentArchiveSessionsInput, AgentSessionRecordsInput, AgentSessionSystemSnapshot } from "../../types/agent/AgentTypes.js";
10
10
  import type { AgentSessionEvent } from "../../types/sdk/AgentSessionEvent.js";
11
11
  import type { AgentSessionPromptInput } from "../../types/sdk/AgentSessionPrompt.js";
12
12
  import type { JsonValue } from "../../types/common/Json.js";
@@ -90,14 +90,14 @@ export type RpcRequest = {
90
90
  } | {
91
91
  /** 请求 id,用于匹配响应。 */
92
92
  id: string;
93
- /** 读取 session history。 */
94
- method: "sdk.sessions.history";
95
- /** history 查询参数。 */
93
+ /** 读取 session records。 */
94
+ method: "sdk.sessions.records";
95
+ /** records 查询参数。 */
96
96
  params: {
97
97
  /** 目标 session id。 */
98
98
  sessionId: string;
99
- /** history 分页与视图参数。 */
100
- input?: AgentSessionHistoryInput;
99
+ /** records 分页与视图参数。 */
100
+ input?: AgentSessionRecordsInput;
101
101
  };
102
102
  } | {
103
103
  /** 请求 id,用于匹配响应。 */
@@ -13,7 +13,7 @@ import type { DowncityConfig } from "../../../types/config/DowncityConfig.js";
13
13
  import type { JsonValue } from "../../../types/common/Json.js";
14
14
  import type { AgentPlugins } from "../../../plugin/types/Plugin.js";
15
15
  import type { Plugin } from "../../../types/plugin/PluginDefinition.js";
16
- import type { SessionMetadataV1, SessionMessageV1 } from "../../../executor/types/SessionMessages.js";
16
+ import type { SessionMetadataV1, SessionRecordV1 } from "../../../executor/types/SessionRecords.js";
17
17
  import type { SessionRunInput, SessionRunResult } from "../../../executor/types/SessionRun.js";
18
18
  import type { SessionHistoryStore } from "../../../executor/store/history/SessionHistoryStore.js";
19
19
  import type { AgentSessionPromptInput } from "../../../types/sdk/AgentSessionPrompt.js";
@@ -113,7 +113,7 @@ export interface SessionPort {
113
113
  *
114
114
  * 关键点(中文)
115
115
  * - 只广播订阅之后产生的事件。
116
- * - 历史消息仍通过 `getHistoryStore()` / SDK `history()` 读取。
116
+ * - session records 仍通过 `getHistoryStore()` / SDK `records()` 读取。
117
117
  */
118
118
  subscribe(subscriber: AgentSessionSubscriber): AgentSessionUnsubscribe;
119
119
  /**
@@ -121,7 +121,7 @@ export interface SessionPort {
121
121
  *
122
122
  * 关键点(中文)
123
123
  * - plugin runtime 用它把审批、外部进度等非模型 chunk 事件推送给订阅方。
124
- * - 历史消息持久化仍由 appendUserMessage / appendAssistantMessage 负责。
124
+ * - 历史消息持久化仍由 append_user_message / append_assistant_message 负责。
125
125
  */
126
126
  publishEvent(event: AgentSessionEvent): void;
127
127
  /**
@@ -135,11 +135,11 @@ export interface SessionPort {
135
135
  /**
136
136
  * 追加一条 user 消息。
137
137
  */
138
- appendUserMessage(params: {
138
+ append_user_message(params: {
139
139
  /**
140
140
  * 已构造好的完整消息。
141
141
  */
142
- message?: SessionMessageV1 | null;
142
+ message?: SessionRecordV1 | null;
143
143
  /**
144
144
  * 兜底文本内容。
145
145
  */
@@ -152,11 +152,11 @@ export interface SessionPort {
152
152
  /**
153
153
  * 追加一条 assistant 消息。
154
154
  */
155
- appendAssistantMessage(params: {
155
+ append_assistant_message(params: {
156
156
  /**
157
157
  * 已构造好的完整消息。
158
158
  */
159
- message?: SessionMessageV1 | null;
159
+ message?: SessionRecordV1 | null;
160
160
  /**
161
161
  * 兜底文本内容。
162
162
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AgentContext.d.ts","sourceRoot":"","sources":["../../../../src/types/runtime/agent/AgentContext.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAC3F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAC9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B;IAiBxC;;;;;;OAMG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW;IAI1C;;OAEG;IACH,uBAAuB,IAAI,MAAM,EAAE;IAInC;;OAEG;IACH,wBAAwB,IAAI,MAAM;IAIlC;;;;;;OAMG;YACW,oBAAoB;CAmBnC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;CACtC,CAAC"}
@@ -1,65 +1,24 @@
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
+ import type { SessionActionRecordV1, SessionActionStateV1 } from "../../executor/types/SessionRecords.js";
9
10
  /**
10
11
  * Session action 当前状态。
11
12
  */
12
- export type AgentSessionActionState = "running" | "completed" | "failed";
13
+ export type AgentSessionActionState = SessionActionStateV1;
13
14
  /**
14
15
  * Session action 记录。
15
16
  */
16
- export interface AgentSessionActionRecord {
17
- /**
18
- * 同一个 action 生命周期内稳定复用的 ID。
19
- *
20
- * 说明(中文)
21
- * - 这是 history item envelope 字段,用于把同一个动作更新为一条记录。
22
- * - 前端展示语义只依赖 `type/title/description/state`。
23
- */
24
- id: string;
25
- /**
26
- * 当前 action 标题。
27
- */
28
- title: string;
29
- /**
30
- * 当前 action 描述。
31
- */
32
- description?: string;
33
- /**
34
- * 当前 action 状态。
35
- */
36
- state: AgentSessionActionState;
37
- /**
38
- * 当前 action 关联的 turn 标识。
39
- */
40
- turnId?: string;
41
- /**
42
- * 是否建议前端展示。
43
- *
44
- * 说明(中文)
45
- * - 默认视为 `true`。
46
- * - 调试或审计类辅助事件可显式写入 `false`。
47
- */
48
- visible?: boolean;
49
- }
17
+ export type AgentSessionActionRecord = SessionActionRecordV1;
50
18
  /**
51
19
  * Session action 订阅事件。
52
20
  */
53
- export interface AgentSessionActionEvent extends Omit<AgentSessionActionRecord, "visible"> {
54
- /**
55
- * 当前事件类型。
56
- */
57
- type: "action";
58
- /**
59
- * 当前 session 唯一标识。
60
- */
61
- sessionId: string;
62
- }
21
+ export type AgentSessionActionEvent = SessionActionRecordV1;
63
22
  /**
64
23
  * Session action 发布回调。
65
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AgentSessionAction.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionAction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,EAAE,uBAAuB,CAAC;IAE/B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBACf,SAAQ,IAAI,CAAC,wBAAwB,EAAE,SAAS,CAAC;IACjD;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,MAAM,EAAE,uBAAuB,KAC5B,OAAO,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"AgentSessionAction.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionAction.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,oCAAoC,CAAC;AAE5C;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG,CACvC,MAAM,EAAE,uBAAuB,KAC5B,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,10 +1,10 @@
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
  export {};
10
10
  //# sourceMappingURL=AgentSessionAction.js.map
@@ -6,7 +6,7 @@
6
6
  * - 同一个 turn 可以吸收多条 prompt,因此多个 prompt 可能返回相同 `id` 的 turn handle。
7
7
  * - 增量过程继续通过 `session.subscribe()` 观察;turn handle 只负责等待最终完成结果。
8
8
  */
9
- import type { SessionModelMessageV1 } from "../../executor/types/SessionMessages.js";
9
+ import type { SessionMessageRecordV1 } from "../../executor/types/SessionRecords.js";
10
10
  /**
11
11
  * 单个 Session turn 的最终结果。
12
12
  */
@@ -30,7 +30,7 @@ export interface AgentSessionTurnResult {
30
30
  * - `turn.finished` 返回的结果以这条消息作为最终事实源。
31
31
  * - transport / runtime service 若需要读取最终结构化输出,应优先消费这里。
32
32
  */
33
- assistantMessage?: SessionModelMessageV1;
33
+ assistantMessage?: SessionMessageRecordV1;
34
34
  /**
35
35
  * 当前 turn 失败时的错误文本。
36
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AgentSessionTurn.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionTurn.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,qBAAqB,CAAC;IAEzC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;OAMG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;;OAMG;IACH,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAEtC;;;;;;OAMG;IACH,QAAQ,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC3C"}
1
+ {"version":3,"file":"AgentSessionTurn.d.ts","sourceRoot":"","sources":["../../../src/types/sdk/AgentSessionTurn.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IAEjB;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAE1C;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;;OAMG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;;OAMG;IACH,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAEtC;;;;;;OAMG;IACH,QAAQ,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CAC3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@downcity/agent",
3
- "version": "1.1.200",
3
+ "version": "1.1.202",
4
4
  "type": "module",
5
5
  "description": "Downcity Agent 运行时 — 单 Agent 执行壳与本机 RPC 能力",
6
6
  "main": "./bin/index.js",
@@ -17,8 +17,8 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@ai-sdk/openai-compatible": "^2.0.48",
20
- "@downcity/shell": "^0.1.69",
21
- "@downcity/type": "0.1.102",
20
+ "@downcity/shell": "^0.1.71",
21
+ "@downcity/type": "0.1.104",
22
22
  "ai": "^6.0.193",
23
23
  "commander": "^15.0.0",
24
24
  "dotenv": "^17.4.2",
@@ -144,7 +144,7 @@ test("session.prompt waits for agent background ready before model execution", a
144
144
  });
145
145
 
146
146
  try {
147
- const session = await agent.session_collection().create_session({
147
+ const session = await agent.sessions.create({
148
148
  sessionId: "ready_session",
149
149
  });
150
150
  const prompt_promise = session.prompt({
@@ -14,6 +14,7 @@ import os from "node:os";
14
14
  import path from "node:path";
15
15
  import fs from "node:fs/promises";
16
16
  import { Agent } from "../bin/index.js";
17
+ import { createAction, createPlugin } from "../bin/plugin/core/PluginActionFactory.js";
17
18
  import { City } from "../../city/bin/index.js";
18
19
  import { tool } from "ai";
19
20
  import { z } from "zod";
@@ -224,12 +225,13 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
224
225
 
225
226
  await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve));
226
227
 
228
+ let agent;
227
229
  try {
228
230
  const address = server.address();
229
231
  assert.ok(address && typeof address === "object");
230
232
  const city = new City({
231
233
  role: "user",
232
- city_url: `http://127.0.0.1:${String(address.port)}`,
234
+ federation_url: `http://127.0.0.1:${String(address.port)}`,
233
235
  city_id: "city_demo",
234
236
  user_token: "ub_test",
235
237
  });
@@ -240,9 +242,25 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
240
242
  const agent_path = await fs.mkdtemp(
241
243
  path.join(os.tmpdir(), "downcity-agent-city-model-tool-loop-"),
242
244
  );
243
- const agent = new Agent({
245
+ const skill_plugin = createPlugin({
246
+ name: "skill",
247
+ title: "Skill",
248
+ description: "Test skill plugin",
249
+ actions: {
250
+ lookup: createAction({
251
+ description: "Lookup a skill",
252
+ execute: async ({ input }) => ({
253
+ success: true,
254
+ data: { name: input.name },
255
+ message: "loaded",
256
+ }),
257
+ }),
258
+ },
259
+ });
260
+ agent = new Agent({
244
261
  id: "tool_loop_agent",
245
262
  path: agent_path,
263
+ plugins: [skill_plugin],
246
264
  tools: {
247
265
  ping: tool({
248
266
  description: "ping tool",
@@ -257,7 +275,7 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
257
275
  },
258
276
  });
259
277
 
260
- const session = await agent.createSession();
278
+ const session = await agent.sessions.create();
261
279
  await session.set({ model });
262
280
  const turn = await session.prompt({ query: "please use the ping tool" });
263
281
  const result = await turn.finished;
@@ -266,8 +284,19 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
266
284
  assert.equal(tool_executed, true);
267
285
  assert.equal(stream_requests, 0);
268
286
  assert.equal(agent_requests.length, 2);
269
- assert.equal(requests.every((request) => request?.city_id === "city_demo"), true);
270
287
  assert.equal(agent_requests[0]?.model, "mock-model");
288
+ const plugin_call_tool = agent_requests[0]?.tools?.find(
289
+ (item) => item?.type === "function" && item?.function?.name === "plugin_call",
290
+ );
291
+ assert.ok(plugin_call_tool);
292
+ const plugin_call_parameters = plugin_call_tool.function.parameters;
293
+ assert.equal(plugin_call_parameters.type, "object");
294
+ assert.deepEqual(plugin_call_parameters.required, ["plugin", "action"]);
295
+ assert.equal(plugin_call_parameters.additionalProperties, false);
296
+ assert.equal(
297
+ plugin_call_parameters.properties.payload.additionalProperties,
298
+ true,
299
+ );
271
300
 
272
301
  const second_request_messages = Array.isArray(agent_requests[1]?.messages)
273
302
  ? agent_requests[1].messages
@@ -278,6 +307,9 @@ test("CityModel uses direct LanguageModel path and sends tool result back", asyn
278
307
  assert.match(serialized_second_messages, /echoed/);
279
308
  assert.match(serialized_second_messages, /hello/);
280
309
  } finally {
310
+ if (agent) {
311
+ await agent.dispose();
312
+ }
281
313
  await new Promise((resolve, reject) => {
282
314
  server.close((error) => {
283
315
  if (error) {
@@ -17,6 +17,7 @@ import {
17
17
  invokePluginReadTool,
18
18
  } from "../bin/executor/tools/plugin/PluginToolBridge.js";
19
19
  import { createPluginTools } from "../bin/executor/tools/plugin/PluginToolDefinition.js";
20
+ import { plugin_call_input_schema } from "../bin/executor/tools/plugin/PluginToolSchemas.js";
20
21
  import { withSessionRunScope } from "../bin/executor/SessionRunScope.js";
21
22
  import { createAction, createPlugin } from "../bin/plugin/core/PluginActionFactory.js";
22
23
  import { createAgentPluginRegistry } from "../bin/agent/local/AgentPluginFactory.js";
@@ -32,6 +33,18 @@ function create_run_context(project_root) {
32
33
  };
33
34
  }
34
35
 
36
+ test("plugin_call payload schema allows arbitrary object properties", async () => {
37
+ const plugin_call_schema = await plugin_call_input_schema.jsonSchema;
38
+ const payload_schema = plugin_call_schema.properties.payload;
39
+
40
+ assert.equal(plugin_call_schema.type, "object");
41
+ assert.deepEqual(plugin_call_schema.required, ["plugin", "action"]);
42
+ assert.equal(plugin_call_schema.additionalProperties, false);
43
+ assert.equal(payload_schema.type, "object");
44
+ assert.equal(payload_schema.additionalProperties, true);
45
+ assert.deepEqual(payload_schema.default, {});
46
+ });
47
+
35
48
  test("invokePluginCallTool returns absolute paths for materialized file parts", async () => {
36
49
  const project_root = await fs.mkdtemp(
37
50
  path.join(os.tmpdir(), "downcity-agent-plugin-tool-files-"),
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @file 验证 action message 的持久化、模型输入过滤与 timeline 投影。
2
+ * @file 验证 action record 的持久化、模型输入过滤与 timeline 投影。
3
3
  *
4
4
  * 关键点(中文)
5
- * - action message 会作为 `type=action` item 写入 JSONL。
5
+ * - action record 会作为 `type=action` item 写入 JSONL。
6
6
  * - 同一个 action id 会被更新为一条历史记录,不拆成 running/completed 多条。
7
- * - history composer 组装 LLM 输入时必须过滤 action message
7
+ * - history composer 组装 LLM 输入时必须过滤 action record
8
8
  */
9
9
 
10
10
  import test from "node:test";
@@ -18,7 +18,7 @@ import { JsonlSessionHistoryComposer } from "../bin/executor/composer/history/js
18
18
  import { toSessionTimelineEvents } from "../bin/session/browse/Browse.js";
19
19
  import { Agent } from "../bin/index.js";
20
20
 
21
- test("action message is upserted but filtered from LLM history", async () => {
21
+ test("action record is upserted but filtered from LLM history", async () => {
22
22
  const root_path = await fs.mkdtemp(
23
23
  path.join(os.tmpdir(), "downcity-agent-action-message-"),
24
24
  );
@@ -30,29 +30,29 @@ test("action message is upserted but filtered from LLM history", async () => {
30
30
  });
31
31
  const composer = new JsonlSessionHistoryComposer({ store });
32
32
 
33
- await store.append(
33
+ await store.write_record(
34
34
  store.userText({
35
35
  text: "hello",
36
36
  metadata: { sessionId: session_id },
37
37
  id: "u:1",
38
38
  }),
39
39
  );
40
- await store.append(
40
+ await store.write_record(
41
41
  store.action({
42
42
  action: {
43
43
  id: "action:1",
44
- title: "Compacting session history",
44
+ title: "Compacting session records",
45
45
  state: "running",
46
46
  turnId: "turn-1",
47
47
  },
48
48
  metadata: { sessionId: session_id },
49
49
  }),
50
50
  );
51
- await store.append(
51
+ await store.write_record(
52
52
  store.action({
53
53
  action: {
54
54
  id: "action:1",
55
- title: "Session history compacted",
55
+ title: "Session records compacted",
56
56
  description: "Compacted earlier messages.",
57
57
  state: "completed",
58
58
  turnId: "turn-1",
@@ -60,7 +60,7 @@ test("action message is upserted but filtered from LLM history", async () => {
60
60
  metadata: { sessionId: session_id },
61
61
  }),
62
62
  );
63
- await store.append(
63
+ await store.write_record(
64
64
  store.assistantText({
65
65
  text: "world",
66
66
  metadata: { sessionId: session_id },
@@ -68,10 +68,10 @@ test("action message is upserted but filtered from LLM history", async () => {
68
68
  }),
69
69
  );
70
70
 
71
- const persisted_messages = await store.list();
71
+ const persisted_messages = await store.list_records();
72
72
  assert.equal(persisted_messages.length, 3);
73
73
  assert.equal(persisted_messages[1].type, "action");
74
- assert.equal(persisted_messages[1].title, "Session history compacted");
74
+ assert.equal(persisted_messages[1].title, "Session records compacted");
75
75
  assert.equal(persisted_messages[1].description, "Compacted earlier messages.");
76
76
  assert.equal(persisted_messages[1].state, "completed");
77
77
 
@@ -90,12 +90,12 @@ test("action message is upserted but filtered from LLM history", async () => {
90
90
  const timeline_events = toSessionTimelineEvents(persisted_messages[1]);
91
91
  assert.equal(timeline_events.length, 1);
92
92
  assert.equal(timeline_events[0].role, "action");
93
- assert.equal(timeline_events[0].actionTitle, "Session history compacted");
93
+ assert.equal(timeline_events[0].actionTitle, "Session records compacted");
94
94
  assert.equal(timeline_events[0].actionDescription, "Compacted earlier messages.");
95
95
  assert.equal(timeline_events[0].actionState, "completed");
96
96
  assert.equal(
97
97
  timeline_events[0].text,
98
- "Session history compacted\nCompacted earlier messages.",
98
+ "Session records compacted\nCompacted earlier messages.",
99
99
  );
100
100
  });
101
101
 
@@ -108,7 +108,7 @@ test("session.set persists and publishes model-switching actions", async () => {
108
108
  path: agent_path,
109
109
  });
110
110
  try {
111
- const session = await agent.session_collection().create_session({
111
+ const session = await agent.sessions.create({
112
112
  sessionId: "model_switching_session",
113
113
  });
114
114
  const events = [];
@@ -130,8 +130,8 @@ test("session.set persists and publishes model-switching actions", async () => {
130
130
  );
131
131
  assert.equal(new Set(events.map((event) => event.id)).size, 1);
132
132
 
133
- const history = await session.history({ view: "timeline" });
134
- const action_events = history.items.filter(
133
+ const records = await session.records({ view: "timeline" });
134
+ const action_events = records.items.filter(
135
135
  (item) => item.role === "action",
136
136
  );
137
137
  assert.deepEqual(
@@ -152,7 +152,7 @@ test("session.fork persists and publishes history-forking actions on source sess
152
152
  path: agent_path,
153
153
  });
154
154
  try {
155
- const session = await agent.session_collection().create_session({
155
+ const session = await agent.sessions.create({
156
156
  sessionId: "history_forking_session",
157
157
  });
158
158
  await session.set({
@@ -161,7 +161,7 @@ test("session.fork persists and publishes history-forking actions on source sess
161
161
  provider: "test",
162
162
  },
163
163
  });
164
- await session.appendUserMessage({ text: "source message" });
164
+ await session.append_user_message({ text: "source message" });
165
165
 
166
166
  const events = [];
167
167
  const unsubscribe = session.subscribe((event) => {
@@ -174,22 +174,22 @@ test("session.fork persists and publishes history-forking actions on source sess
174
174
 
175
175
  assert.deepEqual(
176
176
  events.map((event) => `${event.title}:${event.state}`),
177
- ["Forking session history:running", "Session history forked:completed"],
177
+ ["Forking session records:running", "Session records forked:completed"],
178
178
  );
179
179
  assert.equal(new Set(events.map((event) => event.id)).size, 1);
180
180
  assert.notEqual(forked.id, session.id);
181
181
 
182
- const source_history = await session.history({ view: "timeline" });
183
- const source_fork_actions = source_history.items.filter(
184
- (item) => item.role === "action" && item.actionTitle === "Session history forked",
182
+ const source_records = await session.records({ view: "timeline" });
183
+ const source_fork_actions = source_records.items.filter(
184
+ (item) => item.role === "action" && item.actionTitle === "Session records forked",
185
185
  );
186
186
  assert.deepEqual(
187
187
  source_fork_actions.map((event) => event.actionState),
188
188
  ["completed"],
189
189
  );
190
190
 
191
- const forked_history = await forked.history({ view: "timeline" });
192
- const forked_model_actions = forked_history.items.filter(
191
+ const forked_records = await forked.records({ view: "timeline" });
192
+ const forked_model_actions = forked_records.items.filter(
193
193
  (item) => item.role === "action" && item.actionTitle === "Session model switched",
194
194
  );
195
195
  assert.equal(forked_model_actions.length, 1);
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @file 验证 session compact prompt 与文件操作 XML 记录。
3
+ *
4
+ * 关键点(中文)
5
+ * - compact prompt 必须保持结构化摘要格式稳定。
6
+ * - 迭代更新 prompt 需要携带 previous-summary 标签。
7
+ * - 文件操作 XML 由本地解析追加,不依赖模型复述工具日志。
8
+ */
9
+
10
+ import test from "node:test";
11
+ import assert from "node:assert/strict";
12
+
13
+ import {
14
+ SESSION_COMPACTION_SYSTEM_PROMPT,
15
+ append_session_compaction_file_operations,
16
+ build_initial_session_compaction_prompt,
17
+ build_turn_prefix_session_compaction_prompt,
18
+ build_update_session_compaction_prompt,
19
+ } from "../bin/executor/composer/compaction/jsonl/JsonlSessionCompactionPrompts.js";
20
+ import {
21
+ collect_session_compaction_file_operations,
22
+ format_session_compaction_file_operations,
23
+ } from "../bin/executor/composer/compaction/jsonl/JsonlSessionCompactionFileOperations.js";
24
+
25
+ test("session compaction prompts preserve structured formats", () => {
26
+ assert.match(
27
+ SESSION_COMPACTION_SYSTEM_PROMPT,
28
+ /Do NOT continue the conversation/,
29
+ );
30
+
31
+ const initial_prompt = build_initial_session_compaction_prompt({
32
+ conversation_text: "user: 请修改 packages/agent/src/foo.ts",
33
+ });
34
+ assert.match(initial_prompt, /## Goal/);
35
+ assert.match(initial_prompt, /## Constraints & Preferences/);
36
+ assert.match(initial_prompt, /## Critical Context/);
37
+ assert.match(
38
+ initial_prompt,
39
+ /Keep each section concise\. Preserve exact file paths/,
40
+ );
41
+
42
+ const update_prompt = build_update_session_compaction_prompt({
43
+ previous_summary: "## Goal\n旧目标",
44
+ new_conversation_text: "assistant: 已完成一部分",
45
+ });
46
+ assert.match(update_prompt, /<previous-summary>\n## Goal\n旧目标\n<\/previous-summary>/);
47
+ assert.match(update_prompt, /PRESERVE all existing information/);
48
+ assert.match(update_prompt, /## Next Steps/);
49
+
50
+ const prefix_prompt = build_turn_prefix_session_compaction_prompt({
51
+ prefix_text: "user: 这个 turn 太长",
52
+ });
53
+ assert.match(prefix_prompt, /## Original Request/);
54
+ assert.match(prefix_prompt, /## Context for Suffix/);
55
+ });
56
+
57
+ test("session compaction file operations are appended as xml", () => {
58
+ const messages = [
59
+ {
60
+ id: "a:1",
61
+ role: "assistant",
62
+ parts: [
63
+ {
64
+ type: "tool-exec_command",
65
+ input: {
66
+ cmd: "sed -n '1,40p' packages/agent/src/foo.ts && rg -n compact packages/agent/src",
67
+ },
68
+ output: [
69
+ "*** Update File: packages/agent/src/bar.ts",
70
+ " M packages/agent/src/baz.ts",
71
+ ].join("\n"),
72
+ },
73
+ ],
74
+ },
75
+ ];
76
+
77
+ const operations = collect_session_compaction_file_operations(messages);
78
+ assert.deepEqual(operations.read_files, [
79
+ "packages/agent/src",
80
+ "packages/agent/src/foo.ts",
81
+ ]);
82
+ assert.deepEqual(operations.modified_files, [
83
+ "packages/agent/src/bar.ts",
84
+ "packages/agent/src/baz.ts",
85
+ ]);
86
+
87
+ const xml = format_session_compaction_file_operations(messages);
88
+ assert.match(xml, /<read-files>\npackages\/agent\/src/);
89
+ assert.match(xml, /<modified-files>\npackages\/agent\/src\/bar\.ts/);
90
+
91
+ const summary = append_session_compaction_file_operations({
92
+ summary: "## Goal\n完成 compact",
93
+ file_operations_xml: xml,
94
+ });
95
+ assert.match(summary, /## Goal\n完成 compact\n\n<read-files>/);
96
+ assert.match(summary, /<\/modified-files>$/);
97
+ });