comisai 1.0.11 → 1.0.13

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 (255) hide show
  1. package/node_modules/@comis/agent/dist/model/operation-model-defaults.js +1 -0
  2. package/node_modules/@comis/agent/dist/session/comis-session-manager.js +9 -9
  3. package/node_modules/@comis/agent/package.json +1 -1
  4. package/node_modules/@comis/channels/package.json +1 -1
  5. package/node_modules/@comis/cli/package.json +1 -1
  6. package/node_modules/@comis/core/dist/event-bus/events-infra.d.ts +2 -0
  7. package/node_modules/@comis/core/package.json +1 -1
  8. package/node_modules/@comis/daemon/dist/wiring/setup-channels.js +12 -1
  9. package/node_modules/@comis/daemon/dist/wiring/setup-gateway.js +1 -0
  10. package/node_modules/@comis/daemon/dist/wiring/setup-schedulers.js +1 -0
  11. package/node_modules/@comis/daemon/package.json +1 -1
  12. package/node_modules/@comis/gateway/package.json +1 -1
  13. package/node_modules/@comis/infra/package.json +1 -1
  14. package/node_modules/@comis/memory/package.json +1 -1
  15. package/node_modules/@comis/scheduler/dist/cron/cron-types.d.ts +6 -0
  16. package/node_modules/@comis/scheduler/dist/cron/cron-types.js +2 -0
  17. package/node_modules/@comis/scheduler/package.json +1 -1
  18. package/node_modules/@comis/shared/package.json +1 -1
  19. package/node_modules/@comis/skills/dist/builtin/platform/gateway-tool.d.ts +1 -1
  20. package/node_modules/@comis/skills/package.json +1 -1
  21. package/package.json +18 -18
  22. package/node_modules/@comis/core/dist/approval/approval-gate.test.d.ts +0 -1
  23. package/node_modules/@comis/core/dist/approval/approval-gate.test.js +0 -1003
  24. package/node_modules/@comis/core/dist/bootstrap.test.d.ts +0 -1
  25. package/node_modules/@comis/core/dist/bootstrap.test.js +0 -150
  26. package/node_modules/@comis/core/dist/config/backup.test.d.ts +0 -1
  27. package/node_modules/@comis/core/dist/config/backup.test.js +0 -160
  28. package/node_modules/@comis/core/dist/config/env-substitution.test.d.ts +0 -1
  29. package/node_modules/@comis/core/dist/config/env-substitution.test.js +0 -259
  30. package/node_modules/@comis/core/dist/config/field-metadata.test.d.ts +0 -1
  31. package/node_modules/@comis/core/dist/config/field-metadata.test.js +0 -72
  32. package/node_modules/@comis/core/dist/config/git-manager.test.d.ts +0 -1
  33. package/node_modules/@comis/core/dist/config/git-manager.test.js +0 -1042
  34. package/node_modules/@comis/core/dist/config/immutable-keys.test.d.ts +0 -1
  35. package/node_modules/@comis/core/dist/config/immutable-keys.test.js +0 -283
  36. package/node_modules/@comis/core/dist/config/include-resolver.test.d.ts +0 -1
  37. package/node_modules/@comis/core/dist/config/include-resolver.test.js +0 -292
  38. package/node_modules/@comis/core/dist/config/layered.test.d.ts +0 -1
  39. package/node_modules/@comis/core/dist/config/layered.test.js +0 -211
  40. package/node_modules/@comis/core/dist/config/loader.test.d.ts +0 -1
  41. package/node_modules/@comis/core/dist/config/loader.test.js +0 -300
  42. package/node_modules/@comis/core/dist/config/migrate.test.d.ts +0 -1
  43. package/node_modules/@comis/core/dist/config/migrate.test.js +0 -244
  44. package/node_modules/@comis/core/dist/config/partial-validator.test.d.ts +0 -1
  45. package/node_modules/@comis/core/dist/config/partial-validator.test.js +0 -98
  46. package/node_modules/@comis/core/dist/config/schema-agent-model.test.d.ts +0 -1
  47. package/node_modules/@comis/core/dist/config/schema-agent-model.test.js +0 -279
  48. package/node_modules/@comis/core/dist/config/schema-agent-session.test.d.ts +0 -1
  49. package/node_modules/@comis/core/dist/config/schema-agent-session.test.js +0 -242
  50. package/node_modules/@comis/core/dist/config/schema-agent.test.d.ts +0 -1
  51. package/node_modules/@comis/core/dist/config/schema-agent.test.js +0 -645
  52. package/node_modules/@comis/core/dist/config/schema-channel.test.d.ts +0 -1
  53. package/node_modules/@comis/core/dist/config/schema-channel.test.js +0 -341
  54. package/node_modules/@comis/core/dist/config/schema-coalescer.test.d.ts +0 -1
  55. package/node_modules/@comis/core/dist/config/schema-coalescer.test.js +0 -51
  56. package/node_modules/@comis/core/dist/config/schema-context-engine.test.d.ts +0 -1
  57. package/node_modules/@comis/core/dist/config/schema-context-engine.test.js +0 -797
  58. package/node_modules/@comis/core/dist/config/schema-context-guard.test.d.ts +0 -1
  59. package/node_modules/@comis/core/dist/config/schema-context-guard.test.js +0 -111
  60. package/node_modules/@comis/core/dist/config/schema-daemon.test.d.ts +0 -1
  61. package/node_modules/@comis/core/dist/config/schema-daemon.test.js +0 -107
  62. package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.d.ts +0 -1
  63. package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.js +0 -51
  64. package/node_modules/@comis/core/dist/config/schema-documentation.test.d.ts +0 -1
  65. package/node_modules/@comis/core/dist/config/schema-documentation.test.js +0 -63
  66. package/node_modules/@comis/core/dist/config/schema-gateway.test.d.ts +0 -1
  67. package/node_modules/@comis/core/dist/config/schema-gateway.test.js +0 -219
  68. package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.d.ts +0 -1
  69. package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.js +0 -41
  70. package/node_modules/@comis/core/dist/config/schema-integrations.test.d.ts +0 -1
  71. package/node_modules/@comis/core/dist/config/schema-integrations.test.js +0 -92
  72. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.d.ts +0 -1
  73. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.js +0 -61
  74. package/node_modules/@comis/core/dist/config/schema-misc.test.d.ts +0 -1
  75. package/node_modules/@comis/core/dist/config/schema-misc.test.js +0 -394
  76. package/node_modules/@comis/core/dist/config/schema-observability.test.d.ts +0 -1
  77. package/node_modules/@comis/core/dist/config/schema-observability.test.js +0 -76
  78. package/node_modules/@comis/core/dist/config/schema-providers.test.d.ts +0 -1
  79. package/node_modules/@comis/core/dist/config/schema-providers.test.js +0 -294
  80. package/node_modules/@comis/core/dist/config/schema-queue.test.d.ts +0 -1
  81. package/node_modules/@comis/core/dist/config/schema-queue.test.js +0 -234
  82. package/node_modules/@comis/core/dist/config/schema-response-prefix.test.d.ts +0 -1
  83. package/node_modules/@comis/core/dist/config/schema-response-prefix.test.js +0 -36
  84. package/node_modules/@comis/core/dist/config/schema-security.test.d.ts +0 -1
  85. package/node_modules/@comis/core/dist/config/schema-security.test.js +0 -54
  86. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.d.ts +0 -1
  87. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.js +0 -60
  88. package/node_modules/@comis/core/dist/config/schema-serializer.test.d.ts +0 -1
  89. package/node_modules/@comis/core/dist/config/schema-serializer.test.js +0 -73
  90. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.d.ts +0 -1
  91. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.js +0 -39
  92. package/node_modules/@comis/core/dist/context/context.test.d.ts +0 -1
  93. package/node_modules/@comis/core/dist/context/context.test.js +0 -276
  94. package/node_modules/@comis/core/dist/domain/agent-response.test.d.ts +0 -1
  95. package/node_modules/@comis/core/dist/domain/agent-response.test.js +0 -159
  96. package/node_modules/@comis/core/dist/domain/credential-mapping.test.d.ts +0 -1
  97. package/node_modules/@comis/core/dist/domain/credential-mapping.test.js +0 -135
  98. package/node_modules/@comis/core/dist/domain/delivery-origin.test.d.ts +0 -1
  99. package/node_modules/@comis/core/dist/domain/delivery-origin.test.js +0 -68
  100. package/node_modules/@comis/core/dist/domain/execution-graph.test.d.ts +0 -1
  101. package/node_modules/@comis/core/dist/domain/execution-graph.test.js +0 -441
  102. package/node_modules/@comis/core/dist/domain/memory-entry.test.d.ts +0 -1
  103. package/node_modules/@comis/core/dist/domain/memory-entry.test.js +0 -193
  104. package/node_modules/@comis/core/dist/domain/normalized-message.test.d.ts +0 -1
  105. package/node_modules/@comis/core/dist/domain/normalized-message.test.js +0 -255
  106. package/node_modules/@comis/core/dist/domain/session-key.test.d.ts +0 -1
  107. package/node_modules/@comis/core/dist/domain/session-key.test.js +0 -291
  108. package/node_modules/@comis/core/dist/domain/subagent-context-config.test.d.ts +0 -1
  109. package/node_modules/@comis/core/dist/domain/subagent-context-config.test.js +0 -131
  110. package/node_modules/@comis/core/dist/domain/subagent-context-types.test.d.ts +0 -1
  111. package/node_modules/@comis/core/dist/domain/subagent-context-types.test.js +0 -182
  112. package/node_modules/@comis/core/dist/event-bus/bus.test.d.ts +0 -1
  113. package/node_modules/@comis/core/dist/event-bus/bus.test.js +0 -152
  114. package/node_modules/@comis/core/dist/event-bus/events-agent.test.d.ts +0 -1
  115. package/node_modules/@comis/core/dist/event-bus/events-agent.test.js +0 -409
  116. package/node_modules/@comis/core/dist/event-bus/events-channel.test.d.ts +0 -1
  117. package/node_modules/@comis/core/dist/event-bus/events-channel.test.js +0 -240
  118. package/node_modules/@comis/core/dist/event-bus/events-infra.test.d.ts +0 -1
  119. package/node_modules/@comis/core/dist/event-bus/events-infra.test.js +0 -416
  120. package/node_modules/@comis/core/dist/event-bus/events-messaging.test.d.ts +0 -1
  121. package/node_modules/@comis/core/dist/event-bus/events-messaging.test.js +0 -433
  122. package/node_modules/@comis/core/dist/event-bus/events.test.d.ts +0 -1
  123. package/node_modules/@comis/core/dist/event-bus/events.test.js +0 -93
  124. package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.d.ts +0 -1
  125. package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.js +0 -29
  126. package/node_modules/@comis/core/dist/hooks/hook-runner.test.d.ts +0 -1
  127. package/node_modules/@comis/core/dist/hooks/hook-runner.test.js +0 -490
  128. package/node_modules/@comis/core/dist/hooks/hook-strategies.test.d.ts +0 -1
  129. package/node_modules/@comis/core/dist/hooks/hook-strategies.test.js +0 -209
  130. package/node_modules/@comis/core/dist/hooks/integration.test.d.ts +0 -1
  131. package/node_modules/@comis/core/dist/hooks/integration.test.js +0 -235
  132. package/node_modules/@comis/core/dist/hooks/plugin-registry.test.d.ts +0 -1
  133. package/node_modules/@comis/core/dist/hooks/plugin-registry.test.js +0 -470
  134. package/node_modules/@comis/core/dist/load-env.test.d.ts +0 -1
  135. package/node_modules/@comis/core/dist/load-env.test.js +0 -21
  136. package/node_modules/@comis/core/dist/security/action-classifier.test.d.ts +0 -1
  137. package/node_modules/@comis/core/dist/security/action-classifier.test.js +0 -298
  138. package/node_modules/@comis/core/dist/security/audit-aggregator.test.d.ts +0 -1
  139. package/node_modules/@comis/core/dist/security/audit-aggregator.test.js +0 -128
  140. package/node_modules/@comis/core/dist/security/audit.test.d.ts +0 -1
  141. package/node_modules/@comis/core/dist/security/audit.test.js +0 -154
  142. package/node_modules/@comis/core/dist/security/canary-token.test.d.ts +0 -1
  143. package/node_modules/@comis/core/dist/security/canary-token.test.js +0 -45
  144. package/node_modules/@comis/core/dist/security/config-redaction.test.d.ts +0 -1
  145. package/node_modules/@comis/core/dist/security/config-redaction.test.js +0 -107
  146. package/node_modules/@comis/core/dist/security/external-content.test.d.ts +0 -1
  147. package/node_modules/@comis/core/dist/security/external-content.test.js +0 -210
  148. package/node_modules/@comis/core/dist/security/injection-patterns.test.d.ts +0 -1
  149. package/node_modules/@comis/core/dist/security/injection-patterns.test.js +0 -213
  150. package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.d.ts +0 -1
  151. package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.js +0 -194
  152. package/node_modules/@comis/core/dist/security/input-guard.test.d.ts +0 -1
  153. package/node_modules/@comis/core/dist/security/input-guard.test.js +0 -215
  154. package/node_modules/@comis/core/dist/security/input-security-guard.test.d.ts +0 -1
  155. package/node_modules/@comis/core/dist/security/input-security-guard.test.js +0 -215
  156. package/node_modules/@comis/core/dist/security/input-validator.test.d.ts +0 -1
  157. package/node_modules/@comis/core/dist/security/input-validator.test.js +0 -133
  158. package/node_modules/@comis/core/dist/security/log-sanitizer.test.d.ts +0 -1
  159. package/node_modules/@comis/core/dist/security/log-sanitizer.test.js +0 -260
  160. package/node_modules/@comis/core/dist/security/memory-write-validator.test.d.ts +0 -1
  161. package/node_modules/@comis/core/dist/security/memory-write-validator.test.js +0 -62
  162. package/node_modules/@comis/core/dist/security/output-guard.test.d.ts +0 -1
  163. package/node_modules/@comis/core/dist/security/output-guard.test.js +0 -397
  164. package/node_modules/@comis/core/dist/security/safe-path.test.d.ts +0 -1
  165. package/node_modules/@comis/core/dist/security/safe-path.test.js +0 -95
  166. package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.d.ts +0 -1
  167. package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.js +0 -231
  168. package/node_modules/@comis/core/dist/security/secret-access.test.d.ts +0 -1
  169. package/node_modules/@comis/core/dist/security/secret-access.test.js +0 -41
  170. package/node_modules/@comis/core/dist/security/secret-crypto.test.d.ts +0 -1
  171. package/node_modules/@comis/core/dist/security/secret-crypto.test.js +0 -113
  172. package/node_modules/@comis/core/dist/security/secret-manager.test.d.ts +0 -1
  173. package/node_modules/@comis/core/dist/security/secret-manager.test.js +0 -394
  174. package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.d.ts +0 -1
  175. package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.js +0 -268
  176. package/node_modules/@comis/core/dist/security/secrets-audit.test.d.ts +0 -10
  177. package/node_modules/@comis/core/dist/security/secrets-audit.test.js +0 -295
  178. package/node_modules/@comis/core/dist/security/ssrf-guard.test.d.ts +0 -1
  179. package/node_modules/@comis/core/dist/security/ssrf-guard.test.js +0 -127
  180. package/node_modules/@comis/core/dist/security/token-generator.test.d.ts +0 -1
  181. package/node_modules/@comis/core/dist/security/token-generator.test.js +0 -35
  182. package/node_modules/@comis/core/dist/tool-metadata.test.d.ts +0 -1
  183. package/node_modules/@comis/core/dist/tool-metadata.test.js +0 -112
  184. package/node_modules/@comis/memory/dist/compaction.test.d.ts +0 -1
  185. package/node_modules/@comis/memory/dist/compaction.test.js +0 -298
  186. package/node_modules/@comis/memory/dist/context-schema.test.d.ts +0 -1
  187. package/node_modules/@comis/memory/dist/context-schema.test.js +0 -246
  188. package/node_modules/@comis/memory/dist/context-store.test.d.ts +0 -1
  189. package/node_modules/@comis/memory/dist/context-store.test.js +0 -708
  190. package/node_modules/@comis/memory/dist/credential-mapping-schema.test.d.ts +0 -7
  191. package/node_modules/@comis/memory/dist/credential-mapping-schema.test.js +0 -73
  192. package/node_modules/@comis/memory/dist/credential-mapping-store.test.d.ts +0 -8
  193. package/node_modules/@comis/memory/dist/credential-mapping-store.test.js +0 -340
  194. package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.d.ts +0 -1
  195. package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.js +0 -165
  196. package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.d.ts +0 -1
  197. package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.js +0 -263
  198. package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.d.ts +0 -1
  199. package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.js +0 -202
  200. package/node_modules/@comis/memory/dist/embedding-cache-lru.test.d.ts +0 -1
  201. package/node_modules/@comis/memory/dist/embedding-cache-lru.test.js +0 -241
  202. package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.d.ts +0 -8
  203. package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.js +0 -678
  204. package/node_modules/@comis/memory/dist/embedding-cache.test.d.ts +0 -1
  205. package/node_modules/@comis/memory/dist/embedding-cache.test.js +0 -213
  206. package/node_modules/@comis/memory/dist/embedding-fingerprint.test.d.ts +0 -1
  207. package/node_modules/@comis/memory/dist/embedding-fingerprint.test.js +0 -87
  208. package/node_modules/@comis/memory/dist/embedding-hash.test.d.ts +0 -1
  209. package/node_modules/@comis/memory/dist/embedding-hash.test.js +0 -31
  210. package/node_modules/@comis/memory/dist/embedding-integration.test.d.ts +0 -8
  211. package/node_modules/@comis/memory/dist/embedding-integration.test.js +0 -232
  212. package/node_modules/@comis/memory/dist/embedding-provider-factory.test.d.ts +0 -1
  213. package/node_modules/@comis/memory/dist/embedding-provider-factory.test.js +0 -176
  214. package/node_modules/@comis/memory/dist/embedding-provider-local.test.d.ts +0 -8
  215. package/node_modules/@comis/memory/dist/embedding-provider-local.test.js +0 -76
  216. package/node_modules/@comis/memory/dist/embedding-provider-openai.test.d.ts +0 -8
  217. package/node_modules/@comis/memory/dist/embedding-provider-openai.test.js +0 -100
  218. package/node_modules/@comis/memory/dist/embedding-queue.test.d.ts +0 -1
  219. package/node_modules/@comis/memory/dist/embedding-queue.test.js +0 -236
  220. package/node_modules/@comis/memory/dist/hybrid-search.test.d.ts +0 -1
  221. package/node_modules/@comis/memory/dist/hybrid-search.test.js +0 -476
  222. package/node_modules/@comis/memory/dist/identity-link-store.test.d.ts +0 -1
  223. package/node_modules/@comis/memory/dist/identity-link-store.test.js +0 -88
  224. package/node_modules/@comis/memory/dist/memory-api.test.d.ts +0 -1
  225. package/node_modules/@comis/memory/dist/memory-api.test.js +0 -495
  226. package/node_modules/@comis/memory/dist/memory-concurrency.test.d.ts +0 -20
  227. package/node_modules/@comis/memory/dist/memory-concurrency.test.js +0 -222
  228. package/node_modules/@comis/memory/dist/named-graph-store.test.d.ts +0 -1
  229. package/node_modules/@comis/memory/dist/named-graph-store.test.js +0 -227
  230. package/node_modules/@comis/memory/dist/observability-store.test.d.ts +0 -1
  231. package/node_modules/@comis/memory/dist/observability-store.test.js +0 -704
  232. package/node_modules/@comis/memory/dist/row-mapper.test.d.ts +0 -1
  233. package/node_modules/@comis/memory/dist/row-mapper.test.js +0 -409
  234. package/node_modules/@comis/memory/dist/schema.test.d.ts +0 -1
  235. package/node_modules/@comis/memory/dist/schema.test.js +0 -240
  236. package/node_modules/@comis/memory/dist/secret-store-schema.test.d.ts +0 -7
  237. package/node_modules/@comis/memory/dist/secret-store-schema.test.js +0 -90
  238. package/node_modules/@comis/memory/dist/session-store.test.d.ts +0 -1
  239. package/node_modules/@comis/memory/dist/session-store.test.js +0 -262
  240. package/node_modules/@comis/memory/dist/setup-secrets.test.d.ts +0 -1
  241. package/node_modules/@comis/memory/dist/setup-secrets.test.js +0 -140
  242. package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.d.ts +0 -1
  243. package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.js +0 -888
  244. package/node_modules/@comis/memory/dist/sqlite-secret-store.test.d.ts +0 -8
  245. package/node_modules/@comis/memory/dist/sqlite-secret-store.test.js +0 -245
  246. package/node_modules/@comis/shared/dist/abort.test.d.ts +0 -1
  247. package/node_modules/@comis/shared/dist/abort.test.js +0 -71
  248. package/node_modules/@comis/shared/dist/result.test.d.ts +0 -1
  249. package/node_modules/@comis/shared/dist/result.test.js +0 -178
  250. package/node_modules/@comis/shared/dist/suppress-error.test.d.ts +0 -1
  251. package/node_modules/@comis/shared/dist/suppress-error.test.js +0 -50
  252. package/node_modules/@comis/shared/dist/timeout.test.d.ts +0 -1
  253. package/node_modules/@comis/shared/dist/timeout.test.js +0 -75
  254. package/node_modules/@comis/shared/dist/ttl-cache.test.d.ts +0 -1
  255. package/node_modules/@comis/shared/dist/ttl-cache.test.js +0 -81
@@ -1,470 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { ok } from "@comis/shared";
3
- import { z } from "zod";
4
- import { TypedEventBus } from "../event-bus/index.js";
5
- import { createPluginRegistry } from "./plugin-registry.js";
6
- /**
7
- * Create a minimal test plugin with sensible defaults.
8
- * Overrides allow customizing any field for specific test scenarios.
9
- */
10
- function createTestPlugin(overrides) {
11
- return {
12
- name: overrides.name ?? `test-plugin-${overrides.id}`,
13
- register: overrides.register ?? ((_api) => ok(undefined)),
14
- ...overrides,
15
- };
16
- }
17
- describe("PluginRegistry", () => {
18
- // ─── Registration ───────────────────────────────────────────────
19
- describe("registration", () => {
20
- it("registers a plugin and returns ok result", () => {
21
- const registry = createPluginRegistry();
22
- const plugin = createTestPlugin({ id: "alpha" });
23
- const result = registry.register(plugin);
24
- expect(result.ok).toBe(true);
25
- });
26
- it("rejects duplicate plugin ID with err result", () => {
27
- const registry = createPluginRegistry();
28
- const plugin1 = createTestPlugin({ id: "alpha" });
29
- const plugin2 = createTestPlugin({ id: "alpha", name: "another-alpha" });
30
- registry.register(plugin1);
31
- const result = registry.register(plugin2);
32
- expect(result.ok).toBe(false);
33
- if (!result.ok) {
34
- expect(result.error.message).toContain("already registered");
35
- }
36
- });
37
- it("stores hooks registered by plugin via PluginRegistryApi", () => {
38
- const registry = createPluginRegistry();
39
- const plugin = createTestPlugin({
40
- id: "hook-plugin",
41
- register: (api) => {
42
- api.registerHook("before_agent_start", () => ({ systemPrompt: "test" }));
43
- api.registerHook("agent_end", () => { });
44
- return ok(undefined);
45
- },
46
- });
47
- registry.register(plugin);
48
- const beforeHooks = registry.getHooksByName("before_agent_start");
49
- const endHooks = registry.getHooksByName("agent_end");
50
- expect(beforeHooks).toHaveLength(1);
51
- expect(endHooks).toHaveLength(1);
52
- expect(beforeHooks[0].pluginId).toBe("hook-plugin");
53
- });
54
- it("getPlugin() returns registered plugin by ID", () => {
55
- const registry = createPluginRegistry();
56
- const plugin = createTestPlugin({ id: "lookup-test" });
57
- registry.register(plugin);
58
- const found = registry.getPlugin("lookup-test");
59
- expect(found).toBe(plugin);
60
- });
61
- it("getPlugin() returns undefined for unknown ID", () => {
62
- const registry = createPluginRegistry();
63
- const found = registry.getPlugin("nonexistent");
64
- expect(found).toBeUndefined();
65
- });
66
- it("getPlugins() returns all registered plugins", () => {
67
- const registry = createPluginRegistry();
68
- const p1 = createTestPlugin({ id: "first" });
69
- const p2 = createTestPlugin({ id: "second" });
70
- const p3 = createTestPlugin({ id: "third" });
71
- registry.register(p1);
72
- registry.register(p2);
73
- registry.register(p3);
74
- const all = registry.getPlugins();
75
- expect(all).toHaveLength(3);
76
- expect(all.map((p) => p.id)).toEqual(["first", "second", "third"]);
77
- });
78
- });
79
- // ─── Hook Storage and Priority ──────────────────────────────────
80
- describe("hook storage and priority", () => {
81
- it("hooks are sorted by priority descending (higher first)", () => {
82
- const registry = createPluginRegistry();
83
- const pluginLow = createTestPlugin({
84
- id: "low",
85
- register: (api) => {
86
- api.registerHook("before_agent_start", () => ({ systemPrompt: "low" }), { priority: 5 });
87
- return ok(undefined);
88
- },
89
- });
90
- const pluginHigh = createTestPlugin({
91
- id: "high",
92
- register: (api) => {
93
- api.registerHook("before_agent_start", () => ({ systemPrompt: "high" }), {
94
- priority: 50,
95
- });
96
- return ok(undefined);
97
- },
98
- });
99
- // Register low first, then high
100
- registry.register(pluginLow);
101
- registry.register(pluginHigh);
102
- const hooks = registry.getHooksByName("before_agent_start");
103
- expect(hooks).toHaveLength(2);
104
- expect(hooks[0].pluginId).toBe("high");
105
- expect(hooks[1].pluginId).toBe("low");
106
- });
107
- it("hooks with same priority maintain insertion order", () => {
108
- const registry = createPluginRegistry();
109
- const pluginA = createTestPlugin({
110
- id: "a",
111
- register: (api) => {
112
- api.registerHook("agent_end", () => { }, { priority: 10 });
113
- return ok(undefined);
114
- },
115
- });
116
- const pluginB = createTestPlugin({
117
- id: "b",
118
- register: (api) => {
119
- api.registerHook("agent_end", () => { }, { priority: 10 });
120
- return ok(undefined);
121
- },
122
- });
123
- registry.register(pluginA);
124
- registry.register(pluginB);
125
- const hooks = registry.getHooksByName("agent_end");
126
- expect(hooks).toHaveLength(2);
127
- expect(hooks[0].pluginId).toBe("a");
128
- expect(hooks[1].pluginId).toBe("b");
129
- });
130
- it("default priority is 0 when not specified", () => {
131
- const registry = createPluginRegistry();
132
- const plugin = createTestPlugin({
133
- id: "default-pri",
134
- register: (api) => {
135
- api.registerHook("agent_end", () => { });
136
- return ok(undefined);
137
- },
138
- });
139
- registry.register(plugin);
140
- const hooks = registry.getHooksByName("agent_end");
141
- expect(hooks[0].priority).toBe(0);
142
- });
143
- it("getHooksByName() returns only hooks for requested hook name", () => {
144
- const registry = createPluginRegistry();
145
- const plugin = createTestPlugin({
146
- id: "multi-hook",
147
- register: (api) => {
148
- api.registerHook("before_agent_start", () => ({ systemPrompt: "x" }));
149
- api.registerHook("agent_end", () => { });
150
- api.registerHook("before_tool_call", () => ({}));
151
- return ok(undefined);
152
- },
153
- });
154
- registry.register(plugin);
155
- const beforeHooks = registry.getHooksByName("before_agent_start");
156
- const endHooks = registry.getHooksByName("agent_end");
157
- expect(beforeHooks).toHaveLength(1);
158
- expect(beforeHooks[0].hookName).toBe("before_agent_start");
159
- expect(endHooks).toHaveLength(1);
160
- expect(endHooks[0].hookName).toBe("agent_end");
161
- });
162
- it("getHooksByName() returns empty array for hook with no registrations", () => {
163
- const registry = createPluginRegistry();
164
- const hooks = registry.getHooksByName("gateway_start");
165
- expect(hooks).toEqual([]);
166
- });
167
- });
168
- // ─── Unregistration ─────────────────────────────────────────────
169
- describe("unregistration", () => {
170
- it("unregister() removes plugin and its hooks", () => {
171
- const registry = createPluginRegistry();
172
- const plugin = createTestPlugin({
173
- id: "removable",
174
- register: (api) => {
175
- api.registerHook("agent_end", () => { });
176
- api.registerHook("before_agent_start", () => ({ systemPrompt: "x" }));
177
- return ok(undefined);
178
- },
179
- });
180
- registry.register(plugin);
181
- expect(registry.getPlugin("removable")).toBeDefined();
182
- expect(registry.getHooksByName("agent_end")).toHaveLength(1);
183
- const result = registry.unregister("removable");
184
- expect(result.ok).toBe(true);
185
- expect(registry.getPlugin("removable")).toBeUndefined();
186
- expect(registry.getHooksByName("agent_end")).toHaveLength(0);
187
- expect(registry.getHooksByName("before_agent_start")).toHaveLength(0);
188
- });
189
- it("unregister() returns err for unknown plugin ID", () => {
190
- const registry = createPluginRegistry();
191
- const result = registry.unregister("ghost");
192
- expect(result.ok).toBe(false);
193
- if (!result.ok) {
194
- expect(result.error.message).toContain("not registered");
195
- }
196
- });
197
- });
198
- // ─── Activation / Deactivation ──────────────────────────────────
199
- describe("activation / deactivation", () => {
200
- it("activateAll() calls activate() on plugins that have it", async () => {
201
- const registry = createPluginRegistry();
202
- const activateFn = vi.fn(async () => ok(undefined));
203
- const plugin = createTestPlugin({
204
- id: "activatable",
205
- activate: activateFn,
206
- });
207
- registry.register(plugin);
208
- const result = await registry.activateAll();
209
- expect(result.ok).toBe(true);
210
- expect(activateFn).toHaveBeenCalledOnce();
211
- });
212
- it("activateAll() skips plugins without activate method", async () => {
213
- const registry = createPluginRegistry();
214
- const pluginWithActivate = createTestPlugin({
215
- id: "with",
216
- activate: vi.fn(async () => ok(undefined)),
217
- });
218
- const pluginWithout = createTestPlugin({
219
- id: "without",
220
- // no activate method
221
- });
222
- registry.register(pluginWithActivate);
223
- registry.register(pluginWithout);
224
- const result = await registry.activateAll();
225
- expect(result.ok).toBe(true);
226
- expect(pluginWithActivate.activate).toHaveBeenCalledOnce();
227
- });
228
- it("deactivateAll() calls deactivate() on all plugins", async () => {
229
- const registry = createPluginRegistry();
230
- const deactivateFn = vi.fn(async () => ok(undefined));
231
- const plugin = createTestPlugin({
232
- id: "deactivatable",
233
- deactivate: deactivateFn,
234
- });
235
- registry.register(plugin);
236
- const result = await registry.deactivateAll();
237
- expect(result.ok).toBe(true);
238
- expect(deactivateFn).toHaveBeenCalledOnce();
239
- });
240
- });
241
- // ─── Event Emission ─────────────────────────────────────────────
242
- describe("event emission", () => {
243
- it("emits plugin:registered event when eventBus provided", () => {
244
- const eventBus = new TypedEventBus();
245
- const handler = vi.fn();
246
- eventBus.on("plugin:registered", handler);
247
- const registry = createPluginRegistry({ eventBus });
248
- const plugin = createTestPlugin({
249
- id: "evented",
250
- register: (api) => {
251
- api.registerHook("agent_end", () => { });
252
- return ok(undefined);
253
- },
254
- });
255
- registry.register(plugin);
256
- expect(handler).toHaveBeenCalledOnce();
257
- expect(handler).toHaveBeenCalledWith(expect.objectContaining({
258
- pluginId: "evented",
259
- pluginName: "test-plugin-evented",
260
- hookCount: 1,
261
- }));
262
- });
263
- it("emits plugin:deactivated event on deactivation", async () => {
264
- const eventBus = new TypedEventBus();
265
- const handler = vi.fn();
266
- eventBus.on("plugin:deactivated", handler);
267
- const registry = createPluginRegistry({ eventBus });
268
- const plugin = createTestPlugin({
269
- id: "will-deactivate",
270
- deactivate: async () => ok(undefined),
271
- });
272
- registry.register(plugin);
273
- await registry.deactivateAll();
274
- expect(handler).toHaveBeenCalledOnce();
275
- expect(handler).toHaveBeenCalledWith(expect.objectContaining({
276
- pluginId: "will-deactivate",
277
- reason: "shutdown",
278
- }));
279
- });
280
- it("does not throw when eventBus not provided", () => {
281
- const registry = createPluginRegistry(); // no eventBus
282
- const plugin = createTestPlugin({ id: "no-bus" });
283
- expect(() => registry.register(plugin)).not.toThrow();
284
- });
285
- });
286
- // ─── Tool, Route, and Config Schema Registration ───────────────
287
- describe("tool registration", () => {
288
- it("plugin can register a tool via registerTool()", () => {
289
- const registry = createPluginRegistry();
290
- const executeFn = vi.fn(async () => "result");
291
- const plugin = createTestPlugin({
292
- id: "tool-plugin",
293
- register: (api) => {
294
- api.registerTool({
295
- name: "my-tool",
296
- description: "A test tool",
297
- parameters: { input: { type: "string" } },
298
- execute: executeFn,
299
- });
300
- return ok(undefined);
301
- },
302
- });
303
- registry.register(plugin);
304
- const registeredTools = registry.getRegisteredTools();
305
- expect(registeredTools).toHaveLength(1);
306
- expect(registeredTools[0].name).toBe("my-tool");
307
- expect(registeredTools[0].description).toBe("A test tool");
308
- expect(registeredTools[0].execute).toBe(executeFn);
309
- });
310
- it("rejects tool with empty name", () => {
311
- const registry = createPluginRegistry();
312
- const plugin = createTestPlugin({
313
- id: "bad-tool",
314
- register: (api) => {
315
- api.registerTool({
316
- name: "",
317
- description: "empty name tool",
318
- parameters: {},
319
- execute: async () => null,
320
- });
321
- return ok(undefined);
322
- },
323
- });
324
- const result = registry.register(plugin);
325
- expect(result.ok).toBe(false);
326
- });
327
- });
328
- describe("HTTP route registration", () => {
329
- it("plugin can register an HTTP route via registerHttpRoute()", () => {
330
- const registry = createPluginRegistry();
331
- const handlerFn = vi.fn(async () => ({ status: 200 }));
332
- const plugin = createTestPlugin({
333
- id: "route-plugin",
334
- register: (api) => {
335
- api.registerHttpRoute({
336
- method: "POST",
337
- path: "/api/webhook",
338
- handler: handlerFn,
339
- });
340
- return ok(undefined);
341
- },
342
- });
343
- registry.register(plugin);
344
- const registeredRoutes = registry.getRegisteredRoutes();
345
- expect(registeredRoutes).toHaveLength(1);
346
- expect(registeredRoutes[0].method).toBe("POST");
347
- expect(registeredRoutes[0].path).toBe("/api/webhook");
348
- expect(registeredRoutes[0].handler).toBe(handlerFn);
349
- });
350
- it("rejects route with path not starting with /", () => {
351
- const registry = createPluginRegistry();
352
- const plugin = createTestPlugin({
353
- id: "bad-route",
354
- register: (api) => {
355
- api.registerHttpRoute({
356
- method: "GET",
357
- path: "no-slash",
358
- handler: async () => null,
359
- });
360
- return ok(undefined);
361
- },
362
- });
363
- const result = registry.register(plugin);
364
- expect(result.ok).toBe(false);
365
- });
366
- });
367
- describe("config schema registration", () => {
368
- it("plugin can register a config schema via registerConfigSchema()", () => {
369
- const registry = createPluginRegistry();
370
- const schema = z.object({ apiKey: z.string(), retries: z.number() });
371
- const plugin = createTestPlugin({
372
- id: "config-plugin",
373
- register: (api) => {
374
- api.registerConfigSchema("myPlugin", schema);
375
- return ok(undefined);
376
- },
377
- });
378
- registry.register(plugin);
379
- const schemas = registry.getRegisteredConfigSchemas();
380
- expect(schemas.size).toBe(1);
381
- expect(schemas.get("myPlugin")).toBe(schema);
382
- });
383
- it("rejects config schema with empty section", () => {
384
- const registry = createPluginRegistry();
385
- const plugin = createTestPlugin({
386
- id: "bad-config",
387
- register: (api) => {
388
- api.registerConfigSchema("", z.object({}));
389
- return ok(undefined);
390
- },
391
- });
392
- const result = registry.register(plugin);
393
- expect(result.ok).toBe(false);
394
- });
395
- });
396
- describe("multiple plugin aggregation", () => {
397
- it("aggregates tools, routes, and schemas from multiple plugins", () => {
398
- const registry = createPluginRegistry();
399
- const schema1 = z.object({ key: z.string() });
400
- const schema2 = z.object({ url: z.string() });
401
- const plugin1 = createTestPlugin({
402
- id: "plugin-a",
403
- register: (api) => {
404
- api.registerTool({
405
- name: "tool-a",
406
- description: "Tool A",
407
- parameters: {},
408
- execute: async () => "a",
409
- });
410
- api.registerHttpRoute({
411
- method: "GET",
412
- path: "/api/a",
413
- handler: async () => "a",
414
- });
415
- api.registerConfigSchema("pluginA", schema1);
416
- return ok(undefined);
417
- },
418
- });
419
- const plugin2 = createTestPlugin({
420
- id: "plugin-b",
421
- register: (api) => {
422
- api.registerTool({
423
- name: "tool-b",
424
- description: "Tool B",
425
- parameters: {},
426
- execute: async () => "b",
427
- });
428
- api.registerHttpRoute({
429
- method: "POST",
430
- path: "/api/b",
431
- handler: async () => "b",
432
- });
433
- api.registerConfigSchema("pluginB", schema2);
434
- return ok(undefined);
435
- },
436
- });
437
- registry.register(plugin1);
438
- registry.register(plugin2);
439
- expect(registry.getRegisteredTools()).toHaveLength(2);
440
- expect(registry.getRegisteredTools().map((t) => t.name)).toEqual(["tool-a", "tool-b"]);
441
- expect(registry.getRegisteredRoutes()).toHaveLength(2);
442
- expect(registry.getRegisteredRoutes().map((r) => r.path)).toEqual(["/api/a", "/api/b"]);
443
- const schemas = registry.getRegisteredConfigSchemas();
444
- expect(schemas.size).toBe(2);
445
- expect(schemas.has("pluginA")).toBe(true);
446
- expect(schemas.has("pluginB")).toBe(true);
447
- });
448
- });
449
- describe("backward compatibility", () => {
450
- it("registerHook still works alongside new registration methods", () => {
451
- const registry = createPluginRegistry();
452
- const plugin = createTestPlugin({
453
- id: "compat-plugin",
454
- register: (api) => {
455
- api.registerHook("agent_end", () => { });
456
- api.registerTool({
457
- name: "compat-tool",
458
- description: "backward compat test",
459
- parameters: {},
460
- execute: async () => null,
461
- });
462
- return ok(undefined);
463
- },
464
- });
465
- registry.register(plugin);
466
- expect(registry.getHooksByName("agent_end")).toHaveLength(1);
467
- expect(registry.getRegisteredTools()).toHaveLength(1);
468
- });
469
- });
470
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import { describe, it, expect, beforeEach } from "vitest";
2
- import { assertEnvLoaded, resetEnvLoadedForTest, loadEnvFile } from "./load-env.js";
3
- describe("assertEnvLoaded()", () => {
4
- beforeEach(() => {
5
- resetEnvLoadedForTest();
6
- });
7
- it("SHR-13: throws before loadEnvFile() is called", () => {
8
- expect(() => assertEnvLoaded()).toThrow("loadEnvFile() must be called before createSecretManager()");
9
- });
10
- it("SHR-13: does NOT throw after loadEnvFile() is called", () => {
11
- // Call loadEnvFile with a non-existent path (returns -1 but still sets flag)
12
- loadEnvFile("/tmp/comis-test-nonexistent-env-file-12345");
13
- expect(() => assertEnvLoaded()).not.toThrow();
14
- });
15
- it("SHR-13: resetEnvLoadedForTest() resets the flag", () => {
16
- loadEnvFile("/tmp/comis-test-nonexistent-env-file-12345");
17
- expect(() => assertEnvLoaded()).not.toThrow();
18
- resetEnvLoadedForTest();
19
- expect(() => assertEnvLoaded()).toThrow();
20
- });
21
- });