@downcity/agent 1.1.13 → 1.1.15

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 (545) hide show
  1. package/bin/config/Config.js +1 -1
  2. package/bin/config/Config.js.map +1 -1
  3. package/bin/config/Defaults.d.ts +13 -0
  4. package/bin/config/Defaults.d.ts.map +1 -0
  5. package/bin/config/{DowncityDefault.js → Defaults.js} +11 -1
  6. package/bin/config/Defaults.js.map +1 -0
  7. package/bin/{project/ProjectExecutionBinding.d.ts → config/ExecutionBinding.d.ts} +2 -2
  8. package/bin/config/ExecutionBinding.d.ts.map +1 -0
  9. package/bin/{project/ProjectExecutionBinding.js → config/ExecutionBinding.js} +2 -2
  10. package/bin/config/ExecutionBinding.js.map +1 -0
  11. package/bin/{runtime → core}/AgentContextTypes.d.ts +6 -6
  12. package/bin/core/AgentContextTypes.d.ts.map +1 -0
  13. package/bin/{runtime → core}/AgentContextTypes.js +2 -2
  14. package/bin/core/AgentContextTypes.js.map +1 -0
  15. package/bin/core/AgentCore.d.ts +87 -0
  16. package/bin/core/AgentCore.d.ts.map +1 -0
  17. package/bin/core/AgentCore.js +467 -0
  18. package/bin/core/AgentCore.js.map +1 -0
  19. package/bin/{runtime/AgentRuntimeTypes.d.ts → core/AgentCoreTypes.d.ts} +7 -7
  20. package/bin/core/AgentCoreTypes.d.ts.map +1 -0
  21. package/bin/core/AgentCoreTypes.js +10 -0
  22. package/bin/core/AgentCoreTypes.js.map +1 -0
  23. package/bin/host/daemon/ProjectSetup.d.ts.map +1 -1
  24. package/bin/host/daemon/ProjectSetup.js +1 -1
  25. package/bin/host/daemon/ProjectSetup.js.map +1 -1
  26. package/bin/host/runtime/PluginRuntime.d.ts +1 -1
  27. package/bin/host/runtime/PluginRuntime.d.ts.map +1 -1
  28. package/bin/index.d.ts +9 -11
  29. package/bin/index.d.ts.map +1 -1
  30. package/bin/index.js +5 -8
  31. package/bin/index.js.map +1 -1
  32. package/bin/model/CreateModel.js +1 -1
  33. package/bin/model/CreateModel.js.map +1 -1
  34. package/bin/plugin/builtins/asr/InboundAugment.d.ts +1 -1
  35. package/bin/plugin/builtins/asr/InboundAugment.d.ts.map +1 -1
  36. package/bin/plugin/builtins/auth/runtime/AuthorizationConfig.d.ts +1 -1
  37. package/bin/plugin/builtins/auth/runtime/AuthorizationConfig.d.ts.map +1 -1
  38. package/bin/plugin/builtins/auth/runtime/AuthorizationStore.d.ts +1 -1
  39. package/bin/plugin/builtins/auth/runtime/AuthorizationStore.d.ts.map +1 -1
  40. package/bin/plugin/builtins/voice/InboundAugment.d.ts +1 -1
  41. package/bin/plugin/builtins/voice/InboundAugment.d.ts.map +1 -1
  42. package/bin/plugin/builtins/workboard/runtime/Collector.d.ts +1 -1
  43. package/bin/plugin/builtins/workboard/runtime/Collector.d.ts.map +1 -1
  44. package/bin/plugin/builtins/workboard/runtime/Collector.js +1 -1
  45. package/bin/plugin/builtins/workboard/runtime/Collector.js.map +1 -1
  46. package/bin/plugin/builtins/workboard/runtime/Normalizer.d.ts +1 -1
  47. package/bin/plugin/builtins/workboard/runtime/Normalizer.d.ts.map +1 -1
  48. package/bin/plugin/builtins/workboard/runtime/Store.d.ts +1 -1
  49. package/bin/plugin/builtins/workboard/runtime/Store.d.ts.map +1 -1
  50. package/bin/plugin/core/Activation.d.ts +2 -2
  51. package/bin/plugin/core/Activation.d.ts.map +1 -1
  52. package/bin/plugin/core/HookRegistry.d.ts +1 -1
  53. package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
  54. package/bin/plugin/core/HttpRoutes.d.ts +1 -1
  55. package/bin/plugin/core/HttpRoutes.d.ts.map +1 -1
  56. package/bin/plugin/core/LocalExecution.d.ts.map +1 -1
  57. package/bin/plugin/core/LocalExecution.js +18 -20
  58. package/bin/plugin/core/LocalExecution.js.map +1 -1
  59. package/bin/plugin/core/PluginRegistry.d.ts +1 -1
  60. package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
  61. package/bin/plugin/types/Plugin.d.ts +1 -1
  62. package/bin/plugin/types/Plugin.d.ts.map +1 -1
  63. package/bin/project/AgentInitializer.js +2 -2
  64. package/bin/project/AgentInitializer.js.map +1 -1
  65. package/bin/sandbox/SandboxConfigResolver.d.ts +1 -1
  66. package/bin/sandbox/SandboxConfigResolver.d.ts.map +1 -1
  67. package/bin/sandbox/SandboxRunner.d.ts +1 -1
  68. package/bin/sandbox/SandboxRunner.d.ts.map +1 -1
  69. package/bin/sdk/Agent.d.ts +43 -27
  70. package/bin/sdk/Agent.d.ts.map +1 -1
  71. package/bin/sdk/Agent.js +143 -364
  72. package/bin/sdk/Agent.js.map +1 -1
  73. package/bin/sdk/AgentSdkTypes.d.ts +138 -0
  74. package/bin/sdk/AgentSdkTypes.d.ts.map +1 -1
  75. package/bin/sdk/RemoteAgent.d.ts +1 -1
  76. package/bin/sdk/RemoteAgent.js +1 -1
  77. package/bin/sdk/Session.d.ts +2 -2
  78. package/bin/sdk/Session.d.ts.map +1 -1
  79. package/bin/sdk/Session.js +11 -5
  80. package/bin/sdk/Session.js.map +1 -1
  81. package/bin/sdk/{SessionMetadata.d.ts → session/Metadata.d.ts} +2 -2
  82. package/bin/sdk/session/Metadata.d.ts.map +1 -0
  83. package/bin/sdk/{SessionMetadata.js → session/Metadata.js} +2 -2
  84. package/bin/sdk/session/Metadata.js.map +1 -0
  85. package/bin/sdk/{Paths.d.ts → session/Paths.d.ts} +1 -1
  86. package/bin/sdk/session/Paths.d.ts.map +1 -0
  87. package/bin/sdk/{Paths.js → session/Paths.js} +1 -1
  88. package/bin/sdk/session/Paths.js.map +1 -0
  89. package/bin/sdk/{SessionPersistence.d.ts → session/Persistence.d.ts} +3 -3
  90. package/bin/sdk/session/Persistence.d.ts.map +1 -0
  91. package/bin/sdk/{SessionPersistence.js → session/Persistence.js} +4 -4
  92. package/bin/sdk/session/Persistence.js.map +1 -0
  93. package/bin/sdk/{SessionServicePort.d.ts → session/ServicePort.d.ts} +2 -2
  94. package/bin/sdk/session/ServicePort.d.ts.map +1 -0
  95. package/bin/sdk/{SessionServicePort.js → session/ServicePort.js} +1 -1
  96. package/bin/sdk/session/ServicePort.js.map +1 -0
  97. package/bin/sdk/session/index.d.ts +12 -0
  98. package/bin/sdk/session/index.d.ts.map +1 -0
  99. package/bin/sdk/session/index.js +12 -0
  100. package/bin/sdk/session/index.js.map +1 -0
  101. package/bin/server/http/Server.d.ts +10 -1
  102. package/bin/server/http/Server.d.ts.map +1 -1
  103. package/bin/server/http/Server.js +41 -15
  104. package/bin/server/http/Server.js.map +1 -1
  105. package/bin/server/http/control/AuthControlService.d.ts +1 -1
  106. package/bin/server/http/control/AuthControlService.d.ts.map +1 -1
  107. package/bin/server/http/control/ControlAuthorizationRoutes.d.ts +1 -1
  108. package/bin/server/http/control/ControlAuthorizationRoutes.d.ts.map +1 -1
  109. package/bin/server/http/control/ControlRouter.d.ts +18 -2
  110. package/bin/server/http/control/ControlRouter.d.ts.map +1 -1
  111. package/bin/server/http/control/ControlRouter.js +10 -8
  112. package/bin/server/http/control/ControlRouter.js.map +1 -1
  113. package/bin/server/http/control/ExecuteBySession.d.ts +2 -2
  114. package/bin/server/http/control/ExecuteBySession.d.ts.map +1 -1
  115. package/bin/server/http/control/OverviewRoutes.d.ts.map +1 -1
  116. package/bin/server/http/control/OverviewRoutes.js +6 -2
  117. package/bin/server/http/control/OverviewRoutes.js.map +1 -1
  118. package/bin/server/http/control/SessionSummaryStore.d.ts +1 -1
  119. package/bin/server/http/control/SessionSummaryStore.d.ts.map +1 -1
  120. package/bin/server/http/control/types/ControlRoutes.d.ts +2 -2
  121. package/bin/server/http/control/types/ControlRoutes.d.ts.map +1 -1
  122. package/bin/server/http/execute/execute.d.ts +13 -2
  123. package/bin/server/http/execute/execute.d.ts.map +1 -1
  124. package/bin/server/http/execute/execute.js +73 -71
  125. package/bin/server/http/execute/execute.js.map +1 -1
  126. package/bin/server/http/plugins/plugins.d.ts +13 -2
  127. package/bin/server/http/plugins/plugins.d.ts.map +1 -1
  128. package/bin/server/http/plugins/plugins.js +42 -40
  129. package/bin/server/http/plugins/plugins.js.map +1 -1
  130. package/bin/server/http/services/services.d.ts +12 -8
  131. package/bin/server/http/services/services.d.ts.map +1 -1
  132. package/bin/server/http/services/services.js +57 -64
  133. package/bin/server/http/services/services.js.map +1 -1
  134. package/bin/server/http/static/static.d.ts +13 -2
  135. package/bin/server/http/static/static.d.ts.map +1 -1
  136. package/bin/server/http/static/static.js +81 -79
  137. package/bin/server/http/static/static.js.map +1 -1
  138. package/bin/server/rpc/Server.d.ts +5 -3
  139. package/bin/server/rpc/Server.d.ts.map +1 -1
  140. package/bin/server/rpc/Server.js +22 -12
  141. package/bin/server/rpc/Server.js.map +1 -1
  142. package/bin/service/builtins/BaseService.d.ts +2 -2
  143. package/bin/service/builtins/BaseService.d.ts.map +1 -1
  144. package/bin/service/builtins/chat/Action.d.ts +1 -1
  145. package/bin/service/builtins/chat/Action.d.ts.map +1 -1
  146. package/bin/service/builtins/chat/ChatService.d.ts +2 -2
  147. package/bin/service/builtins/chat/ChatService.d.ts.map +1 -1
  148. package/bin/service/builtins/chat/ChatServiceTypes.d.ts +1 -1
  149. package/bin/service/builtins/chat/ChatServiceTypes.d.ts.map +1 -1
  150. package/bin/service/builtins/chat/channels/BaseChatChannel.d.ts +1 -1
  151. package/bin/service/builtins/chat/channels/BaseChatChannel.d.ts.map +1 -1
  152. package/bin/service/builtins/chat/channels/BaseChatChannelQueue.d.ts +1 -1
  153. package/bin/service/builtins/chat/channels/BaseChatChannelQueue.d.ts.map +1 -1
  154. package/bin/service/builtins/chat/channels/BaseChatChannelSupport.d.ts +1 -1
  155. package/bin/service/builtins/chat/channels/BaseChatChannelSupport.d.ts.map +1 -1
  156. package/bin/service/builtins/chat/channels/feishu/Feishu.d.ts +1 -1
  157. package/bin/service/builtins/chat/channels/feishu/Feishu.d.ts.map +1 -1
  158. package/bin/service/builtins/chat/channels/feishu/FeishuMessageHandler.d.ts +1 -1
  159. package/bin/service/builtins/chat/channels/feishu/FeishuMessageHandler.d.ts.map +1 -1
  160. package/bin/service/builtins/chat/channels/feishu/FeishuPlatformClient.d.ts +1 -1
  161. package/bin/service/builtins/chat/channels/feishu/FeishuPlatformClient.d.ts.map +1 -1
  162. package/bin/service/builtins/chat/channels/qq/QQ.d.ts +1 -1
  163. package/bin/service/builtins/chat/channels/qq/QQ.d.ts.map +1 -1
  164. package/bin/service/builtins/chat/channels/qq/QQMessageHandler.d.ts +1 -1
  165. package/bin/service/builtins/chat/channels/qq/QQMessageHandler.d.ts.map +1 -1
  166. package/bin/service/builtins/chat/channels/qq/QQSupport.d.ts +1 -1
  167. package/bin/service/builtins/chat/channels/qq/QQSupport.d.ts.map +1 -1
  168. package/bin/service/builtins/chat/channels/telegram/Bot.d.ts +1 -1
  169. package/bin/service/builtins/chat/channels/telegram/Bot.d.ts.map +1 -1
  170. package/bin/service/builtins/chat/channels/telegram/TelegramMessageHandler.d.ts +1 -1
  171. package/bin/service/builtins/chat/channels/telegram/TelegramMessageHandler.d.ts.map +1 -1
  172. package/bin/service/builtins/chat/channels/telegram/TelegramPlatformClient.d.ts +1 -1
  173. package/bin/service/builtins/chat/channels/telegram/TelegramPlatformClient.d.ts.map +1 -1
  174. package/bin/service/builtins/chat/runtime/ChannelContextStore.d.ts +1 -1
  175. package/bin/service/builtins/chat/runtime/ChannelContextStore.d.ts.map +1 -1
  176. package/bin/service/builtins/chat/runtime/ChatActionExecution.d.ts +1 -1
  177. package/bin/service/builtins/chat/runtime/ChatActionExecution.d.ts.map +1 -1
  178. package/bin/service/builtins/chat/runtime/ChatActionInput.d.ts +3 -36
  179. package/bin/service/builtins/chat/runtime/ChatActionInput.d.ts.map +1 -1
  180. package/bin/service/builtins/chat/runtime/ChatActionInput.js +3 -118
  181. package/bin/service/builtins/chat/runtime/ChatActionInput.js.map +1 -1
  182. package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts +1 -1
  183. package/bin/service/builtins/chat/runtime/ChatChannelActions.d.ts.map +1 -1
  184. package/bin/service/builtins/chat/runtime/ChatChannelConfig.d.ts +1 -1
  185. package/bin/service/builtins/chat/runtime/ChatChannelConfig.d.ts.map +1 -1
  186. package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts +1 -1
  187. package/bin/service/builtins/chat/runtime/ChatChannelCore.d.ts.map +1 -1
  188. package/bin/service/builtins/chat/runtime/ChatChannelLifecycle.d.ts +1 -1
  189. package/bin/service/builtins/chat/runtime/ChatChannelLifecycle.d.ts.map +1 -1
  190. package/bin/service/builtins/chat/runtime/ChatHistoryStore.d.ts +1 -1
  191. package/bin/service/builtins/chat/runtime/ChatHistoryStore.d.ts.map +1 -1
  192. package/bin/service/builtins/chat/runtime/ChatIngressStore.d.ts +1 -1
  193. package/bin/service/builtins/chat/runtime/ChatIngressStore.d.ts.map +1 -1
  194. package/bin/service/builtins/chat/runtime/ChatMetaStore.d.ts +1 -1
  195. package/bin/service/builtins/chat/runtime/ChatMetaStore.d.ts.map +1 -1
  196. package/bin/service/builtins/chat/runtime/ChatQueueReplyDispatch.d.ts +1 -1
  197. package/bin/service/builtins/chat/runtime/ChatQueueReplyDispatch.d.ts.map +1 -1
  198. package/bin/service/builtins/chat/runtime/ChatQueueSessionBridge.d.ts +1 -1
  199. package/bin/service/builtins/chat/runtime/ChatQueueSessionBridge.d.ts.map +1 -1
  200. package/bin/service/builtins/chat/runtime/ChatQueueStore.d.ts +1 -1
  201. package/bin/service/builtins/chat/runtime/ChatQueueStore.d.ts.map +1 -1
  202. package/bin/service/builtins/chat/runtime/ChatQueueWorker.d.ts +1 -1
  203. package/bin/service/builtins/chat/runtime/ChatQueueWorker.d.ts.map +1 -1
  204. package/bin/service/builtins/chat/runtime/ChatServiceActions.d.ts +1 -1
  205. package/bin/service/builtins/chat/runtime/ChatServiceActions.d.ts.map +1 -1
  206. package/bin/service/builtins/chat/runtime/ChatServiceActions.js +2 -109
  207. package/bin/service/builtins/chat/runtime/ChatServiceActions.js.map +1 -1
  208. package/bin/service/builtins/chat/runtime/ChatServiceSystem.d.ts +1 -1
  209. package/bin/service/builtins/chat/runtime/ChatServiceSystem.d.ts.map +1 -1
  210. package/bin/service/builtins/chat/runtime/ChatSessionDelete.d.ts +1 -1
  211. package/bin/service/builtins/chat/runtime/ChatSessionDelete.d.ts.map +1 -1
  212. package/bin/service/builtins/chat/runtime/ChatkeySend.d.ts +1 -1
  213. package/bin/service/builtins/chat/runtime/ChatkeySend.d.ts.map +1 -1
  214. package/bin/service/builtins/chat/runtime/EnqueueDispatch.d.ts +1 -1
  215. package/bin/service/builtins/chat/runtime/EnqueueDispatch.d.ts.map +1 -1
  216. package/bin/service/builtins/chat/runtime/InboundAugment.d.ts +1 -1
  217. package/bin/service/builtins/chat/runtime/InboundAugment.d.ts.map +1 -1
  218. package/bin/service/builtins/chat/runtime/PluginDispatch.d.ts +1 -1
  219. package/bin/service/builtins/chat/runtime/PluginDispatch.d.ts.map +1 -1
  220. package/bin/service/builtins/chat/runtime/ReplyDispatch.d.ts +1 -1
  221. package/bin/service/builtins/chat/runtime/ReplyDispatch.d.ts.map +1 -1
  222. package/bin/service/builtins/chat/runtime/SystemPrompt.d.ts +1 -1
  223. package/bin/service/builtins/chat/runtime/SystemPrompt.d.ts.map +1 -1
  224. package/bin/service/builtins/contact/Action.d.ts +2 -2
  225. package/bin/service/builtins/contact/Action.d.ts.map +1 -1
  226. package/bin/service/builtins/contact/Action.js +2 -58
  227. package/bin/service/builtins/contact/Action.js.map +1 -1
  228. package/bin/service/builtins/contact/ContactService.d.ts +1 -1
  229. package/bin/service/builtins/contact/ContactService.d.ts.map +1 -1
  230. package/bin/service/builtins/contact/runtime/ChatRuntime.d.ts +1 -1
  231. package/bin/service/builtins/contact/runtime/ChatRuntime.d.ts.map +1 -1
  232. package/bin/service/builtins/contact/runtime/ContactPayload.d.ts +0 -7
  233. package/bin/service/builtins/contact/runtime/ContactPayload.d.ts.map +1 -1
  234. package/bin/service/builtins/contact/runtime/ContactPayload.js +0 -9
  235. package/bin/service/builtins/contact/runtime/ContactPayload.js.map +1 -1
  236. package/bin/service/builtins/contact/runtime/RemoteClient.d.ts +1 -1
  237. package/bin/service/builtins/contact/runtime/RemoteClient.d.ts.map +1 -1
  238. package/bin/service/builtins/contact/runtime/RemoteClient.js +37 -19
  239. package/bin/service/builtins/contact/runtime/RemoteClient.js.map +1 -1
  240. package/bin/service/builtins/contact/runtime/ShareBundle.d.ts +1 -1
  241. package/bin/service/builtins/contact/runtime/ShareBundle.d.ts.map +1 -1
  242. package/bin/service/builtins/memory/Action.d.ts +1 -1
  243. package/bin/service/builtins/memory/Action.d.ts.map +1 -1
  244. package/bin/service/builtins/memory/MemoryService.d.ts +1 -1
  245. package/bin/service/builtins/memory/MemoryService.d.ts.map +1 -1
  246. package/bin/service/builtins/memory/MemoryService.js +0 -27
  247. package/bin/service/builtins/memory/MemoryService.js.map +1 -1
  248. package/bin/service/builtins/memory/runtime/Flush.d.ts +1 -1
  249. package/bin/service/builtins/memory/runtime/Flush.d.ts.map +1 -1
  250. package/bin/service/builtins/memory/runtime/Search.d.ts +1 -1
  251. package/bin/service/builtins/memory/runtime/Search.d.ts.map +1 -1
  252. package/bin/service/builtins/memory/runtime/Store.d.ts +1 -1
  253. package/bin/service/builtins/memory/runtime/Store.d.ts.map +1 -1
  254. package/bin/service/builtins/memory/runtime/SystemProvider.d.ts +1 -1
  255. package/bin/service/builtins/memory/runtime/SystemProvider.d.ts.map +1 -1
  256. package/bin/service/builtins/memory/runtime/Writer.d.ts +1 -1
  257. package/bin/service/builtins/memory/runtime/Writer.d.ts.map +1 -1
  258. package/bin/service/builtins/schedule/ScheduleService.d.ts +39 -0
  259. package/bin/service/builtins/schedule/ScheduleService.d.ts.map +1 -0
  260. package/bin/service/builtins/schedule/ScheduleService.js +106 -0
  261. package/bin/service/builtins/schedule/ScheduleService.js.map +1 -0
  262. package/bin/service/builtins/shell/ShellRuntimeTypes.d.ts +1 -1
  263. package/bin/service/builtins/shell/ShellRuntimeTypes.d.ts.map +1 -1
  264. package/bin/service/builtins/shell/ShellService.d.ts +2 -2
  265. package/bin/service/builtins/shell/ShellService.d.ts.map +1 -1
  266. package/bin/service/builtins/shell/runtime/ShellActionResponse.d.ts +1 -1
  267. package/bin/service/builtins/shell/runtime/ShellActionResponse.d.ts.map +1 -1
  268. package/bin/service/builtins/shell/runtime/ShellActionRuntime.d.ts +1 -1
  269. package/bin/service/builtins/shell/runtime/ShellActionRuntime.d.ts.map +1 -1
  270. package/bin/service/builtins/shell/runtime/ShellActionRuntimeSupport.d.ts +1 -1
  271. package/bin/service/builtins/shell/runtime/ShellActionRuntimeSupport.d.ts.map +1 -1
  272. package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.d.ts +1 -1
  273. package/bin/service/builtins/shell/runtime/ShellRuntimeEnvironment.d.ts.map +1 -1
  274. package/bin/service/builtins/task/Action.d.ts +1 -1
  275. package/bin/service/builtins/task/Action.d.ts.map +1 -1
  276. package/bin/service/builtins/task/Scheduler.d.ts +1 -1
  277. package/bin/service/builtins/task/Scheduler.d.ts.map +1 -1
  278. package/bin/service/builtins/task/TaskService.d.ts +2 -2
  279. package/bin/service/builtins/task/TaskService.d.ts.map +1 -1
  280. package/bin/service/builtins/task/runtime/CronRuntime.d.ts +1 -1
  281. package/bin/service/builtins/task/runtime/CronRuntime.d.ts.map +1 -1
  282. package/bin/service/builtins/task/runtime/Runner.d.ts +1 -1
  283. package/bin/service/builtins/task/runtime/Runner.d.ts.map +1 -1
  284. package/bin/service/builtins/task/runtime/TaskActionExecution.d.ts +1 -1
  285. package/bin/service/builtins/task/runtime/TaskActionExecution.d.ts.map +1 -1
  286. package/bin/service/builtins/task/runtime/TaskActionInput.d.ts +2 -31
  287. package/bin/service/builtins/task/runtime/TaskActionInput.d.ts.map +1 -1
  288. package/bin/service/builtins/task/runtime/TaskActionInput.js +2 -141
  289. package/bin/service/builtins/task/runtime/TaskActionInput.js.map +1 -1
  290. package/bin/service/builtins/task/runtime/TaskRunChatDispatch.d.ts +1 -1
  291. package/bin/service/builtins/task/runtime/TaskRunChatDispatch.d.ts.map +1 -1
  292. package/bin/service/builtins/task/runtime/TaskRunnerRound.d.ts +1 -1
  293. package/bin/service/builtins/task/runtime/TaskRunnerRound.d.ts.map +1 -1
  294. package/bin/service/builtins/task/runtime/TaskRunnerScript.d.ts +1 -1
  295. package/bin/service/builtins/task/runtime/TaskRunnerScript.d.ts.map +1 -1
  296. package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts +1 -1
  297. package/bin/service/builtins/task/runtime/TaskRunnerSession.d.ts.map +1 -1
  298. package/bin/service/builtins/task/runtime/TaskServiceActions.d.ts +1 -1
  299. package/bin/service/builtins/task/runtime/TaskServiceActions.d.ts.map +1 -1
  300. package/bin/service/builtins/task/runtime/TaskServiceActions.js +2 -30
  301. package/bin/service/builtins/task/runtime/TaskServiceActions.js.map +1 -1
  302. package/bin/service/core/Manager.d.ts +0 -1
  303. package/bin/service/core/Manager.d.ts.map +1 -1
  304. package/bin/service/core/Manager.js +0 -1
  305. package/bin/service/core/Manager.js.map +1 -1
  306. package/bin/service/core/ServiceActionRunner.d.ts +1 -1
  307. package/bin/service/core/ServiceActionRunner.d.ts.map +1 -1
  308. package/bin/service/core/ServiceActionRunner.js +5 -3
  309. package/bin/service/core/ServiceActionRunner.js.map +1 -1
  310. package/bin/service/core/ServiceClassRegistry.d.ts +1 -1
  311. package/bin/service/core/ServiceClassRegistry.d.ts.map +1 -1
  312. package/bin/service/core/ServiceCommandRequest.d.ts +36 -0
  313. package/bin/service/core/ServiceCommandRequest.d.ts.map +1 -0
  314. package/bin/service/core/ServiceCommandRequest.js +53 -0
  315. package/bin/service/core/ServiceCommandRequest.js.map +1 -0
  316. package/bin/service/core/ServiceStateController.d.ts +20 -7
  317. package/bin/service/core/ServiceStateController.d.ts.map +1 -1
  318. package/bin/service/core/ServiceStateController.js +23 -20
  319. package/bin/service/core/ServiceStateController.js.map +1 -1
  320. package/bin/service/core/ServiceSystemProviders.d.ts +1 -1
  321. package/bin/service/core/ServiceSystemProviders.d.ts.map +1 -1
  322. package/bin/service/core/Services.d.ts +1 -1
  323. package/bin/service/core/Services.d.ts.map +1 -1
  324. package/bin/service/core/Services.js +2 -0
  325. package/bin/service/core/Services.js.map +1 -1
  326. package/bin/service/{schedule → core/schedule}/Executor.d.ts +2 -2
  327. package/bin/service/core/schedule/Executor.d.ts.map +1 -0
  328. package/bin/service/{schedule → core/schedule}/Executor.js +1 -1
  329. package/bin/service/core/schedule/Executor.js.map +1 -0
  330. package/bin/service/{schedule → core/schedule}/Store.d.ts +1 -1
  331. package/bin/service/core/schedule/Store.d.ts.map +1 -0
  332. package/bin/service/{schedule → core/schedule}/Store.js +2 -2
  333. package/bin/service/core/schedule/Store.js.map +1 -0
  334. package/bin/service/core/schedule/Time.d.ts.map +1 -0
  335. package/bin/service/core/schedule/Time.js.map +1 -0
  336. package/bin/service/types/Service.d.ts +2 -24
  337. package/bin/service/types/Service.d.ts.map +1 -1
  338. package/bin/service/types/Service.js +1 -1
  339. package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts +1 -1
  340. package/bin/session/composer/system/default/DefaultSessionSystemComposer.d.ts.map +1 -1
  341. package/bin/session/composer/system/default/SystemDomain.d.ts +1 -1
  342. package/bin/session/composer/system/default/SystemDomain.d.ts.map +1 -1
  343. package/bin/session/tools/shell/ShellToolBridge.d.ts +1 -1
  344. package/bin/session/tools/shell/ShellToolBridge.d.ts.map +1 -1
  345. package/package.json +1 -1
  346. package/src/config/Config.ts +1 -1
  347. package/src/config/{DowncityDefault.ts → Defaults.ts} +11 -0
  348. package/src/{project/ProjectExecutionBinding.ts → config/ExecutionBinding.ts} +1 -1
  349. package/src/{runtime → core}/AgentContextTypes.ts +6 -7
  350. package/src/core/AgentCore.ts +527 -0
  351. package/src/{runtime/AgentRuntimeTypes.ts → core/AgentCoreTypes.ts} +6 -6
  352. package/src/host/daemon/ProjectSetup.ts +2 -3
  353. package/src/host/runtime/PluginRuntime.ts +1 -1
  354. package/src/index.ts +27 -24
  355. package/src/model/CreateModel.ts +1 -1
  356. package/src/plugin/builtins/asr/InboundAugment.ts +1 -1
  357. package/src/plugin/builtins/auth/runtime/AuthorizationConfig.ts +1 -1
  358. package/src/plugin/builtins/auth/runtime/AuthorizationStore.ts +1 -1
  359. package/src/plugin/builtins/voice/InboundAugment.ts +1 -1
  360. package/src/plugin/builtins/workboard/runtime/Collector.ts +2 -2
  361. package/src/plugin/builtins/workboard/runtime/Normalizer.ts +1 -1
  362. package/src/plugin/builtins/workboard/runtime/Store.ts +1 -1
  363. package/src/plugin/core/Activation.ts +2 -2
  364. package/src/plugin/core/HookRegistry.ts +1 -1
  365. package/src/plugin/core/HttpRoutes.ts +1 -1
  366. package/src/plugin/core/LocalExecution.ts +21 -20
  367. package/src/plugin/core/PluginRegistry.ts +1 -1
  368. package/src/plugin/types/Plugin.ts +1 -1
  369. package/src/project/AgentInitializer.ts +2 -2
  370. package/src/sandbox/SandboxConfigResolver.ts +1 -1
  371. package/src/sandbox/SandboxRunner.ts +1 -1
  372. package/src/sdk/Agent.ts +163 -391
  373. package/src/sdk/AgentSdkTypes.ts +158 -0
  374. package/src/sdk/RemoteAgent.ts +1 -1
  375. package/src/sdk/Session.ts +16 -6
  376. package/src/sdk/{SessionMetadata.ts → session/Metadata.ts} +1 -1
  377. package/src/sdk/{Paths.ts → session/Paths.ts} +1 -1
  378. package/src/sdk/{SessionPersistence.ts → session/Persistence.ts} +1 -1
  379. package/src/sdk/{SessionServicePort.ts → session/ServicePort.ts} +1 -1
  380. package/src/sdk/session/index.ts +34 -0
  381. package/src/server/http/Server.ts +63 -18
  382. package/src/server/http/control/AuthControlService.ts +1 -1
  383. package/src/server/http/control/ControlAuthorizationRoutes.ts +1 -1
  384. package/src/server/http/control/ControlRouter.ts +27 -11
  385. package/src/server/http/control/ExecuteBySession.ts +2 -2
  386. package/src/server/http/control/OverviewRoutes.ts +6 -2
  387. package/src/server/http/control/SessionSummaryStore.ts +1 -1
  388. package/src/server/http/control/types/ControlRoutes.ts +2 -2
  389. package/src/server/http/execute/execute.ts +107 -91
  390. package/src/server/http/plugins/plugins.ts +60 -44
  391. package/src/server/http/services/services.ts +68 -64
  392. package/src/server/http/static/static.ts +95 -79
  393. package/src/server/rpc/Server.ts +26 -15
  394. package/src/service/builtins/BaseService.ts +2 -2
  395. package/src/service/builtins/chat/Action.ts +1 -1
  396. package/src/service/builtins/chat/ChatService.ts +2 -2
  397. package/src/service/builtins/chat/ChatServiceTypes.ts +1 -1
  398. package/src/service/builtins/chat/channels/BaseChatChannel.ts +1 -1
  399. package/src/service/builtins/chat/channels/BaseChatChannelQueue.ts +1 -1
  400. package/src/service/builtins/chat/channels/BaseChatChannelSupport.ts +1 -1
  401. package/src/service/builtins/chat/channels/feishu/Feishu.ts +1 -1
  402. package/src/service/builtins/chat/channels/feishu/FeishuMessageHandler.ts +1 -1
  403. package/src/service/builtins/chat/channels/feishu/FeishuPlatformClient.ts +1 -1
  404. package/src/service/builtins/chat/channels/qq/QQ.ts +1 -1
  405. package/src/service/builtins/chat/channels/qq/QQMessageHandler.ts +1 -1
  406. package/src/service/builtins/chat/channels/qq/QQSupport.ts +1 -1
  407. package/src/service/builtins/chat/channels/telegram/Bot.ts +1 -1
  408. package/src/service/builtins/chat/channels/telegram/TelegramMessageHandler.ts +1 -1
  409. package/src/service/builtins/chat/channels/telegram/TelegramPlatformClient.ts +1 -1
  410. package/src/service/builtins/chat/runtime/ChannelContextStore.ts +1 -1
  411. package/src/service/builtins/chat/runtime/ChatActionExecution.ts +1 -1
  412. package/src/service/builtins/chat/runtime/ChatActionInput.ts +2 -158
  413. package/src/service/builtins/chat/runtime/ChatChannelActions.ts +1 -1
  414. package/src/service/builtins/chat/runtime/ChatChannelConfig.ts +1 -1
  415. package/src/service/builtins/chat/runtime/ChatChannelCore.ts +1 -1
  416. package/src/service/builtins/chat/runtime/ChatChannelLifecycle.ts +1 -1
  417. package/src/service/builtins/chat/runtime/ChatHistoryStore.ts +1 -1
  418. package/src/service/builtins/chat/runtime/ChatIngressStore.ts +1 -1
  419. package/src/service/builtins/chat/runtime/ChatMetaStore.ts +1 -1
  420. package/src/service/builtins/chat/runtime/ChatQueueReplyDispatch.ts +1 -1
  421. package/src/service/builtins/chat/runtime/ChatQueueSessionBridge.ts +1 -1
  422. package/src/service/builtins/chat/runtime/ChatQueueStore.ts +1 -1
  423. package/src/service/builtins/chat/runtime/ChatQueueWorker.ts +1 -1
  424. package/src/service/builtins/chat/runtime/ChatServiceActions.ts +1 -118
  425. package/src/service/builtins/chat/runtime/ChatServiceSystem.ts +1 -1
  426. package/src/service/builtins/chat/runtime/ChatSessionDelete.ts +1 -1
  427. package/src/service/builtins/chat/runtime/ChatkeySend.ts +1 -1
  428. package/src/service/builtins/chat/runtime/EnqueueDispatch.ts +1 -1
  429. package/src/service/builtins/chat/runtime/InboundAugment.ts +1 -1
  430. package/src/service/builtins/chat/runtime/PluginDispatch.ts +1 -1
  431. package/src/service/builtins/chat/runtime/ReplyDispatch.ts +1 -1
  432. package/src/service/builtins/chat/runtime/SystemPrompt.ts +1 -1
  433. package/src/service/builtins/contact/Action.ts +2 -59
  434. package/src/service/builtins/contact/ContactService.ts +2 -2
  435. package/src/service/builtins/contact/runtime/ChatRuntime.ts +1 -1
  436. package/src/service/builtins/contact/runtime/ContactPayload.ts +0 -12
  437. package/src/service/builtins/contact/runtime/RemoteClient.ts +40 -19
  438. package/src/service/builtins/contact/runtime/ShareBundle.ts +1 -1
  439. package/src/service/builtins/memory/Action.ts +1 -1
  440. package/src/service/builtins/memory/MemoryService.ts +1 -28
  441. package/src/service/builtins/memory/runtime/Flush.ts +1 -1
  442. package/src/service/builtins/memory/runtime/Search.ts +1 -1
  443. package/src/service/builtins/memory/runtime/Store.ts +1 -1
  444. package/src/service/builtins/memory/runtime/SystemProvider.ts +1 -1
  445. package/src/service/builtins/memory/runtime/Writer.ts +1 -1
  446. package/src/service/builtins/schedule/ScheduleService.ts +131 -0
  447. package/src/service/builtins/shell/ShellRuntimeTypes.ts +1 -1
  448. package/src/service/builtins/shell/ShellService.ts +2 -2
  449. package/src/service/builtins/shell/runtime/ShellActionResponse.ts +1 -1
  450. package/src/service/builtins/shell/runtime/ShellActionRuntime.ts +1 -1
  451. package/src/service/builtins/shell/runtime/ShellActionRuntimeSupport.ts +1 -1
  452. package/src/service/builtins/shell/runtime/ShellRuntimeEnvironment.ts +1 -1
  453. package/src/service/builtins/task/Action.ts +1 -1
  454. package/src/service/builtins/task/Scheduler.ts +1 -1
  455. package/src/service/builtins/task/TaskService.ts +2 -2
  456. package/src/service/builtins/task/runtime/CronRuntime.ts +1 -1
  457. package/src/service/builtins/task/runtime/Runner.ts +1 -1
  458. package/src/service/builtins/task/runtime/TaskActionExecution.ts +1 -1
  459. package/src/service/builtins/task/runtime/TaskActionInput.ts +3 -185
  460. package/src/service/builtins/task/runtime/TaskRunChatDispatch.ts +1 -1
  461. package/src/service/builtins/task/runtime/TaskRunnerRound.ts +1 -1
  462. package/src/service/builtins/task/runtime/TaskRunnerScript.ts +1 -1
  463. package/src/service/builtins/task/runtime/TaskRunnerSession.ts +1 -1
  464. package/src/service/builtins/task/runtime/TaskServiceActions.ts +1 -35
  465. package/src/service/core/Manager.ts +0 -1
  466. package/src/service/core/ServiceActionRunner.ts +6 -4
  467. package/src/service/core/ServiceClassRegistry.ts +1 -1
  468. package/src/service/core/ServiceCommandRequest.ts +93 -0
  469. package/src/service/core/ServiceStateController.ts +45 -20
  470. package/src/service/core/ServiceSystemProviders.ts +1 -1
  471. package/src/service/core/Services.ts +3 -1
  472. package/src/service/{schedule → core/schedule}/Executor.ts +2 -2
  473. package/src/service/{schedule → core/schedule}/Store.ts +4 -2
  474. package/src/service/types/Service.ts +2 -25
  475. package/src/session/composer/system/default/DefaultSessionSystemComposer.ts +1 -1
  476. package/src/session/composer/system/default/SystemDomain.ts +1 -1
  477. package/src/session/tools/shell/ShellToolBridge.ts +1 -1
  478. package/tsconfig.tsbuildinfo +1 -1
  479. package/bin/config/DowncityDefault.d.ts +0 -3
  480. package/bin/config/DowncityDefault.d.ts.map +0 -1
  481. package/bin/config/DowncityDefault.js.map +0 -1
  482. package/bin/project/ProjectExecutionBinding.d.ts.map +0 -1
  483. package/bin/project/ProjectExecutionBinding.js.map +0 -1
  484. package/bin/runtime/AgentContext.d.ts +0 -23
  485. package/bin/runtime/AgentContext.d.ts.map +0 -1
  486. package/bin/runtime/AgentContext.js +0 -149
  487. package/bin/runtime/AgentContext.js.map +0 -1
  488. package/bin/runtime/AgentContextTypes.d.ts.map +0 -1
  489. package/bin/runtime/AgentContextTypes.js.map +0 -1
  490. package/bin/runtime/AgentRuntime.d.ts +0 -37
  491. package/bin/runtime/AgentRuntime.d.ts.map +0 -1
  492. package/bin/runtime/AgentRuntime.js +0 -291
  493. package/bin/runtime/AgentRuntime.js.map +0 -1
  494. package/bin/runtime/AgentRuntimeState.d.ts +0 -42
  495. package/bin/runtime/AgentRuntimeState.d.ts.map +0 -1
  496. package/bin/runtime/AgentRuntimeState.js +0 -172
  497. package/bin/runtime/AgentRuntimeState.js.map +0 -1
  498. package/bin/runtime/AgentRuntimeTypes.d.ts.map +0 -1
  499. package/bin/runtime/AgentRuntimeTypes.js +0 -10
  500. package/bin/runtime/AgentRuntimeTypes.js.map +0 -1
  501. package/bin/sdk/HttpServer.d.ts +0 -40
  502. package/bin/sdk/HttpServer.d.ts.map +0 -1
  503. package/bin/sdk/HttpServer.js +0 -189
  504. package/bin/sdk/HttpServer.js.map +0 -1
  505. package/bin/sdk/Paths.d.ts.map +0 -1
  506. package/bin/sdk/Paths.js.map +0 -1
  507. package/bin/sdk/RpcServer.d.ts +0 -31
  508. package/bin/sdk/RpcServer.d.ts.map +0 -1
  509. package/bin/sdk/RpcServer.js +0 -207
  510. package/bin/sdk/RpcServer.js.map +0 -1
  511. package/bin/sdk/SessionMetadata.d.ts.map +0 -1
  512. package/bin/sdk/SessionMetadata.js.map +0 -1
  513. package/bin/sdk/SessionPersistence.d.ts.map +0 -1
  514. package/bin/sdk/SessionPersistence.js.map +0 -1
  515. package/bin/sdk/SessionServicePort.d.ts.map +0 -1
  516. package/bin/sdk/SessionServicePort.js.map +0 -1
  517. package/bin/service/core/ServiceActionApi.d.ts +0 -15
  518. package/bin/service/core/ServiceActionApi.d.ts.map +0 -1
  519. package/bin/service/core/ServiceActionApi.js +0 -234
  520. package/bin/service/core/ServiceActionApi.js.map +0 -1
  521. package/bin/service/core/ServiceManager.d.ts +0 -9
  522. package/bin/service/core/ServiceManager.d.ts.map +0 -1
  523. package/bin/service/core/ServiceManager.js +0 -9
  524. package/bin/service/core/ServiceManager.js.map +0 -1
  525. package/bin/service/schedule/Executor.d.ts.map +0 -1
  526. package/bin/service/schedule/Executor.js.map +0 -1
  527. package/bin/service/schedule/Runtime.d.ts +0 -17
  528. package/bin/service/schedule/Runtime.d.ts.map +0 -1
  529. package/bin/service/schedule/Runtime.js +0 -64
  530. package/bin/service/schedule/Runtime.js.map +0 -1
  531. package/bin/service/schedule/Store.d.ts.map +0 -1
  532. package/bin/service/schedule/Store.js.map +0 -1
  533. package/bin/service/schedule/Time.d.ts.map +0 -1
  534. package/bin/service/schedule/Time.js.map +0 -1
  535. package/src/runtime/AgentContext.ts +0 -182
  536. package/src/runtime/AgentRuntime.ts +0 -366
  537. package/src/runtime/AgentRuntimeState.ts +0 -213
  538. package/src/sdk/HttpServer.ts +0 -231
  539. package/src/sdk/RpcServer.ts +0 -244
  540. package/src/service/core/ServiceActionApi.ts +0 -304
  541. package/src/service/core/ServiceManager.ts +0 -20
  542. package/src/service/schedule/Runtime.ts +0 -78
  543. /package/bin/service/{schedule → core/schedule}/Time.d.ts +0 -0
  544. /package/bin/service/{schedule → core/schedule}/Time.js +0 -0
  545. /package/src/service/{schedule → core/schedule}/Time.ts +0 -0
@@ -13,6 +13,9 @@ import type { JsonValue } from "@/types/common/Json.js";
13
13
  import type { Plugin } from "@/plugin/types/Plugin.js";
14
14
  import type { SessionMessageV1 } from "@/session/types/SessionMessages.js";
15
15
  import type { AgentPlatformRuntime } from "@/types/host/AgentHost.js";
16
+ import type { LocalRpcServerHandle } from "@/types/rpc/LocalRpc.js";
17
+ import type { ServerInstance } from "@/server/http/Server.js";
18
+ import type { Session } from "@/sdk/Session.js";
16
19
 
17
20
  /**
18
21
  * 本地 Agent 构造参数。
@@ -61,6 +64,15 @@ export interface AgentOptions {
61
64
  */
62
65
  services?: BaseService[];
63
66
 
67
+ /**
68
+ * 是否自动装配全部内建 service。
69
+ *
70
+ * 关键点(中文)
71
+ * - 适合 city 这类宿主进程直接 `new Agent(...)` 的场景。
72
+ * - 未开启时,默认只使用显式传入的 `services`。
73
+ */
74
+ useBuiltinServices?: boolean;
75
+
64
76
  /**
65
77
  * 当前 agent 显式注册的 plugin 定义集合。
66
78
  *
@@ -71,6 +83,15 @@ export interface AgentOptions {
71
83
  */
72
84
  plugins?: Plugin[];
73
85
 
86
+ /**
87
+ * 是否自动装配全部内建 plugin。
88
+ *
89
+ * 关键点(中文)
90
+ * - 适合 city 这类宿主进程直接 `new Agent(...)` 的场景。
91
+ * - 未开启时,默认只使用显式传入的 `plugins`。
92
+ */
93
+ useBuiltinPlugins?: boolean;
94
+
74
95
  /**
75
96
  * 当前 agent 显式注入的平台能力集合。
76
97
  *
@@ -79,6 +100,143 @@ export interface AgentOptions {
79
100
  * - 推荐由宿主产品显式传入,避免 SDK 本地实例隐式依赖 city。
80
101
  */
81
102
  platform?: AgentPlatformRuntime;
103
+
104
+ /**
105
+ * 在 session 初始化后执行的宿主配置钩子。
106
+ *
107
+ * 关键点(中文)
108
+ * - SDK 不负责默认模型策略,宿主可在这里统一为 session 注入 model 等运行配置。
109
+ * - 该钩子只在 session 首次创建时触发一次,适合做实例级默认装配。
110
+ */
111
+ configureSession?: (session: Session) => Promise<void> | void;
112
+ }
113
+
114
+ /**
115
+ * Agent 启动参数。
116
+ */
117
+ export interface AgentStartOptions {
118
+ /**
119
+ * 是否启动 HTTP 服务。
120
+ *
121
+ * 关键点(中文)
122
+ * - `false` 表示不启动。
123
+ * - 传对象时会按给定 host/port 启动。
124
+ * - 省略时默认不启动,避免 SDK 本地嵌入场景误开端口。
125
+ */
126
+ http?: false | AgentHttpStartOptions;
127
+
128
+ /**
129
+ * 是否启动本地 RPC 服务。
130
+ *
131
+ * 关键点(中文)
132
+ * - `true` 时启动主 local RPC server。
133
+ * - 省略或 `false` 时不启动。
134
+ */
135
+ rpc?: boolean;
136
+
137
+ /**
138
+ * 是否启动当前 agent 的 services。
139
+ *
140
+ * 关键点(中文)
141
+ * - 默认 `true`。
142
+ * - `false` 适合只需要 session 能力、不希望启动后台能力的嵌入场景。
143
+ */
144
+ services?: boolean;
145
+ }
146
+
147
+ /**
148
+ * Agent 停止结果快照。
149
+ */
150
+ export interface AgentStopResult {
151
+ /**
152
+ * 本次是否实际停止了 HTTP 服务。
153
+ */
154
+ httpStopped: boolean;
155
+
156
+ /**
157
+ * 本次是否实际停止了本地 RPC 服务。
158
+ */
159
+ rpcStopped: boolean;
160
+
161
+ /**
162
+ * 本次是否实际停止了 services。
163
+ */
164
+ servicesStopped: boolean;
165
+ }
166
+
167
+ /**
168
+ * Agent 启动后的状态快照。
169
+ */
170
+ export interface AgentStartResult {
171
+ /**
172
+ * 当前 agent 是否已启动 HTTP 服务。
173
+ */
174
+ http?: AgentHttpBinding;
175
+
176
+ /**
177
+ * 当前 agent 是否已启动本地 RPC 服务。
178
+ */
179
+ rpc?: AgentRpcBinding;
180
+
181
+ /**
182
+ * 当前 agent 是否已启动 services。
183
+ */
184
+ servicesStarted: boolean;
185
+ }
186
+
187
+ /**
188
+ * Agent HTTP 启动参数。
189
+ */
190
+ export interface AgentHttpStartOptions {
191
+ /**
192
+ * HTTP 监听主机。
193
+ */
194
+ host?: string;
195
+
196
+ /**
197
+ * HTTP 监听端口。
198
+ */
199
+ port?: number;
200
+ }
201
+
202
+ /**
203
+ * Agent HTTP 绑定信息。
204
+ */
205
+ export interface AgentHttpBinding {
206
+ /**
207
+ * 对外访问地址。
208
+ */
209
+ baseUrl: string;
210
+
211
+ /**
212
+ * 当前 host。
213
+ */
214
+ host: string;
215
+
216
+ /**
217
+ * 当前 port。
218
+ */
219
+ port: number;
220
+
221
+ /**
222
+ * HTTP server 句柄。
223
+ */
224
+ server: ServerInstance;
225
+ }
226
+
227
+ /**
228
+ * Agent RPC 绑定信息。
229
+ */
230
+ export interface AgentRpcBinding {
231
+ /**
232
+ * 当前本地 RPC endpoint。
233
+ */
234
+ endpoint: string;
235
+
236
+ /**
237
+ * 本地 RPC server 句柄。
238
+ */
239
+ server: LocalRpcServerHandle;
82
240
  }
83
241
 
84
242
  /**
@@ -2,7 +2,7 @@
2
2
  * RemoteAgent:远程 SDK 客户端。
3
3
  *
4
4
  * 关键点(中文)
5
- * - 面向已启动 `agent.http.start()` 的远程/本地 HTTP 服务。
5
+ * - 面向已通过 `agent.start({ http: { ... } })` 暴露出来的远程/本地 HTTP 服务。
6
6
  * - 与本地 `Agent` 尽量保持同一套 session 使用面。
7
7
  */
8
8
 
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - 面向 `new Agent(...)` 的本地会话使用场景。
6
- * - 统一收口消息落盘、默认模型配置、run/stream/fork 等高层 API。
6
+ * - 统一收口消息落盘、session 级模型配置、run/stream/fork 等高层 API。
7
7
  * - 内部继续复用 `Executor` / `JsonlSessionHistoryComposer` / `Runner`。
8
8
  */
9
9
 
@@ -34,19 +34,19 @@ import {
34
34
  readSessionMetadata,
35
35
  resolveSystemTimezone,
36
36
  writeSessionMetadata,
37
- } from "@/sdk/SessionMetadata.js";
37
+ } from "@/sdk/session/index.js";
38
38
  import {
39
39
  getSdkAgentSessionArchiveDirPath,
40
40
  getSdkAgentSessionDirPath,
41
- } from "@/sdk/Paths.js";
41
+ } from "@/sdk/session/index.js";
42
42
  import { AsyncQueue } from "@/sdk/AsyncQueue.js";
43
- import type { SessionPort } from "@/runtime/AgentContextTypes.js";
43
+ import type { SessionPort } from "@/core/AgentContextTypes.js";
44
44
  import { pushUiMessageChunkAsSdkEvent } from "@/sdk/StreamEvents.js";
45
45
  import {
46
46
  persistSdkAssistantResult,
47
47
  touchSessionMetadata,
48
- } from "@/sdk/SessionPersistence.js";
49
- import { createSessionServicePort } from "@/sdk/SessionServicePort.js";
48
+ } from "@/sdk/session/index.js";
49
+ import { createSessionServicePort } from "@/sdk/session/index.js";
50
50
 
51
51
  type SessionOptions = {
52
52
  /**
@@ -332,6 +332,11 @@ export class Session {
332
332
  if (!query) {
333
333
  throw new Error("session.run requires a non-empty query");
334
334
  }
335
+ if (!this.sessionConfig.model) {
336
+ throw new Error(
337
+ `Session "${this.id}" requires a configured model. Call session.set({ model }) first or let the host configure the session during creation.`,
338
+ );
339
+ }
335
340
  await this.appendUserMessage({ text: query });
336
341
  const result = await this.executor.run({
337
342
  query,
@@ -355,6 +360,11 @@ export class Session {
355
360
  if (!query) {
356
361
  throw new Error("session.stream requires a non-empty query");
357
362
  }
363
+ if (!this.sessionConfig.model) {
364
+ throw new Error(
365
+ `Session "${this.id}" requires a configured model. Call session.set({ model }) first or let the host configure the session during creation.`,
366
+ );
367
+ }
358
368
  const queue = new AsyncQueue<AgentSessionStreamEvent>();
359
369
  const toolNameByCallId = new Map<string, string>();
360
370
  await this.appendUserMessage({ text: query });
@@ -12,7 +12,7 @@ import type {
12
12
  SessionHistoryMetaV1,
13
13
  SessionHistorySdkConfigV1,
14
14
  } from "@/session/types/SessionHistoryMeta.js";
15
- import { getSdkAgentSessionMetaPath } from "@/sdk/Paths.js";
15
+ import { getSdkAgentSessionMetaPath } from "@/sdk/session/Paths.js";
16
16
 
17
17
  type ReadSessionMetadataInput = {
18
18
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * SDK Session 落盘路径规则。
2
+ * SDK Session 路径规则。
3
3
  *
4
4
  * 关键点(中文)
5
5
  * - 与旧 `.downcity/session/<sessionId>` 路径分开,避免不同 agent 在同一项目目录下互相污染。
@@ -14,7 +14,7 @@ import type { AgentSessionConfigSnapshot } from "@/sdk/AgentSdkTypes.js";
14
14
  import {
15
15
  readSessionMetadata,
16
16
  writeSessionMetadata,
17
- } from "@/sdk/SessionMetadata.js";
17
+ } from "@/sdk/session/Metadata.js";
18
18
 
19
19
  /**
20
20
  * SDK Session 元数据写入参数。
@@ -6,7 +6,7 @@
6
6
  * - service 侧直接复用底层 `Executor` 协议,避免 SDK `run()` 包装层重复补写消息。
7
7
  */
8
8
 
9
- import type { SessionPort } from "@/runtime/AgentContextTypes.js";
9
+ import type { SessionPort } from "@/core/AgentContextTypes.js";
10
10
 
11
11
  /**
12
12
  * 构造 SDK SessionPort 的参数。
@@ -0,0 +1,34 @@
1
+ /**
2
+ * SDK Session 辅助模块聚合入口。
3
+ *
4
+ * 关键点(中文)
5
+ * - 这里收口 `Session.ts` 依赖的路径、元数据、持久化与 service 端口适配能力。
6
+ * - 避免这些实现继续平铺在 `sdk/` 顶层,提升目录语义清晰度。
7
+ */
8
+
9
+ export {
10
+ getSdkAgentDirPath,
11
+ getSdkAgentRpcEndpointPath,
12
+ getSdkAgentSessionArchiveDirPath,
13
+ getSdkAgentSessionDirPath,
14
+ getSdkAgentSessionMessagesDirPath,
15
+ getSdkAgentSessionMessagesPath,
16
+ getSdkAgentSessionMetaPath,
17
+ getSdkAgentSessionsRootDirPath,
18
+ getSdkAgentsRootDirPath,
19
+ getSdkDowncityDirPath,
20
+ } from "./Paths.js";
21
+ export {
22
+ inferModelLabel,
23
+ patchSessionModelLabel,
24
+ readSessionMetadata,
25
+ resolveSystemTimezone,
26
+ writeSessionMetadata,
27
+ } from "./Metadata.js";
28
+ export {
29
+ persistSdkAssistantResult,
30
+ touchSessionMetadata,
31
+ } from "./Persistence.js";
32
+ export {
33
+ createSessionServicePort,
34
+ } from "./ServicePort.js";
@@ -12,20 +12,20 @@ import { cors } from "hono/cors";
12
12
  import { logger } from "hono/logger";
13
13
  import http from "node:http";
14
14
  import { logger as serverLogger } from "@/utils/logger/Logger.js";
15
- import { executeRouter } from "@/server/http/execute/execute.js";
15
+ import { createExecuteRouter } from "@/server/http/execute/execute.js";
16
16
  import { healthRouter } from "@/server/http/health/health.js";
17
17
  import {
18
- ensureServiceActionRoutesRegistered,
19
- servicesRouter,
18
+ createServicesRouter,
20
19
  } from "@/server/http/services/services.js";
21
- import { pluginsRouter } from "@/server/http/plugins/plugins.js";
22
- import { staticRouter } from "@/server/http/static/static.js";
23
- import { controlRouter } from "@/server/http/control/ControlRouter.js";
20
+ import { createPluginsRouter } from "@/server/http/plugins/plugins.js";
21
+ import { createStaticRouter } from "@/server/http/static/static.js";
22
+ import { createControlRouter } from "@/server/http/control/ControlRouter.js";
24
23
  import {
25
- listBuiltinPluginRuntimeAuthPolicies,
26
24
  registerBuiltinPluginHttpRoutes,
27
25
  } from "@/plugin/core/HttpRoutes.js";
28
- import { getAgentContext } from "@/runtime/AgentRuntime.js";
26
+ import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
27
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
28
+ import type { AgentCore } from "@/core/AgentCore.js";
29
29
 
30
30
  /**
31
31
  * Server 启动参数。
@@ -35,6 +35,12 @@ export interface ServerStartOptions {
35
35
  port: number;
36
36
  /** HTTP 服务监听主机。 */
37
37
  host: string;
38
+ /** 可选实例级 agent core。 */
39
+ core?: Pick<AgentCore, "getContext" | "getRuntime">;
40
+ /** 可选实例级 runtime 读取函数。 */
41
+ getAgentRuntime?: () => AgentRuntime;
42
+ /** 可选实例级 context 读取函数。 */
43
+ getAgentContext?: () => AgentContext;
38
44
  }
39
45
 
40
46
  /**
@@ -49,11 +55,41 @@ export interface ServerInstance {
49
55
  stop(): Promise<void>;
50
56
  }
51
57
 
58
+ type AgentServerBindings = {
59
+ getAgentRuntime: () => AgentRuntime;
60
+ getAgentContext: () => AgentContext;
61
+ };
62
+
63
+ function resolveServerBindings(options: Pick<
64
+ ServerStartOptions,
65
+ "core" | "getAgentRuntime" | "getAgentContext"
66
+ >): AgentServerBindings {
67
+ const core = options.core;
68
+ if (core) {
69
+ return {
70
+ getAgentRuntime: () => core.getRuntime(),
71
+ getAgentContext: () => core.getContext(),
72
+ };
73
+ }
74
+ if (options.getAgentRuntime && options.getAgentContext) {
75
+ return {
76
+ getAgentRuntime: options.getAgentRuntime,
77
+ getAgentContext: options.getAgentContext,
78
+ };
79
+ }
80
+ throw new Error(
81
+ "createServerApp/startServer requires either core or both getAgentRuntime/getAgentContext",
82
+ );
83
+ }
84
+
52
85
  /**
53
86
  * 创建主 Hono 应用。
54
87
  */
55
- export function createServerApp(): Hono {
88
+ export function createServerApp(
89
+ options: Pick<ServerStartOptions, "core" | "getAgentRuntime" | "getAgentContext">,
90
+ ): Hono {
56
91
  const app = new Hono();
92
+ const bindings = resolveServerBindings(options);
57
93
 
58
94
  app.use("*", logger());
59
95
  app.use(
@@ -65,19 +101,28 @@ export function createServerApp(): Hono {
65
101
  }),
66
102
  );
67
103
 
68
- // 关键点(中文):service action 路由在 runtime ready 后再注册,避免命令级 import 副作用。
69
- ensureServiceActionRoutesRegistered();
70
-
71
104
  // 关键点(中文):按路由域挂载,server 模块只保留装配职责。
72
- app.route("/", staticRouter);
105
+ app.route("/", createStaticRouter({
106
+ getAgentRuntime: bindings.getAgentRuntime,
107
+ }));
73
108
  app.route("/", healthRouter);
109
+ const servicesRouter = createServicesRouter({
110
+ getAgentContext: bindings.getAgentContext,
111
+ });
74
112
  app.route("/", servicesRouter);
75
- app.route("/", pluginsRouter);
76
- app.route("/", executeRouter);
77
- app.route("/", controlRouter);
113
+ app.route("/", createPluginsRouter({
114
+ getAgentContext: bindings.getAgentContext,
115
+ }));
116
+ app.route("/", createExecuteRouter({
117
+ getAgentRuntime: bindings.getAgentRuntime,
118
+ }));
119
+ app.route("/", createControlRouter({
120
+ getAgentRuntime: bindings.getAgentRuntime,
121
+ getAgentContext: bindings.getAgentContext,
122
+ }));
78
123
  registerBuiltinPluginHttpRoutes({
79
124
  app,
80
- getContext: getAgentContext,
125
+ getContext: bindings.getAgentContext,
81
126
  });
82
127
 
83
128
  return app;
@@ -89,7 +134,7 @@ export function createServerApp(): Hono {
89
134
  export async function startServer(
90
135
  options: ServerStartOptions,
91
136
  ): Promise<ServerInstance> {
92
- const app = createServerApp();
137
+ const app = createServerApp(options);
93
138
  const server = createNodeServer(app, options);
94
139
 
95
140
  await new Promise<void>((resolve) => {
@@ -7,7 +7,7 @@
7
7
  * - 这样调用方不需要知道 plugin action 名称,也不需要依赖 `plugin/builtins/auth/*` 目录。
8
8
  */
9
9
 
10
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
10
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
11
11
  import type { JsonObject } from "@/types/common/Json.js";
12
12
  import type { AuthControlPayload } from "@/server/http/control/types/AuthControl.js";
13
13
  import type {
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import type { Hono } from "hono";
10
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
10
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
11
11
  import {
12
12
  readAuthControlPayload,
13
13
  setAuthControlUserRole,
@@ -13,19 +13,35 @@
13
13
  */
14
14
 
15
15
  import { Hono } from "hono";
16
- import {
17
- getAgentRuntime,
18
- getAgentContext,
19
- } from "@/runtime/AgentRuntime.js";
16
+ import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
17
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
20
18
  import { registerControlApiRoutes } from "@/server/http/control/ControlApiRoutes.js";
21
19
 
22
20
  /**
23
- * 单 agent control API 专用路由。
21
+ * control router 参数。
24
22
  */
25
- export const controlRouter = new Hono();
23
+ type ControlRouterOptions = {
24
+ /**
25
+ * 读取当前 agent runtime。
26
+ */
27
+ getAgentRuntime: () => AgentRuntime;
28
+ /**
29
+ * 读取当前 agent 执行上下文。
30
+ */
31
+ getAgentContext: () => AgentContext;
32
+ };
26
33
 
27
- registerControlApiRoutes({
28
- app: controlRouter,
29
- getAgentRuntime: getAgentRuntime,
30
- getAgentContext: getAgentContext,
31
- });
34
+ /**
35
+ * 创建单 agent control API 专用路由。
36
+ */
37
+ export function createControlRouter(
38
+ options: ControlRouterOptions,
39
+ ): Hono {
40
+ const router = new Hono();
41
+ registerControlApiRoutes({
42
+ app: router,
43
+ getAgentRuntime: options.getAgentRuntime,
44
+ getAgentContext: options.getAgentContext,
45
+ });
46
+ return router;
47
+ }
@@ -6,8 +6,8 @@
6
6
  * - 非 chat session 保留原有直接执行语义。
7
7
  */
8
8
 
9
- import type { AgentRuntime } from "@/runtime/AgentRuntime.js";
10
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
9
+ import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
10
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
11
11
  import type { JsonObject } from "@/types/common/Json.js";
12
12
  import type { ControlSessionExecuteAttachmentInput } from "@/server/http/control/types/ControlSessionExecute.js";
13
13
  import { drainDeferredPersistedUserMessages } from "@session/SessionRunScope.js";
@@ -54,7 +54,9 @@ export function registerControlOverviewRoutes(
54
54
  executionContext: params.getAgentContext(),
55
55
  limit: sessionLimit,
56
56
  });
57
- const services = listServiceStates();
57
+ const services = listServiceStates({
58
+ context: params.getAgentContext(),
59
+ });
58
60
  const taskResult = await listTaskDefinitions({
59
61
  projectRoot: runtime.rootPath,
60
62
  });
@@ -99,7 +101,9 @@ export function registerControlOverviewRoutes(
99
101
  app.get(routePath, (c) => {
100
102
  return c.json({
101
103
  success: true,
102
- services: listServiceStates(),
104
+ services: listServiceStates({
105
+ context: params.getAgentContext(),
106
+ }),
103
107
  });
104
108
  });
105
109
  }
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import fs from "fs-extra";
10
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
10
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
11
11
  import {
12
12
  getDowncitySessionMessagesPath,
13
13
  getDowncitySessionRootDirPath,
@@ -7,8 +7,8 @@
7
7
  */
8
8
 
9
9
  import type { Hono } from "hono";
10
- import type { AgentRuntime } from "@/runtime/AgentRuntimeTypes.js";
11
- import type { AgentContext } from "@/runtime/AgentContextTypes.js";
10
+ import type { AgentRuntime } from "@/core/AgentCoreTypes.js";
11
+ import type { AgentContext } from "@/core/AgentContextTypes.js";
12
12
 
13
13
  /**
14
14
  * Control 路由注册入参。