peerbench 0.0.7 → 0.0.8

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.
Files changed (89) hide show
  1. package/dist/aggregators/abstract.d.ts +10 -0
  2. package/dist/aggregators/index.d.ts +2 -67
  3. package/dist/aggregators/llm/avg.d.ts +26 -0
  4. package/dist/benchmarks/examples/echo-basic/index.d.ts +4 -0
  5. package/dist/benchmarks/examples/echo-basic/runner.d.ts +273 -0
  6. package/dist/benchmarks/examples/echo-basic/schema-sets/echo.v1.d.ts +241 -0
  7. package/dist/benchmarks/examples/echo-basic/storages/json.d.ts +14 -0
  8. package/dist/benchmarks/examples/echo-basic/storages/text.d.ts +24 -0
  9. package/dist/benchmarks/examples/exact-match-scorer/index.d.ts +4 -0
  10. package/dist/benchmarks/examples/exact-match-scorer/runner.d.ts +428 -0
  11. package/dist/benchmarks/examples/exact-match-scorer/schema-sets/exact-match.v1.d.ts +287 -0
  12. package/dist/benchmarks/examples/exact-match-scorer/scorer.d.ts +30 -0
  13. package/dist/benchmarks/examples/exact-match-scorer/storages/json.d.ts +8 -0
  14. package/dist/benchmarks/examples/text-transform/index.d.ts +4 -0
  15. package/dist/benchmarks/examples/text-transform/runner.d.ts +524 -0
  16. package/dist/benchmarks/examples/text-transform/schema-sets/echo.v1.d.ts +211 -0
  17. package/dist/benchmarks/examples/text-transform/schema-sets/namespace.d.ts +1 -0
  18. package/dist/benchmarks/examples/text-transform/schema-sets/reverse.v1.d.ts +216 -0
  19. package/dist/benchmarks/examples/text-transform/storages/json.d.ts +9 -0
  20. package/dist/benchmarks/index.d.ts +1 -1667
  21. package/dist/benchmarks/index.js +16 -16
  22. package/dist/benchmarks/peerbench/index.d.ts +5 -0
  23. package/dist/benchmarks/peerbench/runner.d.ts +754 -0
  24. package/dist/benchmarks/peerbench/schema-sets/mcq.v1.d.ts +261 -0
  25. package/dist/benchmarks/peerbench/schema-sets/multi-turn.v1.d.ts +351 -0
  26. package/dist/benchmarks/peerbench/schema-sets/qa.v1.d.ts +256 -0
  27. package/dist/benchmarks/peerbench/storages/json.d.ts +10 -0
  28. package/dist/{chunk-ZXTQJFGL.js → chunk-Q6GSOHOP.js} +4 -4
  29. package/dist/constants.d.ts +4 -0
  30. package/dist/errors/index.d.ts +2 -0
  31. package/dist/errors/peerbench.d.ts +6 -0
  32. package/dist/errors/polyfill.d.ts +1 -0
  33. package/dist/examples/basic.d.ts +1 -0
  34. package/dist/helpers/define-runner.d.ts +45 -0
  35. package/dist/helpers/index.d.ts +1 -0
  36. package/dist/index.d.ts +6 -101
  37. package/dist/index.js +3 -3
  38. package/dist/providers/abstract/llm.d.ts +20 -0
  39. package/dist/{provider-DnEBdl1n.d.ts → providers/abstract/provider.d.ts} +2 -4
  40. package/dist/providers/example/echo.d.ts +12 -0
  41. package/dist/providers/example/restapi.d.ts +37 -0
  42. package/dist/providers/index.d.ts +5 -96
  43. package/dist/providers/mastra.d.ts +40 -0
  44. package/dist/providers/openai.d.ts +29 -0
  45. package/dist/providers/openrouter.d.ts +27 -0
  46. package/dist/schemas/extensions/index.d.ts +18 -22
  47. package/dist/schemas/extensions/response/llm.d.ts +14 -0
  48. package/dist/schemas/extensions/score/llm-as-a-judge-scorer.d.ts +15 -0
  49. package/dist/schemas/id.d.ts +2 -0
  50. package/dist/schemas/index.d.ts +4 -200
  51. package/dist/schemas/llm/index.d.ts +2 -116
  52. package/dist/schemas/llm/index.js +2 -2
  53. package/dist/schemas/llm/simple-system-prompt.d.ts +51 -0
  54. package/dist/schemas/llm/system-prompt.d.ts +59 -0
  55. package/dist/schemas/response.d.ts +63 -0
  56. package/dist/schemas/schema-definer.d.ts +47 -0
  57. package/dist/schemas/score.d.ts +73 -0
  58. package/dist/schemas/test-case.d.ts +57 -0
  59. package/dist/{abstract-BdgLjkNC.d.ts → scorers/abstract.d.ts} +2 -4
  60. package/dist/scorers/index.d.ts +4 -68
  61. package/dist/scorers/llm-judge.d.ts +55 -0
  62. package/dist/scorers/mcq.d.ts +19 -0
  63. package/dist/scorers/mcq.test.d.ts +1 -0
  64. package/dist/scorers/regex.d.ts +58 -0
  65. package/dist/scorers/regex.test.d.ts +1 -0
  66. package/dist/storages/abstract.d.ts +7 -0
  67. package/dist/storages/examples/http.d.ts +1 -0
  68. package/dist/storages/examples/sqlite.d.ts +1 -0
  69. package/dist/storages/file.d.ts +43 -0
  70. package/dist/storages/http.d.ts +22 -0
  71. package/dist/storages/index.d.ts +5 -69
  72. package/dist/storages/json-file.d.ts +21 -0
  73. package/dist/storages/sqlite.d.ts +41 -0
  74. package/dist/types/index.d.ts +17 -0
  75. package/dist/types/runner.d.ts +18 -0
  76. package/dist/utilities.d.ts +9 -0
  77. package/dist/utils/id-generator.d.ts +2 -0
  78. package/dist/utils/index.d.ts +5 -0
  79. package/dist/utils/json.d.ts +17 -0
  80. package/dist/utils/llm.d.ts +7 -0
  81. package/dist/{rate-limiter-CSmVIRsM.d.ts → utils/rate-limiter.d.ts} +3 -5
  82. package/dist/utils/sleep.d.ts +1 -0
  83. package/dist/utils/string.d.ts +8 -0
  84. package/package.json +3 -3
  85. package/dist/index-Cn20kPrz.d.ts +0 -27
  86. package/dist/json-file-Bgv9TLcX.d.ts +0 -74
  87. package/dist/llm-8ecJmwKJ.d.ts +0 -23
  88. package/dist/llm-judge-BuF80-5-.d.ts +0 -75
  89. /package/dist/{chunk-ZXTQJFGL.js.map → chunk-Q6GSOHOP.js.map} +0 -0
@@ -0,0 +1,51 @@
1
+ import { z } from "zod";
2
+ export declare const SimpleSystemPromptSchemaV1: z.ZodObject<Omit<{
3
+ id: z.ZodString;
4
+ namespace: z.ZodString;
5
+ kind: z.ZodString;
6
+ schemaVersion: z.ZodNumber;
7
+ version: z.ZodNumber;
8
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
9
+ }, "kind" | "namespace" | "schemaVersion"> & {
10
+ content: z.ZodString;
11
+ } & {
12
+ namespace: z.ZodLiteral<"peerbench.ai">;
13
+ kind: z.ZodLiteral<`${string}/simple.sys-prompt`>;
14
+ schemaVersion: z.ZodLiteral<1>;
15
+ }, z.core.$strip> & {
16
+ new: (input: Omit<{
17
+ id: string;
18
+ version: number;
19
+ content: string;
20
+ namespace: "peerbench.ai";
21
+ kind: `${string}/simple.sys-prompt`;
22
+ schemaVersion: 1;
23
+ metadata?: Record<string, unknown> | undefined;
24
+ }, "kind" | "namespace" | "schemaVersion">) => {
25
+ id: string;
26
+ version: number;
27
+ content: string;
28
+ namespace: "peerbench.ai";
29
+ kind: `${string}/simple.sys-prompt`;
30
+ schemaVersion: 1;
31
+ metadata?: Record<string, unknown> | undefined;
32
+ };
33
+ newWithId(input: Omit<{
34
+ id: string;
35
+ version: number;
36
+ content: string;
37
+ namespace: "peerbench.ai";
38
+ kind: `${string}/simple.sys-prompt`;
39
+ schemaVersion: 1;
40
+ metadata?: Record<string, unknown> | undefined;
41
+ }, "kind" | "id" | "namespace" | "schemaVersion">, generator: import("../../index.js").IdGenerator): Promise<{
42
+ id: string;
43
+ version: number;
44
+ content: string;
45
+ namespace: "peerbench.ai";
46
+ kind: `${string}/simple.sys-prompt`;
47
+ schemaVersion: 1;
48
+ metadata?: Record<string, unknown> | undefined;
49
+ }>;
50
+ };
51
+ export type SimpleSystemPromptV1 = z.infer<typeof SimpleSystemPromptSchemaV1>;
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ export declare const BaseSystemPromptSchemaV1: z.ZodObject<{
3
+ id: z.ZodString;
4
+ namespace: z.ZodString;
5
+ kind: z.ZodString;
6
+ schemaVersion: z.ZodNumber;
7
+ version: z.ZodNumber;
8
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
9
+ }, z.core.$strip>;
10
+ export type BaseSystemPromptV1 = z.infer<typeof BaseSystemPromptSchemaV1>;
11
+ export declare const defineSystemPromptSchema: <TBaseSchema extends import("../../index.js").WidenZodObject<z.ZodObject<{
12
+ id: z.ZodString;
13
+ namespace: z.ZodString;
14
+ kind: z.ZodString;
15
+ schemaVersion: z.ZodNumber;
16
+ version: z.ZodNumber;
17
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
18
+ }, z.core.$strip>>, TNamespace extends string | undefined = undefined, TKind extends string | undefined = undefined, TSchemaVersion extends number | undefined = undefined, TFields extends Readonly<{
19
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
20
+ }> = {}>(config: {
21
+ baseSchema: TBaseSchema;
22
+ namespace?: TNamespace | undefined;
23
+ kind?: TKind | undefined;
24
+ schemaVersion?: TSchemaVersion | undefined;
25
+ fields?: TFields | undefined;
26
+ }) => (TBaseSchema extends z.ZodObject<infer U extends Readonly<{
27
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
28
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
29
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
30
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sys-prompt`>;
31
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
32
+ }, z.core.$strip> : never) & {
33
+ new: (input: Omit<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
34
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
35
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
36
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
37
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sys-prompt`>;
38
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
39
+ }, z.core.$strip> : never>, "kind" | "namespace" | "schemaVersion">) => z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
40
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
41
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
42
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
43
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sys-prompt`>;
44
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
45
+ }, z.core.$strip> : never>;
46
+ newWithId(input: Omit<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
47
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
48
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
49
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
50
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sys-prompt`>;
51
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
52
+ }, z.core.$strip> : never>, "kind" | "id" | "namespace" | "schemaVersion">, generator: import("../../index.js").IdGenerator): Promise<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
53
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
54
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
55
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
56
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sys-prompt`>;
57
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
58
+ }, z.core.$strip> : never>>;
59
+ };
@@ -0,0 +1,63 @@
1
+ import z from "zod";
2
+ export declare const BaseResponseSchemaV1: z.ZodObject<{
3
+ id: z.ZodString;
4
+ namespace: z.ZodString;
5
+ schemaVersion: z.ZodNumber;
6
+ kind: z.ZodString;
7
+ startedAt: z.ZodNumber;
8
+ completedAt: z.ZodNumber;
9
+ testCaseId: z.ZodString;
10
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
11
+ }, z.core.$strip>;
12
+ export type BaseResponseV1 = z.infer<typeof BaseResponseSchemaV1>;
13
+ export declare const defineResponseSchema: <TBaseSchema extends import("../index.js").WidenZodObject<z.ZodObject<{
14
+ id: z.ZodString;
15
+ namespace: z.ZodString;
16
+ schemaVersion: z.ZodNumber;
17
+ kind: z.ZodString;
18
+ startedAt: z.ZodNumber;
19
+ completedAt: z.ZodNumber;
20
+ testCaseId: z.ZodString;
21
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
22
+ }, z.core.$strip>>, TNamespace extends string | undefined = undefined, TKind extends string | undefined = undefined, TSchemaVersion extends number | undefined = undefined, TFields extends Readonly<{
23
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
24
+ }> = {}>(config: {
25
+ baseSchema: TBaseSchema;
26
+ namespace?: TNamespace | undefined;
27
+ kind?: TKind | undefined;
28
+ schemaVersion?: TSchemaVersion | undefined;
29
+ fields?: TFields | undefined;
30
+ }) => (TBaseSchema extends z.ZodObject<infer U extends Readonly<{
31
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
32
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
33
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
34
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.rs`>;
35
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
36
+ }, z.core.$strip> : never) & {
37
+ new: (input: Omit<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
38
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
39
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
40
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
41
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.rs`>;
42
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
43
+ }, z.core.$strip> : never>, "kind" | "namespace" | "schemaVersion">) => z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
44
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
45
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
46
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
47
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.rs`>;
48
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
49
+ }, z.core.$strip> : never>;
50
+ newWithId(input: Omit<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
51
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
52
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
53
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
54
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.rs`>;
55
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
56
+ }, z.core.$strip> : never>, "kind" | "id" | "namespace" | "schemaVersion">, generator: import("../index.js").IdGenerator): Promise<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
57
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
58
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
59
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
60
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.rs`>;
61
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
62
+ }, z.core.$strip> : never>>;
63
+ };
@@ -0,0 +1,47 @@
1
+ import { IdGenerator } from "../types";
2
+ import { WidenZodObject } from "../utilities";
3
+ import z from "zod";
4
+ export declare function buildSchemaDefiner<TBaseShape extends {
5
+ kind: z.ZodString | z.ZodLiteral<string>;
6
+ namespace: z.ZodString | z.ZodLiteral<string>;
7
+ schemaVersion: z.ZodNumber | z.ZodLiteral<number>;
8
+ }, TKindSuffix extends string = "">(_schema: z.ZodObject<TBaseShape>, kindSuffix: TKindSuffix): <TBaseSchema extends WidenZodObject<z.ZodObject<TBaseShape>>, TNamespace extends string | undefined = undefined, TKind extends string | undefined = undefined, TSchemaVersion extends number | undefined = undefined, TFields extends z.ZodRawShape = {}>(config: {
9
+ baseSchema: TBaseSchema;
10
+ namespace?: TNamespace;
11
+ kind?: TKind;
12
+ schemaVersion?: TSchemaVersion;
13
+ fields?: TFields;
14
+ }) => (TBaseSchema extends z.ZodObject<infer U extends Readonly<{
15
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
16
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
17
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
18
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.${TKindSuffix}`>;
19
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
20
+ }, z.core.$strip> : never) & {
21
+ new: (input: Omit<z.infer<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
22
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
23
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
24
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
25
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.${TKindSuffix}`>;
26
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
27
+ }, z.core.$strip> : never>, "kind" | "schemaVersion" | "namespace">) => z.infer<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
28
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
29
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
30
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
31
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.${TKindSuffix}`>;
32
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
33
+ }, z.core.$strip> : never>;
34
+ newWithId(input: Omit<z.infer<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
35
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
36
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
37
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
38
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.${TKindSuffix}`>;
39
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
40
+ }, z.core.$strip> : never>, "id" | "kind" | "schemaVersion" | "namespace">, generator: IdGenerator): Promise<z.infer<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
41
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
42
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
43
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
44
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.${TKindSuffix}`>;
45
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
46
+ }, z.core.$strip> : never>>;
47
+ };
@@ -0,0 +1,73 @@
1
+ import z from "zod";
2
+ export declare const BaseScoreSchemaV1: z.ZodObject<{
3
+ id: z.ZodString;
4
+ namespace: z.ZodString;
5
+ kind: z.ZodString;
6
+ schemaVersion: z.ZodNumber;
7
+ value: z.ZodNumber;
8
+ responseId: z.ZodString;
9
+ explanation: z.ZodOptional<z.ZodString>;
10
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
11
+ scoringMethod: z.ZodEnum<{
12
+ readonly ai: "ai";
13
+ readonly human: "human";
14
+ readonly algo: "algo";
15
+ }>;
16
+ }, z.core.$strip>;
17
+ export type BaseScoreV1 = z.infer<typeof BaseScoreSchemaV1>;
18
+ export declare const defineScoreSchema: <TBaseSchema extends import("../index.js").WidenZodObject<z.ZodObject<{
19
+ id: z.ZodString;
20
+ namespace: z.ZodString;
21
+ kind: z.ZodString;
22
+ schemaVersion: z.ZodNumber;
23
+ value: z.ZodNumber;
24
+ responseId: z.ZodString;
25
+ explanation: z.ZodOptional<z.ZodString>;
26
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
27
+ scoringMethod: z.ZodEnum<{
28
+ readonly ai: "ai";
29
+ readonly human: "human";
30
+ readonly algo: "algo";
31
+ }>;
32
+ }, z.core.$strip>>, TNamespace extends string | undefined = undefined, TKind extends string | undefined = undefined, TSchemaVersion extends number | undefined = undefined, TFields extends Readonly<{
33
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
34
+ }> = {}>(config: {
35
+ baseSchema: TBaseSchema;
36
+ namespace?: TNamespace | undefined;
37
+ kind?: TKind | undefined;
38
+ schemaVersion?: TSchemaVersion | undefined;
39
+ fields?: TFields | undefined;
40
+ }) => (TBaseSchema extends z.ZodObject<infer U extends Readonly<{
41
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
42
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
43
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
44
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sc`>;
45
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
46
+ }, z.core.$strip> : never) & {
47
+ new: (input: Omit<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
48
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
49
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
50
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
51
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sc`>;
52
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
53
+ }, z.core.$strip> : never>, "kind" | "namespace" | "schemaVersion">) => z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
54
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
55
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
56
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
57
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sc`>;
58
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
59
+ }, z.core.$strip> : never>;
60
+ newWithId(input: Omit<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
61
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
62
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
63
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
64
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sc`>;
65
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
66
+ }, z.core.$strip> : never>, "kind" | "id" | "namespace" | "schemaVersion">, generator: import("../types").IdGenerator): Promise<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
67
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
68
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
69
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
70
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.sc`>;
71
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
72
+ }, z.core.$strip> : never>>;
73
+ };
@@ -0,0 +1,57 @@
1
+ import { z } from "zod";
2
+ export declare const BaseTestCaseSchemaV1: z.ZodObject<{
3
+ id: z.ZodString;
4
+ namespace: z.ZodString;
5
+ schemaVersion: z.ZodNumber;
6
+ kind: z.ZodString;
7
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
8
+ }, z.core.$strip>;
9
+ export type BaseTestCaseV1 = z.infer<typeof BaseTestCaseSchemaV1>;
10
+ export declare const defineTestCaseSchema: <TBaseSchema extends import("../index.js").WidenZodObject<z.ZodObject<{
11
+ id: z.ZodString;
12
+ namespace: z.ZodString;
13
+ schemaVersion: z.ZodNumber;
14
+ kind: z.ZodString;
15
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
16
+ }, z.core.$strip>>, TNamespace extends string | undefined = undefined, TKind extends string | undefined = undefined, TSchemaVersion extends number | undefined = undefined, TFields extends Readonly<{
17
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
18
+ }> = {}>(config: {
19
+ baseSchema: TBaseSchema;
20
+ namespace?: TNamespace | undefined;
21
+ kind?: TKind | undefined;
22
+ schemaVersion?: TSchemaVersion | undefined;
23
+ fields?: TFields | undefined;
24
+ }) => (TBaseSchema extends z.ZodObject<infer U extends Readonly<{
25
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
26
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
27
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
28
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.tc`>;
29
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
30
+ }, z.core.$strip> : never) & {
31
+ new: (input: Omit<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
32
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
33
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
34
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
35
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.tc`>;
36
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
37
+ }, z.core.$strip> : never>, "kind" | "namespace" | "schemaVersion">) => z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
38
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
39
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
40
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
41
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.tc`>;
42
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
43
+ }, z.core.$strip> : never>;
44
+ newWithId(input: Omit<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
45
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
46
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
47
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
48
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.tc`>;
49
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
50
+ }, z.core.$strip> : never>, "kind" | "id" | "namespace" | "schemaVersion">, generator: import("../index.js").IdGenerator): Promise<z.core.output<TBaseSchema extends z.ZodObject<infer U extends Readonly<{
51
+ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
52
+ }>, z.core.$strip> ? z.ZodObject<Omit<U, "kind" | "namespace" | "schemaVersion"> & TFields & {
53
+ namespace: TNamespace extends undefined ? U["namespace"] : z.ZodLiteral<TNamespace>;
54
+ kind: TKind extends undefined ? U["kind"] : z.ZodLiteral<`${TKind}.tc`>;
55
+ schemaVersion: TSchemaVersion extends undefined ? U["schemaVersion"] : z.ZodLiteral<TSchemaVersion>;
56
+ }, z.core.$strip> : never>>;
57
+ };
@@ -1,4 +1,4 @@
1
- declare abstract class AbstractScorer {
1
+ export declare abstract class AbstractScorer {
2
2
  readonly kind: string;
3
3
  constructor();
4
4
  abstract score(params: any): Promise<BaseScorerResult | null>;
@@ -8,11 +8,9 @@ declare abstract class AbstractScorer {
8
8
  readonly kind: TKind;
9
9
  };
10
10
  }
11
- type BaseScorerResult = {
11
+ export type BaseScorerResult = {
12
12
  value: number;
13
13
  explanation?: string;
14
14
  metadata?: Record<string, unknown>;
15
15
  [key: string]: unknown;
16
16
  };
17
-
18
- export { AbstractScorer as A, type BaseScorerResult as B };
@@ -1,68 +1,4 @@
1
- import { A as AbstractScorer } from '../abstract-BdgLjkNC.js';
2
- export { B as BaseScorerResult } from '../abstract-BdgLjkNC.js';
3
- export { b as LLMAsAJudgeCriterion, c as LLMAsAJudgeScoreParams, L as LLMAsAJudgeScorer, a as MCQScorer, M as MCQScorerParams } from '../llm-judge-BuF80-5-.js';
4
- import '../llm-8ecJmwKJ.js';
5
- import '../provider-DnEBdl1n.js';
6
- import 'openai/resources/shared';
7
- import 'openai/resources/chat/completions';
8
- import '../rate-limiter-CSmVIRsM.js';
9
- import 'zod';
10
-
11
- type RegexPattern = {
12
- /**
13
- * The regex pattern to match against the response
14
- */
15
- regex: RegExp;
16
- /**
17
- * The index of the capture group to extract (1-based, like match[1])
18
- * If not provided, defaults to 1 (first capture group)
19
- */
20
- captureGroupIndex?: number;
21
- /**
22
- * Optional function to transform the extracted value before validation
23
- */
24
- transform?: (value: string) => string | undefined;
25
- };
26
- type RegexScorerParams = {
27
- /**
28
- * The input text to score
29
- */
30
- input: string;
31
- /**
32
- * Array of regex patterns to try (in order, first match wins)
33
- */
34
- patterns: RegexPattern[];
35
- /**
36
- * Expected value(s) to match against. Can be a record of expected values for named groups, or a validation function
37
- */
38
- expectedValue: Record<string, string> | ((groupName: string, match: string) => boolean);
39
- /**
40
- * Optional: Which match to use when multiple matches are found
41
- * Defaults to "last" (uses the last match found)
42
- */
43
- matchPreference?: "first" | "last";
44
- /**
45
- * Optional: If true, allows partial scoring based on how many groups match
46
- * For example, if 2 groups are expected and only 1 matches, score would be 0.5
47
- * Defaults to false (all-or-nothing scoring)
48
- */
49
- allowPartialScoring?: boolean;
50
- };
51
- declare const RegexScorer_base: (new () => AbstractScorer & {
52
- readonly kind: "peerbench.ai/regex";
53
- }) & {
54
- readonly kind: "peerbench.ai/regex";
55
- };
56
- /**
57
- * Generic Regex scorer. It scores the given input against a set of regex patterns.
58
- */
59
- declare class RegexScorer extends RegexScorer_base {
60
- score(params: RegexScorerParams): Promise<{
61
- value: number;
62
- extractedAnswers: {
63
- [k: string]: string;
64
- };
65
- }>;
66
- }
67
-
68
- export { AbstractScorer, type RegexPattern, RegexScorer, type RegexScorerParams };
1
+ export * from "./abstract";
2
+ export * from "./mcq";
3
+ export * from "./llm-judge";
4
+ export * from "./regex";
@@ -0,0 +1,55 @@
1
+ import { AbstractLLMProvider } from "../providers/abstract/llm";
2
+ import { RateLimiter } from "../utils/rate-limiter";
3
+ import { AbstractScorer, BaseScorerResult } from "./abstract";
4
+ import z from "zod";
5
+ declare const LLMAsAJudgeScorer_base: (new () => AbstractScorer & {
6
+ readonly kind: "peerbench.ai/llm-as-a-judge";
7
+ }) & {
8
+ readonly kind: "peerbench.ai/llm-as-a-judge";
9
+ };
10
+ export declare class LLMAsAJudgeScorer extends LLMAsAJudgeScorer_base {
11
+ private provider;
12
+ constructor(config: {
13
+ provider: AbstractLLMProvider;
14
+ rateLimiter?: RateLimiter;
15
+ });
16
+ score<T extends z.ZodRawShape>(params: LLMAsAJudgeScoreParams & {
17
+ fieldsToExtract: T;
18
+ }): Promise<ScorerResultWithExtractedFields<T> | null>;
19
+ score(params: LLMAsAJudgeScoreParams & {
20
+ fieldsToExtract?: never;
21
+ }): Promise<ScorerResultWithoutExtractedFields | null>;
22
+ }
23
+ export type LLMAsAJudgeCriterion = {
24
+ id: string;
25
+ description: string;
26
+ weight: number;
27
+ scale?: {
28
+ min: number;
29
+ max: number;
30
+ };
31
+ };
32
+ export type LLMAsAJudgeScoreParams = {
33
+ model: string;
34
+ response: string;
35
+ rubric: string;
36
+ criteria: LLMAsAJudgeCriterion[];
37
+ systemPrompt?: string;
38
+ maxExplanationLength?: number;
39
+ };
40
+ type ScorerResultWithoutExtractedFields = BaseScorerResult & {
41
+ results: {
42
+ id: string;
43
+ score: number;
44
+ explanation: string;
45
+ }[];
46
+ provider: string;
47
+ inputTokensUsed?: number;
48
+ outputTokensUsed?: number;
49
+ inputCost?: string;
50
+ outputCost?: string;
51
+ };
52
+ type ScorerResultWithExtractedFields<T extends z.ZodRawShape> = ScorerResultWithoutExtractedFields & {
53
+ extractedFields: z.infer<z.ZodObject<T>>;
54
+ };
55
+ export {};
@@ -0,0 +1,19 @@
1
+ import { AbstractScorer, BaseScorerResult } from "./abstract";
2
+ export type MCQScorerParams = {
3
+ response: string;
4
+ choices: Record<string, string>;
5
+ correctAnswers: string[];
6
+ };
7
+ declare const MCQScorer_base: (new () => AbstractScorer & {
8
+ readonly kind: "peerbench.ai/mcq";
9
+ }) & {
10
+ readonly kind: "peerbench.ai/mcq";
11
+ };
12
+ export declare class MCQScorer extends MCQScorer_base {
13
+ private regexScorer;
14
+ score(params: MCQScorerParams): Promise<BaseScorerResult & {
15
+ extractedAnswers: string[];
16
+ }>;
17
+ private buildPatternsForAnswer;
18
+ }
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ import { AbstractScorer } from "./abstract";
2
+ export type RegexPattern = {
3
+ /**
4
+ * The regex pattern to match against the response
5
+ */
6
+ regex: RegExp;
7
+ /**
8
+ * The index of the capture group to extract (1-based, like match[1])
9
+ * If not provided, defaults to 1 (first capture group)
10
+ */
11
+ captureGroupIndex?: number;
12
+ /**
13
+ * Optional function to transform the extracted value before validation
14
+ */
15
+ transform?: (value: string) => string | undefined;
16
+ };
17
+ export type RegexScorerParams = {
18
+ /**
19
+ * The input text to score
20
+ */
21
+ input: string;
22
+ /**
23
+ * Array of regex patterns to try (in order, first match wins)
24
+ */
25
+ patterns: RegexPattern[];
26
+ /**
27
+ * Expected value(s) to match against. Can be a record of expected values for named groups, or a validation function
28
+ */
29
+ expectedValue: Record<string, string> | ((groupName: string, match: string) => boolean);
30
+ /**
31
+ * Optional: Which match to use when multiple matches are found
32
+ * Defaults to "last" (uses the last match found)
33
+ */
34
+ matchPreference?: "first" | "last";
35
+ /**
36
+ * Optional: If true, allows partial scoring based on how many groups match
37
+ * For example, if 2 groups are expected and only 1 matches, score would be 0.5
38
+ * Defaults to false (all-or-nothing scoring)
39
+ */
40
+ allowPartialScoring?: boolean;
41
+ };
42
+ declare const RegexScorer_base: (new () => AbstractScorer & {
43
+ readonly kind: "peerbench.ai/regex";
44
+ }) & {
45
+ readonly kind: "peerbench.ai/regex";
46
+ };
47
+ /**
48
+ * Generic Regex scorer. It scores the given input against a set of regex patterns.
49
+ */
50
+ export declare class RegexScorer extends RegexScorer_base {
51
+ score(params: RegexScorerParams): Promise<{
52
+ value: number;
53
+ extractedAnswers: {
54
+ [k: string]: string;
55
+ };
56
+ }>;
57
+ }
58
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare abstract class AbstractStorage<TObject> {
2
+ abstract init(params?: unknown): Promise<void>;
3
+ abstract read(key: string, params?: unknown): Promise<TObject | null>;
4
+ abstract readAll(params?: unknown): Promise<TObject[]>;
5
+ abstract write(key: string, value: TObject, params?: unknown): Promise<unknown>;
6
+ count(): Promise<number>;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ import { FileHandle } from "node:fs/promises";
2
+ import { AbstractStorage } from "./abstract";
3
+ export declare class FileStorage<TObject> extends AbstractStorage<TObject> {
4
+ protected path: string;
5
+ protected codec: AbstractFileStorageCodec<TObject>;
6
+ protected fileHandle: FileHandle | undefined;
7
+ constructor(config: {
8
+ path: string;
9
+ codec: AbstractFileStorageCodec<TObject>;
10
+ });
11
+ init(): Promise<void>;
12
+ read(_key: string, _params?: unknown): Promise<TObject | null>;
13
+ readAll(_params?: unknown): Promise<TObject[]>;
14
+ write(_key: string, _value: TObject, _params?: unknown): Promise<unknown>;
15
+ protected readChunks(params: {
16
+ startOffset?: number;
17
+ chunkSize: number;
18
+ }): AsyncIterable<{
19
+ offset: number;
20
+ bytes: Uint8Array;
21
+ }>;
22
+ protected size(): Promise<number>;
23
+ protected readAt(offset: number, length: number): Promise<Uint8Array>;
24
+ protected assertInitialized(): asserts this is this & {
25
+ fileHandle: FileHandle;
26
+ };
27
+ }
28
+ export type FileStorageFileHandle = {
29
+ size(): Promise<number>;
30
+ readAt(offset: number, length: number): Promise<Uint8Array>;
31
+ readChunks(params: {
32
+ startOffset?: number;
33
+ chunkSize: number;
34
+ }): AsyncIterable<{
35
+ offset: number;
36
+ bytes: Uint8Array;
37
+ }>;
38
+ };
39
+ export declare abstract class AbstractFileStorageCodec<TObject> {
40
+ abstract readAll(params: {
41
+ fileHandle: FileStorageFileHandle;
42
+ }): Promise<TObject[]>;
43
+ }