@llmagentscore/core 0.2.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.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/anthropic.d.ts +16 -0
- package/dist/llm/anthropic.d.ts.map +1 -0
- package/dist/llm/anthropic.js +67 -0
- package/dist/llm/anthropic.js.map +1 -0
- package/dist/llm/index.d.ts +3 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +2 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/types.d.ts +18 -0
- package/dist/llm/types.d.ts.map +1 -0
- package/dist/llm/types.js +2 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/parser/generic.d.ts +11 -0
- package/dist/parser/generic.d.ts.map +1 -0
- package/dist/parser/generic.js +104 -0
- package/dist/parser/generic.js.map +1 -0
- package/dist/parser/openclaw.d.ts +11 -0
- package/dist/parser/openclaw.d.ts.map +1 -0
- package/dist/parser/openclaw.js +80 -0
- package/dist/parser/openclaw.js.map +1 -0
- package/dist/parser/prompt.d.ts +9 -0
- package/dist/parser/prompt.d.ts.map +1 -0
- package/dist/parser/prompt.js +114 -0
- package/dist/parser/prompt.js.map +1 -0
- package/dist/parser/types.d.ts +58 -0
- package/dist/parser/types.d.ts.map +1 -0
- package/dist/parser/types.js +2 -0
- package/dist/parser/types.js.map +1 -0
- package/dist/score-session.d.ts +11 -0
- package/dist/score-session.d.ts.map +1 -0
- package/dist/score-session.js +15 -0
- package/dist/score-session.js.map +1 -0
- package/dist/scorer/align.d.ts +15 -0
- package/dist/scorer/align.d.ts.map +1 -0
- package/dist/scorer/align.js +175 -0
- package/dist/scorer/align.js.map +1 -0
- package/dist/scorer/drift.d.ts +8 -0
- package/dist/scorer/drift.d.ts.map +1 -0
- package/dist/scorer/drift.js +117 -0
- package/dist/scorer/drift.js.map +1 -0
- package/dist/scorer/index.d.ts +4 -0
- package/dist/scorer/index.d.ts.map +1 -0
- package/dist/scorer/index.js +4 -0
- package/dist/scorer/index.js.map +1 -0
- package/dist/scorer/llm-align.d.ts +17 -0
- package/dist/scorer/llm-align.d.ts.map +1 -0
- package/dist/scorer/llm-align.js +299 -0
- package/dist/scorer/llm-align.js.map +1 -0
- package/dist/scorer/llm-schemas.d.ts +234 -0
- package/dist/scorer/llm-schemas.d.ts.map +1 -0
- package/dist/scorer/llm-schemas.js +46 -0
- package/dist/scorer/llm-schemas.js.map +1 -0
- package/dist/scorer/truthful.d.ts +10 -0
- package/dist/scorer/truthful.d.ts.map +1 -0
- package/dist/scorer/truthful.js +57 -0
- package/dist/scorer/truthful.js.map +1 -0
- package/dist/scorer/types.d.ts +77 -0
- package/dist/scorer/types.d.ts.map +1 -0
- package/dist/scorer/types.js +2 -0
- package/dist/scorer/types.js.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/entities.d.ts +20 -0
- package/dist/utils/entities.d.ts.map +1 -0
- package/dist/utils/entities.js +75 -0
- package/dist/utils/entities.js.map +1 -0
- package/dist/utils/hash.d.ts +16 -0
- package/dist/utils/hash.d.ts.map +1 -0
- package/dist/utils/hash.js +47 -0
- package/dist/utils/hash.js.map +1 -0
- package/dist/utils/semantic.d.ts +29 -0
- package/dist/utils/semantic.d.ts.map +1 -0
- package/dist/utils/semantic.js +121 -0
- package/dist/utils/semantic.js.map +1 -0
- package/dist/utils/tool-verbs.d.ts +16 -0
- package/dist/utils/tool-verbs.d.ts.map +1 -0
- package/dist/utils/tool-verbs.js +89 -0
- package/dist/utils/tool-verbs.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"truthful.js","sourceRoot":"","sources":["../../src/scorer/truthful.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM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GAAG,CAAC,CAAC;IAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,MAAc;IACnC,uBAAuB;IACvB,MAAM,SAAS,GAAG,MAAM;SACrB,KAAK,CAAC,mEAAmE,CAAC;SAC1E,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE/B,8EAA8E;IAC9E,MAAM,cAAc,GAAG;QACrB,+cAA+c;QAC/c,kIAAkI;QAClI,+CAA+C;KAChD,CAAC;IAEF,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CACnC,cAAc,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CACzD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { AgentAction } from '../parser/types.js';
|
|
2
|
+
/** A successfully matched action: expected instruction → actual execution */
|
|
3
|
+
export interface MatchedAction {
|
|
4
|
+
/** The expected instruction text */
|
|
5
|
+
expected: string;
|
|
6
|
+
/** The actual action that matched */
|
|
7
|
+
actual: AgentAction;
|
|
8
|
+
/** Match confidence (0-1) */
|
|
9
|
+
confidence: number;
|
|
10
|
+
/** LLM explanation (only present for LLM scoring) */
|
|
11
|
+
reasoning?: string;
|
|
12
|
+
}
|
|
13
|
+
/** Result of truthfulness verification */
|
|
14
|
+
export interface TruthfulnessResult {
|
|
15
|
+
/** Overall truthfulness score (0-100) */
|
|
16
|
+
score: number;
|
|
17
|
+
/** Individual claim verifications */
|
|
18
|
+
claims: TruthfulnessClaim[];
|
|
19
|
+
}
|
|
20
|
+
/** A single claim from the agent's report and its verification status */
|
|
21
|
+
export interface TruthfulnessClaim {
|
|
22
|
+
/** What the agent claimed it did */
|
|
23
|
+
claimed: string;
|
|
24
|
+
/** Whether a matching action was found */
|
|
25
|
+
verified: boolean;
|
|
26
|
+
/** The matching action, if found */
|
|
27
|
+
matchedAction?: AgentAction;
|
|
28
|
+
/** Match confidence (0-1) */
|
|
29
|
+
confidence: number;
|
|
30
|
+
}
|
|
31
|
+
/** A constraint that was violated by the agent */
|
|
32
|
+
export interface ConstraintViolation {
|
|
33
|
+
/** The constraint that was violated */
|
|
34
|
+
constraint: string;
|
|
35
|
+
/** The action that violated it */
|
|
36
|
+
violatingAction: AgentAction;
|
|
37
|
+
/** Description of the violation */
|
|
38
|
+
description: string;
|
|
39
|
+
}
|
|
40
|
+
/** Complete alignment score output */
|
|
41
|
+
export interface AlignmentScore {
|
|
42
|
+
/** Overall alignment score (0-100) */
|
|
43
|
+
score: number;
|
|
44
|
+
/** Truthfulness score (0-100) */
|
|
45
|
+
truthfulness: number;
|
|
46
|
+
/** Actions that matched expected instructions */
|
|
47
|
+
matched: MatchedAction[];
|
|
48
|
+
/** Instructions that were not executed */
|
|
49
|
+
missed: string[];
|
|
50
|
+
/** Actions taken that were not in the instructions */
|
|
51
|
+
unexpected: AgentAction[];
|
|
52
|
+
/** Constraint violations */
|
|
53
|
+
violations: ConstraintViolation[];
|
|
54
|
+
/** Human-readable summary */
|
|
55
|
+
details: string;
|
|
56
|
+
}
|
|
57
|
+
/** Drift analysis comparing current behavior to a baseline */
|
|
58
|
+
export interface DriftReport {
|
|
59
|
+
/** Current session hash */
|
|
60
|
+
currentHash: string;
|
|
61
|
+
/** Baseline session hash */
|
|
62
|
+
baselineHash: string;
|
|
63
|
+
/** Drift percentage (0-100) */
|
|
64
|
+
driftPercentage: number;
|
|
65
|
+
/** What changed from baseline */
|
|
66
|
+
changes: DriftChange[];
|
|
67
|
+
}
|
|
68
|
+
/** A single behavioral change detected in drift analysis */
|
|
69
|
+
export interface DriftChange {
|
|
70
|
+
/** Type of change */
|
|
71
|
+
type: 'added_tool' | 'removed_tool' | 'frequency_change' | 'order_change';
|
|
72
|
+
/** Description of the change */
|
|
73
|
+
description: string;
|
|
74
|
+
/** Severity (0-1) */
|
|
75
|
+
severity: number;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/scorer/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,MAAM,EAAE,WAAW,CAAC;IACpB,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,MAAM,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,QAAQ,EAAE,OAAO,CAAC;IAClB,oCAAoC;IACpC,aAAa,CAAC,EAAE,WAAW,CAAC;IAC5B,6BAA6B;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,kDAAkD;AAClD,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,eAAe,EAAE,WAAW,CAAC;IAC7B,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,sDAAsD;IACtD,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,4BAA4B;IAC5B,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAClC,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,8DAA8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,4BAA4B;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,eAAe,EAAE,MAAM,CAAC;IACxB,iCAAiC;IACjC,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,qBAAqB;IACrB,IAAI,EAAE,YAAY,GAAG,cAAc,GAAG,kBAAkB,GAAG,cAAc,CAAC;IAC1E,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/scorer/types.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { AgentAction, PromptInstruction, Constraint, AgentSession, ScoringInput, } from './parser/types.js';
|
|
2
|
+
export type { AlignmentScore, MatchedAction, TruthfulnessResult, TruthfulnessClaim, ConstraintViolation, DriftReport, DriftChange, } from './scorer/types.js';
|
|
3
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,YAAY,GACb,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,WAAW,GACZ,MAAM,mBAAmB,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ExtractedEntities {
|
|
2
|
+
emails: string[];
|
|
3
|
+
urls: string[];
|
|
4
|
+
filenames: string[];
|
|
5
|
+
quotedStrings: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Extract structured entities (emails, URLs, filenames, quoted strings) from text.
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractEntities(text: string): ExtractedEntities;
|
|
11
|
+
/**
|
|
12
|
+
* Compute entity overlap between two sets of extracted entities.
|
|
13
|
+
* Returns a score (0-1) indicating how much overlap exists.
|
|
14
|
+
*/
|
|
15
|
+
export declare function entityOverlap(a: ExtractedEntities, b: ExtractedEntities): number;
|
|
16
|
+
/**
|
|
17
|
+
* Flatten an entities object into a single string for text-based matching.
|
|
18
|
+
*/
|
|
19
|
+
export declare function entitiesToString(entities: ExtractedEntities): string;
|
|
20
|
+
//# sourceMappingURL=entities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/utils/entities.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,CAwB/D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAsChF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,CAGpE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/** Patterns for extracting entities from text */
|
|
2
|
+
const EMAIL_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
|
|
3
|
+
const URL_PATTERN = /https?:\/\/[^\s"'<>)]+/g;
|
|
4
|
+
const FILE_PATTERN = /(?:^|\s|["'(])([a-zA-Z0-9_.-]+\.[a-zA-Z]{1,10})(?=\s|$|["')]|,|;)/gm;
|
|
5
|
+
const QUOTED_STRING_PATTERN = /"([^"]+)"|'([^']+)'/g;
|
|
6
|
+
/**
|
|
7
|
+
* Extract structured entities (emails, URLs, filenames, quoted strings) from text.
|
|
8
|
+
*/
|
|
9
|
+
export function extractEntities(text) {
|
|
10
|
+
const emails = [...new Set([...text.matchAll(EMAIL_PATTERN)].map((m) => m[0].toLowerCase()))];
|
|
11
|
+
const urls = [...new Set([...text.matchAll(URL_PATTERN)].map((m) => m[0]))];
|
|
12
|
+
const filenames = [];
|
|
13
|
+
for (const match of text.matchAll(FILE_PATTERN)) {
|
|
14
|
+
const filename = match[1];
|
|
15
|
+
// Filter out common false positives
|
|
16
|
+
if (!['e.g', 'i.e', 'etc.'].some((fp) => filename.startsWith(fp))) {
|
|
17
|
+
filenames.push(filename);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const quotedStrings = [];
|
|
21
|
+
for (const match of text.matchAll(QUOTED_STRING_PATTERN)) {
|
|
22
|
+
quotedStrings.push(match[1] || match[2]);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
emails: [...new Set(emails)],
|
|
26
|
+
urls: [...new Set(urls)],
|
|
27
|
+
filenames: [...new Set(filenames)],
|
|
28
|
+
quotedStrings: [...new Set(quotedStrings)],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Compute entity overlap between two sets of extracted entities.
|
|
33
|
+
* Returns a score (0-1) indicating how much overlap exists.
|
|
34
|
+
*/
|
|
35
|
+
export function entityOverlap(a, b) {
|
|
36
|
+
let matches = 0;
|
|
37
|
+
let total = 0;
|
|
38
|
+
// Check emails
|
|
39
|
+
for (const email of a.emails) {
|
|
40
|
+
total++;
|
|
41
|
+
if (b.emails.includes(email))
|
|
42
|
+
matches++;
|
|
43
|
+
}
|
|
44
|
+
// Check URLs
|
|
45
|
+
for (const url of a.urls) {
|
|
46
|
+
total++;
|
|
47
|
+
if (b.urls.some((bUrl) => bUrl.includes(url) || url.includes(bUrl)))
|
|
48
|
+
matches++;
|
|
49
|
+
}
|
|
50
|
+
// Check filenames
|
|
51
|
+
for (const file of a.filenames) {
|
|
52
|
+
total++;
|
|
53
|
+
if (b.filenames.includes(file))
|
|
54
|
+
matches++;
|
|
55
|
+
}
|
|
56
|
+
// Check quoted strings (fuzzy — substring match)
|
|
57
|
+
for (const qs of a.quotedStrings) {
|
|
58
|
+
total++;
|
|
59
|
+
if (b.quotedStrings.some((bQs) => bQs.toLowerCase().includes(qs.toLowerCase()) ||
|
|
60
|
+
qs.toLowerCase().includes(bQs.toLowerCase()))) {
|
|
61
|
+
matches++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (total === 0)
|
|
65
|
+
return 0;
|
|
66
|
+
return matches / total;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Flatten an entities object into a single string for text-based matching.
|
|
70
|
+
*/
|
|
71
|
+
export function entitiesToString(entities) {
|
|
72
|
+
return [...entities.emails, ...entities.urls, ...entities.filenames, ...entities.quotedStrings]
|
|
73
|
+
.join(' ');
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=entities.js.map
|
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,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC;IAC5C,CAAC;IAED,iDAAiD;IACjD,KAAK,MAAM,EAAE,IAAI,CAAC,CAAC,aAAa,EAAE,CAAC;QACjC,KAAK,EAAE,CAAC;QACR,IACE,CAAC,CAAC,aAAa,CAAC,IAAI,CAClB,CAAC,GAAG,EAAE,EAAE,CACN,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;YAC5C,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAC/C,EACD,CAAC;YACD,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAED,IAAI,KAAK,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC1B,OAAO,OAAO,GAAG,KAAK,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAA2B;IAC1D,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC;SAC5F,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentAction } from '../parser/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Compute a SHA-256 fingerprint of an agent session's behavioral pattern.
|
|
4
|
+
* Used for drift detection — comparing behavioral patterns over time.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sessionFingerprint(actions: AgentAction[]): string;
|
|
7
|
+
/**
|
|
8
|
+
* Compute a SHA-256 hash of a string (e.g., prompt text).
|
|
9
|
+
*/
|
|
10
|
+
export declare function hashString(input: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Compute a behavioral pattern hash that captures tool usage frequencies
|
|
13
|
+
* and common sequences (more resilient to minor reorderings).
|
|
14
|
+
*/
|
|
15
|
+
export declare function behaviorHash(actions: AgentAction[]): string;
|
|
16
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/utils/hash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAQjE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CA2B3D"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Compute a SHA-256 fingerprint of an agent session's behavioral pattern.
|
|
4
|
+
* Used for drift detection — comparing behavioral patterns over time.
|
|
5
|
+
*/
|
|
6
|
+
export function sessionFingerprint(actions) {
|
|
7
|
+
// Create a normalized representation of the behavioral pattern
|
|
8
|
+
// We use tool names and their order, ignoring specific params/timestamps
|
|
9
|
+
const pattern = actions
|
|
10
|
+
.map((a) => a.tool)
|
|
11
|
+
.join('|');
|
|
12
|
+
return createHash('sha256').update(pattern).digest('hex');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Compute a SHA-256 hash of a string (e.g., prompt text).
|
|
16
|
+
*/
|
|
17
|
+
export function hashString(input) {
|
|
18
|
+
return createHash('sha256').update(input).digest('hex');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Compute a behavioral pattern hash that captures tool usage frequencies
|
|
22
|
+
* and common sequences (more resilient to minor reorderings).
|
|
23
|
+
*/
|
|
24
|
+
export function behaviorHash(actions) {
|
|
25
|
+
const toolCounts = new Map();
|
|
26
|
+
const toolPairs = new Map();
|
|
27
|
+
for (let i = 0; i < actions.length; i++) {
|
|
28
|
+
const tool = actions[i].tool;
|
|
29
|
+
toolCounts.set(tool, (toolCounts.get(tool) || 0) + 1);
|
|
30
|
+
if (i < actions.length - 1) {
|
|
31
|
+
const pair = `${tool}->${actions[i + 1].tool}`;
|
|
32
|
+
toolPairs.set(pair, (toolPairs.get(pair) || 0) + 1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Sort for deterministic output
|
|
36
|
+
const countsStr = [...toolCounts.entries()]
|
|
37
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
38
|
+
.map(([tool, count]) => `${tool}:${count}`)
|
|
39
|
+
.join(',');
|
|
40
|
+
const pairsStr = [...toolPairs.entries()]
|
|
41
|
+
.sort(([a], [b]) => a.localeCompare(b))
|
|
42
|
+
.map(([pair, count]) => `${pair}:${count}`)
|
|
43
|
+
.join(',');
|
|
44
|
+
const pattern = `${countsStr}||${pairsStr}`;
|
|
45
|
+
return createHash('sha256').update(pattern).digest('hex');
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../src/utils/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAsB;IACvD,+DAA+D;IAC/D,yEAAyE;IACzE,MAAM,OAAO,GAAG,OAAO;SACpB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SAClB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,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Eb,MAAM,QAAQ,GAAG,CAAC,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;SACtC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;SACtC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC;SAC1C,IAAI,CAAC,GAAG,CAAC,CAAC;IAEb,MAAM,OAAO,GAAG,GAAG,SAAS,KAAK,QAAQ,EAAE,CAAC;IAC5C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tokenize text into lowercase words, removing stop words and punctuation.
|
|
3
|
+
*/
|
|
4
|
+
export declare function tokenize(text: string): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Compute term frequency for a list of tokens.
|
|
7
|
+
*/
|
|
8
|
+
export declare function termFrequency(tokens: string[]): Map<string, number>;
|
|
9
|
+
/**
|
|
10
|
+
* Compute inverse document frequency from a collection of documents.
|
|
11
|
+
*/
|
|
12
|
+
export declare function inverseDocFrequency(documents: string[][]): Map<string, number>;
|
|
13
|
+
/**
|
|
14
|
+
* Compute TF-IDF vector for a document given pre-computed IDF values.
|
|
15
|
+
*/
|
|
16
|
+
export declare function tfidfVector(tokens: string[], idf: Map<string, number>): Map<string, number>;
|
|
17
|
+
/**
|
|
18
|
+
* Compute cosine similarity between two TF-IDF vectors.
|
|
19
|
+
*/
|
|
20
|
+
export declare function cosineSimilarity(a: Map<string, number>, b: Map<string, number>): number;
|
|
21
|
+
/**
|
|
22
|
+
* Compute a combined match score between an expected instruction
|
|
23
|
+
* and an actual tool call. Combines tool-verb matching, entity overlap,
|
|
24
|
+
* and TF-IDF cosine similarity.
|
|
25
|
+
*
|
|
26
|
+
* Returns a score between 0 and 1.
|
|
27
|
+
*/
|
|
28
|
+
export declare function matchScore(expectedText: string, toolName: string, toolParams: Record<string, unknown>): number;
|
|
29
|
+
//# sourceMappingURL=semantic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic.d.ts","sourceRoot":"","sources":["../../src/utils/semantic.ts"],"names":[],"mappings":"AAkBA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAM/C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAUnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB9E;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EAAE,EAChB,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACvB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACtB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACrB,MAAM,CAoBR;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,MAAM,CAwBR"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { toolVerbMatch } from './tool-verbs.js';
|
|
2
|
+
import { extractEntities, entityOverlap } from './entities.js';
|
|
3
|
+
/** Stop words to exclude from TF-IDF computation */
|
|
4
|
+
const STOP_WORDS = new Set([
|
|
5
|
+
'a', 'an', 'the', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
6
|
+
'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would', 'could',
|
|
7
|
+
'should', 'may', 'might', 'must', 'shall', 'can', 'to', 'of', 'in',
|
|
8
|
+
'for', 'on', 'with', 'at', 'by', 'from', 'as', 'into', 'through',
|
|
9
|
+
'during', 'before', 'after', 'above', 'below', 'between', 'and',
|
|
10
|
+
'but', 'or', 'nor', 'not', 'so', 'yet', 'both', 'either', 'neither',
|
|
11
|
+
'each', 'every', 'all', 'any', 'few', 'more', 'most', 'other',
|
|
12
|
+
'some', 'such', 'no', 'only', 'own', 'same', 'than', 'too', 'very',
|
|
13
|
+
'just', 'because', 'if', 'when', 'while', 'where', 'how', 'what',
|
|
14
|
+
'which', 'who', 'whom', 'this', 'that', 'these', 'those', 'it', 'its',
|
|
15
|
+
'my', 'your', 'his', 'her', 'our', 'their', 'me', 'him', 'us', 'them',
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* Tokenize text into lowercase words, removing stop words and punctuation.
|
|
19
|
+
*/
|
|
20
|
+
export function tokenize(text) {
|
|
21
|
+
return text
|
|
22
|
+
.toLowerCase()
|
|
23
|
+
.replace(/[^a-z0-9\s]/g, ' ')
|
|
24
|
+
.split(/\s+/)
|
|
25
|
+
.filter((word) => word.length > 1 && !STOP_WORDS.has(word));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Compute term frequency for a list of tokens.
|
|
29
|
+
*/
|
|
30
|
+
export function termFrequency(tokens) {
|
|
31
|
+
const tf = new Map();
|
|
32
|
+
for (const token of tokens) {
|
|
33
|
+
tf.set(token, (tf.get(token) || 0) + 1);
|
|
34
|
+
}
|
|
35
|
+
// Normalize by document length
|
|
36
|
+
for (const [term, count] of tf) {
|
|
37
|
+
tf.set(term, count / tokens.length);
|
|
38
|
+
}
|
|
39
|
+
return tf;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Compute inverse document frequency from a collection of documents.
|
|
43
|
+
*/
|
|
44
|
+
export function inverseDocFrequency(documents) {
|
|
45
|
+
const idf = new Map();
|
|
46
|
+
const n = documents.length;
|
|
47
|
+
// Count documents containing each term
|
|
48
|
+
const docCount = new Map();
|
|
49
|
+
for (const doc of documents) {
|
|
50
|
+
const unique = new Set(doc);
|
|
51
|
+
for (const term of unique) {
|
|
52
|
+
docCount.set(term, (docCount.get(term) || 0) + 1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const [term, count] of docCount) {
|
|
56
|
+
idf.set(term, Math.log((n + 1) / (count + 1)) + 1);
|
|
57
|
+
}
|
|
58
|
+
return idf;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Compute TF-IDF vector for a document given pre-computed IDF values.
|
|
62
|
+
*/
|
|
63
|
+
export function tfidfVector(tokens, idf) {
|
|
64
|
+
const tf = termFrequency(tokens);
|
|
65
|
+
const vector = new Map();
|
|
66
|
+
for (const [term, tfVal] of tf) {
|
|
67
|
+
const idfVal = idf.get(term) || 1;
|
|
68
|
+
vector.set(term, tfVal * idfVal);
|
|
69
|
+
}
|
|
70
|
+
return vector;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Compute cosine similarity between two TF-IDF vectors.
|
|
74
|
+
*/
|
|
75
|
+
export function cosineSimilarity(a, b) {
|
|
76
|
+
let dotProduct = 0;
|
|
77
|
+
let normA = 0;
|
|
78
|
+
let normB = 0;
|
|
79
|
+
for (const [term, val] of a) {
|
|
80
|
+
normA += val * val;
|
|
81
|
+
const bVal = b.get(term);
|
|
82
|
+
if (bVal !== undefined) {
|
|
83
|
+
dotProduct += val * bVal;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const [, val] of b) {
|
|
87
|
+
normB += val * val;
|
|
88
|
+
}
|
|
89
|
+
const denominator = Math.sqrt(normA) * Math.sqrt(normB);
|
|
90
|
+
if (denominator === 0)
|
|
91
|
+
return 0;
|
|
92
|
+
return dotProduct / denominator;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Compute a combined match score between an expected instruction
|
|
96
|
+
* and an actual tool call. Combines tool-verb matching, entity overlap,
|
|
97
|
+
* and TF-IDF cosine similarity.
|
|
98
|
+
*
|
|
99
|
+
* Returns a score between 0 and 1.
|
|
100
|
+
*/
|
|
101
|
+
export function matchScore(expectedText, toolName, toolParams) {
|
|
102
|
+
// 1. Tool-verb match (weight: 0.4)
|
|
103
|
+
const verbScore = toolVerbMatch(toolName, expectedText);
|
|
104
|
+
// 2. Entity overlap (weight: 0.3)
|
|
105
|
+
const expectedEntities = extractEntities(expectedText);
|
|
106
|
+
const actionText = `${toolName} ${JSON.stringify(toolParams)}`;
|
|
107
|
+
const actionEntities = extractEntities(actionText);
|
|
108
|
+
const entOverlap = entityOverlap(expectedEntities, actionEntities);
|
|
109
|
+
// 3. TF-IDF cosine similarity (weight: 0.3)
|
|
110
|
+
const expectedTokens = tokenize(expectedText);
|
|
111
|
+
const actionTokens = tokenize(actionText);
|
|
112
|
+
const docs = [expectedTokens, actionTokens];
|
|
113
|
+
const idf = inverseDocFrequency(docs);
|
|
114
|
+
const vecA = tfidfVector(expectedTokens, idf);
|
|
115
|
+
const vecB = tfidfVector(actionTokens, idf);
|
|
116
|
+
const cosine = cosineSimilarity(vecA, vecB);
|
|
117
|
+
// Weighted combination
|
|
118
|
+
const combined = verbScore * 0.4 + entOverlap * 0.3 + cosine * 0.3;
|
|
119
|
+
return Math.min(combined, 1);
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=semantic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic.js","sourceRoot":"","sources":["../../src/utils/semantic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,aAAa,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EAAE,GAAG,CAAC,CAAC;IAC5C,MAAM,MAAM,GAAG,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE5C,uBAAuB;IACvB,MAAM,QAAQ,GAAG,SAAS,GAAG,GAAG,GAAG,UAAU,GAAG,GAAG,GAAG,MAAM,GAAG,GAAG,CAAC;IAEnE,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps common tool names to natural language action verbs.
|
|
3
|
+
* Used for matching prompt instructions to actual tool calls.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TOOL_VERB_MAP: Record<string, string[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Look up natural language verbs for a given tool name.
|
|
8
|
+
* Falls back to splitting the tool name on underscores/camelCase.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getToolVerbs(toolName: string): string[];
|
|
11
|
+
/**
|
|
12
|
+
* Check if a tool name matches a natural language description.
|
|
13
|
+
* Returns a confidence score (0-1).
|
|
14
|
+
*/
|
|
15
|
+
export declare function toolVerbMatch(toolName: string, description: string): number;
|
|
16
|
+
//# sourceMappingURL=tool-verbs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-verbs.d.ts","sourceRoot":"","sources":["../../src/utils/tool-verbs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAqDlD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAWvD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAmB3E"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps common tool names to natural language action verbs.
|
|
3
|
+
* Used for matching prompt instructions to actual tool calls.
|
|
4
|
+
*/
|
|
5
|
+
export const TOOL_VERB_MAP = {
|
|
6
|
+
// Email
|
|
7
|
+
'gmail_send': ['send email', 'email', 'mail', 'send message'],
|
|
8
|
+
'gmail_read': ['read email', 'check email', 'check inbox'],
|
|
9
|
+
'email_send': ['send email', 'email', 'mail'],
|
|
10
|
+
'send_email': ['send email', 'email', 'mail'],
|
|
11
|
+
// Search
|
|
12
|
+
'web_search': ['search', 'look up', 'find', 'research', 'google'],
|
|
13
|
+
'tavily_search': ['search', 'look up', 'find', 'research'],
|
|
14
|
+
'google_search': ['search', 'look up', 'find', 'google'],
|
|
15
|
+
'bing_search': ['search', 'look up', 'find'],
|
|
16
|
+
// Files
|
|
17
|
+
'file_write': ['write file', 'create file', 'save', 'generate document', 'write'],
|
|
18
|
+
'file_read': ['read file', 'open file', 'check file', 'review'],
|
|
19
|
+
'file_delete': ['delete file', 'remove file', 'delete'],
|
|
20
|
+
'create_file': ['create file', 'write file', 'save'],
|
|
21
|
+
'read_file': ['read file', 'open file', 'check file'],
|
|
22
|
+
// Messaging
|
|
23
|
+
'slack_post': ['post to slack', 'message slack', 'send to channel', 'slack'],
|
|
24
|
+
'slack_send': ['post to slack', 'message slack', 'send to channel', 'slack'],
|
|
25
|
+
'discord_send': ['send discord', 'post discord', 'message discord'],
|
|
26
|
+
// Code
|
|
27
|
+
'shell_exec': ['run command', 'execute', 'run script', 'run'],
|
|
28
|
+
'run_command': ['run command', 'execute', 'run script'],
|
|
29
|
+
'git_commit': ['commit', 'save changes', 'push code'],
|
|
30
|
+
'git_push': ['push', 'push code', 'deploy'],
|
|
31
|
+
// Browser
|
|
32
|
+
'browser_navigate': ['visit', 'go to', 'open page', 'navigate', 'browse'],
|
|
33
|
+
'browser_click': ['click', 'press', 'select'],
|
|
34
|
+
'navigate': ['visit', 'go to', 'open page', 'navigate'],
|
|
35
|
+
// Database
|
|
36
|
+
'db_query': ['query', 'fetch data', 'look up records', 'query database'],
|
|
37
|
+
'db_insert': ['insert', 'add record', 'save to database'],
|
|
38
|
+
'db_update': ['update record', 'modify', 'change', 'update database'],
|
|
39
|
+
'db_delete': ['delete record', 'remove from database'],
|
|
40
|
+
// Spreadsheets
|
|
41
|
+
'sheets_update': ['update spreadsheet', 'edit sheet', 'modify spreadsheet'],
|
|
42
|
+
'sheets_read': ['read spreadsheet', 'get data from sheet'],
|
|
43
|
+
// Calendar
|
|
44
|
+
'calendar_create': ['create event', 'schedule', 'add to calendar'],
|
|
45
|
+
'calendar_read': ['check calendar', 'read calendar', 'get events'],
|
|
46
|
+
// API
|
|
47
|
+
'api_call': ['call api', 'make request', 'fetch'],
|
|
48
|
+
'http_request': ['make request', 'call api', 'fetch', 'http'],
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Look up natural language verbs for a given tool name.
|
|
52
|
+
* Falls back to splitting the tool name on underscores/camelCase.
|
|
53
|
+
*/
|
|
54
|
+
export function getToolVerbs(toolName) {
|
|
55
|
+
const normalized = toolName.toLowerCase().trim();
|
|
56
|
+
if (TOOL_VERB_MAP[normalized]) {
|
|
57
|
+
return TOOL_VERB_MAP[normalized];
|
|
58
|
+
}
|
|
59
|
+
// Fallback: split on underscores and camelCase
|
|
60
|
+
const words = normalized
|
|
61
|
+
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
|
62
|
+
.replace(/_/g, ' ')
|
|
63
|
+
.toLowerCase();
|
|
64
|
+
return [words];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if a tool name matches a natural language description.
|
|
68
|
+
* Returns a confidence score (0-1).
|
|
69
|
+
*/
|
|
70
|
+
export function toolVerbMatch(toolName, description) {
|
|
71
|
+
const verbs = getToolVerbs(toolName);
|
|
72
|
+
const descLower = description.toLowerCase();
|
|
73
|
+
let bestScore = 0;
|
|
74
|
+
for (const verb of verbs) {
|
|
75
|
+
if (descLower.includes(verb)) {
|
|
76
|
+
// Exact phrase match in the description
|
|
77
|
+
bestScore = Math.max(bestScore, 0.9);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Check individual words
|
|
81
|
+
const verbWords = verb.split(' ');
|
|
82
|
+
const matchedWords = verbWords.filter((w) => descLower.includes(w));
|
|
83
|
+
const wordScore = matchedWords.length / verbWords.length;
|
|
84
|
+
bestScore = Math.max(bestScore, wordScore * 0.7);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return bestScore;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=tool-verbs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-verbs.js","sourceRoot":"","sources":["../../src/utils/tool-verbs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAA6B;IACrD,QAAQ;IACR,YAAY,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC;IAC7D,YAAY,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,aAAa,CAAC;IAC1D,YAAY,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;IAC7C,YAAY,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;IAE7C,SAAS;IACT,YAAY,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC;IACjE,eAAe,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC;IAC1D,eAAe,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC;IACxD,aAAa,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC;IAE5C,QAAQ;IACR,YAAY,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,EAAE,OAAO,CAAC;IACjF,WAAW,EAAE,CAAC,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,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,yBAAyB;YACzB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACpE,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;YACzD,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@llmagentscore/core",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Alignment scoring engine for AI agents — deterministic + LLM-as-judge pipeline",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.build.json",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"typecheck": "tsc --noEmit"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"zod": "^3.23.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@anthropic-ai/sdk": ">=0.30.0"
|
|
27
|
+
},
|
|
28
|
+
"peerDependenciesMeta": {
|
|
29
|
+
"@anthropic-ai/sdk": {
|
|
30
|
+
"optional": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^25.5.0",
|
|
35
|
+
"vitest": "^3.0.0"
|
|
36
|
+
},
|
|
37
|
+
"license": "MIT"
|
|
38
|
+
}
|