openloops 0.10.2 → 0.11.0

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 (614) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/README.md +14 -20
  3. package/dist/clients/llm/llm-client.d.ts +2 -2
  4. package/dist/clients/llm/llm-client.js +17 -18
  5. package/dist/clients/llm/llm-client.mjs +12 -13
  6. package/dist/clients/llm/llm-types.d.ts +2 -2
  7. package/dist/clients/llm/model-resolution.js +4 -5
  8. package/dist/clients/llm/model-resolution.mjs +1 -2
  9. package/dist/clients/serper/serper-client.js +3 -4
  10. package/dist/clients/serper/serper-client.mjs +1 -2
  11. package/dist/clients/slack/slack-client.js +2 -2
  12. package/dist/clients/slack/slack-client.mjs +1 -1
  13. package/dist/common/utils/number-setting.js +2 -2
  14. package/dist/common/utils/number-setting.mjs +1 -1
  15. package/dist/db/indexes/index.js +1 -5
  16. package/dist/db/indexes/index.mjs +1 -5
  17. package/dist/guardrails/guard.d.ts +4 -4
  18. package/dist/harness/actor-profile.d.ts +2 -0
  19. package/dist/{common/error/error-reporter.js → harness/actor-profile.js} +10 -13
  20. package/dist/harness/actor-profile.mjs +9 -0
  21. package/dist/harness/agent-loop.d.ts +4 -5
  22. package/dist/harness/agent.d.ts +7 -7
  23. package/dist/harness/agent.js +46 -46
  24. package/dist/harness/agent.mjs +44 -44
  25. package/dist/harness/default-model.d.ts +20 -0
  26. package/dist/harness/default-model.js +72 -0
  27. package/dist/harness/default-model.mjs +46 -0
  28. package/dist/harness/index.d.ts +2 -0
  29. package/dist/harness/index.js +8 -1
  30. package/dist/harness/index.mjs +5 -1
  31. package/dist/harness/tool-pipeline.d.ts +1 -1
  32. package/dist/harness/tool-pipeline.js +3 -3
  33. package/dist/harness/tool-pipeline.mjs +1 -1
  34. package/dist/harness/usage-limit.d.ts +2 -2
  35. package/dist/harness/usage-limit.js +5 -3
  36. package/dist/harness/usage-limit.mjs +5 -3
  37. package/dist/harness/workspace.d.ts +3 -3
  38. package/dist/harness/workspace.js +8 -8
  39. package/dist/harness/workspace.mjs +8 -8
  40. package/dist/loops/agi/loop.js +2 -2
  41. package/dist/loops/agi/loop.mjs +2 -2
  42. package/dist/services/automations/entities/automation-run.entity.d.ts +1 -1
  43. package/dist/services/automations/entities/automation-run.entity.js +4 -4
  44. package/dist/services/automations/entities/automation-run.entity.mjs +1 -1
  45. package/dist/services/automations/entities/automation.entity.d.ts +1 -1
  46. package/dist/services/automations/entities/automation.entity.js +3 -3
  47. package/dist/services/automations/entities/automation.entity.mjs +1 -1
  48. package/dist/services/automations/repositories/automation-run.repository.d.ts +1 -1
  49. package/dist/services/automations/repositories/automation-run.repository.js +5 -6
  50. package/dist/services/automations/repositories/automation-run.repository.mjs +2 -3
  51. package/dist/services/automations/repositories/automation.repository.d.ts +1 -1
  52. package/dist/services/automations/repositories/automation.repository.js +5 -6
  53. package/dist/services/automations/repositories/automation.repository.mjs +2 -3
  54. package/dist/services/automations/runner/automation-runner.d.ts +4 -4
  55. package/dist/services/automations/runner/automation-runner.js +16 -15
  56. package/dist/services/automations/runner/automation-runner.mjs +11 -10
  57. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.d.ts +1 -1
  58. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.js +2 -2
  59. package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +1 -1
  60. package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +1 -1
  61. package/dist/services/automations/use-cases/claim-due-automations.use-case.js +3 -4
  62. package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +1 -2
  63. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +1 -1
  64. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +2 -2
  65. package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +1 -1
  66. package/dist/services/automations/use-cases/create-automation.use-case.d.ts +1 -1
  67. package/dist/services/automations/use-cases/create-automation.use-case.js +8 -8
  68. package/dist/services/automations/use-cases/create-automation.use-case.mjs +5 -5
  69. package/dist/services/automations/use-cases/delete-automation.use-case.d.ts +1 -1
  70. package/dist/services/automations/use-cases/delete-automation.use-case.js +8 -8
  71. package/dist/services/automations/use-cases/delete-automation.use-case.mjs +5 -5
  72. package/dist/services/automations/use-cases/finish-automation-run.use-case.d.ts +1 -1
  73. package/dist/services/automations/use-cases/finish-automation-run.use-case.js +2 -2
  74. package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +1 -1
  75. package/dist/services/automations/use-cases/get-automation-by-id.use-case.d.ts +1 -1
  76. package/dist/services/automations/use-cases/get-automation-by-id.use-case.js +7 -7
  77. package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +4 -4
  78. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +1 -1
  79. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +7 -7
  80. package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +4 -4
  81. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.d.ts +2 -2
  82. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.js +7 -7
  83. package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +4 -4
  84. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.d.ts +2 -2
  85. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.js +9 -9
  86. package/dist/services/automations/use-cases/list-automation-runs-by-user.use-case.mjs +6 -6
  87. package/dist/services/automations/use-cases/list-automations-by-user.use-case.d.ts +2 -2
  88. package/dist/services/automations/use-cases/list-automations-by-user.use-case.js +9 -9
  89. package/dist/services/automations/use-cases/list-automations-by-user.use-case.mjs +6 -6
  90. package/dist/services/automations/use-cases/preview-automation-runs.use-case.d.ts +1 -1
  91. package/dist/services/automations/use-cases/preview-automation-runs.use-case.js +2 -2
  92. package/dist/services/automations/use-cases/preview-automation-runs.use-case.mjs +1 -1
  93. package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +1 -1
  94. package/dist/services/automations/use-cases/receive-automation-event.use-case.js +3 -3
  95. package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +2 -2
  96. package/dist/services/automations/use-cases/renew-automation-lease.use-case.d.ts +1 -1
  97. package/dist/services/automations/use-cases/renew-automation-lease.use-case.js +2 -2
  98. package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +1 -1
  99. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +1 -1
  100. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +10 -11
  101. package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +7 -8
  102. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +1 -1
  103. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +7 -7
  104. package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +4 -4
  105. package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +1 -1
  106. package/dist/services/automations/use-cases/start-automation-run.use-case.js +5 -5
  107. package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +4 -4
  108. package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +1 -1
  109. package/dist/services/automations/use-cases/sync-automation-run.use-case.js +2 -2
  110. package/dist/services/automations/use-cases/sync-automation-run.use-case.mjs +1 -1
  111. package/dist/services/automations/use-cases/sync-automation-runs.use-case.d.ts +1 -1
  112. package/dist/services/automations/use-cases/sync-automation-runs.use-case.js +2 -2
  113. package/dist/services/automations/use-cases/sync-automation-runs.use-case.mjs +1 -1
  114. package/dist/services/automations/use-cases/update-automation.use-case.d.ts +1 -1
  115. package/dist/services/automations/use-cases/update-automation.use-case.js +8 -9
  116. package/dist/services/automations/use-cases/update-automation.use-case.mjs +4 -5
  117. package/dist/services/automations/utils/event-token.d.ts +1 -0
  118. package/dist/services/automations/utils/event-token.js +9 -6
  119. package/dist/services/automations/utils/event-token.mjs +3 -1
  120. package/dist/services/automations/utils/open-run.d.ts +1 -1
  121. package/dist/services/automations/utils/runner-scope.d.ts +1 -1
  122. package/dist/services/automations/utils/runner-scope.js +3 -3
  123. package/dist/services/automations/utils/runner-scope.mjs +1 -1
  124. package/dist/services/chats/entities/chat-message.entity.d.ts +1 -1
  125. package/dist/services/chats/entities/chat-message.entity.js +3 -3
  126. package/dist/services/chats/entities/chat-message.entity.mjs +1 -1
  127. package/dist/services/chats/entities/chat.entity.d.ts +1 -1
  128. package/dist/services/chats/entities/chat.entity.js +4 -4
  129. package/dist/services/chats/entities/chat.entity.mjs +1 -1
  130. package/dist/services/chats/repositories/chat.repository.d.ts +1 -1
  131. package/dist/services/chats/repositories/chat.repository.js +5 -6
  132. package/dist/services/chats/repositories/chat.repository.mjs +2 -3
  133. package/dist/services/chats/use-cases/create-chat.use-case.d.ts +1 -1
  134. package/dist/services/chats/use-cases/create-chat.use-case.js +7 -7
  135. package/dist/services/chats/use-cases/create-chat.use-case.mjs +4 -4
  136. package/dist/services/chats/use-cases/delete-chat.use-case.d.ts +1 -1
  137. package/dist/services/chats/use-cases/delete-chat.use-case.js +8 -8
  138. package/dist/services/chats/use-cases/delete-chat.use-case.mjs +5 -5
  139. package/dist/services/chats/use-cases/get-chat-by-id.use-case.d.ts +2 -2
  140. package/dist/services/chats/use-cases/get-chat-by-id.use-case.js +7 -7
  141. package/dist/services/chats/use-cases/get-chat-by-id.use-case.mjs +4 -4
  142. package/dist/services/chats/use-cases/interrupt-execution.use-case.d.ts +1 -1
  143. package/dist/services/chats/use-cases/interrupt-execution.use-case.js +7 -7
  144. package/dist/services/chats/use-cases/interrupt-execution.use-case.mjs +4 -4
  145. package/dist/services/chats/use-cases/list-chats-by-props.use-case.d.ts +2 -2
  146. package/dist/services/chats/use-cases/list-chats-by-props.use-case.js +7 -7
  147. package/dist/services/chats/use-cases/list-chats-by-props.use-case.mjs +4 -4
  148. package/dist/services/chats/use-cases/list-chats-by-user.use-case.d.ts +2 -2
  149. package/dist/services/chats/use-cases/list-chats-by-user.use-case.js +8 -8
  150. package/dist/services/chats/use-cases/list-chats-by-user.use-case.mjs +5 -5
  151. package/dist/services/chats/use-cases/update-chat.use-case.d.ts +1 -1
  152. package/dist/services/chats/use-cases/update-chat.use-case.js +7 -7
  153. package/dist/services/chats/use-cases/update-chat.use-case.mjs +4 -4
  154. package/dist/services/llmcalls/entities/llmcall.entity.d.ts +1 -1
  155. package/dist/services/llmcalls/entities/llmcall.entity.js +4 -4
  156. package/dist/services/llmcalls/entities/llmcall.entity.mjs +1 -1
  157. package/dist/services/llmcalls/repositories/llmcall.repository.d.ts +1 -1
  158. package/dist/services/llmcalls/repositories/llmcall.repository.js +5 -6
  159. package/dist/services/llmcalls/repositories/llmcall.repository.mjs +2 -3
  160. package/dist/services/llmcalls/use-cases/create-llmcall.use-case.d.ts +1 -1
  161. package/dist/services/llmcalls/use-cases/create-llmcall.use-case.js +7 -7
  162. package/dist/services/llmcalls/use-cases/create-llmcall.use-case.mjs +4 -4
  163. package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.d.ts +1 -1
  164. package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.js +8 -8
  165. package/dist/services/llmcalls/use-cases/delete-llmcall.use-case.mjs +5 -5
  166. package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.d.ts +1 -1
  167. package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.js +9 -9
  168. package/dist/services/llmcalls/use-cases/get-llm-usage-by-chat.use-case.mjs +6 -6
  169. package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.d.ts +1 -1
  170. package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.js +9 -9
  171. package/dist/services/llmcalls/use-cases/get-llm-usage-by-message.use-case.mjs +6 -6
  172. package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.d.ts +2 -2
  173. package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.js +12 -10
  174. package/dist/services/llmcalls/use-cases/get-llm-usage-stats.use-case.mjs +9 -7
  175. package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.d.ts +1 -1
  176. package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.js +7 -7
  177. package/dist/services/llmcalls/use-cases/get-llmcall-by-id.use-case.mjs +4 -4
  178. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.d.ts +2 -2
  179. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.js +5 -5
  180. package/dist/services/llmcalls/use-cases/list-llmcalls-by-props.use-case.mjs +4 -4
  181. package/dist/services/llmcalls/use-cases/update-llmcall.use-case.d.ts +1 -1
  182. package/dist/services/llmcalls/use-cases/update-llmcall.use-case.js +7 -7
  183. package/dist/services/llmcalls/use-cases/update-llmcall.use-case.mjs +4 -4
  184. package/dist/services/mcp-servers/admin/admin-params.d.ts +5 -0
  185. package/dist/{common/logger/index.js → services/mcp-servers/admin/admin-params.js} +2 -8
  186. package/dist/services/mcp-servers/admin/admin-params.mjs +0 -0
  187. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.d.ts +3 -2
  188. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.js +7 -7
  189. package/dist/services/mcp-servers/admin/use-cases/create-internal-mcp.use-case.mjs +4 -4
  190. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.d.ts +3 -2
  191. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.js +7 -7
  192. package/dist/services/mcp-servers/admin/use-cases/delete-internal-mcp.use-case.mjs +4 -4
  193. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.d.ts +3 -2
  194. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.js +7 -7
  195. package/dist/services/mcp-servers/admin/use-cases/get-internal-mcp-by-id.use-case.mjs +4 -4
  196. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.d.ts +4 -3
  197. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.js +7 -7
  198. package/dist/services/mcp-servers/admin/use-cases/list-internal-mcps.use-case.mjs +4 -4
  199. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.d.ts +3 -2
  200. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.js +8 -9
  201. package/dist/services/mcp-servers/admin/use-cases/update-internal-mcp.use-case.mjs +4 -5
  202. package/dist/services/mcp-servers/entities/mcpserver.entity.d.ts +1 -1
  203. package/dist/services/mcp-servers/entities/mcpserver.entity.js +2 -2
  204. package/dist/services/mcp-servers/entities/mcpserver.entity.mjs +1 -1
  205. package/dist/services/mcp-servers/repositories/mcpserver.repository.d.ts +1 -1
  206. package/dist/services/mcp-servers/repositories/mcpserver.repository.js +6 -7
  207. package/dist/services/mcp-servers/repositories/mcpserver.repository.mjs +2 -3
  208. package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.d.ts +1 -1
  209. package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.js +8 -8
  210. package/dist/services/mcp-servers/use-cases/create-mcpserver.use-case.mjs +5 -5
  211. package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.d.ts +1 -1
  212. package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.js +7 -7
  213. package/dist/services/mcp-servers/use-cases/decide-mcpserver-trust.use-case.mjs +4 -4
  214. package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.d.ts +1 -1
  215. package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.js +8 -8
  216. package/dist/services/mcp-servers/use-cases/delete-mcpserver.use-case.mjs +5 -5
  217. package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.d.ts +1 -1
  218. package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.js +7 -7
  219. package/dist/services/mcp-servers/use-cases/get-mcpserver-by-id.use-case.mjs +4 -4
  220. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.d.ts +1 -1
  221. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.js +8 -8
  222. package/dist/services/mcp-servers/use-cases/list-all-mcpservers-by-user.use-case.mjs +5 -5
  223. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.d.ts +2 -2
  224. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.js +8 -8
  225. package/dist/services/mcp-servers/use-cases/list-mcpservers-by-user.use-case.mjs +5 -5
  226. package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.d.ts +1 -1
  227. package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.js +9 -10
  228. package/dist/services/mcp-servers/use-cases/update-mcpserver.use-case.mjs +5 -6
  229. package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.d.ts +1 -1
  230. package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.js +9 -10
  231. package/dist/services/mcp-servers/use-cases/verify-mcpserver-connection.use-case.mjs +4 -5
  232. package/dist/services/tasks/entities/agent-action.entity.d.ts +1 -1
  233. package/dist/services/tasks/entities/agent-action.entity.js +6 -7
  234. package/dist/services/tasks/entities/agent-action.entity.mjs +1 -2
  235. package/dist/services/tasks/entities/agent-task.entity.d.ts +1 -1
  236. package/dist/services/tasks/entities/agent-task.entity.js +4 -4
  237. package/dist/services/tasks/entities/agent-task.entity.mjs +1 -1
  238. package/dist/services/tasks/repositories/agent-action.repository.d.ts +1 -1
  239. package/dist/services/tasks/repositories/agent-action.repository.js +5 -6
  240. package/dist/services/tasks/repositories/agent-action.repository.mjs +2 -3
  241. package/dist/services/tasks/repositories/agent-task.repository.d.ts +1 -1
  242. package/dist/services/tasks/repositories/agent-task.repository.js +5 -6
  243. package/dist/services/tasks/repositories/agent-task.repository.mjs +2 -3
  244. package/dist/services/tasks/use-cases/create-agent-action.use-case.d.ts +1 -1
  245. package/dist/services/tasks/use-cases/create-agent-action.use-case.js +7 -7
  246. package/dist/services/tasks/use-cases/create-agent-action.use-case.mjs +4 -4
  247. package/dist/services/tasks/use-cases/create-agent-task.use-case.d.ts +1 -1
  248. package/dist/services/tasks/use-cases/create-agent-task.use-case.js +7 -7
  249. package/dist/services/tasks/use-cases/create-agent-task.use-case.mjs +4 -4
  250. package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.d.ts +1 -1
  251. package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.js +7 -7
  252. package/dist/services/tasks/use-cases/get-agent-task-by-id.use-case.mjs +4 -4
  253. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.d.ts +2 -2
  254. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.js +9 -10
  255. package/dist/services/tasks/use-cases/list-agent-actions-by-task.use-case.mjs +6 -7
  256. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.d.ts +2 -2
  257. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.js +9 -10
  258. package/dist/services/tasks/use-cases/list-agent-tasks-by-chat.use-case.mjs +6 -7
  259. package/dist/services/tasks/use-cases/update-agent-action.use-case.d.ts +1 -1
  260. package/dist/services/tasks/use-cases/update-agent-action.use-case.js +7 -7
  261. package/dist/services/tasks/use-cases/update-agent-action.use-case.mjs +4 -4
  262. package/dist/services/tasks/use-cases/update-agent-task.use-case.d.ts +1 -1
  263. package/dist/services/tasks/use-cases/update-agent-task.use-case.js +7 -7
  264. package/dist/services/tasks/use-cases/update-agent-task.use-case.mjs +4 -4
  265. package/dist/services/traces/entities/agent-trace-entry.entity.d.ts +1 -1
  266. package/dist/services/traces/entities/agent-trace-entry.entity.js +6 -6
  267. package/dist/services/traces/entities/agent-trace-entry.entity.mjs +1 -1
  268. package/dist/services/traces/repositories/agent-trace.repository.d.ts +1 -1
  269. package/dist/services/traces/repositories/agent-trace.repository.js +4 -4
  270. package/dist/services/traces/repositories/agent-trace.repository.mjs +2 -2
  271. package/dist/services/traces/use-cases/create-agent-traces.use-case.d.ts +1 -1
  272. package/dist/services/traces/use-cases/create-agent-traces.use-case.js +7 -7
  273. package/dist/services/traces/use-cases/create-agent-traces.use-case.mjs +4 -4
  274. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.d.ts +2 -2
  275. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.js +12 -13
  276. package/dist/services/traces/use-cases/list-agent-traces-by-chat.use-case.mjs +6 -7
  277. package/dist/services/workspaces/entities/workspace-item.entity.d.ts +1 -1
  278. package/dist/services/workspaces/entities/workspace-item.entity.js +5 -5
  279. package/dist/services/workspaces/entities/workspace-item.entity.mjs +1 -1
  280. package/dist/services/workspaces/repositories/workspace-item.repository.d.ts +1 -1
  281. package/dist/services/workspaces/repositories/workspace-item.repository.js +5 -6
  282. package/dist/services/workspaces/repositories/workspace-item.repository.mjs +2 -3
  283. package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.d.ts +1 -1
  284. package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.js +11 -12
  285. package/dist/services/workspaces/use-cases/delete-workspace-item.use-case.mjs +6 -7
  286. package/dist/services/workspaces/use-cases/get-workspace-item.use-case.d.ts +1 -1
  287. package/dist/services/workspaces/use-cases/get-workspace-item.use-case.js +11 -12
  288. package/dist/services/workspaces/use-cases/get-workspace-item.use-case.mjs +6 -7
  289. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.d.ts +2 -2
  290. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.js +11 -12
  291. package/dist/services/workspaces/use-cases/list-workspace-items.use-case.mjs +6 -7
  292. package/dist/services/workspaces/use-cases/save-workspace-item.use-case.d.ts +1 -1
  293. package/dist/services/workspaces/use-cases/save-workspace-item.use-case.js +10 -11
  294. package/dist/services/workspaces/use-cases/save-workspace-item.use-case.mjs +6 -7
  295. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.d.ts +2 -2
  296. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.js +11 -12
  297. package/dist/services/workspaces/use-cases/search-workspace-items.use-case.mjs +6 -7
  298. package/dist/skills/runtime-context.d.ts +3 -3
  299. package/dist/skills/runtime-context.js +24 -21
  300. package/dist/skills/runtime-context.mjs +24 -21
  301. package/dist/skills/skill.d.ts +3 -3
  302. package/dist/skills/skill.js +5 -5
  303. package/dist/skills/skill.mjs +4 -4
  304. package/dist/tools/core/call-ai/call-ai.tool.js +2 -2
  305. package/dist/tools/core/call-ai/call-ai.tool.mjs +2 -2
  306. package/dist/tools/core/web-search/web-search.tool.js +1 -1
  307. package/dist/tools/core/web-search/web-search.tool.mjs +1 -1
  308. package/dist/tools/tool.d.ts +2 -2
  309. package/dist/tools/tool.js +1 -1
  310. package/dist/tools/tool.mjs +1 -1
  311. package/docs/README.md +1 -1
  312. package/docs/agent.md +10 -10
  313. package/docs/authentication.md +15 -114
  314. package/docs/authorization.md +18 -18
  315. package/docs/automations.md +30 -28
  316. package/docs/chats.md +14 -14
  317. package/docs/configuration.md +14 -15
  318. package/docs/error-reporting.md +6 -6
  319. package/docs/guardrails.md +1 -1
  320. package/docs/integration-guide.md +12 -12
  321. package/docs/loops.md +2 -2
  322. package/docs/mcp-servers.md +15 -15
  323. package/docs/skills.md +1 -1
  324. package/docs/tools.md +2 -2
  325. package/docs/usage.md +5 -5
  326. package/docs/users.md +18 -91
  327. package/examples/automations/create-automation.ts +4 -4
  328. package/examples/automations/create-event-automation.ts +5 -5
  329. package/examples/automations/list-automation-runs.ts +7 -7
  330. package/examples/automations/list-automations.ts +4 -4
  331. package/examples/automations/preview-automation-runs.ts +1 -1
  332. package/examples/automations/receive-automation-event.ts +1 -1
  333. package/examples/automations/revoke-automation-event-token.ts +6 -6
  334. package/examples/automations/run-automation-now.ts +4 -4
  335. package/examples/automations/run-automation-worker.ts +1 -1
  336. package/examples/automations/update-automation.ts +6 -6
  337. package/examples/chats/delete-chat.ts +6 -6
  338. package/examples/chats/get-chat-by-id.ts +6 -6
  339. package/examples/chats/list-autonomous-chats.ts +4 -4
  340. package/examples/chats/list-chats.ts +4 -4
  341. package/examples/chats/search-chats.ts +5 -5
  342. package/examples/errors/error-reporting.ts +6 -6
  343. package/examples/loops/custom-loop.ts +5 -5
  344. package/examples/mcps/create-mcp.ts +4 -4
  345. package/examples/mcps/decide-mcp.ts +7 -7
  346. package/examples/mcps/delete-mcp.ts +6 -6
  347. package/examples/mcps/get-mcp-by-id.ts +4 -4
  348. package/examples/mcps/internal-mcp-admin.ts +8 -8
  349. package/examples/mcps/internal-mcp.ts +5 -5
  350. package/examples/mcps/list-all-mcps.ts +4 -4
  351. package/examples/mcps/list-user-mcps.ts +4 -4
  352. package/examples/mcps/update-mcp.ts +4 -4
  353. package/examples/mcps/verify-mcp.ts +4 -4
  354. package/examples/run-agent/interrupt-agent.ts +5 -5
  355. package/examples/run-agent/run-agent-autonomous.ts +5 -5
  356. package/examples/run-agent/run-agent-multi-tenant.ts +10 -11
  357. package/examples/run-agent/run-agent-strict-mode.ts +5 -5
  358. package/examples/run-agent/run-agent-with-confirmation.ts +6 -6
  359. package/examples/run-agent/run-agent-with-fallback-model.ts +5 -5
  360. package/examples/run-agent/run-agent-with-fetch-url.ts +5 -5
  361. package/examples/run-agent/run-agent-with-guards.ts +5 -5
  362. package/examples/run-agent/run-agent-with-hooks.ts +5 -5
  363. package/examples/run-agent/run-agent-with-identity.ts +5 -5
  364. package/examples/run-agent/run-agent-with-model.ts +5 -5
  365. package/examples/run-agent/run-agent-with-slack.ts +5 -5
  366. package/examples/run-agent/run-agent-with-tools.ts +5 -5
  367. package/examples/run-agent/run-agent-with-usage-limit-stop.ts +5 -5
  368. package/examples/run-agent/run-agent-with-usage-limit.ts +5 -5
  369. package/examples/tools/basic-tool.ts +1 -1
  370. package/examples/tools/web-search-tool.ts +1 -1
  371. package/examples/usage/get-chat-usage.ts +4 -4
  372. package/examples/usage/get-message-usage.ts +4 -4
  373. package/examples/usage/get-usage-stats-by-range.ts +4 -4
  374. package/examples/usage/get-usage-stats.ts +4 -4
  375. package/examples/users/set-default-model.ts +12 -21
  376. package/package.json +7 -22
  377. package/dist/common/base/base.app.d.ts +0 -12
  378. package/dist/common/base/base.app.js +0 -57
  379. package/dist/common/base/base.app.mjs +0 -33
  380. package/dist/common/base/base.entity.d.ts +0 -38
  381. package/dist/common/base/base.entity.js +0 -100
  382. package/dist/common/base/base.entity.mjs +0 -76
  383. package/dist/common/base/base.use-case.d.ts +0 -11
  384. package/dist/common/base/base.use-case.js +0 -30
  385. package/dist/common/base/base.use-case.mjs +0 -6
  386. package/dist/common/base/current-session.d.ts +0 -129
  387. package/dist/common/base/current-session.js +0 -123
  388. package/dist/common/base/current-session.mjs +0 -98
  389. package/dist/common/base/current-user.d.ts +0 -16
  390. package/dist/common/base/current-user.js +0 -85
  391. package/dist/common/base/current-user.mjs +0 -61
  392. package/dist/common/base/index.d.ts +0 -3
  393. package/dist/common/base/index.js +0 -26
  394. package/dist/common/base/index.mjs +0 -3
  395. package/dist/common/base/share.d.ts +0 -12
  396. package/dist/common/base/share.js +0 -45
  397. package/dist/common/base/share.mjs +0 -20
  398. package/dist/common/base/utils/index.d.ts +0 -2
  399. package/dist/common/base/utils/index.js +0 -24
  400. package/dist/common/base/utils/index.mjs +0 -2
  401. package/dist/common/base/utils/is-plain-object.d.ts +0 -1
  402. package/dist/common/base/utils/is-plain-object.js +0 -32
  403. package/dist/common/base/utils/is-plain-object.mjs +0 -8
  404. package/dist/common/base/utils/to-patch.d.ts +0 -9
  405. package/dist/common/base/utils/to-patch.js +0 -46
  406. package/dist/common/base/utils/to-patch.mjs +0 -21
  407. package/dist/common/error/error-reporter.d.ts +0 -11
  408. package/dist/common/error/error-reporter.mjs +0 -11
  409. package/dist/common/error/http-error.d.ts +0 -11
  410. package/dist/common/error/http-error.js +0 -37
  411. package/dist/common/error/http-error.mjs +0 -13
  412. package/dist/common/error/index.d.ts +0 -3
  413. package/dist/common/error/index.js +0 -26
  414. package/dist/common/error/index.mjs +0 -3
  415. package/dist/common/error/reportError.d.ts +0 -2
  416. package/dist/common/error/reportError.js +0 -61
  417. package/dist/common/error/reportError.mjs +0 -37
  418. package/dist/common/error/sentry-client.d.ts +0 -10
  419. package/dist/common/error/sentry-client.js +0 -82
  420. package/dist/common/error/sentry-client.mjs +0 -57
  421. package/dist/common/index.d.ts +0 -6
  422. package/dist/common/index.js +0 -37
  423. package/dist/common/index.mjs +0 -9
  424. package/dist/common/logger/index.d.ts +0 -1
  425. package/dist/common/logger/index.mjs +0 -1
  426. package/dist/common/logger/pino.d.ts +0 -12
  427. package/dist/common/logger/pino.js +0 -79
  428. package/dist/common/logger/pino.mjs +0 -44
  429. package/dist/common/repositories/index.d.ts +0 -3
  430. package/dist/common/repositories/index.js +0 -26
  431. package/dist/common/repositories/index.mjs +0 -3
  432. package/dist/common/repositories/mongo-db.client.d.ts +0 -11
  433. package/dist/common/repositories/mongo-db.client.js +0 -83
  434. package/dist/common/repositories/mongo-db.client.mjs +0 -60
  435. package/dist/common/repositories/mongo-db.repository.d.ts +0 -130
  436. package/dist/common/repositories/mongo-db.repository.js +0 -357
  437. package/dist/common/repositories/mongo-db.repository.mjs +0 -332
  438. package/dist/common/repositories/scope.d.ts +0 -19
  439. package/dist/common/repositories/scope.js +0 -63
  440. package/dist/common/repositories/scope.mjs +0 -39
  441. package/dist/common/utils/config-context.d.ts +0 -3
  442. package/dist/common/utils/config-context.js +0 -33
  443. package/dist/common/utils/config-context.mjs +0 -8
  444. package/dist/common/utils/database-name.d.ts +0 -2
  445. package/dist/common/utils/database-name.js +0 -32
  446. package/dist/common/utils/database-name.mjs +0 -7
  447. package/dist/common/utils/secret-manager.d.ts +0 -17
  448. package/dist/common/utils/secret-manager.js +0 -124
  449. package/dist/common/utils/secret-manager.mjs +0 -89
  450. package/dist/db/indexes/refresh-tokens.d.ts +0 -2
  451. package/dist/db/indexes/refresh-tokens.js +0 -33
  452. package/dist/db/indexes/refresh-tokens.mjs +0 -9
  453. package/dist/db/indexes/revoked-tokens.d.ts +0 -2
  454. package/dist/db/indexes/revoked-tokens.js +0 -31
  455. package/dist/db/indexes/revoked-tokens.mjs +0 -7
  456. package/dist/services/authentication/entities/index.d.ts +0 -2
  457. package/dist/services/authentication/entities/index.js +0 -24
  458. package/dist/services/authentication/entities/index.mjs +0 -2
  459. package/dist/services/authentication/entities/refresh-token.entity.d.ts +0 -25
  460. package/dist/services/authentication/entities/refresh-token.entity.js +0 -75
  461. package/dist/services/authentication/entities/refresh-token.entity.mjs +0 -51
  462. package/dist/services/authentication/entities/revoked-token.entity.d.ts +0 -17
  463. package/dist/services/authentication/entities/revoked-token.entity.js +0 -67
  464. package/dist/services/authentication/entities/revoked-token.entity.mjs +0 -43
  465. package/dist/services/authentication/helpers/auth-config.d.ts +0 -9
  466. package/dist/services/authentication/helpers/auth-config.js +0 -36
  467. package/dist/services/authentication/helpers/auth-config.mjs +0 -12
  468. package/dist/services/authentication/helpers/session-tokens.d.ts +0 -16
  469. package/dist/services/authentication/helpers/session-tokens.js +0 -60
  470. package/dist/services/authentication/helpers/session-tokens.mjs +0 -35
  471. package/dist/services/authentication/helpers/tokens.d.ts +0 -43
  472. package/dist/services/authentication/helpers/tokens.js +0 -113
  473. package/dist/services/authentication/helpers/tokens.mjs +0 -71
  474. package/dist/services/authentication/index.d.ts +0 -5
  475. package/dist/services/authentication/index.js +0 -47
  476. package/dist/services/authentication/index.mjs +0 -13
  477. package/dist/services/authentication/module.d.ts +0 -16
  478. package/dist/services/authentication/module.js +0 -81
  479. package/dist/services/authentication/module.mjs +0 -50
  480. package/dist/services/authentication/repositories/index.d.ts +0 -2
  481. package/dist/services/authentication/repositories/index.js +0 -24
  482. package/dist/services/authentication/repositories/index.mjs +0 -2
  483. package/dist/services/authentication/repositories/refresh-token.repository.d.ts +0 -10
  484. package/dist/services/authentication/repositories/refresh-token.repository.js +0 -60
  485. package/dist/services/authentication/repositories/refresh-token.repository.mjs +0 -36
  486. package/dist/services/authentication/repositories/revoked-token.repository.d.ts +0 -7
  487. package/dist/services/authentication/repositories/revoked-token.repository.js +0 -44
  488. package/dist/services/authentication/repositories/revoked-token.repository.mjs +0 -20
  489. package/dist/services/authentication/use-cases/claim-refresh-token.use-case.d.ts +0 -12
  490. package/dist/services/authentication/use-cases/claim-refresh-token.use-case.js +0 -40
  491. package/dist/services/authentication/use-cases/claim-refresh-token.use-case.mjs +0 -16
  492. package/dist/services/authentication/use-cases/create-refresh-token.use-case.d.ts +0 -11
  493. package/dist/services/authentication/use-cases/create-refresh-token.use-case.js +0 -43
  494. package/dist/services/authentication/use-cases/create-refresh-token.use-case.mjs +0 -19
  495. package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.d.ts +0 -11
  496. package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.js +0 -40
  497. package/dist/services/authentication/use-cases/find-refresh-token-by-hash.use-case.mjs +0 -16
  498. package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +0 -13
  499. package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +0 -42
  500. package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +0 -18
  501. package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.d.ts +0 -18
  502. package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.js +0 -49
  503. package/dist/services/authentication/use-cases/issue-password-reset-token.use-case.mjs +0 -25
  504. package/dist/services/authentication/use-cases/issue-session.use-case.d.ts +0 -13
  505. package/dist/services/authentication/use-cases/issue-session.use-case.js +0 -48
  506. package/dist/services/authentication/use-cases/issue-session.use-case.mjs +0 -24
  507. package/dist/services/authentication/use-cases/login.use-case.d.ts +0 -20
  508. package/dist/services/authentication/use-cases/login.use-case.js +0 -54
  509. package/dist/services/authentication/use-cases/login.use-case.mjs +0 -30
  510. package/dist/services/authentication/use-cases/logout.use-case.d.ts +0 -14
  511. package/dist/services/authentication/use-cases/logout.use-case.js +0 -48
  512. package/dist/services/authentication/use-cases/logout.use-case.mjs +0 -24
  513. package/dist/services/authentication/use-cases/refresh.use-case.d.ts +0 -23
  514. package/dist/services/authentication/use-cases/refresh.use-case.js +0 -84
  515. package/dist/services/authentication/use-cases/refresh.use-case.mjs +0 -60
  516. package/dist/services/authentication/use-cases/reset-password.use-case.d.ts +0 -15
  517. package/dist/services/authentication/use-cases/reset-password.use-case.js +0 -61
  518. package/dist/services/authentication/use-cases/reset-password.use-case.mjs +0 -37
  519. package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.d.ts +0 -11
  520. package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.js +0 -40
  521. package/dist/services/authentication/use-cases/revoke-refresh-token-family.use-case.mjs +0 -16
  522. package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +0 -12
  523. package/dist/services/authentication/use-cases/revoke-token.use-case.js +0 -52
  524. package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +0 -28
  525. package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.d.ts +0 -13
  526. package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.js +0 -40
  527. package/dist/services/authentication/use-cases/revoke-user-refresh-tokens.use-case.mjs +0 -16
  528. package/dist/services/users/entities/index.d.ts +0 -1
  529. package/dist/services/users/entities/index.js +0 -22
  530. package/dist/services/users/entities/index.mjs +0 -1
  531. package/dist/services/users/entities/user-acquisition.d.ts +0 -12
  532. package/dist/services/users/entities/user-acquisition.js +0 -42
  533. package/dist/services/users/entities/user-acquisition.mjs +0 -18
  534. package/dist/services/users/entities/user-country.d.ts +0 -11
  535. package/dist/services/users/entities/user-country.js +0 -44
  536. package/dist/services/users/entities/user-country.mjs +0 -20
  537. package/dist/services/users/entities/user-currency.d.ts +0 -13
  538. package/dist/services/users/entities/user-currency.js +0 -44
  539. package/dist/services/users/entities/user-currency.mjs +0 -20
  540. package/dist/services/users/entities/user-default-model.d.ts +0 -11
  541. package/dist/services/users/entities/user-default-model.js +0 -42
  542. package/dist/services/users/entities/user-default-model.mjs +0 -18
  543. package/dist/services/users/entities/user-email.value-object.d.ts +0 -6
  544. package/dist/services/users/entities/user-email.value-object.js +0 -43
  545. package/dist/services/users/entities/user-email.value-object.mjs +0 -19
  546. package/dist/services/users/entities/user-language.d.ts +0 -11
  547. package/dist/services/users/entities/user-language.js +0 -44
  548. package/dist/services/users/entities/user-language.mjs +0 -20
  549. package/dist/services/users/entities/user-marketing.d.ts +0 -9
  550. package/dist/services/users/entities/user-marketing.js +0 -40
  551. package/dist/services/users/entities/user-marketing.mjs +0 -16
  552. package/dist/services/users/entities/user-notification-preferences.d.ts +0 -11
  553. package/dist/services/users/entities/user-notification-preferences.js +0 -41
  554. package/dist/services/users/entities/user-notification-preferences.mjs +0 -17
  555. package/dist/services/users/entities/user-password.value-object.d.ts +0 -8
  556. package/dist/services/users/entities/user-password.value-object.js +0 -69
  557. package/dist/services/users/entities/user-password.value-object.mjs +0 -35
  558. package/dist/services/users/entities/user-permissions.d.ts +0 -21
  559. package/dist/services/users/entities/user-permissions.js +0 -59
  560. package/dist/services/users/entities/user-permissions.mjs +0 -35
  561. package/dist/services/users/entities/user-preferences.d.ts +0 -28
  562. package/dist/services/users/entities/user-preferences.js +0 -74
  563. package/dist/services/users/entities/user-preferences.mjs +0 -50
  564. package/dist/services/users/entities/user-report-preferences.d.ts +0 -16
  565. package/dist/services/users/entities/user-report-preferences.js +0 -56
  566. package/dist/services/users/entities/user-report-preferences.mjs +0 -32
  567. package/dist/services/users/entities/user-report-schedule.d.ts +0 -11
  568. package/dist/services/users/entities/user-report-schedule.js +0 -41
  569. package/dist/services/users/entities/user-report-schedule.mjs +0 -17
  570. package/dist/services/users/entities/user-timezone.d.ts +0 -11
  571. package/dist/services/users/entities/user-timezone.js +0 -44
  572. package/dist/services/users/entities/user-timezone.mjs +0 -20
  573. package/dist/services/users/entities/user.entity.d.ts +0 -42
  574. package/dist/services/users/entities/user.entity.js +0 -117
  575. package/dist/services/users/entities/user.entity.mjs +0 -92
  576. package/dist/services/users/index.d.ts +0 -3
  577. package/dist/services/users/index.js +0 -26
  578. package/dist/services/users/index.mjs +0 -3
  579. package/dist/services/users/module.d.ts +0 -12
  580. package/dist/services/users/module.js +0 -67
  581. package/dist/services/users/module.mjs +0 -38
  582. package/dist/services/users/repositories/index.d.ts +0 -1
  583. package/dist/services/users/repositories/index.js +0 -22
  584. package/dist/services/users/repositories/index.mjs +0 -1
  585. package/dist/services/users/repositories/user.repository.d.ts +0 -18
  586. package/dist/services/users/repositories/user.repository.js +0 -88
  587. package/dist/services/users/repositories/user.repository.mjs +0 -64
  588. package/dist/services/users/use-cases/change-password.use-case.d.ts +0 -15
  589. package/dist/services/users/use-cases/change-password.use-case.js +0 -52
  590. package/dist/services/users/use-cases/change-password.use-case.mjs +0 -28
  591. package/dist/services/users/use-cases/create-user.use-case.d.ts +0 -12
  592. package/dist/services/users/use-cases/create-user.use-case.js +0 -49
  593. package/dist/services/users/use-cases/create-user.use-case.mjs +0 -25
  594. package/dist/services/users/use-cases/delete-user.use-case.d.ts +0 -16
  595. package/dist/services/users/use-cases/delete-user.use-case.js +0 -48
  596. package/dist/services/users/use-cases/delete-user.use-case.mjs +0 -24
  597. package/dist/services/users/use-cases/get-user-by-id.use-case.d.ts +0 -12
  598. package/dist/services/users/use-cases/get-user-by-id.use-case.js +0 -43
  599. package/dist/services/users/use-cases/get-user-by-id.use-case.mjs +0 -19
  600. package/dist/services/users/use-cases/list-users-by-props.use-case.d.ts +0 -17
  601. package/dist/services/users/use-cases/list-users-by-props.use-case.js +0 -42
  602. package/dist/services/users/use-cases/list-users-by-props.use-case.mjs +0 -18
  603. package/dist/services/users/use-cases/update-user.use-case.d.ts +0 -13
  604. package/dist/services/users/use-cases/update-user.use-case.js +0 -53
  605. package/dist/services/users/use-cases/update-user.use-case.mjs +0 -29
  606. package/dist/services/users/utils/default-model.d.ts +0 -6
  607. package/dist/services/users/utils/default-model.js +0 -38
  608. package/dist/services/users/utils/default-model.mjs +0 -14
  609. package/examples/authentication/login.ts +0 -22
  610. package/examples/users/create-user.ts +0 -25
  611. package/examples/users/delete-user.ts +0 -42
  612. package/examples/users/get-user-by-id.ts +0 -21
  613. package/examples/users/list-users.ts +0 -22
  614. package/examples/users/update-user.ts +0 -25
@@ -1,36 +1,39 @@
1
+ import { localeOf } from "nanosaas/common";
2
+ import { buildUserContext } from "nanosaas/users";
1
3
  function buildRuntimeContext(params) {
2
- const { currentUser, currentSession, chat } = params;
3
- const currentCountryCode = currentSession?.location?.country;
4
- const currentCurrencyCode = currentSession?.currencyCode;
4
+ const { actor, requestContext, chat } = params;
5
5
  const now = /* @__PURE__ */ new Date();
6
- const timezone = currentSession?.location?.timezone;
7
- const nowLocal = timezone ? now.toLocaleString("sv-SE", { timeZone: timezone }) : void 0;
6
+ const profile = actor?.profile;
7
+ const context = buildUserContext(profile?.preferences, requestContext, now);
8
+ const here = localeOf(requestContext);
8
9
  return {
9
- now_utc: now.toISOString(),
10
- now_local: nowLocal,
11
- timezone,
10
+ now_utc: context.now.utcNow,
11
+ now_local: context.now.localTime,
12
+ timezone: context.now.timezone,
12
13
  day_of_week: now.toLocaleDateString("en-US", { weekday: "long" }),
13
14
  ...chat?.state?.language ? { detected_language: chat.state.language } : {},
14
- ...currentUser ? {
15
+ ...actor ? {
15
16
  user_details: {
16
- first_name: currentUser?.firstName,
17
- last_name: currentUser?.lastName,
18
- preferred_language: currentUser?.language,
19
- residence_country_code: currentUser?.preferences?.country?.isoCode,
20
- preferred_currency_code: currentUser?.preferences?.currency?.isoCode
17
+ first_name: profile?.firstName,
18
+ last_name: profile?.lastName,
19
+ preferred_language: context.home.language,
20
+ residence_country_code: context.home.country,
21
+ residence_timezone: context.home.timezone,
22
+ preferred_currency_code: context.home.currency
21
23
  }
22
24
  } : {},
23
- ...currentSession ? {
25
+ ...requestContext ? {
24
26
  session_details: {
25
27
  current_location: {
26
- country_code: currentCountryCode,
27
- currency_code: currentCurrencyCode,
28
- timezone_offset: currentSession?.timezoneOffset
28
+ country_code: context.now.country,
29
+ currency_code: here.currency?.isoCode,
30
+ timezone_offset: requestContext.timezoneOffset,
31
+ away_from_home: context.away
29
32
  },
30
33
  client_info: {
31
- platform: currentSession?.device?.os,
32
- brand: currentSession?.device?.brand,
33
- model: currentSession?.device?.model
34
+ platform: requestContext.client.device?.os,
35
+ brand: requestContext.client.device?.brand,
36
+ model: requestContext.client.device?.model
34
37
  }
35
38
  }
36
39
  } : {}
@@ -1,5 +1,5 @@
1
1
  import { LLMMessage, LLMToolDefinition, ThinkingEffort } from '../clients/llm/llm-types.js';
2
- import { CurrentUser, CurrentSession } from '../common/base/index.js';
2
+ import { ActorLike, RequestContext } from 'nanosaas/common';
3
3
  import type { Chat } from '../services/chats/entities/chat.entity.js';
4
4
  import { SkillMode } from './call-modes';
5
5
  export { SkillMode, DEFAULT_SKILL_MODE } from './call-modes';
@@ -23,8 +23,8 @@ export interface SkillRunOptions<TInput = Record<string, any>> {
23
23
  sessionId: string;
24
24
  answerId: string;
25
25
  userMessage?: string;
26
- currentUser?: CurrentUser;
27
- currentSession?: CurrentSession;
26
+ actor?: ActorLike;
27
+ requestContext?: RequestContext;
28
28
  contextInjection?: Record<string, any>;
29
29
  input?: TInput;
30
30
  chat?: Chat;
@@ -25,7 +25,7 @@ __export(skill_exports, {
25
25
  module.exports = __toCommonJS(skill_exports);
26
26
  var import_helpers = require("../common/helpers/index.js");
27
27
  var import_llm_client = require("../clients/llm/llm-client.js");
28
- var import_logger = require("../common/logger/index.js");
28
+ var import_common = require("nanosaas/common");
29
29
  var import_runtime_context = require("./runtime-context");
30
30
  var import_call_modes = require("./call-modes");
31
31
  var import_call_modes2 = require("./call-modes");
@@ -52,14 +52,14 @@ class Skill {
52
52
  this.mode = props.mode ?? import_call_modes.DEFAULT_SKILL_MODE;
53
53
  }
54
54
  async run(options) {
55
- const { provider, modelName, sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat, history = [], chatHistory = [], tools, mode = this.mode, thinking = this.thinking } = options;
55
+ const { provider, modelName, sessionId, answerId, userMessage, actor, requestContext, contextInjection = {}, input = {}, chat, history = [], chatHistory = [], tools, mode = this.mode, thinking = this.thinking } = options;
56
56
  const misplaced = RESERVED_CONTEXT_KEYS.filter((key) => key in contextInjection);
57
57
  if (misplaced.length) throw new Error(`[SKILL:${this.name}] ${misplaced.join(", ")} must be passed as run options, not inside contextInjection`);
58
58
  if (history.length && chatHistory.length) throw new Error(`[SKILL:${this.name}] history and chatHistory cannot be used together`);
59
59
  try {
60
60
  const llmClient = new import_llm_client.LLMClient();
61
61
  const context = {
62
- ...(0, import_runtime_context.buildRuntimeContext)({ currentUser, currentSession, chat }),
62
+ ...(0, import_runtime_context.buildRuntimeContext)({ actor, requestContext, chat }),
63
63
  ...contextInjection
64
64
  };
65
65
  const inputPayload = {
@@ -76,7 +76,7 @@ class Skill {
76
76
  sessionId,
77
77
  answerId,
78
78
  origin: this.name,
79
- currentUser,
79
+ actor,
80
80
  messages: call.messages,
81
81
  tools: call.tools,
82
82
  toolChoice: call.toolChoice,
@@ -86,7 +86,7 @@ class Skill {
86
86
  const reading = (0, import_call_modes.readModeResponse)(mode, this.name, response, { expectActions: Boolean(tools?.length) });
87
87
  if (reading.blocks > 1) {
88
88
  const note = `The model sent ${reading.blocks} text blocks; block ${reading.chosen + 1} was used and the rest were discarded`;
89
- new import_logger.Logger().warn({ skill: this.name, model: response.model, blocks: reading.blocks, chosen: reading.chosen }, `[SKILL:${this.name}] ${note}`);
89
+ new import_common.Logger().warn({ skill: this.name, model: response.model, blocks: reading.blocks, chosen: reading.chosen }, `[SKILL:${this.name}] ${note}`);
90
90
  chat?.addTrace({ node: this.name, reasoning: note });
91
91
  }
92
92
  const parsed = this.parseJsonResponse(reading.text);
@@ -1,6 +1,6 @@
1
1
  import { extractJSON } from "../common/helpers/index.js";
2
2
  import { LLMClient } from "../clients/llm/llm-client.js";
3
- import { Logger } from "../common/logger/index.js";
3
+ import { Logger } from "nanosaas/common";
4
4
  import { buildRuntimeContext } from "./runtime-context";
5
5
  import { DEFAULT_SKILL_MODE, buildModeCall, readModeResponse } from "./call-modes";
6
6
  import { SkillMode as SkillMode2, DEFAULT_SKILL_MODE as DEFAULT_SKILL_MODE2 } from "./call-modes";
@@ -27,14 +27,14 @@ class Skill {
27
27
  this.mode = props.mode ?? DEFAULT_SKILL_MODE;
28
28
  }
29
29
  async run(options) {
30
- const { provider, modelName, sessionId, answerId, userMessage, currentUser, currentSession, contextInjection = {}, input = {}, chat, history = [], chatHistory = [], tools, mode = this.mode, thinking = this.thinking } = options;
30
+ const { provider, modelName, sessionId, answerId, userMessage, actor, requestContext, contextInjection = {}, input = {}, chat, history = [], chatHistory = [], tools, mode = this.mode, thinking = this.thinking } = options;
31
31
  const misplaced = RESERVED_CONTEXT_KEYS.filter((key) => key in contextInjection);
32
32
  if (misplaced.length) throw new Error(`[SKILL:${this.name}] ${misplaced.join(", ")} must be passed as run options, not inside contextInjection`);
33
33
  if (history.length && chatHistory.length) throw new Error(`[SKILL:${this.name}] history and chatHistory cannot be used together`);
34
34
  try {
35
35
  const llmClient = new LLMClient();
36
36
  const context = {
37
- ...buildRuntimeContext({ currentUser, currentSession, chat }),
37
+ ...buildRuntimeContext({ actor, requestContext, chat }),
38
38
  ...contextInjection
39
39
  };
40
40
  const inputPayload = {
@@ -51,7 +51,7 @@ class Skill {
51
51
  sessionId,
52
52
  answerId,
53
53
  origin: this.name,
54
- currentUser,
54
+ actor,
55
55
  messages: call.messages,
56
56
  tools: call.tools,
57
57
  toolChoice: call.toolChoice,
@@ -46,7 +46,7 @@ const callAiTool = new import_tool.Tool({
46
46
  required: ["instructions", "input_data"]
47
47
  },
48
48
  handler: async (params) => {
49
- const { payload, currentUser, sessionId, answerId } = params;
49
+ const { payload, actor, sessionId, answerId } = params;
50
50
  const { instructions, input_data } = payload;
51
51
  if (!instructions) throw new Error("[call_ai_tool] Param instructions is required");
52
52
  if (!input_data) throw new Error("[call_ai_tool] Param input_data is required");
@@ -57,7 +57,7 @@ const callAiTool = new import_tool.Tool({
57
57
  contextInjection: {
58
58
  systemPrompt: instructions
59
59
  },
60
- currentUser
60
+ actor
61
61
  });
62
62
  return { data: result };
63
63
  }
@@ -23,7 +23,7 @@ const callAiTool = new Tool({
23
23
  required: ["instructions", "input_data"]
24
24
  },
25
25
  handler: async (params) => {
26
- const { payload, currentUser, sessionId, answerId } = params;
26
+ const { payload, actor, sessionId, answerId } = params;
27
27
  const { instructions, input_data } = payload;
28
28
  if (!instructions) throw new Error("[call_ai_tool] Param instructions is required");
29
29
  if (!input_data) throw new Error("[call_ai_tool] Param input_data is required");
@@ -34,7 +34,7 @@ const callAiTool = new Tool({
34
34
  contextInjection: {
35
35
  systemPrompt: instructions
36
36
  },
37
- currentUser
37
+ actor
38
38
  });
39
39
  return { data: result };
40
40
  }
@@ -41,7 +41,7 @@ const webSearchTool = new import_tool.Tool({
41
41
  },
42
42
  handler: async (params) => {
43
43
  if (!params) throw new Error("[web_search] params is required");
44
- const { currentUser, sessionId, answerId, ...rest } = params;
44
+ const { actor, sessionId, answerId, ...rest } = params;
45
45
  const serperClient = new import_serper_client.SerperClient();
46
46
  const results = await serperClient.searchOnGoogle(rest);
47
47
  return { data: results };
@@ -20,7 +20,7 @@ const webSearchTool = new Tool({
20
20
  },
21
21
  handler: async (params) => {
22
22
  if (!params) throw new Error("[web_search] params is required");
23
- const { currentUser, sessionId, answerId, ...rest } = params;
23
+ const { actor, sessionId, answerId, ...rest } = params;
24
24
  const serperClient = new SerperClient();
25
25
  const results = await serperClient.searchOnGoogle(rest);
26
26
  return { data: results };
@@ -1,6 +1,6 @@
1
1
  import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
2
  import type { Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
3
- import { CurrentUser } from '../common/base/index.js';
3
+ import { ActorLike } from 'nanosaas/common';
4
4
  interface InputSchema {
5
5
  type: 'object';
6
6
  properties: Record<string, {
@@ -20,7 +20,7 @@ interface Output {
20
20
  data: any;
21
21
  }
22
22
  export interface BaseParams {
23
- currentUser: CurrentUser;
23
+ actor: ActorLike;
24
24
  sessionId: string;
25
25
  answerId: string;
26
26
  }
@@ -124,7 +124,7 @@ class Tool {
124
124
  server: opts.namespace,
125
125
  notice: opts.internal ? void 0 : externalToolNotice(opts.namespace),
126
126
  handler: async (params = {}) => {
127
- const { currentUser, sessionId, answerId, ...args } = params;
127
+ const { actor, sessionId, answerId, ...args } = params;
128
128
  const timeoutMs = (0, import_number_setting.numberSetting)("MCP_TOOL_TIMEOUT_MS", DEFAULT_MCP_TOOL_TIMEOUT_MS);
129
129
  let result;
130
130
  try {
@@ -100,7 +100,7 @@ class Tool {
100
100
  server: opts.namespace,
101
101
  notice: opts.internal ? void 0 : externalToolNotice(opts.namespace),
102
102
  handler: async (params = {}) => {
103
- const { currentUser, sessionId, answerId, ...args } = params;
103
+ const { actor, sessionId, answerId, ...args } = params;
104
104
  const timeoutMs = numberSetting("MCP_TOOL_TIMEOUT_MS", DEFAULT_MCP_TOOL_TIMEOUT_MS);
105
105
  let result;
106
106
  try {
package/docs/README.md CHANGED
@@ -39,7 +39,7 @@ Start with the [README](../README.md) for what `openloops` is and how to run it.
39
39
 
40
40
  | Page | What it covers |
41
41
  | --- | --- |
42
- | [User management](users.md) | `CurrentUser`, creating, listing, updating and deleting users. |
42
+ | [User management](users.md) | `Actor`, creating, listing, updating and deleting users. |
43
43
  | [Authentication](authentication.md) | Login and tokens. |
44
44
  | [LLM usage tracking](usage.md) | Tokens and cost per chat or answer, per-user statistics, and how to limit the spend of a user. |
45
45
 
package/docs/agent.md CHANGED
@@ -54,8 +54,8 @@ const result = await agent.run({
54
54
  modelProvider: 'anthropic',
55
55
  modelName: 'claude-haiku-5-5',
56
56
  },
57
- currentUser,
58
- currentSession,
57
+ actor,
58
+ requestContext,
59
59
  })
60
60
  ```
61
61
 
@@ -72,7 +72,7 @@ Omit `chatId` to start a brand-new chat. Pass an existing `chatId` to continue a
72
72
  | `notifyOnCompletion` | Exposed as `agent.notifyOnCompletion` so a post execution hook can notify the user. |
73
73
  | `isPrivateSession` | Stored in the chat settings for your application to use. |
74
74
 
75
- `currentSession` is optional. It carries device, location and locale, which skills use to answer in the right time zone and language.
75
+ `requestContext` is optional. It carries device, location and locale, which skills use to answer in the right time zone and language.
76
76
 
77
77
  `mcpTokens` is optional. It gives the token of the user to each [internal MCP server](mcp-servers.md#internal-mcp-servers), by name. It is never saved. In an [autonomous run](#autonomous-mode) with no token for a server, the `autonomousToken` of that server is used, see [automations](automations.md#internal-mcp-servers-in-an-automation).
78
78
 
@@ -83,7 +83,7 @@ Pass `usageLimit` in the run to cap what a user can spend, in US dollars, in a p
83
83
  ```typescript
84
84
  const result = await agent.run({
85
85
  input: { message: 'hi' },
86
- currentUser,
86
+ actor,
87
87
  usageLimit: { maxCostUsd: 1, period: 'month' },
88
88
  })
89
89
  ```
@@ -113,7 +113,7 @@ const limits = {
113
113
 
114
114
  const result = await agent.run({
115
115
  input,
116
- currentUser,
116
+ actor,
117
117
  usageLimit: limits[userPays ? 'paid' : 'free'],
118
118
  })
119
119
 
@@ -132,11 +132,11 @@ An autonomous run is one where nobody is in the chat while the agent works, for
132
132
  await agent.run({
133
133
  input: { message: 'Every morning, summarize my open tickets' },
134
134
  options: { executionMode: 'autonomous' },
135
- currentUser,
135
+ actor,
136
136
  })
137
137
  ```
138
138
 
139
- `currentUser` is still required: it owns the chat and the MCP servers. What changes while a run is autonomous:
139
+ `actor` is still required: it owns the chat and the MCP servers. What changes while a run is autonomous:
140
140
 
141
141
  - The model is told that nobody is present, so it plans the whole task and writes a complete final answer.
142
142
  - Questions the model sends with `ask_user` are answered by an automatic evaluator, a skill that only knows the context of the task. The model receives the answer marked as automatic and is told to use its judgment. The evaluator never grants permissions and says it cannot decide when the context does not settle the question. At most 3 questions per task are answered this way.
@@ -157,7 +157,7 @@ To run an agent on a schedule, see [automations](automations.md).
157
157
  `agent.run` does not throw for failures inside the run. It returns:
158
158
 
159
159
  ```typescript
160
- const { data, error } = await agent.run({ input, currentUser })
160
+ const { data, error } = await agent.run({ input, actor })
161
161
 
162
162
  data?.lastAnswer
163
163
  data?.messages
@@ -263,7 +263,7 @@ const stop = agent.onActivity(activity => {
263
263
  stream.write(`event: activity\ndata: ${JSON.stringify({ activity })}\n\n`)
264
264
  })
265
265
 
266
- await agent.run({ input: { chatId, message }, currentUser })
266
+ await agent.run({ input: { chatId, message }, actor })
267
267
 
268
268
  stop()
269
269
  ```
@@ -279,7 +279,7 @@ The listener receives every change of the activity of the run while it is in pro
279
279
  ## Stopping a running turn
280
280
 
281
281
  ```typescript
282
- await Agent.interruptExecution(chatId, currentUser)
282
+ await Agent.interruptExecution(chatId, actor)
283
283
  ```
284
284
 
285
285
  Call it from a separate request while `agent.run()` is still executing, for example when the user presses stop. The running loop checks for the request before every node and stops cleanly. The next message in that chat starts again from the initial node of the loop.
@@ -1,136 +1,37 @@
1
1
  # Authentication
2
2
 
3
- `openloops` logs a user in against its own user records and issues the tokens of the session. It also issues the tokens to reset a password and the tokens of [event automations](automations.md#the-token), all with the same convention. Verifying the token on each request and deciding who may call what is up to your backend, with `verifySessionToken` to read it.
3
+ `openloops` does not log users in. Users, sessions, password reset and the tokens come from [`nanosaas`](https://www.npmjs.com/package/nanosaas), the package that `openloops` has as a peer dependency. Use its `authentication` module for `register`, `login`, `refreshSession`, `logout`, `recoverPassword` and `resetPassword`, and read its documentation for the rate limit, the sessions and the key rotation.
4
+
5
+ What `openloops` asks from your backend is an `actor` on every call. It reads the access token and builds it, without reading the database:
4
6
 
5
7
  ```typescript
6
- import { login, refreshSession, logout, issuePasswordResetToken, resetPassword, revokeUserSessions, revokeToken, isTokenRevoked, verifySessionToken } from 'openloops/authentication'
7
- import { changePassword } from 'openloops/users'
8
- ```
8
+ import { verifySessionToken } from 'nanosaas/authentication'
9
+ import { Actor } from 'nanosaas/common'
9
10
 
10
- `JWT_SECRET` must be set. See [configuration](configuration.md).
11
+ const claims = verifySessionToken(token)
12
+ const actor = Actor.fromClaims({ userId: claims.sub, sessionId: claims.sid })
13
+ ```
11
14
 
12
- **Rate limit is yours.** `openloops` does not limit the attempts to log in, to ask for a reset or to use a token. Your backend must do it before it calls `login` and `issuePasswordResetToken`, by account and by address, and answer 429 when the limit is reached.
15
+ `verifySessionToken` throws a `TokenError` whose `reason` is `invalid` or `expired`. It refuses a token of another audience, so a reset token or an event token cannot be used as a session. See [users](users.md) for what the agent does with the `actor`.
13
16
 
14
17
  ## The tokens
15
18
 
16
- Every token is a JWT signed with `HS256` and `JWT_SECRET`, and carries the same claims:
19
+ Every token is a JWT signed with `HS256` and `JWT_SECRET` (`JWT_SECRET_V<n>` to rotate it), and carries the same claims. The issuer is the one you set with `configure({ appName })` (or `tokenIssuer`), so every product that uses the same name accepts the same tokens.
17
20
 
18
21
  | Claim | Value |
19
22
  | --- | --- |
20
- | `iss` | `openloops`. A token without it, or with another one, is refused. |
23
+ | `iss` | The issuer of your solution. A token without it, or with another one, is refused. |
21
24
  | `aud` | What the token is for: `session`, `password-reset` or `automation-event`. A token is only valid for its own audience. |
22
25
  | `sub` | The id of the user, or the id of the automation for an event token. |
23
26
  | `jti` | A unique id, only in the tokens that can be revoked one by one: reset and event tokens. |
24
27
  | `exp` | When it stops working. |
25
28
 
26
- | Token | Audience | Duration | Extra claims |
27
- | --- | --- | --- | --- |
28
- | Access of a session | `session` | 1 hour | `email`, `firstName`, `lastName`, `sid` (the id of the session) |
29
- | Reset of the password | `password-reset` | 15 minutes | `jti` |
30
- | Event of an automation | `automation-event` | The one you choose, or none | `jti`, `v` |
31
-
32
- The refresh token is not a JWT: it is a random string, and only its hash is stored.
33
-
34
- ## Logging in
35
-
36
- ```typescript
37
- const result = await login({
38
- payload: {
39
- emailOrUsername: 'jose@openloops.xyz',
40
- password: 'a-real-password',
41
- },
42
- })
43
-
44
- result.accessToken
45
- result.refreshToken
46
- result.expiresIn
47
- result.refreshExpiresAt
48
- result.user
49
- ```
50
-
51
- - `accessToken` lasts 1 hour. `refreshToken` lasts 30 days for a user and 7 days for an admin, and a session cannot be extended beyond 90 days (7 for an admin), no matter how often it is refreshed.
52
- - `user` is the user record without the password.
53
- - A missing field fails with 400. An unknown user and a wrong password fail with the same 401, so the answer does not tell which accounts exist.
29
+ The access token of a session carries no personal data. If your client needs the name or the email, ask your backend for the profile of the user.
54
30
 
55
- ## Keeping the session
56
-
57
- ```typescript
58
- const next = await refreshSession({ refreshToken })
59
- ```
60
-
61
- - It gives a new access token and a new refresh token, and the old refresh token cannot be used again. All of them belong to one session.
62
- - A refresh token that was used is accepted again for 10 seconds, to survive a retry of the client. Later than that, it is taken as stolen: the whole session is closed and the next refresh fails with 401.
63
- - It fails with 401 for an unknown, expired or revoked token, and when the user no longer exists.
64
- - Two refreshes at the same time with the same token do not create two sessions.
65
-
66
- ```typescript
67
- await logout({ refreshToken })
68
- ```
69
-
70
- Closes the session of that refresh token. An unknown or missing token is ignored.
71
-
72
- ```typescript
73
- await revokeUserSessions({ userId, now: new Date(), exceptFamilyId })
74
- ```
75
-
76
- Closes every session of the user, except the one you name. `changePassword` and `resetPassword` do it for you.
77
-
78
- ## From a token to a `CurrentUser`
79
-
80
- Your backend reads the access token, and builds the `CurrentUser` that every other call needs:
81
-
82
- ```typescript
83
- import { verifySessionToken } from 'openloops/authentication'
84
- import { CurrentUser } from 'openloops/base'
85
-
86
- const claims = verifySessionToken(token)
87
- const currentUser = await CurrentUser.asyncFromDB(claims.userId)
88
- ```
89
-
90
- `verifySessionToken` throws a `TokenError` whose `reason` is `invalid` or `expired`. It refuses a token of another audience, so a reset token or an event token cannot be used as a session. See [users](users.md).
91
-
92
- ## Resetting a password
93
-
94
- `openloops` does not send emails. It issues the token, and your backend sends the link:
95
-
96
- ```typescript
97
- const issued = await issuePasswordResetToken({ payload: { emailOrUsername } })
98
-
99
- if (issued) await sendEmail(issued.user.email, `https://example.com/reset?token=${issued.token}`)
100
- ```
101
-
102
- - It answers `null` when the user does not exist. Answer the same to the client in both cases, so nobody can learn which accounts exist.
103
- - The token lasts 15 minutes and works once.
104
-
105
- ```typescript
106
- await resetPassword({ token, password })
107
- ```
108
-
109
- - It fails with 401 for a token that is invalid, expired, already used, or that is not a reset token, and with 400 if there is no password.
110
- - It changes the password and closes every session of the user.
111
-
112
- ```typescript
113
- await changePassword({ id, password, sessionId, currentUser })
114
- ```
115
-
116
- For a user that changes their own password while logged in. It closes the other sessions and keeps the one in `sessionId` (the `sessionId` that `verifySessionToken` gives). `updateUser` refuses a `password`: this is the only way to change it.
31
+ The tokens of [event automations](automations.md#the-token) are issued and revoked by `openloops` with the functions of `nanosaas/authentication`, with the audience `automation-event`.
117
32
 
118
33
  ## Revoked tokens
119
34
 
120
- A signed token cannot be taken back, so `openloops` keeps a list of the ids (`jti`) of the tokens that must stop working, in the collection `revoked_tokens`.
121
-
122
- ```typescript
123
- const isFirstTime = await revokeToken({ payload: { jti, audience: 'automation-event', subject: automationId, expiresAt } })
124
-
125
- const data = await isTokenRevoked({ jti })
126
-
127
- data.revoked
128
- ```
129
-
130
- - Revoking the same `jti` twice does nothing and answers `false`. `expiresAt` is optional: when it is set, the entry is deleted by itself on that date, which is when the token would have stopped working anyway.
131
- - Reset tokens use it so they work once, and event tokens use it through `revokeAutomationEventToken`.
132
- - The access token of a session has no `jti`: to cut a session, close it with `logout` or `revokeUserSessions`. The access token still works until it expires, at most one hour.
133
-
134
- ## Collections
35
+ A signed token cannot be taken back, so a list keeps the ids (`jti`) of the tokens that must stop working, in the collection `revoked_tokens` of `nanosaas`. Event tokens use it through `revokeAutomationEventToken`, and reset tokens use it so they work once. The access token of a session has no `jti`: to cut a session, close it with `logout` or `revokeUserSessions`.
135
36
 
136
- `refresh_tokens` and `revoked_tokens` are created by `ensureIndexes` (see [configuration](configuration.md)). If another backend shares the database and uses the same convention, both read and write the same documents.
37
+ The indexes of `refresh_tokens` and `revoked_tokens` are `AUTH_INDEXES` of `nanosaas/authentication`. Apply them with the indexes of `openloops` (see [configuration](configuration.md#indexes)).
@@ -1,27 +1,27 @@
1
1
  # Authorization
2
2
 
3
- > **Breaking change.** Since this version every call that creates, reads or writes a record needs the `currentUser`, or a `scope` you build yourself. The calls that worked without one, or that created a record for the user in the payload, now fail with 401. Read [what changes when you create records](#creating-records) and the [migration steps](#migrating-from-05).
3
+ > **Breaking change.** Since this version every call that creates, reads or writes a record needs the `actor`, or a `scope` you build yourself. The calls that worked without one, or that created a record for the user in the payload, now fail with 401. Read [what changes when you create records](#creating-records) and the [migration steps](#migrating-from-05).
4
4
 
5
5
  Every use case that reads or writes a record of a user checks who owns it. The check is not in a controller, it is in the repository, inside the same query that reads or writes the record, so it does not cost an extra read and cannot be forgotten.
6
6
 
7
7
  ## The scope
8
8
 
9
- A `Scope` tells the repository on whose behalf it works. Use cases build one from the `currentUser` you pass:
9
+ A `Scope` tells the repository on whose behalf it works. Use cases build one from the `actor` you pass:
10
10
 
11
11
  | Scope | Used for | Reaches |
12
12
  | --- | --- | --- |
13
- | `Scope.canView(currentUser)` | Reading. | The records of the user. |
14
- | `Scope.canEdit(currentUser)` | Creating and updating. | The records of the user. |
15
- | `Scope.canManage(currentUser)` | Deleting, issuing and revoking tokens. | The records of the user. |
16
- | `Scope.asAdmin(currentUser)` | Actions of an administrator. | Every record. It fails with 403 if the user is not an admin. |
13
+ | `Scope.canView(actor)` | Reading. | The records of the user. |
14
+ | `Scope.canEdit(actor)` | Creating and updating. | The records of the user. |
15
+ | `Scope.canManage(actor)` | Deleting, issuing and revoking tokens. | The records of the user. |
16
+ | `Scope.asAdmin(actor)` | Actions of an administrator. | Every record. It fails with 403 if the user is not an admin. |
17
17
  | `Scope.system('reason')` | Workers, webhooks and flows without a user. | Every record. The reason is required. |
18
18
 
19
- An admin does not get more access by being an admin. A use case called with an admin as `currentUser` still works on the records of that admin. To work on any record, build the scope yourself and pass it:
19
+ An admin does not get more access by being an admin. A use case called with an admin as `actor` still works on the records of that admin. To work on any record, build the scope yourself and pass it:
20
20
 
21
21
  ```typescript
22
- import { Scope } from 'openloops/base'
22
+ import { Scope } from 'nanosaas/db'
23
23
 
24
- await deleteChat({ id, currentUser, scope: Scope.asAdmin(currentUser) })
24
+ await deleteChat({ id, actor, scope: Scope.asAdmin(actor) })
25
25
  ```
26
26
 
27
27
  Every use case accepts `scope`. Use it only from code you wrote, never from a value that comes from a request.
@@ -30,23 +30,23 @@ Every use case accepts `scope`. Use it only from code you wrote, never from a va
30
30
 
31
31
  Every `create...` use case (`createChat`, `createMcpServer`, `createAutomation`, `createUser`, `createLLMCall`, `createAgentTask`, `createAgentAction`, `createAgentTraces`, `saveWorkspaceItem`) now takes the owner and the author from the scope, not from the payload:
32
32
 
33
- - With a user scope, the new record belongs to the `currentUser`. `ownerId`, `createdBy`, `createdAt` and the other fields of control are set by the repository, and the ones you put in the payload are discarded. You cannot create a record for another user by sending his `ownerId`.
34
- - To create a record for someone else, or without a user (a sign up, a webhook, a worker), pass a trusted scope: `Scope.system('reason')` or `Scope.asAdmin(currentUser)`. The payload is kept as you send it, and `ownerId` is the one you send. With `system` there is no `createdBy`, unless you send it.
35
- - Without `currentUser` and without `scope` the call fails with 401. Before, `createChat` and the others created the record without an owner.
33
+ - With a user scope, the new record belongs to the `actor`. `ownerId`, `createdBy`, `createdAt` and the other fields of control are set by the repository, and the ones you put in the payload are discarded. You cannot create a record for another user by sending his `ownerId`.
34
+ - To create a record for someone else, or without a user (a sign up, a webhook, a worker), pass a trusted scope: `Scope.system('reason')` or `Scope.asAdmin(actor)`. The payload is kept as you send it, and `ownerId` is the one you send. With `system` there is no `createdBy`, unless you send it.
35
+ - Without `actor` and without `scope` the call fails with 401. Before, `createChat` and the others created the record without an owner.
36
36
  - The record that returns has its `_id`, `ownerId`, `createdAt` and `createdBy`.
37
37
 
38
38
  ```typescript
39
- await createChat({ payload, currentUser })
39
+ await createChat({ payload, actor })
40
40
 
41
41
  await createUser({ payload, scope: Scope.system('sign up') })
42
42
 
43
- await createAutomation({ payload: { ...payload, ownerId: otherUserId }, scope: Scope.asAdmin(currentUser) })
43
+ await createAutomation({ payload: { ...payload, ownerId: otherUserId }, scope: Scope.asAdmin(actor) })
44
44
  ```
45
45
 
46
46
  ## What changes in your endpoints
47
47
 
48
48
  - A record that is not the user's is answered as if it did not exist. The functions that update or delete throw a 404 `HttpError` with the message `{{resource_not_found}}`, and the getters return `null` or throw the same 404. Nobody can learn that an id exists by getting a 403.
49
- - A call without `currentUser` and without `scope` fails with 401, it does not read everything.
49
+ - A call without `actor` and without `scope` fails with 401, it does not read everything.
50
50
  - You do not need to load the record to check `ownerId` before calling a function that takes an id.
51
51
 
52
52
  ## What the repository does with the fields of control
@@ -65,11 +65,11 @@ await createUser({ payload, scope: Scope.system('sign up') })
65
65
 
66
66
  ## Migrating from 0.5
67
67
 
68
- - Pass `currentUser`, or a `scope`, to every function that reads or writes the records of a user: the ones that take an id (`getChatById`, `updateChat`, `deleteChat`, `getMcpServerById`, `updateMcpServer`, `deleteMcpServer`, `decideMcpServerTrust`, `verifyMcpServerConnection`, `getUserById`, `updateUser`, `deleteUser`, `updateAutomation`, `deleteAutomation`), the ones that create (see [creating records](#creating-records)), the ones that list and the usage reports (`getLLMUsageByChat`, `getLLMUsageByMessage` and `getLLMUsageStats`). Many of them accepted a call without a user before and did not check the owner. `getAutomationById`, `listAutomationRunsByAutomation`, `startAutomationRun` and `runner.runNow` did not read the user at all.
68
+ - Pass `actor`, or a `scope`, to every function that reads or writes the records of a user: the ones that take an id (`getChatById`, `updateChat`, `deleteChat`, `getMcpServerById`, `updateMcpServer`, `deleteMcpServer`, `decideMcpServerTrust`, `verifyMcpServerConnection`, `getUserById`, `updateUser`, `deleteUser`, `updateAutomation`, `deleteAutomation`), the ones that create (see [creating records](#creating-records)), the ones that list and the usage reports (`getLLMUsageByChat`, `getLLMUsageByMessage` and `getLLMUsageStats`). Many of them accepted a call without a user before and did not check the owner. `getAutomationById`, `listAutomationRunsByAutomation`, `startAutomationRun` and `runner.runNow` did not read the user at all.
69
69
  - You do not need to pass anything to `login`, `revokeToken`, `isTokenRevoked`, `previewAutomationRuns` and `receiveAutomationEvent`, which do not belong to a user, nor to the functions of the runner (`claimDueAutomations`, `claimQueuedAutomationRuns`, `finishAutomationRun`, `syncAutomationRun`, `syncAutomationRuns`, `attachAutomationRunChat` and `renewAutomationLease`), which use their own system scope.
70
- - Pass `currentUser` to `getAutomationById`, `listAutomationRunsByAutomation`, `startAutomationRun` and `runner.runNow`. They did not need it before.
70
+ - Pass `actor` to `getAutomationById`, `listAutomationRunsByAutomation`, `startAutomationRun` and `runner.runNow`. They did not need it before.
71
71
  - Replace `sanitize: false` in `createUser` with a `scope`, as shown above.
72
- - Where an admin used to act on the record of another user, pass `scope: Scope.asAdmin(currentUser)`.
72
+ - Where an admin used to act on the record of another user, pass `scope: Scope.asAdmin(actor)`.
73
73
  - `issueAutomationEventToken`, `revokeAutomationEventToken` and `rotateAutomationEventTokens` are for the owner. They used to accept an admin.
74
74
  - Expect a 404 where you got a 403 for the records of other users, and remove the ownership checks you wrote before calling a function with an id.
75
75
  - Hard delete is for `Scope.asAdmin` or `Scope.system` only.