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,240 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { TypedEventBus } from "./bus.js";
3
- const testSessionKey = { tenantId: "t1", userId: "u1", channelId: "c1" };
4
- describe("ChannelEvents payload structure", () => {
5
- it("channel:registered delivers channelType, pluginId, capabilities", () => {
6
- const bus = new TypedEventBus();
7
- const handler = vi.fn();
8
- const payload = {
9
- channelType: "telegram",
10
- pluginId: "telegram-01",
11
- capabilities: {
12
- chatTypes: ["dm", "group"],
13
- features: {
14
- reactions: true,
15
- editMessages: true,
16
- deleteMessages: true,
17
- fetchHistory: false,
18
- attachments: true,
19
- threads: false,
20
- mentions: false,
21
- formatting: ["markdown", "html"],
22
- buttons: true,
23
- cards: false,
24
- effects: true,
25
- },
26
- limits: { maxMessageChars: 4096 },
27
- streaming: { supported: true, throttleMs: 300, method: "edit" },
28
- threading: { supported: false, threadType: "none" },
29
- },
30
- timestamp: Date.now(),
31
- };
32
- bus.on("channel:registered", handler);
33
- bus.emit("channel:registered", payload);
34
- expect(handler).toHaveBeenCalledWith(payload);
35
- const received = handler.mock.calls[0][0];
36
- expect(received.channelType).toBe("telegram");
37
- expect(received.pluginId).toBe("telegram-01");
38
- expect(received.capabilities.chatTypes).toContain("dm");
39
- expect(received.capabilities.limits.maxMessageChars).toBe(4096);
40
- expect(received.capabilities.features.buttons).toBe(true);
41
- });
42
- it("queue:enqueued delivers sessionKey, queueDepth, mode", () => {
43
- const bus = new TypedEventBus();
44
- const handler = vi.fn();
45
- const payload = {
46
- sessionKey: testSessionKey,
47
- channelType: "discord",
48
- queueDepth: 3,
49
- mode: "queue",
50
- timestamp: Date.now(),
51
- };
52
- bus.on("queue:enqueued", handler);
53
- bus.emit("queue:enqueued", payload);
54
- expect(handler).toHaveBeenCalledWith(payload);
55
- const received = handler.mock.calls[0][0];
56
- expect(received.sessionKey).toEqual(testSessionKey);
57
- expect(received.queueDepth).toBe(3);
58
- expect(received.mode).toBe("queue");
59
- });
60
- it("queue:overflow delivers policy and droppedCount", () => {
61
- const bus = new TypedEventBus();
62
- const handler = vi.fn();
63
- const payload = {
64
- sessionKey: testSessionKey,
65
- channelType: "telegram",
66
- policy: "drop-oldest",
67
- droppedCount: 2,
68
- timestamp: Date.now(),
69
- };
70
- bus.on("queue:overflow", handler);
71
- bus.emit("queue:overflow", payload);
72
- expect(handler).toHaveBeenCalledWith(payload);
73
- const received = handler.mock.calls[0][0];
74
- expect(received.policy).toBe("drop-oldest");
75
- expect(received.droppedCount).toBe(2);
76
- });
77
- it("streaming:block_sent delivers blockIndex, totalBlocks, charCount", () => {
78
- const bus = new TypedEventBus();
79
- const handler = vi.fn();
80
- const payload = {
81
- channelId: "c1",
82
- chatId: "chat-1",
83
- blockIndex: 2,
84
- totalBlocks: 5,
85
- charCount: 150,
86
- timestamp: Date.now(),
87
- };
88
- bus.on("streaming:block_sent", handler);
89
- bus.emit("streaming:block_sent", payload);
90
- expect(handler).toHaveBeenCalledWith(payload);
91
- const received = handler.mock.calls[0][0];
92
- expect(received.blockIndex).toBe(2);
93
- expect(received.totalBlocks).toBe(5);
94
- expect(received.charCount).toBe(150);
95
- });
96
- it("typing:started delivers channelId, chatId, mode", () => {
97
- const bus = new TypedEventBus();
98
- const handler = vi.fn();
99
- const payload = {
100
- channelId: "c1",
101
- chatId: "chat-1",
102
- mode: "continuous",
103
- timestamp: Date.now(),
104
- };
105
- bus.on("typing:started", handler);
106
- bus.emit("typing:started", payload);
107
- expect(handler).toHaveBeenCalledWith(payload);
108
- const received = handler.mock.calls[0][0];
109
- expect(received.channelId).toBe("c1");
110
- expect(received.mode).toBe("continuous");
111
- });
112
- it("autoreply:activated delivers activationMode and reason", () => {
113
- const bus = new TypedEventBus();
114
- const handler = vi.fn();
115
- const payload = {
116
- channelId: "c1",
117
- senderId: "user-1",
118
- activationMode: "mention",
119
- reason: "Bot was mentioned in group",
120
- timestamp: Date.now(),
121
- };
122
- bus.on("autoreply:activated", handler);
123
- bus.emit("autoreply:activated", payload);
124
- expect(handler).toHaveBeenCalledWith(payload);
125
- const received = handler.mock.calls[0][0];
126
- expect(received.activationMode).toBe("mention");
127
- expect(received.reason).toBe("Bot was mentioned in group");
128
- });
129
- it("sendpolicy:denied delivers channelType, optional chatType, reason", () => {
130
- const bus = new TypedEventBus();
131
- const handler = vi.fn();
132
- // With optional chatType
133
- const payload = {
134
- channelId: "c1",
135
- channelType: "telegram",
136
- chatType: "group",
137
- reason: "Send policy disallows group messages",
138
- timestamp: Date.now(),
139
- };
140
- bus.on("sendpolicy:denied", handler);
141
- bus.emit("sendpolicy:denied", payload);
142
- expect(handler).toHaveBeenCalledWith(payload);
143
- const received = handler.mock.calls[0][0];
144
- expect(received.channelType).toBe("telegram");
145
- expect(received.chatType).toBe("group");
146
- expect(received.reason).toBe("Send policy disallows group messages");
147
- // Without optional chatType
148
- const minPayload = {
149
- channelId: "c2",
150
- channelType: "discord",
151
- reason: "Channel blocked",
152
- timestamp: Date.now(),
153
- };
154
- bus.emit("sendpolicy:denied", minPayload);
155
- expect(handler.mock.calls[1][0].chatType).toBeUndefined();
156
- });
157
- it("debounce:buffered delivers windowMs and bufferedCount", () => {
158
- const bus = new TypedEventBus();
159
- const handler = vi.fn();
160
- const payload = {
161
- sessionKey: testSessionKey,
162
- channelType: "telegram",
163
- bufferedCount: 4,
164
- windowMs: 2000,
165
- timestamp: Date.now(),
166
- };
167
- bus.on("debounce:buffered", handler);
168
- bus.emit("debounce:buffered", payload);
169
- expect(handler).toHaveBeenCalledWith(payload);
170
- const received = handler.mock.calls[0][0];
171
- expect(received.windowMs).toBe(2000);
172
- expect(received.bufferedCount).toBe(4);
173
- });
174
- it("retry:attempted delivers attempt, maxAttempts, delayMs, error", () => {
175
- const bus = new TypedEventBus();
176
- const handler = vi.fn();
177
- const payload = {
178
- channelId: "c1",
179
- chatId: "chat-1",
180
- attempt: 2,
181
- maxAttempts: 3,
182
- delayMs: 1000,
183
- error: "Connection timeout",
184
- timestamp: Date.now(),
185
- };
186
- bus.on("retry:attempted", handler);
187
- bus.emit("retry:attempted", payload);
188
- expect(handler).toHaveBeenCalledWith(payload);
189
- const received = handler.mock.calls[0][0];
190
- expect(received.attempt).toBe(2);
191
- expect(received.maxAttempts).toBe(3);
192
- expect(received.delayMs).toBe(1000);
193
- expect(received.error).toBe("Connection timeout");
194
- });
195
- it("steer:injected delivers sessionKey, channelType, agentId", () => {
196
- const bus = new TypedEventBus();
197
- const handler = vi.fn();
198
- const payload = {
199
- sessionKey: testSessionKey,
200
- channelType: "discord",
201
- agentId: "agent-1",
202
- timestamp: Date.now(),
203
- };
204
- bus.on("steer:injected", handler);
205
- bus.emit("steer:injected", payload);
206
- expect(handler).toHaveBeenCalledWith(payload);
207
- const received = handler.mock.calls[0][0];
208
- expect(received.sessionKey).toEqual(testSessionKey);
209
- expect(received.agentId).toBe("agent-1");
210
- });
211
- it("steer:rejected delivers reason union", () => {
212
- const bus = new TypedEventBus();
213
- const handler = vi.fn();
214
- for (const reason of ["not_streaming", "compacting", "no_active_run"]) {
215
- const payload = {
216
- sessionKey: testSessionKey,
217
- channelType: "telegram",
218
- agentId: "agent-1",
219
- reason,
220
- timestamp: Date.now(),
221
- };
222
- bus.on("steer:rejected", handler);
223
- bus.emit("steer:rejected", payload);
224
- bus.removeAllListeners("steer:rejected");
225
- }
226
- expect(handler).toHaveBeenCalledTimes(3);
227
- expect(handler.mock.calls[0][0].reason).toBe("not_streaming");
228
- expect(handler.mock.calls[1][0].reason).toBe("compacting");
229
- expect(handler.mock.calls[2][0].reason).toBe("no_active_run");
230
- });
231
- it("type safety: @ts-expect-error for missing required fields", () => {
232
- const bus = new TypedEventBus();
233
- // @ts-expect-error - missing capabilities in channel:registered
234
- bus.emit("channel:registered", { channelType: "x", pluginId: "y", timestamp: 1 });
235
- // @ts-expect-error - missing queueDepth in queue:enqueued
236
- bus.emit("queue:enqueued", {
237
- sessionKey: testSessionKey, channelType: "x", mode: "queue", timestamp: 1,
238
- });
239
- });
240
- });
@@ -1,416 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { TypedEventBus } from "./bus.js";
3
- describe("InfraEvents payload structure", () => {
4
- it("approval:requested delivers requestId, toolName, params, timeoutMs", () => {
5
- const bus = new TypedEventBus();
6
- const handler = vi.fn();
7
- const payload = {
8
- requestId: "req-001",
9
- toolName: "bash",
10
- action: "execute",
11
- params: { command: "rm -rf /tmp/test" },
12
- agentId: "agent-1",
13
- sessionKey: "t1:u1:c1",
14
- trustLevel: "standard",
15
- createdAt: Date.now(),
16
- timeoutMs: 30000,
17
- };
18
- bus.on("approval:requested", handler);
19
- bus.emit("approval:requested", payload);
20
- expect(handler).toHaveBeenCalledWith(payload);
21
- const received = handler.mock.calls[0][0];
22
- expect(received.requestId).toBe("req-001");
23
- expect(received.toolName).toBe("bash");
24
- expect(received.params).toEqual({ command: "rm -rf /tmp/test" });
25
- expect(received.timeoutMs).toBe(30000);
26
- });
27
- it("approval:resolved delivers approved boolean and optional reason", () => {
28
- const bus = new TypedEventBus();
29
- const handler = vi.fn();
30
- // Approved case
31
- const approvedPayload = {
32
- requestId: "req-001",
33
- approved: true,
34
- approvedBy: "admin",
35
- resolvedAt: Date.now(),
36
- };
37
- bus.on("approval:resolved", handler);
38
- bus.emit("approval:resolved", approvedPayload);
39
- expect(handler.mock.calls[0][0].approved).toBe(true);
40
- expect(handler.mock.calls[0][0].reason).toBeUndefined();
41
- // Denied case with reason
42
- const deniedPayload = {
43
- requestId: "req-002",
44
- approved: false,
45
- approvedBy: "system",
46
- reason: "Timed out after 30s",
47
- resolvedAt: Date.now(),
48
- };
49
- bus.emit("approval:resolved", deniedPayload);
50
- expect(handler.mock.calls[1][0].approved).toBe(false);
51
- expect(handler.mock.calls[1][0].reason).toBe("Timed out after 30s");
52
- });
53
- it("config:patched delivers section, optional key, patchedBy", () => {
54
- const bus = new TypedEventBus();
55
- const handler = vi.fn();
56
- // With key
57
- const payload = {
58
- section: "agent",
59
- key: "model",
60
- patchedBy: "admin",
61
- timestamp: Date.now(),
62
- };
63
- bus.on("config:patched", handler);
64
- bus.emit("config:patched", payload);
65
- expect(handler.mock.calls[0][0].key).toBe("model");
66
- // Without key
67
- const noKeyPayload = {
68
- section: "channels",
69
- patchedBy: "rpc",
70
- timestamp: Date.now(),
71
- };
72
- bus.emit("config:patched", noKeyPayload);
73
- expect(handler.mock.calls[1][0].key).toBeUndefined();
74
- });
75
- it("plugin:registered delivers pluginId, pluginName, hookCount", () => {
76
- const bus = new TypedEventBus();
77
- const handler = vi.fn();
78
- const payload = {
79
- pluginId: "tg-01",
80
- pluginName: "telegram",
81
- hookCount: 3,
82
- timestamp: Date.now(),
83
- };
84
- bus.on("plugin:registered", handler);
85
- bus.emit("plugin:registered", payload);
86
- expect(handler).toHaveBeenCalledWith(payload);
87
- const received = handler.mock.calls[0][0];
88
- expect(received.pluginId).toBe("tg-01");
89
- expect(received.pluginName).toBe("telegram");
90
- expect(received.hookCount).toBe(3);
91
- });
92
- it("hook:executed delivers hookName, pluginId, durationMs, success, optional error", () => {
93
- const bus = new TypedEventBus();
94
- const handler = vi.fn();
95
- // Success case
96
- const successPayload = {
97
- hookName: "onMessage",
98
- pluginId: "tg-01",
99
- durationMs: 12,
100
- success: true,
101
- timestamp: Date.now(),
102
- };
103
- bus.on("hook:executed", handler);
104
- bus.emit("hook:executed", successPayload);
105
- expect(handler.mock.calls[0][0].success).toBe(true);
106
- expect(handler.mock.calls[0][0].error).toBeUndefined();
107
- // Failure case with error
108
- const failPayload = {
109
- hookName: "onConnect",
110
- pluginId: "discord-01",
111
- durationMs: 5000,
112
- success: false,
113
- error: "WebSocket timeout",
114
- timestamp: Date.now(),
115
- };
116
- bus.emit("hook:executed", failPayload);
117
- expect(handler.mock.calls[1][0].success).toBe(false);
118
- expect(handler.mock.calls[1][0].error).toBe("WebSocket timeout");
119
- });
120
- it("auth:token_rotated delivers provider and expiresAtMs", () => {
121
- const bus = new TypedEventBus();
122
- const handler = vi.fn();
123
- const expiresAt = Date.now() + 3600000;
124
- const payload = {
125
- provider: "google",
126
- profileName: "gmail-oauth",
127
- expiresAtMs: expiresAt,
128
- timestamp: Date.now(),
129
- };
130
- bus.on("auth:token_rotated", handler);
131
- bus.emit("auth:token_rotated", payload);
132
- expect(handler).toHaveBeenCalledWith(payload);
133
- const received = handler.mock.calls[0][0];
134
- expect(received.provider).toBe("google");
135
- expect(received.expiresAtMs).toBe(expiresAt);
136
- });
137
- it("diagnostic:message_processed delivers all timing fields, tokensUsed, cost, finishReason", () => {
138
- const bus = new TypedEventBus();
139
- const handler = vi.fn();
140
- const now = Date.now();
141
- const payload = {
142
- messageId: "msg-001",
143
- channelId: "c1",
144
- channelType: "telegram",
145
- agentId: "agent-1",
146
- sessionKey: "t1:u1:c1",
147
- receivedAt: now - 3000,
148
- executionDurationMs: 2500,
149
- deliveryDurationMs: 200,
150
- totalDurationMs: 2700,
151
- tokensUsed: 1500,
152
- cost: 0.018,
153
- success: true,
154
- finishReason: "end_turn",
155
- timestamp: now,
156
- };
157
- bus.on("diagnostic:message_processed", handler);
158
- bus.emit("diagnostic:message_processed", payload);
159
- expect(handler).toHaveBeenCalledWith(payload);
160
- const received = handler.mock.calls[0][0];
161
- expect(received.receivedAt).toBe(now - 3000);
162
- expect(received.executionDurationMs).toBe(2500);
163
- expect(received.deliveryDurationMs).toBe(200);
164
- expect(received.totalDurationMs).toBe(2700);
165
- expect(received.tokensUsed).toBe(1500);
166
- expect(received.cost).toBe(0.018);
167
- expect(received.finishReason).toBe("end_turn");
168
- });
169
- it("diagnostic:channel_health delivers channels array with nested objects", () => {
170
- const bus = new TypedEventBus();
171
- const handler = vi.fn();
172
- const payload = {
173
- channels: [
174
- {
175
- channelId: "tg-1",
176
- channelType: "telegram",
177
- lastActiveAt: Date.now() - 60000,
178
- messagesSent: 150,
179
- messagesReceived: 300,
180
- },
181
- {
182
- channelId: "dc-1",
183
- channelType: "discord",
184
- lastActiveAt: Date.now() - 120000,
185
- messagesSent: 50,
186
- messagesReceived: 100,
187
- },
188
- ],
189
- timestamp: Date.now(),
190
- };
191
- bus.on("diagnostic:channel_health", handler);
192
- bus.emit("diagnostic:channel_health", payload);
193
- expect(handler).toHaveBeenCalledWith(payload);
194
- const received = handler.mock.calls[0][0];
195
- expect(received.channels).toHaveLength(2);
196
- expect(received.channels[0].channelType).toBe("telegram");
197
- expect(received.channels[0].messagesSent).toBe(150);
198
- expect(received.channels[1].channelType).toBe("discord");
199
- });
200
- it("media:file_extracted delivers fileName, mimeType, chars, truncated, durationMs", () => {
201
- const bus = new TypedEventBus();
202
- const handler = vi.fn();
203
- const payload = {
204
- fileName: "report.pdf",
205
- mimeType: "application/pdf",
206
- chars: 25000,
207
- truncated: true,
208
- durationMs: 850,
209
- timestamp: Date.now(),
210
- };
211
- bus.on("media:file_extracted", handler);
212
- bus.emit("media:file_extracted", payload);
213
- expect(handler).toHaveBeenCalledWith(payload);
214
- const received = handler.mock.calls[0][0];
215
- expect(received.fileName).toBe("report.pdf");
216
- expect(received.mimeType).toBe("application/pdf");
217
- expect(received.chars).toBe(25000);
218
- expect(received.truncated).toBe(true);
219
- expect(received.durationMs).toBe(850);
220
- });
221
- it("scheduler:job_result delivers nested deliveryTarget and optional payloadKind union", () => {
222
- const bus = new TypedEventBus();
223
- const handler = vi.fn();
224
- // With payloadKind
225
- const payload = {
226
- jobId: "job-001",
227
- jobName: "daily-summary",
228
- agentId: "agent-1",
229
- result: "Daily summary generated successfully",
230
- success: true,
231
- deliveryTarget: {
232
- channelId: "c1",
233
- userId: "u1",
234
- tenantId: "t1",
235
- channelType: "telegram",
236
- },
237
- timestamp: Date.now(),
238
- payloadKind: "agent_turn",
239
- };
240
- bus.on("scheduler:job_result", handler);
241
- bus.emit("scheduler:job_result", payload);
242
- const received = handler.mock.calls[0][0];
243
- expect(received.deliveryTarget.channelId).toBe("c1");
244
- expect(received.deliveryTarget.userId).toBe("u1");
245
- expect(received.deliveryTarget.tenantId).toBe("t1");
246
- expect(received.deliveryTarget.channelType).toBe("telegram");
247
- expect(received.payloadKind).toBe("agent_turn");
248
- expect(received.onComplete).toBeUndefined(); // optional field
249
- // With onComplete callback
250
- const completeSpy = vi.fn();
251
- const withCallback = {
252
- ...payload,
253
- jobId: "job-001b",
254
- onComplete: completeSpy,
255
- };
256
- bus.emit("scheduler:job_result", withCallback);
257
- const receivedWithCb = handler.mock.calls[1][0];
258
- receivedWithCb.onComplete?.({ status: "error", error: "overloaded" });
259
- expect(completeSpy).toHaveBeenCalledWith({ status: "error", error: "overloaded" });
260
- // Without payloadKind
261
- const noKindPayload = {
262
- jobId: "job-002",
263
- jobName: "heartbeat",
264
- agentId: "agent-1",
265
- result: "OK",
266
- success: true,
267
- deliveryTarget: { channelId: "c2", userId: "u2", tenantId: "t1" },
268
- timestamp: Date.now(),
269
- };
270
- bus.emit("scheduler:job_result", noKindPayload);
271
- expect(handler.mock.calls[2][0].payloadKind).toBeUndefined();
272
- });
273
- it("scheduler:job_result accepts cronJobModel field (INTG-02)", () => {
274
- const bus = new TypedEventBus();
275
- const handler = vi.fn();
276
- const payload = {
277
- jobId: "j1",
278
- jobName: "test-cron",
279
- agentId: "a1",
280
- result: "ok",
281
- success: true,
282
- deliveryTarget: { channelId: "c1", userId: "u1", tenantId: "t1" },
283
- timestamp: Date.now(),
284
- payloadKind: "agent_turn",
285
- cronJobModel: "anthropic:claude-haiku-4-5-20251001",
286
- };
287
- bus.on("scheduler:job_result", handler);
288
- bus.emit("scheduler:job_result", payload);
289
- const received = handler.mock.calls[0][0];
290
- expect(received.cronJobModel).toBe("anthropic:claude-haiku-4-5-20251001");
291
- // Without cronJobModel (undefined)
292
- const noCronModel = {
293
- jobId: "j2",
294
- jobName: "sys-event",
295
- agentId: "a1",
296
- result: "text",
297
- success: true,
298
- deliveryTarget: { channelId: "c1", userId: "u1", tenantId: "t1" },
299
- timestamp: Date.now(),
300
- payloadKind: "system_event",
301
- };
302
- bus.emit("scheduler:job_result", noCronModel);
303
- expect(handler.mock.calls[1][0].cronJobModel).toBeUndefined();
304
- });
305
- it("observability:metrics delivers nested eventLoopDelayMs with min/max/mean/p50/p99", () => {
306
- const bus = new TypedEventBus();
307
- const handler = vi.fn();
308
- const payload = {
309
- rssBytes: 104857600,
310
- heapUsedBytes: 52428800,
311
- heapTotalBytes: 78643200,
312
- externalBytes: 1048576,
313
- eventLoopDelayMs: {
314
- min: 0.1,
315
- max: 15.5,
316
- mean: 1.2,
317
- p50: 0.8,
318
- p99: 12.3,
319
- },
320
- activeHandles: 42,
321
- uptimeSeconds: 3600,
322
- timestamp: Date.now(),
323
- };
324
- bus.on("observability:metrics", handler);
325
- bus.emit("observability:metrics", payload);
326
- expect(handler).toHaveBeenCalledWith(payload);
327
- const received = handler.mock.calls[0][0];
328
- expect(received.eventLoopDelayMs.min).toBe(0.1);
329
- expect(received.eventLoopDelayMs.max).toBe(15.5);
330
- expect(received.eventLoopDelayMs.mean).toBe(1.2);
331
- expect(received.eventLoopDelayMs.p50).toBe(0.8);
332
- expect(received.eventLoopDelayMs.p99).toBe(12.3);
333
- expect(received.rssBytes).toBe(104857600);
334
- expect(received.activeHandles).toBe(42);
335
- });
336
- it("system:shutdown delivers reason and graceful", () => {
337
- const bus = new TypedEventBus();
338
- const handler = vi.fn();
339
- const payload = {
340
- reason: "SIGTERM",
341
- graceful: true,
342
- };
343
- bus.on("system:shutdown", handler);
344
- bus.emit("system:shutdown", payload);
345
- expect(handler).toHaveBeenCalledWith(payload);
346
- const received = handler.mock.calls[0][0];
347
- expect(received.reason).toBe("SIGTERM");
348
- expect(received.graceful).toBe(true);
349
- });
350
- it("system:error delivers Error instance and source string", () => {
351
- const bus = new TypedEventBus();
352
- const handler = vi.fn();
353
- const testError = new Error("Unhandled rejection");
354
- const payload = {
355
- error: testError,
356
- source: "unhandledRejection",
357
- };
358
- bus.on("system:error", handler);
359
- bus.emit("system:error", payload);
360
- expect(handler).toHaveBeenCalledWith(payload);
361
- const received = handler.mock.calls[0][0];
362
- expect(received.error).toBeInstanceOf(Error);
363
- expect(received.error.message).toBe("Unhandled rejection");
364
- expect(received.source).toBe("unhandledRejection");
365
- });
366
- it("secret:accessed delivers outcome union", () => {
367
- const bus = new TypedEventBus();
368
- const handler = vi.fn();
369
- for (const outcome of ["success", "denied", "not_found"]) {
370
- const payload = {
371
- secretName: "OPENAI_API_KEY",
372
- agentId: "agent-1",
373
- outcome,
374
- timestamp: Date.now(),
375
- };
376
- bus.on("secret:accessed", handler);
377
- bus.emit("secret:accessed", payload);
378
- bus.removeAllListeners("secret:accessed");
379
- }
380
- expect(handler).toHaveBeenCalledTimes(3);
381
- expect(handler.mock.calls[0][0].outcome).toBe("success");
382
- expect(handler.mock.calls[1][0].outcome).toBe("denied");
383
- expect(handler.mock.calls[2][0].outcome).toBe("not_found");
384
- });
385
- it("security:warn delivers category, agentId, message", () => {
386
- const bus = new TypedEventBus();
387
- const handler = vi.fn();
388
- const payload = {
389
- category: "secret_access",
390
- agentId: "agent-1",
391
- message: "Agent accessing secrets without explicit allow config",
392
- timestamp: Date.now(),
393
- };
394
- bus.on("security:warn", handler);
395
- bus.emit("security:warn", payload);
396
- expect(handler).toHaveBeenCalledWith(payload);
397
- const received = handler.mock.calls[0][0];
398
- expect(received.category).toBe("secret_access");
399
- expect(received.agentId).toBe("agent-1");
400
- expect(received.message).toBe("Agent accessing secrets without explicit allow config");
401
- });
402
- it("type safety: @ts-expect-error for missing required fields", () => {
403
- const bus = new TypedEventBus();
404
- // @ts-expect-error - missing timeoutMs in approval:requested
405
- bus.emit("approval:requested", {
406
- requestId: "r", toolName: "t", action: "a",
407
- params: {}, agentId: "a", sessionKey: "s",
408
- trustLevel: "x", createdAt: 1,
409
- });
410
- // @ts-expect-error - missing eventLoopDelayMs in observability:metrics
411
- bus.emit("observability:metrics", {
412
- rssBytes: 0, heapUsedBytes: 0, heapTotalBytes: 0,
413
- externalBytes: 0, activeHandles: 0, uptimeSeconds: 0, timestamp: 1,
414
- });
415
- });
416
- });