monomind 1.11.8 → 1.11.10
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/.claude/agents/github/issue-tracker.md +5 -5
- package/.claude/agents/github/pr-manager.md +5 -5
- package/.claude/agents/github/release-manager.md +3 -3
- package/.claude/agents/github/repo-architect.md +3 -3
- package/.claude/agents/github/swarm-issue.md +1 -1
- package/.claude/agents/github/sync-coordinator.md +1 -1
- package/.claude/agents/github/workflow-automation.md +1 -1
- package/.claude/commands/github/repo-architect.md +1 -1
- package/.claude/commands/github/sync-coordinator.md +1 -1
- package/.claude/commands/mastermind/createorg.md +4 -1
- package/.claude/commands/mastermind/help.md +2 -2
- package/.claude/commands/mastermind/orgs.md +21 -0
- package/.claude/commands/mastermind/orgstatus.md +59 -0
- package/.claude/commands/mastermind/runorg.md +4 -2
- package/.claude/commands/mastermind/stoporg.md +78 -0
- package/.claude/commands/mastermind/swarm.md +1 -1
- package/.claude/helpers/handlers/gates-handler.cjs +135 -0
- package/.claude/helpers/handlers/task-handler.cjs +7 -3
- package/.claude/helpers/hook-handler.cjs +11 -2
- package/.claude/helpers/intelligence.cjs +87 -0
- package/.claude/helpers/learning-service.mjs +60 -0
- package/.claude/helpers/memory.cjs +69 -0
- package/.claude/helpers/router.cjs +68 -0
- package/.claude/helpers/session.cjs +63 -0
- package/.claude/helpers/utils/monograph.cjs +4 -2
- package/.claude/helpers/utils/telemetry.cjs +3 -2
- package/.claude/scheduled_tasks.lock +1 -1
- package/.claude/settings.json +12 -2
- package/.claude/skills/agentic-jujutsu/SKILL.md +1 -1
- package/.claude/skills/hive-mind-advanced/SKILL.md +4 -4
- package/.claude/skills/mastermind/_agent-select.md +2 -2
- package/.claude/skills/mastermind/access.md +11 -11
- package/.claude/skills/mastermind/adapter-manager.md +13 -13
- package/.claude/skills/mastermind/adapters.md +7 -7
- package/.claude/skills/mastermind/agent-detail.md +1 -1
- package/.claude/skills/mastermind/agents.md +5 -5
- package/.claude/skills/mastermind/approval-detail.md +6 -6
- package/.claude/skills/mastermind/approve.md +9 -10
- package/.claude/skills/mastermind/backup.md +2 -2
- package/.claude/skills/mastermind/bootstrap.md +2 -2
- package/.claude/skills/mastermind/companies.md +7 -7
- package/.claude/skills/mastermind/createorg.md +213 -8
- package/.claude/skills/mastermind/diagnose.md +4 -4
- package/.claude/skills/mastermind/env.md +1 -1
- package/.claude/skills/mastermind/environments.md +8 -8
- package/.claude/skills/mastermind/export.md +12 -3
- package/.claude/skills/mastermind/goal-detail.md +9 -9
- package/.claude/skills/mastermind/goals.md +4 -4
- package/.claude/skills/mastermind/heartbeat.md +1 -1
- package/.claude/skills/mastermind/idea.md +4 -4
- package/.claude/skills/mastermind/import.md +8 -8
- package/.claude/skills/mastermind/inbox.md +4 -4
- package/.claude/skills/mastermind/instance-settings.md +9 -9
- package/.claude/skills/mastermind/instance.md +9 -7
- package/.claude/skills/mastermind/invite-landing.md +5 -5
- package/.claude/skills/mastermind/invites.md +12 -12
- package/.claude/skills/mastermind/issue-detail.md +8 -8
- package/.claude/skills/mastermind/monitor.md +11 -11
- package/.claude/skills/mastermind/my-issues.md +6 -6
- package/.claude/skills/mastermind/new-agent.md +4 -4
- package/.claude/skills/mastermind/org-chart.md +8 -6
- package/.claude/skills/mastermind/org-settings.md +58 -21
- package/.claude/skills/mastermind/orgs.md +98 -0
- package/.claude/skills/mastermind/orgstatus.md +194 -0
- package/.claude/skills/mastermind/plan-to-tasks.md +1 -1
- package/.claude/skills/mastermind/plugin-manager.md +12 -12
- package/.claude/skills/mastermind/plugin-settings.md +5 -5
- package/.claude/skills/mastermind/plugins.md +5 -5
- package/.claude/skills/mastermind/profile.md +2 -2
- package/.claude/skills/mastermind/project-detail.md +12 -12
- package/.claude/skills/mastermind/project-workspace.md +4 -4
- package/.claude/skills/mastermind/projects.md +4 -4
- package/.claude/skills/mastermind/review.md +50 -0
- package/.claude/skills/mastermind/routine-detail.md +3 -3
- package/.claude/skills/mastermind/routines.md +7 -6
- package/.claude/skills/mastermind/runorg.md +178 -8
- package/.claude/skills/mastermind/search.md +6 -6
- package/.claude/skills/mastermind/secrets.md +6 -6
- package/.claude/skills/mastermind/skills.md +4 -4
- package/.claude/skills/mastermind/stoporg.md +138 -0
- package/.claude/skills/mastermind/workspace-detail.md +5 -5
- package/.claude/skills/mastermind/workspaces.md +9 -9
- package/.claude/skills/performance-analysis/SKILL.md +3 -3
- package/.claude/skills/sparc-methodology/SKILL.md +2 -2
- package/.claude/skills/swarm-advanced/SKILL.md +4 -4
- package/.claude-plugin/README.md +10 -10
- package/.claude-plugin/docs/INSTALLATION.md +6 -6
- package/.claude-plugin/docs/PLUGIN_SUMMARY.md +9 -9
- package/.claude-plugin/docs/QUICKSTART.md +2 -2
- package/.claude-plugin/docs/STRUCTURE.md +1 -1
- package/.claude-plugin/marketplace.json +5 -5
- package/.claude-plugin/plugin.json +3 -3
- package/README.md +129 -376
- package/package.json +4 -8
- package/packages/@monomind/cli/README.md +129 -376
- package/packages/@monomind/cli/dist/src/agents/registry-builder.d.ts +27 -1
- package/packages/@monomind/cli/dist/src/agents/registry-builder.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/agent.js +4 -9
- package/packages/@monomind/cli/dist/src/commands/analyze.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/analyze.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/claims.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/claims.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/cleanup.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/cleanup.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/completions.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/completions.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/deployment.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/deployment.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/doctor.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/doctor.js +69 -4
- package/packages/@monomind/cli/dist/src/commands/guidance.js +129 -0
- package/packages/@monomind/cli/dist/src/commands/index.js +4 -0
- package/packages/@monomind/cli/dist/src/commands/init.js +18 -0
- package/packages/@monomind/cli/dist/src/commands/monovector/import.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/monovector/import.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/monovector/index.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/monovector/index.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/monovector/setup.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/monovector/setup.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/neural.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/performance.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/performance.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/platforms.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/platforms.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/plugins.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/plugins.js +2 -4
- package/packages/@monomind/cli/dist/src/commands/providers.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/providers.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/route.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/route.js +5 -11
- package/packages/@monomind/cli/dist/src/commands/security.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/security.js +140 -91
- package/packages/@monomind/cli/dist/src/dlq/dlq-replayer.d.ts +7 -1
- package/packages/@monomind/cli/dist/src/index.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/index.js +10 -26
- package/packages/@monomind/cli/dist/src/init/claudemd-generator.js +2 -2
- package/packages/@monomind/cli/dist/src/init/executor.js +3 -3
- package/packages/@monomind/cli/dist/src/init/settings-generator.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-client.d.ts +5 -0
- package/packages/@monomind/cli/dist/src/mcp-client.js +7 -0
- package/packages/@monomind/cli/dist/src/mcp-server.js +17 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/a2a-tools.js +6 -6
- package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.js +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +1 -52
- package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +4 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/index.js +4 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +1 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +107 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/security-tools.d.ts +6 -6
- package/packages/@monomind/cli/dist/src/mcp-tools/security-tools.js +48 -61
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +0 -1
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +232 -57
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +3 -32
- package/packages/@monomind/cli/dist/src/plugins/store/discovery.js +0 -69
- package/packages/@monomind/cli/dist/src/routing/embed-worker.d.ts +2 -0
- package/packages/@monomind/cli/dist/src/routing/embed-worker.js +55 -0
- package/packages/@monomind/cli/dist/src/routing/embedder.d.ts +31 -0
- package/packages/@monomind/cli/dist/src/routing/embedder.js +0 -0
- package/packages/@monomind/cli/dist/src/routing/llm-caller.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/routing/llm-caller.js +18 -3
- package/packages/@monomind/cli/dist/src/routing/route-layer-factory.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/routing/route-layer-factory.js +151 -0
- package/packages/@monomind/cli/dist/src/services/worker-daemon.js +0 -1
- package/packages/@monomind/cli/dist/src/suggest.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/suggest.js +1 -1
- package/packages/@monomind/cli/package.json +9 -10
- package/packages/@monomind/cli/scripts/understand-analyze.mjs +1 -1
- package/packages/@monomind/guidance/README.md +6 -6
- package/packages/@monomind/guidance/package.json +9 -1
- package/scripts/install.sh +7 -7
- package/scripts/ua-enrich.mjs +3 -2
- package/packages/@monomind/shared/dist/agent-contract.d.ts +0 -28
- package/packages/@monomind/shared/dist/agent-contract.js +0 -57
- package/packages/@monomind/shared/dist/agent-error-result.d.ts +0 -17
- package/packages/@monomind/shared/dist/agent-error-result.js +0 -23
- package/packages/@monomind/shared/dist/core/config/defaults.d.ts +0 -41
- package/packages/@monomind/shared/dist/core/config/defaults.js +0 -186
- package/packages/@monomind/shared/dist/core/config/index.d.ts +0 -8
- package/packages/@monomind/shared/dist/core/config/index.js +0 -12
- package/packages/@monomind/shared/dist/core/config/loader.d.ts +0 -45
- package/packages/@monomind/shared/dist/core/config/loader.js +0 -238
- package/packages/@monomind/shared/dist/core/config/schema.d.ts +0 -324
- package/packages/@monomind/shared/dist/core/config/schema.js +0 -160
- package/packages/@monomind/shared/dist/core/config/validator.d.ts +0 -92
- package/packages/@monomind/shared/dist/core/config/validator.js +0 -147
- package/packages/@monomind/shared/dist/core/event-bus.d.ts +0 -31
- package/packages/@monomind/shared/dist/core/event-bus.js +0 -197
- package/packages/@monomind/shared/dist/core/index.d.ts +0 -15
- package/packages/@monomind/shared/dist/core/index.js +0 -19
- package/packages/@monomind/shared/dist/core/interfaces/agent.interface.d.ts +0 -200
- package/packages/@monomind/shared/dist/core/interfaces/agent.interface.js +0 -6
- package/packages/@monomind/shared/dist/core/interfaces/coordinator.interface.d.ts +0 -310
- package/packages/@monomind/shared/dist/core/interfaces/coordinator.interface.js +0 -7
- package/packages/@monomind/shared/dist/core/interfaces/event.interface.d.ts +0 -224
- package/packages/@monomind/shared/dist/core/interfaces/event.interface.js +0 -46
- package/packages/@monomind/shared/dist/core/interfaces/index.d.ts +0 -10
- package/packages/@monomind/shared/dist/core/interfaces/index.js +0 -15
- package/packages/@monomind/shared/dist/core/interfaces/memory.interface.d.ts +0 -298
- package/packages/@monomind/shared/dist/core/interfaces/memory.interface.js +0 -7
- package/packages/@monomind/shared/dist/core/interfaces/task.interface.d.ts +0 -185
- package/packages/@monomind/shared/dist/core/interfaces/task.interface.js +0 -6
- package/packages/@monomind/shared/dist/core/orchestrator/event-coordinator.d.ts +0 -35
- package/packages/@monomind/shared/dist/core/orchestrator/event-coordinator.js +0 -101
- package/packages/@monomind/shared/dist/core/orchestrator/health-monitor.d.ts +0 -60
- package/packages/@monomind/shared/dist/core/orchestrator/health-monitor.js +0 -166
- package/packages/@monomind/shared/dist/core/orchestrator/index.d.ts +0 -46
- package/packages/@monomind/shared/dist/core/orchestrator/index.js +0 -64
- package/packages/@monomind/shared/dist/core/orchestrator/lifecycle-manager.d.ts +0 -56
- package/packages/@monomind/shared/dist/core/orchestrator/lifecycle-manager.js +0 -195
- package/packages/@monomind/shared/dist/core/orchestrator/session-manager.d.ts +0 -83
- package/packages/@monomind/shared/dist/core/orchestrator/session-manager.js +0 -193
- package/packages/@monomind/shared/dist/core/orchestrator/task-manager.d.ts +0 -49
- package/packages/@monomind/shared/dist/core/orchestrator/task-manager.js +0 -253
- package/packages/@monomind/shared/dist/events/domain-events.d.ts +0 -282
- package/packages/@monomind/shared/dist/events/domain-events.js +0 -165
- package/packages/@monomind/shared/dist/events/event-store.d.ts +0 -126
- package/packages/@monomind/shared/dist/events/event-store.js +0 -416
- package/packages/@monomind/shared/dist/events/event-store.test.d.ts +0 -8
- package/packages/@monomind/shared/dist/events/event-store.test.js +0 -293
- package/packages/@monomind/shared/dist/events/example-usage.d.ts +0 -10
- package/packages/@monomind/shared/dist/events/example-usage.js +0 -193
- package/packages/@monomind/shared/dist/events/index.d.ts +0 -21
- package/packages/@monomind/shared/dist/events/index.js +0 -22
- package/packages/@monomind/shared/dist/events/projections.d.ts +0 -177
- package/packages/@monomind/shared/dist/events/projections.js +0 -421
- package/packages/@monomind/shared/dist/events/rvf-event-log.d.ts +0 -82
- package/packages/@monomind/shared/dist/events/rvf-event-log.js +0 -340
- package/packages/@monomind/shared/dist/events/state-reconstructor.d.ts +0 -101
- package/packages/@monomind/shared/dist/events/state-reconstructor.js +0 -263
- package/packages/@monomind/shared/dist/events.d.ts +0 -80
- package/packages/@monomind/shared/dist/events.js +0 -249
- package/packages/@monomind/shared/dist/hooks/example-usage.d.ts +0 -42
- package/packages/@monomind/shared/dist/hooks/example-usage.js +0 -351
- package/packages/@monomind/shared/dist/hooks/executor.d.ts +0 -100
- package/packages/@monomind/shared/dist/hooks/executor.js +0 -264
- package/packages/@monomind/shared/dist/hooks/hooks.test.d.ts +0 -9
- package/packages/@monomind/shared/dist/hooks/hooks.test.js +0 -322
- package/packages/@monomind/shared/dist/hooks/index.d.ts +0 -52
- package/packages/@monomind/shared/dist/hooks/index.js +0 -51
- package/packages/@monomind/shared/dist/hooks/registry.d.ts +0 -133
- package/packages/@monomind/shared/dist/hooks/registry.js +0 -277
- package/packages/@monomind/shared/dist/hooks/safety/bash-safety.d.ts +0 -105
- package/packages/@monomind/shared/dist/hooks/safety/bash-safety.js +0 -481
- package/packages/@monomind/shared/dist/hooks/safety/file-organization.d.ts +0 -144
- package/packages/@monomind/shared/dist/hooks/safety/file-organization.js +0 -328
- package/packages/@monomind/shared/dist/hooks/safety/git-commit.d.ts +0 -158
- package/packages/@monomind/shared/dist/hooks/safety/git-commit.js +0 -450
- package/packages/@monomind/shared/dist/hooks/safety/index.d.ts +0 -17
- package/packages/@monomind/shared/dist/hooks/safety/index.js +0 -17
- package/packages/@monomind/shared/dist/hooks/session-hooks.d.ts +0 -234
- package/packages/@monomind/shared/dist/hooks/session-hooks.js +0 -334
- package/packages/@monomind/shared/dist/hooks/task-hooks.d.ts +0 -163
- package/packages/@monomind/shared/dist/hooks/task-hooks.js +0 -326
- package/packages/@monomind/shared/dist/hooks/types.d.ts +0 -267
- package/packages/@monomind/shared/dist/hooks/types.js +0 -62
- package/packages/@monomind/shared/dist/hooks/verify-exports.test.d.ts +0 -9
- package/packages/@monomind/shared/dist/hooks/verify-exports.test.js +0 -93
- package/packages/@monomind/shared/dist/index.d.ts +0 -46
- package/packages/@monomind/shared/dist/index.js +0 -77
- package/packages/@monomind/shared/dist/mcp/connection-pool.d.ts +0 -98
- package/packages/@monomind/shared/dist/mcp/connection-pool.js +0 -364
- package/packages/@monomind/shared/dist/mcp/index.d.ts +0 -69
- package/packages/@monomind/shared/dist/mcp/index.js +0 -84
- package/packages/@monomind/shared/dist/mcp/server.d.ts +0 -166
- package/packages/@monomind/shared/dist/mcp/server.js +0 -593
- package/packages/@monomind/shared/dist/mcp/session-manager.d.ts +0 -136
- package/packages/@monomind/shared/dist/mcp/session-manager.js +0 -335
- package/packages/@monomind/shared/dist/mcp/tool-registry.d.ts +0 -178
- package/packages/@monomind/shared/dist/mcp/tool-registry.js +0 -439
- package/packages/@monomind/shared/dist/mcp/transport/http.d.ts +0 -104
- package/packages/@monomind/shared/dist/mcp/transport/http.js +0 -476
- package/packages/@monomind/shared/dist/mcp/transport/index.d.ts +0 -102
- package/packages/@monomind/shared/dist/mcp/transport/index.js +0 -238
- package/packages/@monomind/shared/dist/mcp/transport/stdio.d.ts +0 -104
- package/packages/@monomind/shared/dist/mcp/transport/stdio.js +0 -263
- package/packages/@monomind/shared/dist/mcp/transport/websocket.d.ts +0 -133
- package/packages/@monomind/shared/dist/mcp/transport/websocket.js +0 -396
- package/packages/@monomind/shared/dist/mcp/types.d.ts +0 -438
- package/packages/@monomind/shared/dist/mcp/types.js +0 -54
- package/packages/@monomind/shared/dist/plugin-interface.d.ts +0 -544
- package/packages/@monomind/shared/dist/plugin-interface.js +0 -23
- package/packages/@monomind/shared/dist/plugin-loader.d.ts +0 -139
- package/packages/@monomind/shared/dist/plugin-loader.js +0 -434
- package/packages/@monomind/shared/dist/plugin-registry.d.ts +0 -183
- package/packages/@monomind/shared/dist/plugin-registry.js +0 -457
- package/packages/@monomind/shared/dist/plugins/index.d.ts +0 -10
- package/packages/@monomind/shared/dist/plugins/index.js +0 -10
- package/packages/@monomind/shared/dist/plugins/official/hive-mind-plugin.d.ts +0 -106
- package/packages/@monomind/shared/dist/plugins/official/hive-mind-plugin.js +0 -241
- package/packages/@monomind/shared/dist/plugins/official/index.d.ts +0 -10
- package/packages/@monomind/shared/dist/plugins/official/index.js +0 -10
- package/packages/@monomind/shared/dist/plugins/official/maestro-plugin.d.ts +0 -121
- package/packages/@monomind/shared/dist/plugins/official/maestro-plugin.js +0 -355
- package/packages/@monomind/shared/dist/plugins/types.d.ts +0 -93
- package/packages/@monomind/shared/dist/plugins/types.js +0 -9
- package/packages/@monomind/shared/dist/reducers.d.ts +0 -33
- package/packages/@monomind/shared/dist/reducers.js +0 -89
- package/packages/@monomind/shared/dist/resilience/bulkhead.d.ts +0 -105
- package/packages/@monomind/shared/dist/resilience/bulkhead.js +0 -206
- package/packages/@monomind/shared/dist/resilience/circuit-breaker.d.ts +0 -132
- package/packages/@monomind/shared/dist/resilience/circuit-breaker.js +0 -233
- package/packages/@monomind/shared/dist/resilience/index.d.ts +0 -19
- package/packages/@monomind/shared/dist/resilience/index.js +0 -19
- package/packages/@monomind/shared/dist/resilience/rate-limiter.d.ts +0 -168
- package/packages/@monomind/shared/dist/resilience/rate-limiter.js +0 -314
- package/packages/@monomind/shared/dist/resilience/retry.d.ts +0 -91
- package/packages/@monomind/shared/dist/resilience/retry.js +0 -159
- package/packages/@monomind/shared/dist/retry-policy.d.ts +0 -14
- package/packages/@monomind/shared/dist/retry-policy.js +0 -23
- package/packages/@monomind/shared/dist/retry-runner.d.ts +0 -21
- package/packages/@monomind/shared/dist/retry-runner.js +0 -57
- package/packages/@monomind/shared/dist/schema-validator.d.ts +0 -46
- package/packages/@monomind/shared/dist/schema-validator.js +0 -133
- package/packages/@monomind/shared/dist/scratchpad.d.ts +0 -23
- package/packages/@monomind/shared/dist/scratchpad.js +0 -32
- package/packages/@monomind/shared/dist/security/index.d.ts +0 -10
- package/packages/@monomind/shared/dist/security/index.js +0 -12
- package/packages/@monomind/shared/dist/security/input-validation.d.ts +0 -73
- package/packages/@monomind/shared/dist/security/input-validation.js +0 -201
- package/packages/@monomind/shared/dist/security/secure-random.d.ts +0 -92
- package/packages/@monomind/shared/dist/security/secure-random.js +0 -142
- package/packages/@monomind/shared/dist/services/index.d.ts +0 -7
- package/packages/@monomind/shared/dist/services/index.js +0 -7
- package/packages/@monomind/shared/dist/services/progress.service.d.ts +0 -124
- package/packages/@monomind/shared/dist/services/progress.service.js +0 -402
- package/packages/@monomind/shared/dist/state-manager.d.ts +0 -34
- package/packages/@monomind/shared/dist/state-manager.js +0 -73
- package/packages/@monomind/shared/dist/state-validator.d.ts +0 -20
- package/packages/@monomind/shared/dist/state-validator.js +0 -49
- package/packages/@monomind/shared/dist/swarm-state.d.ts +0 -52
- package/packages/@monomind/shared/dist/swarm-state.js +0 -18
- package/packages/@monomind/shared/dist/testing/fixture-builder.d.ts +0 -14
- package/packages/@monomind/shared/dist/testing/fixture-builder.js +0 -32
- package/packages/@monomind/shared/dist/testing/index.d.ts +0 -2
- package/packages/@monomind/shared/dist/testing/index.js +0 -2
- package/packages/@monomind/shared/dist/testing/test-model.d.ts +0 -29
- package/packages/@monomind/shared/dist/testing/test-model.js +0 -53
- package/packages/@monomind/shared/dist/types/agent-registry.d.ts +0 -62
- package/packages/@monomind/shared/dist/types/agent-registry.js +0 -8
- package/packages/@monomind/shared/dist/types/agent-version.d.ts +0 -49
- package/packages/@monomind/shared/dist/types/agent-version.js +0 -7
- package/packages/@monomind/shared/dist/types/agent.types.d.ts +0 -137
- package/packages/@monomind/shared/dist/types/agent.types.js +0 -6
- package/packages/@monomind/shared/dist/types/benchmark.d.ts +0 -39
- package/packages/@monomind/shared/dist/types/benchmark.js +0 -6
- package/packages/@monomind/shared/dist/types/communication-flow.d.ts +0 -25
- package/packages/@monomind/shared/dist/types/communication-flow.js +0 -7
- package/packages/@monomind/shared/dist/types/consensus-audit.d.ts +0 -40
- package/packages/@monomind/shared/dist/types/consensus-audit.js +0 -7
- package/packages/@monomind/shared/dist/types/dlq.d.ts +0 -40
- package/packages/@monomind/shared/dist/types/dlq.js +0 -7
- package/packages/@monomind/shared/dist/types/eval.d.ts +0 -59
- package/packages/@monomind/shared/dist/types/eval.js +0 -6
- package/packages/@monomind/shared/dist/types/index.d.ts +0 -19
- package/packages/@monomind/shared/dist/types/index.js +0 -33
- package/packages/@monomind/shared/dist/types/mcp.types.d.ts +0 -266
- package/packages/@monomind/shared/dist/types/mcp.types.js +0 -7
- package/packages/@monomind/shared/dist/types/memory.types.d.ts +0 -236
- package/packages/@monomind/shared/dist/types/memory.types.js +0 -7
- package/packages/@monomind/shared/dist/types/retry.d.ts +0 -72
- package/packages/@monomind/shared/dist/types/retry.js +0 -40
- package/packages/@monomind/shared/dist/types/specialization.d.ts +0 -27
- package/packages/@monomind/shared/dist/types/specialization.js +0 -8
- package/packages/@monomind/shared/dist/types/swarm.types.d.ts +0 -186
- package/packages/@monomind/shared/dist/types/swarm.types.js +0 -65
- package/packages/@monomind/shared/dist/types/task.types.d.ts +0 -178
- package/packages/@monomind/shared/dist/types/task.types.js +0 -32
- package/packages/@monomind/shared/dist/types/termination.d.ts +0 -29
- package/packages/@monomind/shared/dist/types/termination.js +0 -14
- package/packages/@monomind/shared/dist/types/tool-version.d.ts +0 -41
- package/packages/@monomind/shared/dist/types/tool-version.js +0 -8
- package/packages/@monomind/shared/dist/types/trigger.d.ts +0 -40
- package/packages/@monomind/shared/dist/types/trigger.js +0 -8
- package/packages/@monomind/shared/dist/types.d.ts +0 -197
- package/packages/@monomind/shared/dist/types.js +0 -21
- package/packages/@monomind/shared/dist/utils/secure-logger.d.ts +0 -69
- package/packages/@monomind/shared/dist/utils/secure-logger.js +0 -208
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP WebSocket Transport
|
|
3
|
-
*
|
|
4
|
-
* Standalone WebSocket transport for MCP communication:
|
|
5
|
-
* - Native WebSocket server without HTTP dependency
|
|
6
|
-
* - Binary message support for efficiency
|
|
7
|
-
* - Heartbeat/ping-pong for connection health
|
|
8
|
-
* - Automatic reconnection handling
|
|
9
|
-
*
|
|
10
|
-
* Performance Targets:
|
|
11
|
-
* - Message latency: <3ms
|
|
12
|
-
* - Connection overhead: <10ms
|
|
13
|
-
*/
|
|
14
|
-
import { EventEmitter } from 'events';
|
|
15
|
-
import { WebSocket } from 'ws';
|
|
16
|
-
import { ITransport, TransportType, MCPNotification, RequestHandler, NotificationHandler, TransportHealthStatus, ILogger, AuthConfig } from '../types.js';
|
|
17
|
-
/**
|
|
18
|
-
* WebSocket Transport Configuration
|
|
19
|
-
*/
|
|
20
|
-
export interface WebSocketTransportConfig {
|
|
21
|
-
host: string;
|
|
22
|
-
port: number;
|
|
23
|
-
path?: string;
|
|
24
|
-
maxConnections?: number;
|
|
25
|
-
heartbeatInterval?: number;
|
|
26
|
-
heartbeatTimeout?: number;
|
|
27
|
-
maxMessageSize?: number;
|
|
28
|
-
auth?: AuthConfig;
|
|
29
|
-
enableBinaryMode?: boolean;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Client connection info
|
|
33
|
-
*/
|
|
34
|
-
interface ClientConnection {
|
|
35
|
-
id: string;
|
|
36
|
-
ws: WebSocket;
|
|
37
|
-
createdAt: Date;
|
|
38
|
-
lastActivity: Date;
|
|
39
|
-
messageCount: number;
|
|
40
|
-
isAlive: boolean;
|
|
41
|
-
isAuthenticated: boolean;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* WebSocket Transport Implementation
|
|
45
|
-
*/
|
|
46
|
-
export declare class WebSocketTransport extends EventEmitter implements ITransport {
|
|
47
|
-
private readonly logger;
|
|
48
|
-
private readonly config;
|
|
49
|
-
readonly type: TransportType;
|
|
50
|
-
private requestHandler?;
|
|
51
|
-
private notificationHandler?;
|
|
52
|
-
private server?;
|
|
53
|
-
private wss?;
|
|
54
|
-
private clients;
|
|
55
|
-
private heartbeatTimer?;
|
|
56
|
-
private running;
|
|
57
|
-
private connectionCounter;
|
|
58
|
-
private messagesReceived;
|
|
59
|
-
private messagesSent;
|
|
60
|
-
private errors;
|
|
61
|
-
private totalConnections;
|
|
62
|
-
constructor(logger: ILogger, config: WebSocketTransportConfig);
|
|
63
|
-
/**
|
|
64
|
-
* Start the transport
|
|
65
|
-
*/
|
|
66
|
-
start(): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Stop the transport
|
|
69
|
-
*/
|
|
70
|
-
stop(): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Register request handler
|
|
73
|
-
*/
|
|
74
|
-
onRequest(handler: RequestHandler): void;
|
|
75
|
-
/**
|
|
76
|
-
* Register notification handler
|
|
77
|
-
*/
|
|
78
|
-
onNotification(handler: NotificationHandler): void;
|
|
79
|
-
/**
|
|
80
|
-
* Get health status
|
|
81
|
-
*/
|
|
82
|
-
getHealthStatus(): Promise<TransportHealthStatus>;
|
|
83
|
-
/**
|
|
84
|
-
* Send notification to all connected clients
|
|
85
|
-
*/
|
|
86
|
-
sendNotification(notification: MCPNotification): Promise<void>;
|
|
87
|
-
/**
|
|
88
|
-
* Send notification to specific client
|
|
89
|
-
*/
|
|
90
|
-
sendToClient(clientId: string, notification: MCPNotification): Promise<boolean>;
|
|
91
|
-
/**
|
|
92
|
-
* Get connected clients
|
|
93
|
-
*/
|
|
94
|
-
getClients(): string[];
|
|
95
|
-
/**
|
|
96
|
-
* Get client info
|
|
97
|
-
*/
|
|
98
|
-
getClientInfo(clientId: string): ClientConnection | undefined;
|
|
99
|
-
/**
|
|
100
|
-
* Disconnect specific client
|
|
101
|
-
*/
|
|
102
|
-
disconnectClient(clientId: string, reason?: string): boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Setup WebSocket handlers
|
|
105
|
-
*/
|
|
106
|
-
private setupWebSocketHandlers;
|
|
107
|
-
/**
|
|
108
|
-
* Handle incoming message
|
|
109
|
-
*/
|
|
110
|
-
private handleMessage;
|
|
111
|
-
/**
|
|
112
|
-
* Parse incoming message
|
|
113
|
-
*/
|
|
114
|
-
private parseMessage;
|
|
115
|
-
/**
|
|
116
|
-
* Serialize outgoing message
|
|
117
|
-
*/
|
|
118
|
-
private serializeMessage;
|
|
119
|
-
/**
|
|
120
|
-
* Start heartbeat interval
|
|
121
|
-
*/
|
|
122
|
-
private startHeartbeat;
|
|
123
|
-
/**
|
|
124
|
-
* Stop heartbeat interval
|
|
125
|
-
*/
|
|
126
|
-
private stopHeartbeat;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Create WebSocket transport
|
|
130
|
-
*/
|
|
131
|
-
export declare function createWebSocketTransport(logger: ILogger, config: WebSocketTransportConfig): WebSocketTransport;
|
|
132
|
-
export {};
|
|
133
|
-
//# sourceMappingURL=websocket.d.ts.map
|
|
@@ -1,396 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP WebSocket Transport
|
|
3
|
-
*
|
|
4
|
-
* Standalone WebSocket transport for MCP communication:
|
|
5
|
-
* - Native WebSocket server without HTTP dependency
|
|
6
|
-
* - Binary message support for efficiency
|
|
7
|
-
* - Heartbeat/ping-pong for connection health
|
|
8
|
-
* - Automatic reconnection handling
|
|
9
|
-
*
|
|
10
|
-
* Performance Targets:
|
|
11
|
-
* - Message latency: <3ms
|
|
12
|
-
* - Connection overhead: <10ms
|
|
13
|
-
*/
|
|
14
|
-
import { EventEmitter } from 'events';
|
|
15
|
-
import { WebSocketServer, WebSocket } from 'ws';
|
|
16
|
-
import { createServer } from 'http';
|
|
17
|
-
/**
|
|
18
|
-
* WebSocket Transport Implementation
|
|
19
|
-
*/
|
|
20
|
-
export class WebSocketTransport extends EventEmitter {
|
|
21
|
-
logger;
|
|
22
|
-
config;
|
|
23
|
-
type = 'websocket';
|
|
24
|
-
requestHandler;
|
|
25
|
-
notificationHandler;
|
|
26
|
-
server;
|
|
27
|
-
wss;
|
|
28
|
-
clients = new Map();
|
|
29
|
-
heartbeatTimer;
|
|
30
|
-
running = false;
|
|
31
|
-
connectionCounter = 0;
|
|
32
|
-
// Statistics
|
|
33
|
-
messagesReceived = 0;
|
|
34
|
-
messagesSent = 0;
|
|
35
|
-
errors = 0;
|
|
36
|
-
totalConnections = 0;
|
|
37
|
-
constructor(logger, config) {
|
|
38
|
-
super();
|
|
39
|
-
this.logger = logger;
|
|
40
|
-
this.config = config;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Start the transport
|
|
44
|
-
*/
|
|
45
|
-
async start() {
|
|
46
|
-
if (this.running) {
|
|
47
|
-
throw new Error('WebSocket transport already running');
|
|
48
|
-
}
|
|
49
|
-
this.logger.info('Starting WebSocket transport', {
|
|
50
|
-
host: this.config.host,
|
|
51
|
-
port: this.config.port,
|
|
52
|
-
path: this.config.path || '/ws',
|
|
53
|
-
});
|
|
54
|
-
// Create HTTP server for WebSocket upgrade
|
|
55
|
-
this.server = createServer((req, res) => {
|
|
56
|
-
// Simple HTTP response for non-WebSocket requests
|
|
57
|
-
res.writeHead(426, { 'Content-Type': 'text/plain' });
|
|
58
|
-
res.end('Upgrade Required - WebSocket connection expected');
|
|
59
|
-
});
|
|
60
|
-
// Create WebSocket server
|
|
61
|
-
this.wss = new WebSocketServer({
|
|
62
|
-
server: this.server,
|
|
63
|
-
path: this.config.path || '/ws',
|
|
64
|
-
maxPayload: this.config.maxMessageSize || 10 * 1024 * 1024,
|
|
65
|
-
perMessageDeflate: true, // Enable compression
|
|
66
|
-
});
|
|
67
|
-
this.setupWebSocketHandlers();
|
|
68
|
-
this.startHeartbeat();
|
|
69
|
-
// Start server
|
|
70
|
-
await new Promise((resolve, reject) => {
|
|
71
|
-
this.server.listen(this.config.port, this.config.host, () => {
|
|
72
|
-
resolve();
|
|
73
|
-
});
|
|
74
|
-
this.server.on('error', reject);
|
|
75
|
-
});
|
|
76
|
-
this.running = true;
|
|
77
|
-
this.logger.info('WebSocket transport started', {
|
|
78
|
-
url: `ws://${this.config.host}:${this.config.port}${this.config.path || '/ws'}`,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Stop the transport
|
|
83
|
-
*/
|
|
84
|
-
async stop() {
|
|
85
|
-
if (!this.running) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
this.logger.info('Stopping WebSocket transport');
|
|
89
|
-
this.running = false;
|
|
90
|
-
this.stopHeartbeat();
|
|
91
|
-
// Close all client connections
|
|
92
|
-
for (const client of this.clients.values()) {
|
|
93
|
-
try {
|
|
94
|
-
client.ws.close(1000, 'Server shutting down');
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
// Ignore errors
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
this.clients.clear();
|
|
101
|
-
// Close WebSocket server
|
|
102
|
-
if (this.wss) {
|
|
103
|
-
this.wss.close();
|
|
104
|
-
this.wss = undefined;
|
|
105
|
-
}
|
|
106
|
-
// Close HTTP server
|
|
107
|
-
if (this.server) {
|
|
108
|
-
await new Promise((resolve) => {
|
|
109
|
-
this.server.close(() => resolve());
|
|
110
|
-
});
|
|
111
|
-
this.server = undefined;
|
|
112
|
-
}
|
|
113
|
-
this.logger.info('WebSocket transport stopped');
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Register request handler
|
|
117
|
-
*/
|
|
118
|
-
onRequest(handler) {
|
|
119
|
-
this.requestHandler = handler;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Register notification handler
|
|
123
|
-
*/
|
|
124
|
-
onNotification(handler) {
|
|
125
|
-
this.notificationHandler = handler;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Get health status
|
|
129
|
-
*/
|
|
130
|
-
async getHealthStatus() {
|
|
131
|
-
return {
|
|
132
|
-
healthy: this.running,
|
|
133
|
-
metrics: {
|
|
134
|
-
messagesReceived: this.messagesReceived,
|
|
135
|
-
messagesSent: this.messagesSent,
|
|
136
|
-
errors: this.errors,
|
|
137
|
-
activeConnections: this.clients.size,
|
|
138
|
-
totalConnections: this.totalConnections,
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Send notification to all connected clients
|
|
144
|
-
*/
|
|
145
|
-
async sendNotification(notification) {
|
|
146
|
-
const message = this.serializeMessage(notification);
|
|
147
|
-
for (const client of this.clients.values()) {
|
|
148
|
-
try {
|
|
149
|
-
if (client.ws.readyState === WebSocket.OPEN) {
|
|
150
|
-
client.ws.send(message);
|
|
151
|
-
this.messagesSent++;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
this.logger.error('Failed to send notification', { clientId: client.id, error });
|
|
156
|
-
this.errors++;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Send notification to specific client
|
|
162
|
-
*/
|
|
163
|
-
async sendToClient(clientId, notification) {
|
|
164
|
-
const client = this.clients.get(clientId);
|
|
165
|
-
if (!client || client.ws.readyState !== WebSocket.OPEN) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
try {
|
|
169
|
-
client.ws.send(this.serializeMessage(notification));
|
|
170
|
-
this.messagesSent++;
|
|
171
|
-
return true;
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
this.logger.error('Failed to send to client', { clientId, error });
|
|
175
|
-
this.errors++;
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Get connected clients
|
|
181
|
-
*/
|
|
182
|
-
getClients() {
|
|
183
|
-
return Array.from(this.clients.keys());
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Get client info
|
|
187
|
-
*/
|
|
188
|
-
getClientInfo(clientId) {
|
|
189
|
-
return this.clients.get(clientId);
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Disconnect specific client
|
|
193
|
-
*/
|
|
194
|
-
disconnectClient(clientId, reason = 'Disconnected by server') {
|
|
195
|
-
const client = this.clients.get(clientId);
|
|
196
|
-
if (!client) {
|
|
197
|
-
return false;
|
|
198
|
-
}
|
|
199
|
-
try {
|
|
200
|
-
client.ws.close(1000, reason);
|
|
201
|
-
return true;
|
|
202
|
-
}
|
|
203
|
-
catch {
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Setup WebSocket handlers
|
|
209
|
-
*/
|
|
210
|
-
setupWebSocketHandlers() {
|
|
211
|
-
if (!this.wss)
|
|
212
|
-
return;
|
|
213
|
-
this.wss.on('connection', (ws, req) => {
|
|
214
|
-
// Check max connections
|
|
215
|
-
if (this.config.maxConnections && this.clients.size >= this.config.maxConnections) {
|
|
216
|
-
this.logger.warn('Max connections reached, rejecting client');
|
|
217
|
-
ws.close(1013, 'Server at capacity');
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
const clientId = `client-${++this.connectionCounter}`;
|
|
221
|
-
const client = {
|
|
222
|
-
id: clientId,
|
|
223
|
-
ws,
|
|
224
|
-
createdAt: new Date(),
|
|
225
|
-
lastActivity: new Date(),
|
|
226
|
-
messageCount: 0,
|
|
227
|
-
isAlive: true,
|
|
228
|
-
isAuthenticated: !this.config.auth?.enabled,
|
|
229
|
-
};
|
|
230
|
-
this.clients.set(clientId, client);
|
|
231
|
-
this.totalConnections++;
|
|
232
|
-
this.logger.info('Client connected', {
|
|
233
|
-
id: clientId,
|
|
234
|
-
total: this.clients.size,
|
|
235
|
-
});
|
|
236
|
-
// Setup message handler
|
|
237
|
-
ws.on('message', async (data) => {
|
|
238
|
-
await this.handleMessage(client, data);
|
|
239
|
-
});
|
|
240
|
-
// Setup pong handler for heartbeat
|
|
241
|
-
ws.on('pong', () => {
|
|
242
|
-
client.isAlive = true;
|
|
243
|
-
});
|
|
244
|
-
// Setup close handler
|
|
245
|
-
ws.on('close', (code, reason) => {
|
|
246
|
-
this.clients.delete(clientId);
|
|
247
|
-
this.logger.info('Client disconnected', {
|
|
248
|
-
id: clientId,
|
|
249
|
-
code,
|
|
250
|
-
reason: reason.toString(),
|
|
251
|
-
total: this.clients.size,
|
|
252
|
-
});
|
|
253
|
-
this.emit('client:disconnected', clientId);
|
|
254
|
-
});
|
|
255
|
-
// Setup error handler
|
|
256
|
-
ws.on('error', (error) => {
|
|
257
|
-
this.logger.error('Client error', { id: clientId, error });
|
|
258
|
-
this.errors++;
|
|
259
|
-
this.clients.delete(clientId);
|
|
260
|
-
});
|
|
261
|
-
this.emit('client:connected', clientId);
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Handle incoming message
|
|
266
|
-
*/
|
|
267
|
-
async handleMessage(client, data) {
|
|
268
|
-
client.lastActivity = new Date();
|
|
269
|
-
client.messageCount++;
|
|
270
|
-
this.messagesReceived++;
|
|
271
|
-
try {
|
|
272
|
-
const message = this.parseMessage(data);
|
|
273
|
-
// Check authentication for non-authenticated clients
|
|
274
|
-
if (!client.isAuthenticated && this.config.auth?.enabled) {
|
|
275
|
-
if (message.method !== 'authenticate') {
|
|
276
|
-
client.ws.send(this.serializeMessage({
|
|
277
|
-
jsonrpc: '2.0',
|
|
278
|
-
id: message.id || null,
|
|
279
|
-
error: { code: -32001, message: 'Authentication required' },
|
|
280
|
-
}));
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
if (message.jsonrpc !== '2.0') {
|
|
285
|
-
client.ws.send(this.serializeMessage({
|
|
286
|
-
jsonrpc: '2.0',
|
|
287
|
-
id: message.id || null,
|
|
288
|
-
error: { code: -32600, message: 'Invalid JSON-RPC version' },
|
|
289
|
-
}));
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
if (message.id === undefined) {
|
|
293
|
-
// Notification
|
|
294
|
-
if (this.notificationHandler) {
|
|
295
|
-
await this.notificationHandler(message);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
// Request
|
|
300
|
-
if (!this.requestHandler) {
|
|
301
|
-
client.ws.send(this.serializeMessage({
|
|
302
|
-
jsonrpc: '2.0',
|
|
303
|
-
id: message.id,
|
|
304
|
-
error: { code: -32603, message: 'No request handler' },
|
|
305
|
-
}));
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
const startTime = performance.now();
|
|
309
|
-
const response = await this.requestHandler(message);
|
|
310
|
-
const duration = performance.now() - startTime;
|
|
311
|
-
this.logger.debug('Request processed', {
|
|
312
|
-
clientId: client.id,
|
|
313
|
-
method: message.method,
|
|
314
|
-
duration: `${duration.toFixed(2)}ms`,
|
|
315
|
-
});
|
|
316
|
-
client.ws.send(this.serializeMessage(response));
|
|
317
|
-
this.messagesSent++;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
catch (error) {
|
|
321
|
-
this.errors++;
|
|
322
|
-
this.logger.error('Message handling error', { clientId: client.id, error });
|
|
323
|
-
try {
|
|
324
|
-
client.ws.send(this.serializeMessage({
|
|
325
|
-
jsonrpc: '2.0',
|
|
326
|
-
id: null,
|
|
327
|
-
error: { code: -32700, message: 'Parse error' },
|
|
328
|
-
}));
|
|
329
|
-
}
|
|
330
|
-
catch {
|
|
331
|
-
// Ignore send errors
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Parse incoming message
|
|
337
|
-
*/
|
|
338
|
-
parseMessage(data) {
|
|
339
|
-
if (this.config.enableBinaryMode && Buffer.isBuffer(data)) {
|
|
340
|
-
// Could implement binary protocol here
|
|
341
|
-
return JSON.parse(data.toString());
|
|
342
|
-
}
|
|
343
|
-
return JSON.parse(data.toString());
|
|
344
|
-
}
|
|
345
|
-
/**
|
|
346
|
-
* Serialize outgoing message
|
|
347
|
-
*/
|
|
348
|
-
serializeMessage(message) {
|
|
349
|
-
if (this.config.enableBinaryMode) {
|
|
350
|
-
// Could implement binary protocol here
|
|
351
|
-
return JSON.stringify(message);
|
|
352
|
-
}
|
|
353
|
-
return JSON.stringify(message);
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Start heartbeat interval
|
|
357
|
-
*/
|
|
358
|
-
startHeartbeat() {
|
|
359
|
-
const interval = this.config.heartbeatInterval || 30000; // 30 seconds
|
|
360
|
-
const timeout = this.config.heartbeatTimeout || 10000; // 10 seconds
|
|
361
|
-
this.heartbeatTimer = setInterval(() => {
|
|
362
|
-
for (const client of this.clients.values()) {
|
|
363
|
-
if (!client.isAlive) {
|
|
364
|
-
// Client didn't respond to last ping
|
|
365
|
-
this.logger.warn('Client heartbeat timeout', { id: client.id });
|
|
366
|
-
client.ws.terminate();
|
|
367
|
-
this.clients.delete(client.id);
|
|
368
|
-
continue;
|
|
369
|
-
}
|
|
370
|
-
client.isAlive = false;
|
|
371
|
-
try {
|
|
372
|
-
client.ws.ping();
|
|
373
|
-
}
|
|
374
|
-
catch {
|
|
375
|
-
// Ignore ping errors
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}, interval);
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Stop heartbeat interval
|
|
382
|
-
*/
|
|
383
|
-
stopHeartbeat() {
|
|
384
|
-
if (this.heartbeatTimer) {
|
|
385
|
-
clearInterval(this.heartbeatTimer);
|
|
386
|
-
this.heartbeatTimer = undefined;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Create WebSocket transport
|
|
392
|
-
*/
|
|
393
|
-
export function createWebSocketTransport(logger, config) {
|
|
394
|
-
return new WebSocketTransport(logger, config);
|
|
395
|
-
}
|
|
396
|
-
//# sourceMappingURL=websocket.js.map
|