@kya-os/contracts 1.6.18 → 1.6.19
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/dist/cli.d.ts +56 -11
- package/dist/cli.js +38 -14
- package/dist/config/identity.d.ts +117 -0
- package/dist/config/identity.js +34 -2
- package/dist/identity/index.d.ts +3 -0
- package/dist/identity/index.js +7 -0
- package/dist/index.js +1 -0
- package/dist/reputation/api.d.ts +2883 -0
- package/dist/reputation/api.js +417 -0
- package/dist/reputation/constants.d.ts +242 -0
- package/dist/reputation/constants.js +259 -0
- package/dist/reputation/credentials.d.ts +1493 -0
- package/dist/reputation/credentials.js +302 -0
- package/dist/reputation/index.d.ts +20 -0
- package/dist/reputation/index.js +40 -0
- package/dist/reputation/schemas.d.ts +1600 -0
- package/dist/reputation/schemas.js +499 -0
- package/package.json +5 -1
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Reputation Engine Constants
|
|
4
|
+
*
|
|
5
|
+
* Configuration constants for the reputation scoring system.
|
|
6
|
+
* These values control the behavior of the Bayesian algorithm
|
|
7
|
+
* and define standard thresholds and limits.
|
|
8
|
+
*
|
|
9
|
+
* Related Spec: MCP-I §5.1 (Reputation), CLAUDE-reputation-engine.md
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.REPUTATION_ALGORITHM_VERSION = exports.REPUTATION_CONTRACTS_VERSION = exports.CREDENTIAL_VALIDITY = exports.RATE_LIMITS = exports.CACHE_CONFIG = exports.PERFORMANCE_TARGETS = exports.EMPIRICAL_SCORE = exports.PROVISIONAL_THRESHOLDS = exports.CALCULATOR_PRESETS = exports.DEFAULT_WEIGHTS = exports.REPUTATION_THRESHOLDS = exports.CONFIDENCE_THRESHOLDS = exports.K_VALUES = exports.CREDENTIAL_BONUSES = exports.MCP_LEVEL_BONUSES = exports.PRIOR_SCORE = void 0;
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// SCORING CONSTANTS
|
|
15
|
+
// ============================================================================
|
|
16
|
+
/**
|
|
17
|
+
* Prior score configuration
|
|
18
|
+
*
|
|
19
|
+
* Prior score represents the baseline reputation based on credentials
|
|
20
|
+
* before any empirical data (reviews, interactions) is considered.
|
|
21
|
+
*/
|
|
22
|
+
exports.PRIOR_SCORE = {
|
|
23
|
+
/** Base prior score for all agents */
|
|
24
|
+
BASE: 50,
|
|
25
|
+
/** Maximum achievable prior score */
|
|
26
|
+
MAX: 80,
|
|
27
|
+
/** Minimum prior score */
|
|
28
|
+
MIN: 50,
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* MCP Level bonuses to prior score
|
|
32
|
+
*
|
|
33
|
+
* Each MCP compliance level adds points to the prior score.
|
|
34
|
+
*/
|
|
35
|
+
exports.MCP_LEVEL_BONUSES = {
|
|
36
|
+
/** Level 0: No MCP compliance */
|
|
37
|
+
LEVEL_0: 0,
|
|
38
|
+
/** Level 1: Basic MCP compliance */
|
|
39
|
+
LEVEL_1: 5,
|
|
40
|
+
/** Level 2: Standard MCP compliance */
|
|
41
|
+
LEVEL_2: 10,
|
|
42
|
+
/** Level 3: Advanced MCP compliance */
|
|
43
|
+
LEVEL_3: 15,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Credential bonuses to prior score
|
|
47
|
+
*
|
|
48
|
+
* Each verified credential adds points to the prior score.
|
|
49
|
+
*/
|
|
50
|
+
exports.CREDENTIAL_BONUSES = {
|
|
51
|
+
/** Identity verification bonus */
|
|
52
|
+
IDENTITY_VERIFIED: 5,
|
|
53
|
+
/** Security audit passed bonus */
|
|
54
|
+
SECURITY_AUDIT: 7,
|
|
55
|
+
/** Open source bonus */
|
|
56
|
+
OPEN_SOURCE: 3,
|
|
57
|
+
/** GitHub verification bonus */
|
|
58
|
+
GITHUB_VERIFIED: 3,
|
|
59
|
+
/** Company email verification bonus */
|
|
60
|
+
COMPANY_EMAIL: 2,
|
|
61
|
+
/** Agent age > 365 days bonus */
|
|
62
|
+
AGE_OVER_YEAR: 5,
|
|
63
|
+
};
|
|
64
|
+
// ============================================================================
|
|
65
|
+
// CONFIDENCE CALCULATION
|
|
66
|
+
// ============================================================================
|
|
67
|
+
/**
|
|
68
|
+
* K values for confidence calculation
|
|
69
|
+
*
|
|
70
|
+
* Confidence is calculated as: n / (n + k)
|
|
71
|
+
* where n is the number of interactions.
|
|
72
|
+
*
|
|
73
|
+
* Higher k = slower confidence growth (more conservative)
|
|
74
|
+
* Lower k = faster confidence growth (more aggressive)
|
|
75
|
+
*/
|
|
76
|
+
exports.K_VALUES = {
|
|
77
|
+
/** Testing preset: Fast confidence growth */
|
|
78
|
+
TESTING: 5,
|
|
79
|
+
/** Aggressive preset: Moderate confidence growth */
|
|
80
|
+
AGGRESSIVE: 10,
|
|
81
|
+
/** Conservative preset: Slow confidence growth (default) */
|
|
82
|
+
CONSERVATIVE: 20,
|
|
83
|
+
/** Default k value */
|
|
84
|
+
DEFAULT: 15,
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Confidence level thresholds
|
|
88
|
+
*/
|
|
89
|
+
exports.CONFIDENCE_THRESHOLDS = {
|
|
90
|
+
/** Low confidence upper bound */
|
|
91
|
+
LOW: 0.25,
|
|
92
|
+
/** Medium confidence upper bound */
|
|
93
|
+
MEDIUM: 0.5,
|
|
94
|
+
/** High confidence upper bound */
|
|
95
|
+
HIGH: 0.75,
|
|
96
|
+
/** VeryHigh is anything above HIGH */
|
|
97
|
+
};
|
|
98
|
+
// ============================================================================
|
|
99
|
+
// REPUTATION LEVEL THRESHOLDS
|
|
100
|
+
// ============================================================================
|
|
101
|
+
/**
|
|
102
|
+
* Reputation level score thresholds
|
|
103
|
+
*
|
|
104
|
+
* Maps numeric scores to human-readable reputation levels.
|
|
105
|
+
*/
|
|
106
|
+
exports.REPUTATION_THRESHOLDS = {
|
|
107
|
+
/** Poor: 0-29 */
|
|
108
|
+
POOR_MAX: 30,
|
|
109
|
+
/** Below Average: 30-44 */
|
|
110
|
+
BELOW_AVERAGE_MAX: 45,
|
|
111
|
+
/** Average: 45-59 */
|
|
112
|
+
AVERAGE_MAX: 60,
|
|
113
|
+
/** Good: 60-74 */
|
|
114
|
+
GOOD_MAX: 75,
|
|
115
|
+
/** Excellent: 75-89 */
|
|
116
|
+
EXCELLENT_MAX: 90,
|
|
117
|
+
/** Outstanding: 90-100 */
|
|
118
|
+
};
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// WEIGHT PRESETS
|
|
121
|
+
// ============================================================================
|
|
122
|
+
/**
|
|
123
|
+
* Default component weights
|
|
124
|
+
*
|
|
125
|
+
* How much each factor contributes to the empirical score.
|
|
126
|
+
*/
|
|
127
|
+
exports.DEFAULT_WEIGHTS = {
|
|
128
|
+
/** Weight for review-based scoring */
|
|
129
|
+
REVIEWS: 0.4,
|
|
130
|
+
/** Weight for interaction-based scoring */
|
|
131
|
+
INTERACTIONS: 0.3,
|
|
132
|
+
/** Weight for consistency metrics */
|
|
133
|
+
CONSISTENCY: 0.3,
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Preset configurations
|
|
137
|
+
*/
|
|
138
|
+
exports.CALCULATOR_PRESETS = {
|
|
139
|
+
TESTING: {
|
|
140
|
+
kValue: exports.K_VALUES.TESTING,
|
|
141
|
+
weights: { ...exports.DEFAULT_WEIGHTS },
|
|
142
|
+
basePriorScore: exports.PRIOR_SCORE.BASE,
|
|
143
|
+
maxPriorScore: exports.PRIOR_SCORE.MAX,
|
|
144
|
+
},
|
|
145
|
+
CONSERVATIVE: {
|
|
146
|
+
kValue: exports.K_VALUES.CONSERVATIVE,
|
|
147
|
+
weights: { ...exports.DEFAULT_WEIGHTS },
|
|
148
|
+
basePriorScore: exports.PRIOR_SCORE.BASE,
|
|
149
|
+
maxPriorScore: exports.PRIOR_SCORE.MAX,
|
|
150
|
+
},
|
|
151
|
+
AGGRESSIVE: {
|
|
152
|
+
kValue: exports.K_VALUES.AGGRESSIVE,
|
|
153
|
+
weights: { ...exports.DEFAULT_WEIGHTS },
|
|
154
|
+
basePriorScore: exports.PRIOR_SCORE.BASE,
|
|
155
|
+
maxPriorScore: exports.PRIOR_SCORE.MAX,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
// ============================================================================
|
|
159
|
+
// PROVISIONAL SCORE THRESHOLDS
|
|
160
|
+
// ============================================================================
|
|
161
|
+
/**
|
|
162
|
+
* Thresholds for determining provisional scores
|
|
163
|
+
*
|
|
164
|
+
* A score is provisional when there isn't enough data
|
|
165
|
+
* for confident assessment.
|
|
166
|
+
*/
|
|
167
|
+
exports.PROVISIONAL_THRESHOLDS = {
|
|
168
|
+
/** Minimum interactions for non-provisional */
|
|
169
|
+
MIN_INTERACTIONS: 5,
|
|
170
|
+
/** Minimum reviews for non-provisional */
|
|
171
|
+
MIN_REVIEWS: 3,
|
|
172
|
+
/** Minimum confidence for non-provisional */
|
|
173
|
+
MIN_CONFIDENCE: 0.25,
|
|
174
|
+
};
|
|
175
|
+
// ============================================================================
|
|
176
|
+
// EMPIRICAL SCORE CALCULATION
|
|
177
|
+
// ============================================================================
|
|
178
|
+
/**
|
|
179
|
+
* Empirical score calculation constants
|
|
180
|
+
*/
|
|
181
|
+
exports.EMPIRICAL_SCORE = {
|
|
182
|
+
/** Default score when no reviews exist */
|
|
183
|
+
DEFAULT_NO_REVIEWS: 50,
|
|
184
|
+
/** Minimum average rating */
|
|
185
|
+
MIN_RATING: 1.0,
|
|
186
|
+
/** Maximum average rating */
|
|
187
|
+
MAX_RATING: 5.0,
|
|
188
|
+
/** Rating to score multiplier: score = (rating - 1) * 25 */
|
|
189
|
+
RATING_MULTIPLIER: 25,
|
|
190
|
+
};
|
|
191
|
+
// ============================================================================
|
|
192
|
+
// PERFORMANCE TARGETS
|
|
193
|
+
// ============================================================================
|
|
194
|
+
/**
|
|
195
|
+
* Performance targets for reputation calculation
|
|
196
|
+
*/
|
|
197
|
+
exports.PERFORMANCE_TARGETS = {
|
|
198
|
+
/** Target time for single agent calculation (ms) */
|
|
199
|
+
SINGLE_AGENT_MS: 1,
|
|
200
|
+
/** Target time for batch of 1000 agents (ms) */
|
|
201
|
+
BATCH_1000_MS: 100,
|
|
202
|
+
/** Target time in browser/WASM (ms) */
|
|
203
|
+
WASM_SINGLE_MS: 5,
|
|
204
|
+
};
|
|
205
|
+
// ============================================================================
|
|
206
|
+
// CACHING
|
|
207
|
+
// ============================================================================
|
|
208
|
+
/**
|
|
209
|
+
* Cache configuration
|
|
210
|
+
*/
|
|
211
|
+
exports.CACHE_CONFIG = {
|
|
212
|
+
/** Default cache TTL in seconds */
|
|
213
|
+
DEFAULT_TTL_SECONDS: 300,
|
|
214
|
+
/** Maximum cache TTL in seconds */
|
|
215
|
+
MAX_TTL_SECONDS: 3600,
|
|
216
|
+
/** Stale-while-revalidate window in seconds */
|
|
217
|
+
SWR_SECONDS: 60,
|
|
218
|
+
};
|
|
219
|
+
// ============================================================================
|
|
220
|
+
// RATE LIMITING
|
|
221
|
+
// ============================================================================
|
|
222
|
+
/**
|
|
223
|
+
* Rate limiting configuration
|
|
224
|
+
*/
|
|
225
|
+
exports.RATE_LIMITS = {
|
|
226
|
+
/** Requests per minute for single calculations */
|
|
227
|
+
SINGLE_CALCULATE_RPM: 100,
|
|
228
|
+
/** Requests per minute for batch calculations */
|
|
229
|
+
BATCH_CALCULATE_RPM: 10,
|
|
230
|
+
/** Maximum batch size */
|
|
231
|
+
MAX_BATCH_SIZE: 1000,
|
|
232
|
+
};
|
|
233
|
+
// ============================================================================
|
|
234
|
+
// CREDENTIAL VALIDITY
|
|
235
|
+
// ============================================================================
|
|
236
|
+
/**
|
|
237
|
+
* Reputation credential validity periods
|
|
238
|
+
*/
|
|
239
|
+
exports.CREDENTIAL_VALIDITY = {
|
|
240
|
+
/** Default validity period in milliseconds (7 days) */
|
|
241
|
+
DEFAULT_MS: 7 * 24 * 60 * 60 * 1000,
|
|
242
|
+
/** Minimum validity period in milliseconds (1 hour) */
|
|
243
|
+
MIN_MS: 60 * 60 * 1000,
|
|
244
|
+
/** Maximum validity period in milliseconds (30 days) */
|
|
245
|
+
MAX_MS: 30 * 24 * 60 * 60 * 1000,
|
|
246
|
+
/** Recommended freshness for scores (24 hours) */
|
|
247
|
+
RECOMMENDED_FRESHNESS_MS: 24 * 60 * 60 * 1000,
|
|
248
|
+
};
|
|
249
|
+
// ============================================================================
|
|
250
|
+
// VERSION
|
|
251
|
+
// ============================================================================
|
|
252
|
+
/**
|
|
253
|
+
* Reputation contracts version
|
|
254
|
+
*/
|
|
255
|
+
exports.REPUTATION_CONTRACTS_VERSION = "1.0.0";
|
|
256
|
+
/**
|
|
257
|
+
* Reputation algorithm version
|
|
258
|
+
*/
|
|
259
|
+
exports.REPUTATION_ALGORITHM_VERSION = "1.0.0-bayesian";
|