@umsai/ums-code 0.3.0-v2 → 0.5.0-v1

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 (294) hide show
  1. package/dist/package.json +4 -4
  2. package/dist/src/{zed-integration → acp-integration}/acp.d.ts +7 -0
  3. package/dist/src/{zed-integration → acp-integration}/acp.js +25 -0
  4. package/dist/src/acp-integration/acp.js.map +1 -0
  5. package/dist/src/acp-integration/acpAgent.d.ts +10 -0
  6. package/dist/src/acp-integration/acpAgent.js +238 -0
  7. package/dist/src/acp-integration/acpAgent.js.map +1 -0
  8. package/dist/src/{zed-integration → acp-integration}/schema.d.ts +1030 -43
  9. package/dist/src/{zed-integration → acp-integration}/schema.js +81 -2
  10. package/dist/src/acp-integration/schema.js.map +1 -0
  11. package/dist/src/{zed-integration/fileSystemService.d.ts → acp-integration/service/filesystem.d.ts} +1 -1
  12. package/dist/src/{zed-integration/fileSystemService.js → acp-integration/service/filesystem.js} +14 -1
  13. package/dist/src/acp-integration/service/filesystem.js.map +1 -0
  14. package/dist/src/acp-integration/service/filesystem.test.d.ts +6 -0
  15. package/dist/src/acp-integration/service/filesystem.test.js +39 -0
  16. package/dist/src/acp-integration/service/filesystem.test.js.map +1 -0
  17. package/dist/src/acp-integration/session/HistoryReplayer.d.ts +51 -0
  18. package/dist/src/acp-integration/session/HistoryReplayer.js +164 -0
  19. package/dist/src/acp-integration/session/HistoryReplayer.js.map +1 -0
  20. package/dist/src/acp-integration/session/HistoryReplayer.test.d.ts +6 -0
  21. package/dist/src/acp-integration/session/HistoryReplayer.test.js +374 -0
  22. package/dist/src/acp-integration/session/HistoryReplayer.test.js.map +1 -0
  23. package/dist/src/acp-integration/session/Session.d.ts +66 -0
  24. package/dist/src/acp-integration/session/Session.js +760 -0
  25. package/dist/src/acp-integration/session/Session.js.map +1 -0
  26. package/dist/src/acp-integration/session/SubAgentTracker.d.ts +51 -0
  27. package/dist/src/acp-integration/session/SubAgentTracker.js +257 -0
  28. package/dist/src/acp-integration/session/SubAgentTracker.js.map +1 -0
  29. package/dist/src/acp-integration/session/SubAgentTracker.test.d.ts +6 -0
  30. package/dist/src/acp-integration/session/SubAgentTracker.test.js +369 -0
  31. package/dist/src/acp-integration/session/SubAgentTracker.test.js.map +1 -0
  32. package/dist/src/acp-integration/session/emitters/BaseEmitter.d.ts +27 -0
  33. package/dist/src/acp-integration/session/emitters/BaseEmitter.js +34 -0
  34. package/dist/src/acp-integration/session/emitters/BaseEmitter.js.map +1 -0
  35. package/dist/src/acp-integration/session/emitters/MessageEmitter.d.ts +41 -0
  36. package/dist/src/acp-integration/session/emitters/MessageEmitter.js +77 -0
  37. package/dist/src/acp-integration/session/emitters/MessageEmitter.js.map +1 -0
  38. package/dist/src/acp-integration/session/emitters/MessageEmitter.test.d.ts +6 -0
  39. package/dist/src/acp-integration/session/emitters/MessageEmitter.test.js +174 -0
  40. package/dist/src/acp-integration/session/emitters/MessageEmitter.test.js.map +1 -0
  41. package/dist/src/acp-integration/session/emitters/PlanEmitter.d.ts +39 -0
  42. package/dist/src/acp-integration/session/emitters/PlanEmitter.js +83 -0
  43. package/dist/src/acp-integration/session/emitters/PlanEmitter.js.map +1 -0
  44. package/dist/src/acp-integration/session/emitters/PlanEmitter.test.d.ts +6 -0
  45. package/dist/src/acp-integration/session/emitters/PlanEmitter.test.js +176 -0
  46. package/dist/src/acp-integration/session/emitters/PlanEmitter.test.js.map +1 -0
  47. package/dist/src/acp-integration/session/emitters/ToolCallEmitter.d.ts +80 -0
  48. package/dist/src/acp-integration/session/emitters/ToolCallEmitter.js +248 -0
  49. package/dist/src/acp-integration/session/emitters/ToolCallEmitter.js.map +1 -0
  50. package/dist/src/acp-integration/session/emitters/ToolCallEmitter.test.d.ts +6 -0
  51. package/dist/src/acp-integration/session/emitters/ToolCallEmitter.test.js +561 -0
  52. package/dist/src/acp-integration/session/emitters/ToolCallEmitter.test.js.map +1 -0
  53. package/dist/src/acp-integration/session/emitters/index.d.ts +9 -0
  54. package/dist/src/acp-integration/session/emitters/index.js +10 -0
  55. package/dist/src/acp-integration/session/emitters/index.js.map +1 -0
  56. package/dist/src/acp-integration/session/index.d.ts +24 -0
  57. package/dist/src/acp-integration/session/index.js +16 -0
  58. package/dist/src/acp-integration/session/index.js.map +1 -0
  59. package/dist/src/acp-integration/session/types.d.ts +71 -0
  60. package/dist/src/acp-integration/session/types.js +7 -0
  61. package/dist/src/acp-integration/session/types.js.map +1 -0
  62. package/dist/src/config/auth.d.ts +1 -0
  63. package/dist/src/config/auth.js +3 -0
  64. package/dist/src/config/auth.js.map +1 -1
  65. package/dist/src/config/config.d.ts +11 -3
  66. package/dist/src/config/config.js +84 -8
  67. package/dist/src/config/config.js.map +1 -1
  68. package/dist/src/config/extension.js +0 -2
  69. package/dist/src/config/extension.js.map +1 -1
  70. package/dist/src/config/settingsSchema.d.ts +12 -0
  71. package/dist/src/config/settingsSchema.js +10 -0
  72. package/dist/src/config/settingsSchema.js.map +1 -1
  73. package/dist/src/core/auth.d.ts +1 -1
  74. package/dist/src/core/auth.js +3 -2
  75. package/dist/src/core/auth.js.map +1 -1
  76. package/dist/src/gemini.js +38 -18
  77. package/dist/src/gemini.js.map +1 -1
  78. package/dist/src/gemini.test.js +7 -0
  79. package/dist/src/gemini.test.js.map +1 -1
  80. package/dist/src/generated/git-commit.d.ts +2 -2
  81. package/dist/src/generated/git-commit.js +2 -2
  82. package/dist/src/i18n/index.d.ts +1 -1
  83. package/dist/src/i18n/index.js +4 -0
  84. package/dist/src/i18n/index.js.map +1 -1
  85. package/dist/src/i18n/locales/en.js +1 -13
  86. package/dist/src/i18n/locales/ru.js +1121 -0
  87. package/dist/src/i18n/locales/zh.js +1 -10
  88. package/dist/src/nonInteractive/control/ControlDispatcher.d.ts +24 -1
  89. package/dist/src/nonInteractive/control/ControlDispatcher.js +46 -17
  90. package/dist/src/nonInteractive/control/ControlDispatcher.js.map +1 -1
  91. package/dist/src/nonInteractive/control/ControlService.d.ts +2 -1
  92. package/dist/src/nonInteractive/control/ControlService.js +22 -37
  93. package/dist/src/nonInteractive/control/ControlService.js.map +1 -1
  94. package/dist/src/nonInteractive/control/controllers/baseController.d.ts +2 -1
  95. package/dist/src/nonInteractive/control/controllers/baseController.js +38 -5
  96. package/dist/src/nonInteractive/control/controllers/baseController.js.map +1 -1
  97. package/dist/src/nonInteractive/control/controllers/permissionController.d.ts +1 -22
  98. package/dist/src/nonInteractive/control/controllers/permissionController.js +38 -38
  99. package/dist/src/nonInteractive/control/controllers/permissionController.js.map +1 -1
  100. package/dist/src/nonInteractive/control/controllers/sdkMcpController.d.ts +54 -0
  101. package/dist/src/nonInteractive/control/controllers/sdkMcpController.js +84 -0
  102. package/dist/src/nonInteractive/control/controllers/sdkMcpController.js.map +1 -0
  103. package/dist/src/nonInteractive/control/controllers/systemController.d.ts +16 -6
  104. package/dist/src/nonInteractive/control/controllers/systemController.js +189 -44
  105. package/dist/src/nonInteractive/control/controllers/systemController.js.map +1 -1
  106. package/dist/src/nonInteractive/control/types/serviceAPIs.d.ts +1 -16
  107. package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.d.ts +11 -0
  108. package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.js +54 -2
  109. package/dist/src/nonInteractive/io/BaseJsonOutputAdapter.js.map +1 -1
  110. package/dist/src/nonInteractive/session.d.ts +0 -16
  111. package/dist/src/nonInteractive/session.js +317 -321
  112. package/dist/src/nonInteractive/session.js.map +1 -1
  113. package/dist/src/nonInteractive/session.test.js +6 -0
  114. package/dist/src/nonInteractive/session.test.js.map +1 -1
  115. package/dist/src/nonInteractive/types.d.ts +57 -3
  116. package/dist/src/nonInteractive/types.js +0 -1
  117. package/dist/src/nonInteractive/types.js.map +1 -1
  118. package/dist/src/nonInteractiveCli.js +25 -46
  119. package/dist/src/nonInteractiveCli.js.map +1 -1
  120. package/dist/src/services/BuiltinCommandLoader.js +5 -6
  121. package/dist/src/services/BuiltinCommandLoader.js.map +1 -1
  122. package/dist/src/services/BuiltinCommandLoader.test.js +0 -3
  123. package/dist/src/services/BuiltinCommandLoader.test.js.map +1 -1
  124. package/dist/src/test-utils/mockCommandContext.js +11 -2
  125. package/dist/src/test-utils/mockCommandContext.js.map +1 -1
  126. package/dist/src/ui/AppContainer.js +39 -36
  127. package/dist/src/ui/AppContainer.js.map +1 -1
  128. package/dist/src/ui/auth/useAuth.js +20 -1
  129. package/dist/src/ui/auth/useAuth.js.map +1 -1
  130. package/dist/src/ui/commands/clearCommand.js +22 -10
  131. package/dist/src/ui/commands/clearCommand.js.map +1 -1
  132. package/dist/src/ui/commands/languageCommand.js +41 -8
  133. package/dist/src/ui/commands/languageCommand.js.map +1 -1
  134. package/dist/src/ui/commands/languageCommand.test.d.ts +6 -0
  135. package/dist/src/ui/commands/languageCommand.test.js +463 -0
  136. package/dist/src/ui/commands/languageCommand.test.js.map +1 -0
  137. package/dist/src/ui/commands/modelCommand.js +4 -2
  138. package/dist/src/ui/commands/modelCommand.js.map +1 -1
  139. package/dist/src/ui/commands/quitCommand.d.ts +0 -1
  140. package/dist/src/ui/commands/quitCommand.js +0 -27
  141. package/dist/src/ui/commands/quitCommand.js.map +1 -1
  142. package/dist/src/ui/commands/reviewCommand.d.ts +9 -0
  143. package/dist/src/ui/commands/reviewCommand.js +1267 -0
  144. package/dist/src/ui/commands/reviewCommand.js.map +1 -0
  145. package/dist/src/ui/commands/reviewCommand.test.d.ts +6 -0
  146. package/dist/src/ui/commands/reviewCommand.test.js +545 -0
  147. package/dist/src/ui/commands/reviewCommand.test.js.map +1 -0
  148. package/dist/src/ui/commands/setupGithubCommand.js +11 -10
  149. package/dist/src/ui/commands/setupGithubCommand.js.map +1 -1
  150. package/dist/src/ui/commands/setupGithubCommand.test.js +14 -14
  151. package/dist/src/ui/commands/setupGithubCommand.test.js.map +1 -1
  152. package/dist/src/ui/commands/types.d.ts +4 -9
  153. package/dist/src/ui/commands/types.js.map +1 -1
  154. package/dist/src/ui/commands/ums/unittestCommand.d.ts +9 -0
  155. package/dist/src/ui/commands/ums/unittestCommand.js +387 -0
  156. package/dist/src/ui/commands/ums/unittestCommand.js.map +1 -0
  157. package/dist/src/ui/components/Composer.test.js +1 -2
  158. package/dist/src/ui/components/Composer.test.js.map +1 -1
  159. package/dist/src/ui/components/ContextUsageDisplay.d.ts +3 -2
  160. package/dist/src/ui/components/ContextUsageDisplay.js +8 -2
  161. package/dist/src/ui/components/ContextUsageDisplay.js.map +1 -1
  162. package/dist/src/ui/components/DialogManager.js +3 -19
  163. package/dist/src/ui/components/DialogManager.js.map +1 -1
  164. package/dist/src/ui/components/Footer.js +2 -3
  165. package/dist/src/ui/components/Footer.js.map +1 -1
  166. package/dist/src/ui/components/Help.js +13 -2
  167. package/dist/src/ui/components/Help.js.map +1 -1
  168. package/dist/src/ui/components/Help.test.js +6 -0
  169. package/dist/src/ui/components/Help.test.js.map +1 -1
  170. package/dist/src/ui/components/HistoryItemDisplay.js +3 -1
  171. package/dist/src/ui/components/HistoryItemDisplay.js.map +1 -1
  172. package/dist/src/ui/components/InputPrompt.js +6 -4
  173. package/dist/src/ui/components/InputPrompt.js.map +1 -1
  174. package/dist/src/ui/components/ModelDialog.d.ts +3 -1
  175. package/dist/src/ui/components/ModelDialog.js +25 -5
  176. package/dist/src/ui/components/ModelDialog.js.map +1 -1
  177. package/dist/src/ui/components/OpenAIKeyPrompt.d.ts +3 -0
  178. package/dist/src/ui/components/OpenAIKeyPrompt.js +1 -0
  179. package/dist/src/ui/components/OpenAIKeyPrompt.js.map +1 -1
  180. package/dist/src/ui/components/ResumeSessionPicker.d.ts +10 -0
  181. package/dist/src/ui/components/ResumeSessionPicker.js +249 -0
  182. package/dist/src/ui/components/ResumeSessionPicker.js.map +1 -0
  183. package/dist/src/ui/components/SessionSummaryDisplay.js +10 -2
  184. package/dist/src/ui/components/SessionSummaryDisplay.js.map +1 -1
  185. package/dist/src/ui/components/SettingsDialog.test.js +2 -2
  186. package/dist/src/ui/components/SuggestionsDisplay.js +3 -2
  187. package/dist/src/ui/components/SuggestionsDisplay.js.map +1 -1
  188. package/dist/src/ui/components/messages/GeminiThoughtMessage.d.ts +18 -0
  189. package/dist/src/ui/components/messages/GeminiThoughtMessage.js +14 -0
  190. package/dist/src/ui/components/messages/GeminiThoughtMessage.js.map +1 -0
  191. package/dist/src/ui/components/messages/GeminiThoughtMessageContent.d.ts +18 -0
  192. package/dist/src/ui/components/messages/GeminiThoughtMessageContent.js +14 -0
  193. package/dist/src/ui/components/messages/GeminiThoughtMessageContent.js.map +1 -0
  194. package/dist/src/ui/components/subagents/manage/AgentEditStep.js +4 -1
  195. package/dist/src/ui/components/subagents/manage/AgentEditStep.js.map +1 -1
  196. package/dist/src/ui/components/subagents/manage/AgentSelectionStep.js +2 -2
  197. package/dist/src/ui/components/subagents/manage/AgentSelectionStep.js.map +1 -1
  198. package/dist/src/ui/components/ums/UMSKeyPrompt.d.ts +1 -1
  199. package/dist/src/ui/components/ums/UMSKeyPrompt.js +23 -3
  200. package/dist/src/ui/components/ums/UMSKeyPrompt.js.map +1 -1
  201. package/dist/src/ui/components/ums/umsStartupWarnings.d.ts +6 -0
  202. package/dist/src/ui/components/ums/umsStartupWarnings.js +47 -0
  203. package/dist/src/ui/components/ums/umsStartupWarnings.js.map +1 -0
  204. package/dist/src/ui/contexts/SessionContext.d.ts +2 -0
  205. package/dist/src/ui/contexts/SessionContext.js +18 -10
  206. package/dist/src/ui/contexts/SessionContext.js.map +1 -1
  207. package/dist/src/ui/contexts/UIStateContext.d.ts +1 -3
  208. package/dist/src/ui/contexts/UIStateContext.js.map +1 -1
  209. package/dist/src/ui/hooks/slashCommandProcessor.d.ts +2 -8
  210. package/dist/src/ui/hooks/slashCommandProcessor.js +68 -101
  211. package/dist/src/ui/hooks/slashCommandProcessor.js.map +1 -1
  212. package/dist/src/ui/hooks/useAttentionNotifications.d.ts +3 -1
  213. package/dist/src/ui/hooks/useAttentionNotifications.js +10 -5
  214. package/dist/src/ui/hooks/useAttentionNotifications.js.map +1 -1
  215. package/dist/src/ui/hooks/useAttentionNotifications.test.js +39 -2
  216. package/dist/src/ui/hooks/useAttentionNotifications.test.js.map +1 -1
  217. package/dist/src/ui/hooks/useDialogClose.d.ts +0 -3
  218. package/dist/src/ui/hooks/useDialogClose.js +0 -2
  219. package/dist/src/ui/hooks/useDialogClose.js.map +1 -1
  220. package/dist/src/ui/hooks/useGeminiStream.js +49 -9
  221. package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
  222. package/dist/src/ui/hooks/useLogger.d.ts +1 -1
  223. package/dist/src/ui/hooks/useLogger.js +6 -3
  224. package/dist/src/ui/hooks/useLogger.js.map +1 -1
  225. package/dist/src/ui/hooks/useReactToolScheduler.js +2 -2
  226. package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
  227. package/dist/src/ui/hooks/useSlashCompletion.js +9 -1
  228. package/dist/src/ui/hooks/useSlashCompletion.js.map +1 -1
  229. package/dist/src/ui/hooks/useSlashCompletion.test.js +36 -31
  230. package/dist/src/ui/hooks/useSlashCompletion.test.js.map +1 -1
  231. package/dist/src/ui/hooks/useToolScheduler.test.js +1 -0
  232. package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
  233. package/dist/src/ui/models/availableModels.d.ts +8 -2
  234. package/dist/src/ui/models/availableModels.js +24 -35
  235. package/dist/src/ui/models/availableModels.js.map +1 -1
  236. package/dist/src/ui/noninteractive/nonInteractiveUi.js +0 -1
  237. package/dist/src/ui/noninteractive/nonInteractiveUi.js.map +1 -1
  238. package/dist/src/ui/types.d.ts +9 -14
  239. package/dist/src/ui/types.js +0 -1
  240. package/dist/src/ui/types.js.map +1 -1
  241. package/dist/src/ui/utils/InlineMarkdownRenderer.d.ts +1 -0
  242. package/dist/src/ui/utils/InlineMarkdownRenderer.js +2 -2
  243. package/dist/src/ui/utils/InlineMarkdownRenderer.js.map +1 -1
  244. package/dist/src/ui/utils/MarkdownDisplay.d.ts +1 -0
  245. package/dist/src/ui/utils/MarkdownDisplay.js +13 -13
  246. package/dist/src/ui/utils/MarkdownDisplay.js.map +1 -1
  247. package/dist/src/ui/utils/formatters.d.ts +6 -0
  248. package/dist/src/ui/utils/formatters.js +31 -0
  249. package/dist/src/ui/utils/formatters.js.map +1 -1
  250. package/dist/src/ui/utils/formatters.test.js +51 -2
  251. package/dist/src/ui/utils/formatters.test.js.map +1 -1
  252. package/dist/src/ui/utils/resumeHistoryUtils.d.ts +19 -0
  253. package/dist/src/ui/utils/resumeHistoryUtils.js +263 -0
  254. package/dist/src/ui/utils/resumeHistoryUtils.js.map +1 -0
  255. package/dist/src/ui/utils/resumeHistoryUtils.test.d.ts +6 -0
  256. package/dist/src/ui/utils/resumeHistoryUtils.test.js +248 -0
  257. package/dist/src/ui/utils/resumeHistoryUtils.test.js.map +1 -0
  258. package/dist/src/utils/attentionNotification.d.ts +1 -0
  259. package/dist/src/utils/attentionNotification.js +4 -0
  260. package/dist/src/utils/attentionNotification.js.map +1 -1
  261. package/dist/src/utils/gitUtils.js +3 -3
  262. package/dist/src/utils/gitUtils.js.map +1 -1
  263. package/dist/src/utils/nonInteractiveHelpers.js +1 -1
  264. package/dist/src/utils/nonInteractiveHelpers.js.map +1 -1
  265. package/dist/src/utils/nonInteractiveHelpers.test.js +1 -1
  266. package/dist/src/utils/nonInteractiveHelpers.test.js.map +1 -1
  267. package/dist/src/validateNonInterActiveAuth.js +1 -1
  268. package/dist/src/validateNonInterActiveAuth.js.map +1 -1
  269. package/dist/tsconfig.tsbuildinfo +1 -1
  270. package/package.json +5 -5
  271. package/dist/src/nonInteractive/control/controllers/mcpController.d.ts +0 -42
  272. package/dist/src/nonInteractive/control/controllers/mcpController.js +0 -205
  273. package/dist/src/nonInteractive/control/controllers/mcpController.js.map +0 -1
  274. package/dist/src/ui/commands/chatCommand.d.ts +0 -9
  275. package/dist/src/ui/commands/chatCommand.js +0 -351
  276. package/dist/src/ui/commands/chatCommand.js.map +0 -1
  277. package/dist/src/ui/commands/corgiCommand.d.ts +0 -7
  278. package/dist/src/ui/commands/corgiCommand.js +0 -16
  279. package/dist/src/ui/commands/corgiCommand.js.map +0 -1
  280. package/dist/src/ui/components/QuitConfirmationDialog.d.ts +0 -17
  281. package/dist/src/ui/components/QuitConfirmationDialog.js +0 -49
  282. package/dist/src/ui/components/QuitConfirmationDialog.js.map +0 -1
  283. package/dist/src/ui/hooks/usePromptCompletion.d.ts +0 -23
  284. package/dist/src/ui/hooks/usePromptCompletion.js +0 -177
  285. package/dist/src/ui/hooks/usePromptCompletion.js.map +0 -1
  286. package/dist/src/ui/hooks/useQuitConfirmation.d.ts +0 -14
  287. package/dist/src/ui/hooks/useQuitConfirmation.js +0 -36
  288. package/dist/src/ui/hooks/useQuitConfirmation.js.map +0 -1
  289. package/dist/src/zed-integration/acp.js.map +0 -1
  290. package/dist/src/zed-integration/fileSystemService.js.map +0 -1
  291. package/dist/src/zed-integration/schema.js.map +0 -1
  292. package/dist/src/zed-integration/zedIntegration.d.ts +0 -17
  293. package/dist/src/zed-integration/zedIntegration.js +0 -1135
  294. package/dist/src/zed-integration/zedIntegration.js.map +0 -1
@@ -0,0 +1,374 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Qwen
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
7
+ import { HistoryReplayer } from './HistoryReplayer.js';
8
+ describe('HistoryReplayer', () => {
9
+ let mockContext;
10
+ let sendUpdateSpy;
11
+ let replayer;
12
+ beforeEach(() => {
13
+ sendUpdateSpy = vi.fn().mockResolvedValue(undefined);
14
+ const mockToolRegistry = {
15
+ getTool: vi.fn().mockReturnValue(null),
16
+ };
17
+ mockContext = {
18
+ sessionId: 'test-session-id',
19
+ config: {
20
+ getToolRegistry: () => mockToolRegistry,
21
+ },
22
+ sendUpdate: sendUpdateSpy,
23
+ };
24
+ replayer = new HistoryReplayer(mockContext);
25
+ });
26
+ const createUserRecord = (text) => ({
27
+ uuid: 'user-uuid',
28
+ parentUuid: null,
29
+ sessionId: 'test-session',
30
+ timestamp: new Date().toISOString(),
31
+ type: 'user',
32
+ cwd: '/test',
33
+ version: '1.0.0',
34
+ message: {
35
+ role: 'user',
36
+ parts: [{ text }],
37
+ },
38
+ });
39
+ const createAssistantRecord = (text, thought = false) => ({
40
+ uuid: 'assistant-uuid',
41
+ parentUuid: 'user-uuid',
42
+ sessionId: 'test-session',
43
+ timestamp: new Date().toISOString(),
44
+ type: 'assistant',
45
+ cwd: '/test',
46
+ version: '1.0.0',
47
+ message: {
48
+ role: 'model',
49
+ parts: [{ text, thought }],
50
+ },
51
+ });
52
+ const createToolResultRecord = (toolName, resultDisplay, hasError = false) => ({
53
+ uuid: 'tool-uuid',
54
+ parentUuid: 'assistant-uuid',
55
+ sessionId: 'test-session',
56
+ timestamp: new Date().toISOString(),
57
+ type: 'tool_result',
58
+ cwd: '/test',
59
+ version: '1.0.0',
60
+ message: {
61
+ role: 'user',
62
+ parts: [
63
+ {
64
+ functionResponse: {
65
+ name: toolName,
66
+ response: { result: 'ok' },
67
+ },
68
+ },
69
+ ],
70
+ },
71
+ toolCallResult: {
72
+ callId: 'call-123',
73
+ responseParts: [],
74
+ resultDisplay,
75
+ error: hasError ? new Error('Tool failed') : undefined,
76
+ errorType: undefined,
77
+ },
78
+ });
79
+ describe('replay', () => {
80
+ it('should replay empty records array', async () => {
81
+ await replayer.replay([]);
82
+ expect(sendUpdateSpy).not.toHaveBeenCalled();
83
+ });
84
+ it('should replay records in order', async () => {
85
+ const records = [
86
+ createUserRecord('Hello'),
87
+ createAssistantRecord('Hi there'),
88
+ ];
89
+ await replayer.replay(records);
90
+ expect(sendUpdateSpy).toHaveBeenCalledTimes(2);
91
+ expect(sendUpdateSpy.mock.calls[0][0].sessionUpdate).toBe('user_message_chunk');
92
+ expect(sendUpdateSpy.mock.calls[1][0].sessionUpdate).toBe('agent_message_chunk');
93
+ });
94
+ });
95
+ describe('user message replay', () => {
96
+ it('should emit user_message_chunk for user records', async () => {
97
+ const records = [createUserRecord('Hello, world!')];
98
+ await replayer.replay(records);
99
+ expect(sendUpdateSpy).toHaveBeenCalledWith({
100
+ sessionUpdate: 'user_message_chunk',
101
+ content: { type: 'text', text: 'Hello, world!' },
102
+ });
103
+ });
104
+ it('should skip user records without message', async () => {
105
+ const record = {
106
+ ...createUserRecord('test'),
107
+ message: undefined,
108
+ };
109
+ await replayer.replay([record]);
110
+ expect(sendUpdateSpy).not.toHaveBeenCalled();
111
+ });
112
+ });
113
+ describe('assistant message replay', () => {
114
+ it('should emit agent_message_chunk for assistant records', async () => {
115
+ const records = [createAssistantRecord('I can help with that.')];
116
+ await replayer.replay(records);
117
+ expect(sendUpdateSpy).toHaveBeenCalledWith({
118
+ sessionUpdate: 'agent_message_chunk',
119
+ content: { type: 'text', text: 'I can help with that.' },
120
+ });
121
+ });
122
+ it('should emit agent_thought_chunk for thought parts', async () => {
123
+ const records = [createAssistantRecord('Thinking about this...', true)];
124
+ await replayer.replay(records);
125
+ expect(sendUpdateSpy).toHaveBeenCalledWith({
126
+ sessionUpdate: 'agent_thought_chunk',
127
+ content: { type: 'text', text: 'Thinking about this...' },
128
+ });
129
+ });
130
+ it('should handle assistant records with multiple parts', async () => {
131
+ const record = {
132
+ ...createAssistantRecord('First'),
133
+ message: {
134
+ role: 'model',
135
+ parts: [
136
+ { text: 'First part' },
137
+ { text: 'Second part', thought: true },
138
+ { text: 'Third part' },
139
+ ],
140
+ },
141
+ };
142
+ await replayer.replay([record]);
143
+ expect(sendUpdateSpy).toHaveBeenCalledTimes(3);
144
+ expect(sendUpdateSpy.mock.calls[0][0]).toEqual({
145
+ sessionUpdate: 'agent_message_chunk',
146
+ content: { type: 'text', text: 'First part' },
147
+ });
148
+ expect(sendUpdateSpy.mock.calls[1][0]).toEqual({
149
+ sessionUpdate: 'agent_thought_chunk',
150
+ content: { type: 'text', text: 'Second part' },
151
+ });
152
+ expect(sendUpdateSpy.mock.calls[2][0]).toEqual({
153
+ sessionUpdate: 'agent_message_chunk',
154
+ content: { type: 'text', text: 'Third part' },
155
+ });
156
+ });
157
+ });
158
+ describe('function call replay', () => {
159
+ it('should emit tool_call for function call parts', async () => {
160
+ const record = {
161
+ ...createAssistantRecord(''),
162
+ message: {
163
+ role: 'model',
164
+ parts: [
165
+ {
166
+ functionCall: {
167
+ name: 'read_file',
168
+ args: { path: '/test.ts' },
169
+ },
170
+ },
171
+ ],
172
+ },
173
+ };
174
+ await replayer.replay([record]);
175
+ expect(sendUpdateSpy).toHaveBeenCalledWith(expect.objectContaining({
176
+ sessionUpdate: 'tool_call',
177
+ status: 'in_progress',
178
+ title: 'read_file',
179
+ rawInput: { path: '/test.ts' },
180
+ }));
181
+ });
182
+ it('should use function call id as callId when available', async () => {
183
+ const record = {
184
+ ...createAssistantRecord(''),
185
+ message: {
186
+ role: 'model',
187
+ parts: [
188
+ {
189
+ functionCall: {
190
+ id: 'custom-call-id',
191
+ name: 'read_file',
192
+ args: {},
193
+ },
194
+ },
195
+ ],
196
+ },
197
+ };
198
+ await replayer.replay([record]);
199
+ expect(sendUpdateSpy).toHaveBeenCalledWith(expect.objectContaining({
200
+ toolCallId: 'custom-call-id',
201
+ }));
202
+ });
203
+ });
204
+ describe('tool result replay', () => {
205
+ it('should emit tool_call_update for tool result records', async () => {
206
+ const records = [
207
+ createToolResultRecord('read_file', 'File contents here'),
208
+ ];
209
+ await replayer.replay(records);
210
+ expect(sendUpdateSpy).toHaveBeenCalledWith({
211
+ sessionUpdate: 'tool_call_update',
212
+ toolCallId: 'call-123',
213
+ status: 'completed',
214
+ content: [
215
+ {
216
+ type: 'content',
217
+ // Content comes from functionResponse.response (stringified)
218
+ content: { type: 'text', text: '{"result":"ok"}' },
219
+ },
220
+ ],
221
+ // resultDisplay is included as rawOutput
222
+ rawOutput: 'File contents here',
223
+ });
224
+ });
225
+ it('should emit failed status for tool results with errors', async () => {
226
+ const records = [createToolResultRecord('failing_tool', undefined, true)];
227
+ await replayer.replay(records);
228
+ expect(sendUpdateSpy).toHaveBeenCalledWith(expect.objectContaining({
229
+ sessionUpdate: 'tool_call_update',
230
+ status: 'failed',
231
+ }));
232
+ });
233
+ it('should emit plan update for TodoWriteTool results', async () => {
234
+ const todoDisplay = {
235
+ type: 'todo_list',
236
+ todos: [
237
+ { id: '1', content: 'Task 1', status: 'pending' },
238
+ { id: '2', content: 'Task 2', status: 'completed' },
239
+ ],
240
+ };
241
+ const record = createToolResultRecord('todo_write', todoDisplay);
242
+ // Override the function response name
243
+ record.message = {
244
+ role: 'user',
245
+ parts: [
246
+ {
247
+ functionResponse: {
248
+ name: 'todo_write',
249
+ response: { result: 'ok' },
250
+ },
251
+ },
252
+ ],
253
+ };
254
+ await replayer.replay([record]);
255
+ expect(sendUpdateSpy).toHaveBeenCalledWith({
256
+ sessionUpdate: 'plan',
257
+ entries: [
258
+ { content: 'Task 1', priority: 'medium', status: 'pending' },
259
+ { content: 'Task 2', priority: 'medium', status: 'completed' },
260
+ ],
261
+ });
262
+ });
263
+ it('should use record uuid as callId when toolCallResult.callId is missing', async () => {
264
+ const record = {
265
+ ...createToolResultRecord('test_tool'),
266
+ uuid: 'fallback-uuid',
267
+ toolCallResult: {
268
+ callId: undefined,
269
+ responseParts: [],
270
+ resultDisplay: 'Result',
271
+ error: undefined,
272
+ errorType: undefined,
273
+ },
274
+ };
275
+ await replayer.replay([record]);
276
+ expect(sendUpdateSpy).toHaveBeenCalledWith(expect.objectContaining({
277
+ toolCallId: 'fallback-uuid',
278
+ }));
279
+ });
280
+ });
281
+ describe('system records', () => {
282
+ it('should skip system records', async () => {
283
+ const systemRecord = {
284
+ uuid: 'system-uuid',
285
+ parentUuid: null,
286
+ sessionId: 'test-session',
287
+ timestamp: new Date().toISOString(),
288
+ type: 'system',
289
+ subtype: 'chat_compression',
290
+ cwd: '/test',
291
+ version: '1.0.0',
292
+ };
293
+ await replayer.replay([systemRecord]);
294
+ expect(sendUpdateSpy).not.toHaveBeenCalled();
295
+ });
296
+ });
297
+ describe('mixed record types', () => {
298
+ it('should handle a complete conversation replay', async () => {
299
+ const records = [
300
+ createUserRecord('Read the file test.ts'),
301
+ {
302
+ ...createAssistantRecord(''),
303
+ message: {
304
+ role: 'model',
305
+ parts: [
306
+ { text: "I'll read that file for you.", thought: true },
307
+ {
308
+ functionCall: {
309
+ id: 'call-read',
310
+ name: 'read_file',
311
+ args: { path: 'test.ts' },
312
+ },
313
+ },
314
+ ],
315
+ },
316
+ },
317
+ createToolResultRecord('read_file', 'export const x = 1;'),
318
+ createAssistantRecord('The file contains a simple export.'),
319
+ ];
320
+ await replayer.replay(records);
321
+ // Verify order and types of updates
322
+ const updateTypes = sendUpdateSpy.mock.calls.map((call) => call[0].sessionUpdate);
323
+ expect(updateTypes).toEqual([
324
+ 'user_message_chunk',
325
+ 'agent_thought_chunk',
326
+ 'tool_call',
327
+ 'tool_call_update',
328
+ 'agent_message_chunk',
329
+ ]);
330
+ });
331
+ });
332
+ describe('usage metadata replay', () => {
333
+ it('should emit usage metadata after assistant message content', async () => {
334
+ const record = {
335
+ uuid: 'assistant-uuid',
336
+ parentUuid: 'user-uuid',
337
+ sessionId: 'test-session',
338
+ timestamp: new Date().toISOString(),
339
+ type: 'assistant',
340
+ cwd: '/test',
341
+ version: '1.0.0',
342
+ message: {
343
+ role: 'model',
344
+ parts: [{ text: 'Hello!' }],
345
+ },
346
+ usageMetadata: {
347
+ promptTokenCount: 100,
348
+ candidatesTokenCount: 50,
349
+ totalTokenCount: 150,
350
+ },
351
+ };
352
+ await replayer.replay([record]);
353
+ expect(sendUpdateSpy).toHaveBeenCalledTimes(2);
354
+ expect(sendUpdateSpy).toHaveBeenNthCalledWith(1, {
355
+ sessionUpdate: 'agent_message_chunk',
356
+ content: { type: 'text', text: 'Hello!' },
357
+ });
358
+ expect(sendUpdateSpy).toHaveBeenNthCalledWith(2, {
359
+ sessionUpdate: 'agent_message_chunk',
360
+ content: { type: 'text', text: '' },
361
+ _meta: {
362
+ usage: {
363
+ promptTokens: 100,
364
+ completionTokens: 50,
365
+ thoughtsTokens: undefined,
366
+ totalTokens: 150,
367
+ cachedTokens: undefined,
368
+ },
369
+ },
370
+ });
371
+ });
372
+ });
373
+ });
374
+ //# sourceMappingURL=HistoryReplayer.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HistoryReplayer.test.js","sourceRoot":"","sources":["../../../../src/acp-integration/session/HistoryReplayer.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAUvD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,WAA2B,CAAC;IAChC,IAAI,aAAuC,CAAC;IAC5C,IAAI,QAAyB,CAAC;IAE9B,UAAU,CAAC,GAAG,EAAE;QACd,aAAa,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACrD,MAAM,gBAAgB,GAAG;YACvB,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;SACZ,CAAC;QAE7B,WAAW,GAAG;YACZ,SAAS,EAAE,iBAAiB;YAC5B,MAAM,EAAE;gBACN,eAAe,EAAE,GAAG,EAAE,CAAC,gBAAgB;aACnB;YACtB,UAAU,EAAE,aAAa;SAC1B,CAAC;QAEF,QAAQ,GAAG,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAc,EAAE,CAAC,CAAC;QACtD,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,cAAc;QACzB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,OAAO;QAC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CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE;gBAC/C,aAAa,EAAE,qBAAqB;gBACpC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE;gBACnC,KAAK,EAAE;oBACL,KAAK,EAAE;wBACL,YAAY,EAAE,GAAG;wBACjB,gBAAgB,EAAE,EAAE;wBACpB,cAAc,EAAE,SAAS;wBACzB,WAAW,EAAE,GAAG;wBAChB,YAAY,EAAE,SAAS;qBACxB;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Qwen
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { Config, GeminiChat, ChatRecord } from '@umsai/ums-code-core';
7
+ import * as acp from '../acp.js';
8
+ import type { LoadedSettings } from '../../config/settings.js';
9
+ import type { SetModeRequest, SetModeResponse } from '../schema.js';
10
+ import type { SessionContext } from './types.js';
11
+ /**
12
+ * Built-in commands that are allowed in ACP integration mode.
13
+ * Only safe, read-only commands that don't require interactive UI.
14
+ */
15
+ export declare const ALLOWED_BUILTIN_COMMANDS_FOR_ACP: string[];
16
+ /**
17
+ * Session represents an active conversation session with the AI model.
18
+ * It uses modular components for consistent event emission:
19
+ * - HistoryReplayer for replaying past conversations
20
+ * - ToolCallEmitter for tool-related session updates
21
+ * - PlanEmitter for todo/plan updates
22
+ * - SubAgentTracker for tracking sub-agent tool calls
23
+ */
24
+ export declare class Session implements SessionContext {
25
+ #private;
26
+ private readonly chat;
27
+ readonly config: Config;
28
+ private readonly client;
29
+ private readonly settings;
30
+ private pendingPrompt;
31
+ private turn;
32
+ private readonly historyReplayer;
33
+ private readonly toolCallEmitter;
34
+ private readonly planEmitter;
35
+ private readonly messageEmitter;
36
+ readonly sessionId: string;
37
+ constructor(id: string, chat: GeminiChat, config: Config, client: acp.Client, settings: LoadedSettings);
38
+ getId(): string;
39
+ getConfig(): Config;
40
+ /**
41
+ * Replays conversation history to the client using modular components.
42
+ * Delegates to HistoryReplayer for consistent event emission.
43
+ */
44
+ replayHistory(records: ChatRecord[]): Promise<void>;
45
+ cancelPendingPrompt(): Promise<void>;
46
+ prompt(params: acp.PromptRequest): Promise<acp.PromptResponse>;
47
+ sendUpdate(update: acp.SessionUpdate): Promise<void>;
48
+ sendAvailableCommandsUpdate(): Promise<void>;
49
+ /**
50
+ * Requests permission from the client for a tool call.
51
+ * Used by SubAgentTracker for sub-agent approval requests.
52
+ */
53
+ requestPermission(params: acp.RequestPermissionRequest): Promise<acp.RequestPermissionResponse>;
54
+ /**
55
+ * Sets the approval mode for the current session.
56
+ * Maps ACP approval mode values to core ApprovalMode enum.
57
+ */
58
+ setMode(params: SetModeRequest): Promise<SetModeResponse>;
59
+ /**
60
+ * Sends a current_mode_update notification to the client.
61
+ * Called after the agent switches modes (e.g., from exit_plan_mode tool).
62
+ */
63
+ private sendCurrentModeUpdateNotification;
64
+ private runTool;
65
+ debug(msg: string): void;
66
+ }