@mnemom/types 0.1.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/dist/index.d.mts +129 -0
- package/dist/index.d.ts +129 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +33 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +47 -0
- package/src/a2a.ts +8 -0
- package/src/constants.ts +56 -0
- package/src/gate.ts +28 -0
- package/src/index.ts +36 -0
- package/src/reputation.ts +78 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reputation score types.
|
|
3
|
+
*
|
|
4
|
+
* Canonical definitions for Mnemom reputation scores, grades,
|
|
5
|
+
* confidence levels, and score components.
|
|
6
|
+
*/
|
|
7
|
+
/** Reputation grade scale from AAA (highest) to NR (not rated). */
|
|
8
|
+
type ReputationGrade = 'AAA' | 'AA' | 'A' | 'BBB' | 'BB' | 'B' | 'CCC' | 'NR';
|
|
9
|
+
/** Confidence level of a reputation score. */
|
|
10
|
+
type ConfidenceLevel = 'insufficient' | 'low' | 'medium' | 'high';
|
|
11
|
+
/** A single component contributing to an agent's reputation score. */
|
|
12
|
+
interface ReputationComponent {
|
|
13
|
+
/** Machine-readable key (e.g. "integrity_ratio", "compliance") */
|
|
14
|
+
key: string;
|
|
15
|
+
/** Human-readable label (e.g. "Integrity Ratio", "Compliance") */
|
|
16
|
+
label: string;
|
|
17
|
+
/** Raw component score (0-1000) */
|
|
18
|
+
score: number;
|
|
19
|
+
/** Weight applied to this component (0-1) */
|
|
20
|
+
weight: number;
|
|
21
|
+
/** score * weight, rounded */
|
|
22
|
+
weighted_score: number;
|
|
23
|
+
/** Human-readable factors explaining the score */
|
|
24
|
+
factors: string[];
|
|
25
|
+
}
|
|
26
|
+
/** Full reputation score for an agent. */
|
|
27
|
+
interface ReputationScore {
|
|
28
|
+
/** Agent identifier */
|
|
29
|
+
agent_id: string;
|
|
30
|
+
/** Numeric reputation score (0-1000) */
|
|
31
|
+
score: number;
|
|
32
|
+
/** Letter grade */
|
|
33
|
+
grade: ReputationGrade;
|
|
34
|
+
/** Tier label (e.g. "Exemplary", "Reliable") */
|
|
35
|
+
tier: string;
|
|
36
|
+
/** Whether the agent is eligible for reputation (checkpoint_count >= 50) */
|
|
37
|
+
is_eligible: boolean;
|
|
38
|
+
/** Number of checkpoints contributing to the score */
|
|
39
|
+
checkpoint_count: number;
|
|
40
|
+
/** Confidence in the score */
|
|
41
|
+
confidence: ConfidenceLevel;
|
|
42
|
+
/** Score components breakdown */
|
|
43
|
+
components: ReputationComponent[];
|
|
44
|
+
/** When the score was computed (ISO 8601) */
|
|
45
|
+
computed_at: string;
|
|
46
|
+
/** 30-day score trend (positive = improving) */
|
|
47
|
+
trend_30d: number;
|
|
48
|
+
/** Visibility setting */
|
|
49
|
+
visibility: 'public' | 'unlisted' | 'private';
|
|
50
|
+
/** Optional A2A trust extension */
|
|
51
|
+
a2a_trust_extension?: A2ATrustExtension;
|
|
52
|
+
}
|
|
53
|
+
/** A2A trust extension for inter-agent reputation sharing. */
|
|
54
|
+
interface A2ATrustExtension {
|
|
55
|
+
/** URI identifying this extension */
|
|
56
|
+
extension_uri: string;
|
|
57
|
+
/** Reputation provider identifier */
|
|
58
|
+
provider: string;
|
|
59
|
+
/** Numeric reputation score */
|
|
60
|
+
score: number;
|
|
61
|
+
/** Letter grade */
|
|
62
|
+
grade: ReputationGrade;
|
|
63
|
+
/** Confidence in the score */
|
|
64
|
+
confidence: ConfidenceLevel;
|
|
65
|
+
/** URL to verify the score */
|
|
66
|
+
verified_url: string;
|
|
67
|
+
/** URL to the agent's badge */
|
|
68
|
+
badge_url: string;
|
|
69
|
+
/** URL to the scoring methodology */
|
|
70
|
+
methodology_url: string;
|
|
71
|
+
/** When the score was last updated (ISO 8601) */
|
|
72
|
+
last_updated: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Reputation gate types.
|
|
77
|
+
*
|
|
78
|
+
* Types for gating agent interactions based on reputation
|
|
79
|
+
* score and grade thresholds.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
/** Configuration for a reputation gate. */
|
|
83
|
+
interface ReputationGateConfig {
|
|
84
|
+
/** Minimum numeric score required (0-1000) */
|
|
85
|
+
minScore?: number;
|
|
86
|
+
/** Minimum letter grade required */
|
|
87
|
+
minGrade?: ReputationGrade;
|
|
88
|
+
/** Base URL for the reputation API */
|
|
89
|
+
baseUrl?: string;
|
|
90
|
+
}
|
|
91
|
+
/** Result of a reputation gate check. */
|
|
92
|
+
interface GateResult {
|
|
93
|
+
/** Whether the agent is allowed through the gate */
|
|
94
|
+
allowed: boolean;
|
|
95
|
+
/** The agent's reputation score (null if fetch failed) */
|
|
96
|
+
score: ReputationScore | null;
|
|
97
|
+
/** Human-readable reason for denial (if not allowed) */
|
|
98
|
+
reason?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Reputation constants.
|
|
103
|
+
*
|
|
104
|
+
* Centralizes grade ordinals, grade scale definitions, and
|
|
105
|
+
* component weight definitions used across all services and SDKs.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/** Ordinal ranking of reputation grades (higher = better). */
|
|
109
|
+
declare const GRADE_ORDINALS: Record<ReputationGrade, number>;
|
|
110
|
+
/** Grade scale definition with tier names and score boundaries. */
|
|
111
|
+
interface GradeScaleEntry {
|
|
112
|
+
grade: ReputationGrade;
|
|
113
|
+
tier: string;
|
|
114
|
+
min: number;
|
|
115
|
+
max: number;
|
|
116
|
+
}
|
|
117
|
+
/** Grade scale from highest to lowest. */
|
|
118
|
+
declare const GRADE_SCALE: GradeScaleEntry[];
|
|
119
|
+
/** Component weight definition. */
|
|
120
|
+
interface ComponentWeightEntry {
|
|
121
|
+
key: string;
|
|
122
|
+
label: string;
|
|
123
|
+
weight: number;
|
|
124
|
+
source: string;
|
|
125
|
+
}
|
|
126
|
+
/** Scoring component weights. */
|
|
127
|
+
declare const COMPONENT_WEIGHTS: ComponentWeightEntry[];
|
|
128
|
+
|
|
129
|
+
export { type A2ATrustExtension, COMPONENT_WEIGHTS, type ComponentWeightEntry, type ConfidenceLevel, GRADE_ORDINALS, GRADE_SCALE, type GateResult, type GradeScaleEntry, type ReputationComponent, type ReputationGateConfig, type ReputationGrade, type ReputationScore };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reputation score types.
|
|
3
|
+
*
|
|
4
|
+
* Canonical definitions for Mnemom reputation scores, grades,
|
|
5
|
+
* confidence levels, and score components.
|
|
6
|
+
*/
|
|
7
|
+
/** Reputation grade scale from AAA (highest) to NR (not rated). */
|
|
8
|
+
type ReputationGrade = 'AAA' | 'AA' | 'A' | 'BBB' | 'BB' | 'B' | 'CCC' | 'NR';
|
|
9
|
+
/** Confidence level of a reputation score. */
|
|
10
|
+
type ConfidenceLevel = 'insufficient' | 'low' | 'medium' | 'high';
|
|
11
|
+
/** A single component contributing to an agent's reputation score. */
|
|
12
|
+
interface ReputationComponent {
|
|
13
|
+
/** Machine-readable key (e.g. "integrity_ratio", "compliance") */
|
|
14
|
+
key: string;
|
|
15
|
+
/** Human-readable label (e.g. "Integrity Ratio", "Compliance") */
|
|
16
|
+
label: string;
|
|
17
|
+
/** Raw component score (0-1000) */
|
|
18
|
+
score: number;
|
|
19
|
+
/** Weight applied to this component (0-1) */
|
|
20
|
+
weight: number;
|
|
21
|
+
/** score * weight, rounded */
|
|
22
|
+
weighted_score: number;
|
|
23
|
+
/** Human-readable factors explaining the score */
|
|
24
|
+
factors: string[];
|
|
25
|
+
}
|
|
26
|
+
/** Full reputation score for an agent. */
|
|
27
|
+
interface ReputationScore {
|
|
28
|
+
/** Agent identifier */
|
|
29
|
+
agent_id: string;
|
|
30
|
+
/** Numeric reputation score (0-1000) */
|
|
31
|
+
score: number;
|
|
32
|
+
/** Letter grade */
|
|
33
|
+
grade: ReputationGrade;
|
|
34
|
+
/** Tier label (e.g. "Exemplary", "Reliable") */
|
|
35
|
+
tier: string;
|
|
36
|
+
/** Whether the agent is eligible for reputation (checkpoint_count >= 50) */
|
|
37
|
+
is_eligible: boolean;
|
|
38
|
+
/** Number of checkpoints contributing to the score */
|
|
39
|
+
checkpoint_count: number;
|
|
40
|
+
/** Confidence in the score */
|
|
41
|
+
confidence: ConfidenceLevel;
|
|
42
|
+
/** Score components breakdown */
|
|
43
|
+
components: ReputationComponent[];
|
|
44
|
+
/** When the score was computed (ISO 8601) */
|
|
45
|
+
computed_at: string;
|
|
46
|
+
/** 30-day score trend (positive = improving) */
|
|
47
|
+
trend_30d: number;
|
|
48
|
+
/** Visibility setting */
|
|
49
|
+
visibility: 'public' | 'unlisted' | 'private';
|
|
50
|
+
/** Optional A2A trust extension */
|
|
51
|
+
a2a_trust_extension?: A2ATrustExtension;
|
|
52
|
+
}
|
|
53
|
+
/** A2A trust extension for inter-agent reputation sharing. */
|
|
54
|
+
interface A2ATrustExtension {
|
|
55
|
+
/** URI identifying this extension */
|
|
56
|
+
extension_uri: string;
|
|
57
|
+
/** Reputation provider identifier */
|
|
58
|
+
provider: string;
|
|
59
|
+
/** Numeric reputation score */
|
|
60
|
+
score: number;
|
|
61
|
+
/** Letter grade */
|
|
62
|
+
grade: ReputationGrade;
|
|
63
|
+
/** Confidence in the score */
|
|
64
|
+
confidence: ConfidenceLevel;
|
|
65
|
+
/** URL to verify the score */
|
|
66
|
+
verified_url: string;
|
|
67
|
+
/** URL to the agent's badge */
|
|
68
|
+
badge_url: string;
|
|
69
|
+
/** URL to the scoring methodology */
|
|
70
|
+
methodology_url: string;
|
|
71
|
+
/** When the score was last updated (ISO 8601) */
|
|
72
|
+
last_updated: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Reputation gate types.
|
|
77
|
+
*
|
|
78
|
+
* Types for gating agent interactions based on reputation
|
|
79
|
+
* score and grade thresholds.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
/** Configuration for a reputation gate. */
|
|
83
|
+
interface ReputationGateConfig {
|
|
84
|
+
/** Minimum numeric score required (0-1000) */
|
|
85
|
+
minScore?: number;
|
|
86
|
+
/** Minimum letter grade required */
|
|
87
|
+
minGrade?: ReputationGrade;
|
|
88
|
+
/** Base URL for the reputation API */
|
|
89
|
+
baseUrl?: string;
|
|
90
|
+
}
|
|
91
|
+
/** Result of a reputation gate check. */
|
|
92
|
+
interface GateResult {
|
|
93
|
+
/** Whether the agent is allowed through the gate */
|
|
94
|
+
allowed: boolean;
|
|
95
|
+
/** The agent's reputation score (null if fetch failed) */
|
|
96
|
+
score: ReputationScore | null;
|
|
97
|
+
/** Human-readable reason for denial (if not allowed) */
|
|
98
|
+
reason?: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Reputation constants.
|
|
103
|
+
*
|
|
104
|
+
* Centralizes grade ordinals, grade scale definitions, and
|
|
105
|
+
* component weight definitions used across all services and SDKs.
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
/** Ordinal ranking of reputation grades (higher = better). */
|
|
109
|
+
declare const GRADE_ORDINALS: Record<ReputationGrade, number>;
|
|
110
|
+
/** Grade scale definition with tier names and score boundaries. */
|
|
111
|
+
interface GradeScaleEntry {
|
|
112
|
+
grade: ReputationGrade;
|
|
113
|
+
tier: string;
|
|
114
|
+
min: number;
|
|
115
|
+
max: number;
|
|
116
|
+
}
|
|
117
|
+
/** Grade scale from highest to lowest. */
|
|
118
|
+
declare const GRADE_SCALE: GradeScaleEntry[];
|
|
119
|
+
/** Component weight definition. */
|
|
120
|
+
interface ComponentWeightEntry {
|
|
121
|
+
key: string;
|
|
122
|
+
label: string;
|
|
123
|
+
weight: number;
|
|
124
|
+
source: string;
|
|
125
|
+
}
|
|
126
|
+
/** Scoring component weights. */
|
|
127
|
+
declare const COMPONENT_WEIGHTS: ComponentWeightEntry[];
|
|
128
|
+
|
|
129
|
+
export { type A2ATrustExtension, COMPONENT_WEIGHTS, type ComponentWeightEntry, type ConfidenceLevel, GRADE_ORDINALS, GRADE_SCALE, type GateResult, type GradeScaleEntry, type ReputationComponent, type ReputationGateConfig, type ReputationGrade, type ReputationScore };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
COMPONENT_WEIGHTS: () => COMPONENT_WEIGHTS,
|
|
24
|
+
GRADE_ORDINALS: () => GRADE_ORDINALS,
|
|
25
|
+
GRADE_SCALE: () => GRADE_SCALE
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/constants.ts
|
|
30
|
+
var GRADE_ORDINALS = {
|
|
31
|
+
AAA: 7,
|
|
32
|
+
AA: 6,
|
|
33
|
+
A: 5,
|
|
34
|
+
BBB: 4,
|
|
35
|
+
BB: 3,
|
|
36
|
+
B: 2,
|
|
37
|
+
CCC: 1,
|
|
38
|
+
NR: 0
|
|
39
|
+
};
|
|
40
|
+
var GRADE_SCALE = [
|
|
41
|
+
{ grade: "AAA", tier: "Exemplary", min: 900, max: 1e3 },
|
|
42
|
+
{ grade: "AA", tier: "Established", min: 800, max: 899 },
|
|
43
|
+
{ grade: "A", tier: "Reliable", min: 700, max: 799 },
|
|
44
|
+
{ grade: "BBB", tier: "Developing", min: 600, max: 699 },
|
|
45
|
+
{ grade: "BB", tier: "Emerging", min: 500, max: 599 },
|
|
46
|
+
{ grade: "B", tier: "Concerning", min: 400, max: 499 },
|
|
47
|
+
{ grade: "CCC", tier: "Critical", min: 200, max: 399 }
|
|
48
|
+
];
|
|
49
|
+
var COMPONENT_WEIGHTS = [
|
|
50
|
+
{ key: "integrity_ratio", label: "Integrity Ratio", weight: 0.4, source: "Checkpoint clear rate" },
|
|
51
|
+
{ key: "compliance", label: "Compliance", weight: 0.2, source: "Violation impact decay" },
|
|
52
|
+
{ key: "drift_stability", label: "Drift Stability", weight: 0.2, source: "Session stability ratio" },
|
|
53
|
+
{ key: "trace_completeness", label: "Trace Completeness", weight: 0.1, source: "Trace/checkpoint balance" },
|
|
54
|
+
{ key: "coherence_compatibility", label: "Coherence Compatibility", weight: 0.1, source: "Fleet coherence data" }
|
|
55
|
+
];
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
COMPONENT_WEIGHTS,
|
|
59
|
+
GRADE_ORDINALS,
|
|
60
|
+
GRADE_SCALE
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/constants.ts"],"sourcesContent":["/**\n * @mnemom/types — Shared type definitions for Mnemom services and SDKs.\n *\n * @example\n * ```typescript\n * import type { ReputationScore, ReputationGrade } from '@mnemom/types';\n * import { GRADE_ORDINALS, COMPONENT_WEIGHTS } from '@mnemom/types';\n * ```\n */\n\n// Reputation types\nexport type {\n ReputationGrade,\n ConfidenceLevel,\n ReputationComponent,\n ReputationScore,\n A2ATrustExtension,\n} from './reputation';\n\n// Gate types\nexport type {\n ReputationGateConfig,\n GateResult,\n} from './gate';\n\n// Constants\nexport {\n GRADE_ORDINALS,\n GRADE_SCALE,\n COMPONENT_WEIGHTS,\n} from './constants';\n\nexport type {\n GradeScaleEntry,\n ComponentWeightEntry,\n} from './constants';\n","/**\n * Reputation constants.\n *\n * Centralizes grade ordinals, grade scale definitions, and\n * component weight definitions used across all services and SDKs.\n */\n\nimport type { ReputationGrade } from './reputation';\n\n/** Ordinal ranking of reputation grades (higher = better). */\nexport const GRADE_ORDINALS: Record<ReputationGrade, number> = {\n AAA: 7,\n AA: 6,\n A: 5,\n BBB: 4,\n BB: 3,\n B: 2,\n CCC: 1,\n NR: 0,\n};\n\n/** Grade scale definition with tier names and score boundaries. */\nexport interface GradeScaleEntry {\n grade: ReputationGrade;\n tier: string;\n min: number;\n max: number;\n}\n\n/** Grade scale from highest to lowest. */\nexport const GRADE_SCALE: GradeScaleEntry[] = [\n { grade: 'AAA', tier: 'Exemplary', min: 900, max: 1000 },\n { grade: 'AA', tier: 'Established', min: 800, max: 899 },\n { grade: 'A', tier: 'Reliable', min: 700, max: 799 },\n { grade: 'BBB', tier: 'Developing', min: 600, max: 699 },\n { grade: 'BB', tier: 'Emerging', min: 500, max: 599 },\n { grade: 'B', tier: 'Concerning', min: 400, max: 499 },\n { grade: 'CCC', tier: 'Critical', min: 200, max: 399 },\n];\n\n/** Component weight definition. */\nexport interface ComponentWeightEntry {\n key: string;\n label: string;\n weight: number;\n source: string;\n}\n\n/** Scoring component weights. */\nexport const COMPONENT_WEIGHTS: ComponentWeightEntry[] = [\n { key: 'integrity_ratio', label: 'Integrity Ratio', weight: 0.40, source: 'Checkpoint clear rate' },\n { key: 'compliance', label: 'Compliance', weight: 0.20, source: 'Violation impact decay' },\n { key: 'drift_stability', label: 'Drift Stability', weight: 0.20, source: 'Session stability ratio' },\n { key: 'trace_completeness', label: 'Trace Completeness', weight: 0.10, source: 'Trace/checkpoint balance' },\n { key: 'coherence_compatibility', label: 'Coherence Compatibility', weight: 0.10, source: 'Fleet coherence data' },\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUO,IAAM,iBAAkD;AAAA,EAC7D,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,KAAK;AAAA,EACL,IAAI;AACN;AAWO,IAAM,cAAiC;AAAA,EAC5C,EAAE,OAAO,OAAO,MAAM,aAAe,KAAK,KAAK,KAAK,IAAK;AAAA,EACzD,EAAE,OAAO,MAAO,MAAM,eAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,KAAO,MAAM,YAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,OAAO,MAAM,cAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,MAAO,MAAM,YAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,KAAO,MAAM,cAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,OAAO,MAAM,YAAe,KAAK,KAAK,KAAK,IAAI;AAC1D;AAWO,IAAM,oBAA4C;AAAA,EACvD,EAAE,KAAK,mBAA0B,OAAO,mBAA0B,QAAQ,KAAM,QAAQ,wBAAwB;AAAA,EAChH,EAAE,KAAK,cAA0B,OAAO,cAA0B,QAAQ,KAAM,QAAQ,yBAAyB;AAAA,EACjH,EAAE,KAAK,mBAA0B,OAAO,mBAA0B,QAAQ,KAAM,QAAQ,0BAA0B;AAAA,EAClH,EAAE,KAAK,sBAA0B,OAAO,sBAA0B,QAAQ,KAAM,QAAQ,2BAA2B;AAAA,EACnH,EAAE,KAAK,2BAA2B,OAAO,2BAA2B,QAAQ,KAAM,QAAQ,uBAAuB;AACnH;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/constants.ts
|
|
2
|
+
var GRADE_ORDINALS = {
|
|
3
|
+
AAA: 7,
|
|
4
|
+
AA: 6,
|
|
5
|
+
A: 5,
|
|
6
|
+
BBB: 4,
|
|
7
|
+
BB: 3,
|
|
8
|
+
B: 2,
|
|
9
|
+
CCC: 1,
|
|
10
|
+
NR: 0
|
|
11
|
+
};
|
|
12
|
+
var GRADE_SCALE = [
|
|
13
|
+
{ grade: "AAA", tier: "Exemplary", min: 900, max: 1e3 },
|
|
14
|
+
{ grade: "AA", tier: "Established", min: 800, max: 899 },
|
|
15
|
+
{ grade: "A", tier: "Reliable", min: 700, max: 799 },
|
|
16
|
+
{ grade: "BBB", tier: "Developing", min: 600, max: 699 },
|
|
17
|
+
{ grade: "BB", tier: "Emerging", min: 500, max: 599 },
|
|
18
|
+
{ grade: "B", tier: "Concerning", min: 400, max: 499 },
|
|
19
|
+
{ grade: "CCC", tier: "Critical", min: 200, max: 399 }
|
|
20
|
+
];
|
|
21
|
+
var COMPONENT_WEIGHTS = [
|
|
22
|
+
{ key: "integrity_ratio", label: "Integrity Ratio", weight: 0.4, source: "Checkpoint clear rate" },
|
|
23
|
+
{ key: "compliance", label: "Compliance", weight: 0.2, source: "Violation impact decay" },
|
|
24
|
+
{ key: "drift_stability", label: "Drift Stability", weight: 0.2, source: "Session stability ratio" },
|
|
25
|
+
{ key: "trace_completeness", label: "Trace Completeness", weight: 0.1, source: "Trace/checkpoint balance" },
|
|
26
|
+
{ key: "coherence_compatibility", label: "Coherence Compatibility", weight: 0.1, source: "Fleet coherence data" }
|
|
27
|
+
];
|
|
28
|
+
export {
|
|
29
|
+
COMPONENT_WEIGHTS,
|
|
30
|
+
GRADE_ORDINALS,
|
|
31
|
+
GRADE_SCALE
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"sourcesContent":["/**\n * Reputation constants.\n *\n * Centralizes grade ordinals, grade scale definitions, and\n * component weight definitions used across all services and SDKs.\n */\n\nimport type { ReputationGrade } from './reputation';\n\n/** Ordinal ranking of reputation grades (higher = better). */\nexport const GRADE_ORDINALS: Record<ReputationGrade, number> = {\n AAA: 7,\n AA: 6,\n A: 5,\n BBB: 4,\n BB: 3,\n B: 2,\n CCC: 1,\n NR: 0,\n};\n\n/** Grade scale definition with tier names and score boundaries. */\nexport interface GradeScaleEntry {\n grade: ReputationGrade;\n tier: string;\n min: number;\n max: number;\n}\n\n/** Grade scale from highest to lowest. */\nexport const GRADE_SCALE: GradeScaleEntry[] = [\n { grade: 'AAA', tier: 'Exemplary', min: 900, max: 1000 },\n { grade: 'AA', tier: 'Established', min: 800, max: 899 },\n { grade: 'A', tier: 'Reliable', min: 700, max: 799 },\n { grade: 'BBB', tier: 'Developing', min: 600, max: 699 },\n { grade: 'BB', tier: 'Emerging', min: 500, max: 599 },\n { grade: 'B', tier: 'Concerning', min: 400, max: 499 },\n { grade: 'CCC', tier: 'Critical', min: 200, max: 399 },\n];\n\n/** Component weight definition. */\nexport interface ComponentWeightEntry {\n key: string;\n label: string;\n weight: number;\n source: string;\n}\n\n/** Scoring component weights. */\nexport const COMPONENT_WEIGHTS: ComponentWeightEntry[] = [\n { key: 'integrity_ratio', label: 'Integrity Ratio', weight: 0.40, source: 'Checkpoint clear rate' },\n { key: 'compliance', label: 'Compliance', weight: 0.20, source: 'Violation impact decay' },\n { key: 'drift_stability', label: 'Drift Stability', weight: 0.20, source: 'Session stability ratio' },\n { key: 'trace_completeness', label: 'Trace Completeness', weight: 0.10, source: 'Trace/checkpoint balance' },\n { key: 'coherence_compatibility', label: 'Coherence Compatibility', weight: 0.10, source: 'Fleet coherence data' },\n];\n"],"mappings":";AAUO,IAAM,iBAAkD;AAAA,EAC7D,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,GAAG;AAAA,EACH,KAAK;AAAA,EACL,IAAI;AACN;AAWO,IAAM,cAAiC;AAAA,EAC5C,EAAE,OAAO,OAAO,MAAM,aAAe,KAAK,KAAK,KAAK,IAAK;AAAA,EACzD,EAAE,OAAO,MAAO,MAAM,eAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,KAAO,MAAM,YAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,OAAO,MAAM,cAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,MAAO,MAAM,YAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,KAAO,MAAM,cAAe,KAAK,KAAK,KAAK,IAAI;AAAA,EACxD,EAAE,OAAO,OAAO,MAAM,YAAe,KAAK,KAAK,KAAK,IAAI;AAC1D;AAWO,IAAM,oBAA4C;AAAA,EACvD,EAAE,KAAK,mBAA0B,OAAO,mBAA0B,QAAQ,KAAM,QAAQ,wBAAwB;AAAA,EAChH,EAAE,KAAK,cAA0B,OAAO,cAA0B,QAAQ,KAAM,QAAQ,yBAAyB;AAAA,EACjH,EAAE,KAAK,mBAA0B,OAAO,mBAA0B,QAAQ,KAAM,QAAQ,0BAA0B;AAAA,EAClH,EAAE,KAAK,sBAA0B,OAAO,sBAA0B,QAAQ,KAAM,QAAQ,2BAA2B;AAAA,EACnH,EAAE,KAAK,2BAA2B,OAAO,2BAA2B,QAAQ,KAAM,QAAQ,uBAAuB;AACnH;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mnemom/types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared type definitions for Mnemom services and SDKs",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"src"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
21
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
22
|
+
"typecheck": "tsc --noEmit"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mnemom",
|
|
26
|
+
"reputation",
|
|
27
|
+
"types",
|
|
28
|
+
"ai",
|
|
29
|
+
"agents"
|
|
30
|
+
],
|
|
31
|
+
"author": "Mnemom.ai",
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/mnemom/mnemom-types"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"tsup": "^8.0.0",
|
|
42
|
+
"typescript": "^5.0.0"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18.0.0"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/a2a.ts
ADDED
package/src/constants.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reputation constants.
|
|
3
|
+
*
|
|
4
|
+
* Centralizes grade ordinals, grade scale definitions, and
|
|
5
|
+
* component weight definitions used across all services and SDKs.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ReputationGrade } from './reputation';
|
|
9
|
+
|
|
10
|
+
/** Ordinal ranking of reputation grades (higher = better). */
|
|
11
|
+
export const GRADE_ORDINALS: Record<ReputationGrade, number> = {
|
|
12
|
+
AAA: 7,
|
|
13
|
+
AA: 6,
|
|
14
|
+
A: 5,
|
|
15
|
+
BBB: 4,
|
|
16
|
+
BB: 3,
|
|
17
|
+
B: 2,
|
|
18
|
+
CCC: 1,
|
|
19
|
+
NR: 0,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Grade scale definition with tier names and score boundaries. */
|
|
23
|
+
export interface GradeScaleEntry {
|
|
24
|
+
grade: ReputationGrade;
|
|
25
|
+
tier: string;
|
|
26
|
+
min: number;
|
|
27
|
+
max: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Grade scale from highest to lowest. */
|
|
31
|
+
export const GRADE_SCALE: GradeScaleEntry[] = [
|
|
32
|
+
{ grade: 'AAA', tier: 'Exemplary', min: 900, max: 1000 },
|
|
33
|
+
{ grade: 'AA', tier: 'Established', min: 800, max: 899 },
|
|
34
|
+
{ grade: 'A', tier: 'Reliable', min: 700, max: 799 },
|
|
35
|
+
{ grade: 'BBB', tier: 'Developing', min: 600, max: 699 },
|
|
36
|
+
{ grade: 'BB', tier: 'Emerging', min: 500, max: 599 },
|
|
37
|
+
{ grade: 'B', tier: 'Concerning', min: 400, max: 499 },
|
|
38
|
+
{ grade: 'CCC', tier: 'Critical', min: 200, max: 399 },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
/** Component weight definition. */
|
|
42
|
+
export interface ComponentWeightEntry {
|
|
43
|
+
key: string;
|
|
44
|
+
label: string;
|
|
45
|
+
weight: number;
|
|
46
|
+
source: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Scoring component weights. */
|
|
50
|
+
export const COMPONENT_WEIGHTS: ComponentWeightEntry[] = [
|
|
51
|
+
{ key: 'integrity_ratio', label: 'Integrity Ratio', weight: 0.40, source: 'Checkpoint clear rate' },
|
|
52
|
+
{ key: 'compliance', label: 'Compliance', weight: 0.20, source: 'Violation impact decay' },
|
|
53
|
+
{ key: 'drift_stability', label: 'Drift Stability', weight: 0.20, source: 'Session stability ratio' },
|
|
54
|
+
{ key: 'trace_completeness', label: 'Trace Completeness', weight: 0.10, source: 'Trace/checkpoint balance' },
|
|
55
|
+
{ key: 'coherence_compatibility', label: 'Coherence Compatibility', weight: 0.10, source: 'Fleet coherence data' },
|
|
56
|
+
];
|
package/src/gate.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reputation gate types.
|
|
3
|
+
*
|
|
4
|
+
* Types for gating agent interactions based on reputation
|
|
5
|
+
* score and grade thresholds.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ReputationGrade, ReputationScore } from './reputation';
|
|
9
|
+
|
|
10
|
+
/** Configuration for a reputation gate. */
|
|
11
|
+
export interface ReputationGateConfig {
|
|
12
|
+
/** Minimum numeric score required (0-1000) */
|
|
13
|
+
minScore?: number;
|
|
14
|
+
/** Minimum letter grade required */
|
|
15
|
+
minGrade?: ReputationGrade;
|
|
16
|
+
/** Base URL for the reputation API */
|
|
17
|
+
baseUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Result of a reputation gate check. */
|
|
21
|
+
export interface GateResult {
|
|
22
|
+
/** Whether the agent is allowed through the gate */
|
|
23
|
+
allowed: boolean;
|
|
24
|
+
/** The agent's reputation score (null if fetch failed) */
|
|
25
|
+
score: ReputationScore | null;
|
|
26
|
+
/** Human-readable reason for denial (if not allowed) */
|
|
27
|
+
reason?: string;
|
|
28
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mnemom/types — Shared type definitions for Mnemom services and SDKs.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import type { ReputationScore, ReputationGrade } from '@mnemom/types';
|
|
7
|
+
* import { GRADE_ORDINALS, COMPONENT_WEIGHTS } from '@mnemom/types';
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// Reputation types
|
|
12
|
+
export type {
|
|
13
|
+
ReputationGrade,
|
|
14
|
+
ConfidenceLevel,
|
|
15
|
+
ReputationComponent,
|
|
16
|
+
ReputationScore,
|
|
17
|
+
A2ATrustExtension,
|
|
18
|
+
} from './reputation';
|
|
19
|
+
|
|
20
|
+
// Gate types
|
|
21
|
+
export type {
|
|
22
|
+
ReputationGateConfig,
|
|
23
|
+
GateResult,
|
|
24
|
+
} from './gate';
|
|
25
|
+
|
|
26
|
+
// Constants
|
|
27
|
+
export {
|
|
28
|
+
GRADE_ORDINALS,
|
|
29
|
+
GRADE_SCALE,
|
|
30
|
+
COMPONENT_WEIGHTS,
|
|
31
|
+
} from './constants';
|
|
32
|
+
|
|
33
|
+
export type {
|
|
34
|
+
GradeScaleEntry,
|
|
35
|
+
ComponentWeightEntry,
|
|
36
|
+
} from './constants';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reputation score types.
|
|
3
|
+
*
|
|
4
|
+
* Canonical definitions for Mnemom reputation scores, grades,
|
|
5
|
+
* confidence levels, and score components.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Reputation grade scale from AAA (highest) to NR (not rated). */
|
|
9
|
+
export type ReputationGrade = 'AAA' | 'AA' | 'A' | 'BBB' | 'BB' | 'B' | 'CCC' | 'NR';
|
|
10
|
+
|
|
11
|
+
/** Confidence level of a reputation score. */
|
|
12
|
+
export type ConfidenceLevel = 'insufficient' | 'low' | 'medium' | 'high';
|
|
13
|
+
|
|
14
|
+
/** A single component contributing to an agent's reputation score. */
|
|
15
|
+
export interface ReputationComponent {
|
|
16
|
+
/** Machine-readable key (e.g. "integrity_ratio", "compliance") */
|
|
17
|
+
key: string;
|
|
18
|
+
/** Human-readable label (e.g. "Integrity Ratio", "Compliance") */
|
|
19
|
+
label: string;
|
|
20
|
+
/** Raw component score (0-1000) */
|
|
21
|
+
score: number;
|
|
22
|
+
/** Weight applied to this component (0-1) */
|
|
23
|
+
weight: number;
|
|
24
|
+
/** score * weight, rounded */
|
|
25
|
+
weighted_score: number;
|
|
26
|
+
/** Human-readable factors explaining the score */
|
|
27
|
+
factors: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Full reputation score for an agent. */
|
|
31
|
+
export interface ReputationScore {
|
|
32
|
+
/** Agent identifier */
|
|
33
|
+
agent_id: string;
|
|
34
|
+
/** Numeric reputation score (0-1000) */
|
|
35
|
+
score: number;
|
|
36
|
+
/** Letter grade */
|
|
37
|
+
grade: ReputationGrade;
|
|
38
|
+
/** Tier label (e.g. "Exemplary", "Reliable") */
|
|
39
|
+
tier: string;
|
|
40
|
+
/** Whether the agent is eligible for reputation (checkpoint_count >= 50) */
|
|
41
|
+
is_eligible: boolean;
|
|
42
|
+
/** Number of checkpoints contributing to the score */
|
|
43
|
+
checkpoint_count: number;
|
|
44
|
+
/** Confidence in the score */
|
|
45
|
+
confidence: ConfidenceLevel;
|
|
46
|
+
/** Score components breakdown */
|
|
47
|
+
components: ReputationComponent[];
|
|
48
|
+
/** When the score was computed (ISO 8601) */
|
|
49
|
+
computed_at: string;
|
|
50
|
+
/** 30-day score trend (positive = improving) */
|
|
51
|
+
trend_30d: number;
|
|
52
|
+
/** Visibility setting */
|
|
53
|
+
visibility: 'public' | 'unlisted' | 'private';
|
|
54
|
+
/** Optional A2A trust extension */
|
|
55
|
+
a2a_trust_extension?: A2ATrustExtension;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A2A trust extension for inter-agent reputation sharing. */
|
|
59
|
+
export interface A2ATrustExtension {
|
|
60
|
+
/** URI identifying this extension */
|
|
61
|
+
extension_uri: string;
|
|
62
|
+
/** Reputation provider identifier */
|
|
63
|
+
provider: string;
|
|
64
|
+
/** Numeric reputation score */
|
|
65
|
+
score: number;
|
|
66
|
+
/** Letter grade */
|
|
67
|
+
grade: ReputationGrade;
|
|
68
|
+
/** Confidence in the score */
|
|
69
|
+
confidence: ConfidenceLevel;
|
|
70
|
+
/** URL to verify the score */
|
|
71
|
+
verified_url: string;
|
|
72
|
+
/** URL to the agent's badge */
|
|
73
|
+
badge_url: string;
|
|
74
|
+
/** URL to the scoring methodology */
|
|
75
|
+
methodology_url: string;
|
|
76
|
+
/** When the score was last updated (ISO 8601) */
|
|
77
|
+
last_updated: string;
|
|
78
|
+
}
|