@claude-flow/shared 3.0.0-alpha.1
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/.agentic-flow/intelligence.json +16 -0
- package/README.md +323 -0
- package/__tests__/coverage/base.css +224 -0
- package/__tests__/coverage/block-navigation.js +87 -0
- package/__tests__/coverage/coverage-final.json +50 -0
- package/__tests__/coverage/favicon.png +0 -0
- package/__tests__/coverage/index.html +326 -0
- package/__tests__/coverage/lcov-report/base.css +224 -0
- package/__tests__/coverage/lcov-report/block-navigation.js +87 -0
- package/__tests__/coverage/lcov-report/favicon.png +0 -0
- package/__tests__/coverage/lcov-report/index.html +326 -0
- package/__tests__/coverage/lcov-report/prettify.css +1 -0
- package/__tests__/coverage/lcov-report/prettify.js +2 -0
- package/__tests__/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/__tests__/coverage/lcov-report/sorter.js +210 -0
- package/__tests__/coverage/lcov-report/src/core/config/defaults.ts.html +706 -0
- package/__tests__/coverage/lcov-report/src/core/config/index.html +161 -0
- package/__tests__/coverage/lcov-report/src/core/config/loader.ts.html +898 -0
- package/__tests__/coverage/lcov-report/src/core/config/schema.ts.html +649 -0
- package/__tests__/coverage/lcov-report/src/core/config/validator.ts.html +712 -0
- package/__tests__/coverage/lcov-report/src/core/event-bus.ts.html +793 -0
- package/__tests__/coverage/lcov-report/src/core/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/core/interfaces/event.interface.ts.html +886 -0
- package/__tests__/coverage/lcov-report/src/core/interfaces/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/event-coordinator.ts.html +451 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/health-monitor.ts.html +727 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/index.html +176 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/lifecycle-manager.ts.html +874 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/session-manager.ts.html +922 -0
- package/__tests__/coverage/lcov-report/src/core/orchestrator/task-manager.ts.html +1036 -0
- package/__tests__/coverage/lcov-report/src/events/domain-events.ts.html +1837 -0
- package/__tests__/coverage/lcov-report/src/events/event-store.ts.html +1849 -0
- package/__tests__/coverage/lcov-report/src/events/example-usage.ts.html +964 -0
- package/__tests__/coverage/lcov-report/src/events/index.html +176 -0
- package/__tests__/coverage/lcov-report/src/events/projections.ts.html +1768 -0
- package/__tests__/coverage/lcov-report/src/events/state-reconstructor.ts.html +1132 -0
- package/__tests__/coverage/lcov-report/src/events.ts.html +1186 -0
- package/__tests__/coverage/lcov-report/src/hooks/example-usage.ts.html +1582 -0
- package/__tests__/coverage/lcov-report/src/hooks/executor.ts.html +1222 -0
- package/__tests__/coverage/lcov-report/src/hooks/index.html +191 -0
- package/__tests__/coverage/lcov-report/src/hooks/registry.ts.html +1084 -0
- package/__tests__/coverage/lcov-report/src/hooks/safety/bash-safety.ts.html +1897 -0
- package/__tests__/coverage/lcov-report/src/hooks/safety/file-organization.ts.html +1504 -0
- package/__tests__/coverage/lcov-report/src/hooks/safety/git-commit.ts.html +1954 -0
- package/__tests__/coverage/lcov-report/src/hooks/safety/index.html +146 -0
- package/__tests__/coverage/lcov-report/src/hooks/session-hooks.ts.html +1762 -0
- package/__tests__/coverage/lcov-report/src/hooks/task-hooks.ts.html +1624 -0
- package/__tests__/coverage/lcov-report/src/hooks/types.ts.html +1156 -0
- package/__tests__/coverage/lcov-report/src/index.html +176 -0
- package/__tests__/coverage/lcov-report/src/mcp/connection-pool.ts.html +1399 -0
- package/__tests__/coverage/lcov-report/src/mcp/index.html +176 -0
- package/__tests__/coverage/lcov-report/src/mcp/server.ts.html +2407 -0
- package/__tests__/coverage/lcov-report/src/mcp/session-manager.ts.html +1369 -0
- package/__tests__/coverage/lcov-report/src/mcp/tool-registry.ts.html +1783 -0
- package/__tests__/coverage/lcov-report/src/mcp/transport/http.ts.html +1756 -0
- package/__tests__/coverage/lcov-report/src/mcp/transport/index.html +146 -0
- package/__tests__/coverage/lcov-report/src/mcp/transport/stdio.ts.html +1057 -0
- package/__tests__/coverage/lcov-report/src/mcp/transport/websocket.ts.html +1537 -0
- package/__tests__/coverage/lcov-report/src/mcp/types.ts.html +1780 -0
- package/__tests__/coverage/lcov-report/src/plugin-interface.ts.html +2074 -0
- package/__tests__/coverage/lcov-report/src/plugin-loader.ts.html +1999 -0
- package/__tests__/coverage/lcov-report/src/plugin-registry.ts.html +1897 -0
- package/__tests__/coverage/lcov-report/src/plugins/official/hive-mind-plugin.ts.html +1075 -0
- package/__tests__/coverage/lcov-report/src/plugins/official/index.html +131 -0
- package/__tests__/coverage/lcov-report/src/plugins/official/maestro-plugin.ts.html +1609 -0
- package/__tests__/coverage/lcov-report/src/resilience/bulkhead.ts.html +916 -0
- package/__tests__/coverage/lcov-report/src/resilience/circuit-breaker.ts.html +1063 -0
- package/__tests__/coverage/lcov-report/src/resilience/index.html +161 -0
- package/__tests__/coverage/lcov-report/src/resilience/rate-limiter.ts.html +1345 -0
- package/__tests__/coverage/lcov-report/src/resilience/retry.ts.html +757 -0
- package/__tests__/coverage/lcov-report/src/security/index.html +131 -0
- package/__tests__/coverage/lcov-report/src/security/input-validation.ts.html +880 -0
- package/__tests__/coverage/lcov-report/src/security/secure-random.ts.html +562 -0
- package/__tests__/coverage/lcov-report/src/types/index.html +131 -0
- package/__tests__/coverage/lcov-report/src/types/swarm.types.ts.html +850 -0
- package/__tests__/coverage/lcov-report/src/types/task.types.ts.html +700 -0
- package/__tests__/coverage/lcov-report/src/types.ts.html +1186 -0
- package/__tests__/coverage/lcov-report/src/utils/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/utils/secure-logger.ts.html +856 -0
- package/__tests__/coverage/lcov.info +19877 -0
- package/__tests__/coverage/prettify.css +1 -0
- package/__tests__/coverage/prettify.js +2 -0
- package/__tests__/coverage/sort-arrow-sprite.png +0 -0
- package/__tests__/coverage/sorter.js +210 -0
- package/__tests__/coverage/src/core/config/defaults.ts.html +706 -0
- package/__tests__/coverage/src/core/config/index.html +161 -0
- package/__tests__/coverage/src/core/config/loader.ts.html +898 -0
- package/__tests__/coverage/src/core/config/schema.ts.html +649 -0
- package/__tests__/coverage/src/core/config/validator.ts.html +712 -0
- package/__tests__/coverage/src/core/event-bus.ts.html +793 -0
- package/__tests__/coverage/src/core/index.html +116 -0
- package/__tests__/coverage/src/core/interfaces/event.interface.ts.html +886 -0
- package/__tests__/coverage/src/core/interfaces/index.html +116 -0
- package/__tests__/coverage/src/core/orchestrator/event-coordinator.ts.html +451 -0
- package/__tests__/coverage/src/core/orchestrator/health-monitor.ts.html +727 -0
- package/__tests__/coverage/src/core/orchestrator/index.html +176 -0
- package/__tests__/coverage/src/core/orchestrator/lifecycle-manager.ts.html +874 -0
- package/__tests__/coverage/src/core/orchestrator/session-manager.ts.html +922 -0
- package/__tests__/coverage/src/core/orchestrator/task-manager.ts.html +1036 -0
- package/__tests__/coverage/src/events/domain-events.ts.html +1837 -0
- package/__tests__/coverage/src/events/event-store.ts.html +1849 -0
- package/__tests__/coverage/src/events/example-usage.ts.html +964 -0
- package/__tests__/coverage/src/events/index.html +176 -0
- package/__tests__/coverage/src/events/projections.ts.html +1768 -0
- package/__tests__/coverage/src/events/state-reconstructor.ts.html +1132 -0
- package/__tests__/coverage/src/events.ts.html +1186 -0
- package/__tests__/coverage/src/hooks/example-usage.ts.html +1582 -0
- package/__tests__/coverage/src/hooks/executor.ts.html +1222 -0
- package/__tests__/coverage/src/hooks/index.html +191 -0
- package/__tests__/coverage/src/hooks/registry.ts.html +1084 -0
- package/__tests__/coverage/src/hooks/safety/bash-safety.ts.html +1897 -0
- package/__tests__/coverage/src/hooks/safety/file-organization.ts.html +1504 -0
- package/__tests__/coverage/src/hooks/safety/git-commit.ts.html +1954 -0
- package/__tests__/coverage/src/hooks/safety/index.html +146 -0
- package/__tests__/coverage/src/hooks/session-hooks.ts.html +1762 -0
- package/__tests__/coverage/src/hooks/task-hooks.ts.html +1624 -0
- package/__tests__/coverage/src/hooks/types.ts.html +1156 -0
- package/__tests__/coverage/src/index.html +176 -0
- package/__tests__/coverage/src/mcp/connection-pool.ts.html +1399 -0
- package/__tests__/coverage/src/mcp/index.html +176 -0
- package/__tests__/coverage/src/mcp/server.ts.html +2407 -0
- package/__tests__/coverage/src/mcp/session-manager.ts.html +1369 -0
- package/__tests__/coverage/src/mcp/tool-registry.ts.html +1783 -0
- package/__tests__/coverage/src/mcp/transport/http.ts.html +1756 -0
- package/__tests__/coverage/src/mcp/transport/index.html +146 -0
- package/__tests__/coverage/src/mcp/transport/stdio.ts.html +1057 -0
- package/__tests__/coverage/src/mcp/transport/websocket.ts.html +1537 -0
- package/__tests__/coverage/src/mcp/types.ts.html +1780 -0
- package/__tests__/coverage/src/plugin-interface.ts.html +2074 -0
- package/__tests__/coverage/src/plugin-loader.ts.html +1999 -0
- package/__tests__/coverage/src/plugin-registry.ts.html +1897 -0
- package/__tests__/coverage/src/plugins/official/hive-mind-plugin.ts.html +1075 -0
- package/__tests__/coverage/src/plugins/official/index.html +131 -0
- package/__tests__/coverage/src/plugins/official/maestro-plugin.ts.html +1609 -0
- package/__tests__/coverage/src/resilience/bulkhead.ts.html +916 -0
- package/__tests__/coverage/src/resilience/circuit-breaker.ts.html +1063 -0
- package/__tests__/coverage/src/resilience/index.html +161 -0
- package/__tests__/coverage/src/resilience/rate-limiter.ts.html +1345 -0
- package/__tests__/coverage/src/resilience/retry.ts.html +757 -0
- package/__tests__/coverage/src/security/index.html +131 -0
- package/__tests__/coverage/src/security/input-validation.ts.html +880 -0
- package/__tests__/coverage/src/security/secure-random.ts.html +562 -0
- package/__tests__/coverage/src/types/index.html +131 -0
- package/__tests__/coverage/src/types/swarm.types.ts.html +850 -0
- package/__tests__/coverage/src/types/task.types.ts.html +700 -0
- package/__tests__/coverage/src/types.ts.html +1186 -0
- package/__tests__/coverage/src/utils/index.html +116 -0
- package/__tests__/coverage/src/utils/secure-logger.ts.html +856 -0
- package/__tests__/hooks/bash-safety.test.ts +289 -0
- package/__tests__/hooks/file-organization.test.ts +335 -0
- package/__tests__/hooks/git-commit.test.ts +336 -0
- package/__tests__/hooks/index.ts +23 -0
- package/__tests__/hooks/session-hooks.test.ts +357 -0
- package/__tests__/hooks/task-hooks.test.ts +193 -0
- package/dist/core/config/defaults.d.ts +41 -0
- package/dist/core/config/defaults.d.ts.map +1 -0
- package/dist/core/config/defaults.js +186 -0
- package/dist/core/config/defaults.js.map +1 -0
- package/dist/core/config/index.d.ts +8 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +12 -0
- package/dist/core/config/index.js.map +1 -0
- package/dist/core/config/loader.d.ts +45 -0
- package/dist/core/config/loader.d.ts.map +1 -0
- package/dist/core/config/loader.js +222 -0
- package/dist/core/config/loader.js.map +1 -0
- package/dist/core/config/schema.d.ts +1134 -0
- package/dist/core/config/schema.d.ts.map +1 -0
- package/dist/core/config/schema.js +158 -0
- package/dist/core/config/schema.js.map +1 -0
- package/dist/core/config/validator.d.ts +92 -0
- package/dist/core/config/validator.d.ts.map +1 -0
- package/dist/core/config/validator.js +147 -0
- package/dist/core/config/validator.js.map +1 -0
- package/dist/core/event-bus.d.ts +31 -0
- package/dist/core/event-bus.d.ts.map +1 -0
- package/dist/core/event-bus.js +197 -0
- package/dist/core/event-bus.js.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +19 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/interfaces/agent.interface.d.ts +200 -0
- package/dist/core/interfaces/agent.interface.d.ts.map +1 -0
- package/dist/core/interfaces/agent.interface.js +6 -0
- package/dist/core/interfaces/agent.interface.js.map +1 -0
- package/dist/core/interfaces/coordinator.interface.d.ts +310 -0
- package/dist/core/interfaces/coordinator.interface.d.ts.map +1 -0
- package/dist/core/interfaces/coordinator.interface.js +7 -0
- package/dist/core/interfaces/coordinator.interface.js.map +1 -0
- package/dist/core/interfaces/event.interface.d.ts +224 -0
- package/dist/core/interfaces/event.interface.d.ts.map +1 -0
- package/dist/core/interfaces/event.interface.js +46 -0
- package/dist/core/interfaces/event.interface.js.map +1 -0
- package/dist/core/interfaces/index.d.ts +10 -0
- package/dist/core/interfaces/index.d.ts.map +1 -0
- package/dist/core/interfaces/index.js +15 -0
- package/dist/core/interfaces/index.js.map +1 -0
- package/dist/core/interfaces/memory.interface.d.ts +298 -0
- package/dist/core/interfaces/memory.interface.d.ts.map +1 -0
- package/dist/core/interfaces/memory.interface.js +7 -0
- package/dist/core/interfaces/memory.interface.js.map +1 -0
- package/dist/core/interfaces/task.interface.d.ts +185 -0
- package/dist/core/interfaces/task.interface.d.ts.map +1 -0
- package/dist/core/interfaces/task.interface.js +6 -0
- package/dist/core/interfaces/task.interface.js.map +1 -0
- package/dist/core/orchestrator/event-coordinator.d.ts +35 -0
- package/dist/core/orchestrator/event-coordinator.d.ts.map +1 -0
- package/dist/core/orchestrator/event-coordinator.js +101 -0
- package/dist/core/orchestrator/event-coordinator.js.map +1 -0
- package/dist/core/orchestrator/health-monitor.d.ts +60 -0
- package/dist/core/orchestrator/health-monitor.d.ts.map +1 -0
- package/dist/core/orchestrator/health-monitor.js +166 -0
- package/dist/core/orchestrator/health-monitor.js.map +1 -0
- package/dist/core/orchestrator/index.d.ts +46 -0
- package/dist/core/orchestrator/index.d.ts.map +1 -0
- package/dist/core/orchestrator/index.js +64 -0
- package/dist/core/orchestrator/index.js.map +1 -0
- package/dist/core/orchestrator/lifecycle-manager.d.ts +56 -0
- package/dist/core/orchestrator/lifecycle-manager.d.ts.map +1 -0
- package/dist/core/orchestrator/lifecycle-manager.js +195 -0
- package/dist/core/orchestrator/lifecycle-manager.js.map +1 -0
- package/dist/core/orchestrator/session-manager.d.ts +83 -0
- package/dist/core/orchestrator/session-manager.d.ts.map +1 -0
- package/dist/core/orchestrator/session-manager.js +193 -0
- package/dist/core/orchestrator/session-manager.js.map +1 -0
- package/dist/core/orchestrator/task-manager.d.ts +49 -0
- package/dist/core/orchestrator/task-manager.d.ts.map +1 -0
- package/dist/core/orchestrator/task-manager.js +253 -0
- package/dist/core/orchestrator/task-manager.js.map +1 -0
- package/dist/events/domain-events.d.ts +282 -0
- package/dist/events/domain-events.d.ts.map +1 -0
- package/dist/events/domain-events.js +165 -0
- package/dist/events/domain-events.js.map +1 -0
- package/dist/events/event-store.d.ts +126 -0
- package/dist/events/event-store.d.ts.map +1 -0
- package/dist/events/event-store.js +416 -0
- package/dist/events/event-store.js.map +1 -0
- package/dist/events/event-store.test.d.ts +8 -0
- package/dist/events/event-store.test.d.ts.map +1 -0
- package/dist/events/event-store.test.js +293 -0
- package/dist/events/event-store.test.js.map +1 -0
- package/dist/events/example-usage.d.ts +10 -0
- package/dist/events/example-usage.d.ts.map +1 -0
- package/dist/events/example-usage.js +193 -0
- package/dist/events/example-usage.js.map +1 -0
- package/dist/events/index.d.ts +19 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +20 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/projections.d.ts +177 -0
- package/dist/events/projections.d.ts.map +1 -0
- package/dist/events/projections.js +421 -0
- package/dist/events/projections.js.map +1 -0
- package/dist/events/state-reconstructor.d.ts +101 -0
- package/dist/events/state-reconstructor.d.ts.map +1 -0
- package/dist/events/state-reconstructor.js +263 -0
- package/dist/events/state-reconstructor.js.map +1 -0
- package/dist/events.d.ts +80 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +249 -0
- package/dist/events.js.map +1 -0
- package/dist/hooks/example-usage.d.ts +42 -0
- package/dist/hooks/example-usage.d.ts.map +1 -0
- package/dist/hooks/example-usage.js +351 -0
- package/dist/hooks/example-usage.js.map +1 -0
- package/dist/hooks/executor.d.ts +100 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +264 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/hooks.test.d.ts +9 -0
- package/dist/hooks/hooks.test.d.ts.map +1 -0
- package/dist/hooks/hooks.test.js +322 -0
- package/dist/hooks/hooks.test.js.map +1 -0
- package/dist/hooks/index.d.ts +52 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +51 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/registry.d.ts +133 -0
- package/dist/hooks/registry.d.ts.map +1 -0
- package/dist/hooks/registry.js +277 -0
- package/dist/hooks/registry.js.map +1 -0
- package/dist/hooks/safety/bash-safety.d.ts +105 -0
- package/dist/hooks/safety/bash-safety.d.ts.map +1 -0
- package/dist/hooks/safety/bash-safety.js +481 -0
- package/dist/hooks/safety/bash-safety.js.map +1 -0
- package/dist/hooks/safety/file-organization.d.ts +144 -0
- package/dist/hooks/safety/file-organization.d.ts.map +1 -0
- package/dist/hooks/safety/file-organization.js +328 -0
- package/dist/hooks/safety/file-organization.js.map +1 -0
- package/dist/hooks/safety/git-commit.d.ts +158 -0
- package/dist/hooks/safety/git-commit.d.ts.map +1 -0
- package/dist/hooks/safety/git-commit.js +450 -0
- package/dist/hooks/safety/git-commit.js.map +1 -0
- package/dist/hooks/safety/index.d.ts +17 -0
- package/dist/hooks/safety/index.d.ts.map +1 -0
- package/dist/hooks/safety/index.js +17 -0
- package/dist/hooks/safety/index.js.map +1 -0
- package/dist/hooks/session-hooks.d.ts +234 -0
- package/dist/hooks/session-hooks.d.ts.map +1 -0
- package/dist/hooks/session-hooks.js +334 -0
- package/dist/hooks/session-hooks.js.map +1 -0
- package/dist/hooks/task-hooks.d.ts +163 -0
- package/dist/hooks/task-hooks.d.ts.map +1 -0
- package/dist/hooks/task-hooks.js +326 -0
- package/dist/hooks/task-hooks.js.map +1 -0
- package/dist/hooks/types.d.ts +267 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +62 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/hooks/verify-exports.test.d.ts +9 -0
- package/dist/hooks/verify-exports.test.d.ts.map +1 -0
- package/dist/hooks/verify-exports.test.js +93 -0
- package/dist/hooks/verify-exports.test.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/connection-pool.d.ts +98 -0
- package/dist/mcp/connection-pool.d.ts.map +1 -0
- package/dist/mcp/connection-pool.js +364 -0
- package/dist/mcp/connection-pool.js.map +1 -0
- package/dist/mcp/index.d.ts +69 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +84 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +166 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +593 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/session-manager.d.ts +136 -0
- package/dist/mcp/session-manager.d.ts.map +1 -0
- package/dist/mcp/session-manager.js +335 -0
- package/dist/mcp/session-manager.js.map +1 -0
- package/dist/mcp/tool-registry.d.ts +178 -0
- package/dist/mcp/tool-registry.d.ts.map +1 -0
- package/dist/mcp/tool-registry.js +439 -0
- package/dist/mcp/tool-registry.js.map +1 -0
- package/dist/mcp/transport/http.d.ts +104 -0
- package/dist/mcp/transport/http.d.ts.map +1 -0
- package/dist/mcp/transport/http.js +476 -0
- package/dist/mcp/transport/http.js.map +1 -0
- package/dist/mcp/transport/index.d.ts +102 -0
- package/dist/mcp/transport/index.d.ts.map +1 -0
- package/dist/mcp/transport/index.js +238 -0
- package/dist/mcp/transport/index.js.map +1 -0
- package/dist/mcp/transport/stdio.d.ts +104 -0
- package/dist/mcp/transport/stdio.d.ts.map +1 -0
- package/dist/mcp/transport/stdio.js +263 -0
- package/dist/mcp/transport/stdio.js.map +1 -0
- package/dist/mcp/transport/websocket.d.ts +133 -0
- package/dist/mcp/transport/websocket.d.ts.map +1 -0
- package/dist/mcp/transport/websocket.js +396 -0
- package/dist/mcp/transport/websocket.js.map +1 -0
- package/dist/mcp/types.d.ts +438 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +54 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/plugin-interface.d.ts +544 -0
- package/dist/plugin-interface.d.ts.map +1 -0
- package/dist/plugin-interface.js +23 -0
- package/dist/plugin-interface.js.map +1 -0
- package/dist/plugin-loader.d.ts +139 -0
- package/dist/plugin-loader.d.ts.map +1 -0
- package/dist/plugin-loader.js +434 -0
- package/dist/plugin-loader.js.map +1 -0
- package/dist/plugin-registry.d.ts +183 -0
- package/dist/plugin-registry.d.ts.map +1 -0
- package/dist/plugin-registry.js +457 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/plugins/index.d.ts +10 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +10 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/official/hive-mind-plugin.d.ts +106 -0
- package/dist/plugins/official/hive-mind-plugin.d.ts.map +1 -0
- package/dist/plugins/official/hive-mind-plugin.js +241 -0
- package/dist/plugins/official/hive-mind-plugin.js.map +1 -0
- package/dist/plugins/official/index.d.ts +10 -0
- package/dist/plugins/official/index.d.ts.map +1 -0
- package/dist/plugins/official/index.js +10 -0
- package/dist/plugins/official/index.js.map +1 -0
- package/dist/plugins/official/maestro-plugin.d.ts +121 -0
- package/dist/plugins/official/maestro-plugin.d.ts.map +1 -0
- package/dist/plugins/official/maestro-plugin.js +355 -0
- package/dist/plugins/official/maestro-plugin.js.map +1 -0
- package/dist/plugins/types.d.ts +93 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +9 -0
- package/dist/plugins/types.js.map +1 -0
- package/dist/resilience/bulkhead.d.ts +105 -0
- package/dist/resilience/bulkhead.d.ts.map +1 -0
- package/dist/resilience/bulkhead.js +206 -0
- package/dist/resilience/bulkhead.js.map +1 -0
- package/dist/resilience/circuit-breaker.d.ts +132 -0
- package/dist/resilience/circuit-breaker.d.ts.map +1 -0
- package/dist/resilience/circuit-breaker.js +233 -0
- package/dist/resilience/circuit-breaker.js.map +1 -0
- package/dist/resilience/index.d.ts +19 -0
- package/dist/resilience/index.d.ts.map +1 -0
- package/dist/resilience/index.js +19 -0
- package/dist/resilience/index.js.map +1 -0
- package/dist/resilience/rate-limiter.d.ts +168 -0
- package/dist/resilience/rate-limiter.d.ts.map +1 -0
- package/dist/resilience/rate-limiter.js +314 -0
- package/dist/resilience/rate-limiter.js.map +1 -0
- package/dist/resilience/retry.d.ts +91 -0
- package/dist/resilience/retry.d.ts.map +1 -0
- package/dist/resilience/retry.js +159 -0
- package/dist/resilience/retry.js.map +1 -0
- package/dist/security/index.d.ts +10 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +12 -0
- package/dist/security/index.js.map +1 -0
- package/dist/security/input-validation.d.ts +73 -0
- package/dist/security/input-validation.d.ts.map +1 -0
- package/dist/security/input-validation.js +201 -0
- package/dist/security/input-validation.js.map +1 -0
- package/dist/security/secure-random.d.ts +92 -0
- package/dist/security/secure-random.d.ts.map +1 -0
- package/dist/security/secure-random.js +142 -0
- package/dist/security/secure-random.js.map +1 -0
- package/dist/types/agent.types.d.ts +137 -0
- package/dist/types/agent.types.d.ts.map +1 -0
- package/dist/types/agent.types.js +6 -0
- package/dist/types/agent.types.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +17 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp.types.d.ts +266 -0
- package/dist/types/mcp.types.d.ts.map +1 -0
- package/dist/types/mcp.types.js +7 -0
- package/dist/types/mcp.types.js.map +1 -0
- package/dist/types/memory.types.d.ts +236 -0
- package/dist/types/memory.types.d.ts.map +1 -0
- package/dist/types/memory.types.js +7 -0
- package/dist/types/memory.types.js.map +1 -0
- package/dist/types/swarm.types.d.ts +186 -0
- package/dist/types/swarm.types.d.ts.map +1 -0
- package/dist/types/swarm.types.js +65 -0
- package/dist/types/swarm.types.js.map +1 -0
- package/dist/types/task.types.d.ts +178 -0
- package/dist/types/task.types.d.ts.map +1 -0
- package/dist/types/task.types.js +32 -0
- package/dist/types/task.types.js.map +1 -0
- package/dist/types.d.ts +197 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +21 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/secure-logger.d.ts +69 -0
- package/dist/utils/secure-logger.d.ts.map +1 -0
- package/dist/utils/secure-logger.js +208 -0
- package/dist/utils/secure-logger.js.map +1 -0
- package/docs/EVENTS_IMPLEMENTATION_SUMMARY.md +388 -0
- package/docs/EVENTS_QUICK_REFERENCE.md +470 -0
- package/docs/EVENTS_README.md +352 -0
- package/package.json +34 -0
- package/src/core/config/defaults.ts +207 -0
- package/src/core/config/index.ts +15 -0
- package/src/core/config/loader.ts +271 -0
- package/src/core/config/schema.ts +188 -0
- package/src/core/config/validator.ts +209 -0
- package/src/core/event-bus.ts +236 -0
- package/src/core/index.ts +22 -0
- package/src/core/interfaces/agent.interface.ts +251 -0
- package/src/core/interfaces/coordinator.interface.ts +363 -0
- package/src/core/interfaces/event.interface.ts +267 -0
- package/src/core/interfaces/index.ts +19 -0
- package/src/core/interfaces/memory.interface.ts +332 -0
- package/src/core/interfaces/task.interface.ts +223 -0
- package/src/core/orchestrator/event-coordinator.ts +122 -0
- package/src/core/orchestrator/health-monitor.ts +214 -0
- package/src/core/orchestrator/index.ts +89 -0
- package/src/core/orchestrator/lifecycle-manager.ts +263 -0
- package/src/core/orchestrator/session-manager.ts +279 -0
- package/src/core/orchestrator/task-manager.ts +317 -0
- package/src/events/domain-events.ts +584 -0
- package/src/events/event-store.test.ts +387 -0
- package/src/events/event-store.ts +588 -0
- package/src/events/example-usage.ts +293 -0
- package/src/events/index.ts +90 -0
- package/src/events/projections.ts +561 -0
- package/src/events/state-reconstructor.ts +349 -0
- package/src/events.ts +367 -0
- package/src/hooks/INTEGRATION.md +658 -0
- package/src/hooks/README.md +532 -0
- package/src/hooks/example-usage.ts +499 -0
- package/src/hooks/executor.ts +379 -0
- package/src/hooks/hooks.test.ts +421 -0
- package/src/hooks/index.ts +131 -0
- package/src/hooks/registry.ts +333 -0
- package/src/hooks/safety/bash-safety.ts +604 -0
- package/src/hooks/safety/file-organization.ts +473 -0
- package/src/hooks/safety/git-commit.ts +623 -0
- package/src/hooks/safety/index.ts +46 -0
- package/src/hooks/session-hooks.ts +559 -0
- package/src/hooks/task-hooks.ts +513 -0
- package/src/hooks/types.ts +357 -0
- package/src/hooks/verify-exports.test.ts +125 -0
- package/src/index.ts +190 -0
- package/src/mcp/connection-pool.ts +438 -0
- package/src/mcp/index.ts +183 -0
- package/src/mcp/server.ts +774 -0
- package/src/mcp/session-manager.ts +428 -0
- package/src/mcp/tool-registry.ts +566 -0
- package/src/mcp/transport/http.ts +557 -0
- package/src/mcp/transport/index.ts +294 -0
- package/src/mcp/transport/stdio.ts +324 -0
- package/src/mcp/transport/websocket.ts +484 -0
- package/src/mcp/types.ts +565 -0
- package/src/plugin-interface.ts +663 -0
- package/src/plugin-loader.ts +638 -0
- package/src/plugin-registry.ts +604 -0
- package/src/plugins/index.ts +34 -0
- package/src/plugins/official/hive-mind-plugin.ts +330 -0
- package/src/plugins/official/index.ts +24 -0
- package/src/plugins/official/maestro-plugin.ts +508 -0
- package/src/plugins/types.ts +108 -0
- package/src/resilience/bulkhead.ts +277 -0
- package/src/resilience/circuit-breaker.ts +326 -0
- package/src/resilience/index.ts +26 -0
- package/src/resilience/rate-limiter.ts +420 -0
- package/src/resilience/retry.ts +224 -0
- package/src/security/index.ts +39 -0
- package/src/security/input-validation.ts +265 -0
- package/src/security/secure-random.ts +159 -0
- package/src/types/agent.types.ts +144 -0
- package/src/types/index.ts +22 -0
- package/src/types/mcp.types.ts +300 -0
- package/src/types/memory.types.ts +263 -0
- package/src/types/swarm.types.ts +255 -0
- package/src/types/task.types.ts +205 -0
- package/src/types.ts +367 -0
- package/src/utils/secure-logger.d.ts +69 -0
- package/src/utils/secure-logger.d.ts.map +1 -0
- package/src/utils/secure-logger.js +208 -0
- package/src/utils/secure-logger.js.map +1 -0
- package/src/utils/secure-logger.ts +257 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Health Monitor
|
|
3
|
+
* Decomposed from orchestrator.ts - Agent health checks
|
|
4
|
+
* ~150 lines (target achieved)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
IHealthMonitor,
|
|
9
|
+
IHealthStatus,
|
|
10
|
+
IComponentHealth,
|
|
11
|
+
} from '../interfaces/coordinator.interface.js';
|
|
12
|
+
import type { IEventBus } from '../interfaces/event.interface.js';
|
|
13
|
+
import { SystemEventTypes } from '../interfaces/event.interface.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Health check function type
|
|
17
|
+
*/
|
|
18
|
+
export type HealthCheckFn = () => Promise<{
|
|
19
|
+
healthy: boolean;
|
|
20
|
+
error?: string;
|
|
21
|
+
metrics?: Record<string, number>;
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Health monitor configuration
|
|
26
|
+
*/
|
|
27
|
+
export interface HealthMonitorConfig {
|
|
28
|
+
checkInterval: number;
|
|
29
|
+
historyLimit: number;
|
|
30
|
+
degradedThreshold: number;
|
|
31
|
+
unhealthyThreshold: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Health monitor implementation
|
|
36
|
+
*/
|
|
37
|
+
export class HealthMonitor implements IHealthMonitor {
|
|
38
|
+
private checks = new Map<string, HealthCheckFn>();
|
|
39
|
+
private history: IHealthStatus[] = [];
|
|
40
|
+
private interval?: ReturnType<typeof setInterval>;
|
|
41
|
+
private listeners: Array<(status: IHealthStatus) => void> = [];
|
|
42
|
+
private running = false;
|
|
43
|
+
|
|
44
|
+
constructor(
|
|
45
|
+
private eventBus: IEventBus,
|
|
46
|
+
private config: HealthMonitorConfig = {
|
|
47
|
+
checkInterval: 30000,
|
|
48
|
+
historyLimit: 100,
|
|
49
|
+
degradedThreshold: 1,
|
|
50
|
+
unhealthyThreshold: 2,
|
|
51
|
+
},
|
|
52
|
+
) {}
|
|
53
|
+
|
|
54
|
+
start(): void {
|
|
55
|
+
if (this.running) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this.running = true;
|
|
60
|
+
this.interval = setInterval(async () => {
|
|
61
|
+
const status = await this.getStatus();
|
|
62
|
+
this.addToHistory(status);
|
|
63
|
+
this.notifyListeners(status);
|
|
64
|
+
this.eventBus.emit(SystemEventTypes.SYSTEM_HEALTHCHECK, { status });
|
|
65
|
+
}, this.config.checkInterval);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
stop(): void {
|
|
69
|
+
if (this.interval) {
|
|
70
|
+
clearInterval(this.interval);
|
|
71
|
+
this.interval = undefined;
|
|
72
|
+
}
|
|
73
|
+
this.running = false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async getStatus(): Promise<IHealthStatus> {
|
|
77
|
+
const components: Record<string, IComponentHealth> = {};
|
|
78
|
+
let unhealthyCount = 0;
|
|
79
|
+
let degradedCount = 0;
|
|
80
|
+
|
|
81
|
+
const checkPromises = Array.from(this.checks.entries()).map(
|
|
82
|
+
async ([name, check]) => {
|
|
83
|
+
try {
|
|
84
|
+
const result = await Promise.race([
|
|
85
|
+
check(),
|
|
86
|
+
this.timeout(5000, 'Health check timeout'),
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
const health: IComponentHealth = {
|
|
90
|
+
name,
|
|
91
|
+
status: result.healthy ? 'healthy' : 'unhealthy',
|
|
92
|
+
lastCheck: new Date(),
|
|
93
|
+
error: result.error,
|
|
94
|
+
metrics: result.metrics,
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return { name, health };
|
|
98
|
+
} catch (error) {
|
|
99
|
+
return {
|
|
100
|
+
name,
|
|
101
|
+
health: {
|
|
102
|
+
name,
|
|
103
|
+
status: 'unhealthy' as const,
|
|
104
|
+
lastCheck: new Date(),
|
|
105
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const results = await Promise.allSettled(checkPromises);
|
|
113
|
+
|
|
114
|
+
for (const result of results) {
|
|
115
|
+
if (result.status === 'fulfilled') {
|
|
116
|
+
const { name, health } = result.value;
|
|
117
|
+
components[name] = health;
|
|
118
|
+
|
|
119
|
+
if (health.status === 'unhealthy') {
|
|
120
|
+
unhealthyCount++;
|
|
121
|
+
} else if (health.status === 'degraded') {
|
|
122
|
+
degradedCount++;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let overallStatus: IHealthStatus['status'] = 'healthy';
|
|
128
|
+
if (unhealthyCount >= this.config.unhealthyThreshold) {
|
|
129
|
+
overallStatus = 'unhealthy';
|
|
130
|
+
} else if (
|
|
131
|
+
unhealthyCount > 0 ||
|
|
132
|
+
degradedCount >= this.config.degradedThreshold
|
|
133
|
+
) {
|
|
134
|
+
overallStatus = 'degraded';
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
status: overallStatus,
|
|
139
|
+
components,
|
|
140
|
+
timestamp: new Date(),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
registerCheck(name: string, check: HealthCheckFn): void {
|
|
145
|
+
this.checks.set(name, check);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
unregisterCheck(name: string): void {
|
|
149
|
+
this.checks.delete(name);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
getHistory(limit?: number): IHealthStatus[] {
|
|
153
|
+
const count = limit ?? this.config.historyLimit;
|
|
154
|
+
return this.history.slice(-count);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
onHealthChange(callback: (status: IHealthStatus) => void): () => void {
|
|
158
|
+
this.listeners.push(callback);
|
|
159
|
+
return () => {
|
|
160
|
+
const index = this.listeners.indexOf(callback);
|
|
161
|
+
if (index !== -1) {
|
|
162
|
+
this.listeners.splice(index, 1);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private addToHistory(status: IHealthStatus): void {
|
|
168
|
+
this.history.push(status);
|
|
169
|
+
|
|
170
|
+
// Trim history to limit
|
|
171
|
+
if (this.history.length > this.config.historyLimit) {
|
|
172
|
+
this.history = this.history.slice(-this.config.historyLimit);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
private notifyListeners(status: IHealthStatus): void {
|
|
177
|
+
for (const listener of this.listeners) {
|
|
178
|
+
try {
|
|
179
|
+
listener(status);
|
|
180
|
+
} catch {
|
|
181
|
+
// Ignore listener errors
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private timeout(ms: number, message: string): Promise<never> {
|
|
187
|
+
return new Promise((_, reject) => {
|
|
188
|
+
setTimeout(() => reject(new Error(message)), ms);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Get component health by name
|
|
194
|
+
*/
|
|
195
|
+
async getComponentHealth(name: string): Promise<IComponentHealth | undefined> {
|
|
196
|
+
const status = await this.getStatus();
|
|
197
|
+
return status.components[name];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Check if system is healthy
|
|
202
|
+
*/
|
|
203
|
+
async isHealthy(): Promise<boolean> {
|
|
204
|
+
const status = await this.getStatus();
|
|
205
|
+
return status.status === 'healthy';
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get registered check names
|
|
210
|
+
*/
|
|
211
|
+
getRegisteredChecks(): string[] {
|
|
212
|
+
return Array.from(this.checks.keys());
|
|
213
|
+
}
|
|
214
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Orchestrator Facade
|
|
3
|
+
* Unified interface to decomposed orchestrator components
|
|
4
|
+
* ~50 lines (target achieved)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { IOrchestrator, IHealthStatus, IOrchestratorMetrics } from '../interfaces/coordinator.interface.js';
|
|
8
|
+
import type { ITask, ITaskCreate, ITaskResult } from '../interfaces/task.interface.js';
|
|
9
|
+
import type { IAgent, IAgentConfig } from '../interfaces/agent.interface.js';
|
|
10
|
+
import type { IEventBus } from '../interfaces/event.interface.js';
|
|
11
|
+
|
|
12
|
+
import { TaskManager } from './task-manager.js';
|
|
13
|
+
import { SessionManager, type ISessionManager, type SessionManagerConfig } from './session-manager.js';
|
|
14
|
+
import { HealthMonitor, type HealthMonitorConfig } from './health-monitor.js';
|
|
15
|
+
import { LifecycleManager, type LifecycleManagerConfig } from './lifecycle-manager.js';
|
|
16
|
+
import { EventCoordinator } from './event-coordinator.js';
|
|
17
|
+
import { EventBus } from '../event-bus.js';
|
|
18
|
+
|
|
19
|
+
export * from './task-manager.js';
|
|
20
|
+
export * from './session-manager.js';
|
|
21
|
+
export * from './health-monitor.js';
|
|
22
|
+
export * from './lifecycle-manager.js';
|
|
23
|
+
export * from './event-coordinator.js';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Orchestrator facade configuration
|
|
27
|
+
* (Note: For schema-validated config, use OrchestratorConfig from config/schema.ts)
|
|
28
|
+
*/
|
|
29
|
+
export interface OrchestratorFacadeConfig {
|
|
30
|
+
session: SessionManagerConfig;
|
|
31
|
+
health: HealthMonitorConfig;
|
|
32
|
+
lifecycle: LifecycleManagerConfig;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Default orchestrator facade configuration
|
|
37
|
+
*/
|
|
38
|
+
export const defaultOrchestratorFacadeConfig: OrchestratorFacadeConfig = {
|
|
39
|
+
session: {
|
|
40
|
+
persistSessions: true,
|
|
41
|
+
dataDir: './data',
|
|
42
|
+
sessionRetentionMs: 3600000,
|
|
43
|
+
},
|
|
44
|
+
health: {
|
|
45
|
+
checkInterval: 30000,
|
|
46
|
+
historyLimit: 100,
|
|
47
|
+
degradedThreshold: 1,
|
|
48
|
+
unhealthyThreshold: 2,
|
|
49
|
+
},
|
|
50
|
+
lifecycle: {
|
|
51
|
+
maxConcurrentAgents: 20,
|
|
52
|
+
spawnTimeout: 30000,
|
|
53
|
+
terminateTimeout: 10000,
|
|
54
|
+
maxSpawnRetries: 3,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Create orchestrator components
|
|
60
|
+
*/
|
|
61
|
+
export function createOrchestrator(config: Partial<OrchestratorFacadeConfig> = {}) {
|
|
62
|
+
const mergedConfig: OrchestratorFacadeConfig = {
|
|
63
|
+
session: { ...defaultOrchestratorFacadeConfig.session, ...config.session },
|
|
64
|
+
health: { ...defaultOrchestratorFacadeConfig.health, ...config.health },
|
|
65
|
+
lifecycle: { ...defaultOrchestratorFacadeConfig.lifecycle, ...config.lifecycle },
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const eventBus = new EventBus();
|
|
69
|
+
const taskManager = new TaskManager(eventBus);
|
|
70
|
+
const sessionManager = new SessionManager(eventBus, mergedConfig.session);
|
|
71
|
+
const healthMonitor = new HealthMonitor(eventBus, mergedConfig.health);
|
|
72
|
+
const lifecycleManager = new LifecycleManager(eventBus, mergedConfig.lifecycle);
|
|
73
|
+
const eventCoordinator = new EventCoordinator(eventBus);
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
eventBus,
|
|
77
|
+
taskManager,
|
|
78
|
+
sessionManager,
|
|
79
|
+
healthMonitor,
|
|
80
|
+
lifecycleManager,
|
|
81
|
+
eventCoordinator,
|
|
82
|
+
config: mergedConfig,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Orchestrator type for facade
|
|
88
|
+
*/
|
|
89
|
+
export type OrchestratorComponents = ReturnType<typeof createOrchestrator>;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Lifecycle Manager
|
|
3
|
+
* Decomposed from orchestrator.ts - Agent spawn/terminate
|
|
4
|
+
* ~150 lines (target achieved)
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
IAgent,
|
|
9
|
+
IAgentConfig,
|
|
10
|
+
IAgentLifecycleManager,
|
|
11
|
+
IAgentPool,
|
|
12
|
+
AgentStatus,
|
|
13
|
+
} from '../interfaces/agent.interface.js';
|
|
14
|
+
import type { IEventBus } from '../interfaces/event.interface.js';
|
|
15
|
+
import { SystemEventTypes } from '../interfaces/event.interface.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Agent pool implementation
|
|
19
|
+
*/
|
|
20
|
+
export class AgentPool implements IAgentPool {
|
|
21
|
+
private agents = new Map<string, IAgent>();
|
|
22
|
+
|
|
23
|
+
add(agent: IAgent): void {
|
|
24
|
+
this.agents.set(agent.id, agent);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
remove(agentId: string): boolean {
|
|
28
|
+
return this.agents.delete(agentId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get(agentId: string): IAgent | undefined {
|
|
32
|
+
return this.agents.get(agentId);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getAll(): IAgent[] {
|
|
36
|
+
return Array.from(this.agents.values());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getByStatus(status: AgentStatus): IAgent[] {
|
|
40
|
+
return this.getAll().filter(agent => agent.status === status);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getByType(type: string): IAgent[] {
|
|
44
|
+
return this.getAll().filter(agent => agent.type === type);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
getAvailable(): IAgent[] {
|
|
48
|
+
return this.getAll().filter(
|
|
49
|
+
agent =>
|
|
50
|
+
(agent.status === 'active' || agent.status === 'idle') &&
|
|
51
|
+
agent.currentTaskCount < agent.config.maxConcurrentTasks,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
size(): number {
|
|
56
|
+
return this.agents.size;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
hasCapacity(maxSize: number): boolean {
|
|
60
|
+
return this.agents.size < maxSize;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
clear(): void {
|
|
64
|
+
this.agents.clear();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Lifecycle manager configuration
|
|
70
|
+
*/
|
|
71
|
+
export interface LifecycleManagerConfig {
|
|
72
|
+
maxConcurrentAgents: number;
|
|
73
|
+
spawnTimeout: number;
|
|
74
|
+
terminateTimeout: number;
|
|
75
|
+
maxSpawnRetries: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Lifecycle manager implementation
|
|
80
|
+
*/
|
|
81
|
+
export class LifecycleManager implements IAgentLifecycleManager {
|
|
82
|
+
private pool: IAgentPool;
|
|
83
|
+
|
|
84
|
+
constructor(
|
|
85
|
+
private eventBus: IEventBus,
|
|
86
|
+
private config: LifecycleManagerConfig,
|
|
87
|
+
pool?: IAgentPool,
|
|
88
|
+
) {
|
|
89
|
+
this.pool = pool ?? new AgentPool();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async spawn(config: IAgentConfig): Promise<IAgent> {
|
|
93
|
+
// Validate capacity
|
|
94
|
+
if (!this.pool.hasCapacity(this.config.maxConcurrentAgents)) {
|
|
95
|
+
throw new Error('Maximum concurrent agents reached');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Validate agent doesn't already exist
|
|
99
|
+
if (this.pool.get(config.id)) {
|
|
100
|
+
throw new Error(`Agent with ID ${config.id} already exists`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const agent: IAgent = {
|
|
104
|
+
id: config.id,
|
|
105
|
+
name: config.name,
|
|
106
|
+
type: config.type,
|
|
107
|
+
config,
|
|
108
|
+
createdAt: new Date(),
|
|
109
|
+
status: 'spawning',
|
|
110
|
+
currentTaskCount: 0,
|
|
111
|
+
lastActivity: new Date(),
|
|
112
|
+
metrics: {
|
|
113
|
+
tasksCompleted: 0,
|
|
114
|
+
tasksFailed: 0,
|
|
115
|
+
avgTaskDuration: 0,
|
|
116
|
+
errorCount: 0,
|
|
117
|
+
uptime: 0,
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Add to pool
|
|
122
|
+
this.pool.add(agent);
|
|
123
|
+
|
|
124
|
+
// Mark as active
|
|
125
|
+
agent.status = 'active';
|
|
126
|
+
|
|
127
|
+
this.eventBus.emit(SystemEventTypes.AGENT_SPAWNED, {
|
|
128
|
+
agentId: agent.id,
|
|
129
|
+
profile: config,
|
|
130
|
+
sessionId: undefined,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return agent;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async spawnBatch(configs: IAgentConfig[]): Promise<Map<string, IAgent>> {
|
|
137
|
+
const results = new Map<string, IAgent>();
|
|
138
|
+
|
|
139
|
+
// Check total capacity
|
|
140
|
+
if (this.pool.size() + configs.length > this.config.maxConcurrentAgents) {
|
|
141
|
+
throw new Error('Batch would exceed maximum concurrent agents');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Spawn in parallel
|
|
145
|
+
const spawnPromises = configs.map(async config => {
|
|
146
|
+
try {
|
|
147
|
+
const agent = await this.spawn(config);
|
|
148
|
+
return { id: config.id, agent, error: null };
|
|
149
|
+
} catch (error) {
|
|
150
|
+
return { id: config.id, agent: null, error };
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const settled = await Promise.allSettled(spawnPromises);
|
|
155
|
+
|
|
156
|
+
for (const result of settled) {
|
|
157
|
+
if (result.status === 'fulfilled' && result.value.agent) {
|
|
158
|
+
results.set(result.value.id, result.value.agent);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return results;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async terminate(agentId: string, reason?: string): Promise<void> {
|
|
166
|
+
const agent = this.pool.get(agentId);
|
|
167
|
+
if (!agent) {
|
|
168
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
agent.status = 'terminated';
|
|
172
|
+
|
|
173
|
+
// Remove from pool
|
|
174
|
+
this.pool.remove(agentId);
|
|
175
|
+
|
|
176
|
+
this.eventBus.emit(SystemEventTypes.AGENT_TERMINATED, {
|
|
177
|
+
agentId,
|
|
178
|
+
reason: reason ?? 'User requested',
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async terminateAll(reason?: string): Promise<void> {
|
|
183
|
+
const agents = this.pool.getAll();
|
|
184
|
+
await Promise.allSettled(
|
|
185
|
+
agents.map(agent => this.terminate(agent.id, reason)),
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async restart(agentId: string): Promise<IAgent> {
|
|
190
|
+
const agent = this.pool.get(agentId);
|
|
191
|
+
if (!agent) {
|
|
192
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const config = agent.config;
|
|
196
|
+
await this.terminate(agentId, 'Restart requested');
|
|
197
|
+
return this.spawn(config);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async updateConfig(agentId: string, config: Partial<IAgentConfig>): Promise<void> {
|
|
201
|
+
const agent = this.pool.get(agentId);
|
|
202
|
+
if (!agent) {
|
|
203
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
Object.assign(agent.config, config);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
getAgent(agentId: string): IAgent | undefined {
|
|
210
|
+
return this.pool.get(agentId);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
getAllAgents(): IAgent[] {
|
|
214
|
+
return this.pool.getAll();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
getActiveCount(): number {
|
|
218
|
+
return this.pool.getByStatus('active').length +
|
|
219
|
+
this.pool.getByStatus('idle').length;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async checkHealth(agentId: string): Promise<IAgent['health']> {
|
|
223
|
+
const agent = this.pool.get(agentId);
|
|
224
|
+
if (!agent) {
|
|
225
|
+
throw new Error(`Agent not found: ${agentId}`);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Simple health check based on metrics
|
|
229
|
+
const errorRate = agent.metrics
|
|
230
|
+
? agent.metrics.errorCount / Math.max(1, agent.metrics.tasksCompleted + agent.metrics.tasksFailed)
|
|
231
|
+
: 0;
|
|
232
|
+
|
|
233
|
+
const health: IAgent['health'] = {
|
|
234
|
+
status: errorRate > 0.5 ? 'unhealthy' : errorRate > 0.2 ? 'degraded' : 'healthy',
|
|
235
|
+
lastCheck: new Date(),
|
|
236
|
+
issues: [],
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
if (errorRate > 0.2) {
|
|
240
|
+
health.issues?.push(`High error rate: ${(errorRate * 100).toFixed(1)}%`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
agent.health = health;
|
|
244
|
+
|
|
245
|
+
if (health.status !== 'healthy') {
|
|
246
|
+
this.eventBus.emit(SystemEventTypes.AGENT_HEALTH_CHANGED, {
|
|
247
|
+
agentId,
|
|
248
|
+
previousStatus: agent.status,
|
|
249
|
+
currentStatus: agent.status,
|
|
250
|
+
issues: health.issues,
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return health;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Get agent pool
|
|
259
|
+
*/
|
|
260
|
+
getPool(): IAgentPool {
|
|
261
|
+
return this.pool;
|
|
262
|
+
}
|
|
263
|
+
}
|