openloops 0.1.31 → 0.1.33

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 (252) hide show
  1. package/dist/clients/llm-client.d.ts +5 -0
  2. package/dist/clients/llm-client.js +73 -15
  3. package/dist/clients/llm-client.mjs +73 -15
  4. package/dist/clients/llm-error.d.ts +9 -0
  5. package/dist/clients/llm-error.js +69 -0
  6. package/dist/clients/llm-error.mjs +45 -0
  7. package/dist/clients/llm-types.d.ts +61 -0
  8. package/dist/clients/llm-types.js +16 -0
  9. package/dist/clients/llm-types.mjs +0 -0
  10. package/dist/clients/pi-ai-adapter.d.ts +7 -0
  11. package/dist/clients/pi-ai-adapter.js +137 -0
  12. package/dist/clients/pi-ai-adapter.mjs +113 -0
  13. package/dist/{agent → harness}/agent-loop.d.ts +11 -1
  14. package/dist/{agent → harness}/agent-state.js +1 -1
  15. package/dist/{agent → harness}/agent-state.mjs +1 -1
  16. package/dist/{agent → harness}/agent.d.ts +34 -3
  17. package/dist/harness/agent.js +546 -0
  18. package/dist/harness/agent.mjs +530 -0
  19. package/dist/{agent → harness}/index.js +5 -5
  20. package/dist/harness/native-tools.d.ts +23 -0
  21. package/dist/harness/native-tools.js +251 -0
  22. package/dist/harness/native-tools.mjs +227 -0
  23. package/dist/harness/tool-catalog.d.ts +16 -0
  24. package/dist/harness/tool-catalog.js +85 -0
  25. package/dist/harness/tool-catalog.mjs +59 -0
  26. package/dist/harness/tool-pipeline.d.ts +42 -0
  27. package/dist/harness/tool-pipeline.js +200 -0
  28. package/dist/harness/tool-pipeline.mjs +177 -0
  29. package/dist/harness/utils/describe-shape.d.ts +2 -0
  30. package/dist/harness/utils/describe-shape.js +56 -0
  31. package/dist/harness/utils/describe-shape.mjs +32 -0
  32. package/dist/harness/utils/grounding.d.ts +6 -0
  33. package/dist/harness/utils/grounding.js +79 -0
  34. package/dist/harness/utils/grounding.mjs +53 -0
  35. package/dist/harness/workspace.d.ts +44 -0
  36. package/dist/harness/workspace.js +95 -0
  37. package/dist/harness/workspace.mjs +78 -0
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.js +2 -2
  40. package/dist/index.mjs +1 -1
  41. package/dist/loops/agi/index.d.ts +1 -0
  42. package/dist/loops/agi/index.js +22 -0
  43. package/dist/loops/agi/index.mjs +1 -0
  44. package/dist/loops/agi/loop.d.ts +24 -0
  45. package/dist/loops/agi/loop.js +220 -0
  46. package/dist/loops/agi/loop.mjs +197 -0
  47. package/dist/loops/agi/skills/reasoning-engine.d.ts +14 -0
  48. package/dist/loops/agi/skills/reasoning-engine.js +94 -0
  49. package/dist/loops/agi/skills/reasoning-engine.mjs +71 -0
  50. package/dist/loops/index.d.ts +1 -0
  51. package/dist/loops/index.js +3 -1
  52. package/dist/loops/index.mjs +1 -0
  53. package/dist/loops/plan-execute/plan-execute-loop.d.ts +2 -1
  54. package/dist/loops/plan-execute/plan-execute-loop.js +90 -35
  55. package/dist/loops/plan-execute/plan-execute-loop.mjs +80 -25
  56. package/dist/loops/shared/skills/action-planner.js +7 -4
  57. package/dist/loops/shared/skills/action-planner.mjs +7 -4
  58. package/dist/loops/shared/skills/final-responder.js +4 -3
  59. package/dist/loops/shared/skills/final-responder.mjs +4 -3
  60. package/dist/loops/shared/skills/state-observer.js +6 -2
  61. package/dist/loops/shared/skills/state-observer.mjs +6 -2
  62. package/dist/services/chats/entities/chat-message.entity.d.ts +4 -1
  63. package/dist/services/chats/entities/chat-message.entity.js +7 -3
  64. package/dist/services/chats/entities/chat-message.entity.mjs +7 -3
  65. package/dist/services/chats/entities/chat.entity.d.ts +10 -11
  66. package/dist/services/chats/entities/chat.entity.js +17 -21
  67. package/dist/services/chats/entities/chat.entity.mjs +17 -21
  68. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.d.ts +2 -0
  69. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.js +4 -4
  70. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.mjs +2 -2
  71. package/dist/services/tasks/entities/agent-action.entity.d.ts +111 -0
  72. package/dist/services/tasks/entities/agent-action.entity.js +271 -0
  73. package/dist/services/tasks/entities/agent-action.entity.mjs +247 -0
  74. package/dist/services/tasks/entities/agent-task.entity.d.ts +176 -0
  75. package/dist/services/tasks/entities/agent-task.entity.js +695 -0
  76. package/dist/services/tasks/entities/agent-task.entity.mjs +662 -0
  77. package/dist/services/tasks/entities/index.d.ts +2 -0
  78. package/dist/services/tasks/entities/index.js +24 -0
  79. package/dist/services/tasks/entities/index.mjs +2 -0
  80. package/dist/services/tasks/index.d.ts +3 -0
  81. package/dist/services/tasks/index.js +26 -0
  82. package/dist/services/tasks/index.mjs +3 -0
  83. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.d.ts +14 -0
  84. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.js +60 -0
  85. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.mjs +31 -0
  86. package/dist/services/tasks/lambdas/create-agent-action/index.d.ts +1 -0
  87. package/dist/services/tasks/lambdas/create-agent-action/index.js +22 -0
  88. package/dist/services/tasks/lambdas/create-agent-action/index.mjs +1 -0
  89. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.d.ts +14 -0
  90. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.js +60 -0
  91. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.mjs +31 -0
  92. package/dist/services/tasks/lambdas/create-agent-task/index.d.ts +1 -0
  93. package/dist/services/tasks/lambdas/create-agent-task/index.js +22 -0
  94. package/dist/services/tasks/lambdas/create-agent-task/index.mjs +1 -0
  95. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.d.ts +14 -0
  96. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.js +55 -0
  97. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.mjs +26 -0
  98. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.d.ts +1 -0
  99. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.js +22 -0
  100. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.mjs +1 -0
  101. package/dist/services/tasks/lambdas/index.d.ts +7 -0
  102. package/dist/services/tasks/lambdas/index.js +46 -0
  103. package/dist/services/tasks/lambdas/index.mjs +17 -0
  104. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.d.ts +1 -0
  105. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.js +22 -0
  106. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.mjs +1 -0
  107. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.d.ts +16 -0
  108. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.js +62 -0
  109. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.mjs +33 -0
  110. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.d.ts +1 -0
  111. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.js +22 -0
  112. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.mjs +1 -0
  113. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.d.ts +16 -0
  114. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.js +62 -0
  115. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.mjs +33 -0
  116. package/dist/services/tasks/lambdas/update-agent-action/index.d.ts +1 -0
  117. package/dist/services/tasks/lambdas/update-agent-action/index.js +22 -0
  118. package/dist/services/tasks/lambdas/update-agent-action/index.mjs +1 -0
  119. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.d.ts +15 -0
  120. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.js +67 -0
  121. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.mjs +38 -0
  122. package/dist/services/tasks/lambdas/update-agent-task/index.d.ts +1 -0
  123. package/dist/services/tasks/lambdas/update-agent-task/index.js +22 -0
  124. package/dist/services/tasks/lambdas/update-agent-task/index.mjs +1 -0
  125. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.d.ts +15 -0
  126. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.js +67 -0
  127. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.mjs +38 -0
  128. package/dist/services/tasks/module.d.ts +15 -0
  129. package/dist/services/tasks/module.js +76 -0
  130. package/dist/services/tasks/module.mjs +47 -0
  131. package/dist/services/tasks/repositories/agent-action.repository.d.ts +8 -0
  132. package/dist/services/tasks/repositories/agent-action.repository.js +62 -0
  133. package/dist/services/tasks/repositories/agent-action.repository.mjs +33 -0
  134. package/dist/services/tasks/repositories/agent-task.repository.d.ts +9 -0
  135. package/dist/services/tasks/repositories/agent-task.repository.js +65 -0
  136. package/dist/services/tasks/repositories/agent-task.repository.mjs +36 -0
  137. package/dist/services/tasks/repositories/index.d.ts +2 -0
  138. package/dist/services/tasks/repositories/index.js +24 -0
  139. package/dist/services/tasks/repositories/index.mjs +2 -0
  140. package/dist/services/traces/entities/agent-trace-entry.entity.d.ts +30 -0
  141. package/dist/services/traces/entities/agent-trace-entry.entity.js +85 -0
  142. package/dist/services/traces/entities/agent-trace-entry.entity.mjs +62 -0
  143. package/dist/services/traces/entities/index.d.ts +1 -0
  144. package/dist/services/traces/entities/index.js +22 -0
  145. package/dist/services/traces/entities/index.mjs +1 -0
  146. package/dist/services/traces/index.d.ts +3 -0
  147. package/dist/services/traces/index.js +26 -0
  148. package/dist/services/traces/index.mjs +3 -0
  149. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.d.ts +16 -0
  150. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.js +62 -0
  151. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.mjs +33 -0
  152. package/dist/services/traces/lambdas/create-agent-traces/index.d.ts +1 -0
  153. package/dist/services/traces/lambdas/create-agent-traces/index.js +22 -0
  154. package/dist/services/traces/lambdas/create-agent-traces/index.mjs +1 -0
  155. package/dist/services/traces/lambdas/index.d.ts +2 -0
  156. package/dist/services/traces/lambdas/index.js +31 -0
  157. package/dist/services/traces/lambdas/index.mjs +7 -0
  158. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.d.ts +1 -0
  159. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.js +22 -0
  160. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.mjs +1 -0
  161. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.d.ts +18 -0
  162. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.js +67 -0
  163. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.mjs +38 -0
  164. package/dist/services/traces/module.d.ts +5 -0
  165. package/dist/services/traces/module.js +41 -0
  166. package/dist/services/traces/module.mjs +17 -0
  167. package/dist/services/traces/repositories/agent-trace.repository.d.ts +7 -0
  168. package/dist/services/traces/repositories/agent-trace.repository.js +55 -0
  169. package/dist/services/traces/repositories/agent-trace.repository.mjs +26 -0
  170. package/dist/services/traces/repositories/index.d.ts +1 -0
  171. package/dist/services/traces/repositories/index.js +22 -0
  172. package/dist/services/traces/repositories/index.mjs +1 -0
  173. package/dist/services/workspaces/entities/index.d.ts +1 -0
  174. package/dist/services/workspaces/entities/index.js +22 -0
  175. package/dist/services/workspaces/entities/index.mjs +1 -0
  176. package/dist/services/workspaces/entities/workspace-item.entity.d.ts +33 -0
  177. package/dist/services/workspaces/entities/workspace-item.entity.js +95 -0
  178. package/dist/services/workspaces/entities/workspace-item.entity.mjs +72 -0
  179. package/dist/services/workspaces/index.d.ts +3 -0
  180. package/dist/services/workspaces/index.js +26 -0
  181. package/dist/services/workspaces/index.mjs +3 -0
  182. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.d.ts +17 -0
  183. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.js +68 -0
  184. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.mjs +39 -0
  185. package/dist/services/workspaces/lambdas/delete-workspace-item/index.d.ts +1 -0
  186. package/dist/services/workspaces/lambdas/delete-workspace-item/index.js +22 -0
  187. package/dist/services/workspaces/lambdas/delete-workspace-item/index.mjs +1 -0
  188. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.d.ts +17 -0
  189. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.js +67 -0
  190. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.mjs +38 -0
  191. package/dist/services/workspaces/lambdas/get-workspace-item/index.d.ts +1 -0
  192. package/dist/services/workspaces/lambdas/get-workspace-item/index.js +22 -0
  193. package/dist/services/workspaces/lambdas/get-workspace-item/index.mjs +1 -0
  194. package/dist/services/workspaces/lambdas/index.d.ts +5 -0
  195. package/dist/services/workspaces/lambdas/index.js +40 -0
  196. package/dist/services/workspaces/lambdas/index.mjs +13 -0
  197. package/dist/services/workspaces/lambdas/list-workspace-items/index.d.ts +1 -0
  198. package/dist/services/workspaces/lambdas/list-workspace-items/index.js +22 -0
  199. package/dist/services/workspaces/lambdas/list-workspace-items/index.mjs +1 -0
  200. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.d.ts +18 -0
  201. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.js +69 -0
  202. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.mjs +40 -0
  203. package/dist/services/workspaces/lambdas/save-workspace-item/index.d.ts +1 -0
  204. package/dist/services/workspaces/lambdas/save-workspace-item/index.js +22 -0
  205. package/dist/services/workspaces/lambdas/save-workspace-item/index.mjs +1 -0
  206. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.d.ts +14 -0
  207. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.js +76 -0
  208. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.mjs +47 -0
  209. package/dist/services/workspaces/lambdas/search-workspace-items/index.d.ts +1 -0
  210. package/dist/services/workspaces/lambdas/search-workspace-items/index.js +22 -0
  211. package/dist/services/workspaces/lambdas/search-workspace-items/index.mjs +1 -0
  212. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.d.ts +19 -0
  213. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.js +73 -0
  214. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.mjs +44 -0
  215. package/dist/services/workspaces/module.d.ts +11 -0
  216. package/dist/services/workspaces/module.js +62 -0
  217. package/dist/services/workspaces/module.mjs +35 -0
  218. package/dist/services/workspaces/repositories/index.d.ts +1 -0
  219. package/dist/services/workspaces/repositories/index.js +22 -0
  220. package/dist/services/workspaces/repositories/index.mjs +1 -0
  221. package/dist/services/workspaces/repositories/workspace-item.repository.d.ts +18 -0
  222. package/dist/services/workspaces/repositories/workspace-item.repository.js +74 -0
  223. package/dist/services/workspaces/repositories/workspace-item.repository.mjs +45 -0
  224. package/dist/skills/runtime-context.d.ts +8 -0
  225. package/dist/skills/runtime-context.js +65 -0
  226. package/dist/skills/runtime-context.mjs +42 -0
  227. package/dist/skills/skill.d.ts +7 -0
  228. package/dist/skills/skill.js +26 -60
  229. package/dist/skills/skill.mjs +26 -60
  230. package/dist/tools/tool.d.ts +6 -0
  231. package/dist/tools/tool.js +56 -0
  232. package/dist/tools/tool.mjs +56 -0
  233. package/package.json +3 -3
  234. package/dist/agent/agent.js +0 -327
  235. package/dist/agent/agent.mjs +0 -303
  236. package/dist/services/chats/entities/agent-action.entity.d.ts +0 -58
  237. package/dist/services/chats/entities/agent-action.entity.js +0 -151
  238. package/dist/services/chats/entities/agent-action.entity.mjs +0 -128
  239. package/dist/services/chats/entities/agent-task.entity.d.ts +0 -59
  240. package/dist/services/chats/entities/agent-task.entity.js +0 -231
  241. package/dist/services/chats/entities/agent-task.entity.mjs +0 -207
  242. package/dist/services/chats/entities/chat-context.entity.d.ts +0 -39
  243. package/dist/services/chats/entities/chat-context.entity.js +0 -70
  244. package/dist/services/chats/entities/chat-context.entity.mjs +0 -47
  245. /package/dist/{agent → harness}/agent-loop.js +0 -0
  246. /package/dist/{agent → harness}/agent-loop.mjs +0 -0
  247. /package/dist/{agent → harness}/agent-state.d.ts +0 -0
  248. /package/dist/{agent → harness}/index.d.ts +0 -0
  249. /package/dist/{agent → harness}/index.mjs +0 -0
  250. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.d.ts +0 -0
  251. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.js +0 -0
  252. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.mjs +0 -0
@@ -1,151 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var agent_action_entity_exports = {};
20
- __export(agent_action_entity_exports, {
21
- AgentAction: () => AgentAction
22
- });
23
- module.exports = __toCommonJS(agent_action_entity_exports);
24
- var import_mongodb = require("mongodb");
25
- var import_base = require("../../../common/base/base.entity.js");
26
- class AgentAction extends import_base.BaseEntity {
27
- constructor(props, name, stepId, args, dependsOn, status, output, error, reasoning, retries, author, startedAt, completedAt) {
28
- super(props);
29
- this.props = props;
30
- this.name = name;
31
- this.stepId = stepId;
32
- this.args = args;
33
- this.dependsOn = dependsOn;
34
- this.status = status;
35
- this.output = output;
36
- this.error = error;
37
- this.reasoning = reasoning;
38
- this.retries = retries;
39
- this.author = author;
40
- this.startedAt = startedAt;
41
- this.completedAt = completedAt;
42
- }
43
- props;
44
- name;
45
- stepId;
46
- args;
47
- dependsOn;
48
- status;
49
- output;
50
- error;
51
- reasoning;
52
- retries;
53
- author;
54
- startedAt;
55
- completedAt;
56
- static factory(action) {
57
- const actionId = action._id && import_mongodb.ObjectId.isValid(action._id) ? new import_mongodb.ObjectId(action._id) : new import_mongodb.ObjectId();
58
- return AgentAction.fromJSON({ ...action, _id: actionId, status: action.status ?? "pending" });
59
- }
60
- static fromJSON(props) {
61
- return new AgentAction(
62
- props,
63
- props.name,
64
- props.stepId,
65
- props.args,
66
- props.dependsOn,
67
- props.status,
68
- props.output,
69
- props.error,
70
- props.reasoning,
71
- props.retries,
72
- props.author,
73
- props.startedAt,
74
- props.completedAt
75
- );
76
- }
77
- toJSON() {
78
- return {
79
- ...super.toJSON(),
80
- name: this.name,
81
- stepId: this.stepId,
82
- args: this.args,
83
- dependsOn: this.dependsOn,
84
- status: this.status,
85
- output: this.output,
86
- error: this.error,
87
- reasoning: this.reasoning,
88
- retries: this.retries,
89
- author: this.author,
90
- startedAt: this.startedAt,
91
- completedAt: this.completedAt
92
- };
93
- }
94
- get id() {
95
- return this._id.toString();
96
- }
97
- get isReady() {
98
- return this.status === "pending";
99
- }
100
- get isTerminal() {
101
- return this.status === "completed" || this.status === "failed";
102
- }
103
- dependenciesSatisfiedBy(completedRefs) {
104
- if (!this.dependsOn?.length) return true;
105
- return this.dependsOn.every((ref) => completedRefs.has(ref));
106
- }
107
- markRunning() {
108
- this.status = "running";
109
- this.startedAt = /* @__PURE__ */ new Date();
110
- }
111
- markCompleted(output) {
112
- this.status = "completed";
113
- this.output = output;
114
- this.completedAt = /* @__PURE__ */ new Date();
115
- }
116
- markFailed(error) {
117
- this.status = "failed";
118
- this.error = error;
119
- this.completedAt = /* @__PURE__ */ new Date();
120
- }
121
- incrementRetries() {
122
- this.retries = (this.retries ?? 0) + 1;
123
- return this.retries;
124
- }
125
- /** Vuelve a dejar la action en `pending` para un nuevo intento — usar junto a incrementRetries() */
126
- resetForRetry() {
127
- this.status = "pending";
128
- this.error = void 0;
129
- this.startedAt = void 0;
130
- this.completedAt = void 0;
131
- }
132
- /** Corre una tool con los argumentos ya resueltos y registra el resultado en sí misma */
133
- async runTool(tool, args, baseParams) {
134
- if (!tool) {
135
- this.markFailed({ message: `Tool "${this.name}" not found` });
136
- return this;
137
- }
138
- this.markRunning();
139
- try {
140
- const result = await tool.run({ ...args, ...baseParams });
141
- this.markCompleted(result?.data);
142
- } catch (error) {
143
- this.markFailed({ message: error?.message ?? String(error) });
144
- }
145
- return this;
146
- }
147
- }
148
- // Annotate the CommonJS export names for ESM import in node:
149
- 0 && (module.exports = {
150
- AgentAction
151
- });
@@ -1,128 +0,0 @@
1
- import "../../../chunk-CF3WOMB3.mjs";
2
- import { ObjectId } from "mongodb";
3
- import { BaseEntity } from "../../../common/base/base.entity.js";
4
- class AgentAction extends BaseEntity {
5
- constructor(props, name, stepId, args, dependsOn, status, output, error, reasoning, retries, author, startedAt, completedAt) {
6
- super(props);
7
- this.props = props;
8
- this.name = name;
9
- this.stepId = stepId;
10
- this.args = args;
11
- this.dependsOn = dependsOn;
12
- this.status = status;
13
- this.output = output;
14
- this.error = error;
15
- this.reasoning = reasoning;
16
- this.retries = retries;
17
- this.author = author;
18
- this.startedAt = startedAt;
19
- this.completedAt = completedAt;
20
- }
21
- props;
22
- name;
23
- stepId;
24
- args;
25
- dependsOn;
26
- status;
27
- output;
28
- error;
29
- reasoning;
30
- retries;
31
- author;
32
- startedAt;
33
- completedAt;
34
- static factory(action) {
35
- const actionId = action._id && ObjectId.isValid(action._id) ? new ObjectId(action._id) : new ObjectId();
36
- return AgentAction.fromJSON({ ...action, _id: actionId, status: action.status ?? "pending" });
37
- }
38
- static fromJSON(props) {
39
- return new AgentAction(
40
- props,
41
- props.name,
42
- props.stepId,
43
- props.args,
44
- props.dependsOn,
45
- props.status,
46
- props.output,
47
- props.error,
48
- props.reasoning,
49
- props.retries,
50
- props.author,
51
- props.startedAt,
52
- props.completedAt
53
- );
54
- }
55
- toJSON() {
56
- return {
57
- ...super.toJSON(),
58
- name: this.name,
59
- stepId: this.stepId,
60
- args: this.args,
61
- dependsOn: this.dependsOn,
62
- status: this.status,
63
- output: this.output,
64
- error: this.error,
65
- reasoning: this.reasoning,
66
- retries: this.retries,
67
- author: this.author,
68
- startedAt: this.startedAt,
69
- completedAt: this.completedAt
70
- };
71
- }
72
- get id() {
73
- return this._id.toString();
74
- }
75
- get isReady() {
76
- return this.status === "pending";
77
- }
78
- get isTerminal() {
79
- return this.status === "completed" || this.status === "failed";
80
- }
81
- dependenciesSatisfiedBy(completedRefs) {
82
- if (!this.dependsOn?.length) return true;
83
- return this.dependsOn.every((ref) => completedRefs.has(ref));
84
- }
85
- markRunning() {
86
- this.status = "running";
87
- this.startedAt = /* @__PURE__ */ new Date();
88
- }
89
- markCompleted(output) {
90
- this.status = "completed";
91
- this.output = output;
92
- this.completedAt = /* @__PURE__ */ new Date();
93
- }
94
- markFailed(error) {
95
- this.status = "failed";
96
- this.error = error;
97
- this.completedAt = /* @__PURE__ */ new Date();
98
- }
99
- incrementRetries() {
100
- this.retries = (this.retries ?? 0) + 1;
101
- return this.retries;
102
- }
103
- /** Vuelve a dejar la action en `pending` para un nuevo intento — usar junto a incrementRetries() */
104
- resetForRetry() {
105
- this.status = "pending";
106
- this.error = void 0;
107
- this.startedAt = void 0;
108
- this.completedAt = void 0;
109
- }
110
- /** Corre una tool con los argumentos ya resueltos y registra el resultado en sí misma */
111
- async runTool(tool, args, baseParams) {
112
- if (!tool) {
113
- this.markFailed({ message: `Tool "${this.name}" not found` });
114
- return this;
115
- }
116
- this.markRunning();
117
- try {
118
- const result = await tool.run({ ...args, ...baseParams });
119
- this.markCompleted(result?.data);
120
- } catch (error) {
121
- this.markFailed({ message: error?.message ?? String(error) });
122
- }
123
- return this;
124
- }
125
- }
126
- export {
127
- AgentAction
128
- };
@@ -1,59 +0,0 @@
1
- import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
2
- import { AgentAction, AgentActionProps, ActionDescriptor } from './agent-action.entity';
3
- import { ChatContext } from './chat-context.entity';
4
- import { Tool, BaseParams } from '../../../tools/tool.js';
5
- export declare enum TaskStatus {
6
- PENDING = "pending",
7
- IN_PROGRESS = "in_progress",
8
- AWAITING_USER = "awaiting_user",
9
- COMPLETED = "completed",
10
- PAUSED = "paused",
11
- ABANDONED = "abandoned",
12
- CANCELLED = "cancelled",
13
- FAILED = "failed"
14
- }
15
- export interface AgentTaskProps extends BaseEntityProps {
16
- status?: TaskStatus;
17
- goal?: string;
18
- nextNode?: string;
19
- threadId?: string;
20
- previousTaskId?: string;
21
- summary?: string;
22
- loopName?: string;
23
- actions?: AgentActionProps[];
24
- }
25
- export declare class AgentTask extends BaseEntity {
26
- private readonly props;
27
- status?: TaskStatus | undefined;
28
- goal?: string | undefined;
29
- nextNode?: string | undefined;
30
- threadId?: string | undefined;
31
- previousTaskId?: string | undefined;
32
- summary?: string | undefined;
33
- loopName?: string | undefined;
34
- actions: AgentAction[];
35
- static factory(task: AgentTaskProps): AgentTask;
36
- static fromJSON(props: AgentTaskProps): AgentTask;
37
- constructor(props: AgentTaskProps, status?: TaskStatus | undefined, goal?: string | undefined, nextNode?: string | undefined, threadId?: string | undefined, previousTaskId?: string | undefined, summary?: string | undefined, loopName?: string | undefined, actions?: AgentAction[]);
38
- toJSON(): AgentTaskProps;
39
- get id(): string;
40
- addAction(descriptor: ActionDescriptor): AgentAction;
41
- getAction(ref: string): AgentAction | undefined;
42
- findLastByName(name: string): AgentAction | undefined;
43
- get readyActions(): AgentAction[];
44
- get failedActions(): AgentAction[];
45
- get lastExecutedAction(): AgentAction | undefined;
46
- setNextNode(node?: string): void;
47
- complete(summary?: string): void;
48
- fail(): void;
49
- cancel(): void;
50
- pause(): void;
51
- reopen(): void;
52
- resolveArgs(action: AgentAction, context: ChatContext): any;
53
- private resolveValue;
54
- private findActionByRef;
55
- private readContextValue;
56
- runTool(descriptor: ActionDescriptor, tool: Tool | undefined, context: ChatContext, baseParams: BaseParams): Promise<AgentAction>;
57
- runReadyAction(actionRef: string, tool: Tool | undefined, context: ChatContext, baseParams: BaseParams): Promise<AgentAction>;
58
- private executeToolAction;
59
- }
@@ -1,231 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var agent_task_entity_exports = {};
20
- __export(agent_task_entity_exports, {
21
- AgentTask: () => AgentTask,
22
- TaskStatus: () => TaskStatus
23
- });
24
- module.exports = __toCommonJS(agent_task_entity_exports);
25
- var import_mongodb = require("mongodb");
26
- var import_base = require("../../../common/base/base.entity.js");
27
- var import_agent_action = require("./agent-action.entity");
28
- var TaskStatus = /* @__PURE__ */ ((TaskStatus2) => {
29
- TaskStatus2["PENDING"] = "pending";
30
- TaskStatus2["IN_PROGRESS"] = "in_progress";
31
- TaskStatus2["AWAITING_USER"] = "awaiting_user";
32
- TaskStatus2["COMPLETED"] = "completed";
33
- TaskStatus2["PAUSED"] = "paused";
34
- TaskStatus2["ABANDONED"] = "abandoned";
35
- TaskStatus2["CANCELLED"] = "cancelled";
36
- TaskStatus2["FAILED"] = "failed";
37
- return TaskStatus2;
38
- })(TaskStatus || {});
39
- const STEP_REF = /^\{\{step_([\w-]+)\.output\}\}$/;
40
- const STEP_REF_GLOBAL = /\{\{step_([\w-]+)\.output\}\}/g;
41
- const CONTEXT_REF = /^\{\{context\.([\w.-]+)\}\}$/;
42
- const CONTEXT_REF_GLOBAL = /\{\{context\.([\w.-]+)\}\}/g;
43
- function stringifyValue(value) {
44
- return typeof value === "object" ? JSON.stringify(value) : String(value);
45
- }
46
- class AgentTask extends import_base.BaseEntity {
47
- constructor(props, status, goal, nextNode, threadId, previousTaskId, summary, loopName, actions = []) {
48
- super(props);
49
- this.props = props;
50
- this.status = status;
51
- this.goal = goal;
52
- this.nextNode = nextNode;
53
- this.threadId = threadId;
54
- this.previousTaskId = previousTaskId;
55
- this.summary = summary;
56
- this.loopName = loopName;
57
- this.actions = actions;
58
- }
59
- props;
60
- status;
61
- goal;
62
- nextNode;
63
- threadId;
64
- previousTaskId;
65
- summary;
66
- loopName;
67
- actions;
68
- static factory(task) {
69
- const taskId = task._id && import_mongodb.ObjectId.isValid(task._id) ? new import_mongodb.ObjectId(task._id) : new import_mongodb.ObjectId();
70
- return AgentTask.fromJSON({
71
- ...task,
72
- _id: taskId,
73
- status: task.status ?? "in_progress" /* IN_PROGRESS */
74
- });
75
- }
76
- static fromJSON(props) {
77
- return new AgentTask(
78
- props,
79
- props.status,
80
- props.goal,
81
- props.nextNode,
82
- props.threadId,
83
- props.previousTaskId,
84
- props.summary,
85
- props.loopName,
86
- props.actions?.map((a) => import_agent_action.AgentAction.factory(a)) ?? []
87
- );
88
- }
89
- toJSON() {
90
- return {
91
- ...super.toJSON(),
92
- status: this.status,
93
- goal: this.goal,
94
- nextNode: this.nextNode,
95
- threadId: this.threadId,
96
- previousTaskId: this.previousTaskId,
97
- summary: this.summary,
98
- loopName: this.loopName,
99
- actions: this.actions.map((a) => a.toJSON())
100
- };
101
- }
102
- get id() {
103
- return this._id.toString();
104
- }
105
- addAction(descriptor) {
106
- const action = import_agent_action.AgentAction.factory({
107
- name: descriptor.name,
108
- stepId: descriptor.stepId,
109
- args: descriptor.args,
110
- dependsOn: descriptor.dependsOn,
111
- reasoning: descriptor.reasoning,
112
- author: descriptor.author
113
- });
114
- this.actions.push(action);
115
- return action;
116
- }
117
- getAction(ref) {
118
- return this.actions.find((a) => a.id === ref || a.stepId === ref);
119
- }
120
- findLastByName(name) {
121
- return this.actions.slice().reverse().find((a) => a.name === name);
122
- }
123
- /** Actions en `pending` cuyas dependencias (por stepId o id) ya están `completed` */
124
- get readyActions() {
125
- const completedRefs = new Set(
126
- this.actions.filter((a) => a.status === "completed").flatMap((a) => [a.id, a.stepId].filter(Boolean))
127
- );
128
- return this.actions.filter((a) => a.isReady && a.dependenciesSatisfiedBy(completedRefs));
129
- }
130
- get failedActions() {
131
- return this.actions.filter((a) => a.status === "failed");
132
- }
133
- get lastExecutedAction() {
134
- return this.actions.slice().reverse().find((a) => a.isTerminal);
135
- }
136
- setNextNode(node) {
137
- this.nextNode = node;
138
- }
139
- complete(summary) {
140
- this.status = "completed" /* COMPLETED */;
141
- if (summary) this.summary = summary;
142
- this.nextNode = void 0;
143
- }
144
- fail() {
145
- this.status = "failed" /* FAILED */;
146
- this.nextNode = void 0;
147
- }
148
- cancel() {
149
- this.status = "cancelled" /* CANCELLED */;
150
- this.nextNode = void 0;
151
- }
152
- pause() {
153
- if (this.status === "in_progress" /* IN_PROGRESS */ || this.status === "awaiting_user" /* AWAITING_USER */) {
154
- this.status = "paused" /* PAUSED */;
155
- }
156
- }
157
- reopen() {
158
- this.status = "in_progress" /* IN_PROGRESS */;
159
- this.nextNode = void 0;
160
- }
161
- resolveArgs(action, context) {
162
- return this.resolveValue(action.args, context);
163
- }
164
- resolveValue(value, context) {
165
- if (typeof value === "string") {
166
- const stepMatch = value.match(STEP_REF);
167
- if (stepMatch) {
168
- const target = this.findActionByRef(stepMatch[1]);
169
- return target?.output !== void 0 ? target.output : value;
170
- }
171
- const contextMatch = value.match(CONTEXT_REF);
172
- if (contextMatch) {
173
- const resolved = this.readContextValue(contextMatch[1], context);
174
- return resolved !== void 0 ? resolved : value;
175
- }
176
- return value.replace(STEP_REF_GLOBAL, (_, ref) => {
177
- const target = this.findActionByRef(ref);
178
- return target?.output !== void 0 ? stringifyValue(target.output) : "";
179
- }).replace(CONTEXT_REF_GLOBAL, (_, name) => {
180
- const resolved = this.readContextValue(name, context);
181
- return resolved !== void 0 ? stringifyValue(resolved) : "";
182
- });
183
- }
184
- if (Array.isArray(value)) {
185
- return value.map((item) => this.resolveValue(item, context));
186
- }
187
- if (value !== null && typeof value === "object") {
188
- const resolved = {};
189
- for (const key of Object.keys(value)) {
190
- resolved[key] = this.resolveValue(value[key], context);
191
- }
192
- return resolved;
193
- }
194
- return value;
195
- }
196
- findActionByRef(ref) {
197
- return this.actions.find((a) => a.stepId === ref || a.id === ref);
198
- }
199
- readContextValue(name, context) {
200
- const matches = context.selectContext({ taskId: this.id, name });
201
- return matches?.[0]?.content;
202
- }
203
- /** Crea una action nueva y la corre de inmediato (estilo reactivo) */
204
- async runTool(descriptor, tool, context, baseParams) {
205
- const action = this.addAction(descriptor);
206
- return this.executeToolAction(action, tool, context, baseParams);
207
- }
208
- /** Corre una action ya encolada (estilo por lotes: actionPlanner encola, esto ejecuta cuando está `ready`) */
209
- async runReadyAction(actionRef, tool, context, baseParams) {
210
- const action = this.getAction(actionRef);
211
- if (!action) throw new Error(`[AgentTask] Action "${actionRef}" not found`);
212
- return this.executeToolAction(action, tool, context, baseParams);
213
- }
214
- async executeToolAction(action, tool, context, baseParams) {
215
- const resolvedArgs = this.resolveArgs(action, context);
216
- const executed = await action.runTool(tool, resolvedArgs, baseParams);
217
- if (executed.status === "completed" && executed.name) {
218
- context.addContext({
219
- taskId: this.id,
220
- meta: { name: executed.name, type: "tool_output", shortDescription: `Output of ${executed.name}` },
221
- content: executed.output
222
- });
223
- }
224
- return executed;
225
- }
226
- }
227
- // Annotate the CommonJS export names for ESM import in node:
228
- 0 && (module.exports = {
229
- AgentTask,
230
- TaskStatus
231
- });