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,207 +0,0 @@
1
- import "../../../chunk-CF3WOMB3.mjs";
2
- import { ObjectId } from "mongodb";
3
- import { BaseEntity } from "../../../common/base/base.entity.js";
4
- import { AgentAction } from "./agent-action.entity";
5
- var TaskStatus = /* @__PURE__ */ ((TaskStatus2) => {
6
- TaskStatus2["PENDING"] = "pending";
7
- TaskStatus2["IN_PROGRESS"] = "in_progress";
8
- TaskStatus2["AWAITING_USER"] = "awaiting_user";
9
- TaskStatus2["COMPLETED"] = "completed";
10
- TaskStatus2["PAUSED"] = "paused";
11
- TaskStatus2["ABANDONED"] = "abandoned";
12
- TaskStatus2["CANCELLED"] = "cancelled";
13
- TaskStatus2["FAILED"] = "failed";
14
- return TaskStatus2;
15
- })(TaskStatus || {});
16
- const STEP_REF = /^\{\{step_([\w-]+)\.output\}\}$/;
17
- const STEP_REF_GLOBAL = /\{\{step_([\w-]+)\.output\}\}/g;
18
- const CONTEXT_REF = /^\{\{context\.([\w.-]+)\}\}$/;
19
- const CONTEXT_REF_GLOBAL = /\{\{context\.([\w.-]+)\}\}/g;
20
- function stringifyValue(value) {
21
- return typeof value === "object" ? JSON.stringify(value) : String(value);
22
- }
23
- class AgentTask extends BaseEntity {
24
- constructor(props, status, goal, nextNode, threadId, previousTaskId, summary, loopName, actions = []) {
25
- super(props);
26
- this.props = props;
27
- this.status = status;
28
- this.goal = goal;
29
- this.nextNode = nextNode;
30
- this.threadId = threadId;
31
- this.previousTaskId = previousTaskId;
32
- this.summary = summary;
33
- this.loopName = loopName;
34
- this.actions = actions;
35
- }
36
- props;
37
- status;
38
- goal;
39
- nextNode;
40
- threadId;
41
- previousTaskId;
42
- summary;
43
- loopName;
44
- actions;
45
- static factory(task) {
46
- const taskId = task._id && ObjectId.isValid(task._id) ? new ObjectId(task._id) : new ObjectId();
47
- return AgentTask.fromJSON({
48
- ...task,
49
- _id: taskId,
50
- status: task.status ?? "in_progress" /* IN_PROGRESS */
51
- });
52
- }
53
- static fromJSON(props) {
54
- return new AgentTask(
55
- props,
56
- props.status,
57
- props.goal,
58
- props.nextNode,
59
- props.threadId,
60
- props.previousTaskId,
61
- props.summary,
62
- props.loopName,
63
- props.actions?.map((a) => AgentAction.factory(a)) ?? []
64
- );
65
- }
66
- toJSON() {
67
- return {
68
- ...super.toJSON(),
69
- status: this.status,
70
- goal: this.goal,
71
- nextNode: this.nextNode,
72
- threadId: this.threadId,
73
- previousTaskId: this.previousTaskId,
74
- summary: this.summary,
75
- loopName: this.loopName,
76
- actions: this.actions.map((a) => a.toJSON())
77
- };
78
- }
79
- get id() {
80
- return this._id.toString();
81
- }
82
- addAction(descriptor) {
83
- const action = AgentAction.factory({
84
- name: descriptor.name,
85
- stepId: descriptor.stepId,
86
- args: descriptor.args,
87
- dependsOn: descriptor.dependsOn,
88
- reasoning: descriptor.reasoning,
89
- author: descriptor.author
90
- });
91
- this.actions.push(action);
92
- return action;
93
- }
94
- getAction(ref) {
95
- return this.actions.find((a) => a.id === ref || a.stepId === ref);
96
- }
97
- findLastByName(name) {
98
- return this.actions.slice().reverse().find((a) => a.name === name);
99
- }
100
- /** Actions en `pending` cuyas dependencias (por stepId o id) ya están `completed` */
101
- get readyActions() {
102
- const completedRefs = new Set(
103
- this.actions.filter((a) => a.status === "completed").flatMap((a) => [a.id, a.stepId].filter(Boolean))
104
- );
105
- return this.actions.filter((a) => a.isReady && a.dependenciesSatisfiedBy(completedRefs));
106
- }
107
- get failedActions() {
108
- return this.actions.filter((a) => a.status === "failed");
109
- }
110
- get lastExecutedAction() {
111
- return this.actions.slice().reverse().find((a) => a.isTerminal);
112
- }
113
- setNextNode(node) {
114
- this.nextNode = node;
115
- }
116
- complete(summary) {
117
- this.status = "completed" /* COMPLETED */;
118
- if (summary) this.summary = summary;
119
- this.nextNode = void 0;
120
- }
121
- fail() {
122
- this.status = "failed" /* FAILED */;
123
- this.nextNode = void 0;
124
- }
125
- cancel() {
126
- this.status = "cancelled" /* CANCELLED */;
127
- this.nextNode = void 0;
128
- }
129
- pause() {
130
- if (this.status === "in_progress" /* IN_PROGRESS */ || this.status === "awaiting_user" /* AWAITING_USER */) {
131
- this.status = "paused" /* PAUSED */;
132
- }
133
- }
134
- reopen() {
135
- this.status = "in_progress" /* IN_PROGRESS */;
136
- this.nextNode = void 0;
137
- }
138
- resolveArgs(action, context) {
139
- return this.resolveValue(action.args, context);
140
- }
141
- resolveValue(value, context) {
142
- if (typeof value === "string") {
143
- const stepMatch = value.match(STEP_REF);
144
- if (stepMatch) {
145
- const target = this.findActionByRef(stepMatch[1]);
146
- return target?.output !== void 0 ? target.output : value;
147
- }
148
- const contextMatch = value.match(CONTEXT_REF);
149
- if (contextMatch) {
150
- const resolved = this.readContextValue(contextMatch[1], context);
151
- return resolved !== void 0 ? resolved : value;
152
- }
153
- return value.replace(STEP_REF_GLOBAL, (_, ref) => {
154
- const target = this.findActionByRef(ref);
155
- return target?.output !== void 0 ? stringifyValue(target.output) : "";
156
- }).replace(CONTEXT_REF_GLOBAL, (_, name) => {
157
- const resolved = this.readContextValue(name, context);
158
- return resolved !== void 0 ? stringifyValue(resolved) : "";
159
- });
160
- }
161
- if (Array.isArray(value)) {
162
- return value.map((item) => this.resolveValue(item, context));
163
- }
164
- if (value !== null && typeof value === "object") {
165
- const resolved = {};
166
- for (const key of Object.keys(value)) {
167
- resolved[key] = this.resolveValue(value[key], context);
168
- }
169
- return resolved;
170
- }
171
- return value;
172
- }
173
- findActionByRef(ref) {
174
- return this.actions.find((a) => a.stepId === ref || a.id === ref);
175
- }
176
- readContextValue(name, context) {
177
- const matches = context.selectContext({ taskId: this.id, name });
178
- return matches?.[0]?.content;
179
- }
180
- /** Crea una action nueva y la corre de inmediato (estilo reactivo) */
181
- async runTool(descriptor, tool, context, baseParams) {
182
- const action = this.addAction(descriptor);
183
- return this.executeToolAction(action, tool, context, baseParams);
184
- }
185
- /** Corre una action ya encolada (estilo por lotes: actionPlanner encola, esto ejecuta cuando está `ready`) */
186
- async runReadyAction(actionRef, tool, context, baseParams) {
187
- const action = this.getAction(actionRef);
188
- if (!action) throw new Error(`[AgentTask] Action "${actionRef}" not found`);
189
- return this.executeToolAction(action, tool, context, baseParams);
190
- }
191
- async executeToolAction(action, tool, context, baseParams) {
192
- const resolvedArgs = this.resolveArgs(action, context);
193
- const executed = await action.runTool(tool, resolvedArgs, baseParams);
194
- if (executed.status === "completed" && executed.name) {
195
- context.addContext({
196
- taskId: this.id,
197
- meta: { name: executed.name, type: "tool_output", shortDescription: `Output of ${executed.name}` },
198
- content: executed.output
199
- });
200
- }
201
- return executed;
202
- }
203
- }
204
- export {
205
- AgentTask,
206
- TaskStatus
207
- };
@@ -1,39 +0,0 @@
1
- type ContextRecordType = 'message' | 'file' | 'entity' | 'tool_output' | 'artifact' | 'summary';
2
- export interface ContextRecord {
3
- taskId: string;
4
- meta: {
5
- name: string;
6
- type: ContextRecordType;
7
- shortDescription: string;
8
- };
9
- content: any;
10
- }
11
- export interface ChatContextProps {
12
- items?: ContextRecord[];
13
- }
14
- export declare class ChatContext {
15
- private readonly props;
16
- items?: ContextRecord[] | undefined;
17
- private readonly MEMORY_CONTEXT_MAX_CHARS;
18
- static fromJSON(props: ChatContextProps): ChatContext;
19
- constructor(props: ChatContextProps, items?: ContextRecord[] | undefined);
20
- get length(): number;
21
- get allMeta(): {
22
- name: string;
23
- type: ContextRecordType;
24
- shortDescription: string;
25
- }[] | undefined;
26
- toJSON(): ChatContextProps;
27
- addContext(contextRecord: any): void;
28
- selectContext(filters: {
29
- taskId: string;
30
- name: string;
31
- }): ContextRecord[] | undefined;
32
- lastContext(filters: {
33
- taskId: string;
34
- name: string;
35
- }): ContextRecord | undefined;
36
- compress(): void;
37
- pruneContext(): void;
38
- }
39
- export {};
@@ -1,70 +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 chat_context_entity_exports = {};
20
- __export(chat_context_entity_exports, {
21
- ChatContext: () => ChatContext
22
- });
23
- module.exports = __toCommonJS(chat_context_entity_exports);
24
- class ChatContext {
25
- constructor(props, items) {
26
- this.props = props;
27
- this.items = items;
28
- }
29
- props;
30
- items;
31
- MEMORY_CONTEXT_MAX_CHARS = 1e4;
32
- static fromJSON(props) {
33
- return new ChatContext(
34
- props,
35
- props.items
36
- );
37
- }
38
- get length() {
39
- return this.items ? JSON.stringify(this.items).length : 0;
40
- }
41
- get allMeta() {
42
- return this.items?.map((item) => item.meta);
43
- }
44
- toJSON() {
45
- return {
46
- items: this.items
47
- };
48
- }
49
- addContext(contextRecord) {
50
- this.items ??= [];
51
- this.items.push(contextRecord);
52
- }
53
- selectContext(filters) {
54
- return this.items?.filter((item) => {
55
- return (filters.taskId === void 0 || item.taskId === filters.taskId) && (filters.name === void 0 || item.meta.name === filters.name);
56
- });
57
- }
58
- lastContext(filters) {
59
- const matches = this.selectContext(filters);
60
- return matches?.[matches.length - 1];
61
- }
62
- compress() {
63
- }
64
- pruneContext() {
65
- }
66
- }
67
- // Annotate the CommonJS export names for ESM import in node:
68
- 0 && (module.exports = {
69
- ChatContext
70
- });
@@ -1,47 +0,0 @@
1
- import "../../../chunk-CF3WOMB3.mjs";
2
- class ChatContext {
3
- constructor(props, items) {
4
- this.props = props;
5
- this.items = items;
6
- }
7
- props;
8
- items;
9
- MEMORY_CONTEXT_MAX_CHARS = 1e4;
10
- static fromJSON(props) {
11
- return new ChatContext(
12
- props,
13
- props.items
14
- );
15
- }
16
- get length() {
17
- return this.items ? JSON.stringify(this.items).length : 0;
18
- }
19
- get allMeta() {
20
- return this.items?.map((item) => item.meta);
21
- }
22
- toJSON() {
23
- return {
24
- items: this.items
25
- };
26
- }
27
- addContext(contextRecord) {
28
- this.items ??= [];
29
- this.items.push(contextRecord);
30
- }
31
- selectContext(filters) {
32
- return this.items?.filter((item) => {
33
- return (filters.taskId === void 0 || item.taskId === filters.taskId) && (filters.name === void 0 || item.meta.name === filters.name);
34
- });
35
- }
36
- lastContext(filters) {
37
- const matches = this.selectContext(filters);
38
- return matches?.[matches.length - 1];
39
- }
40
- compress() {
41
- }
42
- pruneContext() {
43
- }
44
- }
45
- export {
46
- ChatContext
47
- };
File without changes
File without changes
File without changes
File without changes
File without changes