@backendkit-labs/agent-coding 0.28.5 → 0.30.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.
- package/README.md +4 -0
- package/dist/__tests__/cli-baseline.test.d.ts +2 -0
- package/dist/__tests__/cli-baseline.test.d.ts.map +1 -0
- package/dist/__tests__/cli-baseline.test.js +114 -0
- package/dist/__tests__/cli-baseline.test.js.map +1 -0
- package/dist/__tests__/context-hooks.test.d.ts +2 -0
- package/dist/__tests__/context-hooks.test.d.ts.map +1 -0
- package/dist/__tests__/context-hooks.test.js +21 -0
- package/dist/__tests__/context-hooks.test.js.map +1 -0
- package/dist/__tests__/createCodingEngine.forwarding.test.js +2 -1
- package/dist/__tests__/createCodingEngine.forwarding.test.js.map +1 -1
- package/dist/__tests__/sandbox.test.js +1 -1
- package/dist/__tests__/sandbox.test.js.map +1 -1
- package/dist/__tests__/workspace-trust.test.js +7 -5
- package/dist/__tests__/workspace-trust.test.js.map +1 -1
- package/dist/agents/AgentLoader.d.ts.map +1 -1
- package/dist/agents/AgentLoader.js +2 -1
- package/dist/agents/AgentLoader.js.map +1 -1
- package/dist/cli/agent-discovery/AgentPackageLoader.d.ts +22 -0
- package/dist/cli/agent-discovery/AgentPackageLoader.d.ts.map +1 -0
- package/dist/cli/agent-discovery/AgentPackageLoader.js +100 -0
- package/dist/cli/agent-discovery/AgentPackageLoader.js.map +1 -0
- package/dist/cli/agent-discovery/RemoteAgentRegistry.d.ts +31 -0
- package/dist/cli/agent-discovery/RemoteAgentRegistry.d.ts.map +1 -0
- package/dist/cli/agent-discovery/RemoteAgentRegistry.js +106 -0
- package/dist/cli/agent-discovery/RemoteAgentRegistry.js.map +1 -0
- package/dist/cli/agent-discovery/__tests__/RemoteAgentRegistry.ssrf.test.d.ts +2 -0
- package/dist/cli/agent-discovery/__tests__/RemoteAgentRegistry.ssrf.test.d.ts.map +1 -0
- package/dist/cli/agent-discovery/__tests__/RemoteAgentRegistry.ssrf.test.js +34 -0
- package/dist/cli/agent-discovery/__tests__/RemoteAgentRegistry.ssrf.test.js.map +1 -0
- package/dist/cli/agent-discovery/__tests__/discoverAgents.test.d.ts +2 -0
- package/dist/cli/agent-discovery/__tests__/discoverAgents.test.d.ts.map +1 -0
- package/dist/cli/agent-discovery/__tests__/discoverAgents.test.js +147 -0
- package/dist/cli/agent-discovery/__tests__/discoverAgents.test.js.map +1 -0
- package/dist/cli/agent-discovery/__tests__/download-guard.test.d.ts +2 -0
- package/dist/cli/agent-discovery/__tests__/download-guard.test.d.ts.map +1 -0
- package/dist/cli/agent-discovery/__tests__/download-guard.test.js +47 -0
- package/dist/cli/agent-discovery/__tests__/download-guard.test.js.map +1 -0
- package/dist/cli/agent-discovery/discoverAgents.d.ts +21 -0
- package/dist/cli/agent-discovery/discoverAgents.d.ts.map +1 -0
- package/dist/cli/agent-discovery/discoverAgents.js +74 -0
- package/dist/cli/agent-discovery/discoverAgents.js.map +1 -0
- package/dist/cli/agent-discovery/download-guard.d.ts +20 -0
- package/dist/cli/agent-discovery/download-guard.d.ts.map +1 -0
- package/dist/cli/agent-discovery/download-guard.js +84 -0
- package/dist/cli/agent-discovery/download-guard.js.map +1 -0
- package/dist/cli/agent-discovery/index.d.ts +5 -0
- package/dist/cli/agent-discovery/index.d.ts.map +1 -0
- package/dist/cli/agent-discovery/index.js +12 -0
- package/dist/cli/agent-discovery/index.js.map +1 -0
- package/dist/cli/agent-discovery/types.d.ts +48 -0
- package/dist/cli/agent-discovery/types.d.ts.map +1 -0
- package/dist/cli/agent-discovery/types.js +3 -0
- package/dist/cli/agent-discovery/types.js.map +1 -0
- package/dist/cli/bootstrap/GlobalSeed.d.ts +46 -0
- package/dist/cli/bootstrap/GlobalSeed.d.ts.map +1 -0
- package/dist/cli/bootstrap/GlobalSeed.js +285 -0
- package/dist/cli/bootstrap/GlobalSeed.js.map +1 -0
- package/dist/cli/bootstrap/config.d.ts +24 -0
- package/dist/cli/bootstrap/config.d.ts.map +1 -0
- package/dist/cli/bootstrap/config.js +71 -0
- package/dist/cli/bootstrap/config.js.map +1 -0
- package/dist/cli/checkpoint/index.d.ts +17 -0
- package/dist/cli/checkpoint/index.d.ts.map +1 -0
- package/dist/cli/checkpoint/index.js +207 -0
- package/dist/cli/checkpoint/index.js.map +1 -0
- package/dist/cli/commands/builtin.d.ts +7 -0
- package/dist/cli/commands/builtin.d.ts.map +1 -0
- package/dist/cli/commands/builtin.js +962 -0
- package/dist/cli/commands/builtin.js.map +1 -0
- package/dist/cli/context/__tests__/formatPipeline.test.d.ts +2 -0
- package/dist/cli/context/__tests__/formatPipeline.test.d.ts.map +1 -0
- package/dist/cli/context/__tests__/formatPipeline.test.js +25 -0
- package/dist/cli/context/__tests__/formatPipeline.test.js.map +1 -0
- package/dist/cli/context/index.d.ts +8 -0
- package/dist/cli/context/index.d.ts.map +1 -0
- package/dist/cli/context/index.js +8 -0
- package/dist/cli/context/index.js.map +1 -0
- package/dist/cli/context/pipeline.d.ts +46 -0
- package/dist/cli/context/pipeline.d.ts.map +1 -0
- package/dist/cli/context/pipeline.js +112 -0
- package/dist/cli/context/pipeline.js.map +1 -0
- package/dist/cli/context/stages/stage-instructions.d.ts +12 -0
- package/dist/cli/context/stages/stage-instructions.d.ts.map +1 -0
- package/dist/cli/context/stages/stage-instructions.js +76 -0
- package/dist/cli/context/stages/stage-instructions.js.map +1 -0
- package/dist/cli/context/stages/stage-lessons.d.ts +13 -0
- package/dist/cli/context/stages/stage-lessons.d.ts.map +1 -0
- package/dist/cli/context/stages/stage-lessons.js +83 -0
- package/dist/cli/context/stages/stage-lessons.js.map +1 -0
- package/dist/cli/context/stages/stage-manifest.d.ts +11 -0
- package/dist/cli/context/stages/stage-manifest.d.ts.map +1 -0
- package/dist/cli/context/stages/stage-manifest.js +62 -0
- package/dist/cli/context/stages/stage-manifest.js.map +1 -0
- package/dist/cli/context/stages/stage-project.d.ts +10 -0
- package/dist/cli/context/stages/stage-project.d.ts.map +1 -0
- package/dist/cli/context/stages/stage-project.js +55 -0
- package/dist/cli/context/stages/stage-project.js.map +1 -0
- package/dist/cli/context/stages/stage-session.d.ts +12 -0
- package/dist/cli/context/stages/stage-session.d.ts.map +1 -0
- package/dist/cli/context/stages/stage-session.js +69 -0
- package/dist/cli/context/stages/stage-session.js.map +1 -0
- package/dist/cli/file-sources.d.ts +17 -0
- package/dist/cli/file-sources.d.ts.map +1 -0
- package/dist/cli/file-sources.js +42 -0
- package/dist/cli/file-sources.js.map +1 -0
- package/dist/cli/index.d.ts +26 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +55 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/skills/__tests__/SkillLoader.test.d.ts +2 -0
- package/dist/cli/skills/__tests__/SkillLoader.test.d.ts.map +1 -0
- package/dist/cli/skills/__tests__/SkillLoader.test.js +285 -0
- package/dist/cli/skills/__tests__/SkillLoader.test.js.map +1 -0
- package/dist/cli/skills/__tests__/SkillManager.safety.test.d.ts +2 -0
- package/dist/cli/skills/__tests__/SkillManager.safety.test.d.ts.map +1 -0
- package/dist/cli/skills/__tests__/SkillManager.safety.test.js +87 -0
- package/dist/cli/skills/__tests__/SkillManager.safety.test.js.map +1 -0
- package/dist/cli/skills/__tests__/stack.test.d.ts +2 -0
- package/dist/cli/skills/__tests__/stack.test.d.ts.map +1 -0
- package/dist/cli/skills/__tests__/stack.test.js +81 -0
- package/dist/cli/skills/__tests__/stack.test.js.map +1 -0
- package/dist/cli/skills/loader.d.ts +42 -0
- package/dist/cli/skills/loader.d.ts.map +1 -0
- package/dist/cli/skills/loader.js +158 -0
- package/dist/cli/skills/loader.js.map +1 -0
- package/dist/cli/skills/manager.d.ts +97 -0
- package/dist/cli/skills/manager.d.ts.map +1 -0
- package/dist/cli/skills/manager.js +304 -0
- package/dist/cli/skills/manager.js.map +1 -0
- package/dist/cli/skills/parse-md-skill.d.ts +14 -0
- package/dist/cli/skills/parse-md-skill.d.ts.map +1 -0
- package/dist/cli/skills/parse-md-skill.js +86 -0
- package/dist/cli/skills/parse-md-skill.js.map +1 -0
- package/dist/cli/skills/providers/github.d.ts +21 -0
- package/dist/cli/skills/providers/github.d.ts.map +1 -0
- package/dist/cli/skills/providers/github.js +146 -0
- package/dist/cli/skills/providers/github.js.map +1 -0
- package/dist/cli/skills/providers/index.d.ts +6 -0
- package/dist/cli/skills/providers/index.d.ts.map +1 -0
- package/dist/cli/skills/providers/index.js +12 -0
- package/dist/cli/skills/providers/index.js.map +1 -0
- package/dist/cli/skills/providers/local.d.ts +16 -0
- package/dist/cli/skills/providers/local.d.ts.map +1 -0
- package/dist/cli/skills/providers/local.js +91 -0
- package/dist/cli/skills/providers/local.js.map +1 -0
- package/dist/cli/skills/providers/obsidian.d.ts +31 -0
- package/dist/cli/skills/providers/obsidian.d.ts.map +1 -0
- package/dist/cli/skills/providers/obsidian.js +141 -0
- package/dist/cli/skills/providers/obsidian.js.map +1 -0
- package/dist/cli/skills/providers/skills-sh.d.ts +32 -0
- package/dist/cli/skills/providers/skills-sh.d.ts.map +1 -0
- package/dist/cli/skills/providers/skills-sh.js +53 -0
- package/dist/cli/skills/providers/skills-sh.js.map +1 -0
- package/dist/cli/skills/providers/types.d.ts +25 -0
- package/dist/cli/skills/providers/types.d.ts.map +1 -0
- package/dist/cli/skills/providers/types.js +3 -0
- package/dist/cli/skills/providers/types.js.map +1 -0
- package/dist/cli/skills/safe-name.d.ts +2 -0
- package/dist/cli/skills/safe-name.d.ts.map +1 -0
- package/dist/cli/skills/safe-name.js +22 -0
- package/dist/cli/skills/safe-name.js.map +1 -0
- package/dist/cli/skills/stack.d.ts +3 -0
- package/dist/cli/skills/stack.d.ts.map +1 -0
- package/dist/cli/skills/stack.js +64 -0
- package/dist/cli/skills/stack.js.map +1 -0
- package/dist/cli/skills/types.d.ts +28 -0
- package/dist/cli/skills/types.d.ts.map +1 -0
- package/dist/cli/skills/types.js +3 -0
- package/dist/cli/skills/types.js.map +1 -0
- package/dist/cli/trust/__tests__/workspace-trust.test.d.ts +2 -0
- package/dist/cli/trust/__tests__/workspace-trust.test.d.ts.map +1 -0
- package/dist/cli/trust/__tests__/workspace-trust.test.js +252 -0
- package/dist/cli/trust/__tests__/workspace-trust.test.js.map +1 -0
- package/dist/cli/trust/workspace-trust.d.ts +49 -0
- package/dist/cli/trust/workspace-trust.d.ts.map +1 -0
- package/dist/cli/trust/workspace-trust.js +163 -0
- package/dist/cli/trust/workspace-trust.js.map +1 -0
- package/dist/cli/workspace/index.d.ts +68 -0
- package/dist/cli/workspace/index.d.ts.map +1 -0
- package/dist/cli/workspace/index.js +231 -0
- package/dist/cli/workspace/index.js.map +1 -0
- package/dist/context-hooks.d.ts +11 -0
- package/dist/context-hooks.d.ts.map +1 -0
- package/dist/context-hooks.js +23 -0
- package/dist/context-hooks.js.map +1 -0
- package/dist/context-services.d.ts +12 -0
- package/dist/context-services.d.ts.map +1 -0
- package/dist/context-services.js +20 -0
- package/dist/context-services.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/dist/orchestration/capability-matrix.d.ts +1 -1
- package/dist/orchestration/capability-matrix.d.ts.map +1 -1
- package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.d.ts +2 -0
- package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.d.ts.map +1 -0
- package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.js +42 -0
- package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.js.map +1 -0
- package/dist/pipeline/__tests__/coding-pipeline-hooks.test.d.ts +2 -0
- package/dist/pipeline/__tests__/coding-pipeline-hooks.test.d.ts.map +1 -0
- package/dist/pipeline/__tests__/coding-pipeline-hooks.test.js +64 -0
- package/dist/pipeline/__tests__/coding-pipeline-hooks.test.js.map +1 -0
- package/dist/pipeline/__tests__/engine-brief.test.d.ts +2 -0
- package/dist/pipeline/__tests__/engine-brief.test.d.ts.map +1 -0
- package/dist/pipeline/__tests__/engine-brief.test.js +159 -0
- package/dist/pipeline/__tests__/engine-brief.test.js.map +1 -0
- package/dist/pipeline/__tests__/qa-orchestrator.test.d.ts +2 -0
- package/dist/pipeline/__tests__/qa-orchestrator.test.d.ts.map +1 -0
- package/dist/pipeline/__tests__/qa-orchestrator.test.js +276 -0
- package/dist/pipeline/__tests__/qa-orchestrator.test.js.map +1 -0
- package/dist/pipeline/coding-pipeline-hooks.d.ts +28 -0
- package/dist/pipeline/coding-pipeline-hooks.d.ts.map +1 -0
- package/dist/pipeline/coding-pipeline-hooks.js +91 -0
- package/dist/pipeline/coding-pipeline-hooks.js.map +1 -0
- package/dist/pipeline/index.d.ts +13 -0
- package/dist/pipeline/index.d.ts.map +1 -0
- package/dist/pipeline/index.js +44 -0
- package/dist/pipeline/index.js.map +1 -0
- package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.d.ts +11 -0
- package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.d.ts.map +1 -0
- package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.js +105 -0
- package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.js.map +1 -0
- package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.d.ts +2 -0
- package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.d.ts.map +1 -0
- package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.js +21 -0
- package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.js.map +1 -0
- package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.d.ts +9 -0
- package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.d.ts.map +1 -0
- package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.js +101 -0
- package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.js.map +1 -0
- package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.d.ts +2 -0
- package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.d.ts.map +1 -0
- package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.js +54 -0
- package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.js.map +1 -0
- package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.d.ts +2 -0
- package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.d.ts.map +1 -0
- package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.js +57 -0
- package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.js.map +1 -0
- package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.d.ts +9 -0
- package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.d.ts.map +1 -0
- package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.js +43 -0
- package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.js.map +1 -0
- package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.d.ts +10 -0
- package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.d.ts.map +1 -0
- package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.js +264 -0
- package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.js.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-ci-blocker.d.ts +31 -0
- package/dist/pipeline/orchestration/audit/audit-ci-blocker.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-ci-blocker.js +120 -0
- package/dist/pipeline/orchestration/audit/audit-ci-blocker.js.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-finding-tracer.d.ts +33 -0
- package/dist/pipeline/orchestration/audit/audit-finding-tracer.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-finding-tracer.js +126 -0
- package/dist/pipeline/orchestration/audit/audit-finding-tracer.js.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-lessons-learned.d.ts +27 -0
- package/dist/pipeline/orchestration/audit/audit-lessons-learned.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-lessons-learned.js +155 -0
- package/dist/pipeline/orchestration/audit/audit-lessons-learned.js.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-pending-issues.d.ts +21 -0
- package/dist/pipeline/orchestration/audit/audit-pending-issues.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-pending-issues.js +110 -0
- package/dist/pipeline/orchestration/audit/audit-pending-issues.js.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-reflection-bridge.d.ts +39 -0
- package/dist/pipeline/orchestration/audit/audit-reflection-bridge.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-reflection-bridge.js +65 -0
- package/dist/pipeline/orchestration/audit/audit-reflection-bridge.js.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-report-renderer.d.ts +30 -0
- package/dist/pipeline/orchestration/audit/audit-report-renderer.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-report-renderer.js +249 -0
- package/dist/pipeline/orchestration/audit/audit-report-renderer.js.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-report-version-manager.d.ts +52 -0
- package/dist/pipeline/orchestration/audit/audit-report-version-manager.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-report-version-manager.js +144 -0
- package/dist/pipeline/orchestration/audit/audit-report-version-manager.js.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.d.ts +37 -0
- package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.js +129 -0
- package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.js.map +1 -0
- package/dist/pipeline/orchestration/audit/index.d.ts +17 -0
- package/dist/pipeline/orchestration/audit/index.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/index.js +26 -0
- package/dist/pipeline/orchestration/audit/index.js.map +1 -0
- package/dist/pipeline/orchestration/audit/types.d.ts +79 -0
- package/dist/pipeline/orchestration/audit/types.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit/types.js +10 -0
- package/dist/pipeline/orchestration/audit/types.js.map +1 -0
- package/dist/pipeline/orchestration/audit-reporter.d.ts +133 -0
- package/dist/pipeline/orchestration/audit-reporter.d.ts.map +1 -0
- package/dist/pipeline/orchestration/audit-reporter.js +322 -0
- package/dist/pipeline/orchestration/audit-reporter.js.map +1 -0
- package/dist/pipeline/orchestration/config-loader.d.ts +51 -0
- package/dist/pipeline/orchestration/config-loader.d.ts.map +1 -0
- package/dist/pipeline/orchestration/config-loader.js +215 -0
- package/dist/pipeline/orchestration/config-loader.js.map +1 -0
- package/dist/pipeline/orchestration/domain-detector.d.ts +36 -0
- package/dist/pipeline/orchestration/domain-detector.d.ts.map +1 -0
- package/dist/pipeline/orchestration/domain-detector.js +157 -0
- package/dist/pipeline/orchestration/domain-detector.js.map +1 -0
- package/dist/pipeline/orchestration/fsm.d.ts +92 -0
- package/dist/pipeline/orchestration/fsm.d.ts.map +1 -0
- package/dist/pipeline/orchestration/fsm.js +243 -0
- package/dist/pipeline/orchestration/fsm.js.map +1 -0
- package/dist/pipeline/orchestration/gate-resolver.d.ts +52 -0
- package/dist/pipeline/orchestration/gate-resolver.d.ts.map +1 -0
- package/dist/pipeline/orchestration/gate-resolver.js +120 -0
- package/dist/pipeline/orchestration/gate-resolver.js.map +1 -0
- package/dist/pipeline/orchestration/index.d.ts +16 -0
- package/dist/pipeline/orchestration/index.d.ts.map +1 -0
- package/dist/pipeline/orchestration/index.js +32 -0
- package/dist/pipeline/orchestration/index.js.map +1 -0
- package/dist/pipeline/orchestration/intent-detector.d.ts +37 -0
- package/dist/pipeline/orchestration/intent-detector.d.ts.map +1 -0
- package/dist/pipeline/orchestration/intent-detector.js +248 -0
- package/dist/pipeline/orchestration/intent-detector.js.map +1 -0
- package/dist/pipeline/orchestration/keyword-match.d.ts +17 -0
- package/dist/pipeline/orchestration/keyword-match.d.ts.map +1 -0
- package/dist/pipeline/orchestration/keyword-match.js +26 -0
- package/dist/pipeline/orchestration/keyword-match.js.map +1 -0
- package/dist/pipeline/orchestration/orchestrator.d.ts +158 -0
- package/dist/pipeline/orchestration/orchestrator.d.ts.map +1 -0
- package/dist/pipeline/orchestration/orchestrator.js +414 -0
- package/dist/pipeline/orchestration/orchestrator.js.map +1 -0
- package/dist/pipeline/orchestration/policy-engine.d.ts +54 -0
- package/dist/pipeline/orchestration/policy-engine.d.ts.map +1 -0
- package/dist/pipeline/orchestration/policy-engine.js +278 -0
- package/dist/pipeline/orchestration/policy-engine.js.map +1 -0
- package/dist/pipeline/orchestration/risk-scorer.d.ts +38 -0
- package/dist/pipeline/orchestration/risk-scorer.d.ts.map +1 -0
- package/dist/pipeline/orchestration/risk-scorer.js +145 -0
- package/dist/pipeline/orchestration/risk-scorer.js.map +1 -0
- package/dist/pipeline/orchestration/task-context.d.ts +205 -0
- package/dist/pipeline/orchestration/task-context.d.ts.map +1 -0
- package/dist/pipeline/orchestration/task-context.js +162 -0
- package/dist/pipeline/orchestration/task-context.js.map +1 -0
- package/dist/pipeline/orchestration/types.d.ts +111 -0
- package/dist/pipeline/orchestration/types.d.ts.map +1 -0
- package/dist/pipeline/orchestration/types.js +37 -0
- package/dist/pipeline/orchestration/types.js.map +1 -0
- package/dist/pipeline/qa/__tests__/QAService.test.d.ts +2 -0
- package/dist/pipeline/qa/__tests__/QAService.test.d.ts.map +1 -0
- package/dist/pipeline/qa/__tests__/QAService.test.js +170 -0
- package/dist/pipeline/qa/__tests__/QAService.test.js.map +1 -0
- package/dist/pipeline/qa/__tests__/QAService.verdict.test.d.ts +2 -0
- package/dist/pipeline/qa/__tests__/QAService.verdict.test.d.ts.map +1 -0
- package/dist/pipeline/qa/__tests__/QAService.verdict.test.js +39 -0
- package/dist/pipeline/qa/__tests__/QAService.verdict.test.js.map +1 -0
- package/dist/pipeline/qa/index.d.ts +3 -0
- package/dist/pipeline/qa/index.d.ts.map +1 -0
- package/dist/pipeline/qa/index.js +6 -0
- package/dist/pipeline/qa/index.js.map +1 -0
- package/dist/pipeline/qa/qa-service.d.ts +33 -0
- package/dist/pipeline/qa/qa-service.d.ts.map +1 -0
- package/dist/pipeline/qa/qa-service.js +239 -0
- package/dist/pipeline/qa/qa-service.js.map +1 -0
- package/dist/pipeline/qa-orchestrator.d.ts +60 -0
- package/dist/pipeline/qa-orchestrator.d.ts.map +1 -0
- package/dist/pipeline/qa-orchestrator.js +177 -0
- package/dist/pipeline/qa-orchestrator.js.map +1 -0
- package/dist/pipeline/reflection/domains/agent-domain.d.ts +40 -0
- package/dist/pipeline/reflection/domains/agent-domain.d.ts.map +1 -0
- package/dist/pipeline/reflection/domains/agent-domain.js +161 -0
- package/dist/pipeline/reflection/domains/agent-domain.js.map +1 -0
- package/dist/pipeline/reflection/domains/audit-domain.d.ts +46 -0
- package/dist/pipeline/reflection/domains/audit-domain.d.ts.map +1 -0
- package/dist/pipeline/reflection/domains/audit-domain.js +241 -0
- package/dist/pipeline/reflection/domains/audit-domain.js.map +1 -0
- package/dist/pipeline/reflection/domains/bootstrap-domain.d.ts +40 -0
- package/dist/pipeline/reflection/domains/bootstrap-domain.d.ts.map +1 -0
- package/dist/pipeline/reflection/domains/bootstrap-domain.js +156 -0
- package/dist/pipeline/reflection/domains/bootstrap-domain.js.map +1 -0
- package/dist/pipeline/reflection/domains/commit-domain.d.ts +40 -0
- package/dist/pipeline/reflection/domains/commit-domain.d.ts.map +1 -0
- package/dist/pipeline/reflection/domains/commit-domain.js +174 -0
- package/dist/pipeline/reflection/domains/commit-domain.js.map +1 -0
- package/dist/pipeline/reflection/domains/test-domain.d.ts +40 -0
- package/dist/pipeline/reflection/domains/test-domain.d.ts.map +1 -0
- package/dist/pipeline/reflection/domains/test-domain.js +194 -0
- package/dist/pipeline/reflection/domains/test-domain.js.map +1 -0
- package/dist/pipeline/reflection/historical-loader.d.ts +105 -0
- package/dist/pipeline/reflection/historical-loader.d.ts.map +1 -0
- package/dist/pipeline/reflection/historical-loader.js +462 -0
- package/dist/pipeline/reflection/historical-loader.js.map +1 -0
- package/dist/pipeline/reflection/hooks/agent-hook.d.ts +72 -0
- package/dist/pipeline/reflection/hooks/agent-hook.d.ts.map +1 -0
- package/dist/pipeline/reflection/hooks/agent-hook.js +98 -0
- package/dist/pipeline/reflection/hooks/agent-hook.js.map +1 -0
- package/dist/pipeline/reflection/hooks/audit-hook.d.ts +72 -0
- package/dist/pipeline/reflection/hooks/audit-hook.d.ts.map +1 -0
- package/dist/pipeline/reflection/hooks/audit-hook.js +112 -0
- package/dist/pipeline/reflection/hooks/audit-hook.js.map +1 -0
- package/dist/pipeline/reflection/hooks/bootstrap-hook.d.ts +71 -0
- package/dist/pipeline/reflection/hooks/bootstrap-hook.d.ts.map +1 -0
- package/dist/pipeline/reflection/hooks/bootstrap-hook.js +97 -0
- package/dist/pipeline/reflection/hooks/bootstrap-hook.js.map +1 -0
- package/dist/pipeline/reflection/hooks/commit-hook.d.ts +63 -0
- package/dist/pipeline/reflection/hooks/commit-hook.d.ts.map +1 -0
- package/dist/pipeline/reflection/hooks/commit-hook.js +90 -0
- package/dist/pipeline/reflection/hooks/commit-hook.js.map +1 -0
- package/dist/pipeline/reflection/hooks/test-hook.d.ts +65 -0
- package/dist/pipeline/reflection/hooks/test-hook.d.ts.map +1 -0
- package/dist/pipeline/reflection/hooks/test-hook.js +99 -0
- package/dist/pipeline/reflection/hooks/test-hook.js.map +1 -0
- package/dist/pipeline/reflection/lessons-memo-generator.d.ts +60 -0
- package/dist/pipeline/reflection/lessons-memo-generator.d.ts.map +1 -0
- package/dist/pipeline/reflection/lessons-memo-generator.js +286 -0
- package/dist/pipeline/reflection/lessons-memo-generator.js.map +1 -0
- package/dist/store/ProjectStore.d.ts +1 -1
- package/dist/store/ProjectStore.d.ts.map +1 -1
- package/dist/store/ProjectStore.js +2 -1
- package/dist/store/ProjectStore.js.map +1 -1
- package/dist/store/types.d.ts +28 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +3 -0
- package/dist/store/types.js.map +1 -0
- package/dist/tools/__tests__/command-parser.test.js +1 -1
- package/dist/tools/__tests__/command-parser.test.js.map +1 -1
- package/dist/tools/__tests__/declared-facts.test.d.ts +2 -0
- package/dist/tools/__tests__/declared-facts.test.d.ts.map +1 -0
- package/dist/tools/__tests__/declared-facts.test.js +21 -0
- package/dist/tools/__tests__/declared-facts.test.js.map +1 -0
- package/dist/tools/__tests__/package-install.test.d.ts +2 -0
- package/dist/tools/__tests__/package-install.test.d.ts.map +1 -0
- package/dist/tools/__tests__/package-install.test.js +56 -0
- package/dist/tools/__tests__/package-install.test.js.map +1 -0
- package/dist/tools/__tests__/save-tools.secrets.test.js +1 -1
- package/dist/tools/__tests__/save-tools.secrets.test.js.map +1 -1
- package/dist/tools/edit-file.d.ts.map +1 -1
- package/dist/tools/edit-file.js +1 -0
- package/dist/tools/edit-file.js.map +1 -1
- package/dist/tools/list-directory.d.ts.map +1 -1
- package/dist/tools/list-directory.js +1 -0
- package/dist/tools/list-directory.js.map +1 -1
- package/dist/tools/package-install.d.ts +11 -0
- package/dist/tools/package-install.d.ts.map +1 -0
- package/dist/tools/package-install.js +112 -0
- package/dist/tools/package-install.js.map +1 -0
- package/dist/tools/read-file.d.ts.map +1 -1
- package/dist/tools/read-file.js +1 -0
- package/dist/tools/read-file.js.map +1 -1
- package/dist/tools/run-command.d.ts.map +1 -1
- package/dist/tools/run-command.js +5 -1
- package/dist/tools/run-command.js.map +1 -1
- package/dist/tools/save-audit.d.ts.map +1 -1
- package/dist/tools/save-audit.js +7 -6
- package/dist/tools/save-audit.js.map +1 -1
- package/dist/tools/save-context.d.ts.map +1 -1
- package/dist/tools/save-context.js +3 -2
- package/dist/tools/save-context.js.map +1 -1
- package/dist/tools/save-learning.d.ts.map +1 -1
- package/dist/tools/save-learning.js +4 -3
- package/dist/tools/save-learning.js.map +1 -1
- package/dist/tools/save-user-preference.d.ts.map +1 -1
- package/dist/tools/save-user-preference.js +3 -2
- package/dist/tools/save-user-preference.js.map +1 -1
- package/dist/tools/search-files.d.ts.map +1 -1
- package/dist/tools/search-files.js +1 -0
- package/dist/tools/search-files.js.map +1 -1
- package/dist/tools/update-session.d.ts.map +1 -1
- package/dist/tools/update-session.js +3 -2
- package/dist/tools/update-session.js.map +1 -1
- package/dist/tools/write-file.d.ts.map +1 -1
- package/dist/tools/write-file.js +1 -0
- package/dist/tools/write-file.js.map +1 -1
- package/package.json +71 -44
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description HistoricalLoader — Carga archivos historicos de auditoria (NO-GO)
|
|
4
|
+
* y los convierte en FailureRecord para alimentar el Reflection Engine.
|
|
5
|
+
*
|
|
6
|
+
* Escanea ~/.deepseek-code/projects/{hash}/audits/ en busca de archivos .md
|
|
7
|
+
* con veredicto NO-GO o NO-GO condicional, extrae los hallazgos de la tabla
|
|
8
|
+
* Markdown y los persiste en failures.json, luego dispara reflect() para
|
|
9
|
+
* que PatternDetector detecte patrones y PolicyPromoter genere policyRules.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const loader = new HistoricalLoader({ engine });
|
|
14
|
+
* const result = await loader.loadAll();
|
|
15
|
+
* console.log(`Cargados ${result.loaded} registros, ${result.patterns} patrones detectados`);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
21
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
22
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
23
|
+
}
|
|
24
|
+
Object.defineProperty(o, k2, desc);
|
|
25
|
+
}) : (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
o[k2] = m[k];
|
|
28
|
+
}));
|
|
29
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
30
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
31
|
+
}) : function(o, v) {
|
|
32
|
+
o["default"] = v;
|
|
33
|
+
});
|
|
34
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
35
|
+
var ownKeys = function(o) {
|
|
36
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
37
|
+
var ar = [];
|
|
38
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
39
|
+
return ar;
|
|
40
|
+
};
|
|
41
|
+
return ownKeys(o);
|
|
42
|
+
};
|
|
43
|
+
return function (mod) {
|
|
44
|
+
if (mod && mod.__esModule) return mod;
|
|
45
|
+
var result = {};
|
|
46
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
47
|
+
__setModuleDefault(result, mod);
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
})();
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.HistoricalLoader = void 0;
|
|
53
|
+
const path = __importStar(require("path"));
|
|
54
|
+
const os = __importStar(require("os"));
|
|
55
|
+
const fs = __importStar(require("fs/promises"));
|
|
56
|
+
const agent_core_1 = require("@backendkit-labs/agent-core");
|
|
57
|
+
const agent_core_2 = require("@backendkit-labs/agent-core");
|
|
58
|
+
// ── Constantes ───────────────────────────────────────────────────────────────
|
|
59
|
+
const TABLE_ROW_PATTERN = /^\|\s*([\w-]+)\s*\|\s*(.+?)\s*\|\s*(.+?)\s*\|\s*\*\*(.+?)\*\*\s*\|\s*(.*?)\s*\|\s*(.+?)\s*\|\s*(.+?)\s*\|$/;
|
|
60
|
+
const SEVERITY_MAP = {
|
|
61
|
+
'critical': 'critical', 'critica': 'critical', 'Critica': 'critical', 'Crítica': 'critical',
|
|
62
|
+
'high': 'high', 'alta': 'high', 'Alta': 'high',
|
|
63
|
+
'medium': 'medium', 'media': 'medium', 'Media': 'medium',
|
|
64
|
+
'low': 'low', 'baja': 'low', 'Baja': 'low',
|
|
65
|
+
};
|
|
66
|
+
const SEVERITY_TO_RECORD = SEVERITY_MAP;
|
|
67
|
+
// ── HistoricalLoader ─────────────────────────────────────────────────────────
|
|
68
|
+
class HistoricalLoader {
|
|
69
|
+
engine;
|
|
70
|
+
projectRoot;
|
|
71
|
+
appName;
|
|
72
|
+
constructor(options) {
|
|
73
|
+
this.engine = options.engine;
|
|
74
|
+
this.projectRoot = options.projectRoot ?? process.cwd();
|
|
75
|
+
this.appName = options.appName ?? 'bk-agent';
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @description Escanea y carga todos los proyectos con directorios audits/.
|
|
79
|
+
* Si no se especifica projectRoot, escanea todos los proyectos en
|
|
80
|
+
* ~/.deepseek-code/projects/.
|
|
81
|
+
*/
|
|
82
|
+
async loadAll(options) {
|
|
83
|
+
const result = {
|
|
84
|
+
scannedFiles: 0,
|
|
85
|
+
noGoFiles: 0,
|
|
86
|
+
loaded: 0,
|
|
87
|
+
skipped: 0,
|
|
88
|
+
patterns: 0,
|
|
89
|
+
promotedRules: 0,
|
|
90
|
+
errors: [],
|
|
91
|
+
projectsProcessed: [],
|
|
92
|
+
};
|
|
93
|
+
const projects = options?.onlyCurrentProject !== false
|
|
94
|
+
? [this.resolveProjectAuditsDir(this.projectRoot)]
|
|
95
|
+
: await this.findAllProjectAuditsDirs();
|
|
96
|
+
for (const auditsDir of projects) {
|
|
97
|
+
if (!auditsDir)
|
|
98
|
+
continue;
|
|
99
|
+
const projectKey = path.basename(path.dirname(auditsDir));
|
|
100
|
+
result.projectsProcessed.push(projectKey);
|
|
101
|
+
try {
|
|
102
|
+
const projectResult = await this.loadProject(auditsDir, options?.force);
|
|
103
|
+
result.scannedFiles += projectResult.scannedFiles;
|
|
104
|
+
result.noGoFiles += projectResult.noGoFiles;
|
|
105
|
+
result.loaded += projectResult.loaded;
|
|
106
|
+
result.skipped += projectResult.skipped;
|
|
107
|
+
result.patterns += projectResult.patterns;
|
|
108
|
+
result.promotedRules += projectResult.promotedRules;
|
|
109
|
+
result.errors.push(...projectResult.errors);
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
113
|
+
result.errors.push(`[${projectKey}] Error: ${msg}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @description Carga un proyecto especifico por su directorio de auditorias.
|
|
120
|
+
*/
|
|
121
|
+
async loadProject(auditsDir, force) {
|
|
122
|
+
const result = {
|
|
123
|
+
scannedFiles: 0,
|
|
124
|
+
noGoFiles: 0,
|
|
125
|
+
loaded: 0,
|
|
126
|
+
skipped: 0,
|
|
127
|
+
patterns: 0,
|
|
128
|
+
promotedRules: 0,
|
|
129
|
+
errors: [],
|
|
130
|
+
projectsProcessed: [],
|
|
131
|
+
};
|
|
132
|
+
// Verificar que el directorio existe
|
|
133
|
+
try {
|
|
134
|
+
await fs.access(auditsDir);
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
result.errors.push(`Directorio no encontrado: ${auditsDir}`);
|
|
138
|
+
return result;
|
|
139
|
+
}
|
|
140
|
+
// Listar archivos .md (excluir auto-gates, pending-issues, lecciones)
|
|
141
|
+
const files = await fs.readdir(auditsDir);
|
|
142
|
+
const mdFiles = files.filter(f => f.endsWith('.md') &&
|
|
143
|
+
!f.startsWith('auto-gates') &&
|
|
144
|
+
!f.startsWith('pending-issues') &&
|
|
145
|
+
f !== 'lecciones-aprendidas.md');
|
|
146
|
+
result.scannedFiles = mdFiles.length;
|
|
147
|
+
// Cargar registros existentes para evitar duplicados
|
|
148
|
+
const catalog = this.engine.getCatalog();
|
|
149
|
+
await catalog.ensureLoaded();
|
|
150
|
+
const existingRecords = await catalog.getAllRecords();
|
|
151
|
+
const existingFingerprints = new Set(existingRecords.map(r => `${r.domain}:${r.failureType}:${r.hallazgo.slice(0, 80)}`));
|
|
152
|
+
// Procesar cada archivo
|
|
153
|
+
const newRecords = [];
|
|
154
|
+
for (const file of mdFiles) {
|
|
155
|
+
const filePath = path.join(auditsDir, file);
|
|
156
|
+
try {
|
|
157
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
158
|
+
// Saltar archivos GO sin hallazgos
|
|
159
|
+
if (this.isGoWithoutFindings(content))
|
|
160
|
+
continue;
|
|
161
|
+
result.noGoFiles++;
|
|
162
|
+
const parsed = this.parseGateFile(content, file);
|
|
163
|
+
if (!parsed)
|
|
164
|
+
continue;
|
|
165
|
+
// Extraer dominio del contexto de la tarea o del gate
|
|
166
|
+
const domain = this.inferDomain(parsed);
|
|
167
|
+
for (const finding of parsed.hallazgos) {
|
|
168
|
+
// Inferir failureType del hallazgo
|
|
169
|
+
const failureType = this.inferFailureType(finding, domain);
|
|
170
|
+
// Crear fingerprint para evitar duplicados
|
|
171
|
+
const fingerprint = `${domain}:${failureType}:${finding.hallazgo.slice(0, 80)}`;
|
|
172
|
+
if (!force && existingFingerprints.has(fingerprint)) {
|
|
173
|
+
result.skipped++;
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
const record = {
|
|
177
|
+
id: (0, agent_core_1.generateFailureId)(),
|
|
178
|
+
domain,
|
|
179
|
+
failureType,
|
|
180
|
+
severity: (SEVERITY_TO_RECORD[finding.severidad] ?? 'medium'),
|
|
181
|
+
dimension: finding.dimension,
|
|
182
|
+
gate: parsed.gate,
|
|
183
|
+
agenteResponsable: finding.agenteResponsable,
|
|
184
|
+
hallazgo: finding.hallazgo,
|
|
185
|
+
recomendacion: finding.recomendacion,
|
|
186
|
+
archivos: [],
|
|
187
|
+
fecha: parsed.fecha,
|
|
188
|
+
};
|
|
189
|
+
newRecords.push(record);
|
|
190
|
+
existingFingerprints.add(fingerprint);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
195
|
+
result.errors.push(`Error procesando ${file}: ${msg}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// Persistir registros nuevos
|
|
199
|
+
if (newRecords.length > 0) {
|
|
200
|
+
await catalog.addRecords(newRecords);
|
|
201
|
+
result.loaded = newRecords.length;
|
|
202
|
+
}
|
|
203
|
+
// Disparar reflexion para detectar patrones y promover reglas
|
|
204
|
+
if (newRecords.length > 0) {
|
|
205
|
+
try {
|
|
206
|
+
const reflectResult = await this.engine.reflect({ autoPromote: true });
|
|
207
|
+
result.patterns = reflectResult.patterns.length;
|
|
208
|
+
result.promotedRules = reflectResult.promotedRules.length;
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
212
|
+
result.errors.push(`Error en reflexion: ${msg}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return result;
|
|
216
|
+
}
|
|
217
|
+
// ── Parseo de archivos ─────────────────────────────────────────────────────
|
|
218
|
+
/**
|
|
219
|
+
* @description Parsea un archivo de gate Markdown y extrae metadatos + hallazgos.
|
|
220
|
+
*/
|
|
221
|
+
parseGateFile(content, filename) {
|
|
222
|
+
// Extraer veredicto del frontmatter YAML
|
|
223
|
+
const veredictoMatch = content.match(/veredicto:\s*"(.+?)"/);
|
|
224
|
+
const veredicto = veredictoMatch?.[1] ?? '';
|
|
225
|
+
// Solo procesar NO-GO y NO-GO condicional
|
|
226
|
+
if (veredicto !== 'NO-GO' && veredicto !== 'NO-GO condicional')
|
|
227
|
+
return null;
|
|
228
|
+
// Extraer gate del frontmatter (new format: "Gate Report:", legacy: "Informe de Gate:")
|
|
229
|
+
const gateMatch = content.match(/title:\s*"(?:Gate Report|Informe de Gate):\s*(.+?)"/);
|
|
230
|
+
const gate = gateMatch?.[1]?.toLowerCase() ?? 'unknown';
|
|
231
|
+
// Extraer agente del frontmatter
|
|
232
|
+
const agenteMatch = content.match(/auditor:\s*"(.+?)"/);
|
|
233
|
+
const agente = agenteMatch?.[1] ?? 'unknown';
|
|
234
|
+
// Extraer fecha del frontmatter (new key: date, legacy: fecha)
|
|
235
|
+
const fechaMatch = content.match(/(?:date|fecha):\s*"(.+?)"/);
|
|
236
|
+
const fecha = fechaMatch?.[1] ?? new Date().toISOString();
|
|
237
|
+
// Extraer dominio del contexto de la tarea
|
|
238
|
+
const dominioMatch = content.match(/Domino\(s\):\s*(.+?)(?:\n|$)/);
|
|
239
|
+
const dominio = dominioMatch?.[1]?.trim() ?? '';
|
|
240
|
+
// Extraer hallazgos de la tabla Markdown
|
|
241
|
+
const hallazgos = this.parseFindingsTable(content);
|
|
242
|
+
return { gate, agente, veredicto, fecha, hallazgos, dominio };
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* @description Parsea la tabla de hallazgos en formato Markdown.
|
|
246
|
+
* Formato esperado:
|
|
247
|
+
* | ID | Dimension | Hallazgo | Severidad | Evidencia | Recomendacion | Agente responsable |
|
|
248
|
+
*/
|
|
249
|
+
parseFindingsTable(content) {
|
|
250
|
+
const findings = [];
|
|
251
|
+
const lines = content.split('\n');
|
|
252
|
+
let inTable = false;
|
|
253
|
+
let headerPassed = false;
|
|
254
|
+
for (const line of lines) {
|
|
255
|
+
const trimmed = line.trim();
|
|
256
|
+
// Detectar inicio de tabla
|
|
257
|
+
if (trimmed.startsWith('| ID |')) {
|
|
258
|
+
inTable = true;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
// Saltar separador |---|----|
|
|
262
|
+
if (inTable && trimmed.startsWith('|---')) {
|
|
263
|
+
headerPassed = true;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
// Salir de la tabla al encontrar linea no-tabla
|
|
267
|
+
if (inTable && headerPassed && (!trimmed.startsWith('|') || trimmed.startsWith('| ---'))) {
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
if (inTable && headerPassed && trimmed.startsWith('|')) {
|
|
271
|
+
const finding = this.parseTableRow(trimmed);
|
|
272
|
+
if (finding) {
|
|
273
|
+
findings.push(finding);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return findings;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* @description Parsea una fila de la tabla Markdown.
|
|
281
|
+
* Maneja el encoding corrupto (caracteres corruptos) limpiando el texto.
|
|
282
|
+
*/
|
|
283
|
+
parseTableRow(row) {
|
|
284
|
+
// Dividir por | respetando pipes escapados
|
|
285
|
+
const parts = row.split('|').map(p => p.trim()).filter(p => p.length > 0);
|
|
286
|
+
if (parts.length < 7)
|
|
287
|
+
return null;
|
|
288
|
+
const id = this.cleanText(parts[0]);
|
|
289
|
+
const dimension = this.cleanText(parts[1]);
|
|
290
|
+
const hallazgo = this.cleanText(parts[2]);
|
|
291
|
+
const severidadRaw = this.cleanText(parts[3]).replace(/\*\*/g, '');
|
|
292
|
+
const evidencia = this.cleanText(parts[4]);
|
|
293
|
+
const recomendacion = this.cleanText(parts[5]);
|
|
294
|
+
const agenteResponsable = this.cleanText(parts[6]);
|
|
295
|
+
// Mapear severidad
|
|
296
|
+
const severidad = this.mapSeverity(severidadRaw);
|
|
297
|
+
return {
|
|
298
|
+
id,
|
|
299
|
+
dimension,
|
|
300
|
+
hallazgo,
|
|
301
|
+
severidad,
|
|
302
|
+
evidencia,
|
|
303
|
+
recomendacion,
|
|
304
|
+
agenteResponsable,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
// ── Helpers ────────────────────────────────────────────────────────────────
|
|
308
|
+
/**
|
|
309
|
+
* @description Limpia caracteres corruptos del encoding.
|
|
310
|
+
*/
|
|
311
|
+
cleanText(text) {
|
|
312
|
+
return text
|
|
313
|
+
.replace(/\uFFFD/g, '') // Quitar caracter de reemplazo Unicode
|
|
314
|
+
.replace(/[^\x20-\x7E\s]/g, '') // Quitar no-ASCII imprimible
|
|
315
|
+
.replace(/\s+/g, ' ') // Normalizar espacios
|
|
316
|
+
.trim();
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @description Mapea texto de severidad a enum.
|
|
320
|
+
*/
|
|
321
|
+
mapSeverity(raw) {
|
|
322
|
+
return SEVERITY_MAP[raw] ?? SEVERITY_MAP[raw.toLowerCase()] ?? 'medium';
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* @description Determina si un archivo es GO sin hallazgos (para saltarlo).
|
|
326
|
+
*/
|
|
327
|
+
isGoWithoutFindings(content) {
|
|
328
|
+
const hasNoGo = content.includes('NO-GO');
|
|
329
|
+
const hasFindings = content.includes('| ID |');
|
|
330
|
+
return !hasNoGo && !hasFindings;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* @description Infiere el dominio Reflection a partir del gate y contexto.
|
|
334
|
+
*/
|
|
335
|
+
inferDomain(parsed) {
|
|
336
|
+
const gate = parsed.gate.toLowerCase();
|
|
337
|
+
const dominio = parsed.dominio.toLowerCase();
|
|
338
|
+
if (gate.includes('qa') || gate.includes('test'))
|
|
339
|
+
return 'test';
|
|
340
|
+
if (gate.includes('security'))
|
|
341
|
+
return 'audit';
|
|
342
|
+
if (gate.includes('architecture'))
|
|
343
|
+
return 'audit';
|
|
344
|
+
if (gate.includes('orquest'))
|
|
345
|
+
return 'agent';
|
|
346
|
+
if (dominio.includes('bootstrap') || dominio.includes('config'))
|
|
347
|
+
return 'bootstrap';
|
|
348
|
+
if (dominio.includes('commit'))
|
|
349
|
+
return 'commit';
|
|
350
|
+
return 'audit';
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* @description Infiere el failureType a partir del hallazgo y dominio.
|
|
354
|
+
* Usa palabras clave en el texto del hallazgo.
|
|
355
|
+
*/
|
|
356
|
+
inferFailureType(finding, domain) {
|
|
357
|
+
const text = `${finding.hallazgo} ${finding.dimension} ${finding.evidencia}`.toLowerCase();
|
|
358
|
+
// Patrones por dominio
|
|
359
|
+
if (domain === 'audit') {
|
|
360
|
+
if (text.includes('security') || text.includes('vulnerabilidad') || text.includes('owasp'))
|
|
361
|
+
return 'security_vulnerability';
|
|
362
|
+
if (text.includes('test') || text.includes('cobertura') || text.includes('coverage'))
|
|
363
|
+
return 'missing_test_coverage';
|
|
364
|
+
if (text.includes('error') || text.includes('exception') || text.includes('catch'))
|
|
365
|
+
return 'incomplete_error_handling';
|
|
366
|
+
if (text.includes('documentacion') || text.includes('documentation') || text.includes('doc'))
|
|
367
|
+
return 'missing_documentation';
|
|
368
|
+
if (text.includes('arquitectura') || text.includes('architecture') || text.includes('diseno'))
|
|
369
|
+
return 'architecture_violation';
|
|
370
|
+
if (text.includes('log') || text.includes('logging'))
|
|
371
|
+
return 'missing_logging';
|
|
372
|
+
if (text.includes('validacion') || text.includes('validation') || text.includes('input'))
|
|
373
|
+
return 'unvalidated_input';
|
|
374
|
+
if (text.includes('secret') || text.includes('password') || text.includes('api_key'))
|
|
375
|
+
return 'hardcoded_secret';
|
|
376
|
+
if (text.includes('rollback') || text.includes('migracion'))
|
|
377
|
+
return 'missing_rollback';
|
|
378
|
+
if (text.includes('conexion') || text.includes('connection') || text.includes('pool'))
|
|
379
|
+
return 'connection_leak';
|
|
380
|
+
}
|
|
381
|
+
if (domain === 'test') {
|
|
382
|
+
if (text.includes('timeout') || text.includes('tiempo'))
|
|
383
|
+
return 'jest_timeout';
|
|
384
|
+
if (text.includes('cobertura') || text.includes('coverage') || text.includes('threshold'))
|
|
385
|
+
return 'coverage_below_threshold';
|
|
386
|
+
if (text.includes('flaky') || text.includes('intermitente'))
|
|
387
|
+
return 'flaky_test';
|
|
388
|
+
if (text.includes('assert') || text.includes('assertion'))
|
|
389
|
+
return 'test_without_assertion';
|
|
390
|
+
if (text.includes('integration') || text.includes('integracion'))
|
|
391
|
+
return 'integration_test_without_container';
|
|
392
|
+
if (text.includes('type') || text.includes('tsc') || text.includes('tipado'))
|
|
393
|
+
return 'tsc_noEmit_type_error';
|
|
394
|
+
}
|
|
395
|
+
if (domain === 'agent') {
|
|
396
|
+
if (text.includes('seleccion') || text.includes('wrong') || text.includes('incorrecto'))
|
|
397
|
+
return 'wrong_agent_selected';
|
|
398
|
+
if (text.includes('timeout') || text.includes('tiempo'))
|
|
399
|
+
return 'agent_timeout';
|
|
400
|
+
if (text.includes('alucinacion') || text.includes('hallucination'))
|
|
401
|
+
return 'agent_hallucination';
|
|
402
|
+
if (text.includes('delegacion') || text.includes('delegation'))
|
|
403
|
+
return 'delegation_failed';
|
|
404
|
+
if (text.includes('rechaz') || text.includes('rejected') || text.includes('evaluator'))
|
|
405
|
+
return 'response_rejected_by_evaluator';
|
|
406
|
+
}
|
|
407
|
+
if (domain === 'bootstrap') {
|
|
408
|
+
if (text.includes('config') || text.includes('yaml') || text.includes('manifest'))
|
|
409
|
+
return 'manifest_corrupt';
|
|
410
|
+
if (text.includes('memoria') || text.includes('memory') || text.includes('load'))
|
|
411
|
+
return 'memory_load_failure';
|
|
412
|
+
if (text.includes('seed') || text.includes('configuracion'))
|
|
413
|
+
return 'seed_config_failed';
|
|
414
|
+
}
|
|
415
|
+
if (domain === 'commit') {
|
|
416
|
+
if (text.includes('type') || text.includes('tipo'))
|
|
417
|
+
return 'missing_type';
|
|
418
|
+
if (text.includes('scope') || text.includes('ambito'))
|
|
419
|
+
return 'wrong_scope';
|
|
420
|
+
if (text.includes('branch') || text.includes('rama'))
|
|
421
|
+
return 'branch_naming_invalid';
|
|
422
|
+
}
|
|
423
|
+
return 'unknown_failure';
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* @description Resuelve el directorio de auditorias para un proyecto.
|
|
427
|
+
*/
|
|
428
|
+
resolveProjectAuditsDir(projectRoot) {
|
|
429
|
+
const home = process.env.USERPROFILE ?? process.env.HOME ?? os.homedir();
|
|
430
|
+
const projectKey = (0, agent_core_2.cwdToProjectKey)(projectRoot);
|
|
431
|
+
return path.join(home, `.${this.appName}`, 'projects', projectKey, 'audits');
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* @description Encuentra todos los directorios audits/ en projects/.
|
|
435
|
+
*/
|
|
436
|
+
async findAllProjectAuditsDirs() {
|
|
437
|
+
const home = process.env.USERPROFILE ?? process.env.HOME ?? os.homedir();
|
|
438
|
+
const projectsDir = path.join(home, `.${this.appName}`, 'projects');
|
|
439
|
+
try {
|
|
440
|
+
const entries = await fs.readdir(projectsDir, { withFileTypes: true });
|
|
441
|
+
const dirs = [];
|
|
442
|
+
for (const entry of entries) {
|
|
443
|
+
if (entry.isDirectory()) {
|
|
444
|
+
const auditsDir = path.join(projectsDir, entry.name, 'audits');
|
|
445
|
+
try {
|
|
446
|
+
await fs.access(auditsDir);
|
|
447
|
+
dirs.push(auditsDir);
|
|
448
|
+
}
|
|
449
|
+
catch {
|
|
450
|
+
// No tiene audits/
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return dirs;
|
|
455
|
+
}
|
|
456
|
+
catch {
|
|
457
|
+
return [];
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
exports.HistoricalLoader = HistoricalLoader;
|
|
462
|
+
//# sourceMappingURL=historical-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"historical-loader.js","sourceRoot":"","sources":["../../../src/pipeline/reflection/historical-loader.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,uCAAyB;AACzB,gDAAkC;AAElC,4DAAiG;AAGjG,4DAA8D;AAE9D,gFAAgF;AAEhF,MAAM,iBAAiB,GAAG,4GAA4G,CAAC;AAEvI,MAAM,YAAY,GAA2D;IAC3E,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU;IAC3F,MAAM,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,EAAU,M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AI,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;QAEpE,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;YACvE,MAAM,IAAI,GAAsB,EAAE,CAAC;YAEnC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;oBACxB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;oBAC/D,IAAI,CAAC;wBACH,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;wBAC3B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBACvB,CAAC;oBAAC,MAAM,CAAC;wBACP,mBAAmB;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAtaD,4CAsaC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description AgentHook — Puente entre el evaluator de agentes y el ReflectionEngine.
|
|
3
|
+
*
|
|
4
|
+
* Captura incidentes de comportamiento de agentes (selección incorrecta,
|
|
5
|
+
* alucinaciones, timeouts, herramientas fallidas) y los reporta
|
|
6
|
+
* al ReflectionEngine para detección de patrones.
|
|
7
|
+
*
|
|
8
|
+
* Se integra en el ResponseEvaluator (evaluator.ts) y en el Agent Loop (loop.ts).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const hook = new AgentHook(engine);
|
|
13
|
+
* await hook.reportAgentFailure('wrong_agent_selected', 'Se seleccionó agente general para tarea de seguridad');
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import { ReflectionEngine } from '@backendkit-labs/agent-core';
|
|
17
|
+
import { FailureRecord, ReflectionDomain, FailureType } from '@backendkit-labs/agent-core';
|
|
18
|
+
export declare class AgentHook {
|
|
19
|
+
private engine;
|
|
20
|
+
constructor(engine: ReflectionEngine);
|
|
21
|
+
/**
|
|
22
|
+
* @description Reporta un incidente de comportamiento de agente.
|
|
23
|
+
*
|
|
24
|
+
* @param failureType - Tipo de fallo (opcional, se auto-detecta)
|
|
25
|
+
* @param hallazgo - Descripción del incidente
|
|
26
|
+
* @param agenteResponsable - Nombre del agente involucrado
|
|
27
|
+
* @param archivos - Archivos relacionados
|
|
28
|
+
* @param domain - Dominio del Reflection Engine (default: "agent")
|
|
29
|
+
* @returns El FailureRecord creado y los patrones detectados
|
|
30
|
+
*/
|
|
31
|
+
reportAgentFailure(hallazgo: string, agenteResponsable: string, archivos?: string[], failureType?: FailureType, domain?: ReflectionDomain): Promise<{
|
|
32
|
+
record: FailureRecord;
|
|
33
|
+
patterns: import('@backendkit-labs/agent-core').DetectedPattern[];
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* @description Reporta una alucinación detectada por el evaluator.
|
|
37
|
+
*/
|
|
38
|
+
reportHallucination(agente: string, respuestaOriginal: string, detalle: string): Promise<{
|
|
39
|
+
record: FailureRecord;
|
|
40
|
+
patterns: import('@backendkit-labs/agent-core').DetectedPattern[];
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* @description Reporta un timeout de agente.
|
|
44
|
+
*/
|
|
45
|
+
reportTimeout(agente: string, taskDescription: string): Promise<{
|
|
46
|
+
record: FailureRecord;
|
|
47
|
+
patterns: import('@backendkit-labs/agent-core').DetectedPattern[];
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* @description Reporta una selección incorrecta de agente.
|
|
51
|
+
*/
|
|
52
|
+
reportWrongAgentSelection(agenteSeleccionado: string, dominioRequerido: string): Promise<{
|
|
53
|
+
record: FailureRecord;
|
|
54
|
+
patterns: import('@backendkit-labs/agent-core').DetectedPattern[];
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* @description Ejecuta una reflexión completa del dominio agent.
|
|
58
|
+
*/
|
|
59
|
+
reflectAgentDomain(): Promise<{
|
|
60
|
+
patterns: import('@backendkit-labs/agent-core').DetectedPattern[];
|
|
61
|
+
promotedRules: import('@backendkit-labs/agent-core').ManifestPolicyRule[];
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* @description Obtiene estadísticas de incidentes del dominio agent.
|
|
65
|
+
*/
|
|
66
|
+
getAgentStats(): Promise<{
|
|
67
|
+
totalIncidents: number;
|
|
68
|
+
unresolvedCount: number;
|
|
69
|
+
patternsByFailureType: Record<string, number>;
|
|
70
|
+
}>;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=agent-hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-hook.d.ts","sourceRoot":"","sources":["../../../../src/pipeline/reflection/hooks/agent-hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAK3F,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAmB;gBAErB,MAAM,EAAE,gBAAgB;IAIpC;;;;;;;;;OASG;IACG,kBAAkB,CACtB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,MAAM,EACzB,QAAQ,GAAE,MAAM,EAAO,EACvB,WAAW,CAAC,EAAE,WAAW,EACzB,MAAM,GAAE,gBAA0B,GACjC,OAAO,CAAC;QACT,MAAM,EAAE,aAAa,CAAC;QACtB,QAAQ,EAAE,OAAO,6BAA6B,EAAE,eAAe,EAAE,CAAC;KACnE,CAAC;IAqBF;;OAEG;IACG,mBAAmB,CACvB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,MAAM,EACzB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;QACT,MAAM,EAAE,aAAa,CAAC;QACtB,QAAQ,EAAE,OAAO,6BAA6B,EAAE,eAAe,EAAE,CAAC;KACnE,CAAC;IASF;;OAEG;IACG,aAAa,CACjB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC;QACT,MAAM,EAAE,aAAa,CAAC;QACtB,QAAQ,EAAE,OAAO,6BAA6B,EAAE,eAAe,EAAE,CAAC;KACnE,CAAC;IASF;;OAEG;IACG,yBAAyB,CAC7B,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC;QACT,MAAM,EAAE,aAAa,CAAC;QACtB,QAAQ,EAAE,OAAO,6BAA6B,EAAE,eAAe,EAAE,CAAC;KACnE,CAAC;IASF;;OAEG;IACG,kBAAkB,IAAI,OAAO,CAAC;QAClC,QAAQ,EAAE,OAAO,6BAA6B,EAAE,eAAe,EAAE,CAAC;QAClE,aAAa,EAAE,OAAO,6BAA6B,EAAE,kBAAkB,EAAE,CAAC;KAC3E,CAAC;IAIF;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC;QAC7B,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;QACxB,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC/C,CAAC;CAiBH"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @description AgentHook — Puente entre el evaluator de agentes y el ReflectionEngine.
|
|
4
|
+
*
|
|
5
|
+
* Captura incidentes de comportamiento de agentes (selección incorrecta,
|
|
6
|
+
* alucinaciones, timeouts, herramientas fallidas) y los reporta
|
|
7
|
+
* al ReflectionEngine para detección de patrones.
|
|
8
|
+
*
|
|
9
|
+
* Se integra en el ResponseEvaluator (evaluator.ts) y en el Agent Loop (loop.ts).
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const hook = new AgentHook(engine);
|
|
14
|
+
* await hook.reportAgentFailure('wrong_agent_selected', 'Se seleccionó agente general para tarea de seguridad');
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AgentHook = void 0;
|
|
19
|
+
const agent_domain_1 = require("../domains/agent-domain");
|
|
20
|
+
// ── AgentHook ────────────────────────────────────────────────────────────────
|
|
21
|
+
class AgentHook {
|
|
22
|
+
engine;
|
|
23
|
+
constructor(engine) {
|
|
24
|
+
this.engine = engine;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @description Reporta un incidente de comportamiento de agente.
|
|
28
|
+
*
|
|
29
|
+
* @param failureType - Tipo de fallo (opcional, se auto-detecta)
|
|
30
|
+
* @param hallazgo - Descripción del incidente
|
|
31
|
+
* @param agenteResponsable - Nombre del agente involucrado
|
|
32
|
+
* @param archivos - Archivos relacionados
|
|
33
|
+
* @param domain - Dominio del Reflection Engine (default: "agent")
|
|
34
|
+
* @returns El FailureRecord creado y los patrones detectados
|
|
35
|
+
*/
|
|
36
|
+
async reportAgentFailure(hallazgo, agenteResponsable, archivos = [], failureType, domain = 'agent') {
|
|
37
|
+
const detectedType = failureType ?? (0, agent_domain_1.detectAgentFailureType)(hallazgo);
|
|
38
|
+
const meta = (0, agent_domain_1.getAgentFailureTypeMeta)(detectedType);
|
|
39
|
+
const record = {
|
|
40
|
+
domain,
|
|
41
|
+
failureType: detectedType,
|
|
42
|
+
severity: meta?.severity ?? 'medium',
|
|
43
|
+
dimension: meta?.dimension ?? 'confiabilidad',
|
|
44
|
+
gate: 'agent-loop',
|
|
45
|
+
agenteResponsable,
|
|
46
|
+
hallazgo,
|
|
47
|
+
recomendacion: meta?.genericRecommendation ?? 'Revisar el comportamiento del agente y ajustar el contexto o perfil',
|
|
48
|
+
archivos,
|
|
49
|
+
fecha: new Date().toISOString(),
|
|
50
|
+
};
|
|
51
|
+
const result = await this.engine.reportIncident(record);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @description Reporta una alucinación detectada por el evaluator.
|
|
56
|
+
*/
|
|
57
|
+
async reportHallucination(agente, respuestaOriginal, detalle) {
|
|
58
|
+
return this.reportAgentFailure(`agent_hallucination (${agente}): ${detalle} — Respuesta: "${respuestaOriginal.substring(0, 200)}..."`, agente, [], 'agent_hallucination');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @description Reporta un timeout de agente.
|
|
62
|
+
*/
|
|
63
|
+
async reportTimeout(agente, taskDescription) {
|
|
64
|
+
return this.reportAgentFailure(`agent_timeout: "${agente}" excedió el tiempo límite procesando: "${taskDescription}"`, agente, [], 'agent_timeout');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @description Reporta una selección incorrecta de agente.
|
|
68
|
+
*/
|
|
69
|
+
async reportWrongAgentSelection(agenteSeleccionado, dominioRequerido) {
|
|
70
|
+
return this.reportAgentFailure(`wrong_agent_selected: Se seleccionó "${agenteSeleccionado}" para dominio "${dominioRequerido}"`, agenteSeleccionado, [], 'wrong_agent_selected');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @description Ejecuta una reflexión completa del dominio agent.
|
|
74
|
+
*/
|
|
75
|
+
async reflectAgentDomain() {
|
|
76
|
+
return this.engine.reflect({ domain: 'agent', autoPromote: true });
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @description Obtiene estadísticas de incidentes del dominio agent.
|
|
80
|
+
*/
|
|
81
|
+
async getAgentStats() {
|
|
82
|
+
const stats = await this.engine.getStats();
|
|
83
|
+
const catalog = this.engine.getCatalog();
|
|
84
|
+
const agentRecords = await catalog.findByDomain('agent');
|
|
85
|
+
const unresolved = await catalog.findUnresolved();
|
|
86
|
+
const patternsByFailureType = {};
|
|
87
|
+
for (const record of agentRecords) {
|
|
88
|
+
patternsByFailureType[record.failureType] = (patternsByFailureType[record.failureType] ?? 0) + 1;
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
totalIncidents: stats.totalIncidents,
|
|
92
|
+
unresolvedCount: unresolved.length,
|
|
93
|
+
patternsByFailureType,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.AgentHook = AgentHook;
|
|
98
|
+
//# sourceMappingURL=agent-hook.js.map
|