openloops 0.1.30 → 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 (251) hide show
  1. package/README.md +1 -1
  2. package/dist/clients/llm-client.d.ts +6 -1
  3. package/dist/clients/llm-client.js +77 -17
  4. package/dist/clients/llm-client.mjs +77 -17
  5. package/dist/clients/llm-error.d.ts +9 -0
  6. package/dist/clients/llm-error.js +69 -0
  7. package/dist/clients/llm-error.mjs +45 -0
  8. package/dist/clients/llm-types.d.ts +61 -0
  9. package/dist/clients/llm-types.js +16 -0
  10. package/dist/clients/llm-types.mjs +0 -0
  11. package/dist/clients/pi-ai-adapter.d.ts +7 -0
  12. package/dist/clients/pi-ai-adapter.js +137 -0
  13. package/dist/clients/pi-ai-adapter.mjs +113 -0
  14. package/dist/{agent → harness}/agent-loop.d.ts +11 -1
  15. package/dist/{agent → harness}/agent-state.js +1 -1
  16. package/dist/{agent → harness}/agent-state.mjs +1 -1
  17. package/dist/{agent → harness}/agent.d.ts +34 -3
  18. package/dist/harness/agent.js +546 -0
  19. package/dist/harness/agent.mjs +530 -0
  20. package/dist/{agent → harness}/index.js +5 -5
  21. package/dist/harness/native-tools.d.ts +23 -0
  22. package/dist/harness/native-tools.js +198 -0
  23. package/dist/harness/native-tools.mjs +174 -0
  24. package/dist/harness/tool-catalog.d.ts +16 -0
  25. package/dist/harness/tool-catalog.js +85 -0
  26. package/dist/harness/tool-catalog.mjs +59 -0
  27. package/dist/harness/tool-pipeline.d.ts +42 -0
  28. package/dist/harness/tool-pipeline.js +192 -0
  29. package/dist/harness/tool-pipeline.mjs +169 -0
  30. package/dist/harness/utils/describe-shape.d.ts +2 -0
  31. package/dist/harness/utils/describe-shape.js +56 -0
  32. package/dist/harness/utils/describe-shape.mjs +32 -0
  33. package/dist/harness/workspace.d.ts +44 -0
  34. package/dist/harness/workspace.js +95 -0
  35. package/dist/harness/workspace.mjs +78 -0
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.js +2 -2
  38. package/dist/index.mjs +1 -1
  39. package/dist/loops/agi/index.d.ts +1 -0
  40. package/dist/loops/agi/index.js +22 -0
  41. package/dist/loops/agi/index.mjs +1 -0
  42. package/dist/loops/agi/loop.d.ts +24 -0
  43. package/dist/loops/agi/loop.js +207 -0
  44. package/dist/loops/agi/loop.mjs +184 -0
  45. package/dist/loops/agi/skills/reasoning-engine.d.ts +14 -0
  46. package/dist/loops/agi/skills/reasoning-engine.js +93 -0
  47. package/dist/loops/agi/skills/reasoning-engine.mjs +70 -0
  48. package/dist/loops/index.d.ts +1 -0
  49. package/dist/loops/index.js +3 -1
  50. package/dist/loops/index.mjs +1 -0
  51. package/dist/loops/plan-execute/plan-execute-loop.d.ts +2 -1
  52. package/dist/loops/plan-execute/plan-execute-loop.js +90 -35
  53. package/dist/loops/plan-execute/plan-execute-loop.mjs +80 -25
  54. package/dist/loops/shared/skills/action-planner.js +7 -4
  55. package/dist/loops/shared/skills/action-planner.mjs +7 -4
  56. package/dist/loops/shared/skills/final-responder.js +4 -3
  57. package/dist/loops/shared/skills/final-responder.mjs +4 -3
  58. package/dist/loops/shared/skills/state-observer.js +6 -2
  59. package/dist/loops/shared/skills/state-observer.mjs +6 -2
  60. package/dist/services/chats/entities/chat-message.entity.d.ts +4 -1
  61. package/dist/services/chats/entities/chat-message.entity.js +7 -3
  62. package/dist/services/chats/entities/chat-message.entity.mjs +7 -3
  63. package/dist/services/chats/entities/chat.entity.d.ts +10 -11
  64. package/dist/services/chats/entities/chat.entity.js +17 -21
  65. package/dist/services/chats/entities/chat.entity.mjs +17 -21
  66. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.d.ts +2 -0
  67. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.js +4 -4
  68. package/dist/services/chats/lambdas/get-chat-by-id/get-chat-by-id.use-case.mjs +2 -2
  69. package/dist/services/llmcalls/entities/llmcall.entity.d.ts +1 -1
  70. package/dist/services/tasks/entities/agent-action.entity.d.ts +111 -0
  71. package/dist/services/tasks/entities/agent-action.entity.js +269 -0
  72. package/dist/services/tasks/entities/agent-action.entity.mjs +245 -0
  73. package/dist/services/tasks/entities/agent-task.entity.d.ts +172 -0
  74. package/dist/services/tasks/entities/agent-task.entity.js +665 -0
  75. package/dist/services/tasks/entities/agent-task.entity.mjs +633 -0
  76. package/dist/services/tasks/entities/index.d.ts +2 -0
  77. package/dist/services/tasks/entities/index.js +24 -0
  78. package/dist/services/tasks/entities/index.mjs +2 -0
  79. package/dist/services/tasks/index.d.ts +3 -0
  80. package/dist/services/tasks/index.js +26 -0
  81. package/dist/services/tasks/index.mjs +3 -0
  82. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.d.ts +14 -0
  83. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.js +60 -0
  84. package/dist/services/tasks/lambdas/create-agent-action/create-agent-action.use-case.mjs +31 -0
  85. package/dist/services/tasks/lambdas/create-agent-action/index.d.ts +1 -0
  86. package/dist/services/tasks/lambdas/create-agent-action/index.js +22 -0
  87. package/dist/services/tasks/lambdas/create-agent-action/index.mjs +1 -0
  88. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.d.ts +14 -0
  89. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.js +60 -0
  90. package/dist/services/tasks/lambdas/create-agent-task/create-agent-task.use-case.mjs +31 -0
  91. package/dist/services/tasks/lambdas/create-agent-task/index.d.ts +1 -0
  92. package/dist/services/tasks/lambdas/create-agent-task/index.js +22 -0
  93. package/dist/services/tasks/lambdas/create-agent-task/index.mjs +1 -0
  94. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.d.ts +14 -0
  95. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.js +55 -0
  96. package/dist/services/tasks/lambdas/get-agent-task-by-id/get-agent-task-by-id.use-case.mjs +26 -0
  97. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.d.ts +1 -0
  98. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.js +22 -0
  99. package/dist/services/tasks/lambdas/get-agent-task-by-id/index.mjs +1 -0
  100. package/dist/services/tasks/lambdas/index.d.ts +7 -0
  101. package/dist/services/tasks/lambdas/index.js +46 -0
  102. package/dist/services/tasks/lambdas/index.mjs +17 -0
  103. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.d.ts +1 -0
  104. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.js +22 -0
  105. package/dist/services/tasks/lambdas/list-agent-actions-by-task/index.mjs +1 -0
  106. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.d.ts +16 -0
  107. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.js +62 -0
  108. package/dist/services/tasks/lambdas/list-agent-actions-by-task/list-agent-actions-by-task.use-case.mjs +33 -0
  109. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.d.ts +1 -0
  110. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.js +22 -0
  111. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/index.mjs +1 -0
  112. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.d.ts +16 -0
  113. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.js +62 -0
  114. package/dist/services/tasks/lambdas/list-agent-tasks-by-chat/list-agent-tasks-by-chat.use-case.mjs +33 -0
  115. package/dist/services/tasks/lambdas/update-agent-action/index.d.ts +1 -0
  116. package/dist/services/tasks/lambdas/update-agent-action/index.js +22 -0
  117. package/dist/services/tasks/lambdas/update-agent-action/index.mjs +1 -0
  118. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.d.ts +15 -0
  119. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.js +67 -0
  120. package/dist/services/tasks/lambdas/update-agent-action/update-agent-action.use-case.mjs +38 -0
  121. package/dist/services/tasks/lambdas/update-agent-task/index.d.ts +1 -0
  122. package/dist/services/tasks/lambdas/update-agent-task/index.js +22 -0
  123. package/dist/services/tasks/lambdas/update-agent-task/index.mjs +1 -0
  124. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.d.ts +15 -0
  125. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.js +67 -0
  126. package/dist/services/tasks/lambdas/update-agent-task/update-agent-task.use-case.mjs +38 -0
  127. package/dist/services/tasks/module.d.ts +15 -0
  128. package/dist/services/tasks/module.js +76 -0
  129. package/dist/services/tasks/module.mjs +47 -0
  130. package/dist/services/tasks/repositories/agent-action.repository.d.ts +8 -0
  131. package/dist/services/tasks/repositories/agent-action.repository.js +62 -0
  132. package/dist/services/tasks/repositories/agent-action.repository.mjs +33 -0
  133. package/dist/services/tasks/repositories/agent-task.repository.d.ts +9 -0
  134. package/dist/services/tasks/repositories/agent-task.repository.js +65 -0
  135. package/dist/services/tasks/repositories/agent-task.repository.mjs +36 -0
  136. package/dist/services/tasks/repositories/index.d.ts +2 -0
  137. package/dist/services/tasks/repositories/index.js +24 -0
  138. package/dist/services/tasks/repositories/index.mjs +2 -0
  139. package/dist/services/traces/entities/agent-trace-entry.entity.d.ts +30 -0
  140. package/dist/services/traces/entities/agent-trace-entry.entity.js +85 -0
  141. package/dist/services/traces/entities/agent-trace-entry.entity.mjs +62 -0
  142. package/dist/services/traces/entities/index.d.ts +1 -0
  143. package/dist/services/traces/entities/index.js +22 -0
  144. package/dist/services/traces/entities/index.mjs +1 -0
  145. package/dist/services/traces/index.d.ts +3 -0
  146. package/dist/services/traces/index.js +26 -0
  147. package/dist/services/traces/index.mjs +3 -0
  148. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.d.ts +16 -0
  149. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.js +62 -0
  150. package/dist/services/traces/lambdas/create-agent-traces/create-agent-traces.use-case.mjs +33 -0
  151. package/dist/services/traces/lambdas/create-agent-traces/index.d.ts +1 -0
  152. package/dist/services/traces/lambdas/create-agent-traces/index.js +22 -0
  153. package/dist/services/traces/lambdas/create-agent-traces/index.mjs +1 -0
  154. package/dist/services/traces/lambdas/index.d.ts +2 -0
  155. package/dist/services/traces/lambdas/index.js +31 -0
  156. package/dist/services/traces/lambdas/index.mjs +7 -0
  157. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.d.ts +1 -0
  158. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.js +22 -0
  159. package/dist/services/traces/lambdas/list-agent-traces-by-chat/index.mjs +1 -0
  160. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.d.ts +18 -0
  161. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.js +67 -0
  162. package/dist/services/traces/lambdas/list-agent-traces-by-chat/list-agent-traces-by-chat.use-case.mjs +38 -0
  163. package/dist/services/traces/module.d.ts +5 -0
  164. package/dist/services/traces/module.js +41 -0
  165. package/dist/services/traces/module.mjs +17 -0
  166. package/dist/services/traces/repositories/agent-trace.repository.d.ts +7 -0
  167. package/dist/services/traces/repositories/agent-trace.repository.js +55 -0
  168. package/dist/services/traces/repositories/agent-trace.repository.mjs +26 -0
  169. package/dist/services/traces/repositories/index.d.ts +1 -0
  170. package/dist/services/traces/repositories/index.js +22 -0
  171. package/dist/services/traces/repositories/index.mjs +1 -0
  172. package/dist/services/workspaces/entities/index.d.ts +1 -0
  173. package/dist/services/workspaces/entities/index.js +22 -0
  174. package/dist/services/workspaces/entities/index.mjs +1 -0
  175. package/dist/services/workspaces/entities/workspace-item.entity.d.ts +33 -0
  176. package/dist/services/workspaces/entities/workspace-item.entity.js +95 -0
  177. package/dist/services/workspaces/entities/workspace-item.entity.mjs +72 -0
  178. package/dist/services/workspaces/index.d.ts +3 -0
  179. package/dist/services/workspaces/index.js +26 -0
  180. package/dist/services/workspaces/index.mjs +3 -0
  181. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.d.ts +17 -0
  182. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.js +68 -0
  183. package/dist/services/workspaces/lambdas/delete-workspace-item/delete-workspace-item.use-case.mjs +39 -0
  184. package/dist/services/workspaces/lambdas/delete-workspace-item/index.d.ts +1 -0
  185. package/dist/services/workspaces/lambdas/delete-workspace-item/index.js +22 -0
  186. package/dist/services/workspaces/lambdas/delete-workspace-item/index.mjs +1 -0
  187. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.d.ts +17 -0
  188. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.js +67 -0
  189. package/dist/services/workspaces/lambdas/get-workspace-item/get-workspace-item.use-case.mjs +38 -0
  190. package/dist/services/workspaces/lambdas/get-workspace-item/index.d.ts +1 -0
  191. package/dist/services/workspaces/lambdas/get-workspace-item/index.js +22 -0
  192. package/dist/services/workspaces/lambdas/get-workspace-item/index.mjs +1 -0
  193. package/dist/services/workspaces/lambdas/index.d.ts +5 -0
  194. package/dist/services/workspaces/lambdas/index.js +40 -0
  195. package/dist/services/workspaces/lambdas/index.mjs +13 -0
  196. package/dist/services/workspaces/lambdas/list-workspace-items/index.d.ts +1 -0
  197. package/dist/services/workspaces/lambdas/list-workspace-items/index.js +22 -0
  198. package/dist/services/workspaces/lambdas/list-workspace-items/index.mjs +1 -0
  199. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.d.ts +18 -0
  200. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.js +69 -0
  201. package/dist/services/workspaces/lambdas/list-workspace-items/list-workspace-items.use-case.mjs +40 -0
  202. package/dist/services/workspaces/lambdas/save-workspace-item/index.d.ts +1 -0
  203. package/dist/services/workspaces/lambdas/save-workspace-item/index.js +22 -0
  204. package/dist/services/workspaces/lambdas/save-workspace-item/index.mjs +1 -0
  205. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.d.ts +14 -0
  206. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.js +76 -0
  207. package/dist/services/workspaces/lambdas/save-workspace-item/save-workspace-item.use-case.mjs +47 -0
  208. package/dist/services/workspaces/lambdas/search-workspace-items/index.d.ts +1 -0
  209. package/dist/services/workspaces/lambdas/search-workspace-items/index.js +22 -0
  210. package/dist/services/workspaces/lambdas/search-workspace-items/index.mjs +1 -0
  211. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.d.ts +19 -0
  212. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.js +73 -0
  213. package/dist/services/workspaces/lambdas/search-workspace-items/search-workspace-items.use-case.mjs +44 -0
  214. package/dist/services/workspaces/module.d.ts +11 -0
  215. package/dist/services/workspaces/module.js +62 -0
  216. package/dist/services/workspaces/module.mjs +35 -0
  217. package/dist/services/workspaces/repositories/index.d.ts +1 -0
  218. package/dist/services/workspaces/repositories/index.js +22 -0
  219. package/dist/services/workspaces/repositories/index.mjs +1 -0
  220. package/dist/services/workspaces/repositories/workspace-item.repository.d.ts +18 -0
  221. package/dist/services/workspaces/repositories/workspace-item.repository.js +74 -0
  222. package/dist/services/workspaces/repositories/workspace-item.repository.mjs +45 -0
  223. package/dist/skills/runtime-context.d.ts +8 -0
  224. package/dist/skills/runtime-context.js +65 -0
  225. package/dist/skills/runtime-context.mjs +42 -0
  226. package/dist/skills/skill.d.ts +7 -0
  227. package/dist/skills/skill.js +26 -60
  228. package/dist/skills/skill.mjs +26 -60
  229. package/dist/tools/tool.d.ts +6 -0
  230. package/dist/tools/tool.js +56 -0
  231. package/dist/tools/tool.mjs +56 -0
  232. package/package.json +4 -4
  233. package/dist/agent/agent.js +0 -327
  234. package/dist/agent/agent.mjs +0 -303
  235. package/dist/services/chats/entities/agent-action.entity.d.ts +0 -58
  236. package/dist/services/chats/entities/agent-action.entity.js +0 -151
  237. package/dist/services/chats/entities/agent-action.entity.mjs +0 -128
  238. package/dist/services/chats/entities/agent-task.entity.d.ts +0 -59
  239. package/dist/services/chats/entities/agent-task.entity.js +0 -231
  240. package/dist/services/chats/entities/agent-task.entity.mjs +0 -207
  241. package/dist/services/chats/entities/chat-context.entity.d.ts +0 -39
  242. package/dist/services/chats/entities/chat-context.entity.js +0 -70
  243. package/dist/services/chats/entities/chat-context.entity.mjs +0 -47
  244. /package/dist/{agent → harness}/agent-loop.js +0 -0
  245. /package/dist/{agent → harness}/agent-loop.mjs +0 -0
  246. /package/dist/{agent → harness}/agent-state.d.ts +0 -0
  247. /package/dist/{agent → harness}/index.d.ts +0 -0
  248. /package/dist/{agent → harness}/index.mjs +0 -0
  249. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.d.ts +0 -0
  250. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.js +0 -0
  251. /package/dist/{agent → harness}/utils/rank-tools-by-keywords.mjs +0 -0
@@ -0,0 +1,198 @@
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 native_tools_exports = {};
20
+ __export(native_tools_exports, {
21
+ NATIVE_TOOLS: () => NATIVE_TOOLS,
22
+ NativeTools: () => NativeTools
23
+ });
24
+ module.exports = __toCommonJS(native_tools_exports);
25
+ var import_agent_task = require("../services/tasks/entities/agent-task.entity.js");
26
+ var import_tool_catalog = require("./tool-catalog");
27
+ const DEFAULT_SEARCH_LIMIT = 5;
28
+ const MAX_SEARCH_LIMIT = 8;
29
+ const SEARCH_DESCRIPTION_CHARS = 300;
30
+ const SEARCH_OUTPUT_CHARS = 5500;
31
+ const DEFAULT_READ_CHARS = 4e3;
32
+ const MAX_READ_CHARS = 5e3;
33
+ const NATIVE_TOOLS = [
34
+ {
35
+ name: "search_tools",
36
+ description: "Find external tools by capability. Pass a few keywords, written in the language of the tool descriptions in CONTEXT.tool_sources, each with a weight from 0.1 (marginal) to 1.0 (essential). Returns the matching tools; from your next turn they are in your tool list and you run them by naming them in an action.",
37
+ parameters: {
38
+ type: "object",
39
+ properties: {
40
+ keywords: {
41
+ type: "array",
42
+ description: "Keywords describing the capability, in the language of the tool descriptions, for example calendar, events, list",
43
+ items: {
44
+ type: "object",
45
+ properties: {
46
+ keyword: { type: "string", description: "A single word, or a short fixed expression" },
47
+ weight: { type: "number", description: "Importance from 0.1 to 1.0" }
48
+ },
49
+ required: ["keyword", "weight"]
50
+ }
51
+ },
52
+ page: { type: "integer", description: "Result page, starting at 1" },
53
+ limit: { type: "integer", description: `Tools per page (default ${DEFAULT_SEARCH_LIMIT}, max ${MAX_SEARCH_LIMIT})` }
54
+ },
55
+ required: ["keywords"]
56
+ }
57
+ },
58
+ {
59
+ name: "read_context",
60
+ description: 'Read a workspace item: a note saved with save_context, or a large tool output (use the "workspace_ref" name from its result). Supports a path into structured content and paging for long text.',
61
+ parameters: {
62
+ type: "object",
63
+ properties: {
64
+ name: { type: "string", description: "Name of the workspace item" },
65
+ path: { type: "string", description: "Optional path into structured content, like results[0].id" },
66
+ offset: { type: "integer", description: "Character offset to start reading from (default 0)" },
67
+ max_chars: { type: "integer", description: `Maximum characters to return (default ${DEFAULT_READ_CHARS}, max ${MAX_READ_CHARS})` }
68
+ },
69
+ required: ["name"]
70
+ }
71
+ },
72
+ {
73
+ name: "save_context",
74
+ description: 'Save a note in the task workspace to reuse it later, either with read_context or by referencing "{{context.<name>}}" in tool arguments. Use it for facts, decisions or intermediate results worth keeping.',
75
+ parameters: {
76
+ type: "object",
77
+ properties: {
78
+ name: { type: "string", description: "Short unique name using letters, numbers, underscore or dash" },
79
+ content: { type: "string", description: "The text or JSON to store" },
80
+ description: { type: "string", description: "One line explaining what the note contains" }
81
+ },
82
+ required: ["name", "content"]
83
+ }
84
+ },
85
+ {
86
+ name: "ask_user",
87
+ description: "Pause the task and ask the user a question. Use it only when you cannot continue without information that only the user can provide. Their answer comes back as the result of this action.",
88
+ parameters: {
89
+ type: "object",
90
+ properties: {
91
+ question: { type: "string", description: "The question to show to the user, in the user's language" }
92
+ },
93
+ required: ["question"]
94
+ }
95
+ },
96
+ {
97
+ name: "respond",
98
+ description: "Deliver your final answer to the user and end the task. Use it once, when you have what you need or when you cannot do more. Do not combine it with actions whose results you still need.",
99
+ parameters: {
100
+ type: "object",
101
+ properties: {
102
+ answer: { type: "string", description: "The final answer for the user, in the user's language" }
103
+ },
104
+ required: ["answer"]
105
+ }
106
+ }
107
+ ];
108
+ class NativeTools {
109
+ constructor(deps) {
110
+ this.deps = deps;
111
+ }
112
+ deps;
113
+ async run(task, action) {
114
+ const definition = NATIVE_TOOLS.find((tool) => tool.name === action.name);
115
+ const args = action.args ?? {};
116
+ const missing = (definition?.parameters.required ?? []).filter((key) => args[key] === void 0 || args[key] === null);
117
+ if (missing.length) {
118
+ action.markFailed({ message: `Invalid arguments: ${missing.map((key) => `Missing required argument "${key}"`).join("; ")}`, retryable: false });
119
+ return;
120
+ }
121
+ action.markRunning();
122
+ try {
123
+ action.markCompleted(await this.execute(task, action.name, args));
124
+ } catch (error) {
125
+ action.markFailed({ message: error?.message ?? String(error), retryable: false });
126
+ }
127
+ }
128
+ async execute(task, name, args) {
129
+ switch (name) {
130
+ case "search_tools":
131
+ return this.searchTools(args);
132
+ case "read_context":
133
+ return this.readContext(task, args);
134
+ case "save_context":
135
+ return this.saveContext(task, args);
136
+ default:
137
+ throw new Error(`"${name}" is interpreted by the runtime and cannot be executed`);
138
+ }
139
+ }
140
+ searchTools(args) {
141
+ const keywords = (Array.isArray(args.keywords) ? args.keywords : []).map((item) => typeof item === "string" ? { keyword: item, weight: 1 } : { keyword: String(item?.keyword ?? ""), weight: Number(item?.weight) || 1 });
142
+ const limit = Math.min(Math.max(Number(args.limit) || DEFAULT_SEARCH_LIMIT, 1), MAX_SEARCH_LIMIT);
143
+ const page = Math.max(Number(args.page) || 1, 1);
144
+ const tools = [];
145
+ let size = 0;
146
+ for (const { tool } of this.deps.searchTools(keywords, { page, limit })) {
147
+ const { parameters, ...entry } = (0, import_tool_catalog.describeTool)(tool, SEARCH_DESCRIPTION_CHARS);
148
+ size += JSON.stringify(entry).length;
149
+ if (tools.length && size > SEARCH_OUTPUT_CHARS) break;
150
+ tools.push(entry);
151
+ }
152
+ return tools.length ? { page, tools, note: "These tools are now in your tool list: run them by naming them in an action." } : { page, tools, hint: "No tool matched. Retry with synonyms written in the language of the tool descriptions shown in CONTEXT.tool_sources." };
153
+ }
154
+ async readContext(task, args) {
155
+ const item = await this.deps.workspace.get(String(args.name), { taskId: task.id });
156
+ if (!item) return { found: false };
157
+ const path = args.path ? String(args.path).replace(/^(?=[\w-])/, ".") : void 0;
158
+ const value = (0, import_agent_task.readPath)(item.content, path);
159
+ if (value === void 0) return { found: true, name: item.name, path_found: false };
160
+ const text = typeof value === "string" ? value : JSON.stringify(value);
161
+ const offset = Math.max(Number(args.offset) || 0, 0);
162
+ const max = Math.min(Math.max(Number(args.max_chars) || DEFAULT_READ_CHARS, 1), MAX_READ_CHARS);
163
+ return {
164
+ name: item.name,
165
+ total_chars: text.length,
166
+ offset,
167
+ has_more: offset + max < text.length,
168
+ ...item.truncated ? { stored_truncated: true } : {},
169
+ content: text.slice(offset, offset + max)
170
+ };
171
+ }
172
+ async saveContext(task, args) {
173
+ const name = String(args.name).trim().replace(/[^\w-]/g, "_");
174
+ if (!name) throw new Error("A valid name is required");
175
+ let content = args.content;
176
+ if (typeof content === "string") {
177
+ try {
178
+ content = JSON.parse(content);
179
+ } catch {
180
+ content = args.content;
181
+ }
182
+ }
183
+ await this.deps.workspace.save({
184
+ name,
185
+ kind: "note",
186
+ taskId: task.id,
187
+ content,
188
+ description: args.description,
189
+ source: "save_context"
190
+ });
191
+ return { saved: name };
192
+ }
193
+ }
194
+ // Annotate the CommonJS export names for ESM import in node:
195
+ 0 && (module.exports = {
196
+ NATIVE_TOOLS,
197
+ NativeTools
198
+ });
@@ -0,0 +1,174 @@
1
+ import "../chunk-CF3WOMB3.mjs";
2
+ import { readPath } from "../services/tasks/entities/agent-task.entity.js";
3
+ import { describeTool } from "./tool-catalog";
4
+ const DEFAULT_SEARCH_LIMIT = 5;
5
+ const MAX_SEARCH_LIMIT = 8;
6
+ const SEARCH_DESCRIPTION_CHARS = 300;
7
+ const SEARCH_OUTPUT_CHARS = 5500;
8
+ const DEFAULT_READ_CHARS = 4e3;
9
+ const MAX_READ_CHARS = 5e3;
10
+ const NATIVE_TOOLS = [
11
+ {
12
+ name: "search_tools",
13
+ description: "Find external tools by capability. Pass a few keywords, written in the language of the tool descriptions in CONTEXT.tool_sources, each with a weight from 0.1 (marginal) to 1.0 (essential). Returns the matching tools; from your next turn they are in your tool list and you run them by naming them in an action.",
14
+ parameters: {
15
+ type: "object",
16
+ properties: {
17
+ keywords: {
18
+ type: "array",
19
+ description: "Keywords describing the capability, in the language of the tool descriptions, for example calendar, events, list",
20
+ items: {
21
+ type: "object",
22
+ properties: {
23
+ keyword: { type: "string", description: "A single word, or a short fixed expression" },
24
+ weight: { type: "number", description: "Importance from 0.1 to 1.0" }
25
+ },
26
+ required: ["keyword", "weight"]
27
+ }
28
+ },
29
+ page: { type: "integer", description: "Result page, starting at 1" },
30
+ limit: { type: "integer", description: `Tools per page (default ${DEFAULT_SEARCH_LIMIT}, max ${MAX_SEARCH_LIMIT})` }
31
+ },
32
+ required: ["keywords"]
33
+ }
34
+ },
35
+ {
36
+ name: "read_context",
37
+ description: 'Read a workspace item: a note saved with save_context, or a large tool output (use the "workspace_ref" name from its result). Supports a path into structured content and paging for long text.',
38
+ parameters: {
39
+ type: "object",
40
+ properties: {
41
+ name: { type: "string", description: "Name of the workspace item" },
42
+ path: { type: "string", description: "Optional path into structured content, like results[0].id" },
43
+ offset: { type: "integer", description: "Character offset to start reading from (default 0)" },
44
+ max_chars: { type: "integer", description: `Maximum characters to return (default ${DEFAULT_READ_CHARS}, max ${MAX_READ_CHARS})` }
45
+ },
46
+ required: ["name"]
47
+ }
48
+ },
49
+ {
50
+ name: "save_context",
51
+ description: 'Save a note in the task workspace to reuse it later, either with read_context or by referencing "{{context.<name>}}" in tool arguments. Use it for facts, decisions or intermediate results worth keeping.',
52
+ parameters: {
53
+ type: "object",
54
+ properties: {
55
+ name: { type: "string", description: "Short unique name using letters, numbers, underscore or dash" },
56
+ content: { type: "string", description: "The text or JSON to store" },
57
+ description: { type: "string", description: "One line explaining what the note contains" }
58
+ },
59
+ required: ["name", "content"]
60
+ }
61
+ },
62
+ {
63
+ name: "ask_user",
64
+ description: "Pause the task and ask the user a question. Use it only when you cannot continue without information that only the user can provide. Their answer comes back as the result of this action.",
65
+ parameters: {
66
+ type: "object",
67
+ properties: {
68
+ question: { type: "string", description: "The question to show to the user, in the user's language" }
69
+ },
70
+ required: ["question"]
71
+ }
72
+ },
73
+ {
74
+ name: "respond",
75
+ description: "Deliver your final answer to the user and end the task. Use it once, when you have what you need or when you cannot do more. Do not combine it with actions whose results you still need.",
76
+ parameters: {
77
+ type: "object",
78
+ properties: {
79
+ answer: { type: "string", description: "The final answer for the user, in the user's language" }
80
+ },
81
+ required: ["answer"]
82
+ }
83
+ }
84
+ ];
85
+ class NativeTools {
86
+ constructor(deps) {
87
+ this.deps = deps;
88
+ }
89
+ deps;
90
+ async run(task, action) {
91
+ const definition = NATIVE_TOOLS.find((tool) => tool.name === action.name);
92
+ const args = action.args ?? {};
93
+ const missing = (definition?.parameters.required ?? []).filter((key) => args[key] === void 0 || args[key] === null);
94
+ if (missing.length) {
95
+ action.markFailed({ message: `Invalid arguments: ${missing.map((key) => `Missing required argument "${key}"`).join("; ")}`, retryable: false });
96
+ return;
97
+ }
98
+ action.markRunning();
99
+ try {
100
+ action.markCompleted(await this.execute(task, action.name, args));
101
+ } catch (error) {
102
+ action.markFailed({ message: error?.message ?? String(error), retryable: false });
103
+ }
104
+ }
105
+ async execute(task, name, args) {
106
+ switch (name) {
107
+ case "search_tools":
108
+ return this.searchTools(args);
109
+ case "read_context":
110
+ return this.readContext(task, args);
111
+ case "save_context":
112
+ return this.saveContext(task, args);
113
+ default:
114
+ throw new Error(`"${name}" is interpreted by the runtime and cannot be executed`);
115
+ }
116
+ }
117
+ searchTools(args) {
118
+ const keywords = (Array.isArray(args.keywords) ? args.keywords : []).map((item) => typeof item === "string" ? { keyword: item, weight: 1 } : { keyword: String(item?.keyword ?? ""), weight: Number(item?.weight) || 1 });
119
+ const limit = Math.min(Math.max(Number(args.limit) || DEFAULT_SEARCH_LIMIT, 1), MAX_SEARCH_LIMIT);
120
+ const page = Math.max(Number(args.page) || 1, 1);
121
+ const tools = [];
122
+ let size = 0;
123
+ for (const { tool } of this.deps.searchTools(keywords, { page, limit })) {
124
+ const { parameters, ...entry } = describeTool(tool, SEARCH_DESCRIPTION_CHARS);
125
+ size += JSON.stringify(entry).length;
126
+ if (tools.length && size > SEARCH_OUTPUT_CHARS) break;
127
+ tools.push(entry);
128
+ }
129
+ return tools.length ? { page, tools, note: "These tools are now in your tool list: run them by naming them in an action." } : { page, tools, hint: "No tool matched. Retry with synonyms written in the language of the tool descriptions shown in CONTEXT.tool_sources." };
130
+ }
131
+ async readContext(task, args) {
132
+ const item = await this.deps.workspace.get(String(args.name), { taskId: task.id });
133
+ if (!item) return { found: false };
134
+ const path = args.path ? String(args.path).replace(/^(?=[\w-])/, ".") : void 0;
135
+ const value = readPath(item.content, path);
136
+ if (value === void 0) return { found: true, name: item.name, path_found: false };
137
+ const text = typeof value === "string" ? value : JSON.stringify(value);
138
+ const offset = Math.max(Number(args.offset) || 0, 0);
139
+ const max = Math.min(Math.max(Number(args.max_chars) || DEFAULT_READ_CHARS, 1), MAX_READ_CHARS);
140
+ return {
141
+ name: item.name,
142
+ total_chars: text.length,
143
+ offset,
144
+ has_more: offset + max < text.length,
145
+ ...item.truncated ? { stored_truncated: true } : {},
146
+ content: text.slice(offset, offset + max)
147
+ };
148
+ }
149
+ async saveContext(task, args) {
150
+ const name = String(args.name).trim().replace(/[^\w-]/g, "_");
151
+ if (!name) throw new Error("A valid name is required");
152
+ let content = args.content;
153
+ if (typeof content === "string") {
154
+ try {
155
+ content = JSON.parse(content);
156
+ } catch {
157
+ content = args.content;
158
+ }
159
+ }
160
+ await this.deps.workspace.save({
161
+ name,
162
+ kind: "note",
163
+ taskId: task.id,
164
+ content,
165
+ description: args.description,
166
+ source: "save_context"
167
+ });
168
+ return { saved: name };
169
+ }
170
+ }
171
+ export {
172
+ NATIVE_TOOLS,
173
+ NativeTools
174
+ };
@@ -0,0 +1,16 @@
1
+ import { Tool } from '../tools/tool.js';
2
+ import { LLMToolDefinition } from '../clients/llm-types.js';
3
+ export interface ToolCatalog {
4
+ tools: LLMToolDefinition[];
5
+ context: Record<string, any>;
6
+ }
7
+ export interface ToolDescription {
8
+ name: string;
9
+ description: string;
10
+ requires_confirmation: boolean;
11
+ parameters: Record<string, any>;
12
+ }
13
+ export declare function isDeclarable(tool: Tool): boolean;
14
+ export declare function needsSearch(allTools: Tool[]): boolean;
15
+ export declare function describeTool(tool: Tool, chars?: number): ToolDescription;
16
+ export declare function buildToolCatalog(allTools: Tool[], nativeTools: LLMToolDefinition[], discovered: string[]): ToolCatalog;
@@ -0,0 +1,85 @@
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_catalog_exports = {};
20
+ __export(tool_catalog_exports, {
21
+ buildToolCatalog: () => buildToolCatalog,
22
+ describeTool: () => describeTool,
23
+ isDeclarable: () => isDeclarable,
24
+ needsSearch: () => needsSearch
25
+ });
26
+ module.exports = __toCommonJS(tool_catalog_exports);
27
+ var import_agent_task = require("../services/tasks/entities/agent-task.entity.js");
28
+ const FULL_CATALOG_LIMIT = 15;
29
+ const SAMPLES_PER_SOURCE = 3;
30
+ const SAMPLE_DESCRIPTION_CHARS = 120;
31
+ const TOOL_DESCRIPTION_CHARS = 400;
32
+ const DECLARED_DESCRIPTION_CHARS = 4e3;
33
+ const LOCAL_SOURCE = "local";
34
+ const FUNCTION_NAME = /^[a-zA-Z0-9_-]{1,64}$/;
35
+ function isDeclarable(tool) {
36
+ return FUNCTION_NAME.test(tool.name);
37
+ }
38
+ function needsSearch(allTools) {
39
+ return allTools.filter(isDeclarable).length > FULL_CATALOG_LIMIT;
40
+ }
41
+ function describeTool(tool, chars = TOOL_DESCRIPTION_CHARS) {
42
+ return {
43
+ name: tool.name,
44
+ description: tool.description.slice(0, chars),
45
+ requires_confirmation: tool.destructive,
46
+ parameters: tool.parameters
47
+ };
48
+ }
49
+ function declare(tool) {
50
+ return { name: tool.name, description: tool.description.slice(0, DECLARED_DESCRIPTION_CHARS), parameters: tool.parameters };
51
+ }
52
+ function buildToolCatalog(allTools, nativeTools, discovered) {
53
+ const tools = allTools.filter(isDeclarable);
54
+ if (!needsSearch(allTools)) {
55
+ return {
56
+ tools: [...nativeTools.filter((tool) => tool.name !== import_agent_task.SEARCH_TOOLS), ...tools.map(declare)],
57
+ context: {}
58
+ };
59
+ }
60
+ const sources = /* @__PURE__ */ new Map();
61
+ for (const tool of tools) {
62
+ const separator = tool.name.indexOf("__");
63
+ const source = separator > 0 ? tool.name.slice(0, separator) : LOCAL_SOURCE;
64
+ sources.set(source, [...sources.get(source) ?? [], tool]);
65
+ }
66
+ const found = discovered.map((name) => tools.find((tool) => tool.name === name)).filter((tool) => !!tool);
67
+ return {
68
+ tools: [...nativeTools, ...found.map(declare)],
69
+ context: {
70
+ total_tools: tools.length,
71
+ tool_sources: [...sources.entries()].map(([name, items]) => ({
72
+ name,
73
+ tool_count: items.length,
74
+ sample: items.slice(0, SAMPLES_PER_SOURCE).map((tool) => ({ name: tool.name, description: tool.description.slice(0, SAMPLE_DESCRIPTION_CHARS) }))
75
+ }))
76
+ }
77
+ };
78
+ }
79
+ // Annotate the CommonJS export names for ESM import in node:
80
+ 0 && (module.exports = {
81
+ buildToolCatalog,
82
+ describeTool,
83
+ isDeclarable,
84
+ needsSearch
85
+ });
@@ -0,0 +1,59 @@
1
+ import "../chunk-CF3WOMB3.mjs";
2
+ import { SEARCH_TOOLS } from "../services/tasks/entities/agent-task.entity.js";
3
+ const FULL_CATALOG_LIMIT = 15;
4
+ const SAMPLES_PER_SOURCE = 3;
5
+ const SAMPLE_DESCRIPTION_CHARS = 120;
6
+ const TOOL_DESCRIPTION_CHARS = 400;
7
+ const DECLARED_DESCRIPTION_CHARS = 4e3;
8
+ const LOCAL_SOURCE = "local";
9
+ const FUNCTION_NAME = /^[a-zA-Z0-9_-]{1,64}$/;
10
+ function isDeclarable(tool) {
11
+ return FUNCTION_NAME.test(tool.name);
12
+ }
13
+ function needsSearch(allTools) {
14
+ return allTools.filter(isDeclarable).length > FULL_CATALOG_LIMIT;
15
+ }
16
+ function describeTool(tool, chars = TOOL_DESCRIPTION_CHARS) {
17
+ return {
18
+ name: tool.name,
19
+ description: tool.description.slice(0, chars),
20
+ requires_confirmation: tool.destructive,
21
+ parameters: tool.parameters
22
+ };
23
+ }
24
+ function declare(tool) {
25
+ return { name: tool.name, description: tool.description.slice(0, DECLARED_DESCRIPTION_CHARS), parameters: tool.parameters };
26
+ }
27
+ function buildToolCatalog(allTools, nativeTools, discovered) {
28
+ const tools = allTools.filter(isDeclarable);
29
+ if (!needsSearch(allTools)) {
30
+ return {
31
+ tools: [...nativeTools.filter((tool) => tool.name !== SEARCH_TOOLS), ...tools.map(declare)],
32
+ context: {}
33
+ };
34
+ }
35
+ const sources = /* @__PURE__ */ new Map();
36
+ for (const tool of tools) {
37
+ const separator = tool.name.indexOf("__");
38
+ const source = separator > 0 ? tool.name.slice(0, separator) : LOCAL_SOURCE;
39
+ sources.set(source, [...sources.get(source) ?? [], tool]);
40
+ }
41
+ const found = discovered.map((name) => tools.find((tool) => tool.name === name)).filter((tool) => !!tool);
42
+ return {
43
+ tools: [...nativeTools, ...found.map(declare)],
44
+ context: {
45
+ total_tools: tools.length,
46
+ tool_sources: [...sources.entries()].map(([name, items]) => ({
47
+ name,
48
+ tool_count: items.length,
49
+ sample: items.slice(0, SAMPLES_PER_SOURCE).map((tool) => ({ name: tool.name, description: tool.description.slice(0, SAMPLE_DESCRIPTION_CHARS) }))
50
+ }))
51
+ }
52
+ };
53
+ }
54
+ export {
55
+ buildToolCatalog,
56
+ describeTool,
57
+ isDeclarable,
58
+ needsSearch
59
+ };
@@ -0,0 +1,42 @@
1
+ import { Logger } from '../common/logger/index.js';
2
+ import { Tool, BaseParams } from '../tools/tool.js';
3
+ import { AgentAction } from '../services/tasks/entities/agent-action.entity.js';
4
+ import { AgentTask } from '../services/tasks/entities/agent-task.entity.js';
5
+ import { Workspace } from './workspace';
6
+ import { WeightedKeyword, ScoredTool } from './utils/rank-tools-by-keywords';
7
+ export interface ToolPipelineOptions {
8
+ offloadThresholdChars?: number;
9
+ stubThresholdChars?: number;
10
+ maxStoredChars?: number;
11
+ previewChars?: number;
12
+ }
13
+ export interface ToolPipelineRunOptions {
14
+ blockDuplicates?: boolean;
15
+ }
16
+ interface ToolPipelineDeps {
17
+ workspace: Workspace;
18
+ tools: () => Tool[];
19
+ searchTools: (keywords: WeightedKeyword[], opts?: {
20
+ page?: number;
21
+ limit?: number;
22
+ }) => ScoredTool[];
23
+ baseParams: BaseParams;
24
+ logger: Logger;
25
+ }
26
+ export declare class ToolPipeline {
27
+ private readonly deps;
28
+ private readonly offloadThresholdChars;
29
+ private readonly stubThresholdChars;
30
+ private readonly maxStoredChars;
31
+ private readonly previewChars;
32
+ private readonly nativeTools;
33
+ constructor(deps: ToolPipelineDeps, options?: ToolPipelineOptions);
34
+ private notFoundMessage;
35
+ private searchUnavailableMessage;
36
+ requiresApproval(action: AgentAction): boolean;
37
+ run(task: AgentTask, action: AgentAction, opts?: ToolPipelineRunOptions): Promise<AgentAction>;
38
+ private findTool;
39
+ private loadSources;
40
+ private offload;
41
+ }
42
+ export {};