@reactive-agents/verification 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/LICENSE +21 -0
- package/README.md +39 -0
- package/dist/index.d.ts +133 -0
- package/dist/index.js +286 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tyler Buell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @reactive-agents/verification
|
|
2
|
+
|
|
3
|
+
Output verification for the [Reactive Agents](https://tylerjrbuell.github.io/reactive-agents-ts/) framework.
|
|
4
|
+
|
|
5
|
+
Reduces hallucinations by measuring semantic entropy (consistency across multiple samples) and decomposing claims into verifiable facts.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add @reactive-agents/verification effect
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Techniques
|
|
14
|
+
|
|
15
|
+
| Technique | How it works |
|
|
16
|
+
|-----------|-------------|
|
|
17
|
+
| Semantic entropy | Samples the LLM N times; high variance → low confidence |
|
|
18
|
+
| Fact decomposition | Breaks output into atomic claims, checks each independently |
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { ReactiveAgents } from "reactive-agents";
|
|
24
|
+
|
|
25
|
+
const agent = await ReactiveAgents.create()
|
|
26
|
+
.withName("fact-checker")
|
|
27
|
+
.withProvider("anthropic")
|
|
28
|
+
.withVerification()
|
|
29
|
+
.build();
|
|
30
|
+
|
|
31
|
+
const result = await agent.run("What year did the Berlin Wall fall?");
|
|
32
|
+
console.log(result.metadata.confidence); // 0.0–1.0
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
When confidence is below the threshold, the agent can re-sample or escalate to the user depending on the active interaction mode.
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
Full documentation at [tylerjrbuell.github.io/reactive-agents-ts](https://tylerjrbuell.github.io/reactive-agents-ts/)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Schema, Effect, Context, Layer } from 'effect';
|
|
2
|
+
import * as effect_Cause from 'effect/Cause';
|
|
3
|
+
import * as effect_Types from 'effect/Types';
|
|
4
|
+
import * as effect_Layer from 'effect/Layer';
|
|
5
|
+
|
|
6
|
+
declare const RiskLevel: Schema.Literal<["low", "medium", "high", "critical"]>;
|
|
7
|
+
type RiskLevel = typeof RiskLevel.Type;
|
|
8
|
+
declare const ConfidenceScoreSchema: Schema.Struct<{
|
|
9
|
+
score: typeof Schema.Number;
|
|
10
|
+
calibrated: typeof Schema.Boolean;
|
|
11
|
+
layerScores: Schema.Record$<typeof Schema.String, typeof Schema.Number>;
|
|
12
|
+
}>;
|
|
13
|
+
type ConfidenceScore = typeof ConfidenceScoreSchema.Type;
|
|
14
|
+
declare const ClaimSchema: Schema.Struct<{
|
|
15
|
+
text: typeof Schema.String;
|
|
16
|
+
confidence: typeof Schema.Number;
|
|
17
|
+
source: Schema.optional<typeof Schema.String>;
|
|
18
|
+
}>;
|
|
19
|
+
type Claim = typeof ClaimSchema.Type;
|
|
20
|
+
declare const LayerResultSchema: Schema.Struct<{
|
|
21
|
+
layerName: typeof Schema.String;
|
|
22
|
+
score: typeof Schema.Number;
|
|
23
|
+
passed: typeof Schema.Boolean;
|
|
24
|
+
details: Schema.optional<typeof Schema.String>;
|
|
25
|
+
claims: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
26
|
+
text: typeof Schema.String;
|
|
27
|
+
confidence: typeof Schema.Number;
|
|
28
|
+
source: Schema.optional<typeof Schema.String>;
|
|
29
|
+
}>>>;
|
|
30
|
+
}>;
|
|
31
|
+
type LayerResult = typeof LayerResultSchema.Type;
|
|
32
|
+
declare const VerificationResultSchema: Schema.Struct<{
|
|
33
|
+
overallScore: typeof Schema.Number;
|
|
34
|
+
passed: typeof Schema.Boolean;
|
|
35
|
+
riskLevel: Schema.Literal<["low", "medium", "high", "critical"]>;
|
|
36
|
+
layerResults: Schema.Array$<Schema.Struct<{
|
|
37
|
+
layerName: typeof Schema.String;
|
|
38
|
+
score: typeof Schema.Number;
|
|
39
|
+
passed: typeof Schema.Boolean;
|
|
40
|
+
details: Schema.optional<typeof Schema.String>;
|
|
41
|
+
claims: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
42
|
+
text: typeof Schema.String;
|
|
43
|
+
confidence: typeof Schema.Number;
|
|
44
|
+
source: Schema.optional<typeof Schema.String>;
|
|
45
|
+
}>>>;
|
|
46
|
+
}>>;
|
|
47
|
+
recommendation: Schema.Literal<["accept", "review", "reject"]>;
|
|
48
|
+
verifiedAt: typeof Schema.DateFromSelf;
|
|
49
|
+
}>;
|
|
50
|
+
type VerificationResult = typeof VerificationResultSchema.Type;
|
|
51
|
+
declare const VerificationConfigSchema: Schema.Struct<{
|
|
52
|
+
enableSemanticEntropy: typeof Schema.Boolean;
|
|
53
|
+
enableFactDecomposition: typeof Schema.Boolean;
|
|
54
|
+
enableMultiSource: typeof Schema.Boolean;
|
|
55
|
+
enableSelfConsistency: typeof Schema.Boolean;
|
|
56
|
+
enableNli: typeof Schema.Boolean;
|
|
57
|
+
passThreshold: typeof Schema.Number;
|
|
58
|
+
riskThreshold: typeof Schema.Number;
|
|
59
|
+
}>;
|
|
60
|
+
type VerificationConfig = typeof VerificationConfigSchema.Type;
|
|
61
|
+
declare const defaultVerificationConfig: VerificationConfig;
|
|
62
|
+
|
|
63
|
+
declare const VerificationError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
|
|
64
|
+
readonly _tag: "VerificationError";
|
|
65
|
+
} & Readonly<A>;
|
|
66
|
+
declare class VerificationError extends VerificationError_base<{
|
|
67
|
+
readonly message: string;
|
|
68
|
+
readonly layer?: string;
|
|
69
|
+
readonly cause?: unknown;
|
|
70
|
+
}> {
|
|
71
|
+
}
|
|
72
|
+
declare const CalibrationError_base: new <A extends Record<string, any> = {}>(args: effect_Types.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => effect_Cause.YieldableError & {
|
|
73
|
+
readonly _tag: "CalibrationError";
|
|
74
|
+
} & Readonly<A>;
|
|
75
|
+
declare class CalibrationError extends CalibrationError_base<{
|
|
76
|
+
readonly message: string;
|
|
77
|
+
readonly cause?: unknown;
|
|
78
|
+
}> {
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Semantic Entropy Layer (Tier 1: Heuristic)
|
|
83
|
+
*
|
|
84
|
+
* Measures uncertainty by analyzing word diversity and specificity.
|
|
85
|
+
* Higher entropy = more vague = lower confidence.
|
|
86
|
+
*/
|
|
87
|
+
declare const checkSemanticEntropy: (text: string, _context?: string) => Effect.Effect<LayerResult, never>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Fact Decomposition Layer (Tier 1: Heuristic)
|
|
91
|
+
*
|
|
92
|
+
* Splits response into atomic claims and scores each based on specificity.
|
|
93
|
+
* Claims with dates, numbers, and proper nouns are more verifiable (higher confidence).
|
|
94
|
+
*/
|
|
95
|
+
declare const checkFactDecomposition: (text: string) => Effect.Effect<LayerResult, never>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Multi-Source Layer (Tier 1: Placeholder)
|
|
99
|
+
*
|
|
100
|
+
* In Tier 2, this cross-references claims against multiple sources.
|
|
101
|
+
* In Tier 1, returns moderate confidence as a placeholder.
|
|
102
|
+
*/
|
|
103
|
+
declare const checkMultiSource: (_text: string) => Effect.Effect<LayerResult, never>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Self-Consistency Layer (Tier 1: Heuristic)
|
|
107
|
+
*
|
|
108
|
+
* Checks for internal contradictions within the response.
|
|
109
|
+
* Looks for negation patterns and conflicting statements.
|
|
110
|
+
*/
|
|
111
|
+
declare const checkSelfConsistency: (text: string) => Effect.Effect<LayerResult, never>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Natural Language Inference Layer (Tier 1: Heuristic)
|
|
115
|
+
*
|
|
116
|
+
* Checks if the response logically follows from the input.
|
|
117
|
+
* Uses keyword overlap and relevance heuristics.
|
|
118
|
+
*/
|
|
119
|
+
declare const checkNli: (response: string, input: string) => Effect.Effect<LayerResult, never>;
|
|
120
|
+
|
|
121
|
+
declare const VerificationService_base: Context.TagClass<VerificationService, "VerificationService", {
|
|
122
|
+
/** Verify a response against an input query. */
|
|
123
|
+
readonly verify: (response: string, input: string) => Effect.Effect<VerificationResult, VerificationError>;
|
|
124
|
+
/** Get current verification config. */
|
|
125
|
+
readonly getConfig: () => Effect.Effect<VerificationConfig, never>;
|
|
126
|
+
}>;
|
|
127
|
+
declare class VerificationService extends VerificationService_base {
|
|
128
|
+
}
|
|
129
|
+
declare const VerificationServiceLive: (config: VerificationConfig) => Layer.Layer<VerificationService, never, never>;
|
|
130
|
+
|
|
131
|
+
declare const createVerificationLayer: (config?: Partial<VerificationConfig>) => effect_Layer.Layer<VerificationService, never, never>;
|
|
132
|
+
|
|
133
|
+
export { CalibrationError, type Claim, ClaimSchema, type ConfidenceScore, ConfidenceScoreSchema, type LayerResult, LayerResultSchema, RiskLevel, type VerificationConfig, VerificationConfigSchema, VerificationError, type VerificationResult, VerificationResultSchema, VerificationService, VerificationServiceLive, checkFactDecomposition, checkMultiSource, checkNli, checkSelfConsistency, checkSemanticEntropy, createVerificationLayer, defaultVerificationConfig };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
var RiskLevel = Schema.Literal("low", "medium", "high", "critical");
|
|
4
|
+
var ConfidenceScoreSchema = Schema.Struct({
|
|
5
|
+
score: Schema.Number,
|
|
6
|
+
// 0-1
|
|
7
|
+
calibrated: Schema.Boolean,
|
|
8
|
+
layerScores: Schema.Record({ key: Schema.String, value: Schema.Number })
|
|
9
|
+
});
|
|
10
|
+
var ClaimSchema = Schema.Struct({
|
|
11
|
+
text: Schema.String,
|
|
12
|
+
confidence: Schema.Number,
|
|
13
|
+
source: Schema.optional(Schema.String)
|
|
14
|
+
});
|
|
15
|
+
var LayerResultSchema = Schema.Struct({
|
|
16
|
+
layerName: Schema.String,
|
|
17
|
+
score: Schema.Number,
|
|
18
|
+
// 0-1
|
|
19
|
+
passed: Schema.Boolean,
|
|
20
|
+
details: Schema.optional(Schema.String),
|
|
21
|
+
claims: Schema.optional(Schema.Array(ClaimSchema))
|
|
22
|
+
});
|
|
23
|
+
var VerificationResultSchema = Schema.Struct({
|
|
24
|
+
overallScore: Schema.Number,
|
|
25
|
+
// 0-1
|
|
26
|
+
passed: Schema.Boolean,
|
|
27
|
+
riskLevel: RiskLevel,
|
|
28
|
+
layerResults: Schema.Array(LayerResultSchema),
|
|
29
|
+
recommendation: Schema.Literal("accept", "review", "reject"),
|
|
30
|
+
verifiedAt: Schema.DateFromSelf
|
|
31
|
+
});
|
|
32
|
+
var VerificationConfigSchema = Schema.Struct({
|
|
33
|
+
enableSemanticEntropy: Schema.Boolean,
|
|
34
|
+
enableFactDecomposition: Schema.Boolean,
|
|
35
|
+
enableMultiSource: Schema.Boolean,
|
|
36
|
+
enableSelfConsistency: Schema.Boolean,
|
|
37
|
+
enableNli: Schema.Boolean,
|
|
38
|
+
passThreshold: Schema.Number,
|
|
39
|
+
// Default: 0.7
|
|
40
|
+
riskThreshold: Schema.Number
|
|
41
|
+
// Default: 0.5
|
|
42
|
+
});
|
|
43
|
+
var defaultVerificationConfig = {
|
|
44
|
+
enableSemanticEntropy: true,
|
|
45
|
+
enableFactDecomposition: true,
|
|
46
|
+
enableMultiSource: false,
|
|
47
|
+
// placeholder in Tier 1
|
|
48
|
+
enableSelfConsistency: true,
|
|
49
|
+
enableNli: true,
|
|
50
|
+
passThreshold: 0.7,
|
|
51
|
+
riskThreshold: 0.5
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/errors.ts
|
|
55
|
+
import { Data } from "effect";
|
|
56
|
+
var VerificationError = class extends Data.TaggedError("VerificationError") {
|
|
57
|
+
};
|
|
58
|
+
var CalibrationError = class extends Data.TaggedError("CalibrationError") {
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/layers/semantic-entropy.ts
|
|
62
|
+
import { Effect } from "effect";
|
|
63
|
+
var checkSemanticEntropy = (text, _context) => Effect.sync(() => {
|
|
64
|
+
const words = text.toLowerCase().split(/\s+/).filter((w) => w.length > 2);
|
|
65
|
+
const unique = new Set(words);
|
|
66
|
+
const diversity = words.length > 0 ? unique.size / words.length : 0;
|
|
67
|
+
const hedges = [
|
|
68
|
+
"might",
|
|
69
|
+
"could",
|
|
70
|
+
"perhaps",
|
|
71
|
+
"possibly",
|
|
72
|
+
"maybe",
|
|
73
|
+
"i think",
|
|
74
|
+
"i believe",
|
|
75
|
+
"it seems",
|
|
76
|
+
"probably",
|
|
77
|
+
"likely",
|
|
78
|
+
"not sure",
|
|
79
|
+
"uncertain",
|
|
80
|
+
"approximately",
|
|
81
|
+
"roughly"
|
|
82
|
+
];
|
|
83
|
+
const hedgeCount = hedges.filter((h) => text.toLowerCase().includes(h)).length;
|
|
84
|
+
const hedgePenalty = Math.min(0.3, hedgeCount * 0.1);
|
|
85
|
+
const lengthBonus = Math.min(0.1, words.length / 100);
|
|
86
|
+
const score = Math.max(0, Math.min(1, diversity + lengthBonus - hedgePenalty));
|
|
87
|
+
return {
|
|
88
|
+
layerName: "semantic-entropy",
|
|
89
|
+
score,
|
|
90
|
+
passed: score >= 0.5,
|
|
91
|
+
details: `Diversity: ${diversity.toFixed(2)}, Hedges: ${hedgeCount}, Score: ${score.toFixed(2)}`
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// src/layers/fact-decomposition.ts
|
|
96
|
+
import { Effect as Effect2 } from "effect";
|
|
97
|
+
var checkFactDecomposition = (text) => Effect2.sync(() => {
|
|
98
|
+
const sentences = text.split(/[.!?]+/).map((s) => s.trim()).filter((s) => s.length > 10);
|
|
99
|
+
if (sentences.length === 0) {
|
|
100
|
+
return {
|
|
101
|
+
layerName: "fact-decomposition",
|
|
102
|
+
score: 0.5,
|
|
103
|
+
passed: true,
|
|
104
|
+
details: "No verifiable claims found",
|
|
105
|
+
claims: []
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const claims = sentences.map((sentence) => {
|
|
109
|
+
let confidence = 0.5;
|
|
110
|
+
if (/\d+/.test(sentence)) confidence += 0.15;
|
|
111
|
+
const properNouns = sentence.match(/\b[A-Z][a-z]+\b/g) ?? [];
|
|
112
|
+
confidence += Math.min(0.15, properNouns.length * 0.05);
|
|
113
|
+
if (/\d{4}|\b(January|February|March|April|May|June|July|August|September|October|November|December)\b/i.test(sentence)) {
|
|
114
|
+
confidence += 0.1;
|
|
115
|
+
}
|
|
116
|
+
if (/\b(some|many|often|generally|usually)\b/i.test(sentence)) {
|
|
117
|
+
confidence -= 0.1;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
text: sentence,
|
|
121
|
+
confidence: Math.max(0, Math.min(1, confidence))
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
const avgConfidence = claims.reduce((sum, c) => sum + c.confidence, 0) / claims.length;
|
|
125
|
+
return {
|
|
126
|
+
layerName: "fact-decomposition",
|
|
127
|
+
score: avgConfidence,
|
|
128
|
+
passed: avgConfidence >= 0.5,
|
|
129
|
+
details: `${claims.length} claims, avg confidence: ${avgConfidence.toFixed(2)}`,
|
|
130
|
+
claims
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// src/layers/multi-source.ts
|
|
135
|
+
import { Effect as Effect3 } from "effect";
|
|
136
|
+
var checkMultiSource = (_text) => Effect3.succeed({
|
|
137
|
+
layerName: "multi-source",
|
|
138
|
+
score: 0.6,
|
|
139
|
+
passed: true,
|
|
140
|
+
details: "Tier 1 placeholder \u2014 multi-source verification requires Tier 2"
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// src/layers/self-consistency.ts
|
|
144
|
+
import { Effect as Effect4 } from "effect";
|
|
145
|
+
var checkSelfConsistency = (text) => Effect4.sync(() => {
|
|
146
|
+
const sentences = text.split(/[.!?]+/).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 10);
|
|
147
|
+
if (sentences.length < 2) {
|
|
148
|
+
return {
|
|
149
|
+
layerName: "self-consistency",
|
|
150
|
+
score: 0.8,
|
|
151
|
+
passed: true,
|
|
152
|
+
details: "Too few sentences to check consistency"
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
let contradictions = 0;
|
|
156
|
+
const negationPairs = [
|
|
157
|
+
[/\bis\b/, /\bis not\b/],
|
|
158
|
+
[/\bcan\b/, /\bcannot\b/],
|
|
159
|
+
[/\bwill\b/, /\bwill not\b/],
|
|
160
|
+
[/\btrue\b/, /\bfalse\b/],
|
|
161
|
+
[/\balways\b/, /\bnever\b/],
|
|
162
|
+
[/\beveryone\b/, /\bno one\b/]
|
|
163
|
+
];
|
|
164
|
+
for (let i = 0; i < sentences.length; i++) {
|
|
165
|
+
for (let j = i + 1; j < sentences.length; j++) {
|
|
166
|
+
for (const [pos, neg] of negationPairs) {
|
|
167
|
+
if (pos.test(sentences[i]) && neg.test(sentences[j]) || neg.test(sentences[i]) && pos.test(sentences[j])) {
|
|
168
|
+
const wordsI = new Set(sentences[i].split(/\s+/));
|
|
169
|
+
const wordsJ = new Set(sentences[j].split(/\s+/));
|
|
170
|
+
const overlap = [...wordsI].filter((w) => wordsJ.has(w)).length;
|
|
171
|
+
const similarity = overlap / Math.max(wordsI.size, wordsJ.size);
|
|
172
|
+
if (similarity > 0.3) contradictions++;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const score = Math.max(0, 1 - contradictions * 0.3);
|
|
178
|
+
return {
|
|
179
|
+
layerName: "self-consistency",
|
|
180
|
+
score,
|
|
181
|
+
passed: score >= 0.5,
|
|
182
|
+
details: `${contradictions} potential contradiction(s) found`
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// src/layers/nli.ts
|
|
187
|
+
import { Effect as Effect5 } from "effect";
|
|
188
|
+
var checkNli = (response, input) => Effect5.sync(() => {
|
|
189
|
+
const inputWords = new Set(
|
|
190
|
+
input.toLowerCase().split(/\s+/).filter((w) => w.length > 3)
|
|
191
|
+
);
|
|
192
|
+
const responseWords = response.toLowerCase().split(/\s+/).filter((w) => w.length > 3);
|
|
193
|
+
if (inputWords.size === 0 || responseWords.length === 0) {
|
|
194
|
+
return {
|
|
195
|
+
layerName: "nli",
|
|
196
|
+
score: 0.5,
|
|
197
|
+
passed: true,
|
|
198
|
+
details: "Insufficient text for NLI check"
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const relevantCount = responseWords.filter((w) => inputWords.has(w)).length;
|
|
202
|
+
const relevance = relevantCount / responseWords.length;
|
|
203
|
+
const topicScore = Math.min(1, relevance * 3);
|
|
204
|
+
const offTopicPhrases = [
|
|
205
|
+
"as an ai",
|
|
206
|
+
"i cannot",
|
|
207
|
+
"i'm unable",
|
|
208
|
+
"i don't have",
|
|
209
|
+
"i apologize",
|
|
210
|
+
"sorry, but"
|
|
211
|
+
];
|
|
212
|
+
const offTopicCount = offTopicPhrases.filter(
|
|
213
|
+
(p) => response.toLowerCase().includes(p)
|
|
214
|
+
).length;
|
|
215
|
+
const offTopicPenalty = offTopicCount * 0.1;
|
|
216
|
+
const score = Math.max(0, Math.min(1, topicScore - offTopicPenalty + 0.3));
|
|
217
|
+
return {
|
|
218
|
+
layerName: "nli",
|
|
219
|
+
score,
|
|
220
|
+
passed: score >= 0.5,
|
|
221
|
+
details: `Relevance: ${relevance.toFixed(2)}, Topic score: ${topicScore.toFixed(2)}, Off-topic penalty: ${offTopicPenalty.toFixed(2)}`
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// src/verification-service.ts
|
|
226
|
+
import { Effect as Effect6, Context, Layer } from "effect";
|
|
227
|
+
var VerificationService = class extends Context.Tag("VerificationService")() {
|
|
228
|
+
};
|
|
229
|
+
var VerificationServiceLive = (config) => Layer.succeed(VerificationService, {
|
|
230
|
+
verify: (response, input) => Effect6.gen(function* () {
|
|
231
|
+
const layerResults = [];
|
|
232
|
+
if (config.enableSemanticEntropy) {
|
|
233
|
+
layerResults.push(yield* checkSemanticEntropy(response, input));
|
|
234
|
+
}
|
|
235
|
+
if (config.enableFactDecomposition) {
|
|
236
|
+
layerResults.push(yield* checkFactDecomposition(response));
|
|
237
|
+
}
|
|
238
|
+
if (config.enableMultiSource) {
|
|
239
|
+
layerResults.push(yield* checkMultiSource(response));
|
|
240
|
+
}
|
|
241
|
+
if (config.enableSelfConsistency) {
|
|
242
|
+
layerResults.push(yield* checkSelfConsistency(response));
|
|
243
|
+
}
|
|
244
|
+
if (config.enableNli) {
|
|
245
|
+
layerResults.push(yield* checkNli(response, input));
|
|
246
|
+
}
|
|
247
|
+
const overallScore = layerResults.length > 0 ? layerResults.reduce((sum, r) => sum + r.score, 0) / layerResults.length : 0.5;
|
|
248
|
+
const riskLevel = overallScore >= 0.8 ? "low" : overallScore >= 0.6 ? "medium" : overallScore >= 0.4 ? "high" : "critical";
|
|
249
|
+
const recommendation = overallScore >= config.passThreshold ? "accept" : overallScore >= config.riskThreshold ? "review" : "reject";
|
|
250
|
+
return {
|
|
251
|
+
overallScore,
|
|
252
|
+
passed: overallScore >= config.passThreshold,
|
|
253
|
+
riskLevel,
|
|
254
|
+
layerResults: [...layerResults],
|
|
255
|
+
recommendation,
|
|
256
|
+
verifiedAt: /* @__PURE__ */ new Date()
|
|
257
|
+
};
|
|
258
|
+
}),
|
|
259
|
+
getConfig: () => Effect6.succeed(config)
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// src/runtime.ts
|
|
263
|
+
var createVerificationLayer = (config) => VerificationServiceLive({
|
|
264
|
+
...defaultVerificationConfig,
|
|
265
|
+
...config
|
|
266
|
+
});
|
|
267
|
+
export {
|
|
268
|
+
CalibrationError,
|
|
269
|
+
ClaimSchema,
|
|
270
|
+
ConfidenceScoreSchema,
|
|
271
|
+
LayerResultSchema,
|
|
272
|
+
RiskLevel,
|
|
273
|
+
VerificationConfigSchema,
|
|
274
|
+
VerificationError,
|
|
275
|
+
VerificationResultSchema,
|
|
276
|
+
VerificationService,
|
|
277
|
+
VerificationServiceLive,
|
|
278
|
+
checkFactDecomposition,
|
|
279
|
+
checkMultiSource,
|
|
280
|
+
checkNli,
|
|
281
|
+
checkSelfConsistency,
|
|
282
|
+
checkSemanticEntropy,
|
|
283
|
+
createVerificationLayer,
|
|
284
|
+
defaultVerificationConfig
|
|
285
|
+
};
|
|
286
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/errors.ts","../src/layers/semantic-entropy.ts","../src/layers/fact-decomposition.ts","../src/layers/multi-source.ts","../src/layers/self-consistency.ts","../src/layers/nli.ts","../src/verification-service.ts","../src/runtime.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n// ─── Risk Level ───\n\nexport const RiskLevel = Schema.Literal(\"low\", \"medium\", \"high\", \"critical\");\nexport type RiskLevel = typeof RiskLevel.Type;\n\n// ─── Confidence Score ───\n\nexport const ConfidenceScoreSchema = Schema.Struct({\n score: Schema.Number, // 0-1\n calibrated: Schema.Boolean,\n layerScores: Schema.Record({ key: Schema.String, value: Schema.Number }),\n});\nexport type ConfidenceScore = typeof ConfidenceScoreSchema.Type;\n\n// ─── Claim ───\n\nexport const ClaimSchema = Schema.Struct({\n text: Schema.String,\n confidence: Schema.Number,\n source: Schema.optional(Schema.String),\n});\nexport type Claim = typeof ClaimSchema.Type;\n\n// ─── Verification Layer Result ───\n\nexport const LayerResultSchema = Schema.Struct({\n layerName: Schema.String,\n score: Schema.Number, // 0-1\n passed: Schema.Boolean,\n details: Schema.optional(Schema.String),\n claims: Schema.optional(Schema.Array(ClaimSchema)),\n});\nexport type LayerResult = typeof LayerResultSchema.Type;\n\n// ─── Verification Result ───\n\nexport const VerificationResultSchema = Schema.Struct({\n overallScore: Schema.Number, // 0-1\n passed: Schema.Boolean,\n riskLevel: RiskLevel,\n layerResults: Schema.Array(LayerResultSchema),\n recommendation: Schema.Literal(\"accept\", \"review\", \"reject\"),\n verifiedAt: Schema.DateFromSelf,\n});\nexport type VerificationResult = typeof VerificationResultSchema.Type;\n\n// ─── Verification Config ───\n\nexport const VerificationConfigSchema = Schema.Struct({\n enableSemanticEntropy: Schema.Boolean,\n enableFactDecomposition: Schema.Boolean,\n enableMultiSource: Schema.Boolean,\n enableSelfConsistency: Schema.Boolean,\n enableNli: Schema.Boolean,\n passThreshold: Schema.Number, // Default: 0.7\n riskThreshold: Schema.Number, // Default: 0.5\n});\nexport type VerificationConfig = typeof VerificationConfigSchema.Type;\n\nexport const defaultVerificationConfig: VerificationConfig = {\n enableSemanticEntropy: true,\n enableFactDecomposition: true,\n enableMultiSource: false, // placeholder in Tier 1\n enableSelfConsistency: true,\n enableNli: true,\n passThreshold: 0.7,\n riskThreshold: 0.5,\n};\n","import { Data } from \"effect\";\n\nexport class VerificationError extends Data.TaggedError(\"VerificationError\")<{\n readonly message: string;\n readonly layer?: string;\n readonly cause?: unknown;\n}> {}\n\nexport class CalibrationError extends Data.TaggedError(\"CalibrationError\")<{\n readonly message: string;\n readonly cause?: unknown;\n}> {}\n","import { Effect } from \"effect\";\nimport type { LayerResult } from \"../types.js\";\n\n/**\n * Semantic Entropy Layer (Tier 1: Heuristic)\n *\n * Measures uncertainty by analyzing word diversity and specificity.\n * Higher entropy = more vague = lower confidence.\n */\nexport const checkSemanticEntropy = (\n text: string,\n _context?: string,\n): Effect.Effect<LayerResult, never> =>\n Effect.sync(() => {\n const words = text.toLowerCase().split(/\\s+/).filter((w) => w.length > 2);\n const unique = new Set(words);\n const diversity = words.length > 0 ? unique.size / words.length : 0;\n\n // Hedging phrases indicate uncertainty\n const hedges = [\n \"might\", \"could\", \"perhaps\", \"possibly\", \"maybe\",\n \"i think\", \"i believe\", \"it seems\", \"probably\", \"likely\",\n \"not sure\", \"uncertain\", \"approximately\", \"roughly\",\n ];\n const hedgeCount = hedges.filter((h) => text.toLowerCase().includes(h)).length;\n const hedgePenalty = Math.min(0.3, hedgeCount * 0.1);\n\n // Very short responses are suspicious\n const lengthBonus = Math.min(0.1, words.length / 100);\n\n const score = Math.max(0, Math.min(1, diversity + lengthBonus - hedgePenalty));\n\n return {\n layerName: \"semantic-entropy\",\n score,\n passed: score >= 0.5,\n details: `Diversity: ${diversity.toFixed(2)}, Hedges: ${hedgeCount}, Score: ${score.toFixed(2)}`,\n } satisfies LayerResult;\n });\n","import { Effect } from \"effect\";\nimport type { LayerResult, Claim } from \"../types.js\";\n\n/**\n * Fact Decomposition Layer (Tier 1: Heuristic)\n *\n * Splits response into atomic claims and scores each based on specificity.\n * Claims with dates, numbers, and proper nouns are more verifiable (higher confidence).\n */\nexport const checkFactDecomposition = (\n text: string,\n): Effect.Effect<LayerResult, never> =>\n Effect.sync(() => {\n // Split into sentences\n const sentences = text\n .split(/[.!?]+/)\n .map((s) => s.trim())\n .filter((s) => s.length > 10);\n\n if (sentences.length === 0) {\n return {\n layerName: \"fact-decomposition\",\n score: 0.5,\n passed: true,\n details: \"No verifiable claims found\",\n claims: [],\n };\n }\n\n const claims: Claim[] = sentences.map((sentence) => {\n let confidence = 0.5; // baseline\n\n // Numbers increase specificity\n if (/\\d+/.test(sentence)) confidence += 0.15;\n\n // Proper nouns (capitalized words) increase specificity\n const properNouns = sentence.match(/\\b[A-Z][a-z]+\\b/g) ?? [];\n confidence += Math.min(0.15, properNouns.length * 0.05);\n\n // Dates increase specificity\n if (/\\d{4}|\\b(January|February|March|April|May|June|July|August|September|October|November|December)\\b/i.test(sentence)) {\n confidence += 0.1;\n }\n\n // Weasel words decrease confidence\n if (/\\b(some|many|often|generally|usually)\\b/i.test(sentence)) {\n confidence -= 0.1;\n }\n\n return {\n text: sentence,\n confidence: Math.max(0, Math.min(1, confidence)),\n };\n });\n\n const avgConfidence = claims.reduce((sum, c) => sum + c.confidence, 0) / claims.length;\n\n return {\n layerName: \"fact-decomposition\",\n score: avgConfidence,\n passed: avgConfidence >= 0.5,\n details: `${claims.length} claims, avg confidence: ${avgConfidence.toFixed(2)}`,\n claims,\n } satisfies LayerResult;\n });\n","import { Effect } from \"effect\";\nimport type { LayerResult } from \"../types.js\";\n\n/**\n * Multi-Source Layer (Tier 1: Placeholder)\n *\n * In Tier 2, this cross-references claims against multiple sources.\n * In Tier 1, returns moderate confidence as a placeholder.\n */\nexport const checkMultiSource = (\n _text: string,\n): Effect.Effect<LayerResult, never> =>\n Effect.succeed({\n layerName: \"multi-source\",\n score: 0.6,\n passed: true,\n details: \"Tier 1 placeholder — multi-source verification requires Tier 2\",\n });\n","import { Effect } from \"effect\";\nimport type { LayerResult } from \"../types.js\";\n\n/**\n * Self-Consistency Layer (Tier 1: Heuristic)\n *\n * Checks for internal contradictions within the response.\n * Looks for negation patterns and conflicting statements.\n */\nexport const checkSelfConsistency = (\n text: string,\n): Effect.Effect<LayerResult, never> =>\n Effect.sync(() => {\n const sentences = text\n .split(/[.!?]+/)\n .map((s) => s.trim().toLowerCase())\n .filter((s) => s.length > 10);\n\n if (sentences.length < 2) {\n return {\n layerName: \"self-consistency\",\n score: 0.8,\n passed: true,\n details: \"Too few sentences to check consistency\",\n };\n }\n\n let contradictions = 0;\n\n // Check for direct negation patterns\n const negationPairs = [\n [/\\bis\\b/, /\\bis not\\b/],\n [/\\bcan\\b/, /\\bcannot\\b/],\n [/\\bwill\\b/, /\\bwill not\\b/],\n [/\\btrue\\b/, /\\bfalse\\b/],\n [/\\balways\\b/, /\\bnever\\b/],\n [/\\beveryone\\b/, /\\bno one\\b/],\n ] as const;\n\n for (let i = 0; i < sentences.length; i++) {\n for (let j = i + 1; j < sentences.length; j++) {\n for (const [pos, neg] of negationPairs) {\n if (\n (pos.test(sentences[i]!) && neg.test(sentences[j]!)) ||\n (neg.test(sentences[i]!) && pos.test(sentences[j]!))\n ) {\n // Check if about same subject (share >50% words)\n const wordsI = new Set(sentences[i]!.split(/\\s+/));\n const wordsJ = new Set(sentences[j]!.split(/\\s+/));\n const overlap = [...wordsI].filter((w) => wordsJ.has(w)).length;\n const similarity = overlap / Math.max(wordsI.size, wordsJ.size);\n if (similarity > 0.3) contradictions++;\n }\n }\n }\n }\n\n const score = Math.max(0, 1 - contradictions * 0.3);\n\n return {\n layerName: \"self-consistency\",\n score,\n passed: score >= 0.5,\n details: `${contradictions} potential contradiction(s) found`,\n } satisfies LayerResult;\n });\n","import { Effect } from \"effect\";\nimport type { LayerResult } from \"../types.js\";\n\n/**\n * Natural Language Inference Layer (Tier 1: Heuristic)\n *\n * Checks if the response logically follows from the input.\n * Uses keyword overlap and relevance heuristics.\n */\nexport const checkNli = (\n response: string,\n input: string,\n): Effect.Effect<LayerResult, never> =>\n Effect.sync(() => {\n const inputWords = new Set(\n input.toLowerCase().split(/\\s+/).filter((w) => w.length > 3),\n );\n const responseWords = response.toLowerCase().split(/\\s+/).filter((w) => w.length > 3);\n\n if (inputWords.size === 0 || responseWords.length === 0) {\n return {\n layerName: \"nli\",\n score: 0.5,\n passed: true,\n details: \"Insufficient text for NLI check\",\n };\n }\n\n // Relevance: what fraction of response words relate to input\n const relevantCount = responseWords.filter((w) => inputWords.has(w)).length;\n const relevance = relevantCount / responseWords.length;\n\n // Topicality: does the response stay on topic?\n const topicScore = Math.min(1, relevance * 3); // scale up — even 33% overlap is good\n\n // Off-topic penalty\n const offTopicPhrases = [\n \"as an ai\", \"i cannot\", \"i'm unable\", \"i don't have\",\n \"i apologize\", \"sorry, but\",\n ];\n const offTopicCount = offTopicPhrases.filter((p) =>\n response.toLowerCase().includes(p),\n ).length;\n const offTopicPenalty = offTopicCount * 0.1;\n\n const score = Math.max(0, Math.min(1, topicScore - offTopicPenalty + 0.3));\n\n return {\n layerName: \"nli\",\n score,\n passed: score >= 0.5,\n details: `Relevance: ${relevance.toFixed(2)}, Topic score: ${topicScore.toFixed(2)}, Off-topic penalty: ${offTopicPenalty.toFixed(2)}`,\n } satisfies LayerResult;\n });\n","import { Effect, Context, Layer } from \"effect\";\nimport type { VerificationResult, VerificationConfig, LayerResult, RiskLevel } from \"./types.js\";\nimport { VerificationError } from \"./errors.js\";\nimport { checkSemanticEntropy } from \"./layers/semantic-entropy.js\";\nimport { checkFactDecomposition } from \"./layers/fact-decomposition.js\";\nimport { checkMultiSource } from \"./layers/multi-source.js\";\nimport { checkSelfConsistency } from \"./layers/self-consistency.js\";\nimport { checkNli } from \"./layers/nli.js\";\n\n// ─── Service Tag ───\n\nexport class VerificationService extends Context.Tag(\"VerificationService\")<\n VerificationService,\n {\n /** Verify a response against an input query. */\n readonly verify: (\n response: string,\n input: string,\n ) => Effect.Effect<VerificationResult, VerificationError>;\n\n /** Get current verification config. */\n readonly getConfig: () => Effect.Effect<VerificationConfig, never>;\n }\n>() {}\n\n// ─── Live Implementation ───\n\nexport const VerificationServiceLive = (config: VerificationConfig) =>\n Layer.succeed(VerificationService, {\n verify: (response, input) =>\n Effect.gen(function* () {\n const layerResults: LayerResult[] = [];\n\n if (config.enableSemanticEntropy) {\n layerResults.push(yield* checkSemanticEntropy(response, input));\n }\n\n if (config.enableFactDecomposition) {\n layerResults.push(yield* checkFactDecomposition(response));\n }\n\n if (config.enableMultiSource) {\n layerResults.push(yield* checkMultiSource(response));\n }\n\n if (config.enableSelfConsistency) {\n layerResults.push(yield* checkSelfConsistency(response));\n }\n\n if (config.enableNli) {\n layerResults.push(yield* checkNli(response, input));\n }\n\n // Weighted average of layer scores\n const overallScore =\n layerResults.length > 0\n ? layerResults.reduce((sum, r) => sum + r.score, 0) / layerResults.length\n : 0.5;\n\n const riskLevel: RiskLevel =\n overallScore >= 0.8 ? \"low\" :\n overallScore >= 0.6 ? \"medium\" :\n overallScore >= 0.4 ? \"high\" : \"critical\";\n\n const recommendation =\n overallScore >= config.passThreshold ? \"accept\" as const :\n overallScore >= config.riskThreshold ? \"review\" as const :\n \"reject\" as const;\n\n return {\n overallScore,\n passed: overallScore >= config.passThreshold,\n riskLevel,\n layerResults: [...layerResults],\n recommendation,\n verifiedAt: new Date(),\n } satisfies VerificationResult;\n }),\n\n getConfig: () => Effect.succeed(config),\n });\n","import type { VerificationConfig } from \"./types.js\";\nimport { defaultVerificationConfig } from \"./types.js\";\nimport { VerificationServiceLive } from \"./verification-service.js\";\n\nexport const createVerificationLayer = (config?: Partial<VerificationConfig>) =>\n VerificationServiceLive({\n ...defaultVerificationConfig,\n ...config,\n });\n"],"mappings":";AAAA,SAAS,cAAc;AAIhB,IAAM,YAAY,OAAO,QAAQ,OAAO,UAAU,QAAQ,UAAU;AAKpE,IAAM,wBAAwB,OAAO,OAAO;AAAA,EACjD,OAAO,OAAO;AAAA;AAAA,EACd,YAAY,OAAO;AAAA,EACnB,aAAa,OAAO,OAAO,EAAE,KAAK,OAAO,QAAQ,OAAO,OAAO,OAAO,CAAC;AACzE,CAAC;AAKM,IAAM,cAAc,OAAO,OAAO;AAAA,EACvC,MAAM,OAAO;AAAA,EACb,YAAY,OAAO;AAAA,EACnB,QAAQ,OAAO,SAAS,OAAO,MAAM;AACvC,CAAC;AAKM,IAAM,oBAAoB,OAAO,OAAO;AAAA,EAC7C,WAAW,OAAO;AAAA,EAClB,OAAO,OAAO;AAAA;AAAA,EACd,QAAQ,OAAO;AAAA,EACf,SAAS,OAAO,SAAS,OAAO,MAAM;AAAA,EACtC,QAAQ,OAAO,SAAS,OAAO,MAAM,WAAW,CAAC;AACnD,CAAC;AAKM,IAAM,2BAA2B,OAAO,OAAO;AAAA,EACpD,cAAc,OAAO;AAAA;AAAA,EACrB,QAAQ,OAAO;AAAA,EACf,WAAW;AAAA,EACX,cAAc,OAAO,MAAM,iBAAiB;AAAA,EAC5C,gBAAgB,OAAO,QAAQ,UAAU,UAAU,QAAQ;AAAA,EAC3D,YAAY,OAAO;AACrB,CAAC;AAKM,IAAM,2BAA2B,OAAO,OAAO;AAAA,EACpD,uBAAuB,OAAO;AAAA,EAC9B,yBAAyB,OAAO;AAAA,EAChC,mBAAmB,OAAO;AAAA,EAC1B,uBAAuB,OAAO;AAAA,EAC9B,WAAW,OAAO;AAAA,EAClB,eAAe,OAAO;AAAA;AAAA,EACtB,eAAe,OAAO;AAAA;AACxB,CAAC;AAGM,I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O,QAAQ,MAAM;AACxC,CAAC;;;AC5EI,IAAM,0BAA0B,CAAC,WACtC,wBAAwB;AAAA,EACtB,GAAG;AAAA,EACH,GAAG;AACL,CAAC;","names":["Effect","Effect","Effect","Effect","Effect","Effect"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@reactive-agents/verification",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsup --config ../../tsup.config.base.ts",
|
|
9
|
+
"typecheck": "tsc --noEmit",
|
|
10
|
+
"test": "bun test",
|
|
11
|
+
"test:watch": "bun test --watch"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"effect": "^3.10.0",
|
|
15
|
+
"@reactive-agents/core": "0.1.0",
|
|
16
|
+
"@reactive-agents/llm-provider": "0.1.0",
|
|
17
|
+
"@reactive-agents/memory": "0.1.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"typescript": "^5.7.0",
|
|
21
|
+
"bun-types": "latest"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/tylerjrbuell/reactive-agents-ts.git",
|
|
27
|
+
"directory": "packages/verification"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist",
|
|
34
|
+
"README.md",
|
|
35
|
+
"LICENSE"
|
|
36
|
+
],
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.js",
|
|
41
|
+
"default": "./dist/index.js"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"description": "Output verification for Reactive Agents — semantic entropy and fact decomposition",
|
|
45
|
+
"homepage": "https://tylerjrbuell.github.io/reactive-agents-ts/",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/tylerjrbuell/reactive-agents-ts/issues"
|
|
48
|
+
}
|
|
49
|
+
}
|