@evomap/evolver-runtime-adapters 2.0.0-beta.5 → 2.0.0-beta.6
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/evidenceSummary.d.ts +19 -0
- package/dist/evidenceSummary.js +73 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { NormalizedSession } from './types.js';
|
|
2
|
+
export type RuntimeSessionEvidenceCoverage = 'complete' | 'partial' | 'empty';
|
|
3
|
+
export type RuntimeSessionEvidenceGapCode = 'empty_session' | 'missing_tool_result' | 'unmatched_tool_result';
|
|
4
|
+
export interface RuntimeSessionEvidenceCounts {
|
|
5
|
+
nonMetaTurns: number;
|
|
6
|
+
toolCalls: number;
|
|
7
|
+
toolResults: number;
|
|
8
|
+
matchedToolResults: number;
|
|
9
|
+
missingToolResults: number;
|
|
10
|
+
unmatchedToolResults: number;
|
|
11
|
+
failedToolResults: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RuntimeSessionEvidenceSummary {
|
|
14
|
+
coverage: RuntimeSessionEvidenceCoverage;
|
|
15
|
+
counts: RuntimeSessionEvidenceCounts;
|
|
16
|
+
gapCodes: RuntimeSessionEvidenceGapCode[];
|
|
17
|
+
}
|
|
18
|
+
/** Summarizes transcript structure only; complete coverage does not verify the task outcome. */
|
|
19
|
+
export declare function summarizeSessionEvidence(session: Pick<NormalizedSession, 'turns'>): RuntimeSessionEvidenceSummary;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
function toolUseId(turn) {
|
|
2
|
+
const id = turn.toolUseId;
|
|
3
|
+
return id?.trim() ? id : undefined;
|
|
4
|
+
}
|
|
5
|
+
function isToolCall(turn) {
|
|
6
|
+
return turn.role === 'assistant'
|
|
7
|
+
&& turn.toolResult === undefined
|
|
8
|
+
&& (turn.toolUseId !== undefined
|
|
9
|
+
|| turn.toolInput !== undefined
|
|
10
|
+
|| turn.toolName !== undefined);
|
|
11
|
+
}
|
|
12
|
+
function isToolResult(turn) {
|
|
13
|
+
return turn.role === 'tool';
|
|
14
|
+
}
|
|
15
|
+
/** Summarizes transcript structure only; complete coverage does not verify the task outcome. */
|
|
16
|
+
export function summarizeSessionEvidence(session) {
|
|
17
|
+
const turns = session.turns.filter((turn) => turn.isMeta !== true);
|
|
18
|
+
const pendingCallsById = new Map();
|
|
19
|
+
let toolCalls = 0;
|
|
20
|
+
let toolResults = 0;
|
|
21
|
+
let matchedToolResults = 0;
|
|
22
|
+
let unmatchedToolResults = 0;
|
|
23
|
+
let failedToolResults = 0;
|
|
24
|
+
for (const turn of turns) {
|
|
25
|
+
if (isToolCall(turn)) {
|
|
26
|
+
toolCalls += 1;
|
|
27
|
+
const id = toolUseId(turn);
|
|
28
|
+
if (id)
|
|
29
|
+
pendingCallsById.set(id, (pendingCallsById.get(id) ?? 0) + 1);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (isToolResult(turn)) {
|
|
33
|
+
toolResults += 1;
|
|
34
|
+
if (turn.errorMessage !== undefined)
|
|
35
|
+
failedToolResults += 1;
|
|
36
|
+
const id = toolUseId(turn);
|
|
37
|
+
const pending = id ? pendingCallsById.get(id) ?? 0 : 0;
|
|
38
|
+
if (id && pending > 0) {
|
|
39
|
+
matchedToolResults += 1;
|
|
40
|
+
if (pending === 1)
|
|
41
|
+
pendingCallsById.delete(id);
|
|
42
|
+
else
|
|
43
|
+
pendingCallsById.set(id, pending - 1);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
unmatchedToolResults += 1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const missingToolResults = toolCalls - matchedToolResults;
|
|
51
|
+
const counts = {
|
|
52
|
+
nonMetaTurns: turns.length,
|
|
53
|
+
toolCalls,
|
|
54
|
+
toolResults,
|
|
55
|
+
matchedToolResults,
|
|
56
|
+
missingToolResults,
|
|
57
|
+
unmatchedToolResults,
|
|
58
|
+
failedToolResults,
|
|
59
|
+
};
|
|
60
|
+
const gapCodes = [];
|
|
61
|
+
if (turns.length === 0)
|
|
62
|
+
gapCodes.push('empty_session');
|
|
63
|
+
else {
|
|
64
|
+
if (missingToolResults > 0)
|
|
65
|
+
gapCodes.push('missing_tool_result');
|
|
66
|
+
if (unmatchedToolResults > 0)
|
|
67
|
+
gapCodes.push('unmatched_tool_result');
|
|
68
|
+
}
|
|
69
|
+
const coverage = turns.length === 0
|
|
70
|
+
? 'empty'
|
|
71
|
+
: gapCodes.length > 0 ? 'partial' : 'complete';
|
|
72
|
+
return { coverage, counts, gapCodes };
|
|
73
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED