attocode 0.2.1 → 0.2.3

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 (219) hide show
  1. package/CHANGELOG.md +191 -1
  2. package/README.md +7 -0
  3. package/dist/src/adapters.d.ts +6 -1
  4. package/dist/src/adapters.d.ts.map +1 -1
  5. package/dist/src/adapters.js +8 -1
  6. package/dist/src/adapters.js.map +1 -1
  7. package/dist/src/agent.d.ts +41 -4
  8. package/dist/src/agent.d.ts.map +1 -1
  9. package/dist/src/agent.js +846 -75
  10. package/dist/src/agent.js.map +1 -1
  11. package/dist/src/cli.d.ts.map +1 -1
  12. package/dist/src/cli.js +23 -2
  13. package/dist/src/cli.js.map +1 -1
  14. package/dist/src/core/protocol/types.d.ts +8 -8
  15. package/dist/src/defaults.d.ts +7 -2
  16. package/dist/src/defaults.d.ts.map +1 -1
  17. package/dist/src/defaults.js +38 -2
  18. package/dist/src/defaults.js.map +1 -1
  19. package/dist/src/integrations/agent-registry.d.ts +13 -0
  20. package/dist/src/integrations/agent-registry.d.ts.map +1 -1
  21. package/dist/src/integrations/agent-registry.js.map +1 -1
  22. package/dist/src/integrations/async-subagent.d.ts +135 -0
  23. package/dist/src/integrations/async-subagent.d.ts.map +1 -0
  24. package/dist/src/integrations/async-subagent.js +213 -0
  25. package/dist/src/integrations/async-subagent.js.map +1 -0
  26. package/dist/src/integrations/auto-checkpoint.d.ts +98 -0
  27. package/dist/src/integrations/auto-checkpoint.d.ts.map +1 -0
  28. package/dist/src/integrations/auto-checkpoint.js +252 -0
  29. package/dist/src/integrations/auto-checkpoint.js.map +1 -0
  30. package/dist/src/integrations/auto-compaction.d.ts.map +1 -1
  31. package/dist/src/integrations/auto-compaction.js +5 -1
  32. package/dist/src/integrations/auto-compaction.js.map +1 -1
  33. package/dist/src/integrations/bash-policy.d.ts +33 -0
  34. package/dist/src/integrations/bash-policy.d.ts.map +1 -0
  35. package/dist/src/integrations/bash-policy.js +142 -0
  36. package/dist/src/integrations/bash-policy.js.map +1 -0
  37. package/dist/src/integrations/codebase-context.d.ts +5 -0
  38. package/dist/src/integrations/codebase-context.d.ts.map +1 -1
  39. package/dist/src/integrations/codebase-context.js +33 -0
  40. package/dist/src/integrations/codebase-context.js.map +1 -1
  41. package/dist/src/integrations/complexity-classifier.d.ts +86 -0
  42. package/dist/src/integrations/complexity-classifier.d.ts.map +1 -0
  43. package/dist/src/integrations/complexity-classifier.js +233 -0
  44. package/dist/src/integrations/complexity-classifier.js.map +1 -0
  45. package/dist/src/integrations/delegation-protocol.d.ts +86 -0
  46. package/dist/src/integrations/delegation-protocol.d.ts.map +1 -0
  47. package/dist/src/integrations/delegation-protocol.js +127 -0
  48. package/dist/src/integrations/delegation-protocol.js.map +1 -0
  49. package/dist/src/integrations/dynamic-budget.d.ts +81 -0
  50. package/dist/src/integrations/dynamic-budget.d.ts.map +1 -0
  51. package/dist/src/integrations/dynamic-budget.js +151 -0
  52. package/dist/src/integrations/dynamic-budget.js.map +1 -0
  53. package/dist/src/integrations/economics.d.ts +86 -1
  54. package/dist/src/integrations/economics.d.ts.map +1 -1
  55. package/dist/src/integrations/economics.js +306 -11
  56. package/dist/src/integrations/economics.js.map +1 -1
  57. package/dist/src/integrations/environment-facts.d.ts +52 -0
  58. package/dist/src/integrations/environment-facts.d.ts.map +1 -0
  59. package/dist/src/integrations/environment-facts.js +84 -0
  60. package/dist/src/integrations/environment-facts.js.map +1 -0
  61. package/dist/src/integrations/hierarchical-config.d.ts.map +1 -1
  62. package/dist/src/integrations/hierarchical-config.js +17 -0
  63. package/dist/src/integrations/hierarchical-config.js.map +1 -1
  64. package/dist/src/integrations/index.d.ts +19 -2
  65. package/dist/src/integrations/index.d.ts.map +1 -1
  66. package/dist/src/integrations/index.js +34 -2
  67. package/dist/src/integrations/index.js.map +1 -1
  68. package/dist/src/integrations/injection-budget.d.ts +71 -0
  69. package/dist/src/integrations/injection-budget.d.ts.map +1 -0
  70. package/dist/src/integrations/injection-budget.js +136 -0
  71. package/dist/src/integrations/injection-budget.js.map +1 -0
  72. package/dist/src/integrations/mcp-client.d.ts.map +1 -1
  73. package/dist/src/integrations/mcp-client.js +14 -0
  74. package/dist/src/integrations/mcp-client.js.map +1 -1
  75. package/dist/src/integrations/mcp-custom-tools.d.ts +102 -0
  76. package/dist/src/integrations/mcp-custom-tools.d.ts.map +1 -0
  77. package/dist/src/integrations/mcp-custom-tools.js +232 -0
  78. package/dist/src/integrations/mcp-custom-tools.js.map +1 -0
  79. package/dist/src/integrations/mcp-tool-validator.d.ts +60 -0
  80. package/dist/src/integrations/mcp-tool-validator.d.ts.map +1 -0
  81. package/dist/src/integrations/mcp-tool-validator.js +141 -0
  82. package/dist/src/integrations/mcp-tool-validator.js.map +1 -0
  83. package/dist/src/integrations/policy-engine.d.ts +55 -0
  84. package/dist/src/integrations/policy-engine.d.ts.map +1 -0
  85. package/dist/src/integrations/policy-engine.js +247 -0
  86. package/dist/src/integrations/policy-engine.js.map +1 -0
  87. package/dist/src/integrations/safety.d.ts +5 -4
  88. package/dist/src/integrations/safety.d.ts.map +1 -1
  89. package/dist/src/integrations/safety.js +32 -7
  90. package/dist/src/integrations/safety.js.map +1 -1
  91. package/dist/src/integrations/sandbox/basic.d.ts +7 -0
  92. package/dist/src/integrations/sandbox/basic.d.ts.map +1 -1
  93. package/dist/src/integrations/sandbox/basic.js +27 -2
  94. package/dist/src/integrations/sandbox/basic.js.map +1 -1
  95. package/dist/src/integrations/sandbox/index.d.ts +6 -0
  96. package/dist/src/integrations/sandbox/index.d.ts.map +1 -1
  97. package/dist/src/integrations/sandbox/index.js +3 -0
  98. package/dist/src/integrations/sandbox/index.js.map +1 -1
  99. package/dist/src/integrations/sandbox/landlock.d.ts.map +1 -1
  100. package/dist/src/integrations/sandbox/landlock.js +3 -0
  101. package/dist/src/integrations/sandbox/landlock.js.map +1 -1
  102. package/dist/src/integrations/self-improvement.d.ts +90 -0
  103. package/dist/src/integrations/self-improvement.d.ts.map +1 -0
  104. package/dist/src/integrations/self-improvement.js +229 -0
  105. package/dist/src/integrations/self-improvement.js.map +1 -0
  106. package/dist/src/integrations/smart-decomposer.d.ts +22 -1
  107. package/dist/src/integrations/smart-decomposer.d.ts.map +1 -1
  108. package/dist/src/integrations/smart-decomposer.js +127 -28
  109. package/dist/src/integrations/smart-decomposer.js.map +1 -1
  110. package/dist/src/integrations/subagent-output-store.d.ts +91 -0
  111. package/dist/src/integrations/subagent-output-store.d.ts.map +1 -0
  112. package/dist/src/integrations/subagent-output-store.js +257 -0
  113. package/dist/src/integrations/subagent-output-store.js.map +1 -0
  114. package/dist/src/integrations/swarm/index.d.ts +2 -2
  115. package/dist/src/integrations/swarm/index.d.ts.map +1 -1
  116. package/dist/src/integrations/swarm/index.js +1 -1
  117. package/dist/src/integrations/swarm/index.js.map +1 -1
  118. package/dist/src/integrations/swarm/model-selector.d.ts +16 -0
  119. package/dist/src/integrations/swarm/model-selector.d.ts.map +1 -1
  120. package/dist/src/integrations/swarm/model-selector.js +123 -10
  121. package/dist/src/integrations/swarm/model-selector.js.map +1 -1
  122. package/dist/src/integrations/swarm/swarm-budget.d.ts +4 -0
  123. package/dist/src/integrations/swarm/swarm-budget.d.ts.map +1 -1
  124. package/dist/src/integrations/swarm/swarm-budget.js +6 -0
  125. package/dist/src/integrations/swarm/swarm-budget.js.map +1 -1
  126. package/dist/src/integrations/swarm/swarm-config-loader.d.ts +10 -1
  127. package/dist/src/integrations/swarm/swarm-config-loader.d.ts.map +1 -1
  128. package/dist/src/integrations/swarm/swarm-config-loader.js +226 -13
  129. package/dist/src/integrations/swarm/swarm-config-loader.js.map +1 -1
  130. package/dist/src/integrations/swarm/swarm-event-bridge.d.ts +12 -1
  131. package/dist/src/integrations/swarm/swarm-event-bridge.d.ts.map +1 -1
  132. package/dist/src/integrations/swarm/swarm-event-bridge.js +178 -9
  133. package/dist/src/integrations/swarm/swarm-event-bridge.js.map +1 -1
  134. package/dist/src/integrations/swarm/swarm-events.d.ts +66 -1
  135. package/dist/src/integrations/swarm/swarm-events.d.ts.map +1 -1
  136. package/dist/src/integrations/swarm/swarm-events.js +26 -5
  137. package/dist/src/integrations/swarm/swarm-events.js.map +1 -1
  138. package/dist/src/integrations/swarm/swarm-orchestrator.d.ts +127 -0
  139. package/dist/src/integrations/swarm/swarm-orchestrator.d.ts.map +1 -1
  140. package/dist/src/integrations/swarm/swarm-orchestrator.js +1842 -47
  141. package/dist/src/integrations/swarm/swarm-orchestrator.js.map +1 -1
  142. package/dist/src/integrations/swarm/swarm-quality-gate.d.ts +91 -3
  143. package/dist/src/integrations/swarm/swarm-quality-gate.d.ts.map +1 -1
  144. package/dist/src/integrations/swarm/swarm-quality-gate.js +395 -19
  145. package/dist/src/integrations/swarm/swarm-quality-gate.js.map +1 -1
  146. package/dist/src/integrations/swarm/task-queue.d.ts +55 -1
  147. package/dist/src/integrations/swarm/task-queue.d.ts.map +1 -1
  148. package/dist/src/integrations/swarm/task-queue.js +389 -16
  149. package/dist/src/integrations/swarm/task-queue.js.map +1 -1
  150. package/dist/src/integrations/swarm/types.d.ts +247 -11
  151. package/dist/src/integrations/swarm/types.d.ts.map +1 -1
  152. package/dist/src/integrations/swarm/types.js +67 -9
  153. package/dist/src/integrations/swarm/types.js.map +1 -1
  154. package/dist/src/integrations/swarm/worker-pool.d.ts +18 -5
  155. package/dist/src/integrations/swarm/worker-pool.d.ts.map +1 -1
  156. package/dist/src/integrations/swarm/worker-pool.js +236 -34
  157. package/dist/src/integrations/swarm/worker-pool.js.map +1 -1
  158. package/dist/src/integrations/thinking-strategy.d.ts +52 -0
  159. package/dist/src/integrations/thinking-strategy.d.ts.map +1 -0
  160. package/dist/src/integrations/thinking-strategy.js +129 -0
  161. package/dist/src/integrations/thinking-strategy.js.map +1 -0
  162. package/dist/src/integrations/tool-recommendation.d.ts +61 -0
  163. package/dist/src/integrations/tool-recommendation.d.ts.map +1 -0
  164. package/dist/src/integrations/tool-recommendation.js +268 -0
  165. package/dist/src/integrations/tool-recommendation.js.map +1 -0
  166. package/dist/src/integrations/verification-gate.d.ts +80 -0
  167. package/dist/src/integrations/verification-gate.d.ts.map +1 -0
  168. package/dist/src/integrations/verification-gate.js +146 -0
  169. package/dist/src/integrations/verification-gate.js.map +1 -0
  170. package/dist/src/integrations/work-log.d.ts +87 -0
  171. package/dist/src/integrations/work-log.d.ts.map +1 -0
  172. package/dist/src/integrations/work-log.js +275 -0
  173. package/dist/src/integrations/work-log.js.map +1 -0
  174. package/dist/src/main.js +31 -5
  175. package/dist/src/main.js.map +1 -1
  176. package/dist/src/modes/repl.d.ts.map +1 -1
  177. package/dist/src/modes/repl.js +10 -4
  178. package/dist/src/modes/repl.js.map +1 -1
  179. package/dist/src/modes/tui.d.ts.map +1 -1
  180. package/dist/src/modes/tui.js +5 -0
  181. package/dist/src/modes/tui.js.map +1 -1
  182. package/dist/src/modes.d.ts +6 -0
  183. package/dist/src/modes.d.ts.map +1 -1
  184. package/dist/src/modes.js +69 -21
  185. package/dist/src/modes.js.map +1 -1
  186. package/dist/src/tools/agent.d.ts.map +1 -1
  187. package/dist/src/tools/agent.js +11 -2
  188. package/dist/src/tools/agent.js.map +1 -1
  189. package/dist/src/tools/bash.d.ts +9 -3
  190. package/dist/src/tools/bash.d.ts.map +1 -1
  191. package/dist/src/tools/bash.js +12 -0
  192. package/dist/src/tools/bash.js.map +1 -1
  193. package/dist/src/tools/coercion.d.ts +6 -0
  194. package/dist/src/tools/coercion.d.ts.map +1 -1
  195. package/dist/src/tools/coercion.js +13 -0
  196. package/dist/src/tools/coercion.js.map +1 -1
  197. package/dist/src/tools/file.d.ts +2 -2
  198. package/dist/src/tools/file.js +2 -2
  199. package/dist/src/tools/file.js.map +1 -1
  200. package/dist/src/tools/permission.d.ts.map +1 -1
  201. package/dist/src/tools/permission.js +4 -111
  202. package/dist/src/tools/permission.js.map +1 -1
  203. package/dist/src/tools/standard.d.ts +17 -1
  204. package/dist/src/tools/standard.d.ts.map +1 -1
  205. package/dist/src/tools/standard.js +64 -11
  206. package/dist/src/tools/standard.js.map +1 -1
  207. package/dist/src/tracing/trace-collector.d.ts +167 -0
  208. package/dist/src/tracing/trace-collector.d.ts.map +1 -1
  209. package/dist/src/tracing/trace-collector.js +137 -0
  210. package/dist/src/tracing/trace-collector.js.map +1 -1
  211. package/dist/src/tracing/types.d.ts +105 -1
  212. package/dist/src/tracing/types.d.ts.map +1 -1
  213. package/dist/src/tracing/types.js.map +1 -1
  214. package/dist/src/tui/app.d.ts.map +1 -1
  215. package/dist/src/tui/app.js +34 -5
  216. package/dist/src/tui/app.js.map +1 -1
  217. package/dist/src/types.d.ts +89 -0
  218. package/dist/src/types.d.ts.map +1 -1
  219. package/package.json +6 -2
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Thinking/Reflection Strategy
3
+ *
4
+ * Generates thinking directives that guide LLMs to use their
5
+ * internal reasoning (extended thinking) for better planning,
6
+ * evaluation, and self-assessment.
7
+ *
8
+ * Following Anthropic's multi-agent research pattern:
9
+ * thinking is controlled through prompt engineering, not code mechanics.
10
+ */
11
+ // =============================================================================
12
+ // CONSTANTS
13
+ // =============================================================================
14
+ const DEFAULT_CONFIG = {
15
+ enablePreTaskPlanning: true,
16
+ enablePostToolEvaluation: true,
17
+ enableQualityAssessment: true,
18
+ minComplexityTier: 'medium',
19
+ };
20
+ /**
21
+ * Complexity tier ordering for comparison.
22
+ */
23
+ const TIER_ORDER = {
24
+ simple: 0,
25
+ medium: 1,
26
+ complex: 2,
27
+ deep_research: 3,
28
+ };
29
+ // =============================================================================
30
+ // DIRECTIVE GENERATORS
31
+ // =============================================================================
32
+ /**
33
+ * Generate thinking directives based on complexity and config.
34
+ */
35
+ export function generateThinkingDirectives(complexityTier, config) {
36
+ const cfg = { ...DEFAULT_CONFIG, ...config };
37
+ // Check if thinking should be activated for this complexity level
38
+ if (TIER_ORDER[complexityTier] < TIER_ORDER[cfg.minComplexityTier]) {
39
+ return {}; // No thinking directives for simple tasks
40
+ }
41
+ const directive = {};
42
+ if (cfg.enablePreTaskPlanning) {
43
+ directive.preActionPrompt = getPreActionPrompt(complexityTier);
44
+ }
45
+ if (cfg.enablePostToolEvaluation) {
46
+ directive.postToolPrompt = getPostToolPrompt(complexityTier);
47
+ }
48
+ if (cfg.enableQualityAssessment) {
49
+ directive.qualityCheckPrompt = getQualityCheckPrompt(complexityTier);
50
+ }
51
+ return directive;
52
+ }
53
+ function getPreActionPrompt(tier) {
54
+ if (tier === 'deep_research' || tier === 'complex') {
55
+ return `Before taking any action, use your thinking to:
56
+ 1. Assess which tools are most relevant for this task
57
+ 2. Determine the optimal sequence of operations
58
+ 3. If complex, plan which subagents to spawn and what each should do
59
+ 4. Identify potential pitfalls or dependencies between subtasks
60
+ 5. Decide whether to explore more or act on what you know
61
+
62
+ Then proceed with your plan.`;
63
+ }
64
+ return `Before acting, briefly assess in your thinking:
65
+ 1. What tools are most relevant for this task?
66
+ 2. What is the most efficient approach?
67
+ 3. Are there dependencies between steps?
68
+
69
+ Then proceed.`;
70
+ }
71
+ function getPostToolPrompt(_tier) {
72
+ return `After receiving tool results, evaluate in your thinking:
73
+ - Did the tool calls return useful information?
74
+ - Is the information sufficient or do I need more?
75
+ - Should I change approach based on what I learned?
76
+ - Are there any errors or unexpected results to address?`;
77
+ }
78
+ function getQualityCheckPrompt(_tier) {
79
+ return `Before returning your final answer, evaluate in your thinking:
80
+ 1. Did I address all aspects of the objective?
81
+ 2. Is my output complete and in the correct format?
82
+ 3. Have I met all success criteria?
83
+ 4. Are there any gaps or issues I should flag?`;
84
+ }
85
+ // =============================================================================
86
+ // SYSTEM PROMPT INTEGRATION
87
+ // =============================================================================
88
+ /**
89
+ * Generate thinking-related system prompt additions.
90
+ * Injected into buildMessages() for complex tasks.
91
+ */
92
+ export function getThinkingSystemPrompt(complexityTier, config) {
93
+ const directive = generateThinkingDirectives(complexityTier, config);
94
+ if (!directive.preActionPrompt && !directive.postToolPrompt) {
95
+ return null;
96
+ }
97
+ const parts = ['## Thinking Guidelines'];
98
+ if (directive.preActionPrompt) {
99
+ parts.push(`### Before Acting\n${directive.preActionPrompt}`);
100
+ }
101
+ if (directive.postToolPrompt) {
102
+ parts.push(`### After Tool Results\n${directive.postToolPrompt}`);
103
+ }
104
+ return parts.join('\n\n');
105
+ }
106
+ /**
107
+ * Generate quality self-assessment prompt for subagents.
108
+ * Added to subagent constraints before they return.
109
+ */
110
+ export function getSubagentQualityPrompt() {
111
+ return `Before returning your final result, evaluate your work:
112
+ 1. Did you fully address the objective given to you?
113
+ 2. Is your output in the expected format?
114
+ 3. Did you stay within scope (not doing more or less than asked)?
115
+ 4. Are there any unresolved issues or gaps to flag to the parent?
116
+
117
+ If you find gaps, note them clearly in your response.`;
118
+ }
119
+ /**
120
+ * Create a thinking strategy manager.
121
+ */
122
+ export function createThinkingStrategy(config) {
123
+ return {
124
+ generateDirectives: (tier) => generateThinkingDirectives(tier, config),
125
+ getSystemPrompt: (tier) => getThinkingSystemPrompt(tier, config),
126
+ getSubagentPrompt: getSubagentQualityPrompt,
127
+ };
128
+ }
129
+ //# sourceMappingURL=thinking-strategy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thinking-strategy.js","sourceRoot":"","sources":["../../../src/integrations/thinking-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA4BH,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,cAAc,GAAmB;IACrC,qBAAqB,EAAE,IAAI;IAC3B,wBAAwB,EAAE,IAAI;IAC9B,uBAAuB,EAAE,IAAI;IAC7B,iBAAiB,EAAE,QAAQ;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,GAAmC;IACjD,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,aAAa,EAAE,CAAC;CACjB,CAAC;AAEF,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,cAA8B,EAC9B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CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAa,CAAC,wBAAwB,CAAC,CAAC;IAEnD,IAAI,SAAS,CAAC,eAAe,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,sBAAsB,SAAS,CAAC,eAAe,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,SAAS,CAAC,cAAc,EAAE,CAAC;QAC7B,KAAK,CAAC,IAAI,CAAC,2BAA2B,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,OAAO;;;;;;sDAM6C,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAgC;IAMhC,OAAO;QACL,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC;QACtE,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,uBAAuB,CAAC,IAAI,EAAE,MAAM,CAAC;QAChE,iBAAiB,EAAE,wBAAwB;KAC5C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Tool Recommendation Engine
3
+ *
4
+ * Heuristic-based tool recommendation for subagents and swarm workers.
5
+ * Maps task types to tool categories and analyzes task descriptions
6
+ * for tool-relevant keywords.
7
+ *
8
+ * Key features:
9
+ * - Static task-type → tool-category mappings (no LLM call needed)
10
+ * - Keyword analysis for MCP tool preloading
11
+ * - Tool filtering for subagent specialization
12
+ * - Custom task types fall back to a known type's tools based on capability
13
+ */
14
+ import type { WorkerCapability } from './swarm/types.js';
15
+ export interface ToolRecommendation {
16
+ toolName: string;
17
+ relevanceScore: number;
18
+ reason: string;
19
+ source: 'builtin' | 'mcp';
20
+ }
21
+ export interface ToolRecommendationConfig {
22
+ /** Maximum tools to recommend per agent (default: 15) */
23
+ maxToolsPerAgent?: number;
24
+ /** Enable MCP tool preloading for known patterns (default: true) */
25
+ enablePreloading?: boolean;
26
+ /** Task-type to tool mapping overrides */
27
+ taskToolOverrides?: Record<string, string[]>;
28
+ }
29
+ export interface ToolCategory {
30
+ name: string;
31
+ tools: string[];
32
+ relevance: number;
33
+ }
34
+ export declare class ToolRecommendationEngine {
35
+ private config;
36
+ constructor(config?: ToolRecommendationConfig);
37
+ /**
38
+ * Recommend tools for a task based on type and description.
39
+ * Custom task types not in TASK_TYPE_TOOL_MAP fall back to a known type
40
+ * based on the custom type's capability (via TaskTypeConfig).
41
+ */
42
+ recommendTools(taskDescription: string, taskType: string, availableToolNames: string[], capability?: WorkerCapability): ToolRecommendation[];
43
+ /**
44
+ * Get MCP tool prefixes that should be preloaded for a task type.
45
+ */
46
+ getMCPPreloadPrefixes(taskDescription: string): string[];
47
+ /**
48
+ * Filter tools for an agent based on task type.
49
+ * Returns tool names that should be available to the agent.
50
+ */
51
+ getToolFilterForTaskType(taskType: string, availableToolNames: string[]): string[];
52
+ /**
53
+ * Infer a SubtaskType from an agent name.
54
+ */
55
+ static inferTaskType(agentName: string): string;
56
+ }
57
+ /**
58
+ * Create a tool recommendation engine with optional config.
59
+ */
60
+ export declare function createToolRecommendationEngine(config?: ToolRecommendationConfig): ToolRecommendationEngine;
61
+ //# sourceMappingURL=tool-recommendation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-recommendation.d.ts","sourceRoot":"","sources":["../../../src/integrations/tool-recommendation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAMzD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,SAAS,GAAG,KAAK,CAAC;CAC3B;AAED,MAAM,WAAW,wBAAwB;IACvC,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oEAAoE;IACpE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AA0HD,qBAAa,wBAAwB;IACnC,OAAO,CAAC,MAAM,CAAqC;gBAEvC,MAAM,CAAC,EAAE,wBAAwB;IAQ7C;;;;OAIG;IACH,cAAc,CACZ,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAAE,EAC5B,UAAU,CAAC,EAAE,gBAAgB,GAC5B,kBAAkB,EAAE;IAoEvB;;OAEG;IACH,qBAAqB,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE;IAgBxD;;;OAGG;IACH,wBAAwB,CACtB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,EAAE,GAC3B,MAAM,EAAE;IAKX;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;CAmChD;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,CAAC,EAAE,wBAAwB,GAChC,wBAAwB,CAE1B"}
@@ -0,0 +1,268 @@
1
+ /**
2
+ * Tool Recommendation Engine
3
+ *
4
+ * Heuristic-based tool recommendation for subagents and swarm workers.
5
+ * Maps task types to tool categories and analyzes task descriptions
6
+ * for tool-relevant keywords.
7
+ *
8
+ * Key features:
9
+ * - Static task-type → tool-category mappings (no LLM call needed)
10
+ * - Keyword analysis for MCP tool preloading
11
+ * - Tool filtering for subagent specialization
12
+ * - Custom task types fall back to a known type's tools based on capability
13
+ */
14
+ // =============================================================================
15
+ // CONSTANTS
16
+ // =============================================================================
17
+ /**
18
+ * Static mapping from subtask types to tool categories.
19
+ * Core heuristic: task type determines which tools are most useful.
20
+ */
21
+ const TASK_TYPE_TOOL_MAP = {
22
+ research: [
23
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep', 'list_files', 'search_files', 'search_code', 'get_file_info'], relevance: 1.0 },
24
+ { name: 'web', tools: ['web_search'], relevance: 0.8 },
25
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 0.6 },
26
+ { name: 'bash_readonly', tools: ['bash'], relevance: 0.5 },
27
+ { name: 'task_coordination', tools: ['task_get', 'task_list'], relevance: 0.3 },
28
+ ],
29
+ analysis: [
30
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep', 'list_files', 'search_files', 'search_code'], relevance: 1.0 },
31
+ { name: 'bash_readonly', tools: ['bash'], relevance: 0.6 },
32
+ { name: 'web', tools: ['web_search'], relevance: 0.5 },
33
+ ],
34
+ design: [
35
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep', 'list_files'], relevance: 0.9 },
36
+ { name: 'file_writing', tools: ['write_file'], relevance: 0.4 },
37
+ ],
38
+ implement: [
39
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep', 'list_files'], relevance: 0.8 },
40
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 1.0 },
41
+ { name: 'execution', tools: ['bash'], relevance: 0.7 },
42
+ { name: 'task_coordination', tools: ['task_create', 'task_update', 'task_get', 'task_list'], relevance: 0.3 },
43
+ ],
44
+ test: [
45
+ { name: 'execution', tools: ['bash'], relevance: 1.0 },
46
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep'], relevance: 0.7 },
47
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 0.5 },
48
+ ],
49
+ refactor: [
50
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep', 'list_files', 'search_code'], relevance: 0.9 },
51
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 1.0 },
52
+ { name: 'execution', tools: ['bash'], relevance: 0.5 },
53
+ ],
54
+ review: [
55
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep', 'list_files', 'search_files'], relevance: 1.0 },
56
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 0.4 },
57
+ { name: 'bash_readonly', tools: ['bash'], relevance: 0.3 },
58
+ ],
59
+ document: [
60
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep'], relevance: 0.8 },
61
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 1.0 },
62
+ ],
63
+ integrate: [
64
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep'], relevance: 0.8 },
65
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 0.9 },
66
+ { name: 'execution', tools: ['bash'], relevance: 0.8 },
67
+ ],
68
+ deploy: [
69
+ { name: 'execution', tools: ['bash'], relevance: 1.0 },
70
+ { name: 'file_reading', tools: ['read_file', 'glob'], relevance: 0.5 },
71
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 0.4 },
72
+ ],
73
+ merge: [
74
+ { name: 'file_reading', tools: ['read_file', 'glob', 'grep'], relevance: 0.9 },
75
+ { name: 'file_writing', tools: ['write_file', 'edit_file'], relevance: 1.0 },
76
+ { name: 'execution', tools: ['bash'], relevance: 0.5 },
77
+ { name: 'task_coordination', tools: ['task_get', 'task_list'], relevance: 0.3 },
78
+ ],
79
+ };
80
+ /**
81
+ * Map a WorkerCapability to the closest built-in task type for tool recommendations.
82
+ * Used as a fallback when a custom task type isn't in TASK_TYPE_TOOL_MAP.
83
+ */
84
+ const CAPABILITY_TO_TOOL_MAP_KEY = {
85
+ code: 'implement',
86
+ research: 'research',
87
+ review: 'review',
88
+ test: 'test',
89
+ document: 'document',
90
+ write: 'merge',
91
+ };
92
+ /**
93
+ * Keyword patterns that suggest specific MCP tools.
94
+ */
95
+ const MCP_KEYWORD_PATTERNS = [
96
+ {
97
+ keywords: ['browser', 'screenshot', 'click', 'navigate', 'page', 'web page', 'UI test'],
98
+ mcpPrefix: 'mcp_playwright',
99
+ description: 'Playwright browser automation',
100
+ },
101
+ {
102
+ keywords: ['database', 'sql', 'query', 'table', 'schema'],
103
+ mcpPrefix: 'mcp_sqlite',
104
+ description: 'SQLite database operations',
105
+ },
106
+ {
107
+ keywords: ['documentation', 'library docs', 'api docs', 'npm package'],
108
+ mcpPrefix: 'mcp_context7',
109
+ description: 'Context7 documentation lookup',
110
+ },
111
+ {
112
+ keywords: ['web search', 'google', 'search online', 'look up'],
113
+ mcpPrefix: 'mcp_serper',
114
+ description: 'Web search via Serper',
115
+ },
116
+ {
117
+ keywords: ['github', 'pull request', 'issue', 'repository'],
118
+ mcpPrefix: 'mcp_github',
119
+ description: 'GitHub API operations',
120
+ },
121
+ ];
122
+ // =============================================================================
123
+ // ENGINE
124
+ // =============================================================================
125
+ export class ToolRecommendationEngine {
126
+ config;
127
+ constructor(config) {
128
+ this.config = {
129
+ maxToolsPerAgent: config?.maxToolsPerAgent ?? 15,
130
+ enablePreloading: config?.enablePreloading ?? true,
131
+ taskToolOverrides: config?.taskToolOverrides ?? {},
132
+ };
133
+ }
134
+ /**
135
+ * Recommend tools for a task based on type and description.
136
+ * Custom task types not in TASK_TYPE_TOOL_MAP fall back to a known type
137
+ * based on the custom type's capability (via TaskTypeConfig).
138
+ */
139
+ recommendTools(taskDescription, taskType, availableToolNames, capability) {
140
+ const recommendations = new Map();
141
+ const availableSet = new Set(availableToolNames);
142
+ // Phase 1: Task-type based recommendations
143
+ // For custom types not in the map, fall back to a known type via capability
144
+ let categories;
145
+ if (this.config.taskToolOverrides[taskType]) {
146
+ categories = [{ name: 'override', tools: this.config.taskToolOverrides[taskType], relevance: 1.0 }];
147
+ }
148
+ else if (TASK_TYPE_TOOL_MAP[taskType]) {
149
+ categories = TASK_TYPE_TOOL_MAP[taskType];
150
+ }
151
+ else {
152
+ // Custom type fallback: use capability to find closest built-in tool map
153
+ const fallbackType = capability
154
+ ? CAPABILITY_TO_TOOL_MAP_KEY[capability] ?? 'implement'
155
+ : 'implement';
156
+ categories = TASK_TYPE_TOOL_MAP[fallbackType] ?? [];
157
+ }
158
+ for (const category of categories) {
159
+ for (const toolName of category.tools) {
160
+ if (availableSet.has(toolName) && !recommendations.has(toolName)) {
161
+ recommendations.set(toolName, {
162
+ toolName,
163
+ relevanceScore: category.relevance,
164
+ reason: `${category.name} tool for ${taskType} tasks`,
165
+ source: 'builtin',
166
+ });
167
+ }
168
+ }
169
+ }
170
+ // Phase 2: Keyword-based MCP tool recommendations
171
+ const taskLower = taskDescription.toLowerCase();
172
+ for (const pattern of MCP_KEYWORD_PATTERNS) {
173
+ const matchCount = pattern.keywords.filter(kw => taskLower.includes(kw)).length;
174
+ if (matchCount > 0) {
175
+ // Find available MCP tools matching the prefix
176
+ for (const toolName of availableToolNames) {
177
+ if (toolName.startsWith(pattern.mcpPrefix) && !recommendations.has(toolName)) {
178
+ const relevance = Math.min(0.5 + matchCount * 0.15, 1.0);
179
+ recommendations.set(toolName, {
180
+ toolName,
181
+ relevanceScore: relevance,
182
+ reason: `${pattern.description} (matched: ${matchCount} keywords)`,
183
+ source: 'mcp',
184
+ });
185
+ }
186
+ }
187
+ }
188
+ }
189
+ // Phase 3: Always include spawn_agent for complex tasks
190
+ if (availableSet.has('spawn_agent') && !recommendations.has('spawn_agent')) {
191
+ recommendations.set('spawn_agent', {
192
+ toolName: 'spawn_agent',
193
+ relevanceScore: 0.3,
194
+ reason: 'Available for delegation',
195
+ source: 'builtin',
196
+ });
197
+ }
198
+ // Sort by relevance and limit
199
+ return [...recommendations.values()]
200
+ .sort((a, b) => b.relevanceScore - a.relevanceScore)
201
+ .slice(0, this.config.maxToolsPerAgent);
202
+ }
203
+ /**
204
+ * Get MCP tool prefixes that should be preloaded for a task type.
205
+ */
206
+ getMCPPreloadPrefixes(taskDescription) {
207
+ if (!this.config.enablePreloading)
208
+ return [];
209
+ const taskLower = taskDescription.toLowerCase();
210
+ const prefixes = [];
211
+ for (const pattern of MCP_KEYWORD_PATTERNS) {
212
+ const matches = pattern.keywords.filter(kw => taskLower.includes(kw));
213
+ if (matches.length > 0) {
214
+ prefixes.push(pattern.mcpPrefix);
215
+ }
216
+ }
217
+ return prefixes;
218
+ }
219
+ /**
220
+ * Filter tools for an agent based on task type.
221
+ * Returns tool names that should be available to the agent.
222
+ */
223
+ getToolFilterForTaskType(taskType, availableToolNames) {
224
+ const recommendations = this.recommendTools('', taskType, availableToolNames);
225
+ return recommendations.map(r => r.toolName);
226
+ }
227
+ /**
228
+ * Infer a SubtaskType from an agent name.
229
+ */
230
+ static inferTaskType(agentName) {
231
+ const nameToType = {
232
+ researcher: 'research',
233
+ coder: 'implement',
234
+ reviewer: 'review',
235
+ architect: 'design',
236
+ debugger: 'analysis',
237
+ tester: 'test',
238
+ documenter: 'document',
239
+ synthesizer: 'merge',
240
+ writer: 'document',
241
+ merger: 'merge',
242
+ };
243
+ const lower = agentName.toLowerCase();
244
+ if (nameToType[lower]) {
245
+ return nameToType[lower];
246
+ }
247
+ // Dynamic swarm names like "swarm-coder-task-1" should resolve by role token.
248
+ const tokens = lower.split(/[^a-z0-9]+/).filter(Boolean);
249
+ for (const token of tokens) {
250
+ if (nameToType[token]) {
251
+ return nameToType[token];
252
+ }
253
+ }
254
+ // For swarm workers, default to implementation rather than research so
255
+ // write-capable profiles are selected unless explicitly constrained.
256
+ if (lower.startsWith('swarm-')) {
257
+ return 'implement';
258
+ }
259
+ return 'research';
260
+ }
261
+ }
262
+ /**
263
+ * Create a tool recommendation engine with optional config.
264
+ */
265
+ export function createToolRecommendationEngine(config) {
266
+ return new ToolRecommendationEngine(config);
267
+ }
268
+ //# sourceMappingURL=tool-recommendation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-recommendation.js","sourceRoot":"","sources":["../../../src/integrations/tool-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B,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBACtB,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAED,uEAAuE;QACvE,qEAAqE;QACrE,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAAiC;IAEjC,OAAO,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Verification Gate - Opt-in Completion Verification
3
+ *
4
+ * Prevents premature completion by checking if required verification
5
+ * steps (like running tests) have been performed before allowing
6
+ * the agent to stop.
7
+ *
8
+ * Configuration:
9
+ * - TUI mode: off by default
10
+ * - Eval mode: auto-configured from FAIL_TO_PASS tests
11
+ * - Swarm mode: set by orchestrator per worker
12
+ */
13
+ export interface VerificationCriteria {
14
+ /** Tests that must be run (e.g., pytest test paths) */
15
+ requiredTests?: string[];
16
+ /** Must have edited at least one file */
17
+ requireFileChanges?: boolean;
18
+ /** Max nudges before giving up and allowing completion */
19
+ maxAttempts?: number;
20
+ }
21
+ export interface VerificationState {
22
+ /** Tests that have been detected as run */
23
+ testsRun: Set<string>;
24
+ /** Whether any test passed */
25
+ anyTestPassed: boolean;
26
+ /** Whether file changes were made */
27
+ hasFileChanges: boolean;
28
+ /** Number of verification nudges already sent */
29
+ nudgeCount: number;
30
+ }
31
+ export interface VerificationCheckResult {
32
+ /** Whether verification criteria are satisfied */
33
+ satisfied: boolean;
34
+ /** If not satisfied, a nudge message to inject */
35
+ nudge?: string;
36
+ /** If max attempts exceeded, allow anyway */
37
+ forceAllow: boolean;
38
+ /** What's still missing */
39
+ missing: string[];
40
+ }
41
+ export declare class VerificationGate {
42
+ private criteria;
43
+ private state;
44
+ constructor(criteria: VerificationCriteria);
45
+ /**
46
+ * Record that a bash command was executed.
47
+ * Detects test execution from command patterns and output.
48
+ */
49
+ recordBashExecution(command: string, output: string, exitCode: number | null): void;
50
+ /**
51
+ * Record that a file was modified.
52
+ */
53
+ recordFileChange(): void;
54
+ /**
55
+ * Check if the agent can complete.
56
+ * Returns satisfied=true if criteria are met, or a nudge message if not.
57
+ */
58
+ check(): VerificationCheckResult;
59
+ /**
60
+ * Get the current verification state.
61
+ */
62
+ getState(): {
63
+ testsRun: number;
64
+ anyTestPassed: boolean;
65
+ hasFileChanges: boolean;
66
+ nudgeCount: number;
67
+ maxAttempts: number;
68
+ };
69
+ /**
70
+ * Reset the gate state (for reuse).
71
+ */
72
+ reset(): void;
73
+ private buildNudge;
74
+ }
75
+ /**
76
+ * Create a verification gate from criteria.
77
+ * Returns null if no criteria provided (gate disabled).
78
+ */
79
+ export declare function createVerificationGate(criteria?: VerificationCriteria | null): VerificationGate | null;
80
+ //# sourceMappingURL=verification-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verification-gate.d.ts","sourceRoot":"","sources":["../../../src/integrations/verification-gate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,MAAM,WAAW,oBAAoB;IACnC,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,yCAAyC;IACzC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,8BAA8B;IAC9B,aAAa,EAAE,OAAO,CAAC;IACvB,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,uBAAuB;IACtC,kDAAkD;IAClD,SAAS,EAAE,OA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