@jungjaehoon/mama-os 0.28.6 → 0.29.1

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 (452) hide show
  1. package/dist/agent/agent-loop.d.ts +0 -4
  2. package/dist/agent/agent-loop.d.ts.map +1 -1
  3. package/dist/agent/agent-loop.js +33 -10
  4. package/dist/agent/agent-loop.js.map +1 -1
  5. package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
  6. package/dist/agent/code-act/host-bridge.js +53 -3
  7. package/dist/agent/code-act/host-bridge.js.map +1 -1
  8. package/dist/agent/code-act/tool-policy.d.ts.map +1 -1
  9. package/dist/agent/code-act/tool-policy.js +5 -0
  10. package/dist/agent/code-act/tool-policy.js.map +1 -1
  11. package/dist/agent/codex-auth.d.ts +0 -1
  12. package/dist/agent/codex-auth.d.ts.map +1 -1
  13. package/dist/agent/codex-auth.js +0 -4
  14. package/dist/agent/codex-auth.js.map +1 -1
  15. package/dist/agent/codex-home.d.ts +0 -2
  16. package/dist/agent/codex-home.d.ts.map +1 -1
  17. package/dist/agent/codex-home.js +0 -66
  18. package/dist/agent/codex-home.js.map +1 -1
  19. package/dist/agent/context-compile-service.d.ts +9 -0
  20. package/dist/agent/context-compile-service.d.ts.map +1 -1
  21. package/dist/agent/context-compile-service.js +6 -0
  22. package/dist/agent/context-compile-service.js.map +1 -1
  23. package/dist/agent/context-prompt-builder.d.ts +0 -6
  24. package/dist/agent/context-prompt-builder.d.ts.map +1 -1
  25. package/dist/agent/context-prompt-builder.js +0 -131
  26. package/dist/agent/context-prompt-builder.js.map +1 -1
  27. package/dist/agent/contract-extractor.d.ts +0 -4
  28. package/dist/agent/contract-extractor.d.ts.map +1 -1
  29. package/dist/agent/contract-extractor.js +0 -68
  30. package/dist/agent/contract-extractor.js.map +1 -1
  31. package/dist/agent/gateway-tool-executor.d.ts +20 -15
  32. package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
  33. package/dist/agent/gateway-tool-executor.js +236 -90
  34. package/dist/agent/gateway-tool-executor.js.map +1 -1
  35. package/dist/agent/gateway-tools.md +7 -4
  36. package/dist/agent/skill-loader.d.ts +0 -7
  37. package/dist/agent/skill-loader.d.ts.map +1 -1
  38. package/dist/agent/skill-loader.js +0 -86
  39. package/dist/agent/skill-loader.js.map +1 -1
  40. package/dist/agent/token-estimator.d.ts +0 -8
  41. package/dist/agent/token-estimator.d.ts.map +1 -1
  42. package/dist/agent/token-estimator.js +0 -14
  43. package/dist/agent/token-estimator.js.map +1 -1
  44. package/dist/agent/tool-registry.d.ts.map +1 -1
  45. package/dist/agent/tool-registry.js +23 -5
  46. package/dist/agent/tool-registry.js.map +1 -1
  47. package/dist/agent/types.d.ts +27 -1
  48. package/dist/agent/types.d.ts.map +1 -1
  49. package/dist/agent/types.js.map +1 -1
  50. package/dist/api/agent-graph-handler.d.ts +9 -0
  51. package/dist/api/agent-graph-handler.d.ts.map +1 -1
  52. package/dist/api/agent-graph-handler.js +27 -1
  53. package/dist/api/agent-graph-handler.js.map +1 -1
  54. package/dist/api/entity-audit-handler.d.ts +1 -2
  55. package/dist/api/entity-audit-handler.d.ts.map +1 -1
  56. package/dist/api/entity-audit-handler.js +0 -5
  57. package/dist/api/entity-audit-handler.js.map +1 -1
  58. package/dist/api/index.d.ts +1 -9
  59. package/dist/api/index.d.ts.map +1 -1
  60. package/dist/api/index.js +4 -17
  61. package/dist/api/index.js.map +1 -1
  62. package/dist/api/intelligence-handler.d.ts +0 -5
  63. package/dist/api/intelligence-handler.d.ts.map +1 -1
  64. package/dist/api/intelligence-handler.js +0 -15
  65. package/dist/api/intelligence-handler.js.map +1 -1
  66. package/dist/api/types.d.ts +1 -5
  67. package/dist/api/types.d.ts.map +1 -1
  68. package/dist/api/types.js +0 -14
  69. package/dist/api/types.js.map +1 -1
  70. package/dist/cli/commands/start.d.ts +117 -3
  71. package/dist/cli/commands/start.d.ts.map +1 -1
  72. package/dist/cli/commands/start.js +223 -62
  73. package/dist/cli/commands/start.js.map +1 -1
  74. package/dist/cli/config/config-manager.d.ts +0 -5
  75. package/dist/cli/config/config-manager.d.ts.map +1 -1
  76. package/dist/cli/config/config-manager.js +0 -29
  77. package/dist/cli/config/config-manager.js.map +1 -1
  78. package/dist/cli/config/types.d.ts.map +1 -1
  79. package/dist/cli/config/types.js +3 -0
  80. package/dist/cli/config/types.js.map +1 -1
  81. package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
  82. package/dist/cli/runtime/api-routes-init.js +32 -5
  83. package/dist/cli/runtime/api-routes-init.js.map +1 -1
  84. package/dist/cli/runtime/api-server-init.d.ts.map +1 -1
  85. package/dist/cli/runtime/api-server-init.js +2 -0
  86. package/dist/cli/runtime/api-server-init.js.map +1 -1
  87. package/dist/cli/runtime/gateway-init.d.ts +1 -1
  88. package/dist/cli/runtime/gateway-init.d.ts.map +1 -1
  89. package/dist/cli/runtime/gateway-init.js +11 -38
  90. package/dist/cli/runtime/gateway-init.js.map +1 -1
  91. package/dist/cli/runtime/gateway-wiring.d.ts.map +1 -1
  92. package/dist/cli/runtime/gateway-wiring.js +6 -120
  93. package/dist/cli/runtime/gateway-wiring.js.map +1 -1
  94. package/dist/cli/utils/pid-manager.d.ts +0 -10
  95. package/dist/cli/utils/pid-manager.d.ts.map +1 -1
  96. package/dist/cli/utils/pid-manager.js +0 -26
  97. package/dist/cli/utils/pid-manager.js.map +1 -1
  98. package/dist/connectors/framework/polling-scheduler.d.ts +33 -1
  99. package/dist/connectors/framework/polling-scheduler.d.ts.map +1 -1
  100. package/dist/connectors/framework/polling-scheduler.js +46 -40
  101. package/dist/connectors/framework/polling-scheduler.js.map +1 -1
  102. package/dist/connectors/trello/query-tools.d.ts +32 -5
  103. package/dist/connectors/trello/query-tools.d.ts.map +1 -1
  104. package/dist/connectors/trello/query-tools.js +56 -17
  105. package/dist/connectors/trello/query-tools.js.map +1 -1
  106. package/dist/db/agent-store.d.ts +0 -4
  107. package/dist/db/agent-store.d.ts.map +1 -1
  108. package/dist/db/agent-store.js +0 -65
  109. package/dist/db/agent-store.js.map +1 -1
  110. package/dist/envelope/enforcer.d.ts.map +1 -1
  111. package/dist/envelope/enforcer.js +10 -1
  112. package/dist/envelope/enforcer.js.map +1 -1
  113. package/dist/envelope/index.d.ts +0 -1
  114. package/dist/envelope/index.d.ts.map +1 -1
  115. package/dist/envelope/index.js +0 -1
  116. package/dist/envelope/index.js.map +1 -1
  117. package/dist/envelope/signature.d.ts +0 -1
  118. package/dist/envelope/signature.d.ts.map +1 -1
  119. package/dist/envelope/signature.js +0 -7
  120. package/dist/envelope/signature.js.map +1 -1
  121. package/dist/envelope/tool-connector-scope.d.ts +35 -0
  122. package/dist/envelope/tool-connector-scope.d.ts.map +1 -0
  123. package/dist/envelope/tool-connector-scope.js +57 -0
  124. package/dist/envelope/tool-connector-scope.js.map +1 -0
  125. package/dist/evidence/effects.d.ts +107 -0
  126. package/dist/evidence/effects.d.ts.map +1 -0
  127. package/dist/evidence/effects.js +281 -0
  128. package/dist/evidence/effects.js.map +1 -0
  129. package/dist/evidence/read.d.ts +75 -0
  130. package/dist/evidence/read.d.ts.map +1 -0
  131. package/dist/evidence/read.js +105 -0
  132. package/dist/evidence/read.js.map +1 -0
  133. package/dist/gateways/base-gateway.d.ts +23 -3
  134. package/dist/gateways/base-gateway.d.ts.map +1 -1
  135. package/dist/gateways/base-gateway.js +15 -2
  136. package/dist/gateways/base-gateway.js.map +1 -1
  137. package/dist/gateways/discord.d.ts +4 -16
  138. package/dist/gateways/discord.d.ts.map +1 -1
  139. package/dist/gateways/discord.js +22 -189
  140. package/dist/gateways/discord.js.map +1 -1
  141. package/dist/gateways/index.d.ts +2 -1
  142. package/dist/gateways/index.d.ts.map +1 -1
  143. package/dist/gateways/message-router.d.ts +13 -20
  144. package/dist/gateways/message-router.d.ts.map +1 -1
  145. package/dist/gateways/message-router.js +32 -3
  146. package/dist/gateways/message-router.js.map +1 -1
  147. package/dist/gateways/slack.d.ts +2 -12
  148. package/dist/gateways/slack.d.ts.map +1 -1
  149. package/dist/gateways/slack.js +6 -220
  150. package/dist/gateways/slack.js.map +1 -1
  151. package/dist/gateways/telegram.d.ts +2 -2
  152. package/dist/gateways/telegram.d.ts.map +1 -1
  153. package/dist/gateways/telegram.js +3 -2
  154. package/dist/gateways/telegram.js.map +1 -1
  155. package/dist/gateways/turn-contract.d.ts +104 -0
  156. package/dist/gateways/turn-contract.d.ts.map +1 -0
  157. package/dist/{memory/consult-contract.js → gateways/turn-contract.js} +1 -1
  158. package/dist/gateways/turn-contract.js.map +1 -0
  159. package/dist/memory/provenance-live.d.ts +111 -0
  160. package/dist/memory/provenance-live.d.ts.map +1 -0
  161. package/dist/memory/provenance-live.js +381 -0
  162. package/dist/memory/provenance-live.js.map +1 -0
  163. package/dist/memory/provenance-resolver.d.ts +184 -0
  164. package/dist/memory/provenance-resolver.d.ts.map +1 -0
  165. package/dist/memory/provenance-resolver.js +152 -0
  166. package/dist/memory/provenance-resolver.js.map +1 -0
  167. package/dist/multi-agent/agent-event-bus.d.ts +1 -0
  168. package/dist/multi-agent/agent-event-bus.d.ts.map +1 -1
  169. package/dist/multi-agent/bmad-templates.d.ts +0 -18
  170. package/dist/multi-agent/bmad-templates.d.ts.map +1 -1
  171. package/dist/multi-agent/bmad-templates.js +0 -127
  172. package/dist/multi-agent/bmad-templates.js.map +1 -1
  173. package/dist/multi-agent/dashboard-agent-persona.js +3 -3
  174. package/dist/operator/board-reconcile.d.ts +2 -3
  175. package/dist/operator/board-reconcile.d.ts.map +1 -1
  176. package/dist/operator/board-reconcile.js +18 -32
  177. package/dist/operator/board-reconcile.js.map +1 -1
  178. package/dist/operator/changes-projection.d.ts +70 -0
  179. package/dist/operator/changes-projection.d.ts.map +1 -0
  180. package/dist/operator/changes-projection.js +109 -0
  181. package/dist/operator/changes-projection.js.map +1 -0
  182. package/dist/operator/external-correlation.d.ts +94 -0
  183. package/dist/operator/external-correlation.d.ts.map +1 -0
  184. package/dist/operator/external-correlation.js +177 -0
  185. package/dist/operator/external-correlation.js.map +1 -0
  186. package/dist/operator/operator-trigger-loop.d.ts +9 -1
  187. package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
  188. package/dist/operator/operator-trigger-loop.js +8 -4
  189. package/dist/operator/operator-trigger-loop.js.map +1 -1
  190. package/dist/operator/provenance-lookup.d.ts +18 -0
  191. package/dist/operator/provenance-lookup.d.ts.map +1 -0
  192. package/dist/operator/provenance-lookup.js +54 -0
  193. package/dist/operator/provenance-lookup.js.map +1 -0
  194. package/dist/operator/report-carry.d.ts +18 -1
  195. package/dist/operator/report-carry.d.ts.map +1 -1
  196. package/dist/operator/report-carry.js +22 -3
  197. package/dist/operator/report-carry.js.map +1 -1
  198. package/dist/operator/report-run.d.ts +31 -0
  199. package/dist/operator/report-run.d.ts.map +1 -1
  200. package/dist/operator/report-run.js +140 -22
  201. package/dist/operator/report-run.js.map +1 -1
  202. package/dist/operator/task-ledger.d.ts +84 -2
  203. package/dist/operator/task-ledger.d.ts.map +1 -1
  204. package/dist/operator/task-ledger.js +274 -31
  205. package/dist/operator/task-ledger.js.map +1 -1
  206. package/dist/operator/trigger-author.d.ts +7 -0
  207. package/dist/operator/trigger-author.d.ts.map +1 -1
  208. package/dist/operator/trigger-author.js +78 -7
  209. package/dist/operator/trigger-author.js.map +1 -1
  210. package/dist/operator/worker-run.js +1 -1
  211. package/dist/operator/worker-run.js.map +1 -1
  212. package/dist/operator/workorder-hooks.d.ts +79 -4
  213. package/dist/operator/workorder-hooks.d.ts.map +1 -1
  214. package/dist/operator/workorder-hooks.js +152 -20
  215. package/dist/operator/workorder-hooks.js.map +1 -1
  216. package/dist/operator/workorder-publishers.d.ts +2 -0
  217. package/dist/operator/workorder-publishers.d.ts.map +1 -1
  218. package/dist/operator/workorder-publishers.js +8 -1
  219. package/dist/operator/workorder-publishers.js.map +1 -1
  220. package/dist/utils/untrusted-content.d.ts +11 -0
  221. package/dist/utils/untrusted-content.d.ts.map +1 -1
  222. package/dist/utils/untrusted-content.js +20 -0
  223. package/dist/utils/untrusted-content.js.map +1 -1
  224. package/package.json +4 -3
  225. package/scripts/backfill-channel-keys.ts +451 -0
  226. package/dist/agent/auto-recall.d.ts +0 -48
  227. package/dist/agent/auto-recall.d.ts.map +0 -1
  228. package/dist/agent/auto-recall.js +0 -192
  229. package/dist/agent/auto-recall.js.map +0 -1
  230. package/dist/agent/claude-client.d.ts +0 -50
  231. package/dist/agent/claude-client.d.ts.map +0 -1
  232. package/dist/agent/claude-client.js +0 -219
  233. package/dist/agent/claude-client.js.map +0 -1
  234. package/dist/agent/delegation-executor.d.ts +0 -49
  235. package/dist/agent/delegation-executor.d.ts.map +0 -1
  236. package/dist/agent/delegation-executor.js +0 -692
  237. package/dist/agent/delegation-executor.js.map +0 -1
  238. package/dist/agent/mcp-executor.d.ts +0 -60
  239. package/dist/agent/mcp-executor.d.ts.map +0 -1
  240. package/dist/agent/mcp-executor.js +0 -190
  241. package/dist/agent/mcp-executor.js.map +0 -1
  242. package/dist/agent/process-tree.d.ts +0 -6
  243. package/dist/agent/process-tree.d.ts.map +0 -1
  244. package/dist/agent/process-tree.js +0 -21
  245. package/dist/agent/process-tree.js.map +0 -1
  246. package/dist/agent/streaming-callback-manager.d.ts +0 -85
  247. package/dist/agent/streaming-callback-manager.d.ts.map +0 -1
  248. package/dist/agent/streaming-callback-manager.js +0 -103
  249. package/dist/agent/streaming-callback-manager.js.map +0 -1
  250. package/dist/agent/token-budget.d.ts +0 -49
  251. package/dist/agent/token-budget.d.ts.map +0 -1
  252. package/dist/agent/token-budget.js +0 -92
  253. package/dist/agent/token-budget.js.map +0 -1
  254. package/dist/connectors/kagemusha/history-compiler.d.ts +0 -18
  255. package/dist/connectors/kagemusha/history-compiler.d.ts.map +0 -1
  256. package/dist/connectors/kagemusha/history-compiler.js +0 -35
  257. package/dist/connectors/kagemusha/history-compiler.js.map +0 -1
  258. package/dist/db/migrations/wiki-artifacts.d.ts +0 -3
  259. package/dist/db/migrations/wiki-artifacts.d.ts.map +0 -1
  260. package/dist/db/migrations/wiki-artifacts.js +0 -24
  261. package/dist/db/migrations/wiki-artifacts.js.map +0 -1
  262. package/dist/envelope/subset.d.ts +0 -9
  263. package/dist/envelope/subset.d.ts.map +0 -1
  264. package/dist/envelope/subset.js +0 -67
  265. package/dist/envelope/subset.js.map +0 -1
  266. package/dist/memory/consult-contract.d.ts +0 -8
  267. package/dist/memory/consult-contract.d.ts.map +0 -1
  268. package/dist/memory/consult-contract.js.map +0 -1
  269. package/dist/multi-agent/agent-message-queue.d.ts +0 -104
  270. package/dist/multi-agent/agent-message-queue.d.ts.map +0 -1
  271. package/dist/multi-agent/agent-message-queue.js +0 -227
  272. package/dist/multi-agent/agent-message-queue.js.map +0 -1
  273. package/dist/multi-agent/background-task-manager.d.ts +0 -248
  274. package/dist/multi-agent/background-task-manager.d.ts.map +0 -1
  275. package/dist/multi-agent/background-task-manager.js +0 -415
  276. package/dist/multi-agent/background-task-manager.js.map +0 -1
  277. package/dist/multi-agent/category-router.d.ts +0 -56
  278. package/dist/multi-agent/category-router.d.ts.map +0 -1
  279. package/dist/multi-agent/category-router.js +0 -99
  280. package/dist/multi-agent/category-router.js.map +0 -1
  281. package/dist/multi-agent/council-engine.d.ts +0 -60
  282. package/dist/multi-agent/council-engine.d.ts.map +0 -1
  283. package/dist/multi-agent/council-engine.js +0 -284
  284. package/dist/multi-agent/council-engine.js.map +0 -1
  285. package/dist/multi-agent/delegation-format-validator.d.ts +0 -22
  286. package/dist/multi-agent/delegation-format-validator.d.ts.map +0 -1
  287. package/dist/multi-agent/delegation-format-validator.js +0 -31
  288. package/dist/multi-agent/delegation-format-validator.js.map +0 -1
  289. package/dist/multi-agent/delegation-manager.d.ts +0 -128
  290. package/dist/multi-agent/delegation-manager.d.ts.map +0 -1
  291. package/dist/multi-agent/delegation-manager.js +0 -276
  292. package/dist/multi-agent/delegation-manager.js.map +0 -1
  293. package/dist/multi-agent/i18n-messages.d.ts +0 -35
  294. package/dist/multi-agent/i18n-messages.d.ts.map +0 -1
  295. package/dist/multi-agent/i18n-messages.js +0 -54
  296. package/dist/multi-agent/i18n-messages.js.map +0 -1
  297. package/dist/multi-agent/index.d.ts +0 -31
  298. package/dist/multi-agent/index.d.ts.map +0 -1
  299. package/dist/multi-agent/index.js +0 -46
  300. package/dist/multi-agent/index.js.map +0 -1
  301. package/dist/multi-agent/multi-agent-base.d.ts +0 -223
  302. package/dist/multi-agent/multi-agent-base.d.ts.map +0 -1
  303. package/dist/multi-agent/multi-agent-base.js +0 -592
  304. package/dist/multi-agent/multi-agent-base.js.map +0 -1
  305. package/dist/multi-agent/multi-agent-discord.d.ts +0 -142
  306. package/dist/multi-agent/multi-agent-discord.d.ts.map +0 -1
  307. package/dist/multi-agent/multi-agent-discord.js +0 -1235
  308. package/dist/multi-agent/multi-agent-discord.js.map +0 -1
  309. package/dist/multi-agent/multi-agent-slack.d.ts +0 -146
  310. package/dist/multi-agent/multi-agent-slack.d.ts.map +0 -1
  311. package/dist/multi-agent/multi-agent-slack.js +0 -953
  312. package/dist/multi-agent/multi-agent-slack.js.map +0 -1
  313. package/dist/multi-agent/multi-bot-manager.d.ts +0 -119
  314. package/dist/multi-agent/multi-bot-manager.d.ts.map +0 -1
  315. package/dist/multi-agent/multi-bot-manager.js +0 -449
  316. package/dist/multi-agent/multi-bot-manager.js.map +0 -1
  317. package/dist/multi-agent/orchestrator.d.ts +0 -110
  318. package/dist/multi-agent/orchestrator.d.ts.map +0 -1
  319. package/dist/multi-agent/orchestrator.js +0 -436
  320. package/dist/multi-agent/orchestrator.js.map +0 -1
  321. package/dist/multi-agent/rate-limiter.d.ts +0 -76
  322. package/dist/multi-agent/rate-limiter.d.ts.map +0 -1
  323. package/dist/multi-agent/rate-limiter.js +0 -128
  324. package/dist/multi-agent/rate-limiter.js.map +0 -1
  325. package/dist/multi-agent/shared-context.d.ts +0 -127
  326. package/dist/multi-agent/shared-context.d.ts.map +0 -1
  327. package/dist/multi-agent/shared-context.js +0 -239
  328. package/dist/multi-agent/shared-context.js.map +0 -1
  329. package/dist/multi-agent/slack-config-validator.d.ts +0 -42
  330. package/dist/multi-agent/slack-config-validator.d.ts.map +0 -1
  331. package/dist/multi-agent/slack-config-validator.js +0 -194
  332. package/dist/multi-agent/slack-config-validator.js.map +0 -1
  333. package/dist/multi-agent/slack-multi-bot-manager.d.ts +0 -143
  334. package/dist/multi-agent/slack-multi-bot-manager.d.ts.map +0 -1
  335. package/dist/multi-agent/slack-multi-bot-manager.js +0 -413
  336. package/dist/multi-agent/slack-multi-bot-manager.js.map +0 -1
  337. package/dist/multi-agent/swarm/swarm-anti-pattern-detector.d.ts +0 -98
  338. package/dist/multi-agent/swarm/swarm-anti-pattern-detector.d.ts.map +0 -1
  339. package/dist/multi-agent/swarm/swarm-anti-pattern-detector.js +0 -225
  340. package/dist/multi-agent/swarm/swarm-anti-pattern-detector.js.map +0 -1
  341. package/dist/multi-agent/swarm/swarm-db.d.ts +0 -175
  342. package/dist/multi-agent/swarm/swarm-db.d.ts.map +0 -1
  343. package/dist/multi-agent/swarm/swarm-db.js +0 -313
  344. package/dist/multi-agent/swarm/swarm-db.js.map +0 -1
  345. package/dist/multi-agent/swarm/swarm-event-reporter.d.ts +0 -116
  346. package/dist/multi-agent/swarm/swarm-event-reporter.d.ts.map +0 -1
  347. package/dist/multi-agent/swarm/swarm-event-reporter.js +0 -243
  348. package/dist/multi-agent/swarm/swarm-event-reporter.js.map +0 -1
  349. package/dist/multi-agent/swarm/swarm-mama-adapter.d.ts +0 -57
  350. package/dist/multi-agent/swarm/swarm-mama-adapter.d.ts.map +0 -1
  351. package/dist/multi-agent/swarm/swarm-mama-adapter.js +0 -87
  352. package/dist/multi-agent/swarm/swarm-mama-adapter.js.map +0 -1
  353. package/dist/multi-agent/swarm/swarm-manager.d.ts +0 -122
  354. package/dist/multi-agent/swarm/swarm-manager.d.ts.map +0 -1
  355. package/dist/multi-agent/swarm/swarm-manager.js +0 -199
  356. package/dist/multi-agent/swarm/swarm-manager.js.map +0 -1
  357. package/dist/multi-agent/swarm/swarm-task-learner.d.ts +0 -104
  358. package/dist/multi-agent/swarm/swarm-task-learner.d.ts.map +0 -1
  359. package/dist/multi-agent/swarm/swarm-task-learner.js +0 -211
  360. package/dist/multi-agent/swarm/swarm-task-learner.js.map +0 -1
  361. package/dist/multi-agent/swarm/swarm-task-runner.d.ts +0 -155
  362. package/dist/multi-agent/swarm/swarm-task-runner.d.ts.map +0 -1
  363. package/dist/multi-agent/swarm/swarm-task-runner.js +0 -615
  364. package/dist/multi-agent/swarm/swarm-task-runner.js.map +0 -1
  365. package/dist/multi-agent/swarm/wave-engine.d.ts +0 -96
  366. package/dist/multi-agent/swarm/wave-engine.d.ts.map +0 -1
  367. package/dist/multi-agent/swarm/wave-engine.js +0 -123
  368. package/dist/multi-agent/swarm/wave-engine.js.map +0 -1
  369. package/dist/multi-agent/system-reminder.d.ts +0 -206
  370. package/dist/multi-agent/system-reminder.d.ts.map +0 -1
  371. package/dist/multi-agent/system-reminder.js +0 -455
  372. package/dist/multi-agent/system-reminder.js.map +0 -1
  373. package/dist/multi-agent/task-continuation.d.ts +0 -74
  374. package/dist/multi-agent/task-continuation.d.ts.map +0 -1
  375. package/dist/multi-agent/task-continuation.js +0 -172
  376. package/dist/multi-agent/task-continuation.js.map +0 -1
  377. package/dist/multi-agent/ultrawork-state.d.ts +0 -57
  378. package/dist/multi-agent/ultrawork-state.d.ts.map +0 -1
  379. package/dist/multi-agent/ultrawork-state.js +0 -191
  380. package/dist/multi-agent/ultrawork-state.js.map +0 -1
  381. package/dist/multi-agent/ultrawork.d.ts +0 -152
  382. package/dist/multi-agent/ultrawork.d.ts.map +0 -1
  383. package/dist/multi-agent/ultrawork.js +0 -879
  384. package/dist/multi-agent/ultrawork.js.map +0 -1
  385. package/dist/multi-agent/work-tracker.d.ts +0 -22
  386. package/dist/multi-agent/work-tracker.d.ts.map +0 -1
  387. package/dist/multi-agent/work-tracker.js +0 -45
  388. package/dist/multi-agent/work-tracker.js.map +0 -1
  389. package/dist/multi-agent/workflow-engine.d.ts +0 -87
  390. package/dist/multi-agent/workflow-engine.d.ts.map +0 -1
  391. package/dist/multi-agent/workflow-engine.js +0 -604
  392. package/dist/multi-agent/workflow-engine.js.map +0 -1
  393. package/dist/onboarding/all-tools.d.ts +0 -18
  394. package/dist/onboarding/all-tools.d.ts.map +0 -1
  395. package/dist/onboarding/all-tools.js +0 -149
  396. package/dist/onboarding/all-tools.js.map +0 -1
  397. package/dist/onboarding/autonomous-discovery-tools.d.ts +0 -23
  398. package/dist/onboarding/autonomous-discovery-tools.d.ts.map +0 -1
  399. package/dist/onboarding/autonomous-discovery-tools.js +0 -268
  400. package/dist/onboarding/autonomous-discovery-tools.js.map +0 -1
  401. package/dist/onboarding/onboarding-state.d.ts +0 -70
  402. package/dist/onboarding/onboarding-state.d.ts.map +0 -1
  403. package/dist/onboarding/onboarding-state.js +0 -183
  404. package/dist/onboarding/onboarding-state.js.map +0 -1
  405. package/dist/onboarding/personality-quiz.d.ts +0 -35
  406. package/dist/onboarding/personality-quiz.d.ts.map +0 -1
  407. package/dist/onboarding/personality-quiz.js +0 -219
  408. package/dist/onboarding/personality-quiz.js.map +0 -1
  409. package/dist/onboarding/phase-5-summary.d.ts +0 -26
  410. package/dist/onboarding/phase-5-summary.d.ts.map +0 -1
  411. package/dist/onboarding/phase-5-summary.js +0 -153
  412. package/dist/onboarding/phase-5-summary.js.map +0 -1
  413. package/dist/onboarding/phase-6-security.d.ts +0 -33
  414. package/dist/onboarding/phase-6-security.d.ts.map +0 -1
  415. package/dist/onboarding/phase-6-security.js +0 -473
  416. package/dist/onboarding/phase-6-security.js.map +0 -1
  417. package/dist/onboarding/phase-7-integrations.d.ts +0 -91
  418. package/dist/onboarding/phase-7-integrations.d.ts.map +0 -1
  419. package/dist/onboarding/phase-7-integrations.js +0 -725
  420. package/dist/onboarding/phase-7-integrations.js.map +0 -1
  421. package/dist/onboarding/phase-8-demo.d.ts +0 -43
  422. package/dist/onboarding/phase-8-demo.d.ts.map +0 -1
  423. package/dist/onboarding/phase-8-demo.js +0 -346
  424. package/dist/onboarding/phase-8-demo.js.map +0 -1
  425. package/dist/onboarding/phase-9-finalization.d.ts +0 -27
  426. package/dist/onboarding/phase-9-finalization.d.ts.map +0 -1
  427. package/dist/onboarding/phase-9-finalization.js +0 -417
  428. package/dist/onboarding/phase-9-finalization.js.map +0 -1
  429. package/dist/onboarding/ritual-prompt.d.ts +0 -2
  430. package/dist/onboarding/ritual-prompt.d.ts.map +0 -1
  431. package/dist/onboarding/ritual-prompt.js +0 -285
  432. package/dist/onboarding/ritual-prompt.js.map +0 -1
  433. package/dist/onboarding/ritual-tools.d.ts +0 -17
  434. package/dist/onboarding/ritual-tools.d.ts.map +0 -1
  435. package/dist/onboarding/ritual-tools.js +0 -93
  436. package/dist/onboarding/ritual-tools.js.map +0 -1
  437. package/dist/setup/setup-tools.d.ts +0 -13
  438. package/dist/setup/setup-tools.d.ts.map +0 -1
  439. package/dist/setup/setup-tools.js +0 -106
  440. package/dist/setup/setup-tools.js.map +0 -1
  441. package/dist/utils/slack-input-validator.d.ts +0 -74
  442. package/dist/utils/slack-input-validator.d.ts.map +0 -1
  443. package/dist/utils/slack-input-validator.js +0 -275
  444. package/dist/utils/slack-input-validator.js.map +0 -1
  445. package/dist/utils/slack-rate-limiter.d.ts +0 -139
  446. package/dist/utils/slack-rate-limiter.d.ts.map +0 -1
  447. package/dist/utils/slack-rate-limiter.js +0 -324
  448. package/dist/utils/slack-rate-limiter.js.map +0 -1
  449. package/dist/wiki/wiki-compiler.d.ts +0 -13
  450. package/dist/wiki/wiki-compiler.d.ts.map +0 -1
  451. package/dist/wiki/wiki-compiler.js +0 -82
  452. package/dist/wiki/wiki-compiler.js.map +0 -1
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The turn contract.
3
+ *
4
+ * Router-neutral on purpose. This module imports nothing from the message router, so a
5
+ * user-facing surface can depend on how a turn is served without depending on WHAT
6
+ * serves it. Keeping the contract next to its current implementation would leave the
7
+ * coupling in place while looking inverted - a surface would still reach a concrete
8
+ * router through its own base class.
9
+ *
10
+ * A surface owns receive, normalization, progress display, delivery and its restart
11
+ * ledger. Everything inward of `processTurn` - session locks, durable persistence,
12
+ * prompt assembly, the model run - belongs to the implementation.
13
+ *
14
+ * Connectors do not pass through here. They are data the agent reads, never a turn.
15
+ */
16
+ import type { MessageSource, NormalizedMessage, RelatedDecision } from './types.js';
17
+ import type { StreamCallbacks } from '../agent/types.js';
18
+ /** Options a caller may pass alongside a turn. */
19
+ export interface ProcessOptions {
20
+ /** Called immediately if the session is busy and the turn was queued. */
21
+ onQueued?: () => void;
22
+ onStream?: StreamCallbacks;
23
+ }
24
+ /** Fields every turn outcome carries, whatever happened. */
25
+ export interface TurnOutcomeBase {
26
+ /** Response text from the agent. */
27
+ response: string;
28
+ /** Session the turn ran in. */
29
+ sessionId: string;
30
+ /** Related decisions that were injected. */
31
+ injectedDecisions: RelatedDecision[];
32
+ /** Processing duration in milliseconds. */
33
+ duration: number;
34
+ }
35
+ /**
36
+ * A turn that reached the model. It may still carry no durable run handle - see below.
37
+ *
38
+ * Run identity lives on this branch rather than as optional fields on one flat shape,
39
+ * because a turn can end WITHOUT reaching the model. With optional fields a caller
40
+ * cannot tell "no id recorded" from "no run happened", and anything that later traces a
41
+ * delivered claim back to its evidence rests on exactly that distinction.
42
+ */
43
+ /**
44
+ * Whether this turn left a resolvable trail, and if not, why.
45
+ *
46
+ * A bare nullable id collapsed two different facts into one value: a backend that simply
47
+ * produces no run identity is an expected capability state, while a run that was created
48
+ * and then failed to commit is a durability failure someone has to repair. Both leave a
49
+ * resolver with nothing, so they looked identical - and only one of them is a problem.
50
+ */
51
+ export type TurnProvenance = {
52
+ status: 'available';
53
+ modelRunId: string;
54
+ } | {
55
+ status: 'unavailable';
56
+ reason: 'backend_no_run' | 'commit_failed';
57
+ };
58
+ export interface CompletedTurn extends TurnOutcomeBase {
59
+ outcome: 'completed';
60
+ /** Whether a resolvable run handle exists for this turn, and why not when it does not. */
61
+ provenance: TurnProvenance;
62
+ /** Stable id for this inbound turn. */
63
+ sourceTurnId: string;
64
+ /** Canonical reference to the message that started it. */
65
+ sourceMessageRef: string;
66
+ }
67
+ /** A turn answered without a model run - the caller must not look for run identity. */
68
+ export interface BlockedTurn extends TurnOutcomeBase {
69
+ outcome: 'blocked';
70
+ /** Why no model run exists. */
71
+ reason: 'security_block';
72
+ }
73
+ /** Discriminated on `outcome`; both branches keep the base fields. */
74
+ export type ProcessingResult = CompletedTurn | BlockedTurn;
75
+ /**
76
+ * The one callable boundary between a user-facing surface and turn processing.
77
+ *
78
+ * Session ownership belongs to the implementation, and the shape says so: nothing about
79
+ * a session appears in the input, so a caller cannot hand one in, and the id it gets
80
+ * back is the one the implementation chose. Durable conversation state, the backend
81
+ * resume decision and the per-channel lock are held together; splitting any of them
82
+ * across this boundary would leave one lock with two owners.
83
+ *
84
+ * Known exception, stated rather than discovered later: scheduled operator reports do
85
+ * not pass through here. They run their own lane against a forced fresh session, so two
86
+ * session models exist today.
87
+ */
88
+ export interface TurnProcessor {
89
+ processTurn(message: NormalizedMessage, options?: ProcessOptions): Promise<ProcessingResult>;
90
+ }
91
+ /**
92
+ * Session data a surface may read for its own DISPLAY concerns - naming a channel,
93
+ * listing what is active. Deliberately separate from `TurnProcessor`: reading session
94
+ * data to render something is not turn ownership, and a surface that needs it should
95
+ * have to ask for it by name rather than receive a whole router.
96
+ */
97
+ export interface SessionDirectory {
98
+ listSessions(source: MessageSource): ReadonlyArray<{
99
+ readonly channelId: string;
100
+ readonly channelName?: string | null;
101
+ }>;
102
+ updateChannelName(source: MessageSource, channelId: string, channelName: string): boolean;
103
+ }
104
+ //# sourceMappingURL=turn-contract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-contract.d.ts","sourceRoot":"","sources":["../../src/gateways/turn-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,aAAa,EAA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CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC9F;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CACV,MAAM,EAAE,aAAa,GACpB,aAAa,CAAC;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACvF,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3F"}
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=consult-contract.js.map
3
+ //# sourceMappingURL=turn-contract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-contract.js","sourceRoot":"","sources":["../../src/gateways/turn-contract.ts"],"names":[],"mappings":""}
@@ -0,0 +1,111 @@
1
+ import type { MemoryScopeRef } from '@jungjaehoon/mama-core';
2
+ import { type ChannelGrant } from '@jungjaehoon/mama-core/context-compile';
3
+ import { type IndexedEvent, type ParsedSourceRef, type ProvenanceResolution } from './provenance-resolver.js';
4
+ /** The columns the predicate needs. Shared so a test reads exactly what production does. */
5
+ export declare const EVENT_INDEX_COLUMNS = "event_index_id, source_connector, source_id, channel, content,\n event_datetime, source_timestamp_ms, memory_scope_kind, memory_scope_id,\n project_id, tenant_id";
6
+ export interface EventRow {
7
+ event_index_id: unknown;
8
+ source_connector: unknown;
9
+ source_id: unknown;
10
+ channel: unknown;
11
+ content: unknown;
12
+ event_datetime: unknown;
13
+ source_timestamp_ms: unknown;
14
+ memory_scope_kind: unknown;
15
+ memory_scope_id: unknown;
16
+ project_id: unknown;
17
+ tenant_id: unknown;
18
+ }
19
+ export interface LiveProvenanceOptions {
20
+ /** Scopes active NOW. Not the scopes the memory was written under. */
21
+ scopes: MemoryScopeRef[];
22
+ /**
23
+ * Raw connectors this caller may read. No grant means NO raw events, never all of
24
+ * them - the reader fails closed here and so must this. An earlier version accepted
25
+ * `null` to mean "scope alone decides", which turned a missing envelope into a
26
+ * connector-wide grant.
27
+ */
28
+ connectors: readonly string[];
29
+ /**
30
+ * The channels of each connector this caller may read, when the caller holds a grant.
31
+ * Present means the grant decides, exactly as it does in the reader. Absent means the
32
+ * pre-grant rule applies, so a caller that has not been given one is unaffected.
33
+ */
34
+ channels?: ChannelGrant;
35
+ /** Project and tenant window, mirroring the reader's filters on the same columns. */
36
+ projectIds?: readonly string[];
37
+ tenantId?: string | null;
38
+ /**
39
+ * Visibility clamp on observation time, in epoch ms. Only the MAX is threaded from the
40
+ * call site, deliberately: the reader's lower bound comes solely from `range.start_ms`,
41
+ * which is caller-chosen narrowing, while the upper bound folds in `as_of`, which is an
42
+ * authority clamp. A future reader should not "fix" the asymmetry. The reader bounds raw candidates
43
+ * by `COALESCE(event_datetime, source_timestamp_ms)`; without a counterpart here, an
44
+ * `as_of` boundary would hold for reading and not for citation. Nothing assigns
45
+ * `envelope.scope.as_of` today, so these are null in practice - implemented now
46
+ * because a filter with no counterpart is exactly the shape the tenant leak had.
47
+ */
48
+ minObservedMs?: number | null;
49
+ maxObservedMs?: number | null;
50
+ excerptChars?: number;
51
+ /** Redaction to apply to excerpts, so this surface scrubs what recall scrubs. */
52
+ redact?: (text: string) => string;
53
+ }
54
+ /**
55
+ * Parse a stored source ref into what it actually is.
56
+ *
57
+ * The shapes here were measured, not guessed. Of the source refs on this machine 13,403
58
+ * are `memory:`, 1,748 are `envelope:`, 9 are `message:` and none are `raw:`. An earlier
59
+ * version of this parser understood only `raw:` and reported every real memory as
60
+ * `unsupported_ref` - a tool that was wired, callable, and answered nothing.
61
+ */
62
+ export declare function parseSourceRef(ref: string): ParsedSourceRef;
63
+ /**
64
+ * Whether an event may be shown under the authority active now.
65
+ *
66
+ * When a channel grant is supplied this DELEGATES to the shared rule rather than copying
67
+ * it. The previous version copied the reader clause for clause and said so in a comment,
68
+ * which held until the reader changed - then the copy silently became a different rule
69
+ * that refused excerpts for the very events the reader was citing. The differential test
70
+ * meant to catch that kept passing, because its fixtures never set a grant.
71
+ *
72
+ * "A shared predicate would be better than a faithful copy" is what the old comment here
73
+ * said. It was right.
74
+ *
75
+ * Without a grant the pre-grant rule still applies, so callers that have not been given
76
+ * one behave exactly as before.
77
+ */
78
+ export declare function isEventVisibleNow(event: IndexedEvent, options: {
79
+ scopes: readonly MemoryScopeRef[];
80
+ connectors: readonly string[];
81
+ channels?: ChannelGrant;
82
+ projectIds?: readonly string[];
83
+ tenantId?: string | null;
84
+ minObservedMs?: number | null;
85
+ maxObservedMs?: number | null;
86
+ }): boolean;
87
+ /**
88
+ * Row to the struct the predicate judges.
89
+ *
90
+ * Exported because it is the layer BELOW the predicate, and a differential that
91
+ * hand-builds its own struct proves the predicate mirrors the reader while leaving this
92
+ * mapping unjudged - which is where a scope-column coercion bug already lived once.
93
+ */
94
+ export declare function toIndexedEvent(row: EventRow): IndexedEvent;
95
+ /**
96
+ * Whether a message ref may be named.
97
+ *
98
+ * `sourceMessageRef` is built as `source:channelId:turnId` (message-router.ts), and a
99
+ * channel scope id as `source:channelId` (scope-context.ts) - so a ref belongs to a
100
+ * caller's channel exactly when an active channel scope is its prefix. Compared as a
101
+ * prefix rather than parsed, because a turn id can itself contain a colon
102
+ * (`generated:<uuid>`) and splitting on the last one would silently mis-attribute it.
103
+ *
104
+ * This matters beyond tidiness: every memory carrying such a ref is also bound to
105
+ * global:system, which every caller holds, so an unchecked ref handed a private channel
106
+ * identifier to any agent that could read the memory at all.
107
+ */
108
+ export declare function isMessageRefVisible(ref: string, scopes: readonly MemoryScopeRef[]): boolean;
109
+ /** Resolve one memory's support against the live index and the scopes active now. */
110
+ export declare function resolveMemoryProvenanceLive(memoryId: string, options: LiveProvenanceOptions): Promise<ProvenanceResolution>;
111
+ //# sourceMappingURL=provenance-live.d.ts.map
@@ -0,0 +1 @@
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AAE,MAAM,KAAK,MAAM,CAAC;CACnC;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAqB3D;AAoBD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE;IACP,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAClC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,GACA,OAAO,CA8DT;AAyDD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,YAAY,CAkB1D;AAwGD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,OAAO,CAE3F;AAQD,qFAAqF;AACrF,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAqD/B"}
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EVENT_INDEX_COLUMNS = void 0;
4
+ exports.parseSourceRef = parseSourceRef;
5
+ exports.isEventVisibleNow = isEventVisibleNow;
6
+ exports.toIndexedEvent = toIndexedEvent;
7
+ exports.isMessageRefVisible = isMessageRefVisible;
8
+ exports.resolveMemoryProvenanceLive = resolveMemoryProvenanceLive;
9
+ /**
10
+ * The live wiring for provenance resolution: real memory records, real events, real scope.
11
+ *
12
+ * The resolver itself is pure. This is where it meets the database, and the one rule that
13
+ * governs the whole file is that CITATION MUST NOT OUT-READ READING. If this path were
14
+ * more permissive than the path that reads raw events normally, then citing a claim would
15
+ * become a way to see events the read path denies - the handle would launder access.
16
+ * So this path does not have its own rule any more. When the caller holds a channel grant
17
+ * it calls the SAME function the reader compiles into SQL (mama-core channel-grant.ts).
18
+ * Mirroring by hand is what this file used to do, and the mirror held right up until the
19
+ * reader changed - at which point citation started refusing excerpts for the very events
20
+ * the reader was citing, and the differential test kept passing because its fixtures never
21
+ * set a grant.
22
+ *
23
+ * The pre-grant rule below is retained for callers that hold no grant. It matters that it
24
+ * stays generous about unscoped rows: 19,394 of 30,671 indexed events carry no scope at
25
+ * all, so denying them outright would make provenance useless for most of the corpus.
26
+ */
27
+ const mama_core_1 = require("@jungjaehoon/mama-core");
28
+ const context_compile_1 = require("@jungjaehoon/mama-core/context-compile");
29
+ const provenance_resolver_js_1 = require("./provenance-resolver.js");
30
+ /** The columns the predicate needs. Shared so a test reads exactly what production does. */
31
+ exports.EVENT_INDEX_COLUMNS = `event_index_id, source_connector, source_id, channel, content,
32
+ event_datetime, source_timestamp_ms, memory_scope_kind, memory_scope_id,
33
+ project_id, tenant_id`;
34
+ /**
35
+ * Statuses every memory read path excludes (source-readers.ts:293, and recall's own
36
+ * history exclusion). Mirrored so a citation cannot present a retired record as current.
37
+ */
38
+ const RETIRED_MEMORY_STATUSES = new Set(['superseded', 'quarantined', 'contradicted', 'stale']);
39
+ /**
40
+ * Parse a stored source ref into what it actually is.
41
+ *
42
+ * The shapes here were measured, not guessed. Of the source refs on this machine 13,403
43
+ * are `memory:`, 1,748 are `envelope:`, 9 are `message:` and none are `raw:`. An earlier
44
+ * version of this parser understood only `raw:` and reported every real memory as
45
+ * `unsupported_ref` - a tool that was wired, callable, and answered nothing.
46
+ */
47
+ function parseSourceRef(ref) {
48
+ const separator = ref.indexOf(':');
49
+ if (separator <= 0 || separator === ref.length - 1) {
50
+ return { kind: 'unsupported' };
51
+ }
52
+ const prefix = ref.slice(0, separator);
53
+ const rest = ref.slice(separator + 1);
54
+ if (prefix === 'memory' || prefix === 'envelope' || prefix === 'message') {
55
+ return { kind: prefix, id: rest };
56
+ }
57
+ if (prefix !== 'raw') {
58
+ return { kind: 'unsupported' };
59
+ }
60
+ // `raw:<connector>:<event_index_id>`. Split on the FIRST colon of the remainder so a
61
+ // colon inside the id cannot shift the boundary.
62
+ const inner = rest.indexOf(':');
63
+ if (inner <= 0 || inner === rest.length - 1) {
64
+ return { kind: 'unsupported' };
65
+ }
66
+ return { kind: 'raw', connector: rest.slice(0, inner), eventIndexId: rest.slice(inner + 1) };
67
+ }
68
+ /**
69
+ * The time bound, shared by both branches.
70
+ *
71
+ * An event with no timestamp at all cannot satisfy a bound the reader applies to a
72
+ * COALESCE of two columns, so it is excluded whenever one is set.
73
+ */
74
+ function isWithinObservedWindow(event, options) {
75
+ const min = options.minObservedMs ?? null;
76
+ const max = options.maxObservedMs ?? null;
77
+ if (min === null && max === null)
78
+ return true;
79
+ const observedMs = event.observedAt === null ? null : Date.parse(event.observedAt);
80
+ if (observedMs === null || Number.isNaN(observedMs))
81
+ return false;
82
+ return (min === null || observedMs >= min) && (max === null || observedMs <= max);
83
+ }
84
+ /**
85
+ * Whether an event may be shown under the authority active now.
86
+ *
87
+ * When a channel grant is supplied this DELEGATES to the shared rule rather than copying
88
+ * it. The previous version copied the reader clause for clause and said so in a comment,
89
+ * which held until the reader changed - then the copy silently became a different rule
90
+ * that refused excerpts for the very events the reader was citing. The differential test
91
+ * meant to catch that kept passing, because its fixtures never set a grant.
92
+ *
93
+ * "A shared predicate would be better than a faithful copy" is what the old comment here
94
+ * said. It was right.
95
+ *
96
+ * Without a grant the pre-grant rule still applies, so callers that have not been given
97
+ * one behave exactly as before.
98
+ */
99
+ function isEventVisibleNow(event, options) {
100
+ const { scopes, connectors } = options;
101
+ if (options.channels) {
102
+ return ((0, context_compile_1.isChannelGranted)(event.connector, event.channel, options.channels) &&
103
+ isWithinObservedWindow(event, options));
104
+ }
105
+ const projectIds = options.projectIds ?? [];
106
+ const tenantId = options.tenantId ?? null;
107
+ // The reader's own guard: no connectors or no scopes means no raw events at all.
108
+ if (connectors.length === 0 || scopes.length === 0) {
109
+ return false;
110
+ }
111
+ if (!connectors.includes(event.connector)) {
112
+ return false;
113
+ }
114
+ const hasGlobalSystemScope = scopes.some((scope) => scope.kind === 'global' && scope.id === 'system');
115
+ const hasScopedVisibility = scopes.some((scope) => !(scope.kind === 'global' && scope.id === 'system')) ||
116
+ projectIds.length > 0 ||
117
+ Boolean(tenantId);
118
+ const includesLegacyGlobalSystem = hasGlobalSystemScope && !hasScopedVisibility;
119
+ if (projectIds.length > 0) {
120
+ const projectMatches = (event.projectId !== null &&
121
+ event.projectId !== undefined &&
122
+ projectIds.includes(event.projectId)) ||
123
+ (includesLegacyGlobalSystem && (event.projectId ?? null) === null);
124
+ if (!projectMatches) {
125
+ return false;
126
+ }
127
+ }
128
+ if (tenantId) {
129
+ const tenantMatches = event.tenantId === tenantId ||
130
+ (includesLegacyGlobalSystem && (event.tenantId ?? null) === null);
131
+ if (!tenantMatches) {
132
+ return false;
133
+ }
134
+ }
135
+ if (!isWithinObservedWindow(event, options)) {
136
+ return false;
137
+ }
138
+ const scope = event.memoryScope ?? null;
139
+ if (!scope) {
140
+ return includesLegacyGlobalSystem;
141
+ }
142
+ return scopes.some((active) => active.kind === scope.kind &&
143
+ (active.id === scope.id ||
144
+ // Rows written before the global/system alignment carry id 'global'.
145
+ (active.kind === 'global' && active.id === 'system' && scope.id === 'global')));
146
+ }
147
+ async function resolveAdapter() {
148
+ const dbManager = (await import('@jungjaehoon/mama-core/db-manager'));
149
+ try {
150
+ return dbManager.getAdapter();
151
+ }
152
+ catch (error) {
153
+ if (typeof dbManager.initDB !== 'function') {
154
+ throw error;
155
+ }
156
+ await dbManager.initDB();
157
+ return dbManager.getAdapter();
158
+ }
159
+ }
160
+ /**
161
+ * One column to epoch ms, with SQL's notion of "absent" and no other.
162
+ *
163
+ * `COALESCE` falls through on NULL and nothing else, so 0 and negative values are
164
+ * PRESENT to the reader. Treating them as missing - which this did, by requiring
165
+ * `value > 0` - made the mapper judge a different instant than the query: a row with
166
+ * `event_datetime = 0` compared as 0 in SQL and as its source timestamp here. The
167
+ * differential caught it the moment it was routed through the production mapper.
168
+ *
169
+ * The non-numeric string branch is DEFENSIVE, not faithful: SQLite orders a TEXT value
170
+ * above every INTEGER regardless of what it spells, so SQL would exclude such a row from
171
+ * any upper bound while `Date.parse` gives it a real instant. Unreachable - both columns
172
+ * are INTEGER-affinity, the write path passes a number, and all 30,671 live rows store
173
+ * integers - but it is a divergence if it ever runs, and better named than implied.
174
+ */
175
+ function toEpochMs(value) {
176
+ if (typeof value === 'number') {
177
+ return Number.isFinite(value) ? value : null;
178
+ }
179
+ // better-sqlite3 returns bigint when safeIntegers is on. Nothing enables it today, but
180
+ // without this arm flipping that flag would null every timestamp and silently disable
181
+ // the time clamp entirely.
182
+ if (typeof value === 'bigint') {
183
+ return Number(value);
184
+ }
185
+ if (typeof value === 'string' && value.trim().length > 0) {
186
+ const numeric = Number(value);
187
+ if (Number.isFinite(numeric)) {
188
+ return numeric;
189
+ }
190
+ const parsed = Date.parse(value);
191
+ return Number.isNaN(parsed) ? null : parsed;
192
+ }
193
+ return null;
194
+ }
195
+ function coalesceObservedAt(eventDatetime, sourceTimestampMs) {
196
+ const ms = toEpochMs(eventDatetime) ?? toEpochMs(sourceTimestampMs);
197
+ return ms === null ? null : new Date(ms).toISOString();
198
+ }
199
+ /**
200
+ * Row to the struct the predicate judges.
201
+ *
202
+ * Exported because it is the layer BELOW the predicate, and a differential that
203
+ * hand-builds its own struct proves the predicate mirrors the reader while leaving this
204
+ * mapping unjudged - which is where a scope-column coercion bug already lived once.
205
+ */
206
+ function toIndexedEvent(row) {
207
+ const scopeKind = typeof row.memory_scope_kind === 'string' ? row.memory_scope_kind : null;
208
+ const scopeId = typeof row.memory_scope_id === 'string' ? row.memory_scope_id : null;
209
+ // Only a row with BOTH columns null is unscoped, because that is the only row the
210
+ // reader's `IS NULL AND IS NULL` clause matches. Collapsing a half-populated or
211
+ // empty-string row to "unscoped" would hand it the legacy allowance the reader denies.
212
+ const unscoped = scopeKind === null && scopeId === null;
213
+ return {
214
+ connector: String(row.source_connector ?? ''),
215
+ eventIndexId: String(row.event_index_id ?? ''),
216
+ sourceId: String(row.source_id ?? ''),
217
+ channel: typeof row.channel === 'string' ? row.channel : null,
218
+ observedAt: coalesceObservedAt(row.event_datetime, row.source_timestamp_ms),
219
+ content: typeof row.content === 'string' ? row.content : '',
220
+ memoryScope: unscoped ? null : { kind: scopeKind ?? '', id: scopeId ?? '' },
221
+ projectId: typeof row.project_id === 'string' ? row.project_id : null,
222
+ tenantId: typeof row.tenant_id === 'string' ? row.tenant_id : null,
223
+ };
224
+ }
225
+ function stringOrNull(value) {
226
+ return typeof value === 'string' && value.trim().length > 0 ? value : null;
227
+ }
228
+ /**
229
+ * Fetch a memory's provenance under the scopes active now.
230
+ *
231
+ * Two lookups on purpose. The first is scope-strict. Only if that finds nothing do we ask
232
+ * again admitting records with no scope bindings, and a record that appears only on the
233
+ * second pass is reported as legacy rather than as support. A memory that appears on
234
+ * neither is reported as unknown - never as "exists but withheld", which would confirm
235
+ * the existence of something outside the caller's scope.
236
+ */
237
+ async function lookupWithLegacyFallback(memoryId, scopes) {
238
+ const scoped = await (0, mama_core_1.getMemoryProvenance)(memoryId, { scopes });
239
+ if (scoped) {
240
+ return { record: scoped, legacy: false };
241
+ }
242
+ const unbound = await (0, mama_core_1.getMemoryProvenance)(memoryId, { scopes, includeLegacyUnscoped: true });
243
+ return unbound ? { record: unbound, legacy: true } : null;
244
+ }
245
+ /**
246
+ * The stored record's status. `getMemoryProvenance` selects it nowhere, so this is a
247
+ * separate read rather than a field that was there all along - which is precisely why the
248
+ * status filter had no counterpart on this path for four review rounds.
249
+ */
250
+ async function loadRetirement(memoryId) {
251
+ const adapter = await resolveAdapter();
252
+ const row = adapter
253
+ .prepare(`SELECT status, superseded_by FROM decisions WHERE id = ? LIMIT 1`)
254
+ .get(memoryId);
255
+ const status = typeof row?.status === 'string' ? row.status : null;
256
+ const supersededBy = typeof row?.superseded_by === 'string' ? row.superseded_by : null;
257
+ return {
258
+ status,
259
+ // Either signal retires it: the reader filters on status, and recall additionally
260
+ // requires `superseded_by IS NULL`.
261
+ retired: (status !== null && RETIRED_MEMORY_STATUSES.has(status)) || supersededBy !== null,
262
+ };
263
+ }
264
+ async function loadRecord(memoryId, scopes) {
265
+ const found = await lookupWithLegacyFallback(memoryId, scopes);
266
+ if (!found) {
267
+ return null;
268
+ }
269
+ const record = found.record;
270
+ const retirement = await loadRetirement(record.memory_id);
271
+ const provenance = record.provenance;
272
+ return {
273
+ status: retirement.status,
274
+ retired: retirement.retired,
275
+ modelRunId: record.model_run_id,
276
+ contextPacketId: stringOrNull(provenance?.context_packet_id),
277
+ sourceRefs: record.source_refs.map(parseSourceRef),
278
+ legacyUnscoped: found.legacy,
279
+ };
280
+ }
281
+ /**
282
+ * Which supporting memories the caller may see, resolved up front.
283
+ *
284
+ * The pure resolver checks visibility synchronously, so this pre-answers it for the
285
+ * memory refs a record carries - typically a handful, up to fifty in the live corpus,
286
+ * and up to two lookups each, so ~100 serial round trips at the tail. Bounded and off
287
+ * the hot path (agent-invoked, not per-turn); the second lookup fires only for an
288
+ * ancestor with no scope bindings, of which the live corpus has two. Worth replacing
289
+ * with one bindings query if a memory ever carries hundreds of ancestors.
290
+ * Uses the SAME two-pass gate as the record itself, legacy pass included: an ancestor
291
+ * with no scope bindings is admitted exactly where an unbound record is, rather than
292
+ * reported out of scope because the second pass was skipped. An earlier docstring
293
+ * claimed that parity without the code doing it.
294
+ */
295
+ async function resolveVisibleMemoryRefs(record, scopes) {
296
+ const visible = new Set();
297
+ if (!record) {
298
+ return visible;
299
+ }
300
+ const ids = new Set(record.sourceRefs.flatMap((ref) => (ref.kind === 'memory' ? [ref.id] : [])));
301
+ for (const id of ids) {
302
+ if (await lookupWithLegacyFallback(id, scopes)) {
303
+ visible.add(id);
304
+ }
305
+ }
306
+ return visible;
307
+ }
308
+ /**
309
+ * Whether a message ref may be named.
310
+ *
311
+ * `sourceMessageRef` is built as `source:channelId:turnId` (message-router.ts), and a
312
+ * channel scope id as `source:channelId` (scope-context.ts) - so a ref belongs to a
313
+ * caller's channel exactly when an active channel scope is its prefix. Compared as a
314
+ * prefix rather than parsed, because a turn id can itself contain a colon
315
+ * (`generated:<uuid>`) and splitting on the last one would silently mis-attribute it.
316
+ *
317
+ * This matters beyond tidiness: every memory carrying such a ref is also bound to
318
+ * global:system, which every caller holds, so an unchecked ref handed a private channel
319
+ * identifier to any agent that could read the memory at all.
320
+ */
321
+ function isMessageRefVisible(ref, scopes) {
322
+ return scopes.some((scope) => scope.kind === 'channel' && ref.startsWith(`${scope.id}:`));
323
+ }
324
+ // Known limit, stated rather than discovered: the channel id space is not prefix-free.
325
+ // Real channel ids already contain colons, so a channel `S:X` produces refs that a caller
326
+ // scoped to `S` matches. Nothing in the ref format distinguishes "channel S, turn X:99"
327
+ // from "channel S:X, turn 99", so this cannot be resolved by parsing harder - it would
328
+ // take a delimiter the writer does not use. There are no such colliding pairs in the live
329
+ // scope table, so the guarantee holds on today's data rather than structurally.
330
+ /** Resolve one memory's support against the live index and the scopes active now. */
331
+ async function resolveMemoryProvenanceLive(memoryId, options) {
332
+ const record = await loadRecord(memoryId, options.scopes);
333
+ const visibleMemoryRefs = await resolveVisibleMemoryRefs(record, options.scopes);
334
+ const adapter = await resolveAdapter();
335
+ const statement = adapter.prepare(`SELECT ${exports.EVENT_INDEX_COLUMNS}
336
+ FROM connector_event_index
337
+ WHERE event_index_id = ?
338
+ LIMIT 1`);
339
+ return (0, provenance_resolver_js_1.resolveMemoryProvenance)(memoryId, {
340
+ lookupMemoryProvenance: () => record,
341
+ lookupEvent: (connector, eventIndexId) => {
342
+ const row = statement.get(eventIndexId);
343
+ if (!row) {
344
+ return null;
345
+ }
346
+ const event = toIndexedEvent(row);
347
+ // The id is a hash of connector plus source id, so a connector mismatch means the
348
+ // ref was rewritten rather than that the event moved. Treat it as gone, not as data.
349
+ return event.connector === connector ? event : null;
350
+ },
351
+ ...(options.redact === undefined ? {} : { redact: options.redact }),
352
+ isSupportVisible: (support) => {
353
+ if (support.kind === 'memory') {
354
+ return visibleMemoryRefs.has(support.id);
355
+ }
356
+ if (support.kind === 'message') {
357
+ return isMessageRefVisible(support.id, options.scopes);
358
+ }
359
+ // Envelope hashes are emitted. The reason is NOT that the hash is inert - it is a
360
+ // lookup key into GET /api/memory/provenance, which serves unscoped results by
361
+ // hash and explicitly refuses scope filters (memory-provenance-handler.ts:26-33).
362
+ // What makes it safe is that the route sits behind requireAdminAuth
363
+ // (api/index.ts:215) and no role holding mama_provenance has an admin token or a
364
+ // shell. That is an access control in another file, so if this tool is ever
365
+ // granted to a role with either, revisit this line - the hash stops being safe
366
+ // before anything here changes.
367
+ return true;
368
+ },
369
+ isVisible: (event) => isEventVisibleNow(event, {
370
+ scopes: options.scopes,
371
+ connectors: options.connectors,
372
+ ...(options.channels ? { channels: options.channels } : {}),
373
+ ...(options.projectIds === undefined ? {} : { projectIds: options.projectIds }),
374
+ tenantId: options.tenantId ?? null,
375
+ minObservedMs: options.minObservedMs ?? null,
376
+ maxObservedMs: options.maxObservedMs ?? null,
377
+ }),
378
+ ...(options.excerptChars === undefined ? {} : { excerptChars: options.excerptChars }),
379
+ });
380
+ }
381
+ //# sourceMappingURL=provenance-live.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provenance-live.js","sourceRoot":"","sources":["../../src/memory/provenance-live.ts"],"names":[],"mappings":";;;AA2GA,wCAqBC;AAmCD,8CAyEC;AAgED,wCAkBC;AAqHD,kDAEC;AASD,kEAwDC;AAtfD;;;;;;;;;;;;;;;;;GAiBG;AACH,sDAA6D;AAE7D,4EAA6F;AAC7F,qEAMkC;AAElC,4FAA4F;AAC/E,QAAA,mBAAmB,GAAG;;k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