@octopi-agent/engine 0.70.7 → 0.86.38

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 (362) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +7 -7
  3. package/README.md +64 -26
  4. package/dist/config-schema/agent.d.ts +89 -1
  5. package/dist/config-schema/agent.js +69 -0
  6. package/dist/config-schema/context.d.ts +23 -4
  7. package/dist/config-schema/context.js +28 -1
  8. package/dist/config-schema/engine.d.ts +201 -9
  9. package/dist/config-schema/engine.js +31 -2
  10. package/dist/config-schema/governance.d.ts +95 -0
  11. package/dist/config-schema/governance.js +91 -0
  12. package/dist/config-schema/models.d.ts +1 -1
  13. package/dist/config-schema/observability.d.ts +6 -0
  14. package/dist/config-schema/observability.js +16 -0
  15. package/dist/config-schema/run.d.ts +10 -0
  16. package/dist/config-schema/run.js +18 -0
  17. package/dist/config-schema/shared.d.ts +10 -0
  18. package/dist/config-schema/shared.js +10 -0
  19. package/dist/config-schema/substrate.d.ts +1 -1
  20. package/dist/config-schema/subsystems.d.ts +1 -1
  21. package/dist/config-schema/subsystems.js +2 -1
  22. package/dist/config.d.ts +178 -7
  23. package/dist/config.js +113 -3
  24. package/dist/harness/activation/compiler.js +3 -0
  25. package/dist/harness/activation/runtime.d.ts +7 -0
  26. package/dist/harness/activation/runtime.js +60 -2
  27. package/dist/harness/activation/sources/agent-signal.d.ts +11 -0
  28. package/dist/harness/activation/sources/agent-signal.js +33 -0
  29. package/dist/harness/activation/types.d.ts +6 -1
  30. package/dist/harness/agent/builder.d.ts +47 -3
  31. package/dist/harness/agent/builder.js +180 -54
  32. package/dist/harness/agent/config-bridge.d.ts +33 -25
  33. package/dist/harness/agent/config-bridge.js +81 -291
  34. package/dist/harness/agent/index.d.ts +3 -1
  35. package/dist/harness/agent/index.js +2 -1
  36. package/dist/harness/agent/tool-purpose.d.ts +38 -0
  37. package/dist/harness/agent/tool-purpose.js +118 -0
  38. package/dist/harness/agent/wire-agent-builder.d.ts +133 -0
  39. package/dist/harness/agent/wire-agent-builder.js +363 -0
  40. package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -1
  41. package/dist/harness/collaboration/autonomous-subsystem/runtime.js +14 -8
  42. package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.d.ts +12 -0
  43. package/dist/harness/collaboration/autonomous-subsystem/sense/metrics.js +19 -0
  44. package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.d.ts +6 -0
  45. package/dist/harness/collaboration/autonomous-subsystem/sense/session-lifecycle-bridge.js +24 -7
  46. package/dist/harness/collaboration/autonomous-subsystem/think/executor.d.ts +5 -2
  47. package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +11 -3
  48. package/dist/harness/collaboration/autonomous-subsystem/think/index.d.ts +1 -1
  49. package/dist/harness/collaboration/autonomous-subsystem/think/index.js +1 -1
  50. package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.d.ts +7 -4
  51. package/dist/harness/collaboration/autonomous-subsystem/think/llm-port.js +8 -9
  52. package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.d.ts +36 -10
  53. package/dist/harness/collaboration/autonomous-subsystem/think/model-resolver.js +60 -7
  54. package/dist/harness/collaboration/delegation/child-run.d.ts +144 -0
  55. package/dist/harness/collaboration/delegation/child-run.js +241 -0
  56. package/dist/harness/collaboration/delegation/index.d.ts +26 -0
  57. package/dist/harness/collaboration/delegation/index.js +25 -0
  58. package/dist/harness/collaboration/delegation/notifier.d.ts +46 -0
  59. package/dist/harness/collaboration/delegation/notifier.js +84 -0
  60. package/dist/harness/collaboration/delegation/registry-types.d.ts +200 -0
  61. package/dist/harness/collaboration/delegation/registry-types.js +61 -0
  62. package/dist/harness/collaboration/delegation/registry.d.ts +110 -0
  63. package/dist/harness/collaboration/delegation/registry.js +220 -0
  64. package/dist/harness/collaboration/delegation/service.d.ts +249 -0
  65. package/dist/harness/collaboration/delegation/service.js +499 -0
  66. package/dist/harness/collaboration/delegation/store.d.ts +155 -0
  67. package/dist/harness/collaboration/delegation/store.js +271 -0
  68. package/dist/harness/collaboration/delegation/transport.d.ts +73 -0
  69. package/dist/harness/collaboration/delegation/transport.js +61 -0
  70. package/dist/harness/collaboration/delegation/types.d.ts +231 -0
  71. package/dist/harness/collaboration/delegation/types.js +70 -0
  72. package/dist/harness/collaboration/delegation/wiring.d.ts +111 -0
  73. package/dist/harness/collaboration/delegation/wiring.js +145 -0
  74. package/dist/harness/collaboration/orchestration/index.d.ts +11 -13
  75. package/dist/harness/collaboration/orchestration/index.js +11 -11
  76. package/dist/harness/context/assembler.d.ts +2 -2
  77. package/dist/harness/context/assembler.js +12 -7
  78. package/dist/harness/context/capabilities/compact/engine.js +80 -38
  79. package/dist/harness/context/capabilities/compact/types.d.ts +12 -1
  80. package/dist/harness/context/capabilities/summary/registry.js +10 -0
  81. package/dist/harness/context/constitution/default-agents.md +230 -228
  82. package/dist/harness/context/default-context-engine.d.ts +101 -23
  83. package/dist/harness/context/default-context-engine.js +483 -172
  84. package/dist/harness/context/hybrid-compressor.d.ts +3 -3
  85. package/dist/harness/context/hybrid-compressor.js +18 -23
  86. package/dist/harness/context/index.d.ts +5 -1
  87. package/dist/harness/context/index.js +2 -0
  88. package/dist/harness/context/layer-snapshot.d.ts +4 -0
  89. package/dist/harness/context/layer-snapshot.js +30 -18
  90. package/dist/harness/context/layer-types.d.ts +49 -1
  91. package/dist/harness/context/layer-types.js +72 -4
  92. package/dist/harness/context/layers.d.ts +5 -2
  93. package/dist/harness/context/layers.js +11 -5
  94. package/dist/harness/context/llm-summarizer.d.ts +15 -1
  95. package/dist/harness/context/llm-summarizer.js +107 -56
  96. package/dist/harness/context/message-selector.js +6 -2
  97. package/dist/harness/context/root-instructions.d.ts +72 -0
  98. package/dist/harness/context/root-instructions.js +227 -0
  99. package/dist/harness/context/runtime-datetime.d.ts +34 -7
  100. package/dist/harness/context/runtime-datetime.js +66 -10
  101. package/dist/harness/context/smart-router.d.ts +1 -1
  102. package/dist/harness/context/smart-router.js +1 -1
  103. package/dist/harness/context/system-prompt-assembler.d.ts +30 -0
  104. package/dist/harness/context/system-prompt-assembler.js +67 -6
  105. package/dist/harness/context/token-constants.d.ts +2 -2
  106. package/dist/harness/context/token-constants.js +2 -2
  107. package/dist/harness/context/token-estimate-fns.d.ts +1 -3
  108. package/dist/harness/context/token-estimate-fns.js +2 -4
  109. package/dist/harness/context/token-estimator.d.ts +1 -1
  110. package/dist/harness/context/token-estimator.js +14 -6
  111. package/dist/harness/context/tool-result-aging.d.ts +140 -0
  112. package/dist/harness/context/tool-result-aging.js +331 -0
  113. package/dist/harness/context/tool-result-body.d.ts +10 -0
  114. package/dist/harness/context/tool-result-body.js +27 -0
  115. package/dist/harness/context/turn-envelope.d.ts +123 -0
  116. package/dist/harness/context/turn-envelope.js +188 -0
  117. package/dist/harness/context/types.d.ts +35 -47
  118. package/dist/harness/extension/execution-environment/effect-policy.d.ts +248 -0
  119. package/dist/harness/extension/execution-environment/effect-policy.js +334 -0
  120. package/dist/harness/extension/execution-environment/index.d.ts +18 -2
  121. package/dist/harness/extension/execution-environment/index.js +11 -2
  122. package/dist/harness/extension/execution-environment/memory-undo.d.ts +101 -0
  123. package/dist/harness/extension/execution-environment/memory-undo.js +192 -0
  124. package/dist/harness/extension/execution-environment/process-isolation.d.ts +84 -0
  125. package/dist/harness/extension/execution-environment/process-isolation.js +315 -0
  126. package/dist/harness/extension/execution-environment/resource-limits.d.ts +36 -0
  127. package/dist/harness/extension/execution-environment/resource-limits.js +84 -0
  128. package/dist/harness/extension/execution-environment/sandbox.d.ts +125 -4
  129. package/dist/harness/extension/execution-environment/sandbox.js +493 -51
  130. package/dist/harness/extension/execution-environment/shell-journal.d.ts +100 -0
  131. package/dist/harness/extension/execution-environment/shell-journal.js +299 -0
  132. package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +45 -0
  133. package/dist/harness/extension/execution-environment/tool-capabilities.js +126 -0
  134. package/dist/harness/extension/execution-environment/types.d.ts +67 -39
  135. package/dist/harness/extension/execution-environment/types.js +2 -2
  136. package/dist/harness/extension/execution-environment/undo-log.d.ts +203 -0
  137. package/dist/harness/extension/execution-environment/undo-log.js +627 -0
  138. package/dist/harness/extension/execution-environment/undo-merge.d.ts +40 -0
  139. package/dist/harness/extension/execution-environment/undo-merge.js +167 -0
  140. package/dist/harness/extension/plugin-ecosystem/client-tools/index.d.ts +1 -1
  141. package/dist/harness/extension/plugin-ecosystem/client-tools/types.d.ts +9 -0
  142. package/dist/harness/extension/plugin-ecosystem/mcp/bridge.js +2 -0
  143. package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +1 -6
  144. package/dist/harness/extension/plugin-ecosystem/plugins/api.js +3 -8
  145. package/dist/harness/extension/plugin-ecosystem/plugins/capability.d.ts +0 -3
  146. package/dist/harness/extension/plugin-ecosystem/plugins/capability.js +0 -3
  147. package/dist/harness/extension/plugin-ecosystem/plugins/entry.d.ts +2 -10
  148. package/dist/harness/extension/plugin-ecosystem/plugins/entry.js +2 -9
  149. package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -3
  150. package/dist/harness/extension/plugin-ecosystem/plugins/index.js +1 -3
  151. package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +2 -4
  152. package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +4 -21
  153. package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +3 -9
  154. package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +4 -8
  155. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +1 -4
  156. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +1 -3
  157. package/dist/harness/extension/plugin-ecosystem/skills/manager.d.ts +1 -1
  158. package/dist/harness/extension/plugin-ecosystem/skills/manager.js +1 -1
  159. package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +45 -0
  160. package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +136 -0
  161. package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +1 -0
  162. package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +18 -3
  163. package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +277 -81
  164. package/dist/harness/extension/plugin-ecosystem/tools/delegation.d.ts +31 -0
  165. package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +291 -0
  166. package/dist/harness/extension/plugin-ecosystem/tools/document-tools.js +10 -2
  167. package/dist/harness/extension/plugin-ecosystem/tools/env-info.js +1 -0
  168. package/dist/harness/extension/plugin-ecosystem/tools/eol.d.ts +35 -0
  169. package/dist/harness/extension/plugin-ecosystem/tools/eol.js +43 -0
  170. package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +40 -9
  171. package/dist/harness/extension/plugin-ecosystem/tools/file-ops.d.ts +33 -0
  172. package/dist/harness/extension/plugin-ecosystem/tools/file-ops.js +376 -0
  173. package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +12 -2
  174. package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +239 -61
  175. package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +27 -0
  176. package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +554 -0
  177. package/dist/harness/extension/plugin-ecosystem/tools/http.d.ts +10 -6
  178. package/dist/harness/extension/plugin-ecosystem/tools/http.js +41 -47
  179. package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +2 -0
  180. package/dist/harness/extension/plugin-ecosystem/tools/index.js +2 -0
  181. package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +4 -0
  182. package/dist/harness/extension/plugin-ecosystem/tools/memory.js +25 -1
  183. package/dist/harness/extension/plugin-ecosystem/tools/package-tools.d.ts +13 -0
  184. package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +391 -0
  185. package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +51 -2
  186. package/dist/harness/extension/plugin-ecosystem/tools/platform.js +151 -12
  187. package/dist/harness/extension/plugin-ecosystem/tools/session-history.js +2 -0
  188. package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.d.ts +10 -1
  189. package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +35 -19
  190. package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +8 -0
  191. package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +5 -0
  192. package/dist/harness/extension/plugin-ecosystem/tools/web-search.js +1 -0
  193. package/dist/harness/governance/credentials/index.d.ts +1 -1
  194. package/dist/harness/governance/credentials/store.d.ts +16 -4
  195. package/dist/harness/governance/credentials/store.js +33 -6
  196. package/dist/harness/governance/credentials/types.d.ts +11 -0
  197. package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +105 -0
  198. package/dist/harness/governance/human-in-the-loop/decision-cache.js +184 -0
  199. package/dist/harness/governance/human-in-the-loop/index.d.ts +5 -5
  200. package/dist/harness/governance/human-in-the-loop/index.js +3 -3
  201. package/dist/harness/governance/human-in-the-loop/types.d.ts +7 -62
  202. package/dist/harness/governance/human-in-the-loop/types.js +6 -2
  203. package/dist/harness/governance/security/capability-enforcer.d.ts +9 -1
  204. package/dist/harness/governance/security/capability-enforcer.js +31 -8
  205. package/dist/harness/governance/security/degradation.js +5 -7
  206. package/dist/harness/governance/security/risk-evaluator.d.ts +1 -1
  207. package/dist/harness/governance/security/risk-evaluator.js +4 -82
  208. package/dist/harness/governance/security/temp-path.d.ts +41 -0
  209. package/dist/harness/governance/security/temp-path.js +117 -0
  210. package/dist/harness/governance/session-acl/index.d.ts +1 -0
  211. package/dist/harness/governance/session-acl/index.js +1 -0
  212. package/dist/harness/governance/session-acl/rights.d.ts +12 -0
  213. package/dist/harness/governance/session-acl/rights.js +89 -7
  214. package/dist/harness/governance/session-acl/seed-roles.js +9 -1
  215. package/dist/harness/governance/session-acl/service.js +21 -29
  216. package/dist/harness/governance/session-acl/tool-rights.d.ts +81 -0
  217. package/dist/harness/governance/session-acl/tool-rights.js +238 -0
  218. package/dist/harness/governance/session-acl/types.d.ts +22 -0
  219. package/dist/harness/index.d.ts +14 -12
  220. package/dist/harness/index.js +9 -6
  221. package/dist/harness/knowledge/file-index-store.js +11 -11
  222. package/dist/harness/knowledge/grounding.d.ts +2 -1
  223. package/dist/harness/knowledge/grounding.js +6 -3
  224. package/dist/harness/knowledge/index.d.ts +2 -2
  225. package/dist/harness/knowledge/index.js +1 -1
  226. package/dist/harness/knowledge/ingest.js +4 -1
  227. package/dist/harness/knowledge/job-control-state.js +4 -4
  228. package/dist/harness/knowledge/job-control.js +11 -11
  229. package/dist/harness/knowledge/membership-store.js +11 -11
  230. package/dist/harness/knowledge/network-guard.d.ts +61 -4
  231. package/dist/harness/knowledge/network-guard.js +390 -113
  232. package/dist/harness/knowledge/query-service.js +3 -3
  233. package/dist/harness/knowledge/writer-service.d.ts +2 -0
  234. package/dist/harness/knowledge/writer-service.js +14 -13
  235. package/dist/harness/memory/backfill-trigger.d.ts +2 -2
  236. package/dist/harness/memory/backfill-trigger.js +4 -4
  237. package/dist/harness/memory/index.d.ts +1 -0
  238. package/dist/harness/memory/index.js +1 -0
  239. package/dist/harness/memory/sqlite/agent-db.js +2 -0
  240. package/dist/harness/memory/sqlite/memory-store.d.ts +1 -0
  241. package/dist/harness/memory/sqlite/memory-store.js +14 -4
  242. package/dist/harness/memory/sqlite/wisdom-store.js +9 -9
  243. package/dist/harness/memory/store.d.ts +1 -0
  244. package/dist/harness/memory/store.js +3 -0
  245. package/dist/harness/memory/time-format.d.ts +28 -0
  246. package/dist/harness/memory/time-format.js +52 -0
  247. package/dist/harness/memory/types.d.ts +12 -0
  248. package/dist/harness/observability/observer/hub.js +23 -1
  249. package/dist/harness/observability/observer/index.d.ts +2 -2
  250. package/dist/harness/observability/observer/index.js +1 -1
  251. package/dist/harness/observability/observer/types.d.ts +57 -0
  252. package/dist/harness/observability/observer/types.js +118 -9
  253. package/dist/harness/run/agent/agent.d.ts +18 -0
  254. package/dist/harness/run/agent/agent.js +26 -0
  255. package/dist/harness/run/concurrency/tool-loop-detection-core.d.ts +1 -1
  256. package/dist/harness/run/concurrency/tool-loop-detection-core.js +1 -1
  257. package/dist/harness/run/reliability/harness-events.d.ts +4 -0
  258. package/dist/harness/run/reliability/run-agent.js +110 -18
  259. package/dist/harness/run/reliability/run-metrics-collector.d.ts +28 -2
  260. package/dist/harness/run/reliability/run-metrics-collector.js +92 -2
  261. package/dist/harness/run/run-guard/default-run-guard.d.ts +0 -5
  262. package/dist/harness/run/run-guard/default-run-guard.js +104 -44
  263. package/dist/harness/run/run-scope.d.ts +52 -0
  264. package/dist/harness/run/runner.d.ts +101 -16
  265. package/dist/harness/run/runner.js +556 -158
  266. package/dist/harness/session/attachments/llm-intent.js +17 -17
  267. package/dist/harness/session/history/port.js +1 -0
  268. package/dist/harness/session/in-memory-store.d.ts +1 -0
  269. package/dist/harness/session/in-memory-store.js +22 -1
  270. package/dist/harness/session/schedules/index.d.ts +10 -0
  271. package/dist/harness/session/schedules/index.js +10 -0
  272. package/dist/harness/session/schedules/render.d.ts +13 -0
  273. package/dist/harness/session/schedules/render.js +63 -0
  274. package/dist/harness/session/schedules/service.d.ts +179 -0
  275. package/dist/harness/session/schedules/service.js +695 -0
  276. package/dist/harness/session/schedules/store.d.ts +119 -0
  277. package/dist/harness/session/schedules/store.js +323 -0
  278. package/dist/harness/session/schedules/tools.d.ts +39 -0
  279. package/dist/harness/session/schedules/tools.js +442 -0
  280. package/dist/harness/session/schedules/types.d.ts +104 -0
  281. package/dist/harness/session/schedules/types.js +97 -0
  282. package/dist/harness/session/tasks/tools.js +22 -0
  283. package/dist/harness/session/types.d.ts +35 -0
  284. package/dist/harness/shared/events/agent-event-map.d.ts +13 -0
  285. package/dist/harness/shared/types/agent-definition.d.ts +23 -0
  286. package/dist/index.d.ts +23 -9
  287. package/dist/index.js +10 -2
  288. package/dist/integration/providers/anthropic.d.ts +10 -0
  289. package/dist/integration/providers/anthropic.js +44 -1
  290. package/dist/integration/providers/openai.d.ts +10 -0
  291. package/dist/integration/providers/openai.js +58 -2
  292. package/dist/integration/providers/wire-dump-diff.d.ts +191 -0
  293. package/dist/integration/providers/wire-dump-diff.js +351 -0
  294. package/dist/integration/providers/wire-dump.d.ts +178 -0
  295. package/dist/integration/providers/wire-dump.js +396 -0
  296. package/dist/integration/storage/jsonl.d.ts +11 -0
  297. package/dist/integration/storage/jsonl.js +148 -39
  298. package/dist/integration/storage/session-index.js +63 -8
  299. package/dist/subsystems/cognition-steward/conceptualize/SUBSYSTEM.md +43 -43
  300. package/dist/subsystems/cognition-steward/conceptualize/config.yaml +50 -50
  301. package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +6 -6
  302. package/dist/subsystems/cognition-steward/consolidate/config.yaml +54 -54
  303. package/dist/subsystems/memory-steward/backfill/handler.js +9 -0
  304. package/dist/subsystems/wisdom-steward/evaluate/config.yaml +50 -50
  305. package/dist/subsystems/wisdom-steward/formation/SUBSYSTEM.md +42 -42
  306. package/dist/subsystems/wisdom-steward/formation/config.yaml +54 -54
  307. package/dist/subsystems/wisdom-steward/govern/config.yaml +55 -55
  308. package/package.json +115 -115
  309. package/dist/harness/collaboration/multi-agent/agent-registry-types.d.ts +0 -144
  310. package/dist/harness/collaboration/multi-agent/agent-registry-types.js +0 -25
  311. package/dist/harness/collaboration/multi-agent/index.d.ts +0 -17
  312. package/dist/harness/collaboration/multi-agent/index.js +0 -15
  313. package/dist/harness/collaboration/multi-agent/process.d.ts +0 -167
  314. package/dist/harness/collaboration/multi-agent/process.js +0 -256
  315. package/dist/harness/collaboration/multi-agent/registry.d.ts +0 -36
  316. package/dist/harness/collaboration/multi-agent/registry.js +0 -137
  317. package/dist/harness/collaboration/multi-agent/swarm.d.ts +0 -135
  318. package/dist/harness/collaboration/multi-agent/swarm.js +0 -317
  319. package/dist/harness/collaboration/multi-agent/types.d.ts +0 -66
  320. package/dist/harness/collaboration/multi-agent/types.js +0 -15
  321. package/dist/harness/collaboration/orchestration/async-task-store.d.ts +0 -107
  322. package/dist/harness/collaboration/orchestration/async-task-store.js +0 -12
  323. package/dist/harness/collaboration/orchestration/async-task.d.ts +0 -156
  324. package/dist/harness/collaboration/orchestration/async-task.js +0 -359
  325. package/dist/harness/collaboration/orchestration/planner/hybrid-planner.d.ts +0 -47
  326. package/dist/harness/collaboration/orchestration/planner/hybrid-planner.js +0 -61
  327. package/dist/harness/collaboration/orchestration/planner/index.d.ts +0 -9
  328. package/dist/harness/collaboration/orchestration/planner/index.js +0 -6
  329. package/dist/harness/collaboration/orchestration/planner/llm-planner.d.ts +0 -54
  330. package/dist/harness/collaboration/orchestration/planner/llm-planner.js +0 -167
  331. package/dist/harness/collaboration/orchestration/planner/rule-planner.d.ts +0 -85
  332. package/dist/harness/collaboration/orchestration/planner/rule-planner.js +0 -175
  333. package/dist/harness/collaboration/orchestration/quality/classifier.d.ts +0 -21
  334. package/dist/harness/collaboration/orchestration/quality/classifier.js +0 -235
  335. package/dist/harness/collaboration/orchestration/quality/gate.d.ts +0 -29
  336. package/dist/harness/collaboration/orchestration/quality/gate.js +0 -409
  337. package/dist/harness/collaboration/orchestration/quality/index.d.ts +0 -9
  338. package/dist/harness/collaboration/orchestration/quality/index.js +0 -8
  339. package/dist/harness/collaboration/orchestration/quality/types.d.ts +0 -159
  340. package/dist/harness/collaboration/orchestration/quality/types.js +0 -33
  341. package/dist/harness/collaboration/orchestration/scheduler/index.d.ts +0 -5
  342. package/dist/harness/collaboration/orchestration/scheduler/index.js +0 -4
  343. package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.d.ts +0 -143
  344. package/dist/harness/collaboration/orchestration/scheduler/task-scheduler.js +0 -297
  345. package/dist/harness/collaboration/orchestration/strategy/classifier.d.ts +0 -12
  346. package/dist/harness/collaboration/orchestration/strategy/classifier.js +0 -81
  347. package/dist/harness/collaboration/orchestration/strategy/index.d.ts +0 -3
  348. package/dist/harness/collaboration/orchestration/strategy/index.js +0 -2
  349. package/dist/harness/collaboration/orchestration/strategy/router.d.ts +0 -28
  350. package/dist/harness/collaboration/orchestration/strategy/router.js +0 -105
  351. package/dist/harness/collaboration/orchestration/strategy/types.d.ts +0 -49
  352. package/dist/harness/collaboration/orchestration/strategy/types.js +0 -4
  353. package/dist/harness/collaboration/orchestration/workflow/engine.d.ts +0 -86
  354. package/dist/harness/collaboration/orchestration/workflow/engine.js +0 -298
  355. package/dist/harness/collaboration/orchestration/workflow/index.d.ts +0 -9
  356. package/dist/harness/collaboration/orchestration/workflow/index.js +0 -7
  357. package/dist/harness/collaboration/orchestration/workflow/types.d.ts +0 -143
  358. package/dist/harness/collaboration/orchestration/workflow/types.js +0 -7
  359. package/dist/harness/governance/human-in-the-loop/approval-manager.d.ts +0 -32
  360. package/dist/harness/governance/human-in-the-loop/approval-manager.js +0 -93
  361. /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.d.ts +0 -0
  362. /package/dist/harness/collaboration/{multi-agent → delegation}/message-channel-types.js +0 -0
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Turn 文件 undo 合并 — 补丁逆放(文本)/ 整文件策略(二进制)
3
+ *
4
+ * 逆放语义:把 agent 的 before→after 差分 **逆向** 打到 current 上,
5
+ * 只动仍与 after 对齐的行;用户改过/插入的行原样保留。
6
+ * 不做对称 diff3(会把「用户插行」误判成与「agent 改行」冲突)。
7
+ */
8
+ const isWin = process.platform === 'win32';
9
+ /** 是否可按文本处理 */
10
+ export function isProbablyText(buf) {
11
+ if (buf.includes(0))
12
+ return false;
13
+ try {
14
+ new TextDecoder('utf-8', { fatal: true }).decode(buf);
15
+ return true;
16
+ }
17
+ catch {
18
+ return false;
19
+ }
20
+ }
21
+ function splitLines(s) {
22
+ if (s === '')
23
+ return [];
24
+ return s.split('\n');
25
+ }
26
+ function joinLines(lines) {
27
+ return lines.join('\n');
28
+ }
29
+ function linesEqual(a, b) {
30
+ return a.length === b.length && a.every((x, i) => x === b[i]);
31
+ }
32
+ function lcsPairs(a, b) {
33
+ const n = a.length;
34
+ const m = b.length;
35
+ if (n === 0 || m === 0)
36
+ return [];
37
+ if (n * m > 4_000_000)
38
+ return [];
39
+ const dp = Array.from({ length: n + 1 }, () => new Int32Array(m + 1));
40
+ for (let i = n - 1; i >= 0; i--) {
41
+ for (let j = m - 1; j >= 0; j--) {
42
+ dp[i][j] = a[i] === b[j] ? dp[i + 1][j + 1] + 1 : Math.max(dp[i + 1][j], dp[i][j + 1]);
43
+ }
44
+ }
45
+ const pairs = [];
46
+ let i = 0;
47
+ let j = 0;
48
+ while (i < n && j < m) {
49
+ if (a[i] === b[j]) {
50
+ pairs.push([i, j]);
51
+ i++;
52
+ j++;
53
+ }
54
+ else if (dp[i + 1][j] >= dp[i][j + 1]) {
55
+ i++;
56
+ }
57
+ else {
58
+ j++;
59
+ }
60
+ }
61
+ return pairs;
62
+ }
63
+ /** after → before 的编辑块 */
64
+ function computeEdits(after, before) {
65
+ if (linesEqual(after, before))
66
+ return [];
67
+ const pairs = lcsPairs(after, before);
68
+ const edits = [];
69
+ let ai = 0;
70
+ let bi = 0;
71
+ const flush = (aEnd, bEnd) => {
72
+ if (aEnd > ai || bEnd > bi) {
73
+ edits.push({
74
+ afterLines: after.slice(ai, aEnd),
75
+ beforeLines: before.slice(bi, bEnd),
76
+ });
77
+ }
78
+ };
79
+ for (const [a, b] of pairs) {
80
+ flush(a, b);
81
+ ai = a + 1;
82
+ bi = b + 1;
83
+ }
84
+ flush(after.length, before.length);
85
+ return edits;
86
+ }
87
+ function indexOfSlice(hay, needle, from) {
88
+ if (needle.length === 0)
89
+ return from;
90
+ for (let i = from; i + needle.length <= hay.length; i++) {
91
+ if (needle.every((line, k) => line === hay[i + k]))
92
+ return i;
93
+ }
94
+ return -1;
95
+ }
96
+ /**
97
+ * 逆放 agent overwrite(补丁逆放)。
98
+ *
99
+ * @param before - 写前文本
100
+ * @param after - 写后文本
101
+ * @param current - 磁盘现状文本
102
+ * @returns 逆放结果
103
+ */
104
+ export function reverseAgentOverwrite(before, after, current) {
105
+ if (current === after || current === before) {
106
+ return { kind: 'restored', content: before, skippedHunks: 0 };
107
+ }
108
+ const afterL = splitLines(after);
109
+ const beforeL = splitLines(before);
110
+ const currentL = splitLines(current);
111
+ const edits = computeEdits(afterL, beforeL);
112
+ if (edits.length === 0) {
113
+ return { kind: 'restored', content: before, skippedHunks: 0 };
114
+ }
115
+ const located = [];
116
+ const occupied = [];
117
+ const overlaps = (start, end) => occupied.some((o) => start < o.end && end > o.start);
118
+ for (const edit of edits) {
119
+ if (edit.afterLines.length === 0 && edit.beforeLines.length === 0)
120
+ continue;
121
+ let idx = indexOfSlice(currentL, edit.afterLines, 0);
122
+ while (idx >= 0) {
123
+ const end = idx + edit.afterLines.length;
124
+ if (!overlaps(idx, end)) {
125
+ located.push({ idx, afterLines: edit.afterLines, beforeLines: edit.beforeLines });
126
+ occupied.push({ start: idx, end });
127
+ break;
128
+ }
129
+ idx = indexOfSlice(currentL, edit.afterLines, idx + 1);
130
+ }
131
+ }
132
+ located.sort((a, b) => a.idx - b.idx);
133
+ const result = [];
134
+ let cursor = 0;
135
+ let skippedHunks = 0;
136
+ const matched = located.length;
137
+ for (const h of located) {
138
+ if (h.idx < cursor) {
139
+ skippedHunks += 1;
140
+ continue;
141
+ }
142
+ result.push(...currentL.slice(cursor, h.idx));
143
+ result.push(...h.beforeLines);
144
+ cursor = h.idx + h.afterLines.length;
145
+ }
146
+ result.push(...currentL.slice(cursor));
147
+ // 未能定位的 edit 记 skipped(用户改掉了 after 痕迹)
148
+ skippedHunks += edits.filter((e) => e.afterLines.length > 0 || e.beforeLines.length > 0).length - matched;
149
+ return { kind: 'restored', content: joinLines(result), skippedHunks: Math.max(0, skippedHunks) };
150
+ }
151
+ /** 路径比较键(Windows 忽略大小写) */
152
+ export function pathKey(p) {
153
+ const norm = p.replace(/\\/g, '/');
154
+ return isWin ? norm.toLowerCase() : norm;
155
+ }
156
+ /**
157
+ * 保留兼容入口:补丁逆放(行级)。
158
+ *
159
+ * @param after - agent 写后
160
+ * @param current - 现状
161
+ * @param before - agent 写前
162
+ * @returns 合并行;失败 null
163
+ */
164
+ export function merge3Lines(after, current, before) {
165
+ const r = reverseAgentOverwrite(joinLines(before), joinLines(after), joinLines(current));
166
+ return r.kind === 'restored' ? splitLines(r.content) : null;
167
+ }
@@ -1,4 +1,4 @@
1
- export type { ClientToolCall, ClientToolCallId, ClientToolCallOutcome, ClientToolClientFilter, ClientToolDescriptor, ClientToolDeviceMeta, ClientToolErrorReason, ClientToolInteraction, ClientToolName, ClientToolProvider, ClientToolResult, ClientToolSensitivity, } from './types.js';
1
+ export type { ClientToolCall, ClientToolCallId, ClientToolCallOutcome, ClientToolClientFilter, ClientToolDescriptor, ClientToolDeviceMeta, ClientToolErrorReason, ClientToolInteraction, ClientToolName, ClientToolProvider, ClientToolFileRef, ClientToolResult, ClientToolSensitivity, } from './types.js';
2
2
  export { createClientTool, makeClientToolCallId, DEFAULT_CLIENT_TOOL_TIMEOUT_MS, validateClientToolArgs, validateClientToolDescriptor, validateClientToolOutcome, requireDevicePurpose, type ClientToolInvoker, type ClientToolInvokeRequest, } from './invoke.js';
3
3
  export { ClientToolRegistry, type ClientToolRouteDecision, } from './registry.js';
4
4
  export { ClientStreamTransport, createSinkStreamTool, createSourceStreamTool, createStreamStopTool, type ClientStreamChannel, type ClientStreamDirection, type ClientStreamEvent, type ClientStreamEventType, type ClientStreamSampleInput, type ClientStreamTransportDeps, type OpenStreamInput, type StreamDomainToolDeps, type StreamStopToolDeps, } from './stream.js';
@@ -64,6 +64,13 @@ export type ClientToolResult = {
64
64
  preview?: string;
65
65
  };
66
66
  export type ClientToolErrorReason = 'invalid_arguments' | 'client_unavailable' | 'consent_denied' | 'permission_denied' | 'expired' | 'cancelled' | 'unsupported' | 'internal';
67
+ /** 已 release 的文件引用(send_file);正文经 fileId 内容 API 获取,不进 tool_result */
68
+ export interface ClientToolFileRef {
69
+ fileId: string;
70
+ name: string;
71
+ mime: string;
72
+ sizeBytes: number;
73
+ }
67
74
  export type ClientToolCallOutcome = {
68
75
  status: 'ok';
69
76
  result: ClientToolResult;
@@ -88,6 +95,8 @@ export interface ClientToolCall {
88
95
  completedByPrincipalId?: string;
89
96
  /** html_ui 等大正文落 attachment 后的引用 */
90
97
  assetId?: string;
98
+ /** send_file 已 release 的文件引用;正文经 GET files/:fileId */
99
+ fileRef?: ClientToolFileRef;
91
100
  /** 解释发生地(审计) */
92
101
  processing?: 'server' | 'local';
93
102
  /** 调用解析时的敏感度(换端判定,§15.3) */
@@ -51,6 +51,8 @@ export function mcpToolToOctopiDefinition(mcpTool, serverId) {
51
51
  return {
52
52
  name: `${serverId}${MCP_NAMESPACE_SEP}${mcpTool.name}`,
53
53
  description: mcpTool.description ?? '',
54
+ // D5: MCP talks to an external process — default egress (reduced surface strips it)
55
+ capabilities: ['egress'],
54
56
  parameters: params,
55
57
  };
56
58
  }
@@ -1,10 +1,8 @@
1
1
  /**
2
- * Plugin API — 对齐 OpenClaw 的 OpenClawPluginApi
2
+ * Plugin API
3
3
  *
4
4
  * 这是 plugin register() 回调中接收的 api 对象。
5
5
  * Plugin 通过它注册各种能力(provider、channel、tool、hook 等)。
6
- *
7
- * 参考: https://docs.openclaw.ai/plugins/sdk-overview#registration-api
8
6
  */
9
7
  import type { ModelProvider } from '@octopi-agent/core/interfaces/model-provider.js';
10
8
  import type { WebSearchProvider } from '../tools/web-search-types.js';
@@ -76,7 +74,6 @@ export interface PluginLogger {
76
74
  /**
77
75
  * Plugin API
78
76
  *
79
- * 对齐 OpenClaw 的 OpenClawPluginApi。
80
77
  * Plugin 在 register() 回调中使用此对象注册能力。
81
78
  */
82
79
  export declare class PluginApi {
@@ -149,7 +146,6 @@ export declare class PluginApi {
149
146
  /**
150
147
  * 注册 Agent Tool
151
148
  *
152
- * 对齐 OpenClaw 的 api.registerTool()。
153
149
  * Tool 名称不能与核心 tool 冲突。
154
150
  *
155
151
  * @param tool - Tool 定义(包含 name、description、parameters)
@@ -169,7 +165,6 @@ export declare class PluginApi {
169
165
  /**
170
166
  * 注册 Hook
171
167
  *
172
- * 对齐 OpenClaw 的 api.on()。
173
168
  * Hook handler 按 priority 降序执行,同 priority 按注册顺序。
174
169
  *
175
170
  * @param hookName - Hook 名称
@@ -1,15 +1,12 @@
1
1
  /**
2
- * Plugin API — 对齐 OpenClaw 的 OpenClawPluginApi
2
+ * Plugin API
3
3
  *
4
4
  * 这是 plugin register() 回调中接收的 api 对象。
5
5
  * Plugin 通过它注册各种能力(provider、channel、tool、hook 等)。
6
- *
7
- * 参考: https://docs.openclaw.ai/plugins/sdk-overview#registration-api
8
6
  */
9
7
  /**
10
8
  * Plugin API
11
9
  *
12
- * 对齐 OpenClaw 的 OpenClawPluginApi。
13
10
  * Plugin 在 register() 回调中使用此对象注册能力。
14
11
  */
15
12
  export class PluginApi {
@@ -61,7 +58,7 @@ export class PluginApi {
61
58
  };
62
59
  }
63
60
  // ================================================================
64
- // Capability Registration — 对齐 OpenClaw
61
+ // Capability Registration
65
62
  // ================================================================
66
63
  /**
67
64
  * 注册 LLM Provider
@@ -84,7 +81,6 @@ export class PluginApi {
84
81
  /**
85
82
  * 注册 Agent Tool
86
83
  *
87
- * 对齐 OpenClaw 的 api.registerTool()。
88
84
  * Tool 名称不能与核心 tool 冲突。
89
85
  *
90
86
  * @param tool - Tool 定义(包含 name、description、parameters)
@@ -114,7 +110,6 @@ export class PluginApi {
114
110
  /**
115
111
  * 注册 Hook
116
112
  *
117
- * 对齐 OpenClaw 的 api.on()。
118
113
  * Hook handler 按 priority 降序执行,同 priority 按注册顺序。
119
114
  *
120
115
  * @param hookName - Hook 名称
@@ -159,7 +154,7 @@ export class PluginApi {
159
154
  this.logger.info(`Registered service: ${service.id}`);
160
155
  }
161
156
  // ================================================================
162
- // Extended Registration — 对齐 OpenClaw 更多能力注册
157
+ // Extended Registration
163
158
  // ================================================================
164
159
  /** 已注册的 web search providers */
165
160
  _webSearchProviders = [];
@@ -1,15 +1,12 @@
1
1
  /**
2
2
  * Capability Registry — 能力注册中心
3
3
  *
4
- * 对齐 OpenClaw 的 capability ownership model。
5
4
  * 每种能力类型有独立的注册表,plugin 是能力的所有权边界。
6
5
  *
7
6
  * 核心原则:
8
7
  * - plugin = 所有权边界(一个公司/功能的所有表面)
9
8
  * - capability = 核心合约,多个 plugin 可以实现或消费
10
9
  * - 冲突检测:同一 capability ID 不能被两个 plugin 注册
11
- *
12
- * 参考: https://docs.openclaw.ai/plugins/architecture#capability-ownership-model
13
10
  */
14
11
  import type { PluginManifest } from './manifest.js';
15
12
  /**
@@ -1,15 +1,12 @@
1
1
  /**
2
2
  * Capability Registry — 能力注册中心
3
3
  *
4
- * 对齐 OpenClaw 的 capability ownership model。
5
4
  * 每种能力类型有独立的注册表,plugin 是能力的所有权边界。
6
5
  *
7
6
  * 核心原则:
8
7
  * - plugin = 所有权边界(一个公司/功能的所有表面)
9
8
  * - capability = 核心合约,多个 plugin 可以实现或消费
10
9
  * - 冲突检测:同一 capability ID 不能被两个 plugin 注册
11
- *
12
- * 参考: https://docs.openclaw.ai/plugins/architecture#capability-ownership-model
13
10
  */
14
11
  /**
15
12
  * Capability Registry
@@ -1,13 +1,8 @@
1
1
  /**
2
- * Plugin Entry — 对齐 OpenClaw 的 definePluginEntry
2
+ * Plugin Entry
3
3
  *
4
4
  * definePluginEntry 是创建 plugin 的标准方式。
5
5
  * 它定义了 plugin 的 id、name、register 回调等。
6
- *
7
- * 对齐 OpenClaw 的:
8
- * import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
9
- *
10
- * 参考: https://docs.openclaw.ai/plugins/building-plugins
11
6
  */
12
7
  import type { PluginApi } from './api.js';
13
8
  /**
@@ -57,7 +52,7 @@ export interface OctopiPluginDefinition {
57
52
  /**
58
53
  * 定义一个 Plugin Entry
59
54
  *
60
- * 这是创建 plugin 的标准方式,对齐 OpenClaw 的 definePluginEntry。
55
+ * 这是创建 plugin 的标准方式。
61
56
  *
62
57
  * @param definition - Plugin 定义
63
58
  * @returns Plugin 定义对象
@@ -84,7 +79,6 @@ export declare function definePluginEntry(definition: OctopiPluginDefinition): O
84
79
  * Channel Plugin 定义
85
80
  *
86
81
  * 用于 channel 类型的 plugin。
87
- * 对齐 OpenClaw 的 defineChannelPluginEntry。
88
82
  */
89
83
  export interface OctopiChannelPluginDefinition extends OctopiPluginDefinition {
90
84
  /** Channel ID */
@@ -93,8 +87,6 @@ export interface OctopiChannelPluginDefinition extends OctopiPluginDefinition {
93
87
  /**
94
88
  * 定义一个 Channel Plugin Entry
95
89
  *
96
- * 对齐 OpenClaw 的 defineChannelPluginEntry。
97
- *
98
90
  * @param definition - Channel Plugin 定义
99
91
  * @returns Plugin 定义对象
100
92
  */
@@ -1,18 +1,13 @@
1
1
  /**
2
- * Plugin Entry — 对齐 OpenClaw 的 definePluginEntry
2
+ * Plugin Entry
3
3
  *
4
4
  * definePluginEntry 是创建 plugin 的标准方式。
5
5
  * 它定义了 plugin 的 id、name、register 回调等。
6
- *
7
- * 对齐 OpenClaw 的:
8
- * import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
9
- *
10
- * 参考: https://docs.openclaw.ai/plugins/building-plugins
11
6
  */
12
7
  /**
13
8
  * 定义一个 Plugin Entry
14
9
  *
15
- * 这是创建 plugin 的标准方式,对齐 OpenClaw 的 definePluginEntry。
10
+ * 这是创建 plugin 的标准方式。
16
11
  *
17
12
  * @param definition - Plugin 定义
18
13
  * @returns Plugin 定义对象
@@ -50,8 +45,6 @@ export function definePluginEntry(definition) {
50
45
  /**
51
46
  * 定义一个 Channel Plugin Entry
52
47
  *
53
- * 对齐 OpenClaw 的 defineChannelPluginEntry。
54
- *
55
48
  * @param definition - Channel Plugin 定义
56
49
  * @returns Plugin 定义对象
57
50
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Plugin System — 对齐 OpenClaw 的 Plugin 架构
2
+ * Plugin System
3
3
  *
4
4
  * 核心概念:
5
5
  * - Plugin = 能力的所有权边界(Provider/Channel/Tool/Hook 等)
@@ -9,8 +9,6 @@
9
9
  * - PluginLoader = 发现和加载 plugins
10
10
  * - PluginManager = 管理 plugin 生命周期和 hook 执行
11
11
  * - CapabilityRegistry = 能力注册中心
12
- *
13
- * 参考: https://docs.openclaw.ai/plugins/overview
14
12
  */
15
13
  export { definePluginEntry, defineChannelPluginEntry } from './entry.js';
16
14
  export type { OctopiPluginDefinition, OctopiChannelPluginDefinition } from './entry.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Plugin System — 对齐 OpenClaw 的 Plugin 架构
2
+ * Plugin System
3
3
  *
4
4
  * 核心概念:
5
5
  * - Plugin = 能力的所有权边界(Provider/Channel/Tool/Hook 等)
@@ -9,8 +9,6 @@
9
9
  * - PluginLoader = 发现和加载 plugins
10
10
  * - PluginManager = 管理 plugin 生命周期和 hook 执行
11
11
  * - CapabilityRegistry = 能力注册中心
12
- *
13
- * 参考: https://docs.openclaw.ai/plugins/overview
14
12
  */
15
13
  // ── 定义和创建 ──
16
14
  export { definePluginEntry, defineChannelPluginEntry } from './entry.js';
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * Plugin Loader — Plugin 发现和加载
3
3
  *
4
- * 对齐 OpenClaw 的 plugin loading pipeline:
4
+ * 加载流程:
5
5
  * 1. Discovery — 从配置路径发现候选 plugins
6
6
  * 2. Validation — 验证 manifest、检查 enable/disable 状态
7
7
  * 3. Loading — 进程内加载 plugin 代码
8
8
  * 4. Registration — 调用 register() 注册能力
9
- *
10
- * 参考: https://docs.openclaw.ai/plugins/architecture#architecture-overview
11
9
  */
12
10
  import type { PluginManifest } from './manifest.js';
13
11
  import type { OctopiPluginDefinition } from './entry.js';
@@ -46,7 +44,7 @@ export interface PluginLoaderConfig {
46
44
  pluginEntries?: Record<string, PluginEntryConfig>;
47
45
  }
48
46
  /**
49
- * Plugin Entry 配置(来自 openclaw.json)
47
+ * Plugin Entry 配置(来自宿主配置)
50
48
  */
51
49
  export interface PluginEntryConfig {
52
50
  /** 是否启用 */
@@ -1,13 +1,11 @@
1
1
  /**
2
2
  * Plugin Loader — Plugin 发现和加载
3
3
  *
4
- * 对齐 OpenClaw 的 plugin loading pipeline:
4
+ * 加载流程:
5
5
  * 1. Discovery — 从配置路径发现候选 plugins
6
6
  * 2. Validation — 验证 manifest、检查 enable/disable 状态
7
7
  * 3. Loading — 进程内加载 plugin 代码
8
8
  * 4. Registration — 调用 register() 注册能力
9
- *
10
- * 参考: https://docs.openclaw.ai/plugins/architecture#architecture-overview
11
9
  */
12
10
  import * as path from 'node:path';
13
11
  import * as fs from 'node:fs/promises';
@@ -86,19 +84,10 @@ export class PluginLoader {
86
84
  continue;
87
85
  const pluginDir = path.join(dirPath, entry.name);
88
86
  const manifestPath = path.join(pluginDir, 'octopi.plugin.json');
89
- // 也检查 OpenClaw 格式的 manifest
90
- const openclawManifestPath = path.join(pluginDir, 'openclaw.plugin.json');
91
- let manifestFile = null;
92
- if (existsSync(manifestPath)) {
93
- manifestFile = manifestPath;
94
- }
95
- else if (existsSync(openclawManifestPath)) {
96
- manifestFile = openclawManifestPath;
97
- }
98
- if (!manifestFile)
87
+ if (!existsSync(manifestPath))
99
88
  continue;
100
89
  try {
101
- const plugin = await this.loadPluginFromDir(pluginDir, manifestFile);
90
+ const plugin = await this.loadPluginFromDir(pluginDir, manifestPath);
102
91
  if (plugin) {
103
92
  plugins.push(plugin);
104
93
  }
@@ -188,12 +177,6 @@ export class PluginLoader {
188
177
  if (existsSync(pkgPath)) {
189
178
  try {
190
179
  const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf-8'));
191
- // openclaw 字段中的 extensions
192
- if (pkg.openclaw?.extensions?.[0]) {
193
- const ext = path.resolve(pluginDir, pkg.openclaw.extensions[0]);
194
- if (existsSync(ext))
195
- return ext;
196
- }
197
180
  // main 字段
198
181
  if (pkg.main) {
199
182
  const main = path.resolve(pluginDir, pkg.main);
@@ -259,7 +242,7 @@ export class PluginLoader {
259
242
  for (const dep of plugin.manifest.requiresPlugins) {
260
243
  if (!plugins.some((p) => p.id === dep)) {
261
244
  console.warn(`[PluginLoader] Plugin "${plugin.id}" requires "${dep}" which is not loaded`);
262
- // 不阻塞,只警告(对齐 OpenClaw 行为)
245
+ // 依赖缺失不阻塞加载,只警告
263
246
  }
264
247
  }
265
248
  }
@@ -1,18 +1,15 @@
1
1
  /**
2
- * Plugin Manager — 对齐 OpenClaw 的 Plugin 管理系统
2
+ * Plugin Manager
3
3
  *
4
4
  * 这是 plugin 系统的顶层管理器,负责:
5
5
  * - 加载和管理所有 plugins
6
6
  * - 运行 hooks(支持 priority、timeout、拦截语义)
7
7
  * - 能力注册和查询
8
- * - 对齐 OpenClaw 的 hook catalog
9
8
  *
10
- * Hook 分类(对齐 OpenClaw):
9
+ * Hook 分类:
11
10
  * - 拦截语义:返回值改变执行流程
12
11
  * - 观察语义:所有 plugin 都执行
13
12
  * - 上下文注入:返回 prependContext / systemPrompt 等
14
- *
15
- * 参考: https://docs.openclaw.ai/plugins/hooks
16
13
  */
17
14
  import type { Message, ToolCall, ToolResult, ThinkingLevel } from '@octopi-agent/core/types.js';
18
15
  import type { ChannelAdapter, ChannelMessage, ChannelReply } from '../channel-types.js';
@@ -192,7 +189,6 @@ export interface BeforeInstallEvent {
192
189
  * before_iteration 事件
193
190
  *
194
191
  * 每次 LLM 调用前触发(per-iteration)。
195
- * 与 OpenClaw 的 before_agent_reply(per-message)不同,
196
192
  * 这是 Octopi 独有的迭代级 hook。
197
193
  */
198
194
  export interface BeforeIterationEvent {
@@ -231,7 +227,6 @@ export interface BeforeIterationResult {
231
227
  * after_iteration 事件
232
228
  *
233
229
  * 每次 LLM 调用 + 工具执行完成后触发(per-iteration)。
234
- * 与 OpenClaw 的 after_tool_call(per-tool)不同,
235
230
  * 这是 Octopi 独有的迭代级 hook。
236
231
  */
237
232
  export interface AfterIterationEvent {
@@ -359,7 +354,6 @@ export interface InstallResult {
359
354
  /**
360
355
  * Plugin Manager
361
356
  *
362
- * 对齐 OpenClaw 的 plugin 管理系统。
363
357
  * 负责加载 plugins、运行 hooks、管理能力注册。
364
358
  */
365
359
  export declare class PluginManager {
@@ -389,7 +383,7 @@ export declare class PluginManager {
389
383
  /**
390
384
  * 运行指定 hook
391
385
  *
392
- * 对齐 OpenClaw 的 hook runner:
386
+ * 语义:
393
387
  * - 按 priority 降序执行
394
388
  * - 支持 per-handler timeout
395
389
  * - 拦截语义:返回非 null/undefined 的结果时中断后续 handlers
@@ -1,18 +1,15 @@
1
1
  /**
2
- * Plugin Manager — 对齐 OpenClaw 的 Plugin 管理系统
2
+ * Plugin Manager
3
3
  *
4
4
  * 这是 plugin 系统的顶层管理器,负责:
5
5
  * - 加载和管理所有 plugins
6
6
  * - 运行 hooks(支持 priority、timeout、拦截语义)
7
7
  * - 能力注册和查询
8
- * - 对齐 OpenClaw 的 hook catalog
9
8
  *
10
- * Hook 分类(对齐 OpenClaw):
9
+ * Hook 分类:
11
10
  * - 拦截语义:返回值改变执行流程
12
11
  * - 观察语义:所有 plugin 都执行
13
12
  * - 上下文注入:返回 prependContext / systemPrompt 等
14
- *
15
- * 参考: https://docs.openclaw.ai/plugins/hooks
16
13
  */
17
14
  import { PluginLoader } from './loader.js';
18
15
  // ================================================================
@@ -21,7 +18,6 @@ import { PluginLoader } from './loader.js';
21
18
  /**
22
19
  * Plugin Manager
23
20
  *
24
- * 对齐 OpenClaw 的 plugin 管理系统。
25
21
  * 负责加载 plugins、运行 hooks、管理能力注册。
26
22
  */
27
23
  export class PluginManager {
@@ -63,12 +59,12 @@ export class PluginManager {
63
59
  return this.loader.getPlugin(id);
64
60
  }
65
61
  // ================================================================
66
- // Hook Execution — 对齐 OpenClaw Hook Runner
62
+ // Hook Execution
67
63
  // ================================================================
68
64
  /**
69
65
  * 运行指定 hook
70
66
  *
71
- * 对齐 OpenClaw 的 hook runner:
67
+ * 语义:
72
68
  * - 按 priority 降序执行
73
69
  * - 支持 per-handler timeout
74
70
  * - 拦截语义:返回非 null/undefined 的结果时中断后续 handlers
@@ -1,10 +1,8 @@
1
1
  /**
2
- * Plugin Manifest — 对齐 OpenClaw 的 openclaw.plugin.json 格式
2
+ * Plugin Manifest
3
3
  *
4
4
  * Manifest 是 plugin 的声明式元数据,框架在不执行 plugin 代码的情况下
5
5
  * 就能读取和验证。这是 plugin 系统的基础。
6
- *
7
- * 参考: https://docs.openclaw.ai/plugins/manifest
8
6
  */
9
7
  /**
10
8
  * JSON Schema 基础类型(简化版)
@@ -30,7 +28,6 @@ export interface JsonSchema {
30
28
  /**
31
29
  * Plugin Manifest
32
30
  *
33
- * 对齐 OpenClaw 的 openclaw.plugin.json 格式。
34
31
  * 所有字段都是声明式的,不需要执行 plugin 代码。
35
32
  */
36
33
  export interface PluginManifest {
@@ -1,10 +1,8 @@
1
1
  /**
2
- * Plugin Manifest — 对齐 OpenClaw 的 openclaw.plugin.json 格式
2
+ * Plugin Manifest
3
3
  *
4
4
  * Manifest 是 plugin 的声明式元数据,框架在不执行 plugin 代码的情况下
5
5
  * 就能读取和验证。这是 plugin 系统的基础。
6
- *
7
- * 参考: https://docs.openclaw.ai/plugins/manifest
8
6
  */
9
7
  /**
10
8
  * 验证 manifest 格式
@@ -1,5 +1,5 @@
1
1
  /**
2
- * SkillManager — 两阶段加载实现(对齐 OpenClaw / Agent Skills 标准)
2
+ * SkillManager — 两阶段加载实现(对齐 Agent Skills 标准)
3
3
  *
4
4
  * 阶段 1(启动时):
5
5
  * discover() 扫描 skills/ 目录,只读 SKILL.md 的 frontmatter(name/description)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * SkillManager — 两阶段加载实现(对齐 OpenClaw / Agent Skills 标准)
2
+ * SkillManager — 两阶段加载实现(对齐 Agent Skills 标准)
3
3
  *
4
4
  * 阶段 1(启动时):
5
5
  * discover() 扫描 skills/ 目录,只读 SKILL.md 的 frontmatter(name/description)