comisai 1.0.10 → 1.0.12

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 (251) hide show
  1. package/README.md +3 -3
  2. package/node_modules/@comis/agent/dist/executor/pi-executor.d.ts +1 -4
  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/dist/wizard/steps/06-channels.js +88 -11
  6. package/node_modules/@comis/cli/dist/wizard/steps/10-write-config.js +4 -0
  7. package/node_modules/@comis/cli/dist/wizard/types.d.ts +1 -0
  8. package/node_modules/@comis/cli/package.json +1 -1
  9. package/node_modules/@comis/core/package.json +1 -1
  10. package/node_modules/@comis/daemon/package.json +1 -1
  11. package/node_modules/@comis/gateway/package.json +1 -1
  12. package/node_modules/@comis/infra/package.json +1 -1
  13. package/node_modules/@comis/memory/package.json +1 -1
  14. package/node_modules/@comis/scheduler/package.json +1 -1
  15. package/node_modules/@comis/shared/package.json +1 -1
  16. package/node_modules/@comis/skills/package.json +1 -1
  17. package/package.json +18 -18
  18. package/node_modules/@comis/core/dist/approval/approval-gate.test.d.ts +0 -1
  19. package/node_modules/@comis/core/dist/approval/approval-gate.test.js +0 -1003
  20. package/node_modules/@comis/core/dist/bootstrap.test.d.ts +0 -1
  21. package/node_modules/@comis/core/dist/bootstrap.test.js +0 -150
  22. package/node_modules/@comis/core/dist/config/backup.test.d.ts +0 -1
  23. package/node_modules/@comis/core/dist/config/backup.test.js +0 -160
  24. package/node_modules/@comis/core/dist/config/env-substitution.test.d.ts +0 -1
  25. package/node_modules/@comis/core/dist/config/env-substitution.test.js +0 -259
  26. package/node_modules/@comis/core/dist/config/field-metadata.test.d.ts +0 -1
  27. package/node_modules/@comis/core/dist/config/field-metadata.test.js +0 -72
  28. package/node_modules/@comis/core/dist/config/git-manager.test.d.ts +0 -1
  29. package/node_modules/@comis/core/dist/config/git-manager.test.js +0 -1042
  30. package/node_modules/@comis/core/dist/config/immutable-keys.test.d.ts +0 -1
  31. package/node_modules/@comis/core/dist/config/immutable-keys.test.js +0 -283
  32. package/node_modules/@comis/core/dist/config/include-resolver.test.d.ts +0 -1
  33. package/node_modules/@comis/core/dist/config/include-resolver.test.js +0 -292
  34. package/node_modules/@comis/core/dist/config/layered.test.d.ts +0 -1
  35. package/node_modules/@comis/core/dist/config/layered.test.js +0 -211
  36. package/node_modules/@comis/core/dist/config/loader.test.d.ts +0 -1
  37. package/node_modules/@comis/core/dist/config/loader.test.js +0 -300
  38. package/node_modules/@comis/core/dist/config/migrate.test.d.ts +0 -1
  39. package/node_modules/@comis/core/dist/config/migrate.test.js +0 -244
  40. package/node_modules/@comis/core/dist/config/partial-validator.test.d.ts +0 -1
  41. package/node_modules/@comis/core/dist/config/partial-validator.test.js +0 -98
  42. package/node_modules/@comis/core/dist/config/schema-agent-model.test.d.ts +0 -1
  43. package/node_modules/@comis/core/dist/config/schema-agent-model.test.js +0 -279
  44. package/node_modules/@comis/core/dist/config/schema-agent-session.test.d.ts +0 -1
  45. package/node_modules/@comis/core/dist/config/schema-agent-session.test.js +0 -242
  46. package/node_modules/@comis/core/dist/config/schema-agent.test.d.ts +0 -1
  47. package/node_modules/@comis/core/dist/config/schema-agent.test.js +0 -645
  48. package/node_modules/@comis/core/dist/config/schema-channel.test.d.ts +0 -1
  49. package/node_modules/@comis/core/dist/config/schema-channel.test.js +0 -341
  50. package/node_modules/@comis/core/dist/config/schema-coalescer.test.d.ts +0 -1
  51. package/node_modules/@comis/core/dist/config/schema-coalescer.test.js +0 -51
  52. package/node_modules/@comis/core/dist/config/schema-context-engine.test.d.ts +0 -1
  53. package/node_modules/@comis/core/dist/config/schema-context-engine.test.js +0 -797
  54. package/node_modules/@comis/core/dist/config/schema-context-guard.test.d.ts +0 -1
  55. package/node_modules/@comis/core/dist/config/schema-context-guard.test.js +0 -111
  56. package/node_modules/@comis/core/dist/config/schema-daemon.test.d.ts +0 -1
  57. package/node_modules/@comis/core/dist/config/schema-daemon.test.js +0 -107
  58. package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.d.ts +0 -1
  59. package/node_modules/@comis/core/dist/config/schema-delivery-timing.test.js +0 -51
  60. package/node_modules/@comis/core/dist/config/schema-documentation.test.d.ts +0 -1
  61. package/node_modules/@comis/core/dist/config/schema-documentation.test.js +0 -63
  62. package/node_modules/@comis/core/dist/config/schema-gateway.test.d.ts +0 -1
  63. package/node_modules/@comis/core/dist/config/schema-gateway.test.js +0 -219
  64. package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.d.ts +0 -1
  65. package/node_modules/@comis/core/dist/config/schema-gemini-cache.test.js +0 -41
  66. package/node_modules/@comis/core/dist/config/schema-integrations.test.d.ts +0 -1
  67. package/node_modules/@comis/core/dist/config/schema-integrations.test.js +0 -92
  68. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.d.ts +0 -1
  69. package/node_modules/@comis/core/dist/config/schema-lifecycle-reactions.test.js +0 -61
  70. package/node_modules/@comis/core/dist/config/schema-misc.test.d.ts +0 -1
  71. package/node_modules/@comis/core/dist/config/schema-misc.test.js +0 -394
  72. package/node_modules/@comis/core/dist/config/schema-observability.test.d.ts +0 -1
  73. package/node_modules/@comis/core/dist/config/schema-observability.test.js +0 -76
  74. package/node_modules/@comis/core/dist/config/schema-providers.test.d.ts +0 -1
  75. package/node_modules/@comis/core/dist/config/schema-providers.test.js +0 -294
  76. package/node_modules/@comis/core/dist/config/schema-queue.test.d.ts +0 -1
  77. package/node_modules/@comis/core/dist/config/schema-queue.test.js +0 -234
  78. package/node_modules/@comis/core/dist/config/schema-response-prefix.test.d.ts +0 -1
  79. package/node_modules/@comis/core/dist/config/schema-response-prefix.test.js +0 -36
  80. package/node_modules/@comis/core/dist/config/schema-security.test.d.ts +0 -1
  81. package/node_modules/@comis/core/dist/config/schema-security.test.js +0 -54
  82. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.d.ts +0 -1
  83. package/node_modules/@comis/core/dist/config/schema-sender-trust-display.test.js +0 -60
  84. package/node_modules/@comis/core/dist/config/schema-serializer.test.d.ts +0 -1
  85. package/node_modules/@comis/core/dist/config/schema-serializer.test.js +0 -73
  86. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.d.ts +0 -1
  87. package/node_modules/@comis/core/dist/config/schema-telegram-file-guard.test.js +0 -39
  88. package/node_modules/@comis/core/dist/context/context.test.d.ts +0 -1
  89. package/node_modules/@comis/core/dist/context/context.test.js +0 -276
  90. package/node_modules/@comis/core/dist/domain/agent-response.test.d.ts +0 -1
  91. package/node_modules/@comis/core/dist/domain/agent-response.test.js +0 -159
  92. package/node_modules/@comis/core/dist/domain/credential-mapping.test.d.ts +0 -1
  93. package/node_modules/@comis/core/dist/domain/credential-mapping.test.js +0 -135
  94. package/node_modules/@comis/core/dist/domain/delivery-origin.test.d.ts +0 -1
  95. package/node_modules/@comis/core/dist/domain/delivery-origin.test.js +0 -68
  96. package/node_modules/@comis/core/dist/domain/execution-graph.test.d.ts +0 -1
  97. package/node_modules/@comis/core/dist/domain/execution-graph.test.js +0 -441
  98. package/node_modules/@comis/core/dist/domain/memory-entry.test.d.ts +0 -1
  99. package/node_modules/@comis/core/dist/domain/memory-entry.test.js +0 -193
  100. package/node_modules/@comis/core/dist/domain/normalized-message.test.d.ts +0 -1
  101. package/node_modules/@comis/core/dist/domain/normalized-message.test.js +0 -255
  102. package/node_modules/@comis/core/dist/domain/session-key.test.d.ts +0 -1
  103. package/node_modules/@comis/core/dist/domain/session-key.test.js +0 -291
  104. package/node_modules/@comis/core/dist/domain/subagent-context-config.test.d.ts +0 -1
  105. package/node_modules/@comis/core/dist/domain/subagent-context-config.test.js +0 -131
  106. package/node_modules/@comis/core/dist/domain/subagent-context-types.test.d.ts +0 -1
  107. package/node_modules/@comis/core/dist/domain/subagent-context-types.test.js +0 -182
  108. package/node_modules/@comis/core/dist/event-bus/bus.test.d.ts +0 -1
  109. package/node_modules/@comis/core/dist/event-bus/bus.test.js +0 -152
  110. package/node_modules/@comis/core/dist/event-bus/events-agent.test.d.ts +0 -1
  111. package/node_modules/@comis/core/dist/event-bus/events-agent.test.js +0 -409
  112. package/node_modules/@comis/core/dist/event-bus/events-channel.test.d.ts +0 -1
  113. package/node_modules/@comis/core/dist/event-bus/events-channel.test.js +0 -240
  114. package/node_modules/@comis/core/dist/event-bus/events-infra.test.d.ts +0 -1
  115. package/node_modules/@comis/core/dist/event-bus/events-infra.test.js +0 -416
  116. package/node_modules/@comis/core/dist/event-bus/events-messaging.test.d.ts +0 -1
  117. package/node_modules/@comis/core/dist/event-bus/events-messaging.test.js +0 -433
  118. package/node_modules/@comis/core/dist/event-bus/events.test.d.ts +0 -1
  119. package/node_modules/@comis/core/dist/event-bus/events.test.js +0 -93
  120. package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.d.ts +0 -1
  121. package/node_modules/@comis/core/dist/hooks/hook-runner-global.test.js +0 -29
  122. package/node_modules/@comis/core/dist/hooks/hook-runner.test.d.ts +0 -1
  123. package/node_modules/@comis/core/dist/hooks/hook-runner.test.js +0 -490
  124. package/node_modules/@comis/core/dist/hooks/hook-strategies.test.d.ts +0 -1
  125. package/node_modules/@comis/core/dist/hooks/hook-strategies.test.js +0 -209
  126. package/node_modules/@comis/core/dist/hooks/integration.test.d.ts +0 -1
  127. package/node_modules/@comis/core/dist/hooks/integration.test.js +0 -235
  128. package/node_modules/@comis/core/dist/hooks/plugin-registry.test.d.ts +0 -1
  129. package/node_modules/@comis/core/dist/hooks/plugin-registry.test.js +0 -470
  130. package/node_modules/@comis/core/dist/load-env.test.d.ts +0 -1
  131. package/node_modules/@comis/core/dist/load-env.test.js +0 -21
  132. package/node_modules/@comis/core/dist/security/action-classifier.test.d.ts +0 -1
  133. package/node_modules/@comis/core/dist/security/action-classifier.test.js +0 -298
  134. package/node_modules/@comis/core/dist/security/audit-aggregator.test.d.ts +0 -1
  135. package/node_modules/@comis/core/dist/security/audit-aggregator.test.js +0 -128
  136. package/node_modules/@comis/core/dist/security/audit.test.d.ts +0 -1
  137. package/node_modules/@comis/core/dist/security/audit.test.js +0 -154
  138. package/node_modules/@comis/core/dist/security/canary-token.test.d.ts +0 -1
  139. package/node_modules/@comis/core/dist/security/canary-token.test.js +0 -45
  140. package/node_modules/@comis/core/dist/security/config-redaction.test.d.ts +0 -1
  141. package/node_modules/@comis/core/dist/security/config-redaction.test.js +0 -107
  142. package/node_modules/@comis/core/dist/security/external-content.test.d.ts +0 -1
  143. package/node_modules/@comis/core/dist/security/external-content.test.js +0 -210
  144. package/node_modules/@comis/core/dist/security/injection-patterns.test.d.ts +0 -1
  145. package/node_modules/@comis/core/dist/security/injection-patterns.test.js +0 -213
  146. package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.d.ts +0 -1
  147. package/node_modules/@comis/core/dist/security/injection-rate-limiter.test.js +0 -194
  148. package/node_modules/@comis/core/dist/security/input-guard.test.d.ts +0 -1
  149. package/node_modules/@comis/core/dist/security/input-guard.test.js +0 -215
  150. package/node_modules/@comis/core/dist/security/input-security-guard.test.d.ts +0 -1
  151. package/node_modules/@comis/core/dist/security/input-security-guard.test.js +0 -215
  152. package/node_modules/@comis/core/dist/security/input-validator.test.d.ts +0 -1
  153. package/node_modules/@comis/core/dist/security/input-validator.test.js +0 -133
  154. package/node_modules/@comis/core/dist/security/log-sanitizer.test.d.ts +0 -1
  155. package/node_modules/@comis/core/dist/security/log-sanitizer.test.js +0 -260
  156. package/node_modules/@comis/core/dist/security/memory-write-validator.test.d.ts +0 -1
  157. package/node_modules/@comis/core/dist/security/memory-write-validator.test.js +0 -62
  158. package/node_modules/@comis/core/dist/security/output-guard.test.d.ts +0 -1
  159. package/node_modules/@comis/core/dist/security/output-guard.test.js +0 -397
  160. package/node_modules/@comis/core/dist/security/safe-path.test.d.ts +0 -1
  161. package/node_modules/@comis/core/dist/security/safe-path.test.js +0 -95
  162. package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.d.ts +0 -1
  163. package/node_modules/@comis/core/dist/security/scoped-secret-manager.test.js +0 -231
  164. package/node_modules/@comis/core/dist/security/secret-access.test.d.ts +0 -1
  165. package/node_modules/@comis/core/dist/security/secret-access.test.js +0 -41
  166. package/node_modules/@comis/core/dist/security/secret-crypto.test.d.ts +0 -1
  167. package/node_modules/@comis/core/dist/security/secret-crypto.test.js +0 -113
  168. package/node_modules/@comis/core/dist/security/secret-manager.test.d.ts +0 -1
  169. package/node_modules/@comis/core/dist/security/secret-manager.test.js +0 -394
  170. package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.d.ts +0 -1
  171. package/node_modules/@comis/core/dist/security/secret-ref-resolver.test.js +0 -268
  172. package/node_modules/@comis/core/dist/security/secrets-audit.test.d.ts +0 -10
  173. package/node_modules/@comis/core/dist/security/secrets-audit.test.js +0 -295
  174. package/node_modules/@comis/core/dist/security/ssrf-guard.test.d.ts +0 -1
  175. package/node_modules/@comis/core/dist/security/ssrf-guard.test.js +0 -127
  176. package/node_modules/@comis/core/dist/security/token-generator.test.d.ts +0 -1
  177. package/node_modules/@comis/core/dist/security/token-generator.test.js +0 -35
  178. package/node_modules/@comis/core/dist/tool-metadata.test.d.ts +0 -1
  179. package/node_modules/@comis/core/dist/tool-metadata.test.js +0 -112
  180. package/node_modules/@comis/memory/dist/compaction.test.d.ts +0 -1
  181. package/node_modules/@comis/memory/dist/compaction.test.js +0 -298
  182. package/node_modules/@comis/memory/dist/context-schema.test.d.ts +0 -1
  183. package/node_modules/@comis/memory/dist/context-schema.test.js +0 -246
  184. package/node_modules/@comis/memory/dist/context-store.test.d.ts +0 -1
  185. package/node_modules/@comis/memory/dist/context-store.test.js +0 -708
  186. package/node_modules/@comis/memory/dist/credential-mapping-schema.test.d.ts +0 -7
  187. package/node_modules/@comis/memory/dist/credential-mapping-schema.test.js +0 -73
  188. package/node_modules/@comis/memory/dist/credential-mapping-store.test.d.ts +0 -8
  189. package/node_modules/@comis/memory/dist/credential-mapping-store.test.js +0 -340
  190. package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.d.ts +0 -1
  191. package/node_modules/@comis/memory/dist/delivery-mirror-adapter.test.js +0 -165
  192. package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.d.ts +0 -1
  193. package/node_modules/@comis/memory/dist/delivery-queue-adapter.test.js +0 -263
  194. package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.d.ts +0 -1
  195. package/node_modules/@comis/memory/dist/embedding-batch-indexer.test.js +0 -202
  196. package/node_modules/@comis/memory/dist/embedding-cache-lru.test.d.ts +0 -1
  197. package/node_modules/@comis/memory/dist/embedding-cache-lru.test.js +0 -241
  198. package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.d.ts +0 -8
  199. package/node_modules/@comis/memory/dist/embedding-cache-sqlite.test.js +0 -678
  200. package/node_modules/@comis/memory/dist/embedding-cache.test.d.ts +0 -1
  201. package/node_modules/@comis/memory/dist/embedding-cache.test.js +0 -213
  202. package/node_modules/@comis/memory/dist/embedding-fingerprint.test.d.ts +0 -1
  203. package/node_modules/@comis/memory/dist/embedding-fingerprint.test.js +0 -87
  204. package/node_modules/@comis/memory/dist/embedding-hash.test.d.ts +0 -1
  205. package/node_modules/@comis/memory/dist/embedding-hash.test.js +0 -31
  206. package/node_modules/@comis/memory/dist/embedding-integration.test.d.ts +0 -8
  207. package/node_modules/@comis/memory/dist/embedding-integration.test.js +0 -232
  208. package/node_modules/@comis/memory/dist/embedding-provider-factory.test.d.ts +0 -1
  209. package/node_modules/@comis/memory/dist/embedding-provider-factory.test.js +0 -176
  210. package/node_modules/@comis/memory/dist/embedding-provider-local.test.d.ts +0 -8
  211. package/node_modules/@comis/memory/dist/embedding-provider-local.test.js +0 -76
  212. package/node_modules/@comis/memory/dist/embedding-provider-openai.test.d.ts +0 -8
  213. package/node_modules/@comis/memory/dist/embedding-provider-openai.test.js +0 -100
  214. package/node_modules/@comis/memory/dist/embedding-queue.test.d.ts +0 -1
  215. package/node_modules/@comis/memory/dist/embedding-queue.test.js +0 -236
  216. package/node_modules/@comis/memory/dist/hybrid-search.test.d.ts +0 -1
  217. package/node_modules/@comis/memory/dist/hybrid-search.test.js +0 -476
  218. package/node_modules/@comis/memory/dist/identity-link-store.test.d.ts +0 -1
  219. package/node_modules/@comis/memory/dist/identity-link-store.test.js +0 -88
  220. package/node_modules/@comis/memory/dist/memory-api.test.d.ts +0 -1
  221. package/node_modules/@comis/memory/dist/memory-api.test.js +0 -495
  222. package/node_modules/@comis/memory/dist/memory-concurrency.test.d.ts +0 -20
  223. package/node_modules/@comis/memory/dist/memory-concurrency.test.js +0 -222
  224. package/node_modules/@comis/memory/dist/named-graph-store.test.d.ts +0 -1
  225. package/node_modules/@comis/memory/dist/named-graph-store.test.js +0 -227
  226. package/node_modules/@comis/memory/dist/observability-store.test.d.ts +0 -1
  227. package/node_modules/@comis/memory/dist/observability-store.test.js +0 -704
  228. package/node_modules/@comis/memory/dist/row-mapper.test.d.ts +0 -1
  229. package/node_modules/@comis/memory/dist/row-mapper.test.js +0 -409
  230. package/node_modules/@comis/memory/dist/schema.test.d.ts +0 -1
  231. package/node_modules/@comis/memory/dist/schema.test.js +0 -240
  232. package/node_modules/@comis/memory/dist/secret-store-schema.test.d.ts +0 -7
  233. package/node_modules/@comis/memory/dist/secret-store-schema.test.js +0 -90
  234. package/node_modules/@comis/memory/dist/session-store.test.d.ts +0 -1
  235. package/node_modules/@comis/memory/dist/session-store.test.js +0 -262
  236. package/node_modules/@comis/memory/dist/setup-secrets.test.d.ts +0 -1
  237. package/node_modules/@comis/memory/dist/setup-secrets.test.js +0 -140
  238. package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.d.ts +0 -1
  239. package/node_modules/@comis/memory/dist/sqlite-memory-adapter.test.js +0 -888
  240. package/node_modules/@comis/memory/dist/sqlite-secret-store.test.d.ts +0 -8
  241. package/node_modules/@comis/memory/dist/sqlite-secret-store.test.js +0 -245
  242. package/node_modules/@comis/shared/dist/abort.test.d.ts +0 -1
  243. package/node_modules/@comis/shared/dist/abort.test.js +0 -71
  244. package/node_modules/@comis/shared/dist/result.test.d.ts +0 -1
  245. package/node_modules/@comis/shared/dist/result.test.js +0 -178
  246. package/node_modules/@comis/shared/dist/suppress-error.test.d.ts +0 -1
  247. package/node_modules/@comis/shared/dist/suppress-error.test.js +0 -50
  248. package/node_modules/@comis/shared/dist/timeout.test.d.ts +0 -1
  249. package/node_modules/@comis/shared/dist/timeout.test.js +0 -75
  250. package/node_modules/@comis/shared/dist/ttl-cache.test.d.ts +0 -1
  251. package/node_modules/@comis/shared/dist/ttl-cache.test.js +0 -81
@@ -1,433 +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
- const testMessage = {
5
- id: "550e8400-e29b-41d4-a716-446655440000",
6
- channelId: "c1",
7
- channelType: "telegram",
8
- senderId: "u1",
9
- text: "hello",
10
- timestamp: Date.now(),
11
- attachments: [],
12
- metadata: {},
13
- };
14
- describe("MessagingEvents payload structure", () => {
15
- it("message:received delivers NormalizedMessage + SessionKey", () => {
16
- const bus = new TypedEventBus();
17
- const handler = vi.fn();
18
- bus.on("message:received", handler);
19
- bus.emit("message:received", { message: testMessage, sessionKey: testSessionKey });
20
- expect(handler).toHaveBeenCalledOnce();
21
- const payload = handler.mock.calls[0][0];
22
- expect(payload.message.id).toBe("550e8400-e29b-41d4-a716-446655440000");
23
- expect(payload.message.channelType).toBe("telegram");
24
- expect(payload.message.text).toBe("hello");
25
- expect(payload.message.attachments).toEqual([]);
26
- expect(payload.sessionKey.tenantId).toBe("t1");
27
- expect(payload.sessionKey.userId).toBe("u1");
28
- expect(payload.sessionKey.channelId).toBe("c1");
29
- });
30
- it("message:sent delivers channelId, messageId, content", () => {
31
- const bus = new TypedEventBus();
32
- const handler = vi.fn();
33
- const payload = {
34
- channelId: "c1",
35
- messageId: "msg-001",
36
- content: "Reply text",
37
- };
38
- bus.on("message:sent", handler);
39
- bus.emit("message:sent", payload);
40
- expect(handler).toHaveBeenCalledWith(payload);
41
- const received = handler.mock.calls[0][0];
42
- expect(received.channelId).toBe("c1");
43
- expect(received.messageId).toBe("msg-001");
44
- expect(received.content).toBe("Reply text");
45
- });
46
- it("message:streaming delivers delta + accumulated", () => {
47
- const bus = new TypedEventBus();
48
- const handler = vi.fn();
49
- const payload = {
50
- channelId: "c1",
51
- messageId: "msg-002",
52
- delta: "world",
53
- accumulated: "hello world",
54
- };
55
- bus.on("message:streaming", handler);
56
- bus.emit("message:streaming", payload);
57
- expect(handler).toHaveBeenCalledWith(payload);
58
- const received = handler.mock.calls[0][0];
59
- expect(received.delta).toBe("world");
60
- expect(received.accumulated).toBe("hello world");
61
- });
62
- it("session:created delivers sessionKey + timestamp", () => {
63
- const bus = new TypedEventBus();
64
- const handler = vi.fn();
65
- const now = Date.now();
66
- const payload = {
67
- sessionKey: testSessionKey,
68
- timestamp: now,
69
- };
70
- bus.on("session:created", handler);
71
- bus.emit("session:created", payload);
72
- expect(handler).toHaveBeenCalledWith(payload);
73
- const received = handler.mock.calls[0][0];
74
- expect(received.sessionKey).toEqual(testSessionKey);
75
- expect(received.timestamp).toBe(now);
76
- });
77
- it("session:expired delivers sessionKey + reason", () => {
78
- const bus = new TypedEventBus();
79
- const handler = vi.fn();
80
- const payload = {
81
- sessionKey: testSessionKey,
82
- reason: "idle_timeout",
83
- };
84
- bus.on("session:expired", handler);
85
- bus.emit("session:expired", payload);
86
- expect(handler).toHaveBeenCalledWith(payload);
87
- const received = handler.mock.calls[0][0];
88
- expect(received.reason).toBe("idle_timeout");
89
- });
90
- it("session:cross_send delivers mode union type", () => {
91
- const bus = new TypedEventBus();
92
- const handler = vi.fn();
93
- const now = Date.now();
94
- for (const mode of ["fire-and-forget", "wait", "ping-pong"]) {
95
- const payload = {
96
- fromSessionKey: "session-a",
97
- toSessionKey: "session-b",
98
- mode,
99
- timestamp: now,
100
- };
101
- bus.on("session:cross_send", handler);
102
- bus.emit("session:cross_send", payload);
103
- bus.removeAllListeners("session:cross_send");
104
- }
105
- expect(handler).toHaveBeenCalledTimes(3);
106
- expect(handler.mock.calls[0][0].mode).toBe("fire-and-forget");
107
- expect(handler.mock.calls[1][0].mode).toBe("wait");
108
- expect(handler.mock.calls[2][0].mode).toBe("ping-pong");
109
- });
110
- it("session:sub_agent_spawned delivers runId, parentSessionKey, agentId, task", () => {
111
- const bus = new TypedEventBus();
112
- const handler = vi.fn();
113
- const payload = {
114
- runId: "run-001",
115
- parentSessionKey: "parent-session",
116
- agentId: "sub-agent-1",
117
- task: "summarize conversation",
118
- timestamp: Date.now(),
119
- };
120
- bus.on("session:sub_agent_spawned", handler);
121
- bus.emit("session:sub_agent_spawned", payload);
122
- expect(handler).toHaveBeenCalledWith(payload);
123
- const received = handler.mock.calls[0][0];
124
- expect(received.runId).toBe("run-001");
125
- expect(received.parentSessionKey).toBe("parent-session");
126
- expect(received.agentId).toBe("sub-agent-1");
127
- expect(received.task).toBe("summarize conversation");
128
- });
129
- it("compaction:started delivers agentId, sessionKey, timestamp", () => {
130
- const bus = new TypedEventBus();
131
- const handler = vi.fn();
132
- const now = Date.now();
133
- const payload = {
134
- agentId: "agent-1",
135
- sessionKey: testSessionKey,
136
- timestamp: now,
137
- };
138
- bus.on("compaction:started", handler);
139
- bus.emit("compaction:started", payload);
140
- expect(handler).toHaveBeenCalledWith(payload);
141
- const received = handler.mock.calls[0][0];
142
- expect(received.agentId).toBe("agent-1");
143
- expect(received.sessionKey).toEqual(testSessionKey);
144
- });
145
- it("compaction:recommended delivers contextPercent, contextTokens, contextWindow", () => {
146
- const bus = new TypedEventBus();
147
- const handler = vi.fn();
148
- const payload = {
149
- agentId: "agent-1",
150
- sessionKey: testSessionKey,
151
- contextPercent: 92.5,
152
- contextTokens: 185000,
153
- contextWindow: 200000,
154
- timestamp: Date.now(),
155
- };
156
- bus.on("compaction:recommended", handler);
157
- bus.emit("compaction:recommended", payload);
158
- expect(handler).toHaveBeenCalledWith(payload);
159
- const received = handler.mock.calls[0][0];
160
- expect(received.contextPercent).toBe(92.5);
161
- expect(received.contextTokens).toBe(185000);
162
- expect(received.contextWindow).toBe(200000);
163
- });
164
- it("execution:aborted delivers reason union type", () => {
165
- const bus = new TypedEventBus();
166
- const handler = vi.fn();
167
- const reasons = [
168
- "user_stop",
169
- "budget_exceeded",
170
- "circuit_breaker",
171
- "max_steps",
172
- "context_exhausted",
173
- "pipeline_timeout",
174
- ];
175
- for (const reason of reasons) {
176
- const payload = {
177
- sessionKey: testSessionKey,
178
- reason,
179
- agentId: "agent-1",
180
- timestamp: Date.now(),
181
- };
182
- bus.on("execution:aborted", handler);
183
- bus.emit("execution:aborted", payload);
184
- bus.removeAllListeners("execution:aborted");
185
- }
186
- expect(handler).toHaveBeenCalledTimes(6);
187
- expect(handler.mock.calls[0][0].reason).toBe("user_stop");
188
- expect(handler.mock.calls[4][0].reason).toBe("context_exhausted");
189
- expect(handler.mock.calls[5][0].reason).toBe("pipeline_timeout");
190
- });
191
- it("execution:prompt_timeout delivers agentId, sessionKey, timeoutMs", () => {
192
- const bus = new TypedEventBus();
193
- const handler = vi.fn();
194
- const payload = {
195
- agentId: "agent-1",
196
- sessionKey: "default:user1:channel1",
197
- timeoutMs: 180_000,
198
- timestamp: Date.now(),
199
- };
200
- bus.on("execution:prompt_timeout", handler);
201
- bus.emit("execution:prompt_timeout", payload);
202
- expect(handler).toHaveBeenCalledWith(payload);
203
- const received = handler.mock.calls[0][0];
204
- expect(received.agentId).toBe("agent-1");
205
- expect(received.timeoutMs).toBe(180_000);
206
- });
207
- it("announcement:dead_lettered delivers runId, channelType, reason, timestamp", () => {
208
- const bus = new TypedEventBus();
209
- const handler = vi.fn();
210
- const now = Date.now();
211
- const payload = {
212
- runId: "run-dlq-001",
213
- channelType: "telegram",
214
- reason: "connection_timeout",
215
- timestamp: now,
216
- };
217
- bus.on("announcement:dead_lettered", handler);
218
- bus.emit("announcement:dead_lettered", payload);
219
- expect(handler).toHaveBeenCalledOnce();
220
- const received = handler.mock.calls[0][0];
221
- expect(received.runId).toBe("run-dlq-001");
222
- expect(received.channelType).toBe("telegram");
223
- expect(received.reason).toBe("connection_timeout");
224
- expect(received.timestamp).toBe(now);
225
- });
226
- it("announcement:dead_letter_delivered delivers runId, channelType, attemptCount, timestamp", () => {
227
- const bus = new TypedEventBus();
228
- const handler = vi.fn();
229
- const now = Date.now();
230
- const payload = {
231
- runId: "run-dlq-002",
232
- channelType: "discord",
233
- attemptCount: 3,
234
- timestamp: now,
235
- };
236
- bus.on("announcement:dead_letter_delivered", handler);
237
- bus.emit("announcement:dead_letter_delivered", payload);
238
- expect(handler).toHaveBeenCalledOnce();
239
- const received = handler.mock.calls[0][0];
240
- expect(received.runId).toBe("run-dlq-002");
241
- expect(received.channelType).toBe("discord");
242
- expect(typeof received.attemptCount).toBe("number");
243
- expect(received.attemptCount).toBe(3);
244
- expect(received.timestamp).toBe(now);
245
- });
246
- it("type safety: @ts-expect-error for missing required fields", () => {
247
- const bus = new TypedEventBus();
248
- // @ts-expect-error - missing sessionKey in message:received
249
- bus.emit("message:received", { message: testMessage });
250
- // @ts-expect-error - missing content in message:sent
251
- bus.emit("message:sent", { channelId: "c1", messageId: "m1" });
252
- });
253
- });
254
- // ---------------------------------------------------------------------------
255
- // Subagent context lifecycle events (Phase 398)
256
- // ---------------------------------------------------------------------------
257
- describe("Subagent context lifecycle events (Phase 398)", () => {
258
- it("session:sub_agent_spawn_prepared delivers rich payload", () => {
259
- const bus = new TypedEventBus();
260
- const handler = vi.fn();
261
- const payload = {
262
- runId: "run-spawn-001",
263
- parentSessionKey: "parent-session",
264
- agentId: "sub-agent-1",
265
- task: "analyze codebase",
266
- depth: 1,
267
- maxDepth: 3,
268
- artifactCount: 5,
269
- timestamp: Date.now(),
270
- };
271
- bus.on("session:sub_agent_spawn_prepared", handler);
272
- bus.emit("session:sub_agent_spawn_prepared", payload);
273
- expect(handler).toHaveBeenCalledOnce();
274
- const received = handler.mock.calls[0][0];
275
- expect(received.runId).toBe("run-spawn-001");
276
- expect(received.parentSessionKey).toBe("parent-session");
277
- expect(received.agentId).toBe("sub-agent-1");
278
- expect(received.task).toBe("analyze codebase");
279
- expect(received.depth).toBe(1);
280
- expect(received.maxDepth).toBe(3);
281
- expect(received.artifactCount).toBe(5);
282
- });
283
- it("session:sub_agent_result_condensed delivers condensation data", () => {
284
- const bus = new TypedEventBus();
285
- const handler = vi.fn();
286
- const payload = {
287
- runId: "run-cond-001",
288
- agentId: "sub-agent-1",
289
- level: 2,
290
- originalTokens: 8000,
291
- condensedTokens: 3500,
292
- compressionRatio: 0.4375,
293
- taskComplete: true,
294
- diskPath: "/tmp/results/run-cond-001.json",
295
- timestamp: Date.now(),
296
- };
297
- bus.on("session:sub_agent_result_condensed", handler);
298
- bus.emit("session:sub_agent_result_condensed", payload);
299
- expect(handler).toHaveBeenCalledOnce();
300
- const received = handler.mock.calls[0][0];
301
- expect(received.level).toBe(2);
302
- expect(received.compressionRatio).toBe(0.4375);
303
- expect(received.originalTokens).toBe(8000);
304
- expect(received.condensedTokens).toBe(3500);
305
- expect(received.taskComplete).toBe(true);
306
- expect(received.diskPath).toBe("/tmp/results/run-cond-001.json");
307
- });
308
- it("session:sub_agent_lifecycle_ended includes end reason", () => {
309
- const bus = new TypedEventBus();
310
- const handler = vi.fn();
311
- const payload = {
312
- runId: "run-end-001",
313
- agentId: "sub-agent-1",
314
- parentSessionKey: "parent-session",
315
- endReason: "completed",
316
- durationMs: 15000,
317
- tokensUsed: 12000,
318
- cost: 0.036,
319
- condensationLevel: 1,
320
- timestamp: Date.now(),
321
- };
322
- bus.on("session:sub_agent_lifecycle_ended", handler);
323
- bus.emit("session:sub_agent_lifecycle_ended", payload);
324
- expect(handler).toHaveBeenCalledOnce();
325
- const received = handler.mock.calls[0][0];
326
- expect(received.endReason).toBe("completed");
327
- expect(received.durationMs).toBe(15000);
328
- expect(received.tokensUsed).toBe(12000);
329
- expect(received.cost).toBe(0.036);
330
- expect(received.condensationLevel).toBe(1);
331
- });
332
- it("session:sub_agent_spawn_rejected delivers rejection reason", () => {
333
- const bus = new TypedEventBus();
334
- const handler = vi.fn();
335
- const payload = {
336
- parentSessionKey: "parent-session",
337
- agentId: "sub-agent-deep",
338
- task: "go deeper",
339
- reason: "depth_exceeded",
340
- currentDepth: 3,
341
- maxDepth: 3,
342
- currentChildren: 2,
343
- maxChildren: 5,
344
- timestamp: Date.now(),
345
- };
346
- bus.on("session:sub_agent_spawn_rejected", handler);
347
- bus.emit("session:sub_agent_spawn_rejected", payload);
348
- expect(handler).toHaveBeenCalledOnce();
349
- const received = handler.mock.calls[0][0];
350
- expect(received.reason).toBe("depth_exceeded");
351
- expect(received.currentDepth).toBe(3);
352
- expect(received.maxDepth).toBe(3);
353
- });
354
- it("session:sub_agent_spawn_queued delivers all fields", () => {
355
- const bus = new TypedEventBus();
356
- const handler = vi.fn();
357
- const payload = {
358
- runId: "run-queued-001",
359
- parentSessionKey: "parent-session",
360
- agentId: "sub-agent-1",
361
- task: "queued task",
362
- queuePosition: 2,
363
- activeChildren: 5,
364
- maxChildren: 5,
365
- timestamp: Date.now(),
366
- };
367
- bus.on("session:sub_agent_spawn_queued", handler);
368
- bus.emit("session:sub_agent_spawn_queued", payload);
369
- expect(handler).toHaveBeenCalledOnce();
370
- const received = handler.mock.calls[0][0];
371
- expect(received.runId).toBe("run-queued-001");
372
- expect(received.parentSessionKey).toBe("parent-session");
373
- expect(received.agentId).toBe("sub-agent-1");
374
- expect(received.task).toBe("queued task");
375
- expect(received.queuePosition).toBe(2);
376
- expect(received.activeChildren).toBe(5);
377
- expect(received.maxChildren).toBe(5);
378
- });
379
- it("existing sub_agent_spawned event still works (regression guard)", () => {
380
- const bus = new TypedEventBus();
381
- const handler = vi.fn();
382
- const payload = {
383
- runId: "run-legacy-001",
384
- parentSessionKey: "parent-session",
385
- agentId: "sub-agent-1",
386
- task: "summarize conversation",
387
- timestamp: Date.now(),
388
- };
389
- bus.on("session:sub_agent_spawned", handler);
390
- bus.emit("session:sub_agent_spawned", payload);
391
- expect(handler).toHaveBeenCalledOnce();
392
- const received = handler.mock.calls[0][0];
393
- expect(received.runId).toBe("run-legacy-001");
394
- expect(received.task).toBe("summarize conversation");
395
- });
396
- });
397
- // ---------------------------------------------------------------------------
398
- // Config nesting integration (Phase 398)
399
- // ---------------------------------------------------------------------------
400
- import { SecurityConfigSchema } from "../config/schema-security.js";
401
- describe("Config nesting integration", () => {
402
- it("SecurityConfigSchema includes subagentContext with defaults", () => {
403
- const config = SecurityConfigSchema.parse({});
404
- expect(config.agentToAgent.subagentContext.maxSpawnDepth).toBe(3);
405
- expect(config.agentToAgent.subagentContext.maxChildrenPerAgent).toBe(5);
406
- expect(config.agentToAgent.subagentContext.maxResultTokens).toBe(4_000);
407
- expect(config.agentToAgent.subagentContext.condensationStrategy).toBe("auto");
408
- expect(config.agentToAgent.subagentContext.objectiveReinforcement).toBe(true);
409
- expect(config.agentToAgent.subagentContext.resultRetentionMs).toBe(86_400_000);
410
- });
411
- it("existing agentToAgent fields preserved", () => {
412
- const config = SecurityConfigSchema.parse({});
413
- expect(config.agentToAgent.enabled).toBe(true);
414
- expect(config.agentToAgent.maxPingPongTurns).toBe(3);
415
- expect(config.agentToAgent.subAgentMaxSteps).toBe(50);
416
- expect(config.agentToAgent.subAgentMcpTools).toBe("inherit");
417
- });
418
- it("subagentContext overrides merge with defaults", () => {
419
- const config = SecurityConfigSchema.parse({
420
- agentToAgent: {
421
- subagentContext: {
422
- maxSpawnDepth: 5,
423
- condensationStrategy: "always",
424
- },
425
- },
426
- });
427
- expect(config.agentToAgent.subagentContext.maxSpawnDepth).toBe(5);
428
- expect(config.agentToAgent.subagentContext.condensationStrategy).toBe("always");
429
- // Other defaults still applied
430
- expect(config.agentToAgent.subagentContext.maxChildrenPerAgent).toBe(5);
431
- expect(config.agentToAgent.subagentContext.maxResultTokens).toBe(4_000);
432
- });
433
- });
@@ -1,93 +0,0 @@
1
- import { describe, it, expect, vi } from "vitest";
2
- import { TypedEventBus } from "./bus.js";
3
- describe("EventMap composition", () => {
4
- it("EventMap extends all 4 sub-interfaces", () => {
5
- // Runtime: verify representative keys exist
6
- const bus = new TypedEventBus();
7
- const keys = [
8
- "message:received",
9
- "skill:loaded",
10
- "channel:registered",
11
- "config:patched",
12
- "graph:started",
13
- ];
14
- expect(keys).toHaveLength(5);
15
- });
16
- it("round-trips one event from each domain group through TypedEventBus", () => {
17
- const bus = new TypedEventBus();
18
- // MessagingEvents: message:received
19
- const msgHandler = vi.fn();
20
- const sessionKey = { tenantId: "t1", userId: "u1", channelId: "c1" };
21
- const message = {
22
- id: "550e8400-e29b-41d4-a716-446655440000",
23
- channelId: "c1",
24
- channelType: "telegram",
25
- senderId: "u1",
26
- text: "hello",
27
- timestamp: Date.now(),
28
- attachments: [],
29
- metadata: {},
30
- };
31
- bus.on("message:received", msgHandler);
32
- bus.emit("message:received", { message, sessionKey });
33
- expect(msgHandler).toHaveBeenCalledOnce();
34
- expect(msgHandler.mock.calls[0][0].message.text).toBe("hello");
35
- expect(msgHandler.mock.calls[0][0].sessionKey.tenantId).toBe("t1");
36
- // AgentEvents: skill:loaded
37
- const skillHandler = vi.fn();
38
- const skillPayload = { skillName: "greet", source: "/skills/greet.md", timestamp: Date.now() };
39
- bus.on("skill:loaded", skillHandler);
40
- bus.emit("skill:loaded", skillPayload);
41
- expect(skillHandler).toHaveBeenCalledWith(skillPayload);
42
- // ChannelEvents: channel:registered
43
- const chanHandler = vi.fn();
44
- const chanPayload = {
45
- channelType: "discord",
46
- pluginId: "discord-01",
47
- capabilities: {
48
- chatTypes: ["dm", "group"],
49
- features: {
50
- reactions: true,
51
- editMessages: true,
52
- deleteMessages: true,
53
- fetchHistory: false,
54
- attachments: true,
55
- threads: false,
56
- mentions: true,
57
- formatting: ["markdown"],
58
- buttons: false,
59
- cards: false,
60
- effects: false,
61
- },
62
- limits: { maxMessageChars: 2000 },
63
- streaming: { supported: false, throttleMs: 300, method: "none" },
64
- threading: { supported: false, threadType: "none" },
65
- },
66
- timestamp: Date.now(),
67
- };
68
- bus.on("channel:registered", chanHandler);
69
- bus.emit("channel:registered", chanPayload);
70
- expect(chanHandler).toHaveBeenCalledWith(chanPayload);
71
- // InfraEvents: config:patched
72
- const cfgHandler = vi.fn();
73
- const cfgPayload = { section: "agent", key: "model", patchedBy: "admin", timestamp: Date.now() };
74
- bus.on("config:patched", cfgHandler);
75
- bus.emit("config:patched", cfgPayload);
76
- expect(cfgHandler).toHaveBeenCalledWith(cfgPayload);
77
- });
78
- it("keyof EventMap includes events from all 4 sub-interfaces", () => {
79
- // Type-level: satisfies checks that specific event names are valid EventMap keys
80
- const _msgKey = "message:received";
81
- const _agentKey = "tool:executed";
82
- const _chanKey = "queue:enqueued";
83
- const _infraKey = "system:shutdown";
84
- expect(true).toBe(true); // type-level test passes if it compiles
85
- });
86
- it("type safety: @ts-expect-error for nonexistent event names on EventMap-typed bus", () => {
87
- const bus = new TypedEventBus();
88
- // @ts-expect-error - nonexistent event name
89
- bus.on("does:not:exist", vi.fn());
90
- // @ts-expect-error - close but wrong event name
91
- bus.on("message:receivd", vi.fn());
92
- });
93
- });
@@ -1,29 +0,0 @@
1
- import { describe, it, expect, afterEach } from "vitest";
2
- import { setGlobalHookRunner, getGlobalHookRunner, clearGlobalHookRunner, } from "./hook-runner-global.js";
3
- describe("hook-runner-global", () => {
4
- afterEach(() => {
5
- clearGlobalHookRunner();
6
- });
7
- it("returns null before any runner is set", () => {
8
- expect(getGlobalHookRunner()).toBeNull();
9
- });
10
- it("returns the runner after setGlobalHookRunner", () => {
11
- const runner = {};
12
- setGlobalHookRunner(runner);
13
- expect(getGlobalHookRunner()).toBe(runner);
14
- });
15
- it("returns null after clearGlobalHookRunner", () => {
16
- const runner = {};
17
- setGlobalHookRunner(runner);
18
- clearGlobalHookRunner();
19
- expect(getGlobalHookRunner()).toBeNull();
20
- });
21
- it("replaces the previous runner when set again", () => {
22
- const first = {};
23
- const second = {};
24
- setGlobalHookRunner(first);
25
- setGlobalHookRunner(second);
26
- expect(getGlobalHookRunner()).toBe(second);
27
- expect(getGlobalHookRunner()).not.toBe(first);
28
- });
29
- });