@polpo-ai/core 0.3.0 → 0.3.1
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/assessment-schemas.d.ts +102 -0
- package/dist/assessment-schemas.d.ts.map +1 -0
- package/dist/assessment-schemas.js +112 -0
- package/dist/assessment-schemas.js.map +1 -0
- package/dist/assessment-scoring.d.ts +26 -0
- package/dist/assessment-scoring.d.ts.map +1 -0
- package/dist/assessment-scoring.js +129 -0
- package/dist/assessment-scoring.js.map +1 -0
- package/dist/assessor.d.ts +36 -0
- package/dist/assessor.d.ts.map +1 -0
- package/dist/assessor.js +209 -0
- package/dist/assessor.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/retry.d.ts +22 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +47 -0
- package/dist/retry.js.map +1 -0
- package/package.json +17 -1
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for validating LLM review structured output.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the ReviewPayload shape — used by:
|
|
5
|
+
* - extractSubmitReview (tool call extraction)
|
|
6
|
+
* - tryParseReviewJSON (text-based JSON fallback)
|
|
7
|
+
* - OpenAI response_format json_schema (derived via zodToJsonSchema)
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
export declare const ReviewEvidenceSchema: z.ZodObject<{
|
|
11
|
+
file: z.ZodString;
|
|
12
|
+
line: z.ZodNumber;
|
|
13
|
+
note: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const ReviewScoreSchema: z.ZodObject<{
|
|
16
|
+
dimension: z.ZodString;
|
|
17
|
+
score: z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>;
|
|
18
|
+
reasoning: z.ZodString;
|
|
19
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
20
|
+
file: z.ZodString;
|
|
21
|
+
line: z.ZodNumber;
|
|
22
|
+
note: z.ZodString;
|
|
23
|
+
}, z.core.$strip>>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const ReviewPayloadSchema: z.ZodObject<{
|
|
26
|
+
scores: z.ZodArray<z.ZodObject<{
|
|
27
|
+
dimension: z.ZodString;
|
|
28
|
+
score: z.ZodPipe<z.ZodNumber, z.ZodTransform<number, number>>;
|
|
29
|
+
reasoning: z.ZodString;
|
|
30
|
+
evidence: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
31
|
+
file: z.ZodString;
|
|
32
|
+
line: z.ZodNumber;
|
|
33
|
+
note: z.ZodString;
|
|
34
|
+
}, z.core.$strip>>>;
|
|
35
|
+
}, z.core.$strip>>;
|
|
36
|
+
summary: z.ZodString;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type ValidatedReviewPayload = z.infer<typeof ReviewPayloadSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Validate and normalize a raw object into a ReviewPayload.
|
|
41
|
+
* Returns `{ success: true, data }` or `{ success: false, error }`.
|
|
42
|
+
*
|
|
43
|
+
* This applies:
|
|
44
|
+
* - Type coercion (string scores → numbers)
|
|
45
|
+
* - Clamping (scores rounded to 1-5)
|
|
46
|
+
* - Default reasoning if missing but other fields present
|
|
47
|
+
*/
|
|
48
|
+
export declare function validateReviewPayload(raw: unknown): {
|
|
49
|
+
success: true;
|
|
50
|
+
data: ValidatedReviewPayload;
|
|
51
|
+
} | {
|
|
52
|
+
success: false;
|
|
53
|
+
error: string;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* JSON Schema derived from ReviewPayloadSchema, for use with OpenAI's
|
|
57
|
+
* response_format: { type: "json_schema", json_schema: { ... } }.
|
|
58
|
+
*
|
|
59
|
+
* We maintain this manually to ensure `strict: true` and `additionalProperties: false`
|
|
60
|
+
* which OpenAI requires.
|
|
61
|
+
*/
|
|
62
|
+
export declare const REVIEW_JSON_SCHEMA: {
|
|
63
|
+
type: "json_schema";
|
|
64
|
+
json_schema: {
|
|
65
|
+
name: string;
|
|
66
|
+
strict: boolean;
|
|
67
|
+
schema: {
|
|
68
|
+
type: string;
|
|
69
|
+
properties: {
|
|
70
|
+
scores: {
|
|
71
|
+
type: string;
|
|
72
|
+
items: {
|
|
73
|
+
type: string;
|
|
74
|
+
properties: {
|
|
75
|
+
dimension: {
|
|
76
|
+
type: string;
|
|
77
|
+
description: string;
|
|
78
|
+
};
|
|
79
|
+
score: {
|
|
80
|
+
type: string;
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
reasoning: {
|
|
84
|
+
type: string;
|
|
85
|
+
description: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
required: string[];
|
|
89
|
+
additionalProperties: boolean;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
summary: {
|
|
93
|
+
type: string;
|
|
94
|
+
description: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
required: string[];
|
|
98
|
+
additionalProperties: boolean;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=assessment-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessment-schemas.d.ts","sourceRoot":"","sources":["../src/assessment-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,oBAAoB;;;;iBAI/B,CAAC;AAIH,eAAO,MAAM,iBAAiB;;;;;;;;;iBAK5B,CAAC;AAIH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;iBAG9B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAIzE;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAyCvI;AAID;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2B9B,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for validating LLM review structured output.
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for the ReviewPayload shape — used by:
|
|
5
|
+
* - extractSubmitReview (tool call extraction)
|
|
6
|
+
* - tryParseReviewJSON (text-based JSON fallback)
|
|
7
|
+
* - OpenAI response_format json_schema (derived via zodToJsonSchema)
|
|
8
|
+
*/
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
// ── Score Evidence (optional file:line references) ─────────────────────
|
|
11
|
+
export const ReviewEvidenceSchema = z.object({
|
|
12
|
+
file: z.string(),
|
|
13
|
+
line: z.number(),
|
|
14
|
+
note: z.string(),
|
|
15
|
+
});
|
|
16
|
+
// ── Individual Dimension Score ─────────────────────────────────────────
|
|
17
|
+
export const ReviewScoreSchema = z.object({
|
|
18
|
+
dimension: z.string().min(1),
|
|
19
|
+
score: z.number().min(1).max(5).transform(v => Math.round(v)),
|
|
20
|
+
reasoning: z.string().min(1),
|
|
21
|
+
evidence: z.array(ReviewEvidenceSchema).optional(),
|
|
22
|
+
});
|
|
23
|
+
// ── Full Review Payload ────────────────────────────────────────────────
|
|
24
|
+
export const ReviewPayloadSchema = z.object({
|
|
25
|
+
scores: z.array(ReviewScoreSchema).min(1),
|
|
26
|
+
summary: z.string().min(1),
|
|
27
|
+
});
|
|
28
|
+
// ── Validation Helper ──────────────────────────────────────────────────
|
|
29
|
+
/**
|
|
30
|
+
* Validate and normalize a raw object into a ReviewPayload.
|
|
31
|
+
* Returns `{ success: true, data }` or `{ success: false, error }`.
|
|
32
|
+
*
|
|
33
|
+
* This applies:
|
|
34
|
+
* - Type coercion (string scores → numbers)
|
|
35
|
+
* - Clamping (scores rounded to 1-5)
|
|
36
|
+
* - Default reasoning if missing but other fields present
|
|
37
|
+
*/
|
|
38
|
+
export function validateReviewPayload(raw) {
|
|
39
|
+
if (!raw || typeof raw !== "object") {
|
|
40
|
+
return { success: false, error: "Input is not an object" };
|
|
41
|
+
}
|
|
42
|
+
const obj = raw;
|
|
43
|
+
// Pre-process: coerce common LLM output quirks before Zod validation
|
|
44
|
+
if (obj.scores && Array.isArray(obj.scores)) {
|
|
45
|
+
for (const score of obj.scores) {
|
|
46
|
+
if (score && typeof score === "object") {
|
|
47
|
+
const s = score;
|
|
48
|
+
// Coerce string scores to numbers
|
|
49
|
+
if (typeof s.score === "string") {
|
|
50
|
+
s.score = parseFloat(s.score);
|
|
51
|
+
}
|
|
52
|
+
// Accept alternative reasoning field names
|
|
53
|
+
if (!s.reasoning && s.reason) {
|
|
54
|
+
s.reasoning = s.reason;
|
|
55
|
+
}
|
|
56
|
+
if (!s.reasoning && s.explanation) {
|
|
57
|
+
s.reasoning = s.explanation;
|
|
58
|
+
}
|
|
59
|
+
// Ensure reasoning exists
|
|
60
|
+
if (!s.reasoning || (typeof s.reasoning === "string" && s.reasoning.trim() === "")) {
|
|
61
|
+
s.reasoning = "(no reasoning provided)";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Ensure summary exists
|
|
67
|
+
if (!obj.summary || (typeof obj.summary === "string" && obj.summary.trim() === "")) {
|
|
68
|
+
obj.summary = "(no summary)";
|
|
69
|
+
}
|
|
70
|
+
const result = ReviewPayloadSchema.safeParse(obj);
|
|
71
|
+
if (result.success) {
|
|
72
|
+
return { success: true, data: result.data };
|
|
73
|
+
}
|
|
74
|
+
return { success: false, error: result.error.issues.map(i => `${i.path.join(".")}: ${i.message}`).join("; ") };
|
|
75
|
+
}
|
|
76
|
+
// ── JSON Schema for OpenAI response_format ─────────────────────────────
|
|
77
|
+
/**
|
|
78
|
+
* JSON Schema derived from ReviewPayloadSchema, for use with OpenAI's
|
|
79
|
+
* response_format: { type: "json_schema", json_schema: { ... } }.
|
|
80
|
+
*
|
|
81
|
+
* We maintain this manually to ensure `strict: true` and `additionalProperties: false`
|
|
82
|
+
* which OpenAI requires.
|
|
83
|
+
*/
|
|
84
|
+
export const REVIEW_JSON_SCHEMA = {
|
|
85
|
+
type: "json_schema",
|
|
86
|
+
json_schema: {
|
|
87
|
+
name: "review_scores",
|
|
88
|
+
strict: true,
|
|
89
|
+
schema: {
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
scores: {
|
|
93
|
+
type: "array",
|
|
94
|
+
items: {
|
|
95
|
+
type: "object",
|
|
96
|
+
properties: {
|
|
97
|
+
dimension: { type: "string", description: "Dimension name from the rubric" },
|
|
98
|
+
score: { type: "number", description: "Score 1-5" },
|
|
99
|
+
reasoning: { type: "string", description: "Brief reasoning with file:line evidence" },
|
|
100
|
+
},
|
|
101
|
+
required: ["dimension", "score", "reasoning"],
|
|
102
|
+
additionalProperties: false,
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
summary: { type: "string", description: "Overall review summary" },
|
|
106
|
+
},
|
|
107
|
+
required: ["scores", "summary"],
|
|
108
|
+
additionalProperties: false,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=assessment-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessment-schemas.js","sourceRoot":"","sources":["../src/assessment-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0EAA0E;AAE1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,C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AAoB,EAAE,KAAK;SAC5B;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EvalDimension, DimensionScore } from "./types.js";
|
|
2
|
+
interface ReviewPayload {
|
|
3
|
+
scores: {
|
|
4
|
+
dimension: string;
|
|
5
|
+
score: number;
|
|
6
|
+
reasoning: string;
|
|
7
|
+
evidence?: {
|
|
8
|
+
file: string;
|
|
9
|
+
line: number;
|
|
10
|
+
note: string;
|
|
11
|
+
}[];
|
|
12
|
+
}[];
|
|
13
|
+
summary: string;
|
|
14
|
+
}
|
|
15
|
+
/** Default evaluation dimensions for G-Eval LLM-as-Judge. */
|
|
16
|
+
export declare const DEFAULT_DIMENSIONS: EvalDimension[];
|
|
17
|
+
/** Build the rubric section string for the LLM review prompt. */
|
|
18
|
+
export declare function buildRubricSection(dimensions: EvalDimension[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* Compute the weighted global score from an array of dimension scores.
|
|
21
|
+
* Scores are clamped to 1-5. Returns 0 if total weight is 0.
|
|
22
|
+
*/
|
|
23
|
+
export declare function computeWeightedScore(scores: DimensionScore[]): number;
|
|
24
|
+
export declare function computeMedianScores(reviews: ReviewPayload[], dimensions: EvalDimension[]): ReviewPayload;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=assessment-scoring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessment-scoring.d.ts","sourceRoot":"","sources":["../src/assessment-scoring.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhE,UAAU,aAAa;IACrB,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;KAAE,EAAE,CAAC;IAC7H,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6DAA6D;AAC7D,eAAO,MAAM,kBAAkB,EAAE,aAAa,EAiD7C,CAAC;AAEF,iEAAiE;AACjE,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,aAAa,EAAE,GAAG,MAAM,CActE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAIrE;AAQD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,aAAa,CAmDxG"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/** Default evaluation dimensions for G-Eval LLM-as-Judge. */
|
|
2
|
+
export const DEFAULT_DIMENSIONS = [
|
|
3
|
+
{
|
|
4
|
+
name: "correctness",
|
|
5
|
+
description: "Does the code work correctly? Are there logic errors, runtime exceptions, or incorrect outputs?",
|
|
6
|
+
weight: 0.35,
|
|
7
|
+
rubric: {
|
|
8
|
+
1: "Fundamentally broken — does not run or produces entirely wrong results",
|
|
9
|
+
2: "Major bugs — runs but has significant logic errors affecting core functionality",
|
|
10
|
+
3: "Mostly correct — works for common cases but has edge-case bugs",
|
|
11
|
+
4: "Correct — handles all specified cases properly with minor issues only",
|
|
12
|
+
5: "Flawless — correct in all cases, handles edge cases and boundary conditions perfectly",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "completeness",
|
|
17
|
+
description: "Are all requirements and acceptance criteria fully addressed? Nothing missing?",
|
|
18
|
+
weight: 0.30,
|
|
19
|
+
rubric: {
|
|
20
|
+
1: "Most requirements unmet — major deliverables missing",
|
|
21
|
+
2: "Partially complete — some requirements met but significant gaps remain",
|
|
22
|
+
3: "Core requirements met — main functionality present but extras missing",
|
|
23
|
+
4: "Nearly complete — all requirements met with minor omissions",
|
|
24
|
+
5: "Fully complete — every requirement and criterion addressed comprehensively",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "code_quality",
|
|
29
|
+
description: "Is the code well-structured, readable, and maintainable? Proper naming, organization, and patterns?",
|
|
30
|
+
weight: 0.20,
|
|
31
|
+
rubric: {
|
|
32
|
+
1: "Unreadable — no structure, inconsistent style, impossible to maintain",
|
|
33
|
+
2: "Poor quality — hard to follow, unclear naming, minimal organization",
|
|
34
|
+
3: "Acceptable — readable but could be better structured or more idiomatic",
|
|
35
|
+
4: "Good quality — clean code, clear naming, well-organized",
|
|
36
|
+
5: "Excellent — exemplary structure, idiomatic patterns, easy to extend",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "edge_cases",
|
|
41
|
+
description: "Are edge cases, error conditions, and boundary values handled gracefully?",
|
|
42
|
+
weight: 0.15,
|
|
43
|
+
rubric: {
|
|
44
|
+
1: "No error handling — crashes on any unexpected input",
|
|
45
|
+
2: "Minimal handling — only handles the happy path",
|
|
46
|
+
3: "Some handling — common edge cases covered but gaps exist",
|
|
47
|
+
4: "Good handling — most edge cases and errors handled properly",
|
|
48
|
+
5: "Comprehensive — all edge cases, nulls, empty inputs, and errors handled gracefully",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
/** Build the rubric section string for the LLM review prompt. */
|
|
53
|
+
export function buildRubricSection(dimensions) {
|
|
54
|
+
return dimensions.map(dim => {
|
|
55
|
+
const rubricLines = dim.rubric
|
|
56
|
+
? Object.entries(dim.rubric)
|
|
57
|
+
.sort(([a], [b]) => Number(a) - Number(b))
|
|
58
|
+
.map(([score, desc]) => ` ${score}: ${desc}`)
|
|
59
|
+
.join("\n")
|
|
60
|
+
: " 1: Very poor\n 2: Below average\n 3: Average\n 4: Good\n 5: Excellent";
|
|
61
|
+
return ` ${dim.name} (weight: ${dim.weight}):
|
|
62
|
+
Description: ${dim.description}
|
|
63
|
+
Scoring rubric:
|
|
64
|
+
${rubricLines}`;
|
|
65
|
+
}).join("\n\n");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Compute the weighted global score from an array of dimension scores.
|
|
69
|
+
* Scores are clamped to 1-5. Returns 0 if total weight is 0.
|
|
70
|
+
*/
|
|
71
|
+
export function computeWeightedScore(scores) {
|
|
72
|
+
const totalWeight = scores.reduce((sum, s) => sum + s.weight, 0);
|
|
73
|
+
if (totalWeight === 0)
|
|
74
|
+
return 0;
|
|
75
|
+
return scores.reduce((sum, s) => sum + Math.max(1, Math.min(5, s.score)) * s.weight, 0) / totalWeight;
|
|
76
|
+
}
|
|
77
|
+
function median(values) {
|
|
78
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
79
|
+
const mid = Math.floor(sorted.length / 2);
|
|
80
|
+
return sorted.length % 2 !== 0 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
81
|
+
}
|
|
82
|
+
export function computeMedianScores(reviews, dimensions) {
|
|
83
|
+
const dimMap = new Map();
|
|
84
|
+
for (const dim of dimensions) {
|
|
85
|
+
dimMap.set(dim.name, { scores: [], entries: [] });
|
|
86
|
+
}
|
|
87
|
+
for (const review of reviews) {
|
|
88
|
+
for (const s of review.scores) {
|
|
89
|
+
const bucket = dimMap.get(s.dimension);
|
|
90
|
+
if (bucket) {
|
|
91
|
+
bucket.scores.push(s.score);
|
|
92
|
+
bucket.entries.push(s);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const combinedScores = [];
|
|
97
|
+
for (const dim of dimensions) {
|
|
98
|
+
const bucket = dimMap.get(dim.name);
|
|
99
|
+
if (!bucket || bucket.scores.length === 0)
|
|
100
|
+
continue;
|
|
101
|
+
const med = median(bucket.scores);
|
|
102
|
+
// Exclude outliers deviating >1.5 from median
|
|
103
|
+
const filtered = bucket.entries.filter(e => Math.abs(e.score - med) <= 1.5);
|
|
104
|
+
const pool = filtered.length > 0 ? filtered : bucket.entries;
|
|
105
|
+
const finalMed = median(pool.map(e => e.score));
|
|
106
|
+
// Pick reasoning from entry closest to median
|
|
107
|
+
let best = pool[0];
|
|
108
|
+
let bestDist = Math.abs(best.score - finalMed);
|
|
109
|
+
for (const e of pool) {
|
|
110
|
+
const dist = Math.abs(e.score - finalMed);
|
|
111
|
+
if (dist < bestDist) {
|
|
112
|
+
best = e;
|
|
113
|
+
bestDist = dist;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
combinedScores.push({
|
|
117
|
+
dimension: dim.name,
|
|
118
|
+
score: Math.round(finalMed),
|
|
119
|
+
reasoning: best.reasoning,
|
|
120
|
+
evidence: best.evidence,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const summaries = reviews.map(r => r.summary).filter(Boolean);
|
|
124
|
+
const summary = summaries.length > 0
|
|
125
|
+
? `Consensus from ${reviews.length} reviewers: ${summaries[0]}`
|
|
126
|
+
: `Consensus from ${reviews.length} reviewers`;
|
|
127
|
+
return { scores: combinedScores, summary };
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=assessment-scoring.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessment-scoring.js","sourceRoot":"","sources":["../src/assessment-scoring.ts"],"names":[],"mappings":"AAOA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,kBAAkB,GAAoB;IACjD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,iGAAiG;QAC9G,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE;YACN,CAAC,EAAE,wEAAwE;YAC3E,CAAC,EAAE,iFAAiF;YACpF,CAAC,EAAE,gEAAgE;YACnE,CAAC,EAAE,uEAAuE;YAC1E,CAAC,EAAE,uFAAuF;SAC3F;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,gFAAgF;QAC7F,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE;YACN,CAAC,EAAE,sDAAsD;YACzD,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askMetric, AssessmentResult, CheckResult, MetricResult, ReviewContext, ReasoningLevel } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Runtime dependencies for the assessment pipeline.
|
|
6
|
+
*
|
|
7
|
+
* The shell layer (Node.js) provides NodeFileSystem + NodeShell.
|
|
8
|
+
* The cloud layer provides SandboxProxyFS + SandboxProxyShell.
|
|
9
|
+
* Tests can provide mocks/stubs.
|
|
10
|
+
*/
|
|
11
|
+
export interface AssessmentDeps {
|
|
12
|
+
/** File system abstraction. */
|
|
13
|
+
fs: FileSystem;
|
|
14
|
+
/** Shell command execution abstraction. */
|
|
15
|
+
shell: Shell;
|
|
16
|
+
/** Path to the per-project .polpo directory. */
|
|
17
|
+
polpoDir: string;
|
|
18
|
+
/**
|
|
19
|
+
* LLM review function — injected by the shell layer.
|
|
20
|
+
* When not provided, llm_review expectations will fail with an error message.
|
|
21
|
+
*/
|
|
22
|
+
runLLMReview?: (expectation: TaskExpectation, cwd: string, onProgress?: (msg: string) => void, context?: ReviewContext, reasoning?: ReasoningLevel) => Promise<CheckResult>;
|
|
23
|
+
}
|
|
24
|
+
export declare function runCheck(deps: AssessmentDeps, expectation: TaskExpectation, cwd: string, onProgress?: (msg: string) => void, context?: ReviewContext, reasoning?: ReasoningLevel): Promise<CheckResult>;
|
|
25
|
+
export declare function runMetric(deps: AssessmentDeps, metric: TaskMetric, cwd: string): Promise<MetricResult>;
|
|
26
|
+
export interface CheckProgressEvent {
|
|
27
|
+
index: number;
|
|
28
|
+
total: number;
|
|
29
|
+
type: string;
|
|
30
|
+
label: string;
|
|
31
|
+
phase: "started" | "complete";
|
|
32
|
+
passed?: boolean;
|
|
33
|
+
message?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function assessTask(deps: AssessmentDeps, task: Task, cwd: string, onProgress?: (msg: string) => void, context?: ReviewContext, reasoning?: ReasoningLevel, onCheckProgress?: (event: CheckProgressEvent) => void): Promise<AssessmentResult>;
|
|
36
|
+
//# sourceMappingURL=assessor.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AE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,EAClC,OAAO,CAAC,EAAE,aAAa,EACvB,SAAS,CAAC,EAAE,cAAc,EAC1B,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,GACpD,OAAO,CAAC,gBAAgB,CAAC,CAiC3B"}
|
package/dist/assessor.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { nanoid } from "nanoid";
|
|
2
|
+
// ── Pure path helpers (no node:path dependency) ─────────────────────────
|
|
3
|
+
/** Join path segments with '/'. */
|
|
4
|
+
function pathJoin(...parts) {
|
|
5
|
+
return parts
|
|
6
|
+
.map((p, i) => (i === 0 ? p.replace(/\/+$/, "") : p.replace(/^\/+|\/+$/g, "")))
|
|
7
|
+
.filter(Boolean)
|
|
8
|
+
.join("/");
|
|
9
|
+
}
|
|
10
|
+
/** Resolve a possibly-relative path against a base directory. */
|
|
11
|
+
function pathResolve(base, relative) {
|
|
12
|
+
if (relative.startsWith("/"))
|
|
13
|
+
return relative;
|
|
14
|
+
return pathJoin(base, relative);
|
|
15
|
+
}
|
|
16
|
+
const SCRIPT_MAX_BUFFER = 5 * 1024 * 1024; // 5 MB
|
|
17
|
+
export async function runCheck(deps, expectation, cwd, onProgress, context, reasoning) {
|
|
18
|
+
switch (expectation.type) {
|
|
19
|
+
case "test": {
|
|
20
|
+
const cmd = expectation.command ?? "npm test";
|
|
21
|
+
try {
|
|
22
|
+
await deps.shell.execute(cmd, { cwd });
|
|
23
|
+
return { type: "test", passed: true, message: `Test passed: ${cmd}` };
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
27
|
+
return {
|
|
28
|
+
type: "test",
|
|
29
|
+
passed: false,
|
|
30
|
+
message: `Test failed: ${cmd}`,
|
|
31
|
+
details: msg,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
case "file_exists": {
|
|
36
|
+
const paths = expectation.paths ?? [];
|
|
37
|
+
if (paths.length === 0) {
|
|
38
|
+
return { type: "file_exists", passed: false, message: "No paths specified" };
|
|
39
|
+
}
|
|
40
|
+
const missing = [];
|
|
41
|
+
for (const p of paths) {
|
|
42
|
+
const resolvedPath = pathResolve(cwd, p);
|
|
43
|
+
const exists = await deps.fs.exists(resolvedPath);
|
|
44
|
+
if (!exists) {
|
|
45
|
+
missing.push(p);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (missing.length === 0) {
|
|
49
|
+
return {
|
|
50
|
+
type: "file_exists",
|
|
51
|
+
passed: true,
|
|
52
|
+
message: `All ${paths.length} file(s) exist`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
type: "file_exists",
|
|
57
|
+
passed: false,
|
|
58
|
+
message: `Missing ${missing.length}/${paths.length} file(s)`,
|
|
59
|
+
details: missing.join(", "),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
case "script": {
|
|
63
|
+
const cmd = expectation.command;
|
|
64
|
+
if (!cmd) {
|
|
65
|
+
return {
|
|
66
|
+
type: "script",
|
|
67
|
+
passed: false,
|
|
68
|
+
message: "No script command provided",
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const isMultiLine = cmd.includes("\n");
|
|
72
|
+
const label = isMultiLine
|
|
73
|
+
? `script (${cmd.split("\n").length} lines)`
|
|
74
|
+
: cmd;
|
|
75
|
+
if (!isMultiLine) {
|
|
76
|
+
// Single-line: execute directly
|
|
77
|
+
try {
|
|
78
|
+
const result = await deps.shell.execute(cmd, { cwd });
|
|
79
|
+
if (result.exitCode !== 0) {
|
|
80
|
+
return { type: "script", passed: false, message: `Script failed: ${label}`, details: result.stderr || result.stdout };
|
|
81
|
+
}
|
|
82
|
+
return { type: "script", passed: true, message: `Script passed: ${label}` };
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
86
|
+
return { type: "script", passed: false, message: `Script failed: ${label}`, details: msg };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Multi-line: write to temp file, execute with bash, cleanup
|
|
90
|
+
const tmpDir = pathJoin(deps.polpoDir, "tmp");
|
|
91
|
+
const scriptFile = pathJoin(tmpDir, `check-${nanoid(8)}.sh`);
|
|
92
|
+
try {
|
|
93
|
+
await deps.fs.mkdir(tmpDir);
|
|
94
|
+
// set -euo pipefail: fail on first error, like CI/CD
|
|
95
|
+
const scriptContent = `#!/usr/bin/env bash\nset -euo pipefail\n\n${cmd}\n`;
|
|
96
|
+
await deps.fs.writeFile(scriptFile, scriptContent);
|
|
97
|
+
const result = await deps.shell.execute(`bash "${scriptFile}"`, { cwd });
|
|
98
|
+
if (result.exitCode !== 0) {
|
|
99
|
+
return {
|
|
100
|
+
type: "script",
|
|
101
|
+
passed: false,
|
|
102
|
+
message: `Script failed: ${label}`,
|
|
103
|
+
details: result.stderr || result.stdout,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
type: "script",
|
|
108
|
+
passed: true,
|
|
109
|
+
message: `Script passed: ${label}`,
|
|
110
|
+
details: result.stdout || result.stderr || undefined,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
115
|
+
return {
|
|
116
|
+
type: "script",
|
|
117
|
+
passed: false,
|
|
118
|
+
message: `Script failed: ${label}`,
|
|
119
|
+
details: msg,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
try {
|
|
124
|
+
await deps.fs.remove(scriptFile);
|
|
125
|
+
}
|
|
126
|
+
catch { /* file already removed */ }
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
case "llm_review": {
|
|
130
|
+
if (!deps.runLLMReview) {
|
|
131
|
+
return {
|
|
132
|
+
type: "llm_review",
|
|
133
|
+
passed: false,
|
|
134
|
+
message: "LLM review not available — no runLLMReview port provided",
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return await deps.runLLMReview(expectation, cwd, onProgress, context, reasoning);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export async function runMetric(deps, metric, cwd) {
|
|
142
|
+
try {
|
|
143
|
+
const result = await deps.shell.execute(metric.command, { cwd });
|
|
144
|
+
const value = parseFloat(result.stdout.trim());
|
|
145
|
+
if (isNaN(value)) {
|
|
146
|
+
return {
|
|
147
|
+
name: metric.name,
|
|
148
|
+
value: 0,
|
|
149
|
+
threshold: metric.threshold,
|
|
150
|
+
passed: false,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
name: metric.name,
|
|
155
|
+
value,
|
|
156
|
+
threshold: metric.threshold,
|
|
157
|
+
passed: value >= metric.threshold,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
catch { /* metric command failed */
|
|
161
|
+
return {
|
|
162
|
+
name: metric.name,
|
|
163
|
+
value: 0,
|
|
164
|
+
threshold: metric.threshold,
|
|
165
|
+
passed: false,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/** Label for an expectation — used in progress events. */
|
|
170
|
+
function expectationLabel(exp) {
|
|
171
|
+
if (exp.type === "test")
|
|
172
|
+
return exp.command ?? "npm test";
|
|
173
|
+
if (exp.type === "file_exists")
|
|
174
|
+
return (exp.paths ?? []).join(", ") || "file_exists";
|
|
175
|
+
if (exp.type === "script") {
|
|
176
|
+
const cmd = exp.command ?? "";
|
|
177
|
+
return cmd.includes("\n") ? `script (${cmd.split("\n").length} lines)` : cmd;
|
|
178
|
+
}
|
|
179
|
+
if (exp.type === "llm_review")
|
|
180
|
+
return exp.criteria ? exp.criteria.slice(0, 60) : "LLM review";
|
|
181
|
+
return exp.type;
|
|
182
|
+
}
|
|
183
|
+
export async function assessTask(deps, task, cwd, onProgress, context, reasoning, onCheckProgress) {
|
|
184
|
+
const total = task.expectations.length;
|
|
185
|
+
const checks = await Promise.all(task.expectations.map(async (exp, i) => {
|
|
186
|
+
const label = expectationLabel(exp);
|
|
187
|
+
onCheckProgress?.({ index: i, total, type: exp.type, label, phase: "started" });
|
|
188
|
+
const result = await runCheck(deps, exp, cwd, onProgress, context, reasoning);
|
|
189
|
+
onCheckProgress?.({ index: i, total, type: exp.type, label, phase: "complete", passed: result.passed, message: result.message });
|
|
190
|
+
return result;
|
|
191
|
+
}));
|
|
192
|
+
const metrics = await Promise.all(task.metrics.map((m) => runMetric(deps, m, cwd)));
|
|
193
|
+
const passed = checks.every((c) => c.passed) && metrics.every((m) => m.passed);
|
|
194
|
+
// Extract LLM review details and scores
|
|
195
|
+
const llmCheck = checks.find(c => c.type === "llm_review");
|
|
196
|
+
const llmReview = llmCheck?.details;
|
|
197
|
+
const scores = llmCheck?.scores;
|
|
198
|
+
const globalScore = llmCheck?.globalScore;
|
|
199
|
+
return {
|
|
200
|
+
passed,
|
|
201
|
+
checks,
|
|
202
|
+
metrics,
|
|
203
|
+
llmReview,
|
|
204
|
+
scores,
|
|
205
|
+
globalScore,
|
|
206
|
+
timestamp: new Date().toISOString(),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=assessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assessor.js","sourceRoot":"","sources":["../src/assessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,M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,CAAC,CAAC;IAElE,wCAAwC;IACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAG,QAAQ,EAAE,OAAO,CAAC;IACpC,MAAM,MAAM,GAAG,QAAQ,EAAE,MAAM,CAAC;IAChC,MAAM,WAAW,GAAG,QAAQ,EAAE,WAAW,CAAC;IAE1C,OAAO;QACL,MAAM;QACN,MAAM;QACN,OAAO;QACP,SAAS;QACT,MAAM;QACN,WAAW;QACX,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACpC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -43,4 +43,8 @@ export { AssessmentOrchestrator, type AssessmentPorts } from "./assessment-orche
|
|
|
43
43
|
export { buildFixPrompt, buildRetryPrompt, buildSideEffectFixPrompt, buildSideEffectRetryPrompt, buildJudgePrompt, sleep, type JudgeCorrectionFix, type JudgeCorrection, type JudgeVerdict } from "./assessment-prompts.js";
|
|
44
44
|
export { looksLikeQuestion, classifyAsQuestion } from "./question-detector.js";
|
|
45
45
|
export type { AgentHandle, SpawnContext } from "./adapter.js";
|
|
46
|
+
export { assessTask, runCheck, runMetric, type AssessmentDeps, type CheckProgressEvent as AssessorCheckProgressEvent } from "./assessor.js";
|
|
47
|
+
export { DEFAULT_DIMENSIONS, buildRubricSection, computeWeightedScore, computeMedianScores } from "./assessment-scoring.js";
|
|
48
|
+
export { validateReviewPayload, ReviewPayloadSchema, ReviewScoreSchema, REVIEW_JSON_SCHEMA, type ValidatedReviewPayload } from "./assessment-schemas.js";
|
|
49
|
+
export { withRetry, isTransientError, type RetryOptions } from "./retry.js";
|
|
46
50
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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sB,EAAE,MAAM,yBAAyB,CAAC;AACzJ,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -30,4 +30,9 @@ export { OrchestratorEngine } from "./orchestrator-engine.js";
|
|
|
30
30
|
export { AssessmentOrchestrator } from "./assessment-orchestrator.js";
|
|
31
31
|
export { buildFixPrompt, buildRetryPrompt, buildSideEffectFixPrompt, buildSideEffectRetryPrompt, buildJudgePrompt, sleep } from "./assessment-prompts.js";
|
|
32
32
|
export { looksLikeQuestion, classifyAsQuestion } from "./question-detector.js";
|
|
33
|
+
// ── Assessment (pure — no Node.js deps) ─────────────────────────────────
|
|
34
|
+
export { assessTask, runCheck, runMetric } from "./assessor.js";
|
|
35
|
+
export { DEFAULT_DIMENSIONS, buildRubricSection, computeWeightedScore, computeMedianScores } from "./assessment-scoring.js";
|
|
36
|
+
export { validateReviewPayload, ReviewPayloadSchema, ReviewScoreSchema, REVIEW_JSON_SCHEMA } from "./assessment-schemas.js";
|
|
37
|
+
export { withRetry, isTransientError } from "./retry.js";
|
|
33
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,cAAc,YAAY,CAAC;AAE3B,4EAA4E;AAC5E,cAAc,aAAa,CAAC;AAE5B,4EAA4E;AAC5E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEjG,4EAA4E;AAC5E,cAAc,cAAc,CAAC;AAE7B,4EAA4E;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAgB1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AA6BrD,2EAA2E;AAC3E,OAAO,EAAE,SAAS,EAAE,W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AC5I,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC5H,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAA+B,MAAM,yBAAyB,CAAC;AACzJ,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAqB,MAAM,YAAY,CAAC"}
|
package/dist/retry.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exponential backoff retry utility for LLM/network calls.
|
|
3
|
+
*/
|
|
4
|
+
export interface RetryOptions {
|
|
5
|
+
/** Max number of retry attempts (default: 3) */
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
/** Initial delay in ms (default: 1000) */
|
|
8
|
+
initialDelayMs?: number;
|
|
9
|
+
/** Max delay in ms (default: 30000) */
|
|
10
|
+
maxDelayMs?: number;
|
|
11
|
+
/** Whether to check if errors are transient (default: true) */
|
|
12
|
+
checkTransient?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Check if an error is likely transient (worth retrying).
|
|
16
|
+
*/
|
|
17
|
+
export declare function isTransientError(err: unknown): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Retry a function with exponential backoff and jitter.
|
|
20
|
+
*/
|
|
21
|
+
export declare function withRetry<T>(fn: () => Promise<T>, opts?: RetryOptions): Promise<T>;
|
|
22
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAatD;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,IAAI,GAAE,YAAiB,GACtB,OAAO,CAAC,CAAC,CAAC,CAyBZ"}
|
package/dist/retry.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exponential backoff retry utility for LLM/network calls.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Check if an error is likely transient (worth retrying).
|
|
6
|
+
*/
|
|
7
|
+
export function isTransientError(err) {
|
|
8
|
+
if (!(err instanceof Error))
|
|
9
|
+
return false;
|
|
10
|
+
const msg = err.message.toLowerCase();
|
|
11
|
+
return (msg.includes("timeout") ||
|
|
12
|
+
msg.includes("econnreset") ||
|
|
13
|
+
msg.includes("econnrefused") ||
|
|
14
|
+
msg.includes("socket hang up") ||
|
|
15
|
+
msg.includes("429") ||
|
|
16
|
+
msg.includes("503") ||
|
|
17
|
+
msg.includes("overloaded") ||
|
|
18
|
+
msg.includes("rate limit"));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Retry a function with exponential backoff and jitter.
|
|
22
|
+
*/
|
|
23
|
+
export async function withRetry(fn, opts = {}) {
|
|
24
|
+
const maxRetries = opts.maxRetries ?? 3;
|
|
25
|
+
const initialDelay = opts.initialDelayMs ?? 1000;
|
|
26
|
+
const maxDelay = opts.maxDelayMs ?? 30000;
|
|
27
|
+
const checkTransient = opts.checkTransient ?? true;
|
|
28
|
+
let lastError;
|
|
29
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
30
|
+
try {
|
|
31
|
+
return await fn();
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
lastError = err;
|
|
35
|
+
if (attempt === maxRetries)
|
|
36
|
+
break;
|
|
37
|
+
if (checkTransient && !isTransientError(err))
|
|
38
|
+
break;
|
|
39
|
+
// Exponential backoff with jitter
|
|
40
|
+
const baseDelay = Math.min(initialDelay * 2 ** attempt, maxDelay);
|
|
41
|
+
const jitter = baseDelay * 0.5 * Math.random();
|
|
42
|
+
await new Promise(r => setTimeout(r, baseDelay + jitter));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
throw lastError;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAY;IAC3C,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACtC,OAAO,CACL,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC;QACvB,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC1B,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC;QAC5B,GAAG,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC9B,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;QACnB,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;QACnB,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC;QAC1B,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,EAAoB,EACpB,OAAqB,EAAE;IAEvB,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC;IACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC;IAC1C,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC;IAEnD,IAAI,SAAkB,CAAC;IAEvB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACvD,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,SAAS,GAAG,GAAG,CAAC;YAEhB,IAAI,OAAO,KAAK,UAAU;gBAAE,MAAM;YAClC,IAAI,cAAc,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC;gBAAE,MAAM;YAEpD,kCAAkC;YAClC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,IAAI,OAAO,EAAE,QAAQ,CAAC,CAAC;YAClE,MAAM,MAAM,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/C,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IAED,MAAM,SAAS,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polpo-ai/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Pure business logic, types, schemas, and store interfaces for the Polpo AI agent orchestration platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -173,6 +173,22 @@
|
|
|
173
173
|
"./question-detector": {
|
|
174
174
|
"types": "./dist/question-detector.d.ts",
|
|
175
175
|
"import": "./dist/question-detector.js"
|
|
176
|
+
},
|
|
177
|
+
"./assessor": {
|
|
178
|
+
"types": "./dist/assessor.d.ts",
|
|
179
|
+
"import": "./dist/assessor.js"
|
|
180
|
+
},
|
|
181
|
+
"./assessment-scoring": {
|
|
182
|
+
"types": "./dist/assessment-scoring.d.ts",
|
|
183
|
+
"import": "./dist/assessment-scoring.js"
|
|
184
|
+
},
|
|
185
|
+
"./assessment-schemas": {
|
|
186
|
+
"types": "./dist/assessment-schemas.d.ts",
|
|
187
|
+
"import": "./dist/assessment-schemas.js"
|
|
188
|
+
},
|
|
189
|
+
"./retry": {
|
|
190
|
+
"types": "./dist/retry.d.ts",
|
|
191
|
+
"import": "./dist/retry.js"
|
|
176
192
|
}
|
|
177
193
|
},
|
|
178
194
|
"sideEffects": false,
|