@octopi-agent/engine 0.98.4 → 0.102.10

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 (301) hide show
  1. package/dist/config-schema/agent.d.ts +35 -5
  2. package/dist/config-schema/agent.js +24 -4
  3. package/dist/config-schema/context.d.ts +6 -36
  4. package/dist/config-schema/context.js +4 -28
  5. package/dist/config-schema/engine.d.ts +57 -160
  6. package/dist/config-schema/engine.js +1 -5
  7. package/dist/config-schema/governance.d.ts +8 -1
  8. package/dist/config-schema/governance.js +8 -1
  9. package/dist/config-schema/models.d.ts +2 -8
  10. package/dist/config-schema/models.js +0 -2
  11. package/dist/config-schema/run.d.ts +2 -2
  12. package/dist/config-schema/run.js +2 -2
  13. package/dist/config-schema/shared.d.ts +0 -3
  14. package/dist/config-schema/shared.js +0 -2
  15. package/dist/config-schema/substrate.d.ts +14 -88
  16. package/dist/config-schema/substrate.js +22 -107
  17. package/dist/config.d.ts +45 -113
  18. package/dist/config.js +8 -2
  19. package/dist/harness/activation/dispatcher.js +7 -0
  20. package/dist/harness/activation/inbox.d.ts +3 -3
  21. package/dist/harness/activation/inbox.js +3 -3
  22. package/dist/harness/activation/runtime.js +13 -5
  23. package/dist/harness/activation/types.d.ts +2 -2
  24. package/dist/harness/agent/builder.d.ts +24 -3
  25. package/dist/harness/agent/builder.js +131 -27
  26. package/dist/harness/agent/config-bridge.js +9 -2
  27. package/dist/harness/agent/config-integrity.js +19 -2
  28. package/dist/harness/agent/wire-agent-builder.d.ts +11 -3
  29. package/dist/harness/agent/wire-agent-builder.js +26 -7
  30. package/dist/harness/capabilities/document/factory.d.ts +5 -0
  31. package/dist/harness/capabilities/document/factory.js +1 -0
  32. package/dist/harness/capabilities/document/port.js +6 -3
  33. package/dist/harness/capabilities/document/types.d.ts +5 -0
  34. package/dist/harness/collaboration/autonomous-subsystem/loader.js +1 -1
  35. package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +1 -1
  36. package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +2 -2
  37. package/dist/harness/collaboration/autonomous-subsystem/sense/input-builder.js +4 -4
  38. package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +2 -2
  39. package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +2 -2
  40. package/dist/harness/collaboration/autonomous-subsystem/signal/bus.d.ts +6 -0
  41. package/dist/harness/collaboration/autonomous-subsystem/signal/bus.js +25 -4
  42. package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +1 -1
  43. package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +3 -3
  44. package/dist/harness/collaboration/delegation/child-run.d.ts +1 -1
  45. package/dist/harness/collaboration/delegation/child-run.js +4 -4
  46. package/dist/harness/collaboration/delegation/index.d.ts +1 -1
  47. package/dist/harness/collaboration/delegation/index.js +1 -1
  48. package/dist/harness/collaboration/delegation/notifier.d.ts +6 -1
  49. package/dist/harness/collaboration/delegation/notifier.js +8 -1
  50. package/dist/harness/collaboration/delegation/service.d.ts +2 -0
  51. package/dist/harness/collaboration/delegation/service.js +2 -1
  52. package/dist/harness/collaboration/delegation/store.d.ts +2 -0
  53. package/dist/harness/collaboration/delegation/store.js +2 -1
  54. package/dist/harness/collaboration/delegation/types.d.ts +23 -2
  55. package/dist/harness/collaboration/delegation/types.js +22 -0
  56. package/dist/harness/collaboration/delegation/wiring.js +11 -1
  57. package/dist/harness/context/budget-allocator.d.ts +26 -18
  58. package/dist/harness/context/budget-allocator.js +67 -32
  59. package/dist/harness/context/capabilities/compact/engine.d.ts +0 -6
  60. package/dist/harness/context/capabilities/compact/engine.js +169 -121
  61. package/dist/harness/context/capabilities/compact/handover.d.ts +5 -3
  62. package/dist/harness/context/capabilities/compact/handover.js +7 -5
  63. package/dist/harness/context/capabilities/compact/index.d.ts +5 -1
  64. package/dist/harness/context/capabilities/compact/index.js +4 -0
  65. package/dist/harness/context/capabilities/compact/mechanical.d.ts +130 -0
  66. package/dist/harness/context/capabilities/compact/mechanical.js +268 -0
  67. package/dist/harness/context/capabilities/compact/messages.d.ts +60 -0
  68. package/dist/harness/context/capabilities/compact/messages.js +91 -0
  69. package/dist/harness/context/capabilities/compact/types.d.ts +76 -11
  70. package/dist/harness/context/capabilities/compact/types.js +11 -1
  71. package/dist/harness/context/capabilities/compact/view-split.d.ts +36 -0
  72. package/dist/harness/context/capabilities/compact/view-split.js +72 -0
  73. package/dist/harness/context/capabilities/summary/port.js +0 -1
  74. package/dist/harness/context/capabilities/summary/resolver.d.ts +1 -1
  75. package/dist/harness/context/capabilities/summary/resolver.js +1 -6
  76. package/dist/harness/context/capabilities/summary/tool-binding.d.ts +1 -1
  77. package/dist/harness/context/capabilities/summary/types.d.ts +3 -6
  78. package/dist/harness/context/context-size-ledger.d.ts +143 -0
  79. package/dist/harness/context/context-size-ledger.js +236 -0
  80. package/dist/harness/context/default-context-engine.d.ts +195 -119
  81. package/dist/harness/context/default-context-engine.js +1241 -743
  82. package/dist/harness/context/index.d.ts +2 -2
  83. package/dist/harness/context/index.js +1 -1
  84. package/dist/harness/context/layer-types.d.ts +15 -0
  85. package/dist/harness/context/layer-types.js +14 -1
  86. package/dist/harness/context/layers.d.ts +14 -15
  87. package/dist/harness/context/layers.js +41 -11
  88. package/dist/harness/context/message-selector.d.ts +10 -8
  89. package/dist/harness/context/message-selector.js +49 -27
  90. package/dist/harness/context/summarize.d.ts +2 -2
  91. package/dist/harness/context/summarize.js +9 -2
  92. package/dist/harness/context/system-prompt-assembler.d.ts +2 -0
  93. package/dist/harness/context/system-prompt-assembler.js +2 -1
  94. package/dist/harness/context/token-constants.d.ts +8 -6
  95. package/dist/harness/context/token-constants.js +8 -7
  96. package/dist/harness/context/token-estimate-fns.d.ts +37 -27
  97. package/dist/harness/context/token-estimate-fns.js +85 -66
  98. package/dist/harness/context/token-estimator.d.ts +27 -12
  99. package/dist/harness/context/token-estimator.js +120 -66
  100. package/dist/harness/context/token-segments.d.ts +88 -0
  101. package/dist/harness/context/token-segments.js +103 -0
  102. package/dist/harness/context/tool-result-aging.d.ts +6 -1
  103. package/dist/harness/context/tool-result-aging.js +16 -5
  104. package/dist/harness/context/tool-result-body.js +2 -0
  105. package/dist/harness/context/transform/anchors.d.ts +66 -0
  106. package/dist/harness/context/transform/anchors.js +125 -0
  107. package/dist/harness/context/transform/fold.d.ts +56 -0
  108. package/dist/harness/context/transform/fold.js +135 -0
  109. package/dist/harness/context/transform/migrate.d.ts +41 -0
  110. package/dist/harness/context/transform/migrate.js +69 -0
  111. package/dist/harness/context/transform/types.d.ts +129 -0
  112. package/dist/harness/context/transform/types.js +19 -0
  113. package/dist/harness/context/turn-envelope.d.ts +6 -3
  114. package/dist/harness/context/types.d.ts +127 -117
  115. package/dist/harness/extension/execution-environment/ops-audit.d.ts +1 -1
  116. package/dist/harness/extension/execution-environment/resource-limits.d.ts +1 -1
  117. package/dist/harness/extension/execution-environment/resource-limits.js +1 -1
  118. package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +1 -1
  119. package/dist/harness/extension/plugin-ecosystem/commands/index.d.ts +3 -1
  120. package/dist/harness/extension/plugin-ecosystem/commands/index.js +1 -0
  121. package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.d.ts +12 -1
  122. package/dist/harness/extension/plugin-ecosystem/commands/plugin-bridge.js +14 -4
  123. package/dist/harness/extension/plugin-ecosystem/commands/router.d.ts +5 -4
  124. package/dist/harness/extension/plugin-ecosystem/commands/router.js +23 -14
  125. package/dist/harness/extension/plugin-ecosystem/commands/types.d.ts +8 -1
  126. package/dist/harness/extension/plugin-ecosystem/commands/types.js +2 -1
  127. package/dist/harness/extension/plugin-ecosystem/hooks/adapter.d.ts +54 -0
  128. package/dist/harness/extension/plugin-ecosystem/hooks/adapter.js +397 -0
  129. package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.d.ts +16 -0
  130. package/dist/harness/extension/plugin-ecosystem/hooks/compaction-integration.js +66 -0
  131. package/dist/harness/extension/plugin-ecosystem/hooks/index.d.ts +4 -0
  132. package/dist/harness/extension/plugin-ecosystem/hooks/index.js +2 -0
  133. package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.d.ts +11 -0
  134. package/dist/harness/extension/plugin-ecosystem/hooks/iteration-snapshot.js +54 -0
  135. package/dist/harness/extension/plugin-ecosystem/hooks/journal.d.ts +9 -0
  136. package/dist/harness/extension/plugin-ecosystem/hooks/journal.js +22 -0
  137. package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.d.ts +12 -0
  138. package/dist/harness/extension/plugin-ecosystem/hooks/policy-error.js +19 -0
  139. package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.d.ts +36 -0
  140. package/dist/harness/extension/plugin-ecosystem/hooks/run-integration.js +338 -0
  141. package/dist/harness/extension/plugin-ecosystem/hooks/services.d.ts +24 -0
  142. package/dist/harness/extension/plugin-ecosystem/hooks/services.js +139 -0
  143. package/dist/harness/extension/plugin-ecosystem/hooks/types.d.ts +229 -0
  144. package/dist/harness/extension/plugin-ecosystem/hooks/types.js +1 -0
  145. package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +83 -249
  146. package/dist/harness/extension/plugin-ecosystem/plugins/api.js +88 -214
  147. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +43 -0
  148. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +61 -0
  149. package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.d.ts +4 -0
  150. package/dist/harness/extension/plugin-ecosystem/plugins/engine-compatibility.js +18 -0
  151. package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +7 -85
  152. package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +8 -50
  153. package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +6 -23
  154. package/dist/harness/extension/plugin-ecosystem/plugins/index.js +3 -23
  155. package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +50 -117
  156. package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +316 -285
  157. package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +23 -490
  158. package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +85 -353
  159. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +41 -223
  160. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +138 -19
  161. package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +15 -0
  162. package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +15 -0
  163. package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +6 -1
  164. package/dist/harness/extension/plugin-ecosystem/skills/manager.js +17 -1
  165. package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +3 -0
  166. package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +46 -21
  167. package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -8
  168. package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.d.ts +11 -0
  169. package/dist/harness/extension/plugin-ecosystem/tools/plugin-tool.js +39 -0
  170. package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +1 -1
  171. package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +11 -2
  172. package/dist/harness/governance/accounting/usage-ledger.d.ts +13 -1
  173. package/dist/harness/governance/accounting/usage-ledger.js +23 -1
  174. package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +3 -3
  175. package/dist/harness/governance/human-in-the-loop/decision-cache.js +2 -2
  176. package/dist/harness/governance/security/capability-enforcer.js +1 -2
  177. package/dist/harness/index.d.ts +12 -12
  178. package/dist/harness/index.js +7 -7
  179. package/dist/harness/knowledge/boot-config.d.ts +55 -0
  180. package/dist/harness/knowledge/boot-config.js +50 -0
  181. package/dist/harness/knowledge/catalog-types.d.ts +2 -0
  182. package/dist/harness/knowledge/client.d.ts +24 -2
  183. package/dist/harness/knowledge/client.js +19 -5
  184. package/dist/harness/knowledge/db.js +5 -0
  185. package/dist/harness/knowledge/describe-sample.d.ts +23 -0
  186. package/dist/harness/knowledge/describe-sample.js +58 -0
  187. package/dist/harness/knowledge/describe.d.ts +8 -0
  188. package/dist/harness/knowledge/describe.js +18 -2
  189. package/dist/harness/knowledge/engine-thread.js +6 -0
  190. package/dist/harness/knowledge/grounding.js +3 -1
  191. package/dist/harness/knowledge/http-app.js +35 -4
  192. package/dist/harness/knowledge/http-params.d.ts +18 -0
  193. package/dist/harness/knowledge/http-params.js +24 -0
  194. package/dist/harness/knowledge/index.d.ts +2 -0
  195. package/dist/harness/knowledge/index.js +1 -0
  196. package/dist/harness/knowledge/knowledge-serve-child.js +3 -0
  197. package/dist/harness/knowledge/purge.js +5 -2
  198. package/dist/harness/knowledge/query-service.d.ts +13 -2
  199. package/dist/harness/knowledge/query-service.js +4 -2
  200. package/dist/harness/knowledge/query-worker-client.d.ts +9 -1
  201. package/dist/harness/knowledge/query-worker-client.js +4 -2
  202. package/dist/harness/knowledge/query-worker.js +4 -2
  203. package/dist/harness/knowledge/read-http.js +5 -1
  204. package/dist/harness/knowledge/serve.d.ts +8 -7
  205. package/dist/harness/knowledge/serve.js +9 -0
  206. package/dist/harness/knowledge/source-store.js +26 -3
  207. package/dist/harness/knowledge/start-service-process.d.ts +15 -7
  208. package/dist/harness/knowledge/start-service-process.js +21 -9
  209. package/dist/harness/knowledge/types.d.ts +7 -0
  210. package/dist/harness/knowledge/writer-service.d.ts +37 -9
  211. package/dist/harness/knowledge/writer-service.js +120 -14
  212. package/dist/harness/knowledge/writer-worker-client.d.ts +10 -9
  213. package/dist/harness/knowledge/writer-worker-client.js +20 -2
  214. package/dist/harness/knowledge/writer-worker.js +9 -1
  215. package/dist/harness/memory/sqlite/wisdom-store.js +35 -10
  216. package/dist/harness/memory/types.d.ts +6 -4
  217. package/dist/harness/memory/wisdom-formation.d.ts +14 -3
  218. package/dist/harness/memory/wisdom-formation.js +85 -22
  219. package/dist/harness/memory/wisdom-gates.d.ts +14 -0
  220. package/dist/harness/memory/wisdom-gates.js +59 -19
  221. package/dist/harness/memory/wisdom.js +9 -0
  222. package/dist/harness/observability/observer/hub.js +25 -15
  223. package/dist/harness/observability/observer/types.d.ts +10 -6
  224. package/dist/harness/run/agent/agent.d.ts +40 -21
  225. package/dist/harness/run/agent/agent.js +66 -13
  226. package/dist/harness/run/agent/index.d.ts +1 -1
  227. package/dist/harness/run/budget/budget.d.ts +28 -10
  228. package/dist/harness/run/budget/budget.js +38 -15
  229. package/dist/harness/run/model/index.d.ts +3 -1
  230. package/dist/harness/run/model/index.js +2 -1
  231. package/dist/harness/run/model/resolver.d.ts +4 -1
  232. package/dist/harness/run/model/resolver.js +36 -2
  233. package/dist/harness/run/model/run-scope.d.ts +2 -0
  234. package/dist/harness/run/model/run-scope.js +7 -0
  235. package/dist/harness/run/model/types.d.ts +22 -5
  236. package/dist/harness/run/model/types.js +3 -2
  237. package/dist/harness/run/model/window-truth.d.ts +37 -0
  238. package/dist/harness/run/model/window-truth.js +39 -0
  239. package/dist/harness/run/reliability/context-length-feedback.d.ts +77 -0
  240. package/dist/harness/run/reliability/context-length-feedback.js +128 -0
  241. package/dist/harness/run/reliability/harness-events.d.ts +3 -3
  242. package/dist/harness/run/reliability/model-error-policy.js +4 -0
  243. package/dist/harness/run/reliability/run-agent.d.ts +10 -4
  244. package/dist/harness/run/reliability/run-agent.js +137 -53
  245. package/dist/harness/run/reliability/run-metrics-collector.d.ts +19 -8
  246. package/dist/harness/run/reliability/run-metrics-collector.js +38 -23
  247. package/dist/harness/run/run-guard/default-run-guard.js +8 -8
  248. package/dist/harness/run/run-scope.d.ts +37 -4
  249. package/dist/harness/run/runner.d.ts +44 -29
  250. package/dist/harness/run/runner.js +320 -102
  251. package/dist/harness/session/attachments/index.d.ts +1 -0
  252. package/dist/harness/session/attachments/index.js +1 -0
  253. package/dist/harness/session/attachments/inject.d.ts +21 -10
  254. package/dist/harness/session/attachments/inject.js +76 -24
  255. package/dist/harness/session/attachments/recall-index.d.ts +70 -0
  256. package/dist/harness/session/attachments/recall-index.js +219 -0
  257. package/dist/harness/session/attachments/service.d.ts +21 -0
  258. package/dist/harness/session/attachments/service.js +258 -139
  259. package/dist/harness/session/attachments/types.d.ts +6 -0
  260. package/dist/harness/session/transform-store.d.ts +136 -0
  261. package/dist/harness/session/transform-store.js +302 -0
  262. package/dist/harness/session/types.d.ts +2 -2
  263. package/dist/harness/shared/events/agent-event-map.d.ts +46 -13
  264. package/dist/harness/shared/events/agent-event-map.js +3 -2
  265. package/dist/harness/shared/events/scenario-events.d.ts +6 -6
  266. package/dist/harness/shared/types/agent-definition.d.ts +1 -2
  267. package/dist/index.d.ts +14 -17
  268. package/dist/index.js +7 -9
  269. package/dist/integration/observability/metrics.d.ts +6 -6
  270. package/dist/integration/observability/metrics.js +13 -13
  271. package/dist/integration/observability/observer-bridge.js +2 -2
  272. package/dist/integration/observability/trace-collector.d.ts +5 -5
  273. package/dist/integration/observability/trace-collector.js +34 -35
  274. package/dist/integration/observability/trace-events.d.ts +3 -3
  275. package/dist/integration/observability/trace-events.js +3 -3
  276. package/dist/integration/providers/anthropic.js +14 -1
  277. package/dist/integration/providers/openai.js +7 -1
  278. package/dist/integration/providers/usage.d.ts +1 -1
  279. package/dist/integration/providers/wire-dump.d.ts +1 -1
  280. package/dist/integration/storage/archive-manager.d.ts +6 -0
  281. package/dist/integration/storage/archive-manager.js +10 -0
  282. package/dist/integration/storage/jsonl.d.ts +1 -1
  283. package/dist/integration/storage/jsonl.js +18 -16
  284. package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +8 -1
  285. package/dist/subsystems/wisdom-steward/formation/config.yaml +1 -0
  286. package/dist/subsystems/wisdom-steward/formation/handler.js +27 -5
  287. package/package.json +11 -14
  288. package/dist/harness/context/hybrid-compressor.d.ts +0 -41
  289. package/dist/harness/context/hybrid-compressor.js +0 -159
  290. package/dist/harness/context/llm-summarizer.d.ts +0 -46
  291. package/dist/harness/context/llm-summarizer.js +0 -249
  292. package/dist/harness/context/smart-router.d.ts +0 -75
  293. package/dist/harness/context/smart-router.js +0 -118
  294. package/dist/harness/context/truncate-compressor.d.ts +0 -28
  295. package/dist/harness/context/truncate-compressor.js +0 -107
  296. package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -97
  297. package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -155
  298. package/dist/harness/extension/plugin-ecosystem/plugins/hooks.d.ts +0 -7
  299. package/dist/harness/extension/plugin-ecosystem/plugins/hooks.js +0 -7
  300. package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.d.ts +0 -86
  301. package/dist/harness/extension/plugin-ecosystem/plugins/lifecycle.js +0 -139
@@ -1,46 +1,18 @@
1
- /**
2
- * Plugin API
3
- *
4
- * 这是 plugin register() 回调中接收的 api 对象。
5
- * Plugin 通过它注册各种能力(provider、channel、tool、hook 等)。
6
- */
7
- /**
8
- * Plugin API
9
- *
10
- * Plugin 在 register() 回调中使用此对象注册能力。
11
- */
1
+ /** Public author API. Runtime ownership lives in PluginContributionRegistry. */
2
+ import { resolve } from 'node:path';
3
+ import { TOOL_CAPABILITIES } from '@octopi-agent/core/types.js';
4
+ import { createStaging, readStaging } from './staging.js';
5
+ import { normalizeCommandName } from '../commands/parse.js';
6
+ import { COMMAND_INVOKERS } from '../commands/types.js';
12
7
  export class PluginApi {
13
- /** Plugin ID */
14
8
  id;
15
- /** Plugin 显示名称 */
16
9
  name;
17
- /** Plugin 版本 */
18
10
  version;
19
- /** Plugin 描述 */
20
11
  description;
21
- /** Plugin 源路径 */
22
12
  source;
23
- /** Plugin root 目录 */
24
13
  rootDir;
25
- /** Plugin 配置 */
26
14
  pluginConfig;
27
- /** Plugin Logger */
28
15
  logger;
29
- // ── 内部存储(PluginManager 读取) ──
30
- /** 已注册的 providers */
31
- _providers = [];
32
- /** 已注册的 channels */
33
- _channels = [];
34
- /** 已注册的 tools */
35
- _tools = [];
36
- /** 已注册的 context engines */
37
- _contextEngines = [];
38
- /** 已注册的 hooks */
39
- _hooks = new Map();
40
- /** 已注册的 commands */
41
- _commands = [];
42
- /** 已注册的服务 */
43
- _services = [];
44
16
  constructor(opts) {
45
17
  this.id = opts.id;
46
18
  this.name = opts.name;
@@ -48,218 +20,120 @@ export class PluginApi {
48
20
  this.description = opts.description;
49
21
  this.source = opts.source;
50
22
  this.rootDir = opts.rootDir;
51
- this.pluginConfig = opts.pluginConfig ?? {};
23
+ this.pluginConfig = opts.pluginConfig;
24
+ createStaging(this);
52
25
  const prefix = `[plugin:${opts.id}]`;
53
26
  this.logger = {
54
- debug: (msg, ...args) => console.debug(`${prefix} ${msg}`, ...args),
55
- info: (msg, ...args) => console.info(`${prefix} ${msg}`, ...args),
56
- warn: (msg, ...args) => console.warn(`${prefix} ${msg}`, ...args),
57
- error: (msg, ...args) => console.error(`${prefix} ${msg}`, ...args),
27
+ debug: (message, ...args) => console.debug(`${prefix} ${message}`, ...args),
28
+ info: (message, ...args) => console.info(`${prefix} ${message}`, ...args),
29
+ warn: (message, ...args) => console.warn(`${prefix} ${message}`, ...args),
30
+ error: (message, ...args) => console.error(`${prefix} ${message}`, ...args),
58
31
  };
59
32
  }
60
- // ================================================================
61
- // Capability Registration
62
- // ================================================================
63
33
  /**
64
- * 注册 LLM Provider
34
+ * Stage a Tool contribution. It is not mounted or exposed by this call.
65
35
  *
66
- * @param registration - Provider 注册定义
67
- */
68
- registerProvider(registration) {
69
- this._providers.push(registration);
70
- this.logger.info(`Registered provider: ${registration.id}`);
71
- }
72
- /**
73
- * 注册 Channel Adapter
74
- *
75
- * @param registration - Channel 注册定义
76
- */
77
- registerChannel(registration) {
78
- this._channels.push(registration);
79
- this.logger.info(`Registered channel: ${registration.id}`);
80
- }
81
- /**
82
- * 注册 Agent Tool
83
- *
84
- * Tool 名称不能与核心 tool 冲突。
85
- *
86
- * @param tool - Tool 定义(包含 name、description、parameters)
87
- * @param handler - Tool 处理函数
88
- * @param opts - 注册选项
36
+ * @param tool - Core ToolDefinition
37
+ * @param handler - Core ToolHandler
38
+ * @param opts - Execution and optional contribution metadata
89
39
  */
90
40
  registerTool(tool, handler, opts) {
91
- this._tools.push({
41
+ if (!tool.capabilities || tool.capabilities.length === 0) {
42
+ throw new Error(`Plugin tool "${tool.name}" must declare non-empty capabilities`);
43
+ }
44
+ if (new Set(tool.capabilities).size !== tool.capabilities.length ||
45
+ tool.capabilities.some((capability) => !TOOL_CAPABILITIES.includes(capability))) {
46
+ throw new Error(`Plugin tool "${tool.name}" has unknown or duplicate capabilities`);
47
+ }
48
+ if (readStaging(this).tools.some((entry) => entry.definition.name === tool.name)) {
49
+ throw new Error(`Plugin "${this.id}" registered duplicate tool "${tool.name}"`);
50
+ }
51
+ const executionMode = opts?.executionMode ??
52
+ (tool.capabilities.includes('fs-write') ? 'sequential' : undefined);
53
+ readStaging(this).tools.push({
92
54
  definition: tool,
93
- handler: handler,
55
+ handler,
94
56
  optional: opts?.optional ?? false,
57
+ ...(executionMode === undefined ? {} : { executionMode }),
95
58
  });
96
- this.logger.info(`Registered tool: ${tool.name}${opts?.optional ? ' (optional)' : ''}`);
97
59
  }
98
60
  /**
99
- * 注册 Context Engine
100
- *
101
- * Context Engine 是 exclusive slot —— 同一时刻只有一个 active。
61
+ * Stage a typed hook contribution using one of the 22 existing event names.
102
62
  *
103
- * @param id - Engine ID
104
- * @param engine - Context Engine 实例
105
- */
106
- registerContextEngine(id, engine) {
107
- this._contextEngines.push({ id, engine });
108
- this.logger.info(`Registered context engine: ${id}`);
109
- }
110
- /**
111
- * 注册 Hook
112
- *
113
- * Hook handler 按 priority 降序执行,同 priority 按注册顺序。
114
- *
115
- * @param hookName - Hook 名称
116
- * @param handler - Hook handler
117
- * @param opts - 选项(priority、timeoutMs)
63
+ * @param hookName - Existing hook name
64
+ * @param handler - Event-specific handler
65
+ * @param opts - Ordering and cooperative timeout options
118
66
  */
119
67
  on(hookName, handler, opts) {
120
- if (!this._hooks.has(hookName)) {
121
- this._hooks.set(hookName, []);
68
+ const dualPhase = hookName === 'before_tool_call' || hookName === 'before_iteration';
69
+ if (dualPhase !== (opts?.phase !== undefined)) {
70
+ throw new Error(`Plugin "${this.id}" must ${dualPhase ? 'declare' : 'omit'} phase for hook "${hookName}"`);
71
+ }
72
+ if (opts?.priority !== undefined && !Number.isFinite(opts.priority)) {
73
+ throw new Error(`Plugin "${this.id}" registered invalid hook priority`);
122
74
  }
123
- const entries = this._hooks.get(hookName);
124
- entries.push({
75
+ if (opts?.timeoutMs !== undefined && (!Number.isFinite(opts.timeoutMs) || opts.timeoutMs <= 0)) {
76
+ throw new Error(`Plugin "${this.id}" registered invalid hook timeout`);
77
+ }
78
+ const entry = {
125
79
  pluginId: this.id,
126
80
  hookName,
127
81
  handler: handler,
82
+ phase: opts?.phase ?? 'single',
128
83
  priority: opts?.priority ?? 0,
129
- timeoutMs: opts?.timeoutMs,
130
- });
131
- // 保持按 priority 降序排列
84
+ ...(opts?.timeoutMs === undefined ? {} : { timeoutMs: opts.timeoutMs }),
85
+ };
86
+ const entries = [...(readStaging(this).hooks.get(hookName) ?? []), entry];
132
87
  entries.sort((a, b) => b.priority - a.priority);
88
+ readStaging(this).hooks.set(hookName, entries);
133
89
  }
134
- /**
135
- * 注册 Command
136
- *
137
- * Command 绕过 LLM,直接执行。
138
- *
139
- * @param def - Command 定义
140
- */
141
- registerCommand(def) {
142
- this._commands.push(def);
143
- this.logger.info(`Registered command: ${def.name}`);
90
+ /** Register a parameter Transform or admission Vote for before_tool_call. */
91
+ onBeforeToolCall(phase, handler, opts) {
92
+ this.on('before_tool_call', handler, { ...opts, phase });
144
93
  }
145
- /**
146
- * 注册后台服务
147
- *
148
- * 服务在 Gateway 启动时 start,关闭时 stop。
149
- *
150
- * @param service - 服务定义
151
- */
152
- registerService(service) {
153
- this._services.push(service);
154
- this.logger.info(`Registered service: ${service.id}`);
94
+ /** Register a controlled Iteration Transform or admission Vote. */
95
+ onBeforeIteration(phase, handler, opts) {
96
+ this.on('before_iteration', handler, { ...opts, phase });
155
97
  }
156
- // ================================================================
157
- // Extended Registration
158
- // ================================================================
159
- /** 已注册的 web search providers */
160
- _webSearchProviders = [];
161
- /** 已注册的 media understanding providers */
162
- _mediaUnderstandingProviders = [];
163
- /** 已注册的 image generation providers */
164
- _imageGenerationProviders = [];
165
- /** 已注册的 music generation providers */
166
- _musicGenerationProviders = [];
167
- /** 已注册的 video generation providers */
168
- _videoGenerationProviders = [];
169
- /** 已注册的 speech providers */
170
- _speechProviders = [];
171
- /** 已注册的 model catalog providers */
172
- _modelCatalogProviders = [];
173
- /** 已注册的 memory embedding providers */
174
- _memoryEmbeddingProviders = [];
175
- /**
176
- * 注册 Web Search Provider
177
- *
178
- * @param provider - 实现 WebSearchProvider 契约的实例
179
- */
180
- registerWebSearchProvider(provider) {
181
- const id = provider.id || this.getProviderId(provider);
182
- this._webSearchProviders.push({ id, provider });
183
- this.logger.info(`Registered web search provider: ${id}`);
184
- }
185
- /**
186
- * 注册 Media Understanding Provider
187
- */
188
- registerMediaUnderstandingProvider(provider) {
189
- const id = this.getProviderId(provider);
190
- this._mediaUnderstandingProviders.push({ id, provider });
191
- this.logger.info(`Registered media understanding provider: ${id}`);
192
- }
193
- /**
194
- * 注册 Image Generation Provider
195
- */
196
- registerImageGenerationProvider(provider) {
197
- const id = this.getProviderId(provider);
198
- this._imageGenerationProviders.push({ id, provider });
199
- this.logger.info(`Registered image generation provider: ${id}`);
200
- }
201
- /**
202
- * 注册 Music Generation Provider
203
- */
204
- registerMusicGenerationProvider(provider) {
205
- const id = this.getProviderId(provider);
206
- this._musicGenerationProviders.push({ id, provider });
207
- this.logger.info(`Registered music generation provider: ${id}`);
208
- }
209
- /**
210
- * 注册 Video Generation Provider
211
- */
212
- registerVideoGenerationProvider(provider) {
213
- const id = this.getProviderId(provider);
214
- this._videoGenerationProviders.push({ id, provider });
215
- this.logger.info(`Registered video generation provider: ${id}`);
216
- }
217
- /**
218
- * 注册 Speech Provider
219
- */
220
- registerSpeechProvider(provider) {
221
- const id = this.getProviderId(provider);
222
- this._speechProviders.push({ id, provider });
223
- this.logger.info(`Registered speech provider: ${id}`);
224
- }
225
- /**
226
- * 注册 Model Catalog Provider
227
- */
228
- registerModelCatalogProvider(catalog) {
229
- this._modelCatalogProviders.push(catalog);
230
- this.logger.info(`Registered model catalog: ${catalog.provider} (${catalog.kinds.join(', ')})`);
231
- }
232
- /**
233
- * 注册 Memory Embedding Provider
234
- */
235
- registerMemoryEmbeddingProvider(provider) {
236
- const id = this.getProviderId(provider);
237
- this._memoryEmbeddingProviders.push({ id, provider });
238
- this.logger.info(`Registered memory embedding provider: ${id}`);
98
+ /** Stage a Host-owned background service; start/stop is driven by Gateway. */
99
+ registerService(registration) {
100
+ if (!registration.serviceId.trim() || readStaging(this).services.some((item) => item.serviceId === registration.serviceId)) {
101
+ throw new Error(`Plugin "${this.id}" registered an empty or duplicate service id`);
102
+ }
103
+ if (registration.timeoutMs !== undefined && (!Number.isFinite(registration.timeoutMs) || registration.timeoutMs <= 0)) {
104
+ throw new Error(`Plugin "${this.id}" registered an invalid service timeout`);
105
+ }
106
+ readStaging(this).services.push({ ...registration });
239
107
  }
240
- // ================================================================
241
- // Utility
242
- // ================================================================
243
108
  /**
244
- * 从 provider 对象提取 id(兼容多种命名)
245
- */
246
- getProviderId(provider) {
247
- if (provider && typeof provider === 'object') {
248
- const p = provider;
249
- return (p.id ?? p.name ?? 'unknown');
109
+ * Stage a Command contribution. Host authorization is enforced when mounted.
110
+ *
111
+ * @param definition - Command metadata and handler
112
+ */
113
+ registerCommand(definition) {
114
+ const name = normalizeCommandName(definition.name);
115
+ if (!name)
116
+ throw new Error(`Plugin "${this.id}" registered invalid command name`);
117
+ if (definition.kind !== undefined && definition.kind !== 'control' && definition.kind !== 'prompt') {
118
+ throw new Error(`Plugin "${this.id}" registered unsupported kind for command "${name}"`);
119
+ }
120
+ if (definition.invocableBy && (definition.invocableBy.length === 0 ||
121
+ new Set(definition.invocableBy).size !== definition.invocableBy.length ||
122
+ definition.invocableBy.some((invoker) => !COMMAND_INVOKERS.includes(invoker)))) {
123
+ throw new Error(`Plugin "${this.id}" registered invalid invocableBy for command "${name}"`);
124
+ }
125
+ if (readStaging(this).commands.some((entry) => entry.name === name)) {
126
+ throw new Error(`Plugin "${this.id}" registered duplicate command "${definition.name}"`);
250
127
  }
251
- return 'unknown';
128
+ readStaging(this).commands.push({ ...definition, name });
252
129
  }
253
130
  /**
254
- * 解析相对于 plugin root 的路径
131
+ * Resolve a path relative to the plugin root in ESM.
255
132
  *
256
- * @param input - 相对路径
257
- * @returns 绝对路径
133
+ * @param input - Relative or absolute path
134
+ * @returns Absolute path; not a filesystem security boundary
258
135
  */
259
136
  resolvePath(input) {
260
- if (!this.rootDir)
261
- return input;
262
- const path = require('node:path');
263
- return path.resolve(this.rootDir, input);
137
+ return resolve(this.rootDir, input);
264
138
  }
265
139
  }
@@ -0,0 +1,43 @@
1
+ /** Host-level effective contribution registry; per-Agent buses are mount projections. */
2
+ import type { PluginManifest } from './manifest.js';
3
+ import type { HookServiceRegistration } from '../hooks/types.js';
4
+ export interface PluginServiceRecord extends HookServiceRegistration {
5
+ pluginId: string;
6
+ }
7
+ import type { PluginApi } from './api.js';
8
+ import type { PluginCommandRegistration, PluginToolContribution, OrderedHookEntry } from './api.js';
9
+ export interface RegisteredPlugin {
10
+ manifest: PluginManifest;
11
+ definition: {
12
+ id: string;
13
+ register(api: PluginApi): void | Promise<void>;
14
+ };
15
+ api: PluginApi;
16
+ path: string;
17
+ }
18
+ export interface PluginToolRecord extends PluginToolContribution {
19
+ pluginId: string;
20
+ }
21
+ export interface PluginCommandRecord extends PluginCommandRegistration {
22
+ pluginId: string;
23
+ }
24
+ /** An immutable published contribution set. Mutations are staged by PluginLoader. */
25
+ export declare class PluginContributionRegistry {
26
+ private plugins;
27
+ private tools;
28
+ private commands;
29
+ private hooks;
30
+ private services;
31
+ private owners;
32
+ /** Replace the effective set only after all staged registrations validate. */
33
+ publish(plugins: readonly RegisteredPlugin[]): void;
34
+ /** Clear the effective set before a fresh discovery attempt. */
35
+ clear(): void;
36
+ private addOwner;
37
+ getPlugins(): RegisteredPlugin[];
38
+ getPlugin(id: string): RegisteredPlugin | undefined;
39
+ getTools(): PluginToolRecord[];
40
+ getCommands(): PluginCommandRecord[];
41
+ getHooks(): OrderedHookEntry[];
42
+ getServices(): PluginServiceRecord[];
43
+ }
@@ -0,0 +1,61 @@
1
+ /** Host-level effective contribution registry; per-Agent buses are mount projections. */
2
+ import { readStaging } from './staging.js';
3
+ /** An immutable published contribution set. Mutations are staged by PluginLoader. */
4
+ export class PluginContributionRegistry {
5
+ plugins = new Map();
6
+ tools = [];
7
+ commands = [];
8
+ hooks = [];
9
+ services = [];
10
+ owners = new Map();
11
+ /** Replace the effective set only after all staged registrations validate. */
12
+ publish(plugins) {
13
+ const next = new PluginContributionRegistry();
14
+ for (const plugin of plugins) {
15
+ next.plugins.set(plugin.manifest.id, plugin);
16
+ const staged = readStaging(plugin.api);
17
+ for (const tool of staged.tools) {
18
+ next.addOwner('tool', tool.definition.name, plugin.manifest.id);
19
+ next.tools.push({ pluginId: plugin.manifest.id, ...tool });
20
+ }
21
+ for (const command of staged.commands) {
22
+ next.addOwner('command', command.name, plugin.manifest.id);
23
+ next.commands.push({ pluginId: plugin.manifest.id, ...command });
24
+ }
25
+ for (const entries of staged.hooks.values())
26
+ next.hooks.push(...entries);
27
+ for (const service of staged.services) {
28
+ next.addOwner('service', service.serviceId, plugin.manifest.id);
29
+ next.services.push({ pluginId: plugin.manifest.id, ...service });
30
+ }
31
+ }
32
+ const replyOwners = next.hooks.filter((entry) => entry.hookName === 'before_agent_reply');
33
+ if (replyOwners.length > 1) {
34
+ throw new Error(`Override hook before_agent_reply has multiple owners: ${replyOwners.map((entry) => entry.pluginId).join(', ')}`);
35
+ }
36
+ this.plugins = next.plugins;
37
+ this.tools = next.tools;
38
+ this.commands = next.commands;
39
+ this.hooks = next.hooks;
40
+ this.services = next.services;
41
+ this.owners = next.owners;
42
+ }
43
+ /** Clear the effective set before a fresh discovery attempt. */
44
+ clear() {
45
+ this.publish([]);
46
+ }
47
+ addOwner(type, id, pluginId) {
48
+ const key = `${type}:${id}`;
49
+ const owner = this.owners.get(key);
50
+ if (owner !== undefined) {
51
+ throw new Error(`Contribution conflict ${key}: "${owner}" and "${pluginId}"`);
52
+ }
53
+ this.owners.set(key, pluginId);
54
+ }
55
+ getPlugins() { return [...this.plugins.values()]; }
56
+ getPlugin(id) { return this.plugins.get(id); }
57
+ getTools() { return [...this.tools]; }
58
+ getCommands() { return [...this.commands]; }
59
+ getHooks() { return [...this.hooks]; }
60
+ getServices() { return [...this.services]; }
61
+ }
@@ -0,0 +1,4 @@
1
+ /** Read the installed engine package version through its public package export. */
2
+ export declare function getEngineVersion(): string;
3
+ /** Return whether the installed engine satisfies a manifest's semver range. */
4
+ export declare function satisfiesEngineRange(version: string, range: string): boolean;
@@ -0,0 +1,18 @@
1
+ import { createRequire } from 'node:module';
2
+ import semver from 'semver';
3
+ let cachedVersion;
4
+ /** Read the installed engine package version through its public package export. */
5
+ export function getEngineVersion() {
6
+ if (cachedVersion === undefined) {
7
+ const require = createRequire(import.meta.url);
8
+ const metadata = require('@octopi-agent/engine/package.json');
9
+ cachedVersion = metadata.version;
10
+ }
11
+ return cachedVersion;
12
+ }
13
+ /** Return whether the installed engine satisfies a manifest's semver range. */
14
+ export function satisfiesEngineRange(version, range) {
15
+ if (!semver.valid(version) || !semver.validRange(range))
16
+ return false;
17
+ return semver.satisfies(version, range);
18
+ }
@@ -1,93 +1,15 @@
1
- /**
2
- * Plugin Entry
3
- *
4
- * definePluginEntry 是创建 plugin 的标准方式。
5
- * 它定义了 plugin 的 id、name、register 回调等。
6
- */
1
+ /** Plugin entry contract. Installation metadata lives in octopi.plugin.json. */
7
2
  import type { PluginApi } from './api.js';
8
- /**
9
- * Plugin 定义
10
- *
11
- * 这是 plugin 的完整定义。每个 plugin 必须导出一个 default export,
12
- * 使用 definePluginEntry() 创建。
13
- *
14
- * @example
15
- * ```ts
16
- * export default definePluginEntry({
17
- * id: 'my-plugin',
18
- * name: 'My Plugin',
19
- * description: 'Adds custom capabilities',
20
- * register(api) {
21
- * api.on('before_tool_call', async (event) => {
22
- * // hook logic
23
- * });
24
- *
25
- * api.registerTool(
26
- * { name: 'my_tool', description: '...', parameters: {} },
27
- * async (args, ctx) => { return 'result'; },
28
- * );
29
- * },
30
- * });
31
- * ```
32
- */
33
3
  export interface OctopiPluginDefinition {
34
- /** Plugin 唯一 ID */
4
+ /** Must match the manifest identity. */
35
5
  id: string;
36
- /** Plugin 显示名称 */
37
- name: string;
38
- /** Plugin 描述 */
39
- description?: string;
40
- /** Plugin 版本 */
41
- version?: string;
42
- /**
43
- * 注册回调
44
- *
45
- * 框架在加载 plugin 时调用此方法,传入 PluginApi 对象。
46
- * Plugin 通过 api 对象注册各种能力。
47
- *
48
- * @param api - Plugin API 对象
49
- */
6
+ /** Declaration-only registration; external resources start at a host lifecycle point. */
50
7
  register(api: PluginApi): void | Promise<void>;
51
8
  }
52
9
  /**
53
- * 定义一个 Plugin Entry
54
- *
55
- * 这是创建 plugin 的标准方式。
56
- *
57
- * @param definition - Plugin 定义
58
- * @returns Plugin 定义对象
59
- *
60
- * @example
61
- * ```ts
62
- * // index.ts
63
- * import { definePluginEntry } from '@octopi-agent/engine/plugin-sdk/plugin-entry';
64
- *
65
- * export default definePluginEntry({
66
- * id: 'tool-preflight',
67
- * name: 'Tool Preflight',
68
- * register(api) {
69
- * api.on('before_tool_call', async (event) => {
70
- * if (event.toolName !== 'web_search') return;
71
- * return { requireApproval: { title: 'Run web search' } };
72
- * }, { priority: 50 });
73
- * },
74
- * });
75
- * ```
76
- */
77
- export declare function definePluginEntry(definition: OctopiPluginDefinition): OctopiPluginDefinition;
78
- /**
79
- * Channel Plugin 定义
80
- *
81
- * 用于 channel 类型的 plugin。
82
- */
83
- export interface OctopiChannelPluginDefinition extends OctopiPluginDefinition {
84
- /** Channel ID */
85
- channelId: string;
86
- }
87
- /**
88
- * 定义一个 Channel Plugin Entry
10
+ * Define a v1 plugin entry without duplicating its manifest.
89
11
  *
90
- * @param definition - Channel Plugin 定义
91
- * @returns Plugin 定义对象
12
+ * @param definition - Entry identity and registration function
13
+ * @returns The validated definition
92
14
  */
93
- export declare function defineChannelPluginEntry(definition: OctopiChannelPluginDefinition): OctopiChannelPluginDefinition;
15
+ export declare function definePlugin(definition: OctopiPluginDefinition): OctopiPluginDefinition;
@@ -1,58 +1,16 @@
1
+ /** Plugin entry contract. Installation metadata lives in octopi.plugin.json. */
1
2
  /**
2
- * Plugin Entry
3
+ * Define a v1 plugin entry without duplicating its manifest.
3
4
  *
4
- * definePluginEntry 是创建 plugin 的标准方式。
5
- * 它定义了 plugin 的 id、name、register 回调等。
5
+ * @param definition - Entry identity and registration function
6
+ * @returns The validated definition
6
7
  */
7
- /**
8
- * 定义一个 Plugin Entry
9
- *
10
- * 这是创建 plugin 的标准方式。
11
- *
12
- * @param definition - Plugin 定义
13
- * @returns Plugin 定义对象
14
- *
15
- * @example
16
- * ```ts
17
- * // index.ts
18
- * import { definePluginEntry } from '@octopi-agent/engine/plugin-sdk/plugin-entry';
19
- *
20
- * export default definePluginEntry({
21
- * id: 'tool-preflight',
22
- * name: 'Tool Preflight',
23
- * register(api) {
24
- * api.on('before_tool_call', async (event) => {
25
- * if (event.toolName !== 'web_search') return;
26
- * return { requireApproval: { title: 'Run web search' } };
27
- * }, { priority: 50 });
28
- * },
29
- * });
30
- * ```
31
- */
32
- export function definePluginEntry(definition) {
33
- // 验证必填字段
34
- if (!definition.id || typeof definition.id !== 'string') {
35
- throw new Error('definePluginEntry: "id" is required and must be a string');
36
- }
37
- if (!definition.name || typeof definition.name !== 'string') {
38
- throw new Error('definePluginEntry: "name" is required and must be a string');
8
+ export function definePlugin(definition) {
9
+ if (typeof definition.id !== 'string' || definition.id.length === 0) {
10
+ throw new Error('definePlugin: "id" is required and must be a string');
39
11
  }
40
12
  if (typeof definition.register !== 'function') {
41
- throw new Error(`definePluginEntry: "register" is required and must be a function (plugin: ${definition.id})`);
42
- }
43
- return definition;
44
- }
45
- /**
46
- * 定义一个 Channel Plugin Entry
47
- *
48
- * @param definition - Channel Plugin 定义
49
- * @returns Plugin 定义对象
50
- */
51
- export function defineChannelPluginEntry(definition) {
52
- if (!definition.channelId) {
53
- throw new Error(`defineChannelPluginEntry: "channelId" is required (plugin: ${definition.id})`);
13
+ throw new Error(`definePlugin: "register" must be a function (plugin: ${definition.id})`);
54
14
  }
55
- // 基础验证
56
- definePluginEntry(definition);
57
15
  return definition;
58
16
  }