@downcity/agent 1.1.207 → 1.1.210

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 (292) hide show
  1. package/bin/agent/local/Agent.d.ts +3 -3
  2. package/bin/agent/local/Agent.d.ts.map +1 -1
  3. package/bin/agent/local/Agent.js +0 -3
  4. package/bin/agent/local/Agent.js.map +1 -1
  5. package/bin/agent/local/AgentInstructions.d.ts +2 -1
  6. package/bin/agent/local/AgentInstructions.d.ts.map +1 -1
  7. package/bin/agent/local/AgentInstructions.js +10 -10
  8. package/bin/agent/local/AgentInstructions.js.map +1 -1
  9. package/bin/agent/local/services/AgentAssemblyService.d.ts +3 -8
  10. package/bin/agent/local/services/AgentAssemblyService.d.ts.map +1 -1
  11. package/bin/agent/local/services/AgentAssemblyService.js +0 -1
  12. package/bin/agent/local/services/AgentAssemblyService.js.map +1 -1
  13. package/bin/agent/local/services/AgentSessions.d.ts +5 -7
  14. package/bin/agent/local/services/AgentSessions.d.ts.map +1 -1
  15. package/bin/agent/local/services/AgentSessions.js +2 -3
  16. package/bin/agent/local/services/AgentSessions.js.map +1 -1
  17. package/bin/agent/remote/RemoteAgent.d.ts +3 -1
  18. package/bin/agent/remote/RemoteAgent.d.ts.map +1 -1
  19. package/bin/agent/remote/RemoteAgent.js.map +1 -1
  20. package/bin/agent/remote/RemoteSession.d.ts +10 -1
  21. package/bin/agent/remote/RemoteSession.d.ts.map +1 -1
  22. package/bin/agent/remote/RemoteSession.js +18 -0
  23. package/bin/agent/remote/RemoteSession.js.map +1 -1
  24. package/bin/agent/remote/RemoteTransport.d.ts +5 -1
  25. package/bin/agent/remote/RemoteTransport.d.ts.map +1 -1
  26. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +4 -1
  27. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -1
  28. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +7 -0
  29. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js.map +1 -1
  30. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +4 -1
  31. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -1
  32. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +1 -0
  33. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js.map +1 -1
  34. package/bin/executor/Executor.d.ts +0 -16
  35. package/bin/executor/Executor.d.ts.map +1 -1
  36. package/bin/executor/Executor.js +0 -16
  37. package/bin/executor/Executor.js.map +1 -1
  38. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts +1 -3
  39. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.d.ts.map +1 -1
  40. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js +1 -5
  41. package/bin/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.js.map +1 -1
  42. package/bin/executor/composer/history/SessionHistoryWriter.d.ts +0 -10
  43. package/bin/executor/composer/history/SessionHistoryWriter.d.ts.map +1 -1
  44. package/bin/executor/composer/history/SessionHistoryWriter.js +31 -61
  45. package/bin/executor/composer/history/SessionHistoryWriter.js.map +1 -1
  46. package/bin/executor/composer/system/default/StaticPromptCatalog.d.ts +4 -0
  47. package/bin/executor/composer/system/default/StaticPromptCatalog.d.ts.map +1 -1
  48. package/bin/executor/composer/system/default/StaticPromptCatalog.js +4 -0
  49. package/bin/executor/composer/system/default/StaticPromptCatalog.js.map +1 -1
  50. package/bin/executor/composer/system/default/SystemDomain.d.ts +1 -1
  51. package/bin/executor/composer/system/default/SystemDomain.d.ts.map +1 -1
  52. package/bin/executor/composer/system/default/SystemDomain.js +2 -7
  53. package/bin/executor/composer/system/default/SystemDomain.js.map +1 -1
  54. package/bin/executor/composer/system/default/SystemPromptAssets.d.ts +0 -4
  55. package/bin/executor/composer/system/default/SystemPromptAssets.d.ts.map +1 -1
  56. package/bin/executor/composer/system/default/SystemPromptAssets.js +0 -5
  57. package/bin/executor/composer/system/default/SystemPromptAssets.js.map +1 -1
  58. package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
  59. package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
  60. package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
  61. package/bin/executor/composer/system/default/assets/core.prompt.js.map +1 -1
  62. package/bin/executor/messages/AssistantFileResource.d.ts.map +1 -1
  63. package/bin/executor/messages/AssistantFileResource.js +58 -15
  64. package/bin/executor/messages/AssistantFileResource.js.map +1 -1
  65. package/bin/executor/services/ExecutorInflightService.d.ts +0 -5
  66. package/bin/executor/services/ExecutorInflightService.d.ts.map +1 -1
  67. package/bin/executor/services/ExecutorInflightService.js +0 -6
  68. package/bin/executor/services/ExecutorInflightService.js.map +1 -1
  69. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +4 -0
  70. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
  71. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +115 -3
  72. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
  73. package/bin/executor/types/SessionHistoryMeta.d.ts +6 -0
  74. package/bin/executor/types/SessionHistoryMeta.d.ts.map +1 -1
  75. package/bin/index.d.ts +38 -6
  76. package/bin/index.d.ts.map +1 -1
  77. package/bin/index.js +14 -1
  78. package/bin/index.js.map +1 -1
  79. package/bin/plugin/core/ActionScheduleExecutor.js +1 -1
  80. package/bin/plugin/core/ActionScheduleExecutor.js.map +1 -1
  81. package/bin/plugin/core/BasePlugin.d.ts +7 -9
  82. package/bin/plugin/core/BasePlugin.d.ts.map +1 -1
  83. package/bin/plugin/core/BasePlugin.js +1 -14
  84. package/bin/plugin/core/BasePlugin.js.map +1 -1
  85. package/bin/plugin/core/HookRegistry.d.ts +1 -1
  86. package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
  87. package/bin/plugin/core/PluginActionFactory.d.ts +1 -5
  88. package/bin/plugin/core/PluginActionFactory.d.ts.map +1 -1
  89. package/bin/plugin/core/PluginActionFactory.js +0 -3
  90. package/bin/plugin/core/PluginActionFactory.js.map +1 -1
  91. package/bin/plugin/core/PluginActionRunner.d.ts +6 -4
  92. package/bin/plugin/core/PluginActionRunner.d.ts.map +1 -1
  93. package/bin/plugin/core/PluginActionRunner.js +2 -2
  94. package/bin/plugin/core/PluginActionRunner.js.map +1 -1
  95. package/bin/plugin/core/PluginCatalog.d.ts +2 -1
  96. package/bin/plugin/core/PluginCatalog.d.ts.map +1 -1
  97. package/bin/plugin/core/PluginCatalog.js.map +1 -1
  98. package/bin/plugin/core/PluginCommand.d.ts +1 -1
  99. package/bin/plugin/core/PluginCommand.d.ts.map +1 -1
  100. package/bin/plugin/core/PluginCommand.js.map +1 -1
  101. package/bin/plugin/core/PluginHttpRoutes.d.ts +1 -1
  102. package/bin/plugin/core/PluginHttpRoutes.d.ts.map +1 -1
  103. package/bin/plugin/core/PluginLocalExecution.d.ts +4 -1
  104. package/bin/plugin/core/PluginLocalExecution.d.ts.map +1 -1
  105. package/bin/plugin/core/PluginLocalExecution.js +0 -1
  106. package/bin/plugin/core/PluginLocalExecution.js.map +1 -1
  107. package/bin/plugin/core/PluginRegistry.d.ts +4 -2
  108. package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
  109. package/bin/plugin/core/PluginRegistry.js +7 -6
  110. package/bin/plugin/core/PluginRegistry.js.map +1 -1
  111. package/bin/plugin/core/PluginStateController.d.ts +7 -27
  112. package/bin/plugin/core/PluginStateController.d.ts.map +1 -1
  113. package/bin/plugin/core/PluginStateController.js +5 -39
  114. package/bin/plugin/core/PluginStateController.js.map +1 -1
  115. package/bin/plugin/types/PluginApi.d.ts +3 -79
  116. package/bin/plugin/types/PluginApi.d.ts.map +1 -1
  117. package/bin/rpc/Client.d.ts +11 -6
  118. package/bin/rpc/Client.d.ts.map +1 -1
  119. package/bin/rpc/Client.js +2 -0
  120. package/bin/rpc/Client.js.map +1 -1
  121. package/bin/session/Session.d.ts +2 -5
  122. package/bin/session/Session.d.ts.map +1 -1
  123. package/bin/session/Session.js +3 -16
  124. package/bin/session/Session.js.map +1 -1
  125. package/bin/session/SessionSystemBuilder.d.ts +1 -1
  126. package/bin/session/SessionSystemBuilder.d.ts.map +1 -1
  127. package/bin/session/browse/Browse.d.ts +4 -6
  128. package/bin/session/browse/Browse.d.ts.map +1 -1
  129. package/bin/session/browse/Browse.js +71 -71
  130. package/bin/session/browse/Browse.js.map +1 -1
  131. package/bin/session/preview/SessionMessagePreview.d.ts +13 -0
  132. package/bin/session/preview/SessionMessagePreview.d.ts.map +1 -0
  133. package/bin/session/preview/SessionMessagePreview.js +61 -0
  134. package/bin/session/preview/SessionMessagePreview.js.map +1 -0
  135. package/bin/session/services/SessionStateService.d.ts +1 -1
  136. package/bin/session/services/SessionStateService.d.ts.map +1 -1
  137. package/bin/session/services/SessionStateService.js +2 -2
  138. package/bin/session/services/SessionStateService.js.map +1 -1
  139. package/bin/session/services/SessionViewService.d.ts +2 -1
  140. package/bin/session/services/SessionViewService.d.ts.map +1 -1
  141. package/bin/session/services/SessionViewService.js +4 -1
  142. package/bin/session/services/SessionViewService.js.map +1 -1
  143. package/bin/session/storage/Metadata.d.ts.map +1 -1
  144. package/bin/session/storage/Metadata.js +23 -0
  145. package/bin/session/storage/Metadata.js.map +1 -1
  146. package/bin/session/storage/Persistence.d.ts +1 -1
  147. package/bin/session/storage/Persistence.d.ts.map +1 -1
  148. package/bin/session/storage/RuntimeSessionPort.d.ts +0 -12
  149. package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
  150. package/bin/session/storage/RuntimeSessionPort.js +0 -8
  151. package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
  152. package/bin/types/plugin/PluginAction.d.ts +0 -10
  153. package/bin/types/plugin/PluginAction.d.ts.map +1 -1
  154. package/bin/types/plugin/PluginCommand.d.ts +2 -3
  155. package/bin/types/plugin/PluginCommand.d.ts.map +1 -1
  156. package/bin/types/plugin/PluginControl.d.ts +74 -0
  157. package/bin/types/plugin/PluginControl.d.ts.map +1 -0
  158. package/bin/types/plugin/PluginControl.js +9 -0
  159. package/bin/types/plugin/PluginControl.js.map +1 -0
  160. package/bin/types/plugin/PluginDefinition.d.ts +1 -1
  161. package/bin/types/plugin/PluginDefinition.d.ts.map +1 -1
  162. package/bin/types/plugin/PluginRuntime.d.ts +1 -3
  163. package/bin/types/plugin/PluginRuntime.d.ts.map +1 -1
  164. package/bin/types/plugin/PluginState.d.ts +3 -16
  165. package/bin/types/plugin/PluginState.d.ts.map +1 -1
  166. package/bin/types/rpc/RpcProtocol.d.ts +3 -3
  167. package/bin/types/rpc/RpcProtocol.d.ts.map +1 -1
  168. package/bin/types/runtime/agent/AgentContext.d.ts +1 -9
  169. package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
  170. package/bin/types/runtime/agent/AgentContext.js.map +1 -1
  171. package/bin/types/session/SessionLocalState.d.ts +1 -1
  172. package/bin/types/session/SessionLocalState.d.ts.map +1 -1
  173. package/package.json +4 -7
  174. package/scripts/agent-ready.test.mjs +38 -0
  175. package/scripts/assistant-file-resource.test.mjs +39 -0
  176. package/scripts/city-model-tool-loop.test.mjs +18 -30
  177. package/scripts/image-plugin-job.test.mjs +13 -13
  178. package/scripts/plugin-tool-bridge.test.mjs +2 -3
  179. package/scripts/remote-session-reconnect.test.mjs +67 -0
  180. package/scripts/session-history-writer-error.test.mjs +57 -0
  181. package/scripts/session-list-title.test.mjs +114 -23
  182. package/scripts/session-system-blocks.test.mjs +73 -0
  183. package/src/agent/local/Agent.ts +4 -10
  184. package/src/agent/local/AgentInstructions.ts +11 -11
  185. package/src/agent/local/services/AgentAssemblyService.ts +3 -9
  186. package/src/agent/local/services/AgentSessions.ts +8 -15
  187. package/src/agent/remote/RemoteAgent.ts +5 -4
  188. package/src/agent/remote/RemoteSession.ts +21 -2
  189. package/src/agent/remote/RemoteTransport.ts +6 -2
  190. package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +13 -3
  191. package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +6 -2
  192. package/src/executor/Executor.ts +0 -23
  193. package/src/executor/composer/compaction/jsonl/JsonlSessionCompactionExecutor.ts +2 -8
  194. package/src/executor/composer/history/SessionHistoryWriter.ts +33 -64
  195. package/src/executor/composer/system/default/StaticPromptCatalog.ts +4 -0
  196. package/src/executor/composer/system/default/SystemDomain.ts +1 -9
  197. package/src/executor/composer/system/default/SystemPromptAssets.ts +0 -6
  198. package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
  199. package/src/executor/composer/system/default/assets/core.prompt.ts.txt +37 -15
  200. package/src/executor/messages/AssistantFileResource.ts +61 -17
  201. package/src/executor/services/ExecutorInflightService.ts +0 -10
  202. package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +130 -4
  203. package/src/executor/types/SessionHistoryMeta.ts +6 -0
  204. package/src/index.ts +100 -29
  205. package/src/plugin/core/ActionScheduleExecutor.ts +1 -1
  206. package/src/plugin/core/BasePlugin.ts +8 -22
  207. package/src/plugin/core/HookRegistry.ts +1 -1
  208. package/src/plugin/core/PluginActionFactory.ts +1 -8
  209. package/src/plugin/core/PluginActionRunner.ts +8 -11
  210. package/src/plugin/core/PluginCatalog.ts +2 -5
  211. package/src/plugin/core/PluginCommand.ts +2 -1
  212. package/src/plugin/core/PluginHttpRoutes.ts +1 -1
  213. package/src/plugin/core/PluginLocalExecution.ts +4 -7
  214. package/src/plugin/core/PluginRegistry.ts +10 -10
  215. package/src/plugin/core/PluginStateController.ts +12 -60
  216. package/src/plugin/types/PluginApi.ts +6 -81
  217. package/src/rpc/Client.ts +22 -16
  218. package/src/session/Session.ts +5 -21
  219. package/src/session/SessionSystemBuilder.ts +1 -1
  220. package/src/session/browse/Browse.ts +103 -84
  221. package/src/session/preview/SessionMessagePreview.ts +75 -0
  222. package/src/session/services/SessionStateService.ts +3 -4
  223. package/src/session/services/SessionViewService.ts +6 -6
  224. package/src/session/storage/Metadata.ts +26 -0
  225. package/src/session/storage/Persistence.ts +1 -1
  226. package/src/session/storage/RuntimeSessionPort.ts +0 -20
  227. package/src/types/plugin/PluginAction.ts +0 -10
  228. package/src/types/plugin/PluginCommand.ts +2 -3
  229. package/src/types/plugin/PluginControl.ts +80 -0
  230. package/src/types/plugin/PluginDefinition.ts +1 -1
  231. package/src/types/plugin/PluginRuntime.ts +1 -3
  232. package/src/types/plugin/PluginState.ts +3 -20
  233. package/src/types/rpc/RpcProtocol.ts +4 -4
  234. package/src/types/runtime/agent/AgentContext.ts +1 -9
  235. package/src/types/session/SessionLocalState.ts +1 -1
  236. package/tsconfig.tsbuildinfo +1 -1
  237. package/bin/config/DowncitySchema.d.ts +0 -20
  238. package/bin/config/DowncitySchema.d.ts.map +0 -1
  239. package/bin/config/DowncitySchema.js +0 -160
  240. package/bin/config/DowncitySchema.js.map +0 -1
  241. package/bin/executor/composer/system/default/assets/plugin.prompt.d.ts +0 -7
  242. package/bin/executor/composer/system/default/assets/plugin.prompt.d.ts.map +0 -1
  243. package/bin/executor/composer/system/default/assets/plugin.prompt.js +0 -8
  244. package/bin/executor/composer/system/default/assets/plugin.prompt.js.map +0 -1
  245. package/bin/plugin/core/Activation.d.ts +0 -18
  246. package/bin/plugin/core/Activation.d.ts.map +0 -1
  247. package/bin/plugin/core/Activation.js +0 -21
  248. package/bin/plugin/core/Activation.js.map +0 -1
  249. package/bin/plugin/core/Manager.d.ts +0 -7
  250. package/bin/plugin/core/Manager.d.ts.map +0 -1
  251. package/bin/plugin/core/Manager.js +0 -6
  252. package/bin/plugin/core/Manager.js.map +0 -1
  253. package/bin/plugin/types/Plugin.d.ts +0 -15
  254. package/bin/plugin/types/Plugin.d.ts.map +0 -1
  255. package/bin/plugin/types/Plugin.js +0 -9
  256. package/bin/plugin/types/Plugin.js.map +0 -1
  257. package/bin/plugin/types/PluginLifecycle.d.ts +0 -34
  258. package/bin/plugin/types/PluginLifecycle.d.ts.map +0 -1
  259. package/bin/plugin/types/PluginLifecycle.js +0 -9
  260. package/bin/plugin/types/PluginLifecycle.js.map +0 -1
  261. package/bin/plugin/types/PluginState.d.ts +0 -5
  262. package/bin/plugin/types/PluginState.d.ts.map +0 -1
  263. package/bin/plugin/types/PluginState.js +0 -5
  264. package/bin/plugin/types/PluginState.js.map +0 -1
  265. package/bin/plugin/types/Plugins.d.ts +0 -61
  266. package/bin/plugin/types/Plugins.d.ts.map +0 -1
  267. package/bin/plugin/types/Plugins.js +0 -5
  268. package/bin/plugin/types/Plugins.js.map +0 -1
  269. package/bin/session/index.d.ts +0 -15
  270. package/bin/session/index.d.ts.map +0 -1
  271. package/bin/session/index.js +0 -15
  272. package/bin/session/index.js.map +0 -1
  273. package/bin/types/agent/AgentTypes.d.ts +0 -18
  274. package/bin/types/agent/AgentTypes.d.ts.map +0 -1
  275. package/bin/types/agent/AgentTypes.js +0 -10
  276. package/bin/types/agent/AgentTypes.js.map +0 -1
  277. package/bin/utils/logger/Format.d.ts +0 -11
  278. package/bin/utils/logger/Format.d.ts.map +0 -1
  279. package/bin/utils/logger/Format.js +0 -10
  280. package/bin/utils/logger/Format.js.map +0 -1
  281. package/src/config/DowncitySchema.ts +0 -175
  282. package/src/executor/composer/system/default/assets/plugin.prompt.ts +0 -9
  283. package/src/executor/composer/system/default/assets/plugin.prompt.ts.txt +0 -20
  284. package/src/plugin/core/Activation.ts +0 -26
  285. package/src/plugin/core/Manager.ts +0 -17
  286. package/src/plugin/types/Plugin.ts +0 -63
  287. package/src/plugin/types/PluginLifecycle.ts +0 -35
  288. package/src/plugin/types/PluginState.ts +0 -12
  289. package/src/plugin/types/Plugins.ts +0 -67
  290. package/src/session/index.ts +0 -57
  291. package/src/types/agent/AgentTypes.ts +0 -58
  292. package/src/utils/logger/Format.ts +0 -15
@@ -11,11 +11,11 @@ import { nanoid } from "nanoid";
11
11
  import {
12
12
  buildSessionRecordsPage,
13
13
  buildSessionInfo,
14
- getSdkAgentSessionArchiveFilePath,
15
- ensureSessionTitle,
16
14
  loadSessionArchiveMessagesFromPath,
17
- readSessionMetadata,
18
- } from "@/session/index.js";
15
+ } from "@/session/browse/Browse.js";
16
+ import { getSdkAgentSessionArchiveFilePath } from "@/session/storage/Paths.js";
17
+ import { ensureSessionTitle } from "@/session/SessionTitle.js";
18
+ import { readSessionMetadata } from "@/session/storage/Metadata.js";
19
19
  import { buildSessionSystemBlocks } from "@/session/SessionSystemBuilder.js";
20
20
  import type { JsonlSessionHistoryStore } from "@/executor/store/history/jsonl/JsonlSessionHistoryStore.js";
21
21
  import type { SessionSystemComposer } from "@/executor/composer/system/SessionSystemComposer.js";
@@ -24,10 +24,10 @@ import type {
24
24
  AgentSessionRecordsInput,
25
25
  AgentSessionRecordsPage,
26
26
  AgentSessionInfo,
27
- AgentSession,
28
27
  AgentSessionSystemBlock,
29
28
  AgentSessionSystemSnapshot,
30
- } from "@/types/agent/AgentTypes.js";
29
+ } from "@/types/agent/SessionTypes.js";
30
+ import type { AgentSession } from "@/types/agent/SessionActor.js";
31
31
  import type { SessionRecordV1 } from "@/executor/types/SessionRecords.js";
32
32
  import { SessionStateService } from "@/session/services/SessionStateService.js";
33
33
  import type { SessionRunContext } from "@/types/executor/SessionRunContext.js";
@@ -56,6 +56,23 @@ function normalizeTimezone(input: unknown): string | undefined {
56
56
  return timezone || undefined;
57
57
  }
58
58
 
59
+ function normalize_message_count(input: unknown): number | undefined {
60
+ return typeof input === "number" && Number.isInteger(input) && input >= 0
61
+ ? input
62
+ : undefined;
63
+ }
64
+
65
+ function normalize_preview_text(input: unknown): string | undefined {
66
+ const preview_text = typeof input === "string" ? input.trim() : "";
67
+ return preview_text || undefined;
68
+ }
69
+
70
+ function normalize_history_bytes(input: unknown): number | undefined {
71
+ return typeof input === "number" && Number.isInteger(input) && input >= 0
72
+ ? input
73
+ : undefined;
74
+ }
75
+
59
76
  /**
60
77
  * 从模型实例推导轻量可读标签。
61
78
  */
@@ -136,6 +153,15 @@ export async function readSessionMetadataFromPath(input: {
136
153
  ...(normalizeModelLabel(raw.modelLabel)
137
154
  ? { modelLabel: normalizeModelLabel(raw.modelLabel) }
138
155
  : {}),
156
+ ...(normalize_message_count(raw.messageCount) !== undefined
157
+ ? { messageCount: normalize_message_count(raw.messageCount) }
158
+ : {}),
159
+ ...(normalize_preview_text(raw.previewText)
160
+ ? { previewText: normalize_preview_text(raw.previewText) }
161
+ : {}),
162
+ ...(normalize_history_bytes(raw.historyBytes) !== undefined
163
+ ? { historyBytes: normalize_history_bytes(raw.historyBytes) }
164
+ : {}),
139
165
  };
140
166
  } catch {
141
167
  return {
@@ -13,7 +13,7 @@ import type {
13
13
  SessionMessageRecordV1,
14
14
  } from "@/executor/types/SessionRecords.js";
15
15
  import { persistAssistantResult } from "@/executor/messages/AssistantResultPersistence.js";
16
- import type { AgentSessionConfigSnapshot } from "@/types/agent/AgentTypes.js";
16
+ import type { AgentSessionConfigSnapshot } from "@/types/agent/SessionTypes.js";
17
17
  import {
18
18
  readSessionMetadata,
19
19
  writeSessionMetadata,
@@ -47,14 +47,6 @@ export interface CreateRuntimeSessionPortParams {
47
47
  * 发布一条 session runtime 事件。
48
48
  */
49
49
  publishEvent: (event: AgentSessionEvent) => void;
50
- /**
51
- * 清理当前 session executor 状态。
52
- */
53
- clearExecutor: () => void;
54
- /**
55
- * session 更新后的异步通知回调。
56
- */
57
- afterSessionUpdatedAsync: () => Promise<void>;
58
50
  /**
59
51
  * 追加 user 消息到底层历史。
60
52
  */
@@ -75,10 +67,6 @@ export interface CreateRuntimeSessionPortParams {
75
67
  * 在执行前确保当前 session 已完成初始化与宿主级配置。
76
68
  */
77
69
  ensureReadyForExecution: () => Promise<void>;
78
- /**
79
- * session 更新后需要同步执行的持久化回调。
80
- */
81
- touchMetadata: () => Promise<void>;
82
70
  }
83
71
 
84
72
  /**
@@ -105,19 +93,11 @@ export function createRuntimeSessionPort(
105
93
  publishEvent: (event) => {
106
94
  params.publishEvent(event);
107
95
  },
108
- clearExecutor: () => {
109
- params.clearExecutor();
110
- },
111
- afterSessionUpdatedAsync: async () => {
112
- await params.afterSessionUpdatedAsync();
113
- },
114
96
  append_user_message: async (messageParams) => {
115
97
  await params.append_user_message(messageParams);
116
- await params.touchMetadata();
117
98
  },
118
99
  append_assistant_message: async (messageParams) => {
119
100
  await params.append_assistant_message(messageParams);
120
- await params.touchMetadata();
121
101
  },
122
102
  isExecuting: () => params.isExecuting(),
123
103
  };
@@ -139,14 +139,6 @@ export interface PluginAction<
139
139
  P extends JsonValue = JsonValue,
140
140
  R extends JsonValue = JsonValue,
141
141
  > extends PluginActionMetadata<P> {
142
- /**
143
- * disabled 状态下是否仍允许执行。
144
- *
145
- * 说明(中文)
146
- * - 用于 `on` / `status` / `models` / `configure` / `install` 这类 setup 相关 action。
147
- * - 默认 false,避免 disabled plugin 绕过 registry 保护执行普通业务 action。
148
- */
149
- allowWhenDisabled?: boolean;
150
142
  /** CLI 定义(可选)。 */
151
143
  command?: PluginActionCommand<P>;
152
144
  /** HTTP 定义(可选)。 */
@@ -155,8 +147,6 @@ export interface PluginAction<
155
147
  execute: (params: {
156
148
  /** 当前执行上下文。 */
157
149
  context: AgentContext;
158
- /** 输入 payload。 */
159
- payload: P;
160
150
  /** 已通过 schema 校验后的输入。 */
161
151
  input: P;
162
152
  /** 当前插件名称。 */
@@ -71,11 +71,10 @@ export interface PluginCommandResult {
71
71
  }
72
72
 
73
73
  /**
74
- * Plugin 生命周期兼容定义。
74
+ * Plugin 生命周期定义。
75
75
  *
76
76
  * 关键点(中文)
77
- * - 这是从旧运行生命周期过渡过来的兼容层。
78
- * - 新代码优先直接实现 `start/stop/command`。
77
+ * - 生命周期只描述 plugin 启动、停止和非 action 命令处理。
79
78
  */
80
79
  export interface PluginLifecycle {
81
80
  /** plugin 启动钩子。 */
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Plugin 控制面协议类型。
3
+ *
4
+ * 关键点(中文)
5
+ * - CLI、HTTP 与 RPC 共用同一套 plugin 控制请求和响应结构。
6
+ * - 状态数据统一复用 `PluginSnapshot`,不再复制字段或保留旧别名。
7
+ */
8
+
9
+ import type { JsonValue } from "@/types/common/Json.js";
10
+ import type { PluginControlAction, PluginSnapshot } from "@/types/plugin/PluginState.js";
11
+
12
+ export type { PluginControlAction } from "@/types/plugin/PluginState.js";
13
+
14
+ /**
15
+ * plugin 状态列表响应。
16
+ */
17
+ export type PluginStateListResponse = {
18
+ /** 请求是否成功。 */
19
+ success: boolean;
20
+ /** 当前已注册 plugin 快照。 */
21
+ plugins?: PluginSnapshot[];
22
+ /** 失败原因。 */
23
+ error?: string;
24
+ };
25
+
26
+ /**
27
+ * 单个 plugin 控制响应。
28
+ */
29
+ export type PluginControlResponse = {
30
+ /** 请求是否成功。 */
31
+ success: boolean;
32
+ /** 当前 plugin 快照。 */
33
+ plugin?: PluginSnapshot;
34
+ /** 失败原因。 */
35
+ error?: string;
36
+ };
37
+
38
+ /**
39
+ * plugin command/action 执行响应。
40
+ */
41
+ export type PluginCommandResponse = {
42
+ /** 调用是否成功。 */
43
+ success: boolean;
44
+ /** 当前 plugin 快照。 */
45
+ plugin?: PluginSnapshot;
46
+ /** 人类可读结果。 */
47
+ message?: string;
48
+ /** 结构化结果。 */
49
+ data?: JsonValue;
50
+ /** 失败原因。 */
51
+ error?: string;
52
+ };
53
+
54
+ /**
55
+ * plugin CLI 通用选项。
56
+ */
57
+ export type PluginCliBaseOptions = {
58
+ /** agent 项目路径。 */
59
+ path?: string;
60
+ /** 目标 agent 标识。 */
61
+ agent?: string;
62
+ /** HTTP 主机。 */
63
+ host?: string;
64
+ /** HTTP 端口。 */
65
+ port?: number;
66
+ /** 控制面认证令牌。 */
67
+ token?: string;
68
+ /** 是否输出 JSON。 */
69
+ json?: boolean;
70
+ };
71
+
72
+ /**
73
+ * plugin 控制请求。
74
+ */
75
+ export type PluginControlRequest = {
76
+ /** 目标 plugin 名称。 */
77
+ plugin_name: string;
78
+ /** 控制动作。 */
79
+ action: PluginControlAction;
80
+ };
@@ -63,7 +63,7 @@ export interface Plugin {
63
63
  resolves?: PluginResolves;
64
64
  /** Plugin system 文本构建器(可选)。 */
65
65
  system?: (context: AgentContext) => string | Promise<string>;
66
- /** 旧生命周期兼容定义(可选)。 */
66
+ /** Plugin 生命周期定义(可选)。 */
67
67
  lifecycle?: PluginLifecycle;
68
68
  /** Plugin 可用性检查器(可选)。 */
69
69
  availability?: (
@@ -14,7 +14,7 @@ import type { JsonValue } from "@/types/common/Json.js";
14
14
  import type { PluginActionResult } from "@/types/plugin/PluginAction.js";
15
15
  import type { PluginActionExample } from "@/types/plugin/PluginAction.js";
16
16
  import type { Plugin } from "@/types/plugin/PluginDefinition.js";
17
- import type { AgentSessionSystemBlock } from "@/types/agent/AgentTypes.js";
17
+ import type { AgentSessionSystemBlock } from "@/types/agent/SessionTypes.js";
18
18
  import type { PluginSnapshot } from "@/types/plugin/PluginState.js";
19
19
 
20
20
  /**
@@ -57,8 +57,6 @@ export interface PluginActionReadView {
57
57
  input_schema?: JsonValue;
58
58
  /** Action 调用示例。 */
59
59
  examples?: PluginActionExample[];
60
- /** disabled 状态下是否仍允许执行。 */
61
- allow_when_disabled: boolean;
62
60
  /** 是否声明 CLI command。 */
63
61
  has_command: boolean;
64
62
  /** 是否声明 HTTP API。 */
@@ -46,40 +46,23 @@ export interface PluginSnapshot {
46
46
  description: string;
47
47
  /** 当前注册后的可用状态。 */
48
48
  status: PluginState;
49
- /** 兼容旧字段的状态别名。 */
50
- state: PluginState;
51
49
  /** 注册时间(毫秒时间戳)。 */
52
50
  registered_at: number;
53
51
  /** 最近更新时间(毫秒时间戳)。 */
54
52
  updated_at: number;
55
- /** 兼容旧字段的最近更新时间。 */
56
- updatedAt: number;
57
53
  /** 最近错误。 */
58
54
  last_error?: string;
59
- /** 兼容旧字段的最近错误。 */
60
- lastError?: string;
61
55
  }
62
56
 
63
57
  /**
64
- * 兼容旧名称的 plugin 快照类型。
65
- */
66
- export type PluginStateSnapshot = PluginSnapshot;
67
-
68
- /**
69
- * 兼容旧控制动作类型。
70
- *
71
- * 说明(中文)
72
- * - 控制面只保留状态查询与卸载。
58
+ * Plugin 控制动作。
73
59
  */
74
- export type PluginStateControlAction =
75
- | "register"
76
- | "unregister"
77
- | "status";
60
+ export type PluginControlAction = "unregister" | "status";
78
61
 
79
62
  /**
80
63
  * plugin 控制结果。
81
64
  */
82
- export interface PluginStateControlResult {
65
+ export interface PluginControlResult {
83
66
  /** 控制动作是否成功。 */
84
67
  success: boolean;
85
68
  /** 成功或失败后返回的最新 plugin 快照。 */
@@ -16,13 +16,13 @@ import type {
16
16
  AgentArchiveSessionsResult,
17
17
  AgentCleanArchiveResult,
18
18
  AgentSessionRecordsInput,
19
- AgentSessionStopResult,
20
19
  AgentSessionSystemSnapshot,
21
- } from "@/types/agent/AgentTypes.js";
20
+ } from "@/types/agent/SessionTypes.js";
22
21
  import type { AgentSessionEvent } from "@/types/sdk/AgentSessionEvent.js";
23
22
  import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
23
+ import type { AgentSessionStopResult } from "@/types/sdk/AgentSessionStop.js";
24
24
  import type { JsonObject, JsonValue } from "@/types/common/Json.js";
25
- import type { PluginStateControlAction } from "@/plugin/types/Plugin.js";
25
+ import type { PluginControlAction } from "@/types/plugin/PluginState.js";
26
26
  import type { ShellApprovalMode } from "@downcity/shell";
27
27
 
28
28
  /**
@@ -229,7 +229,7 @@ export type RpcRequest =
229
229
  /** plugin 名称。 */
230
230
  pluginName: string;
231
231
  /** 控制动作。 */
232
- action: PluginStateControlAction;
232
+ action: PluginControlAction;
233
233
  };
234
234
  }
235
235
  | {
@@ -15,7 +15,7 @@ import type {
15
15
  } from "@/types/agent/AgentRuntimeAssembly.js";
16
16
  import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
17
17
  import type { JsonValue } from "@/types/common/Json.js";
18
- import type { AgentPlugins } from "@/plugin/types/Plugin.js";
18
+ import type { AgentPlugins } from "@/types/plugin/PluginRuntime.js";
19
19
  import type { Plugin } from "@/types/plugin/PluginDefinition.js";
20
20
  import type {
21
21
  SessionMetadataV1,
@@ -144,14 +144,6 @@ export interface SessionPort {
144
144
  * - 历史消息持久化仍由 append_user_message / append_assistant_message 负责。
145
145
  */
146
146
  publishEvent(event: AgentSessionEvent): void;
147
- /**
148
- * 清理当前 session 的 executor 缓存。
149
- */
150
- clearExecutor(): void;
151
- /**
152
- * 当前 session 更新后的异步通知钩子。
153
- */
154
- afterSessionUpdatedAsync(): Promise<void>;
155
147
  /**
156
148
  * 追加一条 user 消息。
157
149
  */
@@ -7,7 +7,7 @@
7
7
  * - 这里只保存运行态,不承载行为逻辑。
8
8
  */
9
9
 
10
- import type { AgentSessionConfigSnapshot } from "@/types/agent/AgentTypes.js";
10
+ import type { AgentSessionConfigSnapshot } from "@/types/agent/SessionTypes.js";
11
11
 
12
12
  /**
13
13
  * 本地 Session 内存状态。