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,495 +0,0 @@
1
- import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
- import { createMemoryApi } from "./memory-api.js";
3
- import { createSessionStore } from "./session-store.js";
4
- import { SqliteMemoryAdapter } from "./sqlite-memory-adapter.js";
5
- /** Default test config using in-memory SQLite. */
6
- const testConfig = {
7
- dbPath: ":memory:",
8
- walMode: false, // WAL not supported on :memory:
9
- embeddingModel: "test-model",
10
- embeddingDimensions: 4,
11
- compaction: { enabled: false, threshold: 1000, targetSize: 500 },
12
- retention: { maxAgeDays: 0, maxEntries: 0 },
13
- };
14
- /** Create a minimal valid MemoryEntry for testing. */
15
- function makeEntry(overrides) {
16
- return {
17
- id: overrides?.id ?? crypto.randomUUID(),
18
- tenantId: overrides?.tenantId ?? "default",
19
- agentId: overrides?.agentId ?? "default",
20
- userId: overrides?.userId ?? "user-1",
21
- content: overrides?.content ?? "test memory content",
22
- trustLevel: overrides?.trustLevel ?? "learned",
23
- source: overrides?.source ?? { who: "agent", channel: "telegram" },
24
- tags: overrides?.tags ?? [],
25
- createdAt: overrides?.createdAt ?? Date.now(),
26
- ...(overrides?.updatedAt !== undefined ? { updatedAt: overrides.updatedAt } : {}),
27
- ...(overrides?.expiresAt !== undefined ? { expiresAt: overrides.expiresAt } : {}),
28
- ...(overrides?.embedding ? { embedding: overrides.embedding } : {}),
29
- ...(overrides?.memoryType ? { memoryType: overrides.memoryType } : {}),
30
- };
31
- }
32
- describe("MemoryApi", () => {
33
- let adapter;
34
- let sessionStore;
35
- let api;
36
- beforeEach(async () => {
37
- adapter = new SqliteMemoryAdapter(testConfig);
38
- sessionStore = createSessionStore(adapter.getDb());
39
- api = createMemoryApi(adapter.getDb(), adapter, sessionStore, testConfig);
40
- // Seed varied memory entries
41
- const now = Date.now();
42
- const entries = [
43
- makeEntry({
44
- content: "system config alpha",
45
- trustLevel: "system",
46
- tags: ["config"],
47
- createdAt: now - 10000,
48
- memoryType: "semantic",
49
- }),
50
- makeEntry({
51
- content: "system config beta",
52
- trustLevel: "system",
53
- tags: ["config"],
54
- createdAt: now - 9000,
55
- memoryType: "semantic",
56
- }),
57
- makeEntry({
58
- content: "learned fact about cats",
59
- trustLevel: "learned",
60
- tags: ["animals", "facts"],
61
- createdAt: now - 8000,
62
- memoryType: "semantic",
63
- }),
64
- makeEntry({
65
- content: "learned fact about dogs",
66
- trustLevel: "learned",
67
- tags: ["animals", "facts"],
68
- createdAt: now - 7000,
69
- memoryType: "episodic",
70
- }),
71
- makeEntry({
72
- content: "external web data about weather",
73
- trustLevel: "external",
74
- tags: ["weather"],
75
- createdAt: now - 6000,
76
- memoryType: "semantic",
77
- }),
78
- makeEntry({
79
- content: "external api response data",
80
- trustLevel: "external",
81
- tags: ["api"],
82
- createdAt: now - 5000,
83
- memoryType: "working",
84
- }),
85
- makeEntry({
86
- content: "working memory scratch pad",
87
- trustLevel: "learned",
88
- tags: [],
89
- createdAt: now - 4000,
90
- memoryType: "working",
91
- }),
92
- makeEntry({
93
- content: "episodic conversation summary",
94
- trustLevel: "learned",
95
- tags: ["summary"],
96
- createdAt: now - 3000,
97
- memoryType: "episodic",
98
- }),
99
- makeEntry({
100
- content: "procedural skill steps for deployment",
101
- trustLevel: "system",
102
- tags: ["deployment", "procedure"],
103
- createdAt: now - 2000,
104
- memoryType: "procedural",
105
- }),
106
- makeEntry({
107
- content: "tenant b data point",
108
- trustLevel: "learned",
109
- tenantId: "tenant-b",
110
- tags: [],
111
- createdAt: now - 1000,
112
- memoryType: "semantic",
113
- }),
114
- ];
115
- for (const entry of entries) {
116
- const memoryType = entry.memoryType ?? "semantic";
117
- await adapter.storeWithType(entry, memoryType);
118
- }
119
- // Add a session for stats testing
120
- const sessionKey = { tenantId: "default", userId: "user-1", channelId: "test" };
121
- sessionStore.save(sessionKey, [{ role: "user", content: "hello" }]);
122
- });
123
- afterEach(() => {
124
- adapter.close();
125
- });
126
- // ── inspect ─────────────────────────────────────────────────────
127
- describe("inspect", () => {
128
- it("returns all entries with no filters", () => {
129
- const entries = api.inspect();
130
- expect(entries.length).toBe(10);
131
- });
132
- it("filters by memoryType", () => {
133
- const entries = api.inspect({ memoryType: "episodic" });
134
- expect(entries.length).toBe(2);
135
- for (const e of entries) {
136
- // Verify content matches episodic entries
137
- expect(["learned fact about dogs", "episodic conversation summary"]).toContain(e.content);
138
- }
139
- });
140
- it("filters by trustLevel", () => {
141
- const entries = api.inspect({ trustLevel: "system" });
142
- expect(entries.length).toBe(3);
143
- for (const e of entries) {
144
- expect(e.trustLevel).toBe("system");
145
- }
146
- });
147
- it("filters by tags", () => {
148
- const entries = api.inspect({ tags: ["animals"] });
149
- expect(entries.length).toBe(2);
150
- for (const e of entries) {
151
- expect(e.tags).toContain("animals");
152
- }
153
- });
154
- it("filters by multiple tags (AND logic)", () => {
155
- const entries = api.inspect({ tags: ["animals", "facts"] });
156
- expect(entries.length).toBe(2);
157
- });
158
- it("filters by createdAfter", () => {
159
- const now = Date.now();
160
- const entries = api.inspect({ createdAfter: now - 3500 });
161
- // Should get entries created after now - 3500:
162
- // episodic conversation summary (now-3000), procedural skill (now-2000), tenant-b (now-1000)
163
- expect(entries.length).toBe(3);
164
- });
165
- it("filters by createdBefore", () => {
166
- const now = Date.now();
167
- const entries = api.inspect({ createdBefore: now - 8500 });
168
- // Should get entries created before now - 8500:
169
- // system config alpha (now-10000), system config beta (now-9000)
170
- expect(entries.length).toBe(2);
171
- });
172
- it("filters by tenantId", () => {
173
- const entries = api.inspect({ tenantId: "tenant-b" });
174
- expect(entries.length).toBe(1);
175
- expect(entries[0].content).toBe("tenant b data point");
176
- });
177
- it("respects limit and offset", () => {
178
- const page1 = api.inspect({ limit: 3, offset: 0 });
179
- const page2 = api.inspect({ limit: 3, offset: 3 });
180
- expect(page1.length).toBe(3);
181
- expect(page2.length).toBe(3);
182
- // Pages should not overlap (ordered by created_at DESC)
183
- const ids1 = new Set(page1.map((e) => e.id));
184
- const ids2 = new Set(page2.map((e) => e.id));
185
- for (const id of ids2) {
186
- expect(ids1.has(id)).toBe(false);
187
- }
188
- });
189
- it("combines multiple filters", () => {
190
- const entries = api.inspect({ trustLevel: "learned", tags: ["animals"] });
191
- expect(entries.length).toBe(2);
192
- for (const e of entries) {
193
- expect(e.trustLevel).toBe("learned");
194
- expect(e.tags).toContain("animals");
195
- }
196
- });
197
- });
198
- // ── DATA-06: inspect expiry filtering ──────────────────────────
199
- describe("inspect expiry filtering", () => {
200
- it("excludes expired entries from inspect results", async () => {
201
- // Store an entry with past expiry directly via raw SQL
202
- const expiredId = crypto.randomUUID();
203
- adapter.getDb().prepare(`INSERT INTO memories (id, tenant_id, agent_id, user_id, content, trust_level, memory_type, source_who, tags, created_at, expires_at, has_embedding)
204
- VALUES (?, 'default', 'default', 'user-1', 'expired inspect content', 'learned', 'semantic', 'agent', '[]', ?, ?, 0)`).run(expiredId, Date.now() - 20000, Date.now() - 10000);
205
- const freshId = crypto.randomUUID();
206
- adapter.getDb().prepare(`INSERT INTO memories (id, tenant_id, agent_id, user_id, content, trust_level, memory_type, source_who, tags, created_at, expires_at, has_embedding)
207
- VALUES (?, 'default', 'default', 'user-1', 'fresh inspect content', 'learned', 'semantic', 'agent', '[]', ?, ?, 0)`).run(freshId, Date.now() - 20000, Date.now() + 60000);
208
- const entries = api.inspect({ tenantId: "default" });
209
- const ids = entries.map(e => e.id);
210
- expect(ids).not.toContain(expiredId);
211
- expect(ids).toContain(freshId);
212
- });
213
- it("includes entries with null expiresAt in inspect results", () => {
214
- // All seeded entries have null expiresAt - they should all appear
215
- const entries = api.inspect();
216
- expect(entries.length).toBe(10);
217
- });
218
- });
219
- // ── search ──────────────────────────────────────────────────────
220
- describe("search", () => {
221
- it("finds entries by text query", async () => {
222
- const results = await api.search("cats");
223
- expect(results.length).toBeGreaterThanOrEqual(1);
224
- expect(results[0].entry.content).toContain("cats");
225
- });
226
- it("respects limit option", async () => {
227
- // All entries contain "memory" or related terms
228
- const results = await api.search("data", { limit: 1 });
229
- expect(results.length).toBeLessThanOrEqual(1);
230
- });
231
- it("returns empty for no matches", async () => {
232
- const results = await api.search("xyznonexistent");
233
- expect(results).toHaveLength(0);
234
- });
235
- });
236
- // ── clear ───────────────────────────────────────────────────────
237
- describe("clear", () => {
238
- it("throws on empty scope (safety)", () => {
239
- expect(() => api.clear({})).toThrow("requires at least one scope field");
240
- });
241
- it("clears by memoryType", () => {
242
- const removed = api.clear({ memoryType: "working" });
243
- expect(removed).toBe(2); // external api response + working memory scratch pad
244
- const remaining = api.inspect();
245
- for (const e of remaining) {
246
- // Verify no working entries remain (check by content)
247
- expect(e.content).not.toContain("scratch pad");
248
- expect(e.content).not.toContain("api response");
249
- }
250
- });
251
- it("clears by trustLevel (only external allowed)", () => {
252
- const removed = api.clear({ trustLevel: "external" });
253
- expect(removed).toBe(2); // external web data + external api response
254
- const remaining = api.inspect();
255
- for (const e of remaining) {
256
- expect(e.trustLevel).not.toBe("external");
257
- }
258
- });
259
- it("clears by olderThan", () => {
260
- const now = Date.now();
261
- const removed = api.clear({ olderThan: now - 7500, tenantId: "default" });
262
- // Entries older than now - 7500:
263
- // system config alpha (now-10000), system config beta (now-9000), learned fact about cats (now-8000)
264
- // But system entries are protected! So only learned fact about cats is removed
265
- expect(removed).toBe(1);
266
- });
267
- it("protects system-trust entries from bulk clearing", () => {
268
- const removed = api.clear({ tenantId: "default" });
269
- // Should remove all non-system entries for default tenant (7 entries)
270
- // System entries (3) should be protected
271
- expect(removed).toBe(6); // 9 default tenant entries - 3 system = 6
272
- const remaining = api.inspect({ tenantId: "default" });
273
- expect(remaining.length).toBe(3);
274
- for (const e of remaining) {
275
- expect(e.trustLevel).toBe("system");
276
- }
277
- });
278
- it("clears by sessionKey (uses tenantId)", () => {
279
- const sessionKey = {
280
- tenantId: "tenant-b",
281
- userId: "user-1",
282
- channelId: "test",
283
- };
284
- const removed = api.clear({ sessionKey });
285
- expect(removed).toBe(1); // tenant-b data point (learned, not system)
286
- });
287
- it("returns 0 when no entries match scope", () => {
288
- const removed = api.clear({ tenantId: "nonexistent-tenant" });
289
- expect(removed).toBe(0);
290
- });
291
- });
292
- // ── stats ───────────────────────────────────────────────────────
293
- describe("stats", () => {
294
- it("returns accurate total entries count", () => {
295
- const s = api.stats();
296
- expect(s.totalEntries).toBe(10);
297
- });
298
- it("returns accurate counts by type", () => {
299
- const s = api.stats();
300
- expect(s.byType["semantic"]).toBe(5);
301
- expect(s.byType["episodic"]).toBe(2);
302
- expect(s.byType["working"]).toBe(2);
303
- expect(s.byType["procedural"]).toBe(1);
304
- });
305
- it("returns accurate counts by trust level", () => {
306
- const s = api.stats();
307
- expect(s.byTrustLevel["system"]).toBe(3);
308
- expect(s.byTrustLevel["learned"]).toBe(5);
309
- expect(s.byTrustLevel["external"]).toBe(2);
310
- });
311
- it("returns total sessions count", () => {
312
- const s = api.stats();
313
- expect(s.totalSessions).toBe(1);
314
- });
315
- it("returns embedded entries count", () => {
316
- const s = api.stats();
317
- // No embeddings stored in test seed
318
- expect(s.embeddedEntries).toBe(0);
319
- });
320
- it("returns database size in bytes", () => {
321
- const s = api.stats();
322
- expect(s.dbSizeBytes).toBeGreaterThan(0);
323
- });
324
- it("filters by tenantId when provided", () => {
325
- const s = api.stats("tenant-b");
326
- expect(s.totalEntries).toBe(1);
327
- expect(s.byTrustLevel["learned"]).toBe(1);
328
- });
329
- it("returns oldestCreatedAt as earliest entry timestamp", () => {
330
- const s = api.stats();
331
- // Oldest seeded entry has createdAt = now - 10000
332
- expect(s.oldestCreatedAt).toBeTypeOf("number");
333
- // Should be within 1000ms of (now - 10000)
334
- const expected = Date.now() - 10000;
335
- expect(Math.abs(s.oldestCreatedAt - expected)).toBeLessThan(1000);
336
- });
337
- it("returns null oldestCreatedAt for empty store", () => {
338
- const emptyAdapter = new SqliteMemoryAdapter(testConfig);
339
- const emptySessionStore = createSessionStore(emptyAdapter.getDb());
340
- const emptyApi = createMemoryApi(emptyAdapter.getDb(), emptyAdapter, emptySessionStore, testConfig);
341
- const s = emptyApi.stats();
342
- expect(s.oldestCreatedAt).toBeNull();
343
- emptyAdapter.close();
344
- });
345
- });
346
- // ── multi-agent memory isolation ─────────────────────────────
347
- describe("multi-agent memory isolation", () => {
348
- let multiApi;
349
- let multiAdapter;
350
- let multiSessionStore;
351
- beforeEach(async () => {
352
- multiAdapter = new SqliteMemoryAdapter(testConfig);
353
- multiSessionStore = createSessionStore(multiAdapter.getDb());
354
- multiApi = createMemoryApi(multiAdapter.getDb(), multiAdapter, multiSessionStore, testConfig);
355
- // Seed entries for two agents
356
- const now = Date.now();
357
- const entries = [
358
- makeEntry({
359
- agentId: "coder",
360
- content: "coder fact about TypeScript",
361
- trustLevel: "learned",
362
- createdAt: now - 3000,
363
- memoryType: "semantic",
364
- }),
365
- makeEntry({
366
- agentId: "coder",
367
- content: "coder fact about Rust",
368
- trustLevel: "system",
369
- createdAt: now - 2000,
370
- memoryType: "semantic",
371
- }),
372
- makeEntry({
373
- agentId: "dash",
374
- content: "dash fact about dashboards",
375
- trustLevel: "learned",
376
- createdAt: now - 1000,
377
- memoryType: "episodic",
378
- }),
379
- ];
380
- for (const entry of entries) {
381
- const memoryType = entry.memoryType ?? "semantic";
382
- await multiAdapter.storeWithType(entry, memoryType);
383
- }
384
- });
385
- afterEach(() => {
386
- multiAdapter.close();
387
- });
388
- it("inspect filters by agentId", () => {
389
- const coderEntries = multiApi.inspect({ agentId: "coder" });
390
- expect(coderEntries.length).toBe(2);
391
- for (const e of coderEntries) {
392
- expect(e.agentId).toBe("coder");
393
- }
394
- const dashEntries = multiApi.inspect({ agentId: "dash" });
395
- expect(dashEntries.length).toBe(1);
396
- expect(dashEntries[0].agentId).toBe("dash");
397
- });
398
- it("stats scoped to agentId", () => {
399
- const coderStats = multiApi.stats(undefined, "coder");
400
- expect(coderStats.totalEntries).toBe(2);
401
- expect(coderStats.byTrustLevel["learned"]).toBe(1);
402
- expect(coderStats.byTrustLevel["system"]).toBe(1);
403
- const dashStats = multiApi.stats(undefined, "dash");
404
- expect(dashStats.totalEntries).toBe(1);
405
- expect(dashStats.byType["episodic"]).toBe(1);
406
- });
407
- it("stats returns byAgent breakdown", () => {
408
- const allStats = multiApi.stats();
409
- expect(allStats.byAgent["coder"]).toBe(2);
410
- expect(allStats.byAgent["dash"]).toBe(1);
411
- });
412
- it("returns agent-scoped oldestCreatedAt", () => {
413
- const coderStats = multiApi.stats(undefined, "coder");
414
- // Oldest coder entry has createdAt = now - 3000
415
- expect(coderStats.oldestCreatedAt).toBeTypeOf("number");
416
- const expected = Date.now() - 3000;
417
- expect(Math.abs(coderStats.oldestCreatedAt - expected)).toBeLessThan(1000);
418
- });
419
- it("clear scoped to agentId", () => {
420
- // Clear only coder's memories
421
- const removed = multiApi.clear({ agentId: "coder" });
422
- // Only learned entries removed (system protected by default)
423
- expect(removed).toBe(1);
424
- const remaining = multiApi.inspect();
425
- // coder system entry + dash entry remain
426
- expect(remaining.length).toBe(2);
427
- });
428
- });
429
- // ── enforceGuardrails ─────────────────────────────────────────
430
- describe("enforceGuardrails", () => {
431
- it("returns null when no limits configured", () => {
432
- const result = api.enforceGuardrails();
433
- expect(result).toBeNull();
434
- });
435
- it("returns null when within limits", () => {
436
- // Create api with maxEntries = 20 (we have 10)
437
- const limitedConfig = {
438
- ...testConfig,
439
- retention: { maxAgeDays: 0, maxEntries: 20 },
440
- };
441
- const limitedApi = createMemoryApi(adapter.getDb(), adapter, sessionStore, limitedConfig);
442
- const result = limitedApi.enforceGuardrails();
443
- expect(result).toBeNull();
444
- });
445
- it("removes oldest non-system entries when limit exceeded", () => {
446
- // maxEntries = 7, we have 10 entries, so need to remove 3
447
- const limitedConfig = {
448
- ...testConfig,
449
- retention: { maxAgeDays: 0, maxEntries: 7 },
450
- };
451
- const limitedApi = createMemoryApi(adapter.getDb(), adapter, sessionStore, limitedConfig);
452
- const result = limitedApi.enforceGuardrails();
453
- expect(result).not.toBeNull();
454
- expect(result.entriesRemoved).toBe(3);
455
- expect(result.reason).toContain("exceeded maxEntries");
456
- // Verify system entries are preserved
457
- const remaining = api.inspect({ trustLevel: "system" });
458
- expect(remaining.length).toBe(3);
459
- });
460
- it("preserves system entries even when they are the oldest", () => {
461
- // Create a scenario where system entries are older than non-system
462
- // Our seed data has system entries at now-10000, now-9000, now-2000
463
- // The oldest non-system entry is at now-8000
464
- // Set maxEntries to 5 (need to remove 5 out of 10)
465
- const limitedConfig = {
466
- ...testConfig,
467
- retention: { maxAgeDays: 0, maxEntries: 5 },
468
- };
469
- const limitedApi = createMemoryApi(adapter.getDb(), adapter, sessionStore, limitedConfig);
470
- const result = limitedApi.enforceGuardrails();
471
- expect(result).not.toBeNull();
472
- expect(result.entriesRemoved).toBe(5);
473
- // All 3 system entries should still be there
474
- const systemEntries = api.inspect({ trustLevel: "system" });
475
- expect(systemEntries.length).toBe(3);
476
- // Total should be 5
477
- const total = api.inspect();
478
- expect(total.length).toBe(5);
479
- });
480
- it("scopes enforcement to specific tenant", () => {
481
- // Set maxEntries to 5. Default tenant has 9 entries.
482
- const limitedConfig = {
483
- ...testConfig,
484
- retention: { maxAgeDays: 0, maxEntries: 5 },
485
- };
486
- const limitedApi = createMemoryApi(adapter.getDb(), adapter, sessionStore, limitedConfig);
487
- const result = limitedApi.enforceGuardrails("default");
488
- expect(result).not.toBeNull();
489
- expect(result.entriesRemoved).toBe(4); // 9 - 5 = 4 non-system removed
490
- // tenant-b should be untouched
491
- const tenantB = api.inspect({ tenantId: "tenant-b" });
492
- expect(tenantB.length).toBe(1);
493
- });
494
- });
495
- });
@@ -1,20 +0,0 @@
1
- /**
2
- * AGT-06 / AGT-07: SQLite WAL memory concurrency tests.
3
- *
4
- * Validates that concurrent memory operations under SQLite WAL mode
5
- * with multiple SqliteMemoryAdapter connections produce no errors.
6
- *
7
- * CRITICAL: Uses file-based SQLite (NOT :memory:). :memory: databases
8
- * cannot be shared across connections. WAL concurrency testing requires
9
- * file-based DB with multiple SqliteMemoryAdapter instances.
10
- *
11
- * NOTE on better-sqlite3 synchronous behavior:
12
- * better-sqlite3 is synchronous -- all SQL operations execute on the main
13
- * thread and are naturally serialized by the Node.js event loop within a
14
- * single connection. Promise.all with sync operations may not actually
15
- * overlap within a single tick. However, these tests validate the contract:
16
- * concurrent calls from multiple adapter instances do not produce unhandled
17
- * errors under WAL mode. If SQLITE_BUSY errors appear, adding
18
- * `busy_timeout = 5000` pragma to SqliteMemoryAdapter would resolve them.
19
- */
20
- export {};