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
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(action_planner_exports);
24
24
  var import_skill = require("../../../skills/skill.js");
25
25
  const actionPlanner = new import_skill.Skill({
26
26
  name: "action_planner",
27
- version: "1.6.2",
27
+ version: "1.7.0",
28
28
  description: "Generates an ordered step-by-step tool execution plan based on IntentContext and candidate tools schema. Flags missing tools, missing required execution parameters, or steps requiring user confirmation for destructive actions.",
29
29
  temperature: 0.1,
30
30
  systemInstructions: {
@@ -34,8 +34,11 @@ const actionPlanner = new import_skill.Skill({
34
34
  logic_rules: [
35
35
  "TOOL_EVALUATION: Analyze available tool schemas against userIntent and extracted_entities in IntentContext. Select only the necessary tools required to achieve the goal.",
36
36
  "MISSING_TOOLS_CHECK: If no candidate tools fit the intent, or if essential actions cannot be mapped to any available tool: 1) Set 'plan_status' to 'MISSING_TOOLS', 2) Set 'current_step_index' to 0, 3) Provide a technical explanation in 'missing_tools_explanation' in English, 4) Generate a polite message in 'user_response' written in 'detected_language' explaining that no connected tools/integrations were found to complete the request and suggest checking their active integrations, 5) Set 'steps' to [], 6) Set 'needs_clarification' to false, 'missing_entities' to [], 'clarification_prompt' to '', and 'confirmation_details' to null.",
37
- "STEP_PLANNING: If tools are available, sequence them logically in 'steps'. Assign incremental 'step_id' starting at 1. Set 'current_step_index' to 0 by default. Explicitly list any prerequisite step IDs in 'depends_on_steps' if a step requires output from a prior step. Define a clear 'expected_outcome' describing the precise expected result or data state after this step runs.",
38
- "ARGUMENT_MAPPING: Map extracted_entities and execution context (e.g., CONTEXT metadata like 'now_utc', 'now_local', 'timezone', user_details, and session_details) to tool parameters in 'arguments'. For relative time/date expressions (e.g., 'today', 'afternoon', 'yesterday at 4:30pm'), calculate and resolve the precise value (such as ISO 8601 strings) using the provided reference timestamp and timezone. If a parameter value comes from a future step execution output, represent it as a JSON reference string (e.g., '{{step_1.output.id}}').",
37
+ "STEP_PLANNING: If tools are available, sequence them logically in 'steps'. Assign incremental 'step_id' starting at 1; ids are local to this plan, even when replanning. Set 'current_step_index' to 0 by default. Explicitly list any prerequisite step IDs in 'depends_on_steps' if a step requires output from a prior step. Define a clear 'expected_outcome' describing the precise expected result or data state after this step runs.",
38
+ "ARGUMENT_MAPPING: Map extracted_entities and execution context (e.g., CONTEXT metadata like 'now_utc', 'now_local', 'timezone', user_details, and session_details) to tool parameters in 'arguments'. For relative time/date expressions (e.g., 'today', 'afternoon', 'yesterday at 4:30pm'), calculate and resolve the precise value (such as ISO 8601 strings) using the provided reference timestamp and timezone. If a parameter value comes from the output of another step, represent it as a reference string: '{{step_N.output.path}}' where N is the 'step_id' of an earlier step in THIS plan, or '{{step_REF.output.path}}' where REF is the 'ref' of an entry in CONTEXT.execution_history. The path uses dot and bracket notation into that step's output (e.g., '{{step_1.output.results[0].name}}'), or is omitted to use the whole output.",
39
+ "REFERENCE_SAFETY: Only reference a path you are certain exists in that step's output, based on the tool description or on an output already visible in CONTEXT.execution_history. If the arguments of a step depend on the content of an output you cannot see yet (for example the results of a search or discovery tool), do NOT plan that dependent step: plan only up to the step that produces the data. After it runs, the plan will be revised with the real output in CONTEXT.execution_history. Never invent fields, and never pass empty arguments to a tool that has required parameters.",
40
+ "ARGUMENT_LANGUAGE: Values inside 'arguments' follow the description of each tool parameter, not 'detected_language'. If a parameter description asks for a specific language (for example English keywords), write that value in that language, translating or extracting the relevant domain terms and entity names from the user request when needed. Only values that must be stored or displayed verbatim (names, titles, free text written by the user) keep the user's original language.",
41
+ "REPLANNING: When CONTEXT.execution_history is present, you are revising a plan. Read each entry's 'status', 'output' and 'error', and CONTEXT.replan_feedback when present. Do not propose a step with the same tool and the same arguments as an entry already in the history; use the real outputs to build a different approach (different arguments, another candidate tool, or the data already discovered). If the history shows the goal is already achieved or no different approach is possible with the candidate tools, set 'plan_status' to 'NEEDS_CLARIFICATION' and ask the user for the specific information needed.",
39
42
  "PARAMETER_AND_SAFETY_VALIDATION: For each step, inspect the candidate tool schema properties and flags:",
40
43
  "1) Set 'is_destructive' to match the candidate tool's 'destructive' boolean flag.",
41
44
  "2) If any required parameter is MISSING and CANNOT be derived from CONTEXT: Set step 'status' to 'MISSING_PARAMS' and list the missing keys in 'missing_fields'.",
@@ -44,7 +47,7 @@ const actionPlanner = new import_skill.Skill({
44
47
  "CLARIFICATION_CHECK: If ANY step has status 'MISSING_PARAMS': 1) Set 'plan_status' to 'NEEDS_CLARIFICATION', 2) Set 'needs_clarification' to true, 3) Collect all unresolvable parameters in 'missing_entities' in English, 4) Provide a short, direct, and polite question in 'clarification_prompt' written in 'detected_language', 5) Set 'user_response' to '', and 'confirmation_details' to null.",
45
48
  "CONFIRMATION_CHECK: If NO step has 'MISSING_PARAMS' BUT at least one step has status 'REQUIRES_CONFIRMATION': 1) Set 'plan_status' to 'NEEDS_CONFIRMATION', 2) Set 'needs_clarification' to false, 3) Set 'missing_entities' to [], 4) Populate 'confirmation_details' with: 'actions' (one entry per step with status 'REQUIRES_CONFIRMATION', each with that step's 'step_id' and a short natural-language 'description' of exactly what it will do, naming the action and its target \u2014 never the raw tool name or parameter keys), 'impact_summary' summarizing the overall permanent changes in plain terms, and 'confirm_label' \u2014 a short call-to-action asking the user to approve or decline; this will always be shown as the LAST line of the message, so it must stand on its own as the actual yes/no ask, 5) Provide context in 'clarification_prompt' introducing why confirmation is needed \u2014 this field must NOT itself ask a yes/no question, since 'confirm_label' is the only field that does that, 6) Set 'user_response' to ''. CRITICAL: every piece of text produced in this rule ('actions[].description', 'impact_summary', 'confirm_label', 'clarification_prompt') MUST be written in 'detected_language' \u2014 never default to English here regardless of the language used anywhere else in this instruction set.",
46
49
  "SUCCESS_STATE: If all steps are 'READY' and no tools are missing or requiring confirmation: 1) Set 'plan_status' to 'SUCCESS', 2) Set 'missing_tools_explanation' to '', 3) Set 'user_response' to '', 4) Set 'needs_clarification' to false, 'missing_entities' to [], 'clarification_prompt' to '', and 'confirmation_details' to null.",
47
- "LANGUAGE_ENFORCEMENT: ONLY 'clarification_prompt', 'user_response', and every field inside 'confirmation_details' (including each entry's 'description') MUST be written in the user's actual conversation language \u2014 use CONTEXT.detected_language when present; only fall back to CONTEXT.user_details.preferred_language if 'detected_language' is absent. 'preferred_language' is the app's configured display language and does NOT necessarily match the language the user is typing in right now \u2014 never prefer it over 'detected_language' when both exist. These are the only fields the end user actually reads before approving or declining. ALL OTHER fields ('missing_tools_explanation', step 'rationale', step 'expected_outcome', 'missing_entities', and 'reasoning') MUST strictly be written in English.",
50
+ "LANGUAGE_ENFORCEMENT: ONLY 'clarification_prompt', 'user_response', and every field inside 'confirmation_details' (including each entry's 'description') MUST be written in the user's actual conversation language \u2014 use CONTEXT.detected_language when present; only fall back to CONTEXT.user_details.preferred_language if 'detected_language' is absent. 'preferred_language' is the app's configured display language and does NOT necessarily match the language the user is typing in right now \u2014 never prefer it over 'detected_language' when both exist. These are the only fields the end user actually reads before approving or declining. ALL OTHER fields ('missing_tools_explanation', step 'rationale', step 'expected_outcome', 'missing_entities', and 'reasoning') MUST strictly be written in English, even when the user wrote in another language. The values inside step 'arguments' are governed by ARGUMENT_LANGUAGE.",
48
51
  "STRICT_OUTPUT: Return ONLY the JSON object matching response_schema."
49
52
  ],
50
53
  response_schema: {
@@ -2,7 +2,7 @@ import "../../../chunk-CF3WOMB3.mjs";
2
2
  import { Skill } from "../../../skills/skill.js";
3
3
  const actionPlanner = new Skill({
4
4
  name: "action_planner",
5
- version: "1.6.2",
5
+ version: "1.7.0",
6
6
  description: "Generates an ordered step-by-step tool execution plan based on IntentContext and candidate tools schema. Flags missing tools, missing required execution parameters, or steps requiring user confirmation for destructive actions.",
7
7
  temperature: 0.1,
8
8
  systemInstructions: {
@@ -12,8 +12,11 @@ const actionPlanner = new Skill({
12
12
  logic_rules: [
13
13
  "TOOL_EVALUATION: Analyze available tool schemas against userIntent and extracted_entities in IntentContext. Select only the necessary tools required to achieve the goal.",
14
14
  "MISSING_TOOLS_CHECK: If no candidate tools fit the intent, or if essential actions cannot be mapped to any available tool: 1) Set 'plan_status' to 'MISSING_TOOLS', 2) Set 'current_step_index' to 0, 3) Provide a technical explanation in 'missing_tools_explanation' in English, 4) Generate a polite message in 'user_response' written in 'detected_language' explaining that no connected tools/integrations were found to complete the request and suggest checking their active integrations, 5) Set 'steps' to [], 6) Set 'needs_clarification' to false, 'missing_entities' to [], 'clarification_prompt' to '', and 'confirmation_details' to null.",
15
- "STEP_PLANNING: If tools are available, sequence them logically in 'steps'. Assign incremental 'step_id' starting at 1. Set 'current_step_index' to 0 by default. Explicitly list any prerequisite step IDs in 'depends_on_steps' if a step requires output from a prior step. Define a clear 'expected_outcome' describing the precise expected result or data state after this step runs.",
16
- "ARGUMENT_MAPPING: Map extracted_entities and execution context (e.g., CONTEXT metadata like 'now_utc', 'now_local', 'timezone', user_details, and session_details) to tool parameters in 'arguments'. For relative time/date expressions (e.g., 'today', 'afternoon', 'yesterday at 4:30pm'), calculate and resolve the precise value (such as ISO 8601 strings) using the provided reference timestamp and timezone. If a parameter value comes from a future step execution output, represent it as a JSON reference string (e.g., '{{step_1.output.id}}').",
15
+ "STEP_PLANNING: If tools are available, sequence them logically in 'steps'. Assign incremental 'step_id' starting at 1; ids are local to this plan, even when replanning. Set 'current_step_index' to 0 by default. Explicitly list any prerequisite step IDs in 'depends_on_steps' if a step requires output from a prior step. Define a clear 'expected_outcome' describing the precise expected result or data state after this step runs.",
16
+ "ARGUMENT_MAPPING: Map extracted_entities and execution context (e.g., CONTEXT metadata like 'now_utc', 'now_local', 'timezone', user_details, and session_details) to tool parameters in 'arguments'. For relative time/date expressions (e.g., 'today', 'afternoon', 'yesterday at 4:30pm'), calculate and resolve the precise value (such as ISO 8601 strings) using the provided reference timestamp and timezone. If a parameter value comes from the output of another step, represent it as a reference string: '{{step_N.output.path}}' where N is the 'step_id' of an earlier step in THIS plan, or '{{step_REF.output.path}}' where REF is the 'ref' of an entry in CONTEXT.execution_history. The path uses dot and bracket notation into that step's output (e.g., '{{step_1.output.results[0].name}}'), or is omitted to use the whole output.",
17
+ "REFERENCE_SAFETY: Only reference a path you are certain exists in that step's output, based on the tool description or on an output already visible in CONTEXT.execution_history. If the arguments of a step depend on the content of an output you cannot see yet (for example the results of a search or discovery tool), do NOT plan that dependent step: plan only up to the step that produces the data. After it runs, the plan will be revised with the real output in CONTEXT.execution_history. Never invent fields, and never pass empty arguments to a tool that has required parameters.",
18
+ "ARGUMENT_LANGUAGE: Values inside 'arguments' follow the description of each tool parameter, not 'detected_language'. If a parameter description asks for a specific language (for example English keywords), write that value in that language, translating or extracting the relevant domain terms and entity names from the user request when needed. Only values that must be stored or displayed verbatim (names, titles, free text written by the user) keep the user's original language.",
19
+ "REPLANNING: When CONTEXT.execution_history is present, you are revising a plan. Read each entry's 'status', 'output' and 'error', and CONTEXT.replan_feedback when present. Do not propose a step with the same tool and the same arguments as an entry already in the history; use the real outputs to build a different approach (different arguments, another candidate tool, or the data already discovered). If the history shows the goal is already achieved or no different approach is possible with the candidate tools, set 'plan_status' to 'NEEDS_CLARIFICATION' and ask the user for the specific information needed.",
17
20
  "PARAMETER_AND_SAFETY_VALIDATION: For each step, inspect the candidate tool schema properties and flags:",
18
21
  "1) Set 'is_destructive' to match the candidate tool's 'destructive' boolean flag.",
19
22
  "2) If any required parameter is MISSING and CANNOT be derived from CONTEXT: Set step 'status' to 'MISSING_PARAMS' and list the missing keys in 'missing_fields'.",
@@ -22,7 +25,7 @@ const actionPlanner = new Skill({
22
25
  "CLARIFICATION_CHECK: If ANY step has status 'MISSING_PARAMS': 1) Set 'plan_status' to 'NEEDS_CLARIFICATION', 2) Set 'needs_clarification' to true, 3) Collect all unresolvable parameters in 'missing_entities' in English, 4) Provide a short, direct, and polite question in 'clarification_prompt' written in 'detected_language', 5) Set 'user_response' to '', and 'confirmation_details' to null.",
23
26
  "CONFIRMATION_CHECK: If NO step has 'MISSING_PARAMS' BUT at least one step has status 'REQUIRES_CONFIRMATION': 1) Set 'plan_status' to 'NEEDS_CONFIRMATION', 2) Set 'needs_clarification' to false, 3) Set 'missing_entities' to [], 4) Populate 'confirmation_details' with: 'actions' (one entry per step with status 'REQUIRES_CONFIRMATION', each with that step's 'step_id' and a short natural-language 'description' of exactly what it will do, naming the action and its target \u2014 never the raw tool name or parameter keys), 'impact_summary' summarizing the overall permanent changes in plain terms, and 'confirm_label' \u2014 a short call-to-action asking the user to approve or decline; this will always be shown as the LAST line of the message, so it must stand on its own as the actual yes/no ask, 5) Provide context in 'clarification_prompt' introducing why confirmation is needed \u2014 this field must NOT itself ask a yes/no question, since 'confirm_label' is the only field that does that, 6) Set 'user_response' to ''. CRITICAL: every piece of text produced in this rule ('actions[].description', 'impact_summary', 'confirm_label', 'clarification_prompt') MUST be written in 'detected_language' \u2014 never default to English here regardless of the language used anywhere else in this instruction set.",
24
27
  "SUCCESS_STATE: If all steps are 'READY' and no tools are missing or requiring confirmation: 1) Set 'plan_status' to 'SUCCESS', 2) Set 'missing_tools_explanation' to '', 3) Set 'user_response' to '', 4) Set 'needs_clarification' to false, 'missing_entities' to [], 'clarification_prompt' to '', and 'confirmation_details' to null.",
25
- "LANGUAGE_ENFORCEMENT: ONLY 'clarification_prompt', 'user_response', and every field inside 'confirmation_details' (including each entry's 'description') MUST be written in the user's actual conversation language \u2014 use CONTEXT.detected_language when present; only fall back to CONTEXT.user_details.preferred_language if 'detected_language' is absent. 'preferred_language' is the app's configured display language and does NOT necessarily match the language the user is typing in right now \u2014 never prefer it over 'detected_language' when both exist. These are the only fields the end user actually reads before approving or declining. ALL OTHER fields ('missing_tools_explanation', step 'rationale', step 'expected_outcome', 'missing_entities', and 'reasoning') MUST strictly be written in English.",
28
+ "LANGUAGE_ENFORCEMENT: ONLY 'clarification_prompt', 'user_response', and every field inside 'confirmation_details' (including each entry's 'description') MUST be written in the user's actual conversation language \u2014 use CONTEXT.detected_language when present; only fall back to CONTEXT.user_details.preferred_language if 'detected_language' is absent. 'preferred_language' is the app's configured display language and does NOT necessarily match the language the user is typing in right now \u2014 never prefer it over 'detected_language' when both exist. These are the only fields the end user actually reads before approving or declining. ALL OTHER fields ('missing_tools_explanation', step 'rationale', step 'expected_outcome', 'missing_entities', and 'reasoning') MUST strictly be written in English, even when the user wrote in another language. The values inside step 'arguments' are governed by ARGUMENT_LANGUAGE.",
26
29
  "STRICT_OUTPUT: Return ONLY the JSON object matching response_schema."
27
30
  ],
28
31
  response_schema: {
@@ -25,7 +25,7 @@ var import_skill = require("../../../skills/skill.js");
25
25
  var import_shared_rules = require("../../../skills/shared/shared-rules.js");
26
26
  const finalResponder = new import_skill.Skill({
27
27
  name: "final_responder",
28
- version: "1.0.0",
28
+ version: "1.1.0",
29
29
  description: "Synthesizes tool execution results, scratchpad, and context state into a clear, natural, user-facing final response.",
30
30
  temperature: 0.3,
31
31
  systemInstructions: {
@@ -34,11 +34,12 @@ const finalResponder = new import_skill.Skill({
34
34
  role: "Final synthesis and communication engine",
35
35
  logic_rules: [
36
36
  "RESULT_SYNTHESIS: Review all tool execution results, outputs, and scratchpad context to build a clear, coherent answer addressing the user's original goal.",
37
- "USER_LANGUAGE_MATCHING: Always draft 'final_response' in the language used by the user in their original input or conversation history.",
37
+ "USER_LANGUAGE_MATCHING: Always draft 'final_response' in the user's actual conversation language: use CONTEXT.detected_language when present, otherwise the language used by the user in their original input or conversation history.",
38
+ "STOPPED_TASK: If CONTEXT.stop_reason is present, the task did NOT complete. Never claim success. Explain briefly what was attempted and what blocked progress, without internal tool names or stack traces, and ask the user how to proceed or what specific information would help. Do not add a fun fact in this case.",
38
39
  import_shared_rules.FORMATTING,
39
40
  import_shared_rules.LATEX_FORMATTING,
40
41
  import_shared_rules.CITATION_FORMATTING,
41
- "PROACTIVE_ENGAGEMENT: When 'can_answer' is true, always end your response with a relevant, proactive follow-up question related to the topic. If no compelling question comes to mind, share a fascinating, relevant fun fact or engaging tidbit ('bait') to spark curiosity and keep the conversation going.",
42
+ "PROACTIVE_ENGAGEMENT: When the task completed successfully, always end your response with a relevant, proactive follow-up question related to the topic. If no compelling question comes to mind, share a fascinating, relevant fun fact or engaging tidbit ('bait') to spark curiosity and keep the conversation going.",
42
43
  "ERROR_HANDLING: If tool executions failed or yielded partial results, communicate what was accomplished and what failed gracefully without exposing internal raw stack traces unless relevant.",
43
44
  "REASONING_LOG: Provide a concise logical summary of how the final answer was constructed from the tool outputs in 'reasoning' strictly in English.",
44
45
  "STRICT_ENGLISH_REASONING: The 'reasoning' field MUST strictly be written in English, while 'final_response' MUST match the user's language.",
@@ -3,7 +3,7 @@ import { Skill } from "../../../skills/skill.js";
3
3
  import { FORMATTING, LATEX_FORMATTING, CITATION_FORMATTING } from "../../../skills/shared/shared-rules.js";
4
4
  const finalResponder = new Skill({
5
5
  name: "final_responder",
6
- version: "1.0.0",
6
+ version: "1.1.0",
7
7
  description: "Synthesizes tool execution results, scratchpad, and context state into a clear, natural, user-facing final response.",
8
8
  temperature: 0.3,
9
9
  systemInstructions: {
@@ -12,11 +12,12 @@ const finalResponder = new Skill({
12
12
  role: "Final synthesis and communication engine",
13
13
  logic_rules: [
14
14
  "RESULT_SYNTHESIS: Review all tool execution results, outputs, and scratchpad context to build a clear, coherent answer addressing the user's original goal.",
15
- "USER_LANGUAGE_MATCHING: Always draft 'final_response' in the language used by the user in their original input or conversation history.",
15
+ "USER_LANGUAGE_MATCHING: Always draft 'final_response' in the user's actual conversation language: use CONTEXT.detected_language when present, otherwise the language used by the user in their original input or conversation history.",
16
+ "STOPPED_TASK: If CONTEXT.stop_reason is present, the task did NOT complete. Never claim success. Explain briefly what was attempted and what blocked progress, without internal tool names or stack traces, and ask the user how to proceed or what specific information would help. Do not add a fun fact in this case.",
16
17
  FORMATTING,
17
18
  LATEX_FORMATTING,
18
19
  CITATION_FORMATTING,
19
- "PROACTIVE_ENGAGEMENT: When 'can_answer' is true, always end your response with a relevant, proactive follow-up question related to the topic. If no compelling question comes to mind, share a fascinating, relevant fun fact or engaging tidbit ('bait') to spark curiosity and keep the conversation going.",
20
+ "PROACTIVE_ENGAGEMENT: When the task completed successfully, always end your response with a relevant, proactive follow-up question related to the topic. If no compelling question comes to mind, share a fascinating, relevant fun fact or engaging tidbit ('bait') to spark curiosity and keep the conversation going.",
20
21
  "ERROR_HANDLING: If tool executions failed or yielded partial results, communicate what was accomplished and what failed gracefully without exposing internal raw stack traces unless relevant.",
21
22
  "REASONING_LOG: Provide a concise logical summary of how the final answer was constructed from the tool outputs in 'reasoning' strictly in English.",
22
23
  "STRICT_ENGLISH_REASONING: The 'reasoning' field MUST strictly be written in English, while 'final_response' MUST match the user's language.",
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(state_observer_exports);
24
24
  var import_skill = require("../../../skills/skill.js");
25
25
  const stateObserver = new import_skill.Skill({
26
26
  name: "state_observer",
27
- version: "1.1.0",
27
+ version: "1.2.0",
28
28
  description: "Evaluates the execution output of a tool step against the overall user intent. Determines whether to proceed, replan, ask the user, or finish.",
29
29
  temperature: 0.1,
30
30
  systemInstructions: {
@@ -35,9 +35,13 @@ const stateObserver = new import_skill.Skill({
35
35
  "STEP_OUTPUT_ANALYSIS: Inspect 'executed_step'. Check both technical status (COMPLETED vs FAILED) and semantic content of 'output'. Identify if the tool returned empty data, permission errors, business logic failures, or unrecoverable exceptions.",
36
36
  "EVALUATE_CONTINUE: If the step status is 'COMPLETED' and the 'output' contains valid, expected data required for subsequent steps: 1) Set 'action' to 'CONTINUE', 2) Set 'feedback_for_planner' to '', 3) Set 'user_prompt' to ''.",
37
37
  "EVALUATE_FINISH: If the step status is 'COMPLETED' and the output fully answers the user's intent, rendering remaining planned steps unnecessary: 1) Set 'action' to 'FINISH', 2) Set 'feedback_for_planner' to '', 3) Set 'user_prompt' to ''.",
38
- "EVALUATE_REPLAN: If the step status is 'FAILED', OR if the tool output is empty/invalid, OR if the data returned drastically alters the context/assumptions required for remaining steps: 1) Set 'action' to 'REPLAN', 2) Provide detailed, actionable diagnostic feedback in 'feedback_for_planner' in English explaining why the step failed or what new constraints were discovered, 3) Set 'user_prompt' to ''.",
38
+ "EVALUATE_REPLAN: If the step status is 'FAILED', OR if the tool output is empty/invalid, OR if the data returned drastically alters the context/assumptions required for remaining steps, AND a concretely different approach is realistic (different arguments, another available tool, or new information found in the output): 1) Set 'action' to 'REPLAN', 2) Provide detailed, actionable diagnostic feedback in 'feedback_for_planner' in English explaining why the step failed or what new constraints were discovered, and naming the specific different approach to try (for example, different English keywords, or a tool found in the output), 3) Set 'user_prompt' to ''. If the step failed with 'Invalid arguments' or 'Unresolved references', explain exactly what was wrong so the planner can correct it.",
39
+ "REPLAN_BUDGET: CONTEXT.replans_remaining is the number of replans still allowed. If it is 0, NEVER choose 'REPLAN'; choose 'ASK_USER' instead and ask the user for the specific information needed to proceed.",
40
+ "NO_PROGRESS: If the output is empty or reports no matches and you cannot name a concretely different approach, do not choose 'REPLAN' (it would repeat the same step); choose 'ASK_USER' and ask the user for the specific details that would help.",
41
+ "TRUNCATED_OUTPUT: If 'executed_step.output.truncated' is true, only a preview of the output is shown. Judge from the preview and do not choose 'REPLAN' only because of truncation.",
39
42
  "EVALUATE_ASK_USER: If the tool output explicitly indicates that user intervention, a missing secret, an auth confirmation, or a decision choice is required to proceed: 1) Set 'action' to 'ASK_USER', 2) Set 'feedback_for_planner' to '', 3) Generate a clear, direct prompt in 'user_prompt' written in 'detected_language' asking the user for the necessary input.",
40
43
  "LANGUAGE_DETECTION: Detect the primary language of the user input/context and output its ISO 639-1 code in 'detected_language' (e.g., 'es', 'en', 'pt').",
44
+ "FIELD_DISCIPLINE: 'user_prompt' MUST be non-empty only when 'action' is 'ASK_USER' and MUST be '' for every other action. 'feedback_for_planner' MUST be non-empty only when 'action' is 'REPLAN' and MUST be '' for every other action.",
41
45
  "LANGUAGE_ENFORCEMENT: ONLY 'user_prompt' MUST be written in the language specified in 'detected_language'. ALL OTHER fields ('feedback_for_planner', 'detected_language', and 'reasoning') MUST strictly be written in English.",
42
46
  "STRICT_OUTPUT: Return ONLY the JSON object matching response_schema."
43
47
  ],
@@ -2,7 +2,7 @@ import "../../../chunk-CF3WOMB3.mjs";
2
2
  import { Skill } from "../../../skills/skill.js";
3
3
  const stateObserver = new Skill({
4
4
  name: "state_observer",
5
- version: "1.1.0",
5
+ version: "1.2.0",
6
6
  description: "Evaluates the execution output of a tool step against the overall user intent. Determines whether to proceed, replan, ask the user, or finish.",
7
7
  temperature: 0.1,
8
8
  systemInstructions: {
@@ -13,9 +13,13 @@ const stateObserver = new Skill({
13
13
  "STEP_OUTPUT_ANALYSIS: Inspect 'executed_step'. Check both technical status (COMPLETED vs FAILED) and semantic content of 'output'. Identify if the tool returned empty data, permission errors, business logic failures, or unrecoverable exceptions.",
14
14
  "EVALUATE_CONTINUE: If the step status is 'COMPLETED' and the 'output' contains valid, expected data required for subsequent steps: 1) Set 'action' to 'CONTINUE', 2) Set 'feedback_for_planner' to '', 3) Set 'user_prompt' to ''.",
15
15
  "EVALUATE_FINISH: If the step status is 'COMPLETED' and the output fully answers the user's intent, rendering remaining planned steps unnecessary: 1) Set 'action' to 'FINISH', 2) Set 'feedback_for_planner' to '', 3) Set 'user_prompt' to ''.",
16
- "EVALUATE_REPLAN: If the step status is 'FAILED', OR if the tool output is empty/invalid, OR if the data returned drastically alters the context/assumptions required for remaining steps: 1) Set 'action' to 'REPLAN', 2) Provide detailed, actionable diagnostic feedback in 'feedback_for_planner' in English explaining why the step failed or what new constraints were discovered, 3) Set 'user_prompt' to ''.",
16
+ "EVALUATE_REPLAN: If the step status is 'FAILED', OR if the tool output is empty/invalid, OR if the data returned drastically alters the context/assumptions required for remaining steps, AND a concretely different approach is realistic (different arguments, another available tool, or new information found in the output): 1) Set 'action' to 'REPLAN', 2) Provide detailed, actionable diagnostic feedback in 'feedback_for_planner' in English explaining why the step failed or what new constraints were discovered, and naming the specific different approach to try (for example, different English keywords, or a tool found in the output), 3) Set 'user_prompt' to ''. If the step failed with 'Invalid arguments' or 'Unresolved references', explain exactly what was wrong so the planner can correct it.",
17
+ "REPLAN_BUDGET: CONTEXT.replans_remaining is the number of replans still allowed. If it is 0, NEVER choose 'REPLAN'; choose 'ASK_USER' instead and ask the user for the specific information needed to proceed.",
18
+ "NO_PROGRESS: If the output is empty or reports no matches and you cannot name a concretely different approach, do not choose 'REPLAN' (it would repeat the same step); choose 'ASK_USER' and ask the user for the specific details that would help.",
19
+ "TRUNCATED_OUTPUT: If 'executed_step.output.truncated' is true, only a preview of the output is shown. Judge from the preview and do not choose 'REPLAN' only because of truncation.",
17
20
  "EVALUATE_ASK_USER: If the tool output explicitly indicates that user intervention, a missing secret, an auth confirmation, or a decision choice is required to proceed: 1) Set 'action' to 'ASK_USER', 2) Set 'feedback_for_planner' to '', 3) Generate a clear, direct prompt in 'user_prompt' written in 'detected_language' asking the user for the necessary input.",
18
21
  "LANGUAGE_DETECTION: Detect the primary language of the user input/context and output its ISO 639-1 code in 'detected_language' (e.g., 'es', 'en', 'pt').",
22
+ "FIELD_DISCIPLINE: 'user_prompt' MUST be non-empty only when 'action' is 'ASK_USER' and MUST be '' for every other action. 'feedback_for_planner' MUST be non-empty only when 'action' is 'REPLAN' and MUST be '' for every other action.",
19
23
  "LANGUAGE_ENFORCEMENT: ONLY 'user_prompt' MUST be written in the language specified in 'detected_language'. ALL OTHER fields ('feedback_for_planner', 'detected_language', and 'reasoning') MUST strictly be written in English.",
20
24
  "STRICT_OUTPUT: Return ONLY the JSON object matching response_schema."
21
25
  ],
@@ -1,16 +1,19 @@
1
+ import { ObjectId } from 'mongodb';
1
2
  import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
2
3
  type Roles = 'user' | 'assistant';
3
4
  export interface ChatMessageProps extends BaseEntityProps {
4
5
  role?: Roles;
5
6
  content?: string;
7
+ answerId?: string | ObjectId;
6
8
  }
7
9
  export declare class ChatMessage extends BaseEntity {
8
10
  private readonly props;
9
11
  role?: Roles | undefined;
10
12
  content?: string | undefined;
13
+ answerId?: ObjectId | undefined;
11
14
  static factory(message: ChatMessageProps): ChatMessage;
12
15
  static fromJSON(props: ChatMessageProps): ChatMessage;
13
- constructor(props: ChatMessageProps, role?: Roles | undefined, content?: string | undefined);
16
+ constructor(props: ChatMessageProps, role?: Roles | undefined, content?: string | undefined, answerId?: ObjectId | undefined);
14
17
  toJSON(): ChatMessageProps;
15
18
  }
16
19
  export {};
@@ -24,15 +24,17 @@ module.exports = __toCommonJS(chat_message_entity_exports);
24
24
  var import_mongodb = require("mongodb");
25
25
  var import_base = require("../../../common/base/base.entity.js");
26
26
  class ChatMessage extends import_base.BaseEntity {
27
- constructor(props, role, content) {
27
+ constructor(props, role, content, answerId) {
28
28
  super(props);
29
29
  this.props = props;
30
30
  this.role = role;
31
31
  this.content = content;
32
+ this.answerId = answerId;
32
33
  }
33
34
  props;
34
35
  role;
35
36
  content;
37
+ answerId;
36
38
  static factory(message) {
37
39
  const messageId = message._id && import_mongodb.ObjectId.isValid(message._id) ? new import_mongodb.ObjectId(message._id) : new import_mongodb.ObjectId();
38
40
  return ChatMessage.fromJSON({ ...message, _id: messageId });
@@ -41,14 +43,16 @@ class ChatMessage extends import_base.BaseEntity {
41
43
  return new ChatMessage(
42
44
  props,
43
45
  props.role,
44
- props.content
46
+ props.content,
47
+ import_base.BaseEntity.toObjectId(props.answerId)
45
48
  );
46
49
  }
47
50
  toJSON() {
48
51
  return {
49
52
  ...super.toJSON(),
50
53
  role: this.role,
51
- content: this.content
54
+ content: this.content,
55
+ answerId: this.answerId
52
56
  };
53
57
  }
54
58
  }
@@ -2,15 +2,17 @@ import "../../../chunk-CF3WOMB3.mjs";
2
2
  import { ObjectId } from "mongodb";
3
3
  import { BaseEntity } from "../../../common/base/base.entity.js";
4
4
  class ChatMessage extends BaseEntity {
5
- constructor(props, role, content) {
5
+ constructor(props, role, content, answerId) {
6
6
  super(props);
7
7
  this.props = props;
8
8
  this.role = role;
9
9
  this.content = content;
10
+ this.answerId = answerId;
10
11
  }
11
12
  props;
12
13
  role;
13
14
  content;
15
+ answerId;
14
16
  static factory(message) {
15
17
  const messageId = message._id && ObjectId.isValid(message._id) ? new ObjectId(message._id) : new ObjectId();
16
18
  return ChatMessage.fromJSON({ ...message, _id: messageId });
@@ -19,14 +21,16 @@ class ChatMessage extends BaseEntity {
19
21
  return new ChatMessage(
20
22
  props,
21
23
  props.role,
22
- props.content
24
+ props.content,
25
+ BaseEntity.toObjectId(props.answerId)
23
26
  );
24
27
  }
25
28
  toJSON() {
26
29
  return {
27
30
  ...super.toJSON(),
28
31
  role: this.role,
29
- content: this.content
32
+ content: this.content,
33
+ answerId: this.answerId
30
34
  };
31
35
  }
32
36
  }
@@ -1,40 +1,39 @@
1
1
  import { BaseEntity, BaseEntityProps } from '../../../common/base/base.entity.js';
2
- import { AgentStateProps, AgentState } from '../../../agent/agent-state.js';
2
+ import { AgentStateProps, AgentState } from '../../../harness/agent-state.js';
3
+ import { AgentTask } from '../../tasks/entities/agent-task.entity.js';
3
4
  import { ChatMessage, ChatMessageProps } from './chat-message.entity';
4
5
  import { ChatSettings, ChatSettingsProps } from './chat-settings.entity';
5
- import { ChatContext, ChatContextProps } from './chat-context.entity';
6
- import { AgentTask, AgentTaskProps } from './agent-task.entity';
7
6
  export interface ChatProps extends BaseEntityProps {
8
7
  state?: AgentStateProps;
9
8
  settings?: ChatSettingsProps;
10
9
  messages?: ChatMessageProps[];
11
- context?: ChatContextProps;
12
- tasks?: AgentTaskProps[];
13
- traces?: AgentTrace[];
14
10
  }
15
11
  export interface AgentTrace {
16
12
  node: string;
17
13
  reasoning?: string;
18
14
  taskId?: string;
19
15
  timestamp?: Date | string;
16
+ kind?: 'skill' | 'node' | 'agent';
17
+ iteration?: number;
18
+ durationMs?: number;
20
19
  }
21
20
  export declare class Chat extends BaseEntity {
22
21
  private readonly props;
23
22
  state?: AgentState | undefined;
24
23
  settings?: ChatSettings | undefined;
25
24
  messages?: ChatMessage[] | undefined;
26
- context: ChatContext;
27
- tasks: AgentTask[];
28
- traces?: AgentTrace[] | undefined;
29
25
  static withDefaults(loopName?: string): Chat;
30
26
  static fromJSON(props: ChatProps): Chat;
31
- constructor(props: ChatProps, state?: AgentState | undefined, settings?: ChatSettings | undefined, messages?: ChatMessage[] | undefined, context?: ChatContext, tasks?: AgentTask[], traces?: AgentTrace[] | undefined);
27
+ tasks: AgentTask[];
28
+ private pendingTraces;
29
+ constructor(props: ChatProps, state?: AgentState | undefined, settings?: ChatSettings | undefined, messages?: ChatMessage[] | undefined);
32
30
  get lastAnswer(): string | undefined;
33
31
  get activeTask(): AgentTask | undefined;
34
32
  toJSON(): ChatProps;
35
- pushMessage(message: ChatMessageProps): void;
33
+ pushMessage(message: ChatMessageProps): ChatMessage;
36
34
  lastHistoryMessages(count?: number): ChatMessage[] | undefined;
37
35
  addTrace(entry: Omit<AgentTrace, 'timestamp'>): void;
36
+ drainTraces(): AgentTrace[];
38
37
  setAgentState(contextState: AgentStateProps): void;
39
38
  getTask(taskId: string): AgentTask | undefined;
40
39
  lastCompletedTask(): AgentTask | undefined;
@@ -22,29 +22,22 @@ __export(chat_entity_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(chat_entity_exports);
24
24
  var import_base = require("../../../common/base/base.entity.js");
25
- var import_agent_state = require("../../../agent/agent-state.js");
25
+ var import_agent_state = require("../../../harness/agent-state.js");
26
+ var import_agent_task = require("../../tasks/entities/agent-task.entity.js");
26
27
  var import_chat_message = require("./chat-message.entity");
27
28
  var import_chat_settings = require("./chat-settings.entity");
28
- var import_chat_context = require("./chat-context.entity");
29
- var import_agent_task = require("./agent-task.entity");
30
29
  class Chat extends import_base.BaseEntity {
31
- constructor(props, state, settings, messages, context = import_chat_context.ChatContext.fromJSON({}), tasks = [], traces) {
30
+ constructor(props, state, settings, messages) {
32
31
  super(props);
33
32
  this.props = props;
34
33
  this.state = state;
35
34
  this.settings = settings;
36
35
  this.messages = messages;
37
- this.context = context;
38
- this.tasks = tasks;
39
- this.traces = traces;
40
36
  }
41
37
  props;
42
38
  state;
43
39
  settings;
44
40
  messages;
45
- context;
46
- tasks;
47
- traces;
48
41
  static withDefaults(loopName) {
49
42
  const agentState = new import_agent_state.AgentState();
50
43
  agentState.cleanContext();
@@ -58,12 +51,11 @@ class Chat extends import_base.BaseEntity {
58
51
  props,
59
52
  props.state && import_agent_state.AgentState.fromJSON(props.state),
60
53
  props.settings && import_chat_settings.ChatSettings.fromJSON(props.settings),
61
- props.messages?.map((message) => import_chat_message.ChatMessage.factory(message)),
62
- import_chat_context.ChatContext.fromJSON(props.context ?? {}),
63
- props.tasks?.map((task) => import_agent_task.AgentTask.fromJSON(task)) ?? [],
64
- props.traces
54
+ props.messages?.map((message) => import_chat_message.ChatMessage.factory(message))
65
55
  );
66
56
  }
57
+ tasks = [];
58
+ pendingTraces = [];
67
59
  get lastAnswer() {
68
60
  return this.messages?.slice().reverse().find((message) => message.role === "assistant")?.content;
69
61
  }
@@ -76,27 +68,30 @@ class Chat extends import_base.BaseEntity {
76
68
  ...super.toJSON(),
77
69
  state: this.state?.toJSON(),
78
70
  settings: this.settings?.toJSON(),
79
- messages: this.messages?.map((message) => message.toJSON()),
80
- context: this.context.toJSON(),
81
- tasks: this.tasks.map((task) => task.toJSON()),
82
- traces: this.traces
71
+ messages: this.messages?.map((message) => message.toJSON())
83
72
  };
84
73
  }
85
74
  pushMessage(message) {
86
75
  this.messages ??= [];
87
- this.messages.push(import_chat_message.ChatMessage.factory(message));
76
+ const created = import_chat_message.ChatMessage.factory(message);
77
+ this.messages.push(created);
78
+ return created;
88
79
  }
89
80
  lastHistoryMessages(count = 6) {
90
81
  return this.messages?.slice(-count, -1);
91
82
  }
92
83
  addTrace(entry) {
93
- this.traces ??= [];
94
- this.traces.push({
84
+ this.pendingTraces.push({
95
85
  ...entry,
96
86
  taskId: entry.taskId ?? this.activeTask?.id,
97
87
  timestamp: /* @__PURE__ */ new Date()
98
88
  });
99
89
  }
90
+ drainTraces() {
91
+ const traces = this.pendingTraces;
92
+ this.pendingTraces = [];
93
+ return traces;
94
+ }
100
95
  setAgentState(contextState) {
101
96
  this.state = import_agent_state.AgentState.fromJSON(contextState);
102
97
  }
@@ -112,6 +107,7 @@ class Chat extends import_base.BaseEntity {
112
107
  }
113
108
  const continuesFromTask = opts?.continuesFrom ? this.getTask(opts.continuesFrom) : void 0;
114
109
  const newTask = import_agent_task.AgentTask.factory({
110
+ chatId: this._id,
115
111
  goal,
116
112
  threadId: continuesFromTask?.threadId,
117
113
  previousTaskId: opts?.continuesFrom,
@@ -1,28 +1,21 @@
1
1
  import "../../../chunk-CF3WOMB3.mjs";
2
2
  import { BaseEntity } from "../../../common/base/base.entity.js";
3
- import { AgentState } from "../../../agent/agent-state.js";
3
+ import { AgentState } from "../../../harness/agent-state.js";
4
+ import { AgentTask, TaskStatus } from "../../tasks/entities/agent-task.entity.js";
4
5
  import { ChatMessage } from "./chat-message.entity";
5
6
  import { ChatSettings } from "./chat-settings.entity";
6
- import { ChatContext } from "./chat-context.entity";
7
- import { AgentTask, TaskStatus } from "./agent-task.entity";
8
7
  class Chat extends BaseEntity {
9
- constructor(props, state, settings, messages, context = ChatContext.fromJSON({}), tasks = [], traces) {
8
+ constructor(props, state, settings, messages) {
10
9
  super(props);
11
10
  this.props = props;
12
11
  this.state = state;
13
12
  this.settings = settings;
14
13
  this.messages = messages;
15
- this.context = context;
16
- this.tasks = tasks;
17
- this.traces = traces;
18
14
  }
19
15
  props;
20
16
  state;
21
17
  settings;
22
18
  messages;
23
- context;
24
- tasks;
25
- traces;
26
19
  static withDefaults(loopName) {
27
20
  const agentState = new AgentState();
28
21
  agentState.cleanContext();
@@ -36,12 +29,11 @@ class Chat extends BaseEntity {
36
29
  props,
37
30
  props.state && AgentState.fromJSON(props.state),
38
31
  props.settings && ChatSettings.fromJSON(props.settings),
39
- props.messages?.map((message) => ChatMessage.factory(message)),
40
- ChatContext.fromJSON(props.context ?? {}),
41
- props.tasks?.map((task) => AgentTask.fromJSON(task)) ?? [],
42
- props.traces
32
+ props.messages?.map((message) => ChatMessage.factory(message))
43
33
  );
44
34
  }
35
+ tasks = [];
36
+ pendingTraces = [];
45
37
  get lastAnswer() {
46
38
  return this.messages?.slice().reverse().find((message) => message.role === "assistant")?.content;
47
39
  }
@@ -54,27 +46,30 @@ class Chat extends BaseEntity {
54
46
  ...super.toJSON(),
55
47
  state: this.state?.toJSON(),
56
48
  settings: this.settings?.toJSON(),
57
- messages: this.messages?.map((message) => message.toJSON()),
58
- context: this.context.toJSON(),
59
- tasks: this.tasks.map((task) => task.toJSON()),
60
- traces: this.traces
49
+ messages: this.messages?.map((message) => message.toJSON())
61
50
  };
62
51
  }
63
52
  pushMessage(message) {
64
53
  this.messages ??= [];
65
- this.messages.push(ChatMessage.factory(message));
54
+ const created = ChatMessage.factory(message);
55
+ this.messages.push(created);
56
+ return created;
66
57
  }
67
58
  lastHistoryMessages(count = 6) {
68
59
  return this.messages?.slice(-count, -1);
69
60
  }
70
61
  addTrace(entry) {
71
- this.traces ??= [];
72
- this.traces.push({
62
+ this.pendingTraces.push({
73
63
  ...entry,
74
64
  taskId: entry.taskId ?? this.activeTask?.id,
75
65
  timestamp: /* @__PURE__ */ new Date()
76
66
  });
77
67
  }
68
+ drainTraces() {
69
+ const traces = this.pendingTraces;
70
+ this.pendingTraces = [];
71
+ return traces;
72
+ }
78
73
  setAgentState(contextState) {
79
74
  this.state = AgentState.fromJSON(contextState);
80
75
  }
@@ -90,6 +85,7 @@ class Chat extends BaseEntity {
90
85
  }
91
86
  const continuesFromTask = opts?.continuesFrom ? this.getTask(opts.continuesFrom) : void 0;
92
87
  const newTask = AgentTask.factory({
88
+ chatId: this._id,
93
89
  goal,
94
90
  threadId: continuesFromTask?.threadId,
95
91
  previousTaskId: opts?.continuesFrom,
@@ -1,8 +1,10 @@
1
+ import { QueryParams } from '../../../../common/repositories/index.js';
1
2
  import { BaseUseCase, BaseUseCaseParams, BaseUseCaseOutput } from '../../../../common/base/base.use-case.js';
2
3
  import { ChatRepository } from '../../repositories';
3
4
  import { ChatProps } from '../../entities';
4
5
  export interface Params extends BaseUseCaseParams {
5
6
  id: string;
7
+ select?: QueryParams<ChatProps>['select'];
6
8
  }
7
9
  export interface Output extends BaseUseCaseOutput {
8
10
  data: ChatProps | null;
@@ -32,7 +32,7 @@ __export(get_chat_by_id_use_case_exports, {
32
32
  module.exports = __toCommonJS(get_chat_by_id_use_case_exports);
33
33
  var import_tsyringe = require("tsyringe");
34
34
  var import_base = require("../../../../common/base/base.use-case.js");
35
- var import_repositories = require("../../repositories");
35
+ var import_repositories2 = require("../../repositories");
36
36
  let GetChatByIdUseCase = class extends import_base.BaseUseCase {
37
37
  constructor(chatRepository) {
38
38
  super();
@@ -40,14 +40,14 @@ let GetChatByIdUseCase = class extends import_base.BaseUseCase {
40
40
  }
41
41
  chatRepository;
42
42
  async execute(params) {
43
- const { id } = params;
44
- const data = await this.chatRepository?.findById(id) || {};
43
+ const { id, select } = params;
44
+ const data = await this.chatRepository?.findById(id, select) || {};
45
45
  return { data };
46
46
  }
47
47
  };
48
48
  GetChatByIdUseCase = __decorateClass([
49
49
  (0, import_tsyringe.autoInjectable)(),
50
- __decorateParam(0, (0, import_tsyringe.inject)(import_repositories.ChatRepository))
50
+ __decorateParam(0, (0, import_tsyringe.inject)(import_repositories2.ChatRepository))
51
51
  ], GetChatByIdUseCase);
52
52
  // Annotate the CommonJS export names for ESM import in node:
53
53
  0 && (module.exports = {
@@ -12,8 +12,8 @@ let GetChatByIdUseCase = class extends BaseUseCase {
12
12
  }
13
13
  chatRepository;
14
14
  async execute(params) {
15
- const { id } = params;
16
- const data = await this.chatRepository?.findById(id) || {};
15
+ const { id, select } = params;
16
+ const data = await this.chatRepository?.findById(id, select) || {};
17
17
  return { data };
18
18
  }
19
19
  };