@downcity/agent 1.1.13 → 1.1.14

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 (463) hide show
  1. package/bin/{runtime → core}/AgentContextTypes.d.ts +6 -6
  2. package/bin/core/AgentContextTypes.d.ts.map +1 -0
  3. package/bin/{runtime → core}/AgentContextTypes.js +2 -2
  4. package/bin/core/AgentContextTypes.js.map +1 -0
  5. package/bin/core/AgentCore.d.ts +87 -0
  6. package/bin/core/AgentCore.d.ts.map +1 -0
  7. package/bin/core/AgentCore.js +467 -0
  8. package/bin/core/AgentCore.js.map +1 -0
  9. package/bin/{runtime/AgentRuntimeTypes.d.ts → core/AgentCoreTypes.d.ts} +7 -7
  10. package/bin/core/AgentCoreTypes.d.ts.map +1 -0
  11. package/bin/core/AgentCoreTypes.js +10 -0
  12. package/bin/core/AgentCoreTypes.js.map +1 -0
  13. package/bin/host/runtime/PluginRuntime.d.ts +1 -1
  14. package/bin/host/runtime/PluginRuntime.d.ts.map +1 -1
  15. package/bin/index.d.ts +6 -8
  16. package/bin/index.d.ts.map +1 -1
  17. package/bin/index.js +2 -5
  18. package/bin/index.js.map +1 -1
  19. package/bin/plugin/builtins/asr/InboundAugment.d.ts +1 -1
  20. package/bin/plugin/builtins/asr/InboundAugment.d.ts.map +1 -1
  21. package/bin/plugin/builtins/auth/runtime/AuthorizationConfig.d.ts +1 -1
  22. package/bin/plugin/builtins/auth/runtime/AuthorizationConfig.d.ts.map +1 -1
  23. package/bin/plugin/builtins/auth/runtime/AuthorizationStore.d.ts +1 -1
  24. package/bin/plugin/builtins/auth/runtime/AuthorizationStore.d.ts.map +1 -1
  25. package/bin/plugin/builtins/voice/InboundAugment.d.ts +1 -1
  26. package/bin/plugin/builtins/voice/InboundAugment.d.ts.map +1 -1
  27. package/bin/plugin/builtins/workboard/runtime/Collector.d.ts +1 -1
  28. package/bin/plugin/builtins/workboard/runtime/Collector.d.ts.map +1 -1
  29. package/bin/plugin/builtins/workboard/runtime/Collector.js +1 -1
  30. package/bin/plugin/builtins/workboard/runtime/Collector.js.map +1 -1
  31. package/bin/plugin/builtins/workboard/runtime/Normalizer.d.ts +1 -1
  32. package/bin/plugin/builtins/workboard/runtime/Normalizer.d.ts.map +1 -1
  33. package/bin/plugin/builtins/workboard/runtime/Store.d.ts +1 -1
  34. package/bin/plugin/builtins/workboard/runtime/Store.d.ts.map +1 -1
  35. package/bin/plugin/core/Activation.d.ts +2 -2
  36. package/bin/plugin/core/Activation.d.ts.map +1 -1
  37. package/bin/plugin/core/HookRegistry.d.ts +1 -1
  38. package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
  39. package/bin/plugin/core/HttpRoutes.d.ts +1 -1
  40. package/bin/plugin/core/HttpRoutes.d.ts.map +1 -1
  41. package/bin/plugin/core/LocalExecution.d.ts.map +1 -1
  42. package/bin/plugin/core/LocalExecution.js +18 -20
  43. package/bin/plugin/core/LocalExecution.js.map +1 -1
  44. package/bin/plugin/core/PluginRegistry.d.ts +1 -1
  45. package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
  46. package/bin/plugin/types/Plugin.d.ts +1 -1
  47. package/bin/plugin/types/Plugin.d.ts.map +1 -1
  48. package/bin/sandbox/SandboxConfigResolver.d.ts +1 -1
  49. package/bin/sandbox/SandboxConfigResolver.d.ts.map +1 -1
  50. package/bin/sandbox/SandboxRunner.d.ts +1 -1
  51. package/bin/sandbox/SandboxRunner.d.ts.map +1 -1
  52. package/bin/sdk/Agent.d.ts +25 -23
  53. package/bin/sdk/Agent.d.ts.map +1 -1
  54. package/bin/sdk/Agent.js +86 -365
  55. package/bin/sdk/Agent.js.map +1 -1
  56. package/bin/sdk/AgentSdkTypes.d.ts +138 -0
  57. package/bin/sdk/AgentSdkTypes.d.ts.map +1 -1
  58. package/bin/sdk/HttpServer.d.ts +9 -19
  59. package/bin/sdk/HttpServer.d.ts.map +1 -1
  60. package/bin/sdk/HttpServer.js +26 -156
  61. package/bin/sdk/HttpServer.js.map +1 -1
  62. package/bin/sdk/RpcServer.d.ts +9 -10
  63. package/bin/sdk/RpcServer.d.ts.map +1 -1
  64. package/bin/sdk/RpcServer.js +22 -178
  65. package/bin/sdk/RpcServer.js.map +1 -1
  66. package/bin/sdk/Session.d.ts +2 -2
  67. package/bin/sdk/Session.d.ts.map +1 -1
  68. package/bin/sdk/Session.js +7 -1
  69. package/bin/sdk/Session.js.map +1 -1
  70. package/bin/sdk/SessionServicePort.d.ts +1 -1
  71. package/bin/sdk/SessionServicePort.d.ts.map +1 -1
  72. package/bin/server/http/Server.d.ts +10 -1
  73. package/bin/server/http/Server.d.ts.map +1 -1
  74. package/bin/server/http/Server.js +41 -15
  75. package/bin/server/http/Server.js.map +1 -1
  76. package/bin/server/http/control/AuthControlService.d.ts +1 -1
  77. package/bin/server/http/control/AuthControlService.d.ts.map +1 -1
  78. package/bin/server/http/control/ControlAuthorizationRoutes.d.ts +1 -1
  79. package/bin/server/http/control/ControlAuthorizationRoutes.d.ts.map +1 -1
  80. package/bin/server/http/control/ControlRouter.d.ts +18 -2
  81. package/bin/server/http/control/ControlRouter.d.ts.map +1 -1
  82. package/bin/server/http/control/ControlRouter.js +10 -8
  83. package/bin/server/http/control/ControlRouter.js.map +1 -1
  84. package/bin/server/http/control/ExecuteBySession.d.ts +2 -2
  85. package/bin/server/http/control/ExecuteBySession.d.ts.map +1 -1
  86. package/bin/server/http/control/OverviewRoutes.d.ts.map +1 -1
  87. package/bin/server/http/control/OverviewRoutes.js +6 -2
  88. package/bin/server/http/control/OverviewRoutes.js.map +1 -1
  89. package/bin/server/http/control/SessionSummaryStore.d.ts +1 -1
  90. package/bin/server/http/control/SessionSummaryStore.d.ts.map +1 -1
  91. package/bin/server/http/control/types/ControlRoutes.d.ts +2 -2
  92. package/bin/server/http/control/types/ControlRoutes.d.ts.map +1 -1
  93. package/bin/server/http/execute/execute.d.ts +13 -2
  94. package/bin/server/http/execute/execute.d.ts.map +1 -1
  95. package/bin/server/http/execute/execute.js +73 -71
  96. package/bin/server/http/execute/execute.js.map +1 -1
  97. package/bin/server/http/plugins/plugins.d.ts +13 -2
  98. package/bin/server/http/plugins/plugins.d.ts.map +1 -1
  99. package/bin/server/http/plugins/plugins.js +42 -40
  100. package/bin/server/http/plugins/plugins.js.map +1 -1
  101. package/bin/server/http/services/services.d.ts +12 -8
  102. package/bin/server/http/services/services.d.ts.map +1 -1
  103. package/bin/server/http/services/services.js +57 -64
  104. package/bin/server/http/services/services.js.map +1 -1
  105. package/bin/server/http/static/static.d.ts +13 -2
  106. package/bin/server/http/static/static.d.ts.map +1 -1
  107. package/bin/server/http/static/static.js +81 -79
  108. package/bin/server/http/static/static.js.map +1 -1
  109. package/bin/server/rpc/Server.d.ts +5 -3
  110. package/bin/server/rpc/Server.d.ts.map +1 -1
  111. package/bin/server/rpc/Server.js +22 -12
  112. package/bin/server/rpc/Server.js.map +1 -1
  113. package/bin/service/builtins/BaseService.d.ts +2 -2
  114. package/bin/service/builtins/BaseService.d.ts.map +1 -1
  115. package/bin/service/builtins/chat/Action.d.ts +1 -1
  116. package/bin/service/builtins/chat/Action.d.ts.map +1 -1
  117. package/bin/service/builtins/chat/ChatService.d.ts +2 -2
  118. package/bin/service/builtins/chat/ChatService.d.ts.map +1 -1
  119. package/bin/service/builtins/chat/ChatServiceTypes.d.ts +1 -1
  120. package/bin/service/builtins/chat/ChatServiceTypes.d.ts.map +1 -1
  121. package/bin/service/builtins/chat/channels/BaseChatChannel.d.ts +1 -1
  122. package/bin/service/builtins/chat/channels/BaseChatChannel.d.ts.map +1 -1
  123. package/bin/service/builtins/chat/channels/BaseChatChannelQueue.d.ts +1 -1
  124. package/bin/service/builtins/chat/channels/BaseChatChannelQueue.d.ts.map +1 -1
  125. package/bin/service/builtins/chat/channels/BaseChatChannelSupport.d.ts +1 -1
  126. package/bin/service/builtins/chat/channels/BaseChatChannelSupport.d.ts.map +1 -1
  127. package/bin/service/builtins/chat/channels/feishu/Feishu.d.ts +1 -1
  128. package/bin/service/builtins/chat/channels/feishu/Feishu.d.ts.map +1 -1
  129. package/bin/service/builtins/chat/channels/feishu/FeishuMessageHandler.d.ts +1 -1
  130. package/bin/service/builtins/chat/channels/feishu/FeishuMessageHandler.d.ts.map +1 -1
  131. package/bin/service/builtins/chat/channels/feishu/FeishuPlatformClient.d.ts +1 -1
  132. package/bin/service/builtins/chat/channels/feishu/FeishuPlatformClient.d.ts.map +1 -1
  133. package/bin/service/builtins/chat/channels/qq/QQ.d.ts +1 -1
  134. package/bin/service/builtins/chat/channels/qq/QQ.d.ts.map +1 -1
  135. package/bin/service/builtins/chat/channels/qq/QQMessageHandler.d.ts +1 -1
  136. package/bin/service/builtins/chat/channels/qq/QQMessageHandler.d.ts.map +1 -1
  137. package/bin/service/builtins/chat/channels/qq/QQSupport.d.ts +1 -1
  138. package/bin/service/builtins/chat/channels/qq/QQSupport.d.ts.map +1 -1
  139. package/bin/service/builtins/chat/channels/telegram/Bot.d.ts +1 -1
  140. package/bin/service/builtins/chat/channels/telegram/Bot.d.ts.map +1 -1
  141. package/bin/service/builtins/chat/channels/telegram/TelegramMessageHandler.d.ts +1 -1
  142. package/bin/service/builtins/chat/channels/telegram/TelegramMessageHandler.d.ts.map +1 -1
  143. package/bin/service/builtins/chat/channels/telegram/TelegramPlatformClient.d.ts +1 -1
  144. package/bin/service/builtins/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
  145. package/bin/service/builtins/chat/runtime/ChannelContextStore.d.ts +1 -1
  146. package/bin/service/builtins/chat/runtime/ChannelContextStore.d.ts.map +1 -1
  147. package/bin/service/builtins/chat/runtime/ChatActionExecution.d.ts +1 -1
  148. package/bin/service/builtins/chat/runtime/ChatActionExecution.d.ts.map +1 -1
  149. package/bin/service/builtins/chat/runtime/ChatActionInput.d.ts +3 -36
  150. package/bin/service/builtins/chat/runtime/ChatActionInput.d.ts.map +1 -1
  151. package/bin/service/builtins/chat/runtime/ChatActionInput.js +3 -118
  152. package/bin/service/builtins/chat/runtime/ChatActionInput.js.map +1 -1
  153. package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts +1 -1
  154. package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts.map +1 -1
  155. package/bin/service/builtins/chat/runtime/ChatChannelConfig.d.ts +1 -1
  156. package/bin/service/builtins/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
  157. package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts +1 -1
  158. package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts.map +1 -1
  159. package/bin/service/builtins/chat/runtime/ChatChannelLifecycle.d.ts +1 -1
  160. package/bin/service/builtins/chat/runtime/ChatChannelLifecycle.d.ts.map +1 -1
  161. package/bin/service/builtins/chat/runtime/ChatHistoryStore.d.ts +1 -1
  162. package/bin/service/builtins/chat/runtime/ChatHistoryStore.d.ts.map +1 -1
  163. package/bin/service/builtins/chat/runtime/ChatIngressStore.d.ts +1 -1
  164. package/bin/service/builtins/chat/runtime/ChatIngressStore.d.ts.map +1 -1
  165. package/bin/service/builtins/chat/runtime/ChatMetaStore.d.ts +1 -1
  166. package/bin/service/builtins/chat/runtime/ChatMetaStore.d.ts.map +1 -1
  167. package/bin/service/builtins/chat/runtime/ChatQueueReplyDispatch.d.ts +1 -1
  168. package/bin/service/builtins/chat/runtime/ChatQueueReplyDispatch.d.ts.map +1 -1
  169. package/bin/service/builtins/chat/runtime/ChatQueueSessionBridge.d.ts +1 -1
  170. package/bin/service/builtins/chat/runtime/ChatQueueSessionBridge.d.ts.map +1 -1
  171. package/bin/service/builtins/chat/runtime/ChatQueueStore.d.ts +1 -1
  172. package/bin/service/builtins/chat/runtime/ChatQueueStore.d.ts.map +1 -1
  173. package/bin/service/builtins/chat/runtime/ChatQueueWorker.d.ts +1 -1
  174. package/bin/service/builtins/chat/runtime/ChatQueueWorker.d.ts.map +1 -1
  175. package/bin/service/builtins/chat/runtime/ChatServiceActions.d.ts +1 -1
  176. package/bin/service/builtins/chat/runtime/ChatServiceActions.d.ts.map +1 -1
  177. package/bin/service/builtins/chat/runtime/ChatServiceActions.js +2 -109
  178. package/bin/service/builtins/chat/runtime/ChatServiceActions.js.map +1 -1
  179. package/bin/service/builtins/chat/runtime/ChatServiceSystem.d.ts +1 -1
  180. package/bin/service/builtins/chat/runtime/ChatServiceSystem.d.ts.map +1 -1
  181. package/bin/service/builtins/chat/runtime/ChatSessionDelete.d.ts +1 -1
  182. package/bin/service/builtins/chat/runtime/ChatSessionDelete.d.ts.map +1 -1
  183. package/bin/service/builtins/chat/runtime/ChatkeySend.d.ts +1 -1
  184. package/bin/service/builtins/chat/runtime/ChatkeySend.d.ts.map +1 -1
  185. package/bin/service/builtins/chat/runtime/EnqueueDispatch.d.ts +1 -1
  186. package/bin/service/builtins/chat/runtime/EnqueueDispatch.d.ts.map +1 -1
  187. package/bin/service/builtins/chat/runtime/InboundAugment.d.ts +1 -1
  188. package/bin/service/builtins/chat/runtime/InboundAugment.d.ts.map +1 -1
  189. package/bin/service/builtins/chat/runtime/PluginDispatch.d.ts +1 -1
  190. package/bin/service/builtins/chat/runtime/PluginDispatch.d.ts.map +1 -1
  191. package/bin/service/builtins/chat/runtime/ReplyDispatch.d.ts +1 -1
  192. package/bin/service/builtins/chat/runtime/ReplyDispatch.d.ts.map +1 -1
  193. package/bin/service/builtins/chat/runtime/SystemPrompt.d.ts +1 -1
  194. package/bin/service/builtins/chat/runtime/SystemPrompt.d.ts.map +1 -1
  195. package/bin/service/builtins/contact/Action.d.ts +2 -2
  196. package/bin/service/builtins/contact/Action.d.ts.map +1 -1
  197. package/bin/service/builtins/contact/Action.js +2 -58
  198. package/bin/service/builtins/contact/Action.js.map +1 -1
  199. package/bin/service/builtins/contact/ContactService.d.ts +1 -1
  200. package/bin/service/builtins/contact/ContactService.d.ts.map +1 -1
  201. package/bin/service/builtins/contact/runtime/ChatRuntime.d.ts +1 -1
  202. package/bin/service/builtins/contact/runtime/ChatRuntime.d.ts.map +1 -1
  203. package/bin/service/builtins/contact/runtime/ContactPayload.d.ts +0 -7
  204. package/bin/service/builtins/contact/runtime/ContactPayload.d.ts.map +1 -1
  205. package/bin/service/builtins/contact/runtime/ContactPayload.js +0 -9
  206. package/bin/service/builtins/contact/runtime/ContactPayload.js.map +1 -1
  207. package/bin/service/builtins/contact/runtime/RemoteClient.d.ts +1 -1
  208. package/bin/service/builtins/contact/runtime/RemoteClient.d.ts.map +1 -1
  209. package/bin/service/builtins/contact/runtime/RemoteClient.js +37 -19
  210. package/bin/service/builtins/contact/runtime/RemoteClient.js.map +1 -1
  211. package/bin/service/builtins/contact/runtime/ShareBundle.d.ts +1 -1
  212. package/bin/service/builtins/contact/runtime/ShareBundle.d.ts.map +1 -1
  213. package/bin/service/builtins/memory/Action.d.ts +1 -1
  214. package/bin/service/builtins/memory/Action.d.ts.map +1 -1
  215. package/bin/service/builtins/memory/MemoryService.d.ts +1 -1
  216. package/bin/service/builtins/memory/MemoryService.d.ts.map +1 -1
  217. package/bin/service/builtins/memory/MemoryService.js +0 -27
  218. package/bin/service/builtins/memory/MemoryService.js.map +1 -1
  219. package/bin/service/builtins/memory/runtime/Flush.d.ts +1 -1
  220. package/bin/service/builtins/memory/runtime/Flush.d.ts.map +1 -1
  221. package/bin/service/builtins/memory/runtime/Search.d.ts +1 -1
  222. package/bin/service/builtins/memory/runtime/Search.d.ts.map +1 -1
  223. package/bin/service/builtins/memory/runtime/Store.d.ts +1 -1
  224. package/bin/service/builtins/memory/runtime/Store.d.ts.map +1 -1
  225. package/bin/service/builtins/memory/runtime/SystemProvider.d.ts +1 -1
  226. package/bin/service/builtins/memory/runtime/SystemProvider.d.ts.map +1 -1
  227. package/bin/service/builtins/memory/runtime/Writer.d.ts +1 -1
  228. package/bin/service/builtins/memory/runtime/Writer.d.ts.map +1 -1
  229. package/bin/service/builtins/schedule/ScheduleService.d.ts +39 -0
  230. package/bin/service/builtins/schedule/ScheduleService.d.ts.map +1 -0
  231. package/bin/service/builtins/schedule/ScheduleService.js +106 -0
  232. package/bin/service/builtins/schedule/ScheduleService.js.map +1 -0
  233. package/bin/service/builtins/shell/ShellRuntimeTypes.d.ts +1 -1
  234. package/bin/service/builtins/shell/ShellRuntimeTypes.d.ts.map +1 -1
  235. package/bin/service/builtins/shell/ShellService.d.ts +2 -2
  236. package/bin/service/builtins/shell/ShellService.d.ts.map +1 -1
  237. package/bin/service/builtins/shell/runtime/ShellActionResponse.d.ts +1 -1
  238. package/bin/service/builtins/shell/runtime/ShellActionResponse.d.ts.map +1 -1
  239. package/bin/service/builtins/shell/runtime/ShellActionRuntime.d.ts +1 -1
  240. package/bin/service/builtins/shell/runtime/ShellActionRuntime.d.ts.map +1 -1
  241. package/bin/service/builtins/shell/runtime/ShellActionRuntimeSupport.d.ts +1 -1
  242. package/bin/service/builtins/shell/runtime/ShellActionRuntimeSupport.d.ts.map +1 -1
  243. package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.d.ts +1 -1
  244. package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.d.ts.map +1 -1
  245. package/bin/service/builtins/task/Action.d.ts +1 -1
  246. package/bin/service/builtins/task/Action.d.ts.map +1 -1
  247. package/bin/service/builtins/task/Scheduler.d.ts +1 -1
  248. package/bin/service/builtins/task/Scheduler.d.ts.map +1 -1
  249. package/bin/service/builtins/task/TaskService.d.ts +2 -2
  250. package/bin/service/builtins/task/TaskService.d.ts.map +1 -1
  251. package/bin/service/builtins/task/runtime/CronRuntime.d.ts +1 -1
  252. package/bin/service/builtins/task/runtime/CronRuntime.d.ts.map +1 -1
  253. package/bin/service/builtins/task/runtime/Runner.d.ts +1 -1
  254. package/bin/service/builtins/task/runtime/Runner.d.ts.map +1 -1
  255. package/bin/service/builtins/task/runtime/TaskActionExecution.d.ts +1 -1
  256. package/bin/service/builtins/task/runtime/TaskActionExecution.d.ts.map +1 -1
  257. package/bin/service/builtins/task/runtime/TaskActionInput.d.ts +2 -31
  258. package/bin/service/builtins/task/runtime/TaskActionInput.d.ts.map +1 -1
  259. package/bin/service/builtins/task/runtime/TaskActionInput.js +2 -141
  260. package/bin/service/builtins/task/runtime/TaskActionInput.js.map +1 -1
  261. package/bin/service/builtins/task/runtime/TaskRunChatDispatch.d.ts +1 -1
  262. package/bin/service/builtins/task/runtime/TaskRunChatDispatch.d.ts.map +1 -1
  263. package/bin/service/builtins/task/runtime/TaskRunnerRound.d.ts +1 -1
  264. package/bin/service/builtins/task/runtime/TaskRunnerRound.d.ts.map +1 -1
  265. package/bin/service/builtins/task/runtime/TaskRunnerScript.d.ts +1 -1
  266. package/bin/service/builtins/task/runtime/TaskRunnerScript.d.ts.map +1 -1
  267. package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts +1 -1
  268. package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts.map +1 -1
  269. package/bin/service/builtins/task/runtime/TaskServiceActions.d.ts +1 -1
  270. package/bin/service/builtins/task/runtime/TaskServiceActions.d.ts.map +1 -1
  271. package/bin/service/builtins/task/runtime/TaskServiceActions.js +2 -30
  272. package/bin/service/builtins/task/runtime/TaskServiceActions.js.map +1 -1
  273. package/bin/service/core/Manager.d.ts +0 -1
  274. package/bin/service/core/Manager.d.ts.map +1 -1
  275. package/bin/service/core/Manager.js +0 -1
  276. package/bin/service/core/Manager.js.map +1 -1
  277. package/bin/service/core/ServiceActionRunner.d.ts +1 -1
  278. package/bin/service/core/ServiceActionRunner.d.ts.map +1 -1
  279. package/bin/service/core/ServiceActionRunner.js +3 -1
  280. package/bin/service/core/ServiceActionRunner.js.map +1 -1
  281. package/bin/service/core/ServiceClassRegistry.d.ts +1 -1
  282. package/bin/service/core/ServiceClassRegistry.d.ts.map +1 -1
  283. package/bin/service/core/ServiceCommandRequest.d.ts +36 -0
  284. package/bin/service/core/ServiceCommandRequest.d.ts.map +1 -0
  285. package/bin/service/core/ServiceCommandRequest.js +53 -0
  286. package/bin/service/core/ServiceCommandRequest.js.map +1 -0
  287. package/bin/service/core/ServiceManager.d.ts +1 -1
  288. package/bin/service/core/ServiceManager.d.ts.map +1 -1
  289. package/bin/service/core/ServiceStateController.d.ts +20 -7
  290. package/bin/service/core/ServiceStateController.d.ts.map +1 -1
  291. package/bin/service/core/ServiceStateController.js +23 -20
  292. package/bin/service/core/ServiceStateController.js.map +1 -1
  293. package/bin/service/core/ServiceSystemProviders.d.ts +1 -1
  294. package/bin/service/core/ServiceSystemProviders.d.ts.map +1 -1
  295. package/bin/service/core/Services.d.ts +1 -1
  296. package/bin/service/core/Services.d.ts.map +1 -1
  297. package/bin/service/core/Services.js +2 -0
  298. package/bin/service/core/Services.js.map +1 -1
  299. package/bin/service/schedule/Executor.d.ts +1 -1
  300. package/bin/service/schedule/Executor.d.ts.map +1 -1
  301. package/bin/service/types/Service.d.ts +1 -23
  302. package/bin/service/types/Service.d.ts.map +1 -1
  303. package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts +1 -1
  304. package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts.map +1 -1
  305. package/bin/session/composer/system/default/SystemDomain.d.ts +1 -1
  306. package/bin/session/composer/system/default/SystemDomain.d.ts.map +1 -1
  307. package/bin/session/tools/shell/ShellToolBridge.d.ts +1 -1
  308. package/bin/session/tools/shell/ShellToolBridge.d.ts.map +1 -1
  309. package/package.json +1 -1
  310. package/src/{runtime → core}/AgentContextTypes.ts +6 -7
  311. package/src/core/AgentCore.ts +527 -0
  312. package/src/{runtime/AgentRuntimeTypes.ts → core/AgentCoreTypes.ts} +6 -6
  313. package/src/host/runtime/PluginRuntime.ts +1 -1
  314. package/src/index.ts +24 -21
  315. package/src/plugin/builtins/asr/InboundAugment.ts +1 -1
  316. package/src/plugin/builtins/auth/runtime/AuthorizationConfig.ts +1 -1
  317. package/src/plugin/builtins/auth/runtime/AuthorizationStore.ts +1 -1
  318. package/src/plugin/builtins/voice/InboundAugment.ts +1 -1
  319. package/src/plugin/builtins/workboard/runtime/Collector.ts +2 -2
  320. package/src/plugin/builtins/workboard/runtime/Normalizer.ts +1 -1
  321. package/src/plugin/builtins/workboard/runtime/Store.ts +1 -1
  322. package/src/plugin/core/Activation.ts +2 -2
  323. package/src/plugin/core/HookRegistry.ts +1 -1
  324. package/src/plugin/core/HttpRoutes.ts +1 -1
  325. package/src/plugin/core/LocalExecution.ts +21 -20
  326. package/src/plugin/core/PluginRegistry.ts +1 -1
  327. package/src/plugin/types/Plugin.ts +1 -1
  328. package/src/sandbox/SandboxConfigResolver.ts +1 -1
  329. package/src/sandbox/SandboxRunner.ts +1 -1
  330. package/src/sdk/Agent.ts +99 -393
  331. package/src/sdk/AgentSdkTypes.ts +158 -0
  332. package/src/sdk/HttpServer.ts +27 -192
  333. package/src/sdk/RpcServer.ts +24 -211
  334. package/src/sdk/Session.ts +12 -2
  335. package/src/sdk/SessionServicePort.ts +1 -1
  336. package/src/server/http/Server.ts +63 -18
  337. package/src/server/http/control/AuthControlService.ts +1 -1
  338. package/src/server/http/control/ControlAuthorizationRoutes.ts +1 -1
  339. package/src/server/http/control/ControlRouter.ts +27 -11
  340. package/src/server/http/control/ExecuteBySession.ts +2 -2
  341. package/src/server/http/control/OverviewRoutes.ts +6 -2
  342. package/src/server/http/control/SessionSummaryStore.ts +1 -1
  343. package/src/server/http/control/types/ControlRoutes.ts +2 -2
  344. package/src/server/http/execute/execute.ts +107 -91
  345. package/src/server/http/plugins/plugins.ts +60 -44
  346. package/src/server/http/services/services.ts +68 -64
  347. package/src/server/http/static/static.ts +95 -79
  348. package/src/server/rpc/Server.ts +26 -15
  349. package/src/service/builtins/BaseService.ts +2 -2
  350. package/src/service/builtins/chat/Action.ts +1 -1
  351. package/src/service/builtins/chat/ChatService.ts +2 -2
  352. package/src/service/builtins/chat/ChatServiceTypes.ts +1 -1
  353. package/src/service/builtins/chat/channels/BaseChatChannel.ts +1 -1
  354. package/src/service/builtins/chat/channels/BaseChatChannelQueue.ts +1 -1
  355. package/src/service/builtins/chat/channels/BaseChatChannelSupport.ts +1 -1
  356. package/src/service/builtins/chat/channels/feishu/Feishu.ts +1 -1
  357. package/src/service/builtins/chat/channels/feishu/FeishuMessageHandler.ts +1 -1
  358. package/src/service/builtins/chat/channels/feishu/FeishuPlatformClient.ts +1 -1
  359. package/src/service/builtins/chat/channels/qq/QQ.ts +1 -1
  360. package/src/service/builtins/chat/channels/qq/QQMessageHandler.ts +1 -1
  361. package/src/service/builtins/chat/channels/qq/QQSupport.ts +1 -1
  362. package/src/service/builtins/chat/channels/telegram/Bot.ts +1 -1
  363. package/src/service/builtins/chat/channels/telegram/TelegramMessageHandler.ts +1 -1
  364. package/src/service/builtins/chat/channels/telegram/TelegramPlatformClient.ts +1 -1
  365. package/src/service/builtins/chat/runtime/ChannelContextStore.ts +1 -1
  366. package/src/service/builtins/chat/runtime/ChatActionExecution.ts +1 -1
  367. package/src/service/builtins/chat/runtime/ChatActionInput.ts +2 -158
  368. package/src/service/builtins/chat/runtime/ChatChannelActions.ts +1 -1
  369. package/src/service/builtins/chat/runtime/ChatChannelConfig.ts +1 -1
  370. package/src/service/builtins/chat/runtime/ChatChannelCore.ts +1 -1
  371. package/src/service/builtins/chat/runtime/ChatChannelLifecycle.ts +1 -1
  372. package/src/service/builtins/chat/runtime/ChatHistoryStore.ts +1 -1
  373. package/src/service/builtins/chat/runtime/ChatIngressStore.ts +1 -1
  374. package/src/service/builtins/chat/runtime/ChatMetaStore.ts +1 -1
  375. package/src/service/builtins/chat/runtime/ChatQueueReplyDispatch.ts +1 -1
  376. package/src/service/builtins/chat/runtime/ChatQueueSessionBridge.ts +1 -1
  377. package/src/service/builtins/chat/runtime/ChatQueueStore.ts +1 -1
  378. package/src/service/builtins/chat/runtime/ChatQueueWorker.ts +1 -1
  379. package/src/service/builtins/chat/runtime/ChatServiceActions.ts +1 -118
  380. package/src/service/builtins/chat/runtime/ChatServiceSystem.ts +1 -1
  381. package/src/service/builtins/chat/runtime/ChatSessionDelete.ts +1 -1
  382. package/src/service/builtins/chat/runtime/ChatkeySend.ts +1 -1
  383. package/src/service/builtins/chat/runtime/EnqueueDispatch.ts +1 -1
  384. package/src/service/builtins/chat/runtime/InboundAugment.ts +1 -1
  385. package/src/service/builtins/chat/runtime/PluginDispatch.ts +1 -1
  386. package/src/service/builtins/chat/runtime/ReplyDispatch.ts +1 -1
  387. package/src/service/builtins/chat/runtime/SystemPrompt.ts +1 -1
  388. package/src/service/builtins/contact/Action.ts +2 -59
  389. package/src/service/builtins/contact/ContactService.ts +2 -2
  390. package/src/service/builtins/contact/runtime/ChatRuntime.ts +1 -1
  391. package/src/service/builtins/contact/runtime/ContactPayload.ts +0 -12
  392. package/src/service/builtins/contact/runtime/RemoteClient.ts +40 -19
  393. package/src/service/builtins/contact/runtime/ShareBundle.ts +1 -1
  394. package/src/service/builtins/memory/Action.ts +1 -1
  395. package/src/service/builtins/memory/MemoryService.ts +1 -28
  396. package/src/service/builtins/memory/runtime/Flush.ts +1 -1
  397. package/src/service/builtins/memory/runtime/Search.ts +1 -1
  398. package/src/service/builtins/memory/runtime/Store.ts +1 -1
  399. package/src/service/builtins/memory/runtime/SystemProvider.ts +1 -1
  400. package/src/service/builtins/memory/runtime/Writer.ts +1 -1
  401. package/src/service/builtins/schedule/ScheduleService.ts +131 -0
  402. package/src/service/builtins/shell/ShellRuntimeTypes.ts +1 -1
  403. package/src/service/builtins/shell/ShellService.ts +2 -2
  404. package/src/service/builtins/shell/runtime/ShellActionResponse.ts +1 -1
  405. package/src/service/builtins/shell/runtime/ShellActionRuntime.ts +1 -1
  406. package/src/service/builtins/shell/runtime/ShellActionRuntimeSupport.ts +1 -1
  407. package/src/service/builtins/shell/runtime/ShellRuntimeEnvironment.ts +1 -1
  408. package/src/service/builtins/task/Action.ts +1 -1
  409. package/src/service/builtins/task/Scheduler.ts +1 -1
  410. package/src/service/builtins/task/TaskService.ts +2 -2
  411. package/src/service/builtins/task/runtime/CronRuntime.ts +1 -1
  412. package/src/service/builtins/task/runtime/Runner.ts +1 -1
  413. package/src/service/builtins/task/runtime/TaskActionExecution.ts +1 -1
  414. package/src/service/builtins/task/runtime/TaskActionInput.ts +3 -185
  415. package/src/service/builtins/task/runtime/TaskRunChatDispatch.ts +1 -1
  416. package/src/service/builtins/task/runtime/TaskRunnerRound.ts +1 -1
  417. package/src/service/builtins/task/runtime/TaskRunnerScript.ts +1 -1
  418. package/src/service/builtins/task/runtime/TaskRunnerSession.ts +1 -1
  419. package/src/service/builtins/task/runtime/TaskServiceActions.ts +1 -35
  420. package/src/service/core/Manager.ts +0 -1
  421. package/src/service/core/ServiceActionRunner.ts +4 -2
  422. package/src/service/core/ServiceClassRegistry.ts +1 -1
  423. package/src/service/core/ServiceCommandRequest.ts +93 -0
  424. package/src/service/core/ServiceManager.ts +0 -1
  425. package/src/service/core/ServiceStateController.ts +45 -20
  426. package/src/service/core/ServiceSystemProviders.ts +1 -1
  427. package/src/service/core/Services.ts +3 -1
  428. package/src/service/schedule/Executor.ts +1 -1
  429. package/src/service/types/Service.ts +1 -24
  430. package/src/session/composer/system/default/DefaultSessionSystemComposer.ts +1 -1
  431. package/src/session/composer/system/default/SystemDomain.ts +1 -1
  432. package/src/session/tools/shell/ShellToolBridge.ts +1 -1
  433. package/tsconfig.tsbuildinfo +1 -1
  434. package/bin/runtime/AgentContext.d.ts +0 -23
  435. package/bin/runtime/AgentContext.d.ts.map +0 -1
  436. package/bin/runtime/AgentContext.js +0 -149
  437. package/bin/runtime/AgentContext.js.map +0 -1
  438. package/bin/runtime/AgentContextTypes.d.ts.map +0 -1
  439. package/bin/runtime/AgentContextTypes.js.map +0 -1
  440. package/bin/runtime/AgentRuntime.d.ts +0 -37
  441. package/bin/runtime/AgentRuntime.d.ts.map +0 -1
  442. package/bin/runtime/AgentRuntime.js +0 -291
  443. package/bin/runtime/AgentRuntime.js.map +0 -1
  444. package/bin/runtime/AgentRuntimeState.d.ts +0 -42
  445. package/bin/runtime/AgentRuntimeState.d.ts.map +0 -1
  446. package/bin/runtime/AgentRuntimeState.js +0 -172
  447. package/bin/runtime/AgentRuntimeState.js.map +0 -1
  448. package/bin/runtime/AgentRuntimeTypes.d.ts.map +0 -1
  449. package/bin/runtime/AgentRuntimeTypes.js +0 -10
  450. package/bin/runtime/AgentRuntimeTypes.js.map +0 -1
  451. package/bin/service/core/ServiceActionApi.d.ts +0 -15
  452. package/bin/service/core/ServiceActionApi.d.ts.map +0 -1
  453. package/bin/service/core/ServiceActionApi.js +0 -234
  454. package/bin/service/core/ServiceActionApi.js.map +0 -1
  455. package/bin/service/schedule/Runtime.d.ts +0 -17
  456. package/bin/service/schedule/Runtime.d.ts.map +0 -1
  457. package/bin/service/schedule/Runtime.js +0 -64
  458. package/bin/service/schedule/Runtime.js.map +0 -1
  459. package/src/runtime/AgentContext.ts +0 -182
  460. package/src/runtime/AgentRuntime.ts +0 -366
  461. package/src/runtime/AgentRuntimeState.ts +0 -213
  462. package/src/service/core/ServiceActionApi.ts +0 -304
  463. package/src/service/schedule/Runtime.ts +0 -78
@@ -8,7 +8,7 @@
8
8
  * - 把最终产物写入 run 目录的具体格式委托给 `TaskRunArtifacts.ts`。
9
9
  */
10
10
 
11
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
11
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
12
12
  import type {
13
13
  DialogueRoundRecord,
14
14
  UserSimulatorDecision,
@@ -6,7 +6,7 @@
6
6
  * - task 定义变更后的 scheduler reload 通过回调注入,避免执行层依赖具体 service 实现。
7
7
  */
8
8
 
9
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
9
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
10
10
  import type {
11
11
  TaskCronRegisterResult,
12
12
  TaskListActionPayload,
@@ -1,13 +1,13 @@
1
1
  /**
2
- * TaskActionInput:task service 的 CLI/API 输入映射模块。
2
+ * TaskActionInput:task service 的 CLI 输入映射模块。
3
3
  *
4
4
  * 关键点(中文)
5
- * - 统一处理命令行与 HTTP 请求到 task action payload 的转换。
5
+ * - 统一处理命令行到 task action payload 的转换。
6
6
  * - 参数校验尽量前置到输入层,避免进入执行层后才发现字段非法。
7
7
  */
8
8
 
9
9
  import { resolveSessionId } from "@session/ids/resolveSessionId.js";
10
- import type { JsonObject, JsonValue } from "@/types/common/Json.js";
10
+ import type { JsonValue } from "@/types/common/Json.js";
11
11
  import type { ServiceActionCommandInput } from "@/service/types/Service.js";
12
12
  import type { ShipTaskKind, ShipTaskStatus } from "@/service/builtins/task/types/Task.js";
13
13
  import type {
@@ -19,30 +19,6 @@ import type {
19
19
  } from "@/service/builtins/task/types/TaskCommand.js";
20
20
  import type { TaskListActionPayload } from "@/service/builtins/task/types/TaskService.js";
21
21
 
22
- function parseJsonBodyObject(rawBody: JsonValue): JsonObject {
23
- if (rawBody && typeof rawBody === "object" && !Array.isArray(rawBody)) {
24
- return rawBody as JsonObject;
25
- }
26
- return {};
27
- }
28
-
29
- function getStringField(body: JsonObject, key: string): string {
30
- const value = body[key];
31
- return typeof value === "string" ? value : "";
32
- }
33
-
34
- function getOptionalStringField(
35
- body: JsonObject,
36
- key: string,
37
- ): string | undefined {
38
- const value = body[key];
39
- return typeof value === "string" ? value : undefined;
40
- }
41
-
42
- function getBooleanField(body: JsonObject, key: string): boolean {
43
- return body[key] === true;
44
- }
45
-
46
22
  function parseBooleanLike(value: JsonValue | undefined): boolean | undefined {
47
23
  if (typeof value === "boolean") return value;
48
24
  if (typeof value !== "string") return undefined;
@@ -53,28 +29,6 @@ function parseBooleanLike(value: JsonValue | undefined): boolean | undefined {
53
29
  return undefined;
54
30
  }
55
31
 
56
- function getOptionalTaskStatusField(
57
- body: JsonObject,
58
- key: string,
59
- ): ShipTaskStatus | undefined {
60
- const value = body[key];
61
- if (value === "enabled" || value === "paused" || value === "disabled") {
62
- return value;
63
- }
64
- return undefined;
65
- }
66
-
67
- function getOptionalTaskKindField(
68
- body: JsonObject,
69
- key: string,
70
- ): ShipTaskKind | undefined {
71
- const value = body[key];
72
- if (value === "agent" || value === "script") {
73
- return value;
74
- }
75
- return undefined;
76
- }
77
-
78
32
  function getStringOpt(
79
33
  opts: Record<string, JsonValue>,
80
34
  key: string,
@@ -253,101 +207,6 @@ function mapTaskDeleteCommandInput(titleInput: string): TaskDeleteRequest {
253
207
  return { title };
254
208
  }
255
209
 
256
- function mapTaskListApiInput(query: { status?: string }): TaskListActionPayload {
257
- const status = readTaskStatusOrThrow(
258
- typeof query.status === "string" ? query.status.trim() : undefined,
259
- );
260
- return status ? { status } : {};
261
- }
262
-
263
- function mapTaskCreateApiInput(body: JsonObject): TaskCreateRequest {
264
- const status = getOptionalTaskStatusField(body, "status");
265
- const activate = getBooleanField(body, "activate");
266
- if (activate && status && status !== "enabled") {
267
- throw new Error("`activate` conflicts with `status` unless status=enabled");
268
- }
269
- const resolvedStatus = activate ? "enabled" : status;
270
-
271
- return {
272
- title: getStringField(body, "title"),
273
- when: getStringField(body, "when"),
274
- description: getStringField(body, "description"),
275
- sessionId: getStringField(body, "sessionId"),
276
- kind: getOptionalTaskKindField(body, "kind"),
277
- ...(typeof parseBooleanLike(body.review) === "boolean"
278
- ? { review: parseBooleanLike(body.review) }
279
- : {}),
280
- status: resolvedStatus,
281
- body: getOptionalStringField(body, "body"),
282
- overwrite: getBooleanField(body, "overwrite"),
283
- };
284
- }
285
-
286
- function mapTaskRunApiInput(body: JsonObject): TaskRunRequest {
287
- return {
288
- title: getStringField(body, "title"),
289
- ...(getOptionalStringField(body, "reason")
290
- ? { reason: getOptionalStringField(body, "reason") }
291
- : {}),
292
- };
293
- }
294
-
295
- function mapTaskUpdateApiInput(body: JsonObject): TaskUpdateRequest {
296
- const status = getOptionalTaskStatusField(body, "status");
297
- const activate = getBooleanField(body, "activate");
298
- if (activate && status && status !== "enabled") {
299
- throw new Error("`activate` conflicts with `status` unless status=enabled");
300
- }
301
- const resolvedStatus = activate ? "enabled" : status;
302
-
303
- return {
304
- title: getStringField(body, "title"),
305
- ...(getOptionalStringField(body, "titleNext")
306
- ? { titleNext: getOptionalStringField(body, "titleNext") }
307
- : {}),
308
- ...(getOptionalStringField(body, "description")
309
- ? { description: getOptionalStringField(body, "description") }
310
- : {}),
311
- ...(getOptionalStringField(body, "when")
312
- ? { when: getOptionalStringField(body, "when") }
313
- : {}),
314
- ...(getOptionalStringField(body, "sessionId")
315
- ? { sessionId: getOptionalStringField(body, "sessionId") }
316
- : {}),
317
- ...(getOptionalTaskKindField(body, "kind")
318
- ? { kind: getOptionalTaskKindField(body, "kind") }
319
- : {}),
320
- ...(typeof parseBooleanLike(body.review) === "boolean"
321
- ? { review: parseBooleanLike(body.review) }
322
- : {}),
323
- ...(getBooleanField(body, "clearWhen") ? { clearWhen: true } : {}),
324
- ...(resolvedStatus ? { status: resolvedStatus } : {}),
325
- ...(getOptionalStringField(body, "body")
326
- ? { body: getOptionalStringField(body, "body") }
327
- : {}),
328
- ...(getBooleanField(body, "clearBody") ? { clearBody: true } : {}),
329
- };
330
- }
331
-
332
- function mapTaskStatusApiInput(body: JsonObject): TaskSetStatusRequest {
333
- const status = getOptionalTaskStatusField(body, "status");
334
- if (!status) {
335
- throw new Error("Missing or invalid status");
336
- }
337
- return {
338
- title: getStringField(body, "title"),
339
- status,
340
- };
341
- }
342
-
343
- function mapTaskDeleteApiInput(body: JsonObject): TaskDeleteRequest {
344
- const title = getStringField(body, "title");
345
- if (!String(title || "").trim()) {
346
- throw new Error("Missing title");
347
- }
348
- return { title };
349
- }
350
-
351
210
  export function mapTaskListCommandPayload(
352
211
  input: ServiceActionCommandInput,
353
212
  ): TaskListActionPayload {
@@ -420,44 +279,3 @@ export function mapTaskDisableCommandPayload(
420
279
  status: "disabled",
421
280
  });
422
281
  }
423
-
424
- export function mapTaskListApiPayload(query: {
425
- status?: string;
426
- }): TaskListActionPayload {
427
- return mapTaskListApiInput(query);
428
- }
429
-
430
- export async function mapTaskCreateApiPayload(c: {
431
- req: { json: () => Promise<JsonValue> };
432
- }): Promise<TaskCreateRequest> {
433
- const body = parseJsonBodyObject(await c.req.json());
434
- return mapTaskCreateApiInput(body);
435
- }
436
-
437
- export async function mapTaskRunApiPayload(c: {
438
- req: { json: () => Promise<JsonValue> };
439
- }): Promise<TaskRunRequest> {
440
- const body = parseJsonBodyObject(await c.req.json());
441
- return mapTaskRunApiInput(body);
442
- }
443
-
444
- export async function mapTaskUpdateApiPayload(c: {
445
- req: { json: () => Promise<JsonValue> };
446
- }): Promise<TaskUpdateRequest> {
447
- const body = parseJsonBodyObject(await c.req.json());
448
- return mapTaskUpdateApiInput(body);
449
- }
450
-
451
- export async function mapTaskStatusApiPayload(c: {
452
- req: { json: () => Promise<JsonValue> };
453
- }): Promise<TaskSetStatusRequest> {
454
- const body = parseJsonBodyObject(await c.req.json());
455
- return mapTaskStatusApiInput(body);
456
- }
457
-
458
- export async function mapTaskDeleteApiPayload(c: {
459
- req: { json: () => Promise<JsonValue> };
460
- }): Promise<TaskDeleteRequest> {
461
- const body = parseJsonBodyObject(await c.req.json());
462
- return mapTaskDeleteApiInput(body);
463
- }
@@ -7,7 +7,7 @@
7
7
  * - 回发失败只记录日志,不影响 task run 自身状态。
8
8
  */
9
9
 
10
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
10
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
11
11
  import type { ShipTaskDefinitionV1 } from "@/service/builtins/task/types/Task.js";
12
12
 
13
13
  function resolveTaskFinalText(params: {
@@ -9,7 +9,7 @@
9
9
  import path from "node:path";
10
10
  import fs from "fs-extra";
11
11
  import { stripInvocationAuthEnv } from "@/server/http/auth/AuthEnv.js";
12
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
12
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
13
13
  import { runSandboxCommand } from "@/sandbox/SandboxRunner.js";
14
14
  import type { SessionRunResult } from "@/session/types/SessionRun.js";
15
15
  import type { JsonObject } from "@/types/common/Json.js";
@@ -6,7 +6,7 @@
6
6
  * - 这里集中处理 script 执行、结果校验与进度更新,Runner 主链只消费归一化结果。
7
7
  */
8
8
 
9
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
9
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
10
10
  import type {
11
11
  ShipTaskRunExecutionStatusV1,
12
12
  ShipTaskRunResultStatusV1,
@@ -9,7 +9,7 @@
9
9
  */
10
10
 
11
11
  import path from "node:path";
12
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
12
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
13
13
  import type { SessionRunResult } from "@/session/types/SessionRun.js";
14
14
  import type { TaskSessionRuntimePort } from "@/service/builtins/task/runtime/TaskRunnerTypes.js";
15
15
  import { Runner } from "@session/executors/local/Runner.js";
@@ -2,7 +2,7 @@
2
2
  * TaskServiceActions:task service 的 action 注册表模块。
3
3
  *
4
4
  * 关键点(中文)
5
- * - 这里专门负责把 task 的 CLI/API/execute 定义装配成 `ServiceActions`。
5
+ * - 这里专门负责把 task 的 CLI/execute 定义装配成 `ServiceActions`。
6
6
  * - TaskService 本体只保留实例状态与 lifecycle,不再承载大段 action 声明。
7
7
  */
8
8
 
@@ -26,19 +26,13 @@ import {
26
26
  type TaskSchedulerReloadPort,
27
27
  } from "./TaskActionExecution.js";
28
28
  import {
29
- mapTaskCreateApiPayload,
30
29
  mapTaskCreateCommandPayload,
31
- mapTaskDeleteApiPayload,
32
30
  mapTaskDeleteCommandPayload,
33
31
  mapTaskDisableCommandPayload,
34
32
  mapTaskEnableCommandPayload,
35
- mapTaskListApiPayload,
36
33
  mapTaskListCommandPayload,
37
- mapTaskRunApiPayload,
38
34
  mapTaskRunCommandPayload,
39
- mapTaskStatusApiPayload,
40
35
  mapTaskStatusCommandPayload,
41
- mapTaskUpdateApiPayload,
42
36
  mapTaskUpdateCommandPayload,
43
37
  } from "./TaskActionInput.js";
44
38
 
@@ -60,14 +54,6 @@ export function createTaskServiceActions(params: {
60
54
  },
61
55
  mapInput: mapTaskListCommandPayload,
62
56
  },
63
- api: {
64
- method: "GET",
65
- mapInput(c) {
66
- return mapTaskListApiPayload({
67
- status: c.req.query("status"),
68
- });
69
- },
70
- },
71
57
  execute: async (actionParams) => {
72
58
  return executeTaskListAction({
73
59
  context: actionParams.context,
@@ -103,10 +89,6 @@ export function createTaskServiceActions(params: {
103
89
  },
104
90
  mapInput: mapTaskCreateCommandPayload,
105
91
  },
106
- api: {
107
- method: "POST",
108
- mapInput: mapTaskCreateApiPayload,
109
- },
110
92
  execute: async (actionParams) => {
111
93
  return executeTaskCreateAction({
112
94
  context: actionParams.context,
@@ -125,10 +107,6 @@ export function createTaskServiceActions(params: {
125
107
  },
126
108
  mapInput: mapTaskRunCommandPayload,
127
109
  },
128
- api: {
129
- method: "POST",
130
- mapInput: mapTaskRunApiPayload,
131
- },
132
110
  execute: async (actionParams) => {
133
111
  return executeTaskRunAction({
134
112
  context: actionParams.context,
@@ -144,10 +122,6 @@ export function createTaskServiceActions(params: {
144
122
  },
145
123
  mapInput: mapTaskDeleteCommandPayload,
146
124
  },
147
- api: {
148
- method: "DELETE",
149
- mapInput: mapTaskDeleteApiPayload,
150
- },
151
125
  execute: async (actionParams) => {
152
126
  return executeTaskDeleteAction({
153
127
  context: actionParams.context,
@@ -180,10 +154,6 @@ export function createTaskServiceActions(params: {
180
154
  },
181
155
  mapInput: mapTaskUpdateCommandPayload,
182
156
  },
183
- api: {
184
- method: "PUT",
185
- mapInput: mapTaskUpdateApiPayload,
186
- },
187
157
  execute: async (actionParams) => {
188
158
  return executeTaskUpdateAction({
189
159
  context: actionParams.context,
@@ -200,10 +170,6 @@ export function createTaskServiceActions(params: {
200
170
  },
201
171
  mapInput: mapTaskStatusCommandPayload,
202
172
  },
203
- api: {
204
- method: "PUT",
205
- mapInput: mapTaskStatusApiPayload,
206
- },
207
173
  execute: async (actionParams) => {
208
174
  return executeTaskStatusAction({
209
175
  context: actionParams.context,
@@ -22,4 +22,3 @@ export {
22
22
  stopAllServices,
23
23
  } from "./ServiceStateController.js";
24
24
  export { runServiceCommand } from "./ServiceActionRunner.js";
25
- export { registerAllServicesForServer } from "./ServiceActionApi.js";
@@ -8,7 +8,7 @@
8
8
  */
9
9
 
10
10
  import type { JsonValue } from "@/types/common/Json.js";
11
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
11
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
12
12
  import type { ServiceCommandScheduleInput } from "@/service/types/ServiceSchedule.js";
13
13
  import type {
14
14
  ServiceStateControlAction,
@@ -147,7 +147,9 @@ export async function runServiceCommand(params: {
147
147
  schedule?: JsonValue | ServiceCommandScheduleInput;
148
148
  context: AgentContext;
149
149
  }): Promise<ServiceCommandResult & { service?: ServiceStateSnapshot }> {
150
- const service = resolveServiceByName(params.serviceName);
150
+ const service = resolveServiceByName(params.serviceName, {
151
+ context: params.context,
152
+ });
151
153
  if (!service) {
152
154
  return {
153
155
  success: false,
@@ -7,7 +7,7 @@
7
7
  * - CLI / 只读场景也复用这里构造无宿主实例,避免维护第二套静态 definition。
8
8
  */
9
9
 
10
- import type { AgentRuntime } from "@/runtime/AgentRuntimeTypes.js";
10
+ import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
11
11
  import { SERVICE_CLASSES } from "@/service/core/Services.js";
12
12
  import { BaseService } from "@/service/builtins/BaseService.js";
13
13
  import type { Service } from "@/service/types/Service.js";
@@ -0,0 +1,93 @@
1
+ /**
2
+ * ServiceCommandRequest:统一 service command 请求解析模块。
3
+ *
4
+ * 关键点(中文)
5
+ * - 统一收口 HTTP / RPC 两种入口的请求体解析。
6
+ * - service 远程调用只保留 `/api/services/command` 一种协议,不再让 action 自带 HTTP route。
7
+ * - 通用调度参数(`schedule` / `delay` / `time`)也在这里一次性归一化。
8
+ */
9
+
10
+ import type { JsonValue } from "@/types/common/Json.js";
11
+ import type { ServiceCommandScheduleInput } from "@/service/types/ServiceSchedule.js";
12
+ import {
13
+ normalizeRunAtMsOrThrow,
14
+ parseScheduledRunAtMsOrThrow,
15
+ } from "@/service/schedule/Time.js";
16
+
17
+ type JsonRecord = Record<string, unknown>;
18
+
19
+ /**
20
+ * 统一 service command 请求体。
21
+ */
22
+ export type ServiceCommandRequestBody = {
23
+ /**
24
+ * 目标 service 名称。
25
+ */
26
+ serviceName: string;
27
+ /**
28
+ * 目标 command / action 名称。
29
+ */
30
+ command: string;
31
+ /**
32
+ * 结构化 payload。
33
+ */
34
+ payload?: JsonValue;
35
+ /**
36
+ * 可选调度信息。
37
+ */
38
+ schedule?: ServiceCommandScheduleInput;
39
+ };
40
+
41
+ function isJsonRecord(value: unknown): value is JsonRecord {
42
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
43
+ }
44
+
45
+ /**
46
+ * 从统一请求体中提取调度输入。
47
+ */
48
+ function readScheduleInput(
49
+ body: JsonRecord,
50
+ ): ServiceCommandScheduleInput | undefined {
51
+ const nestedSchedule = isJsonRecord(body.schedule) ? body.schedule : undefined;
52
+ const nestedRunAtMs = nestedSchedule?.runAtMs;
53
+ const topLevelDelay = body.delayMs ?? body.delay;
54
+ const topLevelTime = body.sendAtMs ?? body.sendAt ?? body.time;
55
+
56
+ if (body.schedule !== undefined && !nestedSchedule) {
57
+ throw new Error("schedule must be an object");
58
+ }
59
+ if (nestedRunAtMs !== undefined && (topLevelDelay !== undefined || topLevelTime !== undefined)) {
60
+ throw new Error("`schedule.runAtMs` cannot be used together with `delay/time`.");
61
+ }
62
+ if (nestedRunAtMs !== undefined) {
63
+ return {
64
+ runAtMs: normalizeRunAtMsOrThrow(
65
+ nestedRunAtMs as string | number | undefined,
66
+ "schedule.runAtMs",
67
+ ),
68
+ };
69
+ }
70
+
71
+ const runAtMs = parseScheduledRunAtMsOrThrow({
72
+ delay: topLevelDelay as string | number | undefined,
73
+ time: topLevelTime as string | number | undefined,
74
+ });
75
+ if (typeof runAtMs !== "number") return undefined;
76
+ return { runAtMs };
77
+ }
78
+
79
+ /**
80
+ * 解析统一 service command 请求体。
81
+ */
82
+ export function parseServiceCommandRequestBody(
83
+ rawBody: JsonValue | undefined,
84
+ ): ServiceCommandRequestBody {
85
+ const body = isJsonRecord(rawBody) ? rawBody : {};
86
+ const schedule = readScheduleInput(body);
87
+ return {
88
+ serviceName: String(body.serviceName || "").trim(),
89
+ command: String(body.command || "").trim(),
90
+ ...(body.payload !== undefined ? { payload: body.payload as JsonValue } : {}),
91
+ ...(schedule ? { schedule } : {}),
92
+ };
93
+ }
@@ -9,7 +9,6 @@
9
9
  export type {
10
10
  Service,
11
11
  ServiceAction,
12
- ServiceActionApi,
13
12
  ServiceActionCommand,
14
13
  ServiceActionCommandInput,
15
14
  ServiceActionResult,
@@ -7,14 +7,14 @@
7
7
  * - Manager.ts 只作为门面导出,真正逻辑在这里分层实现。
8
8
  */
9
9
 
10
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
10
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
11
+ import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
11
12
  import type {
12
13
  ServiceStateControlAction,
13
14
  ServiceStateControlResult,
14
15
  ServiceStateRecord,
15
16
  ServiceStateSnapshot,
16
17
  } from "@/service/types/ServiceState.js";
17
- import { getAgentRuntime } from "@/runtime/AgentRuntimeState.js";
18
18
  import {
19
19
  getRegisteredStaticServiceInstances,
20
20
  listRegisteredServices,
@@ -31,17 +31,27 @@ function nowMs(): number {
31
31
  * 列出当前进程内可见的 service 实例。
32
32
  *
33
33
  * 关键点(中文)
34
- * - agent 已就绪,则返回 per-agent service instances
35
- * - 若 agent 尚未初始化,则退回静态装配实例,方便测试与只读场景。
34
+ * - 优先读取显式传入的实例级 context/runtime
35
+ * - 若调用方未传入实例上下文,则只退回静态装配实例,方便测试与只读场景。
36
36
  */
37
- export function listServiceInstances(): BaseService[] {
38
- try {
39
- const agent = getAgentRuntime();
40
- if (agent.services.size > 0) {
41
- return [...agent.services.values()];
42
- }
43
- } catch {
44
- // ignore and fallback
37
+ export function listServiceInstances(input?: {
38
+ context?: AgentContext;
39
+ runtime?: AgentRuntime;
40
+ }): BaseService[] {
41
+ return listServiceInstancesFor(input);
42
+ }
43
+
44
+ function listServiceInstancesFor(input?: {
45
+ context?: AgentContext;
46
+ runtime?: AgentRuntime;
47
+ }): BaseService[] {
48
+ const contextServices = input?.context?.agent?.services;
49
+ if (contextServices instanceof Map && contextServices.size > 0) {
50
+ return [...contextServices.values()];
51
+ }
52
+ const runtimeServices = input?.runtime?.services;
53
+ if (runtimeServices instanceof Map && runtimeServices.size > 0) {
54
+ return [...runtimeServices.values()];
45
55
  }
46
56
  return [...getRegisteredStaticServiceInstances().values()];
47
57
  }
@@ -51,10 +61,14 @@ export function listServiceInstances(): BaseService[] {
51
61
  */
52
62
  export function resolveServiceByName(
53
63
  name: string,
64
+ input?: {
65
+ context?: AgentContext;
66
+ runtime?: AgentRuntime;
67
+ },
54
68
  ): BaseService | null {
55
69
  const key = String(name || "").trim();
56
70
  if (!key) return null;
57
- return listServiceInstances().find((service) => service.name === key) || null;
71
+ return listServiceInstancesFor(input).find((service) => service.name === key) || null;
58
72
  }
59
73
 
60
74
  /**
@@ -153,8 +167,11 @@ export function getServiceRootCommandNames(): string[] {
153
167
  /**
154
168
  * 列出全部 service 状态快照。
155
169
  */
156
- export function listServiceStates(): ServiceStateSnapshot[] {
157
- return listServiceInstances()
170
+ export function listServiceStates(input?: {
171
+ context?: AgentContext;
172
+ runtime?: AgentRuntime;
173
+ }): ServiceStateSnapshot[] {
174
+ return listServiceInstancesFor(input)
158
175
  .map((service) =>
159
176
  toServiceStateSnapshot(ensureServiceStateRecord(service), service),
160
177
  )
@@ -164,8 +181,14 @@ export function listServiceStates(): ServiceStateSnapshot[] {
164
181
  /**
165
182
  * 判断指定 service 是否处于运行中。
166
183
  */
167
- export function isServiceRunning(serviceName: string): boolean {
168
- const service = resolveServiceByName(serviceName);
184
+ export function isServiceRunning(
185
+ serviceName: string,
186
+ input?: {
187
+ context?: AgentContext;
188
+ runtime?: AgentRuntime;
189
+ },
190
+ ): boolean {
191
+ const service = resolveServiceByName(serviceName, input);
169
192
  if (!service) return false;
170
193
  return ensureServiceStateRecord(service).state === "running";
171
194
  }
@@ -238,7 +261,9 @@ export async function controlServiceState(params: {
238
261
  action: ServiceStateControlAction;
239
262
  context: AgentContext;
240
263
  }): Promise<ServiceStateControlResult> {
241
- const service = resolveServiceByName(params.serviceName);
264
+ const service = resolveServiceByName(params.serviceName, {
265
+ context: params.context,
266
+ });
242
267
  if (!service) {
243
268
  return {
244
269
  success: false,
@@ -277,7 +302,7 @@ export async function startAllServices(
277
302
  results: ServiceStateControlResult[];
278
303
  }> {
279
304
  const results: ServiceStateControlResult[] = [];
280
- for (const service of listServiceInstances()) {
305
+ for (const service of listServiceInstancesFor({ context })) {
281
306
  results.push(
282
307
  await controlServiceState({
283
308
  serviceName: service.name,
@@ -300,7 +325,7 @@ export async function stopAllServices(context: AgentContext): Promise<{
300
325
  results: ServiceStateControlResult[];
301
326
  }> {
302
327
  const results: ServiceStateControlResult[] = [];
303
- for (const service of listServiceInstances()) {
328
+ for (const service of listServiceInstancesFor({ context })) {
304
329
  results.push(
305
330
  await controlServiceState({
306
331
  serviceName: service.name,
@@ -7,7 +7,7 @@
7
7
  * - 这样也能避开 `task -> runner -> prompt system -> service class registry` 的循环依赖。
8
8
  */
9
9
 
10
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
10
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
11
11
  import { buildChatServiceSystem } from "@/service/builtins/chat/runtime/ChatServiceSystem.js";
12
12
  import { buildContactServiceSystemText } from "@/service/builtins/contact/runtime/SystemProvider.js";
13
13
  import { buildMemoryServiceSystemText } from "@/service/builtins/memory/runtime/SystemProvider.js";
@@ -6,13 +6,14 @@
6
6
  * - 这里只声明“有哪些 service class”,不承载运行态逻辑。
7
7
  */
8
8
 
9
- import type { AgentRuntime } from "@/runtime/AgentRuntimeTypes.js";
9
+ import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
10
10
  import type { BaseService } from "@/service/builtins/BaseService.js";
11
11
  import { ChatService } from "@/service/builtins/chat/ChatService.js";
12
12
  import { TaskService } from "@/service/builtins/task/TaskService.js";
13
13
  import { MemoryService } from "@/service/builtins/memory/MemoryService.js";
14
14
  import { ShellService } from "@/service/builtins/shell/ShellService.js";
15
15
  import { ContactService } from "@/service/builtins/contact/ContactService.js";
16
+ import { ScheduleService } from "@/service/builtins/schedule/ScheduleService.js";
16
17
 
17
18
  /**
18
19
  * 单个 service class 构造器。
@@ -27,6 +28,7 @@ export type ServiceClass<T extends BaseService = BaseService> = new (
27
28
  export const SERVICE_CLASSES: ServiceClass[] = [
28
29
  ChatService,
29
30
  ContactService,
31
+ ScheduleService,
30
32
  TaskService,
31
33
  MemoryService,
32
34
  ShellService,