@downcity/agent 1.1.73 → 1.1.79

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 (390) hide show
  1. package/README.md +26 -28
  2. package/bin/agent/{Agent.d.ts → local/Agent.d.ts} +8 -36
  3. package/bin/agent/local/Agent.d.ts.map +1 -0
  4. package/bin/agent/{Agent.js → local/Agent.js} +45 -200
  5. package/bin/agent/local/Agent.js.map +1 -0
  6. package/bin/agent/local/AgentInstructions.d.ts +22 -0
  7. package/bin/agent/local/AgentInstructions.d.ts.map +1 -0
  8. package/bin/agent/local/AgentInstructions.js +57 -0
  9. package/bin/agent/local/AgentInstructions.js.map +1 -0
  10. package/bin/agent/local/AgentPluginFactory.d.ts +29 -0
  11. package/bin/agent/local/AgentPluginFactory.d.ts.map +1 -0
  12. package/bin/agent/local/AgentPluginFactory.js +53 -0
  13. package/bin/agent/local/AgentPluginFactory.js.map +1 -0
  14. package/bin/{runtime/host/AgentHostRuntime.d.ts → agent/local/AgentRuntimeAssembly.d.ts} +2 -2
  15. package/bin/agent/local/AgentRuntimeAssembly.d.ts.map +1 -0
  16. package/bin/{runtime/host/AgentHostRuntime.js → agent/local/AgentRuntimeAssembly.js} +2 -2
  17. package/bin/agent/local/AgentRuntimeAssembly.js.map +1 -0
  18. package/bin/agent/local/AgentRuntimeFactory.d.ts +72 -0
  19. package/bin/agent/local/AgentRuntimeFactory.d.ts.map +1 -0
  20. package/bin/agent/local/AgentRuntimeFactory.js +94 -0
  21. package/bin/agent/local/AgentRuntimeFactory.js.map +1 -0
  22. package/bin/{runtime/host → agent/local}/ProjectSetup.d.ts +1 -1
  23. package/bin/agent/local/ProjectSetup.d.ts.map +1 -0
  24. package/bin/{runtime/host → agent/local}/ProjectSetup.js +1 -1
  25. package/bin/agent/local/ProjectSetup.js.map +1 -0
  26. package/bin/agent/{RemoteAgent.d.ts → remote/RemoteAgent.d.ts} +3 -3
  27. package/bin/agent/remote/RemoteAgent.d.ts.map +1 -0
  28. package/bin/agent/remote/RemoteAgent.js +58 -0
  29. package/bin/agent/remote/RemoteAgent.js.map +1 -0
  30. package/bin/agent/remote/RemoteSession.d.ts +62 -0
  31. package/bin/agent/remote/RemoteSession.d.ts.map +1 -0
  32. package/bin/agent/remote/RemoteSession.js +225 -0
  33. package/bin/agent/remote/RemoteSession.js.map +1 -0
  34. package/bin/agent/remote/RemoteTransport.d.ts +52 -0
  35. package/bin/agent/remote/RemoteTransport.d.ts.map +1 -0
  36. package/bin/agent/remote/RemoteTransport.js +9 -0
  37. package/bin/agent/remote/RemoteTransport.js.map +1 -0
  38. package/bin/agent/remote/TransportFactory.d.ts +13 -0
  39. package/bin/agent/remote/TransportFactory.d.ts.map +1 -0
  40. package/bin/agent/remote/TransportFactory.js +22 -0
  41. package/bin/agent/remote/TransportFactory.js.map +1 -0
  42. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +35 -0
  43. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -0
  44. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +259 -0
  45. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js.map +1 -0
  46. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +34 -0
  47. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -0
  48. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +66 -0
  49. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js.map +1 -0
  50. package/bin/config/AgentInitializer.d.ts +1 -1
  51. package/bin/config/AgentInitializer.js +1 -1
  52. package/bin/executor/Executor.d.ts +4 -0
  53. package/bin/executor/Executor.d.ts.map +1 -1
  54. package/bin/executor/Executor.js +52 -35
  55. package/bin/executor/Executor.js.map +1 -1
  56. package/bin/executor/composer/history/SessionHistoryWriter.js +2 -2
  57. package/bin/executor/composer/history/SessionHistoryWriter.js.map +1 -1
  58. package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
  59. package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
  60. package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
  61. package/bin/executor/composer/system/default/assets/core.prompt.js.map +1 -1
  62. package/bin/executor/messages/AssistantResultPersistence.d.ts +3 -3
  63. package/bin/executor/messages/AssistantResultPersistence.d.ts.map +1 -1
  64. package/bin/executor/messages/AssistantResultPersistence.js +2 -6
  65. package/bin/executor/messages/AssistantResultPersistence.js.map +1 -1
  66. package/bin/executor/messages/SessionStepEventMapper.d.ts +7 -8
  67. package/bin/executor/messages/SessionStepEventMapper.d.ts.map +1 -1
  68. package/bin/executor/messages/SessionStepEventMapper.js +55 -86
  69. package/bin/executor/messages/SessionStepEventMapper.js.map +1 -1
  70. package/bin/executor/messages/UserVisibleText.d.ts +2 -10
  71. package/bin/executor/messages/UserVisibleText.d.ts.map +1 -1
  72. package/bin/executor/messages/UserVisibleText.js +3 -16
  73. package/bin/executor/messages/UserVisibleText.js.map +1 -1
  74. package/bin/executor/store/history/SessionHistoryStore.d.ts +12 -0
  75. package/bin/executor/store/history/SessionHistoryStore.d.ts.map +1 -1
  76. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts +12 -0
  77. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.d.ts.map +1 -1
  78. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js +145 -8
  79. package/bin/executor/store/history/jsonl/JsonlSessionHistoryStore.js.map +1 -1
  80. package/bin/executor/tools/shell/ShellToolFormatting.d.ts +1 -10
  81. package/bin/executor/tools/shell/ShellToolFormatting.d.ts.map +1 -1
  82. package/bin/executor/tools/shell/ShellToolFormatting.js +1 -39
  83. package/bin/executor/tools/shell/ShellToolFormatting.js.map +1 -1
  84. package/bin/executor/types/SessionHistoryPaths.d.ts +4 -0
  85. package/bin/executor/types/SessionHistoryPaths.d.ts.map +1 -1
  86. package/bin/index.d.ts +5 -5
  87. package/bin/index.d.ts.map +1 -1
  88. package/bin/index.js +3 -3
  89. package/bin/index.js.map +1 -1
  90. package/bin/plugin/core/PluginCommandRequest.d.ts +1 -1
  91. package/bin/plugin/core/PluginCommandRequest.js +1 -1
  92. package/bin/plugin/core/PluginLocalExecution.js +1 -1
  93. package/bin/plugin/core/PluginLocalExecution.js.map +1 -1
  94. package/bin/plugin/core/ProjectConfigStore.d.ts +3 -2
  95. package/bin/plugin/core/ProjectConfigStore.d.ts.map +1 -1
  96. package/bin/plugin/core/ProjectConfigStore.js +3 -4
  97. package/bin/plugin/core/ProjectConfigStore.js.map +1 -1
  98. package/bin/plugin/types/Plugin.d.ts +10 -842
  99. package/bin/plugin/types/Plugin.d.ts.map +1 -1
  100. package/bin/plugin/types/Plugin.js +3 -4
  101. package/bin/plugin/types/Plugin.js.map +1 -1
  102. package/bin/plugin/types/PluginApi.d.ts +1 -1
  103. package/bin/plugin/types/PluginApi.js +1 -1
  104. package/bin/plugin/types/PluginState.d.ts +1 -1
  105. package/bin/plugin/types/PluginState.d.ts.map +1 -1
  106. package/bin/rpc/Client.d.ts +2 -99
  107. package/bin/rpc/Client.d.ts.map +1 -1
  108. package/bin/rpc/Client.js +0 -46
  109. package/bin/rpc/Client.js.map +1 -1
  110. package/bin/rpc/Server.d.ts +5 -21
  111. package/bin/rpc/Server.d.ts.map +1 -1
  112. package/bin/rpc/Server.js +30 -315
  113. package/bin/rpc/Server.js.map +1 -1
  114. package/bin/rpc/server/InternalHandlers.d.ts +21 -0
  115. package/bin/rpc/server/InternalHandlers.d.ts.map +1 -0
  116. package/bin/rpc/server/InternalHandlers.js +190 -0
  117. package/bin/rpc/server/InternalHandlers.js.map +1 -0
  118. package/bin/rpc/server/RequestDispatcher.d.ts +27 -0
  119. package/bin/rpc/server/RequestDispatcher.d.ts.map +1 -0
  120. package/bin/rpc/server/RequestDispatcher.js +38 -0
  121. package/bin/rpc/server/RequestDispatcher.js.map +1 -0
  122. package/bin/rpc/server/SdkSessionHandlers.d.ts +25 -0
  123. package/bin/rpc/server/SdkSessionHandlers.d.ts.map +1 -0
  124. package/bin/rpc/server/SdkSessionHandlers.js +86 -0
  125. package/bin/rpc/server/SdkSessionHandlers.js.map +1 -0
  126. package/bin/rpc/server/ServerTypes.d.ts +59 -0
  127. package/bin/rpc/server/ServerTypes.d.ts.map +1 -0
  128. package/bin/rpc/server/ServerTypes.js +9 -0
  129. package/bin/rpc/server/ServerTypes.js.map +1 -0
  130. package/bin/{runtime/sandbox → sandbox}/MacOsSeatbeltSandbox.d.ts +1 -1
  131. package/bin/sandbox/MacOsSeatbeltSandbox.d.ts.map +1 -0
  132. package/bin/sandbox/MacOsSeatbeltSandbox.js.map +1 -0
  133. package/bin/{runtime/sandbox → sandbox}/SandboxConfigResolver.d.ts +2 -2
  134. package/bin/sandbox/SandboxConfigResolver.d.ts.map +1 -0
  135. package/bin/sandbox/SandboxConfigResolver.js.map +1 -0
  136. package/bin/{runtime/sandbox → sandbox}/SandboxRunner.d.ts +2 -2
  137. package/bin/sandbox/SandboxRunner.d.ts.map +1 -0
  138. package/bin/{runtime/sandbox → sandbox}/SandboxRunner.js +2 -2
  139. package/bin/sandbox/SandboxRunner.js.map +1 -0
  140. package/bin/sandbox/types/Sandbox.d.ts.map +1 -0
  141. package/bin/sandbox/types/Sandbox.js.map +1 -0
  142. package/bin/{runtime/sandbox → sandbox}/types/SandboxRuntime.d.ts +2 -2
  143. package/bin/sandbox/types/SandboxRuntime.d.ts.map +1 -0
  144. package/bin/sandbox/types/SandboxRuntime.js.map +1 -0
  145. package/bin/session/Session.d.ts.map +1 -1
  146. package/bin/session/Session.js +2 -1
  147. package/bin/session/Session.js.map +1 -1
  148. package/bin/session/browse/Browse.d.ts +1 -1
  149. package/bin/session/browse/Browse.d.ts.map +1 -1
  150. package/bin/session/browse/Browse.js +28 -13
  151. package/bin/session/browse/Browse.js.map +1 -1
  152. package/bin/session/index.d.ts +1 -1
  153. package/bin/session/index.d.ts.map +1 -1
  154. package/bin/session/index.js +1 -1
  155. package/bin/session/index.js.map +1 -1
  156. package/bin/session/storage/Paths.d.ts +9 -0
  157. package/bin/session/storage/Paths.d.ts.map +1 -1
  158. package/bin/session/storage/Paths.js +11 -0
  159. package/bin/session/storage/Paths.js.map +1 -1
  160. package/bin/types/agent/AgentOptions.d.ts +134 -0
  161. package/bin/types/agent/AgentOptions.d.ts.map +1 -0
  162. package/bin/types/agent/AgentOptions.js +9 -0
  163. package/bin/types/agent/AgentOptions.js.map +1 -0
  164. package/bin/types/{runtime/host/AgentHost.d.ts → agent/AgentRuntimeAssembly.d.ts} +4 -4
  165. package/bin/types/agent/AgentRuntimeAssembly.d.ts.map +1 -0
  166. package/bin/types/{runtime/host/AgentHost.js → agent/AgentRuntimeAssembly.js} +3 -3
  167. package/bin/types/agent/AgentRuntimeAssembly.js.map +1 -0
  168. package/bin/types/agent/AgentTypes.d.ts +8 -613
  169. package/bin/types/agent/AgentTypes.d.ts.map +1 -1
  170. package/bin/types/agent/AgentTypes.js +4 -4
  171. package/bin/types/agent/RemoteAgentOptions.d.ts +28 -0
  172. package/bin/types/agent/RemoteAgentOptions.d.ts.map +1 -0
  173. package/bin/types/agent/RemoteAgentOptions.js +9 -0
  174. package/bin/types/agent/RemoteAgentOptions.js.map +1 -0
  175. package/bin/types/agent/SessionActor.d.ts +60 -0
  176. package/bin/types/agent/SessionActor.d.ts.map +1 -0
  177. package/bin/types/agent/SessionActor.js +9 -0
  178. package/bin/types/agent/SessionActor.js.map +1 -0
  179. package/bin/types/agent/SessionTypes.d.ts +312 -0
  180. package/bin/types/agent/SessionTypes.d.ts.map +1 -0
  181. package/bin/types/agent/SessionTypes.js +9 -0
  182. package/bin/types/agent/SessionTypes.js.map +1 -0
  183. package/bin/types/config/DowncityConfig.d.ts +1 -1
  184. package/bin/types/config/DowncityConfig.d.ts.map +1 -1
  185. package/bin/types/{runtime/host → platform}/Store.d.ts +1 -1
  186. package/bin/types/platform/Store.d.ts.map +1 -0
  187. package/bin/types/{runtime/host → platform}/Store.js +1 -1
  188. package/bin/types/platform/Store.js.map +1 -0
  189. package/bin/types/plugin/PluginAction.d.ts +119 -0
  190. package/bin/types/plugin/PluginAction.d.ts.map +1 -0
  191. package/bin/types/plugin/PluginAction.js +9 -0
  192. package/bin/types/plugin/PluginAction.js.map +1 -0
  193. package/bin/types/plugin/PluginCommand.d.ts +80 -0
  194. package/bin/types/plugin/PluginCommand.d.ts.map +1 -0
  195. package/bin/types/plugin/PluginCommand.js +9 -0
  196. package/bin/types/plugin/PluginCommand.js.map +1 -0
  197. package/bin/types/plugin/PluginDefinition.d.ts +57 -0
  198. package/bin/types/plugin/PluginDefinition.d.ts.map +1 -0
  199. package/bin/types/plugin/PluginDefinition.js +9 -0
  200. package/bin/types/plugin/PluginDefinition.js.map +1 -0
  201. package/bin/types/plugin/PluginHttp.d.ts +34 -0
  202. package/bin/types/plugin/PluginHttp.d.ts.map +1 -0
  203. package/bin/types/plugin/PluginHttp.js +9 -0
  204. package/bin/types/plugin/PluginHttp.js.map +1 -0
  205. package/bin/types/plugin/PluginRuntime.d.ts +148 -0
  206. package/bin/types/plugin/PluginRuntime.d.ts.map +1 -0
  207. package/bin/types/plugin/PluginRuntime.js +9 -0
  208. package/bin/types/plugin/PluginRuntime.js.map +1 -0
  209. package/bin/types/plugin/PluginSetup.d.ts +133 -0
  210. package/bin/types/plugin/PluginSetup.d.ts.map +1 -0
  211. package/bin/types/plugin/PluginSetup.js +9 -0
  212. package/bin/types/plugin/PluginSetup.js.map +1 -0
  213. package/bin/types/plugin/PluginState.d.ts +69 -0
  214. package/bin/types/plugin/PluginState.d.ts.map +1 -0
  215. package/bin/types/plugin/PluginState.js +9 -0
  216. package/bin/types/plugin/PluginState.js.map +1 -0
  217. package/bin/types/rpc/RpcProtocol.d.ts +323 -0
  218. package/bin/types/rpc/RpcProtocol.d.ts.map +1 -0
  219. package/bin/types/rpc/RpcProtocol.js +10 -0
  220. package/bin/types/rpc/RpcProtocol.js.map +1 -0
  221. package/bin/types/runtime/agent/AgentContext.d.ts +1 -1
  222. package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
  223. package/bin/types/runtime/agent/AgentRuntime.d.ts +1 -1
  224. package/bin/types/runtime/agent/AgentRuntime.d.ts.map +1 -1
  225. package/bin/types/runtime/platform/Platform.d.ts +7 -7
  226. package/bin/types/runtime/platform/PlatformGateway.d.ts +1 -1
  227. package/bin/types/runtime/platform/PlatformGateway.js +1 -1
  228. package/package.json +2 -2
  229. package/scripts/session-history-inflight.test.mjs +146 -0
  230. package/src/agent/{Agent.ts → local/Agent.ts} +50 -228
  231. package/src/agent/local/AgentInstructions.ts +68 -0
  232. package/src/agent/local/AgentPluginFactory.ts +83 -0
  233. package/src/{runtime/host/AgentHostRuntime.ts → agent/local/AgentRuntimeAssembly.ts} +2 -2
  234. package/src/agent/local/AgentRuntimeFactory.ts +173 -0
  235. package/src/{runtime/host → agent/local}/ProjectSetup.ts +1 -1
  236. package/src/agent/remote/RemoteAgent.ts +76 -0
  237. package/src/agent/remote/RemoteSession.ts +287 -0
  238. package/src/agent/remote/RemoteTransport.ts +71 -0
  239. package/src/agent/remote/TransportFactory.ts +29 -0
  240. package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +347 -0
  241. package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +107 -0
  242. package/src/config/AgentInitializer.ts +1 -1
  243. package/src/executor/Executor.ts +56 -37
  244. package/src/executor/composer/history/SessionHistoryWriter.ts +2 -2
  245. package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
  246. package/src/executor/composer/system/default/assets/core.prompt.ts.txt +1 -1
  247. package/src/executor/messages/AssistantResultPersistence.ts +4 -12
  248. package/src/executor/messages/SessionStepEventMapper.ts +59 -101
  249. package/src/executor/messages/UserVisibleText.ts +3 -18
  250. package/src/executor/store/history/SessionHistoryStore.ts +15 -0
  251. package/src/executor/store/history/jsonl/JsonlSessionHistoryStore.ts +164 -11
  252. package/src/executor/tools/shell/ShellToolFormatting.ts +1 -50
  253. package/src/executor/types/SessionHistoryPaths.ts +5 -0
  254. package/src/index.ts +5 -5
  255. package/src/plugin/core/PluginCommandRequest.ts +1 -1
  256. package/src/plugin/core/PluginLocalExecution.ts +1 -1
  257. package/src/plugin/core/ProjectConfigStore.ts +4 -4
  258. package/src/plugin/types/Plugin.ts +54 -913
  259. package/src/plugin/types/PluginApi.ts +1 -1
  260. package/src/plugin/types/PluginState.ts +1 -1
  261. package/src/rpc/Client.ts +16 -322
  262. package/src/rpc/Server.ts +39 -565
  263. package/src/rpc/server/InternalHandlers.ts +230 -0
  264. package/src/rpc/server/RequestDispatcher.ts +67 -0
  265. package/src/rpc/server/SdkSessionHandlers.ts +106 -0
  266. package/src/rpc/server/ServerTypes.ts +65 -0
  267. package/src/{runtime/sandbox → sandbox}/MacOsSeatbeltSandbox.ts +1 -1
  268. package/src/{runtime/sandbox → sandbox}/SandboxConfigResolver.ts +1 -1
  269. package/src/{runtime/sandbox → sandbox}/SandboxRunner.ts +3 -3
  270. package/src/{runtime/sandbox → sandbox}/types/SandboxRuntime.ts +2 -2
  271. package/src/session/Session.ts +6 -0
  272. package/src/session/browse/Browse.ts +29 -10
  273. package/src/session/index.ts +1 -0
  274. package/src/session/storage/Paths.ts +19 -0
  275. package/src/types/agent/AgentOptions.ts +147 -0
  276. package/src/types/{runtime/host/AgentHost.ts → agent/AgentRuntimeAssembly.ts} +2 -2
  277. package/src/types/agent/AgentTypes.ts +37 -709
  278. package/src/types/agent/RemoteAgentOptions.ts +29 -0
  279. package/src/types/agent/SessionActor.ts +88 -0
  280. package/src/types/agent/SessionTypes.ts +334 -0
  281. package/src/types/config/DowncityConfig.ts +1 -1
  282. package/src/types/{runtime/host → platform}/Store.ts +1 -1
  283. package/src/types/plugin/PluginAction.ts +133 -0
  284. package/src/types/plugin/PluginCommand.ts +89 -0
  285. package/src/types/plugin/PluginDefinition.ts +74 -0
  286. package/src/types/plugin/PluginHttp.ts +36 -0
  287. package/src/types/plugin/PluginRuntime.ts +169 -0
  288. package/src/types/plugin/PluginSetup.ts +138 -0
  289. package/src/types/plugin/PluginState.ts +82 -0
  290. package/src/types/rpc/RpcProtocol.ts +361 -0
  291. package/src/types/runtime/agent/AgentContext.ts +1 -1
  292. package/src/types/runtime/agent/AgentRuntime.ts +1 -1
  293. package/src/types/runtime/platform/Platform.ts +7 -7
  294. package/src/types/runtime/platform/PlatformGateway.ts +1 -1
  295. package/tsconfig.tsbuildinfo +1 -1
  296. package/bin/agent/Agent.d.ts.map +0 -1
  297. package/bin/agent/Agent.js.map +0 -1
  298. package/bin/agent/RemoteAgent.d.ts.map +0 -1
  299. package/bin/agent/RemoteAgent.js +0 -585
  300. package/bin/agent/RemoteAgent.js.map +0 -1
  301. package/bin/runtime/auth/AuthEnv.d.ts +0 -36
  302. package/bin/runtime/auth/AuthEnv.d.ts.map +0 -1
  303. package/bin/runtime/auth/AuthEnv.js +0 -54
  304. package/bin/runtime/auth/AuthEnv.js.map +0 -1
  305. package/bin/runtime/auth/CliAuthStateStore.d.ts +0 -29
  306. package/bin/runtime/auth/CliAuthStateStore.d.ts.map +0 -1
  307. package/bin/runtime/auth/CliAuthStateStore.js +0 -26
  308. package/bin/runtime/auth/CliAuthStateStore.js.map +0 -1
  309. package/bin/runtime/control/AuthControlService.d.ts +0 -34
  310. package/bin/runtime/control/AuthControlService.d.ts.map +0 -1
  311. package/bin/runtime/control/AuthControlService.js +0 -129
  312. package/bin/runtime/control/AuthControlService.js.map +0 -1
  313. package/bin/runtime/control/CommonHelpers.d.ts +0 -36
  314. package/bin/runtime/control/CommonHelpers.d.ts.map +0 -1
  315. package/bin/runtime/control/CommonHelpers.js +0 -63
  316. package/bin/runtime/control/CommonHelpers.js.map +0 -1
  317. package/bin/runtime/control/ExecuteBySession.d.ts +0 -30
  318. package/bin/runtime/control/ExecuteBySession.d.ts.map +0 -1
  319. package/bin/runtime/control/ExecuteBySession.js +0 -41
  320. package/bin/runtime/control/ExecuteBySession.js.map +0 -1
  321. package/bin/runtime/control/ExecuteInput.d.ts +0 -18
  322. package/bin/runtime/control/ExecuteInput.d.ts.map +0 -1
  323. package/bin/runtime/control/ExecuteInput.js +0 -201
  324. package/bin/runtime/control/ExecuteInput.js.map +0 -1
  325. package/bin/runtime/control/Helpers.d.ts +0 -13
  326. package/bin/runtime/control/Helpers.d.ts.map +0 -1
  327. package/bin/runtime/control/Helpers.js +0 -13
  328. package/bin/runtime/control/Helpers.js.map +0 -1
  329. package/bin/runtime/control/MessageTimeline.d.ts +0 -22
  330. package/bin/runtime/control/MessageTimeline.d.ts.map +0 -1
  331. package/bin/runtime/control/MessageTimeline.js +0 -226
  332. package/bin/runtime/control/MessageTimeline.js.map +0 -1
  333. package/bin/runtime/control/SessionSummaryStore.d.ts +0 -20
  334. package/bin/runtime/control/SessionSummaryStore.d.ts.map +0 -1
  335. package/bin/runtime/control/SessionSummaryStore.js +0 -50
  336. package/bin/runtime/control/SessionSummaryStore.js.map +0 -1
  337. package/bin/runtime/control/TaskStore.d.ts +0 -33
  338. package/bin/runtime/control/TaskStore.d.ts.map +0 -1
  339. package/bin/runtime/control/TaskStore.js +0 -175
  340. package/bin/runtime/control/TaskStore.js.map +0 -1
  341. package/bin/runtime/control/types/AuthControl.d.ts +0 -30
  342. package/bin/runtime/control/types/AuthControl.d.ts.map +0 -1
  343. package/bin/runtime/control/types/AuthControl.js +0 -9
  344. package/bin/runtime/control/types/AuthControl.js.map +0 -1
  345. package/bin/runtime/control/types/ControlSessionExecute.d.ts +0 -85
  346. package/bin/runtime/control/types/ControlSessionExecute.d.ts.map +0 -1
  347. package/bin/runtime/control/types/ControlSessionExecute.js +0 -9
  348. package/bin/runtime/control/types/ControlSessionExecute.js.map +0 -1
  349. package/bin/runtime/control/types/ControlViewData.d.ts +0 -320
  350. package/bin/runtime/control/types/ControlViewData.d.ts.map +0 -1
  351. package/bin/runtime/control/types/ControlViewData.js +0 -9
  352. package/bin/runtime/control/types/ControlViewData.js.map +0 -1
  353. package/bin/runtime/host/AgentHostRuntime.d.ts.map +0 -1
  354. package/bin/runtime/host/AgentHostRuntime.js.map +0 -1
  355. package/bin/runtime/host/ProjectSetup.d.ts.map +0 -1
  356. package/bin/runtime/host/ProjectSetup.js.map +0 -1
  357. package/bin/runtime/sandbox/MacOsSeatbeltSandbox.d.ts.map +0 -1
  358. package/bin/runtime/sandbox/MacOsSeatbeltSandbox.js.map +0 -1
  359. package/bin/runtime/sandbox/SandboxConfigResolver.d.ts.map +0 -1
  360. package/bin/runtime/sandbox/SandboxConfigResolver.js.map +0 -1
  361. package/bin/runtime/sandbox/SandboxRunner.d.ts.map +0 -1
  362. package/bin/runtime/sandbox/SandboxRunner.js.map +0 -1
  363. package/bin/runtime/sandbox/types/Sandbox.d.ts.map +0 -1
  364. package/bin/runtime/sandbox/types/Sandbox.js.map +0 -1
  365. package/bin/runtime/sandbox/types/SandboxRuntime.d.ts.map +0 -1
  366. package/bin/runtime/sandbox/types/SandboxRuntime.js.map +0 -1
  367. package/bin/types/runtime/host/AgentHost.d.ts.map +0 -1
  368. package/bin/types/runtime/host/AgentHost.js.map +0 -1
  369. package/bin/types/runtime/host/Store.d.ts.map +0 -1
  370. package/bin/types/runtime/host/Store.js.map +0 -1
  371. package/src/agent/RemoteAgent.ts +0 -834
  372. package/src/runtime/auth/AuthEnv.ts +0 -62
  373. package/src/runtime/auth/CliAuthStateStore.ts +0 -46
  374. package/src/runtime/control/AuthControlService.ts +0 -169
  375. package/src/runtime/control/CommonHelpers.ts +0 -69
  376. package/src/runtime/control/ExecuteBySession.ts +0 -52
  377. package/src/runtime/control/ExecuteInput.ts +0 -236
  378. package/src/runtime/control/Helpers.ts +0 -22
  379. package/src/runtime/control/MessageTimeline.ts +0 -269
  380. package/src/runtime/control/SessionSummaryStore.ts +0 -72
  381. package/src/runtime/control/TaskStore.ts +0 -242
  382. package/src/runtime/control/types/AuthControl.ts +0 -34
  383. package/src/runtime/control/types/ControlSessionExecute.ts +0 -99
  384. package/src/runtime/control/types/ControlViewData.ts +0 -392
  385. /package/bin/{runtime/sandbox → sandbox}/MacOsSeatbeltSandbox.js +0 -0
  386. /package/bin/{runtime/sandbox → sandbox}/SandboxConfigResolver.js +0 -0
  387. /package/bin/{runtime/sandbox → sandbox}/types/Sandbox.d.ts +0 -0
  388. /package/bin/{runtime/sandbox → sandbox}/types/Sandbox.js +0 -0
  389. /package/bin/{runtime/sandbox → sandbox}/types/SandboxRuntime.js +0 -0
  390. /package/src/{runtime/sandbox → sandbox}/types/Sandbox.ts +0 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Agent remote:统一远程 SDK 客户端。
3
+ *
4
+ * 关键点(中文)
5
+ * - 对外只暴露一个 `url` 入口,不向用户暴露 transport 细节。
6
+ * - 当前内部支持 `http/https` 与 `rpc` 两种访问方式。
7
+ * - `RemoteAgent` 只负责远程访问,不重复实现第二套会话编排器。
8
+ */
9
+
10
+ import type {
11
+ AgentCreateSessionInput,
12
+ AgentListSessionsInput,
13
+ AgentSessionSummaryPage,
14
+ RemoteAgentOptions,
15
+ RemoteAgentSession,
16
+ } from "@/types/agent/AgentTypes.js";
17
+ import type { RemoteAgentTransport } from "@/agent/remote/RemoteTransport.js";
18
+ import { RemoteSession } from "@/agent/remote/RemoteSession.js";
19
+ import { create_remote_agent_transport } from "@/agent/remote/TransportFactory.js";
20
+
21
+ /**
22
+ * RemoteAgent:远程 Agent 客户端。
23
+ */
24
+ export class RemoteAgent {
25
+ private readonly transport: RemoteAgentTransport;
26
+
27
+ constructor(options: RemoteAgentOptions) {
28
+ const url = String(options.url || "").trim();
29
+ if (!url) {
30
+ throw new Error("RemoteAgent requires a non-empty url");
31
+ }
32
+ this.transport = create_remote_agent_transport(url, options.token);
33
+ }
34
+
35
+ /**
36
+ * 新建一个远程 session。
37
+ */
38
+ async createSession(
39
+ input?: AgentCreateSessionInput,
40
+ ): Promise<RemoteAgentSession> {
41
+ const info = await this.transport.create_session(input);
42
+ return new RemoteSession(this.transport, info.sessionId);
43
+ }
44
+
45
+ /**
46
+ * 获取一个已存在的远程 session。
47
+ */
48
+ async getSession(sessionId: string): Promise<RemoteAgentSession> {
49
+ const resolved_session_id = String(sessionId || "").trim();
50
+ if (!resolved_session_id) {
51
+ throw new Error("getSession requires a non-empty sessionId");
52
+ }
53
+ const info = await this.transport.get_info(resolved_session_id);
54
+ return new RemoteSession(this.transport, info.sessionId);
55
+ }
56
+
57
+ /**
58
+ * 列出远程 agent 的 session 摘要页。
59
+ */
60
+ async listSessions(
61
+ input?: AgentListSessionsInput,
62
+ ): Promise<AgentSessionSummaryPage> {
63
+ return await this.transport.list_sessions(input);
64
+ }
65
+
66
+ /**
67
+ * 关闭远程 transport。
68
+ *
69
+ * 关键点(中文)
70
+ * - `rpc://` 会关闭底层长连接。
71
+ * - `http://` / `https://` 没有常驻连接,调用时是安全 no-op。
72
+ */
73
+ async close(): Promise<void> {
74
+ await this.transport.close?.();
75
+ }
76
+ }
@@ -0,0 +1,287 @@
1
+ /**
2
+ * RemoteSession:远程 session actor 客户端。
3
+ *
4
+ * 关键点(中文)
5
+ * - 这里只负责 session 级 API、turn lifecycle 与事件泵。
6
+ * - 具体 HTTP / RPC 细节由 RemoteSessionTransport 提供。
7
+ */
8
+
9
+ import type {
10
+ AgentSessionForkInput,
11
+ AgentSessionHistoryInput,
12
+ AgentSessionHistoryPage,
13
+ AgentSessionInfo,
14
+ AgentSessionSetInput,
15
+ AgentSessionSystemSnapshot,
16
+ RemoteAgentSession,
17
+ } from "@/types/agent/AgentTypes.js";
18
+ import type {
19
+ AgentSessionEvent,
20
+ AgentSessionSubscriber,
21
+ AgentSessionUnsubscribe,
22
+ } from "@/types/sdk/AgentSessionEvent.js";
23
+ import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
24
+ import type {
25
+ AgentSessionTurnHandle,
26
+ AgentSessionTurnResult,
27
+ } from "@/types/sdk/AgentSessionTurn.js";
28
+ import { SessionEventHub } from "@/session/runtime/SessionEventHub.js";
29
+ import type {
30
+ RemoteSessionTransport,
31
+ TransportSubscription,
32
+ } from "@/agent/remote/RemoteTransport.js";
33
+
34
+ type Deferred<T> = {
35
+ /** 当前延迟 Promise。 */
36
+ promise: Promise<T>;
37
+ /** 兑现 Promise。 */
38
+ resolve: (value: T) => void;
39
+ };
40
+
41
+ type RemoteTurnLifecycle = {
42
+ /** 当前 turnId。 */
43
+ turnId: string;
44
+ /** 当前 turn 的最终结果快照。 */
45
+ result: AgentSessionTurnResult | null;
46
+ /** 当前 turn 完成 Promise 控制器。 */
47
+ deferred_finished: Deferred<AgentSessionTurnResult>;
48
+ };
49
+
50
+ /**
51
+ * 远程 Session 客户端。
52
+ */
53
+ export class RemoteSession implements RemoteAgentSession {
54
+ readonly id: string;
55
+
56
+ private readonly transport: RemoteSessionTransport;
57
+ private readonly event_hub = new SessionEventHub();
58
+ private readonly turns_by_id = new Map<string, RemoteTurnLifecycle>();
59
+ private readonly completed_turn_ids: string[] = [];
60
+ private event_pump_connect_promise: Promise<void> | null = null;
61
+ private event_pump_running = false;
62
+ private event_subscriber_count = 0;
63
+ private event_subscription: TransportSubscription | null = null;
64
+
65
+ constructor(transport: RemoteSessionTransport, session_id: string) {
66
+ this.transport = transport;
67
+ this.id = session_id;
68
+ }
69
+
70
+ /**
71
+ * 远程 session 当前不支持直接注入本地模型实例。
72
+ */
73
+ async set(_input: AgentSessionSetInput): Promise<void> {
74
+ throw new Error(
75
+ "Remote session.set({ model }) is not supported in v1. Configure the model on the server-side local Agent session instead.",
76
+ );
77
+ }
78
+
79
+ /**
80
+ * 读取当前远程 session 详情。
81
+ */
82
+ async getInfo(): Promise<AgentSessionInfo> {
83
+ return await this.transport.get_info(this.id);
84
+ }
85
+
86
+ /**
87
+ * 向当前远程 session 追加一条新的 prompt。
88
+ */
89
+ async prompt(input: AgentSessionPromptInput): Promise<AgentSessionTurnHandle> {
90
+ const query = String(input.query || "").trim();
91
+ if (!query) {
92
+ throw new Error("remote session.prompt requires a non-empty query");
93
+ }
94
+
95
+ await this.ensure_event_pump();
96
+ const turn = await this.transport.prompt(this.id, input);
97
+ const lifecycle = this.ensure_turn_lifecycle(turn.id);
98
+ return create_turn_handle(lifecycle);
99
+ }
100
+
101
+ /**
102
+ * 订阅当前远程 session 的 future 事件。
103
+ */
104
+ subscribe(subscriber: AgentSessionSubscriber): AgentSessionUnsubscribe {
105
+ this.event_subscriber_count += 1;
106
+ void this.ensure_event_pump().catch((error) => {
107
+ this.event_hub.publish({
108
+ type: "error",
109
+ message: error instanceof Error ? error.message : String(error),
110
+ });
111
+ });
112
+ const unsubscribe = this.event_hub.subscribe(subscriber);
113
+ return () => {
114
+ unsubscribe();
115
+ this.event_subscriber_count = Math.max(0, this.event_subscriber_count - 1);
116
+ void this.maybe_stop_event_pump();
117
+ };
118
+ }
119
+
120
+ /**
121
+ * 读取远程消息历史。
122
+ */
123
+ async history(input?: AgentSessionHistoryInput): Promise<AgentSessionHistoryPage> {
124
+ return await this.transport.history(this.id, input);
125
+ }
126
+
127
+ /**
128
+ * 读取远程 session 当前生效的 system prompt 快照。
129
+ */
130
+ async system(): Promise<AgentSessionSystemSnapshot> {
131
+ return await this.transport.system(this.id);
132
+ }
133
+
134
+ /**
135
+ * 分叉远程 session。
136
+ */
137
+ async fork(input?: AgentSessionForkInput | string): Promise<RemoteAgentSession> {
138
+ const info = await this.transport.fork(this.id, input);
139
+ return new RemoteSession(this.transport, info.sessionId);
140
+ }
141
+
142
+ private async ensure_event_pump(): Promise<void> {
143
+ if (this.event_pump_connect_promise) {
144
+ await this.event_pump_connect_promise;
145
+ return;
146
+ }
147
+ if (this.event_pump_running) return;
148
+
149
+ this.event_pump_connect_promise = (async () => {
150
+ let resolved_ready = false;
151
+ this.event_subscription = await this.transport.subscribe({
152
+ session_id: this.id,
153
+ on_ready: () => {
154
+ resolved_ready = true;
155
+ },
156
+ on_event: (event) => {
157
+ this.handle_event(event);
158
+ },
159
+ });
160
+ this.event_pump_running = true;
161
+ if (!resolved_ready) {
162
+ throw new Error("Remote session events connection closed before ready");
163
+ }
164
+ })();
165
+
166
+ try {
167
+ await this.event_pump_connect_promise;
168
+ } finally {
169
+ this.event_pump_connect_promise = null;
170
+ }
171
+ }
172
+
173
+ private handle_event(event: AgentSessionEvent): void {
174
+ if (event.type === "error") {
175
+ this.fail_pending_turns(event.message);
176
+ }
177
+ const turn_id = extract_turn_id(event);
178
+ if (turn_id) {
179
+ this.ensure_turn_lifecycle(turn_id);
180
+ }
181
+
182
+ if (event.type === "turn-finish") {
183
+ const lifecycle = this.ensure_turn_lifecycle(event.turnId);
184
+ const result: AgentSessionTurnResult = {
185
+ turnId: event.turnId,
186
+ text: event.text,
187
+ success: event.success,
188
+ ...(event.error ? { error: event.error } : {}),
189
+ };
190
+ lifecycle.result = result;
191
+ lifecycle.deferred_finished.resolve(result);
192
+ this.remember_completed_turn(event.turnId);
193
+ void this.maybe_stop_event_pump();
194
+ }
195
+
196
+ this.event_hub.publish(event);
197
+ }
198
+
199
+ private ensure_turn_lifecycle(turn_id: string): RemoteTurnLifecycle {
200
+ const cached = this.turns_by_id.get(turn_id);
201
+ if (cached) return cached;
202
+ const created: RemoteTurnLifecycle = {
203
+ turnId: turn_id,
204
+ result: null,
205
+ deferred_finished: create_deferred<AgentSessionTurnResult>(),
206
+ };
207
+ this.turns_by_id.set(turn_id, created);
208
+ return created;
209
+ }
210
+
211
+ private fail_pending_turns(message: string): void {
212
+ for (const lifecycle of this.turns_by_id.values()) {
213
+ if (lifecycle.result) continue;
214
+ const result: AgentSessionTurnResult = {
215
+ turnId: lifecycle.turnId,
216
+ text: "",
217
+ success: false,
218
+ error: message,
219
+ };
220
+ lifecycle.result = result;
221
+ lifecycle.deferred_finished.resolve(result);
222
+ this.remember_completed_turn(lifecycle.turnId);
223
+ }
224
+ }
225
+
226
+ private remember_completed_turn(turn_id: string): void {
227
+ this.completed_turn_ids.push(turn_id);
228
+ while (this.completed_turn_ids.length > 200) {
229
+ const oldest_turn_id = this.completed_turn_ids.shift();
230
+ if (oldest_turn_id) {
231
+ this.turns_by_id.delete(oldest_turn_id);
232
+ }
233
+ }
234
+ }
235
+
236
+ private async maybe_stop_event_pump(): Promise<void> {
237
+ if (this.event_subscriber_count > 0) return;
238
+ if ([...this.turns_by_id.values()].some((item) => item.result === null)) return;
239
+ const current = this.event_subscription;
240
+ this.event_subscription = null;
241
+ this.event_pump_running = false;
242
+ if (!current) return;
243
+ await current.close().catch((error) => {
244
+ this.fail_pending_turns(
245
+ error instanceof Error ? error.message : String(error),
246
+ );
247
+ });
248
+ }
249
+ }
250
+
251
+ function create_deferred<T>(): Deferred<T> {
252
+ let resolve!: (value: T) => void;
253
+ const promise = new Promise<T>((inner_resolve) => {
254
+ resolve = inner_resolve;
255
+ });
256
+ return {
257
+ promise,
258
+ resolve,
259
+ };
260
+ }
261
+
262
+ function create_turn_handle(
263
+ lifecycle: RemoteTurnLifecycle,
264
+ ): AgentSessionTurnHandle {
265
+ return {
266
+ id: lifecycle.turnId,
267
+ get result() {
268
+ return lifecycle.result;
269
+ },
270
+ finished: lifecycle.deferred_finished.promise,
271
+ };
272
+ }
273
+
274
+ function extract_turn_id(event: AgentSessionEvent): string | null {
275
+ switch (event.type) {
276
+ case "turn-start":
277
+ case "text-delta":
278
+ case "reasoning-delta":
279
+ case "tool-call":
280
+ case "tool-result":
281
+ case "assistant-step":
282
+ case "turn-finish":
283
+ return event.turnId;
284
+ default:
285
+ return null;
286
+ }
287
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * RemoteAgent transport 协议。
3
+ *
4
+ * 关键点(中文)
5
+ * - RemoteSession 只依赖这里定义的最小会话传输能力。
6
+ * - HTTP / RPC transport 只负责协议适配,不持有 session 编排逻辑。
7
+ */
8
+
9
+ import type {
10
+ AgentCreateSessionInput,
11
+ AgentListSessionsInput,
12
+ AgentSessionForkInput,
13
+ AgentSessionHistoryInput,
14
+ AgentSessionHistoryPage,
15
+ AgentSessionInfo,
16
+ AgentSessionSummaryPage,
17
+ AgentSessionSystemSnapshot,
18
+ } from "@/types/agent/AgentTypes.js";
19
+ import type { AgentSessionEvent } from "@/types/sdk/AgentSessionEvent.js";
20
+ import type { AgentSessionPromptInput } from "@/types/sdk/AgentSessionPrompt.js";
21
+
22
+ /**
23
+ * Transport 持有的事件订阅句柄。
24
+ */
25
+ export type TransportSubscription = {
26
+ /** 关闭当前订阅。 */
27
+ close(): Promise<void>;
28
+ };
29
+
30
+ /**
31
+ * 单个远程 session 所需的 transport 能力。
32
+ */
33
+ export type RemoteSessionTransport = {
34
+ /** 读取 session 信息。 */
35
+ get_info(session_id: string): Promise<AgentSessionInfo>;
36
+ /** 发送 prompt。 */
37
+ prompt(
38
+ session_id: string,
39
+ input: AgentSessionPromptInput,
40
+ ): Promise<{ id: string }>;
41
+ /** 订阅 session 事件。 */
42
+ subscribe(params: {
43
+ session_id: string;
44
+ on_ready: () => void;
45
+ on_event: (event: AgentSessionEvent) => void;
46
+ }): Promise<TransportSubscription>;
47
+ /** 读取 history。 */
48
+ history(
49
+ session_id: string,
50
+ input?: AgentSessionHistoryInput,
51
+ ): Promise<AgentSessionHistoryPage>;
52
+ /** 读取 system snapshot。 */
53
+ system(session_id: string): Promise<AgentSessionSystemSnapshot>;
54
+ /** 分叉 session。 */
55
+ fork(
56
+ session_id: string,
57
+ input?: AgentSessionForkInput | string,
58
+ ): Promise<AgentSessionInfo>;
59
+ };
60
+
61
+ /**
62
+ * RemoteAgent 顶层 transport 能力。
63
+ */
64
+ export type RemoteAgentTransport = RemoteSessionTransport & {
65
+ /** 新建 session。 */
66
+ create_session(input?: AgentCreateSessionInput): Promise<AgentSessionInfo>;
67
+ /** 列出 sessions。 */
68
+ list_sessions(input?: AgentListSessionsInput): Promise<AgentSessionSummaryPage>;
69
+ /** 关闭 transport 持有的长期连接。 */
70
+ close?(): Promise<void>;
71
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * RemoteAgent transport 工厂。
3
+ *
4
+ * 关键点(中文)
5
+ * - `RemoteAgent` 对外只接收 url,这里负责选择具体 transport。
6
+ * - HTTP token 只传给 HTTP transport,RPC 不读取 token。
7
+ */
8
+
9
+ import type { RemoteAgentTransport } from "@/agent/remote/RemoteTransport.js";
10
+ import { HttpRemoteAgentTransport } from "@/agent/remote/transports/HttpRemoteAgentTransport.js";
11
+ import { RpcRemoteAgentTransport } from "@/agent/remote/transports/RpcRemoteAgentTransport.js";
12
+
13
+ /**
14
+ * 根据 URL 协议创建远程 transport。
15
+ */
16
+ export function create_remote_agent_transport(
17
+ url: string,
18
+ token?: string,
19
+ ): RemoteAgentTransport {
20
+ if (/^https?:\/\//i.test(url)) {
21
+ return new HttpRemoteAgentTransport(url, token);
22
+ }
23
+ if (/^rpc:\/\//i.test(url)) {
24
+ return new RpcRemoteAgentTransport(url);
25
+ }
26
+ throw new Error(
27
+ `Unsupported RemoteAgent url protocol: ${url}. Expected http://, https://, or rpc://`,
28
+ );
29
+ }