openloops 0.1.31 → 0.1.32

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 (249) 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 +198 -0
  22. package/dist/harness/native-tools.mjs +174 -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 +192 -0
  28. package/dist/harness/tool-pipeline.mjs +169 -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/workspace.d.ts +44 -0
  33. package/dist/harness/workspace.js +95 -0
  34. package/dist/harness/workspace.mjs +78 -0
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.js +2 -2
  37. package/dist/index.mjs +1 -1
  38. package/dist/loops/agi/index.d.ts +1 -0
  39. package/dist/loops/agi/index.js +22 -0
  40. package/dist/loops/agi/index.mjs +1 -0
  41. package/dist/loops/agi/loop.d.ts +24 -0
  42. package/dist/loops/agi/loop.js +207 -0
  43. package/dist/loops/agi/loop.mjs +184 -0
  44. package/dist/loops/agi/skills/reasoning-engine.d.ts +14 -0
  45. package/dist/loops/agi/skills/reasoning-engine.js +93 -0
  46. package/dist/loops/agi/skills/reasoning-engine.mjs +70 -0
  47. package/dist/loops/index.d.ts +1 -0
  48. package/dist/loops/index.js +3 -1
  49. package/dist/loops/index.mjs +1 -0
  50. package/dist/loops/plan-execute/plan-execute-loop.d.ts +2 -1
  51. package/dist/loops/plan-execute/plan-execute-loop.js +90 -35
  52. package/dist/loops/plan-execute/plan-execute-loop.mjs +80 -25
  53. package/dist/loops/shared/skills/action-planner.js +7 -4
  54. package/dist/loops/shared/skills/action-planner.mjs +7 -4
  55. package/dist/loops/shared/skills/final-responder.js +4 -3
  56. package/dist/loops/shared/skills/final-responder.mjs +4 -3
  57. package/dist/loops/shared/skills/state-observer.js +6 -2
  58. package/dist/loops/shared/skills/state-observer.mjs +6 -2
  59. package/dist/services/chats/entities/chat-message.entity.d.ts +4 -1
  60. package/dist/services/chats/entities/chat-message.entity.js +7 -3
  61. package/dist/services/chats/entities/chat-message.entity.mjs +7 -3
  62. package/dist/services/chats/entities/chat.entity.d.ts +10 -11
  63. package/dist/services/chats/entities/chat.entity.js +17 -21
  64. package/dist/services/chats/entities/chat.entity.mjs +17 -21
  65. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.d.ts +2 -0
  66. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.js +4 -4
  67. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.mjs +2 -2
  68. package/dist/services/tasks/entities/agent-action.entity.d.ts +111 -0
  69. package/dist/services/tasks/entities/agent-action.entity.js +269 -0
  70. package/dist/services/tasks/entities/agent-action.entity.mjs +245 -0
  71. package/dist/services/tasks/entities/agent-task.entity.d.ts +172 -0
  72. package/dist/services/tasks/entities/agent-task.entity.js +665 -0
  73. package/dist/services/tasks/entities/agent-task.entity.mjs +633 -0
  74. package/dist/services/tasks/entities/index.d.ts +2 -0
  75. package/dist/services/tasks/entities/index.js +24 -0
  76. package/dist/services/tasks/entities/index.mjs +2 -0
  77. package/dist/services/tasks/index.d.ts +3 -0
  78. package/dist/services/tasks/index.js +26 -0
  79. package/dist/services/tasks/index.mjs +3 -0
  80. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.d.ts +14 -0
  81. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.js +60 -0
  82. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.mjs +31 -0
  83. package/dist/services/tasks/lambdas/create-agent-action/index.d.ts +1 -0
  84. package/dist/services/tasks/lambdas/create-agent-action/index.js +22 -0
  85. package/dist/services/tasks/lambdas/create-agent-action/index.mjs +1 -0
  86. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.d.ts +14 -0
  87. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.js +60 -0
  88. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.mjs +31 -0
  89. package/dist/services/tasks/lambdas/create-agent-task/index.d.ts +1 -0
  90. package/dist/services/tasks/lambdas/create-agent-task/index.js +22 -0
  91. package/dist/services/tasks/lambdas/create-agent-task/index.mjs +1 -0
  92. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.d.ts +14 -0
  93. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.js +55 -0
  94. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.mjs +26 -0
  95. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.d.ts +1 -0
  96. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.js +22 -0
  97. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.mjs +1 -0
  98. package/dist/services/tasks/lambdas/index.d.ts +7 -0
  99. package/dist/services/tasks/lambdas/index.js +46 -0
  100. package/dist/services/tasks/lambdas/index.mjs +17 -0
  101. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.d.ts +1 -0
  102. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.js +22 -0
  103. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.mjs +1 -0
  104. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.d.ts +16 -0
  105. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.js +62 -0
  106. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.mjs +33 -0
  107. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.d.ts +1 -0
  108. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.js +22 -0
  109. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.mjs +1 -0
  110. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.d.ts +16 -0
  111. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.js +62 -0
  112. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.mjs +33 -0
  113. package/dist/services/tasks/lambdas/update-agent-action/index.d.ts +1 -0
  114. package/dist/services/tasks/lambdas/update-agent-action/index.js +22 -0
  115. package/dist/services/tasks/lambdas/update-agent-action/index.mjs +1 -0
  116. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.d.ts +15 -0
  117. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.js +67 -0
  118. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.mjs +38 -0
  119. package/dist/services/tasks/lambdas/update-agent-task/index.d.ts +1 -0
  120. package/dist/services/tasks/lambdas/update-agent-task/index.js +22 -0
  121. package/dist/services/tasks/lambdas/update-agent-task/index.mjs +1 -0
  122. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.d.ts +15 -0
  123. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.js +67 -0
  124. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.mjs +38 -0
  125. package/dist/services/tasks/module.d.ts +15 -0
  126. package/dist/services/tasks/module.js +76 -0
  127. package/dist/services/tasks/module.mjs +47 -0
  128. package/dist/services/tasks/repositories/agent-action.repository.d.ts +8 -0
  129. package/dist/services/tasks/repositories/agent-action.repository.js +62 -0
  130. package/dist/services/tasks/repositories/agent-action.repository.mjs +33 -0
  131. package/dist/services/tasks/repositories/agent-task.repository.d.ts +9 -0
  132. package/dist/services/tasks/repositories/agent-task.repository.js +65 -0
  133. package/dist/services/tasks/repositories/agent-task.repository.mjs +36 -0
  134. package/dist/services/tasks/repositories/index.d.ts +2 -0
  135. package/dist/services/tasks/repositories/index.js +24 -0
  136. package/dist/services/tasks/repositories/index.mjs +2 -0
  137. package/dist/services/traces/entities/agent-trace-entry.entity.d.ts +30 -0
  138. package/dist/services/traces/entities/agent-trace-entry.entity.js +85 -0
  139. package/dist/services/traces/entities/agent-trace-entry.entity.mjs +62 -0
  140. package/dist/services/traces/entities/index.d.ts +1 -0
  141. package/dist/services/traces/entities/index.js +22 -0
  142. package/dist/services/traces/entities/index.mjs +1 -0
  143. package/dist/services/traces/index.d.ts +3 -0
  144. package/dist/services/traces/index.js +26 -0
  145. package/dist/services/traces/index.mjs +3 -0
  146. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.d.ts +16 -0
  147. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.js +62 -0
  148. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.mjs +33 -0
  149. package/dist/services/traces/lambdas/create-agent-traces/index.d.ts +1 -0
  150. package/dist/services/traces/lambdas/create-agent-traces/index.js +22 -0
  151. package/dist/services/traces/lambdas/create-agent-traces/index.mjs +1 -0
  152. package/dist/services/traces/lambdas/index.d.ts +2 -0
  153. package/dist/services/traces/lambdas/index.js +31 -0
  154. package/dist/services/traces/lambdas/index.mjs +7 -0
  155. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.d.ts +1 -0
  156. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.js +22 -0
  157. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.mjs +1 -0
  158. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.d.ts +18 -0
  159. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.js +67 -0
  160. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.mjs +38 -0
  161. package/dist/services/traces/module.d.ts +5 -0
  162. package/dist/services/traces/module.js +41 -0
  163. package/dist/services/traces/module.mjs +17 -0
  164. package/dist/services/traces/repositories/agent-trace.repository.d.ts +7 -0
  165. package/dist/services/traces/repositories/agent-trace.repository.js +55 -0
  166. package/dist/services/traces/repositories/agent-trace.repository.mjs +26 -0
  167. package/dist/services/traces/repositories/index.d.ts +1 -0
  168. package/dist/services/traces/repositories/index.js +22 -0
  169. package/dist/services/traces/repositories/index.mjs +1 -0
  170. package/dist/services/workspaces/entities/index.d.ts +1 -0
  171. package/dist/services/workspaces/entities/index.js +22 -0
  172. package/dist/services/workspaces/entities/index.mjs +1 -0
  173. package/dist/services/workspaces/entities/workspace-item.entity.d.ts +33 -0
  174. package/dist/services/workspaces/entities/workspace-item.entity.js +95 -0
  175. package/dist/services/workspaces/entities/workspace-item.entity.mjs +72 -0
  176. package/dist/services/workspaces/index.d.ts +3 -0
  177. package/dist/services/workspaces/index.js +26 -0
  178. package/dist/services/workspaces/index.mjs +3 -0
  179. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.d.ts +17 -0
  180. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.js +68 -0
  181. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.mjs +39 -0
  182. package/dist/services/workspaces/lambdas/delete-workspace-item/index.d.ts +1 -0
  183. package/dist/services/workspaces/lambdas/delete-workspace-item/index.js +22 -0
  184. package/dist/services/workspaces/lambdas/delete-workspace-item/index.mjs +1 -0
  185. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.d.ts +17 -0
  186. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.js +67 -0
  187. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.mjs +38 -0
  188. package/dist/services/workspaces/lambdas/get-workspace-item/index.d.ts +1 -0
  189. package/dist/services/workspaces/lambdas/get-workspace-item/index.js +22 -0
  190. package/dist/services/workspaces/lambdas/get-workspace-item/index.mjs +1 -0
  191. package/dist/services/workspaces/lambdas/index.d.ts +5 -0
  192. package/dist/services/workspaces/lambdas/index.js +40 -0
  193. package/dist/services/workspaces/lambdas/index.mjs +13 -0
  194. package/dist/services/workspaces/lambdas/list-workspace-items/index.d.ts +1 -0
  195. package/dist/services/workspaces/lambdas/list-workspace-items/index.js +22 -0
  196. package/dist/services/workspaces/lambdas/list-workspace-items/index.mjs +1 -0
  197. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.d.ts +18 -0
  198. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.js +69 -0
  199. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.mjs +40 -0
  200. package/dist/services/workspaces/lambdas/save-workspace-item/index.d.ts +1 -0
  201. package/dist/services/workspaces/lambdas/save-workspace-item/index.js +22 -0
  202. package/dist/services/workspaces/lambdas/save-workspace-item/index.mjs +1 -0
  203. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.d.ts +14 -0
  204. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.js +76 -0
  205. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.mjs +47 -0
  206. package/dist/services/workspaces/lambdas/search-workspace-items/index.d.ts +1 -0
  207. package/dist/services/workspaces/lambdas/search-workspace-items/index.js +22 -0
  208. package/dist/services/workspaces/lambdas/search-workspace-items/index.mjs +1 -0
  209. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.d.ts +19 -0
  210. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.js +73 -0
  211. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.mjs +44 -0
  212. package/dist/services/workspaces/module.d.ts +11 -0
  213. package/dist/services/workspaces/module.js +62 -0
  214. package/dist/services/workspaces/module.mjs +35 -0
  215. package/dist/services/workspaces/repositories/index.d.ts +1 -0
  216. package/dist/services/workspaces/repositories/index.js +22 -0
  217. package/dist/services/workspaces/repositories/index.mjs +1 -0
  218. package/dist/services/workspaces/repositories/workspace-item.repository.d.ts +18 -0
  219. package/dist/services/workspaces/repositories/workspace-item.repository.js +74 -0
  220. package/dist/services/workspaces/repositories/workspace-item.repository.mjs +45 -0
  221. package/dist/skills/runtime-context.d.ts +8 -0
  222. package/dist/skills/runtime-context.js +65 -0
  223. package/dist/skills/runtime-context.mjs +42 -0
  224. package/dist/skills/skill.d.ts +7 -0
  225. package/dist/skills/skill.js +26 -60
  226. package/dist/skills/skill.mjs +26 -60
  227. package/dist/tools/tool.d.ts +6 -0
  228. package/dist/tools/tool.js +56 -0
  229. package/dist/tools/tool.mjs +56 -0
  230. package/package.json +3 -3
  231. package/dist/agent/agent.js +0 -327
  232. package/dist/agent/agent.mjs +0 -303
  233. package/dist/services/chats/entities/agent-action.entity.d.ts +0 -58
  234. package/dist/services/chats/entities/agent-action.entity.js +0 -151
  235. package/dist/services/chats/entities/agent-action.entity.mjs +0 -128
  236. package/dist/services/chats/entities/agent-task.entity.d.ts +0 -59
  237. package/dist/services/chats/entities/agent-task.entity.js +0 -231
  238. package/dist/services/chats/entities/agent-task.entity.mjs +0 -207
  239. package/dist/services/chats/entities/chat-context.entity.d.ts +0 -39
  240. package/dist/services/chats/entities/chat-context.entity.js +0 -70
  241. package/dist/services/chats/entities/chat-context.entity.mjs +0 -47
  242. /package/dist/{agent → harness}/agent-loop.js +0 -0
  243. /package/dist/{agent → harness}/agent-loop.mjs +0 -0
  244. /package/dist/{agent → harness}/agent-state.d.ts +0 -0
  245. /package/dist/{agent → harness}/index.d.ts +0 -0
  246. /package/dist/{agent → harness}/index.mjs +0 -0
  247. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.d.ts +0 -0
  248. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.js +0 -0
  249. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.mjs +0 -0
@@ -0,0 +1,192 @@
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 tool_pipeline_exports = {};
20
+ __export(tool_pipeline_exports, {
21
+ ToolPipeline: () => ToolPipeline
22
+ });
23
+ module.exports = __toCommonJS(tool_pipeline_exports);
24
+ var import_base = require("../common/base/base.entity.js");
25
+ var import_agent_action = require("../services/tasks/entities/agent-action.entity.js");
26
+ var import_agent_task = require("../services/tasks/entities/agent-task.entity.js");
27
+ var import_tool_catalog = require("./tool-catalog");
28
+ var import_native_tools = require("./native-tools");
29
+ var import_describe_shape = require("./utils/describe-shape");
30
+ const DEFAULT_OFFLOAD_THRESHOLD_CHARS = 1e5;
31
+ const DEFAULT_STUB_THRESHOLD_CHARS = 4e3;
32
+ const TRANSIENT_PATTERN = /timeout|timed out|econn|enotfound|network|socket|\b50[234]\b|\b429\b|rate limit|temporar|unavailable|overloaded/i;
33
+ const NOT_FOUND_PATTERN = /not found|does not exist|doesn't exist|no existe|no encontrad/i;
34
+ const NOT_FOUND_NOTE = "Harness note: a name that fails once may only be written differently from how the system stores it. Do not ask the user whether the name is correct and do not conclude that it does not exist. Find a tool that lists or searches that kind of entity, run it, and compare the names normalized (case, spaces, hyphens, underscores). Treat any suggestion in the error as a hint to verify, not as the answer.";
35
+ const VALIDATION_PATTERN = /unexpected keyword argument|unexpected argument|missing required argument|validation errors? for/i;
36
+ const VALIDATION_NOTE = "Harness note: the arguments do not match the tool's schema. An unexpected argument is usually a misnamed version of a missing one: keep its value and use the name from the schema (HARNESS.schemas lists the arguments of the tools you have already seen).";
37
+ const AMBIGUOUS_PATTERN = /ambiguous|more than one (?:match|result|entity)|multiple (?:matches|results|entities)|\b\d+ \w+ match\b/i;
38
+ const AMBIGUOUS_NOTE = "Harness note: the system matched more than one entity, and even an exact name can be ambiguous. Use the unique identifier of the candidate the user chose, from the error or from a listing, in the same argument that took the name. If the user already chose, do not ask again, and never repeat the call with the name.";
39
+ const DEFAULT_MAX_STORED_CHARS = 2e6;
40
+ const DEFAULT_PREVIEW_CHARS = 500;
41
+ class ToolPipeline {
42
+ constructor(deps, options) {
43
+ this.deps = deps;
44
+ this.nativeTools = new import_native_tools.NativeTools({ workspace: deps.workspace, searchTools: deps.searchTools });
45
+ this.offloadThresholdChars = options?.offloadThresholdChars ?? DEFAULT_OFFLOAD_THRESHOLD_CHARS;
46
+ this.stubThresholdChars = options?.stubThresholdChars ?? DEFAULT_STUB_THRESHOLD_CHARS;
47
+ this.maxStoredChars = options?.maxStoredChars ?? DEFAULT_MAX_STORED_CHARS;
48
+ this.previewChars = options?.previewChars ?? DEFAULT_PREVIEW_CHARS;
49
+ }
50
+ deps;
51
+ offloadThresholdChars;
52
+ stubThresholdChars;
53
+ maxStoredChars;
54
+ previewChars;
55
+ nativeTools;
56
+ notFoundMessage(name) {
57
+ const invokers = this.deps.tools().map((tool) => tool.name).filter((toolName) => toolName.endsWith("__invoke_tool"));
58
+ const base = `Tool "${name}" is not in your tool list.`;
59
+ const suffix = `__${name.toLowerCase()}`;
60
+ const similar = this.deps.tools().map((tool) => tool.name).filter((toolName) => toolName.toLowerCase().endsWith(suffix));
61
+ if (similar.length) return `${base} Tool names include the server prefix, written in full. Did you mean ${similar.map((toolName) => `"${toolName}"`).join(" or ")}?`;
62
+ if (!invokers.length) return `${base} Use the exact tool names from your tool list.`;
63
+ const example = JSON.stringify({ tool: invokers[0], arguments: { name, arguments: {} } });
64
+ return `${base} It is a hidden tool of a server, so it cannot be called directly. Run it through the server's invoke tool (${invokers.join(", ")}) like this: ${example}, filling "arguments" with the input schema returned by the server's search.`;
65
+ }
66
+ searchUnavailableMessage() {
67
+ const searchers = this.deps.tools().map((tool) => tool.name).filter((toolName) => toolName.endsWith("__search_tools"));
68
+ const base = `Tool "${import_agent_task.SEARCH_TOOLS}" is not in your tool list: all the external tools you can use are already listed.`;
69
+ if (!searchers.length) return `${base} Use the exact tool names from your tool list.`;
70
+ return `${base} To find the hidden tools of a server, run that server's own search tool (${searchers.join(", ")}) following its description.`;
71
+ }
72
+ requiresApproval(action) {
73
+ const tool = this.findTool(action.name);
74
+ return Boolean(tool?.destructive) && !action.approved;
75
+ }
76
+ async run(task, action, opts) {
77
+ if (action.name === import_agent_task.SEARCH_TOOLS && !(0, import_tool_catalog.needsSearch)(this.deps.tools())) {
78
+ action.markFailed({ message: this.searchUnavailableMessage(), retryable: false });
79
+ return action;
80
+ }
81
+ if (import_agent_task.NATIVE_TOOL_NAMES.includes(action.name)) {
82
+ action.answerId = import_base.BaseEntity.toObjectId(this.deps.baseParams.answerId);
83
+ await this.nativeTools.run(task, action);
84
+ return action;
85
+ }
86
+ const tool = this.findTool(action.name);
87
+ if (!tool) {
88
+ action.markFailed({ message: this.notFoundMessage(String(action.name)), retryable: false });
89
+ return action;
90
+ }
91
+ if (tool.destructive && !action.approved) {
92
+ action.markFailed({ message: `Tool "${tool.name}" is destructive and needs explicit user confirmation before it can run`, retryable: false });
93
+ return action;
94
+ }
95
+ const sources = await this.loadSources(task, action);
96
+ const unresolved = [];
97
+ const args = task.resolveArgs(action, sources, unresolved);
98
+ if (unresolved.length) {
99
+ action.markFailed({ message: `Unresolved references in arguments: ${unresolved.join(", ")}. The referenced step output or path does not exist.`, retryable: false });
100
+ return action;
101
+ }
102
+ const failedBefore = task.findExecuted(action.name, args, { status: "failed", exclude: action });
103
+ if (failedBefore && !TRANSIENT_PATTERN.test(failedBefore.error?.message ?? "")) {
104
+ const previous = String(failedBefore.error?.message ?? "").slice(0, 500);
105
+ action.markFailed({ message: `An identical call to "${action.name}" already failed (ref ${failedBefore.stepId ?? failedBefore.id}) with: ${previous}
106
+
107
+ Repeating it will not change the result. Change the arguments or the approach.`, retryable: false });
108
+ return action;
109
+ }
110
+ if (opts?.blockDuplicates !== false) {
111
+ const duplicate = task.findExecuted(action.name, args, { status: "completed", exclude: action });
112
+ if (duplicate) {
113
+ action.markFailed({ message: `An identical call to "${action.name}" already completed (ref ${duplicate.stepId ?? duplicate.id}). Reuse its output instead of repeating it.`, retryable: false });
114
+ return action;
115
+ }
116
+ }
117
+ action.answerId = import_base.BaseEntity.toObjectId(this.deps.baseParams.answerId);
118
+ await action.runTool(tool, args, this.deps.baseParams);
119
+ if (action.status === "failed" && action.error) {
120
+ const message = action.error.message ?? "";
121
+ const notes = [
122
+ ...NOT_FOUND_PATTERN.test(message) ? [NOT_FOUND_NOTE] : [],
123
+ ...VALIDATION_PATTERN.test(message) ? [VALIDATION_NOTE] : [],
124
+ ...AMBIGUOUS_PATTERN.test(message) ? [AMBIGUOUS_NOTE] : []
125
+ ];
126
+ if (notes.length) action.error = { ...action.error, message: `${message}
127
+
128
+ ${notes.join("\n\n")}` };
129
+ }
130
+ if (action.status === "completed") {
131
+ task.learnSchemas(action.structuredOutput);
132
+ await this.offload(task, action);
133
+ }
134
+ return action;
135
+ }
136
+ findTool(name) {
137
+ return this.deps.tools().find((tool) => tool.name === name);
138
+ }
139
+ async loadSources(task, action) {
140
+ const { contexts } = import_agent_task.AgentTask.collectRefs(action.args);
141
+ const outputs = /* @__PURE__ */ new Map();
142
+ const notes = /* @__PURE__ */ new Map();
143
+ const offloaded = task.referencedActions(action.args).filter((a) => a.outputRef);
144
+ await Promise.all([
145
+ ...offloaded.map(async (referenced) => {
146
+ const item = await this.deps.workspace.get(referenced.outputRef, { taskId: task.id });
147
+ if (item && !item.truncated) outputs.set(referenced.id, item.content);
148
+ }),
149
+ ...Array.from(new Set(contexts)).map(async (name) => {
150
+ const item = await this.deps.workspace.get(name, { taskId: task.id });
151
+ if (item) notes.set(name, item.content);
152
+ })
153
+ ]);
154
+ return {
155
+ stepOutput: (referenced) => outputs.get(referenced.id),
156
+ context: (name) => notes.get(name)
157
+ };
158
+ }
159
+ async offload(task, action) {
160
+ const output = action.structuredOutput;
161
+ const text = typeof output === "string" ? output : JSON.stringify(output);
162
+ if (!text || text.length <= this.stubThresholdChars) return;
163
+ const name = `out_${String(action.stepId ?? action.id).replace(/[^\w-]/g, "_")}`;
164
+ const oversized = text.length > this.maxStoredChars;
165
+ try {
166
+ await this.deps.workspace.save({
167
+ name,
168
+ kind: "tool_output",
169
+ taskId: task.id,
170
+ source: action.name,
171
+ description: `Output of ${action.name}`,
172
+ content: oversized ? text.slice(0, this.maxStoredChars) : output,
173
+ truncated: oversized
174
+ });
175
+ const offloaded = {
176
+ ref: name,
177
+ totalChars: text.length,
178
+ outline: oversized ? void 0 : (0, import_describe_shape.describeShapeWithin)(output),
179
+ preview: text.slice(0, this.previewChars)
180
+ };
181
+ if (text.length > this.offloadThresholdChars) action.offloadOutput(offloaded);
182
+ else action.keepOutputWithStub(offloaded);
183
+ } catch (error) {
184
+ this.deps.logger.error({ error: error?.message ?? error, action: action.name }, "[TOOL PIPELINE] Failed to offload output, keeping a truncated copy");
185
+ if (text.length > this.offloadThresholdChars) action.output = (0, import_agent_action.truncateForPrompt)(output, this.offloadThresholdChars);
186
+ }
187
+ }
188
+ }
189
+ // Annotate the CommonJS export names for ESM import in node:
190
+ 0 && (module.exports = {
191
+ ToolPipeline
192
+ });
@@ -0,0 +1,169 @@
1
+ import "../chunk-CF3WOMB3.mjs";
2
+ import { BaseEntity } from "../common/base/base.entity.js";
3
+ import { truncateForPrompt } from "../services/tasks/entities/agent-action.entity.js";
4
+ import { AgentTask, NATIVE_TOOL_NAMES, SEARCH_TOOLS } from "../services/tasks/entities/agent-task.entity.js";
5
+ import { needsSearch } from "./tool-catalog";
6
+ import { NativeTools } from "./native-tools";
7
+ import { describeShapeWithin } from "./utils/describe-shape";
8
+ const DEFAULT_OFFLOAD_THRESHOLD_CHARS = 1e5;
9
+ const DEFAULT_STUB_THRESHOLD_CHARS = 4e3;
10
+ const TRANSIENT_PATTERN = /timeout|timed out|econn|enotfound|network|socket|\b50[234]\b|\b429\b|rate limit|temporar|unavailable|overloaded/i;
11
+ const NOT_FOUND_PATTERN = /not found|does not exist|doesn't exist|no existe|no encontrad/i;
12
+ const NOT_FOUND_NOTE = "Harness note: a name that fails once may only be written differently from how the system stores it. Do not ask the user whether the name is correct and do not conclude that it does not exist. Find a tool that lists or searches that kind of entity, run it, and compare the names normalized (case, spaces, hyphens, underscores). Treat any suggestion in the error as a hint to verify, not as the answer.";
13
+ const VALIDATION_PATTERN = /unexpected keyword argument|unexpected argument|missing required argument|validation errors? for/i;
14
+ const VALIDATION_NOTE = "Harness note: the arguments do not match the tool's schema. An unexpected argument is usually a misnamed version of a missing one: keep its value and use the name from the schema (HARNESS.schemas lists the arguments of the tools you have already seen).";
15
+ const AMBIGUOUS_PATTERN = /ambiguous|more than one (?:match|result|entity)|multiple (?:matches|results|entities)|\b\d+ \w+ match\b/i;
16
+ const AMBIGUOUS_NOTE = "Harness note: the system matched more than one entity, and even an exact name can be ambiguous. Use the unique identifier of the candidate the user chose, from the error or from a listing, in the same argument that took the name. If the user already chose, do not ask again, and never repeat the call with the name.";
17
+ const DEFAULT_MAX_STORED_CHARS = 2e6;
18
+ const DEFAULT_PREVIEW_CHARS = 500;
19
+ class ToolPipeline {
20
+ constructor(deps, options) {
21
+ this.deps = deps;
22
+ this.nativeTools = new NativeTools({ workspace: deps.workspace, searchTools: deps.searchTools });
23
+ this.offloadThresholdChars = options?.offloadThresholdChars ?? DEFAULT_OFFLOAD_THRESHOLD_CHARS;
24
+ this.stubThresholdChars = options?.stubThresholdChars ?? DEFAULT_STUB_THRESHOLD_CHARS;
25
+ this.maxStoredChars = options?.maxStoredChars ?? DEFAULT_MAX_STORED_CHARS;
26
+ this.previewChars = options?.previewChars ?? DEFAULT_PREVIEW_CHARS;
27
+ }
28
+ deps;
29
+ offloadThresholdChars;
30
+ stubThresholdChars;
31
+ maxStoredChars;
32
+ previewChars;
33
+ nativeTools;
34
+ notFoundMessage(name) {
35
+ const invokers = this.deps.tools().map((tool) => tool.name).filter((toolName) => toolName.endsWith("__invoke_tool"));
36
+ const base = `Tool "${name}" is not in your tool list.`;
37
+ const suffix = `__${name.toLowerCase()}`;
38
+ const similar = this.deps.tools().map((tool) => tool.name).filter((toolName) => toolName.toLowerCase().endsWith(suffix));
39
+ if (similar.length) return `${base} Tool names include the server prefix, written in full. Did you mean ${similar.map((toolName) => `"${toolName}"`).join(" or ")}?`;
40
+ if (!invokers.length) return `${base} Use the exact tool names from your tool list.`;
41
+ const example = JSON.stringify({ tool: invokers[0], arguments: { name, arguments: {} } });
42
+ return `${base} It is a hidden tool of a server, so it cannot be called directly. Run it through the server's invoke tool (${invokers.join(", ")}) like this: ${example}, filling "arguments" with the input schema returned by the server's search.`;
43
+ }
44
+ searchUnavailableMessage() {
45
+ const searchers = this.deps.tools().map((tool) => tool.name).filter((toolName) => toolName.endsWith("__search_tools"));
46
+ const base = `Tool "${SEARCH_TOOLS}" is not in your tool list: all the external tools you can use are already listed.`;
47
+ if (!searchers.length) return `${base} Use the exact tool names from your tool list.`;
48
+ return `${base} To find the hidden tools of a server, run that server's own search tool (${searchers.join(", ")}) following its description.`;
49
+ }
50
+ requiresApproval(action) {
51
+ const tool = this.findTool(action.name);
52
+ return Boolean(tool?.destructive) && !action.approved;
53
+ }
54
+ async run(task, action, opts) {
55
+ if (action.name === SEARCH_TOOLS && !needsSearch(this.deps.tools())) {
56
+ action.markFailed({ message: this.searchUnavailableMessage(), retryable: false });
57
+ return action;
58
+ }
59
+ if (NATIVE_TOOL_NAMES.includes(action.name)) {
60
+ action.answerId = BaseEntity.toObjectId(this.deps.baseParams.answerId);
61
+ await this.nativeTools.run(task, action);
62
+ return action;
63
+ }
64
+ const tool = this.findTool(action.name);
65
+ if (!tool) {
66
+ action.markFailed({ message: this.notFoundMessage(String(action.name)), retryable: false });
67
+ return action;
68
+ }
69
+ if (tool.destructive && !action.approved) {
70
+ action.markFailed({ message: `Tool "${tool.name}" is destructive and needs explicit user confirmation before it can run`, retryable: false });
71
+ return action;
72
+ }
73
+ const sources = await this.loadSources(task, action);
74
+ const unresolved = [];
75
+ const args = task.resolveArgs(action, sources, unresolved);
76
+ if (unresolved.length) {
77
+ action.markFailed({ message: `Unresolved references in arguments: ${unresolved.join(", ")}. The referenced step output or path does not exist.`, retryable: false });
78
+ return action;
79
+ }
80
+ const failedBefore = task.findExecuted(action.name, args, { status: "failed", exclude: action });
81
+ if (failedBefore && !TRANSIENT_PATTERN.test(failedBefore.error?.message ?? "")) {
82
+ const previous = String(failedBefore.error?.message ?? "").slice(0, 500);
83
+ action.markFailed({ message: `An identical call to "${action.name}" already failed (ref ${failedBefore.stepId ?? failedBefore.id}) with: ${previous}
84
+
85
+ Repeating it will not change the result. Change the arguments or the approach.`, retryable: false });
86
+ return action;
87
+ }
88
+ if (opts?.blockDuplicates !== false) {
89
+ const duplicate = task.findExecuted(action.name, args, { status: "completed", exclude: action });
90
+ if (duplicate) {
91
+ action.markFailed({ message: `An identical call to "${action.name}" already completed (ref ${duplicate.stepId ?? duplicate.id}). Reuse its output instead of repeating it.`, retryable: false });
92
+ return action;
93
+ }
94
+ }
95
+ action.answerId = BaseEntity.toObjectId(this.deps.baseParams.answerId);
96
+ await action.runTool(tool, args, this.deps.baseParams);
97
+ if (action.status === "failed" && action.error) {
98
+ const message = action.error.message ?? "";
99
+ const notes = [
100
+ ...NOT_FOUND_PATTERN.test(message) ? [NOT_FOUND_NOTE] : [],
101
+ ...VALIDATION_PATTERN.test(message) ? [VALIDATION_NOTE] : [],
102
+ ...AMBIGUOUS_PATTERN.test(message) ? [AMBIGUOUS_NOTE] : []
103
+ ];
104
+ if (notes.length) action.error = { ...action.error, message: `${message}
105
+
106
+ ${notes.join("\n\n")}` };
107
+ }
108
+ if (action.status === "completed") {
109
+ task.learnSchemas(action.structuredOutput);
110
+ await this.offload(task, action);
111
+ }
112
+ return action;
113
+ }
114
+ findTool(name) {
115
+ return this.deps.tools().find((tool) => tool.name === name);
116
+ }
117
+ async loadSources(task, action) {
118
+ const { contexts } = AgentTask.collectRefs(action.args);
119
+ const outputs = /* @__PURE__ */ new Map();
120
+ const notes = /* @__PURE__ */ new Map();
121
+ const offloaded = task.referencedActions(action.args).filter((a) => a.outputRef);
122
+ await Promise.all([
123
+ ...offloaded.map(async (referenced) => {
124
+ const item = await this.deps.workspace.get(referenced.outputRef, { taskId: task.id });
125
+ if (item && !item.truncated) outputs.set(referenced.id, item.content);
126
+ }),
127
+ ...Array.from(new Set(contexts)).map(async (name) => {
128
+ const item = await this.deps.workspace.get(name, { taskId: task.id });
129
+ if (item) notes.set(name, item.content);
130
+ })
131
+ ]);
132
+ return {
133
+ stepOutput: (referenced) => outputs.get(referenced.id),
134
+ context: (name) => notes.get(name)
135
+ };
136
+ }
137
+ async offload(task, action) {
138
+ const output = action.structuredOutput;
139
+ const text = typeof output === "string" ? output : JSON.stringify(output);
140
+ if (!text || text.length <= this.stubThresholdChars) return;
141
+ const name = `out_${String(action.stepId ?? action.id).replace(/[^\w-]/g, "_")}`;
142
+ const oversized = text.length > this.maxStoredChars;
143
+ try {
144
+ await this.deps.workspace.save({
145
+ name,
146
+ kind: "tool_output",
147
+ taskId: task.id,
148
+ source: action.name,
149
+ description: `Output of ${action.name}`,
150
+ content: oversized ? text.slice(0, this.maxStoredChars) : output,
151
+ truncated: oversized
152
+ });
153
+ const offloaded = {
154
+ ref: name,
155
+ totalChars: text.length,
156
+ outline: oversized ? void 0 : describeShapeWithin(output),
157
+ preview: text.slice(0, this.previewChars)
158
+ };
159
+ if (text.length > this.offloadThresholdChars) action.offloadOutput(offloaded);
160
+ else action.keepOutputWithStub(offloaded);
161
+ } catch (error) {
162
+ this.deps.logger.error({ error: error?.message ?? error, action: action.name }, "[TOOL PIPELINE] Failed to offload output, keeping a truncated copy");
163
+ if (text.length > this.offloadThresholdChars) action.output = truncateForPrompt(output, this.offloadThresholdChars);
164
+ }
165
+ }
166
+ }
167
+ export {
168
+ ToolPipeline
169
+ };
@@ -0,0 +1,2 @@
1
+ export declare function describeShape(value: any, depth?: number): any;
2
+ export declare function describeShapeWithin(value: any, maxChars?: number): any;
@@ -0,0 +1,56 @@
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 describe_shape_exports = {};
20
+ __export(describe_shape_exports, {
21
+ describeShape: () => describeShape,
22
+ describeShapeWithin: () => describeShapeWithin
23
+ });
24
+ module.exports = __toCommonJS(describe_shape_exports);
25
+ const MAX_KEYS = 20;
26
+ function describeShape(value, depth = 2) {
27
+ if (Array.isArray(value)) {
28
+ return {
29
+ type: "array",
30
+ length: value.length,
31
+ ...value.length && depth > 0 ? { item: describeShape(value[0], depth - 1) } : {}
32
+ };
33
+ }
34
+ if (value !== null && typeof value === "object") {
35
+ const keys = Object.keys(value);
36
+ if (depth <= 0) return { type: "object", keys: keys.slice(0, MAX_KEYS) };
37
+ const shape = {};
38
+ for (const key of keys.slice(0, MAX_KEYS)) shape[key] = describeShape(value[key], depth - 1);
39
+ if (keys.length > MAX_KEYS) shape["..."] = `${keys.length - MAX_KEYS} more keys`;
40
+ return shape;
41
+ }
42
+ if (typeof value === "string" && value.length > 80) return `string(${value.length})`;
43
+ return value === null ? "null" : typeof value;
44
+ }
45
+ function describeShapeWithin(value, maxChars = 1200) {
46
+ for (const depth of [3, 2, 1, 0]) {
47
+ const shape = describeShape(value, depth);
48
+ if (JSON.stringify(shape).length <= maxChars) return shape;
49
+ }
50
+ return describeShape(value, 0);
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ describeShape,
55
+ describeShapeWithin
56
+ });
@@ -0,0 +1,32 @@
1
+ import "../../chunk-CF3WOMB3.mjs";
2
+ const MAX_KEYS = 20;
3
+ function describeShape(value, depth = 2) {
4
+ if (Array.isArray(value)) {
5
+ return {
6
+ type: "array",
7
+ length: value.length,
8
+ ...value.length && depth > 0 ? { item: describeShape(value[0], depth - 1) } : {}
9
+ };
10
+ }
11
+ if (value !== null && typeof value === "object") {
12
+ const keys = Object.keys(value);
13
+ if (depth <= 0) return { type: "object", keys: keys.slice(0, MAX_KEYS) };
14
+ const shape = {};
15
+ for (const key of keys.slice(0, MAX_KEYS)) shape[key] = describeShape(value[key], depth - 1);
16
+ if (keys.length > MAX_KEYS) shape["..."] = `${keys.length - MAX_KEYS} more keys`;
17
+ return shape;
18
+ }
19
+ if (typeof value === "string" && value.length > 80) return `string(${value.length})`;
20
+ return value === null ? "null" : typeof value;
21
+ }
22
+ function describeShapeWithin(value, maxChars = 1200) {
23
+ for (const depth of [3, 2, 1, 0]) {
24
+ const shape = describeShape(value, depth);
25
+ if (JSON.stringify(shape).length <= maxChars) return shape;
26
+ }
27
+ return describeShape(value, 0);
28
+ }
29
+ export {
30
+ describeShape,
31
+ describeShapeWithin
32
+ };
@@ -0,0 +1,44 @@
1
+ import { CurrentUser } from '../common/base/index.js';
2
+ import { WorkspaceItemProps, WorkspaceItemKind } from '../services/workspaces/index.js';
3
+ export interface WorkspaceSaveInput {
4
+ name: string;
5
+ content: any;
6
+ kind?: WorkspaceItemKind;
7
+ description?: string;
8
+ taskId?: string;
9
+ source?: string;
10
+ truncated?: boolean;
11
+ }
12
+ export interface WorkspaceFilters {
13
+ taskId?: string;
14
+ kind?: WorkspaceItemKind;
15
+ limit?: number;
16
+ }
17
+ export interface Workspace {
18
+ save: (input: WorkspaceSaveInput) => Promise<WorkspaceItemProps>;
19
+ get: (name: string, opts?: {
20
+ taskId?: string;
21
+ includeContent?: boolean;
22
+ }) => Promise<WorkspaceItemProps | null>;
23
+ list: (filters?: WorkspaceFilters) => Promise<WorkspaceItemProps[]>;
24
+ search: (query: string, filters?: WorkspaceFilters) => Promise<WorkspaceItemProps[]>;
25
+ remove: (name: string, opts?: {
26
+ taskId?: string;
27
+ }) => Promise<number>;
28
+ }
29
+ export declare class AgentWorkspace implements Workspace {
30
+ private readonly chatId;
31
+ private readonly currentUser;
32
+ private readonly answerId?;
33
+ constructor(chatId: string, currentUser: CurrentUser, answerId?: string | undefined);
34
+ save(input: WorkspaceSaveInput): Promise<WorkspaceItemProps>;
35
+ get(name: string, opts?: {
36
+ taskId?: string;
37
+ includeContent?: boolean;
38
+ }): Promise<WorkspaceItemProps | null>;
39
+ list(filters?: WorkspaceFilters): Promise<WorkspaceItemProps[]>;
40
+ search(query: string, filters?: WorkspaceFilters): Promise<WorkspaceItemProps[]>;
41
+ remove(name: string, opts?: {
42
+ taskId?: string;
43
+ }): Promise<number>;
44
+ }
@@ -0,0 +1,95 @@
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 workspace_exports = {};
20
+ __export(workspace_exports, {
21
+ AgentWorkspace: () => AgentWorkspace
22
+ });
23
+ module.exports = __toCommonJS(workspace_exports);
24
+ var import_workspaces = require("../services/workspaces/index.js");
25
+ class AgentWorkspace {
26
+ constructor(chatId, currentUser, answerId) {
27
+ this.chatId = chatId;
28
+ this.currentUser = currentUser;
29
+ this.answerId = answerId;
30
+ }
31
+ chatId;
32
+ currentUser;
33
+ answerId;
34
+ async save(input) {
35
+ const { data } = await (0, import_workspaces.saveWorkspaceItem)({
36
+ payload: {
37
+ chatId: this.chatId,
38
+ taskId: input.taskId,
39
+ kind: input.kind ?? "note",
40
+ name: input.name,
41
+ description: input.description,
42
+ content: input.content,
43
+ source: input.source,
44
+ truncated: input.truncated,
45
+ answerId: this.answerId
46
+ },
47
+ currentUser: this.currentUser
48
+ });
49
+ return data;
50
+ }
51
+ async get(name, opts) {
52
+ const { data } = await (0, import_workspaces.getWorkspaceItem)({
53
+ chatId: this.chatId,
54
+ name,
55
+ taskId: opts?.taskId,
56
+ includeContent: opts?.includeContent,
57
+ currentUser: this.currentUser
58
+ });
59
+ return data;
60
+ }
61
+ async list(filters) {
62
+ const { data } = await (0, import_workspaces.listWorkspaceItems)({
63
+ chatId: this.chatId,
64
+ taskId: filters?.taskId,
65
+ kind: filters?.kind,
66
+ options: filters?.limit ? { limit: filters.limit } : void 0,
67
+ currentUser: this.currentUser
68
+ });
69
+ return data;
70
+ }
71
+ async search(query, filters) {
72
+ const { data } = await (0, import_workspaces.searchWorkspaceItems)({
73
+ chatId: this.chatId,
74
+ query,
75
+ taskId: filters?.taskId,
76
+ kind: filters?.kind,
77
+ options: filters?.limit ? { limit: filters.limit } : void 0,
78
+ currentUser: this.currentUser
79
+ });
80
+ return data;
81
+ }
82
+ async remove(name, opts) {
83
+ const { data } = await (0, import_workspaces.deleteWorkspaceItem)({
84
+ chatId: this.chatId,
85
+ name,
86
+ taskId: opts?.taskId,
87
+ currentUser: this.currentUser
88
+ });
89
+ return data.deletedCount;
90
+ }
91
+ }
92
+ // Annotate the CommonJS export names for ESM import in node:
93
+ 0 && (module.exports = {
94
+ AgentWorkspace
95
+ });
@@ -0,0 +1,78 @@
1
+ import "../chunk-CF3WOMB3.mjs";
2
+ import {
3
+ saveWorkspaceItem,
4
+ getWorkspaceItem,
5
+ listWorkspaceItems,
6
+ searchWorkspaceItems,
7
+ deleteWorkspaceItem
8
+ } from "../services/workspaces/index.js";
9
+ class AgentWorkspace {
10
+ constructor(chatId, currentUser, answerId) {
11
+ this.chatId = chatId;
12
+ this.currentUser = currentUser;
13
+ this.answerId = answerId;
14
+ }
15
+ chatId;
16
+ currentUser;
17
+ answerId;
18
+ async save(input) {
19
+ const { data } = await saveWorkspaceItem({
20
+ payload: {
21
+ chatId: this.chatId,
22
+ taskId: input.taskId,
23
+ kind: input.kind ?? "note",
24
+ name: input.name,
25
+ description: input.description,
26
+ content: input.content,
27
+ source: input.source,
28
+ truncated: input.truncated,
29
+ answerId: this.answerId
30
+ },
31
+ currentUser: this.currentUser
32
+ });
33
+ return data;
34
+ }
35
+ async get(name, opts) {
36
+ const { data } = await getWorkspaceItem({
37
+ chatId: this.chatId,
38
+ name,
39
+ taskId: opts?.taskId,
40
+ includeContent: opts?.includeContent,
41
+ currentUser: this.currentUser
42
+ });
43
+ return data;
44
+ }
45
+ async list(filters) {
46
+ const { data } = await listWorkspaceItems({
47
+ chatId: this.chatId,
48
+ taskId: filters?.taskId,
49
+ kind: filters?.kind,
50
+ options: filters?.limit ? { limit: filters.limit } : void 0,
51
+ currentUser: this.currentUser
52
+ });
53
+ return data;
54
+ }
55
+ async search(query, filters) {
56
+ const { data } = await searchWorkspaceItems({
57
+ chatId: this.chatId,
58
+ query,
59
+ taskId: filters?.taskId,
60
+ kind: filters?.kind,
61
+ options: filters?.limit ? { limit: filters.limit } : void 0,
62
+ currentUser: this.currentUser
63
+ });
64
+ return data;
65
+ }
66
+ async remove(name, opts) {
67
+ const { data } = await deleteWorkspaceItem({
68
+ chatId: this.chatId,
69
+ name,
70
+ taskId: opts?.taskId,
71
+ currentUser: this.currentUser
72
+ });
73
+ return data.deletedCount;
74
+ }
75
+ }
76
+ export {
77
+ AgentWorkspace
78
+ };
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './agent';
1
+ export * from './harness';