@backendkit-labs/agent-coding 0.28.5 → 0.29.0

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 (288) hide show
  1. package/dist/__tests__/context-hooks.test.d.ts +2 -0
  2. package/dist/__tests__/context-hooks.test.d.ts.map +1 -0
  3. package/dist/__tests__/context-hooks.test.js +21 -0
  4. package/dist/__tests__/context-hooks.test.js.map +1 -0
  5. package/dist/__tests__/sandbox.test.js +1 -1
  6. package/dist/__tests__/sandbox.test.js.map +1 -1
  7. package/dist/context-hooks.d.ts +11 -0
  8. package/dist/context-hooks.d.ts.map +1 -0
  9. package/dist/context-hooks.js +23 -0
  10. package/dist/context-hooks.js.map +1 -0
  11. package/dist/context-services.d.ts +12 -0
  12. package/dist/context-services.d.ts.map +1 -0
  13. package/dist/context-services.js +20 -0
  14. package/dist/context-services.js.map +1 -0
  15. package/dist/index.d.ts +5 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +21 -8
  18. package/dist/index.js.map +1 -1
  19. package/dist/orchestration/capability-matrix.d.ts +1 -1
  20. package/dist/orchestration/capability-matrix.d.ts.map +1 -1
  21. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.d.ts +2 -0
  22. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.d.ts.map +1 -0
  23. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.js +42 -0
  24. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.js.map +1 -0
  25. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.d.ts +2 -0
  26. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.d.ts.map +1 -0
  27. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.js +64 -0
  28. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.js.map +1 -0
  29. package/dist/pipeline/__tests__/engine-brief.test.d.ts +2 -0
  30. package/dist/pipeline/__tests__/engine-brief.test.d.ts.map +1 -0
  31. package/dist/pipeline/__tests__/engine-brief.test.js +159 -0
  32. package/dist/pipeline/__tests__/engine-brief.test.js.map +1 -0
  33. package/dist/pipeline/__tests__/qa-orchestrator.test.d.ts +2 -0
  34. package/dist/pipeline/__tests__/qa-orchestrator.test.d.ts.map +1 -0
  35. package/dist/pipeline/__tests__/qa-orchestrator.test.js +276 -0
  36. package/dist/pipeline/__tests__/qa-orchestrator.test.js.map +1 -0
  37. package/dist/pipeline/coding-pipeline-hooks.d.ts +28 -0
  38. package/dist/pipeline/coding-pipeline-hooks.d.ts.map +1 -0
  39. package/dist/pipeline/coding-pipeline-hooks.js +91 -0
  40. package/dist/pipeline/coding-pipeline-hooks.js.map +1 -0
  41. package/dist/pipeline/index.d.ts +13 -0
  42. package/dist/pipeline/index.d.ts.map +1 -0
  43. package/dist/pipeline/index.js +44 -0
  44. package/dist/pipeline/index.js.map +1 -0
  45. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.d.ts +11 -0
  46. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.d.ts.map +1 -0
  47. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.js +105 -0
  48. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.js.map +1 -0
  49. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.d.ts +2 -0
  50. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.d.ts.map +1 -0
  51. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.js +21 -0
  52. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.js.map +1 -0
  53. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.d.ts +9 -0
  54. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.d.ts.map +1 -0
  55. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.js +101 -0
  56. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.js.map +1 -0
  57. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.d.ts +2 -0
  58. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.d.ts.map +1 -0
  59. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.js +54 -0
  60. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.js.map +1 -0
  61. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.d.ts +2 -0
  62. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.d.ts.map +1 -0
  63. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.js +57 -0
  64. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.js.map +1 -0
  65. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.d.ts +9 -0
  66. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.d.ts.map +1 -0
  67. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.js +43 -0
  68. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.js.map +1 -0
  69. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.d.ts +10 -0
  70. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.d.ts.map +1 -0
  71. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.js +264 -0
  72. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.js.map +1 -0
  73. package/dist/pipeline/orchestration/audit/audit-ci-blocker.d.ts +31 -0
  74. package/dist/pipeline/orchestration/audit/audit-ci-blocker.d.ts.map +1 -0
  75. package/dist/pipeline/orchestration/audit/audit-ci-blocker.js +120 -0
  76. package/dist/pipeline/orchestration/audit/audit-ci-blocker.js.map +1 -0
  77. package/dist/pipeline/orchestration/audit/audit-finding-tracer.d.ts +33 -0
  78. package/dist/pipeline/orchestration/audit/audit-finding-tracer.d.ts.map +1 -0
  79. package/dist/pipeline/orchestration/audit/audit-finding-tracer.js +126 -0
  80. package/dist/pipeline/orchestration/audit/audit-finding-tracer.js.map +1 -0
  81. package/dist/pipeline/orchestration/audit/audit-lessons-learned.d.ts +27 -0
  82. package/dist/pipeline/orchestration/audit/audit-lessons-learned.d.ts.map +1 -0
  83. package/dist/pipeline/orchestration/audit/audit-lessons-learned.js +155 -0
  84. package/dist/pipeline/orchestration/audit/audit-lessons-learned.js.map +1 -0
  85. package/dist/pipeline/orchestration/audit/audit-pending-issues.d.ts +21 -0
  86. package/dist/pipeline/orchestration/audit/audit-pending-issues.d.ts.map +1 -0
  87. package/dist/pipeline/orchestration/audit/audit-pending-issues.js +110 -0
  88. package/dist/pipeline/orchestration/audit/audit-pending-issues.js.map +1 -0
  89. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.d.ts +39 -0
  90. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.d.ts.map +1 -0
  91. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.js +65 -0
  92. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.js.map +1 -0
  93. package/dist/pipeline/orchestration/audit/audit-report-renderer.d.ts +30 -0
  94. package/dist/pipeline/orchestration/audit/audit-report-renderer.d.ts.map +1 -0
  95. package/dist/pipeline/orchestration/audit/audit-report-renderer.js +249 -0
  96. package/dist/pipeline/orchestration/audit/audit-report-renderer.js.map +1 -0
  97. package/dist/pipeline/orchestration/audit/audit-report-version-manager.d.ts +52 -0
  98. package/dist/pipeline/orchestration/audit/audit-report-version-manager.d.ts.map +1 -0
  99. package/dist/pipeline/orchestration/audit/audit-report-version-manager.js +144 -0
  100. package/dist/pipeline/orchestration/audit/audit-report-version-manager.js.map +1 -0
  101. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.d.ts +37 -0
  102. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.d.ts.map +1 -0
  103. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.js +129 -0
  104. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.js.map +1 -0
  105. package/dist/pipeline/orchestration/audit/index.d.ts +17 -0
  106. package/dist/pipeline/orchestration/audit/index.d.ts.map +1 -0
  107. package/dist/pipeline/orchestration/audit/index.js +26 -0
  108. package/dist/pipeline/orchestration/audit/index.js.map +1 -0
  109. package/dist/pipeline/orchestration/audit/types.d.ts +79 -0
  110. package/dist/pipeline/orchestration/audit/types.d.ts.map +1 -0
  111. package/dist/pipeline/orchestration/audit/types.js +10 -0
  112. package/dist/pipeline/orchestration/audit/types.js.map +1 -0
  113. package/dist/pipeline/orchestration/audit-reporter.d.ts +133 -0
  114. package/dist/pipeline/orchestration/audit-reporter.d.ts.map +1 -0
  115. package/dist/pipeline/orchestration/audit-reporter.js +322 -0
  116. package/dist/pipeline/orchestration/audit-reporter.js.map +1 -0
  117. package/dist/pipeline/orchestration/config-loader.d.ts +51 -0
  118. package/dist/pipeline/orchestration/config-loader.d.ts.map +1 -0
  119. package/dist/pipeline/orchestration/config-loader.js +215 -0
  120. package/dist/pipeline/orchestration/config-loader.js.map +1 -0
  121. package/dist/pipeline/orchestration/domain-detector.d.ts +36 -0
  122. package/dist/pipeline/orchestration/domain-detector.d.ts.map +1 -0
  123. package/dist/pipeline/orchestration/domain-detector.js +157 -0
  124. package/dist/pipeline/orchestration/domain-detector.js.map +1 -0
  125. package/dist/pipeline/orchestration/fsm.d.ts +92 -0
  126. package/dist/pipeline/orchestration/fsm.d.ts.map +1 -0
  127. package/dist/pipeline/orchestration/fsm.js +243 -0
  128. package/dist/pipeline/orchestration/fsm.js.map +1 -0
  129. package/dist/pipeline/orchestration/gate-resolver.d.ts +52 -0
  130. package/dist/pipeline/orchestration/gate-resolver.d.ts.map +1 -0
  131. package/dist/pipeline/orchestration/gate-resolver.js +120 -0
  132. package/dist/pipeline/orchestration/gate-resolver.js.map +1 -0
  133. package/dist/pipeline/orchestration/index.d.ts +16 -0
  134. package/dist/pipeline/orchestration/index.d.ts.map +1 -0
  135. package/dist/pipeline/orchestration/index.js +32 -0
  136. package/dist/pipeline/orchestration/index.js.map +1 -0
  137. package/dist/pipeline/orchestration/intent-detector.d.ts +37 -0
  138. package/dist/pipeline/orchestration/intent-detector.d.ts.map +1 -0
  139. package/dist/pipeline/orchestration/intent-detector.js +248 -0
  140. package/dist/pipeline/orchestration/intent-detector.js.map +1 -0
  141. package/dist/pipeline/orchestration/keyword-match.d.ts +17 -0
  142. package/dist/pipeline/orchestration/keyword-match.d.ts.map +1 -0
  143. package/dist/pipeline/orchestration/keyword-match.js +26 -0
  144. package/dist/pipeline/orchestration/keyword-match.js.map +1 -0
  145. package/dist/pipeline/orchestration/orchestrator.d.ts +158 -0
  146. package/dist/pipeline/orchestration/orchestrator.d.ts.map +1 -0
  147. package/dist/pipeline/orchestration/orchestrator.js +414 -0
  148. package/dist/pipeline/orchestration/orchestrator.js.map +1 -0
  149. package/dist/pipeline/orchestration/policy-engine.d.ts +54 -0
  150. package/dist/pipeline/orchestration/policy-engine.d.ts.map +1 -0
  151. package/dist/pipeline/orchestration/policy-engine.js +278 -0
  152. package/dist/pipeline/orchestration/policy-engine.js.map +1 -0
  153. package/dist/pipeline/orchestration/risk-scorer.d.ts +38 -0
  154. package/dist/pipeline/orchestration/risk-scorer.d.ts.map +1 -0
  155. package/dist/pipeline/orchestration/risk-scorer.js +145 -0
  156. package/dist/pipeline/orchestration/risk-scorer.js.map +1 -0
  157. package/dist/pipeline/orchestration/task-context.d.ts +205 -0
  158. package/dist/pipeline/orchestration/task-context.d.ts.map +1 -0
  159. package/dist/pipeline/orchestration/task-context.js +162 -0
  160. package/dist/pipeline/orchestration/task-context.js.map +1 -0
  161. package/dist/pipeline/orchestration/types.d.ts +111 -0
  162. package/dist/pipeline/orchestration/types.d.ts.map +1 -0
  163. package/dist/pipeline/orchestration/types.js +37 -0
  164. package/dist/pipeline/orchestration/types.js.map +1 -0
  165. package/dist/pipeline/qa/__tests__/QAService.test.d.ts +2 -0
  166. package/dist/pipeline/qa/__tests__/QAService.test.d.ts.map +1 -0
  167. package/dist/pipeline/qa/__tests__/QAService.test.js +170 -0
  168. package/dist/pipeline/qa/__tests__/QAService.test.js.map +1 -0
  169. package/dist/pipeline/qa/__tests__/QAService.verdict.test.d.ts +2 -0
  170. package/dist/pipeline/qa/__tests__/QAService.verdict.test.d.ts.map +1 -0
  171. package/dist/pipeline/qa/__tests__/QAService.verdict.test.js +39 -0
  172. package/dist/pipeline/qa/__tests__/QAService.verdict.test.js.map +1 -0
  173. package/dist/pipeline/qa/index.d.ts +3 -0
  174. package/dist/pipeline/qa/index.d.ts.map +1 -0
  175. package/dist/pipeline/qa/index.js +6 -0
  176. package/dist/pipeline/qa/index.js.map +1 -0
  177. package/dist/pipeline/qa/qa-service.d.ts +33 -0
  178. package/dist/pipeline/qa/qa-service.d.ts.map +1 -0
  179. package/dist/pipeline/qa/qa-service.js +239 -0
  180. package/dist/pipeline/qa/qa-service.js.map +1 -0
  181. package/dist/pipeline/qa-orchestrator.d.ts +60 -0
  182. package/dist/pipeline/qa-orchestrator.d.ts.map +1 -0
  183. package/dist/pipeline/qa-orchestrator.js +177 -0
  184. package/dist/pipeline/qa-orchestrator.js.map +1 -0
  185. package/dist/pipeline/reflection/domains/agent-domain.d.ts +40 -0
  186. package/dist/pipeline/reflection/domains/agent-domain.d.ts.map +1 -0
  187. package/dist/pipeline/reflection/domains/agent-domain.js +161 -0
  188. package/dist/pipeline/reflection/domains/agent-domain.js.map +1 -0
  189. package/dist/pipeline/reflection/domains/audit-domain.d.ts +46 -0
  190. package/dist/pipeline/reflection/domains/audit-domain.d.ts.map +1 -0
  191. package/dist/pipeline/reflection/domains/audit-domain.js +241 -0
  192. package/dist/pipeline/reflection/domains/audit-domain.js.map +1 -0
  193. package/dist/pipeline/reflection/domains/bootstrap-domain.d.ts +40 -0
  194. package/dist/pipeline/reflection/domains/bootstrap-domain.d.ts.map +1 -0
  195. package/dist/pipeline/reflection/domains/bootstrap-domain.js +156 -0
  196. package/dist/pipeline/reflection/domains/bootstrap-domain.js.map +1 -0
  197. package/dist/pipeline/reflection/domains/commit-domain.d.ts +40 -0
  198. package/dist/pipeline/reflection/domains/commit-domain.d.ts.map +1 -0
  199. package/dist/pipeline/reflection/domains/commit-domain.js +174 -0
  200. package/dist/pipeline/reflection/domains/commit-domain.js.map +1 -0
  201. package/dist/pipeline/reflection/domains/test-domain.d.ts +40 -0
  202. package/dist/pipeline/reflection/domains/test-domain.d.ts.map +1 -0
  203. package/dist/pipeline/reflection/domains/test-domain.js +194 -0
  204. package/dist/pipeline/reflection/domains/test-domain.js.map +1 -0
  205. package/dist/pipeline/reflection/historical-loader.d.ts +105 -0
  206. package/dist/pipeline/reflection/historical-loader.d.ts.map +1 -0
  207. package/dist/pipeline/reflection/historical-loader.js +462 -0
  208. package/dist/pipeline/reflection/historical-loader.js.map +1 -0
  209. package/dist/pipeline/reflection/hooks/agent-hook.d.ts +72 -0
  210. package/dist/pipeline/reflection/hooks/agent-hook.d.ts.map +1 -0
  211. package/dist/pipeline/reflection/hooks/agent-hook.js +98 -0
  212. package/dist/pipeline/reflection/hooks/agent-hook.js.map +1 -0
  213. package/dist/pipeline/reflection/hooks/audit-hook.d.ts +72 -0
  214. package/dist/pipeline/reflection/hooks/audit-hook.d.ts.map +1 -0
  215. package/dist/pipeline/reflection/hooks/audit-hook.js +112 -0
  216. package/dist/pipeline/reflection/hooks/audit-hook.js.map +1 -0
  217. package/dist/pipeline/reflection/hooks/bootstrap-hook.d.ts +71 -0
  218. package/dist/pipeline/reflection/hooks/bootstrap-hook.d.ts.map +1 -0
  219. package/dist/pipeline/reflection/hooks/bootstrap-hook.js +97 -0
  220. package/dist/pipeline/reflection/hooks/bootstrap-hook.js.map +1 -0
  221. package/dist/pipeline/reflection/hooks/commit-hook.d.ts +63 -0
  222. package/dist/pipeline/reflection/hooks/commit-hook.d.ts.map +1 -0
  223. package/dist/pipeline/reflection/hooks/commit-hook.js +90 -0
  224. package/dist/pipeline/reflection/hooks/commit-hook.js.map +1 -0
  225. package/dist/pipeline/reflection/hooks/test-hook.d.ts +65 -0
  226. package/dist/pipeline/reflection/hooks/test-hook.d.ts.map +1 -0
  227. package/dist/pipeline/reflection/hooks/test-hook.js +99 -0
  228. package/dist/pipeline/reflection/hooks/test-hook.js.map +1 -0
  229. package/dist/pipeline/reflection/lessons-memo-generator.d.ts +60 -0
  230. package/dist/pipeline/reflection/lessons-memo-generator.d.ts.map +1 -0
  231. package/dist/pipeline/reflection/lessons-memo-generator.js +286 -0
  232. package/dist/pipeline/reflection/lessons-memo-generator.js.map +1 -0
  233. package/dist/store/ProjectStore.d.ts +1 -1
  234. package/dist/store/ProjectStore.d.ts.map +1 -1
  235. package/dist/store/types.d.ts +28 -0
  236. package/dist/store/types.d.ts.map +1 -0
  237. package/dist/store/types.js +3 -0
  238. package/dist/store/types.js.map +1 -0
  239. package/dist/tools/__tests__/command-parser.test.js +1 -1
  240. package/dist/tools/__tests__/command-parser.test.js.map +1 -1
  241. package/dist/tools/__tests__/declared-facts.test.d.ts +2 -0
  242. package/dist/tools/__tests__/declared-facts.test.d.ts.map +1 -0
  243. package/dist/tools/__tests__/declared-facts.test.js +21 -0
  244. package/dist/tools/__tests__/declared-facts.test.js.map +1 -0
  245. package/dist/tools/__tests__/package-install.test.d.ts +2 -0
  246. package/dist/tools/__tests__/package-install.test.d.ts.map +1 -0
  247. package/dist/tools/__tests__/package-install.test.js +56 -0
  248. package/dist/tools/__tests__/package-install.test.js.map +1 -0
  249. package/dist/tools/__tests__/save-tools.secrets.test.js +1 -1
  250. package/dist/tools/__tests__/save-tools.secrets.test.js.map +1 -1
  251. package/dist/tools/edit-file.d.ts.map +1 -1
  252. package/dist/tools/edit-file.js +1 -0
  253. package/dist/tools/edit-file.js.map +1 -1
  254. package/dist/tools/list-directory.d.ts.map +1 -1
  255. package/dist/tools/list-directory.js +1 -0
  256. package/dist/tools/list-directory.js.map +1 -1
  257. package/dist/tools/package-install.d.ts +11 -0
  258. package/dist/tools/package-install.d.ts.map +1 -0
  259. package/dist/tools/package-install.js +112 -0
  260. package/dist/tools/package-install.js.map +1 -0
  261. package/dist/tools/read-file.d.ts.map +1 -1
  262. package/dist/tools/read-file.js +1 -0
  263. package/dist/tools/read-file.js.map +1 -1
  264. package/dist/tools/run-command.d.ts.map +1 -1
  265. package/dist/tools/run-command.js +5 -1
  266. package/dist/tools/run-command.js.map +1 -1
  267. package/dist/tools/save-audit.d.ts.map +1 -1
  268. package/dist/tools/save-audit.js +7 -6
  269. package/dist/tools/save-audit.js.map +1 -1
  270. package/dist/tools/save-context.d.ts.map +1 -1
  271. package/dist/tools/save-context.js +3 -2
  272. package/dist/tools/save-context.js.map +1 -1
  273. package/dist/tools/save-learning.d.ts.map +1 -1
  274. package/dist/tools/save-learning.js +4 -3
  275. package/dist/tools/save-learning.js.map +1 -1
  276. package/dist/tools/save-user-preference.d.ts.map +1 -1
  277. package/dist/tools/save-user-preference.js +3 -2
  278. package/dist/tools/save-user-preference.js.map +1 -1
  279. package/dist/tools/search-files.d.ts.map +1 -1
  280. package/dist/tools/search-files.js +1 -0
  281. package/dist/tools/search-files.js.map +1 -1
  282. package/dist/tools/update-session.d.ts.map +1 -1
  283. package/dist/tools/update-session.js +3 -2
  284. package/dist/tools/update-session.js.map +1 -1
  285. package/dist/tools/write-file.d.ts.map +1 -1
  286. package/dist/tools/write-file.js +1 -0
  287. package/dist/tools/write-file.js.map +1 -1
  288. package/package.json +63 -44
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ /**
3
+ * @description FSM — Finite State Machine para el ciclo de vida de tareas.
4
+ *
5
+ * Define los estados válidos y las transiciones permitidas para un TaskContext.
6
+ * Cada tarea comienza en 'new' y progresa a través de gates (architecture,
7
+ * security, QA) hasta llegar a 'commit_allowed' o 'rejected'.
8
+ *
9
+ * El FSM se integra con el Orchestrator para validar que las transiciones
10
+ * sean legales según las políticas aplicadas.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const fsm = new TaskFSM();
15
+ * const task = createTaskContext('Implementar auth');
16
+ *
17
+ * // Transición válida
18
+ * const result = fsm.transition(task, 'classified');
19
+ * // result.allowed === true
20
+ * // result.task.status === 'classified'
21
+ *
22
+ * // Transición inválida
23
+ * const result2 = fsm.transition(task, 'commit_allowed');
24
+ * // result.allowed === false
25
+ * // result.error === 'Transición no permitida: new → commit_allowed'
26
+ * ```
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.TaskFSM = exports.DEFAULT_MAX_REWORK = void 0;
30
+ const task_context_1 = require("./task-context");
31
+ // ── Definición de transiciones ───────────────────────────────────────────────
32
+ /**
33
+ * Mapa de transiciones permitidas.
34
+ * Cada estado tiene un conjunto de estados destino válidos.
35
+ */
36
+ const TRANSITIONS = {
37
+ 'new': ['classified', 'commit_planning'], // ← commit_planning para @commit sin orquestación
38
+ 'classified': ['design_review', 'implementation', 'security_review', 'qa_review', 'rejected'],
39
+ 'design_review': ['implementation', 'security_review', 'qa_review', 'rework_required', 'rejected'],
40
+ 'implementation': ['security_review', 'qa_review', 'design_review', 'rework_required', 'rejected'],
41
+ 'security_review': ['qa_review', 'design_review', 'implementation', 'rework_required', 'rejected'],
42
+ 'qa_review': ['approved', 'rework_required', 'rejected'],
43
+ 'rework_required': ['design_review', 'implementation', 'security_review', 'qa_review', 'rejected'],
44
+ // Sin 'implementation': un cambio aprobado que se vuelve a editar debe pasar por rework_required,
45
+ // que repite los gates. Volver directo dejaba llegar a commit_allowed sin nueva revisión.
46
+ 'approved': ['commit_allowed', 'commit_planning', 'rejected'],
47
+ 'commit_allowed': ['commit_planning'], // Puede re-planificar desde commit_allowed
48
+ 'rejected': [], // Estado terminal
49
+ // Nuevos estados del commit workflow
50
+ 'commit_planning': ['commit_reviewing', 'commit_failed', 'commit_skipped'],
51
+ 'commit_reviewing': ['commit_validated', 'commit_rejected', 'commit_failed'],
52
+ 'commit_validated': ['commit_allowed'], // Plan validado, listo para ejecutar commit
53
+ 'commit_rejected': ['commit_planning', 'rejected'], // Rechazado, puede replanificar
54
+ 'commit_failed': ['commit_planning', 'rejected'], // Falló, puede reintentar
55
+ 'commit_skipped': ['commit_allowed'], // Saltado, vuelve a commit_allowed
56
+ };
57
+ const GUARDS = [
58
+ // No se puede saltar a commit_allowed sin pasar por approved o commit_validated
59
+ (task, to) => {
60
+ if (to === 'commit_allowed' && task.status !== 'approved' && task.status !== 'commit_validated' && task.status !== 'commit_skipped') {
61
+ return 'Debe estar en estado "approved", "commit_validated" o "commit_skipped" antes de permitir commit';
62
+ }
63
+ return null;
64
+ },
65
+ // Si requiere architecture review, debe pasar por design_review
66
+ (task, to) => {
67
+ if (task.requiresArchitectureReview && to === 'implementation' && task.status !== 'design_review' && task.status !== 'classified') {
68
+ return 'Requiere revisión de arquitectura (design_review) antes de implementar';
69
+ }
70
+ return null;
71
+ },
72
+ // Si requiere security review, debe pasar por security_review
73
+ (task, to) => {
74
+ if (task.requiresSecurityReview && to === 'qa_review' && task.status !== 'security_review') {
75
+ return 'Requiere revisión de seguridad (security_review) antes de QA';
76
+ }
77
+ return null;
78
+ },
79
+ // Si requiere QA approval, debe pasar por qa_review
80
+ (task, to) => {
81
+ if (task.requiresQaApproval && to === 'approved' && task.status !== 'qa_review') {
82
+ return 'Requiere aprobación de QA (qa_review) antes de approved';
83
+ }
84
+ return null;
85
+ },
86
+ ];
87
+ // ── TaskFSM ──────────────────────────────────────────────────────────────────
88
+ /** Vueltas de rework_required permitidas por tarea antes de exigir rechazo o decisión humana. */
89
+ exports.DEFAULT_MAX_REWORK = 5;
90
+ class TaskFSM {
91
+ opts;
92
+ constructor(opts = {}) {
93
+ this.opts = opts;
94
+ }
95
+ /**
96
+ * @description Intenta transicionar una tarea a un nuevo estado.
97
+ * Valida que la transición esté en el mapa de transiciones permitidas
98
+ * y que pase todos los guards.
99
+ *
100
+ * @param task - Tarea actual
101
+ * @param to - Estado destino
102
+ * @returns Resultado con la tarea actualizada o error
103
+ */
104
+ transition(task, to) {
105
+ const available = this.getAvailableTransitions(task.status);
106
+ // Verificar que la transición esté permitida
107
+ if (!available.includes(to)) {
108
+ return {
109
+ allowed: false,
110
+ error: `Transición no permitida: ${task.status} → ${to}. Estados válidos: ${available.join(', ')}`,
111
+ availableTransitions: available,
112
+ };
113
+ }
114
+ // Tope del ciclo de rework: sin él, QA y revisión pueden alternar indefinidamente
115
+ const maxRework = this.opts.maxRework ?? exports.DEFAULT_MAX_REWORK;
116
+ const reworkCount = task.reworkCount ?? 0;
117
+ if (to === 'rework_required' && reworkCount >= maxRework) {
118
+ return {
119
+ allowed: false,
120
+ error: `Límite de rework alcanzado (${maxRework}): la tarea debe rechazarse o pasar a decisión humana`,
121
+ availableTransitions: available,
122
+ };
123
+ }
124
+ // Ejecutar guards
125
+ for (const guard of GUARDS) {
126
+ const error = guard(task, to);
127
+ if (error) {
128
+ return {
129
+ allowed: false,
130
+ error,
131
+ availableTransitions: available,
132
+ };
133
+ }
134
+ }
135
+ // Transición válida
136
+ return {
137
+ allowed: true,
138
+ task: to === 'rework_required'
139
+ ? { ...(0, task_context_1.transitionTask)(task, to), reworkCount: reworkCount + 1 }
140
+ : (0, task_context_1.transitionTask)(task, to),
141
+ availableTransitions: this.getAvailableTransitions(to),
142
+ };
143
+ }
144
+ /**
145
+ * @description Obtiene los estados destino válidos desde un estado dado.
146
+ */
147
+ getAvailableTransitions(from) {
148
+ return TRANSITIONS[from] ?? [];
149
+ }
150
+ /**
151
+ * @description Determina si un estado es terminal (no tiene salidas).
152
+ */
153
+ isTerminal(status) {
154
+ return TRANSITIONS[status]?.length === 0;
155
+ }
156
+ /**
157
+ * @description Calcula la ruta crítica desde el estado actual hasta commit_allowed.
158
+ * Útil para mostrar al usuario qué gates faltan.
159
+ */
160
+ getCriticalPath(task) {
161
+ const path = [task.status];
162
+ const current = task.status;
163
+ if (current === 'commit_allowed' || current === 'rejected')
164
+ return path;
165
+ // Si está en new, debe clasificarse
166
+ if (current === 'new') {
167
+ path.push('classified');
168
+ }
169
+ // Si requiere architecture review y no ha pasado
170
+ if (task.requiresArchitectureReview && !this.hasPassedGate(task, 'design_review')) {
171
+ if (!path.includes('design_review'))
172
+ path.push('design_review');
173
+ }
174
+ // Si no ha llegado a implementation
175
+ if (current !== 'implementation' && current !== 'design_review') {
176
+ if (!path.includes('implementation'))
177
+ path.push('implementation');
178
+ }
179
+ // Si requiere security review
180
+ if (task.requiresSecurityReview && !this.hasPassedGate(task, 'security_review')) {
181
+ if (!path.includes('security_review'))
182
+ path.push('security_review');
183
+ }
184
+ // Si requiere QA approval
185
+ if (task.requiresQaApproval && !this.hasPassedGate(task, 'qa_review')) {
186
+ if (!path.includes('qa_review'))
187
+ path.push('qa_review');
188
+ }
189
+ // Approved → commit_allowed
190
+ if (!path.includes('approved'))
191
+ path.push('approved');
192
+ if (!path.includes('commit_allowed'))
193
+ path.push('commit_allowed');
194
+ return path;
195
+ }
196
+ /**
197
+ * Verifica si la tarea definitivamente ha pasado por un gate específico.
198
+ *
199
+ * La verificacion es deliberadamente conservadora: prefiere falsos negativos
200
+ * (mostrar un gate como pendiente cuando ya paso) antes que falsos positivos
201
+ * (ocultarlo cuando no paso). getCriticalPath es una funcion de display, no
202
+ * de enforcement — el FSM ya se encarga de bloquear transiciones invalidas.
203
+ *
204
+ * Razon del cambio: el enfoque anterior con indice lineal daba falsos positivos.
205
+ * Ejemplo: classified → implementation con requiresArchitectureReview=true
206
+ * reportaba design_review como "ya pasado" porque implementation(idx=3) > design_review(idx=2),
207
+ * cuando en realidad el FSM permite saltarse design_review desde classified.
208
+ *
209
+ * Logica basada en guardas reales del FSM:
210
+ * - "approved" y estados posteriores garantizan que los gates requeridos se
211
+ * cumplieron (las guardas del FSM bloquean esos saltos).
212
+ * - security_review: si requiresSecurityReview=true y el task esta en qa_review
213
+ * o posterior, el FSM garantiza que security_review fue visitado.
214
+ * - design_review: no hay guarda que lo garantice en todos los caminos
215
+ * (classified → implementation esta permitido aunque requiresArchitectureReview=true),
216
+ * asi que solo retorna true si el task esta exactamente en ese estado.
217
+ */
218
+ hasPassedGate(task, gate) {
219
+ const s = task.status;
220
+ if (s === gate)
221
+ return true;
222
+ // Desde approved en adelante el FSM garantiza que todos los gates requeridos
223
+ // fueron satisfechos (las guardas son transitivas por la cadena de transiciones).
224
+ const postApproval = new Set([
225
+ 'approved', 'commit_allowed', 'commit_planning', 'commit_reviewing',
226
+ 'commit_validated', 'commit_skipped',
227
+ ]);
228
+ if (postApproval.has(s))
229
+ return true;
230
+ // security_review: la guarda del FSM bloquea qa_review si requiresSecurityReview
231
+ // y el task no esta en security_review — por lo tanto qa_review garantiza que
232
+ // security_review fue visitado cuando el flag esta activo.
233
+ if (gate === 'security_review' && task.requiresSecurityReview) {
234
+ return s === 'qa_review' || postApproval.has(s);
235
+ }
236
+ // design_review: no hay guarda que fuerce su visita antes de implementation
237
+ // desde classified, asi que no podemos asumir que fue visitado.
238
+ // Solo retorna true si el task esta en ese estado (cubierto arriba).
239
+ return false;
240
+ }
241
+ }
242
+ exports.TaskFSM = TaskFSM;
243
+ //# sourceMappingURL=fsm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fsm.js","sourceRoot":"","sources":["../../../src/pipeline/orchestration/fsm.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAEH,iDAAyE;AAEzE,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,WAAW,GAAqC;IACpD,KAAK,EAAE,CAAC,YAAY,EAAE,iBAAiB,CAAC,EAAE,kDAAkD;IAC5F,YAAY,EAAE,CAAC,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,UAAU,CAAC;IAC7F,eAAe,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,CAAC;IAClG,gBAAgB,EAAE,CAAC,iBAAiB,EAAE,WAAW,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,CAAC;IAClG,iBAAiB,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,UAAU,CAAC;IAClG,WAAW,EAAE,CAAC,UAAU,EAAE,iBAAiB,EAAE,UAAU,CAAC;IAC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AI,CAAC,QAAQ,CAAC,gBAAgB,CAAC;YAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAElE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACK,aAAa,CAAC,IAAiB,EAAE,IAAgB;QACvD,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAEtB,IAAI,CAAC,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QAE5B,6EAA6E;QAC7E,kFAAkF;QAClF,MAAM,YAAY,GAA4B,IAAI,GAAG,CAAC;YACpD,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,kBAAkB;YACnE,kBAAkB,EAAE,gBAAgB;SACrC,CAAC,CAAC;QACH,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QAErC,iFAAiF;QACjF,8EAA8E;QAC9E,2DAA2D;QAC3D,IAAI,IAAI,KAAK,iBAAiB,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC9D,OAAO,CAAC,KAAK,WAAW,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;QAED,4EAA4E;QAC5E,gEAAgE;QAChE,qEAAqE;QAErE,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAjKD,0BAiKC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @description GateResolver — Única fuente de verdad para la resolución de gates.
3
+ *
4
+ * Consolida la lógica que estaba dispersa en:
5
+ * - buildPipeline() de orchestrator/index.ts
6
+ * - isCommitAllowed() de orchestrator/index.ts
7
+ * - policy-engine.ts (requiredGates)
8
+ * - risk-scorer.ts (riskLevel → gates)
9
+ *
10
+ * Usar esta función como punto de entrada canónico para determinar:
11
+ * qué agentes se activan en cada fase, y si el commit está permitido.
12
+ */
13
+ import { TaskContext } from './task-context';
14
+ import { PolicyEngineResult } from './policy-engine';
15
+ import { AgentPipelinePhase } from './types';
16
+ import { OrchestratorConfig } from './types';
17
+ export interface GateResolution {
18
+ /** Pipeline de fases de agentes a ejecutar */
19
+ pipeline: AgentPipelinePhase[];
20
+ /** Si el commit está permitido en el estado actual */
21
+ commitAllowed: boolean;
22
+ /** Reviews obligatorias detectadas (para trazabilidad) — incluye nombres de customGates */
23
+ requiredReviews: string[];
24
+ }
25
+ /** Agent IDs para las fases review/verify. Default: roster de agent-coding. */
26
+ export interface GateReviewAgentIds {
27
+ security?: string;
28
+ architecture?: string;
29
+ qa?: string;
30
+ }
31
+ /**
32
+ * @description Determina el pipeline de gates y si el commit está permitido.
33
+ *
34
+ * @param task - Contexto de la tarea orquestada
35
+ * @param policyResult - Resultado del PolicyEngine con gates requeridos
36
+ * @param config - Configuración del orquestador
37
+ * @param selectedAgents - Agentes ya seleccionados por el router
38
+ * @param reviewAgents - Agent IDs para security/architecture/qa. Default: agent-coding
39
+ * ('security'/'architecture'/'qa-engineer'). Verticales sin esos agentes pasan los suyos.
40
+ * @param customGateAgents - Mapa nombre-de-gate → agentId para los customGates de task.
41
+ * Si un gate no tiene entrada acá, se usa su propio nombre como agentId.
42
+ */
43
+ export declare function resolveGates(task: TaskContext, policyResult: PolicyEngineResult, config: OrchestratorConfig, selectedAgents: Array<{
44
+ agentId: string;
45
+ score: number;
46
+ reason: string;
47
+ }>, reviewAgents?: GateReviewAgentIds, customGateAgents?: Record<string, string>): GateResolution;
48
+ /**
49
+ * @description Determina si el commit está permitido según el estado del task y las políticas.
50
+ */
51
+ export declare function resolveCommitAllowed(task: TaskContext, policyResult: PolicyEngineResult, config: OrchestratorConfig): boolean;
52
+ //# sourceMappingURL=gate-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate-resolver.d.ts","sourceRoot":"","sources":["../../../src/pipeline/orchestration/gate-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,8CAA8C;IAC9C,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,sDAAsD;IACtD,aAAa,EAAE,OAAO,CAAC;IACvB,2FAA2F;IAC3F,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,kBAAkB,EAC1B,cAAc,EAAE,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,EACzE,YAAY,CAAC,EAAE,kBAAkB,EACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACxC,cAAc,CA2EhB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,WAAW,EACjB,YAAY,EAAE,kBAAkB,EAChC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAiBT"}
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ /**
3
+ * @description GateResolver — Única fuente de verdad para la resolución de gates.
4
+ *
5
+ * Consolida la lógica que estaba dispersa en:
6
+ * - buildPipeline() de orchestrator/index.ts
7
+ * - isCommitAllowed() de orchestrator/index.ts
8
+ * - policy-engine.ts (requiredGates)
9
+ * - risk-scorer.ts (riskLevel → gates)
10
+ *
11
+ * Usar esta función como punto de entrada canónico para determinar:
12
+ * qué agentes se activan en cada fase, y si el commit está permitido.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.resolveGates = resolveGates;
16
+ exports.resolveCommitAllowed = resolveCommitAllowed;
17
+ /**
18
+ * @description Determina el pipeline de gates y si el commit está permitido.
19
+ *
20
+ * @param task - Contexto de la tarea orquestada
21
+ * @param policyResult - Resultado del PolicyEngine con gates requeridos
22
+ * @param config - Configuración del orquestador
23
+ * @param selectedAgents - Agentes ya seleccionados por el router
24
+ * @param reviewAgents - Agent IDs para security/architecture/qa. Default: agent-coding
25
+ * ('security'/'architecture'/'qa-engineer'). Verticales sin esos agentes pasan los suyos.
26
+ * @param customGateAgents - Mapa nombre-de-gate → agentId para los customGates de task.
27
+ * Si un gate no tiene entrada acá, se usa su propio nombre como agentId.
28
+ */
29
+ function resolveGates(task, policyResult, config, selectedAgents, reviewAgents, customGateAgents) {
30
+ const pipeline = [];
31
+ const requiredReviews = [];
32
+ const securityAgentId = reviewAgents?.security ?? 'security';
33
+ const architectureAgentId = reviewAgents?.architecture ?? 'architecture';
34
+ const qaAgentId = reviewAgents?.qa ?? 'qa-engineer';
35
+ const isHighRisk = task.riskLevel === 'high' || task.riskLevel === 'critical';
36
+ const hasSecurityDomain = task.domains.includes('security');
37
+ const hasArchitectureDomain = task.domains.includes('architecture') || task.domains.includes('resilience');
38
+ // Review de seguridad
39
+ if (task.requiresSecurityReview || (isHighRisk && hasSecurityDomain)) {
40
+ pipeline.push({
41
+ phase: 'review',
42
+ agentId: securityAgentId,
43
+ purpose: 'Review security implications',
44
+ optional: false,
45
+ });
46
+ requiredReviews.push('security');
47
+ }
48
+ // Review de arquitectura
49
+ if (task.requiresArchitectureReview || (isHighRisk && hasArchitectureDomain)) {
50
+ pipeline.push({
51
+ phase: 'review',
52
+ agentId: architectureAgentId,
53
+ purpose: 'Review architecture for high-risk change',
54
+ optional: false,
55
+ });
56
+ requiredReviews.push('architecture');
57
+ }
58
+ // Reviews de gates con nombre abierto (ej. 'compliance' para un vertical de finance).
59
+ // No tienen orden ni estado propio en la FSM — se satisfacen marcando su nombre en
60
+ // task.completedCustomGates, típicamente desde fuera del flujo LLM (aprobación humana,
61
+ // webhook de negocio), igual que el gate_criteria de orchestrator-agent.
62
+ for (const [gateName, required] of Object.entries(task.customGates)) {
63
+ if (!required || task.completedCustomGates.includes(gateName))
64
+ continue;
65
+ pipeline.push({
66
+ phase: 'review',
67
+ agentId: customGateAgents?.[gateName] ?? gateName,
68
+ purpose: `Custom review: ${gateName}`,
69
+ optional: false,
70
+ });
71
+ requiredReviews.push(gateName);
72
+ }
73
+ // Fase de implementación: mejor agente seleccionado
74
+ const topAgent = selectedAgents[0];
75
+ if (topAgent && topAgent.agentId !== 'general') {
76
+ pipeline.push({
77
+ phase: 'implement',
78
+ agentId: topAgent.agentId,
79
+ purpose: topAgent.reason,
80
+ optional: false,
81
+ });
82
+ }
83
+ // Fase de verificación QA
84
+ const hasImplementPhase = pipeline.some(p => p.phase === 'implement');
85
+ if (hasImplementPhase && task.requiresQaApproval) {
86
+ pipeline.push({
87
+ phase: 'verify',
88
+ agentId: qaAgentId,
89
+ purpose: 'Verify implementation quality and best practices',
90
+ optional: false,
91
+ });
92
+ requiredReviews.push('qa');
93
+ }
94
+ const commitAllowed = resolveCommitAllowed(task, policyResult, config);
95
+ return { pipeline, commitAllowed, requiredReviews };
96
+ }
97
+ /**
98
+ * @description Determina si el commit está permitido según el estado del task y las políticas.
99
+ */
100
+ function resolveCommitAllowed(task, policyResult, config) {
101
+ if (!config.features.commitGate)
102
+ return true;
103
+ if (task.status === 'commit_allowed')
104
+ return true;
105
+ if (task.requiresQaApproval && task.status !== 'approved' && task.status !== 'qa_review')
106
+ return false;
107
+ if (task.requiresSecurityReview && task.status !== 'approved' && task.status !== 'security_review')
108
+ return false;
109
+ if (task.requiresArchitectureReview && task.status !== 'approved' && task.status !== 'design_review')
110
+ return false;
111
+ const pendingCustomGates = Object.entries(task.customGates)
112
+ .some(([name, required]) => required && !task.completedCustomGates.includes(name));
113
+ if (pendingCustomGates)
114
+ return false;
115
+ if (!task.requiresQaApproval && !task.requiresSecurityReview && !task.requiresArchitectureReview) {
116
+ return true;
117
+ }
118
+ return false;
119
+ }
120
+ //# sourceMappingURL=gate-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate-resolver.js","sourceRoot":"","sources":["../../../src/pipeline/orchestration/gate-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAmCH,oCAkFC;AAKD,oDAqBC;AAxHD;;;;;;;;;;;GAWG;AACH,SAAgB,YAAY,CAC1B,IAAiB,EACjB,YAAgC,EAChC,MAA0B,EAC1B,cAAyE,EACzE,YAAiC,EACjC,gBAAyC;IAEzC,MAAM,QAAQ,GAAyB,EAAE,CAAC;IAC1C,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,eAAe,GAAO,YAAY,EAAE,QAAQ,IAAI,UAAU,CAAC;IACjE,MAAM,mBAAmB,GAAG,YAAY,EAAE,YAAY,IAAI,cAAc,CAAC;IACzE,MAAM,SAAS,GAAa,YAAY,EAAE,EAAE,IAAI,aAAa,CAAC;IAE9D,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,KAAK,MAAM,IAAI,IAAI,CAAC,SAAS,KAAK,UAAU,CAAC;IAC9E,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,qBAAqB,GACzB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAE/E,sBAAsB;IACtB,IAAI,IAAI,CAAC,sBAAsB,IAAI,CAAC,UAAU,IAAI,iBAAiB,CAAC,EAAE,CAAC;QACrE,QAAQ,CAAC,IAAI,CAAC;YACZ,KAAK,EAAE,QAAQ;Y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KAAK,CAAC;IAEnH,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC;SACxD,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACrF,IAAI,kBAAkB;QAAE,OAAO,KAAK,CAAC;IAErC,IAAI,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE,CAAC;QACjG,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ export { Orchestrator } from './orchestrator';
2
+ export type { ReviewAgentIds } from './orchestrator';
3
+ export type { LLMChatClient } from './intent-detector';
4
+ export { detectIntent, enrichTaskWithIntent } from './intent-detector';
5
+ export { detectDomains, enrichTaskWithDomains } from './domain-detector';
6
+ export { calculateRisk, enrichTaskWithRisk } from './risk-scorer';
7
+ export { evaluatePolicies, applyPolicies } from './policy-engine';
8
+ export { TaskFSM } from './fsm';
9
+ export { AuditReporter } from './audit-reporter';
10
+ export type { OrchestratorConfig, PolicyRule, OrchestrationResult, AgentCapability, CapabilityMatrix, AgentPipelinePhase, AgentPipelinePhaseType, } from './types';
11
+ export { defaultOrchestratorConfig } from './types';
12
+ export type { TaskContext, ActionType, RiskLevel, RiskFactors, TaskStatus, CommitPlan, ConventionalCommitType, DelegationRequest, DelegationResult, } from './task-context';
13
+ export { createTaskContext, touchTask, transitionTask, detectScopeFromFiles, } from './task-context';
14
+ export type { FSMTransitionResult } from './fsm';
15
+ export type { GateVeredict } from './audit';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pipeline/orchestration/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,YAAY,EACR,kBAAkB,EAClB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,GACzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD,YAAY,EACR,WAAW,EACX,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,UAAU,EACV,sBAAsB,EACtB,iBAAiB,EACjB,gBAAgB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,oBAAoB,GACvB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.detectScopeFromFiles = exports.transitionTask = exports.touchTask = exports.createTaskContext = exports.defaultOrchestratorConfig = exports.AuditReporter = exports.TaskFSM = exports.applyPolicies = exports.evaluatePolicies = exports.enrichTaskWithRisk = exports.calculateRisk = exports.enrichTaskWithDomains = exports.detectDomains = exports.enrichTaskWithIntent = exports.detectIntent = exports.Orchestrator = void 0;
4
+ // Main orchestrator
5
+ var orchestrator_1 = require("./orchestrator");
6
+ Object.defineProperty(exports, "Orchestrator", { enumerable: true, get: function () { return orchestrator_1.Orchestrator; } });
7
+ // Pipeline components
8
+ var intent_detector_1 = require("./intent-detector");
9
+ Object.defineProperty(exports, "detectIntent", { enumerable: true, get: function () { return intent_detector_1.detectIntent; } });
10
+ Object.defineProperty(exports, "enrichTaskWithIntent", { enumerable: true, get: function () { return intent_detector_1.enrichTaskWithIntent; } });
11
+ var domain_detector_1 = require("./domain-detector");
12
+ Object.defineProperty(exports, "detectDomains", { enumerable: true, get: function () { return domain_detector_1.detectDomains; } });
13
+ Object.defineProperty(exports, "enrichTaskWithDomains", { enumerable: true, get: function () { return domain_detector_1.enrichTaskWithDomains; } });
14
+ var risk_scorer_1 = require("./risk-scorer");
15
+ Object.defineProperty(exports, "calculateRisk", { enumerable: true, get: function () { return risk_scorer_1.calculateRisk; } });
16
+ Object.defineProperty(exports, "enrichTaskWithRisk", { enumerable: true, get: function () { return risk_scorer_1.enrichTaskWithRisk; } });
17
+ var policy_engine_1 = require("./policy-engine");
18
+ Object.defineProperty(exports, "evaluatePolicies", { enumerable: true, get: function () { return policy_engine_1.evaluatePolicies; } });
19
+ Object.defineProperty(exports, "applyPolicies", { enumerable: true, get: function () { return policy_engine_1.applyPolicies; } });
20
+ var fsm_1 = require("./fsm");
21
+ Object.defineProperty(exports, "TaskFSM", { enumerable: true, get: function () { return fsm_1.TaskFSM; } });
22
+ // Audit
23
+ var audit_reporter_1 = require("./audit-reporter");
24
+ Object.defineProperty(exports, "AuditReporter", { enumerable: true, get: function () { return audit_reporter_1.AuditReporter; } });
25
+ var types_1 = require("./types");
26
+ Object.defineProperty(exports, "defaultOrchestratorConfig", { enumerable: true, get: function () { return types_1.defaultOrchestratorConfig; } });
27
+ var task_context_1 = require("./task-context");
28
+ Object.defineProperty(exports, "createTaskContext", { enumerable: true, get: function () { return task_context_1.createTaskContext; } });
29
+ Object.defineProperty(exports, "touchTask", { enumerable: true, get: function () { return task_context_1.touchTask; } });
30
+ Object.defineProperty(exports, "transitionTask", { enumerable: true, get: function () { return task_context_1.transitionTask; } });
31
+ Object.defineProperty(exports, "detectScopeFromFiles", { enumerable: true, get: function () { return task_context_1.detectScopeFromFiles; } });
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/pipeline/orchestration/index.ts"],"names":[],"mappings":";;;AAAA,oBAAoB;AACpB,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAIrB,sBAAsB;AACtB,qDAAuE;AAA9D,+GAAA,YAAY,OAAA;AAAE,uHAAA,oBAAoB,OAAA;AAC3C,qDAAyE;AAAhE,gHAAA,aAAa,OAAA;AAAE,wHAAA,qBAAqB,OAAA;AAC7C,6CAAkE;AAAzD,4GAAA,aAAa,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AAC1C,iDAAkE;AAAzD,iHAAA,gBAAgB,OAAA;AAAE,8GAAA,aAAa,OAAA;AACxC,6BAAgC;AAAvB,8FAAA,OAAO,OAAA;AAEhB,QAAQ;AACR,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AAYtB,iCAAoD;AAA3C,kHAAA,yBAAyB,OAAA;AAalC,+CAKwB;AAJpB,iHAAA,iBAAiB,OAAA;AACjB,yGAAA,SAAS,OAAA;AACT,8GAAA,cAAc,OAAA;AACd,oHAAA,oBAAoB,OAAA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @description Intent Detector — Clasifica el input del usuario en un ActionType.
3
+ *
4
+ * Usa un enfoque de dos niveles:
5
+ * 1. Keyword scoring rápido (síncrono, sin LLM)
6
+ * 2. Clasificación semántica vía LLM cuando hay ambigüedad
7
+ *
8
+ * El detector transforma lenguaje natural ambiguo ("necesito mejorar la
9
+ * consistencia entre órdenes y pagos") en una acción formal como
10
+ * 'design' o 'implementation'.
11
+ */
12
+ import type { LLMChatClient } from '@backendkit-labs/agent-core';
13
+ import { ActionType, TaskContext } from './task-context';
14
+ export type { LLMChatClient };
15
+ export interface IntentDetectionResult {
16
+ actionType: ActionType;
17
+ confidence: number;
18
+ scores: Record<ActionType, number>;
19
+ method: 'keyword' | 'llm';
20
+ }
21
+ /**
22
+ * @description Detecta el tipo de acción a partir del input del usuario.
23
+ *
24
+ * Primero intenta clasificar con keywords (rápido, sin LLM).
25
+ * Si hay ambigüedad (múltiples acciones con score similar), usa LLM.
26
+ *
27
+ * @param input - Texto del usuario
28
+ * @param client - Cliente DeepSeek (opcional, solo para fallback LLM)
29
+ * @returns Resultado con el actionType detectado y nivel de confianza
30
+ */
31
+ export declare function detectIntent(input: string, client?: LLMChatClient): Promise<IntentDetectionResult>;
32
+ /**
33
+ * @description Enriquce un TaskContext con el actionType detectado.
34
+ * Es el entry point principal para el orquestador.
35
+ */
36
+ export declare function enrichTaskWithIntent(task: TaskContext, client?: LLMChatClient): Promise<TaskContext>;
37
+ //# sourceMappingURL=intent-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intent-detector.d.ts","sourceRoot":"","sources":["../../../src/pipeline/orchestration/intent-detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAqB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAY5E,YAAY,EAAE,aAAa,EAAE,CAAC;AAwG9B,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,EAAE,SAAS,GAAG,KAAK,CAAC;CAC3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,qBAAqB,CAAC,CA4DhC;AAwED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,WAAW,EACjB,MAAM,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,WAAW,CAAC,CAQtB"}