monomind 1.10.56 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/core/coordinator.md +71 -0
- package/.claude/agents/generated/case-analyst.md +50 -0
- package/.claude/agents/generated/copy-editor.md +45 -0
- package/.claude/agents/generated/court-reporter.md +50 -0
- package/.claude/agents/generated/defender.md +51 -0
- package/.claude/agents/generated/editor-in-chief.md +45 -0
- package/.claude/agents/generated/fact-checker.md +45 -0
- package/.claude/agents/generated/judge.md +51 -0
- package/.claude/agents/generated/prosecutor.md +51 -0
- package/.claude/agents/generated/reporter.md +45 -0
- package/.claude/commands/hooks/README.md +1 -1
- package/.claude/commands/hooks/overview.md +1 -1
- package/.claude/commands/mastermind/_repeat.md +1 -1
- package/.claude/commands/mastermind/do.md +3 -1
- package/.claude/commands/mastermind/help.md +2 -2
- package/.claude/commands/mastermind/master.md +39 -6
- package/.claude/commands/mastermind/memory.md +1 -1
- package/.claude/commands/memory/memory-search.md +2 -2
- package/.claude/commands/monitoring/status.md +1 -1
- package/.claude/commands/{browse.md → monobrowse.md} +2 -2
- package/.claude/commands/sparc.md +1 -1
- package/.claude/helpers/handlers/graph-status-handler.cjs +1 -1
- package/.claude/helpers/loop-tracker.cjs +1 -1
- package/.claude/scheduled_tasks.lock +1 -1
- package/.claude/skills/agent-browser-testing/SKILL.md +1 -1
- package/.claude/skills/hooks-automation/SKILL.md +0 -3
- package/.claude/skills/mastermind/build.md +1 -1
- package/.claude/skills/mastermind/code-quality-reviewer-prompt.md +60 -0
- package/.claude/skills/mastermind/content.md +1 -1
- package/.claude/skills/mastermind/createorg.md +79 -2
- package/.claude/skills/mastermind/design.md +3 -1
- package/.claude/skills/mastermind/finance.md +1 -1
- package/.claude/skills/mastermind/implementer-prompt.md +109 -0
- package/.claude/skills/mastermind/marketing.md +1 -1
- package/.claude/skills/mastermind/ops.md +1 -1
- package/.claude/skills/mastermind/plan.md +20 -2
- package/.claude/skills/mastermind/release.md +1 -1
- package/.claude/skills/mastermind/research.md +1 -1
- package/.claude/skills/mastermind/review.md +1 -1
- package/.claude/skills/mastermind/sales.md +1 -1
- package/.claude/skills/mastermind/spec-reviewer-prompt.md +63 -0
- package/.claude/skills/sparc-methodology/SKILL.md +3 -3
- package/.claude/skills/swarm-advanced/SKILL.md +1 -4
- package/.claude-plugin/README.md +1 -2
- package/.claude-plugin/docs/PLUGIN_SUMMARY.md +0 -1
- package/README.md +18 -32
- package/package.json +1 -1
- package/packages/@monomind/cli/README.md +18 -32
- package/packages/@monomind/cli/dist/src/agents/registry-builder.d.ts +1 -7
- package/packages/@monomind/cli/dist/src/agents/registry-builder.js +10 -6
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.d.ts +59 -12
- package/packages/@monomind/cli/dist/src/benchmarks/benchmark-runner.js +67 -13
- package/packages/@monomind/cli/dist/src/benchmarks/pretrain/index.d.ts +0 -13
- package/packages/@monomind/cli/dist/src/commands/agent-wasm.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/agent-wasm.js +5 -5
- package/packages/@monomind/cli/dist/src/commands/agent.js +1 -6
- package/packages/@monomind/cli/dist/src/commands/analyze.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/analyze.js +8 -18
- package/packages/@monomind/cli/dist/src/commands/doctor.js +53 -3
- package/packages/@monomind/cli/dist/src/commands/embeddings.js +9 -33
- package/packages/@monomind/cli/dist/src/commands/hooks.js +24 -76
- package/packages/@monomind/cli/dist/src/commands/index.d.ts +4 -6
- package/packages/@monomind/cli/dist/src/commands/index.js +8 -15
- package/packages/@monomind/cli/dist/src/commands/init.js +2 -2
- package/packages/@monomind/cli/dist/src/commands/issues.js +16 -11
- package/packages/@monomind/cli/dist/src/commands/mcp.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/memory.js +6 -6
- package/packages/@monomind/cli/dist/src/commands/migrate.js +1 -2
- package/packages/@monomind/cli/dist/src/commands/monograph.js +18 -11
- package/packages/@monomind/cli/dist/src/commands/monovector/backup.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/backup.js +25 -25
- package/packages/@monomind/cli/dist/src/commands/monovector/benchmark.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/benchmark.js +14 -14
- package/packages/@monomind/cli/dist/src/commands/monovector/import.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/import.js +21 -21
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/index.d.ts +6 -6
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/index.js +22 -22
- package/packages/@monomind/cli/dist/src/commands/monovector/init.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/init.js +36 -36
- package/packages/@monomind/cli/dist/src/commands/monovector/migrate.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/migrate.js +16 -16
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/optimize.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/optimize.js +10 -10
- package/packages/@monomind/cli/dist/src/commands/monovector/setup.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/setup.js +77 -77
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/status.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/{ruvector → monovector}/status.js +34 -34
- package/packages/@monomind/cli/dist/src/commands/neural.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/commands/neural.js +31 -608
- package/packages/@monomind/cli/dist/src/commands/performance.js +7 -10
- package/packages/@monomind/cli/dist/src/commands/plugins.js +3 -4
- package/packages/@monomind/cli/dist/src/commands/process.js +5 -12
- package/packages/@monomind/cli/dist/src/commands/progress.js +16 -16
- package/packages/@monomind/cli/dist/src/commands/route.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/commands/route.js +23 -23
- package/packages/@monomind/cli/dist/src/commands/status.js +0 -3
- package/packages/@monomind/cli/dist/src/commands/swarm.js +2 -3
- package/packages/@monomind/cli/dist/src/commands/update.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/config-adapter.js +27 -0
- package/packages/@monomind/cli/dist/src/consensus/audit-writer.d.ts +44 -17
- package/packages/@monomind/cli/dist/src/dlq/dlq-replayer.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/index.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/index.js +5 -5
- package/packages/@monomind/cli/dist/src/init/claudemd-generator.js +10 -14
- package/packages/@monomind/cli/dist/src/init/executor.js +17 -27
- package/packages/@monomind/cli/dist/src/init/helpers-generator.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/init/helpers-generator.js +2 -2
- package/packages/@monomind/cli/dist/src/init/types.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-client.js +1 -7
- package/packages/@monomind/cli/dist/src/mcp-server.js +9 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +1 -52
- package/packages/@monomind/cli/dist/src/mcp-tools/analyze-tools.js +5 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/mcp-tools/autopilot-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/browser-tools.js +6 -5
- package/packages/@monomind/cli/dist/src/mcp-tools/claims-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/coordination-tools.js +51 -54
- package/packages/@monomind/cli/dist/src/mcp-tools/daa-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/embeddings-tools.js +10 -10
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/guidance-tools.js +0 -24
- package/packages/@monomind/cli/dist/src/mcp-tools/hooks-tools.js +189 -446
- package/packages/@monomind/cli/dist/src/mcp-tools/index.d.ts +0 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/index.js +0 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.d.ts +334 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +1108 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +76 -34
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/neural-tools.js +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/progress-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/ruvllm-tools.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/mcp-tools/ruvllm-tools.js +3 -3
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/terminal-tools.js +29 -19
- package/packages/@monomind/cli/dist/src/mcp-tools/transfer-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/mcp-tools/wasm-agent-tools.js +2 -2
- package/packages/@monomind/cli/dist/src/memory/intelligence.js +14 -8
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +17 -2
- package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +76 -23
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/memory/memory-initializer.js +37 -39
- package/packages/@monomind/cli/dist/src/monovector/capabilities.d.ts +34 -0
- package/packages/@monomind/cli/dist/src/monovector/capabilities.js +37 -0
- package/packages/@monomind/cli/dist/src/monovector/command-outcomes.d.ts +37 -0
- package/packages/@monomind/cli/dist/src/monovector/command-outcomes.js +87 -0
- package/packages/@monomind/cli/dist/src/monovector/coverage-router.d.ts +103 -0
- package/packages/@monomind/cli/dist/src/monovector/coverage-router.js +337 -0
- package/packages/@monomind/cli/dist/src/monovector/coverage-tools.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/monovector/coverage-tools.js +112 -0
- package/packages/@monomind/cli/dist/src/{ruvector → monovector}/diff-classifier.d.ts +2 -2
- package/packages/@monomind/cli/dist/src/monovector/index.d.ts +61 -0
- package/packages/@monomind/cli/dist/src/monovector/index.js +67 -0
- package/packages/@monomind/cli/dist/src/monovector/init-state.d.ts +35 -0
- package/packages/@monomind/cli/dist/src/monovector/init-state.js +36 -0
- package/packages/@monomind/cli/dist/src/monovector/route-outcomes.d.ts +55 -0
- package/packages/@monomind/cli/dist/src/monovector/route-outcomes.js +137 -0
- package/packages/@monomind/cli/dist/src/parser.js +3 -3
- package/packages/@monomind/cli/dist/src/plugins/store/discovery.js +0 -31
- package/packages/@monomind/cli/dist/src/production/circuit-breaker.d.ts +26 -6
- package/packages/@monomind/cli/dist/src/production/error-handler.d.ts +55 -30
- package/packages/@monomind/cli/dist/src/production/index.d.ts +3 -20
- package/packages/@monomind/cli/dist/src/production/index.js +3 -15
- package/packages/@monomind/cli/dist/src/production/monitoring.d.ts +54 -34
- package/packages/@monomind/cli/dist/src/production/monitoring.js +12 -14
- package/packages/@monomind/cli/dist/src/production/rate-limiter.d.ts +64 -19
- package/packages/@monomind/cli/dist/src/production/rate-limiter.js +5 -5
- package/packages/@monomind/cli/dist/src/production/retry.js +4 -2
- package/packages/@monomind/cli/dist/src/runtime/headless.d.ts +3 -3
- package/packages/@monomind/cli/dist/src/services/claim-service.d.ts +50 -59
- package/packages/@monomind/cli/dist/src/services/claim-service.js +83 -50
- package/packages/@monomind/cli/dist/src/services/config-file-manager.js +8 -1
- package/packages/@monomind/cli/dist/src/services/worker-daemon.js +4 -0
- package/packages/@monomind/cli/dist/src/transfer/ipfs/upload.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/transfer/storage/gcs.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/types.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/update/checker.d.ts +1 -1
- package/packages/@monomind/cli/dist/src/update/index.d.ts +1 -1
- package/packages/@monomind/cli/package.json +13 -13
- package/packages/@monomind/guidance/dist/index.d.ts +1 -1
- package/packages/@monomind/guidance/dist/index.js +1 -1
- package/packages/@monomind/guidance/package.json +1 -2
- package/scripts/build-monovector.sh +10 -0
- package/scripts/publish-monovector.sh +20 -0
- package/.claude/commands/monomind/adr.md +0 -11
- package/.claude/commands/monomind/budget.md +0 -7
- package/.claude/commands/monomind/createtask.md +0 -277
- package/.claude/commands/monomind/do.md +0 -498
- package/.claude/commands/monomind/graph-status.md +0 -7
- package/.claude/commands/monomind/help.md +0 -118
- package/.claude/commands/monomind/idea.md +0 -273
- package/.claude/commands/monomind/improve.md +0 -352
- package/.claude/commands/monomind/loops.md +0 -7
- package/.claude/commands/monomind/memory.md +0 -230
- package/.claude/commands/monomind/repeat.md +0 -257
- package/.claude/commands/monomind/review.md +0 -317
- package/.claude/commands/monomind/specialagents.md +0 -125
- package/.claude/commands/monomind/swarm.md +0 -161
- package/.claude/commands/monomind/understand.md +0 -139
- package/.claude/commands/training/README.md +0 -39
- package/.claude/commands/training/neural-patterns.md +0 -73
- package/.claude/commands/training/neural-train.md +0 -79
- package/packages/@monomind/cli/dist/src/commands/appliance-advanced.d.ts +0 -9
- package/packages/@monomind/cli/dist/src/commands/appliance-advanced.js +0 -238
- package/packages/@monomind/cli/dist/src/commands/appliance.d.ts +0 -8
- package/packages/@monomind/cli/dist/src/commands/appliance.js +0 -406
- package/packages/@monomind/cli/dist/src/commands/ruvector/backup.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/ruvector/benchmark.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/ruvector/import.d.ts +0 -18
- package/packages/@monomind/cli/dist/src/commands/ruvector/init.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/ruvector/migrate.d.ts +0 -11
- package/packages/@monomind/cli/dist/src/commands/ruvector/setup.d.ts +0 -18
- package/packages/@monomind/cli/dist/src/ruvector/agent-wasm.d.ts +0 -182
- package/packages/@monomind/cli/dist/src/ruvector/agent-wasm.js +0 -316
- package/packages/@monomind/cli/dist/src/ruvector/ast-analyzer.d.ts +0 -67
- package/packages/@monomind/cli/dist/src/ruvector/ast-analyzer.js +0 -277
- package/packages/@monomind/cli/dist/src/ruvector/coverage-router.d.ts +0 -160
- package/packages/@monomind/cli/dist/src/ruvector/coverage-router.js +0 -539
- package/packages/@monomind/cli/dist/src/ruvector/coverage-tools.d.ts +0 -33
- package/packages/@monomind/cli/dist/src/ruvector/coverage-tools.js +0 -157
- package/packages/@monomind/cli/dist/src/ruvector/enhanced-model-router.d.ts +0 -146
- package/packages/@monomind/cli/dist/src/ruvector/enhanced-model-router.js +0 -551
- package/packages/@monomind/cli/dist/src/ruvector/flash-attention.d.ts +0 -195
- package/packages/@monomind/cli/dist/src/ruvector/flash-attention.js +0 -643
- package/packages/@monomind/cli/dist/src/ruvector/graph-analyzer.d.ts +0 -187
- package/packages/@monomind/cli/dist/src/ruvector/graph-analyzer.js +0 -929
- package/packages/@monomind/cli/dist/src/ruvector/index.d.ts +0 -56
- package/packages/@monomind/cli/dist/src/ruvector/index.js +0 -58
- package/packages/@monomind/cli/dist/src/ruvector/lora-adapter.d.ts +0 -218
- package/packages/@monomind/cli/dist/src/ruvector/lora-adapter.js +0 -455
- package/packages/@monomind/cli/dist/src/ruvector/model-router.d.ts +0 -222
- package/packages/@monomind/cli/dist/src/ruvector/model-router.js +0 -512
- package/packages/@monomind/cli/dist/src/ruvector/moe-router.d.ts +0 -213
- package/packages/@monomind/cli/dist/src/ruvector/moe-router.js +0 -649
- package/packages/@monomind/cli/dist/src/ruvector/q-learning-router.d.ts +0 -217
- package/packages/@monomind/cli/dist/src/ruvector/q-learning-router.js +0 -712
- package/packages/@monomind/cli/dist/src/ruvector/ruvllm-wasm.d.ts +0 -179
- package/packages/@monomind/cli/dist/src/ruvector/ruvllm-wasm.js +0 -363
- package/packages/@monomind/cli/dist/src/ruvector/semantic-router.d.ts +0 -77
- package/packages/@monomind/cli/dist/src/ruvector/semantic-router.js +0 -178
- package/packages/@monomind/cli/dist/src/ruvector/vector-db.d.ts +0 -69
- package/packages/@monomind/cli/dist/src/ruvector/vector-db.js +0 -243
- package/packages/@monomind/cli/dist/src/services/ruvector-training.d.ts +0 -222
- package/packages/@monomind/cli/dist/src/services/ruvector-training.js +0 -696
- /package/packages/@monomind/cli/dist/src/{ruvector → monovector}/diff-classifier.js +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MonoVector Integration Module for Monomind CLI (lean)
|
|
3
|
+
*
|
|
4
|
+
* After the SONA / native / WASM teardown this module provides only the
|
|
5
|
+
* lightweight surface:
|
|
6
|
+
* - Capability probing: getCapabilities() — stubbed, always reports JS-only
|
|
7
|
+
* - Initialization state: createInitState()
|
|
8
|
+
* - Keyword-based task routing: createKeywordRouter()
|
|
9
|
+
* - Route recommendation→outcome records: recordRoute(), joinOutcome(), accuracy
|
|
10
|
+
* - AST diff classification: DiffClassifier
|
|
11
|
+
*
|
|
12
|
+
* @module @monomind/cli/monovector
|
|
13
|
+
*/
|
|
14
|
+
import { getCapabilities } from './capabilities.js';
|
|
15
|
+
export { getCapabilities, getCachedCapabilities, resetCapabilitiesCache, refreshCapabilities } from './capabilities.js';
|
|
16
|
+
export { createInitState } from './init-state.js';
|
|
17
|
+
export { recordRoute, joinOutcome, joinLatestUnresolved, readOutcomes, computeRoutingAccuracy, computeAdherence, } from './route-outcomes.js';
|
|
18
|
+
export { DiffClassifier, createDiffClassifier, analyzeDiff, analyzeDiffSync, assessFileRisk, assessOverallRisk, classifyDiff, suggestReviewers, getGitDiffNumstat, getGitDiffNumstatAsync, clearDiffCache, clearAllDiffCaches, } from './diff-classifier.js';
|
|
19
|
+
export function createKeywordRouter(_config) {
|
|
20
|
+
const agentTypes = ['coder', 'tester', 'reviewer', 'architect', 'researcher', 'optimizer', 'debugger', 'documenter'];
|
|
21
|
+
return {
|
|
22
|
+
async route(task) {
|
|
23
|
+
const lower = task.toLowerCase();
|
|
24
|
+
let agentType = 'coder';
|
|
25
|
+
if (lower.includes('test'))
|
|
26
|
+
agentType = 'tester';
|
|
27
|
+
else if (lower.includes('review') || lower.includes('security'))
|
|
28
|
+
agentType = 'reviewer';
|
|
29
|
+
else if (lower.includes('design') || lower.includes('architect'))
|
|
30
|
+
agentType = 'architect';
|
|
31
|
+
else if (lower.includes('research') || lower.includes('analyz'))
|
|
32
|
+
agentType = 'researcher';
|
|
33
|
+
else if (lower.includes('optim') || lower.includes('perform'))
|
|
34
|
+
agentType = 'optimizer';
|
|
35
|
+
else if (lower.includes('debug') || lower.includes('fix') || lower.includes('bug'))
|
|
36
|
+
agentType = 'debugger';
|
|
37
|
+
else if (lower.includes('doc'))
|
|
38
|
+
agentType = 'documenter';
|
|
39
|
+
return {
|
|
40
|
+
agentType,
|
|
41
|
+
confidence: 0.75,
|
|
42
|
+
reasoning: 'keyword-based routing',
|
|
43
|
+
route: agentType,
|
|
44
|
+
qValues: [],
|
|
45
|
+
explored: false,
|
|
46
|
+
alternatives: agentTypes.filter(a => a !== agentType).slice(0, 3).map(a => ({ route: a, score: 0 })),
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
async initialize() { },
|
|
50
|
+
getStats() {
|
|
51
|
+
return { updateCount: 0, qTableSize: 0, stepCount: 0, epsilon: 0, avgTDError: 0, useNative: 0 };
|
|
52
|
+
},
|
|
53
|
+
update() { return 0; },
|
|
54
|
+
reset() { },
|
|
55
|
+
export() { return {}; },
|
|
56
|
+
import() { },
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** @deprecated Use (await getCapabilities()).sona */
|
|
60
|
+
export async function isMonovectorAvailable() {
|
|
61
|
+
return (await getCapabilities()).sona;
|
|
62
|
+
}
|
|
63
|
+
/** @deprecated Use (await getCapabilities()).learningWasm */
|
|
64
|
+
export async function isWasmBackendAvailable() {
|
|
65
|
+
return (await getCapabilities()).learningWasm;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable init-state tracker with a counter-with-max pattern.
|
|
3
|
+
*
|
|
4
|
+
* - Allows transient failures (returns NOT_READY) without permanently disabling
|
|
5
|
+
* - Permanently disables after maxAttempts consecutive failures
|
|
6
|
+
* - Thread-safe for single-threaded JS (no concurrent writes)
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const state = createInitState({ maxAttempts: 3 });
|
|
10
|
+
* if (state.canTry()) {
|
|
11
|
+
* try { ... state.markReady(); }
|
|
12
|
+
* catch { state.markFailed(); }
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export type InitStatus = 'pending' | 'ready' | 'failed';
|
|
16
|
+
export interface InitState {
|
|
17
|
+
/** True if another init attempt should be made */
|
|
18
|
+
canTry(): boolean;
|
|
19
|
+
/** Mark initialization as permanently successful */
|
|
20
|
+
markReady(): void;
|
|
21
|
+
/** Mark this attempt as failed; permanently fails after maxAttempts */
|
|
22
|
+
markFailed(): void;
|
|
23
|
+
/** Immediately mark as permanently failed without consuming retry budget */
|
|
24
|
+
markPermanentlyFailed(): void;
|
|
25
|
+
/** True if init succeeded */
|
|
26
|
+
isReady(): boolean;
|
|
27
|
+
/** True if permanently failed (exhausted retries) */
|
|
28
|
+
isFailed(): boolean;
|
|
29
|
+
/** Number of failed attempts so far */
|
|
30
|
+
attempts(): number;
|
|
31
|
+
}
|
|
32
|
+
export declare function createInitState(opts?: {
|
|
33
|
+
maxAttempts?: number;
|
|
34
|
+
}): InitState;
|
|
35
|
+
//# sourceMappingURL=init-state.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable init-state tracker with a counter-with-max pattern.
|
|
3
|
+
*
|
|
4
|
+
* - Allows transient failures (returns NOT_READY) without permanently disabling
|
|
5
|
+
* - Permanently disables after maxAttempts consecutive failures
|
|
6
|
+
* - Thread-safe for single-threaded JS (no concurrent writes)
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* const state = createInitState({ maxAttempts: 3 });
|
|
10
|
+
* if (state.canTry()) {
|
|
11
|
+
* try { ... state.markReady(); }
|
|
12
|
+
* catch { state.markFailed(); }
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
export function createInitState(opts = {}) {
|
|
16
|
+
const max = opts.maxAttempts ?? 3;
|
|
17
|
+
let status = 'pending';
|
|
18
|
+
let count = 0;
|
|
19
|
+
return {
|
|
20
|
+
canTry() { return status === 'pending' && count < max; },
|
|
21
|
+
markReady() { status = 'ready'; },
|
|
22
|
+
markFailed() {
|
|
23
|
+
count++;
|
|
24
|
+
if (count >= max)
|
|
25
|
+
status = 'failed';
|
|
26
|
+
},
|
|
27
|
+
markPermanentlyFailed() {
|
|
28
|
+
count = max;
|
|
29
|
+
status = 'failed';
|
|
30
|
+
},
|
|
31
|
+
isReady() { return status === 'ready'; },
|
|
32
|
+
isFailed() { return status === 'failed'; },
|
|
33
|
+
attempts() { return count; },
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=init-state.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface RouteOutcomeRecord {
|
|
2
|
+
routeId: string;
|
|
3
|
+
ts: number;
|
|
4
|
+
task: string;
|
|
5
|
+
recommendedAgent: string;
|
|
6
|
+
routingMethod: string;
|
|
7
|
+
confidence: number;
|
|
8
|
+
learningMode: 'native' | 'js';
|
|
9
|
+
agentActuallyUsed?: string;
|
|
10
|
+
measuredSuccess?: boolean;
|
|
11
|
+
quality?: number;
|
|
12
|
+
}
|
|
13
|
+
/** Append a route recommendation (pre-outcome). */
|
|
14
|
+
export declare function recordRoute(baseDir: string, rec: RouteOutcomeRecord): Promise<void>;
|
|
15
|
+
/** Join outcome data onto the most recent matching route record by routeId. */
|
|
16
|
+
export declare function joinOutcome(baseDir: string, routeId: string, outcome: {
|
|
17
|
+
agentActuallyUsed?: string;
|
|
18
|
+
measuredSuccess?: boolean;
|
|
19
|
+
quality?: number;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Join an outcome to the most recent route record that has no measured outcome yet.
|
|
23
|
+
* Used when the caller does not thread an explicit routeId — auto-correlates the
|
|
24
|
+
* latest recommendation to the next task completion. Returns the joined routeId or null.
|
|
25
|
+
*/
|
|
26
|
+
export declare function joinLatestUnresolved(baseDir: string, outcome: {
|
|
27
|
+
agentActuallyUsed?: string;
|
|
28
|
+
measuredSuccess?: boolean;
|
|
29
|
+
quality?: number;
|
|
30
|
+
}, maxAgeMs?: number): Promise<string | null>;
|
|
31
|
+
/** Read all outcome records (for metrics). */
|
|
32
|
+
export declare function readOutcomes(baseDir: string): Promise<RouteOutcomeRecord[]>;
|
|
33
|
+
export interface RoutingAccuracy {
|
|
34
|
+
window: number;
|
|
35
|
+
totalWithOutcome: number;
|
|
36
|
+
accuracy: number | null;
|
|
37
|
+
byMode: {
|
|
38
|
+
native: number | null;
|
|
39
|
+
js: number | null;
|
|
40
|
+
};
|
|
41
|
+
recentVsPrior: number | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Compute routing accuracy over the most recent N records that have a joined outcome.
|
|
45
|
+
* accuracy = fraction of records whose joined outcome reports measuredSuccess === true.
|
|
46
|
+
* (agentActuallyUsed is recorded per row but not required to match the recommendation;
|
|
47
|
+
* the success label already reflects whether the chosen routing worked out.)
|
|
48
|
+
*/
|
|
49
|
+
export declare function computeRoutingAccuracy(baseDir: string, window?: number): Promise<RoutingAccuracy>;
|
|
50
|
+
/** Fraction of joined routes where the agent actually used matched the recommendation. */
|
|
51
|
+
export declare function computeAdherence(baseDir: string, window?: number): Promise<{
|
|
52
|
+
adherence: number | null;
|
|
53
|
+
sample: number;
|
|
54
|
+
}>;
|
|
55
|
+
//# sourceMappingURL=route-outcomes.d.ts.map
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-route outcome records — the join between a routing recommendation and
|
|
3
|
+
* what actually happened. This is the foundation for routing-accuracy metrics
|
|
4
|
+
* and for giving SONA a real training label.
|
|
5
|
+
*/
|
|
6
|
+
import { promises as fs } from 'node:fs';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
function storePath(baseDir) {
|
|
9
|
+
return join(baseDir, 'route-outcomes.jsonl');
|
|
10
|
+
}
|
|
11
|
+
/** Append a route recommendation (pre-outcome). */
|
|
12
|
+
export async function recordRoute(baseDir, rec) {
|
|
13
|
+
try {
|
|
14
|
+
await fs.mkdir(baseDir, { recursive: true });
|
|
15
|
+
await fs.appendFile(storePath(baseDir), JSON.stringify(rec) + '\n', 'utf8');
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Non-fatal — telemetry must never break routing
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Join outcome data onto the most recent matching route record by routeId. */
|
|
22
|
+
export async function joinOutcome(baseDir, routeId, outcome) {
|
|
23
|
+
try {
|
|
24
|
+
const path = storePath(baseDir);
|
|
25
|
+
const content = await fs.readFile(path, 'utf8').catch(() => '');
|
|
26
|
+
if (!content)
|
|
27
|
+
return;
|
|
28
|
+
const lines = content.trim().split('\n');
|
|
29
|
+
// Find the last record with this routeId and merge outcome
|
|
30
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
31
|
+
try {
|
|
32
|
+
const rec = JSON.parse(lines[i]);
|
|
33
|
+
if (rec.routeId === routeId) {
|
|
34
|
+
lines[i] = JSON.stringify({ ...rec, ...outcome });
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch { /* skip malformed line */ }
|
|
39
|
+
}
|
|
40
|
+
await fs.writeFile(path, lines.join('\n') + '\n', 'utf8');
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// Non-fatal
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Join an outcome to the most recent route record that has no measured outcome yet.
|
|
48
|
+
* Used when the caller does not thread an explicit routeId — auto-correlates the
|
|
49
|
+
* latest recommendation to the next task completion. Returns the joined routeId or null.
|
|
50
|
+
*/
|
|
51
|
+
export async function joinLatestUnresolved(baseDir, outcome, maxAgeMs = 600_000 // only correlate within 10 minutes to avoid stale joins
|
|
52
|
+
) {
|
|
53
|
+
try {
|
|
54
|
+
const path = storePath(baseDir);
|
|
55
|
+
const content = await fs.readFile(path, 'utf8').catch(() => '');
|
|
56
|
+
if (!content)
|
|
57
|
+
return null;
|
|
58
|
+
const lines = content.trim().split('\n');
|
|
59
|
+
const now = Date.now();
|
|
60
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
61
|
+
try {
|
|
62
|
+
const rec = JSON.parse(lines[i]);
|
|
63
|
+
// Skip already-joined records
|
|
64
|
+
if (typeof rec.measuredSuccess === 'boolean')
|
|
65
|
+
continue;
|
|
66
|
+
// Skip stale records beyond the correlation window
|
|
67
|
+
if (now - rec.ts > maxAgeMs)
|
|
68
|
+
return null;
|
|
69
|
+
lines[i] = JSON.stringify({ ...rec, ...outcome });
|
|
70
|
+
await fs.writeFile(path, lines.join('\n') + '\n', 'utf8');
|
|
71
|
+
return rec.routeId;
|
|
72
|
+
}
|
|
73
|
+
catch { /* skip malformed */ }
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Read all outcome records (for metrics). */
|
|
82
|
+
export async function readOutcomes(baseDir) {
|
|
83
|
+
try {
|
|
84
|
+
const content = await fs.readFile(storePath(baseDir), 'utf8').catch(() => '');
|
|
85
|
+
if (!content)
|
|
86
|
+
return [];
|
|
87
|
+
return content.trim().split('\n').map(l => {
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(l);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
}).filter((r) => r !== null);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Compute routing accuracy over the most recent N records that have a joined outcome.
|
|
102
|
+
* accuracy = fraction of records whose joined outcome reports measuredSuccess === true.
|
|
103
|
+
* (agentActuallyUsed is recorded per row but not required to match the recommendation;
|
|
104
|
+
* the success label already reflects whether the chosen routing worked out.)
|
|
105
|
+
*/
|
|
106
|
+
export async function computeRoutingAccuracy(baseDir, window = 100) {
|
|
107
|
+
const all = await readOutcomes(baseDir);
|
|
108
|
+
// Only records with a measured outcome count
|
|
109
|
+
const withOutcome = all.filter(r => typeof r.measuredSuccess === 'boolean').slice(-window);
|
|
110
|
+
const n = withOutcome.length;
|
|
111
|
+
if (n === 0) {
|
|
112
|
+
return { window, totalWithOutcome: 0, accuracy: null, byMode: { native: null, js: null }, recentVsPrior: null };
|
|
113
|
+
}
|
|
114
|
+
const succ = (recs) => recs.length ? recs.filter(r => r.measuredSuccess).length / recs.length : null;
|
|
115
|
+
const native = withOutcome.filter(r => r.learningMode === 'native');
|
|
116
|
+
const js = withOutcome.filter(r => r.learningMode === 'js');
|
|
117
|
+
const mid = Math.floor(n / 2);
|
|
118
|
+
const prior = succ(withOutcome.slice(0, mid));
|
|
119
|
+
const recent = succ(withOutcome.slice(mid));
|
|
120
|
+
return {
|
|
121
|
+
window,
|
|
122
|
+
totalWithOutcome: n,
|
|
123
|
+
accuracy: succ(withOutcome),
|
|
124
|
+
byMode: { native: succ(native), js: succ(js) },
|
|
125
|
+
recentVsPrior: (recent !== null && prior !== null) ? recent - prior : null,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** Fraction of joined routes where the agent actually used matched the recommendation. */
|
|
129
|
+
export async function computeAdherence(baseDir, window = 100) {
|
|
130
|
+
const all = await readOutcomes(baseDir);
|
|
131
|
+
const joined = all.filter(r => r.agentActuallyUsed && r.recommendedAgent).slice(-window);
|
|
132
|
+
if (joined.length === 0)
|
|
133
|
+
return { adherence: null, sample: 0 };
|
|
134
|
+
const matches = joined.filter(r => r.agentActuallyUsed === r.recommendedAgent).length;
|
|
135
|
+
return { adherence: matches / joined.length, sample: joined.length };
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=route-outcomes.js.map
|
|
@@ -61,10 +61,10 @@ export class CommandParser {
|
|
|
61
61
|
choices: ['text', 'json', 'table']
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
|
-
name: '
|
|
65
|
-
description: '
|
|
64
|
+
name: 'color',
|
|
65
|
+
description: 'Enable colored output (use --no-color to disable)',
|
|
66
66
|
type: 'boolean',
|
|
67
|
-
default:
|
|
67
|
+
default: true
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
70
|
name: 'interactive',
|
|
@@ -204,7 +204,6 @@ export class PluginDiscoveryService {
|
|
|
204
204
|
newest: ['@monomind/plugin-agentic-qe', '@monomind/plugin-prime-radiant'],
|
|
205
205
|
official: ['@monomind/plugin-agentic-qe', '@monomind/plugin-prime-radiant', '@monomind/security', '@monomind/claims'],
|
|
206
206
|
compatibilityMatrix: [
|
|
207
|
-
{ pluginId: '@monomind/neural', pluginVersion: '3.0.0', monomindVersions: ['3.x'], tested: true },
|
|
208
207
|
{ pluginId: '@monomind/security', pluginVersion: '3.0.0', monomindVersions: ['3.x'], tested: true },
|
|
209
208
|
],
|
|
210
209
|
};
|
|
@@ -243,35 +242,6 @@ export class PluginDiscoveryService {
|
|
|
243
242
|
reputation: 85,
|
|
244
243
|
};
|
|
245
244
|
return [
|
|
246
|
-
{
|
|
247
|
-
id: '@monomind/neural',
|
|
248
|
-
name: '@monomind/neural',
|
|
249
|
-
displayName: 'Neural Patterns',
|
|
250
|
-
description: 'Neural pattern training and inference with WASM SIMD acceleration, MoE routing, and Flash Attention optimization',
|
|
251
|
-
version: '3.0.0',
|
|
252
|
-
cid: 'bafybeineuralpatternplugin',
|
|
253
|
-
size: 245000,
|
|
254
|
-
checksum: 'sha256:abc123neural',
|
|
255
|
-
author: officialAuthor,
|
|
256
|
-
license: 'MIT',
|
|
257
|
-
categories: ['ai-ml'],
|
|
258
|
-
tags: ['neural', 'training', 'inference', 'wasm', 'simd'],
|
|
259
|
-
keywords: ['neural', 'patterns', 'ml'],
|
|
260
|
-
downloads: 15000,
|
|
261
|
-
rating: 4.9,
|
|
262
|
-
ratingCount: 245,
|
|
263
|
-
lastUpdated: baseTime,
|
|
264
|
-
createdAt: '2024-01-01T00:00:00Z',
|
|
265
|
-
minMonomindVersion: '3.0.0',
|
|
266
|
-
dependencies: [{ name: '@monomind/core', version: '^3.0.0' }],
|
|
267
|
-
type: 'core',
|
|
268
|
-
hooks: ['neural:train', 'neural:inference', 'pattern:learn'],
|
|
269
|
-
commands: ['neural train', 'neural predict', 'neural patterns'],
|
|
270
|
-
permissions: ['memory', 'network'],
|
|
271
|
-
exports: ['NeuralTrainer', 'PatternRecognizer', 'FlashAttention'],
|
|
272
|
-
verified: true,
|
|
273
|
-
trustLevel: 'official',
|
|
274
|
-
},
|
|
275
245
|
{
|
|
276
246
|
id: '@monomind/security',
|
|
277
247
|
name: '@monomind/security',
|
|
@@ -743,7 +713,6 @@ export class PluginDiscoveryService {
|
|
|
743
713
|
'@monomind/security',
|
|
744
714
|
'@monomind/plugins',
|
|
745
715
|
'@monomind/embeddings',
|
|
746
|
-
'@monomind/neural',
|
|
747
716
|
'@monomind/performance',
|
|
748
717
|
'@monomind/teammate-plugin',
|
|
749
718
|
// Gas Town Bridge
|
|
@@ -6,20 +6,40 @@
|
|
|
6
6
|
* - Open: Failing fast, not calling service
|
|
7
7
|
* - Half-Open: Testing if service recovered
|
|
8
8
|
*
|
|
9
|
-
* @module @
|
|
9
|
+
* @module @monomind/cli/production/circuit-breaker
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Circuit breaker states.
|
|
13
|
+
* - `closed`: Normal operation, requests pass through.
|
|
14
|
+
* - `open`: Failing fast, requests are rejected immediately.
|
|
15
|
+
* - `half-open`: Testing recovery, a percentage of requests pass through.
|
|
10
16
|
*/
|
|
11
17
|
export type CircuitState = 'closed' | 'open' | 'half-open';
|
|
18
|
+
/**
|
|
19
|
+
* Circuit breaker configuration options.
|
|
20
|
+
*/
|
|
12
21
|
export interface CircuitBreakerConfig {
|
|
22
|
+
/** Number of failures within the window before opening the circuit. */
|
|
13
23
|
failureThreshold: number;
|
|
24
|
+
/** Time (ms) to wait in the open state before transitioning to half-open. */
|
|
14
25
|
resetTimeoutMs: number;
|
|
26
|
+
/** Number of consecutive successes in half-open before closing. */
|
|
15
27
|
successThreshold: number;
|
|
28
|
+
/** Sliding window (ms) over which failures are counted. */
|
|
16
29
|
failureWindowMs: number;
|
|
30
|
+
/** Fraction of requests (0-1) allowed through while half-open. */
|
|
17
31
|
halfOpenRequestPercentage: number;
|
|
18
|
-
|
|
19
|
-
onOpen?: (
|
|
32
|
+
/** Called when the circuit transitions to the open state. */
|
|
33
|
+
onOpen?: (failureCount: number) => void;
|
|
34
|
+
/** Called when the circuit transitions to the closed state. */
|
|
20
35
|
onClose?: () => void;
|
|
36
|
+
/** Called on any state transition. */
|
|
37
|
+
onStateChange?: (oldState: CircuitState, newState: CircuitState) => void;
|
|
21
38
|
}
|
|
22
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Snapshot of circuit breaker statistics.
|
|
41
|
+
*/
|
|
42
|
+
export interface CircuitBreakerStats {
|
|
23
43
|
state: CircuitState;
|
|
24
44
|
failures: number;
|
|
25
45
|
successes: number;
|
|
@@ -77,7 +97,7 @@ export declare class CircuitBreaker {
|
|
|
77
97
|
/**
|
|
78
98
|
* Get circuit statistics
|
|
79
99
|
*/
|
|
80
|
-
getStats():
|
|
100
|
+
getStats(): CircuitBreakerStats;
|
|
81
101
|
/**
|
|
82
102
|
* Get failure rate
|
|
83
103
|
*/
|
|
@@ -92,7 +112,7 @@ export declare function getCircuitBreaker(name: string, config?: Partial<Circuit
|
|
|
92
112
|
/**
|
|
93
113
|
* Get all circuit breaker stats
|
|
94
114
|
*/
|
|
95
|
-
export declare function getAllCircuitStats(): Record<string,
|
|
115
|
+
export declare function getAllCircuitStats(): Record<string, CircuitBreakerStats>;
|
|
96
116
|
/**
|
|
97
117
|
* Reset all circuit breakers
|
|
98
118
|
*/
|
|
@@ -9,36 +9,66 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @module @monomind/cli/production/error-handler
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
timestamp: string;
|
|
20
|
-
}
|
|
12
|
+
/**
|
|
13
|
+
* Error category derived from message-pattern classification.
|
|
14
|
+
*/
|
|
15
|
+
export type ErrorCategory = 'validation' | 'authentication' | 'authorization' | 'not_found' | 'rate_limit' | 'timeout' | 'circuit_open' | 'external_service' | 'internal' | 'unknown';
|
|
16
|
+
/**
|
|
17
|
+
* Configuration for the {@link ErrorHandler}.
|
|
18
|
+
*/
|
|
21
19
|
export interface ErrorHandlerConfig {
|
|
20
|
+
/** Include stack traces in structured errors (default: off in production). */
|
|
22
21
|
includeStack: boolean;
|
|
22
|
+
/** Redact sensitive keys/values from context and messages. */
|
|
23
23
|
sanitize: boolean;
|
|
24
|
+
/** Whether errors should be forwarded to monitoring. */
|
|
24
25
|
reportToMonitoring: boolean;
|
|
26
|
+
/** Per-category cap before responses are rate-limited. */
|
|
25
27
|
maxErrorsPerMinute: number;
|
|
26
|
-
|
|
28
|
+
/** Optional per-category overrides. */
|
|
29
|
+
errorCategories: Record<string, unknown>;
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Contextual metadata attached to a handled error.
|
|
33
|
+
*/
|
|
34
|
+
export interface ErrorContext {
|
|
35
|
+
/** The input that triggered the error (sanitized when handled). */
|
|
36
|
+
input?: unknown;
|
|
37
|
+
/** Arbitrary additional context fields. */
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The error payload embedded in a structured error response.
|
|
42
|
+
*/
|
|
43
|
+
export interface StructuredErrorPayload {
|
|
44
|
+
code: string;
|
|
45
|
+
message: string;
|
|
46
|
+
category: ErrorCategory;
|
|
47
|
+
retryable: boolean;
|
|
48
|
+
retryAfterMs?: number;
|
|
49
|
+
details?: {
|
|
50
|
+
stack: string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A standardized, structured error response.
|
|
55
|
+
*/
|
|
29
56
|
export interface StructuredError {
|
|
30
57
|
success: false;
|
|
31
|
-
error:
|
|
32
|
-
|
|
33
|
-
message: string;
|
|
34
|
-
category: ErrorCategory;
|
|
35
|
-
retryable: boolean;
|
|
36
|
-
retryAfterMs?: number;
|
|
37
|
-
details?: Record<string, unknown>;
|
|
38
|
-
};
|
|
39
|
-
context?: Partial<ErrorContext>;
|
|
58
|
+
error: StructuredErrorPayload;
|
|
59
|
+
context: ErrorContext;
|
|
40
60
|
timestamp: string;
|
|
41
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Aggregated error statistics returned by {@link ErrorHandler.getStats}.
|
|
64
|
+
*/
|
|
65
|
+
export interface ErrorStats {
|
|
66
|
+
totalErrors: number;
|
|
67
|
+
byCategory: Record<string, number>;
|
|
68
|
+
recentErrors: StructuredError[];
|
|
69
|
+
/** Errors per minute over the last 5 minutes. */
|
|
70
|
+
errorRate: number;
|
|
71
|
+
}
|
|
42
72
|
export declare class ErrorHandler {
|
|
43
73
|
private config;
|
|
44
74
|
private errorCounts;
|
|
@@ -58,24 +88,19 @@ export declare class ErrorHandler {
|
|
|
58
88
|
* Cycle-safe and depth-bounded — circular references and deeply nested objects
|
|
59
89
|
* will not cause stack overflow.
|
|
60
90
|
*/
|
|
61
|
-
sanitize(input:
|
|
91
|
+
sanitize(input: unknown, _seen?: WeakSet<object>, _depth?: number): unknown;
|
|
62
92
|
/**
|
|
63
93
|
* Handle an error and return a structured response
|
|
64
94
|
*/
|
|
65
|
-
handle(error: Error | string, context?:
|
|
95
|
+
handle(error: Error | string, context?: ErrorContext): StructuredError;
|
|
66
96
|
/**
|
|
67
97
|
* Wrap a handler with error handling
|
|
68
98
|
*/
|
|
69
|
-
wrap<
|
|
99
|
+
wrap<TArgs extends unknown[], TResult>(handler: (...args: TArgs) => Promise<TResult>, context?: ErrorContext): (...args: TArgs) => Promise<TResult | StructuredError>;
|
|
70
100
|
/**
|
|
71
101
|
* Get error statistics
|
|
72
102
|
*/
|
|
73
|
-
getStats():
|
|
74
|
-
totalErrors: number;
|
|
75
|
-
byCategory: Record<string, number>;
|
|
76
|
-
recentErrors: StructuredError[];
|
|
77
|
-
errorRate: number;
|
|
78
|
-
};
|
|
103
|
+
getStats(): ErrorStats;
|
|
79
104
|
/**
|
|
80
105
|
* Clear error log
|
|
81
106
|
*/
|
|
@@ -89,6 +114,6 @@ export declare class ErrorHandler {
|
|
|
89
114
|
/**
|
|
90
115
|
* Wrap a handler with error handling (convenience function)
|
|
91
116
|
*/
|
|
92
|
-
export declare function withErrorHandling<
|
|
117
|
+
export declare function withErrorHandling<TArgs extends unknown[], TResult>(handler: (...args: TArgs) => Promise<TResult>, context?: ErrorContext): (...args: TArgs) => Promise<TResult | StructuredError>;
|
|
93
118
|
export default ErrorHandler;
|
|
94
119
|
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -1,23 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V1 Production Hardening Module
|
|
3
|
-
*
|
|
4
|
-
* Provides production-grade utilities:
|
|
5
|
-
* - Error handling middleware
|
|
6
|
-
* - Rate limiting
|
|
7
|
-
* - Retry mechanisms with exponential backoff
|
|
8
|
-
* - Circuit breaker pattern
|
|
9
|
-
* - Monitoring and observability hooks
|
|
10
|
-
*
|
|
11
|
-
* @module @monoes/cli/production
|
|
12
|
-
*/
|
|
13
1
|
export { ErrorHandler, withErrorHandling } from './error-handler.js';
|
|
14
|
-
export type { ErrorContext, ErrorHandlerConfig } from './error-handler.js';
|
|
15
2
|
export { RateLimiter, createRateLimiter } from './rate-limiter.js';
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
18
|
-
export
|
|
19
|
-
export { CircuitBreaker } from './circuit-breaker.js';
|
|
20
|
-
export type { CircuitBreakerConfig, CircuitState } from './circuit-breaker.js';
|
|
21
|
-
export { MonitoringHooks, createMonitor } from './monitoring.js';
|
|
22
|
-
export type { MonitorConfig, MetricEvent } from './monitoring.js';
|
|
3
|
+
export { withRetry, makeRetryable, Retryable } from './retry.js';
|
|
4
|
+
export { CircuitBreaker, getCircuitBreaker, getAllCircuitStats, resetAllCircuits } from './circuit-breaker.js';
|
|
5
|
+
export { MonitoringHooks, createMonitor, getMonitor } from './monitoring.js';
|
|
23
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V1 Production Hardening Module
|
|
3
|
-
*
|
|
4
|
-
* Provides production-grade utilities:
|
|
5
|
-
* - Error handling middleware
|
|
6
|
-
* - Rate limiting
|
|
7
|
-
* - Retry mechanisms with exponential backoff
|
|
8
|
-
* - Circuit breaker pattern
|
|
9
|
-
* - Monitoring and observability hooks
|
|
10
|
-
*
|
|
11
|
-
* @module @monoes/cli/production
|
|
12
|
-
*/
|
|
13
1
|
export { ErrorHandler, withErrorHandling } from './error-handler.js';
|
|
14
2
|
export { RateLimiter, createRateLimiter } from './rate-limiter.js';
|
|
15
|
-
export { withRetry } from './retry.js';
|
|
16
|
-
export { CircuitBreaker } from './circuit-breaker.js';
|
|
17
|
-
export { MonitoringHooks, createMonitor } from './monitoring.js';
|
|
3
|
+
export { withRetry, makeRetryable, Retryable } from './retry.js';
|
|
4
|
+
export { CircuitBreaker, getCircuitBreaker, getAllCircuitStats, resetAllCircuits } from './circuit-breaker.js';
|
|
5
|
+
export { MonitoringHooks, createMonitor, getMonitor } from './monitoring.js';
|
|
18
6
|
//# sourceMappingURL=index.js.map
|