@downcity/agent 1.1.135 → 1.1.148

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 (180) hide show
  1. package/README.md +2 -2
  2. package/bin/agent/local/Agent.d.ts +3 -21
  3. package/bin/agent/local/Agent.d.ts.map +1 -1
  4. package/bin/agent/local/Agent.js +3 -30
  5. package/bin/agent/local/Agent.js.map +1 -1
  6. package/bin/agent/local/ProjectSetup.js +2 -2
  7. package/bin/agent/local/ProjectSetup.js.map +1 -1
  8. package/bin/agent/local/services/AgentAssemblyService.d.ts +1 -6
  9. package/bin/agent/local/services/AgentAssemblyService.d.ts.map +1 -1
  10. package/bin/agent/local/services/AgentAssemblyService.js +13 -20
  11. package/bin/agent/local/services/AgentAssemblyService.js.map +1 -1
  12. package/bin/agent/local/services/AgentSessionManager.d.ts +16 -7
  13. package/bin/agent/local/services/AgentSessionManager.d.ts.map +1 -1
  14. package/bin/agent/local/services/AgentSessionManager.js +83 -8
  15. package/bin/agent/local/services/AgentSessionManager.js.map +1 -1
  16. package/bin/agent/remote/RemoteAgent.d.ts +9 -13
  17. package/bin/agent/remote/RemoteAgent.d.ts.map +1 -1
  18. package/bin/agent/remote/RemoteAgent.js +23 -24
  19. package/bin/agent/remote/RemoteAgent.js.map +1 -1
  20. package/bin/agent/remote/RemoteSession.d.ts +11 -4
  21. package/bin/agent/remote/RemoteSession.d.ts.map +1 -1
  22. package/bin/agent/remote/RemoteSession.js +15 -3
  23. package/bin/agent/remote/RemoteSession.js.map +1 -1
  24. package/bin/agent/remote/RemoteTransport.d.ts +9 -1
  25. package/bin/agent/remote/RemoteTransport.d.ts.map +1 -1
  26. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts +7 -3
  27. package/bin/agent/remote/transports/HttpRemoteAgentTransport.d.ts.map +1 -1
  28. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js +65 -2
  29. package/bin/agent/remote/transports/HttpRemoteAgentTransport.js.map +1 -1
  30. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts +5 -1
  31. package/bin/agent/remote/transports/RpcRemoteAgentTransport.d.ts.map +1 -1
  32. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js +12 -0
  33. package/bin/agent/remote/transports/RpcRemoteAgentTransport.js.map +1 -1
  34. package/bin/config/AgentInitializer.d.ts +2 -2
  35. package/bin/config/AgentInitializer.js +2 -2
  36. package/bin/executor/Executor.d.ts +5 -0
  37. package/bin/executor/Executor.d.ts.map +1 -1
  38. package/bin/executor/Executor.js +34 -0
  39. package/bin/executor/Executor.js.map +1 -1
  40. package/bin/executor/composer/system/default/InitPrompts.d.ts +1 -1
  41. package/bin/executor/composer/system/default/InitPrompts.js +1 -1
  42. package/bin/executor/composer/system/default/SystemDomain.js +2 -2
  43. package/bin/executor/composer/system/default/SystemDomain.js.map +1 -1
  44. package/bin/executor/core-engine/CoreEngineRunner.d.ts.map +1 -1
  45. package/bin/executor/core-engine/CoreEngineRunner.js +16 -0
  46. package/bin/executor/core-engine/CoreEngineRunner.js.map +1 -1
  47. package/bin/executor/messages/ChatMessageMarkupTypes.d.ts +1 -1
  48. package/bin/executor/messages/ChatMessageMarkupTypes.js +1 -1
  49. package/bin/executor/types/SessionExecutor.d.ts +8 -0
  50. package/bin/executor/types/SessionExecutor.d.ts.map +1 -1
  51. package/bin/index.d.ts +2 -2
  52. package/bin/index.d.ts.map +1 -1
  53. package/bin/index.js.map +1 -1
  54. package/bin/plugin/core/Activation.d.ts +0 -2
  55. package/bin/plugin/core/Activation.d.ts.map +1 -1
  56. package/bin/plugin/core/Activation.js +1 -1
  57. package/bin/plugin/core/Activation.js.map +1 -1
  58. package/bin/plugin/core/PluginCommandRequest.d.ts +1 -1
  59. package/bin/plugin/core/PluginCommandRequest.js +1 -1
  60. package/bin/plugin/core/PluginStateController.d.ts +0 -5
  61. package/bin/plugin/core/PluginStateController.d.ts.map +1 -1
  62. package/bin/plugin/core/PluginStateController.js +1 -5
  63. package/bin/plugin/core/PluginStateController.js.map +1 -1
  64. package/bin/plugin/types/PluginApi.d.ts +1 -1
  65. package/bin/plugin/types/PluginApi.js +1 -1
  66. package/bin/rpc/Client.d.ts +17 -1
  67. package/bin/rpc/Client.d.ts.map +1 -1
  68. package/bin/rpc/Client.js +47 -0
  69. package/bin/rpc/Client.js.map +1 -1
  70. package/bin/session/Session.d.ts +5 -0
  71. package/bin/session/Session.d.ts.map +1 -1
  72. package/bin/session/Session.js +7 -0
  73. package/bin/session/Session.js.map +1 -1
  74. package/bin/session/browse/Browse.d.ts +9 -1
  75. package/bin/session/browse/Browse.d.ts.map +1 -1
  76. package/bin/session/browse/Browse.js +81 -3
  77. package/bin/session/browse/Browse.js.map +1 -1
  78. package/bin/session/index.d.ts +3 -3
  79. package/bin/session/index.d.ts.map +1 -1
  80. package/bin/session/index.js +3 -3
  81. package/bin/session/index.js.map +1 -1
  82. package/bin/session/runtime/SessionPromptRuntime.d.ts +13 -0
  83. package/bin/session/runtime/SessionPromptRuntime.d.ts.map +1 -1
  84. package/bin/session/runtime/SessionPromptRuntime.js +82 -5
  85. package/bin/session/runtime/SessionPromptRuntime.js.map +1 -1
  86. package/bin/session/services/SessionTurnService.d.ts +5 -0
  87. package/bin/session/services/SessionTurnService.d.ts.map +1 -1
  88. package/bin/session/services/SessionTurnService.js +10 -1
  89. package/bin/session/services/SessionTurnService.js.map +1 -1
  90. package/bin/session/storage/Metadata.d.ts +15 -0
  91. package/bin/session/storage/Metadata.d.ts.map +1 -1
  92. package/bin/session/storage/Metadata.js +15 -1
  93. package/bin/session/storage/Metadata.js.map +1 -1
  94. package/bin/session/storage/Paths.d.ts +24 -0
  95. package/bin/session/storage/Paths.d.ts.map +1 -1
  96. package/bin/session/storage/Paths.js +34 -0
  97. package/bin/session/storage/Paths.js.map +1 -1
  98. package/bin/session/storage/RuntimeSessionPort.d.ts +5 -0
  99. package/bin/session/storage/RuntimeSessionPort.d.ts.map +1 -1
  100. package/bin/session/storage/RuntimeSessionPort.js +4 -0
  101. package/bin/session/storage/RuntimeSessionPort.js.map +1 -1
  102. package/bin/types/agent/AgentTypes.d.ts +2 -1
  103. package/bin/types/agent/AgentTypes.d.ts.map +1 -1
  104. package/bin/types/agent/SessionActor.d.ts +13 -4
  105. package/bin/types/agent/SessionActor.d.ts.map +1 -1
  106. package/bin/types/agent/SessionTypes.d.ts +62 -0
  107. package/bin/types/agent/SessionTypes.d.ts.map +1 -1
  108. package/bin/types/config/DowncityConfig.d.ts +1 -1
  109. package/bin/types/executor/SessionRunContext.d.ts +8 -0
  110. package/bin/types/executor/SessionRunContext.d.ts.map +1 -1
  111. package/bin/types/platform/Store.d.ts +2 -2
  112. package/bin/types/platform/Store.js +2 -2
  113. package/bin/types/rpc/RpcProtocol.d.ts +37 -5
  114. package/bin/types/rpc/RpcProtocol.d.ts.map +1 -1
  115. package/bin/types/rpc/RpcProtocol.js +1 -1
  116. package/bin/types/runtime/agent/AgentContext.d.ts +36 -11
  117. package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
  118. package/bin/types/runtime/agent/AgentContext.js +26 -8
  119. package/bin/types/runtime/agent/AgentContext.js.map +1 -1
  120. package/bin/types/runtime/platform/Platform.d.ts +8 -8
  121. package/bin/types/runtime/platform/PlatformGateway.d.ts +2 -2
  122. package/bin/types/sdk/AgentSessionStop.d.ts +36 -0
  123. package/bin/types/sdk/AgentSessionStop.d.ts.map +1 -0
  124. package/bin/types/sdk/AgentSessionStop.js +9 -0
  125. package/bin/types/sdk/AgentSessionStop.js.map +1 -0
  126. package/package.json +3 -3
  127. package/scripts/city-model-tool-loop.test.mjs +2 -2
  128. package/scripts/session-prompt-runtime.test.mjs +59 -0
  129. package/src/agent/local/Agent.ts +3 -41
  130. package/src/agent/local/ProjectSetup.ts +2 -2
  131. package/src/agent/local/services/AgentAssemblyService.ts +17 -28
  132. package/src/agent/local/services/AgentSessionManager.ts +127 -13
  133. package/src/agent/remote/RemoteAgent.ts +25 -34
  134. package/src/agent/remote/RemoteSession.ts +21 -6
  135. package/src/agent/remote/RemoteTransport.ts +14 -0
  136. package/src/agent/remote/transports/HttpRemoteAgentTransport.ts +100 -2
  137. package/src/agent/remote/transports/RpcRemoteAgentTransport.ts +26 -0
  138. package/src/config/AgentInitializer.ts +2 -2
  139. package/src/executor/Executor.ts +33 -0
  140. package/src/executor/composer/system/default/InitPrompts.ts +1 -1
  141. package/src/executor/composer/system/default/SystemDomain.ts +2 -2
  142. package/src/executor/core-engine/CoreEngineRunner.ts +21 -0
  143. package/src/executor/messages/ChatMessageMarkupTypes.ts +1 -1
  144. package/src/executor/types/SessionExecutor.ts +2 -1
  145. package/src/index.ts +6 -1
  146. package/src/plugin/core/Activation.ts +1 -3
  147. package/src/plugin/core/PluginCommandRequest.ts +1 -1
  148. package/src/plugin/core/PluginStateController.ts +1 -10
  149. package/src/plugin/types/PluginApi.ts +1 -1
  150. package/src/rpc/Client.ts +61 -0
  151. package/src/session/Session.ts +9 -0
  152. package/src/session/browse/Browse.ts +103 -3
  153. package/src/session/index.ts +7 -0
  154. package/src/session/runtime/SessionPromptRuntime.ts +100 -5
  155. package/src/session/services/SessionTurnService.ts +13 -1
  156. package/src/session/storage/Metadata.ts +23 -1
  157. package/src/session/storage/Paths.ts +70 -0
  158. package/src/session/storage/RuntimeSessionPort.ts +9 -0
  159. package/src/types/agent/AgentTypes.ts +6 -0
  160. package/src/types/agent/SessionActor.ts +21 -3
  161. package/src/types/agent/SessionTypes.ts +68 -0
  162. package/src/types/config/DowncityConfig.ts +1 -1
  163. package/src/types/executor/SessionRunContext.ts +9 -0
  164. package/src/types/platform/Store.ts +2 -2
  165. package/src/types/rpc/RpcProtocol.ts +46 -4
  166. package/src/types/runtime/agent/AgentContext.ts +41 -14
  167. package/src/types/runtime/platform/Platform.ts +8 -8
  168. package/src/types/runtime/platform/PlatformGateway.ts +2 -2
  169. package/src/types/sdk/AgentSessionStop.ts +39 -0
  170. package/tsconfig.tsbuildinfo +1 -1
  171. package/bin/agent/local/AgentRuntimeFactory.d.ts +0 -47
  172. package/bin/agent/local/AgentRuntimeFactory.d.ts.map +0 -1
  173. package/bin/agent/local/AgentRuntimeFactory.js +0 -34
  174. package/bin/agent/local/AgentRuntimeFactory.js.map +0 -1
  175. package/bin/types/runtime/agent/AgentRuntime.d.ts +0 -79
  176. package/bin/types/runtime/agent/AgentRuntime.d.ts.map +0 -1
  177. package/bin/types/runtime/agent/AgentRuntime.js +0 -13
  178. package/bin/types/runtime/agent/AgentRuntime.js.map +0 -1
  179. package/src/agent/local/AgentRuntimeFactory.ts +0 -78
  180. package/src/types/runtime/agent/AgentRuntime.ts +0 -84
@@ -1,47 +0,0 @@
1
- /**
2
- * Agent runtime / context 装配工厂。
3
- *
4
- * 关键点(中文)
5
- * - 这里只创建长期 runtime 视图。
6
- * - `AgentContext` 已经收敛为 class,调用方直接 `new AgentContext(...)`,不再走工厂。
7
- * - Agent 仍然持有 session/plugin 状态;这里通过函数参数读取状态。
8
- */
9
- import type { BasePlugin } from "../../plugin/core/BasePlugin.js";
10
- import type { Logger } from "../../utils/logger/Logger.js";
11
- import type { DowncityConfig } from "../../types/config/DowncityConfig.js";
12
- import type { SessionPort } from "../../types/runtime/agent/AgentContext.js";
13
- import type { AgentRuntime } from "../../types/runtime/agent/AgentRuntime.js";
14
- import type { AgentManagedSession } from "../../types/agent/AgentTypes.js";
15
- /**
16
- * 创建 AgentRuntime 的参数。
17
- */
18
- export interface CreateAgentRuntimeOptions {
19
- /** 当前 agent id。 */
20
- agent_id: string;
21
- /** 当前项目根目录。 */
22
- project_root: string;
23
- /** 统一日志器。 */
24
- logger: Logger;
25
- /** 当前解析后的配置。 */
26
- config: DowncityConfig;
27
- /**
28
- * 当前 agent 共享 env 对象。
29
- *
30
- * 关键点(中文)
31
- * - 必须传入 Agent 持有的同一份 mutable 对象,runtime / context 直接复用同一引用。
32
- */
33
- env: Record<string, string>;
34
- /** 当前静态 system 文本集合。 */
35
- systems: string[];
36
- /** 当前 plugin 实例集合。 */
37
- plugin_instances: Map<string, BasePlugin>;
38
- /** 获取或创建 session runtime port。 */
39
- get_session_port: (session_id: string) => SessionPort;
40
- /** 读取当前已缓存的 session 实例。 */
41
- list_cached_sessions: () => AgentManagedSession[];
42
- }
43
- /**
44
- * 创建实例级 runtime 视图。
45
- */
46
- export declare function createAgentRuntime(options: CreateAgentRuntimeOptions): AgentRuntime;
47
- //# sourceMappingURL=AgentRuntimeFactory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgentRuntimeFactory.d.ts","sourceRoot":"","sources":["../../../src/agent/local/AgentRuntimeFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAMvE;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,mBAAmB;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa;IACb,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,MAAM,EAAE,cAAc,CAAC;IACvB;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,wBAAwB;IACxB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sBAAsB;IACtB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC1C,kCAAkC;IAClC,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,WAAW,CAAC;IACtD,2BAA2B;IAC3B,oBAAoB,EAAE,MAAM,mBAAmB,EAAE,CAAC;CACnD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,GACjC,YAAY,CAuBd"}
@@ -1,34 +0,0 @@
1
- /**
2
- * Agent runtime / context 装配工厂。
3
- *
4
- * 关键点(中文)
5
- * - 这里只创建长期 runtime 视图。
6
- * - `AgentContext` 已经收敛为 class,调用方直接 `new AgentContext(...)`,不再走工厂。
7
- * - Agent 仍然持有 session/plugin 状态;这里通过函数参数读取状态。
8
- */
9
- import { createAgentPathRuntime, createAgentPluginConfigRuntime, } from "../../agent/local/AgentRuntimeAssembly.js";
10
- /**
11
- * 创建实例级 runtime 视图。
12
- */
13
- export function createAgentRuntime(options) {
14
- return {
15
- cwd: options.project_root,
16
- rootPath: options.project_root,
17
- logger: options.logger,
18
- config: options.config,
19
- env: options.env,
20
- systems: options.systems,
21
- paths: createAgentPathRuntime(options.project_root, options.agent_id),
22
- pluginConfig: createAgentPluginConfigRuntime(options.project_root),
23
- getSession: (session_id) => options.get_session_port(session_id),
24
- listExecutingSessionIds: () => options
25
- .list_cached_sessions()
26
- .filter((session) => session.isExecuting())
27
- .map((session) => session.id),
28
- getExecutingSessionCount: () => options
29
- .list_cached_sessions()
30
- .filter((session) => session.isExecuting()).length,
31
- pluginInstances: options.plugin_instances,
32
- };
33
- }
34
- //# sourceMappingURL=AgentRuntimeFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgentRuntimeFactory.js","sourceRoot":"","sources":["../../../src/agent/local/AgentRuntimeFactory.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAC/B,MAAM,uCAAuC,CAAC;AA+B/C;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAkC;IAElC,OAAO;QACL,GAAG,EAAE,OAAO,CAAC,YAAY;QACzB,QAAQ,EAAE,OAAO,CAAC,YAAY;QAC9B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK,EAAE,sBAAsB,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC;QACrE,YAAY,EAAE,8BAA8B,CAAC,OAAO,CAAC,YAAY,CAAC;QAClE,UAAU,EAAE,CAAC,UAAkB,EAAe,EAAE,CAC9C,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC;QACtC,uBAAuB,EAAE,GAAG,EAAE,CAC5B,OAAO;aACJ,oBAAoB,EAAE;aACtB,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;aAC1C,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,wBAAwB,EAAE,GAAG,EAAE,CAC7B,OAAO;aACJ,oBAAoB,EAAE;aACtB,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM;QACtD,eAAe,EAAE,OAAO,CAAC,gBAAgB;KAC1C,CAAC;AACJ,CAAC"}
@@ -1,79 +0,0 @@
1
- /**
2
- * Agent 实例运行时类型定义。
3
- *
4
- * 职责说明(中文)
5
- * - 这里定义单个 `Agent` 实例持有的长期运行状态视图。
6
- * - Session、plugin、server 等长期对象都通过这组类型共享统一状态结构。
7
- *
8
- * 边界说明(中文)
9
- * - 这些类型描述的是“实例级长期状态”,不是某一次执行的上下文视图。
10
- * - 运行时实现细节仍分散在各模块中,这里只保留稳定的共享结构定义。
11
- */
12
- import type { Logger } from "../../../utils/logger/Logger.js";
13
- import type { DowncityConfig } from "../../../types/config/DowncityConfig.js";
14
- import type { AgentPathRuntime, AgentPluginConfigRuntime } from "../../../types/agent/AgentRuntimeAssembly.js";
15
- import type { BasePlugin } from "../../../plugin/core/BasePlugin.js";
16
- import type { SessionPort } from "../../../types/runtime/agent/AgentContext.js";
17
- /**
18
- * Agent 实例启动早期的基础状态。
19
- */
20
- export interface AgentRuntimeBase {
21
- /**
22
- * 当前命令工作目录。
23
- */
24
- cwd: string;
25
- /**
26
- * 当前 agent 项目根目录。
27
- */
28
- rootPath: string;
29
- /**
30
- * 当前统一日志器。
31
- */
32
- logger: Logger;
33
- /**
34
- * 当前解析后的项目配置。
35
- */
36
- config: DowncityConfig;
37
- /**
38
- * 当前 agent 局部环境变量快照。
39
- */
40
- env: Record<string, string>;
41
- /**
42
- * 当前生效的静态 system 文本集合。
43
- */
44
- systems: string[];
45
- /**
46
- * 当前 agent 可见的路径能力集合。
47
- */
48
- paths: AgentPathRuntime;
49
- /**
50
- * 当前 agent 可见的 plugin 配置持久化能力集合。
51
- */
52
- pluginConfig: AgentPluginConfigRuntime;
53
- }
54
- /**
55
- * Agent 实例完整运行状态。
56
- */
57
- export interface AgentRuntime extends AgentRuntimeBase {
58
- /**
59
- * 读取指定 sessionId 对应的 session 端口。
60
- *
61
- * 关键点(中文)
62
- * - 返回值是统一的 `SessionPort`,而不是裸 `Executor`。
63
- * - 这样 HTTP / plugin runtime / chat queue / contact 等入口都能复用同一层会话装配与执行兜底。
64
- */
65
- getSession(sessionId: string): SessionPort;
66
- /**
67
- * 返回当前执行中的 sessionId 列表。
68
- */
69
- listExecutingSessionIds(): string[];
70
- /**
71
- * 返回当前执行中的 session 数量。
72
- */
73
- getExecutingSessionCount(): number;
74
- /**
75
- * 当前 agent 持有的插件实例集合。
76
- */
77
- pluginInstances: Map<string, BasePlugin>;
78
- }
79
- //# sourceMappingURL=AgentRuntime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgentRuntime.d.ts","sourceRoot":"","sources":["../../../../src/types/runtime/agent/AgentRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,KAAK,EACV,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;IACvB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,KAAK,EAAE,gBAAgB,CAAC;IACxB;;OAEG;IACH,YAAY,EAAE,wBAAwB,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD;;;;;;OAMG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3C;;OAEG;IACH,uBAAuB,IAAI,MAAM,EAAE,CAAC;IACpC;;OAEG;IACH,wBAAwB,IAAI,MAAM,CAAC;IACnC;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAC1C"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Agent 实例运行时类型定义。
3
- *
4
- * 职责说明(中文)
5
- * - 这里定义单个 `Agent` 实例持有的长期运行状态视图。
6
- * - Session、plugin、server 等长期对象都通过这组类型共享统一状态结构。
7
- *
8
- * 边界说明(中文)
9
- * - 这些类型描述的是“实例级长期状态”,不是某一次执行的上下文视图。
10
- * - 运行时实现细节仍分散在各模块中,这里只保留稳定的共享结构定义。
11
- */
12
- export {};
13
- //# sourceMappingURL=AgentRuntime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgentRuntime.js","sourceRoot":"","sources":["../../../../src/types/runtime/agent/AgentRuntime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -1,78 +0,0 @@
1
- /**
2
- * Agent runtime / context 装配工厂。
3
- *
4
- * 关键点(中文)
5
- * - 这里只创建长期 runtime 视图。
6
- * - `AgentContext` 已经收敛为 class,调用方直接 `new AgentContext(...)`,不再走工厂。
7
- * - Agent 仍然持有 session/plugin 状态;这里通过函数参数读取状态。
8
- */
9
-
10
- import type { BasePlugin } from "@/plugin/core/BasePlugin.js";
11
- import type { Logger } from "@/utils/logger/Logger.js";
12
- import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
13
- import type { SessionPort } from "@/types/runtime/agent/AgentContext.js";
14
- import type { AgentRuntime } from "@/types/runtime/agent/AgentRuntime.js";
15
- import type { AgentManagedSession } from "@/types/agent/AgentTypes.js";
16
- import {
17
- createAgentPathRuntime,
18
- createAgentPluginConfigRuntime,
19
- } from "@/agent/local/AgentRuntimeAssembly.js";
20
-
21
- /**
22
- * 创建 AgentRuntime 的参数。
23
- */
24
- export interface CreateAgentRuntimeOptions {
25
- /** 当前 agent id。 */
26
- agent_id: string;
27
- /** 当前项目根目录。 */
28
- project_root: string;
29
- /** 统一日志器。 */
30
- logger: Logger;
31
- /** 当前解析后的配置。 */
32
- config: DowncityConfig;
33
- /**
34
- * 当前 agent 共享 env 对象。
35
- *
36
- * 关键点(中文)
37
- * - 必须传入 Agent 持有的同一份 mutable 对象,runtime / context 直接复用同一引用。
38
- */
39
- env: Record<string, string>;
40
- /** 当前静态 system 文本集合。 */
41
- systems: string[];
42
- /** 当前 plugin 实例集合。 */
43
- plugin_instances: Map<string, BasePlugin>;
44
- /** 获取或创建 session runtime port。 */
45
- get_session_port: (session_id: string) => SessionPort;
46
- /** 读取当前已缓存的 session 实例。 */
47
- list_cached_sessions: () => AgentManagedSession[];
48
- }
49
-
50
- /**
51
- * 创建实例级 runtime 视图。
52
- */
53
- export function createAgentRuntime(
54
- options: CreateAgentRuntimeOptions,
55
- ): AgentRuntime {
56
- return {
57
- cwd: options.project_root,
58
- rootPath: options.project_root,
59
- logger: options.logger,
60
- config: options.config,
61
- env: options.env,
62
- systems: options.systems,
63
- paths: createAgentPathRuntime(options.project_root, options.agent_id),
64
- pluginConfig: createAgentPluginConfigRuntime(options.project_root),
65
- getSession: (session_id: string): SessionPort =>
66
- options.get_session_port(session_id),
67
- listExecutingSessionIds: () =>
68
- options
69
- .list_cached_sessions()
70
- .filter((session) => session.isExecuting())
71
- .map((session) => session.id),
72
- getExecutingSessionCount: () =>
73
- options
74
- .list_cached_sessions()
75
- .filter((session) => session.isExecuting()).length,
76
- pluginInstances: options.plugin_instances,
77
- };
78
- }
@@ -1,84 +0,0 @@
1
- /**
2
- * Agent 实例运行时类型定义。
3
- *
4
- * 职责说明(中文)
5
- * - 这里定义单个 `Agent` 实例持有的长期运行状态视图。
6
- * - Session、plugin、server 等长期对象都通过这组类型共享统一状态结构。
7
- *
8
- * 边界说明(中文)
9
- * - 这些类型描述的是“实例级长期状态”,不是某一次执行的上下文视图。
10
- * - 运行时实现细节仍分散在各模块中,这里只保留稳定的共享结构定义。
11
- */
12
-
13
- import type { Logger } from "@/utils/logger/Logger.js";
14
- import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
15
- import type {
16
- AgentPathRuntime,
17
- AgentPluginConfigRuntime,
18
- } from "@/types/agent/AgentRuntimeAssembly.js";
19
- import type { BasePlugin } from "@/plugin/core/BasePlugin.js";
20
- import type { SessionPort } from "@/types/runtime/agent/AgentContext.js";
21
-
22
- /**
23
- * Agent 实例启动早期的基础状态。
24
- */
25
- export interface AgentRuntimeBase {
26
- /**
27
- * 当前命令工作目录。
28
- */
29
- cwd: string;
30
- /**
31
- * 当前 agent 项目根目录。
32
- */
33
- rootPath: string;
34
- /**
35
- * 当前统一日志器。
36
- */
37
- logger: Logger;
38
- /**
39
- * 当前解析后的项目配置。
40
- */
41
- config: DowncityConfig;
42
- /**
43
- * 当前 agent 局部环境变量快照。
44
- */
45
- env: Record<string, string>;
46
- /**
47
- * 当前生效的静态 system 文本集合。
48
- */
49
- systems: string[];
50
- /**
51
- * 当前 agent 可见的路径能力集合。
52
- */
53
- paths: AgentPathRuntime;
54
- /**
55
- * 当前 agent 可见的 plugin 配置持久化能力集合。
56
- */
57
- pluginConfig: AgentPluginConfigRuntime;
58
- }
59
-
60
- /**
61
- * Agent 实例完整运行状态。
62
- */
63
- export interface AgentRuntime extends AgentRuntimeBase {
64
- /**
65
- * 读取指定 sessionId 对应的 session 端口。
66
- *
67
- * 关键点(中文)
68
- * - 返回值是统一的 `SessionPort`,而不是裸 `Executor`。
69
- * - 这样 HTTP / plugin runtime / chat queue / contact 等入口都能复用同一层会话装配与执行兜底。
70
- */
71
- getSession(sessionId: string): SessionPort;
72
- /**
73
- * 返回当前执行中的 sessionId 列表。
74
- */
75
- listExecutingSessionIds(): string[];
76
- /**
77
- * 返回当前执行中的 session 数量。
78
- */
79
- getExecutingSessionCount(): number;
80
- /**
81
- * 当前 agent 持有的插件实例集合。
82
- */
83
- pluginInstances: Map<string, BasePlugin>;
84
- }