@downcity/agent 1.1.175 → 1.1.178

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 (139) hide show
  1. package/bin/agent/local/AgentPluginFactory.d.ts +4 -2
  2. package/bin/agent/local/AgentPluginFactory.d.ts.map +1 -1
  3. package/bin/agent/local/AgentPluginFactory.js +4 -6
  4. package/bin/agent/local/AgentPluginFactory.js.map +1 -1
  5. package/bin/agent/local/AgentRuntimeAssembly.d.ts.map +1 -1
  6. package/bin/agent/local/AgentRuntimeAssembly.js +3 -8
  7. package/bin/agent/local/AgentRuntimeAssembly.js.map +1 -1
  8. package/bin/agent/local/ProjectSetup.d.ts +1 -1
  9. package/bin/agent/local/ProjectSetup.d.ts.map +1 -1
  10. package/bin/agent/local/ProjectSetup.js +2 -6
  11. package/bin/agent/local/ProjectSetup.js.map +1 -1
  12. package/bin/agent/local/services/AgentAssemblyService.d.ts +2 -3
  13. package/bin/agent/local/services/AgentAssemblyService.d.ts.map +1 -1
  14. package/bin/agent/local/services/AgentAssemblyService.js +9 -14
  15. package/bin/agent/local/services/AgentAssemblyService.js.map +1 -1
  16. package/bin/agent/local/services/AgentBackgroundService.d.ts.map +1 -1
  17. package/bin/agent/local/services/AgentBackgroundService.js +5 -6
  18. package/bin/agent/local/services/AgentBackgroundService.js.map +1 -1
  19. package/bin/agent/local/services/AgentSessionManager.d.ts +2 -2
  20. package/bin/agent/local/services/AgentSessionManager.d.ts.map +1 -1
  21. package/bin/agent/local/services/AgentSessionManager.js +1 -28
  22. package/bin/agent/local/services/AgentSessionManager.js.map +1 -1
  23. package/bin/config/AgentInitializer.d.ts +4 -4
  24. package/bin/config/AgentInitializer.d.ts.map +1 -1
  25. package/bin/config/AgentInitializer.js +7 -49
  26. package/bin/config/AgentInitializer.js.map +1 -1
  27. package/bin/config/DowncitySchema.d.ts +3 -4
  28. package/bin/config/DowncitySchema.d.ts.map +1 -1
  29. package/bin/config/DowncitySchema.js +1 -2
  30. package/bin/config/DowncitySchema.js.map +1 -1
  31. package/bin/executor/composer/system/default/SystemDomain.d.ts.map +1 -1
  32. package/bin/executor/composer/system/default/SystemDomain.js +1 -2
  33. package/bin/executor/composer/system/default/SystemDomain.js.map +1 -1
  34. package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
  35. package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
  36. package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
  37. package/bin/executor/composer/system/default/assets/core.prompt.js.map +1 -1
  38. package/bin/index.d.ts +0 -2
  39. package/bin/index.d.ts.map +1 -1
  40. package/bin/index.js +1 -4
  41. package/bin/index.js.map +1 -1
  42. package/bin/plugin/core/Activation.d.ts +6 -5
  43. package/bin/plugin/core/Activation.d.ts.map +1 -1
  44. package/bin/plugin/core/Activation.js +9 -9
  45. package/bin/plugin/core/Activation.js.map +1 -1
  46. package/bin/plugin/core/BasePlugin.d.ts +5 -4
  47. package/bin/plugin/core/BasePlugin.d.ts.map +1 -1
  48. package/bin/plugin/core/BasePlugin.js +7 -4
  49. package/bin/plugin/core/BasePlugin.js.map +1 -1
  50. package/bin/plugin/core/HookRegistry.d.ts +4 -0
  51. package/bin/plugin/core/HookRegistry.d.ts.map +1 -1
  52. package/bin/plugin/core/HookRegistry.js +40 -0
  53. package/bin/plugin/core/HookRegistry.js.map +1 -1
  54. package/bin/plugin/core/Manager.d.ts +1 -1
  55. package/bin/plugin/core/Manager.d.ts.map +1 -1
  56. package/bin/plugin/core/Manager.js +1 -1
  57. package/bin/plugin/core/Manager.js.map +1 -1
  58. package/bin/plugin/core/PluginActionRunner.d.ts +13 -7
  59. package/bin/plugin/core/PluginActionRunner.d.ts.map +1 -1
  60. package/bin/plugin/core/PluginActionRunner.js +46 -111
  61. package/bin/plugin/core/PluginActionRunner.js.map +1 -1
  62. package/bin/plugin/core/PluginCatalog.d.ts +1 -1
  63. package/bin/plugin/core/PluginCatalog.d.ts.map +1 -1
  64. package/bin/plugin/core/PluginCatalog.js +1 -21
  65. package/bin/plugin/core/PluginCatalog.js.map +1 -1
  66. package/bin/plugin/core/PluginLocalExecution.d.ts +12 -2
  67. package/bin/plugin/core/PluginLocalExecution.d.ts.map +1 -1
  68. package/bin/plugin/core/PluginLocalExecution.js +18 -24
  69. package/bin/plugin/core/PluginLocalExecution.js.map +1 -1
  70. package/bin/plugin/core/PluginRegistry.d.ts +60 -7
  71. package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
  72. package/bin/plugin/core/PluginRegistry.js +269 -42
  73. package/bin/plugin/core/PluginRegistry.js.map +1 -1
  74. package/bin/plugin/core/PluginStateController.d.ts +11 -36
  75. package/bin/plugin/core/PluginStateController.d.ts.map +1 -1
  76. package/bin/plugin/core/PluginStateController.js +45 -190
  77. package/bin/plugin/core/PluginStateController.js.map +1 -1
  78. package/bin/plugin/types/Plugin.d.ts +1 -1
  79. package/bin/plugin/types/Plugin.d.ts.map +1 -1
  80. package/bin/plugin/types/PluginState.d.ts +1 -1
  81. package/bin/plugin/types/PluginState.d.ts.map +1 -1
  82. package/bin/plugin/types/Plugins.d.ts +12 -12
  83. package/bin/plugin/types/Plugins.d.ts.map +1 -1
  84. package/bin/types/agent/AgentOptions.d.ts +12 -3
  85. package/bin/types/agent/AgentOptions.d.ts.map +1 -1
  86. package/bin/types/agent/AgentRuntimeAssembly.d.ts +1 -1
  87. package/bin/types/config/AgentProject.d.ts +6 -14
  88. package/bin/types/config/AgentProject.d.ts.map +1 -1
  89. package/bin/types/plugin/PluginRuntime.d.ts +23 -2
  90. package/bin/types/plugin/PluginRuntime.d.ts.map +1 -1
  91. package/bin/types/plugin/PluginState.d.ts +47 -36
  92. package/bin/types/plugin/PluginState.d.ts.map +1 -1
  93. package/bin/types/plugin/PluginState.js +4 -3
  94. package/bin/types/plugin/PluginState.js.map +1 -1
  95. package/bin/types/runtime/agent/AgentContext.d.ts +3 -3
  96. package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
  97. package/bin/types/runtime/agent/AgentContext.js.map +1 -1
  98. package/package.json +3 -3
  99. package/src/agent/local/AgentPluginFactory.ts +8 -8
  100. package/src/agent/local/AgentRuntimeAssembly.ts +3 -9
  101. package/src/agent/local/ProjectSetup.ts +1 -8
  102. package/src/agent/local/services/AgentAssemblyService.ts +13 -23
  103. package/src/agent/local/services/AgentBackgroundService.ts +5 -6
  104. package/src/agent/local/services/AgentSessionManager.ts +4 -26
  105. package/src/config/AgentInitializer.ts +7 -57
  106. package/src/config/DowncitySchema.ts +3 -4
  107. package/src/executor/composer/system/default/SystemDomain.ts +1 -2
  108. package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
  109. package/src/executor/composer/system/default/assets/core.prompt.ts.txt +1 -1
  110. package/src/index.ts +1 -8
  111. package/src/plugin/core/Activation.ts +10 -10
  112. package/src/plugin/core/BasePlugin.ts +9 -6
  113. package/src/plugin/core/HookRegistry.ts +41 -0
  114. package/src/plugin/core/Manager.ts +0 -2
  115. package/src/plugin/core/PluginActionRunner.ts +52 -133
  116. package/src/plugin/core/PluginCatalog.ts +1 -23
  117. package/src/plugin/core/PluginLocalExecution.ts +30 -25
  118. package/src/plugin/core/PluginRegistry.ts +298 -44
  119. package/src/plugin/core/PluginStateController.ts +45 -235
  120. package/src/plugin/types/Plugin.ts +2 -1
  121. package/src/plugin/types/PluginState.ts +2 -1
  122. package/src/plugin/types/Plugins.ts +12 -12
  123. package/src/types/agent/AgentOptions.ts +13 -3
  124. package/src/types/agent/AgentRuntimeAssembly.ts +1 -1
  125. package/src/types/config/AgentProject.ts +7 -15
  126. package/src/types/plugin/PluginRuntime.ts +23 -2
  127. package/src/types/plugin/PluginState.ts +50 -43
  128. package/src/types/runtime/agent/AgentContext.ts +3 -3
  129. package/tsconfig.tsbuildinfo +1 -1
  130. package/bin/config/Defaults.d.ts +0 -21
  131. package/bin/config/Defaults.d.ts.map +0 -1
  132. package/bin/config/Defaults.js +0 -47
  133. package/bin/config/Defaults.js.map +0 -1
  134. package/bin/plugin/core/ProjectConfigStore.d.ts +0 -84
  135. package/bin/plugin/core/ProjectConfigStore.d.ts.map +0 -1
  136. package/bin/plugin/core/ProjectConfigStore.js +0 -89
  137. package/bin/plugin/core/ProjectConfigStore.js.map +0 -1
  138. package/src/config/Defaults.ts +0 -49
  139. package/src/plugin/core/ProjectConfigStore.ts +0 -155
@@ -1,82 +1,89 @@
1
1
  /**
2
- * Plugin 状态类型。
2
+ * Plugin 注册状态类型。
3
3
  *
4
4
  * 关键点(中文)
5
- * - 只描述 plugin 生命周期状态与控制结果。
6
- * - 不包含 command/action/hook 等执行协议,避免状态类型被运行时细节污染。
5
+ * - Plugin 只属于 Agent:注册即生效,卸载即不可见。
6
+ * - 不再暴露 start / stop / restart 这类生命周期状态。
7
+ * - `error` 只表示最近一次注册后运行发生错误,方便开发者诊断。
7
8
  */
8
9
 
10
+ import type { Plugin } from "@/types/plugin/PluginDefinition.js";
11
+
9
12
  /**
10
- * Plugin 运行状态。
11
- *
12
- * 说明(中文)
13
- * - `starting` / `stopping` 仅用于生命周期过渡态。
14
- * - `error` 表示最近一次 lifecycle / command / action 执行失败后留下的状态标记。
13
+ * Plugin 当前可观察状态。
15
14
  */
16
- export type PluginState =
17
- | "running"
18
- | "stopped"
19
- | "starting"
20
- | "stopping"
21
- | "error";
15
+ export type PluginState = "ready" | "error";
22
16
 
23
17
  /**
24
- * 单个 plugin 实例内部持有的状态记录。
18
+ * 单个已注册 plugin 的运行时记录。
25
19
  */
26
- export interface PluginStateRecord {
27
- /** 当前运行状态。 */
20
+ export interface PluginRuntimeRecord {
21
+ /** 当前 plugin 实例。 */
22
+ plugin: Plugin;
23
+ /** 当前可观察状态。 */
28
24
  state: PluginState;
25
+ /** plugin 注册时间(毫秒时间戳)。 */
26
+ registered_at: number;
29
27
  /** 最近一次状态更新时间(毫秒时间戳)。 */
30
- updatedAt: number;
28
+ updated_at: number;
31
29
  /** 最近一次错误信息。 */
32
- lastError?: string;
33
- /** 最近一次执行的命令名。 */
34
- lastCommand?: string;
35
- /** 最近一次执行命令的时间(毫秒时间戳)。 */
36
- lastCommandAt?: number;
37
- /** 当前串行控制链。 */
30
+ last_error?: string;
31
+ /** 当前串行变更链。 */
38
32
  chain: Promise<void>;
33
+ /** lifecycle.start 是否已经执行成功。 */
34
+ lifecycle_started: boolean;
39
35
  }
40
36
 
41
37
  /**
42
- * 单个 plugin 状态的对外快照。
38
+ * 单个 plugin 注册快照。
43
39
  */
44
- export interface PluginStateSnapshot {
40
+ export interface PluginSnapshot {
45
41
  /** plugin 名称。 */
46
42
  name: string;
47
- /** 当前运行状态。 */
43
+ /** plugin 标题。 */
44
+ title: string;
45
+ /** plugin 描述。 */
46
+ description: string;
47
+ /** 当前注册后的可用状态。 */
48
+ status: PluginState;
49
+ /** 兼容旧字段的状态别名。 */
48
50
  state: PluginState;
49
- /** 最近一次状态更新时间(毫秒时间戳)。 */
51
+ /** 注册时间(毫秒时间戳)。 */
52
+ registered_at: number;
53
+ /** 最近更新时间(毫秒时间戳)。 */
54
+ updated_at: number;
55
+ /** 兼容旧字段的最近更新时间。 */
50
56
  updatedAt: number;
51
- /** 最近一次错误信息。 */
57
+ /** 最近错误。 */
58
+ last_error?: string;
59
+ /** 兼容旧字段的最近错误。 */
52
60
  lastError?: string;
53
- /** 最近一次执行的命令名。 */
54
- lastCommand?: string;
55
- /** 最近一次执行命令的时间(毫秒时间戳)。 */
56
- lastCommandAt?: number;
57
- /** 是否支持主动生命周期。 */
58
- supportsLifecycle: boolean;
59
- /** 是否支持 command/action。 */
60
- supportsCommand: boolean;
61
61
  }
62
62
 
63
63
  /**
64
- * plugin 状态控制动作。
64
+ * 兼容旧名称的 plugin 快照类型。
65
+ */
66
+ export type PluginStateSnapshot = PluginSnapshot;
67
+
68
+ /**
69
+ * 兼容旧控制动作类型。
70
+ *
71
+ * 说明(中文)
72
+ * - 控制面只保留状态查询与卸载。
65
73
  */
66
74
  export type PluginStateControlAction =
67
- | "start"
68
- | "stop"
69
- | "restart"
75
+ | "register"
76
+ | "unregister"
70
77
  | "status";
71
78
 
72
79
  /**
73
- * plugin 状态控制结果。
80
+ * plugin 控制结果。
74
81
  */
75
82
  export interface PluginStateControlResult {
76
83
  /** 控制动作是否成功。 */
77
84
  success: boolean;
78
85
  /** 成功或失败后返回的最新 plugin 快照。 */
79
- plugin?: PluginStateSnapshot;
86
+ plugin?: PluginSnapshot;
80
87
  /** 失败时的错误信息。 */
81
88
  error?: string;
82
89
  }
@@ -16,7 +16,7 @@ import type {
16
16
  import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
17
17
  import type { JsonValue } from "@/types/common/Json.js";
18
18
  import type { AgentPlugins } from "@/plugin/types/Plugin.js";
19
- import type { BasePlugin } from "@/plugin/core/BasePlugin.js";
19
+ import type { Plugin } from "@/types/plugin/PluginDefinition.js";
20
20
  import type {
21
21
  SessionMetadataV1,
22
22
  SessionMessageV1,
@@ -249,7 +249,7 @@ export interface AgentContextOptions {
249
249
  /** 当前可见的 plugin 配置持久化能力集合。 */
250
250
  pluginConfig: AgentPluginConfigRuntime;
251
251
  /** 当前 agent 持有的插件实例集合。 */
252
- pluginInstances: Map<string, BasePlugin>;
252
+ pluginInstances: Map<string, Plugin>;
253
253
  /** Session 能力入口。 */
254
254
  session: SessionCollectionPort;
255
255
  /** Plugin 调用入口。 */
@@ -282,7 +282,7 @@ export class AgentContext {
282
282
  /** 当前可见的 plugin 配置持久化能力集合。 */
283
283
  readonly pluginConfig: AgentPluginConfigRuntime;
284
284
  /** 当前 agent 持有的插件实例集合。 */
285
- readonly pluginInstances: Map<string, BasePlugin>;
285
+ readonly pluginInstances: Map<string, Plugin>;
286
286
  /** Session 能力入口。 */
287
287
  readonly session: SessionCollectionPort;
288
288
  /** Plugin 调用入口。 */