@octopi-agent/engine 0.102.10 → 0.121.15

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 (321) hide show
  1. package/dist/builtin-model-info.js +28 -7
  2. package/dist/config-admin/agent-presets.d.ts +32 -0
  3. package/dist/config-admin/agent-presets.js +133 -0
  4. package/dist/config-admin/console-access-key.d.ts +46 -0
  5. package/dist/config-admin/console-access-key.js +47 -0
  6. package/dist/config-admin/discover.d.ts +33 -4
  7. package/dist/config-admin/discover.js +101 -6
  8. package/dist/config-admin/env.d.ts +11 -0
  9. package/dist/config-admin/env.js +41 -0
  10. package/dist/config-admin/error-copy.d.ts +106 -0
  11. package/dist/config-admin/error-copy.js +287 -0
  12. package/dist/config-admin/i18n.d.ts +21 -0
  13. package/dist/config-admin/i18n.js +19 -0
  14. package/dist/config-admin/index.d.ts +8 -2
  15. package/dist/config-admin/index.js +4 -1
  16. package/dist/config-admin/model-presets.d.ts +14 -0
  17. package/dist/config-admin/model-presets.js +595 -70
  18. package/dist/config-admin/onboarding-apply.d.ts +83 -0
  19. package/dist/config-admin/onboarding-apply.js +259 -0
  20. package/dist/config-admin/onboarding.d.ts +160 -0
  21. package/dist/config-admin/onboarding.js +298 -0
  22. package/dist/config-admin/password-policy.d.ts +24 -0
  23. package/dist/config-admin/password-policy.js +31 -0
  24. package/dist/config-admin/redact.d.ts +42 -9
  25. package/dist/config-admin/redact.js +69 -5
  26. package/dist/config-schema/agent.d.ts +5 -1
  27. package/dist/config-schema/agent.js +20 -2
  28. package/dist/config-schema/browser.d.ts +62 -0
  29. package/dist/config-schema/browser.js +89 -0
  30. package/dist/config-schema/context.d.ts +7 -2
  31. package/dist/config-schema/context.js +6 -3
  32. package/dist/config-schema/engine.d.ts +86 -7
  33. package/dist/config-schema/engine.js +9 -2
  34. package/dist/config-schema/governance.d.ts +12 -1
  35. package/dist/config-schema/governance.js +10 -2
  36. package/dist/config-schema/models.d.ts +12 -8
  37. package/dist/config-schema/models.js +16 -1
  38. package/dist/config-schema/run.d.ts +4 -0
  39. package/dist/config-schema/run.js +10 -0
  40. package/dist/config-schema/shared.d.ts +1 -0
  41. package/dist/config-schema/shared.js +4 -2
  42. package/dist/config-schema/substrate.d.ts +5 -0
  43. package/dist/config-schema/substrate.js +8 -0
  44. package/dist/config.d.ts +116 -10
  45. package/dist/config.js +109 -13
  46. package/dist/file-mode.d.ts +67 -0
  47. package/dist/file-mode.js +182 -0
  48. package/dist/fork-child.d.ts +82 -0
  49. package/dist/fork-child.js +123 -0
  50. package/dist/harness/activation/delegated-run.d.ts +42 -0
  51. package/dist/harness/activation/delegated-run.js +71 -0
  52. package/dist/harness/activation/dispatcher.js +4 -0
  53. package/dist/harness/activation/index.d.ts +1 -0
  54. package/dist/harness/activation/run-backend.d.ts +92 -0
  55. package/dist/harness/activation/run-backend.js +16 -0
  56. package/dist/harness/activation/run-protocol.d.ts +392 -0
  57. package/dist/harness/activation/run-protocol.js +19 -0
  58. package/dist/harness/activation/runtime.d.ts +33 -0
  59. package/dist/harness/activation/runtime.js +119 -28
  60. package/dist/harness/activation/types.d.ts +19 -2
  61. package/dist/harness/agent/builder.d.ts +12 -0
  62. package/dist/harness/agent/builder.js +78 -22
  63. package/dist/harness/agent/config-bridge.d.ts +10 -1
  64. package/dist/harness/agent/config-bridge.js +15 -3
  65. package/dist/harness/agent/registered-tool-adapter.d.ts +27 -0
  66. package/dist/harness/agent/registered-tool-adapter.js +67 -0
  67. package/dist/harness/agent/wire-agent-builder.d.ts +2 -0
  68. package/dist/harness/agent/wire-agent-builder.js +9 -2
  69. package/dist/harness/capabilities/document/backends/plain.js +2 -1
  70. package/dist/harness/capabilities/document/legacy/factory.js +3 -2
  71. package/dist/harness/collaboration/autonomous-subsystem/audit/reader.d.ts +17 -0
  72. package/dist/harness/collaboration/autonomous-subsystem/audit/reader.js +66 -36
  73. package/dist/harness/collaboration/autonomous-subsystem/audit/writer.d.ts +6 -2
  74. package/dist/harness/collaboration/autonomous-subsystem/audit/writer.js +27 -7
  75. package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +13 -0
  76. package/dist/harness/collaboration/autonomous-subsystem/loader.js +1 -0
  77. package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +11 -0
  78. package/dist/harness/collaboration/autonomous-subsystem/runtime.js +17 -0
  79. package/dist/harness/collaboration/autonomous-subsystem/sense/engine.d.ts +13 -3
  80. package/dist/harness/collaboration/autonomous-subsystem/sense/engine.js +48 -39
  81. package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +3 -0
  82. package/dist/harness/collaboration/autonomous-subsystem/types.d.ts +4 -0
  83. package/dist/harness/collaboration/delegation/child-run.d.ts +9 -0
  84. package/dist/harness/collaboration/delegation/child-run.js +34 -2
  85. package/dist/harness/collaboration/delegation/registry-types.d.ts +2 -0
  86. package/dist/harness/collaboration/delegation/service.d.ts +9 -4
  87. package/dist/harness/collaboration/delegation/service.js +33 -12
  88. package/dist/harness/collaboration/delegation/store.d.ts +2 -0
  89. package/dist/harness/collaboration/delegation/store.js +1 -0
  90. package/dist/harness/collaboration/delegation/types.d.ts +11 -0
  91. package/dist/harness/collaboration/delegation/wiring.d.ts +2 -0
  92. package/dist/harness/collaboration/delegation/wiring.js +1 -0
  93. package/dist/harness/context/capabilities/compact/engine.d.ts +44 -5
  94. package/dist/harness/context/capabilities/compact/engine.js +127 -39
  95. package/dist/harness/context/capabilities/compact/index.d.ts +2 -1
  96. package/dist/harness/context/capabilities/compact/index.js +1 -1
  97. package/dist/harness/context/capabilities/compact/types.d.ts +59 -9
  98. package/dist/harness/context/capabilities/summary/gate.d.ts +19 -2
  99. package/dist/harness/context/capabilities/summary/gate.js +53 -6
  100. package/dist/harness/context/capabilities/summary/registry.js +20 -0
  101. package/dist/harness/context/capabilities/summary/tool-binding.js +16 -12
  102. package/dist/harness/context/capabilities/summary/tool-bindings.d.ts +13 -0
  103. package/dist/harness/context/capabilities/summary/tool-bindings.js +22 -0
  104. package/dist/harness/context/capabilities/summary/types.d.ts +16 -0
  105. package/dist/harness/context/constitution/default-agents.md +85 -0
  106. package/dist/harness/context/context-size-ledger.js +8 -1
  107. package/dist/harness/context/default-context-engine.d.ts +100 -6
  108. package/dist/harness/context/default-context-engine.js +382 -89
  109. package/dist/harness/context/index.d.ts +2 -1
  110. package/dist/harness/context/index.js +1 -0
  111. package/dist/harness/context/layer-health.d.ts +4 -0
  112. package/dist/harness/context/layer-health.js +4 -0
  113. package/dist/harness/context/layer-types.d.ts +57 -0
  114. package/dist/harness/context/layer-types.js +73 -1
  115. package/dist/harness/context/layers.d.ts +3 -0
  116. package/dist/harness/context/layers.js +13 -6
  117. package/dist/harness/context/prefix-fingerprint.d.ts +46 -0
  118. package/dist/harness/context/prefix-fingerprint.js +52 -0
  119. package/dist/harness/context/summarize.js +18 -0
  120. package/dist/harness/context/system-prompt-assembler.d.ts +2 -0
  121. package/dist/harness/context/system-prompt-assembler.js +5 -2
  122. package/dist/harness/context/tool-result-aging.d.ts +104 -16
  123. package/dist/harness/context/tool-result-aging.js +211 -57
  124. package/dist/harness/context/types.d.ts +71 -4
  125. package/dist/harness/context/types.js +25 -1
  126. package/dist/harness/extension/execution-environment/effect-policy.d.ts +4 -3
  127. package/dist/harness/extension/execution-environment/effect-policy.js +2 -2
  128. package/dist/harness/extension/execution-environment/privileged-exec.js +4 -1
  129. package/dist/harness/extension/execution-environment/workspace.js +1 -1
  130. package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +27 -1
  131. package/dist/harness/extension/plugin-ecosystem/channel-types.js +11 -2
  132. package/dist/harness/extension/plugin-ecosystem/client-tools/registry.d.ts +12 -0
  133. package/dist/harness/extension/plugin-ecosystem/client-tools/registry.js +25 -0
  134. package/dist/harness/extension/plugin-ecosystem/commands/builtin.js +28 -1
  135. package/dist/harness/extension/plugin-ecosystem/index.d.ts +1 -0
  136. package/dist/harness/extension/plugin-ecosystem/index.js +1 -0
  137. package/dist/harness/extension/plugin-ecosystem/plugins/api.d.ts +168 -1
  138. package/dist/harness/extension/plugin-ecosystem/plugins/api.js +156 -15
  139. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.d.ts +95 -0
  140. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-instances.js +170 -0
  141. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.d.ts +178 -0
  142. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-kinds.js +314 -0
  143. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.d.ts +40 -5
  144. package/dist/harness/extension/plugin-ecosystem/plugins/contribution-registry.js +45 -26
  145. package/dist/harness/extension/plugin-ecosystem/plugins/index.d.ts +1 -1
  146. package/dist/harness/extension/plugin-ecosystem/plugins/loader.d.ts +11 -1
  147. package/dist/harness/extension/plugin-ecosystem/plugins/loader.js +42 -76
  148. package/dist/harness/extension/plugin-ecosystem/plugins/manager.d.ts +30 -1
  149. package/dist/harness/extension/plugin-ecosystem/plugins/manager.js +46 -0
  150. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.d.ts +9 -0
  151. package/dist/harness/extension/plugin-ecosystem/plugins/manifest.js +19 -14
  152. package/dist/harness/extension/plugin-ecosystem/plugins/staging.d.ts +3 -1
  153. package/dist/harness/extension/plugin-ecosystem/plugins/staging.js +1 -1
  154. package/dist/harness/extension/plugin-ecosystem/tools/browser-types.d.ts +333 -0
  155. package/dist/harness/extension/plugin-ecosystem/tools/browser-types.js +16 -0
  156. package/dist/harness/extension/plugin-ecosystem/tools/browser.d.ts +64 -0
  157. package/dist/harness/extension/plugin-ecosystem/tools/browser.js +692 -0
  158. package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +0 -37
  159. package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +108 -4
  160. package/dist/harness/extension/plugin-ecosystem/tools/delegation.js +18 -0
  161. package/dist/harness/extension/plugin-ecosystem/tools/file-edit.js +34 -0
  162. package/dist/harness/extension/plugin-ecosystem/tools/file-search.d.ts +0 -6
  163. package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +57 -4
  164. package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +81 -13
  165. package/dist/harness/extension/plugin-ecosystem/tools/http.js +5 -0
  166. package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +13 -7
  167. package/dist/harness/extension/plugin-ecosystem/tools/package-tools.js +126 -14
  168. package/dist/harness/extension/plugin-ecosystem/tools/platform.d.ts +1 -1
  169. package/dist/harness/extension/plugin-ecosystem/tools/platform.js +44 -5
  170. package/dist/harness/extension/plugin-ecosystem/tools/tool-bus.js +10 -24
  171. package/dist/harness/extension/plugin-ecosystem/tools/tool-set.d.ts +7 -0
  172. package/dist/harness/extension/plugin-ecosystem/tools/tool-set.js +4 -0
  173. package/dist/harness/governance/credentials/db.d.ts +9 -0
  174. package/dist/harness/governance/credentials/db.js +122 -31
  175. package/dist/harness/governance/credentials/store.d.ts +68 -7
  176. package/dist/harness/governance/credentials/store.js +177 -64
  177. package/dist/harness/governance/credentials/types.d.ts +13 -2
  178. package/dist/harness/governance/index.d.ts +1 -0
  179. package/dist/harness/governance/index.js +1 -0
  180. package/dist/harness/governance/registry/db.d.ts +32 -0
  181. package/dist/harness/governance/registry/db.js +142 -0
  182. package/dist/harness/governance/registry/index.d.ts +9 -0
  183. package/dist/harness/governance/registry/index.js +9 -0
  184. package/dist/harness/governance/registry/service.d.ts +381 -0
  185. package/dist/harness/governance/registry/service.js +825 -0
  186. package/dist/harness/governance/registry/types.d.ts +77 -0
  187. package/dist/harness/governance/registry/types.js +7 -0
  188. package/dist/harness/governance/security/default-security-guard.d.ts +3 -0
  189. package/dist/harness/governance/security/default-security-guard.js +12 -1
  190. package/dist/harness/governance/security/risk-evaluator.d.ts +13 -3
  191. package/dist/harness/governance/security/risk-evaluator.js +307 -21
  192. package/dist/harness/governance/security/shell-parser-treesitter.js +12 -4
  193. package/dist/harness/governance/session-acl/tool-rights.d.ts +1 -0
  194. package/dist/harness/index.d.ts +5 -3
  195. package/dist/harness/index.js +2 -2
  196. package/dist/harness/knowledge/boot-config.d.ts +2 -0
  197. package/dist/harness/knowledge/boot-config.js +2 -0
  198. package/dist/harness/knowledge/client.d.ts +53 -7
  199. package/dist/harness/knowledge/client.js +77 -20
  200. package/dist/harness/knowledge/db.d.ts +16 -0
  201. package/dist/harness/knowledge/db.js +107 -41
  202. package/dist/harness/knowledge/engine-thread.js +5 -7
  203. package/dist/harness/knowledge/grounding.js +4 -1
  204. package/dist/harness/knowledge/http-app.d.ts +15 -0
  205. package/dist/harness/knowledge/http-app.js +82 -21
  206. package/dist/harness/knowledge/http-bridge.d.ts +15 -0
  207. package/dist/harness/knowledge/http-bridge.js +19 -0
  208. package/dist/harness/knowledge/knowledge-serve-child.js +2 -3
  209. package/dist/harness/knowledge/query-service.d.ts +12 -2
  210. package/dist/harness/knowledge/query-service.js +75 -41
  211. package/dist/harness/knowledge/query-worker-client.d.ts +5 -1
  212. package/dist/harness/knowledge/query-worker-client.js +4 -1
  213. package/dist/harness/knowledge/query-worker.js +5 -3
  214. package/dist/harness/knowledge/read-http.d.ts +2 -0
  215. package/dist/harness/knowledge/read-http.js +9 -2
  216. package/dist/harness/knowledge/retriever.d.ts +1 -1
  217. package/dist/harness/knowledge/retriever.js +1 -2
  218. package/dist/harness/knowledge/serve.d.ts +6 -1
  219. package/dist/harness/knowledge/serve.js +5 -6
  220. package/dist/harness/knowledge/source-store.d.ts +101 -5
  221. package/dist/harness/knowledge/source-store.js +297 -71
  222. package/dist/harness/knowledge/start-service-process.d.ts +27 -8
  223. package/dist/harness/knowledge/start-service-process.js +49 -90
  224. package/dist/harness/knowledge/tenant-gate.d.ts +81 -0
  225. package/dist/harness/knowledge/tenant-gate.js +167 -0
  226. package/dist/harness/knowledge/writer-service.d.ts +18 -2
  227. package/dist/harness/knowledge/writer-service.js +80 -16
  228. package/dist/harness/knowledge/writer-worker-client.d.ts +9 -2
  229. package/dist/harness/knowledge/writer-worker-client.js +20 -3
  230. package/dist/harness/knowledge/writer-worker.js +11 -4
  231. package/dist/harness/memory/backfill-trigger.d.ts +10 -3
  232. package/dist/harness/memory/backfill-trigger.js +19 -19
  233. package/dist/harness/memory/cognition-seeds.d.ts +45 -0
  234. package/dist/harness/memory/cognition-seeds.js +67 -0
  235. package/dist/harness/memory/cognition.d.ts +12 -3
  236. package/dist/harness/memory/cognition.js +55 -35
  237. package/dist/harness/memory/conceptualizer.d.ts +11 -1
  238. package/dist/harness/memory/conceptualizer.js +10 -1
  239. package/dist/harness/memory/context-slice.d.ts +42 -0
  240. package/dist/harness/memory/context-slice.js +197 -0
  241. package/dist/harness/memory/health-probe.d.ts +8 -2
  242. package/dist/harness/memory/health-probe.js +10 -13
  243. package/dist/harness/memory/index.d.ts +5 -1
  244. package/dist/harness/memory/index.js +3 -1
  245. package/dist/harness/memory/sqlite/agent-db.d.ts +1 -0
  246. package/dist/harness/memory/sqlite/agent-db.js +9 -8
  247. package/dist/harness/memory/sqlite/cognition-store.d.ts +26 -3
  248. package/dist/harness/memory/sqlite/cognition-store.js +103 -45
  249. package/dist/harness/memory/sqlite/memory-store.js +4 -0
  250. package/dist/harness/memory/sqlite/sqlite-vec.d.ts +24 -1
  251. package/dist/harness/memory/sqlite/sqlite-vec.js +37 -1
  252. package/dist/harness/memory/types.d.ts +18 -2
  253. package/dist/harness/observability/observer/hub.d.ts +10 -0
  254. package/dist/harness/observability/observer/hub.js +95 -2
  255. package/dist/harness/run/agent/agent.js +3 -2
  256. package/dist/harness/run/concurrency/tool-validator.js +4 -3
  257. package/dist/harness/run/reliability/run-agent.d.ts +22 -0
  258. package/dist/harness/run/reliability/run-agent.js +79 -10
  259. package/dist/harness/run/run-host.d.ts +302 -0
  260. package/dist/harness/run/run-host.js +978 -0
  261. package/dist/harness/run/run-scope.d.ts +11 -0
  262. package/dist/harness/run/run-scope.js +19 -1
  263. package/dist/harness/run/runner.d.ts +149 -22
  264. package/dist/harness/run/runner.js +352 -35
  265. package/dist/harness/session/in-memory-store.js +13 -1
  266. package/dist/harness/session/schedules/service.d.ts +10 -2
  267. package/dist/harness/session/schedules/service.js +13 -2
  268. package/dist/harness/session/tasks/tools.js +12 -0
  269. package/dist/harness/session/types.d.ts +10 -14
  270. package/dist/harness/shared/events/agent-event-map.d.ts +29 -0
  271. package/dist/harness/shared/types/agent-definition.d.ts +6 -0
  272. package/dist/index.d.ts +3 -2
  273. package/dist/index.js +2 -1
  274. package/dist/integration/agent-runtime/channel-message-source.d.ts +3 -1
  275. package/dist/integration/agent-runtime/channel-message-source.js +4 -3
  276. package/dist/integration/browser/camoufox.d.ts +40 -0
  277. package/dist/integration/browser/camoufox.js +80 -0
  278. package/dist/integration/browser/index.d.ts +91 -0
  279. package/dist/integration/browser/index.js +110 -0
  280. package/dist/integration/browser/install.d.ts +47 -0
  281. package/dist/integration/browser/install.js +214 -0
  282. package/dist/integration/browser/playwright.d.ts +224 -0
  283. package/dist/integration/browser/playwright.js +925 -0
  284. package/dist/integration/browser/service.d.ts +41 -0
  285. package/dist/integration/browser/service.js +181 -0
  286. package/dist/integration/browser/stealth.d.ts +42 -0
  287. package/dist/integration/browser/stealth.js +104 -0
  288. package/dist/integration/providers/anthropic-message-normalize.d.ts +20 -0
  289. package/dist/integration/providers/anthropic-message-normalize.js +48 -0
  290. package/dist/integration/providers/anthropic.js +27 -2
  291. package/dist/integration/providers/fetch-timeout.d.ts +17 -0
  292. package/dist/integration/providers/fetch-timeout.js +24 -0
  293. package/dist/integration/providers/openai.d.ts +8 -0
  294. package/dist/integration/providers/openai.js +41 -1
  295. package/dist/integration/providers/wire-dump-diff.js +2 -1
  296. package/dist/integration/providers/wire-dump.d.ts +56 -2
  297. package/dist/integration/providers/wire-dump.js +119 -6
  298. package/dist/integration/storage/archive-manager.d.ts +14 -2
  299. package/dist/integration/storage/archive-manager.js +24 -8
  300. package/dist/integration/storage/atomic-tmp.d.ts +12 -0
  301. package/dist/integration/storage/atomic-tmp.js +36 -0
  302. package/dist/integration/storage/jsonl.d.ts +9 -0
  303. package/dist/integration/storage/jsonl.js +137 -38
  304. package/dist/integration/storage/session-index.d.ts +5 -0
  305. package/dist/integration/storage/session-index.js +25 -4
  306. package/dist/integration/tools/assemble.d.ts +50 -0
  307. package/dist/integration/tools/assemble.js +137 -0
  308. package/dist/paths.d.ts +18 -0
  309. package/dist/paths.js +36 -0
  310. package/dist/subsystems/cognition-steward/conceptualize/config.yaml +3 -1
  311. package/dist/subsystems/cognition-steward/conceptualize/handler.js +74 -5
  312. package/dist/subsystems/cognition-steward/consolidate/SUBSYSTEM.md +3 -2
  313. package/dist/subsystems/cognition-steward/consolidate/config.yaml +11 -2
  314. package/dist/subsystems/cognition-steward/consolidate/handler.d.ts +6 -3
  315. package/dist/subsystems/cognition-steward/consolidate/handler.js +266 -28
  316. package/dist/subsystems/memory-steward/backfill/handler.js +3 -2
  317. package/dist/subsystems/memory-steward/govern/config.yaml +6 -1
  318. package/dist/subsystems/wisdom-steward/attribute/config.yaml +5 -1
  319. package/dist/subsystems/wisdom-steward/formation/config.yaml +3 -0
  320. package/dist/subsystems/wisdom-steward/govern/config.yaml +6 -1
  321. package/package.json +5 -3
@@ -0,0 +1,314 @@
1
+ /**
2
+ * Declarative contribution-kind table — the single source of truth for the
3
+ * plugin contribution pipeline semantics: staging uniqueness, reserved ids,
4
+ * publish ownership, manifest claims, manifest uniqueness and manifest↔
5
+ * registration reconciliation.
6
+ *
7
+ * Adding a contribution kind = one descriptor here + the typed surfaces
8
+ * (PluginApi.registerXxx signature, staging slot, record type/getter, manifest
9
+ * schema field). The staging write path (`push`, via `stageContribution`) and
10
+ * the staged-entry read path (`forEachStaged`, which pairs entries with their
11
+ * keys) both live on the descriptor, so the key↔entry pairing and the
12
+ * uniqueness checks cannot be bypassed or forgotten per kind.
13
+ *
14
+ * Hooks are the deliberate semantic exception (multi-handler per name, no
15
+ * cross-plugin ownership), but their staging write path — priority-sorted Map
16
+ * insert — is also owned here (`hooks.push`), not by `PluginApi.on`.
17
+ */
18
+ import { BUILTIN_CHANNEL_IDS } from '../channel-types.js';
19
+ const tools = {
20
+ field: 'tools',
21
+ label: 'tool',
22
+ globallyUnique: true,
23
+ perPluginUnique: true,
24
+ reservedIds: [],
25
+ keyOf: (entry) => entry.definition.name,
26
+ declaredKeys: (manifest) => manifest.contributes?.tools ?? [],
27
+ forEachStaged: (slot, visit) => {
28
+ for (const entry of slot.tools)
29
+ visit(entry.definition.name, entry);
30
+ },
31
+ push: (slot, entry) => {
32
+ slot.tools.push(entry);
33
+ },
34
+ collect: (sink, pluginId, entry) => {
35
+ sink.tools.push({ pluginId, ...entry });
36
+ },
37
+ };
38
+ const commands = {
39
+ field: 'commands',
40
+ label: 'command',
41
+ globallyUnique: true,
42
+ perPluginUnique: true,
43
+ reservedIds: [],
44
+ keyOf: (entry) => entry.name,
45
+ declaredKeys: (manifest) => (manifest.contributes?.commands ?? []).map((command) => command.name),
46
+ forEachStaged: (slot, visit) => {
47
+ for (const entry of slot.commands)
48
+ visit(entry.name, entry);
49
+ },
50
+ push: (slot, entry) => {
51
+ slot.commands.push(entry);
52
+ },
53
+ collect: (sink, pluginId, entry) => {
54
+ sink.commands.push({ pluginId, ...entry });
55
+ },
56
+ assertManifestExtras: (manifest) => {
57
+ for (const command of manifest.contributes?.commands ?? []) {
58
+ assertUnique(command.sessionOps ?? [], `contributes.commands.${command.name}.sessionOps`);
59
+ }
60
+ },
61
+ reconcileExtra: (manifest, slot) => {
62
+ const declared = new Map((manifest.contributes?.commands ?? []).map((command) => [command.name, command.sessionOps ?? []]));
63
+ for (const command of slot.commands) {
64
+ const expected = declared.get(command.name) ?? [];
65
+ const actual = command.sessionOps ?? [];
66
+ if (JSON.stringify([...expected].sort()) !== JSON.stringify([...actual].sort())) {
67
+ throw new Error(`Command "${command.name}" sessionOps differ from manifest`);
68
+ }
69
+ }
70
+ },
71
+ };
72
+ const hooks = {
73
+ field: 'hooks',
74
+ label: 'hook',
75
+ globallyUnique: false,
76
+ perPluginUnique: false,
77
+ reservedIds: [],
78
+ keyOf: (entry) => entry.hookName,
79
+ declaredKeys: (manifest) => manifest.contributes?.hooks ?? [],
80
+ forEachStaged: (slot, visit) => {
81
+ for (const [hookName, entries] of slot.hooks) {
82
+ for (const entry of entries)
83
+ visit(hookName, entry);
84
+ }
85
+ },
86
+ push: (slot, entry) => {
87
+ const entries = [...(slot.hooks.get(entry.hookName) ?? []), entry];
88
+ entries.sort((a, b) => b.priority - a.priority);
89
+ slot.hooks.set(entry.hookName, entries);
90
+ },
91
+ collect: (sink, _pluginId, entry) => {
92
+ // Invariant: entry.pluginId is stamped with PluginApi.id at registration
93
+ // (api.ts `on`), and publish only ever iterates that plugin's own staging.
94
+ sink.hooks.push(entry);
95
+ },
96
+ };
97
+ const services = {
98
+ field: 'services',
99
+ label: 'service',
100
+ globallyUnique: true,
101
+ perPluginUnique: true,
102
+ reservedIds: [],
103
+ keyOf: (entry) => entry.serviceId,
104
+ declaredKeys: (manifest) => manifest.contributes?.services ?? [],
105
+ forEachStaged: (slot, visit) => {
106
+ for (const entry of slot.services)
107
+ visit(entry.serviceId, entry);
108
+ },
109
+ push: (slot, entry) => {
110
+ slot.services.push(entry);
111
+ },
112
+ collect: (sink, pluginId, entry) => {
113
+ sink.services.push({ pluginId, ...entry });
114
+ },
115
+ };
116
+ const providers = {
117
+ field: 'providers',
118
+ label: 'provider',
119
+ globallyUnique: true,
120
+ perPluginUnique: true,
121
+ reservedIds: [],
122
+ keyOf: (entry) => entry.id,
123
+ declaredKeys: (manifest) => manifest.contributes?.providers ?? [],
124
+ forEachStaged: (slot, visit) => {
125
+ for (const entry of slot.providers)
126
+ visit(entry.id, entry);
127
+ },
128
+ push: (slot, entry) => {
129
+ slot.providers.push(entry);
130
+ },
131
+ collect: (sink, pluginId, entry) => {
132
+ sink.providers.push({ pluginId, ...entry });
133
+ },
134
+ bindInstances: (entry, instances) => ({
135
+ ...entry,
136
+ // The Host calls acceptInstance after validating the factory product
137
+ // (config.ts::createProviderFromConfig) — birth means Host acceptance.
138
+ acceptInstance: (instance, label) => instances.attach({
139
+ kind: 'provider',
140
+ key: entry.id,
141
+ label,
142
+ instance,
143
+ retireMethod: 'dispose',
144
+ // dispose is optional on ModelProvider — define it as a retirement
145
+ // marker so Host teardown always retires the registry entry.
146
+ defineRetire: true,
147
+ }),
148
+ }),
149
+ };
150
+ const channels = {
151
+ field: 'channels',
152
+ label: 'channel',
153
+ globallyUnique: true,
154
+ perPluginUnique: true,
155
+ reservedIds: BUILTIN_CHANNEL_IDS,
156
+ keyOf: (entry) => entry.id,
157
+ declaredKeys: (manifest) => manifest.contributes?.channels ?? [],
158
+ forEachStaged: (slot, visit) => {
159
+ for (const entry of slot.channels)
160
+ visit(entry.id, entry);
161
+ },
162
+ push: (slot, entry) => {
163
+ slot.channels.push(entry);
164
+ },
165
+ collect: (sink, pluginId, entry) => {
166
+ sink.channels.push({ pluginId, ...entry });
167
+ },
168
+ bindInstances: (entry, instances) => ({
169
+ ...entry,
170
+ // The Host calls acceptInstance after validating the factory product
171
+ // (config.ts::createChannelAdapterFromConfig) — birth means Host acceptance.
172
+ acceptInstance: (instance, label) => instances.attach({
173
+ kind: 'channel',
174
+ key: entry.id,
175
+ label,
176
+ instance,
177
+ retireMethod: 'stop',
178
+ // stop is mandatory on ChannelAdapter — never add it here, or the
179
+ // Host's contract validation would stop reporting broken adapters.
180
+ defineRetire: false,
181
+ }),
182
+ }),
183
+ };
184
+ /**
185
+ * Every contribution kind in manifest-schema order. Iteration order is
186
+ * observable in first-failure diagnostics and record ordering — keep it aligned
187
+ * with the `contributes` schema field order.
188
+ */
189
+ export const CONTRIBUTION_KINDS = [
190
+ tools,
191
+ commands,
192
+ hooks,
193
+ services,
194
+ providers,
195
+ channels,
196
+ ];
197
+ /** Typed staging slots for the author-facing register methods. */
198
+ export const TOOL_KIND = tools;
199
+ export const COMMAND_KIND = commands;
200
+ export const HOOK_KIND = hooks;
201
+ export const SERVICE_KIND = services;
202
+ export const PROVIDER_KIND = providers;
203
+ export const CHANNEL_KIND = channels;
204
+ function capitalize(label) {
205
+ return label.charAt(0).toUpperCase() + label.slice(1);
206
+ }
207
+ /**
208
+ * Reject a manifest key list containing duplicates.
209
+ *
210
+ * @param values - Declared contribution keys
211
+ * @param field - Manifest field path for the error message
212
+ */
213
+ export function assertUnique(values, field) {
214
+ if (new Set(values).size !== values.length) {
215
+ throw new Error(`Plugin manifest ${field} contains duplicate entries`);
216
+ }
217
+ }
218
+ /**
219
+ * Enforce per-kind key uniqueness of the manifest `contributes` block, plus
220
+ * kind-specific manifest checks.
221
+ *
222
+ * @param manifest - Plugin manifest
223
+ * @throws Error naming the first duplicated key
224
+ */
225
+ export function assertManifestKeysUnique(manifest) {
226
+ for (const kind of CONTRIBUTION_KINDS) {
227
+ assertUnique(kind.declaredKeys(manifest), `contributes.${kind.field}`);
228
+ kind.assertManifestExtras?.(manifest);
229
+ }
230
+ }
231
+ /**
232
+ * Reject a contribution key a plugin may never claim (built-in adapters).
233
+ *
234
+ * @param pluginId - Staging plugin
235
+ * @param kind - Contribution kind being staged
236
+ * @param key - Normalized contribution key
237
+ */
238
+ export function assertClaimable(pluginId, kind, key) {
239
+ if (kind.reservedIds.includes(key)) {
240
+ throw new Error(`Plugin "${pluginId}" cannot register ${kind.label} "${key}": reserved by built-in adapters`);
241
+ }
242
+ }
243
+ /**
244
+ * Reject a duplicate key staged twice by one plugin.
245
+ *
246
+ * @param pluginId - Staging plugin
247
+ * @param kind - Contribution kind being staged
248
+ * @param slot - The plugin's staging area
249
+ * @param key - Normalized contribution key
250
+ */
251
+ export function assertStagingKeyFree(pluginId, kind, slot, key) {
252
+ if (!kind.perPluginUnique)
253
+ return;
254
+ let duplicate = false;
255
+ kind.forEachStaged(slot, (stagedKey) => {
256
+ if (stagedKey === key)
257
+ duplicate = true;
258
+ });
259
+ if (duplicate) {
260
+ throw new Error(`Plugin "${pluginId}" registered duplicate ${kind.label} "${key}"`);
261
+ }
262
+ }
263
+ /**
264
+ * The staging write path shared by every register method: reserved-id and
265
+ * per-plugin uniqueness checks, then the kind's own staging insert.
266
+ *
267
+ * @param pluginId - Staging plugin
268
+ * @param kind - Contribution kind being staged
269
+ * @param slot - The plugin's staging area
270
+ * @param entry - Contribution entry to stage
271
+ */
272
+ export function stageContribution(pluginId, kind, slot, entry) {
273
+ const key = kind.keyOf(entry);
274
+ assertClaimable(pluginId, kind, key);
275
+ assertStagingKeyFree(pluginId, kind, slot, key);
276
+ kind.push(slot, entry);
277
+ }
278
+ /**
279
+ * Manifest-side ownership claim strings ("provider:openai-compat") used by the
280
+ * loader's cross-plugin conflict detection. Kinds without cross-plugin
281
+ * ownership (hooks) declare no claims.
282
+ *
283
+ * @param kind - Contribution kind
284
+ * @param manifest - Candidate manifest
285
+ * @returns Claim strings for every declared key of the kind
286
+ */
287
+ export function declaredClaims(kind, manifest) {
288
+ if (!kind.globallyUnique)
289
+ return [];
290
+ return kind.declaredKeys(manifest).map((key) => `${kind.label}:${key}`);
291
+ }
292
+ /**
293
+ * Reconcile the manifest `contributes` block against what the plugin actually
294
+ * staged: both directions must match exactly, then kind-specific checks run.
295
+ *
296
+ * @param kind - Contribution kind
297
+ * @param manifest - Plugin manifest
298
+ * @param slot - The plugin's staging area
299
+ * @throws Error naming the first mismatched key
300
+ */
301
+ export function assertManifestCoverage(kind, manifest, slot) {
302
+ const declared = new Set(kind.declaredKeys(manifest));
303
+ const actual = new Set();
304
+ kind.forEachStaged(slot, (key) => actual.add(key));
305
+ for (const key of actual) {
306
+ if (!declared.has(key))
307
+ throw new Error(`${capitalize(kind.label)} "${key}" is not declared in manifest`);
308
+ }
309
+ for (const key of declared) {
310
+ if (!actual.has(key))
311
+ throw new Error(`Declared ${kind.label} "${key}" was not registered`);
312
+ }
313
+ kind.reconcileExtra?.(manifest, slot);
314
+ }
@@ -4,7 +4,7 @@ import type { HookServiceRegistration } from '../hooks/types.js';
4
4
  export interface PluginServiceRecord extends HookServiceRegistration {
5
5
  pluginId: string;
6
6
  }
7
- import type { PluginApi } from './api.js';
7
+ import type { PluginApi, PluginProviderFactory, PluginChannelFactory } from './api.js';
8
8
  import type { PluginCommandRegistration, PluginToolContribution, OrderedHookEntry } from './api.js';
9
9
  export interface RegisteredPlugin {
10
10
  manifest: PluginManifest;
@@ -21,13 +21,31 @@ export interface PluginToolRecord extends PluginToolContribution {
21
21
  export interface PluginCommandRecord extends PluginCommandRegistration {
22
22
  pluginId: string;
23
23
  }
24
+ /** A published provider factory contribution; globally unique id, like services. */
25
+ export interface PluginProviderRecord {
26
+ pluginId: string;
27
+ id: string;
28
+ factory: PluginProviderFactory;
29
+ /**
30
+ * Host-private instance-registration hook (see contribution-kinds
31
+ * `bindInstances`). Hosts MUST call it with the accepted factory product —
32
+ * after contract validation, before any Host-side decorator wraps it — so
33
+ * the instance registry's notion of "live" matches what the Host routes to.
34
+ */
35
+ acceptInstance?(instance: object, label: string): boolean;
36
+ }
37
+ /** A published channel factory contribution; globally unique id, like providers. */
38
+ export interface PluginChannelRecord {
39
+ pluginId: string;
40
+ id: string;
41
+ factory: PluginChannelFactory;
42
+ /** Host-private instance-registration hook; see PluginProviderRecord.acceptInstance. */
43
+ acceptInstance?(instance: object, label: string): boolean;
44
+ }
24
45
  /** An immutable published contribution set. Mutations are staged by PluginLoader. */
25
46
  export declare class PluginContributionRegistry {
26
47
  private plugins;
27
- private tools;
28
- private commands;
29
- private hooks;
30
- private services;
48
+ private records;
31
49
  private owners;
32
50
  /** Replace the effective set only after all staged registrations validate. */
33
51
  publish(plugins: readonly RegisteredPlugin[]): void;
@@ -40,4 +58,21 @@ export declare class PluginContributionRegistry {
40
58
  getCommands(): PluginCommandRecord[];
41
59
  getHooks(): OrderedHookEntry[];
42
60
  getServices(): PluginServiceRecord[];
61
+ getProviders(): PluginProviderRecord[];
62
+ getChannels(): PluginChannelRecord[];
63
+ /**
64
+ * Roll back an accepted-but-never-installed instance across all plugin
65
+ * instance tables (see ContributionInstanceTable.discardByInstance).
66
+ *
67
+ * @param instance - The instance the Host validated but never routed to
68
+ */
69
+ discardInstance(instance: object): void;
70
+ /**
71
+ * Logical retirement by instance identity across all plugin instance tables
72
+ * (see ContributionInstanceTable.retireByInstance) — called when the Host
73
+ * stops routing to an instance.
74
+ *
75
+ * @param instance - The instance the Host stopped routing to
76
+ */
77
+ retireInstance(instance: object): void;
43
78
  }
@@ -1,12 +1,14 @@
1
1
  /** Host-level effective contribution registry; per-Agent buses are mount projections. */
2
+ import { CONTRIBUTION_KINDS } from './contribution-kinds.js';
3
+ import { readInstanceTable } from './contribution-instances.js';
2
4
  import { readStaging } from './staging.js';
5
+ function emptySink() {
6
+ return { tools: [], commands: [], hooks: [], services: [], providers: [], channels: [] };
7
+ }
3
8
  /** An immutable published contribution set. Mutations are staged by PluginLoader. */
4
9
  export class PluginContributionRegistry {
5
10
  plugins = new Map();
6
- tools = [];
7
- commands = [];
8
- hooks = [];
9
- services = [];
11
+ records = emptySink();
10
12
  owners = new Map();
11
13
  /** Replace the effective set only after all staged registrations validate. */
12
14
  publish(plugins) {
@@ -14,30 +16,24 @@ export class PluginContributionRegistry {
14
16
  for (const plugin of plugins) {
15
17
  next.plugins.set(plugin.manifest.id, plugin);
16
18
  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 });
19
+ for (const kind of CONTRIBUTION_KINDS) {
20
+ kind.forEachStaged(staged, (key, entry) => {
21
+ if (kind.globallyUnique)
22
+ next.addOwner(kind.label, key, plugin.manifest.id);
23
+ const bound = kind.bindInstances?.(entry, readInstanceTable(plugin.api)) ?? entry;
24
+ if (kind.bindInstances !== undefined && typeof bound.acceptInstance !== 'function') {
25
+ throw new Error(`contribution kind "${kind.label}" is factory-backed but bindInstances did not wire acceptInstance`);
26
+ }
27
+ kind.collect(next.records, plugin.manifest.id, bound);
28
+ });
30
29
  }
31
30
  }
32
- const replyOwners = next.hooks.filter((entry) => entry.hookName === 'before_agent_reply');
31
+ const replyOwners = next.records.hooks.filter((entry) => entry.hookName === 'before_agent_reply');
33
32
  if (replyOwners.length > 1) {
34
33
  throw new Error(`Override hook before_agent_reply has multiple owners: ${replyOwners.map((entry) => entry.pluginId).join(', ')}`);
35
34
  }
36
35
  this.plugins = next.plugins;
37
- this.tools = next.tools;
38
- this.commands = next.commands;
39
- this.hooks = next.hooks;
40
- this.services = next.services;
36
+ this.records = next.records;
41
37
  this.owners = next.owners;
42
38
  }
43
39
  /** Clear the effective set before a fresh discovery attempt. */
@@ -54,8 +50,31 @@ export class PluginContributionRegistry {
54
50
  }
55
51
  getPlugins() { return [...this.plugins.values()]; }
56
52
  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]; }
53
+ getTools() { return [...this.records.tools]; }
54
+ getCommands() { return [...this.records.commands]; }
55
+ getHooks() { return [...this.records.hooks]; }
56
+ getServices() { return [...this.records.services]; }
57
+ getProviders() { return [...this.records.providers]; }
58
+ getChannels() { return [...this.records.channels]; }
59
+ /**
60
+ * Roll back an accepted-but-never-installed instance across all plugin
61
+ * instance tables (see ContributionInstanceTable.discardByInstance).
62
+ *
63
+ * @param instance - The instance the Host validated but never routed to
64
+ */
65
+ discardInstance(instance) {
66
+ for (const plugin of this.plugins.values())
67
+ readInstanceTable(plugin.api).discardByInstance(instance);
68
+ }
69
+ /**
70
+ * Logical retirement by instance identity across all plugin instance tables
71
+ * (see ContributionInstanceTable.retireByInstance) — called when the Host
72
+ * stops routing to an instance.
73
+ *
74
+ * @param instance - The instance the Host stopped routing to
75
+ */
76
+ retireInstance(instance) {
77
+ for (const plugin of this.plugins.values())
78
+ readInstanceTable(plugin.api).retireByInstance(instance);
79
+ }
61
80
  }
@@ -2,6 +2,6 @@
2
2
  export { definePlugin } from './entry.js';
3
3
  export type { OctopiPluginDefinition } from './entry.js';
4
4
  export { PluginApi } from './api.js';
5
- export type { PluginLogger, PluginCommandRegistration, PluginCommandContext, PluginHookMap, HookHandler, HookRegistrationOptions, ToolRegistrationOptions, } from './api.js';
5
+ export type { PluginLogger, PluginCommandRegistration, PluginCommandContext, PluginHookMap, HookHandler, HookRegistrationOptions, ToolRegistrationOptions, PluginProviderFactory, PluginProviderFactoryContext, PluginProviderModelEntry, PluginProviderRegistration, PluginChannelFactory, PluginChannelFactoryContext, PluginChannelRegistration, PluginChannelAdapterLike, ContributionInstanceKind, } from './api.js';
6
6
  export { PLUGIN_API_VERSION, PLUGIN_HOOK_NAMES, validateManifest, parseManifest, validatePluginConfig, } from './manifest.js';
7
7
  export type { PluginManifest, PluginContributions, PluginCommandContribution, PluginHookName, PluginSessionOpName, JsonSchema, } from './manifest.js';
@@ -11,6 +11,17 @@ export interface PluginEntryConfig {
11
11
  timeouts?: Record<string, number>;
12
12
  };
13
13
  }
14
+ /**
15
+ * Resolve a manifest entry to its real path inside the plugin root. Shared
16
+ * single source for the loader and `octopi plugin doctor`: rejects entries
17
+ * that escape the plugin root (before and after symlink resolution).
18
+ *
19
+ * @param rootDir - Plugin directory
20
+ * @param entry - Manifest `entry` (relative path)
21
+ * @returns The real path of the entry file
22
+ * @throws When the entry is missing, escapes its root, or is not a file
23
+ */
24
+ export declare function resolvePluginEntry(rootDir: string, entry: string): string;
14
25
  export interface PluginLoaderConfig {
15
26
  loadPaths: string[];
16
27
  allowList?: string[];
@@ -55,7 +66,6 @@ export declare class PluginLoader {
55
66
  private markDependencyFailures;
56
67
  private checkDeclaredConflicts;
57
68
  private importAndRegister;
58
- private resolveEntry;
59
69
  private assertActualContributions;
60
70
  private disabled;
61
71
  private fail;
@@ -3,10 +3,34 @@ import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs';
3
3
  import { join, relative, resolve, sep } from 'node:path';
4
4
  import { pathToFileURL } from 'node:url';
5
5
  import { PluginApi } from './api.js';
6
+ import { CONTRIBUTION_KINDS, assertManifestCoverage, declaredClaims } from './contribution-kinds.js';
6
7
  import { parseManifest, validatePluginConfig, } from './manifest.js';
7
8
  import { PluginContributionRegistry, } from './contribution-registry.js';
8
9
  import { getEngineVersion, satisfiesEngineRange } from './engine-compatibility.js';
9
10
  import { readStaging } from './staging.js';
11
+ /**
12
+ * Resolve a manifest entry to its real path inside the plugin root. Shared
13
+ * single source for the loader and `octopi plugin doctor`: rejects entries
14
+ * that escape the plugin root (before and after symlink resolution).
15
+ *
16
+ * @param rootDir - Plugin directory
17
+ * @param entry - Manifest `entry` (relative path)
18
+ * @returns The real path of the entry file
19
+ * @throws When the entry is missing, escapes its root, or is not a file
20
+ */
21
+ export function resolvePluginEntry(rootDir, entry) {
22
+ const root = realpathSync(rootDir);
23
+ const candidate = resolve(root, entry);
24
+ if (relative(root, candidate).startsWith(`..${sep}`) || relative(root, candidate) === '..') {
25
+ throw new Error(`Plugin entry escapes its root: ${entry}`);
26
+ }
27
+ const real = realpathSync(candidate);
28
+ const rel = relative(root, real);
29
+ if (rel === '..' || rel.startsWith(`..${sep}`)) {
30
+ throw new Error(`Plugin entry realpath escapes its root: ${entry}`);
31
+ }
32
+ return real;
33
+ }
10
34
  const PLUGIN_MANIFEST_FILENAME = 'octopi.plugin.json';
11
35
  export class PluginLoader {
12
36
  contributions = new PluginContributionRegistry();
@@ -118,7 +142,8 @@ export class PluginLoader {
118
142
  if (existsSync(join(root, PLUGIN_MANIFEST_FILENAME)))
119
143
  return [root];
120
144
  return stat
121
- .filter((entry) => entry.isDirectory() && existsSync(join(root, entry.name, PLUGIN_MANIFEST_FILENAME)))
145
+ // Dot-dirs are never plugin candidates (sync scratch `.sync-*`, VCS, hidden).
146
+ .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.') && existsSync(join(root, entry.name, PLUGIN_MANIFEST_FILENAME)))
122
147
  .map((entry) => join(root, entry.name));
123
148
  }
124
149
  catch (error) {
@@ -190,7 +215,7 @@ export class PluginLoader {
190
215
  }
191
216
  prepareCandidate(candidate) {
192
217
  try {
193
- candidate.entryPoint = this.resolveEntry(candidate.rootDir, candidate.manifest.entry);
218
+ candidate.entryPoint = resolvePluginEntry(candidate.rootDir, candidate.manifest.entry);
194
219
  candidate.pluginConfig = validatePluginConfig(candidate.manifest, candidate.config?.config);
195
220
  const engineVersion = this.config.engineVersion ?? getEngineVersion();
196
221
  if (!satisfiesEngineRange(engineVersion, candidate.manifest.engine.octopi)) {
@@ -238,24 +263,21 @@ export class PluginLoader {
238
263
  for (const candidate of candidates.values()) {
239
264
  if (!candidate.eligible)
240
265
  continue;
241
- const entries = [
242
- ...(candidate.manifest.contributes?.tools ?? []).map((name) => `tool:${name}`),
243
- ...(candidate.manifest.contributes?.commands ?? []).map((command) => `command:${command.name}`),
244
- ...(candidate.manifest.contributes?.services ?? []).map((name) => `service:${name}`),
245
- ];
246
- for (const claim of entries) {
247
- const owner = claims.get(claim);
248
- if (owner) {
249
- this.fail(candidate.id, 'register', new Error(`Declared ${claim} conflicts with "${owner}"`), candidate.rootDir);
250
- candidate.eligible = false;
251
- const first = candidates.get(owner);
252
- if (first) {
253
- first.eligible = false;
254
- this.fail(owner, 'register', new Error(`Declared ${claim} conflicts with "${candidate.id}"`), first.rootDir);
266
+ for (const kind of CONTRIBUTION_KINDS) {
267
+ for (const claim of declaredClaims(kind, candidate.manifest)) {
268
+ const owner = claims.get(claim);
269
+ if (owner) {
270
+ this.fail(candidate.id, 'register', new Error(`Declared ${claim} conflicts with "${owner}"`), candidate.rootDir);
271
+ candidate.eligible = false;
272
+ const first = candidates.get(owner);
273
+ if (first) {
274
+ first.eligible = false;
275
+ this.fail(owner, 'register', new Error(`Declared ${claim} conflicts with "${candidate.id}"`), first.rootDir);
276
+ }
255
277
  }
278
+ else
279
+ claims.set(claim, candidate.id);
256
280
  }
257
- else
258
- claims.set(claim, candidate.id);
259
281
  }
260
282
  }
261
283
  }
@@ -289,66 +311,10 @@ export class PluginLoader {
289
311
  return null;
290
312
  }
291
313
  }
292
- resolveEntry(rootDir, entry) {
293
- const root = realpathSync(rootDir);
294
- const candidate = resolve(root, entry);
295
- if (relative(root, candidate).startsWith(`..${sep}`) || relative(root, candidate) === '..') {
296
- throw new Error(`Plugin entry escapes its root: ${entry}`);
297
- }
298
- const real = realpathSync(candidate);
299
- const rel = relative(root, real);
300
- if (rel === '..' || rel.startsWith(`..${sep}`)) {
301
- throw new Error(`Plugin entry realpath escapes its root: ${entry}`);
302
- }
303
- return real;
304
- }
305
314
  assertActualContributions(manifest, api) {
306
315
  const staged = readStaging(api);
307
- const declaredTools = new Set(manifest.contributes?.tools ?? []);
308
- const actualTools = new Set(staged.tools.map((tool) => tool.definition.name));
309
- const declaredCommands = new Map((manifest.contributes?.commands ?? []).map((command) => [command.name, command.sessionOps ?? []]));
310
- for (const tool of actualTools) {
311
- if (!declaredTools.has(tool))
312
- throw new Error(`Tool "${tool}" is not declared in manifest`);
313
- }
314
- for (const tool of declaredTools) {
315
- if (!actualTools.has(tool))
316
- throw new Error(`Declared tool "${tool}" was not registered`);
317
- }
318
- const actualCommands = new Set(staged.commands.map((command) => command.name));
319
- for (const command of actualCommands) {
320
- if (!declaredCommands.has(command))
321
- throw new Error(`Command "${command}" is not declared in manifest`);
322
- }
323
- for (const command of declaredCommands.keys()) {
324
- if (!actualCommands.has(command))
325
- throw new Error(`Declared command "${command}" was not registered`);
326
- }
327
- for (const command of staged.commands) {
328
- const declared = declaredCommands.get(command.name) ?? [];
329
- const actual = command.sessionOps ?? [];
330
- if (JSON.stringify([...declared].sort()) !== JSON.stringify([...actual].sort())) {
331
- throw new Error(`Command "${command.name}" sessionOps differ from manifest`);
332
- }
333
- }
334
- const declaredHooks = new Set(manifest.contributes?.hooks ?? []);
335
- for (const hook of staged.hooks.keys()) {
336
- if (!declaredHooks.has(hook))
337
- throw new Error(`Hook "${hook}" is not declared in manifest`);
338
- }
339
- for (const hook of declaredHooks) {
340
- if (!staged.hooks.has(hook))
341
- throw new Error(`Declared hook "${hook}" was not registered`);
342
- }
343
- const declaredServices = new Set(manifest.contributes?.services ?? []);
344
- const actualServices = new Set(staged.services.map((service) => service.serviceId));
345
- for (const service of actualServices) {
346
- if (!declaredServices.has(service))
347
- throw new Error(`Service "${service}" is not declared in manifest`);
348
- }
349
- for (const service of declaredServices) {
350
- if (!actualServices.has(service))
351
- throw new Error(`Declared service "${service}" was not registered`);
316
+ for (const kind of CONTRIBUTION_KINDS) {
317
+ assertManifestCoverage(kind, manifest, staged);
352
318
  }
353
319
  }
354
320
  disabled(candidate, reason) {